[ODE] ode crashing at loadtime

Fabian Mathews supagu at hotmail.com
Sun Feb 22 08:42:51 MST 2004


a few scenarios:

i have no physics objects.... ODE crashes when i call dWorldStep(world, 
1.0f);

PhysicsMgr::PhysicsMgr()
{
	//create an ODE world
	world = dWorldCreate();
	space = dHashSpaceCreate(0);
	dWorldSetGravity (world,0,-0.5,0);
	dCreatePlane(space,0,1,0,0);
	contactgroup = dJointGroupCreate(0);

	printf("CREATING A NEW SIMULATION\n");
}

static void nearCollisionCallback(void *data, dGeomID o1, dGeomID o2)
{
	PhysicsMgr::GetInstance().NearCollisionCallback( data, o1, o2);
}

void PhysicsMgr::NearCollisionCallback(void *data, dGeomID o1, dGeomID o2)
{
	const int N = 10;
	dContact contact[N];

	int n = dCollide( o1, o2 ,N, &contact[0].geom, sizeof(dContact) );

	if( n > 0 )
	{
		for( int i=0; i < n; i++ )
		{
			contact[i].surface.mode = dContactSlip1 | dContactSlip2 |
			dContactSoftERP | dContactSoftCFM | dContactApprox1;
			contact[i].surface.mu = dInfinity;
			contact[i].surface.slip1 = 0.1;
			contact[i].surface.slip2 = 0.1;
			contact[i].surface.soft_erp = 0.5;
			contact[i].surface.soft_cfm = 0.3;

			dJointID c = dJointCreateContact(world, contactgroup, &contact[i] );
			dJointAttach(c, dGeomGetBody( contact[i].geom.g1), 
dGeomGetBody(contact[i].geom.g2));
		}
	}
}

void PhysicsMgr::Update( unsigned long tick )
{
	dSpaceCollide( space, 0, &nearCollisionCallback );

	dWorldStep(world, 1.0f); //CRASHES HERE!!!!!
	dJointGroupEmpty(contactgroup);
}


remmeber that class is a singleton hence the PhysicsMgr::GetInstance().

so if i comment that line out dWorldStep(world, 1.0f);

it works okay (ie. it loads)

now if i make a physics obj:

//my constructor
PhysicsObj::PhysicsObj()
{
	body = dBodyCreate( PhysicsMgr::GetInstance().GetWorld() );
	printf("NEW PHYS OBJ\n");
	dBodySetLinearVel(body, 3, 5, 1);
	geom = dCreateSphere( PhysicsMgr::GetInstance().GetSpace(), 35 ); //CRASHES 
HERE
	dGeomSetBody( geom, body );
	SetSpace( PhysicsMgr::GetInstance().GetSpace() );
}

this crashes saying bad argument.

if i comment out these lines:
	geom = dCreateSphere( PhysicsMgr::GetInstance().GetSpace(), 35 ); //CRASHES 
HERE
	dGeomSetBody( geom, body );

it works okay, so GetSpace() seems to be working fine :-/

any ideas as to what the problem is?
-------------------------------
Fabian "SupaGu" Mathews

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail



More information about the ODE mailing list