[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16736] trunk/blender: Allow Bullet soft bodies to be created using a AddObject actuator.

Erwin Coumans blender at erwincoumans.com
Fri Sep 26 04:28:00 CEST 2008


Revision: 16736
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16736
Author:   erwin
Date:     2008-09-26 04:27:59 +0200 (Fri, 26 Sep 2008)

Log Message:
-----------
Allow Bullet soft bodies to be created using a AddObject actuator. Added a fake world coordinate system to game soft bodies, although the vertices are already in world space.
Added Bullet/Gimpact concave collision detection to Blender. If your build system isn't updated yet, please add extern/bullet2/src/BulletCollision/Gimpact/*
This allows moving/dynamic concave triangle meshes (decomposing meshes into compound convex shapes, and using 'compound' shapes is still preferred)

Modified Paths:
--------------
    trunk/blender/extern/bullet2/CMakeLists.txt
    trunk/blender/extern/bullet2/Makefile
    trunk/blender/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
    trunk/blender/extern/bullet2/src/BulletSoftBody/btSoftBody.h
    trunk/blender/extern/bullet2/src/SConscript
    trunk/blender/source/gameengine/Converter/BL_DeformableGameObject.cpp
    trunk/blender/source/gameengine/Converter/BL_MeshDeformer.h
    trunk/blender/source/gameengine/Converter/BL_ShapeDeformer.cpp
    trunk/blender/source/gameengine/Converter/BL_ShapeDeformer.h
    trunk/blender/source/gameengine/Converter/BL_SkinDeformer.cpp
    trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h
    trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.h
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
    trunk/blender/source/gameengine/Rasterizer/RAS_Deformer.h
    trunk/blender/source/gameengine/Rasterizer/RAS_TexVert.cpp

Added Paths:
-----------
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btBoxCollision.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btClipPolygon.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btContactProcessing.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btContactProcessing.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactBvh.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactBvh.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactMassUtil.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGenericPoolAllocator.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGenericPoolAllocator.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btGeometryOperations.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btQuantization.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btTriangleShapeEx.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btTriangleShapeEx.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_array.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_basic_geometry_operations.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_bitset.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_box_collision.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_box_set.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_box_set.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_clip_polygon.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_contact.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_geom_types.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_geometry.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_hash_table.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_linear_math.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_math.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_memory.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_memory.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_radixsort.h
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_tri_collision.cpp
    trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/gim_tri_collision.h

