[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59887] branches/soc-2013-rigid_body_sim/ source/blender/editors/space_view3d/drawobject.c: drawobject: Draw collision shapes when object has rigid body

Sergej Reich sergej.reich at googlemail.com
Fri Sep 6 19:58:47 CEST 2013


Revision: 59887
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59887
Author:   sergof
Date:     2013-09-06 17:58:47 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
drawobject: Draw collision shapes when object has rigid body

This uses the regular bounds drawing like the game engine for now, which
is not always accurate.
Will fix next.

Modified Paths:
--------------
    branches/soc-2013-rigid_body_sim/source/blender/editors/space_view3d/drawobject.c

Modified: branches/soc-2013-rigid_body_sim/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/editors/space_view3d/drawobject.c	2013-09-06 17:58:46 UTC (rev 59886)
+++ branches/soc-2013-rigid_body_sim/source/blender/editors/space_view3d/drawobject.c	2013-09-06 17:58:47 UTC (rev 59887)
@@ -6553,6 +6553,36 @@
 
 }
 
+static void draw_rigidbody_shape(Object *ob)
+{
+	BoundBox *bb = NULL;
+
+	if (ob->type == OB_MESH) {
+		bb = BKE_mesh_boundbox_get(ob);
+	}
+
+	if (bb == NULL)
+		return;
+
+	switch (ob->rigidbody_object->shape) {
+		case RB_SHAPE_BOX:
+			draw_box(bb->vec);
+			break;
+		case RB_SHAPE_SPHERE:
+			draw_bb_quadric(bb, OB_BOUND_SPHERE);
+			break;
+		case RB_SHAPE_CONE:
+			draw_bb_quadric(bb, OB_BOUND_CONE);
+			break;
+		case RB_SHAPE_CYLINDER:
+			draw_bb_quadric(bb, OB_BOUND_CYLINDER);
+			break;
+		case RB_SHAPE_CAPSULE:
+			draw_bb_quadric(bb, OB_BOUND_CAPSULE);
+			break;
+	}
+}
+
 /**
  * main object drawing function, draws in selection
  * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
@@ -7102,6 +7132,9 @@
 				setlinestyle(0);
 			}
 		}
+		else if (ob->rigidbody_object) {
+			draw_rigidbody_shape(ob);
+		}
 
 		/* draw extra: after normal draw because of makeDispList */
 		if (dtx && (G.f & G_RENDER_OGL) == 0) {




More information about the Bf-blender-cvs mailing list