Commit: 4b7f793d1ddac4e761d1555c84470247464a575f
Author: Lukas Tönne
Date:   Fri Aug 8 09:07:21 2014 +0200
Branches: testbuild
https://developer.blender.org/rB4b7f793d1ddac4e761d1555c84470247464a575f

Hair System test build.

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

M       build_files/cmake/macros.cmake
M       intern/rigidbody/CMakeLists.txt
M       intern/rigidbody/RBI_api.h
M       intern/rigidbody/rb_bullet_api.cpp
A       intern/rigidbody/rb_internal_types.h
M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/CMakeLists.txt
M       source/blender/SConscript
A       source/blender/blenkernel/BKE_hair.h
A       source/blender/blenkernel/BKE_mesh_sample.h
M       source/blender/blenkernel/BKE_object.h
M       source/blender/blenkernel/BKE_particle.h
M       source/blender/blenkernel/BKE_rigidbody.h
M       source/blender/blenkernel/CMakeLists.txt
M       source/blender/blenkernel/SConscript
A       source/blender/blenkernel/intern/hair.c
A       source/blender/blenkernel/intern/mesh_sample.c
M       source/blender/blenkernel/intern/object.c
M       source/blender/blenkernel/intern/particle.c
M       source/blender/blenkernel/intern/rigidbody.c
A       source/blender/blenkernel/intern/rigidbody_objects.c
M       source/blender/blenkernel/intern/scene.c
M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c
M       source/blender/editors/physics/CMakeLists.txt
M       source/blender/editors/physics/SConscript
A       source/blender/editors/physics/hair_ops.c
M       source/blender/editors/physics/physics_intern.h
M       source/blender/editors/physics/physics_ops.c
M       source/blender/editors/space_view3d/CMakeLists.txt
M       source/blender/editors/space_view3d/SConscript
A       source/blender/editors/space_view3d/drawhair.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/view3d_intern.h
M       source/blender/editors/transform/transform_conversions.c
A       source/blender/hair/CMakeLists.txt
A       source/blender/hair/HAIR_capi.cpp
A       source/blender/hair/HAIR_capi.h
A       source/blender/hair/SConscript
A       source/blender/hair/intern/HAIR_collision.cpp
A       source/blender/hair/intern/HAIR_curve.cpp
A       source/blender/hair/intern/HAIR_curve.h
A       source/blender/hair/intern/HAIR_debug.cpp
A       source/blender/hair/intern/HAIR_debug.h
A       source/blender/hair/intern/HAIR_math.cpp
A       source/blender/hair/intern/HAIR_math.h
A       source/blender/hair/intern/HAIR_memalloc.h
A       source/blender/hair/intern/HAIR_scene.cpp
A       source/blender/hair/intern/HAIR_scene.h
A       source/blender/hair/intern/HAIR_smoothing.cpp
A       source/blender/hair/intern/HAIR_smoothing.h
A       source/blender/hair/intern/HAIR_solver.cpp
A       source/blender/hair/intern/HAIR_solver.h
A       source/blender/hair/intern/HAIR_types.cpp
A       source/blender/hair/intern/HAIR_types.h
A       source/blender/makesdna/DNA_hair_types.h
M       source/blender/makesdna/DNA_meshdata_types.h
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesdna/DNA_rigidbody_types.h
M       source/blender/makesdna/intern/makesdna.c
M       source/blender/makesrna/intern/CMakeLists.txt
M       source/blender/makesrna/intern/makesrna.c
A       source/blender/makesrna/intern/rna_hair.c
M       source/blender/makesrna/intern/rna_internal.h
A       source/blender/makesrna/intern/rna_mesh_sample.c
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/makesrna/intern/rna_rigidbody.c
M       source/blender/modifiers/CMakeLists.txt
M       source/blender/modifiers/MOD_modifiertypes.h
M       source/blender/modifiers/SConscript
A       source/blender/modifiers/intern/MOD_hair.c
M       source/blender/modifiers/intern/MOD_util.c

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

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index adbba81..788a359 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -496,6 +496,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
                bf_freestyle
                bf_ikplugin
                bf_modifiers