Modified: trunk/blender/extern/bullet2/CMakeLists.txt
===================================================================
--- trunk/blender/extern/bullet2/CMakeLists.txt	2008-09-26 02:02:02 UTC (rev 16735)
+++ trunk/blender/extern/bullet2/CMakeLists.txt	2008-09-26 02:27:59 UTC (rev 16736)
@@ -31,6 +31,7 @@
   src/BulletCollision/BroadphaseCollision/*.cpp
   src/BulletCollision/CollisionShapes/*.cpp
   src/BulletCollision/NarrowPhaseCollision/*.cpp
+  src/BulletCollision/Gimpact/*.cpp
   src/BulletCollision//CollisionDispatch/*.cpp
   src/BulletDynamics/ConstraintSolver/*.cpp
   src/BulletDynamics/Vehicle/*.cpp

Modified: trunk/blender/extern/bullet2/Makefile
===================================================================
--- trunk/blender/extern/bullet2/Makefile	2008-09-26 02:02:02 UTC (rev 16735)
+++ trunk/blender/extern/bullet2/Makefile	2008-09-26 02:27:59 UTC (rev 16736)
@@ -37,6 +37,7 @@
 BulletCollision/BroadphaseCollision \
 BulletCollision/CollisionShapes \
 BulletCollision/NarrowPhaseCollision \
+BulletCollision/Gimpact \
 BulletCollision//CollisionDispatch \
 BulletDynamics/ConstraintSolver \
 BulletDynamics/Vehicle \

Added: trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btBoxCollision.h
===================================================================
--- trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btBoxCollision.h	                        (rev 0)
+++ trunk/blender/extern/bullet2/src/BulletCollision/Gimpact/btBoxCollision.h	2008-09-26 02:27:59 UTC (rev 16736)
@@ -0,0 +1,651 @@
+#ifndef BT_BOX_COLLISION_H_INCLUDED
+#define BT_BOX_COLLISION_H_INCLUDED
+
+/*! \file gim_box_collision.h
+\author Francisco Le\xF3n N\xE1jera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman at yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "LinearMath/btTransform.h"
+
+/*! \defgroup BOUND_AABB_OPERATIONS
+*/
+//! @{
+
+///Swap numbers
+#define BT_SWAP_NUMBERS(a,b){ \
+    a = a+b; \
+    b = a-b; \
+    a = a-b; \
+}\
+
+
+#define BT_MAX(a,b) (a<b?b:a)
+#define BT_MIN(a,b) (a>b?b:a)
+
+#define BT_GREATER(x, y)	fabsf(x) > (y)
+
+#define BT_MAX3(a,b,c) BT_MAX(a,BT_MAX(b,c))
+#define BT_MIN3(a,b,c) BT_MIN(a,BT_MIN(b,c))
+
+
+
+
+
+
+enum eBT_PLANE_INTERSECTION_TYPE
+{
+	BT_CONST_BACK_PLANE = 0,
+	BT_CONST_COLLIDE_PLANE,
+	BT_CONST_FRONT_PLANE
+};
+
+//SIMD_FORCE_INLINE bool test_cross_edge_box(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, const btVector3 & extend,
+//	int dir_index0,
+//	int dir_index1
+//	int component_index0,
+//	int component_index1)
+//{
+//	// dir coords are -z and y
+//
+//	const btScalar dir0 = -edge[dir_index0];
+//	const btScalar dir1 = edge[dir_index1];
+//	btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1;
+//	btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1;
+//	//find minmax
+//	if(pmin>pmax)
+//	{
+//		BT_SWAP_NUMBERS(pmin,pmax);
+//	}
+//	//find extends
+//	const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] +
+//					extend[component_index1] * absolute_edge[dir_index1];
+//
+//	if(pmin>rad || -rad>pmax) return false;
+//	return true;
+//}
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2);
+//}
+//
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0);
+//}
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1);
+//}
+
+
+#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\
+{\
+	const btScalar dir0 = -edge[i_dir_0];\
+	const btScalar dir1 = edge[i_dir_1];\
+	btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\
+	btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\
+	if(pmin>pmax)\
+	{\
+		BT_SWAP_NUMBERS(pmin,pmax); \
+	}\
+	const btScalar abs_dir0 = absolute_edge[i_dir_0];\
+	const btScalar abs_dir1 = absolute_edge[i_dir_1];\
+	const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\
+	if(pmin>rad || -rad>pmax) return false;\
+}\
+
+
+#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\
+}\
+
+#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\
+}\
+
+#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\
+}\
+
+
+//! Returns the dot product between a vec3f and the col of a matrix
+SIMD_FORCE_INLINE btScalar bt_mat3_dot_col(
+const btMatrix3x3 & mat, const btVector3 & vec3, int colindex)
+{
+	return vec3[0]*mat[0][colindex] + vec3[1]*mat[1][colindex] + vec3[2]*mat[2][colindex];
+}
+
+
+//!  Class for transforming a model1 to the space of model0
+ATTRIBUTE_ALIGNED16	(class) BT_BOX_BOX_TRANSFORM_CACHE
+{
+public:
+    btVector3  m_T1to0;//!< Transforms translation of model1 to model 0
+	btMatrix3x3 m_R1to0;//!< Transforms Rotation of model1 to model 0, equal  to R0' * R1
+	btMatrix3x3 m_AR;//!< Absolute value of m_R1to0
+
+	SIMD_FORCE_INLINE void calc_absolute_matrix()
+	{
+//		static const btVector3 vepsi(1e-6f,1e-6f,1e-6f);
+//		m_AR[0] = vepsi + m_R1to0[0].absolute();
+//		m_AR[1] = vepsi + m_R1to0[1].absolute();
+//		m_AR[2] = vepsi + m_R1to0[2].absolute();
+
+		int i,j;
+
+        for(i=0;i<3;i++)
+        {
+            for(j=0;j<3;j++ )
+            {
+            	m_AR[i][j] = 1e-6f + fabsf(m_R1to0[i][j]);
+            }
+        }
+
+	}
+
+	BT_BOX_BOX_TRANSFORM_CACHE()
+	{
+	}
+
+
+
+	//! Calc the transformation relative  1 to 0. Inverts matrics by transposing
+	SIMD_FORCE_INLINE void calc_from_homogenic(const btTransform & trans0,const btTransform & trans1)
+	{
+
+		btTransform temp_trans = trans0.inverse();
+		temp_trans = temp_trans * trans1;
+
+		m_T1to0 = temp_trans.getOrigin();
+		m_R1to0 = temp_trans.getBasis();
+
+
+		calc_absolute_matrix();
+	}
+
+	//! Calcs the full invertion of the matrices. Useful for scaling matrices
+	SIMD_FORCE_INLINE void calc_from_full_invert(const btTransform & trans0,const btTransform & trans1)
+	{
+		m_R1to0 = trans0.getBasis().inverse();
+		m_T1to0 = m_R1to0 * (-trans0.getOrigin());
+
+		m_T1to0 += m_R1to0*trans1.getOrigin();
+		m_R1to0 *= trans1.getBasis();
+
+		calc_absolute_matrix();
+	}
+
+	SIMD_FORCE_INLINE btVector3 transform(const btVector3 & point) const
+	{
+		return btVector3(m_R1to0[0].dot(point) + m_T1to0.x(),
+			m_R1to0[1].dot(point) + m_T1to0.y(),
+			m_R1to0[2].dot(point) + m_T1to0.z());
+	}
+};
+
+
+#define BOX_PLANE_EPSILON 0.000001f
+
+//! Axis aligned box
+ATTRIBUTE_ALIGNED16	(class) btAABB
+{
+public:
+	btVector3 m_min;
+	btVector3 m_max;
+
+	btAABB()
+	{}
+
+
+	btAABB(const btVector3 & V1,
+			 const btVector3 & V2,
+			 const btVector3 & V3)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]);
+	}
+
+	btAABB(const btVector3 & V1,
+			 const btVector3 & V2,
+			 const btVector3 & V3,
+			 btScalar margin)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]);
+
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	btAABB(const btAABB &other):
+		m_min(other.m_min),m_max(other.m_max)
+	{
+	}
+
+	btAABB(const btAABB &other,btScalar margin ):
+		m_min(other.m_min),m_max(other.m_max)
+	{
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	SIMD_FORCE_INLINE void invalidate()
+	{
+		m_min[0] = SIMD_INFINITY;
+		m_min[1] = SIMD_INFINITY;
+		m_min[2] = SIMD_INFINITY;
+		m_max[0] = -SIMD_INFINITY;
+		m_max[1] = -SIMD_INFINITY;
+		m_max[2] = -SIMD_INFINITY;
+	}
+
+	SIMD_FORCE_INLINE void increment_margin(btScalar margin)
+	{
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	SIMD_FORCE_INLINE void copy_with_margin(const btAABB &other, btScalar margin)
+	{
+		m_min[0] = other.m_min[0] - margin;
+		m_min[1] = other.m_min[1] - margin;
+		m_min[2] = other.m_min[2] - margin;
+
+		m_max[0] = other.m_max[0] + margin;
+		m_max[1] = other.m_max[1] + margin;
+		m_max[2] = other.m_max[2] + margin;
+	}
+
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void calc_from_triangle(
+							const CLASS_POINT & V1,
+							const CLASS_POINT & V2,
+							const CLASS_POINT & V3)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list