[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60313] branches/soc-2013-rigid_body_sim/ source/blender/blenkernel: rigidbody: Code cleanup
Sergej Reich
sergej.reich at googlemail.com
Sun Sep 22 15:49:59 CEST 2013
Revision: 60313
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60313
Author: sergof
Date: 2013-09-22 13:49:59 +0000 (Sun, 22 Sep 2013)
Log Message:
-----------
rigidbody: Code cleanup
Make functions private that are only used internally.
Also remove a nested if statement.
Modified Paths:
--------------
branches/soc-2013-rigid_body_sim/source/blender/blenkernel/BKE_rigidbody.h
branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c
Modified: branches/soc-2013-rigid_body_sim/source/blender/blenkernel/BKE_rigidbody.h
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/blenkernel/BKE_rigidbody.h 2013-09-22 13:49:57 UTC (rev 60312)
+++ branches/soc-2013-rigid_body_sim/source/blender/blenkernel/BKE_rigidbody.h 2013-09-22 13:49:59 UTC (rev 60313)
@@ -68,9 +68,6 @@
/* 'validate' (i.e. make new or replace old) Physics-Engine objects */
void BKE_rigidbody_validate_sim_world(struct Scene *scene, struct RigidBodyWorld *rbw, bool rebuild);
-void BKE_rigidbody_validate_sim_object(struct RigidBodyWorld *rbw, struct Object *ob, bool rebuild);
-void BKE_rigidbody_validate_sim_shape(struct Object *ob, bool rebuild);
-void BKE_rigidbody_validate_sim_constraint(struct RigidBodyWorld *rbw, struct Object *ob, bool rebuild);
/* -------------- */
/* Utilities */
Modified: branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c 2013-09-22 13:49:57 UTC (rev 60312)
+++ branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c 2013-09-22 13:49:59 UTC (rev 60313)
@@ -511,7 +511,7 @@
/* Create new physics sim collision shape for object and store it,
* or remove the existing one first and replace...
*/
-void BKE_rigidbody_validate_sim_shape(Object *ob, bool rebuild)
+static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
{
RigidBodyOb *rbo = ob->rigidbody_object;
rbCollisionShape *new_shape = NULL;
@@ -614,7 +614,7 @@
}
else { /* otherwise fall back to box shape */
rbo->shape = RB_SHAPE_BOX;
- BKE_rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(ob, true);
}
}
@@ -623,7 +623,7 @@
/* Create physics sim representation of object given RigidBody settings
* < rebuild: even if an instance already exists, replace it
*/
-void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool rebuild)
+static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool rebuild)
{
RigidBodyOb *rbo = (ob) ? ob->rigidbody_object : NULL;
float loc[3];
@@ -638,11 +638,10 @@
/* make sure collision shape exists */
/* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects, but it's needed for constraints to update correctly */
if (rbo->physics_shape == NULL || rebuild)
- BKE_rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(ob, true);
- if (rbo->physics_object) {
- if (rebuild == false)
- RB_dworld_remove_body(rbw->physics_world, rbo->physics_object);
+ if (rbo->physics_object && rebuild == false) {
+ RB_dworld_remove_body(rbw->physics_world, rbo->physics_object);
}
if (!rbo->physics_object || rebuild) {
/* remove rigid body if it already exists before creating a new one */
@@ -693,7 +692,7 @@
/* Create physics sim representation of constraint given rigid body constraint settings
* < rebuild: even if an instance already exists, replace it
*/
-void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, bool rebuild)
+static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, bool rebuild)
{
RigidBodyCon *rbc = (ob) ? ob->rigidbody_constraint : NULL;
float loc[3];
@@ -1313,7 +1312,7 @@
* - assume object to be active? That is the default for newly added settings...
*/
ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, RBO_TYPE_ACTIVE);
- BKE_rigidbody_validate_sim_object(rbw, ob, true);
+ rigidbody_validate_sim_object(rbw, ob, true);
rbo = ob->rigidbody_object;
}
@@ -1322,15 +1321,15 @@
/* refresh object... */
if (rebuild) {
/* World has been rebuilt so rebuild object */
- BKE_rigidbody_validate_sim_object(rbw, ob, true);
+ rigidbody_validate_sim_object(rbw, ob, true);
}
else if (rbo->flag & RBO_FLAG_NEEDS_VALIDATE) {
- BKE_rigidbody_validate_sim_object(rbw, ob, false);
+ rigidbody_validate_sim_object(rbw, ob, false);
}
/* refresh shape... */
if (rbo->flag & RBO_FLAG_NEEDS_RESHAPE) {
/* mesh/shape data changed, so force shape refresh */
- BKE_rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(ob, true);
/* now tell RB sim about it */
// XXX: we assume that this can only get applied for active/passive shapes that will be included as rigidbodies
RB_body_set_collision_shape(rbo->physics_object, rbo->physics_shape);
@@ -1363,7 +1362,7 @@
* constraint settings (perhaps it was added manually), add!
*/
ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, RBC_TYPE_FIXED);
- BKE_rigidbody_validate_sim_constraint(rbw, ob, true);
+ rigidbody_validate_sim_constraint(rbw, ob, true);
rbc = ob->rigidbody_constraint;
}
@@ -1371,10 +1370,10 @@
/* perform simulation data updates as tagged */
if (rebuild) {
/* World has been rebuilt so rebuild constraint */
- BKE_rigidbody_validate_sim_constraint(rbw, ob, true);
+ rigidbody_validate_sim_constraint(rbw, ob, true);
}
else if (rbc->flag & RBC_FLAG_NEEDS_VALIDATE) {
- BKE_rigidbody_validate_sim_constraint(rbw, ob, false);
+ rigidbody_validate_sim_constraint(rbw, ob, false);
}
rbc->flag &= ~RBC_FLAG_NEEDS_VALIDATE;
}
More information about the Bf-blender-cvs
mailing list