+               bf_hair
                bf_bmesh
                bf_blenkernel
                bf_nodes
diff --git a/intern/rigidbody/CMakeLists.txt b/intern/rigidbody/CMakeLists.txt
index 5d84c2c..dae0e36 100644
--- a/intern/rigidbody/CMakeLists.txt
+++ b/intern/rigidbody/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC_SYS
 
 set(SRC
        rb_bullet_api.cpp
+       rb_internal_types.h
        
        RBI_api.h
 )
diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 688ca91..6078e1d 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,11 @@ typedef struct rbDynamicsWorld rbDynamicsWorld;
 
 /* Rigid Body */
 typedef struct rbRigidBody rbRigidBody;
+extern const size_t rbRigidBodySize;
+
+/* Ghost Object */
+typedef struct rbGhostObject rbGhostObject;
+extern const size_t rbGhostObjectSize;
 
 /* Collision Shape */
 typedef struct rbCollisionShape rbCollisionShape;
@@ -66,6 +73,9 @@ typedef struct rbMeshData rbMeshData;
 /* Constraint */
 typedef struct rbConstraint rbConstraint;
 
+/* Callback type for handling simulation ticks */
+typedef void (*rbSimulationTickCallback)(void *userdata, float timestep);
+
 /* ********************************** */
 /* Dynamics World Methods */
 
@@ -92,7 +102,8 @@ void RB_dworld_set_split_impulse(rbDynamicsWorld *world, int 
split_impulse);
 /* Simulation ----------------------- */
 
 /* Step the simulation by the desired amount (in seconds) with extra controls 
on substep sizes and maximum substeps */
-void RB_dworld_step_simulation(rbDynamicsWorld *world, float timeStep, int 
maxSubSteps, float timeSubStep);
+void RB_dworld_step_simulation(rbDynamicsWorld *world, float timeStep, int 
maxSubSteps, float timeSubStep,
+                               rbSimulationTickCallback cb, void *userdata, 
bool is_pre_tick);
 
 /* Export -------------------------- */
 
