There is a way, but it is not yet exposed on the public interface. I will add it, but first I want to get finished with overhauling the scene graph synchronisation. About the normals, well, I don’t know a way to disable then, without modifying the Bullet source code. This does not mean that there is no way.
Hi ennOx,
Just tried to recompile my app using the last cvs version.
Here is what I get:
1>------ Build started: Project: jctut, Configuration: Release Win32 ------
1>Linking... (Intel C++ Environment)
1>ipo: warning #11021: unresolved ?parents_changed@BulletRigidBodyNode@@MAEXXZ
1> Referenced in ipo_49845obj.obj
1>ipo: warning #11021: unresolved ?set_disable_deactivation@BulletBodyNode@@QAEX_N0@Z
1> Referenced in ipo_49845obj.obj
something wrong ??? Are ‘parents_changed’ and ‘set_disable_deactivation’ accessible?
I checked in a few files, so yes, a few things have changed. I wanted to wait until the buildbots have compiled the new code and run a few tests, before anouncing the changes.
1.) set_disable_deactivation(true) has been renamed to set_deactivation_enabled(false). This has been done in order to harmonise the method names throughout the module. Please pay attention that you now have to pass a different boolean value (disable --> enable).
2.) parent_changed is no longer required, and thus has been removed. Anyway, the method has been protected, so you should not have been able to access it externally.
3.) I added asserts which catch empty convex hull shapes and empty triangle mesh shapes. “Empty” means zero vertices here.
4.) The debug node can now have a non-identity global or local transform. The global transform is applied to each vertex before rendering.
5.) I added a function to enable/disable the debug visualisation for individual collision objects (rigid body, soft body, ghost).
6.) The synchronisation between Panda3D scene graph and Bullet objects has been redesigned. Previously I have been working with PandaNode hooks (parent_changed, transform_changed) and Bullet interfaces (i.e. btTransformState) to sync P2B and B2P. Now I have iterations over all objects before and after stepping the simulation inside do_physics. Before advancing I synchronise P2B, and after the step I synchronise B2P.
I hope the new approch will provide better support for global transforms and scale. It should be possible now to changed the transform of the parent node of i.e. a BulletRigidBodyNode, and the transform change is detected when next advancing the simulation.
However, since synchronisation is a complex mechanism it might be that there are still a few bugs in the new approach.
Good,
Just tried it, and it happens that for some nodes the debug geometry is not showing up anymore.
This is the code I use to attach kinematic collision spheres to the hands and feet of my actor.
void attach_hit_sphere_to_node(NodePath node, int radius, char *name) {
PT(BulletSphereShape) shapeS = new BulletSphereShape(radius);
PT(BulletRigidBodyNode) hitRigidBody = new BulletRigidBodyNode(name);
NodePath hitNP = worldNP.attach_new_node(hitRigidBody);
hitRigidBody->set_kinematic(true); // KINEMATIC Node
hitRigidBody->set_mass(0);
hitRigidBody->add_shape(shapeS);
hitRigidBody->set_restitution(0.25); // 0 dur, 1.0 ressort
hitRigidBody->set_friction(0.2);
hitNP.set_collide_mask(BitMask32::all_on());
// hitRigidBody->set_disable_deactivation(true); // ** former code
hitRigidBody->set_deactivation_enabled(false); // ** new code
hitRigidBody->set_debug_enabled(true); // ** new code
mgr->attach_rigid_body(hitRigidBody);
hitNP.reparent_to(node);
}
Great, thank you! This is what I love F(L)OSS for!
Now, I’ve got the next one: There is a getTuning() in BulletVehicle, but no possibility to setTuning(BulletVehicleTuning). Is there something else planned or just a method missing?
They are not gone, but at global coordinates (0, 0, 0).
I have been cleaning up a bit too much. btMotionState.getWorldTransform is required for kinematic bodies. I added an implementation to the CVS HEAD. My apologies.
It works like this: The BulletVehicleTuning object is owned by the BulletVehicle. With “getTuning” you get a reference to the tuning object. You can use this reference to modify the tuning object. There is not need to set a tuning object yourself.
Hey, no problem we’re here to test!
You’re doing a superb job, many thanks.
Jean-Claude
Let me rephrase my question: why can’t I collide an object with no mass with an object which has mass and which is not in motion?
My case: trying to collide a sphere with cube which is on a plane (collisions do happen when for example the cube is falling.
Examples I can think of are bullets, explosions or wind effects.
I am not sure, but i think that you need to use this (depending on version you are using)
It is something about bullet deactivating object not in motion or something like that
Yes, that seems like it
Any ideas what it actually does internally?
It is an optimisation implemented in most physics engines. If a dynamic body moves less than a threshold for some time it will be deactivated, or put to “sleep”. This means the physics engine won’t compute forces etc. for this body from now on. And it won’t consider this body for collision detection with static bodies or other sleeping bodies. Moving dynamic bodies however can collide with sleeping objects, and if this happens they wake the sleeping body up again.
The API of a physics engine usually has methods to
- set the thresholds for deactivation
- put bodies to sleep and wake them up manually
- check the bodies activation state
From what you said it had to work even without it. I shoot a sphere (dynamic body) on the “sleeping” cube but they don’t collide. That is when the sphere has 0 mass, collision works when I set a mass on the sphere.
If the sphere has 0 mass then it is by definition static, so no collision.
If the sphere has mass > 0 then it is dynamic or kinematic, so collision.
Please tell me how you managed to “shoot” a static (mass = 0). A small sample would be great.
My code is a bit messy right now but I’ll try to clean it up and post it if needed. I’m actually moving a nodepath the bullet node is attached to with a task. The effect I’m aiming for is that of a leaf blower. This is my first experience with physics engines, so please tell me if you have a better idea.
Moving a body around by hand (that is, by explicitly setting the position/orientation) should be an exception when using physics engines. After all this is what you use a physics engine for - to have the engine move the bodies in a more-or-less realistic way for you. Usually you move a body only once, when loading the level/environment.
Most physics engines know three types of objects:
1.) Static: these object are assumed to be static, that is to stay in exactly the same place forever. They can not even be pushed around by forces. Static objects are used for ground, environment, obstacles etc. Static objects have mass=0, meaning that the mass is infinite large.
2.) Dynamic: these objects are intended to be moved around by the engine. The way to move them is by applyication of forces (e.g. gravity) or by “pushing” them with something else. Dynamic objects have mass > 0. You should not move them around yourself, except to “teleport” them somewhere else now and then.
3.) Kinematic: these objects are an exceptional case. They are not moved by the engine, meaning they are not affected by forces like gravity, and they can not be pushed around. The only way to move them is to set their position each frame. These objects are used for example in character controllers, which are difficult to implement using dynamic bodies.
Well I tried setKinematic(True) on my spheres and it did the trick
I have another question, I’m trying to make ragdolls and don’t know where to start. I have accessed all the bones in Panda and can transform them, but I don’t know what to do now (my first experience in this).
BTW, I don’t know if this has been mentioned before, but the debug node seems to lack behind the visible one a little (both have the same parent nodepath)
Working on it right now.
I start college back next week, and I thought it would be a good parting gift.
Nice.
Great news