[ODE] Exception in dCollide when using trimesh

Kris kris at kolos.math.uni.lodz.pl
Mon Mar 14 11:35:45 MST 2005


Hi!

I have an access violation exception inside dCollide when
box is about to collide with my trimesh geometry. I use
precompiled 0.5-msvc-single-trimesh library from sourceforge
in VC7.1

here are function calls leading to crash:
Trinity_r.exe!Opcode::OBBCollider::_Collide()  + 0x662  C++
Trinity_r.exe!Opcode::OBBCollider::_Collide()  + 0x19ad C++
Trinity_r.exe!Opcode::OBBCollider::_Collide()  + 0xf93  C++
Trinity_r.exe!Opcode::OBBCollider::Collide()  + 0xde    C++
Trinity_r.exe!dCollideBTL()  + 0x456    C++
Trinity_r.exe!_dCollide()  + 0x58   C++
Trinity_r.exe!trinity::physic::CPhysicsManager::nearCallback(void * _data=0x096fe110, dxGeom * _obj1=0x0a354aa8, dxGeom * _obj2=0x096fe5c8)  Line 188 + 0xd6    C++
Trinity_r.exe!_dJointGetSliderPosition()  + 0x1689  C++
Trinity_r.exe!dxHashSpace::collide()  + 0x38e   C++
Trinity_r.exe!_dSpaceCollide()  + 0x13  C++
Trinity_r.exe!trinity::physic::CPhysicsManager::step(float _stepTime=0.0099999998)  Line 224    C++
Trinity_r.exe!trinity::physic::CPhysicsManager::simulate(float _stepTime=0.049400002)  Line 206 C++
Trinity_r.exe!trinity::CTempState::process(const Ogre::FrameEvent & evt={...})  Line 280    C++
Trinity_r.exe!trinity::CMainLoop::frameStarted(const Ogre::FrameEvent & evt={...})  Line 76 + 0xd   C++
OgreMain.dll!10155292()
OgreMain.dll!101553b3()
OgreMain.dll!101556cf()
OgreMain.dll!101556a4()
Trinity_r.exe!trinity::CApp::run()  Line 79 C++
Trinity_r.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00141f05, int nShowCmd=1)  Line 19 C++
Trinity_r.exe!WinMainCRTStartup()  Line 390 + 0x1b  C
KERNEL32.DLL!77e7eb69()

Here is nearCallback

void CPhysicsManager::nearCallback(void* _data, dGeomID _obj1, dGeomID _obj2)
        {
            CPhysicsManager* pm = static_cast< CPhysicsManager* >(_data);
            dBodyID b1 = dGeomGetBody(_obj1);
            dBodyID b2 = dGeomGetBody(_obj2);

            if( b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact) ) return;
            if( dGeomIsSpace(_obj1) || dGeomIsSpace(_obj2) ) dSpaceCollide2(_obj1, _obj2, _data, nearCallback);
            const int N = 3;
            int i;
            dContact contact[N];
            for(i = 0; i < N; ++i)
            {
                contact[i].surface.mode = dContactBounce | dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
                contact[i].surface.mu = 1.0f;
                contact[i].surface.slip1 = 0.0;
                contact[i].surface.slip2 = 0.0;
                contact[i].surface.bounce = 0.01f;
                contact[i].surface.soft_erp = 0.7f;
                contact[i].surface.soft_cfm = 0.001f;
            }
            if( int collisions = dCollide(_obj1, _obj2, N, &contact[0].geom, sizeof(dContact)) )
            {
                for(i = 0; i < collisions; ++i)
                {
                    dJointID c = dJointCreateContact(pm->mWorldID, pm->mJointGroupID, contact + i);
                    dJointAttach(c, b1, b2);
                }
            }
        }

i've tried changing number of contact points to 30 but is changes nothing :(

World settings

  dWorldSetGravity( mWorldID, 0, -9.0f, 0 );
  dWorldSetCFM( mWorldID, 1e-4 );
  dWorldSetERP( mWorldID, 0.7f );
  dWorldSetContactMaxCorrectingVel( mWorldID, 1.0f );


here are vertices and indices
  	vertexCount = 5;
            vertices = new dVector3[5];^M
            vertices[0][0] = 5; vertices[0][1] = 5; vertices[0][2] = 5;
            vertices[1][0] = 50; vertices[1][1] = 45; vertices[1][2] = 50;
            vertices[2][0] = -50; vertices[2][1] = 45; vertices[2][2] = 50;
            vertices[3][0] = 50; vertices[3][1] = 45; vertices[3][2] = -50;
            vertices[4][0] = -50; vertices[4][1] = 45; vertices[4][2] = -50;

            indexCount = 12;
            indices = new int[12];
            indices[0] = 0; indices[1] = 1; indices[2] = 3;
            indices[3] = 0; indices[4] = 3; indices[5] = 4;
            indices[6] = 0; indices[7] = 4; indices[8] = 2;
            indices[9] = 0; indices[10] = 2; indices[11] = 1;
            _pos[0] = _pos[2] = 5; _pos[1] = 40;

btw. does oreder od indices for particular triangle has any meaning
(clock / unclock wise) while normal calculations by ODE?

I build trimesh the following way:

            dTriMeshDataID mTriMeshData = dGeomTriMeshDataCreate();

            //dGeomTriMeshDataBuildSingle(mTriMeshData, _vertices, 3 * sizeof(dReal), _vertexNum, _indices, _indexNum, 3 * sizeof(int));
            dGeomTriMeshDataBuildSimple(mTriMeshData, _vertices, _vertexNum, _indices, _indexNum);

            mGeomID = dCreateTriMesh(mSpaceID, mTriMeshData, 0, 0, 0);

            dGeomSetPosition(mGeomID, _pos[0], _pos[1], _pos[2]);

            dGeomSetBody(mGeomID, 0); //no body attached

box mass is 1.0, density 5.0, box side is 50 length

i've lost 2 days already seeking for error source, read through few
examples (from ode and OgreOde) and it looks ok, please help!


Pozdr __DEVELOPER_TRINITY_CREEZ_H__
-- 
===========================================
                 GG: 1271378
-------------[ PROJECT TRINITY ]-----------
  [ http://trinity.glt.pl ]   [ Trinity ]
        [ The post-nuclear cRPG ]
===========================================



More information about the ODE mailing list