[Bf-blender-cvs] [52c3687] hair_system: Create sphere collision shapes for the hair point ghost objects.

Lukas Tönne noreply at git.blender.org
Mon Aug 4 09:45:08 CEST 2014


Commit: 52c368749fb8d5ccbba0829722fc587d181672a9
Author: Lukas Tönne
Date:   Mon Aug 4 09:43:21 2014 +0200
Branches: hair_system
https://developer.blender.org/rB52c368749fb8d5ccbba0829722fc587d181672a9

Create sphere collision shapes for the hair point ghost objects.

NOTE: Bullet sphere collision shapes are created directly in the hair
code atm, bypassing the RBI API! This should be resolved eventually,
using the API everywhere instead of directly accessing Bullet. The
problem is that collision shapes in Bullet are an abstract base class,
the actual types are subclasses, which are difficult to handle nicely
in a C API ...

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/hair/intern/HAIR_curve.cpp
M	source/blender/hair/intern/HAIR_curve.h
M	source/blender/hair/intern/HAIR_scene.cpp

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 708bd15..71fc2ae 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4594,9 +4594,6 @@ static void direct_link_hair_system(FileData *fd, HairSystem *hsys)
 	for (hair = hsys->curves, i = 0; i < hsys->totcurves; ++hair, ++i) {
 		hair->points = newdataadr(fd, hair->points);
 	}
-
-	hsys->physics_objects = NULL;
-	hsys->tot_physics_objects = 0;
 }
 
 static void direct_link_modifiers(FileData *fd, ListBase *lb)
diff --git a/source/blender/hair/intern/HAIR_curve.cpp b/source/blender/hair/intern/HAIR_curve.cpp
index 3be4db3..75e547f 100644
--- a/source/blender/hair/intern/HAIR_curve.cpp
+++ b/source/blender/hair/intern/HAIR_curve.cpp
@@ -24,19 +24,50 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include "rb_internal_types.h"
+
 #include "HAIR_curve.h"
 
 HAIR_NAMESPACE_BEGIN
 
-Point::Point()
+Point::Point() :
+    rb_ghost(),
+    bt_shape(1.0f)
 {
+	rb_ghost.ghost.setCollisionShape(&bt_shape);
 }
 
 Point::Point(const float3 &rest_co) :
-    rest_co(rest_co)
+    rest_co(rest_co),
+    rb_ghost(),
+    bt_shape(1.0f)
 {
 	cur.co = rest_co;
 	cur.vel = float3(0.0f, 0.0f, 0.0f);
+	
+	rb_ghost.ghost.setCollisionShape(&bt_shape);
+}
+
+Point::Point(const Point &other) :
+    bt_shape(1.0f)
+{
+	*this = other;
+}
+
+Point &Point::operator = (const Point &other)
+{
+	rest_co = other.rest_co;
+	rest_bend = other.rest_bend;
+	
+	cur = other.cur;
+	next = other.next;
+	
+	rb_ghost = other.rb_ghost;
+	bt_shape = other.bt_shape;
+	/* assign new collision shape */
+	rb_ghost.ghost.setCollisionShape(&bt_shape);
+	
+	return *this;
 }
 
 Curve::Curve(int totpoints, Point *points) :
diff --git a/source/blender/hair/intern/HAIR_curve.h b/source/blender/hair/intern/HAIR_curve.h
index 03af43f..082c0c0 100644
--- a/source/blender/hair/intern/HAIR_curve.h
+++ b/source/blender/hair/intern/HAIR_curve.h
@@ -31,6 +31,8 @@ extern "C" {
 #include "RBI_api.h"
 }
 
+#include <BulletCollision/CollisionShapes/btSphereShape.h>
+
 #include "rb_internal_types.h"
 
 #include "HAIR_memalloc.h"
@@ -47,6 +49,9 @@ struct Point {
 	
 	Point();
 	Point(const float3 &rest_co);
+	Point(const Point &other);
+	
+	Point &operator = (const Point &other);
 	
 	State cur;
 	State next;
@@ -55,6 +60,7 @@ struct Point {
 	float3 rest_bend;
 	
 	rbGhostObject rb_ghost;
+	btSphereShape bt_shape;
 	
 	HAIR_CXX_CLASS_ALLOC(Point)
 };
diff --git a/source/blender/hair/intern/HAIR_scene.cpp b/source/blender/hair/intern/HAIR_scene.cpp
index cebf9e8..7b1ba55 100644
--- a/source/blender/hair/intern/HAIR_scene.cpp
+++ b/source/blender/hair/intern/HAIR_scene.cpp
@@ -125,7 +125,7 @@ void SceneConverter::update_solver_data_externals(SolverData *data, SolverForces
 		mesh_sample_eval(dm, mat, &hcurve->root, curve->root1.co, curve->root1.nor);
 	}
 	
-	forces.dynamics_world = (rbDynamicsWorld *)scene->rigidbody_world->physics_world;
+	forces.dynamics_world = scene->rigidbody_world ? (rbDynamicsWorld *)scene->rigidbody_world->physics_world : NULL;
 	forces.gravity = float3(scene->physics_settings.gravity);
 }




More information about the Bf-blender-cvs mailing list