[Bf-blender-cvs] [839149e] particles_refactor: Fix for RigidBodyWorld reading: initialize empty body mempool when reading blend files, this is not actually stored.
Lukas Tönne
noreply at git.blender.org
Tue Apr 22 12:06:47 CEST 2014
Commit: 839149ea902851b607dc5e376c77d718a53c0df8
Author: Lukas Tönne
Date: Wed Jan 1 15:59:47 2014 +0100
https://developer.blender.org/rB839149ea902851b607dc5e376c77d718a53c0df8
Fix for RigidBodyWorld reading: initialize empty body mempool when
reading blend files, this is not actually stored.
===================================================================
M source/blender/blenkernel/BKE_rigidbody.h
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index f5bc55b..53d03c1 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -62,6 +62,9 @@ struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene);
struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type);
struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type);
+/* initialize mempools, for readfile */
+void BKE_rigidbody_world_init_mempool(struct RigidBodyWorld *rbw);
+
/* copy */
struct RigidBodyWorld *BKE_rigidbody_world_copy(struct RigidBodyWorld *rbw);
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index eeebd7d..cea8387 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -866,8 +866,7 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
/* create a new sim world */
rbw = MEM_callocN(sizeof(RigidBodyWorld), "RigidBodyWorld");
-
- rbw->body_pool = BLI_mempool_create(rbRigidBodySize, 512, 512, BLI_MEMPOOL_ALLOW_ITER);
+ BKE_rigidbody_world_init_mempool(rbw);
/* set default settings */
rbw->effector_weights = BKE_add_effector_weights(NULL);
@@ -886,6 +885,11 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
return rbw;
}
+void BKE_rigidbody_world_init_mempool(RigidBodyWorld *rbw)
+{
+ rbw->body_pool = BLI_mempool_create(rbRigidBodySize, 512, 512, BLI_MEMPOOL_ALLOW_ITER);
+}
+
RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw)
{
RigidBodyWorld *rbwn = MEM_dupallocN(rbw);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5684430..c783d87 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -146,6 +146,7 @@
#include "BKE_pointcache.h"
#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_report.h"
+#include "BKE_rigidbody.h"
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_screen.h"
@@ -5249,6 +5250,8 @@ static void lib_link_scene(FileData *fd, Main *main)
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);
+ /* create empty mempool */
+ BKE_rigidbody_world_init_mempool(rbw);
}
if (sce->nodetree) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index f128b3b..48e49c0 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2380,9 +2380,10 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
/* writing RigidBodyWorld data to the blend file */
if (sce->rigidbody_world) {
- writestruct(wd, DATA, "RigidBodyWorld", 1, sce->rigidbody_world);
- writestruct(wd, DATA, "EffectorWeights", 1, sce->rigidbody_world->effector_weights);
- write_pointcaches(wd, &(sce->rigidbody_world->ptcaches));
+ RigidBodyWorld *rbw = sce->rigidbody_world;
+ writestruct(wd, DATA, "RigidBodyWorld", 1, rbw);
+ writestruct(wd, DATA, "EffectorWeights", 1, rbw->effector_weights);
+ write_pointcaches(wd, &rbw->ptcaches);
}
sce= sce->id.next;
More information about the Bf-blender-cvs
mailing list