22 #include <pcg/pcg_random.hpp>
28 #ifndef INC_C4Particles
29 #define INC_C4Particles
79 bool Compile(
char *particle_source,
const char *name);
112 float startValue, endValue;
122 float parameterValue;
134 size_t keyFrameCount;
135 std::vector<float> keyFrames;
140 std::vector<C4ParticleValueProvider*> childrenValueProviders;
146 size_t keyFrameIndex;
154 int typeOfValueToChange;
158 bool IsRandom()
const {
return valueFunction == &C4ParticleValueProvider::Random; }
160 startValue(0.f), endValue(0.f), currentValue(0.f), rerollInterval(0), smoothing(0), keyFrameCount(0), valueFunction(nullptr), isConstant(true), floatValueToChange(nullptr), typeOfValueToChange(VAL_TYPE_FLOAT)
164 for (
auto &child : childrenValueProviders)
181 void FloatifyParameterValue(
float C4ParticleValueProvider::*value,
float denominator,
size_t keyFrameIndex = 0);
292 for (
int vertex = 0; vertex < 4; ++vertex)
301 void SetPosition(
float x,
float y,
float size,
float rotation = 0.f,
float stretch = 1.f);
350 std::vector<C4Particle*> particles;
351 std::vector<C4Particle::DrawingData::Vertex> vertexCoordinates;
352 size_t particleCount;
355 GLuint drawingDataVertexBufferObject;
356 unsigned int drawingDataVertexArraysObject;
357 void ClearBufferObjects();
360 void DeleteAndReplaceParticle(
size_t indexToReplace,
size_t indexFrom);
363 C4ParticleChunk() : sourceDefinition(nullptr), blitMode(0), attachment(
C4ATTACH_None), particleCount(0), drawingDataVertexBufferObject(0), drawingDataVertexArraysObject(0)
379 bool IsEmpty()
const {
return !particleCount; }
394 std::list<C4ParticleChunk*> particleChunks;
422 void Exec(
float timeDelta = 1.f);
450 void Execute()
override;
460 std::list<C4ParticleList> particleLists;
461 void PreparePrimitiveRestartIndices(uint32_t forSize);
467 int currentSimulationTime;
470 void ExecuteCalculation();
484 frameCounterAdvancedEvent.
Set();
492 if (globalParticles) globalParticles->
Draw(cgo,
nullptr);
499 return globalParticles;
515 GLuint
GetIBO(
size_t forParticleAmount);
C4ParticleAttachmentPropertyID
bool(C4ParticleProperties::* C4ParticleCollisionCallback)(C4Particle *)
C4ParticleValueProviderID
C4ParticleCollisionFuncID
C4ParticleSystem Particles
float(C4ParticleValueProvider::* C4ParticleValueProviderFunction)(C4Particle *)
C4Particle * AddNewParticle()
bool Exec(C4Object *obj, float timeDelta)
bool IsOfType(C4ParticleDef *def, uint32_t _blitMode, uint32_t attachment) const
C4ParticleChunk & operator=(const C4ParticleChunk &)=delete
void ReserveSpace(uint32_t forAmount)
void Draw(C4TargetFacet cgo, C4Object *obj, C4ShaderCall &call, int texUnit, const StdProjectionMatrix &modelview)
C4ParticleChunk(const C4ParticleChunk &)=delete
bool Compile(char *particle_source, const char *name)
void CompileFunc(StdCompiler *compiler)
bool Load(C4Group &group)
struct C4Particle::DrawingData drawingData
bool Exec(C4Object *obj, float timeDelta, C4ParticleDef *sourceDef)
void SetPosition(float x, float y)
C4ParticleProperties properties
float GetLifetime() const
float GetRelativeAge() const
C4ParticleList(const C4ParticleList &)=delete
C4ParticleList(C4Object *obj=nullptr)
void Draw(C4TargetFacet cgo, C4Object *obj)
C4ParticleList & operator=(const C4ParticleList &)=delete
C4ParticleChunk * GetFittingParticleChunk(C4ParticleDef *def, uint32_t blitMode, uint32_t attachment, bool alreadyLocked)
C4Particle * AddNewParticle(C4ParticleDef *def, uint32_t blitMode, uint32_t attachment, bool alreadyLocked, int remaining=0)
void Exec(float timeDelta=1.f)
bool CollisionDie(C4Particle *forParticle)
C4ParticleValueProvider rotation
void SetCollisionFunc(const C4Value &source)
C4ParticleValueProvider collisionDensity
C4ParticleCollisionCallback collisionCallback
void Set(C4PropList *dataSource)
C4ParticleValueProvider speedDampingX
C4ParticleValueProvider collisionVertex
C4ParticleValueProvider speedDampingY
C4ParticleValueProvider phase
C4ParticleValueProvider size
C4ParticleValueProvider colorG
C4ParticleValueProvider forceY
bool CollisionBounce(C4Particle *forParticle)
C4ParticleValueProvider stretch
C4ParticleValueProvider colorAlpha
C4ParticleValueProvider colorR
C4ParticleValueProvider colorB
C4ParticleValueProvider forceX
bool CollisionStop(C4Particle *forParticle)
C4ParticleDef * GetDef(const char *name, C4ParticleDef *exclude=nullptr)
C4ParticleSystemDefinitionList()
C4ParticleList * GetNewParticleList(C4Object *forTarget=nullptr)
void DrawGlobalParticles(C4TargetFacet cgo)
C4ParticleSystemDefinitionList definitions
GLuint GetIBO(size_t forParticleAmount)
C4ParticleList * GetGlobalParticles()
void Create(C4ParticleDef *of_def, C4ParticleValueProvider &x, C4ParticleValueProvider &y, C4ParticleValueProvider &speedX, C4ParticleValueProvider &speedY, C4ParticleValueProvider &lifetime, C4PropList *properties, int amount=1, C4Object *object=nullptr)
void ReleaseParticleList(C4ParticleList *first, C4ParticleList *second=nullptr)
friend class CalculationThread
float GetValue(C4Particle *forParticle)
C4ParticleValueProvider()
void Set(const C4Value &value)
void Floatify(float denominator)
~C4ParticleValueProvider()
C4ParticleValueProvider(const C4ParticleValueProvider &other)
C4ParticleValueProvider & operator=(const C4ParticleValueProvider &other)
void SetPosition(float x, float y, float size, float rotation=0.f, float stretch=1.f)
void SetColor(float r, float g, float b, float a=1.0f)
void SetPhase(int phase, C4ParticleDef *sourceDef)
static const int vertexCountPerParticle
void SetPointer(Vertex *startingVertex, bool initial=false)
void SetOffset(float x, float y)