summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@joel-desktop.(none)>2008-01-26 22:19:50 +0900
committerJoel Bosveld <joel@joel-desktop.(none)>2008-01-26 22:19:50 +0900
commit76ea38fcc9d257eac00aee0b3ca9399732ba617a (patch)
treed3ec393e64a8194c137f94976fd240fa19991f70
parentab43e948af6282ea83edd0e0a949b108163093ee (diff)
downloadcubedbus-76ea38fcc9d257eac00aee0b3ca9399732ba617a.tar.gz
cubedbus-76ea38fcc9d257eac00aee0b3ca9399732ba617a.tar.bz2
Fixed some errors, but still haven't stopped it crashing with particle
system. Will now crash if it runs out of memory (rather than continuing and crashing later
-rw-r--r--cubedbusParticle.c.in13
-rw-r--r--particleFx/emitter.c.in29
2 files changed, 27 insertions, 15 deletions
diff --git a/cubedbusParticle.c.in b/cubedbusParticle.c.in
index 211af73..12a52cc 100644
--- a/cubedbusParticle.c.in
+++ b/cubedbusParticle.c.in
@@ -120,37 +120,50 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
particle->dataSets[0].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[0].name, "position");
particle->dataSets[0].data->data = malloc (sizeof (CompFxParticleData) * 3);
+ particle->dataSets[0].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[0].nData=3;
particle->dataSets[1].data = malloc (sizeof (CompFxParticleEmitterParticleData));
particle->dataSets[1].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[1].name, "velocity");
particle->dataSets[1].data->data = malloc (sizeof (CompFxParticleData) * 3);
particle->dataSets[1].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[1].nData=3;
particle->dataSets[2].data = malloc (sizeof (CompFxParticleEmitterParticleData));
particle->dataSets[2].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[2].name, "colour");
particle->dataSets[2].data->data = malloc (sizeof (CompFxParticleData) * 3); /* XXX should be RGBA not just RGB */
+ particle->dataSets[2].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[2].nData=3;
particle->dataSets[3].data = malloc (sizeof (CompFxParticleEmitterParticleData));
particle->dataSets[3].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[3].name, "timeout");
particle->dataSets[3].data->data = malloc (sizeof (CompFxParticleData) * 1);
+ particle->dataSets[3].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[3].nData=1;
particle->dataSets[4].data = malloc (sizeof (CompFxParticleEmitterParticleData));
particle->dataSets[4].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[4].name, "life");
particle->dataSets[4].data->data = malloc (sizeof (CompFxParticleData) * 1);
+ particle->dataSets[4].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[4].nData=1;
particle->dataSets[5].data = malloc (sizeof (CompFxParticleEmitterParticleData));
particle->dataSets[5].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[5].name, "dList");
particle->dataSets[5].data->data = malloc (sizeof (CompFxParticleData) * 1);
+ particle->dataSets[5].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[5].nData=1;
particle->dataSets[6].data = malloc (sizeof (CompFxParticleEmitterParticleData));
particle->dataSets[6].name= malloc (sizeof (char) * 12);
strcpy (particle->dataSets[6].name, "acceleration");
particle->dataSets[6].data->data = malloc (sizeof (CompFxParticleData) * 3);
+ particle->dataSets[6].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+ particle->dataSets[6].nData=3;
CompFxParticleEmitterParticleData *particleDataUnion = particle->dataSets[5].data;
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index 5aaceaf..a11364e 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -1,3 +1,12 @@
+/* the data pointer under emitterData should point to a typedef'd union of type CompFxParticleData */
+
+static void
+compFxParticleEmitterAddDataStandard (CompFxParticleData *particleData, CompFxParticleEmitterParticleData *emitterData)
+{
+ memcpy(particleData, emitterData->data, sizeof( CompFxParticleData));
+}
+
+
/* Emitter functions */
static CompFxParticle
@@ -29,7 +38,7 @@ static CompFxParticle
static void
compFxParticleInitiate (CompFxParticle *particle, CompFxParticleEmitterParticleDataInfo *data)
{
- int i,i2;
+ int i,i2,debug;
particle->compFxParticleDrawProc=data->compFxParticleDrawProc;
particle->compFxParticleMoveProc=data->compFxParticleMoveProc;
@@ -37,31 +46,21 @@ compFxParticleInitiate (CompFxParticle *particle, CompFxParticleEmitterParticleD
particle->nDataSets=data->nDataSets;
particle->dataSets = malloc (sizeof (CompFxParticleDataSet) * particle->nDataSets);
- if(particle->dataSets == NULL) /* XXX error XXX */
+ if(particle->dataSets == NULL) debug=atoi(NULL);/* XXX error XXX */
for(i=0; i < particle->nDataSets;i++)
{
particle->dataSets[i].name=data->dataSets[i].name;
particle->dataSets[i].data= malloc (sizeof (CompFxParticleData) * data->dataSets[i].nData);
- if(particle->dataSets[i].data == NULL) /* XXX error XXX */
-
+ if(particle->dataSets[i].data == NULL) debug=atoi(NULL);/* XXX error XXX */
+ debug = data->dataSets[i].nData;
for(i2=0; i2 < data->dataSets[i].nData;i2++)
{
- (data->dataSets[i].data[i2].compFxParticleEmitterAddDataProc) ( &(particle->dataSets[i].data[i2]), &(data->dataSets[i].data[i2]));
+ compFxParticleEmitterAddDataStandard /* (data->dataSets[i].data[i2].compFxParticleEmitterAddDataProc)*/ ( &(particle->dataSets[i].data[i2]), &(data->dataSets[i].data[i2]));
}
}
}
-/* the data pointer under emitterData should point to a typedef'd union of type CompFxParticleData */
-
-static void
-compFxParticleEmitterAddDataStandard (CompFxParticleData *particleData, CompFxParticleEmitterParticleData *emitterData)
-{
- particleData=emitterData->data;
- //memcpy(particleData, *emitterData->data, sizeof( CompFxParticleData));
-}
-
-
/* Softcoded step function to create particles for an emitter - also for testing */