summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@joel-desktop.(none)>2008-01-28 13:40:20 +0900
committerJoel Bosveld <joel@joel-desktop.(none)>2008-01-28 13:40:20 +0900
commit191906345d057c4aaeb008549bc3d05d4c647897 (patch)
tree3d1b3aec84d730ca2876d7629b6e29033072f461
parent76ea38fcc9d257eac00aee0b3ca9399732ba617a (diff)
downloadcubedbus-191906345d057c4aaeb008549bc3d05d4c647897.tar.gz
cubedbus-191906345d057c4aaeb008549bc3d05d4c647897.tar.bz2
Finally fixed crash...
-rw-r--r--cubedbusParticle.c.in132
-rw-r--r--particleFx/emitter.c.in15
2 files changed, 87 insertions, 60 deletions
diff --git a/cubedbusParticle.c.in b/cubedbusParticle.c.in
index 12a52cc..b8e11ba 100644
--- a/cubedbusParticle.c.in
+++ b/cubedbusParticle.c.in
@@ -106,69 +106,78 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
particleData->emitter->particleInfo = malloc (sizeof(CompFxParticleEmitterParticleDataInfo));
particleData->emitter->nParticleInfo =1 ;
-
- CompFxParticleEmitterParticleDataInfo *particle = particleData->emitter->particleInfo;
+ CompFxParticleEmitterParticleDataInfo *particle = particleData->emitter->particleInfo;
+
+ particle->compFxParticleDrawProc = &compFxParticleDrawColour;
+ particle->compFxParticleMoveProc = &compFxParticleMoveConstantAcceleration;
+ particle->compFxParticleDeathProc = &compFxParticleDeathTimeout;
- particle->compFxParticleDrawProc = &compFxParticleDrawColour;
- particle->compFxParticleMoveProc = &compFxParticleMoveConstantAcceleration;
- particle->compFxParticleDeathProc = &compFxParticleDeathTimeout;
+ particle->nDataSets=7;
+ particle->dataSets = malloc (sizeof (CompFxParticleEmitterParticleDataSet) * particle->nDataSets);
- particle->nDataSets=7;
- particle->dataSets = malloc (sizeof (CompFxParticleEmitterParticleDataSet) * particle->nDataSets);
- particle->dataSets[0].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[0].nData=3;
+ particle->dataSets[0].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[0].nData);
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[0].data[0].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[0].data[1].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[0].data[2].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[1].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[1].nData=3;
+ particle->dataSets[1].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[1].nData);
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[1].data[0].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[1].data[1].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[1].data[2].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[2].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[2].nData=3;
+ particle->dataSets[2].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[2].nData);
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[2].data[0].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[2].data[1].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[2].data[2].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[3].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[3].nData=1;
+ particle->dataSets[3].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[3].nData);
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[3].data[0].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[4].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[4].nData=1;
+ particle->dataSets[4].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[4].nData);
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[4].data[0].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[5].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[5].nData=1;
+ particle->dataSets[5].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[5].nData);
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[5].data[0].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[6].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[6].nData=3;
+ particle->dataSets[6].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[6].nData);
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;
+ particle->dataSets[6].data[0].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[6].data[1].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[6].data[2].data = malloc (sizeof(CompFxParticleData));
+
- CompFxParticleEmitterParticleData *particleDataUnion = particle->dataSets[5].data;
+ CompFxParticleEmitterParticleData *particleDataUnion = &(particle->dataSets[5].data[0]);
CompFxParticleData *dta = particleDataUnion->data;
- dta[0].u=glGenLists (1);
+ dta->u=glGenLists (1);
glNewList (dta[0].u, GL_COMPILE);
glBegin(GL_TRIANGLES);
@@ -180,40 +189,57 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
glEnd();
glEndList();
- particleDataUnion = particle->dataSets[2].data;
- dta = particleDataUnion->data;
+ particleDataUnion = &particle->dataSets[2].data[0];
+ dta = particleDataUnion->data;
dta[0].f=0.75+0.25*((double) rand() / ((double) RAND_MAX+1));
- dta[1].f=0.25*((double) rand() / ((double) RAND_MAX+1));
- dta[2].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+ particleDataUnion = &particle->dataSets[2].data[1];
+ dta = particleDataUnion->data;
+ dta[0].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+ particleDataUnion = &particle->dataSets[2].data[2];
+ dta = particleDataUnion->data;
+ dta[0].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+
- particleDataUnion = particle->dataSets[1].data;
- dta = particleDataUnion->data;
+ particleDataUnion = &particle->dataSets[1].data[0];
+ dta = particleDataUnion->data;
dta[0].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
- dta[1].f= (0.0050 * (double) rand() / ((double) RAND_MAX+1));
- dta[2].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
+ particleDataUnion = &particle->dataSets[1].data[1];
+ dta = particleDataUnion->data;
+ dta[0].f= (0.0050 * (double) rand() / ((double) RAND_MAX+1));
+ particleDataUnion = &particle->dataSets[1].data[2];
+ dta = particleDataUnion->data;
+ dta[0].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
+
- particleDataUnion = particle->dataSets[3].data;
- dta = particleDataUnion->data;
+ particleDataUnion = particle->dataSets[3].data;
+ dta = particleDataUnion->data;
dta[0].l = 600;
- particleDataUnion = particle->dataSets[4].data;
- dta = particleDataUnion->data;
+ particleDataUnion = particle->dataSets[4].data;
+ dta = particleDataUnion->data;
dta[0].l = 0;
- particleDataUnion = particle->dataSets[0].data;
- dta = particleDataUnion->data;
+
+ particleDataUnion = &particle->dataSets[0].data[0];
+ dta = particleDataUnion->data;
+ dta[0].f=0;
+ particleDataUnion = &particle->dataSets[0].data[1];
+ dta = particleDataUnion->data;
+ dta[0].f=0;
+ particleDataUnion = &particle->dataSets[0].data[2];
+ dta = particleDataUnion->data;
dta[0].f=0;
- dta[1].f=0;
- dta[2].f=0;
- particleDataUnion = particle->dataSets[6].data;
- dta = particleDataUnion->data;
+ particleDataUnion = &particle->dataSets[6].data[0];
+ dta = particleDataUnion->data;
dta[0].f=0;
- dta[1].f=-0.000025;
- dta[2].f=0;
-
-
-
+ particleDataUnion = &particle->dataSets[6].data[1];
+ dta = particleDataUnion->data;
+ dta[0].f=-0.000025;
+ particleDataUnion = &particle->dataSets[6].data[2];
+ dta = particleDataUnion->data;
+ dta[0].f=0;
+
return TRUE;
}
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index a11364e..a03f692 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -3,7 +3,8 @@
static void
compFxParticleEmitterAddDataStandard (CompFxParticleData *particleData, CompFxParticleEmitterParticleData *emitterData)
{
- memcpy(particleData, emitterData->data, sizeof( CompFxParticleData));
+ CompFxParticleData *data=emitterData->data;
+ memcpy(particleData, data, sizeof( CompFxParticleData));
}
@@ -38,7 +39,8 @@ static CompFxParticle
static void
compFxParticleInitiate (CompFxParticle *particle, CompFxParticleEmitterParticleDataInfo *data)
{
- int i,i2,debug;
+ int i,i2;
+
particle->compFxParticleDrawProc=data->compFxParticleDrawProc;
particle->compFxParticleMoveProc=data->compFxParticleMoveProc;
@@ -46,17 +48,16 @@ compFxParticleInitiate (CompFxParticle *particle, CompFxParticleEmitterParticleD
particle->nDataSets=data->nDataSets;
particle->dataSets = malloc (sizeof (CompFxParticleDataSet) * particle->nDataSets);
- if(particle->dataSets == NULL) debug=atoi(NULL);/* XXX error XXX */
+ if(particle->dataSets == 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) debug=atoi(NULL);/* XXX error XXX */
- debug = data->dataSets[i].nData;
+ if(particle->dataSets[i].data == NULL); /* XXX error XXX */
for(i2=0; i2 < data->dataSets[i].nData;i2++)
{
- compFxParticleEmitterAddDataStandard /* (data->dataSets[i].data[i2].compFxParticleEmitterAddDataProc)*/ ( &(particle->dataSets[i].data[i2]), &(data->dataSets[i].data[i2]));
+ compFxParticleEmitterAddDataStandard (particle->dataSets[i].data + i2 , data->dataSets[i].data + i2) /* (data->dataSets[i].data[i2].compFxParticleEmitterAddDataProc) ( &(particle->dataSets[i].data[i2]), &(data->dataSets[i].data[i2])) */;
}
}
}
@@ -69,7 +70,7 @@ compFxParticleEmitterStepSoft (CompFxParticleEmitter *emitter)
{
CompFxParticle *particle = NULL;
- if(emitter->nParticles >= 1000) /* XXX should be a variable in emitter */
+ if(emitter->nParticles >= 500) /* XXX should be a variable in emitter */
{
}
else if( (particle = compFxParticleCreate (emitter)) == NULL) /* this function sets up the emitter, next, and prev fields */