[Bf-blender-cvs] [c448c0a67f0] blender2.8: RigidBody: Replaced 'if' with 'switch'
Sybren A. Stüvel
noreply at git.blender.org
Mon Jun 25 11:25:09 CEST 2018
Commit: c448c0a67f0b00aa9dca4d0d5b40868d608a7435
Author: Sybren A. Stüvel
Date: Mon Jun 25 11:24:55 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc448c0a67f0b00aa9dca4d0d5b40868d608a7435
RigidBody: Replaced 'if' with 'switch'
===================================================================
M source/blender/blenkernel/intern/rigidbody.c
===================================================================
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 1fcac5db97f..6d38b9b1188 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -238,20 +238,22 @@ RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int UNUSED(f
/* get the appropriate DerivedMesh based on rigid body mesh source */
static Mesh *rigidbody_get_mesh(Object *ob)
{
- /* TODO(Sybren): turn this into a switch statement */
- if (ob->rigidbody_object->mesh_source == RBO_MESH_DEFORM) {
- return ob->runtime.mesh_deform_eval;
- }
- else if (ob->rigidbody_object->mesh_source == RBO_MESH_FINAL) {
- return ob->runtime.mesh_eval;
- }
- else {
- /* This mesh may be used for computing looptris, which should be done
- * on the original; otherwise every time the CoW is recreated it will
- * have to be recomputed. */
- BLI_assert(ob->rigidbody_object->mesh_source == RBO_MESH_BASE);
- return DEG_get_original_object(ob)->data;
- }
+ switch(ob->rigidbody_object->mesh_source) {
+ case RBO_MESH_DEFORM:
+ return ob->runtime.mesh_deform_eval;
+ case RBO_MESH_FINAL:
+ return ob->runtime.mesh_eval;
+ case RBO_MESH_BASE:
+ /* This mesh may be used for computing looptris, which should be done
+ * on the original; otherwise every time the CoW is recreated it will
+ * have to be recomputed. */
+ BLI_assert(ob->rigidbody_object->mesh_source == RBO_MESH_BASE);
+ return DEG_get_original_object(ob)->data;
+ }
+
+ /* Just return something sensible so that at least Blender won't crash. */
+ BLI_assert(!"Unknown mesh source");
+ return ob->runtime.mesh_eval;
}
/* create collision shape of mesh - convex hull */
More information about the Bf-blender-cvs
mailing list