Game Development Community

TGEA crashes when vehicle collides with difs

by Nigel Hungerford-Symes · in Torque Game Engine Advanced · 04/29/2007 (5:38 am) · 9 replies

I'm having difficulty with difs created in Constructer and then exported with both legacy TGEA dif and map2dif_plus options.

When using the default setup in starter.racing TGEA crashes about 4 out of 5 times when the vehicle collides with the dif.

I have one simple ramp dif that has no problems. Other "box" like difs I make will crash tgea when touched by the car.

Any ideas?

#1
04/29/2007 (7:07 am)
Sorry to be the bearer of bad news, but this is not specific to TGEA or your case.

What you can do (and you should have) is search the forums for countermeasures you can employ to make the effect less severe. There are different collision tolerances and thresholds which can be tweaked. And really, if you want to get in detail on what is causing this then there are a ton of threads on that, in particular you should read the posts of Brad Shapcott.
#2
04/30/2007 (6:21 am)
Yeah, I've searched around he forums, lots of posts way back in 2001/2002 detailing what appears, prima facie to be the same problem.

Anyway haven't found anything that fixes it yet.

When reproducing the error in a debug session I get the following output at the point of failure:

First-chance exception at 0x00740836 in TGEA_DEBUG.exe: 0xC0000005: Access violation reading location 0x1fe00318.
Unhandled exception at 0x00740836 in TGEA_DEBUG.exe: 0xC0000005: Access violation reading location 0x1fe00318.

Furthermore I'm at this point on the callstack (top is the latest obviously):
> TGEA_DEBUG.exe!PlaneF::set(const Point3F & k={...}, const Point3F & j={...}, const Point3F & l={...}) Line 239 + 0x3 bytes C++
TGEA_DEBUG.exe!PlaneF::PlaneF(const Point3F & j={...}, const Point3F & k={...}, const Point3F & l={...}) Line 107 C++
TGEA_DEBUG.exe!InteriorConvex::getFeatures(const MatrixF & mat={...}, const Point3F & n={...}, ConvexFeature * cf=0x0012ec04) Line 1435 C++
TGEA_DEBUG.exe!Convex::getCollisionInfo(const MatrixF & mat={...}, const Point3F & scale={...}, CollisionList * cList=0x04d8ede0, float tol=0.20000000) Line 590 + 0x2c bytes C++
TGEA_DEBUG.exe!Vehicle::updateCollision(float dt=0.00050000002) Line 1069 C++
TGEA_DEBUG.exe!Vehicle::updatePos(float dt=0.00050000002) Line 944 + 0xf bytes C++


And I'm at this line in mPlane.h (239):

F32 ax = k.x-j.x;


Well that is all the time I have for debugging tonight....I'll try and pick it up tomorow
#3
05/01/2007 (5:13 am)
Looking at the disassembly when the error happens leads to Convex:getFeatures sending a bad pointer to PlaneF::PlaneF and then it sending the bad data to PlaneF::Set

It is trying to create a Plane and gets a bad pointer and crashes.

This Plane is being created by this line in interiorCollision.cpp:

cf->mFaceList.last().normal = plane;

This line forms part of a loop

Maybe some form of sanity check here would help? (naive I know but it is all I've got at the moment)
#4
05/01/2007 (5:25 am)
My next random thought on it. Somewhere between Contructor making the dif, TGEA creating the material on the dif at runtime there is an array boundary issue or similar to do with the material assigned.

It seems the exception error only happens when the collision hull of the vehicle is tested against only certain faces of the mesh. Are the default collision test loops accidentally running over the bounds of an array because of something the materials are doing?

It is after all a wrong data being sent to a function that creates a plane from vertices and the erroneous data causing the crash is a vertex.
#5
05/01/2007 (8:13 am)
You could try creating the Material entry "by hand" in script to test that theory.
#6
05/02/2007 (10:29 pm)
Its the same place where i have my application crashes. i tested my dif with the older versions of Torque ie 1.3 & 1.4 & 1.5, i did try to collide the vehicle with my difs and it was working fine there, it crashes only in TGEA and i seriously cant make out the differences in the other torque versions and TGEA
#7
05/04/2007 (4:29 pm)
The funny thing is that, for me at least, TGEA does not crash with the default starter.racing dif objects.

This leads me to think something in the creation process of the dif or material on the dif is causing a problem with TGEA.

It is made more tricky as it seems the crash isn't the first face tested with that material but one somewhere in the loop.

Maybe this means some bad material data is causing an overstepping of an array or something?
#8
05/05/2007 (8:26 pm)
Well I have a workaround.

Using a current version of map2dif_plus.

1) Make your structure in Constructor.

2) Save it as a *.map file

3) Then run map2dif_plus -h foo.map

4) Then make sure you have a material.cs that creates the "demoMaterial" for each texture used.

5) Import it.


Just to clarify, if you export from Constructor using the defaults, you'll get crashes in TGEA, using a current build of map2dif_plus seems to not cause the crash.
#9
05/06/2007 (11:49 pm)
Another "workaround" that I'm using is to ditch Constructor and use Blender with Vincent Billet's map exporter and then use map2dif_plus.

I'm used to Blender so it is much faster for me to work in Blender and this method is 100% stable.