Hi all, I'm trying to lock a previously dynamic object in place. I still want other objects to collide with this object, but I don't want this object to move at all. I can't figure out of how to accomplish this. Anyone got any ideas?
The objects I'm trying to lock in place were previously created like this
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, colShape, localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
//add the body to the dynamics world.
m_dynamicsWorld->addRigidBody(body);
Locking a dynamic object in place.
-
- Posts: 39
- Joined: Sat May 02, 2009 9:38 am
Re: Locking a dynamic object in place.
Maybe
body->setMassProps(0, btVector3(0,0,0));
It should make the body have infinite mass (in other words joined with the static world).
body->setMassProps(0, btVector3(0,0,0));
It should make the body have infinite mass (in other words joined with the static world).
-
- Posts: 14
- Joined: Mon Feb 04, 2008 5:23 pm
Re: Locking a dynamic object in place.
Thanks frica, that sort of works. What happens now is the object does not move. Other objects hitting this object seem to get a bit of a "kick" though.
Here's exactly what I'm doing. I have a static terrain. I drop a cube onto it. When that cube goes to ISLAND_SLEEPING, I body->setMassProps(0, btVector3(0,0,0)); I then spawn another dropping cube. The new cube if it's coming to rest against the old cube can get a bit of an impulse when it looks like should be stopping. Anyone got any suggestions?
Here's exactly what I'm doing. I have a static terrain. I drop a cube onto it. When that cube goes to ISLAND_SLEEPING, I body->setMassProps(0, btVector3(0,0,0)); I then spawn another dropping cube. The new cube if it's coming to rest against the old cube can get a bit of an impulse when it looks like should be stopping. Anyone got any suggestions?
-
- Posts: 14
- Joined: Mon Feb 04, 2008 5:23 pm
Re: Locking a dynamic object in place.
I've made a very small (388k/14 second) video of the problem. Please ignore the shading errors. Watch the 4th cube at around the 10-11 seconds mark. Ther's energy being injected into the simulation somehow :/
https://www.cs.tcd.ie/~fowlerc/cubes.avi
https://www.cs.tcd.ie/~fowlerc/cubes.avi
-
- Posts: 10
- Joined: Wed Jul 29, 2009 4:04 am
- Location: Seoul, Korea
Re: Locking a dynamic object in place.
Hi,
I assume that just setting mass props to zero would not suffice because velocities (lin & ang) when object was dynamic are preserved forever and affect future collision responses.
To be certain, check your cube's lin & ang velocity when it's locked.
If it is so, try this (extending frca's suggestion):
Thanks
I assume that just setting mass props to zero would not suffice because velocities (lin & ang) when object was dynamic are preserved forever and affect future collision responses.
To be certain, check your cube's lin & ang velocity when it's locked.
If it is so, try this (extending frca's suggestion):
Code: Select all
body->setMassProps(0, btVector3(0,0,0));
body->setLinearVelocity(btVector3(0,0,0));
body->setAngularVelocity(btVector3(0,0,0);
-
- Posts: 141
- Joined: Mon Jul 02, 2007 5:12 pm
Re: Locking a dynamic object in place.
What's worked for me in the past is removing the body before changing anything, then adding it afterwards.
- Alex
Code: Select all
_pSimulationWorld->removeRigidBody(obj->GetBody());
obj->GetBody()->setMassProps(0, btVector3(0,0,0));
_pSimulationWorld->addRigidBody(obj->GetBody());
-
- Posts: 14
- Joined: Mon Feb 04, 2008 5:23 pm
Re: Locking a dynamic object in place.
Ellon wrote:Hi,
I assume that just setting mass props to zero would not suffice because velocities (lin & ang) when object was dynamic are preserved forever and affect future collision responses.
To be certain, check your cube's lin & ang velocity when it's locked.
If it is so, try this (extending frca's suggestion):
ThanksCode: Select all
body->setMassProps(0, btVector3(0,0,0)); body->setLinearVelocity(btVector3(0,0,0)); body->setAngularVelocity(btVector3(0,0,0);
Thanks Elon, but that doesn't seem to make a difference
My problem is that I (currently) need to keep the objects in the physics engine in the same order as the objects in the rest of the engine. I might be able to work around that though. I'll try engineering this up as a solution.AlexSilverman wrote:What's worked for me in the past is removing the body before changing anything, then adding it afterwards.- AlexCode: Select all
_pSimulationWorld->removeRigidBody(obj->GetBody()); obj->GetBody()->setMassProps(0, btVector3(0,0,0)); _pSimulationWorld->addRigidBody(obj->GetBody());
-
- Posts: 14
- Joined: Mon Feb 04, 2008 5:23 pm
Re: Locking a dynamic object in place.
Drat :/ Remove and adding does not work. Argghh.
-
- Posts: 4
- Joined: Sat Jul 25, 2009 6:06 pm
Re: Locking a dynamic object in place.
it more recent versions of bullet have a stronger dampening value, in Blender3D when the rotation and translation dampening are set to 1.0, the object wont move.
-
- Posts: 10
- Joined: Wed Jul 29, 2009 4:04 am
- Location: Seoul, Korea
Re: Locking a dynamic object in place.
What I was missing is that I should call 'body->updateInertiaTensor()' after changing body's mass props.
In fact, I've figured it out today.. Sorry to bump old thread.
In fact, I've figured it out today.. Sorry to bump old thread.
-
- Posts: 14
- Joined: Mon Feb 04, 2008 5:23 pm
Re: Locking a dynamic object in place.
Excellent, I was just coming back to this today! I'll give it a whirl.