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:22 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-01-23 09:56:22 +0400
commit27601aaf017263bf356dce37a4b90a764a819ee7 (patch)
tree8fb82ff4a5681a93a77883603786d730da13b4c4 /source/blender/blenloader
parent5c85deb28570a911e825af5923a7939ca5781ee7 (diff)
rigidbody: Add DNA/RNA/BKE infrastructure for the rigid body sim
This is just the basic structure, the simulation isn't hooked up yet. Scenes get a pointer to a rigid body world that holds rigid body objects. Objects get a pointer to a rigdid body object. Both rigid body world and objects aren't used directly in the simulation and only hold information to create the actual physics objects. Physics objects are created when rigid body objects are validated. In order to keep blender and bullet objects in sync care has to be taken to either call appropriate set functions or flag objects for validation. Part of GSoC 2010 and 2012. Authors: Joshua Leung (aligorith), Sergej Reich (sergof)
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c38
-rw-r--r--source/blender/blenloader/intern/writefile.c13
2 files changed, 49 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index d042e43f9ca..95fa4018392 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -81,6 +81,7 @@
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_property_types.h"
+#include "DNA_rigidbody_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
@@ -4785,7 +4786,18 @@ static void direct_link_object(FileData *fd, Object *ob)
}
ob->bsoft = newdataadr(fd, ob->bsoft);
ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
-
+
+ ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object);
+ if (ob->rigidbody_object) {
+ RigidBodyOb *rbo = ob->rigidbody_object;
+
+ /* must nullify the references to physics sim objects, since they no-longer exist
+ * (and will need to be recalculated)
+ */
+ rbo->physics_object = NULL;
+ rbo->physics_shape = NULL;
+ }
+
link_list(fd, &ob->particlesystem);
direct_link_particlesystems(fd, &ob->particlesystem);
@@ -5003,6 +5015,14 @@ static void lib_link_scene(FileData *fd, Main *main)
BKE_sequencer_update_muting(sce->ed);
BKE_sequencer_update_sound_bounds_all(sce);
+
+ /* rigidbody world relies on it's linked groups */
+ if (sce->rigidbody_world) {
+ RigidBodyWorld *rbw = sce->rigidbody_world;
+ if (rbw->group)
+ rbw->group = newlibadr(fd, sce->id.lib, rbw->group);
+ }
+
if (sce->nodetree) {
lib_link_ntree(fd, &sce->id, sce->nodetree);
composite_patch(sce->nodetree, sce);
@@ -5079,6 +5099,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
Editing *ed;
Sequence *seq;
MetaStack *ms;
+ RigidBodyWorld *rbw;
sce->theDag = NULL;
sce->dagisvalid = 0;
@@ -5265,6 +5286,17 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
direct_link_view_settings(fd, &sce->view_settings);
+
+ sce->rigidbody_world = newdataadr(fd, sce->rigidbody_world);
+ rbw = sce->rigidbody_world;
+ if (rbw) {
+ /* must nullify the reference to physics sim object, since it no-longer exist
+ * (and will need to be recalculated)
+ */
+ rbw->physics_world = NULL;
+ rbw->objects = NULL;
+ rbw->numbodies = 0;
+ }
}
/* ************ READ WM ***************** */
@@ -9680,6 +9712,10 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
}
SEQ_END
}
+
+ if (sce->rigidbody_world) {
+ expand_doit(fd, mainvar, sce->rigidbody_world->group);
+ }
#ifdef DURIAN_CAMERA_SWITCH
{
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index ef0c5b0e6bd..a52e4e28981 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -118,6 +118,7 @@
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_property_types.h"
+#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
@@ -1487,6 +1488,11 @@ static void write_objects(WriteData *wd, ListBase *idbase)
}
writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
+ if (ob->rigidbody_object) {
+ // TODO: if any extra data is added to handle duplis, will need separate function then
+ writestruct(wd, DATA, "RigidBodyOb", 1, ob->rigidbody_object);
+ }
+
write_particlesystems(wd, &ob->particlesystem);
write_modifiers(wd, &ob->modifiers);
}
@@ -2296,7 +2302,12 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
}
write_view_settings(wd, &sce->view_settings);
-
+
+ /* writing RigidBodyWorld data to the blend file */
+ if (sce->rigidbody_world) {
+ writestruct(wd, DATA, "RigidBodyWorld", 1, sce->rigidbody_world);
+ }
+
sce= sce->id.next;
}
/* flush helps the compression for undo-save */