btDiscreteDynamicsWorld::addRigidBody question
-
- Posts: 17
- Joined: Thu Nov 09, 2006 8:50 pm
- Location: Middletown, PA
btDiscreteDynamicsWorld::addRigidBody question
When I run btDiscreteDynamicsWorld::addRigidBody in my code I get a segmentation fault, I'm creating a rigid body from a triangle mesh loaded from a collada model just to try convex simulation, but when I try to add it to my dynamics world it seg faults, and I have no idea why. The pointer is fine. Any suggestions, if needed I can post snippets. Also I have a code repository which could be easily browsed by links
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
-
- Posts: 17
- Joined: Thu Nov 09, 2006 8:50 pm
- Location: Middletown, PA
Whoops
I suppose this implied that I was following the collada physics demo, this is not the case. I have been loading models with FCollada for a while and am looking to implement the physics, I at first was trying to load in a triangle mesh and create the btRigidBody from that. But I quickly learned that simulating dynamic triangle meshes is apparently not a common thing and that games do a good job at faking it by combining multiple common shapes. But that doesn't explain why it crashed when I tried to add a rigid body. I didn't set up the collision functions or anything though, I'm not sure if this would cause a crash, although it's not good to assume that there's a default.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
A complete callstack at the time of the crash (in debug mode) would be helpful.
What kind of collision shape are you exactly using (snippet of how you initialize this, all data passed in etc).
This is the first message of this kind, so it is likely an application issue,
Thanks for the feedback,
Erwin
What kind of collision shape are you exactly using (snippet of how you initialize this, all data passed in etc).
This is the first message of this kind, so it is likely an application issue,
Thanks for the feedback,
Erwin
-
- Posts: 17
- Joined: Thu Nov 09, 2006 8:50 pm
- Location: Middletown, PA
Now I'm have some problems
I finally have it not crashing by not using tri meshes, which I'm pretty sure was a problem on my end with invalid pointers. But now I'm just trying to simulate a sphere, and I've only added one rigid body and am using a discrete world, but I didn't do any setting up the collision callback functions or anything and I'm passing the stepSimulation frame time in seconds but nothing seems to be happening. Here is the code I'm using to draw.
Basically I only have one rigid body and I'm just trying to pull out it's new transform matrix, MultMatrix is glMultMatrix, and DrawSphere is glutSolidSphere, I have a gravity of (0, -10.0, 0). If further initialization is requires besides simply creating a dynamics world and stepping the simulation please let me know. All I want to do is have the sphere drop. From there I can get into more advanced things. Thanks again.
Code: Select all
// physics object for this model drawing
btDynamicsWorld *world = physics->GetWorldPtr();
btCollisionObject* colObj = world->getCollisionObjectArray()[0];
btRigidBody* body = btRigidBody::upcast(colObj);
float m[16];
if (body && body->getMotionState()){
btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
}else{
colObj->getWorldTransform().getOpenGLMatrix(m);
}
graphics.MultMatrix(m);
graphics.DrawSphere(1.0f, false);
-
- Posts: 17
- Joined: Thu Nov 09, 2006 8:50 pm
- Location: Middletown, PA
nm, I wasn't setting the gravity per object
nm, I wasn't setting the gravity per object