[Bf-blender-cvs] [e933095] particles_refactor: Added a mempool to RigidBodyWorld as a memory manager for bodies.

Lukas Tönne noreply at git.blender.org
Tue Apr 22 12:06:30 CEST 2014


Commit: e93309556bf27fe27c8d16b16d13f6e71252ea45
Author: Lukas Tönne
Date:   Tue Dec 31 09:32:58 2013 +0100
https://developer.blender.org/rBe93309556bf27fe27c8d16b16d13f6e71252ea45

Added a mempool to RigidBodyWorld as a memory manager for bodies.

Conflicts:
	intern/rigidbody/rb_bullet_api.cpp

===================================================================

M	intern/rigidbody/RBI_api.h
M	intern/rigidbody/rb_bullet_api.cpp
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/makesdna/DNA_rigidbody_types.h

===================================================================

diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 688ca91..f1c2c02 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -37,6 +37,8 @@
 extern "C" {
 #endif
 
+#include <string.h>
+
 /* API Notes:
  * Currently, this API is optimised for Bullet RigidBodies, and doesn't
  * take into account other Physics Engines. Some tweaking may be necessary
@@ -56,6 +58,7 @@ typedef struct rbDynamicsWorld rbDynamicsWorld;
 
 /* Rigid Body */
 typedef struct rbRigidBody rbRigidBody;
+extern size_t rbRigidBodySize;
 
 /* Collision Shape */
 typedef struct rbCollisionShape rbCollisionShape;
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index 6d39e32..7d5654e 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -81,11 +81,14 @@ struct rbDynamicsWorld {
 	btConstraintSolver *constraintSolver;
 	btOverlapFilterCallback *filterCallback;
 };
+
 struct rbRigidBody {
 	btRigidBody *body;
 	int col_groups;
 };
 
+size_t rbRigidBodySize = sizeof(rbRigidBody);
+
 struct rbVert {
 	float x, y, z;
 };
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 0e17166..761b727 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -41,6 +41,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
+#include "BLI_mempool.h"
 
 #ifdef WITH_BULLET
 #  include "RBI_api.h"
@@ -121,6 +122,8 @@ void BKE_rigidbody_free_world(RigidBodyWorld *rbw)
 	if (rbw->effector_weights)
 		MEM_freeN(rbw->effector_weights);
 
+	BLI_mempool_destroy(rbw->body_pool);
+
 	/* free rigidbody world itself */
 	MEM_freeN(rbw);
 }
@@ -735,6 +738,8 @@ 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);
+
 	/* set default settings */
 	rbw->effector_weights = BKE_add_effector_weights(NULL);
 
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 5d76ffe..e59012a 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -55,6 +55,8 @@ typedef struct RigidBodyWorld {
 	
 	struct Group *constraints;	/* Group containing objects to use for Rigid Body Constraints*/
 
+	struct BLI_mempool *body_pool;
+
 	int pad;
 	float ltime;				/* last frame world was evaluated for (internal) */




More information about the Bf-blender-cvs mailing list