@@ -110,6 +121,10 @@ void RB_dworld_add_body(rbDynamicsWorld *world, 
rbRigidBody *body, int col_group
 /* Remove RigidBody from dynamics world */
 void RB_dworld_remove_body(rbDynamicsWorld *world, rbRigidBody *body);
 
+/* Ghost Object for detecting collisions */
+void RB_dworld_add_ghost(rbDynamicsWorld *world, rbGhostObject *object, int 
col_groups);
+void RB_dworld_remove_ghost(rbDynamicsWorld *world, rbGhostObject *object);
+
 /* Collision detection */
 
 void RB_world_convex_sweep_test(
@@ -120,10 +135,14 @@ void RB_world_convex_sweep_test(
 /* ............ */
 
 /* Create new RigidBody instance */
-rbRigidBody *RB_body_new(rbCollisionShape *shape, const float loc[3], const 
float rot[4]);
+void RB_body_init(rbRigidBody *object, rbCollisionShape *shape, const float 
loc[3], const float rot[4]);
 
 /* Delete the given RigidBody instance */
-void RB_body_delete(rbRigidBody *body);
+void RB_body_free(rbRigidBody *object);
+
+/* Ghost Object for detecting collisions */
+void RB_ghost_init(rbGhostObject *object, rbCollisionShape *shape, const float 
loc[3], const float rot[4]);
+void RB_ghost_free(rbGhostObject *object);
 
 /* Settings ------------------------- */
 
@@ -137,6 +156,11 @@ void RB_body_set_collision_shape(rbRigidBody *body, 
rbCollisionShape *shape);
 
 /* ............ */
 
+/* Generic flagging */
+extern int RB_body_get_flags(rbRigidBody *body);
+extern void RB_body_set_flag(rbRigidBody *body, int flag);
+extern void RB_body_clear_flag(rbRigidBody *body, int flag);
+
 /* Mass */
 float RB_body_get_mass(rbRigidBody *body);
 void RB_body_set_mass(rbRigidBody *body, float value);
@@ -210,6 +234,14 @@ void RB_body_get_orientation(rbRigidBody *body, float 
v_out[4]);
 
 void RB_body_apply_central_force(rbRigidBody *body, const float v_in[3]);
 
+/* ............ */
+
+int RB_ghost_get_flags(rbGhostObject *ghost);
+void RB_ghost_set_flag(rbGhostObject *ghost, int flag);
+void RB_ghost_clear_flag(rbGhostObject *ghost, int flag);
+
+void RB_ghost_set_loc_rot(rbGhostObject *ghost, const float loc[3], const 
float rot[4]);
+
 /* ********************************** */
 /* Collision Shape Methods */
 
diff --git a/intern/rigidbody/rb_bullet_api.cpp 
b/intern/rigidbody/rb_bullet_api.cpp
index 17bb381..07ffe20 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -72,19 +72,12 @@ subject to the following restrictions:
 #include "BulletCollision/Gimpact/btGImpactShape.h"
 #include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
 #include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
+#include "BulletCollision/CollisionDispatch/btGhostObject.h"
 
-struct rbDynamicsWorld {
-       btDiscreteDynamicsWorld *dynamicsWorld;
-       btDefaultCollisionConfiguration *collisionConfiguration;
-       btDispatcher *dispatcher;
-       btBroadphaseInterface *pairCache;
-       btConstraintSolver *constraintSolver;
-       btOverlapFilterCallback *filterCallback;
-};
-struct rbRigidBody {
-       btRigidBody *body;
-       int col_groups;
-};
+#include "rb_internal_types.h"
+
+const size_t rbRigidBodySize = sizeof(rbRigidBody);
+const size_t rbGhostObjectSize = sizeof(rbGhostObject);
 
 struct rbVert {
        float x, y, z;
@@ -110,13 +103,13 @@ struct rbFilterCallback : public btOverlapFilterCallback
 {
        virtual bool needBroadphaseCollision(btBroadphaseProxy *proxy0, 
btBroadphaseProxy *proxy1) const
        {
-               rbRigidBody *rb0 = (rbRigidBody *)((btRigidBody 
*)proxy0->m_clientObject)->getUserPointer();
-               rbRigidBody *rb1 = (rbRigidBody *)((btRigidBody 
*)proxy1->m_clientObject)->getUserPointer();
+               rbCollisionObject *ob0 = (rbCollisionObject 
*)((btCollisionObject *)proxy0->m_clientObject)->getUserPointer();
+               rbCollisionObject *ob1 = (rbCollisionObject 
*)((btCollisionObject *)proxy1->m_clientObject)->getUserPointer();
                
                bool collides;
                collides = (proxy0->m_collisionFilterGroup & 
proxy1->m_collisionFilterMask) != 0;
                collides = collides && (proxy1->m_collisionFilterGroup & 
proxy0->m_collisionFilterMask);
-               collides = collides && (rb0->col_groups & rb1->col_groups);
+               collides = collides && (ob0->col_groups & ob1->col_groups);
                
                return collides;
        }
@@ -155,6 +148,8 @@ rbDynamicsWorld *RB_dworld_new(const float gravity[3])
        
        world->filterCallback = new rbFilterCallback();
        
world->pairCache->getOverlappingPairCache()->setOverlapFilterCallback(world->filterCallback);
+       world->ghostPairCallback = new btGhostPairCallback();
+       
world->pairCache->getOverlappingPairCache()->setInternalGhostPairCallback(world->ghostPairCallback);
 
        /* constraint solving */
        world->constraintSolver = new btSequentialImpulseConstraintSolver();
@@ -179,6 +174,7 @@ void RB_dworld_delete(rbDynamicsWorld *world)
        delete world->dispatcher;
        delete world->collisionConfiguration;
        delete world->filterCallback;
+       delete world->ghostPairCallback;
        delete world;
 }
 
@@ -213,9 +209,32 @@ void RB_dworld_set_split_impulse(rbDynamicsWorld *world, 
int split_impulse)
 
 /* Simulation ----------------------- */
 
-void RB_dworld_step_simulation(rbDynamicsWorld *world, float timeStep, int 
maxSubSteps, float timeSubStep)
+struct rbSimulationTickData {
+       rbSimulationTickData(rbSimulationTickCallback cb, void *userdata) : 
cb(cb), userdata(userdata) {}
+       
+       rbSimulationTickCallback cb;
+       void *userdata;
+};
+
+/* wrapper for our own callback type */
+static void rb_simulation_step_cb(btDynamicsWorld *world, btScalar timestep)
+{
+       rbSimulationTickData *data = (rbSimulationTickData 
*)world->getWorldUserInfo();
+       data->cb(data->userdata, timestep);
+}
+
+void RB_dworld_step_simulation(rbDynamicsWorld *world, float timeStep, int 
maxSubSteps, float timeSubStep,
+                               rbSimulationTickCallback cb, void *userdata, 
bool is_pre_tick)
 {
+       /* set the tick callback */
+       rbSimulationTickData data(cb, userdata);
+       world->dynamicsWorld->setInternalTickCallback(rb_simulation_step_cb, 
(void *)(&data), is_pre_tick);
+       
+       /* perform actual time step */
        world->dynamicsWorld->stepSimulation(timeStep, maxSubSteps, 
timeSubStep);
+       
+       /* clean up */
+       world->dynamicsWorld->setWorldUserInfo(NULL);
 }
 
 /* Export -------------------------- */
@@ -252,7 +271,7 @@ void RB_dworld_export(rbDynamicsWorld *world, const char 
*filename)
 
 void RB_dworld_add_body(rbDynamicsWorld *world, rbRigidBody *object, int 
col_groups)
 {
-       btRigidBody *body = object->body;
+       btRigidBody *body = &object->body;
        object->col_groups = col_groups;
        
        world->dynamicsWorld->addRigidBody(body);
@@ -260,11 +279,26 @@ void RB_dworld_add_body(rbDynamicsWorld *world, 
rbRigidBody *object, int col_gro
 
 void RB_dworld_remove_body(rbDynamicsWorld *world, rbRigidBody *object)
 {
-       btRigidBody *body = object->body;
+       btRigidBody *body = &object->body;
        
        world->dynamicsWorld->removeRigidBody(body);
 }
 
+void RB_dworld_add_ghost(rbDynamicsWorld *world, rbGhostObject *object, int 
col_groups)
+{
+       btGhostObject *ghost = &object->ghost;
+       object->col_groups = col_groups;
+       
+       world->dynamicsWorld->addCollisionObject(ghost, 
btBroadphaseProxy::DefaultFilter, btBroadphaseProxy::AllFilter ^ 
btBroadphaseProxy::DefaultFilter);
+}
+
+void RB_dworld_remove_ghost(rbDynamicsWorld *world, rbGhostObject *object)
+{
+       btGhostObject *ghost = &object->ghost;
+       
+       world->dynamicsWorld->removeCollisionObject(ghost);
+}
+
 /* Collision detection */
 
 void RB_world_convex_sweep_test(
@@ -272,7 +306,7 @@ void RB_world_convex_sweep_test(
         const float loc_start[3], const float loc_end[3],
         float v_location[3],  float v_hitpoint[3],  float v_normal[3], int 
*r_hit)
 {
-       btRigidBody *body = object->body;
+       btRigidBody *body = &object->body;
        btCollisionShape *collisionShape = body->getCollisionShape();
        /* only convex shapes are supported, but user can specify a non convex 
shape */
        if (collisionShape->isConvex()) {
@@ -320,9 +354,8 @@ void RB_world_convex_sweep_test(
 
 /* ............ */
 
-rbRigidBody *RB_body_new(rbCollisionShape *shape, const float loc

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to