diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-02-25 19:51:53 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-02-25 19:51:53 +0400 |
commit | be8bda5abc59324e8e4c15edbbf3c4f72926dfbd (patch) | |
tree | d6f8d324185e451463b39a10ae98f887a31621b5 /source/blender/blenkernel | |
parent | 06264b63df6eb4b863a06b3ac3d1707592228fa2 (diff) |
rigidbody: Don't embed collision margin if object has no volume
While it's not a good idea to create convex hull shapes from objects
with no volume, this makes them behave a little nicer.
Fixes [#34410] Planes with Rigid Body always keep distance to colliding objects
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 4c6bae122cd..d3a457ac2ed 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -347,6 +347,7 @@ void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild) float capsule_height; float hull_margin = 0.0f; bool can_embed = true; + bool has_volume; /* sanity check */ if (rbo == NULL) @@ -404,11 +405,13 @@ void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild) case RB_SHAPE_CONVEXH: /* try to emged collision margin */ - if (!(rbo->flag & RBO_FLAG_USE_MARGIN)) + has_volume = (MIN3(size[0], size[1], size[2]) > 0.0f); + + if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && has_volume) hull_margin = 0.04f; new_shape = rigidbody_get_shape_convexhull_from_mesh(ob, hull_margin, &can_embed); if (!(rbo->flag & RBO_FLAG_USE_MARGIN)) - rbo->margin = (can_embed) ? 0.04f : 0.0f; /* RB_TODO ideally we shouldn't directly change the margin here */ + rbo->margin = (can_embed && has_volume) ? 0.04f : 0.0f; /* RB_TODO ideally we shouldn't directly change the margin here */ break; case RB_SHAPE_TRIMESH: new_shape = rigidbody_get_shape_trimesh_from_mesh(ob); |