Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParticleData.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_PARTICLE_DATA_H_
34#define DVD_PARTICLE_DATA_H_
35
37
38namespace Divide {
39
40class GFXDevice;
41
43{
49 COUNT = 5
50};
51
52namespace Names {
53 static const char* particleDataProperties[] = {
54 "Position", "Velocity", "Acceleration", "Colour", "Colour transform", "UNKNOWN"
55 };
56}
57
60 public:
61 static constexpr U32 g_threadPartitionSize = 256;
62
83
84
88
89 void setBillboarded(bool state) noexcept;
90
91 [[nodiscard]] PrimitiveTopology particleGeometryType() const noexcept {
93 }
94
95 [[nodiscard]] const vector<vec3<F32>>& particleGeometryVertices() const noexcept {
97 }
98
99 [[nodiscard]] const vector<U32>& particleGeometryIndices() const noexcept {
101 }
102
103 [[nodiscard]] bool isBillboarded() const noexcept {
104 return _isBillboarded;
105 }
106
107 PROPERTY_RW(U32, optionsMask, 0u);
108 public:
109 explicit ParticleData(GFXDevice& context, U32 particleCount, U32 optionsMask);
111
112 void generateParticles(U32 particleCount, U32 optionsMask);
113 void kill(U32 index);
114 void wake(U32 index);
115 void swapData(U32 indexA, U32 indexB);
116
117 [[nodiscard]] U32 aliveCount() const noexcept { return _aliveCount; }
118 [[nodiscard]] U32 totalCount() const noexcept { return _totalCount; }
119
121 void sort();
122
123 protected:
126
127 bool _isBillboarded = true;
131
133};
134
135} // namespace Divide
136
137#endif //DVD_PARTICLE_DATA_H_
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Container to store data for a given set of particles.
Definition: ParticleData.h:59
void sort()
Sort ALIVE particles only.
PrimitiveTopology particleGeometryType() const noexcept
Definition: ParticleData.h:91
static constexpr U32 g_threadPartitionSize
Definition: ParticleData.h:61
PROPERTY_RW(U32, optionsMask, 0u)
void swapData(U32 indexA, U32 indexB)
vector< vec4< F32 > > _acceleration
x,y,z = _acceleration; w = weight;
Definition: ParticleData.h:72
vector< FColour4 > _startColour
r,g,b,a = colour and transparency
Definition: ParticleData.h:78
GFXDevice & _context
Definition: ParticleData.h:132
vector< vec4< F32 > > _position
x,y,z = position; w = size
Definition: ParticleData.h:68
vector< vec3< F32 > > _particleGeometryVertices
Definition: ParticleData.h:128
void wake(U32 index)
U32 aliveCount() const noexcept
Definition: ParticleData.h:117
vector< U32 > _particleGeometryIndices
Definition: ParticleData.h:129
vector< vec4< F32 > > _renderingPositions
Definition: ParticleData.h:65
PrimitiveTopology _particleGeometryType
Definition: ParticleData.h:130
vector< std::pair< U32, F32 > > _indices
helper array used for sorting
Definition: ParticleData.h:64
const vector< U32 > & particleGeometryIndices() const noexcept
Definition: ParticleData.h:99
void setParticleGeometry(const vector< vec3< F32 > > &particleGeometryVertices, const vector< U32 > &particleGeometryIndices, PrimitiveTopology particleGeometryType)
void generateParticles(U32 particleCount, U32 optionsMask)
vector< FColour4 > _colour
r,g,b,a = colour and transparency
Definition: ParticleData.h:76
U32 totalCount() const noexcept
Definition: ParticleData.h:118
bool isBillboarded() const noexcept
Definition: ParticleData.h:103
const vector< vec3< F32 > > & particleGeometryVertices() const noexcept
Definition: ParticleData.h:95
void kill(U32 index)
vector< UColour4 > _renderingColours
Definition: ParticleData.h:66
vector< FColour4 > _endColour
r,g,b,a = colour and transparency
Definition: ParticleData.h:80
void setBillboarded(bool state) noexcept
string _textureFileName
Location of the texture file. Leave blank for colour only.
Definition: ParticleData.h:82
vector< vec4< F32 > > _misc
x = time; y = interpolation; z = 1 / time; w = distance to camera sq;
Definition: ParticleData.h:74
vector< vec4< F32 > > _velocity
x,y,z = _velocity; w = angle;
Definition: ParticleData.h:70
static const char * particleDataProperties[]
Definition: ParticleData.h:53
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8
ParticleDataProperties
Definition: ParticleData.h:43
eastl::vector< Type > vector
Definition: Vector.h:42
uint32_t U32
constexpr T toBit(const T X)
Converts an arbitrary positive integer value to a bitwise value used for masks.