From be8bda5abc59324e8e4c15edbbf3c4f72926dfbd Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Mon, 25 Feb 2013 15:51:53 +0000 Subject: 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 --- source/blender/blenkernel/intern/rigidbody.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/rigidbody.c') 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); -- cgit v1.2.3