[Solved][Git] Crash with creating Heightfield Geometry

Druha

22-09-2009 15:38:47

I am using this commit http://github.com/betajaen/nxogre/commi ... e27bf00d4d

I want to match NxOgre heightfield with Ogre TSM (I use 1.6). I've generated .xhf file from raw image using Flour 0.3.2.
When I try to create geometry from heightfield I get a crash:
"Unhandled exception at 0x00000000 in Esertia.exe: 0xC0000005: Access violation reading location 0x00000000."

Here is related code:

NxOgre::ResourceSystem::getSingleton()->openArchive("media", "file:../../data");

NxOgre::HeightField* hf = NxOgre::HeightFieldManager::getSingleton()->load("media:test1.xhf");
NxOgre::HeightFieldGeometry* hfg = new NxOgre::HeightFieldGeometry(hf, Vector3(5000,350,5000));
mScene->createSceneGeometry(hfg); // <-- crash here

Here is callstack generated by MSVC

00000000()
NxOgre_Debug.dll!NxOgre::PhysXShapeBinder::BindShape(NxShape * shape=0x0b41cdb8) Line 95 + 0x25 bytes C++
NxOgre_Debug.dll!NxOgre::RigidBody::create(NxOgre::RigidBodyPrototype * prototype=0x0b41c760, NxOgre::Scene * scene=0x0b37ea88, NxOgre::Array<NxOgre::Shape *> * final_shapes=0x0b41c9ec) Line 197 + 0xc bytes C++
NxOgre_Debug.dll!NxOgre::SceneGeometry::SceneGeometry(NxOgre::RigidBodyPrototype * prototype=0x0b41c760, NxOgre::Scene * scene=0x0b37ea88) Line 53 C++
NxOgre_Debug.dll!NxOgre::Scene::createSceneGeometry(NxOgre::Shape * shape=0x002ea3ac, const NxOgre::Matrix44 & pose={...}, const NxOgre::RigidBodyDescription & description={...}) Line 216 + 0x33 bytes C++
Esertia.exe!GameRoot::setupPhysics() Line 180 + 0x171 bytes C++
Esertia.exe!GameRoot::GameRoot(Options * opts=0x002ea600) Line 99 C++
Esertia.exe!WinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * __formal=0x00000000, char * strCmdLine=0x002f2c8c, HINSTANCE__ * __formal=0x00000000) Line 38 + 0x2f bytes C++
Esertia.exe!__tmainCRTStartup() Line 589 + 0x35 bytes C
Esertia.exe!WinMainCRTStartup() Line 414 C
kernel32.dll!768d3833()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!77b9a9bd()

Same files (I mean .xhf and executables) worked fine with BloodyMess 1.5.5.

betajaen

22-09-2009 15:53:14

Looks like a Null Pointer exception, probably the heightfield.

This may be the culprit:

NxOgre::ResourceSystem::getSingleton()->openArchive("media", "file:../../data");

Don't cheat, make an archive to that data directory.

Druha

22-09-2009 16:02:05

I've tried to specify the full path to directory... Nothing changed (Or I misunderstod you?).
I've made a debug build and updated the call stack in first post.

And I repeat - same .xhf file and code works fine with 1.5.5. Maybe I should use Git Flour with it?

betajaen

22-09-2009 17:31:30

Git Flour doesn't do heightfields, yet.

If you like you can PM the heightfield and I'll see if I can get it working for you.

Illidanz

23-09-2009 07:24:55

I'm getting the same error after upgrading Git too, with my code from the wiki.

Thought it was my fault, but maybe it's not.

This is the nxogre-related stack trace
00000000()
> NxOgre_Debug.dll!NxOgre::PhysXShapeBinder::BindShape(NxShape * shape=0x0a284848) Line 95 + 0x25 byte C++
NxOgre_Debug.dll!NxOgre::RigidBody::create(NxOgre::RigidBodyPrototype * prototype=0x0a316a68, NxOgre::Scene * scene=0x0bb6ba98, NxOgre::Array<NxOgre::Shape *> * final_shapes=0x0a2bc084) Line 197 + 0xc byte C++
NxOgre_Debug.dll!NxOgre::SceneGeometry::SceneGeometry(NxOgre::RigidBodyPrototype * prototype=0x0a316a68, NxOgre::Scene * scene=0x0bb6ba98) Line 53 C++
NxOgre_Debug.dll!NxOgre::Scene::createSceneGeometry(NxOgre::Shape * shape=0x0a3acd34, const NxOgre::Matrix44 & pose={...}, const NxOgre::RigidBodyDescription & description={...}) Line 216 + 0x33 byte C++


And it crashes on
(*gFunctions[shape->getType()])(shape);

I was using 779a2023c9a4e9b7d5b0f1a9898d13af5c1db04d and upgraded to 409449197e85fafb0c9ea512aa1242659c9b5cd4

Illidanz

23-09-2009 07:49:23

This fixes it for me, everything is working again:

After line 89 in NxOgreRigidBody.cpp add
gFunctions[NX_SHAPE_HEIGHTFIELD] = &PhysX_NxHeightFieldShape_BindFunction;

Hope this works for you too :)

betajaen

23-09-2009 09:46:43

Excellent find! I feel a little stupid leaving that piece of code out.

Anyway; http://github.com/betajaen/nxogre/commi ... a377d86999

Once the OP confirms, I'll mark this thread as solved and close it.

Druha

23-09-2009 12:33:23

Yes, Illidanz's fix helps a lot, it works now.

Offtopic:
But I noticed some strange behaviour.
Betajaen, you adviced me to change archive path from relative (file:../../data) to absolute (file:D:/backup/ogre/Esertia/Game/data).
But when i use absolute path my app crashes with heap corruption on this line:

NxOgre::HeightField* hf = NxOgre::HeightFieldManager::getSingleton()->load("media:test1.xhf");

And it works with relative path... What am I doing wrong? :oops:

betajaen

23-09-2009 12:50:04

Actually, it was my bad. Go back to the relative path, when I wrote that, I mis-read what you typed and was thinking you was using directories in ArchiveResourceIdentifiers - which is a no-no.