RigidBody with associated ConvexHull will not respond to physics

105 views
Skip to first unread message

Tassos Stamadianos

unread,
Jan 14, 2014, 11:58:57 PM1/14/14
to urh...@googlegroups.com
After creating a rigid body and attaching it to a node, I create a CollisionShape and set it to ConvexHull. I provide the necessary .mdl, and save the node. After importing into my game, the forces I enact on the body have no effect. I should also say that not all the info is exported into the XML -- values I haven't touched are not included, which makes sense since they are default values. Am I doing something incorrect?

Chris Friesen

unread,
Jan 15, 2014, 12:24:20 AM1/15/14
to urh...@googlegroups.com
I just made a box, did the collision shape with a triangle mesh set to the box, set a mass and it fell through the floor.  I am feeling kind of sheepish.

Tassos Stamadianos

unread,
Jan 15, 2014, 2:37:56 AM1/15/14
to urh...@googlegroups.com
I should say that using other CollisionShapes lead to expected results.

Lasse Öörni

unread,
Jan 15, 2014, 2:57:52 AM1/15/14
to
A moving TriangleMesh will not collide properly (this is a limitation of Bullet library.) ConvexHull should. I tested briefly with the Ninja model as convex hull, that worked.

It would be good if you can post minimal files which reproduce the issue (scene xml + model). Otherwise it's hard to say what's going wrong.

Tassos Stamadianos

unread,
Jan 15, 2014, 2:58:14 AM1/15/14
to urh...@googlegroups.com
I have a pretty simple level XML attached. The CollisionShape code is at like 96. Is it possible that it can't calculate a center of gravity?

On Wednesday, January 15, 2014 2:50:06 AM UTC-5, Lasse Öörni wrote:
A moving TriangleMesh will not collide properly. ConvexHull should. I tested briefly with the Ninja model as convex hull, that worked.
TheLevelLayout.xml

Tassos Stamadianos

unread,
Jan 15, 2014, 3:03:11 AM1/15/14
to urh...@googlegroups.com
Oh the MDL is attached too.
A10Warthog.mdl

Lasse Öörni

unread,
Jan 15, 2014, 3:08:09 AM1/15/14
to
I need also the .mdl file that is used as a convex hull to be able to test the case.

If you're unconfortable sharing it over the group you can send it to loo...@gmail.com.

(edit: there doesn't seem to be any ConvexHull collision shapes in the scene, only a Sphere shape that is referring to a model)

Lasse Öörni

unread,
Jan 15, 2014, 3:18:06 AM1/15/14
to urh...@googlegroups.com
The airplane in the scene is using "Sphere" collision shape, which is just a small sphere in its origin. If I set it to ConvexHull in the editor and test creating a large plane with box collision the plane applies gravity & collides OK against plane.

Tassos Stamadianos

unread,
Jan 15, 2014, 3:19:42 AM1/15/14
to urh...@googlegroups.com
Sorry, I sent you the file I had edited just to get something that would respond to physics. When I change the collision shape to ConvexHull, it responds normally to ApplyForce and gravity, but will not respond to ApplyTorque.

Lasse Öörni

unread,
Jan 15, 2014, 3:29:51 AM1/15/14
to urh...@googlegroups.com
Ok, now we know much better what the issue is. There are two possibilities:
- We don't setup the inertia for a rigid body with convex shape correctly
- It's a bug in bullet

Tassos Stamadianos

unread,
Jan 15, 2014, 3:31:29 AM1/15/14
to urh...@googlegroups.com
It may be specific to how it loads it in from the editor. I haven't tried manually doing it in script, I'll give that a shot.

Tassos Stamadianos

unread,
Jan 15, 2014, 3:54:48 AM1/15/14
to urh...@googlegroups.com
Alright, I did it manually in script and it worked fine. I guess there's a bug in the loading code.

Lasse Öörni

unread,
Jan 15, 2014, 10:02:43 AM1/15/14
to
I modified the SceneReplication sample to steer the airplane with convex hull around instead of the sphere (it uses ApplyTorque()) but didn't spot a difference in behavior between creating the components in code, or loading them from an XML node prefab saved in the editor.

Both when setting the shape in code or loading it via attributes the CollisionShape should call

        UpdateShape();
        NotifyRigidBody();

NotifyRigidBody() calls UpdateMass() on the RigidBody, which is the important part which recalculates the body's inertia. Can you verify whether this is called when the rigidbody appears to be misbehaving? Also, when you create the object in script code and it works, are these the only RigidBody properties you are setting?

rigidBody.mass = 750;
rigidBody.angularRestThreshold = 0.1;


Lasse Öörni

unread,
Jan 15, 2014, 11:54:39 AM1/15/14
to urh...@googlegroups.com
Two more questions, which may be relevant to the case: which OS are you on, and is it a 32bit or 64bit build of Urho?

Tassos Stamadianos

unread,
Jan 15, 2014, 12:23:07 PM1/15/14
to urh...@googlegroups.com
I'm on a 64-bit version of Win7, but I'm building a 32-bit Urho. Furthermore, only those two values are exported by the editor. I'll have a chance to test for that function call later today.

Tassos Stamadianos

unread,
Jan 16, 2014, 4:17:42 PM1/16/14
to urh...@googlegroups.com
So does it work for you in a simple example? I noticed I have to add a lot more force to move the object. This is probably due to it calculating the COM properly as opposed to the simple formula necessary for a box COM.

Tassos Stamadianos

unread,
Jan 16, 2014, 4:29:12 PM1/16/14
to urh...@googlegroups.com
Forgot to post:

I imported it into a simple example. Haven't tried it in my game yet.

Tassos Stamadianos

unread,
Jan 16, 2014, 6:31:02 PM1/16/14
to urh...@googlegroups.com
Alright, I attached my game to a debugger and it did in fact run through those lines.

Then, just for curiosity's sake, I upped the torque I was applying to the jet. The jet then moved.

I guess you just have to apply more force to certain objects with a weird COM.

Sorry for the message spam! :P

Lasse Öörni

unread,
Jan 17, 2014, 4:11:17 AM1/17/14
to urh...@googlegroups.com
Yes, I have to apply quite huge torque to the object.

In my experiments the convex hull object behaved the same, and moved the same (once I started using huge torque values) independent of whether it was created in code or loaded from xml, of course with the exact same parameters.

If you can get it to somehow behave differently between code / xml loading, then there's a bug, but I couldn't get that to happen.

Reply all
Reply to author
Forward
0 new messages