crash after connecting a own particle OP

   4297   4   2
User Avatar
Member
229 posts
Joined: May 2006
Offline
Hi,

i've gont a problem with my particle op i've created.
when i connect it to a normal “location” pop everything works fine and fancy, but when i connect it to a source pop which gets the emitting geometry from an outside sop, it crashes without warning.
so i've started debugging the whole mess and found out that instead of iterating through the particle primitives created with the location pop, not a single particle primitive is available when my pop its connected to the source pop.

here i got some codesnippets

OP_ERROR
POP_FrequenzTest::cookPop (OP_Context &context)
{
float t = context.myTime;
POP_ContextData* data = (POP_ContextData*) context.myData;
float timeInc = data->myTimeInc;
GEO_PrimParticle* part;
GEO_ParticleVertex* pvtx;
UT_Matrix4 xform;
UT_Vector3 origin;
UT_Vector3 dir;
UT_Vector3 gravity;
float radius;
float length;
POP_FParam strength;
POP_FParam mass;
int massOffset;
UT_String sourceName;
const GB_PointGroup *sourceGroup = NULL;
GU_PrimTubeParms tubeParms;
GU_PrimTubeParms cubeParms;
GU_CapOptions caps;
UT_Interrupt* boss = UTgetInterrupt();


this->pConnAttribID = data->getDetail()->addPointAttrib(“connections”,sizeof(hou_particleConnections),GB_ATTRIB_MIXED,0);

// Add this to the list of guide geometries to show in the POP_ContextData.
if (doUpdateViewport(data))
{
data->myOPGuides.append(myGuide);
data->myGuidePOPs.append(this);
}

if (lockInputs(context) >= UT_ERROR_ABORT) return(error());

setupDynamicVars(data);

// Build the particle list that this POP needs to process.
if (buildParticleList(context) >= UT_ERROR_ABORT)
{
unlockInputs();
myCurrPt = NULL;
return error();
}

if (!checkActivation(data, (POP_FParam) &POP_FrequenzTest::ACTIVATE)) // Checks if Node is Active
{
unlockInputs();
myCurrPt = NULL;
return
}


if (this->getActiveParticle(context)>= UT_ERROR_ABORT)
{
unlockInputs();
myCurrPt = NULL;
return error();
}


}

and here's the

OP_ERROR POP_FrequenzTest::getActiveParticle(OP_Context &context)
{
POP_ContextData* data = (POP_ContextData*) context.myData;
GEO_ParticleVertex* pvtx;
GEO_PrimParticle* part;
UT_String sourceName;
activeParticleSourceGroup = NULL;
this->SOURCE(sourceName);
if (sourceName.isstring())
{
activeParticleSourceGroup = parsePointGroups((const char*)sourceName,data->getDetail());
if (!activeParticleSourceGroup)
{
addError(POP_BAD_GROUP, sourceName);
{
unlockInputs();
// Reset this so something is defined for UI dialog updates.
myCurrPt = NULL;
return error();
}
}
}
// In order for the local variables to work, we must initialize them.
setupVars(data, activeParticleSourceGroup);
myCurrIter = 0;
if (activeParticleSourceGroup)
{
hou_particleID zaehler_ = 0;
FOR_ALL_GROUP_POINTS(data->getDetail(),activeParticleSourceGroup, myCurrPt)
{
UT_Vector3 *accel_ = (UT_Vector3*)myCurrPt->getAttribData(data->getAccelOffset());
UT_Vector3 *veloc_ = (UT_Vector3*)myCurrPt->getAttribData(data->getVelocityOffset());
UT_Vector4 pos_ = myCurrPt->getPos();
int pID_ = *(int*)myCurrPt->getAttribData(data->getIDOffset());
hou_particleConnections *partConn_ hou_particleConnections*) myCurrPt->getAttribData(this->pConnAttribID);
int * state = (int*) myCurrPt->getAttribData(data->getStateOffset());

myCurrIter++;

}
}
else
{
int i=0;
for (part = myParticleList.iterateInit() ;part ; part = myParticleList.iterateNext())
{
for (pvtx = part->iterateInit() ; pvtx ; pvtx = pvtx->next)
{
myCurrPt = pvtx->getPt();
UT_Vector3 *accel_= (UT_Vector3*)myCurrPt->getAttribData(data->getAccelOffset());
UT_Vector3 *veloc_ = (UT_Vector3*)myCurrPt->getAttribData(data->getVelocityOffset());
int *state = (int*)myCurrPt->getAttribData(data->getStateOffset());
UT_Vector4 pos_ = myCurrPt->getPos();
int pID_ = *(int*)myCurrPt->getAttribData(data->getIDOffset());
hou_particleConnections *partConn_ = (hou_particleConnections*) myCurrPt->getAttribData(this->pConnAttribID);
myCurrIter++;
}
}
}

return error();
}


it would be very nice if somebody have a clue why its not workin with a source pop.

thx in advance

Sebastian
User Avatar
Member
325 posts
Joined: July 2005
Offline
Hi, Infernalspawn.

Unless somebody from the dev.team sees the obvious reason in your code - I may try giving you a suggestion what I normally do in such cases. I am sure that you are perfectly aware of this method already, nevertheless that's what always works in case I can't find what's wrong with my code:

- simply quote your code, starting from the part you deem is the most likely to contain a bug - then spread the ‘bug catching area’ if no change.

btw - when you track down the bug - could you post here the reason that was causing the crash?

Happy coding!
I liked the Mustang
User Avatar
Member
166 posts
Joined: Feb. 2006
Offline
Hi well, I only had a quick look at the code but cant be sure of the following. I may be totally wrong….
- If a location POP works but not a source POP piping a Geometry, it may be a problem of initialisation/valid source.
sourceName is checked if it is a string, but not if it is a valid Source it is self. That s what it looks like…
As said above, a SESI guy may spot the error straight away.
Time to get out of this messy world.
User Avatar
Member
387 posts
Joined: July 2005
Offline
Here's a clue: there are several places where the code “dereferences a pointer” without checking whether the pointer is valid (ie that the pointer is not ‘0’ (NULL)). If “->” is used on a pointer which is ‘0’ there will be a crash. eg: instead, do this sort of thing: if(data) { timeInc = data->myTimeInc } and so on.
b.
''You're always doing this: reducing it to science. Why can't it be real?'' – Jackie Tyler
User Avatar
Member
229 posts
Joined: May 2006
Offline
Hi,

actualy i'm debuging it using 2 times the same scene, once with the POP_LocalForce sample pop, and one time with my pop.
in the LocalForce pop i got some particles and in myParticleList, but in my own pop i dont have any particle in myParticleList.
does anybody have an idea why that may happen ?

thx
Sebastian
  • Quick Links