Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergej Reich <sergej.reich@googlemail.com>2013-02-25 19:51:53 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-02-25 19:51:53 +0400
commitbe8bda5abc59324e8e4c15edbbf3c4f72926dfbd (patch)
treed6f8d324185e451463b39a10ae98f887a31621b5 /source/blender/blenkernel/intern/rigidbody.c
parent06264b63df6eb4b863a06b3ac3d1707592228fa2 (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/intern/rigidbody.c')
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c7
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);