[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54855] trunk/blender/source/blender/ blenkernel/intern/rigidbody.c: rigidbody: Don' t embed collision margin if object has no volume
Sergej Reich
sergej.reich at googlemail.com
Mon Feb 25 16:51:53 CET 2013
Revision: 54855
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54855
Author: sergof
Date: 2013-02-25 15:51:53 +0000 (Mon, 25 Feb 2013)
Log Message:
-----------
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
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/rigidbody.c
Modified: trunk/blender/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/rigidbody.c 2013-02-25 13:15:42 UTC (rev 54854)
+++ trunk/blender/source/blender/blenkernel/intern/rigidbody.c 2013-02-25 15:51:53 UTC (rev 54855)
@@ -347,6 +347,7 @@
float capsule_height;
float hull_margin = 0.0f;
bool can_embed = true;
+ bool has_volume;
/* sanity check */
if (rbo == NULL)
@@ -404,11 +405,13 @@
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);
More information about the Bf-blender-cvs
mailing list