diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-06-25 12:24:55 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-06-25 12:24:55 +0300 |
commit | c448c0a67f0b00aa9dca4d0d5b40868d608a7435 (patch) | |
tree | d8bc8af025395f05a1969fb900f630142b036533 /source | |
parent | eb56ca3119f5c2a0d949c01982f793345a1e334d (diff) |
RigidBody: Replaced 'if' with 'switch'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 30 |
1 files changed, 16 insertions, 14 deletions
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 */ |