userdata question - physX not nxogre [SOLVED]

nasirus1983

25-02-2009 08:06:08

Hi,

I have got a question about a userData in PhysX. I know that is not about NxOgre, but I hope that maybe here I'll get help, because on Nvidia PhysX forum nobody answered.
So, I've read here on the forum, that in NxOgre I should't use use userData. Because I need it, I've had to use PhysX. My code is:


void OgreApplication::makeActorsForBones()
{

Ogre::Entity* e=(Ogre::Entity*)characterSN->getAttachedObject(0);
Ogre::SkeletonInstance* skeletonInst = e->getSkeleton();
Ogre::Skeleton::BoneIterator boneI=skeletonInst->getBoneIterator();

while(boneI.hasMoreElements())
{
Ogre::Bone* bone=boneI.getNext();
Ogre::String bName=bone->getName();

if (bone->getChild(0))
{
Ogre::Vector3 curr = bone->_getDerivedPosition();
Ogre::Vector3 next = bone->getChild(0)->_getDerivedPosition();
Ogre::Vector3 difference = next-curr;

//length of bone
Ogre::Real lenght = difference.length();

NxReal boxStartHeight = 3.5;

// Add a single-shape actor to the scene
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;

// The actor has one shape, a box, 1m on a side
NxBoxShapeDesc boxDesc;
boxDesc.dimensions.set(difference.x,difference.y,difference.z);
boxDesc.localPose.t = NxVec3(0, 0, 0);
actorDesc.shapes.pushBack(&boxDesc);

actorDesc.body = &bodyDesc;
actorDesc.density = 10.0f;
actorDesc.globalPose.t = NxVec3(0,boxStartHeight,0);

NxActor *pActor = gScene->createActor(actorDesc);

MyActorDescription* myActorDesc = new MyActorDesription();
myActorDesc->name = bone->getName().c_str();

pActor->userData = (void*)myActorDesc;
pActor->raiseBodyFlag(NX_BF_KINEMATIC);

//if (!bone->getParent())
}
}
}

Problem is that after I running application it crashes - access violation. VS as the line of the problem showing:

pActor->userData = (void*)myActorDesc;

When I comment this line, the next line is the problem, with the same error.Moreover when I watching line (pActor variable in the watch):

pActor->userData = (void*)myActorDesc;

in the debuger is see something like this:

CX0030: Error: expression cannot be evaluated.


Any idea's what is wrong ? Something not allocated or deallocated ?

p.s.
The same problem is, when I'm using:

pActor->setName(bone->getName().c_str())

instead userdata.

nasirus1983

28-02-2009 01:04:41

I've figured out where is mistake :] - the problem was in variable difference, where values could be with the minus sign.
That value, delivered to shape desc as dimmension, caused the error.