NxOgreGC.h unhandled exception

lordmonkey

19-04-2011 21:46:53

Hello,
I got another problem with Critter::RenderSystem. When I try to run this code :
// Setup a BodyDescription.
Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 40.0f; // Set the mass to 40kg.
NxOgre::BoxDescription boxDecr = NxOgre::BoxDescription(5,5,5);

Critter::Body* mBody1 = NULL;
mBody1 = mRenderSystem->createBody(boxDecr , NxOgre::Matrix44::IDENTITY, "cube.1m.mesh", bodyDescription);


I get an unhandled exception at this piece of code in NxOgreGC.h :
template<typename T, typename A1, typename A2> inline T* safe_new2(const A1& v1, const A2& v2, const char* file = 0, int line = 0)
{
T* ptr = new T(v1, v2); // -------AT THIS LINE !! -----------
#if NXOGRE_DEBUG_MEMORY == 1
gc_debugger_push_ptr(ptr, sizeof(T), type2id<T>::type_name(), file, line);
#endif
return ptr;
};


The debugger says that it has a problem with ptr whereas ptr._Pfirst is a NULL pointer.

Any ideas ?

betajaen

19-04-2011 21:56:40

Critter::Body* mBody1 = NULL;

Is "mBody1" a member variable or a temporary variable in that function? "m" stands for member.

lordmonkey

19-04-2011 22:08:37

Thanks for pointing this out. Although this was a locally created pointer inside a function and that might have been a problem I have changed the code now so that I use a member of OgreApp1 -mBody and I get the same error.

void OgreApp1::createCube()
{
// Setup a BodyDescription.
Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 40.0f; // Set the mass to 40kg.
NxOgre::BoxDescription boxDecr = NxOgre::BoxDescription(5,5,5);

mBody = mRenderSystem->createBody(boxDecr , NxOgre::Matrix44::IDENTITY, "cube.1m.mesh", bodyDescription);
mBody->setAngularVelocity(0,3,0);
mBody->setGlobalPosition(20,50,0);
mBody->getNode()->setScale(5);
}

betajaen

19-04-2011 22:32:16

It isn't a problem with safe_new2. It's your code, your giving NxOgre wrong or invalid pointers, mRenderSystem most likely.

lordmonkey

19-04-2011 22:48:49

Ok, so one problem solved but another arises (an old one). The problem was that I had the
mRenderSystem = new Critter::RenderSystem(mNxScene, mSceneMgr);

before initializing the mSceneMgr, but now when I changed its position so that everything is ok I get an error I already posted here :
http://www.ogre3d.org/addonforums/viewtopic.php?f=6&t=14296

extern "C" _CRTIMP int __cdecl _CrtIsValidHeapPointer(
const void * pUserData
)
{
if (!pUserData)
return FALSE;

if (!_CrtIsValidPointer(pHdr(pUserData), sizeof(_CrtMemBlockHeader), FALSE))
return FALSE;

return HeapValidate( _crtheap, 0, pHdr(pUserData) ); //-----HERE
}

betajaen

19-04-2011 22:56:55

It's still your code and order, null or uninitialised pointers.

NxOgre is over 6 years old. People use it daily, if there was a problem with creating these simple classes it would be found by now.