Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergej Reich <sergej.reich@googlemail.com>2013-01-23 09:56:56 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-01-23 09:56:56 +0400
commit47c96081d00f2edfb1148d5d7c276489f03a8581 (patch)
tree51f1b93916d4042313dad5bc3907dcc6e0b33503 /source/blender/blenloader
parentcdc8ed24bfc771e8fcf729ce23db9ab060ade87d (diff)
rigidbody: Add rigid body constraints
Constraints connect two rigid bodies. Depending on which constraint is used different degrees of freedom are limited, e.g. a hinge constraint only allows the objects to rotate around a common axis. Constraints are implemented as individual objects and bahave similar to rigid bodies in terms of adding/removing/validating. The position and orientation of the constraint object is the pivot point of the constraint. Constraints have their own group in the rigid body world. To make connecting rigid bodies easier, there is a "Connect" operator that creates an empty objects with a rigid body constraint connecting the selected objects to active. Currently the following constraints are implemented: * Fixed * Point * Hinge * Slider * Piston * Generic Note: constraint limits aren't animatable yet).
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c20
-rw-r--r--source/blender/blenloader/intern/writefile.c5
2 files changed, 22 insertions, 3 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index edb033e80f8..070cb4676a1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4363,6 +4363,11 @@ static void lib_link_object(FileData *fd, Main *main)
lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
lib_link_modifiers(fd, ob);
+
+ if (ob->rigidbody_constraint) {
+ ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
+ ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2);
+ }
}
}
@@ -4797,7 +4802,10 @@ static void direct_link_object(FileData *fd, Object *ob)
rbo->physics_object = NULL;
rbo->physics_shape = NULL;
}
-
+ ob->rigidbody_constraint = newdataadr(fd, ob->rigidbody_constraint);
+ if (ob->rigidbody_constraint)
+ ob->rigidbody_constraint->physics_constraint = NULL;
+
link_list(fd, &ob->particlesystem);
direct_link_particlesystems(fd, &ob->particlesystem);
@@ -5021,6 +5029,8 @@ static void lib_link_scene(FileData *fd, Main *main)
RigidBodyWorld *rbw = sce->rigidbody_world;
if (rbw->group)
rbw->group = newlibadr(fd, sce->id.lib, rbw->group);
+ if (rbw->constraints)
+ rbw->constraints = newlibadr(fd, sce->id.lib, rbw->constraints);
if (rbw->effector_weights)
rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group);
}
@@ -9679,7 +9689,12 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
if (ob->pd && ob->pd->tex)
expand_doit(fd, mainvar, ob->pd->tex);
-
+
+ if (ob->rigidbody_constraint) {
+ expand_doit(fd, mainvar, ob->rigidbody_constraint->ob1);
+ expand_doit(fd, mainvar, ob->rigidbody_constraint->ob2);
+ }
+
}
static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
@@ -9728,6 +9743,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
if (sce->rigidbody_world) {
expand_doit(fd, mainvar, sce->rigidbody_world->group);
+ expand_doit(fd, mainvar, sce->rigidbody_world->constraints);
}
#ifdef DURIAN_CAMERA_SWITCH
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index ebd752c0118..e7a53670849 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1492,7 +1492,10 @@ static void write_objects(WriteData *wd, ListBase *idbase)
// TODO: if any extra data is added to handle duplis, will need separate function then
writestruct(wd, DATA, "RigidBodyOb", 1, ob->rigidbody_object);
}
-
+ if (ob->rigidbody_constraint) {
+ writestruct(wd, DATA, "RigidBodyCon", 1, ob->rigidbody_constraint);
+ }
+
write_particlesystems(wd, &ob->particlesystem);
write_modifiers(wd, &ob->modifiers);
}