So here I was, perfect debug display, perfect physics, perfect rotations and locations that I thought, hey let's make the map have some collision!
First, I create the TreeCollision, I call the beginTreeCollision procedure, start adding faces to it, and at ending I get a memory error ( oh I love those.. )
The source code for the maps is a little large, ( Unreal t3d map importer )
First, before file loading:
- Code: Select all
*map_collision = NewtonCreateTreeCollision( *NewtonWorld, 0 )
NewtonTreeCollisionBeginBuild( *map_collision )
Then while the map is loading, from time to time add 3 vertexes:
- Code: Select all
Dim vertexes.f(8)
vertexes(0) = next_t3d_surface\VertexPoints(1+i)\x
vertexes(1) = next_t3d_surface\VertexPoints(1+i)\y
vertexes(2) = next_t3d_surface\VertexPoints(1+i)\z
vertexes(3) = next_t3d_surface\VertexPoints(0)\x
vertexes(4) = next_t3d_surface\VertexPoints(0)\y
vertexes(5) = next_t3d_surface\VertexPoints(0)\z
vertexes(6) = next_t3d_surface\VertexPoints(2+i)\x
vertexes(7) = next_t3d_surface\VertexPoints(2+i)\y
vertexes(8) = next_t3d_surface\VertexPoints(2+i)\z
NewtonTreeCollisionAddFace( *map_collision, 9, @vertexes(), 12, 0 ) // I tried multiple 12, 24, 36 ( which hangs the application ) etc.
Then when the file was loaded, we close the file and want to finish up:
- Code: Select all
NewtonTreeCollisionEndBuild( *map_collision, 0 ) // KABOOMM!!!!! Tried 0 and 1
It just fails hard with an exception here, any idea what I might be doing wrong?
Thanks!
FIXED IT!!
1 vertex = 3 floats, I told it I had 9 vertices but I only had 3 , with 3 values each and the array only contained enough info for 3 vertices, to think noone including me noticed..
