Browse Source

Nuke Bullet

Panagiotis Christopoulos Charitos 10 months ago
parent
commit
bbea8fdca5
100 changed files with 6 additions and 19321 deletions
  1. 1 1
      AnKi/CMakeLists.txt
  2. 1 1
      AnKi/Core/CMakeLists.txt
  3. 0 5
      AnKi/Physics/CMakeLists.txt
  4. 0 22
      AnKi/Physics/Common.cpp
  5. 0 146
      AnKi/Physics/Common.h
  6. 0 8
      AnKi/Physics/Forward.h
  7. 0 77
      AnKi/Physics/PhysicsBody.cpp
  8. 0 136
      AnKi/Physics/PhysicsBody.h
  9. 0 87
      AnKi/Physics/PhysicsCollisionShape.cpp
  10. 0 147
      AnKi/Physics/PhysicsCollisionShape.h
  11. 0 19
      AnKi/Physics/PhysicsDrawer.cpp
  12. 0 77
      AnKi/Physics/PhysicsDrawer.h
  13. 0 75
      AnKi/Physics/PhysicsJoint.cpp
  14. 0 115
      AnKi/Physics/PhysicsJoint.h
  15. 0 29
      AnKi/Physics/PhysicsObject.cpp
  16. 0 193
      AnKi/Physics/PhysicsObject.h
  17. 0 69
      AnKi/Physics/PhysicsPlayerController.cpp
  18. 0 70
      AnKi/Physics/PhysicsPlayerController.h
  19. 0 132
      AnKi/Physics/PhysicsTrigger.cpp
  20. 0 82
      AnKi/Physics/PhysicsTrigger.h
  21. 0 337
      AnKi/Physics/PhysicsWorld.cpp
  22. 0 133
      AnKi/Physics/PhysicsWorld.h
  23. 1 1
      AnKi/Resource/CMakeLists.txt
  24. 1 1
      AnKi/Resource/ParticleEmitterResource.h
  25. 1 1
      AnKi/Scene/Components/ParticleEmitterComponent.cpp
  26. 1 10
      CMakeLists.txt
  27. 0 35
      ThirdParty/Bullet/.travis.yml
  28. 0 45
      ThirdParty/Bullet/AUTHORS.txt
  29. 0 25
      ThirdParty/Bullet/BulletConfig.cmake.in
  30. 0 513
      ThirdParty/Bullet/CMakeLists.txt
  31. 0 780
      ThirdParty/Bullet/Doxyfile
  32. 0 317
      ThirdParty/Bullet/Extras/BulletRobotics/CMakeLists.txt
  33. 0 6
      ThirdParty/Bullet/Extras/BulletRobotics/bullet_robotics.pc.cmake
  34. 0 183
      ThirdParty/Bullet/Extras/BulletRobotics/premake4.lua
  35. 0 196
      ThirdParty/Bullet/Extras/BulletRoboticsGUI/CMakeLists.txt
  36. 0 6
      ThirdParty/Bullet/Extras/BulletRoboticsGUI/bullet_robotics_gui.pc.cmake
  37. 0 40
      ThirdParty/Bullet/Extras/CMakeLists.txt
  38. 0 67
      ThirdParty/Bullet/Extras/ConvexDecomposition/CMakeLists.txt
  39. 0 350
      ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexBuilder.cpp
  40. 0 103
      ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexBuilder.h
  41. 0 346
      ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexDecomposition.cpp
  42. 0 202
      ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexDecomposition.h
  43. 0 19
      ThirdParty/Bullet/Extras/ConvexDecomposition/LICENSE.txt
  44. 0 448
      ThirdParty/Bullet/Extras/ConvexDecomposition/bestfit.cpp
  45. 0 63
      ThirdParty/Bullet/Extras/ConvexDecomposition/bestfit.h
  46. 0 166
      ThirdParty/Bullet/Extras/ConvexDecomposition/bestfitobb.cpp
  47. 0 41
      ThirdParty/Bullet/Extras/ConvexDecomposition/bestfitobb.h
  48. 0 3370
      ThirdParty/Bullet/Extras/ConvexDecomposition/cd_hull.cpp
  49. 0 148
      ThirdParty/Bullet/Extras/ConvexDecomposition/cd_hull.h
  50. 0 1192
      ThirdParty/Bullet/Extras/ConvexDecomposition/cd_vector.h
  51. 0 824
      ThirdParty/Bullet/Extras/ConvexDecomposition/cd_wavefront.cpp
  52. 0 57
      ThirdParty/Bullet/Extras/ConvexDecomposition/cd_wavefront.h
  53. 0 761
      ThirdParty/Bullet/Extras/ConvexDecomposition/concavity.cpp
  54. 0 55
      ThirdParty/Bullet/Extras/ConvexDecomposition/concavity.h
  55. 0 197
      ThirdParty/Bullet/Extras/ConvexDecomposition/fitsphere.cpp
  56. 0 41
      ThirdParty/Bullet/Extras/ConvexDecomposition/fitsphere.h
  57. 0 238
      ThirdParty/Bullet/Extras/ConvexDecomposition/float_math.cpp
  58. 0 71
      ThirdParty/Bullet/Extras/ConvexDecomposition/float_math.h
  59. 0 124
      ThirdParty/Bullet/Extras/ConvexDecomposition/meshvolume.cpp
  60. 0 42
      ThirdParty/Bullet/Extras/ConvexDecomposition/meshvolume.h
  61. 0 227
      ThirdParty/Bullet/Extras/ConvexDecomposition/planetri.cpp
  62. 0 55
      ThirdParty/Bullet/Extras/ConvexDecomposition/planetri.h
  63. 0 12
      ThirdParty/Bullet/Extras/ConvexDecomposition/premake4.lua
  64. 0 128
      ThirdParty/Bullet/Extras/ConvexDecomposition/raytri.cpp
  65. 0 43
      ThirdParty/Bullet/Extras/ConvexDecomposition/raytri.h
  66. 0 294
      ThirdParty/Bullet/Extras/ConvexDecomposition/splitplane.cpp
  67. 0 55
      ThirdParty/Bullet/Extras/ConvexDecomposition/splitplane.h
  68. 0 311
      ThirdParty/Bullet/Extras/ConvexDecomposition/vlookup.cpp
  69. 0 115
      ThirdParty/Bullet/Extras/ConvexDecomposition/vlookup.h
  70. 0 40
      ThirdParty/Bullet/Extras/GIMPACTUtils/CMakeLists.txt
  71. 0 11
      ThirdParty/Bullet/Extras/GIMPACTUtils/LICENSE.txt
  72. 0 218
      ThirdParty/Bullet/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.cpp
  73. 0 79
      ThirdParty/Bullet/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.h
  74. 0 55
      ThirdParty/Bullet/Extras/HACD/CMakeLists.txt
  75. 0 13
      ThirdParty/Bullet/Extras/HACD/LICENSE.txt
  76. 0 86
      ThirdParty/Bullet/Extras/HACD/hacdCircularList.h
  77. 0 163
      ThirdParty/Bullet/Extras/HACD/hacdCircularList.inl
  78. 0 290
      ThirdParty/Bullet/Extras/HACD/hacdGraph.cpp
  79. 0 119
      ThirdParty/Bullet/Extras/HACD/hacdGraph.h
  80. 0 851
      ThirdParty/Bullet/Extras/HACD/hacdHACD.cpp
  81. 0 285
      ThirdParty/Bullet/Extras/HACD/hacdHACD.h
  82. 0 1020
      ThirdParty/Bullet/Extras/HACD/hacdICHull.cpp
  83. 0 120
      ThirdParty/Bullet/Extras/HACD/hacdICHull.h
  84. 0 582
      ThirdParty/Bullet/Extras/HACD/hacdManifoldMesh.cpp
  85. 0 251
      ThirdParty/Bullet/Extras/HACD/hacdManifoldMesh.h
  86. 0 68
      ThirdParty/Bullet/Extras/HACD/hacdVector.h
  87. 0 178
      ThirdParty/Bullet/Extras/HACD/hacdVector.inl
  88. 0 20
      ThirdParty/Bullet/Extras/HACD/hacdVersion.h
  89. 0 12
      ThirdParty/Bullet/Extras/HACD/premake4.lua
  90. 0 15
      ThirdParty/Bullet/Extras/InverseDynamics/BulletInverseDynamicsUtilsCommon.h
  91. 0 50
      ThirdParty/Bullet/Extras/InverseDynamics/CMakeLists.txt
  92. 0 59
      ThirdParty/Bullet/Extras/InverseDynamics/CloneTreeCreator.cpp
  93. 0 29
      ThirdParty/Bullet/Extras/InverseDynamics/CloneTreeCreator.hpp
  94. 0 73
      ThirdParty/Bullet/Extras/InverseDynamics/CoilCreator.cpp
  95. 0 41
      ThirdParty/Bullet/Extras/InverseDynamics/CoilCreator.hpp
  96. 0 136
      ThirdParty/Bullet/Extras/InverseDynamics/DillCreator.cpp
  97. 0 47
      ThirdParty/Bullet/Extras/InverseDynamics/DillCreator.hpp
  98. 0 76
      ThirdParty/Bullet/Extras/InverseDynamics/IDRandomUtil.cpp
  99. 0 37
      ThirdParty/Bullet/Extras/InverseDynamics/IDRandomUtil.hpp
  100. 0 12
      ThirdParty/Bullet/Extras/InverseDynamics/LICENSE.txt

+ 1 - 1
AnKi/CMakeLists.txt

@@ -1,4 +1,4 @@
-set(ANKI_SUB_DIRS Importer Core Script Renderer Scene Ui Window Physics Resource Gr Collision Math Util ShaderCompiler
+set(ANKI_SUB_DIRS Importer Core Script Renderer Scene Ui Window Resource Gr Collision Math Util ShaderCompiler
 	Shaders Physics2)
 foreach(TMP ${ANKI_SUB_DIRS})
 	add_subdirectory(${TMP})

+ 1 - 1
AnKi/Core/CMakeLists.txt

@@ -36,4 +36,4 @@ elseif(WINDOWS)
 endif()
 
 target_compile_definitions(AnKiCore PRIVATE -DANKI_SOURCE_FILE)
-target_link_libraries(AnKiCore AnKiGr AnKiResource AnKiUi AnKiRenderer AnKiUtil AnKiPhysics AnKiScript AnKiWindow ${extra_libs})
+target_link_libraries(AnKiCore AnKiGr AnKiResource AnKiUi AnKiRenderer AnKiUtil AnKiPhysics2 AnKiScript AnKiWindow ${extra_libs})

+ 0 - 5
AnKi/Physics/CMakeLists.txt

@@ -1,5 +0,0 @@
-file(GLOB_RECURSE sources *.cpp)
-file(GLOB_RECURSE headers *.h)
-add_library(AnKiPhysics ${sources} ${headers})
-target_compile_definitions(AnKiPhysics PRIVATE -DANKI_SOURCE_FILE)
-target_link_libraries(AnKiPhysics AnKiUtil BulletSoftBody BulletDynamics BulletCollision LinearMath)

+ 0 - 22
AnKi/Physics/Common.cpp

@@ -1,22 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/Common.h>
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-
-namespace anki {
-
-void PhysicsPtrDeleter::operator()(PhysicsObject* ptr)
-{
-	if(ptr == nullptr)
-	{
-		return;
-	}
-
-	PhysicsWorld::getSingleton().destroyObject(ptr);
-}
-
-} // end namespace anki

+ 0 - 146
AnKi/Physics/Common.h

@@ -1,146 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Util/StdTypes.h>
-#include <AnKi/Util/Enum.h>
-#include <AnKi/Util/Ptr.h>
-#include <AnKi/Util/MemoryPool.h>
-#include <AnKi/Math.h>
-
-#if ANKI_COMPILER_GCC_COMPATIBLE
-#	pragma GCC diagnostic push
-#	pragma GCC diagnostic ignored "-Wall"
-#	pragma GCC diagnostic ignored "-Wconversion"
-#	pragma GCC diagnostic ignored "-Wfloat-conversion"
-#	if(ANKI_COMPILER_GCC && __GNUC__ >= 9) || (ANKI_COMPILER_CLANG && __clang_major__ >= 10)
-#		pragma GCC diagnostic ignored "-Wdeprecated-copy"
-#	endif
-#endif
-#if ANKI_COMPILER_MSVC
-#	pragma warning(push)
-#	pragma warning(disable : 4305)
-#endif
-#define BT_THREADSAFE 0
-#define BT_NO_PROFILE 1
-#include <btBulletCollisionCommon.h>
-#include <btBulletDynamicsCommon.h>
-#include <BulletCollision/CollisionDispatch/btGhostObject.h>
-#include <BulletDynamics/Character/btKinematicCharacterController.h>
-#include <BulletCollision/Gimpact/btGImpactShape.h>
-#if ANKI_COMPILER_GCC_COMPATIBLE
-#	pragma GCC diagnostic pop
-#endif
-#if ANKI_COMPILER_MSVC
-#	pragma warning(pop)
-#endif
-
-namespace anki {
-
-#define ANKI_PHYS_LOGI(...) ANKI_LOG("PHYS", kNormal, __VA_ARGS__)
-#define ANKI_PHYS_LOGE(...) ANKI_LOG("PHYS", kError, __VA_ARGS__)
-#define ANKI_PHYS_LOGW(...) ANKI_LOG("PHYS", kWarning, __VA_ARGS__)
-#define ANKI_PHYS_LOGF(...) ANKI_LOG("PHYS", kFatal, __VA_ARGS__)
-
-class PhysicsMemoryPool : public HeapMemoryPool, public MakeSingleton<PhysicsMemoryPool>
-{
-	template<typename>
-	friend class MakeSingleton;
-
-private:
-	PhysicsMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData)
-		: HeapMemoryPool(allocCb, allocCbUserData, "PhysicsMemPool")
-	{
-	}
-
-	~PhysicsMemoryPool() = default;
-};
-
-ANKI_DEFINE_SUBMODULE_UTIL_CONTAINERS(Physics, PhysicsMemoryPool)
-
-// Forward
-class PhysicsObject;
-class PhysicsFilteredObject;
-class PhysicsWorld;
-class PhysicsCollisionShape;
-class PhysicsBody;
-class PhysicsPlayerController;
-class PhysicsJoint;
-class PhysicsTrigger;
-
-/// @addtogroup physics
-/// @{
-
-/// PhysicsPtr custom deleter.
-class PhysicsPtrDeleter
-{
-public:
-	void operator()(PhysicsObject* ptr);
-};
-
-/// Smart pointer for physics objects.
-template<typename T>
-using PhysicsPtr = IntrusivePtr<T, PhysicsPtrDeleter>;
-
-using PhysicsObjectPtr = PhysicsPtr<PhysicsObject>;
-using PhysicsFilteredObjectPtr = PhysicsPtr<PhysicsFilteredObject>;
-using PhysicsCollisionShapePtr = PhysicsPtr<PhysicsCollisionShape>;
-using PhysicsBodyPtr = PhysicsPtr<PhysicsBody>;
-using PhysicsPlayerControllerPtr = PhysicsPtr<PhysicsPlayerController>;
-using PhysicsJointPtr = PhysicsPtr<PhysicsJoint>;
-using PhysicsTriggerPtr = PhysicsPtr<PhysicsTrigger>;
-
-/// Material types.
-enum class PhysicsMaterialBit : U64
-{
-	kNone = 0,
-	kStaticGeometry = 1 << 0,
-	kDynamicGeometry = 1 << 1,
-	kTrigger = 1 << 2,
-	kPlayer = 1 << 3,
-	kParticle = 1 << 4,
-
-	kAll = kMaxU64
-};
-ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(PhysicsMaterialBit)
-
-[[nodiscard]] inline Vec3 toAnki(const btVector3& v)
-{
-	return Vec3(v.getX(), v.getY(), v.getZ());
-}
-
-[[nodiscard]] inline btVector3 toBt(const Vec3& v)
-{
-	return btVector3(v.x(), v.y(), v.z());
-}
-
-[[nodiscard]] inline btTransform toBt(const Transform& a)
-{
-	Mat4 mat(a);
-	mat.transpose();
-	btTransform out;
-	out.setFromOpenGLMatrix(&mat(0, 0));
-	return out;
-}
-
-[[nodiscard]] inline Mat3x4 toAnki(const btMatrix3x3& m)
-{
-	Mat3x4 m3;
-	m3.setRows(Vec4(toAnki(m[0]), 0.0f), Vec4(toAnki(m[1]), 0.0f), Vec4(toAnki(m[2]), 0.0f));
-	return m3;
-}
-
-[[nodiscard]] inline Transform toAnki(const btTransform& t)
-{
-	Transform out;
-	out.setRotation(toAnki(t.getBasis()));
-	out.setOrigin(Vec4(toAnki(t.getOrigin()), 0.0f));
-	out.setScale(Vec4(1.0f, 1.0f, 1.0f, 0.0f));
-	return out;
-}
-/// @}
-
-} // end namespace anki

+ 0 - 8
AnKi/Physics/Forward.h

@@ -1,8 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/Common.h>

+ 0 - 77
AnKi/Physics/PhysicsBody.cpp

@@ -1,77 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsBody.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-#include <AnKi/Physics/PhysicsCollisionShape.h>
-
-namespace anki {
-
-PhysicsBody::PhysicsBody(const PhysicsBodyInitInfo& init)
-	: PhysicsFilteredObject(kClassType)
-{
-	ANKI_ASSERT(init.m_mass >= 0.0f);
-
-	const Bool dynamic = init.m_mass > 0.0f;
-	m_shape = init.m_shape;
-	m_mass = init.m_mass;
-
-	// Create motion state
-	m_motionState.m_body = this;
-
-	// Compute inertia
-	btCollisionShape* shape = m_shape->getBtShape(dynamic);
-	btVector3 localInertia(0, 0, 0);
-	if(dynamic)
-	{
-		shape->calculateLocalInertia(init.m_mass, localInertia);
-	}
-
-	// Create body
-	btRigidBody::btRigidBodyConstructionInfo cInfo(init.m_mass, &m_motionState, shape, localInertia);
-	cInfo.m_friction = init.m_friction;
-	m_body.construct(cInfo);
-
-	// User pointer
-	m_body->setUserPointer(static_cast<PhysicsObject*>(this));
-
-	// Other
-	setMaterialGroup((dynamic) ? PhysicsMaterialBit::kDynamicGeometry : PhysicsMaterialBit::kStaticGeometry);
-
-	PhysicsMaterialBit collidesWith = PhysicsMaterialBit::kAll;
-	if(!dynamic)
-	{
-		collidesWith &= ~PhysicsMaterialBit::kStaticGeometry;
-	}
-	setMaterialMask(collidesWith);
-	setTransform(init.m_transform);
-}
-
-PhysicsBody::~PhysicsBody()
-{
-	m_body.destroy();
-}
-
-void PhysicsBody::setMass(F32 mass)
-{
-	ANKI_ASSERT(m_mass > 0.0f && "Only relevant for dynamic bodies");
-	ANKI_ASSERT(mass > 0.0f);
-	btVector3 inertia;
-	m_shape->getBtShape(true)->calculateLocalInertia(mass, inertia);
-	m_body->setMassProps(mass, inertia);
-	m_mass = mass;
-}
-
-void PhysicsBody::registerToWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().addRigidBody(m_body.get());
-}
-
-void PhysicsBody::unregisterFromWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().removeRigidBody(m_body.get());
-}
-
-} // end namespace anki

+ 0 - 136
AnKi/Physics/PhysicsBody.h

@@ -1,136 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Util/ClassWrapper.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// Init info for PhysicsBody.
-class PhysicsBodyInitInfo
-{
-public:
-	PhysicsCollisionShapePtr m_shape;
-	F32 m_mass = 0.0f;
-	Transform m_transform = Transform::getIdentity();
-	F32 m_friction = 0.5f;
-};
-
-/// Rigid body.
-class PhysicsBody : public PhysicsFilteredObject
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kBody)
-
-public:
-	const Transform& getTransform() const
-	{
-		return m_trf;
-	}
-
-	void setTransform(const Transform& trf)
-	{
-		m_trf = trf;
-		m_body->setWorldTransform(toBt(trf));
-	}
-
-	void applyForce(const Vec3& force, const Vec3& relPos)
-	{
-		m_body->applyForce(toBt(force), toBt(relPos));
-	}
-
-	void setMass(F32 mass);
-
-	F32 getMass() const
-	{
-		return m_mass;
-	}
-
-	void activate(Bool activate)
-	{
-		m_body->forceActivationState((activate) ? ACTIVE_TAG : DISABLE_SIMULATION);
-		if(activate)
-		{
-			m_body->activate(true);
-		}
-	}
-
-	void clearForces()
-	{
-		m_body->clearForces();
-	}
-
-	void setLinearVelocity(const Vec3& velocity)
-	{
-		m_body->setLinearVelocity(toBt(velocity));
-	}
-
-	void setAngularVelocity(const Vec3& velocity)
-	{
-		m_body->setAngularVelocity(toBt(velocity));
-	}
-
-	void setGravity(const Vec3& gravity)
-	{
-		m_body->setGravity(toBt(gravity));
-	}
-
-	void setAngularFactor(const Vec3& factor)
-	{
-		m_body->setAngularFactor(toBt(factor));
-	}
-
-	ANKI_INTERNAL const btRigidBody* getBtBody() const
-	{
-		return m_body.get();
-	}
-
-	ANKI_INTERNAL btRigidBody* getBtBody()
-	{
-		return m_body.get();
-	}
-
-private:
-	class MotionState : public btMotionState
-	{
-	public:
-		PhysicsBody* m_body = nullptr;
-
-		void getWorldTransform(btTransform& worldTrans) const override
-		{
-			worldTrans = toBt(m_body->m_trf);
-		}
-
-		void setWorldTransform(const btTransform& worldTrans) override
-		{
-			m_body->m_trf = toAnki(worldTrans);
-		}
-	};
-
-	/// Store the data of the btRigidBody in place to avoid additional allocations.
-	ClassWrapper<btRigidBody> m_body;
-
-	Transform m_trf = Transform::getIdentity();
-	MotionState m_motionState;
-
-	PhysicsCollisionShapePtr m_shape;
-
-	F32 m_mass = 1.0f;
-
-	PhysicsBody(const PhysicsBodyInitInfo& init);
-
-	~PhysicsBody();
-
-	void registerToWorld() override;
-
-	void unregisterFromWorld() override;
-};
-/// @}
-
-} // end namespace anki

+ 0 - 87
AnKi/Physics/PhysicsCollisionShape.cpp

@@ -1,87 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsCollisionShape.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-
-namespace anki {
-
-PhysicsSphere::PhysicsSphere(F32 radius)
-	: PhysicsCollisionShape(ShapeType::kSphere)
-{
-	m_sphere.construct(radius);
-	m_sphere->setMargin(PhysicsWorld::getSingleton().getCollisionMargin());
-	m_sphere->setUserPointer(static_cast<PhysicsObject*>(this));
-}
-
-PhysicsSphere::~PhysicsSphere()
-{
-	m_sphere.destroy();
-}
-
-PhysicsBox::PhysicsBox(const Vec3& extend)
-	: PhysicsCollisionShape(ShapeType::kBox)
-{
-	m_box.construct(toBt(extend));
-	m_box->setMargin(PhysicsWorld::getSingleton().getCollisionMargin());
-	m_box->setUserPointer(static_cast<PhysicsObject*>(this));
-}
-
-PhysicsBox::~PhysicsBox()
-{
-	m_box.destroy();
-}
-
-PhysicsTriangleSoup::PhysicsTriangleSoup(ConstWeakArray<Vec3> positions, ConstWeakArray<U32> indices, Bool convex)
-	: PhysicsCollisionShape(ShapeType::kTrimesh)
-{
-	if(!convex)
-	{
-		ANKI_ASSERT((indices.getSize() % 3) == 0);
-
-		m_mesh.construct();
-
-		for(U32 i = 0; i < indices.getSize(); i += 3)
-		{
-			m_mesh->addTriangle(toBt(positions[indices[i]]), toBt(positions[indices[i + 1]]), toBt(positions[indices[i + 2]]));
-		}
-
-		// Create the dynamic shape
-		m_triMesh.m_dynamic.construct(m_mesh.get());
-		m_triMesh.m_dynamic->setMargin(PhysicsWorld::getSingleton().getCollisionMargin());
-		m_triMesh.m_dynamic->updateBound();
-		m_triMesh.m_dynamic->setUserPointer(static_cast<PhysicsObject*>(this));
-
-		// And the static one
-		m_triMesh.m_static.construct(m_mesh.get(), true);
-		m_triMesh.m_static->setMargin(PhysicsWorld::getSingleton().getCollisionMargin());
-		m_triMesh.m_static->setUserPointer(static_cast<PhysicsObject*>(this));
-	}
-	else
-	{
-		m_type = ShapeType::kConvex; // Fake the type
-
-		m_convex.construct(&positions[0][0], I32(positions.getSize()), U32(sizeof(Vec3)));
-		m_convex->setMargin(PhysicsWorld::getSingleton().getCollisionMargin());
-		m_convex->setUserPointer(static_cast<PhysicsObject*>(this));
-	}
-}
-
-PhysicsTriangleSoup::~PhysicsTriangleSoup()
-{
-	if(m_type == ShapeType::kTrimesh)
-	{
-		m_triMesh.m_dynamic.destroy();
-		m_triMesh.m_static.destroy();
-		m_mesh.destroy();
-	}
-	else
-	{
-		ANKI_ASSERT(m_type == ShapeType::kConvex);
-		m_convex.destroy();
-	}
-}
-
-} // end namespace anki

+ 0 - 147
AnKi/Physics/PhysicsCollisionShape.h

@@ -1,147 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Util/WeakArray.h>
-#include <AnKi/Util/ClassWrapper.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// The base of all collision shapes.
-class PhysicsCollisionShape : public PhysicsObject
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kCollisionShape)
-
-public:
-	ANKI_INTERNAL const btCollisionShape* getBtShape(Bool forDynamicBodies = false) const
-	{
-		return getBtShapeInternal(forDynamicBodies);
-	}
-
-	ANKI_INTERNAL btCollisionShape* getBtShape(Bool forDynamicBodies = false)
-	{
-		return const_cast<btCollisionShape*>(getBtShapeInternal(forDynamicBodies));
-	}
-
-protected:
-	enum class ShapeType : U8
-	{
-		kBox,
-		kSphere,
-		kConvex,
-		kTrimesh
-	};
-
-	class TriMesh
-	{
-	public:
-		ClassWrapper<btGImpactMeshShape> m_dynamic;
-		ClassWrapper<btBvhTriangleMeshShape> m_static;
-	};
-
-	// All shapes
-	union
-	{
-		ClassWrapper<btBoxShape> m_box;
-		ClassWrapper<btSphereShape> m_sphere;
-		ClassWrapper<btConvexHullShape> m_convex;
-		TriMesh m_triMesh;
-	};
-
-	ShapeType m_type;
-
-	PhysicsCollisionShape(ShapeType type)
-		: PhysicsObject(kClassType)
-		, m_type(type)
-	{
-	}
-
-	const btCollisionShape* getBtShapeInternal(Bool forDynamicBodies) const
-	{
-		switch(m_type)
-		{
-		case ShapeType::kBox:
-			return m_box.get();
-		case ShapeType::kSphere:
-			return m_sphere.get();
-		case ShapeType::kConvex:
-			return m_convex.get();
-		case ShapeType::kTrimesh:
-			if(forDynamicBodies)
-			{
-				return m_triMesh.m_dynamic.get();
-			}
-			else
-			{
-				return m_triMesh.m_static.get();
-			}
-		default:
-			ANKI_ASSERT(0);
-			return nullptr;
-		}
-	}
-
-	void registerToWorld() override
-	{
-	}
-
-	void unregisterFromWorld() override
-	{
-	}
-};
-
-/// Sphere collision shape.
-class PhysicsSphere final : public PhysicsCollisionShape
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kCollisionShape)
-
-private:
-	PhysicsSphere(F32 radius);
-
-	~PhysicsSphere();
-};
-
-/// Box collision shape.
-class PhysicsBox final : public PhysicsCollisionShape
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kCollisionShape)
-
-private:
-	PhysicsBox(const Vec3& extend);
-
-	~PhysicsBox();
-};
-
-/// Convex hull collision shape.
-class PhysicsConvexHull final : public PhysicsCollisionShape
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kCollisionShape)
-
-private:
-	PhysicsConvexHull(const Vec3* positions, U32 positionsCount, U32 positionsStride);
-
-	~PhysicsConvexHull();
-};
-
-/// Static triangle mesh shape.
-class PhysicsTriangleSoup final : public PhysicsCollisionShape
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kCollisionShape)
-
-private:
-	ClassWrapper<btTriangleMesh> m_mesh;
-
-	PhysicsTriangleSoup(ConstWeakArray<Vec3> positions, ConstWeakArray<U32> indices, Bool convex = false);
-
-	~PhysicsTriangleSoup();
-};
-/// @}
-
-} // end namespace anki

+ 0 - 19
AnKi/Physics/PhysicsDrawer.cpp

@@ -1,19 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsDrawer.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-
-namespace anki {
-
-void PhysicsDrawer::drawWorld(const PhysicsWorld& world)
-{
-	btDynamicsWorld& btWorld = const_cast<btDynamicsWorld&>(world.getBtWorld());
-
-	btWorld.setDebugDrawer(&m_debugDraw);
-	btWorld.debugDrawWorld();
-}
-
-} // end namespace anki

+ 0 - 77
AnKi/Physics/PhysicsDrawer.h

@@ -1,77 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/Common.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// Physics debug drawer interface.
-class PhysicsDrawer
-{
-public:
-	PhysicsDrawer()
-		: m_debugDraw(this)
-	{
-	}
-
-	/// Draw a line.
-	virtual void drawLines(const Vec3* lines, const U32 vertCount, const Vec4& color) = 0;
-
-	void drawWorld(const PhysicsWorld& world);
-
-private:
-	class DebugDraw : public btIDebugDraw
-	{
-	public:
-		PhysicsDrawer* m_drawer = nullptr;
-
-		DebugDraw(PhysicsDrawer* drawer)
-			: m_drawer(drawer)
-		{
-		}
-
-		void drawLine(const btVector3& from, const btVector3& to, const btVector3& color) override
-		{
-			Array<Vec3, 2> lines = {toAnki(from), toAnki(to)};
-			m_drawer->drawLines(&lines[0], 2, Vec4(toAnki(color), 1.0f));
-		}
-
-		void drawContactPoint([[maybe_unused]] const btVector3& PointOnB, [[maybe_unused]] const btVector3& normalOnB,
-							  [[maybe_unused]] btScalar distance, [[maybe_unused]] int lifeTime, [[maybe_unused]] const btVector3& color) override
-		{
-			// TODO
-		}
-
-		void reportErrorWarning(const char* warningString) override
-		{
-			ANKI_PHYS_LOGW("%s", warningString);
-		}
-
-		void draw3dText([[maybe_unused]] const btVector3& location, [[maybe_unused]] const char* textString) override
-		{
-			// TODO
-		}
-
-		void setDebugMode([[maybe_unused]] int debugMode) override
-		{
-			// TODO
-		}
-
-		int getDebugMode() const override
-		{
-			return btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb;
-		}
-	};
-
-	DebugDraw m_debugDraw;
-};
-/// @}
-
-} // end namespace anki

+ 0 - 75
AnKi/Physics/PhysicsJoint.cpp

@@ -1,75 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsJoint.h>
-#include <AnKi/Physics/PhysicsBody.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-
-namespace anki {
-
-PhysicsJoint::PhysicsJoint(JointType type)
-	: PhysicsObject(kClassType)
-	, m_type(type)
-{
-}
-
-void PhysicsJoint::registerToWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().addConstraint(getJoint());
-}
-
-void PhysicsJoint::unregisterFromWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().removeConstraint(getJoint());
-}
-
-PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsBodyPtr bodyA, const Vec3& relPos)
-	: PhysicsJoint(JointType::kP2P)
-{
-	m_bodyA = std::move(bodyA);
-	m_p2p.construct(*m_bodyA->getBtBody(), toBt(relPos));
-	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
-}
-
-PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsBodyPtr bodyA, const Vec3& relPosA, PhysicsBodyPtr bodyB, const Vec3& relPosB)
-	: PhysicsJoint(JointType::kP2P)
-{
-	ANKI_ASSERT(bodyA != bodyB);
-	m_bodyA = std::move(bodyA);
-	m_bodyB = std::move(bodyB);
-
-	m_p2p.construct(*m_bodyA->getBtBody(), *m_bodyB->getBtBody(), toBt(relPosA), toBt(relPosB));
-	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
-}
-
-PhysicsPoint2PointJoint::~PhysicsPoint2PointJoint()
-{
-	m_p2p.destroy();
-}
-
-PhysicsHingeJoint::PhysicsHingeJoint(PhysicsBodyPtr bodyA, const Vec3& relPos, const Vec3& axis)
-	: PhysicsJoint(JointType::kHinge)
-{
-	m_bodyA = std::move(bodyA);
-	m_hinge.construct(*m_bodyA->getBtBody(), toBt(relPos), toBt(axis));
-	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
-}
-
-PhysicsHingeJoint::PhysicsHingeJoint(PhysicsBodyPtr bodyA, const Vec3& relPosA, const Vec3& axisA, PhysicsBodyPtr bodyB, const Vec3& relPosB,
-									 const Vec3& axisB)
-	: PhysicsJoint(JointType::kHinge)
-{
-	m_bodyA = std::move(bodyA);
-	m_bodyB = std::move(bodyB);
-	m_hinge.construct(*m_bodyA->getBtBody(), *m_bodyB->getBtBody(), toBt(relPosA), toBt(relPosB), toBt(axisA), toBt(axisB));
-	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
-}
-
-PhysicsHingeJoint::~PhysicsHingeJoint()
-{
-	m_hinge.destroy();
-}
-
-} // end namespace anki

+ 0 - 115
AnKi/Physics/PhysicsJoint.h

@@ -1,115 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Util/ClassWrapper.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// Joint base class. Joints connect two (or a single one) rigid bodies together.
-class PhysicsJoint : public PhysicsObject
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kJoint)
-
-public:
-	/// Set the breaking impulse.
-	void setBreakingImpulseThreshold(F32 impulse)
-	{
-		getJoint()->setBreakingImpulseThreshold(impulse);
-	}
-
-	/// Return true if the joint broke.
-	Bool isBroken() const
-	{
-		return !getJoint()->isEnabled();
-	}
-
-	/// Break the joint.
-	void brake()
-	{
-		getJoint()->setEnabled(false);
-	}
-
-protected:
-	union
-	{
-		ClassWrapper<btPoint2PointConstraint> m_p2p;
-		ClassWrapper<btHingeConstraint> m_hinge;
-	};
-
-	PhysicsBodyPtr m_bodyA;
-	PhysicsBodyPtr m_bodyB;
-
-	enum class JointType : U8
-	{
-		kP2P,
-		kHinge,
-	};
-
-	JointType m_type;
-
-	PhysicsJoint(JointType type);
-
-	void registerToWorld() override;
-	void unregisterFromWorld() override;
-
-	const btTypedConstraint* getJoint() const
-	{
-		return getJointInternal();
-	}
-
-	btTypedConstraint* getJoint()
-	{
-		return const_cast<btTypedConstraint*>(getJointInternal());
-	}
-
-	const btTypedConstraint* getJointInternal() const
-	{
-		switch(m_type)
-		{
-		case JointType::kP2P:
-			return m_p2p.get();
-		case JointType::kHinge:
-			return m_hinge.get();
-		default:
-			ANKI_ASSERT(0);
-			return nullptr;
-		}
-	}
-};
-
-/// Point to point joint.
-class PhysicsPoint2PointJoint : public PhysicsJoint
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kJoint)
-
-private:
-	PhysicsPoint2PointJoint(PhysicsBodyPtr bodyA, const Vec3& relPos);
-
-	PhysicsPoint2PointJoint(PhysicsBodyPtr bodyA, const Vec3& relPosA, PhysicsBodyPtr bodyB, const Vec3& relPosB);
-
-	~PhysicsPoint2PointJoint();
-};
-
-/// Hinge joint.
-class PhysicsHingeJoint : public PhysicsJoint
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kJoint)
-
-private:
-	PhysicsHingeJoint(PhysicsBodyPtr bodyA, const Vec3& relPos, const Vec3& axis);
-
-	PhysicsHingeJoint(PhysicsBodyPtr bodyA, const Vec3& relPosA, const Vec3& axisA, PhysicsBodyPtr bodyB, const Vec3& relPosB, const Vec3& axisB);
-
-	~PhysicsHingeJoint();
-};
-/// @}
-
-} // end namespace anki

+ 0 - 29
AnKi/Physics/PhysicsObject.cpp

@@ -1,29 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-
-namespace anki {
-
-PhysicsFilteredObject::~PhysicsFilteredObject()
-{
-	for(PhysicsTriggerFilteredPair* pair : m_triggerFilteredPairs)
-	{
-		if(pair == nullptr)
-		{
-			continue;
-		}
-
-		pair->m_filteredObject = nullptr;
-
-		if(pair->shouldDelete())
-		{
-			deleteInstance(PhysicsMemoryPool::getSingleton(), pair);
-		}
-	}
-}
-
-} // end namespace anki

+ 0 - 193
AnKi/Physics/PhysicsObject.h

@@ -1,193 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/Common.h>
-#include <AnKi/Util/List.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// Type of the physics object.
-enum class PhysicsObjectType : U8
-{
-	kCollisionShape,
-	kJoint,
-	kBody,
-	kPlayerController,
-	kTrigger,
-
-	kCount,
-	kFirst = 0,
-	kLast = kCount - 1,
-	kFirstFiltered = kBody,
-	kLastFiltered = kTrigger,
-};
-ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(PhysicsObjectType)
-
-#define ANKI_PHYSICS_OBJECT_FRIENDS \
-	friend class PhysicsWorld; \
-	friend class PhysicsPtrDeleter; \
-	template<typename T, typename TDeleter> \
-	friend class IntrusivePtr; \
-	ANKI_FRIEND_CALL_CONSTRUCTOR_AND_DESTRUCTOR
-
-#define ANKI_PHYSICS_OBJECT(type) \
-	ANKI_PHYSICS_OBJECT_FRIENDS \
-public: \
-	static constexpr PhysicsObjectType kClassType = type; \
-\
-private:
-
-/// Base of all physics objects.
-class PhysicsObject : public IntrusiveListEnabled<PhysicsObject>
-{
-	ANKI_PHYSICS_OBJECT_FRIENDS
-
-public:
-	PhysicsObject(PhysicsObjectType type)
-		: m_type(type)
-	{
-	}
-
-	virtual ~PhysicsObject()
-	{
-		ANKI_ASSERT(!m_registered);
-	}
-
-	PhysicsObjectType getType() const
-	{
-		return m_type;
-	}
-
-	void setUserData(void* ud)
-	{
-		m_userData = ud;
-	}
-
-	void* getUserData() const
-	{
-		return m_userData;
-	}
-
-protected:
-	void retain() const
-	{
-		m_refcount.fetchAdd(1);
-	}
-
-	I32 release() const
-	{
-		return m_refcount.fetchSub(1);
-	}
-
-private:
-	mutable Atomic<I32> m_refcount = {0};
-	void* m_userData = nullptr;
-
-	PhysicsObjectType m_type;
-	Bool m_registered = false;
-
-	virtual void registerToWorld() = 0;
-
-	virtual void unregisterFromWorld() = 0;
-};
-
-/// This is a factor that will decide if two filtered objects will be checked for collision.
-/// @memberof PhysicsFilteredObject
-class PhysicsBroadPhaseFilterCallback
-{
-public:
-	virtual Bool needsCollision(const PhysicsFilteredObject& a, const PhysicsFilteredObject& b) = 0;
-};
-
-/// A pair of a trigger and a filtered object.
-class PhysicsTriggerFilteredPair
-{
-public:
-	PhysicsFilteredObject* m_filteredObject = nullptr;
-	PhysicsTrigger* m_trigger = nullptr;
-	U64 m_frame = 0;
-
-	Bool isAlive() const
-	{
-		return m_filteredObject && m_trigger;
-	}
-
-	Bool shouldDelete() const
-	{
-		return m_filteredObject == nullptr && m_trigger == nullptr;
-	}
-};
-
-/// A PhysicsObject that takes part into collision detection. Has functionality to filter the broad phase detection.
-class PhysicsFilteredObject : public PhysicsObject
-{
-public:
-	ANKI_PHYSICS_OBJECT_FRIENDS
-
-	PhysicsFilteredObject(PhysicsObjectType type)
-		: PhysicsObject(type)
-	{
-	}
-
-	~PhysicsFilteredObject();
-
-	static Bool classof(const PhysicsObject* obj)
-	{
-		return obj->getType() >= PhysicsObjectType::kFirstFiltered && obj->getType() <= PhysicsObjectType::kLastFiltered;
-	}
-
-	/// Get the material(s) this object belongs.
-	PhysicsMaterialBit getMaterialGroup() const
-	{
-		return m_materialGroup;
-	}
-
-	/// Set the material(s) this object belongs.
-	void setMaterialGroup(PhysicsMaterialBit bits)
-	{
-		m_materialGroup = bits;
-	}
-
-	/// Get the materials this object collides.
-	PhysicsMaterialBit getMaterialMask() const
-	{
-		return m_materialMask;
-	}
-
-	/// Set the materials this object collides.
-	void setMaterialMask(PhysicsMaterialBit bit)
-	{
-		m_materialMask = bit;
-	}
-
-	/// Get the broadphase callback.
-	PhysicsBroadPhaseFilterCallback* getPhysicsBroadPhaseFilterCallback() const
-	{
-		return m_filter;
-	}
-
-	/// Set the broadphase callback.
-	void setPhysicsBroadPhaseFilterCallback(PhysicsBroadPhaseFilterCallback* f)
-	{
-		m_filter = f;
-	}
-
-private:
-	PhysicsMaterialBit m_materialGroup = PhysicsMaterialBit::kAll;
-	PhysicsMaterialBit m_materialMask = PhysicsMaterialBit::kAll;
-
-	PhysicsBroadPhaseFilterCallback* m_filter = nullptr;
-
-	static constexpr U32 kMaxTriggerFilteredPairs = 4;
-	Array<PhysicsTriggerFilteredPair*, kMaxTriggerFilteredPairs> m_triggerFilteredPairs = {};
-};
-/// @}
-
-} // end namespace anki

+ 0 - 69
AnKi/Physics/PhysicsPlayerController.cpp

@@ -1,69 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsPlayerController.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-
-namespace anki {
-
-PhysicsPlayerController::PhysicsPlayerController(const PhysicsPlayerControllerInitInfo& init)
-	: PhysicsFilteredObject(kClassType)
-{
-	const btTransform trf = toBt(Transform(init.m_position.xyz0(), Mat3x4::getIdentity(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
-
-	m_convexShape.construct(init.m_outerRadius, init.m_height);
-
-	m_ghostObject.construct();
-	m_ghostObject->setWorldTransform(trf);
-	m_ghostObject->setCollisionShape(m_convexShape.get());
-	m_ghostObject->setUserPointer(static_cast<PhysicsObject*>(this));
-	setMaterialGroup(PhysicsMaterialBit::kPlayer);
-	setMaterialMask(PhysicsMaterialBit::kAll);
-
-	m_controller.construct(m_ghostObject.get(), m_convexShape.get(), init.m_stepHeight, btVector3(0, 1, 0));
-
-	// Need to call this else the player is upside down
-	moveToPosition(init.m_position);
-}
-
-PhysicsPlayerController::~PhysicsPlayerController()
-{
-	m_controller.destroy();
-	m_ghostObject.destroy();
-	m_convexShape.destroy();
-}
-
-void PhysicsPlayerController::registerToWorld()
-{
-	btDynamicsWorld& btworld = PhysicsWorld::getSingleton().getBtWorld();
-	btworld.addCollisionObject(m_ghostObject.get(), btBroadphaseProxy::CharacterFilter,
-							   btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
-	btworld.addAction(m_controller.get());
-}
-
-void PhysicsPlayerController::unregisterFromWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().removeAction(m_controller.get());
-	PhysicsWorld::getSingleton().getBtWorld().removeCollisionObject(m_ghostObject.get());
-}
-
-void PhysicsPlayerController::moveToPositionForReal()
-{
-	if(m_moveToPosition.x() == kMaxF32)
-	{
-		return;
-	}
-
-	btDynamicsWorld& btworld = PhysicsWorld::getSingleton().getBtWorld();
-
-	btworld.getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_ghostObject->getBroadphaseHandle(), btworld.getDispatcher());
-
-	m_controller->reset(&btworld);
-	m_controller->warp(toBt(m_moveToPosition));
-
-	m_moveToPosition.x() = kMaxF32;
-}
-
-} // end namespace anki

+ 0 - 70
AnKi/Physics/PhysicsPlayerController.h

@@ -1,70 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Util/ClassWrapper.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// Init info for PhysicsPlayerController.
-class PhysicsPlayerControllerInitInfo
-{
-public:
-	F32 m_mass = 83.0f;
-	F32 m_innerRadius = 0.30f;
-	F32 m_outerRadius = 0.50f;
-	F32 m_height = 1.9f;
-	F32 m_stepHeight = 1.9f * 0.33f;
-	Vec3 m_position = Vec3(0.0f);
-};
-
-/// A player controller that walks the world.
-class PhysicsPlayerController final : public PhysicsFilteredObject
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kPlayerController)
-
-public:
-	// Update the state machine
-	void setVelocity(F32 forwardSpeed, [[maybe_unused]] F32 strafeSpeed, [[maybe_unused]] F32 jumpSpeed, const Vec4& forwardDir)
-	{
-		m_controller->setWalkDirection(toBt((forwardDir * forwardSpeed).xyz()));
-	}
-
-	/// This is a deferred operation, will happen on the next PhysicsWorld::update.
-	void moveToPosition(const Vec3& position)
-	{
-		m_moveToPosition = position;
-	}
-
-	Transform getTransform()
-	{
-		return toAnki(m_ghostObject->getWorldTransform());
-	}
-
-private:
-	ClassWrapper<btPairCachingGhostObject> m_ghostObject;
-	ClassWrapper<btCapsuleShape> m_convexShape;
-	ClassWrapper<btKinematicCharacterController> m_controller;
-	Vec3 m_moveToPosition = Vec3(kMaxF32);
-
-	PhysicsPlayerController(const PhysicsPlayerControllerInitInfo& init);
-
-	~PhysicsPlayerController();
-
-	void registerToWorld() override;
-
-	void unregisterFromWorld() override;
-
-	/// Called in PhysicsWorld::update.
-	void moveToPositionForReal();
-};
-/// @}
-
-} // end namespace anki

+ 0 - 132
AnKi/Physics/PhysicsTrigger.cpp

@@ -1,132 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsTrigger.h>
-#include <AnKi/Physics/PhysicsCollisionShape.h>
-#include <AnKi/Physics/PhysicsWorld.h>
-#include <AnKi/Util/Rtti.h>
-
-namespace anki {
-
-PhysicsTrigger::PhysicsTrigger(PhysicsCollisionShapePtr shape)
-	: PhysicsFilteredObject(kClassType)
-{
-	m_shape = shape;
-
-	m_ghostShape.construct();
-	m_ghostShape->setWorldTransform(btTransform::getIdentity());
-	m_ghostShape->setCollisionShape(shape->getBtShape(true));
-
-	// If you don't have that bodies will bounce on the trigger
-	m_ghostShape->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
-
-	m_ghostShape->setUserPointer(static_cast<PhysicsObject*>(this));
-
-	setMaterialGroup(PhysicsMaterialBit::kTrigger);
-	setMaterialMask(PhysicsMaterialBit::kAll ^ PhysicsMaterialBit::kStaticGeometry);
-}
-
-PhysicsTrigger::~PhysicsTrigger()
-{
-	for(PhysicsTriggerFilteredPair* pair : m_pairs)
-	{
-		ANKI_ASSERT(pair);
-
-		pair->m_trigger = nullptr;
-
-		if(pair->shouldDelete())
-		{
-			deleteInstance(PhysicsMemoryPool::getSingleton(), pair);
-		}
-	}
-
-	m_ghostShape.destroy();
-}
-
-void PhysicsTrigger::registerToWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().addCollisionObject(m_ghostShape.get());
-}
-
-void PhysicsTrigger::unregisterFromWorld()
-{
-	PhysicsWorld::getSingleton().getBtWorld().removeCollisionObject(m_ghostShape.get());
-}
-
-void PhysicsTrigger::processContacts()
-{
-	++m_processContactsFrame;
-
-	if(m_contactCallback == nullptr)
-	{
-		m_pairs.destroy();
-		return;
-	}
-
-	// Gather the new pairs
-	DynamicArray<PhysicsTriggerFilteredPair*, MemoryPoolPtrWrapper<StackMemoryPool>> newPairs(&PhysicsWorld::getSingleton().getTempMemoryPool());
-	newPairs.resizeStorage(m_ghostShape->getOverlappingPairs().size());
-	for(U32 i = 0; i < U32(m_ghostShape->getOverlappingPairs().size()); ++i)
-	{
-		btCollisionObject* bobj = m_ghostShape->getOverlappingPairs()[i];
-		ANKI_ASSERT(bobj);
-		PhysicsObject* aobj = static_cast<PhysicsObject*>(bobj->getUserPointer());
-		ANKI_ASSERT(aobj);
-		PhysicsFilteredObject* obj = dcast<PhysicsFilteredObject*>(aobj);
-
-		Bool isNew;
-		PhysicsTriggerFilteredPair* pair = PhysicsWorld::getSingleton().getOrCreatePhysicsTriggerFilteredPair(this, obj, isNew);
-		if(pair)
-		{
-			ANKI_ASSERT(pair->isAlive());
-			newPairs.emplaceBack(pair);
-
-			if(isNew)
-			{
-				m_contactCallback->onTriggerEnter(*this, *obj);
-			}
-			else
-			{
-				m_contactCallback->onTriggerInside(*this, *obj);
-			}
-
-			pair->m_frame = m_processContactsFrame;
-		}
-	}
-
-	// Remove stale pairs
-	for(U32 i = 0; i < m_pairs.getSize(); ++i)
-	{
-		PhysicsTriggerFilteredPair* pair = m_pairs[i];
-		ANKI_ASSERT(pair->m_trigger == this);
-
-		if(pair->m_filteredObject == nullptr)
-		{
-			// Filtered object died while inside the tigger, destroy the pair
-			deleteInstance(PhysicsMemoryPool::getSingleton(), pair);
-		}
-		else if(pair->m_frame == m_processContactsFrame)
-		{
-			// Was updated this frame so don't touch it
-		}
-		else
-		{
-			// Was updated in some previous frame, notify and brake the link to the pair
-			ANKI_ASSERT(pair->isAlive());
-			ANKI_ASSERT(pair->m_frame < m_processContactsFrame);
-			m_contactCallback->onTriggerExit(*this, *pair->m_filteredObject);
-			pair->m_trigger = nullptr;
-		}
-	}
-
-	// Store the new contacts
-	m_pairs.resize(newPairs.getSize());
-	if(m_pairs.getSize())
-	{
-		memcpy(&m_pairs[0], &newPairs[0], m_pairs.getSizeInBytes());
-	}
-}
-
-} // end namespace anki

+ 0 - 82
AnKi/Physics/PhysicsTrigger.h

@@ -1,82 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Util/WeakArray.h>
-#include <AnKi/Util/ClassWrapper.h>
-#include <AnKi/Util/HashMap.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// An interface to process contacts.
-/// @memberof PhysicsTrigger
-class PhysicsTriggerProcessContactCallback
-{
-public:
-	/// Will be called whenever a contact first touches a trigger.
-	virtual void onTriggerEnter([[maybe_unused]] PhysicsTrigger& trigger, [[maybe_unused]] PhysicsFilteredObject& obj)
-	{
-	}
-
-	/// Will be called whenever a contact touches a trigger.
-	virtual void onTriggerInside([[maybe_unused]] PhysicsTrigger& trigger, [[maybe_unused]] PhysicsFilteredObject& obj)
-	{
-	}
-
-	/// Will be called whenever a contact stops touching a trigger.
-	virtual void onTriggerExit([[maybe_unused]] PhysicsTrigger& trigger, [[maybe_unused]] PhysicsFilteredObject& obj)
-	{
-	}
-};
-
-/// A trigger that uses a PhysicsShape and its purpose is to collect collision events.
-class PhysicsTrigger : public PhysicsFilteredObject
-{
-	ANKI_PHYSICS_OBJECT(PhysicsObjectType::kTrigger)
-
-public:
-	Transform getTransform() const
-	{
-		return toAnki(m_ghostShape->getWorldTransform());
-	}
-
-	void setTransform(const Transform& trf)
-	{
-		m_ghostShape->setWorldTransform(toBt(trf));
-	}
-
-	void setContactProcessCallback(PhysicsTriggerProcessContactCallback* cb)
-	{
-		m_contactCallback = cb;
-	}
-
-private:
-	PhysicsCollisionShapePtr m_shape;
-	ClassWrapper<btGhostObject> m_ghostShape;
-
-	PhysicsDynamicArray<PhysicsTriggerFilteredPair*> m_pairs;
-
-	PhysicsTriggerProcessContactCallback* m_contactCallback = nullptr;
-
-	U64 m_processContactsFrame = 0;
-
-	PhysicsTrigger(PhysicsCollisionShapePtr shape);
-
-	~PhysicsTrigger();
-
-	void registerToWorld() override;
-
-	void unregisterFromWorld() override;
-
-	void processContacts();
-};
-/// @}
-
-} // end namespace anki

+ 0 - 337
AnKi/Physics/PhysicsWorld.cpp

@@ -1,337 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Physics/PhysicsWorld.h>
-#include <AnKi/Physics/PhysicsCollisionShape.h>
-#include <AnKi/Physics/PhysicsBody.h>
-#include <AnKi/Physics/PhysicsTrigger.h>
-#include <AnKi/Physics/PhysicsPlayerController.h>
-#include <AnKi/Util/Rtti.h>
-#include <BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h>
-
-namespace anki {
-
-static void* btAlloc(size_t size)
-{
-	return PhysicsMemoryPool::getSingleton().allocate(size, 16);
-}
-
-static void btFree(void* ptr)
-{
-	PhysicsMemoryPool::getSingleton().free(ptr);
-}
-
-/// Broad phase collision callback.
-class PhysicsWorld::MyOverlapFilterCallback : public btOverlapFilterCallback
-{
-public:
-	Bool needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const override
-	{
-		ANKI_ASSERT(proxy0 && proxy1);
-
-		const btCollisionObject* btObj0 = static_cast<const btCollisionObject*>(proxy0->m_clientObject);
-		const btCollisionObject* btObj1 = static_cast<const btCollisionObject*>(proxy1->m_clientObject);
-		ANKI_ASSERT(btObj0 && btObj1);
-
-		const PhysicsObject* aobj0 = static_cast<const PhysicsObject*>(btObj0->getUserPointer());
-		const PhysicsObject* aobj1 = static_cast<const PhysicsObject*>(btObj1->getUserPointer());
-
-		if(aobj0 == nullptr || aobj1 == nullptr)
-		{
-			return false;
-		}
-
-		const PhysicsFilteredObject* fobj0 = dcast<const PhysicsFilteredObject*>(aobj0);
-		const PhysicsFilteredObject* fobj1 = dcast<const PhysicsFilteredObject*>(aobj1);
-
-		// First check the masks
-		Bool collide = !!(fobj0->getMaterialGroup() & fobj1->getMaterialMask());
-		collide = collide && !!(fobj1->getMaterialGroup() & fobj0->getMaterialMask());
-		if(!collide)
-		{
-			return false;
-		}
-
-		// Reject if they are both static
-		if(fobj0->getMaterialGroup() == PhysicsMaterialBit::kStaticGeometry && fobj1->getMaterialGroup() == PhysicsMaterialBit::kStaticGeometry)
-			[[unlikely]]
-		{
-			return false;
-		}
-
-		// Detailed tests using callbacks
-		if(fobj0->getPhysicsBroadPhaseFilterCallback())
-		{
-			collide = fobj0->getPhysicsBroadPhaseFilterCallback()->needsCollision(*fobj0, *fobj1);
-			if(!collide)
-			{
-				return false;
-			}
-		}
-
-		if(fobj1->getPhysicsBroadPhaseFilterCallback())
-		{
-			collide = fobj1->getPhysicsBroadPhaseFilterCallback()->needsCollision(*fobj1, *fobj0);
-			if(!collide)
-			{
-				return false;
-			}
-		}
-
-		return true;
-	}
-};
-
-class PhysicsWorld::MyRaycastCallback : public btCollisionWorld::RayResultCallback
-{
-public:
-	PhysicsWorldRayCastCallback* m_raycast = nullptr;
-
-	Bool needsCollision(btBroadphaseProxy* proxy) const override
-	{
-		ANKI_ASSERT(proxy);
-
-		const btCollisionObject* cobj = static_cast<const btCollisionObject*>(proxy->m_clientObject);
-		ANKI_ASSERT(cobj);
-
-		const PhysicsObject* pobj = static_cast<const PhysicsObject*>(cobj->getUserPointer());
-		ANKI_ASSERT(pobj);
-
-		const PhysicsFilteredObject* fobj = dcast<const PhysicsFilteredObject*>(pobj);
-
-		return !!(fobj->getMaterialGroup() & m_raycast->m_materialMask);
-	}
-
-	btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult, Bool normalInWorldSpace) final
-	{
-		// No idea why
-		if(m_raycast->m_firstHit)
-		{
-			m_closestHitFraction = rayResult.m_hitFraction;
-		}
-
-		m_collisionObject = rayResult.m_collisionObject;
-		Vec3 worldNormal;
-		if(normalInWorldSpace)
-		{
-			worldNormal = toAnki(rayResult.m_hitNormalLocal);
-		}
-		else
-		{
-			worldNormal = toAnki(m_collisionObject->getWorldTransform().getBasis() * rayResult.m_hitNormalLocal);
-		}
-
-		Vec3 hitPointWorld = mix(m_raycast->m_from, m_raycast->m_to, rayResult.m_hitFraction);
-
-		// Call the callback
-		PhysicsObject* pobj = static_cast<PhysicsObject*>(m_collisionObject->getUserPointer());
-		ANKI_ASSERT(pobj);
-		m_raycast->processResult(dcast<PhysicsFilteredObject&>(*pobj), worldNormal, hitPointWorld);
-
-		return m_closestHitFraction;
-	}
-};
-
-PhysicsWorld::PhysicsWorld()
-{
-}
-
-PhysicsWorld::~PhysicsWorld()
-{
-	destroyMarkedForDeletion();
-
-	ANKI_ASSERT(m_objectsCreatedCount.load() == 0 && "Forgot to delete some objects");
-
-	m_world.destroy();
-	m_solver.destroy();
-	m_dispatcher.destroy();
-	m_collisionConfig.destroy();
-	m_broadphase.destroy();
-	m_gpc.destroy();
-	deleteInstance(PhysicsMemoryPool::getSingleton(), m_filterCallback);
-
-	PhysicsMemoryPool::freeSingleton();
-}
-
-Error PhysicsWorld::init(AllocAlignedCallback allocCb, void* allocCbData)
-{
-	PhysicsMemoryPool::allocateSingleton(allocCb, allocCbData);
-
-	m_tmpPool.init(allocCb, allocCbData, 1_KB, 2.0f);
-
-	// Set allocators
-	btAlignedAllocSetCustom(btAlloc, btFree);
-
-	// Create objects
-	m_broadphase.construct();
-	m_gpc.construct();
-	m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_gpc.get());
-	m_filterCallback = anki::newInstance<MyOverlapFilterCallback>(PhysicsMemoryPool::getSingleton());
-	m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback);
-
-	m_collisionConfig.construct();
-
-	m_dispatcher.construct(m_collisionConfig.get());
-	btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher.get());
-
-	m_solver.construct();
-
-	m_world.construct(m_dispatcher.get(), m_broadphase.get(), m_solver.get(), m_collisionConfig.get());
-	m_world->setGravity(btVector3(0.0f, -9.8f, 0.0f));
-
-	return Error::kNone;
-}
-
-void PhysicsWorld::destroyMarkedForDeletion()
-{
-	while(true)
-	{
-		PhysicsObject* obj = nullptr;
-
-		// Don't delete the instance (call the destructor) while holding the lock to avoid deadlocks
-		{
-			LockGuard<Mutex> lock(m_markedMtx);
-			if(!m_markedForDeletion.isEmpty())
-			{
-				obj = m_markedForDeletion.popFront();
-				if(obj->m_registered)
-				{
-					obj->unregisterFromWorld();
-					obj->m_registered = false;
-				}
-			}
-		}
-
-		if(obj == nullptr)
-		{
-			break;
-		}
-
-		deleteInstance(PhysicsMemoryPool::getSingleton(), obj);
-#if ANKI_ASSERTIONS_ENABLED
-		const I32 count = m_objectsCreatedCount.fetchSub(1) - 1;
-		ANKI_ASSERT(count >= 0);
-#endif
-	}
-}
-
-void PhysicsWorld::update(Second dt)
-{
-	// First destroy
-	destroyMarkedForDeletion();
-
-	// Create new objects
-	{
-		LockGuard<Mutex> lock(m_markedMtx);
-
-		// Create
-		while(!m_markedForCreation.isEmpty())
-		{
-			PhysicsObject* obj = m_markedForCreation.popFront();
-			ANKI_ASSERT(!obj->m_registered);
-			obj->registerToWorld();
-			obj->m_registered = true;
-			m_objectLists[obj->getType()].pushBack(obj);
-		}
-	}
-
-	// Update the player controllers
-	for(PhysicsObject& obj : m_objectLists[PhysicsObjectType::kPlayerController])
-	{
-		PhysicsPlayerController& playerController = static_cast<PhysicsPlayerController&>(obj);
-		playerController.moveToPositionForReal();
-	}
-
-	// Update world
-	m_world->stepSimulation(F32(dt), 1, 1.0f / 60.0f);
-
-	// Process trigger contacts
-	for(PhysicsObject& trigger : m_objectLists[PhysicsObjectType::kTrigger])
-	{
-		static_cast<PhysicsTrigger&>(trigger).processContacts();
-	}
-
-	// Reset the pool
-	m_tmpPool.reset();
-}
-
-void PhysicsWorld::destroyObject(PhysicsObject* obj)
-{
-	ANKI_ASSERT(obj);
-	LockGuard<Mutex> lock(m_markedMtx);
-	if(obj->m_registered)
-	{
-		m_objectLists[obj->getType()].erase(obj);
-	}
-	else
-	{
-		m_markedForCreation.erase(obj);
-	}
-	m_markedForDeletion.pushBack(obj);
-}
-
-void PhysicsWorld::rayCast(WeakArray<PhysicsWorldRayCastCallback*> rayCasts) const
-{
-	MyRaycastCallback callback;
-	for(PhysicsWorldRayCastCallback* cb : rayCasts)
-	{
-		callback.m_raycast = cb;
-		m_world->rayTest(toBt(cb->m_from), toBt(cb->m_to), callback);
-	}
-}
-
-PhysicsTriggerFilteredPair* PhysicsWorld::getOrCreatePhysicsTriggerFilteredPair(PhysicsTrigger* trigger, PhysicsFilteredObject* filtered, Bool& isNew)
-{
-	ANKI_ASSERT(trigger && filtered);
-
-	U32 emptySlot = kMaxU32;
-	for(U32 i = 0; i < filtered->m_triggerFilteredPairs.getSize(); ++i)
-	{
-		PhysicsTriggerFilteredPair* pair = filtered->m_triggerFilteredPairs[i];
-
-		if(pair && pair->m_trigger == trigger)
-		{
-			// Found it
-			ANKI_ASSERT(pair->m_filteredObject == filtered);
-			isNew = false;
-			return pair;
-		}
-		else if(pair == nullptr)
-		{
-			// Empty slot, save it for later
-			emptySlot = i;
-		}
-		else if(pair && pair->m_trigger == nullptr)
-		{
-			// Pair exists but it's invalid, repurpose it
-			ANKI_ASSERT(pair->m_filteredObject == filtered);
-			emptySlot = i;
-		}
-	}
-
-	if(emptySlot == kMaxU32)
-	{
-		ANKI_PHYS_LOGW("Contact ignored. Too many active contacts for the filtered object");
-		return nullptr;
-	}
-
-	// Not found, create a new one
-	isNew = true;
-
-	PhysicsTriggerFilteredPair* newPair;
-	if(filtered->m_triggerFilteredPairs[emptySlot] == nullptr)
-	{
-		filtered->m_triggerFilteredPairs[emptySlot] = anki::newInstance<PhysicsTriggerFilteredPair>(PhysicsMemoryPool::getSingleton());
-	}
-	newPair = filtered->m_triggerFilteredPairs[emptySlot];
-
-	newPair->m_filteredObject = filtered;
-	newPair->m_trigger = trigger;
-	newPair->m_frame = 0;
-
-	return newPair;
-}
-
-} // end namespace anki

+ 0 - 133
AnKi/Physics/PhysicsWorld.h

@@ -1,133 +0,0 @@
-// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Physics/Common.h>
-#include <AnKi/Physics/PhysicsObject.h>
-#include <AnKi/Util/List.h>
-#include <AnKi/Util/WeakArray.h>
-#include <AnKi/Util/ClassWrapper.h>
-
-namespace anki {
-
-/// @addtogroup physics
-/// @{
-
-/// Raycast callback (interface).
-class PhysicsWorldRayCastCallback
-{
-public:
-	Vec3 m_from;
-	Vec3 m_to;
-	PhysicsMaterialBit m_materialMask; ///< Materials to check
-	Bool m_firstHit = true;
-
-	PhysicsWorldRayCastCallback(const Vec3& from, const Vec3& to, PhysicsMaterialBit materialMask)
-		: m_from(from)
-		, m_to(to)
-		, m_materialMask(materialMask)
-	{
-	}
-
-	/// Process a raycast result.
-	virtual void processResult(PhysicsFilteredObject& obj, const Vec3& worldNormal, const Vec3& worldPosition) = 0;
-};
-
-/// The master container for all physics related stuff.
-class PhysicsWorld : public MakeSingleton<PhysicsWorld>
-{
-	template<typename>
-	friend class MakeSingleton;
-
-public:
-	Error init(AllocAlignedCallback allocCb, void* allocCbData);
-
-	template<typename T, typename... TArgs>
-	PhysicsPtr<T> newInstance(TArgs&&... args)
-	{
-		T* obj = static_cast<T*>(PhysicsMemoryPool::getSingleton().allocate(sizeof(T), alignof(T)));
-		callConstructor(*obj, std::forward<TArgs>(args)...);
-		{
-			LockGuard<Mutex> lock(m_markedMtx);
-			m_markedForCreation.pushBack(obj);
-		}
-#if ANKI_ASSERTIONS_ENABLED
-		const U32 count = m_objectsCreatedCount.fetchAdd(1) + 1;
-		ANKI_ASSERT(count > 0);
-#endif
-		return PhysicsPtr<T>(obj);
-	}
-
-	/// Do the update.
-	void update(Second dt);
-
-	StackMemoryPool& getTempMemoryPool()
-	{
-		return m_tmpPool;
-	}
-
-	void rayCast(WeakArray<PhysicsWorldRayCastCallback*> rayCasts) const;
-
-	void rayCast(PhysicsWorldRayCastCallback& raycast) const
-	{
-		PhysicsWorldRayCastCallback* ptr = &raycast;
-		WeakArray<PhysicsWorldRayCastCallback*> arr(&ptr, 1);
-		rayCast(arr);
-	}
-
-	ANKI_INTERNAL btDynamicsWorld& getBtWorld()
-	{
-		return *m_world;
-	}
-
-	ANKI_INTERNAL const btDynamicsWorld& getBtWorld() const
-	{
-		return *m_world;
-	}
-
-	ANKI_INTERNAL constexpr F32 getCollisionMargin() const
-	{
-		return 0.04f;
-	}
-
-	ANKI_INTERNAL void destroyObject(PhysicsObject* obj);
-
-	ANKI_INTERNAL PhysicsTriggerFilteredPair* getOrCreatePhysicsTriggerFilteredPair(PhysicsTrigger* trigger, PhysicsFilteredObject* filtered,
-																					Bool& isNew);
-
-private:
-	class MyOverlapFilterCallback;
-	class MyRaycastCallback;
-
-	StackMemoryPool m_tmpPool;
-
-	ClassWrapper<btDbvtBroadphase> m_broadphase;
-	ClassWrapper<btGhostPairCallback> m_gpc;
-	MyOverlapFilterCallback* m_filterCallback = nullptr;
-
-	ClassWrapper<btDefaultCollisionConfiguration> m_collisionConfig;
-	ClassWrapper<btCollisionDispatcher> m_dispatcher;
-	ClassWrapper<btSequentialImpulseConstraintSolver> m_solver;
-	ClassWrapper<btDiscreteDynamicsWorld> m_world;
-
-	Array<IntrusiveList<PhysicsObject>, U(PhysicsObjectType::kCount)> m_objectLists;
-	IntrusiveList<PhysicsObject> m_markedForCreation;
-	IntrusiveList<PhysicsObject> m_markedForDeletion;
-	Mutex m_markedMtx; ///< Locks the above
-
-#if ANKI_ASSERTIONS_ENABLED
-	Atomic<I32> m_objectsCreatedCount = {0};
-#endif
-
-	PhysicsWorld();
-
-	~PhysicsWorld();
-
-	void destroyMarkedForDeletion();
-};
-/// @}
-
-} // end namespace anki

+ 1 - 1
AnKi/Resource/CMakeLists.txt

@@ -2,4 +2,4 @@ file(GLOB_RECURSE sources *.cpp)
 file(GLOB_RECURSE headers *.h)
 add_library(AnKiResource ${sources} ${headers})
 target_compile_definitions(AnKiResource PRIVATE -DANKI_SOURCE_FILE)
-target_link_libraries(AnKiResource AnKiCore AnKiGr AnKiPhysics AnKiPhysics2 AnKiZLib AnKiShaderCompiler)
+target_link_libraries(AnKiResource AnKiCore AnKiGr AnKiPhysics2 AnKiZLib AnKiShaderCompiler)

+ 1 - 1
AnKi/Resource/ParticleEmitterResource.h

@@ -66,7 +66,7 @@ public:
 
 	U32 m_particlesPerEmission = 1; ///< How many particles are emitted every emission. Required
 
-	Bool m_usePhysicsEngine = false; ///< Use bullet for the simulation
+	Bool m_usePhysicsEngine = false; ///< Use Jolt for the simulation
 
 	Vec3 m_emitterBoundingVolumeMin = Vec3(0.0f); ///< Limit the size of the emitter. Mainly for visibility tests.
 

+ 1 - 1
AnKi/Scene/Components/ParticleEmitterComponent.cpp

@@ -123,7 +123,7 @@ public:
 	}
 };
 
-/// Particle for bullet simulations
+/// Particle for Jolt simulations
 class ParticleEmitterComponent::PhysicsParticle : public ParticleEmitterComponent::ParticleBase
 {
 public:

+ 1 - 10
CMakeLists.txt

@@ -297,15 +297,7 @@ endif()
 ################################################################################
 # Thirdparty                                                                   #
 ################################################################################
-set(ANKI_EXTERN_SUB_DIRS TinyXml2 Lua ZLib Bullet ImGui MeshOptimizer SpirvCross "Jolt/Build")
-
-# Bullet config
-option(BUILD_BULLET2_DEMOS OFF)
-option(BUILD_BULLET3 OFF)
-option(BUILD_CPU_DEMOS OFF)
-option(BUILD_OPENGL3_DEMOS OFF)
-option(BUILD_EXTRAS OFF)
-option(BUILD_UNIT_TESTS OFF)
+set(ANKI_EXTERN_SUB_DIRS TinyXml2 Lua ZLib ImGui MeshOptimizer SpirvCross "Jolt/Build")
 
 # Jolt config
 option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" OFF)
@@ -461,7 +453,6 @@ configure_file("AnKi/Config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/AnKi/Config.h"
 include_directories(
 	"ThirdParty/Khronos"
 	"${CMAKE_CURRENT_BINARY_DIR}"
-	"${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Bullet/src"
 	"ThirdParty"
 	"ThirdParty/ZLib"
 	"ThirdParty/Jolt"

+ 0 - 35
ThirdParty/Bullet/.travis.yml

@@ -1,35 +0,0 @@
-language: cpp
-os:
-  - linux
-  - osx
-compiler:
-  - gcc
-  - clang
-addons:
-  apt:
-    packages:
-      - python3
-
-
-script:
-  - echo "CXX="$CXX
-  - echo "CC="$CC
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then sudo apt-get install python3-pip; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then sudo pip3 install -U pip wheel; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then sudo pip3 install setuptools; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then sudo python3 setup.py install; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then python3 examples/pybullet/unittests/unittests.py --verbose; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then python3 examples/pybullet/unittests/userDataTest.py --verbose; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then python3 examples/pybullet/unittests/saveRestoreStateTest.py --verbose; fi
-  - cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror
-  - make -j8
-  - ctest -j8 --output-on-failure
-  # Build again with double precision
-  - cmake . -G "Unix Makefiles" -DUSE_DOUBLE_PRECISION=ON #-DCMAKE_CXX_FLAGS=-Werror
-  - make -j8
-  - ctest -j8 --output-on-failure
-  # Build again with shared libraries
-  - cmake . -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON
-  - make -j8
-  - ctest -j8 --output-on-failure
-  - sudo make install

+ 0 - 45
ThirdParty/Bullet/AUTHORS.txt

@@ -1,45 +0,0 @@
-Bullet Physics is created by Erwin Coumans with contributions from the following authors / copyright holders:
-
-AMD
-Apple
-Yunfei Bai
-Steve Baker
-Gino van den Bergen
-Jeff Bingham
-Nicola Candussi
-Erin Catto
-Lawrence Chai
-Erwin Coumans
-Disney Animation
-Benjamin Ellenberger
-Christer Ericson
-Google
-Dirk Gregorius
-Marcus Hennix
-Jasmine Hsu
-MBSim Development Team
-Takahiro Harada
-Simon Hobbs
-John Hsu
-Ole Kniemeyer
-Jay Lee
-Francisco Leon
-lunkhound
-Vsevolod Klementjev
-Phil Knight
-John McCutchan
-Steven Peters
-Roman Ponomarev
-Nathanael Presson
-Gabor PUHR
-Arthur Shek
-Russel Smith
-Sony
-Jakub Stephien
-Marten Svanfeldt
-Jie Tan
-Pierre Terdiman
-Steven Thompson
-Tamas Umenhoffer
-
-If your name is missing, please send an email to [email protected] or file an issue at http://github.com/bulletphysics/bullet3

+ 0 - 25
ThirdParty/Bullet/BulletConfig.cmake.in

@@ -1,25 +0,0 @@
-#                                               -*- cmake -*-
-#
-#  BulletConfig.cmake(.in)
-#
-
-# Use the following variables to compile and link against Bullet:
-#  BULLET_FOUND              - True if Bullet was found on your system
-#  BULLET_USE_FILE           - The file making Bullet usable
-#  BULLET_DEFINITIONS        - Definitions needed to build with Bullet
-#  BULLET_INCLUDE_DIR        - Directory where Bullet-C-Api.h can be found
-#  BULLET_INCLUDE_DIRS       - List of directories of Bullet and it's dependencies
-#  BULLET_LIBRARIES          - List of libraries to link against Bullet library
-#  BULLET_LIBRARY_DIRS       - List of directories containing Bullet' libraries
-#  BULLET_ROOT_DIR           - The base directory of Bullet
-#  BULLET_VERSION_STRING     - A human-readable string containing the version
-
-set ( BULLET_FOUND 1 )
-set ( BULLET_USE_FILE     "@BULLET_USE_FILE@" )
-set ( BULLET_DEFINITIONS  "@BULLET_DEFINITIONS@" )
-set ( BULLET_INCLUDE_DIR  "@INCLUDE_INSTALL_DIR@" )
-set ( BULLET_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@" )
-set ( BULLET_LIBRARIES    "@BULLET_LIBRARIES@" )
-set ( BULLET_LIBRARY_DIRS "@LIB_DESTINATION@" )
-set ( BULLET_ROOT_DIR     "@CMAKE_INSTALL_PREFIX@" )
-set ( BULLET_VERSION_STRING "@BULLET_VERSION@" )

+ 0 - 513
ThirdParty/Bullet/CMakeLists.txt

@@ -1,513 +0,0 @@
-cmake_minimum_required(VERSION 2.4.3)
-set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
-cmake_policy(SET CMP0017 NEW)
-#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
-SET(MSVC_INCREMENTAL_DEFAULT ON)
-
-PROJECT(BULLET_PHYSICS)
-FILE (STRINGS "VERSION" BULLET_VERSION)
-
-IF(COMMAND cmake_policy)
-   cmake_policy(SET CMP0003 NEW)
-   if(POLICY CMP0042)
-      # Enable MACOSX_RPATH by default.
-      cmake_policy(SET CMP0042 NEW)
-   endif(POLICY CMP0042)
-ENDIF(COMMAND cmake_policy)
-
-IF (NOT CMAKE_BUILD_TYPE)
-# SET(CMAKE_BUILD_TYPE "Debug")
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF (NOT CMAKE_BUILD_TYPE)
-
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
-#MESSAGE("CMAKE_CXX_FLAGS_DEBUG="+${CMAKE_CXX_FLAGS_DEBUG})
-
-OPTION(USE_DOUBLE_PRECISION "Use double precision"	OFF)
-SET(CLAMP_VELOCITIES "0" CACHE STRING "Clamp rigid bodies' velocity to this value, if larger than zero. Useful to prevent floating point errors or in general runaway velocities in complex scenarios")
-OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
-OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF)
-OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" ON)
-OPTION(USE_OPENVR "Use OpenVR for virtual reality" OFF)
-
-OPTION(ENABLE_VHACD "Use VHACD in BulletRobotics and pybullet" ON)
-
-OPTION(BULLET2_MULTITHREADING "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF)
-IF (BULLET2_MULTITHREADING)
-    OPTION(BULLET2_USE_OPEN_MP_MULTITHREADING "Build Bullet 2 with support for multi-threading with OpenMP (requires a compiler with OpenMP support)" OFF)
-    OPTION(BULLET2_USE_TBB_MULTITHREADING "Build Bullet 2 with support for multi-threading with Intel Threading Building Blocks (requires the TBB library to be already installed)" OFF)
-    IF (MSVC)
-        OPTION(BULLET2_USE_PPL_MULTITHREADING "Build Bullet 2 with support for multi-threading with Microsoft Parallel Patterns Library (requires MSVC compiler)" OFF)
-    ENDIF (MSVC)
-ENDIF (BULLET2_MULTITHREADING)
-
-
-IF(NOT WIN32)
-	SET(DL ${CMAKE_DL_LIBS})
-	IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
-		MESSAGE("Linux")
-		SET(OSDEF -D_LINUX)
-	ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
-		IF(APPLE)
-			MESSAGE("Apple")
-			SET(OSDEF -D_DARWIN)
-		ELSE(APPLE)
-			MESSAGE("BSD?")
-			SET(OSDEF -D_BSD)
-		ENDIF(APPLE)
-	ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
-ENDIF(NOT WIN32)
-
-OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
-
-#statically linking VC++ isn't supported for WindowsPhone/WindowsStore
-IF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
-	OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON)
-ELSE ()
-	OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" OFF)
-ENDIF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
-OPTION(USE_MSVC_RELEASE_RUNTIME_ALWAYS "Use MSVC Release Runtime Library even in Debug" OFF)
-
-#SET(CMAKE_EXE_LINKER_FLAGS_INIT    "/STACK:10000000 /INCREMENTAL:NO")
-#SET(CMAKE_EXE_LINKER_FLAGS    "/STACK:10000000 /INCREMENTAL:NO")
-
-#MESSAGE("MSVC_INCREMENTAL_YES_FLAG"+${MSVC_INCREMENTAL_YES_FLAG})
-
-
-IF(MSVC)
-	IF (NOT USE_MSVC_INCREMENTAL_LINKING)
-		#MESSAGE("MSVC_INCREMENTAL_DEFAULT"+${MSVC_INCREMENTAL_DEFAULT})
-		SET( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:NO")
-
-		STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
-		SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
-		MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
-
-		STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 "${CMAKE_EXE_LINKER_FLAGS}")
-
-		SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
-		STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 "${CMAKE_EXTRA_LINK_FLAGS}")
-
-		SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
-
-
-		STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
-		SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacementFlags3})
-		SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO ${replacementFlags3}" )
-
-	ENDIF (NOT USE_MSVC_INCREMENTAL_LINKING)
-
-	# godlike: Workaround to compile
-	IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL AND FALSE)
-		#We statically link to reduce dependencies
-		FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO )
-			IF(${flag_var} MATCHES "/MD")
-				STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
-			ENDIF(${flag_var} MATCHES "/MD")
-			IF(${flag_var} MATCHES "/MDd")
-				STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
-			ENDIF(${flag_var} MATCHES "/MDd")
-		ENDFOREACH(flag_var)
-	ENDIF ()
-
-	IF (USE_MSVC_RELEASE_RUNTIME_ALWAYS)
-		FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO )
-			IF(${flag_var} MATCHES "/MDd")
-				STRING(REGEX REPLACE "/MDd" "/MD" ${flag_var} "${${flag_var}}")
-			ENDIF(${flag_var} MATCHES "/MDd")
-			IF(${flag_var} MATCHES "/MTd")
-				STRING(REGEX REPLACE "/MTd" "/MT" ${flag_var} "${${flag_var}}")
-			ENDIF(${flag_var} MATCHES "/MTd")
-			# Need to remove _DEBUG too otherwise things like _ITERATOR_DEBUG_LEVEL mismatch
-			IF(${flag_var} MATCHES "-D_DEBUG")
-				STRING(REGEX REPLACE "-D_DEBUG" "" ${flag_var} "${${flag_var}}")
-			ENDIF(${flag_var} MATCHES "-D_DEBUG")
-		ENDFOREACH(flag_var)
-	ENDIF (USE_MSVC_RELEASE_RUNTIME_ALWAYS)
-
-	IF (CMAKE_CL_64)
-	  ADD_DEFINITIONS(-D_WIN64)
-	ELSE()
-	  OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option"	OFF)
-	  option(USE_MSVC_SSE2 "Compile your program with SSE2 instructions" ON)
-
-	  IF (USE_MSVC_SSE)
-		  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
-	  ENDIF()
-	  IF (USE_MSVC_SSE2)
-		  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
-	  ENDIF()
-
-	ENDIF()
-
-	option(USE_MSVC_AVX "Compile your program with AVX instructions"  OFF)
-
-	IF(USE_MSVC_AVX)
-		add_definitions(/arch:AVX)
-	ENDIF()
-
-	OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option"	ON)
-	IF (USE_MSVC_FAST_FLOATINGPOINT)
-		  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
-  ENDIF()
-
-	OPTION(USE_MSVC_STRING_POOLING "Use MSVC /GF string pooling option"	ON)
-	IF (USE_MSVC_STRING_POOLING)
-		SET(CMAKE_C_FLAGS "/GF ${CMAKE_C_FLAGS}")
-		SET(CMAKE_CXX_FLAGS "/GF ${CMAKE_CXX_FLAGS}")
-	ENDIF()
-
-	OPTION(USE_MSVC_FUNCTION_LEVEL_LINKING "Use MSVC /Gy function level linking option"	ON)
-	IF(USE_MSVC_FUNCTION_LEVEL_LINKING)
-		SET(CMAKE_C_FLAGS "/Gy ${CMAKE_C_FLAGS}")
-		SET(CMAKE_CXX_FLAGS "/Gy ${CMAKE_CXX_FLAGS}")
-		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF")
-		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF")
-	ENDIF(USE_MSVC_FUNCTION_LEVEL_LINKING)
-
-	OPTION(USE_MSVC_EXEPTIONS "Use MSVC C++ exceptions option"	OFF)
-
-
-
-	OPTION(USE_MSVC_COMDAT_FOLDING "Use MSVC /OPT:ICF COMDAT folding option"	ON)
-
-	IF(USE_MSVC_COMDAT_FOLDING)
-		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:ICF")
-		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:ICF")
-	ENDIF()
-
-	OPTION(USE_MSVC_DISABLE_RTTI "Use MSVC /GR- disabled RTTI flags option"	ON)
-	IF(USE_MSVC_DISABLE_RTTI)
-	  STRING(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
-		SET(CMAKE_C_FLAGS "/GR- ${CMAKE_C_FLAGS}")
-		SET(CMAKE_CXX_FLAGS "/GR- ${CMAKE_CXX_FLAGS}")
-	ENDIF(USE_MSVC_DISABLE_RTTI)
-
-	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267")
-ENDIF(MSVC)
-
-
-
-IF (WIN32)
-OPTION(INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES "Create MSVC projectfiles that can be distributed" OFF)
-
-IF (INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-	SET (LIBRARY_OUTPUT_PATH ${BULLET_PHYSICS_SOURCE_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
-	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR})
-	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BULLET_PHYSICS_SOURCE_DIR})
-	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BULLET_PHYSICS_SOURCE_DIR})
-	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BULLET_PHYSICS_SOURCE_DIR})
-	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BULLET_PHYSICS_SOURCE_DIR})
-ELSE()
-	SET (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
-ENDIF()
-
-
-
-OPTION(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES "Create MSVC projectfiles with relative paths" OFF)
-OPTION(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES "Add MSVC postfix for executable names (_Debug)" OFF)
-
-SET(CMAKE_DEBUG_POSTFIX "_Debug" CACHE STRING "Adds a postfix for debug-built libraries.")
-SET(CMAKE_MINSIZEREL_POSTFIX "_MinsizeRel" CACHE STRING "Adds a postfix for MinsizeRelease-built libraries.")
-SET(CMAKE_RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo" CACHE STRING "Adds a postfix for ReleaseWithDebug-built libraries.")
-
-
-
-
-
-IF (INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
-SET(CMAKE_SUPPRESS_REGENERATION  1)
-SET(CMAKE_USE_RELATIVE_PATHS 1)
-ENDIF(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
-
-ENDIF (WIN32)
-
-
-OPTION(BUILD_CPU_DEMOS "Build original Bullet CPU examples" ON)
-
-
-
-OPTION(INTERNAL_UPDATE_SERIALIZATION_STRUCTURES "Internal update serialization structures" OFF)
-IF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
-ADD_DEFINITIONS( -DBT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
-ENDIF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
-
-IF (CLAMP_VELOCITIES)
-ADD_DEFINITIONS( -DBT_CLAMP_VELOCITY_TO=${CLAMP_VELOCITIES})
-ENDIF (CLAMP_VELOCITIES)
-
-IF (USE_DOUBLE_PRECISION)
-ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
-SET( BULLET_DOUBLE_DEF "-DBT_USE_DOUBLE_PRECISION")
-ENDIF (USE_DOUBLE_PRECISION)
-
-IF (NOT USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
-ADD_DEFINITIONS(-DSKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
-ENDIF ()
-
-IF(USE_GRAPHICAL_BENCHMARK)
-ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK)
-ENDIF (USE_GRAPHICAL_BENCHMARK)
-
-IF(BULLET2_MULTITHREADING)
-	ADD_DEFINITIONS( -DBT_THREADSAFE=1 )
-	IF (NOT MSVC)
-		SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-	ENDIF (NOT MSVC)
-	IF (NOT WIN32)
-		FIND_PACKAGE(Threads)
-		LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} )
-	ENDIF (NOT WIN32)
-ENDIF (BULLET2_MULTITHREADING)
-
-IF (BULLET2_USE_OPEN_MP_MULTITHREADING)
-    ADD_DEFINITIONS("-DBT_USE_OPENMP=1")
-    IF (MSVC)
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
-    ELSE (MSVC)
-        # GCC, Clang
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
-    ENDIF (MSVC)
-ENDIF (BULLET2_USE_OPEN_MP_MULTITHREADING)
-
-IF (BULLET2_USE_TBB_MULTITHREADING)
-    SET (BULLET2_TBB_INCLUDE_DIR "not found" CACHE PATH "Directory for Intel TBB includes.")
-    SET (BULLET2_TBB_LIB_DIR "not found" CACHE PATH "Directory for Intel TBB libraries.")
-    find_library(TBB_LIBRARY tbb PATHS ${BULLET2_TBB_LIB_DIR})
-    find_library(TBBMALLOC_LIBRARY tbbmalloc PATHS ${BULLET2_TBB_LIB_DIR})
-    ADD_DEFINITIONS("-DBT_USE_TBB=1")
-    INCLUDE_DIRECTORIES( ${BULLET2_TBB_INCLUDE_DIR} )
-    LINK_LIBRARIES( ${TBB_LIBRARY} ${TBBMALLOC_LIBRARY} )
-ENDIF (BULLET2_USE_TBB_MULTITHREADING)
-
-IF (BULLET2_USE_PPL_MULTITHREADING)
-    ADD_DEFINITIONS("-DBT_USE_PPL=1")
-ENDIF (BULLET2_USE_PPL_MULTITHREADING)
-
-IF (WIN32)
-OPTION(USE_GLUT "Use Glut"	ON)
-ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
-ADD_DEFINITIONS( -D_CRT_SECURE_NO_DEPRECATE )
-ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
-
-IF (USE_GLUT AND MSVC)
-	string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-	remove_definitions(-D_WINDOWS )
-ENDIF()
-
-
-
-ELSE(WIN32)
-OPTION(USE_GLUT "Use Glut"	ON)
-ENDIF(WIN32)
-
-
-IF(COMMAND cmake_policy)
-   cmake_policy(SET CMP0003 NEW)
-ENDIF(COMMAND cmake_policy)
-
-
-# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system
-# This should be the case.
-
-FIND_PACKAGE(OpenGL)
-IF (OPENGL_FOUND)
-	MESSAGE("OPENGL FOUND")
-	MESSAGE(${OPENGL_LIBRARIES})
-ELSE (OPENGL_FOUND)
-	MESSAGE("OPENGL NOT FOUND")
-	SET(OPENGL_gl_LIBRARY opengl32)
-	SET(OPENGL_glu_LIBRARY glu32)
-ENDIF (OPENGL_FOUND)
-
-
-#FIND_PACKAGE(GLU)
-
-
-IF (APPLE)
-  FIND_LIBRARY(COCOA_LIBRARY Cocoa)
-ENDIF()
-
-OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON)
-
-# Optional Python configuration
-# Will not probe environment for Python configuration (which can abort the
-# build process) unless you explicitly turn on BUILD_PYBULLET.
-OPTION(BUILD_PYBULLET "Set when you want to build pybullet (Python bindings for Bullet)" OFF)
-IF(BUILD_PYBULLET)
-	SET(PYTHON_VERSION_PYBULLET "" CACHE STRING "Python version pybullet will use.")
-	SET(Python_ADDITIONAL_VERSIONS 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.7.12 2.7.10 2.7.3 )
-	SET_PROPERTY(CACHE PYTHON_VERSION_PYBULLET PROPERTY STRINGS ${Python_ADDITIONAL_VERSIONS})
-	SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build3/cmake ${CMAKE_MODULE_PATH})
-	OPTION(EXACT_PYTHON_VERSION "Require Python and match PYTHON_VERSION_PYBULLET exactly, e.g. 2.7.12" OFF)
-	IF(EXACT_PYTHON_VERSION)
-	    set(EXACT_PYTHON_VERSION_FLAG EXACT REQUIRED)
-	ENDIF(EXACT_PYTHON_VERSION)
-	# first find the python interpreter
-	FIND_PACKAGE(PythonInterp ${PYTHON_VERSION_PYBULLET} ${EXACT_PYTHON_VERSION_FLAG})
-	# python library should exactly match that of the interpreter
-	# the following can result in fatal error if you don't have the right python configuration
-	FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
-ENDIF(BUILD_PYBULLET)
-
-OPTION(BUILD_ENET "Set when you want to build apps with enet UDP networking support" ON)
-OPTION(BUILD_CLSOCKET "Set when you want to build apps with enet TCP networking support" ON)
-
-
-IF(BUILD_PYBULLET)
-	FIND_PACKAGE(PythonLibs)
-
-	OPTION(BUILD_PYBULLET_NUMPY "Set when you want to build pybullet with NumPy support" OFF)
-	OPTION(BUILD_PYBULLET_ENET "Set when you want to build pybullet with enet UDP networking support" ON)
-	OPTION(BUILD_PYBULLET_CLSOCKET "Set when you want to build pybullet with enet TCP networking support" ON)
-
-	OPTION(BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK "Set when you want to use the Python Framework on Mac" OFF)
-
-	IF(BUILD_PYBULLET_NUMPY)
-		#include(FindNumPy)
-		FIND_PACKAGE(NumPy)
-		if (PYTHON_NUMPY_FOUND)
-			message("NumPy found")
-			add_definitions(-DPYBULLET_USE_NUMPY)
-		else()
-			message("NumPy not found")
-		endif()
-	ENDIF()
-
-	IF(WIN32)
-		SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared Libs" FORCE)
-	ELSE(WIN32)
-		SET(BUILD_SHARED_LIBS ON CACHE BOOL "Shared Libs" FORCE)
-	ENDIF(WIN32)
-
-	IF(APPLE)
-		OPTION(BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK "Set when you want to use the Python Framework on Mac" ON)
-		IF(NOT BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK)
-			add_definitions(-DB3_NO_PYTHON_FRAMEWORK)
-		ENDIF(NOT BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK)
-		OPTION(BUILD_PYBULLET_SHOW_PY_VERSION "Set when you want to show the PY_MAJOR_VERSION and PY_MAJOR_VERSION using #pragme message." OFF)
-		IF(BUILD_PYBULLET_SHOW_PY_VERSION)
-			add_definitions(-DB3_DUMP_PYTHON_VERSION)
-		ENDIF()
-
-	ENDIF(APPLE)
-
-ENDIF(BUILD_PYBULLET)
-
-IF(NOT WIN32 AND NOT APPLE)
-    OPTION(BUILD_EGL "Build OpenGL/EGL" ON)
-    IF(BUILD_EGL)
-        ADD_DEFINITIONS(-DBT_USE_EGL)
-    ENDIF(BUILD_EGL)
-ENDIF()
-
-IF(BUILD_BULLET3)
-	 IF(APPLE)
-		MESSAGE("Mac OSX Version is ${_CURRENT_OSX_VERSION}")
-		IF(_CURRENT_OSX_VERSION  VERSION_LESS 10.9)
-			MESSAGE("Mac OSX below 10.9 has no OpenGL 3 support so please disable the BUILD_OPENGL3_DEMOS option")
-			#unset(BUILD_OPENGL3_DEMOS CACHE)
-
-			OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build the OpenGL3+ demos" OFF)
-		ELSE()
-			OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build the OpenGL3+ demos" ON)
-		ENDIF()
-	ELSE()
-		OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build Bullet 3 OpenGL3+ demos" ON)
-	ENDIF()
-ELSE(BUILD_BULLET3)
-	unset(BUILD_OPENGL3_DEMOS CACHE)
-	OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build Bullet 3 OpenGL3+ demos" OFF)
-ENDIF(BUILD_BULLET3)
-IF(BUILD_OPENGL3_DEMOS)
-	IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos3 AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos3)
-		SUBDIRS(Demos3)
-	ENDIF()
-ELSE()
-	ADD_DEFINITIONS(-DNO_OPENGL3)
-ENDIF(BUILD_OPENGL3_DEMOS)
-
-OPTION(BUILD_BULLET2_DEMOS "Set when you want to build the Bullet 2 demos" ON)
-IF(BUILD_BULLET2_DEMOS)
-
-	IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/examples AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/examples)
-		SUBDIRS(examples)
-	ENDIF()
-
-ENDIF(BUILD_BULLET2_DEMOS)
-
-
-
-OPTION(BUILD_EXTRAS "Set when you want to build the extras" ON)
-IF(BUILD_EXTRAS)
-  SUBDIRS(Extras)
-ENDIF(BUILD_EXTRAS)
-
-
-
-SUBDIRS(src)
-
-IF("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
-	OPTION(INSTALL_LIBS "Set when you want to install libraries" ON)
-ELSE()
-	IF(APPLE AND FRAMEWORK)
-		OPTION(INSTALL_LIBS "Set when you want to install libraries" ON)
-	ELSE()
-#by default, don't enable the 'INSTALL' option for Xcode and MSVC projectfiles
-		OPTION(INSTALL_LIBS "Set when you want to install libraries" OFF)
-	ENDIF()
-ENDIF()
-
-
-IF(INSTALL_LIBS)
-	#INSTALL of other files requires CMake 2.6
-	IF(BUILD_EXTRAS)
-		IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-			OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" ON)
-		ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-	ENDIF(BUILD_EXTRAS)
-
-	SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
-	SET (LIB_DESTINATION "lib${LIB_SUFFIX}" CACHE STRING "Library directory name")
-	## the following are directories where stuff will be installed to
-	SET(INCLUDE_INSTALL_DIR "include/bullet/" CACHE PATH "The subdirectory to the header prefix")
-	SET(PKGCONFIG_INSTALL_PREFIX "lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
-	IF(NOT MSVC)
-	  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc @ONLY)
-  	INSTALL(
-		FILES
-		${CMAKE_CURRENT_BINARY_DIR}/bullet.pc
-		DESTINATION
-		${PKGCONFIG_INSTALL_PREFIX})
-	ENDIF(NOT MSVC)
-ENDIF()
-
-
-OPTION(BUILD_UNIT_TESTS "Build Unit Tests"	ON)
-
-IF (BUILD_UNIT_TESTS)
-	ENABLE_TESTING()
-	SUBDIRS(test)
-ENDIF()
-
-set (BULLET_CONFIG_CMAKE_PATH lib${LIB_SUFFIX}/cmake/bullet )
-list (APPEND BULLET_DEFINITIONS ${BULLET_DOUBLE_DEF})
-list (APPEND BULLET_LIBRARIES LinearMath)
-list (APPEND BULLET_LIBRARIES Bullet3Common)
-list (APPEND BULLET_LIBRARIES BulletInverseDynamics)
-list (APPEND BULLET_LIBRARIES BulletCollision)
-list (APPEND BULLET_LIBRARIES BulletDynamics)
-list (APPEND BULLET_LIBRARIES BulletSoftBody)
-set (BULLET_USE_FILE ${BULLET_CONFIG_CMAKE_PATH}/UseBullet.cmake)
-configure_file 	( ${CMAKE_CURRENT_SOURCE_DIR}/BulletConfig.cmake.in
-					${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
-					@ONLY ESCAPE_QUOTES
-				)
-OPTION(INSTALL_CMAKE_FILES "Install generated CMake files" ON)
-
-IF (INSTALL_CMAKE_FILES)
-	install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/UseBullet.cmake
-		${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
-		DESTINATION ${BULLET_CONFIG_CMAKE_PATH}
-	)
-ENDIF (INSTALL_CMAKE_FILES)

+ 0 - 780
ThirdParty/Bullet/Doxyfile

@@ -1,780 +0,0 @@
-# Doxyfile 1.2.4
-
-# This file describes the settings to be used by doxygen for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-#       TAG = value [value, ...]
-# For lists items can also be appended using:
-#       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# General configuration options
-#---------------------------------------------------------------------------
-
-
-
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
-# by quotes) that should identify the project. 
-PROJECT_NAME           = "Bullet Collision Detection & Physics Library"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
-# if some version control system is used.
-
-PROJECT_NUMBER         = 
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY       = 
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese, 
-# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian, 
-# Polish, Portuguese and Slovene.
-
-OUTPUT_LANGUAGE        = English
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 
-
-EXTRACT_ALL            = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
-# will be included in the documentation. 
-
-EXTRACT_PRIVATE        = YES
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
-# will be included in the documentation. 
-
-EXTRACT_STATIC         = YES
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
-# This option has no effect if EXTRACT_ALL is enabled. 
-
-HIDE_UNDOC_MEMBERS     = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these class will be included in the various 
-# overviews. This option has no effect if EXTRACT_ALL is enabled. 
-
-HIDE_UNDOC_CLASSES     = NO
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
-# Set to NO to disable this. 
-
-BRIEF_MEMBER_DESC      = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
-# brief descriptions will be completely suppressed. 
-
-REPEAT_BRIEF           = YES
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
-# description. 
-
-ALWAYS_DETAILED_SEC    = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
-# to NO the shortest path that makes the file name unique will be used. 
-
-FULL_PATH_NAMES        = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. It is allowed to use relative paths in the argument list.
-
-STRIP_FROM_PATH        = 
-
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
-# Set it to YES to include the internal documentation. 
-
-INTERNAL_DOCS          = NO
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a class diagram (in Html and LaTeX) for classes with base or 
-# super classes. Setting the tag to NO turns the diagrams off. 
-
-CLASS_DIAGRAMS         = YES
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
-# be generated. Documented entities will be cross-referenced with these sources. 
-
-SOURCE_BROWSER         = YES
-
-# Setting the INLINE_SOURCES tag to YES will include the body 
-# of functions and classes directly in the documentation. 
-
-INLINE_SOURCES         = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
-# fragments. Normal C and C++ comments will always remain visible. 
-
-STRIP_CODE_COMMENTS    = YES
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower case letters. If set to YES upper case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
-# users are adviced to set this option to NO.
-
-CASE_SENSE_NAMES       = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
-# documentation. If set to YES the scope will be hidden. 
-
-HIDE_SCOPE_NAMES       = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
-# which an include is specified. Set to NO to disable this. 
-
-VERBATIM_HEADERS       = YES
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put list of the files that are included by a file in the documentation 
-# of that file. 
-
-SHOW_INCLUDE_FILES     = YES
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments  will behave just like the Qt-style comments (thus requiring an 
-# explict @brief command for a brief description. 
-
-JAVADOC_AUTOBRIEF      = YES
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
-# reimplements. 
-
-INHERIT_DOCS           = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
-# is inserted in the documentation for inline members. 
-
-INLINE_INFO            = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
-# declaration order. 
-
-SORT_MEMBER_DOCS       = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC   = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
-# Doxygen uses this value to replace tabs by spaces in code fragments. 
-
-TAB_SIZE               = 8
-
-# The ENABLE_SECTIONS tag can be used to enable conditional 
-# documentation sections, marked by \if sectionname ... \endif. 
-
-ENABLED_SECTIONS       = 
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
-# commands in the documentation.
-
-GENERATE_TODOLIST      = NO
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
-# commands in the documentation.
-
-GENERATE_TESTLIST      = YES
-
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user defined paragraph with heading "Side Effects:". 
-# You can put \n's in the value part of an alias to insert newlines. 
-
-ALIASES                = 
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated 
-# by doxygen. Possible values are YES and NO. If left blank NO is used. 
-
-QUIET                  = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
-# NO is used. 
-
-WARNINGS               = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
-# automatically be disabled. 
-
-WARN_IF_UNDOCUMENTED   = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text. 
-
-WARN_FORMAT            = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
-# to stderr. 
-
-WARN_LOGFILE           = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
-# with spaces. 
-
-INPUT                  = src/LinearMath src/BulletCollision src/BulletDynamics src/BulletSoftBody src/btBulletCollisionCommon.h src/btBulletDynamicsCommon.h  Extras/Serialize/BulletWorldImporter Extras/Serialize/BulletFileLoader
-
-
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank all files are included. 
-
-FILE_PATTERNS          = *.h *.cpp *.c
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
-# If left blank NO is used. 
-
-RECURSIVE              = YES
-
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
-# subdirectory from a directory tree whose root is specified with the INPUT tag. 
-
-EXCLUDE                = 
-
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories. 
-
-EXCLUDE_PATTERNS       = 
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
-# the \include command). 
-
-EXAMPLE_PATH           = 
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank all files are included. 
-
-EXAMPLE_PATTERNS       = 
-
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
-# the \image command). 
-
-IMAGE_PATH             = 
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
-# to standard output. 
-
-INPUT_FILTER           = 
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
-# files to browse. 
-
-FILTER_SOURCE_FILES    = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
-# contains a lot of classes, structs, unions or interfaces. 
-
-ALPHABETICAL_INDEX     = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
-# in which this list will be split (can be a number in the range [1..20]) 
-
-COLS_IN_ALPHA_INDEX    = 5
-
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
-# should be ignored while generating the index headers. 
-
-IGNORE_PREFIX          = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
-# generate HTML output. 
-
-GENERATE_HTML          = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `html' will be used as the default path. 
-
-HTML_OUTPUT            = html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard header.
-
-HTML_HEADER            = 
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard footer.
-
-HTML_FOOTER            = 
-
-# The HTML_STYLESHEET tag can be used to specify a user defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet 
-
-HTML_STYLESHEET        = 
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
-# NO a bullet list will be used. 
-
-HTML_ALIGN_MEMBERS     = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
-# of the generated HTML documentation. 
-
-GENERATE_HTMLHELP      = YES
-
-# HHC_LOCATION = "C:\Program Files\HTML Help Workshop\hhc.exe"
-HHC_LOCATION = "C:\Program Files (x86)\HTML Help Workshop\hhc.exe"
-
-
-HTML_FILE_EXTENSION = .html
-HTML_HEADER = 
-HTML_FOOTER = 
-#HTML_STYLESHEET = "\\server\exchange\Software Development\Documentation\DoxyGen\doxygen.css"
-
-CHM_FILE = BulletDocs.chm
-HHC_LOCATION = "c:\program files\HTML Help Workshop\hhc.exe"
-GENERATE_CHI = YES
-BINARY_TOC = YES
-
-TOC_EXPAND = YES
-
-SHOW_DIRECTORIES       = YES
-
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
-# the value YES disables it. 
-
-DISABLE_INDEX          = NO
-
-# This tag can be used to set the number of enum values (range [1..20]) 
-# that doxygen will group on one line in the generated HTML documentation. 
-
-ENUM_VALUES_PER_LINE   = 1
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side pannel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript and frames is required (for instance Netscape 4.0+ 
-# or Internet explorer 4.0+). 
-
-GENERATE_TREEVIEW      = YES
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
-# is shown. 
-
-TREEVIEW_WIDTH         = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
-# generate Latex output. 
-
-GENERATE_LATEX         = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `latex' will be used as the default path. 
-
-LATEX_OUTPUT           = latex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
-# save some trees in general. 
-
-COMPACT_LATEX          = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
-# executive. If left blank a4wide will be used. 
-
-PAPER_TYPE             = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
-# packages that should be included in the LaTeX output. 
-
-EXTRA_PACKAGES         = 
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
-# standard header. Notice: only use this tag if you know what you are doing! 
-
-LATEX_HEADER           = 
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
-# This makes the output suitable for online browsing using a pdf viewer. 
-
-PDF_HYPERLINKS         = NO
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
-# higher quality PDF documentation. 
-
-USE_PDFLATEX           = NO
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
-# This option is also used when generating formulas in HTML. 
-
-LATEX_BATCHMODE        = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimised for Word 97 and may not look very pretty with 
-# other RTF readers or editors.
-
-GENERATE_RTF           = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `rtf' will be used as the default path. 
-
-RTF_OUTPUT             = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
-# save some trees in general. 
-
-COMPACT_RTF            = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using a WORD or other. 
-# programs which support those fields. 
-# Note: wordpad (write) and others do not support links. 
-
-RTF_HYPERLINKS         = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assigments. You only have to provide 
-# replacements, missing definitions are set to their default value. 
-
-RTF_STYLESHEET_FILE    = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
-# generate man pages 
-
-GENERATE_MAN           = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `man' will be used as the default path. 
-
-MAN_OUTPUT             = man
-
-# The MAN_EXTENSION tag determines the extension that is added to 
-# the generated man pages (default is the subroutine's section .3) 
-
-MAN_EXTENSION          = .3
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
-# the code including all documentation. Warning: This feature 
-# is still experimental and very incomplete.
-
-GENERATE_XML           = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
-# files. 
-
-ENABLE_PREPROCESSING   = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
-# way by setting EXPAND_ONLY_PREDEF to YES. 
-
-MACRO_EXPANSION        = YES
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
-# PREDEFINED and EXPAND_AS_PREDEFINED tags. 
-
-EXPAND_ONLY_PREDEF     = YES
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
-# in the INCLUDE_PATH (see below) will be search if a #include is found. 
-
-SEARCH_INCLUDES        = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
-# the preprocessor. 
-
-INCLUDE_PATH           = 
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
-# be used. 
-
-INCLUDE_FILE_PATTERNS  = 
-
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed. 
-
-PREDEFINED		=	"ATTRIBUTE_ALIGNED128(x)=x" \
-					"ATTRIBUTE_ALIGNED16(x)=x" \
-					"SIMD_FORCE_INLINE=inline" \
-					"VECTORMATH_FORCE_INLINE=inline" \
-					"USE_WIN32_THREADING=1"\
-					"USE_PTHREADS=1"\
-					"_WIN32=1"
-					
-
-# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
-# Use the PREDEFINED tag if you want to use a different macro definition. 
-
-EXPAND_AS_DEFINED      = 
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to external references   
-#---------------------------------------------------------------------------
-
-# The TAGFILES tag can be used to specify one or more tagfiles. 
-
-TAGFILES               = 
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
-# a tag file that is based on the input files it reads. 
-
-GENERATE_TAGFILE       = 
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
-# will be listed. 
-
-ALLEXTERNALS           = NO
-
-# The PERL_PATH should be the absolute path and name of the perl script 
-# interpreter (i.e. the result of `which perl'). 
-
-PERL_PATH              = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
-# have no effect if this option is set to NO (the default) 
-
-HAVE_DOT               = YES
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH            = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
-# class references variables) of the class with other documented classes. 
-
-COLLABORATION_GRAPH    = YES
-
-# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to 
-# YES then doxygen will generate a graph for each documented file showing 
-# the direct and indirect include dependencies of the file with other 
-# documented files. 
-
-INCLUDE_GRAPH          = YES
-
-# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to 
-# YES then doxygen will generate a graph for each documented header file showing 
-# the documented files that directly or indirectly include this file 
-
-INCLUDED_BY_GRAPH      = YES
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
-# will graphical hierarchy of all classes instead of a textual one. 
-
-GRAPHICAL_HIERARCHY    = YES
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
-# found. If left blank, it is assumed the dot tool can be found on the path. 
-
-DOT_PATH               = 
-
-# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
-# this value, doxygen will try to truncate the graph, so that it fits within 
-# the specified constraint. Beware that most browsers cannot cope with very 
-# large images. 
-
-MAX_DOT_GRAPH_WIDTH    = 1024
-
-# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
-# this value, doxygen will try to truncate the graph, so that it fits within 
-# the specified constraint. Beware that most browsers cannot cope with very 
-# large images. 
-
-MAX_DOT_GRAPH_HEIGHT   = 1024
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
-# arrows in the dot generated graphs. 
-
-GENERATE_LEGEND        = YES
-
-
-# delete intermediate dot files?
-
-DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to the search engine   
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be 
-# used. If set to NO the values of all tags below this one will be ignored. 
-
-SEARCHENGINE           = NO
-
-# The CGI_NAME tag should be the name of the CGI script that 
-# starts the search engine (doxysearch) with the correct parameters. 
-# A script with this name will be generated by doxygen. 
-
-CGI_NAME               = search.cgi
-
-# The CGI_URL tag should be the absolute URL to the directory where the 
-# cgi binaries are located. See the documentation of your http daemon for 
-# details. 
-
-CGI_URL                = 
-
-# The DOC_URL tag should be the absolute URL to the directory where the 
-# documentation is located. If left blank the absolute path to the 
-# documentation, with file:// prepended to it, will be used. 
-
-DOC_URL                = 
-
-# The DOC_ABSPATH tag should be the absolute path to the directory where the 
-# documentation is located. If left blank the directory on the local machine 
-# will be used. 
-
-DOC_ABSPATH            = 
-
-# The BIN_ABSPATH tag must point to the directory where the doxysearch binary 
-# is installed. 
-
-BIN_ABSPATH            = c:\program files\doxygen\bin
-
-# The EXT_DOC_PATHS tag can be used to specify one or more paths to 
-# documentation generated for other projects. This allows doxysearch to search 
-# the documentation for these projects as well. 
-
-EXT_DOC_PATHS          = 

+ 0 - 317
ThirdParty/Bullet/Extras/BulletRobotics/CMakeLists.txt

@@ -1,317 +0,0 @@
-
-INCLUDE_DIRECTORIES(
-		${BULLET_PHYSICS_SOURCE_DIR}/src
-		${BULLET_PHYSICS_SOURCE_DIR}/examples
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
-)
-ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN)
-
-
-
-SET(BulletRobotics_INCLUDES
-  ../../examples/CommonInterfaces/Common2dCanvasInterface.h
-  ../../examples/CommonInterfaces/CommonCallbacks.h
-  ../../examples/CommonInterfaces/CommonCameraInterface.h
-  ../../examples/CommonInterfaces/CommonExampleInterface.h
-  ../../examples/CommonInterfaces/CommonFileIOInterface.h
-  ../../examples/CommonInterfaces/CommonGraphicsAppInterface.h
-  ../../examples/CommonInterfaces/CommonGUIHelperInterface.h
-  ../../examples/CommonInterfaces/CommonMultiBodyBase.h
-  ../../examples/CommonInterfaces/CommonParameterInterface.h
-  ../../examples/CommonInterfaces/CommonRenderInterface.h
-  ../../examples/CommonInterfaces/CommonRigidBodyBase.h
-  ../../examples/CommonInterfaces/CommonWindowInterface.h
-
-  ../../examples/OpenGLWindow/SimpleCamera.h
-
-  ../../examples/TinyRenderer/geometry.h
-  ../../examples/TinyRenderer/model.h
-  ../../examples/TinyRenderer/tgaimage.h
-  ../../examples/TinyRenderer/our_gl.h
-  ../../examples/TinyRenderer/TinyRenderer.h
-
-  ../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.h
-  ../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h
-  ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h
-  ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h
-  ../../examples/SharedMemory/IKTrajectoryHelper.h
-  ../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.h
-  ../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.h
-  ../../examples/SharedMemory/InProcessMemory.h
-  ../../examples/SharedMemory/PhysicsServer.h
-  ../../examples/SharedMemory/PhysicsClient.h
-  ../../examples/SharedMemory/PhysicsServerSharedMemory.h
-  ../../examples/SharedMemory/PhysicsDirect.h
-  ../../examples/SharedMemory/PhysicsDirectC_API.h
-  ../../examples/SharedMemory/PhysicsServerCommandProcessor.h
-  ../../examples/SharedMemory/b3PluginManager.h
-  ../../examples/SharedMemory/PhysicsClientSharedMemory.h
-  ../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.h
-  ../../examples/SharedMemory/PhysicsClientC_API.h
-  ../../examples/SharedMemory/SharedMemoryPublic.h
-  ../../examples/SharedMemory/Win32SharedMemory.h
-  ../../examples/SharedMemory/PosixSharedMemory.h
-
-  ../../examples/Utils/b3ResourcePath.h
-  ../../examples/Utils/RobotLoggingUtil.h
-  ../../examples/Utils/b3Clock.h
-  ../../examples/Utils/b3ResourcePath.h
-  ../../examples/Utils/ChromeTraceUtil.h
-  ../../examples/Utils/b3ERPCFMHelper.hpp
-  ../../examples/Utils/b3ReferenceFrameHelper.hpp  
-
-  ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.h
-  ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
-  ../../examples/ThirdPartyLibs/stb_image/stb_image.h
-  ../../examples/ThirdPartyLibs/BussIK/Jacobian.h
-  ../../examples/ThirdPartyLibs/BussIK/LinearR2.h
-  ../../examples/ThirdPartyLibs/BussIK/LinearR3.h
-  ../../examples/ThirdPartyLibs/BussIK/LinearR4.h
-  ../../examples/ThirdPartyLibs/BussIK/MatrixRmn.h
-  ../../examples/ThirdPartyLibs/BussIK/Node.h
-  ../../examples/ThirdPartyLibs/BussIK/Tree.h
-  ../../examples/ThirdPartyLibs/BussIK/VectorRn.h
-
-  ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h
-  ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.h
-  ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h
-  ../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.h
-  ../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.h
-  ../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h
-  ../../examples/Importers/ImportURDFDemo/URDF2Bullet.h
-  ../../examples/Importers/ImportURDFDemo/UrdfParser.h
-  ../../examples/Importers/ImportURDFDemo/urdfStringSplit.h
-  ../../examples/Importers/ImportURDFDemo/URDFImporterInterface.h
-  ../../examples/Importers/ImportURDFDemo/URDFJointTypes.h
-  ../../examples/Importers/ImportURDFDemo/SDFAudioTypes.h
-  ../../examples/Importers/ImportURDFDemo/UrdfRenderingInterface.h
-  ../../examples/Importers/ImportURDFDemo/MultiBodyCreationInterface.h
-  ../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h
-  
-  ../../examples/MultiThreading/b3PosixThreadSupport.h
-  ../../examples/MultiThreading/b3Win32ThreadSupport.h
-  ../../examples/MultiThreading/b3ThreadSupportInterface.h
-)
-
-SET(BulletRobotics_SRCS ${BulletRobotics_INCLUDES}
-	../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h
-	../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/Shape.h
-	../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.h
-	../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.h
-	../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h
-	../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.h
-	../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp
-	../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h
-	
-	../../examples/OpenGLWindow/SimpleCamera.cpp
-
-	../../examples/TinyRenderer/geometry.cpp
-	../../examples/TinyRenderer/model.cpp
-	../../examples/TinyRenderer/tgaimage.cpp
-	../../examples/TinyRenderer/our_gl.cpp
-	../../examples/TinyRenderer/TinyRenderer.cpp
-
-	../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp
-	../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp
-	../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp
-	../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp
-	../../examples/SharedMemory/IKTrajectoryHelper.cpp
-	../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp
-	../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp
-	../../examples/SharedMemory/InProcessMemory.cpp
-	../../examples/SharedMemory/PhysicsClient.cpp
-	../../examples/SharedMemory/PhysicsServer.cpp
-	../../examples/SharedMemory/PhysicsServerSharedMemory.cpp
-	../../examples/SharedMemory/PhysicsDirect.cpp
-	../../examples/SharedMemory/PhysicsDirectC_API.cpp
-	../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp
-	../../examples/SharedMemory/b3PluginManager.cpp
-	../../examples/SharedMemory/PhysicsClientSharedMemory.cpp
-	../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp
-	../../examples/SharedMemory/PhysicsClientC_API.cpp
-	../../examples/SharedMemory/Win32SharedMemory.cpp
-	../../examples/SharedMemory/PosixSharedMemory.cpp
-
-	../../examples/Utils/b3ResourcePath.cpp
-	../../examples/Utils/RobotLoggingUtil.cpp
-	../../examples/Utils/b3Clock.cpp
-	../../examples/Utils/b3ResourcePath.cpp
-	../../examples/Utils/ChromeTraceUtil.cpp
-
-	../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
-	../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
-	../../examples/ThirdPartyLibs/stb_image/stb_image.cpp
-	../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp
-	../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp
-	../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp
-	../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp
-	../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp
-	../../examples/ThirdPartyLibs/BussIK/Misc.cpp
-	../../examples/ThirdPartyLibs/BussIK/Node.cpp
-	../../examples/ThirdPartyLibs/BussIK/Tree.cpp
-	../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp
-
-	../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp
-	../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp
-	../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp
-	../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
-	../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp
-	../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp
-	../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp
-	../../examples/Importers/ImportURDFDemo/UrdfParser.cpp
-	../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp
-	../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp 
-
-	../../examples/MultiThreading/b3PosixThreadSupport.cpp
-	../../examples/MultiThreading/b3Win32ThreadSupport.cpp
-	../../examples/MultiThreading/b3ThreadSupportInterface.cpp
-
-
-)
-
-IF(ENABLE_VHACD)
-ADD_DEFINITIONS(-DBT_ENABLE_VHACD)
-SET(BulletRobotics_SRCS ${BulletRobotics_SRCS}
-  ../../Extras/VHACD/test/src/main_vhacd.cpp
-  ../../Extras/VHACD/src/VHACD.cpp
-  ../../Extras/VHACD/src/vhacdICHull.cpp
-  ../../Extras/VHACD/src/vhacdManifoldMesh.cpp
-  ../../Extras/VHACD/src/vhacdMesh.cpp
-  ../../Extras/VHACD/src/vhacdVolume.cpp
-)
-INCLUDE_DIRECTORIES( 
-  ../../Extras/VHACD/inc
-  ../../Extras/VHACD/public
-)
-ENDIF(ENABLE_VHACD)
-
-IF(BUILD_CLSOCKET)
- ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET)
-ENDIF(BUILD_CLSOCKET)
-
-IF(WIN32)
-	IF(BUILD_ENET)
-		ADD_DEFINITIONS(-DWIN32 -DBT_ENABLE_ENET)
-	ENDIF(BUILD_ENET)
-	IF(BUILD_CLSOCKET)
-		ADD_DEFINITIONS(-DWIN32)
-	ENDIF(BUILD_CLSOCKET)
-
-ELSE(WIN32)
-	IF(BUILD_ENET)
-		ADD_DEFINITIONS(-DHAS_SOCKLEN_T -DBT_ENABLE_ENET)
-	ENDIF(BUILD_ENET)
-
-	IF(BUILD_CLSOCKET)	
-		ADD_DEFINITIONS(${OSDEF})
-	ENDIF(BUILD_CLSOCKET)
-		
-	IF(NOT APPLE)
-		FIND_PACKAGE(Threads)
-		LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} )
-	ENDIF(NOT APPLE)
-ENDIF(WIN32)
-
-IF(BUILD_ENET)
-  set(BulletRobotics_ENET_INCLUDES 
-    ../../examples/SharedMemory/PhysicsClientUDP.h		
-    ../../examples/SharedMemory/PhysicsClientUDP_C_API.h
-    ../../examples/ThirdPartyLibs/enet/include/enet/win32.h
-		../../examples/ThirdPartyLibs/enet/include/enet/unix.h
-		../../examples/ThirdPartyLibs/enet/include/enet/callbacks.h
-		../../examples/ThirdPartyLibs/enet/include/enet/list.h
-		../../examples/ThirdPartyLibs/enet/include/enet/protocol.h
-  )
-  set(BulletRobotics_ENET_SRCS
-    ../../examples/SharedMemory/PhysicsClientUDP.cpp
-    ../../examples/SharedMemory/PhysicsClientUDP_C_API.cpp
-		../../examples/ThirdPartyLibs/enet/win32.c
-		../../examples/ThirdPartyLibs/enet/unix.c
-		../../examples/ThirdPartyLibs/enet/callbacks.c
-		../../examples/ThirdPartyLibs/enet/compress.c
-		../../examples/ThirdPartyLibs/enet/host.c
-		../../examples/ThirdPartyLibs/enet/list.c
-		../../examples/ThirdPartyLibs/enet/packet.c
-		../../examples/ThirdPartyLibs/enet/peer.c
-		../../examples/ThirdPartyLibs/enet/protocol.c
-  )
-
-  set(BulletRobotics_INCLUDES
-    ${BulletRobotics_INCLUDES}
-    ${BulletRobotics_ENET_INCLUDES}
-	)
-
-  set(BulletRobotics_SRCS
-    ${BulletRobotics_SRCS}
-    ${BulletRobotics_ENET_INCLUDES}
-    ${BulletRobotics_ENET_SRCS}
-	)
-
-ENDIF(BUILD_ENET)
-
-IF(BUILD_CLSOCKET)
-  set(BulletRobotics_CLSOCKET_SRCS
-    ../../examples/SharedMemory/PhysicsClientTCP.cpp
-    ../../examples/SharedMemory/PhysicsClientTCP_C_API.cpp
-    ../../examples/ThirdPartyLibs/clsocket/src/SimpleSocket.cpp
-    ../../examples/ThirdPartyLibs/clsocket/src/ActiveSocket.cpp
-    ../../examples/ThirdPartyLibs/clsocket/src/PassiveSocket.cpp
-  )
-
-  set(BulletRobotics_SRCS
-    ${BulletRobotics_SRCS}
-    ${BulletRobotics_CLSOCKET_SRCS}
-  )
-ENDIF()
-
-ADD_DEFINITIONS(-DPHYSICS_SERVER_DIRECT)
-
-
-ADD_LIBRARY(BulletRobotics ${BulletRobotics_SRCS})
-
-SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES VERSION ${BULLET_VERSION})
-SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES SOVERSION ${BULLET_VERSION})
-
-IF (BUILD_SHARED_LIBS)
-	TARGET_LINK_LIBRARIES(BulletRobotics BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics LinearMath Bullet3Common)
-ENDIF (BUILD_SHARED_LIBS)
-
-  
-
-INSTALL (
-    DIRECTORY ${CMAKE_SOURCE_DIR}/examples/
-    DESTINATION include/bullet
-    FILES_MATCHING PATTERN "*.h*")
-
-	INSTALL(TARGETS
-		BulletRobotics
-		LIBRARY DESTINATION lib${LIB_SUFFIX}
-		ARCHIVE DESTINATION lib${LIB_SUFFIX}
-	)
-		
-  IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-    SET_TARGET_PROPERTIES(BulletRobotics  PROPERTIES FRAMEWORK true)
-    SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES PUBLIC_HEADER "PhysicsClientC_API.h" )
-  ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)	
-
-IF(NOT MSVC)
-    SET(PKGCONFIG_INSTALL_PREFIX "lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
-    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet_robotics.pc.cmake
-                   ${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics.pc @ONLY)
-  	INSTALL(
-      FILES
-      ${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics.pc
-      DESTINATION
-      ${PKGCONFIG_INSTALL_PREFIX}
-    )
-ENDIF(NOT MSVC)
-

+ 0 - 6
ThirdParty/Bullet/Extras/BulletRobotics/bullet_robotics.pc.cmake

@@ -1,6 +0,0 @@
-Name: bullet_robotics
-Description: Bullet extras that include several utilities for robotics including a urdf parser
-Requires: bullet
-Version: @BULLET_VERSION@
-Libs: -L@CMAKE_INSTALL_PREFIX@/@LIB_DESTINATION@ -lBulletRobotics
-Cflags: @BULLET_DOUBLE_DEF@ -I@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@ -I@CMAKE_INSTALL_PREFIX@/include/bullet_robotics

+ 0 - 183
ThirdParty/Bullet/Extras/BulletRobotics/premake4.lua

@@ -1,183 +0,0 @@
-		
-
-project ("BulletRobotics")
-		language "C++"
-		kind "StaticLib"
-		
-		includedirs {"../../src", "../../examples",
-		"../../examples/ThirdPartyLibs"}
-		defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
-	hasCL = findOpenCL("clew")
-
-	links{"BulletExampleBrowserLib","gwen", "BulletFileLoader","BulletWorldImporter","OpenGL_Window","BulletSoftBody", "BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision","LinearMath","BussIK", "Bullet3Common"}
-	initOpenGL()
-	initGlew()
-
-  	includedirs {
-                "../../src",
-                "../../examples",
-                "../../examples/SharedMemory",
-                "../ThirdPartyLibs",
-                "../ThirdPartyLibs/enet/include",
-                "../ThirdPartyLibs/clsocket/src",
-                }
-
-	if os.is("MacOSX") then
---		targetextension {"so"}
-		links{"Cocoa.framework","Python"}
-	end
-
-	
-if not _OPTIONS["no-enet"] then
-
-		includedirs {"../../examples/ThirdPartyLibs/enet/include"}
-	
-		if os.is("Windows") then 
---			targetextension {"dylib"}
-			defines { "WIN32" }
-			links {"Ws2_32","Winmm"}
-		end
-		if os.is("Linux") then
-		end
-		if os.is("MacOSX") then
-		end		
-		
-		links {"enet"}		
-
-		files {
-			"../../examples/SharedMemory/PhysicsClientUDP.cpp",
-			"../../examples/SharedMemory/PhysicsClientUDP.h",
-			"../../examples/SharedMemory/PhysicsClientUDP_C_API.cpp",
-			"../../examples/SharedMemory/PhysicsClientUDP_C_API.h",
-		}	
-		defines {"BT_ENABLE_ENET"}
-	end
-
-	if not _OPTIONS["no-clsocket"] then
-
-                includedirs {"../../examples/ThirdPartyLibs/clsocket/src"}
-
-		 if os.is("Windows") then
-                	defines { "WIN32" }
-                	links {"Ws2_32","Winmm"}
-       		 end
-        	if os.is("Linux") then
-                	defines {"_LINUX"}
-        	end
-        	if os.is("MacOSX") then
-                	defines {"_DARWIN"}
-        	end
-
-                links {"clsocket"}
-
-                files {
-			"../../examples/SharedMemory/RemoteGUIHelperTCP.cpp",
-                        "../../examples/SharedMemory/PhysicsClientTCP.cpp",
-			"../../examples/SharedMemory/GraphicsServerExample.cpp",
-                        "../../examples/SharedMemory/PhysicsClientTCP.h",
-                        "../../examples/SharedMemory/PhysicsClientTCP_C_API.cpp",
-                        "../../examples/SharedMemory/PhysicsClientTCP_C_API.h",
-                }
-                defines {"BT_ENABLE_CLSOCKET"}
-        end
-
-
-		files {
-		"../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp",
-		"../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp",
-		"../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h",
-		"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp",
-		"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h",
-		"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp",
-		"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h",
-		"../../examples/SharedMemory/IKTrajectoryHelper.cpp",
-		"../../examples/SharedMemory/IKTrajectoryHelper.h",
-		"../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp",
-		"../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp",
-		"../../examples/SharedMemory/RemoteGUIHelper.cpp",
-		"../../examples/OpenGLWindow/SimpleCamera.cpp",
-		"../../examples/OpenGLWindow/SimpleCamera.h",
-		"../../examples/TinyRenderer/geometry.cpp",
-		"../../examples/TinyRenderer/model.cpp",
-		"../../examples/TinyRenderer/tgaimage.cpp",
-		"../../examples/TinyRenderer/our_gl.cpp",
-		"../../examples/TinyRenderer/TinyRenderer.cpp",
-		"../../examples/SharedMemory/InProcessMemory.cpp",
-		"../../examples/SharedMemory/PhysicsClient.cpp",
-		"../../examples/SharedMemory/PhysicsClient.h",
-		"../../examples/SharedMemory/PhysicsServer.cpp",
-		"../../examples/SharedMemory/PhysicsServer.h",
-		"../../examples/SharedMemory/PhysicsServerSharedMemory.cpp",
-		"../../examples/SharedMemory/PhysicsServerSharedMemory.h",
-		"../../examples/SharedMemory/PhysicsDirect.cpp",
-		"../../examples/SharedMemory/PhysicsDirect.h",
-		"../../examples/SharedMemory/PhysicsDirectC_API.cpp",
-		"../../examples/SharedMemory/PhysicsDirectC_API.h",
-		"../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp",
-		"../../examples/SharedMemory/PhysicsServerCommandProcessor.h",
-		"../../examples/SharedMemory/b3PluginManager.cpp",
-		"../../examples/SharedMemory/b3PluginManager.h",
-				
-		"../../examples/SharedMemory/PhysicsClientSharedMemory.cpp",
-		"../../examples/SharedMemory/PhysicsClientSharedMemory.h",
-		"../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp",
-		"../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.h",
-		"../../examples/SharedMemory/PhysicsClientC_API.cpp",
-	
-		"../../examples/SharedMemory/PhysicsClientC_API.h",
-		"../../examples/SharedMemory/SharedMemoryPublic.h",
-
-		"../../examples/SharedMemory/Win32SharedMemory.cpp",
-		"../../examples/SharedMemory/Win32SharedMemory.h",
-		"../../examples/SharedMemory/PosixSharedMemory.cpp",
-		"../../examples/SharedMemory/PosixSharedMemory.h",
-
-		"../../examples/Utils/b3ResourcePath.cpp",
-		"../../examples/Utils/b3ResourcePath.h",
-		"../../examples/Utils/RobotLoggingUtil.cpp",
-		"../../examples/Utils/RobotLoggingUtil.h",
-		"../../examples/Utils/b3Clock.cpp",
-		"../../examples/Utils/b3ResourcePath.cpp",
-		"../../examples/Utils/b3ERPCFMHelper.hpp",
-		"../../examples/Utils/b3ReferenceFrameHelper.hpp",
-		"../../examples/Utils/ChromeTraceUtil.cpp",
-
-		"../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
-
-		"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
-		"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
-
-		"../../examples/ThirdPartyLibs/stb_image/stb_image.cpp",
-
-		"../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/Misc.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/Node.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/Tree.cpp",
-		"../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp",
-
-		"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
-		"../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp",
-		"../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
-		"../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp",
-		"../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp",
-		"../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp",
-		"../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp",
-		"../../examples/Importers/ImportURDFDemo/UrdfParser.cpp",
-		"../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp",
-		"../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
-
-		"../../examples/MultiThreading/b3PosixThreadSupport.cpp",
-		"../../examples/MultiThreading/b3Win32ThreadSupport.cpp",
-		"../../examples/MultiThreading/b3ThreadSupportInterface.cpp",
-			}
-			
-if (_OPTIONS["enable_static_vr_plugin"]) then
-		files {"../../examples/SharedMemory/plugins/vrSyncPlugin/vrSyncPlugin.cpp"}
-end
-
-
-	

+ 0 - 196
ThirdParty/Bullet/Extras/BulletRoboticsGUI/CMakeLists.txt

@@ -1,196 +0,0 @@
-
-INCLUDE_DIRECTORIES(
-		${BULLET_PHYSICS_SOURCE_DIR}/src
-		${BULLET_PHYSICS_SOURCE_DIR}/examples
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
-		${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
-)
-
-SET(BulletRoboticsGUI_INCLUDES
-  ../../examples/CommonInterfaces/Common2dCanvasInterface.h
-  ../../examples/CommonInterfaces/CommonCallbacks.h
-  ../../examples/CommonInterfaces/CommonCameraInterface.h
-  ../../examples/CommonInterfaces/CommonExampleInterface.h
-  ../../examples/CommonInterfaces/CommonFileIOInterface.h
-  ../../examples/CommonInterfaces/CommonGraphicsAppInterface.h
-  ../../examples/CommonInterfaces/CommonGUIHelperInterface.h
-  ../../examples/CommonInterfaces/CommonMultiBodyBase.h
-  ../../examples/CommonInterfaces/CommonParameterInterface.h
-  ../../examples/CommonInterfaces/CommonRenderInterface.h
-  ../../examples/CommonInterfaces/CommonRigidBodyBase.h
-  ../../examples/CommonInterfaces/CommonWindowInterface.h
-
-  ../../examples/OpenGLWindow/SimpleCamera.h
-
-  ../../examples/TinyRenderer/geometry.h
-  ../../examples/TinyRenderer/model.h
-  ../../examples/TinyRenderer/tgaimage.h
-  ../../examples/TinyRenderer/our_gl.h
-  ../../examples/TinyRenderer/TinyRenderer.h
-
-  ../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.h
-  ../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h
-  ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h
-  ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h
-  ../../examples/SharedMemory/IKTrajectoryHelper.h
-  ../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.h
-  ../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.h
-  ../../examples/SharedMemory/InProcessMemory.h
-  ../../examples/SharedMemory/PhysicsServer.h
-  ../../examples/SharedMemory/PhysicsClient.h
-  ../../examples/SharedMemory/PhysicsServerSharedMemory.h
-  ../../examples/SharedMemory/PhysicsDirect.h
-  ../../examples/SharedMemory/PhysicsDirectC_API.h
-  ../../examples/SharedMemory/PhysicsServerCommandProcessor.h
-  ../../examples/SharedMemory/b3PluginManager.h
-  ../../examples/SharedMemory/PhysicsClientSharedMemory.h
-  ../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.h
-  ../../examples/SharedMemory/PhysicsClientC_API.h
-  ../../examples/SharedMemory/SharedMemoryPublic.h
-  ../../examples/SharedMemory/Win32SharedMemory.h
-  ../../examples/SharedMemory/PosixSharedMemory.h
-
-  ../../examples/Utils/b3ResourcePath.h
-  ../../examples/Utils/RobotLoggingUtil.h
-  ../../examples/Utils/b3Clock.h
-  ../../examples/Utils/b3ResourcePath.h
-  ../../examples/Utils/ChromeTraceUtil.h
-  ../../examples/Utils/b3ERPCFMHelper.hpp
-  ../../examples/Utils/b3ReferenceFrameHelper.hpp  
-
-  ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.h
-  ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
-  ../../examples/ThirdPartyLibs/stb_image/stb_image.h
-  ../../examples/ThirdPartyLibs/BussIK/Jacobian.h
-  ../../examples/ThirdPartyLibs/BussIK/LinearR2.h
-  ../../examples/ThirdPartyLibs/BussIK/LinearR3.h
-  ../../examples/ThirdPartyLibs/BussIK/LinearR4.h
-  ../../examples/ThirdPartyLibs/BussIK/MatrixRmn.h
-  ../../examples/ThirdPartyLibs/BussIK/Node.h
-  ../../examples/ThirdPartyLibs/BussIK/Tree.h
-  ../../examples/ThirdPartyLibs/BussIK/VectorRn.h
-
-  ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h
-  ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.h
-  ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h
-  ../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.h
-  ../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.h
-  ../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h
-  ../../examples/Importers/ImportURDFDemo/URDF2Bullet.h
-  ../../examples/Importers/ImportURDFDemo/UrdfParser.h
-  ../../examples/Importers/ImportURDFDemo/urdfStringSplit.h
-  ../../examples/Importers/ImportURDFDemo/URDFImporterInterface.h
-  ../../examples/Importers/ImportURDFDemo/URDFJointTypes.h
-  ../../examples/Importers/ImportURDFDemo/SDFAudioTypes.h
-  ../../examples/Importers/ImportURDFDemo/UrdfRenderingInterface.h
-  ../../examples/Importers/ImportURDFDemo/MultiBodyCreationInterface.h
-  ../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h
-  
-  ../../examples/MultiThreading/b3PosixThreadSupport.h
-  ../../examples/MultiThreading/b3Win32ThreadSupport.h
-  ../../examples/MultiThreading/b3ThreadSupportInterface.h
-)
-
-SET(BulletRoboticsGUI_SRCS ${BulletRoboticsGUI_INCLUDES}
-	../../examples/ExampleBrowser/InProcessExampleBrowser.cpp
-	../../examples/SharedMemory/GraphicsServerExample.cpp
-	../../examples/SharedMemory/GraphicsClientExample.cpp
-	../../examples/SharedMemory/RemoteGUIHelper.cpp
-	../../examples/SharedMemory/RemoteGUIHelperTCP.cpp
-	../../examples/SharedMemory/GraphicsServerExample.h
-	../../examples/SharedMemory/GraphicsClientExample.h
-	../../examples/SharedMemory/RemoteGUIHelper.h
-	../../examples/SharedMemory/GraphicsSharedMemoryCommands.h
-	../../examples/SharedMemory/GraphicsSharedMemoryPublic.h
-	../../examples/SharedMemory/PhysicsServerExample.cpp
-	../../examples/SharedMemory/PhysicsServerExampleBullet2.cpp
-	../../examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp		
-)
-
-IF(BUILD_CLSOCKET)
- ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET)
-ENDIF(BUILD_CLSOCKET)
-
-IF(WIN32)
-	IF(BUILD_ENET)
-		ADD_DEFINITIONS(-DWIN32 -DBT_ENABLE_ENET)
-	ENDIF(BUILD_ENET)
-	IF(BUILD_CLSOCKET)
-		ADD_DEFINITIONS(-DWIN32)
-	ENDIF(BUILD_CLSOCKET)
-
-ELSE(WIN32)
-	IF(BUILD_ENET)
-		ADD_DEFINITIONS(-DHAS_SOCKLEN_T -DBT_ENABLE_ENET)
-	ENDIF(BUILD_ENET)
-
-	IF(BUILD_CLSOCKET)	
-		ADD_DEFINITIONS(${OSDEF})
-	ENDIF(BUILD_CLSOCKET)
-		
-	IF(NOT APPLE)
-		FIND_PACKAGE(Threads)
-		LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} )
-	ENDIF(NOT APPLE)
-ENDIF(WIN32)
-
-IF(BUILD_ENET)
-  set(BulletRoboticsGUI_ENET_INCLUDES 
-    ../../examples/SharedMemory/PhysicsClientUDP.h		
-    ../../examples/SharedMemory/PhysicsClientUDP_C_API.h
-    ../../examples/ThirdPartyLibs/enet/include/enet/win32.h
-		../../examples/ThirdPartyLibs/enet/include/enet/unix.h
-		../../examples/ThirdPartyLibs/enet/include/enet/callbacks.h
-		../../examples/ThirdPartyLibs/enet/include/enet/list.h
-		../../examples/ThirdPartyLibs/enet/include/enet/protocol.h
-  )
-
-  set(BulletRoboticsGUI_INCLUDES
-    ${BulletRoboticsGUI_INCLUDES}
-    ${BulletRoboticsGUI_ENET_INCLUDES}
-	)
-
-
-
-ENDIF(BUILD_ENET)
-
-
-ADD_DEFINITIONS(-DPHYSICS_SERVER_DIRECT)
-
-
-ADD_LIBRARY(BulletRoboticsGUI ${BulletRoboticsGUI_SRCS})
-
-SET_TARGET_PROPERTIES(BulletRoboticsGUI PROPERTIES VERSION ${BULLET_VERSION})
-SET_TARGET_PROPERTIES(BulletRoboticsGUI PROPERTIES SOVERSION ${BULLET_VERSION})
-
-IF (BUILD_SHARED_LIBS)
-	TARGET_LINK_LIBRARIES(BulletRoboticsGUI  BulletExampleBrowserLib BulletRobotics  BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics LinearMath Bullet3Common)
-ENDIF (BUILD_SHARED_LIBS)
-
-  
-
-	INSTALL(TARGETS
-		BulletRoboticsGUI
-		LIBRARY DESTINATION lib${LIB_SUFFIX}
-		ARCHIVE DESTINATION lib${LIB_SUFFIX}
-	)
-		
-  IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-    SET_TARGET_PROPERTIES(BulletRobotics  PROPERTIES FRAMEWORK true)
-    SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES PUBLIC_HEADER "PhysicsClientC_API.h" )
-  ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)	
-
-IF(NOT MSVC)
-    SET(PKGCONFIG_INSTALL_PREFIX "lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
-    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet_robotics_gui.pc.cmake
-                   ${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics_gui.pc @ONLY)
-  	INSTALL(
-      FILES
-      ${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics_gui.pc
-      DESTINATION
-      ${PKGCONFIG_INSTALL_PREFIX}
-    )
-ENDIF(NOT MSVC)
-

+ 0 - 6
ThirdParty/Bullet/Extras/BulletRoboticsGUI/bullet_robotics_gui.pc.cmake

@@ -1,6 +0,0 @@
-Name: bullet_robotics_gui
-Description: Bullet GUI extras for robotics
-Requires: bullet
-Version: @BULLET_VERSION@
-Libs: -L@CMAKE_INSTALL_PREFIX@/@LIB_DESTINATION@ -lBulletRoboticsGUI
-Cflags: @BULLET_DOUBLE_DEF@ -I@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@ -I@CMAKE_INSTALL_PREFIX@/include/bullet_robotics_gui

+ 0 - 40
ThirdParty/Bullet/Extras/CMakeLists.txt

@@ -1,40 +0,0 @@
-OPTION(BUILD_INVERSE_DYNAMIC_EXTRA "Build InverseDynamic extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_BULLET_ROBOTICS_GUI_EXTRA "Build BulletRoboticsGUI extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_BULLET_ROBOTICS_EXTRA "Build BulletRobotics extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_OBJ2SDF_EXTRA "Build obj2sdf extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_SERIALIZE_EXTRA "Build Serialize extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_CONVEX_DECOMPOSITION_EXTRA "Build ConvexDecomposition extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_HACD_EXTRA "Build HACD extra module, only applied when BUILD_EXTRAS is ON" ON)
-OPTION(BUILD_GIMPACTUTILS_EXTRA "Build GIMPACTUtils extra module, only applied when BUILD_EXTRAS is ON" ON)
-
-IF(BUILD_INVERSE_DYNAMIC_EXTRA)
-  SUBDIRS( InverseDynamics )
-ENDIF()
-IF(BUILD_BULLET_ROBOTICS_GUI_EXTRA)
-  SUBDIRS( BulletRoboticsGUI )
-ENDIF()
-IF(BUILD_BULLET_ROBOTICS_EXTRA)
-  SUBDIRS( BulletRobotics )
-ENDIF()
-IF(BUILD_OBJ2SDF_EXTRA)
-  SUBDIRS( obj2sdf )
-ENDIF()
-IF(BUILD_SERIALIZE_EXTRA)
-  SUBDIRS( Serialize )
-ENDIF()
-IF(BUILD_CONVEX_DECOMPOSITION_EXTRA)
-  SUBDIRS( ConvexDecomposition )
-ENDIF()
-IF(BUILD_HACD_EXTRA)
-  SUBDIRS( HACD )
-ENDIF()
-IF(BUILD_GIMPACTUTILS_EXTRA)
-  SUBDIRS( GIMPACTUtils )
-ENDIF()
-
-
-#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
-
-#IF (USE_GLUT AND GLUT_FOUND)
-#	SUBDIRS (glui)
-#ENDIF ()

+ 0 - 67
ThirdParty/Bullet/Extras/ConvexDecomposition/CMakeLists.txt

@@ -1,67 +0,0 @@
-INCLUDE_DIRECTORIES(
- ${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexDecomposition ${BULLET_PHYSICS_SOURCE_DIR}/src
-)
-
-SET(ConvexDecomposition_SRCS
-	bestfitobb.cpp
-	ConvexBuilder.cpp
-	cd_wavefront.cpp
-	fitsphere.cpp
-	meshvolume.cpp
-	raytri.cpp
-	vlookup.cpp
-	bestfit.cpp
-	cd_hull.cpp
-	ConvexDecomposition.cpp
-	concavity.cpp
-	float_math.cpp
-	planetri.cpp
-	splitplane.cpp
-)
-
-SET(ConvexDecomposition_HDRS
-	ConvexDecomposition.h
-	cd_vector.h
-	concavity.h
-	bestfitobb.h
-	ConvexBuilder.h
-	cd_wavefront.h
-	fitsphere.h
-	meshvolume.h
-	raytri.h
-	vlookup.h
-	bestfit.h
-	cd_hull.h
-)
-
-ADD_LIBRARY(ConvexDecomposition ${ConvexDecomposition_SRCS} ${ConvexDecomposition_HDRS})
-SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES VERSION ${BULLET_VERSION})
-SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES SOVERSION ${BULLET_VERSION})
-
-IF (BUILD_SHARED_LIBS)
-  TARGET_LINK_LIBRARIES(ConvexDecomposition BulletCollision LinearMath)
-ENDIF (BUILD_SHARED_LIBS)
-
-IF (INSTALL_EXTRA_LIBS)
-	IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-		#FILES_MATCHING requires CMake 2.6
-		IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-			IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS ConvexDecomposition DESTINATION .)
-			ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS ConvexDecomposition
-                                        RUNTIME DESTINATION bin
-                                        LIBRARY DESTINATION lib${LIB_SUFFIX}
-                                        ARCHIVE DESTINATION lib${LIB_SUFFIX})
-				INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h"  PATTERN
-".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
-			ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-		ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-
-		IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-			SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES FRAMEWORK true)
-			SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES PUBLIC_HEADER "${ConvexDecomposition_HDRS}")
-		ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-	ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-ENDIF (INSTALL_EXTRA_LIBS)

+ 0 - 350
ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexBuilder.cpp

@@ -1,350 +0,0 @@
-#include "float_math.h"
-#include "ConvexBuilder.h"
-#include "meshvolume.h"
-#include "bestfit.h"
-#include <assert.h>
-#include "cd_hull.h"
-
-#include "fitsphere.h"
-#include "bestfitobb.h"
-
-unsigned int MAXDEPTH = 8;
-float CONCAVE_PERCENT = 1.0f;
-float MERGE_PERCENT = 2.0f;
-
-CHull::CHull(const ConvexDecomposition::ConvexResult &result)
-{
-	mResult = new ConvexDecomposition::ConvexResult(result);
-	mVolume = computeMeshVolume(result.mHullVertices, result.mHullTcount, result.mHullIndices);
-
-	mDiagonal = getBoundingRegion(result.mHullVcount, result.mHullVertices, sizeof(float) * 3, mMin, mMax);
-
-	float dx = mMax[0] - mMin[0];
-	float dy = mMax[1] - mMin[1];
-	float dz = mMax[2] - mMin[2];
-
-	dx *= 0.1f;  // inflate 1/10th on each edge
-	dy *= 0.1f;  // inflate 1/10th on each edge
-	dz *= 0.1f;  // inflate 1/10th on each edge
-
-	mMin[0] -= dx;
-	mMin[1] -= dy;
-	mMin[2] -= dz;
-
-	mMax[0] += dx;
-	mMax[1] += dy;
-	mMax[2] += dz;
-}
-
-CHull::~CHull(void)
-{
-	delete mResult;
-}
-
-bool CHull::overlap(const CHull &h) const
-{
-	return overlapAABB(mMin, mMax, h.mMin, h.mMax);
-}
-
-ConvexBuilder::ConvexBuilder(ConvexDecompInterface *callback)
-{
-	mCallback = callback;
-}
-
-ConvexBuilder::~ConvexBuilder(void)
-{
-	int i;
-	for (i = 0; i < mChulls.size(); i++)
-	{
-		CHull *cr = mChulls[i];
-		delete cr;
-	}
-}
-
-bool ConvexBuilder::isDuplicate(unsigned int i1, unsigned int i2, unsigned int i3,
-								unsigned int ci1, unsigned int ci2, unsigned int ci3)
-{
-	unsigned int dcount = 0;
-
-	assert(i1 != i2 && i1 != i3 && i2 != i3);
-	assert(ci1 != ci2 && ci1 != ci3 && ci2 != ci3);
-
-	if (i1 == ci1 || i1 == ci2 || i1 == ci3) dcount++;
-	if (i2 == ci1 || i2 == ci2 || i2 == ci3) dcount++;
-	if (i3 == ci1 || i3 == ci2 || i3 == ci3) dcount++;
-
-	return dcount == 3;
-}
-
-void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector &indices)
-{
-	unsigned int *src = cr.mHullIndices;
-
-	for (unsigned int i = 0; i < cr.mHullTcount; i++)
-	{
-		unsigned int i1 = *src++;
-		unsigned int i2 = *src++;
-		unsigned int i3 = *src++;
-
-		const float *p1 = &cr.mHullVertices[i1 * 3];
-		const float *p2 = &cr.mHullVertices[i2 * 3];
-		const float *p3 = &cr.mHullVertices[i3 * 3];
-
-		i1 = Vl_getIndex(vc, p1);
-		i2 = Vl_getIndex(vc, p2);
-		i3 = Vl_getIndex(vc, p3);
-
-#if 0
-		bool duplicate = false;
-
-		unsigned int tcount = indices.size()/3;
-		for (unsigned int j=0; j<tcount; j++)
-		{
-			unsigned int ci1 = indices[j*3+0];
-			unsigned int ci2 = indices[j*3+1];
-			unsigned int ci3 = indices[j*3+2];
-			if ( isDuplicate(i1,i2,i3, ci1, ci2, ci3 ) )
-			{
-				duplicate = true;
-				break;
-			}
-		}
-
-		if ( !duplicate )
-		{
-			indices.push_back(i1);
-			indices.push_back(i2);
-			indices.push_back(i3);
-		}
-#endif
-	}
-}
-
-CHull *ConvexBuilder::canMerge(CHull *a, CHull *b)
-{
-	if (!a->overlap(*b)) return 0;  // if their AABB's (with a little slop) don't overlap, then return.
-
-	CHull *ret = 0;
-
-	// ok..we are going to combine both meshes into a single mesh
-	// and then we are going to compute the concavity...
-
-	VertexLookup vc = Vl_createVertexLookup();
-
-	UintVector indices;
-
-	getMesh(*a->mResult, vc, indices);
-	getMesh(*b->mResult, vc, indices);
-
-	unsigned int vcount = Vl_getVcount(vc);
-	const float *vertices = Vl_getVertices(vc);
-	unsigned int tcount = indices.size() / 3;
-
-	//don't do anything if hull is empty
-	if (!tcount)
-	{
-		Vl_releaseVertexLookup(vc);
-		return 0;
-	}
-
-	ConvexDecomposition::HullResult hresult;
-	ConvexDecomposition::HullLibrary hl;
-	ConvexDecomposition::HullDesc desc;
-
-	desc.SetHullFlag(ConvexDecomposition::QF_TRIANGLES);
-
-	desc.mVcount = vcount;
-	desc.mVertices = vertices;
-	desc.mVertexStride = sizeof(float) * 3;
-
-	ConvexDecomposition::HullError hret = hl.CreateConvexHull(desc, hresult);
-
-	if (hret == ConvexDecomposition::QE_OK)
-	{
-		float combineVolume = computeMeshVolume(hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
-		float sumVolume = a->mVolume + b->mVolume;
-
-		float percent = (sumVolume * 100) / combineVolume;
-		if (percent >= (100.0f - MERGE_PERCENT))
-		{
-			ConvexDecomposition::ConvexResult cr(hresult.mNumOutputVertices, hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
-			ret = new CHull(cr);
-		}
-	}
-
-	Vl_releaseVertexLookup(vc);
-
-	return ret;
-}
-
-bool ConvexBuilder::combineHulls(void)
-{
-	bool combine = false;
-
-	sortChulls(mChulls);  // sort the convex hulls, largest volume to least...
-
-	CHullVector output;  // the output hulls...
-
-	int i;
-
-	for (i = 0; i < mChulls.size() && !combine; ++i)
-	{
-		CHull *cr = mChulls[i];
-
-		int j;
-		for (j = 0; j < mChulls.size(); j++)
-		{
-			CHull *match = mChulls[j];
-
-			if (cr != match)  // don't try to merge a hull with itself, that be stoopid
-			{
-				CHull *merge = canMerge(cr, match);  // if we can merge these two....
-
-				if (merge)
-				{
-					output.push_back(merge);
-
-					++i;
-					while (i != mChulls.size())
-					{
-						CHull *cr = mChulls[i];
-						if (cr != match)
-						{
-							output.push_back(cr);
-						}
-						i++;
-					}
-
-					delete cr;
-					delete match;
-					combine = true;
-					break;
-				}
-			}
-		}
-
-		if (combine)
-		{
-			break;
-		}
-		else
-		{
-			output.push_back(cr);
-		}
-	}
-
-	if (combine)
-	{
-		mChulls.clear();
-		mChulls.copyFromArray(output);
-		output.clear();
-	}
-
-	return combine;
-}
-
-unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc)
-{
-	unsigned int ret = 0;
-
-	MAXDEPTH = desc.mDepth;
-	CONCAVE_PERCENT = desc.mCpercent;
-	MERGE_PERCENT = desc.mPpercent;
-
-	calcConvexDecomposition(desc.mVcount, desc.mVertices, desc.mTcount, desc.mIndices, this, 0, 0);
-
-	while (combineHulls())
-		;  // keep combinging hulls until I can't combine any more...
-
-	int i;
-	for (i = 0; i < mChulls.size(); i++)
-	{
-		CHull *cr = mChulls[i];
-
-		// before we hand it back to the application, we need to regenerate the hull based on the
-		// limits given by the user.
-
-		const ConvexDecomposition::ConvexResult &c = *cr->mResult;  // the high resolution hull...
-
-		ConvexDecomposition::HullResult result;
-		ConvexDecomposition::HullLibrary hl;
-		ConvexDecomposition::HullDesc hdesc;
-
-		hdesc.SetHullFlag(ConvexDecomposition::QF_TRIANGLES);
-
-		hdesc.mVcount = c.mHullVcount;
-		hdesc.mVertices = c.mHullVertices;
-		hdesc.mVertexStride = sizeof(float) * 3;
-		hdesc.mMaxVertices = desc.mMaxVertices;  // maximum number of vertices allowed in the output
-
-		if (desc.mSkinWidth)
-		{
-			hdesc.mSkinWidth = desc.mSkinWidth;
-			hdesc.SetHullFlag(ConvexDecomposition::QF_SKIN_WIDTH);  // do skin width computation.
-		}
-
-		ConvexDecomposition::HullError ret = hl.CreateConvexHull(hdesc, result);
-
-		if (ret == ConvexDecomposition::QE_OK)
-		{
-			ConvexDecomposition::ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
-
-			r.mHullVolume = computeMeshVolume(result.mOutputVertices, result.mNumFaces, result.mIndices);  // the volume of the hull.
-
-			// compute the best fit OBB
-			computeBestFitOBB(result.mNumOutputVertices, result.mOutputVertices, sizeof(float) * 3, r.mOBBSides, r.mOBBTransform);
-
-			r.mOBBVolume = r.mOBBSides[0] * r.mOBBSides[1] * r.mOBBSides[2];  // compute the OBB volume.
-
-			fm_getTranslation(r.mOBBTransform, r.mOBBCenter);  // get the translation component of the 4x4 matrix.
-
-			fm_matrixToQuat(r.mOBBTransform, r.mOBBOrientation);  // extract the orientation as a quaternion.
-
-			r.mSphereRadius = computeBoundingSphere(result.mNumOutputVertices, result.mOutputVertices, r.mSphereCenter);
-			r.mSphereVolume = fm_sphereVolume(r.mSphereRadius);
-
-			mCallback->ConvexDecompResult(r);
-		}
-
-		hl.ReleaseResult(result);
-
-		delete cr;
-	}
-
-	ret = mChulls.size();
-
-	mChulls.clear();
-
-	return ret;
-}
-
-void ConvexBuilder::ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color)
-{
-	mCallback->ConvexDebugTri(p1, p2, p3, color);
-}
-
-void ConvexBuilder::ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color)
-{
-	mCallback->ConvexDebugOBB(sides, matrix, color);
-}
-void ConvexBuilder::ConvexDebugPoint(const float *p, float dist, unsigned int color)
-{
-	mCallback->ConvexDebugPoint(p, dist, color);
-}
-
-void ConvexBuilder::ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color)
-{
-	mCallback->ConvexDebugBound(bmin, bmax, color);
-}
-
-void ConvexBuilder::ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
-{
-	CHull *ch = new CHull(result);
-	mChulls.push_back(ch);
-}
-
-void ConvexBuilder::sortChulls(CHullVector &hulls)
-{
-	hulls.quickSort(CHullSort());
-	//hulls.heapSort(CHullSort());
-}

+ 0 - 103
ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexBuilder.h

@@ -1,103 +0,0 @@
-#ifndef CONVEX_BUILDER_H
-#define CONVEX_BUILDER_H
-
-/*----------------------------------------------------------------------
-Copyright (c) 2004 Open Dynamics Framework Group
-www.physicstools.org
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided
-that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this list of conditions
-and the following disclaimer.
-
-Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-
-Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#include "ConvexDecomposition.h"
-#include "vlookup.h"
-#include "LinearMath/btAlignedObjectArray.h"
-
-class CHull
-{
-public:
-	CHull(const ConvexDecomposition::ConvexResult &result);
-
-	~CHull(void);
-
-	bool overlap(const CHull &h) const;
-
-	float mMin[3];
-	float mMax[3];
-	float mVolume;
-	float mDiagonal;  // long edge..
-	ConvexDecomposition::ConvexResult *mResult;
-};
-
-// Usage: std::sort( list.begin(), list.end(), StringSortRef() );
-class CHullSort
-{
-public:
-	inline bool operator()(const CHull *a, const CHull *b) const
-	{
-		return a->mVolume < b->mVolume;
-	}
-};
-
-typedef btAlignedObjectArray<CHull *> CHullVector;
-
-class ConvexBuilder : public ConvexDecomposition::ConvexDecompInterface
-{
-public:
-	ConvexBuilder(ConvexDecomposition::ConvexDecompInterface *callback);
-
-	virtual ~ConvexBuilder(void);
-
-	bool isDuplicate(unsigned int i1, unsigned int i2, unsigned int i3,
-					 unsigned int ci1, unsigned int ci2, unsigned int ci3);
-
-	void getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector &indices);
-
-	CHull *canMerge(CHull *a, CHull *b);
-
-	bool combineHulls(void);
-
-	unsigned int process(const ConvexDecomposition::DecompDesc &desc);
-
-	virtual void ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color);
-
-	virtual void ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color);
-	virtual void ConvexDebugPoint(const float *p, float dist, unsigned int color);
-
-	virtual void ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color);
-
-	virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result);
-
-	void sortChulls(CHullVector &hulls);
-
-	CHullVector mChulls;
-	ConvexDecompInterface *mCallback;
-};
-
-#endif  //CONVEX_BUILDER_H

+ 0 - 346
ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexDecomposition.cpp

@@ -1,346 +0,0 @@
-#include "float_math.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#include "ConvexDecomposition.h"
-#include "cd_vector.h"
-#include "cd_hull.h"
-#include "bestfit.h"
-#include "planetri.h"
-#include "vlookup.h"
-#include "splitplane.h"
-#include "meshvolume.h"
-#include "concavity.h"
-#include "bestfitobb.h"
-#include "float_math.h"
-#include "fitsphere.h"
-
-#define SHOW_MESH 0
-#define MAKE_MESH 1
-
-using namespace ConvexDecomposition;
-
-namespace ConvexDecomposition
-{
-class FaceTri
-{
-public:
-	FaceTri(void){};
-	FaceTri(const float *vertices, unsigned int i1, unsigned int i2, unsigned int i3)
-	{
-		mP1.Set(&vertices[i1 * 3]);
-		mP2.Set(&vertices[i2 * 3]);
-		mP3.Set(&vertices[i3 * 3]);
-	}
-
-	Vector3d mP1;
-	Vector3d mP2;
-	Vector3d mP3;
-	Vector3d mNormal;
-};
-
-void addTri(VertexLookup vl, UintVector &list, const Vector3d &p1, const Vector3d &p2, const Vector3d &p3)
-{
-	unsigned int i1 = Vl_getIndex(vl, p1.Ptr());
-	unsigned int i2 = Vl_getIndex(vl, p2.Ptr());
-	unsigned int i3 = Vl_getIndex(vl, p3.Ptr());
-
-	// do *not* process degenerate triangles!
-
-	if (i1 != i2 && i1 != i3 && i2 != i3)
-	{
-		list.push_back(i1);
-		list.push_back(i2);
-		list.push_back(i3);
-	}
-}
-
-void calcConvexDecomposition(unsigned int vcount,
-							 const float *vertices,
-							 unsigned int tcount,
-							 const unsigned int *indices,
-							 ConvexDecompInterface *callback,
-							 float masterVolume,
-							 unsigned int depth)
-
-{
-	float plane[4];
-
-	bool split = false;
-
-	if (depth < MAXDEPTH)
-	{
-		float volume;
-		float c = computeConcavity(vcount, vertices, tcount, indices, callback, plane, volume);
-
-		if (depth == 0)
-		{
-			masterVolume = volume;
-		}
-
-		float percent = (c * 100.0f) / masterVolume;
-
-		if (percent > CONCAVE_PERCENT)  // if great than 5% of the total volume is concave, go ahead and keep splitting.
-		{
-			split = true;
-		}
-	}
-
-	if (depth >= MAXDEPTH || !split)
-	{
-#if 1
-
-		HullResult result;
-		HullLibrary hl;
-		HullDesc desc;
-
-		desc.SetHullFlag(QF_TRIANGLES);
-
-		desc.mVcount = vcount;
-		desc.mVertices = vertices;
-		desc.mVertexStride = sizeof(float) * 3;
-
-		HullError ret = hl.CreateConvexHull(desc, result);
-
-		if (ret == QE_OK)
-		{
-			ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
-
-			callback->ConvexDecompResult(r);
-		}
-
-#else
-
-		static unsigned int colors[8] =
-			{
-				0xFF0000,
-				0x00FF00,
-				0x0000FF,
-				0xFFFF00,
-				0x00FFFF,
-				0xFF00FF,
-				0xFFFFFF,
-				0xFF8040};
-
-		static int count = 0;
-
-		count++;
-
-		if (count == 8) count = 0;
-
-		assert(count >= 0 && count < 8);
-
-		unsigned int color = colors[count];
-
-		const unsigned int *source = indices;
-
-		for (unsigned int i = 0; i < tcount; i++)
-		{
-			unsigned int i1 = *source++;
-			unsigned int i2 = *source++;
-			unsigned int i3 = *source++;
-
-			FaceTri t(vertices, i1, i2, i3);
-
-			callback->ConvexDebugTri(t.mP1.Ptr(), t.mP2.Ptr(), t.mP3.Ptr(), color);
-		}
-#endif
-
-		hl.ReleaseResult(result);
-		return;
-	}
-
-	UintVector ifront;
-	UintVector iback;
-
-	VertexLookup vfront = Vl_createVertexLookup();
-	VertexLookup vback = Vl_createVertexLookup();
-
-	bool showmesh = false;
-#if SHOW_MESH
-	showmesh = true;
-#endif
-
-	if (0)
-	{
-		showmesh = true;
-		for (float x = -1; x < 1; x += 0.10f)
-		{
-			for (float y = 0; y < 1; y += 0.10f)
-			{
-				for (float z = -1; z < 1; z += 0.04f)
-				{
-					float d = x * plane[0] + y * plane[1] + z * plane[2] + plane[3];
-					Vector3d p(x, y, z);
-					if (d >= 0)
-						callback->ConvexDebugPoint(p.Ptr(), 0.02f, 0x00FF00);
-					else
-						callback->ConvexDebugPoint(p.Ptr(), 0.02f, 0xFF0000);
-				}
-			}
-		}
-	}
-
-	if (1)
-	{
-		// ok..now we are going to 'split' all of the input triangles against this plane!
-		const unsigned int *source = indices;
-		for (unsigned int i = 0; i < tcount; i++)
-		{
-			unsigned int i1 = *source++;
-			unsigned int i2 = *source++;
-			unsigned int i3 = *source++;
-
-			FaceTri t(vertices, i1, i2, i3);
-
-			Vector3d front[4];
-			Vector3d back[4];
-
-			unsigned int fcount = 0;
-			unsigned int bcount = 0;
-
-			PlaneTriResult result;
-
-			result = planeTriIntersection(plane, t.mP1.Ptr(), sizeof(Vector3d), 0.00001f, front[0].Ptr(), fcount, back[0].Ptr(), bcount);
-
-			if (fcount > 4 || bcount > 4)
-			{
-				result = planeTriIntersection(plane, t.mP1.Ptr(), sizeof(Vector3d), 0.00001f, front[0].Ptr(), fcount, back[0].Ptr(), bcount);
-			}
-
-			switch (result)
-			{
-				case PTR_FRONT:
-
-					assert(fcount == 3);
-
-					if (showmesh)
-						callback->ConvexDebugTri(front[0].Ptr(), front[1].Ptr(), front[2].Ptr(), 0x00FF00);
-
-#if MAKE_MESH
-
-					addTri(vfront, ifront, front[0], front[1], front[2]);
-
-#endif
-
-					break;
-				case PTR_BACK:
-					assert(bcount == 3);
-
-					if (showmesh)
-						callback->ConvexDebugTri(back[0].Ptr(), back[1].Ptr(), back[2].Ptr(), 0xFFFF00);
-
-#if MAKE_MESH
-
-					addTri(vback, iback, back[0], back[1], back[2]);
-
-#endif
-
-					break;
-				case PTR_SPLIT:
-
-					assert(fcount >= 3 && fcount <= 4);
-					assert(bcount >= 3 && bcount <= 4);
-
-#if MAKE_MESH
-
-					addTri(vfront, ifront, front[0], front[1], front[2]);
-					addTri(vback, iback, back[0], back[1], back[2]);
-
-					if (fcount == 4)
-					{
-						addTri(vfront, ifront, front[0], front[2], front[3]);
-					}
-
-					if (bcount == 4)
-					{
-						addTri(vback, iback, back[0], back[2], back[3]);
-					}
-
-#endif
-
-					if (showmesh)
-					{
-						callback->ConvexDebugTri(front[0].Ptr(), front[1].Ptr(), front[2].Ptr(), 0x00D000);
-						callback->ConvexDebugTri(back[0].Ptr(), back[1].Ptr(), back[2].Ptr(), 0xD0D000);
-
-						if (fcount == 4)
-						{
-							callback->ConvexDebugTri(front[0].Ptr(), front[2].Ptr(), front[3].Ptr(), 0x00D000);
-						}
-						if (bcount == 4)
-						{
-							callback->ConvexDebugTri(back[0].Ptr(), back[2].Ptr(), back[3].Ptr(), 0xD0D000);
-						}
-					}
-
-					break;
-			}
-		}
-
-		// ok... here we recursively call
-		if (ifront.size())
-		{
-			unsigned int vcount = Vl_getVcount(vfront);
-			const float *vertices = Vl_getVertices(vfront);
-			unsigned int tcount = ifront.size() / 3;
-
-			calcConvexDecomposition(vcount, vertices, tcount, &ifront[0], callback, masterVolume, depth + 1);
-		}
-
-		ifront.clear();
-
-		Vl_releaseVertexLookup(vfront);
-
-		if (iback.size())
-		{
-			unsigned int vcount = Vl_getVcount(vback);
-			const float *vertices = Vl_getVertices(vback);
-			unsigned int tcount = iback.size() / 3;
-
-			calcConvexDecomposition(vcount, vertices, tcount, &iback[0], callback, masterVolume, depth + 1);
-		}
-
-		iback.clear();
-		Vl_releaseVertexLookup(vback);
-	}
-}
-
-}  // namespace ConvexDecomposition

+ 0 - 202
ThirdParty/Bullet/Extras/ConvexDecomposition/ConvexDecomposition.h

@@ -1,202 +0,0 @@
-#ifndef CONVEX_DECOMPOSITION_H
-
-#define CONVEX_DECOMPOSITION_H
-
-/*----------------------------------------------------------------------
-Copyright (c) 2004 Open Dynamics Framework Group
-www.physicstools.org
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided
-that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this list of conditions
-and the following disclaimer.
-
-Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-
-Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#ifdef _WIN32
-#include <memory.h>  //memcpy
-#endif
-#include <string.h>
-#include <stdio.h>
-#include "LinearMath/btAlignedObjectArray.h"
-
-extern unsigned int MAXDEPTH;
-extern float CONCAVE_PERCENT;
-extern float MERGE_PERCENT;
-
-typedef btAlignedObjectArray<unsigned int> UintVector;
-
-namespace ConvexDecomposition
-{
-class ConvexResult
-{
-public:
-	ConvexResult(void)
-	{
-		mHullVcount = 0;
-		mHullVertices = 0;
-		mHullTcount = 0;
-		mHullIndices = 0;
-	}
-
-	ConvexResult(unsigned int hvcount, const float *hvertices, unsigned int htcount, const unsigned int *hindices)
-	{
-		mHullVcount = hvcount;
-		if (mHullVcount)
-		{
-			mHullVertices = new float[mHullVcount * sizeof(float) * 3];
-			memcpy(mHullVertices, hvertices, sizeof(float) * 3 * mHullVcount);
-		}
-		else
-		{
-			mHullVertices = 0;
-		}
-
-		mHullTcount = htcount;
-
-		if (mHullTcount)
-		{
-			mHullIndices = new unsigned int[sizeof(unsigned int) * mHullTcount * 3];
-			memcpy(mHullIndices, hindices, sizeof(unsigned int) * mHullTcount * 3);
-		}
-		else
-		{
-			mHullIndices = 0;
-		}
-	}
-
-	ConvexResult(const ConvexResult &r)
-	{
-		mHullVcount = r.mHullVcount;
-		if (mHullVcount)
-		{
-			mHullVertices = new float[mHullVcount * sizeof(float) * 3];
-			memcpy(mHullVertices, r.mHullVertices, sizeof(float) * 3 * mHullVcount);
-		}
-		else
-		{
-			mHullVertices = 0;
-		}
-		mHullTcount = r.mHullTcount;
-		if (mHullTcount)
-		{
-			mHullIndices = new unsigned int[sizeof(unsigned int) * mHullTcount * 3];
-			memcpy(mHullIndices, r.mHullIndices, sizeof(unsigned int) * mHullTcount * 3);
-		}
-		else
-		{
-			mHullIndices = 0;
-		}
-	}
-
-	~ConvexResult(void)
-	{
-		delete[] mHullVertices;
-		delete[] mHullIndices;
-	}
-
-	// the convex hull.
-	unsigned int mHullVcount;
-	float *mHullVertices;
-	unsigned int mHullTcount;
-	unsigned int *mHullIndices;
-
-	float mHullVolume;  // the volume of the convex hull.
-
-	float mOBBSides[3];        // the width, height and breadth of the best fit OBB
-	float mOBBCenter[3];       // the center of the OBB
-	float mOBBOrientation[4];  // the quaternion rotation of the OBB.
-	float mOBBTransform[16];   // the 4x4 transform of the OBB.
-	float mOBBVolume;          // the volume of the OBB
-
-	float mSphereRadius;  // radius and center of best fit sphere
-	float mSphereCenter[3];
-	float mSphereVolume;  // volume of the best fit sphere
-};
-
-class ConvexDecompInterface
-{
-public:
-	virtual ~ConvexDecompInterface(){};
-	virtual void ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color){};
-	virtual void ConvexDebugPoint(const float *p, float dist, unsigned int color){};
-	virtual void ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color){};
-	virtual void ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color){};
-
-	virtual void ConvexDecompResult(ConvexResult &result) = 0;
-};
-
-// just to avoid passing a zillion parameters to the method the
-// options are packed into this descriptor.
-class DecompDesc
-{
-public:
-	DecompDesc(void)
-	{
-		mVcount = 0;
-		mVertices = 0;
-		mTcount = 0;
-		mIndices = 0;
-		mDepth = 5;
-		mCpercent = 5;
-		mPpercent = 5;
-		mMaxVertices = 32;
-		mSkinWidth = 0;
-		mCallback = 0;
-	}
-
-	// describes the input triangle.
-	unsigned int mVcount;    // the number of vertices in the source mesh.
-	const float *mVertices;  // start of the vertex position array.  Assumes a stride of 3 floats.
-	unsigned int mTcount;    // the number of triangles in the source mesh.
-	unsigned int *mIndices;  // the indexed triangle list array (zero index based)
-
-	// options
-	unsigned int mDepth;  // depth to split, a maximum of 10, generally not over 7.
-	float mCpercent;      // the concavity threshold percentage.  0=20 is reasonable.
-	float mPpercent;      // the percentage volume conservation threshold to collapse hulls. 0-30 is reasonable.
-
-	// hull output limits.
-	unsigned int mMaxVertices;  // maximum number of vertices in the output hull. Recommended 32 or less.
-	float mSkinWidth;           // a skin width to apply to the output hulls.
-
-	ConvexDecompInterface *mCallback;  // the interface to receive back the results.
-};
-
-// perform approximate convex decomposition on a mesh.
-unsigned int performConvexDecomposition(const DecompDesc &desc);  // returns the number of hulls produced.
-
-void calcConvexDecomposition(unsigned int vcount,
-							 const float *vertices,
-							 unsigned int tcount,
-							 const unsigned int *indices,
-							 ConvexDecompInterface *callback,
-							 float masterVolume,
-							 unsigned int depth);
-
-}  // namespace ConvexDecomposition
-
-#endif

+ 0 - 19
ThirdParty/Bullet/Extras/ConvexDecomposition/LICENSE.txt

@@ -1,19 +0,0 @@
-Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 448
ThirdParty/Bullet/Extras/ConvexDecomposition/bestfit.cpp

@@ -1,448 +0,0 @@
-#include "float_math.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <math.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-// Geometric Tools, Inc.
-// http://www.geometrictools.com
-// Copyright (c) 1998-2006.  All Rights Reserved
-//
-// The Wild Magic Library (WM3) source code is supplied under the terms of
-// the license agreement
-//     http://www.geometrictools.com/License/WildMagic3License.pdf
-// and may not be copied or disclosed except in accordance with the terms
-// of that agreement.
-
-#include "bestfit.h"
-
-namespace BestFit
-{
-class Vec3
-{
-public:
-	Vec3(void){};
-	Vec3(float _x, float _y, float _z)
-	{
-		x = _x;
-		y = _y;
-		z = _z;
-	};
-
-	float dot(const Vec3 &v)
-	{
-		return x * v.x + y * v.y + z * v.z;  // the dot product
-	}
-
-	float x;
-	float y;
-	float z;
-};
-
-class Eigen
-{
-public:
-	void DecrSortEigenStuff(void)
-	{
-		Tridiagonal();  //diagonalize the matrix.
-		QLAlgorithm();  //
-		DecreasingSort();
-		GuaranteeRotation();
-	}
-
-	void Tridiagonal(void)
-	{
-		float fM00 = mElement[0][0];
-		float fM01 = mElement[0][1];
-		float fM02 = mElement[0][2];
-		float fM11 = mElement[1][1];
-		float fM12 = mElement[1][2];
-		float fM22 = mElement[2][2];
-
-		m_afDiag[0] = fM00;
-		m_afSubd[2] = 0;
-		if (fM02 != (float)0.0)
-		{
-			float fLength = sqrtf(fM01 * fM01 + fM02 * fM02);
-			float fInvLength = ((float)1.0) / fLength;
-			fM01 *= fInvLength;
-			fM02 *= fInvLength;
-			float fQ = ((float)2.0) * fM01 * fM12 + fM02 * (fM22 - fM11);
-			m_afDiag[1] = fM11 + fM02 * fQ;
-			m_afDiag[2] = fM22 - fM02 * fQ;
-			m_afSubd[0] = fLength;
-			m_afSubd[1] = fM12 - fM01 * fQ;
-			mElement[0][0] = (float)1.0;
-			mElement[0][1] = (float)0.0;
-			mElement[0][2] = (float)0.0;
-			mElement[1][0] = (float)0.0;
-			mElement[1][1] = fM01;
-			mElement[1][2] = fM02;
-			mElement[2][0] = (float)0.0;
-			mElement[2][1] = fM02;
-			mElement[2][2] = -fM01;
-			m_bIsRotation = false;
-		}
-		else
-		{
-			m_afDiag[1] = fM11;
-			m_afDiag[2] = fM22;
-			m_afSubd[0] = fM01;
-			m_afSubd[1] = fM12;
-			mElement[0][0] = (float)1.0;
-			mElement[0][1] = (float)0.0;
-			mElement[0][2] = (float)0.0;
-			mElement[1][0] = (float)0.0;
-			mElement[1][1] = (float)1.0;
-			mElement[1][2] = (float)0.0;
-			mElement[2][0] = (float)0.0;
-			mElement[2][1] = (float)0.0;
-			mElement[2][2] = (float)1.0;
-			m_bIsRotation = true;
-		}
-	}
-
-	bool QLAlgorithm(void)
-	{
-		const int iMaxIter = 32;
-
-		for (int i0 = 0; i0 < 3; i0++)
-		{
-			int i1;
-			for (i1 = 0; i1 < iMaxIter; i1++)
-			{
-				int i2;
-				for (i2 = i0; i2 <= (3 - 2); i2++)
-				{
-					float fTmp = fabsf(m_afDiag[i2]) + fabsf(m_afDiag[i2 + 1]);
-					if (fabsf(m_afSubd[i2]) + fTmp == fTmp)
-						break;
-				}
-				if (i2 == i0)
-				{
-					break;
-				}
-
-				float fG = (m_afDiag[i0 + 1] - m_afDiag[i0]) / (((float)2.0) * m_afSubd[i0]);
-				float fR = sqrtf(fG * fG + (float)1.0);
-				if (fG < (float)0.0)
-				{
-					fG = m_afDiag[i2] - m_afDiag[i0] + m_afSubd[i0] / (fG - fR);
-				}
-				else
-				{
-					fG = m_afDiag[i2] - m_afDiag[i0] + m_afSubd[i0] / (fG + fR);
-				}
-				float fSin = (float)1.0, fCos = (float)1.0, fP = (float)0.0;
-				for (int i3 = i2 - 1; i3 >= i0; i3--)
-				{
-					float fF = fSin * m_afSubd[i3];
-					float fB = fCos * m_afSubd[i3];
-					if (fabsf(fF) >= fabsf(fG))
-					{
-						fCos = fG / fF;
-						fR = sqrtf(fCos * fCos + (float)1.0);
-						m_afSubd[i3 + 1] = fF * fR;
-						fSin = ((float)1.0) / fR;
-						fCos *= fSin;
-					}
-					else
-					{
-						fSin = fF / fG;
-						fR = sqrtf(fSin * fSin + (float)1.0);
-						m_afSubd[i3 + 1] = fG * fR;
-						fCos = ((float)1.0) / fR;
-						fSin *= fCos;
-					}
-					fG = m_afDiag[i3 + 1] - fP;
-					fR = (m_afDiag[i3] - fG) * fSin + ((float)2.0) * fB * fCos;
-					fP = fSin * fR;
-					m_afDiag[i3 + 1] = fG + fP;
-					fG = fCos * fR - fB;
-					for (int i4 = 0; i4 < 3; i4++)
-					{
-						fF = mElement[i4][i3 + 1];
-						mElement[i4][i3 + 1] = fSin * mElement[i4][i3] + fCos * fF;
-						mElement[i4][i3] = fCos * mElement[i4][i3] - fSin * fF;
-					}
-				}
-				m_afDiag[i0] -= fP;
-				m_afSubd[i0] = fG;
-				m_afSubd[i2] = (float)0.0;
-			}
-			if (i1 == iMaxIter)
-			{
-				return false;
-			}
-		}
-		return true;
-	}
-
-	void DecreasingSort(void)
-	{
-		//sort eigenvalues in decreasing order, e[0] >= ... >= e[iSize-1]
-		for (int i0 = 0, i1; i0 <= 3 - 2; i0++)
-		{
-			// locate maximum eigenvalue
-			i1 = i0;
-			float fMax = m_afDiag[i1];
-			int i2;
-			for (i2 = i0 + 1; i2 < 3; i2++)
-			{
-				if (m_afDiag[i2] > fMax)
-				{
-					i1 = i2;
-					fMax = m_afDiag[i1];
-				}
-			}
-
-			if (i1 != i0)
-			{
-				// swap eigenvalues
-				m_afDiag[i1] = m_afDiag[i0];
-				m_afDiag[i0] = fMax;
-				// swap eigenvectors
-				for (i2 = 0; i2 < 3; i2++)
-				{
-					float fTmp = mElement[i2][i0];
-					mElement[i2][i0] = mElement[i2][i1];
-					mElement[i2][i1] = fTmp;
-					m_bIsRotation = !m_bIsRotation;
-				}
-			}
-		}
-	}
-
-	void GuaranteeRotation(void)
-	{
-		if (!m_bIsRotation)
-		{
-			// change sign on the first column
-			for (int iRow = 0; iRow < 3; iRow++)
-			{
-				mElement[iRow][0] = -mElement[iRow][0];
-			}
-		}
-	}
-
-	float mElement[3][3];
-	float m_afDiag[3];
-	float m_afSubd[3];
-	bool m_bIsRotation;
-};
-
-}  // namespace BestFit
-
-using namespace BestFit;
-
-bool getBestFitPlane(unsigned int vcount,
-					 const float *points,
-					 unsigned int vstride,
-					 const float *weights,
-					 unsigned int wstride,
-					 float *plane)
-{
-	bool ret = false;
-
-	Vec3 kOrigin(0, 0, 0);
-
-	float wtotal = 0;
-
-	if (1)
-	{
-		const char *source = (const char *)points;
-		const char *wsource = (const char *)weights;
-
-		for (unsigned int i = 0; i < vcount; i++)
-		{
-			const float *p = (const float *)source;
-
-			float w = 1;
-
-			if (wsource)
-			{
-				const float *ws = (const float *)wsource;
-				w = *ws;  //
-				wsource += wstride;
-			}
-
-			kOrigin.x += p[0] * w;
-			kOrigin.y += p[1] * w;
-			kOrigin.z += p[2] * w;
-
-			wtotal += w;
-
-			source += vstride;
-		}
-	}
-
-	float recip = 1.0f / wtotal;  // reciprocol of total weighting
-
-	kOrigin.x *= recip;
-	kOrigin.y *= recip;
-	kOrigin.z *= recip;
-
-	float fSumXX = 0;
-	float fSumXY = 0;
-	float fSumXZ = 0;
-
-	float fSumYY = 0;
-	float fSumYZ = 0;
-	float fSumZZ = 0;
-
-	if (1)
-	{
-		const char *source = (const char *)points;
-		const char *wsource = (const char *)weights;
-
-		for (unsigned int i = 0; i < vcount; i++)
-		{
-			const float *p = (const float *)source;
-
-			float w = 1;
-
-			if (wsource)
-			{
-				const float *ws = (const float *)wsource;
-				w = *ws;  //
-				wsource += wstride;
-			}
-
-			Vec3 kDiff;
-
-			kDiff.x = w * (p[0] - kOrigin.x);  // apply vertex weighting!
-			kDiff.y = w * (p[1] - kOrigin.y);
-			kDiff.z = w * (p[2] - kOrigin.z);
-
-			fSumXX += kDiff.x * kDiff.x;  // sume of the squares of the differences.
-			fSumXY += kDiff.x * kDiff.y;  // sume of the squares of the differences.
-			fSumXZ += kDiff.x * kDiff.z;  // sume of the squares of the differences.
-
-			fSumYY += kDiff.y * kDiff.y;
-			fSumYZ += kDiff.y * kDiff.z;
-			fSumZZ += kDiff.z * kDiff.z;
-
-			source += vstride;
-		}
-	}
-
-	fSumXX *= recip;
-	fSumXY *= recip;
-	fSumXZ *= recip;
-	fSumYY *= recip;
-	fSumYZ *= recip;
-	fSumZZ *= recip;
-
-	// setup the eigensolver
-	Eigen kES;
-
-	kES.mElement[0][0] = fSumXX;
-	kES.mElement[0][1] = fSumXY;
-	kES.mElement[0][2] = fSumXZ;
-
-	kES.mElement[1][0] = fSumXY;
-	kES.mElement[1][1] = fSumYY;
-	kES.mElement[1][2] = fSumYZ;
-
-	kES.mElement[2][0] = fSumXZ;
-	kES.mElement[2][1] = fSumYZ;
-	kES.mElement[2][2] = fSumZZ;
-
-	// compute eigenstuff, smallest eigenvalue is in last position
-	kES.DecrSortEigenStuff();
-
-	Vec3 kNormal;
-
-	kNormal.x = kES.mElement[0][2];
-	kNormal.y = kES.mElement[1][2];
-	kNormal.z = kES.mElement[2][2];
-
-	// the minimum energy
-	plane[0] = kNormal.x;
-	plane[1] = kNormal.y;
-	plane[2] = kNormal.z;
-
-	plane[3] = 0 - kNormal.dot(kOrigin);
-
-	return ret;
-}
-
-float getBoundingRegion(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax)  // returns the diagonal distance
-{
-	const unsigned char *source = (const unsigned char *)points;
-
-	bmin[0] = points[0];
-	bmin[1] = points[1];
-	bmin[2] = points[2];
-
-	bmax[0] = points[0];
-	bmax[1] = points[1];
-	bmax[2] = points[2];
-
-	for (unsigned int i = 1; i < vcount; i++)
-	{
-		source += pstride;
-		const float *p = (const float *)source;
-
-		if (p[0] < bmin[0]) bmin[0] = p[0];
-		if (p[1] < bmin[1]) bmin[1] = p[1];
-		if (p[2] < bmin[2]) bmin[2] = p[2];
-
-		if (p[0] > bmax[0]) bmax[0] = p[0];
-		if (p[1] > bmax[1]) bmax[1] = p[1];
-		if (p[2] > bmax[2]) bmax[2] = p[2];
-	}
-
-	float dx = bmax[0] - bmin[0];
-	float dy = bmax[1] - bmin[1];
-	float dz = bmax[2] - bmin[2];
-
-	return sqrtf(dx * dx + dy * dy + dz * dz);
-}
-
-bool overlapAABB(const float *bmin1, const float *bmax1, const float *bmin2, const float *bmax2)  // return true if the two AABB's overlap.
-{
-	if (bmax2[0] < bmin1[0]) return false;  // if the maximum is less than our minimum on any axis
-	if (bmax2[1] < bmin1[1]) return false;
-	if (bmax2[2] < bmin1[2]) return false;
-
-	if (bmin2[0] > bmax1[0]) return false;  // if the minimum is greater than our maximum on any axis
-	if (bmin2[1] > bmax1[1]) return false;  // if the minimum is greater than our maximum on any axis
-	if (bmin2[2] > bmax1[2]) return false;  // if the minimum is greater than our maximum on any axis
-
-	return true;  // the extents overlap
-}

+ 0 - 63
ThirdParty/Bullet/Extras/ConvexDecomposition/bestfit.h

@@ -1,63 +0,0 @@
-#ifndef BEST_FIT_H
-
-#define BEST_FIT_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-// This routine was released in 'snippet' form
-// by John W. Ratcliff mailto:[email protected]
-// on March 22, 2006.
-//
-// This routine computes the 'best fit' plane equation to
-// a set of input data points with an optional per vertex
-// weighting component.
-//
-// The implementation for this was lifted directly from
-// David Eberly's Magic Software implementation.
-
-// computes the best fit plane to a collection of data points.
-// returns the plane equation as A,B,C,D format. (Ax+By+Cz+D)
-
-bool getBestFitPlane(unsigned int vcount,   // number of input data points
-					 const float *points,   // starting address of points array.
-					 unsigned int vstride,  // stride between input points.
-					 const float *weights,  // *optional point weighting values.
-					 unsigned int wstride,  // weight stride for each vertex.
-					 float *plane);
-
-float getBoundingRegion(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax);  // returns the diagonal distance
-bool overlapAABB(const float *bmin1, const float *bmax1, const float *bmin2, const float *bmax2);                   // return true if the two AABB's overlap.
-
-#endif

+ 0 - 166
ThirdParty/Bullet/Extras/ConvexDecomposition/bestfitobb.cpp

@@ -1,166 +0,0 @@
-#include "float_math.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#include "bestfitobb.h"
-#include "float_math.h"
-
-// computes the OBB for this set of points relative to this transform matrix.
-void computeOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, const float *matrix)
-{
-	const char *src = (const char *)points;
-
-	float bmin[3] = {1e9, 1e9, 1e9};
-	float bmax[3] = {-1e9, -1e9, -1e9};
-
-	for (unsigned int i = 0; i < vcount; i++)
-	{
-		const float *p = (const float *)src;
-		float t[3];
-
-		fm_inverseRT(matrix, p, t);  // inverse rotate translate
-
-		if (t[0] < bmin[0]) bmin[0] = t[0];
-		if (t[1] < bmin[1]) bmin[1] = t[1];
-		if (t[2] < bmin[2]) bmin[2] = t[2];
-
-		if (t[0] > bmax[0]) bmax[0] = t[0];
-		if (t[1] > bmax[1]) bmax[1] = t[1];
-		if (t[2] > bmax[2]) bmax[2] = t[2];
-
-		src += pstride;
-	}
-
-	sides[0] = bmax[0];
-	sides[1] = bmax[1];
-	sides[2] = bmax[2];
-
-	if (fabsf(bmin[0]) > sides[0]) sides[0] = fabsf(bmin[0]);
-	if (fabsf(bmin[1]) > sides[1]) sides[1] = fabsf(bmin[1]);
-	if (fabsf(bmin[2]) > sides[2]) sides[2] = fabsf(bmin[2]);
-
-	sides[0] *= 2.0f;
-	sides[1] *= 2.0f;
-	sides[2] *= 2.0f;
-}
-
-void computeBestFitOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, float *matrix)
-{
-	float bmin[3];
-	float bmax[3];
-
-	fm_getAABB(vcount, points, pstride, bmin, bmax);
-
-	float center[3];
-
-	center[0] = (bmax[0] - bmin[0]) * 0.5f + bmin[0];
-	center[1] = (bmax[1] - bmin[1]) * 0.5f + bmin[1];
-	center[2] = (bmax[2] - bmin[2]) * 0.5f + bmin[2];
-
-	float ax = 0;
-	float ay = 0;
-	float az = 0;
-
-	float sweep = 45.0f;  // 180 degree sweep on all three axes.
-	float steps = 8.0f;   // 16 steps on each axis.
-
-	float bestVolume = 1e9;
-	float angle[3] = {0.f, 0.f, 0.f};
-
-	while (sweep >= 1)
-	{
-		bool found = false;
-
-		float stepsize = sweep / steps;
-
-		for (float x = ax - sweep; x <= ax + sweep; x += stepsize)
-		{
-			for (float y = ay - sweep; y <= ay + sweep; y += stepsize)
-			{
-				for (float z = az - sweep; z <= az + sweep; z += stepsize)
-				{
-					float pmatrix[16];
-
-					fm_eulerMatrix(x * FM_DEG_TO_RAD, y * FM_DEG_TO_RAD, z * FM_DEG_TO_RAD, pmatrix);
-
-					pmatrix[3 * 4 + 0] = center[0];
-					pmatrix[3 * 4 + 1] = center[1];
-					pmatrix[3 * 4 + 2] = center[2];
-
-					float psides[3];
-
-					computeOBB(vcount, points, pstride, psides, pmatrix);
-
-					float volume = psides[0] * psides[1] * psides[2];  // the volume of the cube
-
-					if (volume <= bestVolume)
-					{
-						bestVolume = volume;
-
-						sides[0] = psides[0];
-						sides[1] = psides[1];
-						sides[2] = psides[2];
-
-						angle[0] = ax;
-						angle[1] = ay;
-						angle[2] = az;
-
-						memcpy(matrix, pmatrix, sizeof(float) * 16);
-						found = true;  // yes, we found an improvement.
-					}
-				}
-			}
-		}
-
-		if (found)
-		{
-			ax = angle[0];
-			ay = angle[1];
-			az = angle[2];
-
-			sweep *= 0.5f;  // sweep 1/2 the distance as the last time.
-		}
-		else
-		{
-			break;  // no improvement, so just
-		}
-	}
-}

+ 0 - 41
ThirdParty/Bullet/Extras/ConvexDecomposition/bestfitobb.h

@@ -1,41 +0,0 @@
-#ifndef BEST_FIT_OBB_H
-
-#define BEST_FIT_OBB_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-void computeBestFitOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, float *matrix);
-
-#endif

+ 0 - 3370
ThirdParty/Bullet/Extras/ConvexDecomposition/cd_hull.cpp

@@ -1,3370 +0,0 @@
-#include "float_math.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <math.h>
-#include <float.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#include "cd_hull.h"
-
-using namespace ConvexDecomposition;
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-#define PI 3.14159264f
-
-//*****************************************************
-//*****************************************************
-//********* Stan Melax's vector math template needed
-//********* to use his hull building code.
-//*****************************************************
-//*****************************************************
-
-#define DEG2RAD (PI / 180.0f)
-#define RAD2DEG (180.0f / PI)
-#define SQRT_OF_2 (1.4142135f)
-#define OFFSET(Class, Member) (((char *)(&(((Class *)NULL)->Member))) - ((char *)NULL))
-
-namespace ConvexDecomposition
-{
-int argmin(float a[], int n);
-float sqr(float a);
-float clampf(float a);
-float Round(float a, float precision);
-float Interpolate(const float &f0, const float &f1, float alpha);
-
-template <class T>
-void Swap(T &a, T &b)
-{
-	T tmp = a;
-	a = b;
-	b = tmp;
-}
-
-template <class T>
-T Max(const T &a, const T &b)
-{
-	return (a > b) ? a : b;
-}
-
-template <class T>
-T Min(const T &a, const T &b)
-{
-	return (a < b) ? a : b;
-}
-
-//----------------------------------
-
-class int3
-{
-public:
-	int x, y, z;
-	int3(){};
-	int3(int _x, int _y, int _z)
-	{
-		x = _x;
-		y = _y;
-		z = _z;
-	}
-	const int &operator[](int i) const { return (&x)[i]; }
-	int &operator[](int i) { return (&x)[i]; }
-};
-
-//-------- 2D --------
-
-class float2
-{
-public:
-	float x, y;
-	float2()
-	{
-		x = 0;
-		y = 0;
-	};
-	float2(float _x, float _y)
-	{
-		x = _x;
-		y = _y;
-	}
-	float &operator[](int i)
-	{
-		assert(i >= 0 && i < 2);
-		return ((float *)this)[i];
-	}
-	const float &operator[](int i) const
-	{
-		assert(i >= 0 && i < 2);
-		return ((float *)this)[i];
-	}
-};
-inline float2 operator-(const float2 &a, const float2 &b) { return float2(a.x - b.x, a.y - b.y); }
-inline float2 operator+(const float2 &a, const float2 &b) { return float2(a.x + b.x, a.y + b.y); }
-
-//--------- 3D ---------
-
-class float3  // 3D
-{
-public:
-	float x, y, z;
-	float3()
-	{
-		x = 0;
-		y = 0;
-		z = 0;
-	};
-	float3(float _x, float _y, float _z)
-	{
-		x = _x;
-		y = _y;
-		z = _z;
-	};
-	//operator float *() { return &x;};
-	float &operator[](int i)
-	{
-		assert(i >= 0 && i < 3);
-		return ((float *)this)[i];
-	}
-	const float &operator[](int i) const
-	{
-		assert(i >= 0 && i < 3);
-		return ((float *)this)[i];
-	}
-#ifdef PLUGIN_3DSMAX
-	float3(const Point3 &p) : x(p.x), y(p.y), z(p.z)
-	{
-	}
-	operator Point3() { return *((Point3 *)this); }
-#endif
-};
-
-float3 &operator+=(float3 &a, const float3 &b);
-float3 &operator-=(float3 &a, const float3 &b);
-float3 &operator*=(float3 &v, const float s);
-float3 &operator/=(float3 &v, const float s);
-
-float magnitude(const float3 &v);
-float3 normalize(const float3 &v);
-float3 safenormalize(const float3 &v);
-float3 vabs(const float3 &v);
-float3 operator+(const float3 &a, const float3 &b);
-float3 operator-(const float3 &a, const float3 &b);
-float3 operator-(const float3 &v);
-float3 operator*(const float3 &v, const float s);
-float3 operator*(const float s, const float3 &v);
-float3 operator/(const float3 &v, const float s);
-inline int operator==(const float3 &a, const float3 &b) { return (a.x == b.x && a.y == b.y && a.z == b.z); }
-inline int operator!=(const float3 &a, const float3 &b) { return (a.x != b.x || a.y != b.y || a.z != b.z); }
-// due to ambiguity and inconsistent standards ther are no overloaded operators for mult such as va*vb.
-float dot(const float3 &a, const float3 &b);
-float3 cmul(const float3 &a, const float3 &b);
-float3 cross(const float3 &a, const float3 &b);
-float3 Interpolate(const float3 &v0, const float3 &v1, float alpha);
-float3 Round(const float3 &a, float precision);
-float3 VectorMax(const float3 &a, const float3 &b);
-float3 VectorMin(const float3 &a, const float3 &b);
-
-class float3x3
-{
-public:
-	float3 x, y, z;  // the 3 rows of the Matrix
-	float3x3() {}
-	float3x3(float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz) : x(xx, xy, xz), y(yx, yy, yz), z(zx, zy, zz) {}
-	float3x3(float3 _x, float3 _y, float3 _z) : x(_x), y(_y), z(_z) {}
-	float3 &operator[](int i)
-	{
-		assert(i >= 0 && i < 3);
-		return (&x)[i];
-	}
-	const float3 &operator[](int i) const
-	{
-		assert(i >= 0 && i < 3);
-		return (&x)[i];
-	}
-	float &operator()(int r, int c)
-	{
-		assert(r >= 0 && r < 3 && c >= 0 && c < 3);
-		return ((&x)[r])[c];
-	}
-	const float &operator()(int r, int c) const
-	{
-		assert(r >= 0 && r < 3 && c >= 0 && c < 3);
-		return ((&x)[r])[c];
-	}
-};
-float3x3 Transpose(const float3x3 &m);
-float3 operator*(const float3 &v, const float3x3 &m);
-float3 operator*(const float3x3 &m, const float3 &v);
-float3x3 operator*(const float3x3 &m, const float &s);
-float3x3 operator*(const float3x3 &ma, const float3x3 &mb);
-float3x3 operator/(const float3x3 &a, const float &s);
-float3x3 operator+(const float3x3 &a, const float3x3 &b);
-float3x3 operator-(const float3x3 &a, const float3x3 &b);
-float3x3 &operator+=(float3x3 &a, const float3x3 &b);
-float3x3 &operator-=(float3x3 &a, const float3x3 &b);
-float3x3 &operator*=(float3x3 &a, const float &s);
-float Determinant(const float3x3 &m);
-float3x3 Inverse(const float3x3 &a);  // its just 3x3 so we simply do that cofactor method
-
-//-------- 4D Math --------
-
-class float4
-{
-public:
-	float x, y, z, w;
-	float4()
-	{
-		x = 0;
-		y = 0;
-		z = 0;
-		w = 0;
-	};
-	float4(float _x, float _y, float _z, float _w)
-	{
-		x = _x;
-		y = _y;
-		z = _z;
-		w = _w;
-	}
-	float4(const float3 &v, float _w)
-	{
-		x = v.x;
-		y = v.y;
-		z = v.z;
-		w = _w;
-	}
-	//operator float *() { return &x;};
-	float &operator[](int i)
-	{
-		assert(i >= 0 && i < 4);
-		return ((float *)this)[i];
-	}
-	const float &operator[](int i) const
-	{
-		assert(i >= 0 && i < 4);
-		return ((float *)this)[i];
-	}
-	const float3 &xyz() const { return *((float3 *)this); }
-	float3 &xyz() { return *((float3 *)this); }
-};
-
-struct D3DXMATRIX;
-
-class float4x4
-{
-public:
-	float4 x, y, z, w;  // the 4 rows
-	float4x4() {}
-	float4x4(const float4 &_x, const float4 &_y, const float4 &_z, const float4 &_w) : x(_x), y(_y), z(_z), w(_w) {}
-	float4x4(float m00, float m01, float m02, float m03,
-			 float m10, float m11, float m12, float m13,
-			 float m20, float m21, float m22, float m23,
-			 float m30, float m31, float m32, float m33)
-		: x(m00, m01, m02, m03), y(m10, m11, m12, m13), z(m20, m21, m22, m23), w(m30, m31, m32, m33) {}
-	float &operator()(int r, int c)
-	{
-		assert(r >= 0 && r < 4 && c >= 0 && c < 4);
-		return ((&x)[r])[c];
-	}
-	const float &operator()(int r, int c) const
-	{
-		assert(r >= 0 && r < 4 && c >= 0 && c < 4);
-		return ((&x)[r])[c];
-	}
-	operator float *() { return &x.x; }
-	operator const float *() const { return &x.x; }
-	operator struct D3DXMATRIX *() { return (struct D3DXMATRIX *)this; }
-	operator const struct D3DXMATRIX *() const { return (struct D3DXMATRIX *)this; }
-};
-
-int operator==(const float4 &a, const float4 &b);
-float4 Homogenize(const float3 &v3, const float &w = 1.0f);  // Turns a 3D float3 4D vector4 by appending w
-float4 cmul(const float4 &a, const float4 &b);
-float4 operator*(const float4 &v, float s);
-float4 operator*(float s, const float4 &v);
-float4 operator+(const float4 &a, const float4 &b);
-float4 operator-(const float4 &a, const float4 &b);
-float4x4 operator*(const float4x4 &a, const float4x4 &b);
-float4 operator*(const float4 &v, const float4x4 &m);
-float4x4 Inverse(const float4x4 &m);
-float4x4 MatrixRigidInverse(const float4x4 &m);
-float4x4 MatrixTranspose(const float4x4 &m);
-float4x4 MatrixPerspectiveFov(float fovy, float Aspect, float zn, float zf);
-float4x4 MatrixTranslation(const float3 &t);
-float4x4 MatrixRotationZ(const float angle_radians);
-float4x4 MatrixLookAt(const float3 &eye, const float3 &at, const float3 &up);
-int operator==(const float4x4 &a, const float4x4 &b);
-
-//-------- Quaternion ------------
-
-class Quaternion : public float4
-{
-public:
-	Quaternion()
-	{
-		x = y = z = 0.0f;
-		w = 1.0f;
-	}
-	Quaternion(float3 v, float t)
-	{
-		v = normalize(v);
-		w = cosf(t / 2.0f);
-		v = v * sinf(t / 2.0f);
-		x = v.x;
-		y = v.y;
-		z = v.z;
-	}
-	Quaternion(float _x, float _y, float _z, float _w)
-	{
-		x = _x;
-		y = _y;
-		z = _z;
-		w = _w;
-	}
-	float angle() const { return acosf(w) * 2.0f; }
-	float3 axis() const
-	{
-		float3 a(x, y, z);
-		if (fabsf(angle()) < 0.0000001f) return float3(1, 0, 0);
-		return a * (1 / sinf(angle() / 2.0f));
-	}
-	float3 xdir() const { return float3(1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y)); }
-	float3 ydir() const { return float3(2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x)); }
-	float3 zdir() const { return float3(2 * (x * z + w * y), 2 * (y * z - w * x), 1 - 2 * (x * x + y * y)); }
-	float3x3 getmatrix() const { return float3x3(xdir(), ydir(), zdir()); }
-	operator float3x3() { return getmatrix(); }
-	void Normalize();
-};
-
-Quaternion &operator*=(Quaternion &a, float s);
-Quaternion operator*(const Quaternion &a, float s);
-Quaternion operator*(const Quaternion &a, const Quaternion &b);
-Quaternion operator+(const Quaternion &a, const Quaternion &b);
-Quaternion normalize(Quaternion a);
-float dot(const Quaternion &a, const Quaternion &b);
-float3 operator*(const Quaternion &q, const float3 &v);
-float3 operator*(const float3 &v, const Quaternion &q);
-Quaternion slerp(Quaternion a, const Quaternion &b, float interp);
-Quaternion Interpolate(const Quaternion &q0, const Quaternion &q1, float alpha);
-Quaternion RotationArc(float3 v0, float3 v1);  // returns quat q where q*v0=v1
-Quaternion Inverse(const Quaternion &q);
-float4x4 MatrixFromQuatVec(const Quaternion &q, const float3 &v);
-
-//------ Euler Angle -----
-
-Quaternion YawPitchRoll(float yaw, float pitch, float roll);
-float Yaw(const Quaternion &q);
-float Pitch(const Quaternion &q);
-float Roll(Quaternion q);
-float Yaw(const float3 &v);
-float Pitch(const float3 &v);
-
-//------- Plane ----------
-
-class Plane
-{
-public:
-	float3 normal;
-	float dist;  // distance below origin - the D from plane equasion Ax+By+Cz+D=0
-	Plane(const float3 &n, float d) : normal(n), dist(d) {}
-	Plane() : normal(), dist(0) {}
-	void Transform(const float3 &position, const Quaternion &orientation);
-};
-
-inline Plane PlaneFlip(const Plane &plane) { return Plane(-plane.normal, -plane.dist); }
-inline int operator==(const Plane &a, const Plane &b) { return (a.normal == b.normal && a.dist == b.dist); }
-inline int coplanar(const Plane &a, const Plane &b) { return (a == b || a == PlaneFlip(b)); }
-
-//--------- Utility Functions ------
-
-float3 PlaneLineIntersection(const Plane &plane, const float3 &p0, const float3 &p1);
-float3 PlaneProject(const Plane &plane, const float3 &point);
-float3 LineProject(const float3 &p0, const float3 &p1, const float3 &a);  // projects a onto infinite line p0p1
-float LineProjectTime(const float3 &p0, const float3 &p1, const float3 &a);
-float3 ThreePlaneIntersection(const Plane &p0, const Plane &p1, const Plane &p2);
-int PolyHit(const float3 *vert, const int n, const float3 &v0, const float3 &v1, float3 *impact = NULL, float3 *normal = NULL);
-int BoxInside(const float3 &p, const float3 &bmin, const float3 &bmax);
-int BoxIntersect(const float3 &v0, const float3 &v1, const float3 &bmin, const float3 &bmax, float3 *impact);
-float DistanceBetweenLines(const float3 &ustart, const float3 &udir, const float3 &vstart, const float3 &vdir, float3 *upoint = NULL, float3 *vpoint = NULL);
-float3 TriNormal(const float3 &v0, const float3 &v1, const float3 &v2);
-float3 NormalOf(const float3 *vert, const int n);
-Quaternion VirtualTrackBall(const float3 &cop, const float3 &cor, const float3 &dir0, const float3 &dir1);
-
-float sqr(float a) { return a * a; }
-float clampf(float a) { return Min(1.0f, Max(0.0f, a)); }
-
-float Round(float a, float precision)
-{
-	return floorf(0.5f + a / precision) * precision;
-}
-
-float Interpolate(const float &f0, const float &f1, float alpha)
-{
-	return f0 * (1 - alpha) + f1 * alpha;
-}
-
-int argmin(float a[], int n)
-{
-	int r = 0;
-	for (int i = 1; i < n; i++)
-	{
-		if (a[i] < a[r])
-		{
-			r = i;
-		}
-	}
-	return r;
-}
-
-//------------ float3 (3D) --------------
-
-float3 operator+(const float3 &a, const float3 &b)
-{
-	return float3(a.x + b.x, a.y + b.y, a.z + b.z);
-}
-
-float3 operator-(const float3 &a, const float3 &b)
-{
-	return float3(a.x - b.x, a.y - b.y, a.z - b.z);
-}
-
-float3 operator-(const float3 &v)
-{
-	return float3(-v.x, -v.y, -v.z);
-}
-
-float3 operator*(const float3 &v, float s)
-{
-	return float3(v.x * s, v.y * s, v.z * s);
-}
-
-float3 operator*(float s, const float3 &v)
-{
-	return float3(v.x * s, v.y * s, v.z * s);
-}
-
-float3 operator/(const float3 &v, float s)
-{
-	return v * (1.0f / s);
-}
-
-float dot(const float3 &a, const float3 &b)
-{
-	return a.x * b.x + a.y * b.y + a.z * b.z;
-}
-
-float3 cmul(const float3 &v1, const float3 &v2)
-{
-	return float3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
-}
-
-float3 cross(const float3 &a, const float3 &b)
-{
-	return float3(a.y * b.z - a.z * b.y,
-				  a.z * b.x - a.x * b.z,
-				  a.x * b.y - a.y * b.x);
-}
-
-float3 &operator+=(float3 &a, const float3 &b)
-{
-	a.x += b.x;
-	a.y += b.y;
-	a.z += b.z;
-	return a;
-}
-
-float3 &operator-=(float3 &a, const float3 &b)
-{
-	a.x -= b.x;
-	a.y -= b.y;
-	a.z -= b.z;
-	return a;
-}
-
-float3 &operator*=(float3 &v, float s)
-{
-	v.x *= s;
-	v.y *= s;
-	v.z *= s;
-	return v;
-}
-
-float3 &operator/=(float3 &v, float s)
-{
-	float sinv = 1.0f / s;
-	v.x *= sinv;
-	v.y *= sinv;
-	v.z *= sinv;
-	return v;
-}
-
-float3 vabs(const float3 &v)
-{
-	return float3(fabsf(v.x), fabsf(v.y), fabsf(v.z));
-}
-
-float magnitude(const float3 &v)
-{
-	return sqrtf(sqr(v.x) + sqr(v.y) + sqr(v.z));
-}
-
-float3 normalize(const float3 &v)
-{
-	// this routine, normalize, is ok, provided magnitude works!!
-	float d = magnitude(v);
-	if (d == 0)
-	{
-		printf("Cant normalize ZERO vector\n");
-		assert(0);  // yes this could go here
-		d = 0.1f;
-	}
-	d = 1 / d;
-	return float3(v.x * d, v.y * d, v.z * d);
-}
-
-float3 safenormalize(const float3 &v)
-{
-	if (magnitude(v) <= 0.0f)
-	{
-		return float3(1, 0, 0);
-	}
-	return normalize(v);
-}
-
-float3 Round(const float3 &a, float precision)
-{
-	return float3(Round(a.x, precision), Round(a.y, precision), Round(a.z, precision));
-}
-
-float3 Interpolate(const float3 &v0, const float3 &v1, float alpha)
-{
-	return v0 * (1 - alpha) + v1 * alpha;
-}
-
-float3 VectorMin(const float3 &a, const float3 &b)
-{
-	return float3(Min(a.x, b.x), Min(a.y, b.y), Min(a.z, b.z));
-}
-float3 VectorMax(const float3 &a, const float3 &b)
-{
-	return float3(Max(a.x, b.x), Max(a.y, b.y), Max(a.z, b.z));
-}
-
-// the statement v1*v2 is ambiguous since there are 3 types
-// of vector multiplication
-//  - componantwise (for example combining colors)
-//  - dot product
-//  - cross product
-// Therefore we never declare/implement this function.
-// So we will never see:  float3 operator*(float3 a,float3 b)
-
-//------------ float3x3 ---------------
-float Determinant(const float3x3 &m)
-{
-	return m.x.x * m.y.y * m.z.z + m.y.x * m.z.y * m.x.z + m.z.x * m.x.y * m.y.z - m.x.x * m.z.y * m.y.z - m.y.x * m.x.y * m.z.z - m.z.x * m.y.y * m.x.z;
-}
-
-float3x3 Inverse(const float3x3 &a)
-{
-	float3x3 b;
-	float d = Determinant(a);
-	assert(d != 0);
-	for (int i = 0; i < 3; i++)
-	{
-		for (int j = 0; j < 3; j++)
-		{
-			int i1 = (i + 1) % 3;
-			int i2 = (i + 2) % 3;
-			int j1 = (j + 1) % 3;
-			int j2 = (j + 2) % 3;
-			// reverse indexs i&j to take transpose
-			b[j][i] = (a[i1][j1] * a[i2][j2] - a[i1][j2] * a[i2][j1]) / d;
-		}
-	}
-	// Matrix check=a*b; // Matrix 'check' should be the identity (or close to it)
-	return b;
-}
-
-float3x3 Transpose(const float3x3 &m)
-{
-	return float3x3(float3(m.x.x, m.y.x, m.z.x),
-					float3(m.x.y, m.y.y, m.z.y),
-					float3(m.x.z, m.y.z, m.z.z));
-}
-
-float3 operator*(const float3 &v, const float3x3 &m)
-{
-	return float3((m.x.x * v.x + m.y.x * v.y + m.z.x * v.z),
-				  (m.x.y * v.x + m.y.y * v.y + m.z.y * v.z),
-				  (m.x.z * v.x + m.y.z * v.y + m.z.z * v.z));
-}
-float3 operator*(const float3x3 &m, const float3 &v)
-{
-	return float3(dot(m.x, v), dot(m.y, v), dot(m.z, v));
-}
-
-float3x3 operator*(const float3x3 &a, const float3x3 &b)
-{
-	return float3x3(a.x * b, a.y * b, a.z * b);
-}
-
-float3x3 operator*(const float3x3 &a, const float &s)
-{
-	return float3x3(a.x * s, a.y * s, a.z * s);
-}
-float3x3 operator/(const float3x3 &a, const float &s)
-{
-	float t = 1 / s;
-	return float3x3(a.x * t, a.y * t, a.z * t);
-}
-float3x3 operator+(const float3x3 &a, const float3x3 &b)
-{
-	return float3x3(a.x + b.x, a.y + b.y, a.z + b.z);
-}
-float3x3 operator-(const float3x3 &a, const float3x3 &b)
-{
-	return float3x3(a.x - b.x, a.y - b.y, a.z - b.z);
-}
-float3x3 &operator+=(float3x3 &a, const float3x3 &b)
-{
-	a.x += b.x;
-	a.y += b.y;
-	a.z += b.z;
-	return a;
-}
-float3x3 &operator-=(float3x3 &a, const float3x3 &b)
-{
-	a.x -= b.x;
-	a.y -= b.y;
-	a.z -= b.z;
-	return a;
-}
-float3x3 &operator*=(float3x3 &a, const float &s)
-{
-	a.x *= s;
-	a.y *= s;
-	a.z *= s;
-	return a;
-}
-
-float3 ThreePlaneIntersection(const Plane &p0, const Plane &p1, const Plane &p2)
-{
-	float3x3 mp = Transpose(float3x3(p0.normal, p1.normal, p2.normal));
-	float3x3 mi = Inverse(mp);
-	float3 b(p0.dist, p1.dist, p2.dist);
-	return -b * mi;
-}
-
-//--------------- 4D ----------------
-
-float4 operator*(const float4 &v, const float4x4 &m)
-{
-	return v.x * m.x + v.y * m.y + v.z * m.z + v.w * m.w;  // yes this actually works
-}
-
-int operator==(const float4 &a, const float4 &b)
-{
-	return (a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
-}
-
-//  Dont implement m*v for now, since that might confuse us
-//  All our transforms are based on multiplying the "row" vector on the left
-//float4   operator*(const float4x4& m , const float4&   v )
-//{
-//	return float4(dot(v,m.x),dot(v,m.y),dot(v,m.z),dot(v,m.w));
-//}
-
-float4 cmul(const float4 &a, const float4 &b)
-{
-	return float4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
-}
-
-float4 operator*(const float4 &v, float s)
-{
-	return float4(v.x * s, v.y * s, v.z * s, v.w * s);
-}
-
-float4 operator*(float s, const float4 &v)
-{
-	return float4(v.x * s, v.y * s, v.z * s, v.w * s);
-}
-
-float4 operator+(const float4 &a, const float4 &b)
-{
-	return float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
-}
-
-float4 operator-(const float4 &a, const float4 &b)
-{
-	return float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
-}
-
-float4 Homogenize(const float3 &v3, const float &w)
-{
-	return float4(v3.x, v3.y, v3.z, w);
-}
-
-float4x4 operator*(const float4x4 &a, const float4x4 &b)
-{
-	return float4x4(a.x * b, a.y * b, a.z * b, a.w * b);
-}
-
-float4x4 MatrixTranspose(const float4x4 &m)
-{
-	return float4x4(
-		m.x.x, m.y.x, m.z.x, m.w.x,
-		m.x.y, m.y.y, m.z.y, m.w.y,
-		m.x.z, m.y.z, m.z.z, m.w.z,
-		m.x.w, m.y.w, m.z.w, m.w.w);
-}
-
-float4x4 MatrixRigidInverse(const float4x4 &m)
-{
-	float4x4 trans_inverse = MatrixTranslation(-m.w.xyz());
-	float4x4 rot = m;
-	rot.w = float4(0, 0, 0, 1);
-	return trans_inverse * MatrixTranspose(rot);
-}
-
-float4x4 MatrixPerspectiveFov(float fovy, float aspect, float zn, float zf)
-{
-	float h = 1.0f / tanf(fovy / 2.0f);  // view space height
-	float w = h / aspect;                // view space width
-	return float4x4(
-		w, 0, 0, 0,
-		0, h, 0, 0,
-		0, 0, zf / (zn - zf), -1,
-		0, 0, zn * zf / (zn - zf), 0);
-}
-
-float4x4 MatrixLookAt(const float3 &eye, const float3 &at, const float3 &up)
-{
-	float4x4 m;
-	m.w.w = 1.0f;
-	m.w.xyz() = eye;
-	m.z.xyz() = normalize(eye - at);
-	m.x.xyz() = normalize(cross(up, m.z.xyz()));
-	m.y.xyz() = cross(m.z.xyz(), m.x.xyz());
-	return MatrixRigidInverse(m);
-}
-
-float4x4 MatrixTranslation(const float3 &t)
-{
-	return float4x4(
-		1, 0, 0, 0,
-		0, 1, 0, 0,
-		0, 0, 1, 0,
-		t.x, t.y, t.z, 1);
-}
-
-float4x4 MatrixRotationZ(const float angle_radians)
-{
-	float s = sinf(angle_radians);
-	float c = cosf(angle_radians);
-	return float4x4(
-		c, s, 0, 0,
-		-s, c, 0, 0,
-		0, 0, 1, 0,
-		0, 0, 0, 1);
-}
-
-int operator==(const float4x4 &a, const float4x4 &b)
-{
-	return (a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
-}
-
-float4x4 Inverse(const float4x4 &m)
-{
-	float4x4 d;
-	float *dst = &d.x.x;
-	float tmp[12]; /* temp array for pairs */
-	float src[16]; /* array of transpose source matrix */
-	float det;     /* determinant */
-	/* transpose matrix */
-	for (int i = 0; i < 4; i++)
-	{
-		src[i] = m(i, 0);
-		src[i + 4] = m(i, 1);
-		src[i + 8] = m(i, 2);
-		src[i + 12] = m(i, 3);
-	}
-	/* calculate pairs for first 8 elements (cofactors) */
-	tmp[0] = src[10] * src[15];
-	tmp[1] = src[11] * src[14];
-	tmp[2] = src[9] * src[15];
-	tmp[3] = src[11] * src[13];
-	tmp[4] = src[9] * src[14];
-	tmp[5] = src[10] * src[13];
-	tmp[6] = src[8] * src[15];
-	tmp[7] = src[11] * src[12];
-	tmp[8] = src[8] * src[14];
-	tmp[9] = src[10] * src[12];
-	tmp[10] = src[8] * src[13];
-	tmp[11] = src[9] * src[12];
-	/* calculate first 8 elements (cofactors) */
-	dst[0] = tmp[0] * src[5] + tmp[3] * src[6] + tmp[4] * src[7];
-	dst[0] -= tmp[1] * src[5] + tmp[2] * src[6] + tmp[5] * src[7];
-	dst[1] = tmp[1] * src[4] + tmp[6] * src[6] + tmp[9] * src[7];
-	dst[1] -= tmp[0] * src[4] + tmp[7] * src[6] + tmp[8] * src[7];
-	dst[2] = tmp[2] * src[4] + tmp[7] * src[5] + tmp[10] * src[7];
-	dst[2] -= tmp[3] * src[4] + tmp[6] * src[5] + tmp[11] * src[7];
-	dst[3] = tmp[5] * src[4] + tmp[8] * src[5] + tmp[11] * src[6];
-	dst[3] -= tmp[4] * src[4] + tmp[9] * src[5] + tmp[10] * src[6];
-	dst[4] = tmp[1] * src[1] + tmp[2] * src[2] + tmp[5] * src[3];
-	dst[4] -= tmp[0] * src[1] + tmp[3] * src[2] + tmp[4] * src[3];
-	dst[5] = tmp[0] * src[0] + tmp[7] * src[2] + tmp[8] * src[3];
-	dst[5] -= tmp[1] * src[0] + tmp[6] * src[2] + tmp[9] * src[3];
-	dst[6] = tmp[3] * src[0] + tmp[6] * src[1] + tmp[11] * src[3];
-	dst[6] -= tmp[2] * src[0] + tmp[7] * src[1] + tmp[10] * src[3];
-	dst[7] = tmp[4] * src[0] + tmp[9] * src[1] + tmp[10] * src[2];
-	dst[7] -= tmp[5] * src[0] + tmp[8] * src[1] + tmp[11] * src[2];
-	/* calculate pairs for second 8 elements (cofactors) */
-	tmp[0] = src[2] * src[7];
-	tmp[1] = src[3] * src[6];
-	tmp[2] = src[1] * src[7];
-	tmp[3] = src[3] * src[5];
-	tmp[4] = src[1] * src[6];
-	tmp[5] = src[2] * src[5];
-	tmp[6] = src[0] * src[7];
-	tmp[7] = src[3] * src[4];
-	tmp[8] = src[0] * src[6];
-	tmp[9] = src[2] * src[4];
-	tmp[10] = src[0] * src[5];
-	tmp[11] = src[1] * src[4];
-	/* calculate second 8 elements (cofactors) */
-	dst[8] = tmp[0] * src[13] + tmp[3] * src[14] + tmp[4] * src[15];
-	dst[8] -= tmp[1] * src[13] + tmp[2] * src[14] + tmp[5] * src[15];
-	dst[9] = tmp[1] * src[12] + tmp[6] * src[14] + tmp[9] * src[15];
-	dst[9] -= tmp[0] * src[12] + tmp[7] * src[14] + tmp[8] * src[15];
-	dst[10] = tmp[2] * src[12] + tmp[7] * src[13] + tmp[10] * src[15];
-	dst[10] -= tmp[3] * src[12] + tmp[6] * src[13] + tmp[11] * src[15];
-	dst[11] = tmp[5] * src[12] + tmp[8] * src[13] + tmp[11] * src[14];
-	dst[11] -= tmp[4] * src[12] + tmp[9] * src[13] + tmp[10] * src[14];
-	dst[12] = tmp[2] * src[10] + tmp[5] * src[11] + tmp[1] * src[9];
-	dst[12] -= tmp[4] * src[11] + tmp[0] * src[9] + tmp[3] * src[10];
-	dst[13] = tmp[8] * src[11] + tmp[0] * src[8] + tmp[7] * src[10];
-	dst[13] -= tmp[6] * src[10] + tmp[9] * src[11] + tmp[1] * src[8];
-	dst[14] = tmp[6] * src[9] + tmp[11] * src[11] + tmp[3] * src[8];
-	dst[14] -= tmp[10] * src[11] + tmp[2] * src[8] + tmp[7] * src[9];
-	dst[15] = tmp[10] * src[10] + tmp[4] * src[8] + tmp[9] * src[9];
-	dst[15] -= tmp[8] * src[9] + tmp[11] * src[10] + tmp[5] * src[8];
-	/* calculate determinant */
-	det = src[0] * dst[0] + src[1] * dst[1] + src[2] * dst[2] + src[3] * dst[3];
-	/* calculate matrix inverse */
-	det = 1 / det;
-	for (int j = 0; j < 16; j++)
-		dst[j] *= det;
-	return d;
-}
-
-//--------- Quaternion --------------
-
-Quaternion operator*(const Quaternion &a, const Quaternion &b)
-{
-	Quaternion c;
-	c.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;
-	c.x = a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y;
-	c.y = a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x;
-	c.z = a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w;
-	return c;
-}
-
-Quaternion operator*(const Quaternion &a, float b)
-{
-	return Quaternion(a.x * b, a.y * b, a.z * b, a.w * b);
-}
-
-Quaternion Inverse(const Quaternion &q)
-{
-	return Quaternion(-q.x, -q.y, -q.z, q.w);
-}
-
-Quaternion &operator*=(Quaternion &q, const float s)
-{
-	q.x *= s;
-	q.y *= s;
-	q.z *= s;
-	q.w *= s;
-	return q;
-}
-void Quaternion::Normalize()
-{
-	float m = sqrtf(sqr(w) + sqr(x) + sqr(y) + sqr(z));
-	if (m < 0.000000001f)
-	{
-		w = 1.0f;
-		x = y = z = 0.0f;
-		return;
-	}
-	(*this) *= (1.0f / m);
-}
-
-float3 operator*(const Quaternion &q, const float3 &v)
-{
-	// The following is equivalent to:
-	//return (q.getmatrix() * v);
-	float qx2 = q.x * q.x;
-	float qy2 = q.y * q.y;
-	float qz2 = q.z * q.z;
-
-	float qxqy = q.x * q.y;
-	float qxqz = q.x * q.z;
-	float qxqw = q.x * q.w;
-	float qyqz = q.y * q.z;
-	float qyqw = q.y * q.w;
-	float qzqw = q.z * q.w;
-	return float3(
-		(1 - 2 * (qy2 + qz2)) * v.x + (2 * (qxqy - qzqw)) * v.y + (2 * (qxqz + qyqw)) * v.z,
-		(2 * (qxqy + qzqw)) * v.x + (1 - 2 * (qx2 + qz2)) * v.y + (2 * (qyqz - qxqw)) * v.z,
-		(2 * (qxqz - qyqw)) * v.x + (2 * (qyqz + qxqw)) * v.y + (1 - 2 * (qx2 + qy2)) * v.z);
-}
-
-float3 operator*(const float3 &v, const Quaternion &q)
-{
-	assert(0);  // must multiply with the quat on the left
-	return float3(0.0f, 0.0f, 0.0f);
-}
-
-Quaternion operator+(const Quaternion &a, const Quaternion &b)
-{
-	return Quaternion(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
-}
-
-float dot(const Quaternion &a, const Quaternion &b)
-{
-	return (a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z);
-}
-
-Quaternion normalize(Quaternion a)
-{
-	float m = sqrtf(sqr(a.w) + sqr(a.x) + sqr(a.y) + sqr(a.z));
-	if (m < 0.000000001)
-	{
-		a.w = 1;
-		a.x = a.y = a.z = 0;
-		return a;
-	}
-	return a * (1 / m);
-}
-
-Quaternion slerp(Quaternion a, const Quaternion &b, float interp)
-{
-	if (dot(a, b) < 0.0)
-	{
-		a.w = -a.w;
-		a.x = -a.x;
-		a.y = -a.y;
-		a.z = -a.z;
-	}
-	float d = dot(a, b);
-	if (d >= 1.0)
-	{
-		return a;
-	}
-	float theta = acosf(d);
-	if (theta == 0.0f)
-	{
-		return (a);
-	}
-	return a * (sinf(theta - interp * theta) / sinf(theta)) + b * (sinf(interp * theta) / sinf(theta));
-}
-
-Quaternion Interpolate(const Quaternion &q0, const Quaternion &q1, float alpha)
-{
-	return slerp(q0, q1, alpha);
-}
-
-Quaternion YawPitchRoll(float yaw, float pitch, float roll)
-{
-	roll *= DEG2RAD;
-	yaw *= DEG2RAD;
-	pitch *= DEG2RAD;
-	return Quaternion(float3(0.0f, 0.0f, 1.0f), yaw) * Quaternion(float3(1.0f, 0.0f, 0.0f), pitch) * Quaternion(float3(0.0f, 1.0f, 0.0f), roll);
-}
-
-float Yaw(const Quaternion &q)
-{
-	float3 v;
-	v = q.ydir();
-	return (v.y == 0.0 && v.x == 0.0) ? 0.0f : atan2f(-v.x, v.y) * RAD2DEG;
-}
-
-float Pitch(const Quaternion &q)
-{
-	float3 v;
-	v = q.ydir();
-	return atan2f(v.z, sqrtf(sqr(v.x) + sqr(v.y))) * RAD2DEG;
-}
-
-float Roll(Quaternion q)
-{
-	q = Quaternion(float3(0.0f, 0.0f, 1.0f), -Yaw(q) * DEG2RAD) * q;
-	q = Quaternion(float3(1.0f, 0.0f, 0.0f), -Pitch(q) * DEG2RAD) * q;
-	return atan2f(-q.xdir().z, q.xdir().x) * RAD2DEG;
-}
-
-float Yaw(const float3 &v)
-{
-	return (v.y == 0.0 && v.x == 0.0) ? 0.0f : atan2f(-v.x, v.y) * RAD2DEG;
-}
-
-float Pitch(const float3 &v)
-{
-	return atan2f(v.z, sqrtf(sqr(v.x) + sqr(v.y))) * RAD2DEG;
-}
-
-//------------- Plane --------------
-
-void Plane::Transform(const float3 &position, const Quaternion &orientation)
-{
-	//   Transforms the plane to the space defined by the
-	//   given position/orientation.
-	float3 newnormal;
-	float3 origin;
-
-	newnormal = Inverse(orientation) * normal;
-	origin = Inverse(orientation) * (-normal * dist - position);
-
-	normal = newnormal;
-	dist = -dot(newnormal, origin);
-}
-
-//--------- utility functions -------------
-
-//        RotationArc()
-// Given two vectors v0 and v1 this function
-// returns quaternion q where q*v0==v1.
-// Routine taken from game programming gems.
-Quaternion RotationArc(float3 v0, float3 v1)
-{
-	Quaternion q;
-	v0 = normalize(v0);  // Comment these two lines out if you know its not needed.
-	v1 = normalize(v1);  // If vector is already unit length then why do it again?
-	float3 c = cross(v0, v1);
-	float d = dot(v0, v1);
-	if (d <= -1.0f)
-	{
-		return Quaternion(1, 0, 0, 0);
-	}  // 180 about x axis
-	float s = sqrtf((1 + d) * 2);
-	q.x = c.x / s;
-	q.y = c.y / s;
-	q.z = c.z / s;
-	q.w = s / 2.0f;
-	return q;
-}
-
-float4x4 MatrixFromQuatVec(const Quaternion &q, const float3 &v)
-{
-	// builds a 4x4 transformation matrix based on orientation q and translation v
-	float qx2 = q.x * q.x;
-	float qy2 = q.y * q.y;
-	float qz2 = q.z * q.z;
-
-	float qxqy = q.x * q.y;
-	float qxqz = q.x * q.z;
-	float qxqw = q.x * q.w;
-	float qyqz = q.y * q.z;
-	float qyqw = q.y * q.w;
-	float qzqw = q.z * q.w;
-
-	return float4x4(
-		1 - 2 * (qy2 + qz2),
-		2 * (qxqy + qzqw),
-		2 * (qxqz - qyqw),
-		0,
-		2 * (qxqy - qzqw),
-		1 - 2 * (qx2 + qz2),
-		2 * (qyqz + qxqw),
-		0,
-		2 * (qxqz + qyqw),
-		2 * (qyqz - qxqw),
-		1 - 2 * (qx2 + qy2),
-		0,
-		v.x,
-		v.y,
-		v.z,
-		1.0f);
-}
-
-float3 PlaneLineIntersection(const Plane &plane, const float3 &p0, const float3 &p1)
-{
-	// returns the point where the line p0-p1 intersects the plane n&d
-	float3 dif;
-	dif = p1 - p0;
-	float dn = dot(plane.normal, dif);
-	float t = -(plane.dist + dot(plane.normal, p0)) / dn;
-	return p0 + (dif * t);
-}
-
-float3 PlaneProject(const Plane &plane, const float3 &point)
-{
-	return point - plane.normal * (dot(point, plane.normal) + plane.dist);
-}
-
-float3 LineProject(const float3 &p0, const float3 &p1, const float3 &a)
-{
-	float3 w;
-	w = p1 - p0;
-	float t = dot(w, (a - p0)) / (sqr(w.x) + sqr(w.y) + sqr(w.z));
-	return p0 + w * t;
-}
-
-float LineProjectTime(const float3 &p0, const float3 &p1, const float3 &a)
-{
-	float3 w;
-	w = p1 - p0;
-	float t = dot(w, (a - p0)) / (sqr(w.x) + sqr(w.y) + sqr(w.z));
-	return t;
-}
-
-float3 TriNormal(const float3 &v0, const float3 &v1, const float3 &v2)
-{
-	// return the normal of the triangle
-	// inscribed by v0, v1, and v2
-	float3 cp = cross(v1 - v0, v2 - v1);
-	float m = magnitude(cp);
-	if (m == 0) return float3(1, 0, 0);
-	return cp * (1.0f / m);
-}
-
-int BoxInside(const float3 &p, const float3 &bmin, const float3 &bmax)
-{
-	return (p.x >= bmin.x && p.x <= bmax.x &&
-			p.y >= bmin.y && p.y <= bmax.y &&
-			p.z >= bmin.z && p.z <= bmax.z);
-}
-
-int BoxIntersect(const float3 &v0, const float3 &v1, const float3 &bmin, const float3 &bmax, float3 *impact)
-{
-	if (BoxInside(v0, bmin, bmax))
-	{
-		*impact = v0;
-		return 1;
-	}
-	if (v0.x <= bmin.x && v1.x >= bmin.x)
-	{
-		float a = (bmin.x - v0.x) / (v1.x - v0.x);
-		//v.x = bmin.x;
-		float vy = (1 - a) * v0.y + a * v1.y;
-		float vz = (1 - a) * v0.z + a * v1.z;
-		if (vy >= bmin.y && vy <= bmax.y && vz >= bmin.z && vz <= bmax.z)
-		{
-			impact->x = bmin.x;
-			impact->y = vy;
-			impact->z = vz;
-			return 1;
-		}
-	}
-	else if (v0.x >= bmax.x && v1.x <= bmax.x)
-	{
-		float a = (bmax.x - v0.x) / (v1.x - v0.x);
-		//v.x = bmax.x;
-		float vy = (1 - a) * v0.y + a * v1.y;
-		float vz = (1 - a) * v0.z + a * v1.z;
-		if (vy >= bmin.y && vy <= bmax.y && vz >= bmin.z && vz <= bmax.z)
-		{
-			impact->x = bmax.x;
-			impact->y = vy;
-			impact->z = vz;
-			return 1;
-		}
-	}
-	if (v0.y <= bmin.y && v1.y >= bmin.y)
-	{
-		float a = (bmin.y - v0.y) / (v1.y - v0.y);
-		float vx = (1 - a) * v0.x + a * v1.x;
-		//v.y = bmin.y;
-		float vz = (1 - a) * v0.z + a * v1.z;
-		if (vx >= bmin.x && vx <= bmax.x && vz >= bmin.z && vz <= bmax.z)
-		{
-			impact->x = vx;
-			impact->y = bmin.y;
-			impact->z = vz;
-			return 1;
-		}
-	}
-	else if (v0.y >= bmax.y && v1.y <= bmax.y)
-	{
-		float a = (bmax.y - v0.y) / (v1.y - v0.y);
-		float vx = (1 - a) * v0.x + a * v1.x;
-		// vy = bmax.y;
-		float vz = (1 - a) * v0.z + a * v1.z;
-		if (vx >= bmin.x && vx <= bmax.x && vz >= bmin.z && vz <= bmax.z)
-		{
-			impact->x = vx;
-			impact->y = bmax.y;
-			impact->z = vz;
-			return 1;
-		}
-	}
-	if (v0.z <= bmin.z && v1.z >= bmin.z)
-	{
-		float a = (bmin.z - v0.z) / (v1.z - v0.z);
-		float vx = (1 - a) * v0.x + a * v1.x;
-		float vy = (1 - a) * v0.y + a * v1.y;
-		// v.z = bmin.z;
-		if (vy >= bmin.y && vy <= bmax.y && vx >= bmin.x && vx <= bmax.x)
-		{
-			impact->x = vx;
-			impact->y = vy;
-			impact->z = bmin.z;
-			return 1;
-		}
-	}
-	else if (v0.z >= bmax.z && v1.z <= bmax.z)
-	{
-		float a = (bmax.z - v0.z) / (v1.z - v0.z);
-		float vx = (1 - a) * v0.x + a * v1.x;
-		float vy = (1 - a) * v0.y + a * v1.y;
-		// v.z = bmax.z;
-		if (vy >= bmin.y && vy <= bmax.y && vx >= bmin.x && vx <= bmax.x)
-		{
-			impact->x = vx;
-			impact->y = vy;
-			impact->z = bmax.z;
-			return 1;
-		}
-	}
-	return 0;
-}
-
-float DistanceBetweenLines(const float3 &ustart, const float3 &udir, const float3 &vstart, const float3 &vdir, float3 *upoint, float3 *vpoint)
-{
-	float3 cp;
-	cp = normalize(cross(udir, vdir));
-
-	float distu = -dot(cp, ustart);
-	float distv = -dot(cp, vstart);
-	float dist = (float)fabs(distu - distv);
-	if (upoint)
-	{
-		Plane plane;
-		plane.normal = normalize(cross(vdir, cp));
-		plane.dist = -dot(plane.normal, vstart);
-		*upoint = PlaneLineIntersection(plane, ustart, ustart + udir);
-	}
-	if (vpoint)
-	{
-		Plane plane;
-		plane.normal = normalize(cross(udir, cp));
-		plane.dist = -dot(plane.normal, ustart);
-		*vpoint = PlaneLineIntersection(plane, vstart, vstart + vdir);
-	}
-	return dist;
-}
-
-Quaternion VirtualTrackBall(const float3 &cop, const float3 &cor, const float3 &dir1, const float3 &dir2)
-{
-	// routine taken from game programming gems.
-	// Implement track ball functionality to spin stuf on the screen
-	//  cop   center of projection
-	//  cor   center of rotation
-	//  dir1  old mouse direction
-	//  dir2  new mouse direction
-	// pretend there is a sphere around cor.  Then find the points
-	// where dir1 and dir2 intersect that sphere.  Find the
-	// rotation that takes the first point to the second.
-	float m;
-	// compute plane
-	float3 nrml = cor - cop;
-	float fudgefactor = 1.0f / (magnitude(nrml) * 0.25f);  // since trackball proportional to distance from cop
-	nrml = normalize(nrml);
-	float dist = -dot(nrml, cor);
-	float3 u = PlaneLineIntersection(Plane(nrml, dist), cop, cop + dir1);
-	u = u - cor;
-	u = u * fudgefactor;
-	m = magnitude(u);
-	if (m > 1)
-	{
-		u /= m;
-	}
-	else
-	{
-		u = u - (nrml * sqrtf(1 - m * m));
-	}
-	float3 v = PlaneLineIntersection(Plane(nrml, dist), cop, cop + dir2);
-	v = v - cor;
-	v = v * fudgefactor;
-	m = magnitude(v);
-	if (m > 1)
-	{
-		v /= m;
-	}
-	else
-	{
-		v = v - (nrml * sqrtf(1 - m * m));
-	}
-	return RotationArc(u, v);
-}
-
-int countpolyhit = 0;
-int PolyHit(const float3 *vert, const int n, const float3 &v0, const float3 &v1, float3 *impact, float3 *normal)
-{
-	countpolyhit++;
-	int i;
-	float3 nrml(0, 0, 0);
-	for (i = 0; i < n; i++)
-	{
-		int i1 = (i + 1) % n;
-		int i2 = (i + 2) % n;
-		nrml = nrml + cross(vert[i1] - vert[i], vert[i2] - vert[i1]);
-	}
-
-	float m = magnitude(nrml);
-	if (m == 0.0)
-	{
-		return 0;
-	}
-	nrml = nrml * (1.0f / m);
-	float dist = -dot(nrml, vert[0]);
-	float d0, d1;
-	if ((d0 = dot(v0, nrml) + dist) < 0 || (d1 = dot(v1, nrml) + dist) > 0)
-	{
-		return 0;
-	}
-
-	float3 the_point;
-	// By using the cached plane distances d0 and d1
-	// we can optimize the following:
-	//     the_point = planelineintersection(nrml,dist,v0,v1);
-	float a = d0 / (d0 - d1);
-	the_point = v0 * (1 - a) + v1 * a;
-
-	int inside = 1;
-	for (int j = 0; inside && j < n; j++)
-	{
-		// let inside = 0 if outside
-		float3 pp1, pp2, side;
-		pp1 = vert[j];
-		pp2 = vert[(j + 1) % n];
-		side = cross((pp2 - pp1), (the_point - pp1));
-		inside = (dot(nrml, side) >= 0.0);
-	}
-	if (inside)
-	{
-		if (normal)
-		{
-			*normal = nrml;
-		}
-		if (impact)
-		{
-			*impact = the_point;
-		}
-	}
-	return inside;
-}
-
-//**************************************************************************
-//**************************************************************************
-//*** Stan Melax's array template, needed to compile his hull generation code
-//**************************************************************************
-//**************************************************************************
-
-template <class Type>
-class ArrayRet;
-template <class Type>
-class Array
-{
-public:
-	Array(int s = 0);
-	Array(Array<Type> &array);
-	Array(ArrayRet<Type> &array);
-	~Array();
-	void allocate(int s);
-	void SetSize(int s);
-	void Pack();
-	Type &Add(Type);
-	void AddUnique(Type);
-	int Contains(Type);
-	void Insert(Type, int);
-	int IndexOf(Type);
-	void Remove(Type);
-	void DelIndex(int i);
-	Type *element;
-	int count;
-	int array_size;
-	const Type &operator[](int i) const
-	{
-		assert(i >= 0 && i < count);
-		return element[i];
-	}
-	Type &operator[](int i)
-	{
-		assert(i >= 0 && i < count);
-		return element[i];
-	}
-	Type &Pop()
-	{
-		assert(count);
-		count--;
-		return element[count];
-	}
-	Array<Type> &operator=(Array<Type> &array);
-	Array<Type> &operator=(ArrayRet<Type> &array);
-	// operator ArrayRet<Type> &() { return *(ArrayRet<Type> *)this;} // this worked but i suspect could be dangerous
-};
-
-template <class Type>
-class ArrayRet : public Array<Type>
-{
-};
-
-template <class Type>
-Array<Type>::Array(int s)
-{
-	count = 0;
-	array_size = 0;
-	element = NULL;
-	if (s)
-	{
-		allocate(s);
-	}
-}
-
-template <class Type>
-Array<Type>::Array(Array<Type> &array)
-{
-	count = 0;
-	array_size = 0;
-	element = NULL;
-	for (int i = 0; i < array.count; i++)
-	{
-		Add(array[i]);
-	}
-}
-
-template <class Type>
-Array<Type>::Array(ArrayRet<Type> &array)
-{
-	*this = array;
-}
-template <class Type>
-Array<Type> &Array<Type>::operator=(ArrayRet<Type> &array)
-{
-	count = array.count;
-	array_size = array.array_size;
-	element = array.element;
-	array.element = NULL;
-	array.count = 0;
-	array.array_size = 0;
-	return *this;
-}
-
-template <class Type>
-Array<Type> &Array<Type>::operator=(Array<Type> &array)
-{
-	count = 0;
-	for (int i = 0; i < array.count; i++)
-	{
-		Add(array[i]);
-	}
-	return *this;
-}
-
-template <class Type>
-Array<Type>::~Array()
-{
-	if (element != NULL)
-	{
-		free(element);
-	}
-	count = 0;
-	array_size = 0;
-	element = NULL;
-}
-
-template <class Type>
-void Array<Type>::allocate(int s)
-{
-	assert(s > 0);
-	assert(s >= count);
-	Type *old = element;
-	array_size = s;
-	element = (Type *)malloc(sizeof(Type) * array_size);
-	assert(element);
-	for (int i = 0; i < count; i++)
-	{
-		element[i] = old[i];
-	}
-	if (old)
-	{
-		free(old);
-	}
-}
-
-template <class Type>
-void Array<Type>::SetSize(int s)
-{
-	if (s == 0)
-	{
-		if (element)
-		{
-			free(element);
-			element = NULL;
-		}
-		array_size = s;
-	}
-	else
-	{
-		allocate(s);
-	}
-	count = s;
-}
-
-template <class Type>
-void Array<Type>::Pack()
-{
-	allocate(count);
-}
-
-template <class Type>
-Type &Array<Type>::Add(Type t)
-{
-	assert(count <= array_size);
-	if (count == array_size)
-	{
-		allocate((array_size) ? array_size * 2 : 16);
-	}
-	element[count++] = t;
-	return element[count - 1];
-}
-
-template <class Type>
-int Array<Type>::Contains(Type t)
-{
-	int i;
-	int found = 0;
-	for (i = 0; i < count; i++)
-	{
-		if (element[i] == t) found++;
-	}
-	return found;
-}
-
-template <class Type>
-void Array<Type>::AddUnique(Type t)
-{
-	if (!Contains(t)) Add(t);
-}
-
-template <class Type>
-void Array<Type>::DelIndex(int i)
-{
-	assert(i < count);
-	count--;
-	while (i < count)
-	{
-		element[i] = element[i + 1];
-		i++;
-	}
-}
-
-template <class Type>
-void Array<Type>::Remove(Type t)
-{
-	int i;
-	for (i = 0; i < count; i++)
-	{
-		if (element[i] == t)
-		{
-			break;
-		}
-	}
-	assert(i < count);  // assert object t is in the array.
-	DelIndex(i);
-	for (i = 0; i < count; i++)
-	{
-		assert(element[i] != t);
-	}
-}
-
-template <class Type>
-void Array<Type>::Insert(Type t, int k)
-{
-	int i = count;
-	Add(t);  // to allocate space
-	while (i > k)
-	{
-		element[i] = element[i - 1];
-		i--;
-	}
-	assert(i == k);
-	element[k] = t;
-}
-
-template <class Type>
-int Array<Type>::IndexOf(Type t)
-{
-	int i;
-	for (i = 0; i < count; i++)
-	{
-		if (element[i] == t)
-		{
-			return i;
-		}
-	}
-	assert(0);
-	return -1;
-}
-
-//*********************************************************************
-//*********************************************************************
-//********  Hull header
-//*********************************************************************
-//*********************************************************************
-
-class PHullResult
-{
-public:
-	PHullResult(void)
-	{
-		mVcount = 0;
-		mIndexCount = 0;
-		mFaceCount = 0;
-		mVertices = 0;
-		mIndices = 0;
-	}
-
-	unsigned int mVcount;
-	unsigned int mIndexCount;
-	unsigned int mFaceCount;
-	float *mVertices;
-	unsigned int *mIndices;
-};
-
-#define REAL3 float3
-#define REAL float
-
-#define COPLANAR (0)
-#define UNDER (1)
-#define OVER (2)
-#define SPLIT (OVER | UNDER)
-#define PAPERWIDTH (0.001f)
-
-float planetestepsilon = PAPERWIDTH;
-
-class ConvexH
-{
-public:
-	class HalfEdge
-	{
-	public:
-		short ea;         // the other half of the edge (index into edges list)
-		unsigned char v;  // the vertex at the start of this edge (index into vertices list)
-		unsigned char p;  // the facet on which this edge lies (index into facets list)
-		HalfEdge() {}
-		HalfEdge(short _ea, unsigned char _v, unsigned char _p) : ea(_ea), v(_v), p(_p) {}
-	};
-	Array<REAL3> vertices;
-	Array<HalfEdge> edges;
-	Array<Plane> facets;
-	ConvexH(int vertices_size, int edges_size, int facets_size);
-};
-
-typedef ConvexH::HalfEdge HalfEdge;
-
-ConvexH::ConvexH(int vertices_size, int edges_size, int facets_size)
-	: vertices(vertices_size), edges(edges_size), facets(facets_size)
-{
-	vertices.count = vertices_size;
-	edges.count = edges_size;
-	facets.count = facets_size;
-}
-
-ConvexH *ConvexHDup(ConvexH *src)
-{
-	ConvexH *dst = new ConvexH(src->vertices.count, src->edges.count, src->facets.count);
-	memcpy(dst->vertices.element, src->vertices.element, sizeof(float3) * src->vertices.count);
-	memcpy(dst->edges.element, src->edges.element, sizeof(HalfEdge) * src->edges.count);
-	memcpy(dst->facets.element, src->facets.element, sizeof(Plane) * src->facets.count);
-	return dst;
-}
-
-int PlaneTest(const Plane &p, const REAL3 &v)
-{
-	REAL a = dot(v, p.normal) + p.dist;
-	int flag = (a > planetestepsilon) ? OVER : ((a < -planetestepsilon) ? UNDER : COPLANAR);
-	return flag;
-}
-
-int SplitTest(ConvexH &convex, const Plane &plane)
-{
-	int flag = 0;
-	for (int i = 0; i < convex.vertices.count; i++)
-	{
-		flag |= PlaneTest(plane, convex.vertices[i]);
-	}
-	return flag;
-}
-
-class VertFlag
-{
-public:
-	unsigned char planetest;
-	unsigned char junk;
-	unsigned char undermap;
-	unsigned char overmap;
-};
-class EdgeFlag
-{
-public:
-	unsigned char planetest;
-	unsigned char fixes;
-	short undermap;
-	short overmap;
-};
-class PlaneFlag
-{
-public:
-	unsigned char undermap;
-	unsigned char overmap;
-};
-class Coplanar
-{
-public:
-	unsigned short ea;
-	unsigned char v0;
-	unsigned char v1;
-};
-
-int AssertIntact(ConvexH &convex)
-{
-	int i;
-	int estart = 0;
-	for (i = 0; i < convex.edges.count; i++)
-	{
-		if (convex.edges[estart].p != convex.edges[i].p)
-		{
-			estart = i;
-		}
-		int inext = i + 1;
-		if (inext >= convex.edges.count || convex.edges[inext].p != convex.edges[i].p)
-		{
-			inext = estart;
-		}
-		assert(convex.edges[inext].p == convex.edges[i].p);
-		int nb = convex.edges[i].ea;
-		assert(nb != 255);
-		if (nb == 255 || nb == -1) return 0;
-		assert(nb != -1);
-		assert(i == convex.edges[nb].ea);
-	}
-	for (i = 0; i < convex.edges.count; i++)
-	{
-		assert(COPLANAR == PlaneTest(convex.facets[convex.edges[i].p], convex.vertices[convex.edges[i].v]));
-		if (COPLANAR != PlaneTest(convex.facets[convex.edges[i].p], convex.vertices[convex.edges[i].v])) return 0;
-		if (convex.edges[estart].p != convex.edges[i].p)
-		{
-			estart = i;
-		}
-		int i1 = i + 1;
-		if (i1 >= convex.edges.count || convex.edges[i1].p != convex.edges[i].p)
-		{
-			i1 = estart;
-		}
-		int i2 = i1 + 1;
-		if (i2 >= convex.edges.count || convex.edges[i2].p != convex.edges[i].p)
-		{
-			i2 = estart;
-		}
-		if (i == i2) continue;  // i sliced tangent to an edge and created 2 meaningless edges
-		REAL3 localnormal = TriNormal(convex.vertices[convex.edges[i].v],
-									  convex.vertices[convex.edges[i1].v],
-									  convex.vertices[convex.edges[i2].v]);
-		assert(dot(localnormal, convex.facets[convex.edges[i].p].normal) > 0);
-		if (dot(localnormal, convex.facets[convex.edges[i].p].normal) <= 0) return 0;
-	}
-	return 1;
-}
-
-// back to back quads
-ConvexH *test_btbq()
-{
-	ConvexH *convex = new ConvexH(4, 8, 2);
-	convex->vertices[0] = REAL3(0, 0, 0);
-	convex->vertices[1] = REAL3(1, 0, 0);
-	convex->vertices[2] = REAL3(1, 1, 0);
-	convex->vertices[3] = REAL3(0, 1, 0);
-	convex->facets[0] = Plane(REAL3(0, 0, 1), 0);
-	convex->facets[1] = Plane(REAL3(0, 0, -1), 0);
-	convex->edges[0] = HalfEdge(7, 0, 0);
-	convex->edges[1] = HalfEdge(6, 1, 0);
-	convex->edges[2] = HalfEdge(5, 2, 0);
-	convex->edges[3] = HalfEdge(4, 3, 0);
-
-	convex->edges[4] = HalfEdge(3, 0, 1);
-	convex->edges[5] = HalfEdge(2, 3, 1);
-	convex->edges[6] = HalfEdge(1, 2, 1);
-	convex->edges[7] = HalfEdge(0, 1, 1);
-	AssertIntact(*convex);
-	return convex;
-}
-ConvexH *test_cube()
-{
-	ConvexH *convex = new ConvexH(8, 24, 6);
-	convex->vertices[0] = REAL3(0, 0, 0);
-	convex->vertices[1] = REAL3(0, 0, 1);
-	convex->vertices[2] = REAL3(0, 1, 0);
-	convex->vertices[3] = REAL3(0, 1, 1);
-	convex->vertices[4] = REAL3(1, 0, 0);
-	convex->vertices[5] = REAL3(1, 0, 1);
-	convex->vertices[6] = REAL3(1, 1, 0);
-	convex->vertices[7] = REAL3(1, 1, 1);
-
-	convex->facets[0] = Plane(REAL3(-1, 0, 0), 0);
-	convex->facets[1] = Plane(REAL3(1, 0, 0), -1);
-	convex->facets[2] = Plane(REAL3(0, -1, 0), 0);
-	convex->facets[3] = Plane(REAL3(0, 1, 0), -1);
-	convex->facets[4] = Plane(REAL3(0, 0, -1), 0);
-	convex->facets[5] = Plane(REAL3(0, 0, 1), -1);
-
-	convex->edges[0] = HalfEdge(11, 0, 0);
-	convex->edges[1] = HalfEdge(23, 1, 0);
-	convex->edges[2] = HalfEdge(15, 3, 0);
-	convex->edges[3] = HalfEdge(16, 2, 0);
-
-	convex->edges[4] = HalfEdge(13, 6, 1);
-	convex->edges[5] = HalfEdge(21, 7, 1);
-	convex->edges[6] = HalfEdge(9, 5, 1);
-	convex->edges[7] = HalfEdge(18, 4, 1);
-
-	convex->edges[8] = HalfEdge(19, 0, 2);
-	convex->edges[9] = HalfEdge(6, 4, 2);
-	convex->edges[10] = HalfEdge(20, 5, 2);
-	convex->edges[11] = HalfEdge(0, 1, 2);
-
-	convex->edges[12] = HalfEdge(22, 3, 3);
-	convex->edges[13] = HalfEdge(4, 7, 3);
-	convex->edges[14] = HalfEdge(17, 6, 3);
-	convex->edges[15] = HalfEdge(2, 2, 3);
-
-	convex->edges[16] = HalfEdge(3, 0, 4);
-	convex->edges[17] = HalfEdge(14, 2, 4);
-	convex->edges[18] = HalfEdge(7, 6, 4);
-	convex->edges[19] = HalfEdge(8, 4, 4);
-
-	convex->edges[20] = HalfEdge(10, 1, 5);
-	convex->edges[21] = HalfEdge(5, 5, 5);
-	convex->edges[22] = HalfEdge(12, 7, 5);
-	convex->edges[23] = HalfEdge(1, 3, 5);
-
-	return convex;
-}
-ConvexH *ConvexHMakeCube(const REAL3 &bmin, const REAL3 &bmax)
-{
-	ConvexH *convex = test_cube();
-	convex->vertices[0] = REAL3(bmin.x, bmin.y, bmin.z);
-	convex->vertices[1] = REAL3(bmin.x, bmin.y, bmax.z);
-	convex->vertices[2] = REAL3(bmin.x, bmax.y, bmin.z);
-	convex->vertices[3] = REAL3(bmin.x, bmax.y, bmax.z);
-	convex->vertices[4] = REAL3(bmax.x, bmin.y, bmin.z);
-	convex->vertices[5] = REAL3(bmax.x, bmin.y, bmax.z);
-	convex->vertices[6] = REAL3(bmax.x, bmax.y, bmin.z);
-	convex->vertices[7] = REAL3(bmax.x, bmax.y, bmax.z);
-
-	convex->facets[0] = Plane(REAL3(-1, 0, 0), bmin.x);
-	convex->facets[1] = Plane(REAL3(1, 0, 0), -bmax.x);
-	convex->facets[2] = Plane(REAL3(0, -1, 0), bmin.y);
-	convex->facets[3] = Plane(REAL3(0, 1, 0), -bmax.y);
-	convex->facets[4] = Plane(REAL3(0, 0, -1), bmin.z);
-	convex->facets[5] = Plane(REAL3(0, 0, 1), -bmax.z);
-	return convex;
-}
-ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice)
-{
-	int i;
-	int vertcountunder = 0;
-	int vertcountover = 0;
-	Array<int> vertscoplanar;  // existing vertex members of convex that are coplanar
-	vertscoplanar.count = 0;
-	Array<int> edgesplit;  // existing edges that members of convex that cross the splitplane
-	edgesplit.count = 0;
-
-	assert(convex.edges.count < 480);
-
-	EdgeFlag edgeflag[512];
-	VertFlag vertflag[256];
-	PlaneFlag planeflag[128];
-	HalfEdge tmpunderedges[512];
-	Plane tmpunderplanes[128];
-	Coplanar coplanaredges[512];
-	int coplanaredges_num = 0;
-
-	Array<REAL3> createdverts;
-	// do the side-of-plane tests
-	for (i = 0; i < convex.vertices.count; i++)
-	{
-		vertflag[i].planetest = PlaneTest(slice, convex.vertices[i]);
-		if (vertflag[i].planetest == COPLANAR)
-		{
-			// ? vertscoplanar.Add(i);
-			vertflag[i].undermap = vertcountunder++;
-			vertflag[i].overmap = vertcountover++;
-		}
-		else if (vertflag[i].planetest == UNDER)
-		{
-			vertflag[i].undermap = vertcountunder++;
-		}
-		else
-		{
-			assert(vertflag[i].planetest == OVER);
-			vertflag[i].overmap = vertcountover++;
-			vertflag[i].undermap = 255;  // for debugging purposes
-		}
-	}
-	int vertcountunderold = vertcountunder;  // for debugging only
-
-	int under_edge_count = 0;
-	int underplanescount = 0;
-	int e0 = 0;
-
-	for (int currentplane = 0; currentplane < convex.facets.count; currentplane++)
-	{
-		int estart = e0;
-		int enextface = 0;
-		int planeside = 0;
-		int e1 = e0 + 1;
-		int vout = -1;
-		int vin = -1;
-		int coplanaredge = -1;
-		do
-		{
-			if (e1 >= convex.edges.count || convex.edges[e1].p != currentplane)
-			{
-				enextface = e1;
-				e1 = estart;
-			}
-			HalfEdge &edge0 = convex.edges[e0];
-			HalfEdge &edge1 = convex.edges[e1];
-			HalfEdge &edgea = convex.edges[edge0.ea];
-
-			planeside |= vertflag[edge0.v].planetest;
-			//if((vertflag[edge0.v].planetest & vertflag[edge1.v].planetest)  == COPLANAR) {
-			//	assert(ecop==-1);
-			//	ecop=e;
-			//}
-
-			if (vertflag[edge0.v].planetest == OVER && vertflag[edge1.v].planetest == OVER)
-			{
-				// both endpoints over plane
-				edgeflag[e0].undermap = -1;
-			}
-			else if ((vertflag[edge0.v].planetest | vertflag[edge1.v].planetest) == UNDER)
-			{
-				// at least one endpoint under, the other coplanar or under
-
-				edgeflag[e0].undermap = under_edge_count;
-				tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap;
-				tmpunderedges[under_edge_count].p = underplanescount;
-				if (edge0.ea < e0)
-				{
-					// connect the neighbors
-					assert(edgeflag[edge0.ea].undermap != -1);
-					tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap;
-					tmpunderedges[edgeflag[edge0.ea].undermap].ea = under_edge_count;
-				}
-				under_edge_count++;
-			}
-			else if ((vertflag[edge0.v].planetest | vertflag[edge1.v].planetest) == COPLANAR)
-			{
-				// both endpoints coplanar
-				// must check a 3rd point to see if UNDER
-				int e2 = e1 + 1;
-				if (e2 >= convex.edges.count || convex.edges[e2].p != currentplane)
-				{
-					e2 = estart;
-				}
-				assert(convex.edges[e2].p == currentplane);
-				HalfEdge &edge2 = convex.edges[e2];
-				if (vertflag[edge2.v].planetest == UNDER)
-				{
-					edgeflag[e0].undermap = under_edge_count;
-					tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap;
-					tmpunderedges[under_edge_count].p = underplanescount;
-					tmpunderedges[under_edge_count].ea = -1;
-					// make sure this edge is added to the "coplanar" list
-					coplanaredge = under_edge_count;
-					vout = vertflag[edge0.v].undermap;
-					vin = vertflag[edge1.v].undermap;
-					under_edge_count++;
-				}
-				else
-				{
-					edgeflag[e0].undermap = -1;
-				}
-			}
-			else if (vertflag[edge0.v].planetest == UNDER && vertflag[edge1.v].planetest == OVER)
-			{
-				// first is under 2nd is over
-
-				edgeflag[e0].undermap = under_edge_count;
-				tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap;
-				tmpunderedges[under_edge_count].p = underplanescount;
-				if (edge0.ea < e0)
-				{
-					assert(edgeflag[edge0.ea].undermap != -1);
-					// connect the neighbors
-					tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap;
-					tmpunderedges[edgeflag[edge0.ea].undermap].ea = under_edge_count;
-					vout = tmpunderedges[edgeflag[edge0.ea].undermap].v;
-				}
-				else
-				{
-					Plane &p0 = convex.facets[edge0.p];
-					Plane &pa = convex.facets[edgea.p];
-					createdverts.Add(ThreePlaneIntersection(p0, pa, slice));
-					//createdverts.Add(PlaneProject(slice,PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v])));
-					//createdverts.Add(PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v]));
-					vout = vertcountunder++;
-				}
-				under_edge_count++;
-				/// hmmm something to think about: i might be able to output this edge regarless of
-				// wheter or not we know v-in yet.  ok i;ll try this now:
-				tmpunderedges[under_edge_count].v = vout;
-				tmpunderedges[under_edge_count].p = underplanescount;
-				tmpunderedges[under_edge_count].ea = -1;
-				coplanaredge = under_edge_count;
-				under_edge_count++;
-
-				if (vin != -1)
-				{
-					// we previously processed an edge  where we came under
-					// now we know about vout as well
-
-					// ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!!
-				}
-			}
-			else if (vertflag[edge0.v].planetest == COPLANAR && vertflag[edge1.v].planetest == OVER)
-			{
-				// first is coplanar 2nd is over
-
-				edgeflag[e0].undermap = -1;
-				vout = vertflag[edge0.v].undermap;
-				// I hate this but i have to make sure part of this face is UNDER before ouputting this vert
-				int k = estart;
-				assert(edge0.p == currentplane);
-				while (!(planeside & UNDER) && k < convex.edges.count && convex.edges[k].p == edge0.p)
-				{
-					planeside |= vertflag[convex.edges[k].v].planetest;
-					k++;
-				}
-				if (planeside & UNDER)
-				{
-					tmpunderedges[under_edge_count].v = vout;
-					tmpunderedges[under_edge_count].p = underplanescount;
-					tmpunderedges[under_edge_count].ea = -1;
-					coplanaredge = under_edge_count;  // hmmm should make a note of the edge # for later on
-					under_edge_count++;
-				}
-			}
-			else if (vertflag[edge0.v].planetest == OVER && vertflag[edge1.v].planetest == UNDER)
-			{
-				// first is over next is under
-				// new vertex!!!
-				assert(vin == -1);
-				if (e0 < edge0.ea)
-				{
-					Plane &p0 = convex.facets[edge0.p];
-					Plane &pa = convex.facets[edgea.p];
-					createdverts.Add(ThreePlaneIntersection(p0, pa, slice));
-					//createdverts.Add(PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v]));
-					//createdverts.Add(PlaneProject(slice,PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v])));
-					vin = vertcountunder++;
-				}
-				else
-				{
-					// find the new vertex that was created by edge[edge0.ea]
-					int nea = edgeflag[edge0.ea].undermap;
-					assert(tmpunderedges[nea].p == tmpunderedges[nea + 1].p);
-					vin = tmpunderedges[nea + 1].v;
-					assert(vin < vertcountunder);
-					assert(vin >= vertcountunderold);  // for debugging only
-				}
-				if (vout != -1)
-				{
-					// we previously processed an edge  where we went over
-					// now we know vin too
-					// ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!!
-				}
-				// output edge
-				tmpunderedges[under_edge_count].v = vin;
-				tmpunderedges[under_edge_count].p = underplanescount;
-				edgeflag[e0].undermap = under_edge_count;
-				if (e0 > edge0.ea)
-				{
-					assert(edgeflag[edge0.ea].undermap != -1);
-					// connect the neighbors
-					tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap;
-					tmpunderedges[edgeflag[edge0.ea].undermap].ea = under_edge_count;
-				}
-				assert(edgeflag[e0].undermap == under_edge_count);
-				under_edge_count++;
-			}
-			else if (vertflag[edge0.v].planetest == OVER && vertflag[edge1.v].planetest == COPLANAR)
-			{
-				// first is over next is coplanar
-
-				edgeflag[e0].undermap = -1;
-				vin = vertflag[edge1.v].undermap;
-				assert(vin != -1);
-				if (vout != -1)
-				{
-					// we previously processed an edge  where we came under
-					// now we know both endpoints
-					// ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!!
-				}
-			}
-			else
-			{
-				assert(0);
-			}
-
-			e0 = e1;
-			e1++;  // do the modulo at the beginning of the loop
-
-		} while (e0 != estart);
-		e0 = enextface;
-		if (planeside & UNDER)
-		{
-			planeflag[currentplane].undermap = underplanescount;
-			tmpunderplanes[underplanescount] = convex.facets[currentplane];
-			underplanescount++;
-		}
-		else
-		{
-			planeflag[currentplane].undermap = 0;
-		}
-		if (vout >= 0 && (planeside & UNDER))
-		{
-			assert(vin >= 0);
-			assert(coplanaredge >= 0);
-			assert(coplanaredge != 511);
-			coplanaredges[coplanaredges_num].ea = coplanaredge;
-			coplanaredges[coplanaredges_num].v0 = vin;
-			coplanaredges[coplanaredges_num].v1 = vout;
-			coplanaredges_num++;
-		}
-	}
-
-	// add the new plane to the mix:
-	if (coplanaredges_num > 0)
-	{
-		tmpunderplanes[underplanescount++] = slice;
-	}
-	for (i = 0; i < coplanaredges_num - 1; i++)
-	{
-		if (coplanaredges[i].v1 != coplanaredges[i + 1].v0)
-		{
-			int j = 0;
-			for (j = i + 2; j < coplanaredges_num; j++)
-			{
-				if (coplanaredges[i].v1 == coplanaredges[j].v0)
-				{
-					Coplanar tmp = coplanaredges[i + 1];
-					coplanaredges[i + 1] = coplanaredges[j];
-					coplanaredges[j] = tmp;
-					break;
-				}
-			}
-			if (j >= coplanaredges_num)
-			{
-				assert(j < coplanaredges_num);
-				return NULL;
-			}
-		}
-	}
-	ConvexH *punder = new ConvexH(vertcountunder, under_edge_count + coplanaredges_num, underplanescount);
-	ConvexH &under = *punder;
-	int k = 0;
-	for (i = 0; i < convex.vertices.count; i++)
-	{
-		if (vertflag[i].planetest != OVER)
-		{
-			under.vertices[k++] = convex.vertices[i];
-		}
-	}
-	i = 0;
-	while (k < vertcountunder)
-	{
-		under.vertices[k++] = createdverts[i++];
-	}
-	assert(i == createdverts.count);
-
-	for (i = 0; i < coplanaredges_num; i++)
-	{
-		under.edges[under_edge_count + i].p = underplanescount - 1;
-		under.edges[under_edge_count + i].ea = coplanaredges[i].ea;
-		tmpunderedges[coplanaredges[i].ea].ea = under_edge_count + i;
-		under.edges[under_edge_count + i].v = coplanaredges[i].v0;
-	}
-
-	memcpy(under.edges.element, tmpunderedges, sizeof(HalfEdge) * under_edge_count);
-	memcpy(under.facets.element, tmpunderplanes, sizeof(Plane) * underplanescount);
-	return punder;
-}
-
-static int candidateplane(Plane *planes, int planes_count, ConvexH *convex, float epsilon)
-{
-	int p = 0;
-	REAL md = 0;
-	int i;
-	for (i = 0; i < planes_count; i++)
-	{
-		REAL d = 0;
-		for (int j = 0; j < convex->vertices.count; j++)
-		{
-			d = Max(d, dot(convex->vertices[j], planes[i].normal) + planes[i].dist);
-		}
-		if (i == 0 || d > md)
-		{
-			p = i;
-			md = d;
-		}
-	}
-	return (md > epsilon) ? p : -1;
-}
-
-template <class T>
-inline int maxdir(const T *p, int count, const T &dir)
-{
-	assert(count);
-	int m = 0;
-	float currDotm = dot(p[0], dir);
-	for (int i = 1; i < count; i++)
-	{
-		const float currDoti = dot(p[i], dir);
-		if (currDoti > currDotm)
-		{
-			currDotm = currDoti;
-			m = i;
-		}
-	}
-	return m;
-}
-
-template <class T>
-int maxdirfiltered(const T *p, int count, const T &dir, Array<int> &allow)
-{
-	assert(count);
-	int m = -1;
-	float currDotm = dot(p[0], dir);
-	for (int i = 0; i < count; i++)
-	{
-		if (allow[i])
-		{
-			if (m == -1)
-			{
-				currDotm = dot(p[i], dir);
-				m = i;
-			}
-			else
-			{
-				const float currDoti = dot(p[i], dir);
-				if (currDoti > currDotm)
-				{
-					currDotm = currDoti;
-					m = i;
-				}
-			}
-		}
-	}
-	assert(m != -1);
-	return m;
-}
-
-float3 orth(const float3 &v)
-{
-	float3 a = cross(v, float3(0, 0, 1));
-	float3 b = cross(v, float3(0, 1, 0));
-	return normalize((magnitude(a) > magnitude(b)) ? a : b);
-}
-
-template <class T>
-int maxdirsterid(const T *p, int count, const T &dir, Array<int> &allow)
-{
-	int m = -1;
-	while (m == -1)
-	{
-		m = maxdirfiltered(p, count, dir, allow);
-		if (allow[m] == 3) return m;
-		T u = orth(dir);
-		T v = cross(u, dir);
-		int ma = -1;
-		for (float x = 0.0f; x <= 360.0f; x += 45.0f)
-		{
-			float s = sinf(DEG2RAD * (x));
-			float c = cosf(DEG2RAD * (x));
-			int mb = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow);
-			if (ma == m && mb == m)
-			{
-				allow[m] = 3;
-				return m;
-			}
-			if (ma != -1 && ma != mb)  // Yuck - this is really ugly
-			{
-				int mc = ma;
-				for (float xx = x - 40.0f; xx <= x; xx += 5.0f)
-				{
-					float s = sinf(DEG2RAD * (xx));
-					float c = cosf(DEG2RAD * (xx));
-					int md = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow);
-					if (mc == m && md == m)
-					{
-						allow[m] = 3;
-						return m;
-					}
-					mc = md;
-				}
-			}
-			ma = mb;
-		}
-		allow[m] = 0;
-		m = -1;
-	}
-	assert(0);
-	return m;
-}
-
-int operator==(const int3 &a, const int3 &b)
-{
-	for (int i = 0; i < 3; i++)
-	{
-		if (a[i] != b[i]) return 0;
-	}
-	return 1;
-}
-
-int3 roll3(int3 a)
-{
-	int tmp = a[0];
-	a[0] = a[1];
-	a[1] = a[2];
-	a[2] = tmp;
-	return a;
-}
-int isa(const int3 &a, const int3 &b)
-{
-	return (a == b || roll3(a) == b || a == roll3(b));
-}
-int b2b(const int3 &a, const int3 &b)
-{
-	return isa(a, int3(b[2], b[1], b[0]));
-}
-int above(float3 *vertices, const int3 &t, const float3 &p, float epsilon)
-{
-	float3 n = TriNormal(vertices[t[0]], vertices[t[1]], vertices[t[2]]);
-	return (dot(n, p - vertices[t[0]]) > epsilon);  // EPSILON???
-}
-int hasedge(const int3 &t, int a, int b)
-{
-	for (int i = 0; i < 3; i++)
-	{
-		int i1 = (i + 1) % 3;
-		if (t[i] == a && t[i1] == b) return 1;
-	}
-	return 0;
-}
-int hasvert(const int3 &t, int v)
-{
-	return (t[0] == v || t[1] == v || t[2] == v);
-}
-int shareedge(const int3 &a, const int3 &b)
-{
-	int i;
-	for (i = 0; i < 3; i++)
-	{
-		int i1 = (i + 1) % 3;
-		if (hasedge(a, b[i1], b[i])) return 1;
-	}
-	return 0;
-}
-
-class btHullTriangle;
-
-//Array<btHullTriangle*> tris;
-
-class btHullTriangle : public int3
-{
-public:
-	int3 n;
-	int id;
-	int vmax;
-	float rise;
-	Array<btHullTriangle *> *tris;
-	btHullTriangle(int a, int b, int c, Array<btHullTriangle *> *pTris) : int3(a, b, c), n(-1, -1, -1)
-	{
-		tris = pTris;
-		id = tris->count;
-		tris->Add(this);
-		vmax = -1;
-		rise = 0.0f;
-	}
-	~btHullTriangle()
-	{
-		assert((*tris)[id] == this);
-		(*tris)[id] = NULL;
-	}
-	int &neib(int a, int b);
-};
-
-int &btHullTriangle::neib(int a, int b)
-{
-	static int er = -1;
-	int i;
-	for (i = 0; i < 3; i++)
-	{
-		int i1 = (i + 1) % 3;
-		int i2 = (i + 2) % 3;
-		if ((*this)[i] == a && (*this)[i1] == b) return n[i2];
-		if ((*this)[i] == b && (*this)[i1] == a) return n[i2];
-	}
-	assert(0);
-	return er;
-}
-void b2bfix(btHullTriangle *s, btHullTriangle *t, Array<btHullTriangle *> &tris)
-{
-	int i;
-	for (i = 0; i < 3; i++)
-	{
-		int i1 = (i + 1) % 3;
-		int i2 = (i + 2) % 3;
-		int a = (*s)[i1];
-		int b = (*s)[i2];
-		assert(tris[s->neib(a, b)]->neib(b, a) == s->id);
-		assert(tris[t->neib(a, b)]->neib(b, a) == t->id);
-		tris[s->neib(a, b)]->neib(b, a) = t->neib(b, a);
-		tris[t->neib(b, a)]->neib(a, b) = s->neib(a, b);
-	}
-}
-
-void removeb2b(btHullTriangle *s, btHullTriangle *t, Array<btHullTriangle *> &tris)
-{
-	b2bfix(s, t, tris);
-	delete s;
-	delete t;
-}
-
-void checkit(btHullTriangle *t, Array<btHullTriangle *> &tris)
-{
-	int i;
-	assert(tris[t->id] == t);
-	for (i = 0; i < 3; i++)
-	{
-		int i1 = (i + 1) % 3;
-		int i2 = (i + 2) % 3;
-		int a = (*t)[i1];
-		int b = (*t)[i2];
-		assert(a != b);
-		assert(tris[t->n[i]]->neib(b, a) == t->id);
-	}
-}
-void extrude(btHullTriangle *t0, int v, Array<btHullTriangle *> &tris)
-{
-	int3 t = *t0;
-	int n = tris.count;
-	btHullTriangle *ta = new btHullTriangle(v, t[1], t[2], &tris);
-	ta->n = int3(t0->n[0], n + 1, n + 2);
-	tris[t0->n[0]]->neib(t[1], t[2]) = n + 0;
-	btHullTriangle *tb = new btHullTriangle(v, t[2], t[0], &tris);
-	tb->n = int3(t0->n[1], n + 2, n + 0);
-	tris[t0->n[1]]->neib(t[2], t[0]) = n + 1;
-	btHullTriangle *tc = new btHullTriangle(v, t[0], t[1], &tris);
-	tc->n = int3(t0->n[2], n + 0, n + 1);
-	tris[t0->n[2]]->neib(t[0], t[1]) = n + 2;
-	checkit(ta, tris);
-	checkit(tb, tris);
-	checkit(tc, tris);
-	if (hasvert(*tris[ta->n[0]], v)) removeb2b(ta, tris[ta->n[0]], tris);
-	if (hasvert(*tris[tb->n[0]], v)) removeb2b(tb, tris[tb->n[0]], tris);
-	if (hasvert(*tris[tc->n[0]], v)) removeb2b(tc, tris[tc->n[0]], tris);
-	delete t0;
-}
-
-btHullTriangle *extrudable(float epsilon, Array<btHullTriangle *> &tris)
-{
-	int i;
-	btHullTriangle *t = NULL;
-	for (i = 0; i < tris.count; i++)
-	{
-		if (!t || (tris[i] && t->rise < tris[i]->rise))
-		{
-			t = tris[i];
-		}
-	}
-	return (t->rise > epsilon) ? t : NULL;
-}
-
-class int4
-{
-public:
-	int x, y, z, w;
-	int4(){};
-	int4(int _x, int _y, int _z, int _w)
-	{
-		x = _x;
-		y = _y;
-		z = _z;
-		w = _w;
-	}
-	const int &operator[](int i) const { return (&x)[i]; }
-	int &operator[](int i) { return (&x)[i]; }
-};
-
-int4 FindSimplex(float3 *verts, int verts_count, Array<int> &allow)
-{
-	float3 basis[3];
-	basis[0] = float3(0.01f, 0.02f, 1.0f);
-	int p0 = maxdirsterid(verts, verts_count, basis[0], allow);
-	int p1 = maxdirsterid(verts, verts_count, -basis[0], allow);
-	basis[0] = verts[p0] - verts[p1];
-	if (p0 == p1 || basis[0] == float3(0, 0, 0))
-		return int4(-1, -1, -1, -1);
-	basis[1] = cross(float3(1, 0.02f, 0), basis[0]);
-	basis[2] = cross(float3(-0.02f, 1, 0), basis[0]);
-	basis[1] = normalize((magnitude(basis[1]) > magnitude(basis[2])) ? basis[1] : basis[2]);
-	int p2 = maxdirsterid(verts, verts_count, basis[1], allow);
-	if (p2 == p0 || p2 == p1)
-	{
-		p2 = maxdirsterid(verts, verts_count, -basis[1], allow);
-	}
-	if (p2 == p0 || p2 == p1)
-		return int4(-1, -1, -1, -1);
-	basis[1] = verts[p2] - verts[p0];
-	basis[2] = normalize(cross(basis[1], basis[0]));
-	int p3 = maxdirsterid(verts, verts_count, basis[2], allow);
-	if (p3 == p0 || p3 == p1 || p3 == p2) p3 = maxdirsterid(verts, verts_count, -basis[2], allow);
-	if (p3 == p0 || p3 == p1 || p3 == p2)
-		return int4(-1, -1, -1, -1);
-	assert(!(p0 == p1 || p0 == p2 || p0 == p3 || p1 == p2 || p1 == p3 || p2 == p3));
-	if (dot(verts[p3] - verts[p0], cross(verts[p1] - verts[p0], verts[p2] - verts[p0])) < 0)
-	{
-		Swap(p2, p3);
-	}
-	return int4(p0, p1, p2, p3);
-}
-
-int calchullgen(float3 *verts, int verts_count, int vlimit, Array<btHullTriangle *> &tris)
-{
-	if (verts_count < 4) return 0;
-	if (vlimit == 0) vlimit = 1000000000;
-	int j;
-	float3 bmin(*verts), bmax(*verts);
-	Array<int> isextreme(verts_count);
-	Array<int> allow(verts_count);
-	for (j = 0; j < verts_count; j++)
-	{
-		allow.Add(1);
-		isextreme.Add(0);
-		bmin = VectorMin(bmin, verts[j]);
-		bmax = VectorMax(bmax, verts[j]);
-	}
-	float epsilon = magnitude(bmax - bmin) * 0.001f;
-
-	int4 p = FindSimplex(verts, verts_count, allow);
-	if (p.x == -1) return 0;  // simplex failed
-
-	float3 center = (verts[p[0]] + verts[p[1]] + verts[p[2]] + verts[p[3]]) / 4.0f;  // a valid interior point
-	btHullTriangle *t0 = new btHullTriangle(p[2], p[3], p[1], &tris);
-	t0->n = int3(2, 3, 1);
-	btHullTriangle *t1 = new btHullTriangle(p[3], p[2], p[0], &tris);
-	t1->n = int3(3, 2, 0);
-	btHullTriangle *t2 = new btHullTriangle(p[0], p[1], p[3], &tris);
-	t2->n = int3(0, 1, 3);
-	btHullTriangle *t3 = new btHullTriangle(p[1], p[0], p[2], &tris);
-	t3->n = int3(1, 0, 2);
-	isextreme[p[0]] = isextreme[p[1]] = isextreme[p[2]] = isextreme[p[3]] = 1;
-	checkit(t0, tris);
-	checkit(t1, tris);
-	checkit(t2, tris);
-	checkit(t3, tris);
-
-	for (j = 0; j < tris.count; j++)
-	{
-		btHullTriangle *t = tris[j];
-		assert(t);
-		assert(t->vmax < 0);
-		float3 n = TriNormal(verts[(*t)[0]], verts[(*t)[1]], verts[(*t)[2]]);
-		t->vmax = maxdirsterid(verts, verts_count, n, allow);
-		t->rise = dot(n, verts[t->vmax] - verts[(*t)[0]]);
-	}
-	btHullTriangle *te;
-	vlimit -= 4;
-	while (vlimit > 0 && (te = extrudable(epsilon, tris)))
-	{
-		//	int3 ti=*te;
-		int v = te->vmax;
-		assert(!isextreme[v]);  // wtf we've already done this vertex
-		isextreme[v] = 1;
-		//if(v==p0 || v==p1 || v==p2 || v==p3) continue; // done these already
-		j = tris.count;
-		while (j--)
-		{
-			if (!tris[j]) continue;
-			int3 t = *tris[j];
-			if (above(verts, t, verts[v], 0.01f * epsilon))
-			{
-				extrude(tris[j], v, tris);
-			}
-		}
-		// now check for those degenerate cases where we have a flipped triangle or a really skinny triangle
-		j = tris.count;
-		while (j--)
-		{
-			if (!tris[j]) continue;
-			if (!hasvert(*tris[j], v)) break;
-			int3 nt = *tris[j];
-			if (above(verts, nt, center, 0.01f * epsilon) || magnitude(cross(verts[nt[1]] - verts[nt[0]], verts[nt[2]] - verts[nt[1]])) < epsilon * epsilon * 0.1f)
-			{
-				btHullTriangle *nb = tris[tris[j]->n[0]];
-				assert(nb);
-				assert(!hasvert(*nb, v));
-				assert(nb->id < j);
-				extrude(nb, v, tris);
-				j = tris.count;
-			}
-		}
-		j = tris.count;
-		while (j--)
-		{
-			btHullTriangle *t = tris[j];
-			if (!t) continue;
-			if (t->vmax >= 0) break;
-			float3 n = TriNormal(verts[(*t)[0]], verts[(*t)[1]], verts[(*t)[2]]);
-			t->vmax = maxdirsterid(verts, verts_count, n, allow);
-			if (isextreme[t->vmax])
-			{
-				t->vmax = -1;  // already done that vertex - algorithm needs to be able to terminate.
-			}
-			else
-			{
-				t->rise = dot(n, verts[t->vmax] - verts[(*t)[0]]);
-			}
-		}
-		vlimit--;
-	}
-	return 1;
-}
-
-int calchull(float3 *verts, int verts_count, int *&tris_out, int &tris_count, int vlimit, Array<btHullTriangle *> &tris)
-{
-	int rc = calchullgen(verts, verts_count, vlimit, tris);
-	if (!rc) return 0;
-	Array<int> ts;
-	for (int i = 0; i < tris.count; i++)
-		if (tris[i])
-		{
-			for (int j = 0; j < 3; j++) ts.Add((*tris[i])[j]);
-			delete tris[i];
-		}
-	tris_count = ts.count / 3;
-	tris_out = ts.element;
-	ts.element = NULL;
-	ts.count = ts.array_size = 0;
-	tris.count = 0;
-	return 1;
-}
-
-int calchullpbev(float3 *verts, int verts_count, int vlimit, Array<Plane> &planes, float bevangle, Array<btHullTriangle *> &tris)
-{
-	int i, j;
-	planes.count = 0;
-	int rc = calchullgen(verts, verts_count, vlimit, tris);
-	if (!rc) return 0;
-	for (i = 0; i < tris.count; i++)
-		if (tris[i])
-		{
-			Plane p;
-			btHullTriangle *t = tris[i];
-			p.normal = TriNormal(verts[(*t)[0]], verts[(*t)[1]], verts[(*t)[2]]);
-			p.dist = -dot(p.normal, verts[(*t)[0]]);
-			planes.Add(p);
-			for (j = 0; j < 3; j++)
-			{
-				if (t->n[j] < t->id) continue;
-				btHullTriangle *s = tris[t->n[j]];
-				REAL3 snormal = TriNormal(verts[(*s)[0]], verts[(*s)[1]], verts[(*s)[2]]);
-				if (dot(snormal, p.normal) >= cos(bevangle * DEG2RAD)) continue;
-				REAL3 n = normalize(snormal + p.normal);
-				planes.Add(Plane(n, -dot(n, verts[maxdir(verts, verts_count, n)])));
-			}
-		}
-
-	for (i = 0; i < tris.count; i++)
-		if (tris[i])
-		{
-			delete tris[i];  // delete tris[i];
-		}
-	tris.count = 0;
-	return 1;
-}
-
-int overhull(Plane *planes, int planes_count, float3 *verts, int verts_count, int maxplanes,
-			 float3 *&verts_out, int &verts_count_out, int *&faces_out, int &faces_count_out, float inflate)
-{
-	int i, j;
-	if (verts_count < 4) return 0;
-	maxplanes = Min(maxplanes, planes_count);
-	float3 bmin(verts[0]), bmax(verts[0]);
-	for (i = 0; i < verts_count; i++)
-	{
-		bmin = VectorMin(bmin, verts[i]);
-		bmax = VectorMax(bmax, verts[i]);
-	}
-	//	float diameter = magnitude(bmax-bmin);
-	//	inflate *=diameter;   // RELATIVE INFLATION
-	bmin -= float3(inflate, inflate, inflate);
-	bmax += float3(inflate, inflate, inflate);
-	for (i = 0; i < planes_count; i++)
-	{
-		planes[i].dist -= inflate;
-	}
-	float3 emin = bmin;  // VectorMin(bmin,float3(0,0,0));
-	float3 emax = bmax;  // VectorMax(bmax,float3(0,0,0));
-	float epsilon = magnitude(emax - emin) * 0.025f;
-	planetestepsilon = magnitude(emax - emin) * PAPERWIDTH;
-	// todo: add bounding cube planes to force bevel. or try instead not adding the diameter expansion ??? must think.
-	// ConvexH *convex = ConvexHMakeCube(bmin - float3(diameter,diameter,diameter),bmax+float3(diameter,diameter,diameter));
-	ConvexH *c = ConvexHMakeCube(REAL3(bmin), REAL3(bmax));
-	int k;
-	while (maxplanes-- && (k = candidateplane(planes, planes_count, c, epsilon)) >= 0)
-	{
-		ConvexH *tmp = c;
-		c = ConvexHCrop(*tmp, planes[k]);
-		if (c == NULL)
-		{
-			c = tmp;
-			break;
-		}  // might want to debug this case better!!!
-		if (!AssertIntact(*c))
-		{
-			c = tmp;
-			break;
-		}  // might want to debug this case better too!!!
-		delete tmp;
-	}
-
-	assert(AssertIntact(*c));
-	//return c;
-	faces_out = (int *)malloc(sizeof(int) * (1 + c->facets.count + c->edges.count));  // new int[1+c->facets.count+c->edges.count];
-	faces_count_out = 0;
-	i = 0;
-	faces_out[faces_count_out++] = -1;
-	k = 0;
-	while (i < c->edges.count)
-	{
-		j = 1;
-		while (j + i < c->edges.count && c->edges[i].p == c->edges[i + j].p)
-		{
-			j++;
-		}
-		faces_out[faces_count_out++] = j;
-		while (j--)
-		{
-			faces_out[faces_count_out++] = c->edges[i].v;
-			i++;
-		}
-		k++;
-	}
-	faces_out[0] = k;  // number of faces.
-	assert(k == c->facets.count);
-	assert(faces_count_out == 1 + c->facets.count + c->edges.count);
-	verts_out = c->vertices.element;  // new float3[c->vertices.count];
-	verts_count_out = c->vertices.count;
-	for (i = 0; i < c->vertices.count; i++)
-	{
-		verts_out[i] = float3(c->vertices[i]);
-	}
-	c->vertices.count = c->vertices.array_size = 0;
-	c->vertices.element = NULL;
-	delete c;
-	return 1;
-}
-
-int overhullv(float3 *verts, int verts_count, int maxplanes,
-			  float3 *&verts_out, int &verts_count_out, int *&faces_out, int &faces_count_out, float inflate, float bevangle, int vlimit, Array<btHullTriangle *> &tris)
-{
-	if (!verts_count) return 0;
-	extern int calchullpbev(float3 * verts, int verts_count, int vlimit, Array<Plane> &planes, float bevangle, Array<btHullTriangle *> &tris);
-	Array<Plane> planes;
-	int rc = calchullpbev(verts, verts_count, vlimit, planes, bevangle, tris);
-	if (!rc) return 0;
-	return overhull(planes.element, planes.count, verts, verts_count, maxplanes, verts_out, verts_count_out, faces_out, faces_count_out, inflate);
-}
-
-bool ComputeHull(unsigned int vcount, const float *vertices, PHullResult &result, unsigned int vlimit, float inflate, Array<btHullTriangle *> &arrtris)
-{
-	int index_count;
-	int *faces;
-	float3 *verts_out;
-	int verts_count_out;
-
-	if (inflate == 0.0f)
-	{
-		int *tris_out;
-		int tris_count;
-		int ret = calchull((float3 *)vertices, (int)vcount, tris_out, tris_count, vlimit, arrtris);
-		if (!ret) return false;
-		result.mIndexCount = (unsigned int)(tris_count * 3);
-		result.mFaceCount = (unsigned int)tris_count;
-		result.mVertices = (float *)vertices;
-		result.mVcount = (unsigned int)vcount;
-		result.mIndices = (unsigned int *)tris_out;
-		return true;
-	}
-
-	int ret = overhullv((float3 *)vertices, vcount, 35, verts_out, verts_count_out, faces, index_count, inflate, 120.0f, vlimit, arrtris);
-	if (!ret) return false;
-
-	Array<int3> tris;
-	int n = faces[0];
-	int k = 1;
-	for (int i = 0; i < n; i++)
-	{
-		int pn = faces[k++];
-		for (int j = 2; j < pn; j++) tris.Add(int3(faces[k], faces[k + j - 1], faces[k + j]));
-		k += pn;
-	}
-	assert(tris.count == index_count - 1 - (n * 3));
-
-	result.mIndexCount = (unsigned int)(tris.count * 3);
-	result.mFaceCount = (unsigned int)tris.count;
-	result.mVertices = (float *)verts_out;
-	result.mVcount = (unsigned int)verts_count_out;
-	result.mIndices = (unsigned int *)tris.element;
-	tris.element = NULL;
-	tris.count = tris.array_size = 0;
-
-	return true;
-}
-
-void ReleaseHull(PHullResult &result)
-{
-	if (result.mIndices)
-	{
-		free(result.mIndices);
-	}
-
-	result.mVcount = 0;
-	result.mIndexCount = 0;
-	result.mIndices = 0;
-	result.mVertices = 0;
-	result.mIndices = 0;
-}
-
-//*********************************************************************
-//*********************************************************************
-//********  HullLib header
-//*********************************************************************
-//*********************************************************************
-
-//*********************************************************************
-//*********************************************************************
-//********  HullLib implementation
-//*********************************************************************
-//*********************************************************************
-
-HullError HullLibrary::CreateConvexHull(const HullDesc &desc,  // describes the input request
-										HullResult &result)    // contains the resulst
-{
-	HullError ret = QE_FAIL;
-
-	PHullResult hr;
-
-	unsigned int vcount = desc.mVcount;
-	if (vcount < 8) vcount = 8;
-
-	float *vsource = (float *)malloc(sizeof(float) * vcount * 3);
-
-	float scale[3];
-
-	unsigned int ovcount;
-
-	bool ok = CleanupVertices(desc.mVcount, desc.mVertices, desc.mVertexStride, ovcount, vsource, desc.mNormalEpsilon, scale);  // normalize point cloud, remove duplicates!
-
-	if (ok)
-	{
-		if (1)  // scale vertices back to their original size.
-		{
-			for (unsigned int i = 0; i < ovcount; i++)
-			{
-				float *v = &vsource[i * 3];
-				v[0] *= scale[0];
-				v[1] *= scale[1];
-				v[2] *= scale[2];
-			}
-		}
-
-		float skinwidth = 0;
-		if (desc.HasHullFlag(QF_SKIN_WIDTH))
-			skinwidth = desc.mSkinWidth;
-
-		Array<btHullTriangle *> tris;
-		ok = ComputeHull(ovcount, vsource, hr, desc.mMaxVertices, skinwidth, tris);
-
-		if (ok)
-		{
-			// re-index triangle mesh so it refers to only used vertices, rebuild a new vertex table.
-			float *vscratch = (float *)malloc(sizeof(float) * hr.mVcount * 3);
-			BringOutYourDead(hr.mVertices, hr.mVcount, vscratch, ovcount, hr.mIndices, hr.mIndexCount);
-
-			ret = QE_OK;
-
-			if (desc.HasHullFlag(QF_TRIANGLES))  // if he wants the results as triangle!
-			{
-				result.mPolygons = false;
-				result.mNumOutputVertices = ovcount;
-				result.mOutputVertices = (float *)malloc(sizeof(float) * ovcount * 3);
-				result.mNumFaces = hr.mFaceCount;
-				result.mNumIndices = hr.mIndexCount;
-
-				result.mIndices = (unsigned int *)malloc(sizeof(unsigned int) * hr.mIndexCount);
-
-				memcpy(result.mOutputVertices, vscratch, sizeof(float) * 3 * ovcount);
-
-				if (desc.HasHullFlag(QF_REVERSE_ORDER))
-				{
-					const unsigned int *source = hr.mIndices;
-					unsigned int *dest = result.mIndices;
-
-					for (unsigned int i = 0; i < hr.mFaceCount; i++)
-					{
-						dest[0] = source[2];
-						dest[1] = source[1];
-						dest[2] = source[0];
-						dest += 3;
-						source += 3;
-					}
-				}
-				else
-				{
-					memcpy(result.mIndices, hr.mIndices, sizeof(unsigned int) * hr.mIndexCount);
-				}
-			}
-			else
-			{
-				result.mPolygons = true;
-				result.mNumOutputVertices = ovcount;
-				result.mOutputVertices = (float *)malloc(sizeof(float) * ovcount * 3);
-				result.mNumFaces = hr.mFaceCount;
-				result.mNumIndices = hr.mIndexCount + hr.mFaceCount;
-				result.mIndices = (unsigned int *)malloc(sizeof(unsigned int) * result.mNumIndices);
-				memcpy(result.mOutputVertices, vscratch, sizeof(float) * 3 * ovcount);
-
-				if (1)
-				{
-					const unsigned int *source = hr.mIndices;
-					unsigned int *dest = result.mIndices;
-					for (unsigned int i = 0; i < hr.mFaceCount; i++)
-					{
-						dest[0] = 3;
-						if (desc.HasHullFlag(QF_REVERSE_ORDER))
-						{
-							dest[1] = source[2];
-							dest[2] = source[1];
-							dest[3] = source[0];
-						}
-						else
-						{
-							dest[1] = source[0];
-							dest[2] = source[1];
-							dest[3] = source[2];
-						}
-
-						dest += 4;
-						source += 3;
-					}
-				}
-			}
-			ReleaseHull(hr);
-			if (vscratch)
-			{
-				free(vscratch);
-			}
-		}
-	}
-
-	if (vsource)
-	{
-		free(vsource);
-	}
-
-	return ret;
-}
-
-HullError HullLibrary::ReleaseResult(HullResult &result)  // release memory allocated for this result, we are done with it.
-{
-	if (result.mOutputVertices)
-	{
-		free(result.mOutputVertices);
-		result.mOutputVertices = 0;
-	}
-	if (result.mIndices)
-	{
-		free(result.mIndices);
-		result.mIndices = 0;
-	}
-	return QE_OK;
-}
-
-static void addPoint(unsigned int &vcount, float *p, float x, float y, float z)
-{
-	float *dest = &p[vcount * 3];
-	dest[0] = x;
-	dest[1] = y;
-	dest[2] = z;
-	vcount++;
-}
-
-float GetDist(float px, float py, float pz, const float *p2)
-{
-	float dx = px - p2[0];
-	float dy = py - p2[1];
-	float dz = pz - p2[2];
-
-	return dx * dx + dy * dy + dz * dz;
-}
-
-bool HullLibrary::CleanupVertices(unsigned int svcount,
-								  const float *svertices,
-								  unsigned int stride,
-								  unsigned int &vcount,  // output number of vertices
-								  float *vertices,       // location to store the results.
-								  float normalepsilon,
-								  float *scale)
-{
-	if (svcount == 0) return false;
-
-#define EPSILON 0.000001f /* close enough to consider two floating point numbers to be 'the same'. */
-
-	vcount = 0;
-
-	float recip[3];
-
-	if (scale)
-	{
-		scale[0] = 1;
-		scale[1] = 1;
-		scale[2] = 1;
-	}
-
-	float bmin[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
-	float bmax[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
-
-	const char *vtx = (const char *)svertices;
-
-	if (1)
-	{
-		for (unsigned int i = 0; i < svcount; i++)
-		{
-			const float *p = (const float *)vtx;
-
-			vtx += stride;
-
-			for (int j = 0; j < 3; j++)
-			{
-				if (p[j] < bmin[j]) bmin[j] = p[j];
-				if (p[j] > bmax[j]) bmax[j] = p[j];
-			}
-		}
-	}
-
-	float dx = bmax[0] - bmin[0];
-	float dy = bmax[1] - bmin[1];
-	float dz = bmax[2] - bmin[2];
-
-	float center[3];
-
-	center[0] = dx * 0.5f + bmin[0];
-	center[1] = dy * 0.5f + bmin[1];
-	center[2] = dz * 0.5f + bmin[2];
-
-	if (dx < EPSILON || dy < EPSILON || dz < EPSILON || svcount < 3)
-	{
-		float len = FLT_MAX;
-
-		if (dx > EPSILON && dx < len) len = dx;
-		if (dy > EPSILON && dy < len) len = dy;
-		if (dz > EPSILON && dz < len) len = dz;
-
-		if (len == FLT_MAX)
-		{
-			dx = dy = dz = 0.01f;  // one centimeter
-		}
-		else
-		{
-			if (dx < EPSILON) dx = len * 0.05f;  // 1/5th the shortest non-zero edge.
-			if (dy < EPSILON) dy = len * 0.05f;
-			if (dz < EPSILON) dz = len * 0.05f;
-		}
-
-		float x1 = center[0] - dx;
-		float x2 = center[0] + dx;
-
-		float y1 = center[1] - dy;
-		float y2 = center[1] + dy;
-
-		float z1 = center[2] - dz;
-		float z2 = center[2] + dz;
-
-		addPoint(vcount, vertices, x1, y1, z1);
-		addPoint(vcount, vertices, x2, y1, z1);
-		addPoint(vcount, vertices, x2, y2, z1);
-		addPoint(vcount, vertices, x1, y2, z1);
-		addPoint(vcount, vertices, x1, y1, z2);
-		addPoint(vcount, vertices, x2, y1, z2);
-		addPoint(vcount, vertices, x2, y2, z2);
-		addPoint(vcount, vertices, x1, y2, z2);
-
-		return true;  // return cube
-	}
-	else
-	{
-		if (scale)
-		{
-			scale[0] = dx;
-			scale[1] = dy;
-			scale[2] = dz;
-
-			recip[0] = 1 / dx;
-			recip[1] = 1 / dy;
-			recip[2] = 1 / dz;
-
-			center[0] *= recip[0];
-			center[1] *= recip[1];
-			center[2] *= recip[2];
-		}
-	}
-
-	vtx = (const char *)svertices;
-
-	for (unsigned int i = 0; i < svcount; i++)
-	{
-		const float *p = (const float *)vtx;
-		vtx += stride;
-
-		float px = p[0];
-		float py = p[1];
-		float pz = p[2];
-
-		if (scale)
-		{
-			px = px * recip[0];  // normalize
-			py = py * recip[1];  // normalize
-			pz = pz * recip[2];  // normalize
-		}
-
-		if (1)
-		{
-			unsigned int j;
-
-			for (j = 0; j < vcount; j++)
-			{
-				float *v = &vertices[j * 3];
-
-				float x = v[0];
-				float y = v[1];
-				float z = v[2];
-
-				float dx = fabsf(x - px);
-				float dy = fabsf(y - py);
-				float dz = fabsf(z - pz);
-
-				if (dx < normalepsilon && dy < normalepsilon && dz < normalepsilon)
-				{
-					// ok, it is close enough to the old one
-					// now let us see if it is further from the center of the point cloud than the one we already recorded.
-					// in which case we keep this one instead.
-
-					float dist1 = GetDist(px, py, pz, center);
-					float dist2 = GetDist(v[0], v[1], v[2], center);
-
-					if (dist1 > dist2)
-					{
-						v[0] = px;
-						v[1] = py;
-						v[2] = pz;
-					}
-
-					break;
-				}
-			}
-
-			if (j == vcount)
-			{
-				float *dest = &vertices[vcount * 3];
-				dest[0] = px;
-				dest[1] = py;
-				dest[2] = pz;
-				vcount++;
-			}
-		}
-	}
-
-	// ok..now make sure we didn't prune so many vertices it is now invalid.
-	if (1)
-	{
-		float bmin[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
-		float bmax[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
-
-		for (unsigned int i = 0; i < vcount; i++)
-		{
-			const float *p = &vertices[i * 3];
-			for (int j = 0; j < 3; j++)
-			{
-				if (p[j] < bmin[j]) bmin[j] = p[j];
-				if (p[j] > bmax[j]) bmax[j] = p[j];
-			}
-		}
-
-		float dx = bmax[0] - bmin[0];
-		float dy = bmax[1] - bmin[1];
-		float dz = bmax[2] - bmin[2];
-
-		if (dx < EPSILON || dy < EPSILON || dz < EPSILON || vcount < 3)
-		{
-			float cx = dx * 0.5f + bmin[0];
-			float cy = dy * 0.5f + bmin[1];
-			float cz = dz * 0.5f + bmin[2];
-
-			float len = FLT_MAX;
-
-			if (dx >= EPSILON && dx < len) len = dx;
-			if (dy >= EPSILON && dy < len) len = dy;
-			if (dz >= EPSILON && dz < len) len = dz;
-
-			if (len == FLT_MAX)
-			{
-				dx = dy = dz = 0.01f;  // one centimeter
-			}
-			else
-			{
-				if (dx < EPSILON) dx = len * 0.05f;  // 1/5th the shortest non-zero edge.
-				if (dy < EPSILON) dy = len * 0.05f;
-				if (dz < EPSILON) dz = len * 0.05f;
-			}
-
-			float x1 = cx - dx;
-			float x2 = cx + dx;
-
-			float y1 = cy - dy;
-			float y2 = cy + dy;
-
-			float z1 = cz - dz;
-			float z2 = cz + dz;
-
-			vcount = 0;  // add box
-
-			addPoint(vcount, vertices, x1, y1, z1);
-			addPoint(vcount, vertices, x2, y1, z1);
-			addPoint(vcount, vertices, x2, y2, z1);
-			addPoint(vcount, vertices, x1, y2, z1);
-			addPoint(vcount, vertices, x1, y1, z2);
-			addPoint(vcount, vertices, x2, y1, z2);
-			addPoint(vcount, vertices, x2, y2, z2);
-			addPoint(vcount, vertices, x1, y2, z2);
-
-			return true;
-		}
-	}
-
-	return true;
-}
-
-void HullLibrary::BringOutYourDead(const float *verts, unsigned int vcount, float *overts, unsigned int &ocount, unsigned int *indices, unsigned indexcount)
-{
-	unsigned int *used = (unsigned int *)malloc(sizeof(unsigned int) * vcount);
-	memset(used, 0, sizeof(unsigned int) * vcount);
-
-	ocount = 0;
-
-	for (unsigned int i = 0; i < indexcount; i++)
-	{
-		unsigned int v = indices[i];  // original array index
-
-		assert(v >= 0 && v < vcount);
-
-		if (used[v])  // if already remapped
-		{
-			indices[i] = used[v] - 1;  // index to new array
-		}
-		else
-		{
-			indices[i] = ocount;  // new index mapping
-
-			overts[ocount * 3 + 0] = verts[v * 3 + 0];  // copy old vert to new vert array
-			overts[ocount * 3 + 1] = verts[v * 3 + 1];
-			overts[ocount * 3 + 2] = verts[v * 3 + 2];
-
-			ocount++;  // increment output vert count
-
-			assert(ocount >= 0 && ocount <= vcount);
-
-			used[v] = ocount;  // assign new index remapping
-		}
-	}
-
-	free(used);
-}
-
-}  // namespace ConvexDecomposition

+ 0 - 148
ThirdParty/Bullet/Extras/ConvexDecomposition/cd_hull.h

@@ -1,148 +0,0 @@
-#ifndef CD_HULL_H
-
-#define CD_HULL_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-namespace ConvexDecomposition
-{
-class HullResult
-{
-public:
-	HullResult(void)
-	{
-		mPolygons = true;
-		mNumOutputVertices = 0;
-		mOutputVertices = 0;
-		mNumFaces = 0;
-		mNumIndices = 0;
-		mIndices = 0;
-	}
-	bool mPolygons;                   // true if indices represents polygons, false indices are triangles
-	unsigned int mNumOutputVertices;  // number of vertices in the output hull
-	float *mOutputVertices;           // array of vertices, 3 floats each x,y,z
-	unsigned int mNumFaces;           // the number of faces produced
-	unsigned int mNumIndices;         // the total number of indices
-	unsigned int *mIndices;           // pointer to indices.
-
-	// If triangles, then indices are array indexes into the vertex list.
-	// If polygons, indices are in the form (number of points in face) (p1, p2, p3, ..) etc..
-};
-
-enum HullFlag
-{
-	QF_TRIANGLES = (1 << 0),      // report results as triangles, not polygons.
-	QF_REVERSE_ORDER = (1 << 1),  // reverse order of the triangle indices.
-	QF_SKIN_WIDTH = (1 << 2),     // extrude hull based on this skin width
-	QF_DEFAULT = 0
-};
-
-class HullDesc
-{
-public:
-	HullDesc(void)
-	{
-		mFlags = QF_DEFAULT;
-		mVcount = 0;
-		mVertices = 0;
-		mVertexStride = sizeof(float) * 3;
-		mNormalEpsilon = 0.001f;
-		mMaxVertices = 4096;  // maximum number of points to be considered for a convex hull.
-		mMaxFaces = 4096;
-		mSkinWidth = 0.01f;  // default is one centimeter
-	};
-
-	HullDesc(HullFlag flag,
-			 unsigned int vcount,
-			 const float *vertices,
-			 unsigned int stride)
-	{
-		mFlags = flag;
-		mVcount = vcount;
-		mVertices = vertices;
-		mVertexStride = stride;
-		mNormalEpsilon = 0.001f;
-		mMaxVertices = 4096;
-		mSkinWidth = 0.01f;  // default is one centimeter
-	}
-
-	bool HasHullFlag(HullFlag flag) const
-	{
-		if (mFlags & flag) return true;
-		return false;
-	}
-
-	void SetHullFlag(HullFlag flag)
-	{
-		mFlags |= flag;
-	}
-
-	void ClearHullFlag(HullFlag flag)
-	{
-		mFlags &= ~flag;
-	}
-
-	unsigned int mFlags;         // flags to use when generating the convex hull.
-	unsigned int mVcount;        // number of vertices in the input point cloud
-	const float *mVertices;      // the array of vertices.
-	unsigned int mVertexStride;  // the stride of each vertex, in bytes.
-	float mNormalEpsilon;        // the epsilon for removing duplicates.  This is a normalized value, if normalized bit is on.
-	float mSkinWidth;
-	unsigned int mMaxVertices;  // maximum number of vertices to be considered for the hull!
-	unsigned int mMaxFaces;
-};
-
-enum HullError
-{
-	QE_OK,   // success!
-	QE_FAIL  // failed.
-};
-
-class HullLibrary
-{
-public:
-	HullError CreateConvexHull(const HullDesc &desc,  // describes the input request
-							   HullResult &result);   // contains the resulst
-
-	HullError ReleaseResult(HullResult &result);  // release memory allocated for this result, we are done with it.
-
-private:
-	void BringOutYourDead(const float *verts, unsigned int vcount, float *overts, unsigned int &ocount, unsigned int *indices, unsigned indexcount);
-
-	bool CleanupVertices(unsigned int svcount,
-						 const float *svertices,
-						 unsigned int stride,
-						 unsigned int &vcount,  // output number of vertices
-						 float *vertices,       // location to store the results.
-						 float normalepsilon,
-						 float *scale);
-};
-
-}  // namespace ConvexDecomposition
-
-#endif

+ 0 - 1192
ThirdParty/Bullet/Extras/ConvexDecomposition/cd_vector.h

@@ -1,1192 +0,0 @@
-#ifndef CD_VECTOR_H
-
-#define CD_VECTOR_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#pragma warning(disable : 4786)
-
-#include <math.h>
-#include <float.h>
-#include <vector>
-
-namespace ConvexDecomposition
-{
-const float DEG_TO_RAD = ((2.0f * 3.14152654f) / 360.0f);
-const float RAD_TO_DEG = (360.0f / (2.0f * 3.141592654f));
-
-class Vector3d
-{
-public:
-	Vector3d(void){};  // null constructor, does not inialize point.
-
-	Vector3d(const Vector3d &a)  // constructor copies existing vector.
-	{
-		x = a.x;
-		y = a.y;
-		z = a.z;
-	};
-
-	Vector3d(float a, float b, float c)  // construct with initial point.
-	{
-		x = a;
-		y = b;
-		z = c;
-	};
-
-	Vector3d(const float *t)
-	{
-		x = t[0];
-		y = t[1];
-		z = t[2];
-	};
-
-	Vector3d(const int *t)
-	{
-		x = t[0];
-		y = t[1];
-		z = t[2];
-	};
-
-	bool operator==(const Vector3d &a) const
-	{
-		return (a.x == x && a.y == y && a.z == z);
-	};
-
-	bool operator!=(const Vector3d &a) const
-	{
-		return (a.x != x || a.y != y || a.z != z);
-	};
-
-	// Operators
-	Vector3d &operator=(const Vector3d &A)  // ASSIGNMENT (=)
-	{
-		x = A.x;
-		y = A.y;
-		z = A.z;
-		return (*this);
-	};
-
-	Vector3d operator+(const Vector3d &A) const  // ADDITION (+)
-	{
-		Vector3d Sum(x + A.x, y + A.y, z + A.z);
-		return (Sum);
-	};
-
-	Vector3d operator-(const Vector3d &A) const  // SUBTRACTION (-)
-	{
-		Vector3d Diff(x - A.x, y - A.y, z - A.z);
-		return (Diff);
-	};
-
-	Vector3d operator*(const float s) const  // MULTIPLY BY SCALAR (*)
-	{
-		Vector3d Scaled(x * s, y * s, z * s);
-		return (Scaled);
-	};
-
-	Vector3d operator+(const float s) const  // ADD CONSTANT TO ALL 3 COMPONENTS (*)
-	{
-		Vector3d Scaled(x + s, y + s, z + s);
-		return (Scaled);
-	};
-
-	Vector3d operator/(const float s) const  // DIVIDE BY SCALAR (/)
-	{
-		float r = 1.0f / s;
-		Vector3d Scaled(x * r, y * r, z * r);
-		return (Scaled);
-	};
-
-	void operator/=(float A)  // ACCUMULATED VECTOR ADDITION (/=)
-	{
-		x /= A;
-		y /= A;
-		z /= A;
-	};
-
-	void operator+=(const Vector3d A)  // ACCUMULATED VECTOR ADDITION (+=)
-	{
-		x += A.x;
-		y += A.y;
-		z += A.z;
-	};
-	void operator-=(const Vector3d A)  // ACCUMULATED VECTOR SUBTRACTION (+=)
-	{
-		x -= A.x;
-		y -= A.y;
-		z -= A.z;
-	};
-	void operator*=(const float s)  // ACCUMULATED SCALAR MULTIPLICATION (*=) (bpc 4/24/2000)
-	{
-		x *= s;
-		y *= s;
-		z *= s;
-	}
-
-	void operator+=(const float A)  // ACCUMULATED VECTOR ADDITION (+=)
-	{
-		x += A;
-		y += A;
-		z += A;
-	};
-
-	Vector3d operator-(void) const  // NEGATION (-)
-	{
-		Vector3d Negated(-x, -y, -z);
-		return (Negated);
-	};
-
-	float operator[](const int i) const  // ALLOWS VECTOR ACCESS AS AN ARRAY.
-	{
-		return ((i == 0) ? x : ((i == 1) ? y : z));
-	};
-	float &operator[](const int i)
-	{
-		return ((i == 0) ? x : ((i == 1) ? y : z));
-	};
-	//
-
-	// accessor methods.
-	float GetX(void) const { return x; };
-	float GetY(void) const { return y; };
-	float GetZ(void) const { return z; };
-
-	float X(void) const { return x; };
-	float Y(void) const { return y; };
-	float Z(void) const { return z; };
-
-	void SetX(float t) { x = t; };
-	void SetY(float t) { y = t; };
-	void SetZ(float t) { z = t; };
-
-	bool IsSame(const Vector3d &v, float epsilon) const
-	{
-		float dx = fabsf(x - v.x);
-		if (dx > epsilon) return false;
-		float dy = fabsf(y - v.y);
-		if (dy > epsilon) return false;
-		float dz = fabsf(z - v.z);
-		if (dz > epsilon) return false;
-		return true;
-	}
-
-	float ComputeNormal(const Vector3d &A,
-						const Vector3d &B,
-						const Vector3d &C)
-	{
-		float vx, vy, vz, wx, wy, wz, vw_x, vw_y, vw_z, mag;
-
-		vx = (B.x - C.x);
-		vy = (B.y - C.y);
-		vz = (B.z - C.z);
-
-		wx = (A.x - B.x);
-		wy = (A.y - B.y);
-		wz = (A.z - B.z);
-
-		vw_x = vy * wz - vz * wy;
-		vw_y = vz * wx - vx * wz;
-		vw_z = vx * wy - vy * wx;
-
-		mag = sqrtf((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
-
-		if (mag < 0.000001f)
-		{
-			mag = 0;
-		}
-		else
-		{
-			mag = 1.0f / mag;
-		}
-
-		x = vw_x * mag;
-		y = vw_y * mag;
-		z = vw_z * mag;
-
-		return mag;
-	}
-
-	void ScaleSumScale(float c0, float c1, const Vector3d &pos)
-	{
-		x = (x * c0) + (pos.x * c1);
-		y = (y * c0) + (pos.y * c1);
-		z = (z * c0) + (pos.z * c1);
-	}
-
-	void SwapYZ(void)
-	{
-		float t = y;
-		y = z;
-		z = t;
-	};
-
-	void Get(float *v) const
-	{
-		v[0] = x;
-		v[1] = y;
-		v[2] = z;
-	};
-
-	void Set(const int *p)
-	{
-		x = (float)p[0];
-		y = (float)p[1];
-		z = (float)p[2];
-	}
-
-	void Set(const float *p)
-	{
-		x = (float)p[0];
-		y = (float)p[1];
-		z = (float)p[2];
-	}
-
-	void Set(float a, float b, float c)
-	{
-		x = a;
-		y = b;
-		z = c;
-	};
-
-	void Zero(void)
-	{
-		x = y = z = 0;
-	};
-
-	const float *Ptr() const { return &x; }
-	float *Ptr() { return &x; }
-
-	// return -(*this).
-	Vector3d negative(void) const
-	{
-		Vector3d result;
-		result.x = -x;
-		result.y = -y;
-		result.z = -z;
-		return result;
-	}
-
-	float Magnitude(void) const
-	{
-		return float(sqrt(x * x + y * y + z * z));
-	};
-
-	float FastMagnitude(void) const
-	{
-		return float(sqrtf(x * x + y * y + z * z));
-	};
-
-	float FasterMagnitude(void) const
-	{
-		return float(sqrtf(x * x + y * y + z * z));
-	};
-
-	void Lerp(const Vector3d &from, const Vector3d &to, float slerp)
-	{
-		x = ((to.x - from.x) * slerp) + from.x;
-		y = ((to.y - from.y) * slerp) + from.y;
-		z = ((to.z - from.z) * slerp) + from.z;
-	};
-
-	// Highly specialized interpolate routine.  Will compute the interpolated position
-	// shifted forward or backwards along the ray defined between (from) and (to).
-	// Reason for existance is so that when a bullet collides with a wall, for
-	// example, you can generate a graphic effect slightly *before* it hit the
-	// wall so that the effect doesn't sort into the wall itself.
-	void Interpolate(const Vector3d &from, const Vector3d &to, float offset)
-	{
-		x = to.x - from.x;
-		y = to.y - from.y;
-		z = to.z - from.z;
-		float d = sqrtf(x * x + y * y + z * z);
-		float recip = 1.0f / d;
-		x *= recip;
-		y *= recip;
-		z *= recip;   // normalize vector
-		d += offset;  // shift along ray
-		x = x * d + from.x;
-		y = y * d + from.y;
-		z = z * d + from.z;
-	};
-
-	bool BinaryEqual(const Vector3d &p) const
-	{
-		const int *source = (const int *)&x;
-		const int *dest = (const int *)&p.x;
-
-		if (source[0] == dest[0] &&
-			source[1] == dest[1] &&
-			source[2] == dest[2]) return true;
-
-		return false;
-	};
-
-	/*bool BinaryEqual(const Vector3d<int> &p) const
-	{
-		if ( x == p.x && y == p.y && z == p.z ) return true;
-		return false;
-	}
-	*/
-
-	/** Computes the reflection vector between two vectors.*/
-	void Reflection(const Vector3d &a, const Vector3d &b)  // compute reflection vector.
-	{
-		Vector3d c;
-		Vector3d d;
-
-		float dot = a.Dot(b) * 2.0f;
-
-		c = b * dot;
-
-		d = c - a;
-
-		x = -d.x;
-		y = -d.y;
-		z = -d.z;
-	};
-
-	void AngleAxis(float angle, const Vector3d &axis)
-	{
-		x = axis.x * angle;
-		y = axis.y * angle;
-		z = axis.z * angle;
-	};
-
-	float Length(void) const  // length of vector.
-	{
-		return float(sqrt(x * x + y * y + z * z));
-	};
-
-	float ComputePlane(const Vector3d &A,
-					   const Vector3d &B,
-					   const Vector3d &C)
-	{
-		float vx, vy, vz, wx, wy, wz, vw_x, vw_y, vw_z, mag;
-
-		vx = (B.x - C.x);
-		vy = (B.y - C.y);
-		vz = (B.z - C.z);
-
-		wx = (A.x - B.x);
-		wy = (A.y - B.y);
-		wz = (A.z - B.z);
-
-		vw_x = vy * wz - vz * wy;
-		vw_y = vz * wx - vx * wz;
-		vw_z = vx * wy - vy * wx;
-
-		mag = sqrtf((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
-
-		if (mag < 0.000001f)
-		{
-			mag = 0;
-		}
-		else
-		{
-			mag = 1.0f / mag;
-		}
-
-		x = vw_x * mag;
-		y = vw_y * mag;
-		z = vw_z * mag;
-
-		float D = 0.0f - ((x * A.x) + (y * A.y) + (z * A.z));
-
-		return D;
-	}
-
-	float FastLength(void) const  // length of vector.
-	{
-		return float(sqrtf(x * x + y * y + z * z));
-	};
-
-	float FasterLength(void) const  // length of vector.
-	{
-		return float(sqrtf(x * x + y * y + z * z));
-	};
-
-	float Length2(void) const  // squared distance, prior to square root.
-	{
-		float l2 = x * x + y * y + z * z;
-		return l2;
-	};
-
-	float Distance(const Vector3d &a) const  // distance between two points.
-	{
-		Vector3d d(a.x - x, a.y - y, a.z - z);
-		return d.Length();
-	}
-
-	float FastDistance(const Vector3d &a) const  // distance between two points.
-	{
-		Vector3d d(a.x - x, a.y - y, a.z - z);
-		return d.FastLength();
-	}
-
-	float FasterDistance(const Vector3d &a) const  // distance between two points.
-	{
-		Vector3d d(a.x - x, a.y - y, a.z - z);
-		return d.FasterLength();
-	}
-
-	float DistanceXY(const Vector3d &a) const
-	{
-		float dx = a.x - x;
-		float dy = a.y - y;
-		float dist = dx * dx + dy * dy;
-		return dist;
-	}
-
-	float Distance2(const Vector3d &a) const  // squared distance.
-	{
-		float dx = a.x - x;
-		float dy = a.y - y;
-		float dz = a.z - z;
-		return dx * dx + dy * dy + dz * dz;
-	};
-
-	float Partial(const Vector3d &p) const
-	{
-		return (x * p.y) - (p.x * y);
-	}
-
-	float Area(const Vector3d &p1, const Vector3d &p2) const
-	{
-		float A = Partial(p1);
-		A += p1.Partial(p2);
-		A += p2.Partial(*this);
-		return A * 0.5f;
-	}
-
-	inline float Normalize(void)  // normalize to a unit vector, returns distance.
-	{
-		float d = sqrtf(static_cast<float>(x * x + y * y + z * z));
-		if (d > 0)
-		{
-			float r = 1.0f / d;
-			x *= r;
-			y *= r;
-			z *= r;
-		}
-		else
-		{
-			x = y = z = 1;
-		}
-		return d;
-	};
-
-	inline float FastNormalize(void)  // normalize to a unit vector, returns distance.
-	{
-		float d = sqrt(static_cast<float>(x * x + y * y + z * z));
-		if (d > 0)
-		{
-			float r = 1.0f / d;
-			x *= r;
-			y *= r;
-			z *= r;
-		}
-		else
-		{
-			x = y = z = 1;
-		}
-		return d;
-	};
-
-	inline float FasterNormalize(void)  // normalize to a unit vector, returns distance.
-	{
-		float d = sqrtf(static_cast<float>(x * x + y * y + z * z));
-		if (d > 0)
-		{
-			float r = 1.0f / d;
-			x *= r;
-			y *= r;
-			z *= r;
-		}
-		else
-		{
-			x = y = z = 1;
-		}
-		return d;
-	};
-
-	float Dot(const Vector3d &a) const  // computes dot product.
-	{
-		return (x * a.x + y * a.y + z * a.z);
-	};
-
-	Vector3d Cross(const Vector3d &other) const
-	{
-		Vector3d result(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
-
-		return result;
-	}
-
-	void Cross(const Vector3d &a, const Vector3d &b)  // cross two vectors result in this one.
-	{
-		x = a.y * b.z - a.z * b.y;
-		y = a.z * b.x - a.x * b.z;
-		z = a.x * b.y - a.y * b.x;
-	};
-
-	/******************************************/
-	// Check if next edge (b to c) turns inward
-	//
-	//    Edge from a to b is already in face
-	//    Edge from b to c is being considered for addition to face
-	/******************************************/
-	bool Concave(const Vector3d &a, const Vector3d &b)
-	{
-		float vx, vy, vz, wx, wy, wz, vw_x, vw_y, vw_z, mag, nx, ny, nz, mag_a, mag_b;
-
-		wx = b.x - a.x;
-		wy = b.y - a.y;
-		wz = b.z - a.z;
-
-		mag_a = (float)sqrtf((wx * wx) + (wy * wy) + (wz * wz));
-
-		vx = x - b.x;
-		vy = y - b.y;
-		vz = z - b.z;
-
-		mag_b = (float)sqrtf((vx * vx) + (vy * vy) + (vz * vz));
-
-		vw_x = (vy * wz) - (vz * wy);
-		vw_y = (vz * wx) - (vx * wz);
-		vw_z = (vx * wy) - (vy * wx);
-
-		mag = (float)sqrtf((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
-
-		// Check magnitude of cross product, which is a sine function
-		// i.e., mag (a x b) = mag (a) * mag (b) * sin (theta);
-		// If sin (theta) small, then angle between edges is very close to
-		// 180, which we may want to call a concavity.	Setting the
-		// CONCAVITY_TOLERANCE value greater than about 0.01 MAY cause
-		// face consolidation to get stuck on particular face.	Most meshes
-		// convert properly with a value of 0.0
-
-		if (mag / (mag_a * mag_b) <= 0.0f) return true;
-
-		mag = 1.0f / mag;
-
-		nx = vw_x * mag;
-		ny = vw_y * mag;
-		nz = vw_z * mag;
-
-		// Dot product of tri normal with cross product result will
-		// yield positive number if edges are convex (+1.0 if two tris
-		// are coplanar), negative number if edges are concave (-1.0 if
-		// two tris are coplanar.)
-
-		mag = (x * nx) + (y * ny) + (z * nz);
-
-		if (mag > 0.0f) return false;
-
-		return (true);
-	};
-
-	bool PointTestXY(const Vector3d &i, const Vector3d &j) const
-	{
-		if ((((i.y <= y) && (y < j.y)) ||
-			 ((j.y <= y) && (y < i.y))) &&
-			(x < (j.x - i.x) * (y - i.y) / (j.y - i.y) + i.x)) return true;
-		return false;
-	}
-
-	// test to see if this point is inside the triangle specified by
-	// these three points on the X/Y plane.
-	bool PointInTriXY(const Vector3d &p1,
-					  const Vector3d &p2,
-					  const Vector3d &p3) const
-	{
-		float ax = p3.x - p2.x;
-		float ay = p3.y - p2.y;
-		float bx = p1.x - p3.x;
-		float by = p1.y - p3.y;
-		float cx = p2.x - p1.x;
-		float cy = p2.y - p1.y;
-		float apx = x - p1.x;
-		float apy = y - p1.y;
-		float bpx = x - p2.x;
-		float bpy = y - p2.y;
-		float cpx = x - p3.x;
-		float cpy = y - p3.y;
-
-		float aCROSSbp = ax * bpy - ay * bpx;
-		float cCROSSap = cx * apy - cy * apx;
-		float bCROSScp = bx * cpy - by * cpx;
-
-		return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
-	};
-
-	// test to see if this point is inside the triangle specified by
-	// these three points on the X/Y plane.
-	bool PointInTriYZ(const Vector3d &p1,
-					  const Vector3d &p2,
-					  const Vector3d &p3) const
-	{
-		float ay = p3.y - p2.y;
-		float az = p3.z - p2.z;
-		float by = p1.y - p3.y;
-		float bz = p1.z - p3.z;
-		float cy = p2.y - p1.y;
-		float cz = p2.z - p1.z;
-		float apy = y - p1.y;
-		float apz = z - p1.z;
-		float bpy = y - p2.y;
-		float bpz = z - p2.z;
-		float cpy = y - p3.y;
-		float cpz = z - p3.z;
-
-		float aCROSSbp = ay * bpz - az * bpy;
-		float cCROSSap = cy * apz - cz * apy;
-		float bCROSScp = by * cpz - bz * cpy;
-
-		return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
-	};
-
-	// test to see if this point is inside the triangle specified by
-	// these three points on the X/Y plane.
-	bool PointInTriXZ(const Vector3d &p1,
-					  const Vector3d &p2,
-					  const Vector3d &p3) const
-	{
-		float az = p3.z - p2.z;
-		float ax = p3.x - p2.x;
-		float bz = p1.z - p3.z;
-		float bx = p1.x - p3.x;
-		float cz = p2.z - p1.z;
-		float cx = p2.x - p1.x;
-		float apz = z - p1.z;
-		float apx = x - p1.x;
-		float bpz = z - p2.z;
-		float bpx = x - p2.x;
-		float cpz = z - p3.z;
-		float cpx = x - p3.x;
-
-		float aCROSSbp = az * bpx - ax * bpz;
-		float cCROSSap = cz * apx - cx * apz;
-		float bCROSScp = bz * cpx - bx * cpz;
-
-		return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
-	};
-
-	// Given a point and a line (defined by two points), compute the closest point
-	// in the line.  (The line is treated as infinitely long.)
-	void NearestPointInLine(const Vector3d &point,
-							const Vector3d &line0,
-							const Vector3d &line1)
-	{
-		Vector3d &nearestPoint = *this;
-		Vector3d lineDelta = line1 - line0;
-
-		// Handle degenerate lines
-		if (lineDelta == Vector3d(0, 0, 0))
-		{
-			nearestPoint = line0;
-		}
-		else
-		{
-			float delta = (point - line0).Dot(lineDelta) / (lineDelta).Dot(lineDelta);
-			nearestPoint = line0 + lineDelta * delta;
-		}
-	}
-
-	// Given a point and a line segment (defined by two points), compute the closest point
-	// in the line.  Cap the point at the endpoints of the line segment.
-	void NearestPointInLineSegment(const Vector3d &point,
-								   const Vector3d &line0,
-								   const Vector3d &line1)
-	{
-		Vector3d &nearestPoint = *this;
-		Vector3d lineDelta = line1 - line0;
-
-		// Handle degenerate lines
-		if (lineDelta == Vector3d(0, 0, 0))
-		{
-			nearestPoint = line0;
-		}
-		else
-		{
-			float delta = (point - line0).Dot(lineDelta) / (lineDelta).Dot(lineDelta);
-
-			// Clamp the point to conform to the segment's endpoints
-			if (delta < 0)
-				delta = 0;
-			else if (delta > 1)
-				delta = 1;
-
-			nearestPoint = line0 + lineDelta * delta;
-		}
-	}
-
-	// Given a point and a plane (defined by three points), compute the closest point
-	// in the plane.  (The plane is unbounded.)
-	void NearestPointInPlane(const Vector3d &point,
-							 const Vector3d &triangle0,
-							 const Vector3d &triangle1,
-							 const Vector3d &triangle2)
-	{
-		Vector3d &nearestPoint = *this;
-		Vector3d lineDelta0 = triangle1 - triangle0;
-		Vector3d lineDelta1 = triangle2 - triangle0;
-		Vector3d pointDelta = point - triangle0;
-		Vector3d normal;
-
-		// Get the normal of the polygon (doesn't have to be a unit vector)
-		normal.Cross(lineDelta0, lineDelta1);
-
-		float delta = normal.Dot(pointDelta) / normal.Dot(normal);
-		nearestPoint = point - normal * delta;
-	}
-
-	// Given a point and a plane (defined by a coplanar point and a normal), compute the closest point
-	// in the plane.  (The plane is unbounded.)
-	void NearestPointInPlane(const Vector3d &point,
-							 const Vector3d &planePoint,
-							 const Vector3d &planeNormal)
-	{
-		Vector3d &nearestPoint = *this;
-		Vector3d pointDelta = point - planePoint;
-
-		float delta = planeNormal.Dot(pointDelta) / planeNormal.Dot(planeNormal);
-		nearestPoint = point - planeNormal * delta;
-	}
-
-	// Given a point and a triangle (defined by three points), compute the closest point
-	// in the triangle.  Clamp the point so it's confined to the area of the triangle.
-	void NearestPointInTriangle(const Vector3d &point,
-								const Vector3d &triangle0,
-								const Vector3d &triangle1,
-								const Vector3d &triangle2)
-	{
-		static const Vector3d zeroVector(0, 0, 0);
-
-		Vector3d &nearestPoint = *this;
-
-		Vector3d lineDelta0 = triangle1 - triangle0;
-		Vector3d lineDelta1 = triangle2 - triangle0;
-
-		// Handle degenerate triangles
-		if ((lineDelta0 == zeroVector) || (lineDelta1 == zeroVector))
-		{
-			nearestPoint.NearestPointInLineSegment(point, triangle1, triangle2);
-		}
-		else if (lineDelta0 == lineDelta1)
-		{
-			nearestPoint.NearestPointInLineSegment(point, triangle0, triangle1);
-		}
-
-		else
-		{
-			Vector3d axis[3];
-			axis[0].NearestPointInLine(triangle0, triangle1, triangle2);
-			axis[1].NearestPointInLine(triangle1, triangle0, triangle2);
-			axis[2].NearestPointInLine(triangle2, triangle0, triangle1);
-
-			float axisDot[3];
-			axisDot[0] = (triangle0 - axis[0]).Dot(point - axis[0]);
-			axisDot[1] = (triangle1 - axis[1]).Dot(point - axis[1]);
-			axisDot[2] = (triangle2 - axis[2]).Dot(point - axis[2]);
-
-			bool bForce = true;
-			float bestMagnitude2 = 0;
-			float closeMagnitude2;
-			Vector3d closePoint;
-
-			if (axisDot[0] < 0)
-			{
-				closePoint.NearestPointInLineSegment(point, triangle1, triangle2);
-				closeMagnitude2 = point.Distance2(closePoint);
-				if (bForce || (bestMagnitude2 > closeMagnitude2))
-				{
-					bForce = false;
-					bestMagnitude2 = closeMagnitude2;
-					nearestPoint = closePoint;
-				}
-			}
-			if (axisDot[1] < 0)
-			{
-				closePoint.NearestPointInLineSegment(point, triangle0, triangle2);
-				closeMagnitude2 = point.Distance2(closePoint);
-				if (bForce || (bestMagnitude2 > closeMagnitude2))
-				{
-					bForce = false;
-					bestMagnitude2 = closeMagnitude2;
-					nearestPoint = closePoint;
-				}
-			}
-			if (axisDot[2] < 0)
-			{
-				closePoint.NearestPointInLineSegment(point, triangle0, triangle1);
-				closeMagnitude2 = point.Distance2(closePoint);
-				if (bForce || (bestMagnitude2 > closeMagnitude2))
-				{
-					bForce = false;
-					bestMagnitude2 = closeMagnitude2;
-					nearestPoint = closePoint;
-				}
-			}
-
-			// If bForce is true at this point, it means the nearest point lies
-			// inside the triangle; use the nearest-point-on-a-plane equation
-			if (bForce)
-			{
-				Vector3d normal;
-
-				// Get the normal of the polygon (doesn't have to be a unit vector)
-				normal.Cross(lineDelta0, lineDelta1);
-
-				Vector3d pointDelta = point - triangle0;
-				float delta = normal.Dot(pointDelta) / normal.Dot(normal);
-
-				nearestPoint = point - normal * delta;
-			}
-		}
-	}
-
-	//private:
-
-	float x;
-	float y;
-	float z;
-};
-
-class Vector2d
-{
-public:
-	Vector2d(void){};  // null constructor, does not inialize point.
-
-	Vector2d(const Vector2d &a)  // constructor copies existing vector.
-	{
-		x = a.x;
-		y = a.y;
-	};
-
-	Vector2d(const float *t)
-	{
-		x = t[0];
-		y = t[1];
-	};
-
-	Vector2d(float a, float b)  // construct with initial point.
-	{
-		x = a;
-		y = b;
-	};
-
-	const float *Ptr() const { return &x; }
-	float *Ptr() { return &x; }
-
-	Vector2d &operator+=(const Vector2d &a)  // += operator.
-	{
-		x += a.x;
-		y += a.y;
-		return *this;
-	};
-
-	Vector2d &operator-=(const Vector2d &a)
-	{
-		x -= a.x;
-		y -= a.y;
-		return *this;
-	};
-
-	Vector2d &operator*=(const Vector2d &a)
-	{
-		x *= a.x;
-		y *= a.y;
-		return *this;
-	};
-
-	Vector2d &operator/=(const Vector2d &a)
-	{
-		x /= a.x;
-		y /= a.y;
-		return *this;
-	};
-
-	bool operator==(const Vector2d &a) const
-	{
-		if (a.x == x && a.y == y) return true;
-		return false;
-	};
-
-	bool operator!=(const Vector2d &a) const
-	{
-		if (a.x != x || a.y != y) return true;
-		return false;
-	};
-
-	Vector2d operator+(Vector2d a) const
-	{
-		a.x += x;
-		a.y += y;
-		return a;
-	};
-
-	Vector2d operator-(Vector2d a) const
-	{
-		a.x = x - a.x;
-		a.y = y - a.y;
-		return a;
-	};
-
-	Vector2d operator-(void) const
-	{
-		return negative();
-	};
-
-	Vector2d operator*(Vector2d a) const
-	{
-		a.x *= x;
-		a.y *= y;
-		return a;
-	};
-
-	Vector2d operator*(float c) const
-	{
-		Vector2d a;
-
-		a.x = x * c;
-		a.y = y * c;
-
-		return a;
-	};
-
-	Vector2d operator/(Vector2d a) const
-	{
-		a.x = x / a.x;
-		a.y = y / a.y;
-		return a;
-	};
-
-	float Dot(const Vector2d &a) const  // computes dot product.
-	{
-		return (x * a.x + y * a.y);
-	};
-
-	float GetX(void) const { return x; };
-	float GetY(void) const { return y; };
-
-	void SetX(float t) { x = t; };
-	void SetY(float t) { y = t; };
-
-	void Set(float a, float b)
-	{
-		x = a;
-		y = b;
-	};
-
-	void Zero(void)
-	{
-		x = y = 0;
-	};
-
-	Vector2d negative(void) const
-	{
-		Vector2d result;
-		result.x = -x;
-		result.y = -y;
-		return result;
-	}
-
-	float magnitude(void) const
-	{
-		return (float)sqrtf(x * x + y * y);
-	}
-
-	float fastmagnitude(void) const
-	{
-		return (float)sqrtf(x * x + y * y);
-	}
-
-	float fastermagnitude(void) const
-	{
-		return (float)sqrtf(x * x + y * y);
-	}
-
-	void Reflection(Vector2d &a, Vector2d &b);  // compute reflection vector.
-
-	float Length(void) const  // length of vector.
-	{
-		return float(sqrtf(x * x + y * y));
-	};
-
-	float FastLength(void) const  // length of vector.
-	{
-		return float(sqrtf(x * x + y * y));
-	};
-
-	float FasterLength(void) const  // length of vector.
-	{
-		return float(sqrtf(x * x + y * y));
-	};
-
-	float Length2(void)  // squared distance, prior to square root.
-	{
-		return x * x + y * y;
-	}
-
-	float Distance(const Vector2d &a) const  // distance between two points.
-	{
-		float dx = a.x - x;
-		float dy = a.y - y;
-		float d = dx * dx + dy * dy;
-		return sqrtf(d);
-	};
-
-	float FastDistance(const Vector2d &a) const  // distance between two points.
-	{
-		float dx = a.x - x;
-		float dy = a.y - y;
-		float d = dx * dx + dy * dy;
-		return sqrtf(d);
-	};
-
-	float FasterDistance(const Vector2d &a) const  // distance between two points.
-	{
-		float dx = a.x - x;
-		float dy = a.y - y;
-		float d = dx * dx + dy * dy;
-		return sqrtf(d);
-	};
-
-	float Distance2(Vector2d &a)  // squared distance.
-	{
-		float dx = a.x - x;
-		float dy = a.y - y;
-		return dx * dx + dy * dy;
-	};
-
-	void Lerp(const Vector2d &from, const Vector2d &to, float slerp)
-	{
-		x = ((to.x - from.x) * slerp) + from.x;
-		y = ((to.y - from.y) * slerp) + from.y;
-	};
-
-	void Cross(const Vector2d &a, const Vector2d &b)  // cross two vectors result in this one.
-	{
-		x = a.y * b.x - a.x * b.y;
-		y = a.x * b.x - a.x * b.x;
-	};
-
-	float Normalize(void)  // normalize to a unit vector, returns distance.
-	{
-		float l = Length();
-		if (l != 0)
-		{
-			l = float(1) / l;
-			x *= l;
-			y *= l;
-		}
-		else
-		{
-			x = y = 0;
-		}
-		return l;
-	};
-
-	float FastNormalize(void)  // normalize to a unit vector, returns distance.
-	{
-		float l = FastLength();
-		if (l != 0)
-		{
-			l = float(1) / l;
-			x *= l;
-			y *= l;
-		}
-		else
-		{
-			x = y = 0;
-		}
-		return l;
-	};
-
-	float FasterNormalize(void)  // normalize to a unit vector, returns distance.
-	{
-		float l = FasterLength();
-		if (l != 0)
-		{
-			l = float(1) / l;
-			x *= l;
-			y *= l;
-		}
-		else
-		{
-			x = y = 0;
-		}
-		return l;
-	};
-
-	float x;
-	float y;
-};
-
-class Line
-{
-public:
-	Line(const Vector3d &from, const Vector3d &to)
-	{
-		mP1 = from;
-		mP2 = to;
-	};
-	// JWR  Test for the intersection of two lines.
-
-	bool Intersect(const Line &src, Vector3d &sect);
-
-private:
-	Vector3d mP1;
-	Vector3d mP2;
-};
-
-typedef std::vector<Vector3d> Vector3dVector;
-typedef std::vector<Vector2d> Vector2dVector;
-
-inline Vector3d operator*(float s, const Vector3d &v)
-{
-	Vector3d Scaled(v.x * s, v.y * s, v.z * s);
-	return (Scaled);
-}
-
-inline Vector2d operator*(float s, const Vector2d &v)
-{
-	Vector2d Scaled(v.x * s, v.y * s);
-	return (Scaled);
-}
-
-}  // namespace ConvexDecomposition
-
-#endif

+ 0 - 824
ThirdParty/Bullet/Extras/ConvexDecomposition/cd_wavefront.cpp

@@ -1,824 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <ctype.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-#include "float_math.h"
-
-#include "cd_wavefront.h"
-
-using namespace ConvexDecomposition;
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-#include <vector>
-
-namespace ConvexDecomposition
-{
-typedef std::vector<int> IntVector;
-typedef std::vector<float> FloatVector;
-
-#if defined(__APPLE__) || defined(__CELLOS_LV2__)
-#define stricmp(a, b) strcasecmp((a), (b))
-#endif
-
-/*******************************************************************/
-/******************** InParser.h  ********************************/
-/*******************************************************************/
-class InPlaceParserInterface
-{
-public:
-	virtual ~InPlaceParserInterface(){};
-
-	virtual int ParseLine(int lineno, int argc, const char **argv) = 0;  // return TRUE to continue parsing, return FALSE to abort parsing process
-};
-
-enum SeparatorType
-{
-	ST_DATA,  // is data
-	ST_HARD,  // is a hard separator
-	ST_SOFT,  // is a soft separator
-	ST_EOS    // is a comment symbol, and everything past this character should be ignored
-};
-
-class InPlaceParser
-{
-public:
-	InPlaceParser(void)
-	{
-		Init();
-	}
-
-	InPlaceParser(char *data, int len)
-	{
-		Init();
-		SetSourceData(data, len);
-	}
-
-	InPlaceParser(const char *fname)
-	{
-		Init();
-		SetFile(fname);
-	}
-
-	~InPlaceParser(void);
-
-	void Init(void)
-	{
-		mQuoteChar = 34;
-		mData = 0;
-		mLen = 0;
-		mMyAlloc = false;
-		for (int i = 0; i < 256; i++)
-		{
-			mHard[i] = ST_DATA;
-			mHardString[i * 2] = i;
-			mHardString[i * 2 + 1] = 0;
-		}
-		mHard[0] = ST_EOS;
-		mHard[32] = ST_SOFT;
-		mHard[9] = ST_SOFT;
-		mHard[13] = ST_SOFT;
-		mHard[10] = ST_SOFT;
-	}
-
-	void SetFile(const char *fname);  // use this file as source data to parse.
-
-	void SetSourceData(char *data, int len)
-	{
-		mData = data;
-		mLen = len;
-		mMyAlloc = false;
-	};
-
-	int Parse(InPlaceParserInterface *callback);  // returns true if entire file was parsed, false if it aborted for some reason
-
-	int ProcessLine(int lineno, char *line, InPlaceParserInterface *callback);
-
-	const char **GetArglist(char *source, int &count);  // convert source string into an arg list, this is a destructive parse.
-
-	void SetHardSeparator(char c)  // add a hard separator
-	{
-		mHard[(int)c] = ST_HARD;
-	}
-
-	void SetHard(char c)  // add a hard separator
-	{
-		mHard[(int)c] = ST_HARD;
-	}
-
-	void SetCommentSymbol(char c)  // comment character, treated as 'end of string'
-	{
-		mHard[(int)c] = ST_EOS;
-	}
-
-	void ClearHardSeparator(char c)
-	{
-		mHard[(int)c] = ST_DATA;
-	}
-
-	void DefaultSymbols(void);  // set up default symbols for hard separator and comment symbol of the '#' character.
-
-	bool EOS(char c)
-	{
-		if (mHard[(int)c] == ST_EOS)
-		{
-			return true;
-		}
-		return false;
-	}
-
-	void SetQuoteChar(char c)
-	{
-		mQuoteChar = c;
-	}
-
-private:
-	inline char *AddHard(int &argc, const char **argv, char *foo);
-	inline bool IsHard(char c);
-	inline char *SkipSpaces(char *foo);
-	inline bool IsWhiteSpace(char c);
-	inline bool IsNonSeparator(char c);  // non separator, neither hard nor soft
-
-	bool mMyAlloc;  // whether or not *I* allocated the buffer and am responsible for deleting it.
-	char *mData;    // ascii data to parse.
-	int mLen;       // length of data
-	SeparatorType mHard[256];
-	char mHardString[256 * 2];
-	char mQuoteChar;
-};
-
-/*******************************************************************/
-/******************** InParser.cpp  ********************************/
-/*******************************************************************/
-void InPlaceParser::SetFile(const char *fname)
-{
-	if (mMyAlloc)
-	{
-		free(mData);
-	}
-	mData = 0;
-	mLen = 0;
-	mMyAlloc = false;
-
-	FILE *fph = fopen(fname, "rb");
-	if (fph)
-	{
-		fseek(fph, 0L, SEEK_END);
-		mLen = ftell(fph);
-		fseek(fph, 0L, SEEK_SET);
-		if (mLen)
-		{
-			mData = (char *)malloc(sizeof(char) * (mLen + 1));
-			int ok = fread(mData, mLen, 1, fph);
-			if (!ok)
-			{
-				free(mData);
-				mData = 0;
-			}
-			else
-			{
-				mData[mLen] = 0;  // zero byte terminate end of file marker.
-				mMyAlloc = true;
-			}
-		}
-		fclose(fph);
-	}
-}
-
-InPlaceParser::~InPlaceParser(void)
-{
-	if (mMyAlloc)
-	{
-		free(mData);
-	}
-}
-
-#define MAXARGS 512
-
-bool InPlaceParser::IsHard(char c)
-{
-	return mHard[(int)c] == ST_HARD;
-}
-
-char *InPlaceParser::AddHard(int &argc, const char **argv, char *foo)
-{
-	while (IsHard(*foo))
-	{
-		const char *hard = &mHardString[*foo * 2];
-		if (argc < MAXARGS)
-		{
-			argv[argc++] = hard;
-		}
-		foo++;
-	}
-	return foo;
-}
-
-bool InPlaceParser::IsWhiteSpace(char c)
-{
-	return mHard[(int)c] == ST_SOFT;
-}
-
-char *InPlaceParser::SkipSpaces(char *foo)
-{
-	while (!EOS(*foo) && IsWhiteSpace(*foo)) foo++;
-	return foo;
-}
-
-bool InPlaceParser::IsNonSeparator(char c)
-{
-	if (!IsHard(c) && !IsWhiteSpace(c) && c != 0) return true;
-	return false;
-}
-
-int InPlaceParser::ProcessLine(int lineno, char *line, InPlaceParserInterface *callback)
-{
-	int ret = 0;
-
-	const char *argv[MAXARGS];
-	int argc = 0;
-
-	char *foo = line;
-
-	while (!EOS(*foo) && argc < MAXARGS)
-	{
-		foo = SkipSpaces(foo);  // skip any leading spaces
-
-		if (EOS(*foo)) break;
-
-		if (*foo == mQuoteChar)  // if it is an open quote
-		{
-			foo++;
-			if (argc < MAXARGS)
-			{
-				argv[argc++] = foo;
-			}
-			while (!EOS(*foo) && *foo != mQuoteChar) foo++;
-			if (!EOS(*foo))
-			{
-				*foo = 0;  // replace close quote with zero byte EOS
-				foo++;
-			}
-		}
-		else
-		{
-			foo = AddHard(argc, argv, foo);  // add any hard separators, skip any spaces
-
-			if (IsNonSeparator(*foo))  // add non-hard argument.
-			{
-				bool quote = false;
-				if (*foo == mQuoteChar)
-				{
-					foo++;
-					quote = true;
-				}
-
-				if (argc < MAXARGS)
-				{
-					argv[argc++] = foo;
-				}
-
-				if (quote)
-				{
-					while (*foo && *foo != mQuoteChar) foo++;
-					if (*foo) *foo = 32;
-				}
-
-				// continue..until we hit an eos ..
-				while (!EOS(*foo))  // until we hit EOS
-				{
-					if (IsWhiteSpace(*foo))  // if we hit a space, stomp a zero byte, and exit
-					{
-						*foo = 0;
-						foo++;
-						break;
-					}
-					else if (IsHard(*foo))  // if we hit a hard separator, stomp a zero byte and store the hard separator argument
-					{
-						const char *hard = &mHardString[*foo * 2];
-						*foo = 0;
-						if (argc < MAXARGS)
-						{
-							argv[argc++] = hard;
-						}
-						foo++;
-						break;
-					}
-					foo++;
-				}  // end of while loop...
-			}
-		}
-	}
-
-	if (argc)
-	{
-		ret = callback->ParseLine(lineno, argc, argv);
-	}
-
-	return ret;
-}
-
-int InPlaceParser::Parse(InPlaceParserInterface *callback)  // returns true if entire file was parsed, false if it aborted for some reason
-{
-	assert(callback);
-	if (!mData) return 0;
-
-	int ret = 0;
-
-	int lineno = 0;
-
-	char *foo = mData;
-	char *begin = foo;
-
-	while (*foo)
-	{
-		if (*foo == 10 || *foo == 13)
-		{
-			lineno++;
-			*foo = 0;
-
-			if (*begin)  // if there is any data to parse at all...
-			{
-				int v = ProcessLine(lineno, begin, callback);
-				if (v) ret = v;
-			}
-
-			foo++;
-			if (*foo == 10) foo++;  // skip line feed, if it is in the carraige-return line-feed format...
-			begin = foo;
-		}
-		else
-		{
-			foo++;
-		}
-	}
-
-	lineno++;  // lasst line.
-
-	int v = ProcessLine(lineno, begin, callback);
-	if (v) ret = v;
-	return ret;
-}
-
-void InPlaceParser::DefaultSymbols(void)
-{
-	SetHardSeparator(',');
-	SetHardSeparator('(');
-	SetHardSeparator(')');
-	SetHardSeparator('=');
-	SetHardSeparator('[');
-	SetHardSeparator(']');
-	SetHardSeparator('{');
-	SetHardSeparator('}');
-	SetCommentSymbol('#');
-}
-
-const char **InPlaceParser::GetArglist(char *line, int &count)  // convert source string into an arg list, this is a destructive parse.
-{
-	const char **ret = 0;
-
-	static const char *argv[MAXARGS];
-	int argc = 0;
-
-	char *foo = line;
-
-	while (!EOS(*foo) && argc < MAXARGS)
-	{
-		foo = SkipSpaces(foo);  // skip any leading spaces
-
-		if (EOS(*foo)) break;
-
-		if (*foo == mQuoteChar)  // if it is an open quote
-		{
-			foo++;
-			if (argc < MAXARGS)
-			{
-				argv[argc++] = foo;
-			}
-			while (!EOS(*foo) && *foo != mQuoteChar) foo++;
-			if (!EOS(*foo))
-			{
-				*foo = 0;  // replace close quote with zero byte EOS
-				foo++;
-			}
-		}
-		else
-		{
-			foo = AddHard(argc, argv, foo);  // add any hard separators, skip any spaces
-
-			if (IsNonSeparator(*foo))  // add non-hard argument.
-			{
-				bool quote = false;
-				if (*foo == mQuoteChar)
-				{
-					foo++;
-					quote = true;
-				}
-
-				if (argc < MAXARGS)
-				{
-					argv[argc++] = foo;
-				}
-
-				if (quote)
-				{
-					while (*foo && *foo != mQuoteChar) foo++;
-					if (*foo) *foo = 32;
-				}
-
-				// continue..until we hit an eos ..
-				while (!EOS(*foo))  // until we hit EOS
-				{
-					if (IsWhiteSpace(*foo))  // if we hit a space, stomp a zero byte, and exit
-					{
-						*foo = 0;
-						foo++;
-						break;
-					}
-					else if (IsHard(*foo))  // if we hit a hard separator, stomp a zero byte and store the hard separator argument
-					{
-						const char *hard = &mHardString[*foo * 2];
-						*foo = 0;
-						if (argc < MAXARGS)
-						{
-							argv[argc++] = hard;
-						}
-						foo++;
-						break;
-					}
-					foo++;
-				}  // end of while loop...
-			}
-		}
-	}
-
-	count = argc;
-	if (argc)
-	{
-		ret = argv;
-	}
-
-	return ret;
-}
-
-/*******************************************************************/
-/******************** Geometry.h  ********************************/
-/*******************************************************************/
-
-class GeometryVertex
-{
-public:
-	float mPos[3];
-	float mNormal[3];
-	float mTexel[2];
-};
-
-class GeometryInterface
-{
-public:
-	virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3) {}
-
-	virtual ~GeometryInterface() {}
-};
-
-/*******************************************************************/
-/******************** Obj.h  ********************************/
-/*******************************************************************/
-
-class OBJ : public InPlaceParserInterface
-{
-public:
-	int LoadMesh(const char *fname, GeometryInterface *callback);
-	int ParseLine(int lineno, int argc, const char **argv);  // return TRUE to continue parsing, return FALSE to abort parsing process
-private:
-	void getVertex(GeometryVertex &v, const char *face) const;
-
-	FloatVector mVerts;
-	FloatVector mTexels;
-	FloatVector mNormals;
-
-	GeometryInterface *mCallback;
-};
-
-/*******************************************************************/
-/******************** Obj.cpp  ********************************/
-/*******************************************************************/
-
-int OBJ::LoadMesh(const char *fname, GeometryInterface *iface)
-{
-	int ret = 0;
-
-	mVerts.clear();
-	mTexels.clear();
-	mNormals.clear();
-
-	mCallback = iface;
-
-	InPlaceParser ipp(fname);
-
-	ipp.Parse(this);
-
-	return ret;
-}
-
-//static const char * GetArg(const char **argv,int i,int argc)
-//{
-// const char * ret = 0;
-// if ( i < argc ) ret = argv[i];
-// return ret;
-//}
-
-void OBJ::getVertex(GeometryVertex &v, const char *face) const
-{
-	v.mPos[0] = 0;
-	v.mPos[1] = 0;
-	v.mPos[2] = 0;
-
-	v.mTexel[0] = 0;
-	v.mTexel[1] = 0;
-
-	v.mNormal[0] = 0;
-	v.mNormal[1] = 1;
-	v.mNormal[2] = 0;
-
-	int index = atoi(face) - 1;
-
-	const char *texel = strstr(face, "/");
-
-	if (texel)
-	{
-		int tindex = atoi(texel + 1) - 1;
-
-		if (tindex >= 0 && tindex < (int)(mTexels.size() / 2))
-		{
-			const float *t = &mTexels[tindex * 2];
-
-			v.mTexel[0] = t[0];
-			v.mTexel[1] = t[1];
-		}
-
-		const char *normal = strstr(texel + 1, "/");
-		if (normal)
-		{
-			int nindex = atoi(normal + 1) - 1;
-
-			if (nindex >= 0 && nindex < (int)(mNormals.size() / 3))
-			{
-				const float *n = &mNormals[nindex * 3];
-
-				v.mNormal[0] = n[0];
-				v.mNormal[1] = n[1];
-				v.mNormal[2] = n[2];
-			}
-		}
-	}
-
-	if (index >= 0 && index < (int)(mVerts.size() / 3))
-	{
-		const float *p = &mVerts[index * 3];
-
-		v.mPos[0] = p[0];
-		v.mPos[1] = p[1];
-		v.mPos[2] = p[2];
-	}
-}
-
-int OBJ::ParseLine(int lineno, int argc, const char **argv)  // return TRUE to continue parsing, return FALSE to abort parsing process
-{
-	int ret = 0;
-
-	if (argc >= 1)
-	{
-		const char *foo = argv[0];
-		if (*foo != '#')
-		{
-			if (strcmp(argv[0], "v") == 0 && argc == 4)
-
-			//if ( stricmp(argv[0],"v") == 0 && argc == 4 )
-			{
-				float vx = (float)atof(argv[1]);
-				float vy = (float)atof(argv[2]);
-				float vz = (float)atof(argv[3]);
-				mVerts.push_back(vx);
-				mVerts.push_back(vy);
-				mVerts.push_back(vz);
-			}
-			else if (strcmp(argv[0], "vt") == 0 && argc == 3)
-
-			//     else if ( stricmp(argv[0],"vt") == 0 && argc == 3 )
-			{
-				float tx = (float)atof(argv[1]);
-				float ty = (float)atof(argv[2]);
-				mTexels.push_back(tx);
-				mTexels.push_back(ty);
-			}
-			//  else if ( stricmp(argv[0],"vn") == 0 && argc == 4 )
-
-			else if (strcmp(argv[0], "vn") == 0 && argc == 4)
-			{
-				float normalx = (float)atof(argv[1]);
-				float normaly = (float)atof(argv[2]);
-				float normalz = (float)atof(argv[3]);
-				mNormals.push_back(normalx);
-				mNormals.push_back(normaly);
-				mNormals.push_back(normalz);
-			}
-			//  else if ( stricmp(argv[0],"f") == 0 && argc >= 4 )
-
-			else if (strcmp(argv[0], "f") == 0 && argc >= 4)
-			{
-				GeometryVertex v[32];
-
-				int vcount = argc - 1;
-
-				for (int i = 1; i < argc; i++)
-				{
-					getVertex(v[i - 1], argv[i]);
-				}
-
-				// need to generate a normal!
-#if 0  // not currently implemented
-        if ( mNormals.empty() )
-        {
-          Vector3d<float> p1( v[0].mPos );
-          Vector3d<float> p2( v[1].mPos );
-          Vector3d<float> p3( v[2].mPos );
-
-          Vector3d<float> n;
-          n.ComputeNormal(p3,p2,p1);
-
-          for (int i=0; i<vcount; i++)
-          {
-            v[i].mNormal[0] = n.x;
-            v[i].mNormal[1] = n.y;
-            v[i].mNormal[2] = n.z;
-          }
-
-        }
-#endif
-
-				mCallback->NodeTriangle(&v[0], &v[1], &v[2]);
-
-				if (vcount >= 3)  // do the fan
-				{
-					for (int i = 2; i < (vcount - 1); i++)
-					{
-						mCallback->NodeTriangle(&v[0], &v[i], &v[i + 1]);
-					}
-				}
-			}
-		}
-	}
-
-	return ret;
-}
-
-class BuildMesh : public GeometryInterface
-{
-public:
-	int getIndex(const float *p)
-	{
-		int vcount = mVertices.size() / 3;
-
-		if (vcount > 0)
-		{
-			//New MS STL library checks indices in debug build, so zero causes an assert if it is empty.
-			const float *v = &mVertices[0];
-
-			for (int i = 0; i < vcount; i++)
-			{
-				if (v[0] == p[0] && v[1] == p[1] && v[2] == p[2]) return i;
-				v += 3;
-			}
-		}
-
-		mVertices.push_back(p[0]);
-		mVertices.push_back(p[1]);
-		mVertices.push_back(p[2]);
-
-		return vcount;
-	}
-
-	virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3)
-	{
-		mIndices.push_back(getIndex(v1->mPos));
-		mIndices.push_back(getIndex(v2->mPos));
-		mIndices.push_back(getIndex(v3->mPos));
-	}
-
-	const FloatVector &GetVertices(void) const { return mVertices; };
-	const IntVector &GetIndices(void) const { return mIndices; };
-
-private:
-	FloatVector mVertices;
-	IntVector mIndices;
-};
-
-WavefrontObj::WavefrontObj(void)
-{
-	mVertexCount = 0;
-	mTriCount = 0;
-	mIndices = 0;
-	mVertices = 0;
-}
-
-WavefrontObj::~WavefrontObj(void)
-{
-	delete[] mIndices;
-	delete[] mVertices;
-}
-
-unsigned int WavefrontObj::loadObj(const char *fname)  // load a wavefront obj returns number of triangles that were loaded.  Data is persists until the class is destructed.
-{
-	unsigned int ret = 0;
-
-	delete[] mVertices;
-	mVertices = 0;
-	delete[] mIndices;
-	mIndices = 0;
-	mVertexCount = 0;
-	mTriCount = 0;
-
-	BuildMesh bm;
-
-	OBJ obj;
-
-	obj.LoadMesh(fname, &bm);
-
-	const FloatVector &vlist = bm.GetVertices();
-	const IntVector &indices = bm.GetIndices();
-	if (vlist.size())
-	{
-		mVertexCount = vlist.size() / 3;
-		mVertices = new float[mVertexCount * 3];
-		memcpy(mVertices, &vlist[0], sizeof(float) * mVertexCount * 3);
-		mTriCount = indices.size() / 3;
-		mIndices = new int[mTriCount * 3 * sizeof(int)];
-		memcpy(mIndices, &indices[0], sizeof(int) * mTriCount * 3);
-		ret = mTriCount;
-	}
-
-	return ret;
-}
-
-}  // namespace ConvexDecomposition

+ 0 - 57
ThirdParty/Bullet/Extras/ConvexDecomposition/cd_wavefront.h

@@ -1,57 +0,0 @@
-#ifndef CD_WAVEFRONT_OBJ_H
-
-#define CD_WAVEFRONT_OBJ_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-namespace ConvexDecomposition
-{
-class WavefrontObj
-{
-public:
-	WavefrontObj(void);
-	~WavefrontObj(void);
-
-	unsigned int loadObj(const char *fname);  // load a wavefront obj returns number of triangles that were loaded.  Data is persists until the class is destructed.
-
-	int mVertexCount;
-	int mTriCount;
-	int *mIndices;
-	float *mVertices;
-};
-
-}  // namespace ConvexDecomposition
-
-#endif

+ 0 - 761
ThirdParty/Bullet/Extras/ConvexDecomposition/concavity.cpp

@@ -1,761 +0,0 @@
-#include "float_math.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include <vector>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#include "concavity.h"
-#include "raytri.h"
-#include "bestfit.h"
-#include "cd_hull.h"
-#include "meshvolume.h"
-#include "cd_vector.h"
-#include "splitplane.h"
-#include "ConvexDecomposition.h"
-
-#define WSCALE 4
-#define CONCAVE_THRESH 0.05f
-
-namespace ConvexDecomposition
-{
-unsigned int getDebugColor(void)
-{
-	static unsigned int colors[8] =
-		{
-			0xFF0000,
-			0x00FF00,
-			0x0000FF,
-			0xFFFF00,
-			0x00FFFF,
-			0xFF00FF,
-			0xFFFFFF,
-			0xFF8040};
-
-	static int count = 0;
-
-	count++;
-
-	if (count == 8) count = 0;
-
-	assert(count >= 0 && count < 8);
-
-	unsigned int color = colors[count];
-
-	return color;
-}
-
-class Wpoint
-{
-public:
-	Wpoint(const Vector3d &p, float w)
-	{
-		mPoint = p;
-		mWeight = w;
-	}
-
-	Vector3d mPoint;
-	float mWeight;
-};
-
-typedef std::vector<Wpoint> WpointVector;
-
-static inline float DistToPt(const float *p, const float *plane)
-{
-	float x = p[0];
-	float y = p[1];
-	float z = p[2];
-	float d = x * plane[0] + y * plane[1] + z * plane[2] + plane[3];
-	return d;
-}
-
-static void intersect(const float *p1, const float *p2, float *split, const float *plane)
-{
-	float dp1 = DistToPt(p1, plane);
-
-	float dir[3];
-
-	dir[0] = p2[0] - p1[0];
-	dir[1] = p2[1] - p1[1];
-	dir[2] = p2[2] - p1[2];
-
-	float dot1 = dir[0] * plane[0] + dir[1] * plane[1] + dir[2] * plane[2];
-	float dot2 = dp1 - plane[3];
-
-	float t = -(plane[3] + dot2) / dot1;
-
-	split[0] = (dir[0] * t) + p1[0];
-	split[1] = (dir[1] * t) + p1[1];
-	split[2] = (dir[2] * t) + p1[2];
-}
-
-class CTri
-{
-public:
-	CTri(void){};
-
-	CTri(const float *p1, const float *p2, const float *p3, unsigned int i1, unsigned int i2, unsigned int i3)
-	{
-		mProcessed = 0;
-		mI1 = i1;
-		mI2 = i2;
-		mI3 = i3;
-
-		mP1.Set(p1);
-		mP2.Set(p2);
-		mP3.Set(p3);
-
-		mPlaneD = mNormal.ComputePlane(mP1, mP2, mP3);
-	}
-
-	float Facing(const CTri &t)
-	{
-		float d = mNormal.Dot(t.mNormal);
-		return d;
-	}
-
-	// clip this line segment against this triangle.
-	bool clip(const Vector3d &start, Vector3d &end) const
-	{
-		Vector3d sect;
-
-		bool hit = lineIntersectsTriangle(start.Ptr(), end.Ptr(), mP1.Ptr(), mP2.Ptr(), mP3.Ptr(), sect.Ptr());
-
-		if (hit)
-		{
-			end = sect;
-		}
-		return hit;
-	}
-
-	bool Concave(const Vector3d &p, float &distance, Vector3d &n) const
-	{
-		n.NearestPointInTriangle(p, mP1, mP2, mP3);
-		distance = p.Distance(n);
-		return true;
-	}
-
-	void addTri(unsigned int *indices, unsigned int i1, unsigned int i2, unsigned int i3, unsigned int &tcount) const
-	{
-		indices[tcount * 3 + 0] = i1;
-		indices[tcount * 3 + 1] = i2;
-		indices[tcount * 3 + 2] = i3;
-		tcount++;
-	}
-
-	float getVolume(ConvexDecompInterface *callback) const
-	{
-		unsigned int indices[8 * 3];
-
-		unsigned int tcount = 0;
-
-		addTri(indices, 0, 1, 2, tcount);
-		addTri(indices, 3, 4, 5, tcount);
-
-		addTri(indices, 0, 3, 4, tcount);
-		addTri(indices, 0, 4, 1, tcount);
-
-		addTri(indices, 1, 4, 5, tcount);
-		addTri(indices, 1, 5, 2, tcount);
-
-		addTri(indices, 0, 3, 5, tcount);
-		addTri(indices, 0, 5, 2, tcount);
-
-		const float *vertices = mP1.Ptr();
-
-		if (callback)
-		{
-			unsigned int color = getDebugColor();
-
-#if 0
-  		Vector3d d1 = mNear1;
-  		Vector3d d2 = mNear2;
-	  	Vector3d d3 = mNear3;
-
-  		callback->ConvexDebugPoint(mP1.Ptr(),0.01f,0x00FF00);
-  		callback->ConvexDebugPoint(mP2.Ptr(),0.01f,0x00FF00);
-  		callback->ConvexDebugPoint(mP3.Ptr(),0.01f,0x00FF00);
-  		callback->ConvexDebugPoint(d1.Ptr(),0.01f,0xFF0000);
-  		callback->ConvexDebugPoint(d2.Ptr(),0.01f,0xFF0000);
-  		callback->ConvexDebugPoint(d3.Ptr(),0.01f,0xFF0000);
-
-  		callback->ConvexDebugTri(mP1.Ptr(), d1.Ptr(),  d1.Ptr(),0x00FF00);
-  		callback->ConvexDebugTri(mP2.Ptr(), d2.Ptr(),  d2.Ptr(),0x00FF00);
-  		callback->ConvexDebugTri(mP3.Ptr(), d3.Ptr(),  d3.Ptr(),0x00FF00);
-
-#else
-			for (unsigned int i = 0; i < tcount; i++)
-			{
-				unsigned int i1 = indices[i * 3 + 0];
-				unsigned int i2 = indices[i * 3 + 1];
-				unsigned int i3 = indices[i * 3 + 2];
-
-				const float *p1 = &vertices[i1 * 3];
-				const float *p2 = &vertices[i2 * 3];
-				const float *p3 = &vertices[i3 * 3];
-
-				callback->ConvexDebugTri(p1, p2, p3, color);
-			}
-#endif
-		}
-
-		float v = computeMeshVolume(mP1.Ptr(), tcount, indices);
-
-		return v;
-	}
-
-	float raySect(const Vector3d &p, const Vector3d &dir, Vector3d &sect) const
-	{
-		float plane[4];
-
-		plane[0] = mNormal.x;
-		plane[1] = mNormal.y;
-		plane[2] = mNormal.z;
-		plane[3] = mPlaneD;
-
-		Vector3d dest = p + dir * 100000;
-
-		intersect(p.Ptr(), dest.Ptr(), sect.Ptr(), plane);
-
-		return sect.Distance(p);  // return the intersection distance.
-	}
-
-	float planeDistance(const Vector3d &p) const
-	{
-		float plane[4];
-
-		plane[0] = mNormal.x;
-		plane[1] = mNormal.y;
-		plane[2] = mNormal.z;
-		plane[3] = mPlaneD;
-
-		return DistToPt(p.Ptr(), plane);
-	}
-
-	bool samePlane(const CTri &t) const
-	{
-		const float THRESH = 0.001f;
-		float dd = fabsf(t.mPlaneD - mPlaneD);
-		if (dd > THRESH) return false;
-		dd = fabsf(t.mNormal.x - mNormal.x);
-		if (dd > THRESH) return false;
-		dd = fabsf(t.mNormal.y - mNormal.y);
-		if (dd > THRESH) return false;
-		dd = fabsf(t.mNormal.z - mNormal.z);
-		if (dd > THRESH) return false;
-		return true;
-	}
-
-	bool hasIndex(unsigned int i) const
-	{
-		if (i == mI1 || i == mI2 || i == mI3) return true;
-		return false;
-	}
-
-	bool sharesEdge(const CTri &t) const
-	{
-		bool ret = false;
-		unsigned int count = 0;
-
-		if (t.hasIndex(mI1)) count++;
-		if (t.hasIndex(mI2)) count++;
-		if (t.hasIndex(mI3)) count++;
-
-		if (count >= 2) ret = true;
-
-		return ret;
-	}
-
-	void debug(unsigned int color, ConvexDecompInterface *callback)
-	{
-		callback->ConvexDebugTri(mP1.Ptr(), mP2.Ptr(), mP3.Ptr(), color);
-		callback->ConvexDebugTri(mP1.Ptr(), mP1.Ptr(), mNear1.Ptr(), 0xFF0000);
-		callback->ConvexDebugTri(mP2.Ptr(), mP2.Ptr(), mNear2.Ptr(), 0xFF0000);
-		callback->ConvexDebugTri(mP2.Ptr(), mP3.Ptr(), mNear3.Ptr(), 0xFF0000);
-		callback->ConvexDebugPoint(mNear1.Ptr(), 0.01f, 0xFF0000);
-		callback->ConvexDebugPoint(mNear2.Ptr(), 0.01f, 0xFF0000);
-		callback->ConvexDebugPoint(mNear3.Ptr(), 0.01f, 0xFF0000);
-	}
-
-	float area(void)
-	{
-		float a = mConcavity * mP1.Area(mP2, mP3);
-		return a;
-	}
-
-	void addWeighted(WpointVector &list, ConvexDecompInterface *callback)
-	{
-		Wpoint p1(mP1, mC1);
-		Wpoint p2(mP2, mC2);
-		Wpoint p3(mP3, mC3);
-
-		Vector3d d1 = mNear1 - mP1;
-		Vector3d d2 = mNear2 - mP2;
-		Vector3d d3 = mNear3 - mP3;
-
-		d1 *= WSCALE;
-		d2 *= WSCALE;
-		d3 *= WSCALE;
-
-		d1 = d1 + mP1;
-		d2 = d2 + mP2;
-		d3 = d3 + mP3;
-
-		Wpoint p4(d1, mC1);
-		Wpoint p5(d2, mC2);
-		Wpoint p6(d3, mC3);
-
-		list.push_back(p1);
-		list.push_back(p2);
-		list.push_back(p3);
-
-		list.push_back(p4);
-		list.push_back(p5);
-		list.push_back(p6);
-
-#if 0
-		callback->ConvexDebugPoint(mP1.Ptr(),0.01f,0x00FF00);
-		callback->ConvexDebugPoint(mP2.Ptr(),0.01f,0x00FF00);
-		callback->ConvexDebugPoint(mP3.Ptr(),0.01f,0x00FF00);
-		callback->ConvexDebugPoint(d1.Ptr(),0.01f,0xFF0000);
-		callback->ConvexDebugPoint(d2.Ptr(),0.01f,0xFF0000);
-		callback->ConvexDebugPoint(d3.Ptr(),0.01f,0xFF0000);
-
-		callback->ConvexDebugTri(mP1.Ptr(), d1.Ptr(),  d1.Ptr(),0x00FF00);
-		callback->ConvexDebugTri(mP2.Ptr(), d2.Ptr(),  d2.Ptr(),0x00FF00);
-		callback->ConvexDebugTri(mP3.Ptr(), d3.Ptr(),  d3.Ptr(),0x00FF00);
-
-		Vector3d np1 = mP1 + mNormal*0.05f;
-		Vector3d np2 = mP2 + mNormal*0.05f;
-		Vector3d np3 = mP3 + mNormal*0.05f;
-
-		callback->ConvexDebugTri(mP1.Ptr(), np1.Ptr(), np1.Ptr(), 0xFF00FF );
-		callback->ConvexDebugTri(mP2.Ptr(), np2.Ptr(), np2.Ptr(), 0xFF00FF );
-		callback->ConvexDebugTri(mP3.Ptr(), np3.Ptr(), np3.Ptr(), 0xFF00FF );
-
-		callback->ConvexDebugPoint( np1.Ptr(), 0.01F, 0XFF00FF );
-		callback->ConvexDebugPoint( np2.Ptr(), 0.01F, 0XFF00FF );
-		callback->ConvexDebugPoint( np3.Ptr(), 0.01F, 0XFF00FF );
-
-#endif
-	}
-
-	Vector3d mP1;
-	Vector3d mP2;
-	Vector3d mP3;
-	Vector3d mNear1;
-	Vector3d mNear2;
-	Vector3d mNear3;
-	Vector3d mNormal;
-	float mPlaneD;
-	float mConcavity;
-	float mC1;
-	float mC2;
-	float mC3;
-	unsigned int mI1;
-	unsigned int mI2;
-	unsigned int mI3;
-	int mProcessed;  // already been added...
-};
-
-typedef std::vector<CTri> CTriVector;
-
-bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callback, const CTriVector &input_mesh)
-{
-	bool ret = false;
-
-	float neardot = 0.707f;
-
-	m.mConcavity = 0;
-
-	//gLog->Display("*********** FEATURE MATCH *************\r\n");
-	//gLog->Display("Plane: %0.4f,%0.4f,%0.4f   %0.4f\r\n", m.mNormal.x, m.mNormal.y, m.mNormal.z, m.mPlaneD );
-	//gLog->Display("*********************************************\r\n");
-
-	CTriVector::const_iterator i;
-
-	CTri nearest;
-
-	for (i = tris.begin(); i != tris.end(); ++i)
-	{
-		const CTri &t = (*i);
-
-		//gLog->Display("   HullPlane: %0.4f,%0.4f,%0.4f   %0.4f\r\n", t.mNormal.x, t.mNormal.y, t.mNormal.z, t.mPlaneD );
-
-		if (t.samePlane(m))
-		{
-			//gLog->Display("*** PLANE MATCH!!!\r\n");
-			ret = false;
-			break;
-		}
-
-		float dot = t.mNormal.Dot(m.mNormal);
-
-		if (dot > neardot)
-		{
-			float d1 = t.planeDistance(m.mP1);
-			float d2 = t.planeDistance(m.mP2);
-			float d3 = t.planeDistance(m.mP3);
-
-			if (d1 > 0.001f || d2 > 0.001f || d3 > 0.001f)  // can't be near coplaner!
-			{
-				neardot = dot;
-
-				Vector3d n1, n2, n3;
-
-				t.raySect(m.mP1, m.mNormal, m.mNear1);
-				t.raySect(m.mP2, m.mNormal, m.mNear2);
-				t.raySect(m.mP3, m.mNormal, m.mNear3);
-
-				nearest = t;
-
-				ret = true;
-			}
-		}
-	}
-
-	if (ret)
-	{
-		if (0)
-		{
-			CTriVector::const_iterator i;
-			for (i = input_mesh.begin(); i != input_mesh.end(); ++i)
-			{
-				const CTri &c = (*i);
-				if (c.mI1 != m.mI1 && c.mI2 != m.mI2 && c.mI3 != m.mI3)
-				{
-					c.clip(m.mP1, m.mNear1);
-					c.clip(m.mP2, m.mNear2);
-					c.clip(m.mP3, m.mNear3);
-				}
-			}
-		}
-
-		//gLog->Display("*********************************************\r\n");
-		//gLog->Display("   HullPlaneNearest: %0.4f,%0.4f,%0.4f   %0.4f\r\n", nearest.mNormal.x, nearest.mNormal.y, nearest.mNormal.z, nearest.mPlaneD );
-
-		m.mC1 = m.mP1.Distance(m.mNear1);
-		m.mC2 = m.mP2.Distance(m.mNear2);
-		m.mC3 = m.mP3.Distance(m.mNear3);
-
-		m.mConcavity = m.mC1;
-
-		if (m.mC2 > m.mConcavity) m.mConcavity = m.mC2;
-		if (m.mC3 > m.mConcavity) m.mConcavity = m.mC3;
-
-#if 0
-		callback->ConvexDebugTri( m.mP1.Ptr(), m.mP2.Ptr(), m.mP3.Ptr(), 0x00FF00 );
-		callback->ConvexDebugTri( m.mNear1.Ptr(), m.mNear2.Ptr(), m.mNear3.Ptr(), 0xFF0000 );
-
-		callback->ConvexDebugTri( m.mP1.Ptr(), m.mP1.Ptr(), m.mNear1.Ptr(), 0xFFFF00 );
-		callback->ConvexDebugTri( m.mP2.Ptr(), m.mP2.Ptr(), m.mNear2.Ptr(), 0xFFFF00 );
-		callback->ConvexDebugTri( m.mP3.Ptr(), m.mP3.Ptr(), m.mNear3.Ptr(), 0xFFFF00 );
-#endif
-	}
-	else
-	{
-		//gLog->Display("No match\r\n");
-	}
-
-	//gLog->Display("*********************************************\r\n");
-	return ret;
-}
-
-bool isFeatureTri(CTri &t, CTriVector &flist, float fc, ConvexDecompInterface *callback, unsigned int color)
-{
-	bool ret = false;
-
-	if (t.mProcessed == 0)  // if not already processed
-	{
-		float c = t.mConcavity / fc;  // must be within 80% of the concavity of the parent.
-
-		if (c > 0.85f)
-		{
-			// see if this triangle is a 'feature' triangle.  Meaning it shares an
-			// edge with any existing feature triangle and is within roughly the same
-			// concavity of the parent.
-			if (flist.size())
-			{
-				CTriVector::iterator i;
-				for (i = flist.begin(); i != flist.end(); ++i)
-				{
-					CTri &ftri = (*i);
-					if (ftri.sharesEdge(t))
-					{
-						t.mProcessed = 2;    // it is now part of a feature.
-						flist.push_back(t);  // add it to the feature list.
-											 //					  callback->ConvexDebugTri( t.mP1.Ptr(), t.mP2.Ptr(),t.mP3.Ptr(), color );
-						ret = true;
-						break;
-					}
-				}
-			}
-			else
-			{
-				t.mProcessed = 2;
-				flist.push_back(t);  // add it to the feature list.
-									 //				callback->ConvexDebugTri( t.mP1.Ptr(), t.mP2.Ptr(),t.mP3.Ptr(), color );
-				ret = true;
-			}
-		}
-		else
-		{
-			t.mProcessed = 1;  // eliminated for this feature, but might be valid for the next one..
-		}
-	}
-	return ret;
-}
-
-float computeConcavity(unsigned int vcount,
-					   const float *vertices,
-					   unsigned int tcount,
-					   const unsigned int *indices,
-					   ConvexDecompInterface *callback,
-					   float *plane,  // plane equation to split on
-					   float &volume)
-{
-	float cret = 0;
-	volume = 1;
-
-	HullResult result;
-	HullLibrary hl;
-	HullDesc desc;
-
-	desc.mMaxFaces = 256;
-	desc.mMaxVertices = 256;
-	desc.SetHullFlag(QF_TRIANGLES);
-
-	desc.mVcount = vcount;
-	desc.mVertices = vertices;
-	desc.mVertexStride = sizeof(float) * 3;
-
-	HullError ret = hl.CreateConvexHull(desc, result);
-
-	if (ret == QE_OK)
-	{
-#if 0
-		float bmin[3];
-		float bmax[3];
-
-		float dx = bmax[0] - bmin[0];
-		float dy = bmax[1] - bmin[1];
-		float dz = bmax[2] - bmin[2];
-
-		Vector3d center;
-
-		center.x = bmin[0] + dx*0.5f;
-		center.y = bmin[1] + dy*0.5f;
-		center.z = bmin[2] + dz*0.5f;
-#endif
-
-		volume = computeMeshVolume2(result.mOutputVertices, result.mNumFaces, result.mIndices);
-
-#if 1
-		// ok..now..for each triangle on the original mesh..
-		// we extrude the points to the nearest point on the hull.
-		const unsigned int *source = result.mIndices;
-
-		CTriVector tris;
-
-		for (unsigned int i = 0; i < result.mNumFaces; i++)
-		{
-			unsigned int i1 = *source++;
-			unsigned int i2 = *source++;
-			unsigned int i3 = *source++;
-
-			const float *p1 = &result.mOutputVertices[i1 * 3];
-			const float *p2 = &result.mOutputVertices[i2 * 3];
-			const float *p3 = &result.mOutputVertices[i3 * 3];
-
-			//			callback->ConvexDebugTri(p1,p2,p3,0xFFFFFF);
-
-			CTri t(p1, p2, p3, i1, i2, i3);  //
-			tris.push_back(t);
-		}
-
-		// we have not pre-computed the plane equation for each triangle in the convex hull..
-
-		float totalVolume = 0;
-
-		CTriVector ftris;  // 'feature' triangles.
-
-		const unsigned int *src = indices;
-
-		float maxc = 0;
-
-		if (1)
-		{
-			CTriVector input_mesh;
-			if (1)
-			{
-				const unsigned int *src = indices;
-				for (unsigned int i = 0; i < tcount; i++)
-				{
-					unsigned int i1 = *src++;
-					unsigned int i2 = *src++;
-					unsigned int i3 = *src++;
-
-					const float *p1 = &vertices[i1 * 3];
-					const float *p2 = &vertices[i2 * 3];
-					const float *p3 = &vertices[i3 * 3];
-
-					CTri t(p1, p2, p3, i1, i2, i3);
-					input_mesh.push_back(t);
-				}
-			}
-
-			CTri maxctri;
-
-			for (unsigned int i = 0; i < tcount; i++)
-			{
-				unsigned int i1 = *src++;
-				unsigned int i2 = *src++;
-				unsigned int i3 = *src++;
-
-				const float *p1 = &vertices[i1 * 3];
-				const float *p2 = &vertices[i2 * 3];
-				const float *p3 = &vertices[i3 * 3];
-
-				CTri t(p1, p2, p3, i1, i2, i3);
-
-				featureMatch(t, tris, callback, input_mesh);
-
-				if (t.mConcavity > CONCAVE_THRESH)
-				{
-					if (t.mConcavity > maxc)
-					{
-						maxc = t.mConcavity;
-						maxctri = t;
-					}
-
-					float v = t.getVolume(0);
-					totalVolume += v;
-					ftris.push_back(t);
-				}
-			}
-		}
-
-#if 0
-	  if ( ftris.size()  && 0 )
-	  {
-
-      // ok..now we extract the triangles which form the maximum concavity.
-      CTriVector major_feature;
-      float maxarea = 0;
-
-      while ( maxc > CONCAVE_THRESH  )
-      {
-
-        unsigned int color = getDebugColor();  //
-
-        CTriVector flist;
-
-        bool found;
-
-        float totalarea = 0;
-
-        do
-        {
-			  found = false;
-			  CTriVector::iterator i;
-			  for (i=ftris.begin(); i!=ftris.end(); ++i)
-			  {
-				CTri &t = (*i);
-				if ( isFeatureTri(t,flist,maxc,callback,color) )
-				{
-				  found = true;
-				  totalarea+=t.area();
-				}
-			  }
-        } while ( found );
-
-
-        if ( totalarea > maxarea )
-        {
-          major_feature = flist;
-          maxarea = totalarea;
-        }
-
-        maxc = 0;
-
-        for (unsigned int i=0; i<ftris.size(); i++)
-        {
-          CTri &t = ftris[i];
-          if ( t.mProcessed != 2 )
-          {
-            t.mProcessed = 0;
-            if ( t.mConcavity > maxc )
-            {
-              maxc = t.mConcavity;
-            }
-          }
-        }
-		  
-      }
-
-      unsigned int color = getDebugColor();
-
-      WpointVector list;
-      for (unsigned int i=0; i<major_feature.size(); ++i)
-      {
-        major_feature[i].addWeighted(list,callback);
-        major_feature[i].debug(color,callback);
-      }
-
-      getBestFitPlane( list.size(), &list[0].mPoint.x, sizeof(Wpoint), &list[0].mWeight, sizeof(Wpoint), plane );
-
-	  	computeSplitPlane( vcount, vertices, tcount, indices, callback, plane );
-
-
-		}
-	  else
-	  {
-	  	computeSplitPlane( vcount, vertices, tcount, indices, callback, plane );
-	  }
-#endif
-
-		cret = totalVolume;
-
-		hl.ReleaseResult(result);
-	}
-#endif
-
-	return cret;
-}
-
-}  // namespace ConvexDecomposition

+ 0 - 55
ThirdParty/Bullet/Extras/ConvexDecomposition/concavity.h

@@ -1,55 +0,0 @@
-#ifndef COMPUTE_CONCAVITY_H
-
-#define COMPUTE_CONCAVITY_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-namespace ConvexDecomposition
-{
-class ConvexDecompInterface;
-
-// compute's how 'concave' this object is and returns the total volume of the
-// convex hull as well as the volume of the 'concavity' which was found.
-float computeConcavity(unsigned int vcount,
-					   const float *vertices,
-					   unsigned int tcount,
-					   const unsigned int *indices,
-					   ConvexDecompInterface *callback,
-					   float *plane,
-					   float &volume);
-
-}  // namespace ConvexDecomposition
-
-#endif

+ 0 - 197
ThirdParty/Bullet/Extras/ConvexDecomposition/fitsphere.cpp

@@ -1,197 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <math.h>
-
-#include "fitsphere.h"
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-/*
-An Efficient Bounding Sphere
-by Jack Ritter
-from "Graphics Gems", Academic Press, 1990
-*/
-
-/* Routine to calculate tight bounding sphere over    */
-/* a set of points in 3D */
-/* This contains the routine find_bounding_sphere(), */
-/* the struct definition, and the globals used for parameters. */
-/* The abs() of all coordinates must be < BIGNUMBER */
-/* Code written by Jack Ritter and Lyle Rains. */
-
-#define BIGNUMBER 100000000.0 /* hundred million */
-
-static inline void Set(float *n, float x, float y, float z)
-{
-	n[0] = x;
-	n[1] = y;
-	n[2] = z;
-}
-
-static inline void Copy(float *dest, const float *source)
-{
-	dest[0] = source[0];
-	dest[1] = source[1];
-	dest[2] = source[2];
-}
-
-float computeBoundingSphere(unsigned int vcount, const float *points, float *center)
-{
-	float mRadius;
-	float mRadius2;
-
-	float xmin[3];
-	float xmax[3];
-	float ymin[3];
-	float ymax[3];
-	float zmin[3];
-	float zmax[3];
-	float dia1[3];
-	float dia2[3];
-
-	/* FIRST PASS: find 6 minima/maxima points */
-	Set(xmin, BIGNUMBER, BIGNUMBER, BIGNUMBER);
-	Set(xmax, -BIGNUMBER, -BIGNUMBER, -BIGNUMBER);
-	Set(ymin, BIGNUMBER, BIGNUMBER, BIGNUMBER);
-	Set(ymax, -BIGNUMBER, -BIGNUMBER, -BIGNUMBER);
-	Set(zmin, BIGNUMBER, BIGNUMBER, BIGNUMBER);
-	Set(zmax, -BIGNUMBER, -BIGNUMBER, -BIGNUMBER);
-
-	for (unsigned i = 0; i < vcount; i++)
-	{
-		const float *caller_p = &points[i * 3];
-
-		if (caller_p[0] < xmin[0])
-			Copy(xmin, caller_p); /* New xminimum point */
-		if (caller_p[0] > xmax[0])
-			Copy(xmax, caller_p);
-		if (caller_p[1] < ymin[1])
-			Copy(ymin, caller_p);
-		if (caller_p[1] > ymax[1])
-			Copy(ymax, caller_p);
-		if (caller_p[2] < zmin[2])
-			Copy(zmin, caller_p);
-		if (caller_p[2] > zmax[2])
-			Copy(zmax, caller_p);
-	}
-
-	/* Set xspan = distance between the 2 points xmin & xmax (squared) */
-	float dx = xmax[0] - xmin[0];
-	float dy = xmax[1] - xmin[1];
-	float dz = xmax[2] - xmin[2];
-	float xspan = dx * dx + dy * dy + dz * dz;
-
-	/* Same for y & z spans */
-	dx = ymax[0] - ymin[0];
-	dy = ymax[1] - ymin[1];
-	dz = ymax[2] - ymin[2];
-	float yspan = dx * dx + dy * dy + dz * dz;
-
-	dx = zmax[0] - zmin[0];
-	dy = zmax[1] - zmin[1];
-	dz = zmax[2] - zmin[2];
-	float zspan = dx * dx + dy * dy + dz * dz;
-
-	/* Set points dia1 & dia2 to the maximally separated pair */
-	Copy(dia1, xmin);
-	Copy(dia2, xmax); /* assume xspan biggest */
-	float maxspan = xspan;
-
-	if (yspan > maxspan)
-	{
-		maxspan = yspan;
-		Copy(dia1, ymin);
-		Copy(dia2, ymax);
-	}
-
-	if (zspan > maxspan)
-	{
-		Copy(dia1, zmin);
-		Copy(dia2, zmax);
-	}
-
-	/* dia1,dia2 is a diameter of initial sphere */
-	/* calc initial center */
-	center[0] = (dia1[0] + dia2[0]) * 0.5f;
-	center[1] = (dia1[1] + dia2[1]) * 0.5f;
-	center[2] = (dia1[2] + dia2[2]) * 0.5f;
-
-	/* calculate initial radius**2 and radius */
-
-	dx = dia2[0] - center[0]; /* x component of radius vector */
-	dy = dia2[1] - center[1]; /* y component of radius vector */
-	dz = dia2[2] - center[2]; /* z component of radius vector */
-
-	mRadius2 = dx * dx + dy * dy + dz * dz;
-	mRadius = float(sqrt(mRadius2));
-
-	/* SECOND PASS: increment current sphere */
-
-	if (1)
-	{
-		for (unsigned i = 0; i < vcount; i++)
-		{
-			const float *caller_p = &points[i * 3];
-
-			dx = caller_p[0] - center[0];
-			dy = caller_p[1] - center[1];
-			dz = caller_p[2] - center[2];
-
-			float old_to_p_sq = dx * dx + dy * dy + dz * dz;
-
-			if (old_to_p_sq > mRadius2) /* do r**2 test first */
-			{                           /* this point is outside of current sphere */
-				float old_to_p = float(sqrt(old_to_p_sq));
-				/* calc radius of new sphere */
-				mRadius = (mRadius + old_to_p) * 0.5f;
-				mRadius2 = mRadius * mRadius; /* for next r**2 compare */
-				float old_to_new = old_to_p - mRadius;
-
-				/* calc center of new sphere */
-
-				float recip = 1.0f / old_to_p;
-
-				float cx = (mRadius * center[0] + old_to_new * caller_p[0]) * recip;
-				float cy = (mRadius * center[1] + old_to_new * caller_p[1]) * recip;
-				float cz = (mRadius * center[2] + old_to_new * caller_p[2]) * recip;
-
-				Set(center, cx, cy, cz);
-			}
-		}
-	}
-
-	return mRadius;
-}

+ 0 - 41
ThirdParty/Bullet/Extras/ConvexDecomposition/fitsphere.h

@@ -1,41 +0,0 @@
-#ifndef FIT_SPHERE_H
-
-#define FIT_SPHERE_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-float computeBoundingSphere(unsigned int vcount, const float *points, float *center);
-
-#endif

+ 0 - 238
ThirdParty/Bullet/Extras/ConvexDecomposition/float_math.cpp

@@ -1,238 +0,0 @@
-#include "float_math.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <math.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-void fm_inverseRT(const float *matrix, const float *pos, float *t)  // inverse rotate translate the point.
-{
-	float _x = pos[0] - matrix[3 * 4 + 0];
-	float _y = pos[1] - matrix[3 * 4 + 1];
-	float _z = pos[2] - matrix[3 * 4 + 2];
-
-	// Multiply inverse-translated source vector by inverted rotation transform
-
-	t[0] = (matrix[0 * 4 + 0] * _x) + (matrix[0 * 4 + 1] * _y) + (matrix[0 * 4 + 2] * _z);
-	t[1] = (matrix[1 * 4 + 0] * _x) + (matrix[1 * 4 + 1] * _y) + (matrix[1 * 4 + 2] * _z);
-	t[2] = (matrix[2 * 4 + 0] * _x) + (matrix[2 * 4 + 1] * _y) + (matrix[2 * 4 + 2] * _z);
-}
-
-void fm_identity(float *matrix)  // set 4x4 matrix to identity.
-{
-	matrix[0 * 4 + 0] = 1;
-	matrix[1 * 4 + 1] = 1;
-	matrix[2 * 4 + 2] = 1;
-	matrix[3 * 4 + 3] = 1;
-
-	matrix[1 * 4 + 0] = 0;
-	matrix[2 * 4 + 0] = 0;
-	matrix[3 * 4 + 0] = 0;
-
-	matrix[0 * 4 + 1] = 0;
-	matrix[2 * 4 + 1] = 0;
-	matrix[3 * 4 + 1] = 0;
-
-	matrix[0 * 4 + 2] = 0;
-	matrix[1 * 4 + 2] = 0;
-	matrix[3 * 4 + 2] = 0;
-
-	matrix[0 * 4 + 3] = 0;
-	matrix[1 * 4 + 3] = 0;
-	matrix[2 * 4 + 3] = 0;
-}
-
-void fm_eulerMatrix(float ax, float ay, float az, float *matrix)  // convert euler (in radians) to a dest 4x4 matrix (translation set to zero)
-{
-	float quat[4];
-	fm_eulerToQuat(ax, ay, az, quat);
-	fm_quatToMatrix(quat, matrix);
-}
-
-void fm_getAABB(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax)
-{
-	const unsigned char *source = (const unsigned char *)points;
-
-	bmin[0] = points[0];
-	bmin[1] = points[1];
-	bmin[2] = points[2];
-
-	bmax[0] = points[0];
-	bmax[1] = points[1];
-	bmax[2] = points[2];
-
-	for (unsigned int i = 1; i < vcount; i++)
-	{
-		source += pstride;
-		const float *p = (const float *)source;
-
-		if (p[0] < bmin[0]) bmin[0] = p[0];
-		if (p[1] < bmin[1]) bmin[1] = p[1];
-		if (p[2] < bmin[2]) bmin[2] = p[2];
-
-		if (p[0] > bmax[0]) bmax[0] = p[0];
-		if (p[1] > bmax[1]) bmax[1] = p[1];
-		if (p[2] > bmax[2]) bmax[2] = p[2];
-	}
-}
-
-void fm_eulerToQuat(float roll, float pitch, float yaw, float *quat)  // convert euler angles to quaternion.
-{
-	roll *= 0.5f;
-	pitch *= 0.5f;
-	yaw *= 0.5f;
-
-	float cr = cosf(roll);
-	float cp = cosf(pitch);
-	float cy = cosf(yaw);
-
-	float sr = sinf(roll);
-	float sp = sinf(pitch);
-	float sy = sinf(yaw);
-
-	float cpcy = cp * cy;
-	float spsy = sp * sy;
-	float spcy = sp * cy;
-	float cpsy = cp * sy;
-
-	quat[0] = (sr * cpcy - cr * spsy);
-	quat[1] = (cr * spcy + sr * cpsy);
-	quat[2] = (cr * cpsy - sr * spcy);
-	quat[3] = cr * cpcy + sr * spsy;
-}
-
-void fm_quatToMatrix(const float *quat, float *matrix)  // convert quaterinion rotation to matrix, zeros out the translation component.
-{
-	float xx = quat[0] * quat[0];
-	float yy = quat[1] * quat[1];
-	float zz = quat[2] * quat[2];
-	float xy = quat[0] * quat[1];
-	float xz = quat[0] * quat[2];
-	float yz = quat[1] * quat[2];
-	float wx = quat[3] * quat[0];
-	float wy = quat[3] * quat[1];
-	float wz = quat[3] * quat[2];
-
-	matrix[0 * 4 + 0] = 1 - 2 * (yy + zz);
-	matrix[1 * 4 + 0] = 2 * (xy - wz);
-	matrix[2 * 4 + 0] = 2 * (xz + wy);
-
-	matrix[0 * 4 + 1] = 2 * (xy + wz);
-	matrix[1 * 4 + 1] = 1 - 2 * (xx + zz);
-	matrix[2 * 4 + 1] = 2 * (yz - wx);
-
-	matrix[0 * 4 + 2] = 2 * (xz - wy);
-	matrix[1 * 4 + 2] = 2 * (yz + wx);
-	matrix[2 * 4 + 2] = 1 - 2 * (xx + yy);
-
-	matrix[3 * 4 + 0] = matrix[3 * 4 + 1] = matrix[3 * 4 + 2] = 0.0f;
-	matrix[0 * 4 + 3] = matrix[1 * 4 + 3] = matrix[2 * 4 + 3] = 0.0f;
-	matrix[3 * 4 + 3] = 1.0f;
-}
-
-void fm_quatRotate(const float *quat, const float *v, float *r)  // rotate a vector directly by a quaternion.
-{
-	float left[4];
-
-	left[0] = quat[3] * v[0] + quat[1] * v[2] - v[1] * quat[2];
-	left[1] = quat[3] * v[1] + quat[2] * v[0] - v[2] * quat[0];
-	left[2] = quat[3] * v[2] + quat[0] * v[1] - v[0] * quat[1];
-	left[3] = -quat[0] * v[0] - quat[1] * v[1] - quat[2] * v[2];
-
-	r[0] = (left[3] * -quat[0]) + (quat[3] * left[0]) + (left[1] * -quat[2]) - (-quat[1] * left[2]);
-	r[1] = (left[3] * -quat[1]) + (quat[3] * left[1]) + (left[2] * -quat[0]) - (-quat[2] * left[0]);
-	r[2] = (left[3] * -quat[2]) + (quat[3] * left[2]) + (left[0] * -quat[1]) - (-quat[0] * left[1]);
-}
-
-void fm_getTranslation(const float *matrix, float *t)
-{
-	t[0] = matrix[3 * 4 + 0];
-	t[1] = matrix[3 * 4 + 1];
-	t[2] = matrix[3 * 4 + 2];
-}
-
-void fm_matrixToQuat(const float *matrix, float *quat)  // convert the 3x3 portion of a 4x4 matrix into a quaterion as x,y,z,w
-{
-	float tr = matrix[0 * 4 + 0] + matrix[1 * 4 + 1] + matrix[2 * 4 + 2];
-
-	// check the diagonal
-
-	if (tr > 0.0f)
-	{
-		float s = (float)sqrt((double)(tr + 1.0f));
-		quat[3] = s * 0.5f;
-		s = 0.5f / s;
-		quat[0] = (matrix[1 * 4 + 2] - matrix[2 * 4 + 1]) * s;
-		quat[1] = (matrix[2 * 4 + 0] - matrix[0 * 4 + 2]) * s;
-		quat[2] = (matrix[0 * 4 + 1] - matrix[1 * 4 + 0]) * s;
-	}
-	else
-	{
-		// diagonal is negative
-		int nxt[3] = {1, 2, 0};
-		float qa[4];
-
-		int i = 0;
-
-		if (matrix[1 * 4 + 1] > matrix[0 * 4 + 0]) i = 1;
-		if (matrix[2 * 4 + 2] > matrix[i * 4 + i]) i = 2;
-
-		int j = nxt[i];
-		int k = nxt[j];
-
-		float s = sqrtf(((matrix[i * 4 + i] - (matrix[j * 4 + j] + matrix[k * 4 + k])) + 1.0f));
-
-		qa[i] = s * 0.5f;
-
-		if (s != 0.0f) s = 0.5f / s;
-
-		qa[3] = (matrix[j * 4 + k] - matrix[k * 4 + j]) * s;
-		qa[j] = (matrix[i * 4 + j] + matrix[j * 4 + i]) * s;
-		qa[k] = (matrix[i * 4 + k] + matrix[k * 4 + i]) * s;
-
-		quat[0] = qa[0];
-		quat[1] = qa[1];
-		quat[2] = qa[2];
-		quat[3] = qa[3];
-	}
-}
-
-float fm_sphereVolume(float radius)  // return's the volume of a sphere of this radius (4/3 PI * R cubed )
-{
-	return (4.0f / 3.0f) * FM_PI * radius * radius * radius;
-}

+ 0 - 71
ThirdParty/Bullet/Extras/ConvexDecomposition/float_math.h

@@ -1,71 +0,0 @@
-#ifndef FLOAT_MATH_H
-
-#define FLOAT_MATH_H
-
-#ifdef _WIN32
-#pragma warning(disable : 4324)  // disable padding warning
-#pragma warning(disable : 4244)  // disable padding warning
-#pragma warning(disable : 4267)  //  possible loss of data
-#pragma warning(disable : 4530)  // Disable the exception disable but used in MSCV Stl warning.
-#pragma warning(disable : 4996)  //Turn off warnings about deprecated C routines
-#pragma warning(disable : 4786)  // Disable the "debug name too long" warning
-#endif
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-// a set of routines that last you do common 3d math
-// operations without any vector, matrix, or quaternion
-// classes or templates.
-//
-// a vector (or point) is a 'float *' to 3 floating point numbers.
-// a matrix is a 'float *' to an array of 16 floating point numbers representing a 4x4 transformation matrix compatible with D3D or OGL
-// a quaternion is a 'float *' to 4 floats representing a quaternion x,y,z,w
-
-const float FM_PI = 3.141592654f;
-const float FM_DEG_TO_RAD = ((2.0f * FM_PI) / 360.0f);
-const float FM_RAD_TO_DEG = (360.0f / (2.0f * FM_PI));
-
-void fm_identity(float *matrix);                                     // set 4x4 matrix to identity.
-void fm_inverseRT(const float *matrix, const float *pos, float *t);  // inverse rotate translate the point.
-void fm_eulerMatrix(float ax, float ay, float az, float *matrix);    // convert euler (in radians) to a dest 4x4 matrix (translation set to zero)
-void fm_getAABB(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax);
-void fm_eulerToQuat(float roll, float pitch, float yaw, float *quat);  // convert euler angles to quaternion.
-void fm_quatToMatrix(const float *quat, float *matrix);                // convert quaterinion rotation to matrix, translation set to zero.
-void fm_quatRotate(const float *quat, const float *v, float *r);       // rotate a vector directly by a quaternion.
-void fm_getTranslation(const float *matrix, float *t);
-void fm_matrixToQuat(const float *matrix, float *quat);  // convert the 3x3 portion of a 4x4 matrix into a quaterion as x,y,z,w
-float fm_sphereVolume(float radius);                     // return's the volume of a sphere of this radius (4/3 PI * R cubed )
-
-#endif

+ 0 - 124
ThirdParty/Bullet/Extras/ConvexDecomposition/meshvolume.cpp

@@ -1,124 +0,0 @@
-#include "float_math.h"
-#include "meshvolume.h"
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-inline float det(const float *p1, const float *p2, const float *p3)
-{
-	return p1[0] * p2[1] * p3[2] + p2[0] * p3[1] * p1[2] + p3[0] * p1[1] * p2[2] - p1[0] * p3[1] * p2[2] - p2[0] * p1[1] * p3[2] - p3[0] * p2[1] * p1[2];
-}
-
-float computeMeshVolume(const float *vertices, unsigned int tcount, const unsigned int *indices)
-{
-	float volume = 0;
-
-	for (unsigned int i = 0; i < tcount; i++, indices += 3)
-	{
-		const float *p1 = &vertices[indices[0] * 3];
-		const float *p2 = &vertices[indices[1] * 3];
-		const float *p3 = &vertices[indices[2] * 3];
-
-		volume += det(p1, p2, p3);  // compute the volume of the tetrahedran relative to the origin.
-	}
-
-	volume *= (1.0f / 6.0f);
-	if (volume < 0)
-		volume *= -1;
-	return volume;
-}
-
-inline void CrossProduct(const float *a, const float *b, float *cross)
-{
-	cross[0] = a[1] * b[2] - a[2] * b[1];
-	cross[1] = a[2] * b[0] - a[0] * b[2];
-	cross[2] = a[0] * b[1] - a[1] * b[0];
-}
-
-inline float DotProduct(const float *a, const float *b)
-{
-	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
-}
-
-inline float tetVolume(const float *p0, const float *p1, const float *p2, const float *p3)
-{
-	float a[3];
-	float b[3];
-	float c[3];
-
-	a[0] = p1[0] - p0[0];
-	a[1] = p1[1] - p0[1];
-	a[2] = p1[2] - p0[2];
-
-	b[0] = p2[0] - p0[0];
-	b[1] = p2[1] - p0[1];
-	b[2] = p2[2] - p0[2];
-
-	c[0] = p3[0] - p0[0];
-	c[1] = p3[1] - p0[1];
-	c[2] = p3[2] - p0[2];
-
-	float cross[3];
-
-	CrossProduct(b, c, cross);
-
-	float volume = DotProduct(a, cross);
-
-	if (volume < 0)
-		return -volume;
-
-	return volume;
-}
-
-inline float det(const float *p0, const float *p1, const float *p2, const float *p3)
-{
-	return p1[0] * p2[1] * p3[2] + p2[0] * p3[1] * p1[2] + p3[0] * p1[1] * p2[2] - p1[0] * p3[1] * p2[2] - p2[0] * p1[1] * p3[2] - p3[0] * p2[1] * p1[2];
-}
-
-float computeMeshVolume2(const float *vertices, unsigned int tcount, const unsigned int *indices)
-{
-	float volume = 0;
-
-	const float *p0 = vertices;
-	for (unsigned int i = 0; i < tcount; i++, indices += 3)
-	{
-		const float *p1 = &vertices[indices[0] * 3];
-		const float *p2 = &vertices[indices[1] * 3];
-		const float *p3 = &vertices[indices[2] * 3];
-
-		volume += tetVolume(p0, p1, p2, p3);  // compute the volume of the tetrahdren relative to the root vertice
-	}
-
-	return volume * (1.0f / 6.0f);
-}

+ 0 - 42
ThirdParty/Bullet/Extras/ConvexDecomposition/meshvolume.h

@@ -1,42 +0,0 @@
-#ifndef MESH_VOLUME_H
-
-#define MESH_VOLUME_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-float computeMeshVolume(const float *vertices, unsigned int tcount, const unsigned int *indices);
-float computeMeshVolume2(const float *vertices, unsigned int tcount, const unsigned int *indices);
-
-#endif

+ 0 - 227
ThirdParty/Bullet/Extras/ConvexDecomposition/planetri.cpp

@@ -1,227 +0,0 @@
-#include "float_math.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "planetri.h"
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-static inline float DistToPt(const float *p, const float *plane)
-{
-	float x = p[0];
-	float y = p[1];
-	float z = p[2];
-	float d = x * plane[0] + y * plane[1] + z * plane[2] + plane[3];
-	return d;
-}
-
-static PlaneTriResult getSidePlane(const float *p, const float *plane, float epsilon)
-{
-	float d = DistToPt(p, plane);
-
-	if ((d + epsilon) > 0)
-		return PTR_FRONT;  // it is 'in front' within the provided epsilon value.
-
-	return PTR_BACK;
-}
-
-static void add(const float *p, float *dest, unsigned int tstride, unsigned int &pcount)
-{
-	char *d = (char *)dest;
-	d = d + pcount * tstride;
-	dest = (float *)d;
-	dest[0] = p[0];
-	dest[1] = p[1];
-	dest[2] = p[2];
-	pcount++;
-	assert(pcount <= 4);
-}
-
-// assumes that the points are on opposite sides of the plane!
-static void intersect(const float *p1, const float *p2, float *split, const float *plane)
-{
-	float dp1 = DistToPt(p1, plane);
-
-	float dir[3];
-
-	dir[0] = p2[0] - p1[0];
-	dir[1] = p2[1] - p1[1];
-	dir[2] = p2[2] - p1[2];
-
-	float dot1 = dir[0] * plane[0] + dir[1] * plane[1] + dir[2] * plane[2];
-	float dot2 = dp1 - plane[3];
-
-	float t = -(plane[3] + dot2) / dot1;
-
-	split[0] = (dir[0] * t) + p1[0];
-	split[1] = (dir[1] * t) + p1[1];
-	split[2] = (dir[2] * t) + p1[2];
-}
-
-PlaneTriResult planeTriIntersection(const float *plane,     // the plane equation in Ax+By+Cz+D format
-									const float *triangle,  // the source triangle.
-									unsigned int tstride,   // stride in bytes of the input and output triangles
-									float epsilon,          // the co-planer epsilon value.
-									float *front,           // the triangle in front of the
-									unsigned int &fcount,   // number of vertices in the 'front' triangle
-									float *back,            // the triangle in back of the plane
-									unsigned int &bcount)   // the number of vertices in the 'back' triangle.
-{
-	fcount = 0;
-	bcount = 0;
-
-	const char *tsource = (const char *)triangle;
-
-	// get the three vertices of the triangle.
-	const float *p1 = (const float *)(tsource);
-	const float *p2 = (const float *)(tsource + tstride);
-	const float *p3 = (const float *)(tsource + tstride * 2);
-
-	PlaneTriResult r1 = getSidePlane(p1, plane, epsilon);  // compute the side of the plane each vertex is on
-	PlaneTriResult r2 = getSidePlane(p2, plane, epsilon);
-	PlaneTriResult r3 = getSidePlane(p3, plane, epsilon);
-
-	if (r1 == r2 && r1 == r3)  // if all three vertices are on the same side of the plane.
-	{
-		if (r1 == PTR_FRONT)  // if all three are in front of the plane, then copy to the 'front' output triangle.
-		{
-			add(p1, front, tstride, fcount);
-			add(p2, front, tstride, fcount);
-			add(p3, front, tstride, fcount);
-		}
-		else
-		{
-			add(p1, back, tstride, bcount);  // if all three are in 'abck' then copy to the 'back' output triangle.
-			add(p2, back, tstride, bcount);
-			add(p3, back, tstride, bcount);
-		}
-		return r1;  // if all three points are on the same side of the plane return result
-	}
-
-	// ok.. we need to split the triangle at the plane.
-
-	// First test ray segment P1 to P2
-	if (r1 == r2)  // if these are both on the same side...
-	{
-		if (r1 == PTR_FRONT)
-		{
-			add(p1, front, tstride, fcount);
-			add(p2, front, tstride, fcount);
-		}
-		else
-		{
-			add(p1, back, tstride, bcount);
-			add(p2, back, tstride, bcount);
-		}
-	}
-	else
-	{
-		float split[3];  // split the point
-		intersect(p1, p2, split, plane);
-
-		if (r1 == PTR_FRONT)
-		{
-			add(p1, front, tstride, fcount);
-			add(split, front, tstride, fcount);
-
-			add(split, back, tstride, bcount);
-			add(p2, back, tstride, bcount);
-		}
-		else
-		{
-			add(p1, back, tstride, bcount);
-			add(split, back, tstride, bcount);
-
-			add(split, front, tstride, fcount);
-			add(p2, front, tstride, fcount);
-		}
-	}
-
-	// Next test ray segment P2 to P3
-	if (r2 == r3)  // if these are both on the same side...
-	{
-		if (r3 == PTR_FRONT)
-		{
-			add(p3, front, tstride, fcount);
-		}
-		else
-		{
-			add(p3, back, tstride, bcount);
-		}
-	}
-	else
-	{
-		float split[3];  // split the point
-		intersect(p2, p3, split, plane);
-
-		if (r3 == PTR_FRONT)
-		{
-			add(split, front, tstride, fcount);
-			add(split, back, tstride, bcount);
-
-			add(p3, front, tstride, fcount);
-		}
-		else
-		{
-			add(split, front, tstride, fcount);
-			add(split, back, tstride, bcount);
-
-			add(p3, back, tstride, bcount);
-		}
-	}
-
-	// Next test ray segment P3 to P1
-	if (r3 != r1)  // if these are both on the same side...
-	{
-		float split[3];  // split the point
-
-		intersect(p3, p1, split, plane);
-
-		if (r1 == PTR_FRONT)
-		{
-			add(split, front, tstride, fcount);
-			add(split, back, tstride, bcount);
-		}
-		else
-		{
-			add(split, front, tstride, fcount);
-			add(split, back, tstride, bcount);
-		}
-	}
-
-	return PTR_SPLIT;
-}

+ 0 - 55
ThirdParty/Bullet/Extras/ConvexDecomposition/planetri.h

@@ -1,55 +0,0 @@
-#ifndef PLANE_TRI_H
-
-#define PLANE_TRI_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-enum PlaneTriResult
-{
-	PTR_FRONT,
-	PTR_BACK,
-	PTR_SPLIT
-};
-
-PlaneTriResult planeTriIntersection(const float *plane,     // the plane equation in Ax+By+Cz+D format
-									const float *triangle,  // the source position triangle.
-									unsigned int tstride,   // stride in bytes between vertices of the triangle.
-									float epsilon,          // the co-planer epsilon value.
-									float *front,           // the triangle in front of the
-									unsigned int &fcount,   // number of vertices in the 'front' triangle.
-									float *back,            // the triangle in back of the plane
-									unsigned int &bcount);  // the number of vertices in the 'back' triangle.
-
-#endif

+ 0 - 12
ThirdParty/Bullet/Extras/ConvexDecomposition/premake4.lua

@@ -1,12 +0,0 @@
-	project "ConvexDecomposition"
-		
-	kind "StaticLib"
-	
-	includedirs {".","../../src"}
-    if os.is("Linux") then
-        buildoptions{"-fPIC"}
-    end
-	files {
-		"**.cpp",
-		"**.h"
-	}

+ 0 - 128
ThirdParty/Bullet/Extras/ConvexDecomposition/raytri.cpp

@@ -1,128 +0,0 @@
-#include "float_math.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <math.h>
-
-#include "raytri.h"
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-/* a = b - c */
-#define vector(a, b, c)       \
-	(a)[0] = (b)[0] - (c)[0]; \
-	(a)[1] = (b)[1] - (c)[1]; \
-	(a)[2] = (b)[2] - (c)[2];
-
-#define innerProduct(v, q) \
-	((v)[0] * (q)[0] +     \
-	 (v)[1] * (q)[1] +     \
-	 (v)[2] * (q)[2])
-
-#define crossProduct(a, b, c)                   \
-	(a)[0] = (b)[1] * (c)[2] - (c)[1] * (b)[2]; \
-	(a)[1] = (b)[2] * (c)[0] - (c)[2] * (b)[0]; \
-	(a)[2] = (b)[0] * (c)[1] - (c)[0] * (b)[1];
-
-bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t)
-{
-	float e1[3], e2[3], h[3], s[3], q[3];
-	float a, f, u, v;
-
-	vector(e1, v1, v0);
-	vector(e2, v2, v0);
-	crossProduct(h, d, e2);
-	a = innerProduct(e1, h);
-
-	if (a > -0.00001 && a < 0.00001)
-		return (false);
-
-	f = 1 / a;
-	vector(s, p, v0);
-	u = f * (innerProduct(s, h));
-
-	if (u < 0.0 || u > 1.0)
-		return (false);
-
-	crossProduct(q, s, e1);
-	v = f * innerProduct(d, q);
-	if (v < 0.0 || u + v > 1.0)
-		return (false);
-	// at this stage we can compute t to find out where
-	// the intersection point is on the line
-	t = f * innerProduct(e2, q);
-	if (t > 0)  // ray intersection
-		return (true);
-	else  // this means that there is a line intersection
-		// but not a ray intersection
-		return (false);
-}
-
-bool lineIntersectsTriangle(const float *rayStart, const float *rayEnd, const float *p1, const float *p2, const float *p3, float *sect)
-{
-	float dir[3];
-
-	dir[0] = rayEnd[0] - rayStart[0];
-	dir[1] = rayEnd[1] - rayStart[1];
-	dir[2] = rayEnd[2] - rayStart[2];
-
-	float d = sqrtf(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);
-	float r = 1.0f / d;
-
-	dir[0] *= r;
-	dir[1] *= r;
-	dir[2] *= r;
-
-	float t;
-
-	bool ret = rayIntersectsTriangle(rayStart, dir, p1, p2, p3, t);
-
-	if (ret)
-	{
-		if (t > d)
-		{
-			sect[0] = rayStart[0] + dir[0] * t;
-			sect[1] = rayStart[1] + dir[1] * t;
-			sect[2] = rayStart[2] + dir[2] * t;
-		}
-		else
-		{
-			ret = false;
-		}
-	}
-
-	return ret;
-}

+ 0 - 43
ThirdParty/Bullet/Extras/ConvexDecomposition/raytri.h

@@ -1,43 +0,0 @@
-#ifndef RAY_TRI_H
-
-#define RAY_TRI_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-// returns true if the ray intersects the triangle.
-bool lineIntersectsTriangle(const float *rayStart, const float *rayEnd, const float *p1, const float *p2, const float *p3, float *sect);
-bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t);
-
-#endif

+ 0 - 294
ThirdParty/Bullet/Extras/ConvexDecomposition/splitplane.cpp

@@ -1,294 +0,0 @@
-#include "float_math.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <float.h>
-#include <math.h>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-#include "splitplane.h"
-#include "ConvexDecomposition.h"
-#include "cd_vector.h"
-#include "cd_hull.h"
-#include "cd_wavefront.h"
-#include "bestfit.h"
-#include "planetri.h"
-#include "vlookup.h"
-#include "meshvolume.h"
-
-namespace ConvexDecomposition
-{
-static void computePlane(const float *A, const float *B, const float *C, float *plane)
-{
-	float vx = (B[0] - C[0]);
-	float vy = (B[1] - C[1]);
-	float vz = (B[2] - C[2]);
-
-	float wx = (A[0] - B[0]);
-	float wy = (A[1] - B[1]);
-	float wz = (A[2] - B[2]);
-
-	float vw_x = vy * wz - vz * wy;
-	float vw_y = vz * wx - vx * wz;
-	float vw_z = vx * wy - vy * wx;
-
-	float mag = sqrtf((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
-
-	if (mag < 0.000001f)
-	{
-		mag = 0;
-	}
-	else
-	{
-		mag = 1.0f / mag;
-	}
-
-	float x = vw_x * mag;
-	float y = vw_y * mag;
-	float z = vw_z * mag;
-
-	float D = 0.0f - ((x * A[0]) + (y * A[1]) + (z * A[2]));
-
-	plane[0] = x;
-	plane[1] = y;
-	plane[2] = z;
-	plane[3] = D;
-}
-
-class Rect3d
-{
-public:
-	Rect3d(void){};
-
-	Rect3d(const float *bmin, const float *bmax)
-	{
-		mMin[0] = bmin[0];
-		mMin[1] = bmin[1];
-		mMin[2] = bmin[2];
-
-		mMax[0] = bmax[0];
-		mMax[1] = bmax[1];
-		mMax[2] = bmax[2];
-	}
-
-	void SetMin(const float *bmin)
-	{
-		mMin[0] = bmin[0];
-		mMin[1] = bmin[1];
-		mMin[2] = bmin[2];
-	}
-
-	void SetMax(const float *bmax)
-	{
-		mMax[0] = bmax[0];
-		mMax[1] = bmax[1];
-		mMax[2] = bmax[2];
-	}
-
-	void SetMin(float x, float y, float z)
-	{
-		mMin[0] = x;
-		mMin[1] = y;
-		mMin[2] = z;
-	}
-
-	void SetMax(float x, float y, float z)
-	{
-		mMax[0] = x;
-		mMax[1] = y;
-		mMax[2] = z;
-	}
-
-	float mMin[3];
-	float mMax[3];
-};
-
-void splitRect(unsigned int axis,
-			   const Rect3d &source,
-			   Rect3d &b1,
-			   Rect3d &b2,
-			   const float *midpoint)
-{
-	switch (axis)
-	{
-		case 0:
-			b1.SetMin(source.mMin);
-			b1.SetMax(midpoint[0], source.mMax[1], source.mMax[2]);
-
-			b2.SetMin(midpoint[0], source.mMin[1], source.mMin[2]);
-			b2.SetMax(source.mMax);
-
-			break;
-		case 1:
-			b1.SetMin(source.mMin);
-			b1.SetMax(source.mMax[0], midpoint[1], source.mMax[2]);
-
-			b2.SetMin(source.mMin[0], midpoint[1], source.mMin[2]);
-			b2.SetMax(source.mMax);
-
-			break;
-		case 2:
-			b1.SetMin(source.mMin);
-			b1.SetMax(source.mMax[0], source.mMax[1], midpoint[2]);
-
-			b2.SetMin(source.mMin[0], source.mMin[1], midpoint[2]);
-			b2.SetMax(source.mMax);
-
-			break;
-	}
-}
-
-bool computeSplitPlane(unsigned int vcount,
-					   const float *vertices,
-					   unsigned int tcount,
-					   const unsigned int *indices,
-					   ConvexDecompInterface *callback,
-					   float *plane)
-{
-	float bmin[3] = {1e9, 1e9, 1e9};
-	float bmax[3] = {-1e9, -1e9, -1e9};
-
-	for (unsigned int i = 0; i < vcount; i++)
-	{
-		const float *p = &vertices[i * 3];
-
-		if (p[0] < bmin[0]) bmin[0] = p[0];
-		if (p[1] < bmin[1]) bmin[1] = p[1];
-		if (p[2] < bmin[2]) bmin[2] = p[2];
-
-		if (p[0] > bmax[0]) bmax[0] = p[0];
-		if (p[1] > bmax[1]) bmax[1] = p[1];
-		if (p[2] > bmax[2]) bmax[2] = p[2];
-	}
-
-	float dx = bmax[0] - bmin[0];
-	float dy = bmax[1] - bmin[1];
-	float dz = bmax[2] - bmin[2];
-
-	float laxis = dx;
-
-	unsigned int axis = 0;
-
-	if (dy > dx)
-	{
-		axis = 1;
-		laxis = dy;
-	}
-
-	if (dz > dx && dz > dy)
-	{
-		axis = 2;
-		laxis = dz;
-	}
-
-	float p1[3];
-	float p2[3];
-	float p3[3];
-
-	p3[0] = p2[0] = p1[0] = bmin[0] + dx * 0.5f;
-	p3[1] = p2[1] = p1[1] = bmin[1] + dy * 0.5f;
-	p3[2] = p2[2] = p1[2] = bmin[2] + dz * 0.5f;
-
-	Rect3d b(bmin, bmax);
-
-	Rect3d b1, b2;
-
-	splitRect(axis, b, b1, b2, p1);
-
-	//  callback->ConvexDebugBound(b1.mMin,b1.mMax,0x00FF00);
-	//  callback->ConvexDebugBound(b2.mMin,b2.mMax,0xFFFF00);
-
-	switch (axis)
-	{
-		case 0:
-			p2[1] = bmin[1];
-			p2[2] = bmin[2];
-
-			if (dz > dy)
-			{
-				p3[1] = bmax[1];
-				p3[2] = bmin[2];
-			}
-			else
-			{
-				p3[1] = bmin[1];
-				p3[2] = bmax[2];
-			}
-
-			break;
-		case 1:
-			p2[0] = bmin[0];
-			p2[2] = bmin[2];
-
-			if (dx > dz)
-			{
-				p3[0] = bmax[0];
-				p3[2] = bmin[2];
-			}
-			else
-			{
-				p3[0] = bmin[0];
-				p3[2] = bmax[2];
-			}
-
-			break;
-		case 2:
-			p2[0] = bmin[0];
-			p2[1] = bmin[1];
-
-			if (dx > dy)
-			{
-				p3[0] = bmax[0];
-				p3[1] = bmin[1];
-			}
-			else
-			{
-				p3[0] = bmin[0];
-				p3[1] = bmax[1];
-			}
-
-			break;
-	}
-
-	//  callback->ConvexDebugTri(p1,p2,p3,0xFF0000);
-
-	computePlane(p1, p2, p3, plane);
-
-	return true;
-}
-
-}  // namespace ConvexDecomposition

+ 0 - 55
ThirdParty/Bullet/Extras/ConvexDecomposition/splitplane.h

@@ -1,55 +0,0 @@
-#ifndef SPLIT_PLANE_H
-
-#define SPLIT_PLANE_H
-
-//** Computes an 'optimal' split plane for the supplied mesh.
-//** needs much improvement since it currently just splits along
-//** the longest side of the AABB.
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-namespace ConvexDecomposition
-{
-class ConvexDecompInterface;
-
-bool computeSplitPlane(unsigned int vcount,
-					   const float *vertices,
-					   unsigned int tcount,
-					   const unsigned int *indices,
-					   ConvexDecompInterface *callback,
-					   float *plane);
-
-}  // namespace ConvexDecomposition
-
-#endif

+ 0 - 311
ThirdParty/Bullet/Extras/ConvexDecomposition/vlookup.cpp

@@ -1,311 +0,0 @@
-#include "float_math.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#pragma warning(disable : 4786)
-
-#include <vector>
-#include <map>
-#include <set>
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-// CodeSnippet provided by John W. Ratcliff
-// on March 23, 2006.
-//
-// mailto: [email protected]
-//
-// Personal website: http://jratcliffscarab.blogspot.com
-// Coding Website:   http://codesuppository.blogspot.com
-// FundRaising Blog: http://amillionpixels.blogspot.com
-// Fundraising site: http://www.amillionpixels.us
-// New Temple Site:  http://newtemple.blogspot.com
-//
-// This snippet shows how to 'hide' the complexity of
-// the STL by wrapping some useful piece of functionality
-// around a handful of discrete API calls.
-//
-// This API allows you to create an indexed triangle list
-// from a collection of raw input triangles.  Internally
-// it uses an STL set to build the lookup table very rapidly.
-//
-// Here is how you would use it to build an indexed triangle
-// list from a raw list of triangles.
-//
-// (1) create a 'VertexLookup' interface by calling
-//
-//     VertexLook vl = Vl_createVertexLookup();
-//
-// (2) For each vertice in each triangle call:
-//
-//     unsigned int i1 = Vl_getIndex(vl,p1);
-//     unsigned int i2 = Vl_getIndex(vl,p2);
-//     unsigned int i3 = Vl_getIndex(vl,p3);
-//
-//     save the 3 indices into your triangle list array.
-//
-// (3) Get the vertex array by calling:
-//
-//     const float *vertices = Vl_getVertices(vl);
-//
-// (4) Get the number of vertices so you can copy them into
-//     your own buffer.
-//     unsigned int vcount = Vl_getVcount(vl);
-//
-// (5) Release the VertexLookup interface when you are done with it.
-//     Vl_releaseVertexLookup(vl);
-//
-// Teaches the following lessons:
-//
-//    How to wrap the complexity of STL and C++ classes around a
-//    simple API interface.
-//
-//    How to use an STL set and custom comparator operator for
-//    a complex data type.
-//
-//    How to create a template class.
-//
-//    How to achieve significant performance improvements by
-//    taking advantage of built in STL containers in just
-//    a few lines of code.
-//
-//    You could easily modify this code to support other vertex
-//    formats with any number of interpolants.
-
-#include "vlookup.h"
-
-namespace Vlookup
-{
-class VertexPosition
-{
-public:
-	VertexPosition(void){};
-	VertexPosition(const float *p)
-	{
-		mPos[0] = p[0];
-		mPos[1] = p[1];
-		mPos[2] = p[2];
-	};
-
-	void Set(int index, const float *pos)
-	{
-		const float *p = &pos[index * 3];
-
-		mPos[0] = p[0];
-		mPos[1] = p[1];
-		mPos[2] = p[2];
-	};
-
-	float GetX(void) const { return mPos[0]; };
-	float GetY(void) const { return mPos[1]; };
-	float GetZ(void) const { return mPos[2]; };
-
-	float mPos[3];
-};
-
-typedef std::vector<VertexPosition> VertexVector;
-
-struct Tracker
-{
-	VertexPosition mFind;  // vertice to locate.
-	VertexVector *mList;
-
-	Tracker()
-	{
-		mList = 0;
-	}
-
-	void SetSearch(const VertexPosition &match, VertexVector *list)
-	{
-		mFind = match;
-		mList = list;
-	};
-};
-
-struct VertexID
-{
-	int mID;
-	Tracker *mTracker;
-
-	VertexID(int ID, Tracker *Tracker)
-	{
-		mID = ID;
-		mTracker = Tracker;
-	}
-};
-
-class VertexLess
-{
-public:
-	bool operator()(VertexID v1, VertexID v2) const;
-
-private:
-	const VertexPosition &Get(VertexID index) const
-	{
-		if (index.mID == -1) return index.mTracker->mFind;
-		VertexVector &vlist = *index.mTracker->mList;
-		return vlist[index.mID];
-	}
-};
-
-template <class Type>
-class VertexPool
-{
-public:
-	typedef std::set<VertexID, VertexLess> VertexSet;
-	typedef std::vector<Type> VertexVector;
-
-	int getVertex(const Type &vtx)
-	{
-		mTracker.SetSearch(vtx, &mVtxs);
-		VertexSet::iterator found;
-		found = mVertSet.find(VertexID(-1, &mTracker));
-		if (found != mVertSet.end())
-		{
-			return found->mID;
-		}
-		int idx = (int)mVtxs.size();
-		mVtxs.push_back(vtx);
-		mVertSet.insert(VertexID(idx, &mTracker));
-		return idx;
-	};
-
-	const float *GetPos(int idx) const
-	{
-		return mVtxs[idx].mPos;
-	}
-
-	const Type &Get(int idx) const
-	{
-		return mVtxs[idx];
-	};
-
-	unsigned int GetSize(void) const
-	{
-		return mVtxs.size();
-	};
-
-	void Clear(int reservesize)  // clear the vertice pool.
-	{
-		mVertSet.clear();
-		mVtxs.clear();
-		mVtxs.reserve(reservesize);
-	};
-
-	const VertexVector &GetVertexList(void) const { return mVtxs; };
-
-	void Set(const Type &vtx)
-	{
-		mVtxs.push_back(vtx);
-	}
-
-	unsigned int GetVertexCount(void) const
-	{
-		return mVtxs.size();
-	};
-
-	Type *getBuffer(void)
-	{
-		return &mVtxs[0];
-	};
-
-private:
-	VertexSet mVertSet;  // ordered list.
-	VertexVector mVtxs;  // set of vertices.
-	Tracker mTracker;
-};
-
-bool VertexLess::operator()(VertexID v1, VertexID v2) const
-{
-	const VertexPosition &a = Get(v1);
-	const VertexPosition &b = Get(v2);
-
-	int ixA = (int)(a.GetX() * 10000.0f);
-	int ixB = (int)(b.GetX() * 10000.0f);
-
-	if (ixA < ixB) return true;
-	if (ixA > ixB) return false;
-
-	int iyA = (int)(a.GetY() * 10000.0f);
-	int iyB = (int)(b.GetY() * 10000.0f);
-
-	if (iyA < iyB) return true;
-	if (iyA > iyB) return false;
-
-	int izA = (int)(a.GetZ() * 10000.0f);
-	int izB = (int)(b.GetZ() * 10000.0f);
-
-	if (izA < izB) return true;
-	if (izA > izB) return false;
-
-	return false;
-}
-
-}  // namespace Vlookup
-
-using namespace Vlookup;
-
-VertexLookup Vl_createVertexLookup(void)
-{
-	VertexLookup ret = new VertexPool<VertexPosition>;
-	return ret;
-}
-
-void Vl_releaseVertexLookup(VertexLookup vlook)
-{
-	VertexPool<VertexPosition> *vp = (VertexPool<VertexPosition> *)vlook;
-	delete vp;
-}
-
-unsigned int Vl_getIndex(VertexLookup vlook, const float *pos)  // get index.
-{
-	VertexPool<VertexPosition> *vp = (VertexPool<VertexPosition> *)vlook;
-	VertexPosition p(pos);
-	return vp->getVertex(p);
-}
-
-const float *Vl_getVertices(VertexLookup vlook)
-{
-	VertexPool<VertexPosition> *vp = (VertexPool<VertexPosition> *)vlook;
-	return vp->GetPos(0);
-}
-
-unsigned int Vl_getVcount(VertexLookup vlook)
-{
-	VertexPool<VertexPosition> *vp = (VertexPool<VertexPosition> *)vlook;
-	return vp->GetVertexCount();
-}

+ 0 - 115
ThirdParty/Bullet/Extras/ConvexDecomposition/vlookup.h

@@ -1,115 +0,0 @@
-#ifndef VLOOKUP_H
-
-#define VLOOKUP_H
-
-/*----------------------------------------------------------------------
-		Copyright (c) 2004 Open Dynamics Framework Group
-					www.physicstools.org
-		All rights reserved.
-
-		Redistribution and use in source and binary forms, with or without modification, are permitted provided
-		that the following conditions are met:
-
-		Redistributions of source code must retain the above copyright notice, this list of conditions
-		and the following disclaimer.
-
-		Redistributions in binary form must reproduce the above copyright notice,
-		this list of conditions and the following disclaimer in the documentation
-		and/or other materials provided with the distribution.
-
-		Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
-		be used to endorse or promote products derived from this software without specific prior written permission.
-
-		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-		INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-		DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-		EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-		IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-		THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------*/
-
-// http://codesuppository.blogspot.com
-//
-// mailto: [email protected]
-//
-// http://www.amillionpixels.us
-//
-
-// CodeSnippet provided by John W. Ratcliff
-// on March 23, 2006.
-//
-// mailto: [email protected]
-//
-// Personal website: http://jratcliffscarab.blogspot.com
-// Coding Website:   http://codesuppository.blogspot.com
-// FundRaising Blog: http://amillionpixels.blogspot.com
-// Fundraising site: http://www.amillionpixels.us
-// New Temple Site:  http://newtemple.blogspot.com
-//
-// This snippet shows how to 'hide' the complexity of
-// the STL by wrapping some useful piece of functionality
-// around a handful of discrete API calls.
-//
-// This API allows you to create an indexed triangle list
-// from a collection of raw input triangles.  Internally
-// it uses an STL set to build the lookup table very rapidly.
-//
-// Here is how you would use it to build an indexed triangle
-// list from a raw list of triangles.
-//
-// (1) create a 'VertexLookup' interface by calling
-//
-//     VertexLook vl = Vl_createVertexLookup();
-//
-// (2) For each vertice in each triangle call:
-//
-//     unsigned int i1 = Vl_getIndex(vl,p1);
-//     unsigned int i2 = Vl_getIndex(vl,p2);
-//     unsigned int i3 = Vl_getIndex(vl,p3);
-//
-//     save the 3 indices into your triangle list array.
-//
-// (3) Get the vertex array by calling:
-//
-//     const float *vertices = Vl_getVertices(vl);
-//
-// (4) Get the number of vertices so you can copy them into
-//     your own buffer.
-//     unsigned int vcount = Vl_getVcount(vl);
-//
-// (5) Release the VertexLookup interface when you are done with it.
-//     Vl_releaseVertexLookup(vl);
-//
-// Teaches the following lessons:
-//
-//    How to wrap the complexity of STL and C++ classes around a
-//    simple API interface.
-//
-//    How to use an STL set and custom comparator operator for
-//    a complex data type.
-//
-//    How to create a template class.
-//
-//    How to achieve significant performance improvements by
-//    taking advantage of built in STL containers in just
-//    a few lines of code.
-//
-//    You could easily modify this code to support other vertex
-//    formats with any number of interpolants.
-//
-//    Hide C++ classes from the rest of your application by
-//    keeping them in the CPP and wrapping them in a namespace
-// Uses an STL set to create an index table for a bunch of vertex positions
-// used typically to re-index a collection of raw triangle data.
-
-typedef void *VertexLookup;
-
-VertexLookup Vl_createVertexLookup(void);
-void Vl_releaseVertexLookup(VertexLookup vlook);
-
-unsigned int Vl_getIndex(VertexLookup vlook, const float *pos);  // get index.
-const float *Vl_getVertices(VertexLookup vlook);
-unsigned int Vl_getVcount(VertexLookup vlook);
-
-#endif

+ 0 - 40
ThirdParty/Bullet/Extras/GIMPACTUtils/CMakeLists.txt

@@ -1,40 +0,0 @@
-INCLUDE_DIRECTORIES(
-${BULLET_PHYSICS_SOURCE_DIR}/Extras/GIMPACT/include
-${BULLET_PHYSICS_SOURCE_DIR}/src
-${BULLET_PHYSICS_SOURCE_DIR}/Extras/GIMPACTUtils
-${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexDecomposition
-)
-
-ADD_LIBRARY(GIMPACTUtils
-btGImpactConvexDecompositionShape.cpp	btGImpactConvexDecompositionShape.h
-)
-SET_TARGET_PROPERTIES(GIMPACTUtils PROPERTIES VERSION ${BULLET_VERSION})
-SET_TARGET_PROPERTIES(GIMPACTUtils PROPERTIES SOVERSION ${BULLET_VERSION})
-
-IF (BUILD_SHARED_LIBS)
-  TARGET_LINK_LIBRARIES(GIMPACTUtils ConvexDecomposition BulletCollision)
-ENDIF (BUILD_SHARED_LIBS)
-
-IF (INSTALL_EXTRA_LIBS)
-	IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-		#FILES_MATCHING requires CMake 2.6
-		IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-			IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS GIMPACTUtils DESTINATION .)
-			ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS GIMPACTUtils 
-                                        RUNTIME DESTINATION bin
-                                        LIBRARY DESTINATION lib${LIB_SUFFIX}
-                                        ARCHIVE DESTINATION lib${LIB_SUFFIX})
-				INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h"  PATTERN
-".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
-			ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-		ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-
-		IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-			SET_TARGET_PROPERTIES(GIMPACTUtils PROPERTIES FRAMEWORK true)
-			SET_TARGET_PROPERTIES(GIMPACTUtils PROPERTIES PUBLIC_HEADER "btGImpactConvexDecompositionShape.h")
-		ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-	ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-ENDIF (INSTALL_EXTRA_LIBS)

+ 0 - 11
ThirdParty/Bullet/Extras/GIMPACTUtils/LICENSE.txt

@@ -1,11 +0,0 @@
-
-Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
-email: [email protected]
-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.

+ 0 - 218
ThirdParty/Bullet/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.cpp

@@ -1,218 +0,0 @@
-/*
-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: [email protected]
-
-
-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 "btGImpactConvexDecompositionShape.h"
-#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
-
-#include "ConvexBuilder.h"
-
-class GIM_ConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
-{
-protected:
-	btGImpactConvexDecompositionShape* m_compoundShape;
-
-	btAlignedObjectArray<btCollisionShape*> m_convexShapes;
-
-public:
-	int mBaseCount;
-	int mHullCount;
-	bool m_transformSubShapes;
-
-	GIM_ConvexDecomposition(btGImpactConvexDecompositionShape* compoundShape, bool transformSubShapes)
-	{
-		mBaseCount = 0;
-		mHullCount = 0;
-		m_compoundShape = compoundShape;
-		m_transformSubShapes = transformSubShapes;
-	}
-
-	virtual ~GIM_ConvexDecomposition()
-	{
-		int i;
-		for (i = 0; i < m_convexShapes.size(); i++)
-		{
-			btCollisionShape* shape = m_convexShapes[i];
-			delete shape;
-		}
-	}
-
-	virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult& result)
-	{
-		//calc centroid, to shift vertices around center of mass
-		btVector3 centroid(0, 0, 0);
-		btAlignedObjectArray<btVector3> vertices;
-
-		if (m_transformSubShapes)
-		{
-			//const unsigned int *src = result.mHullIndices;
-			for (unsigned int i = 0; i < result.mHullVcount; i++)
-			{
-				btVector3 vertex(result.mHullVertices[i * 3], result.mHullVertices[i * 3 + 1], result.mHullVertices[i * 3 + 2]);
-
-				centroid += vertex;
-			}
-			centroid *= 1.f / (float(result.mHullVcount));
-		}
-
-		// collect vertices
-		for (unsigned int i = 0; i < result.mHullVcount; i++)
-		{
-			btVector3 vertex(result.mHullVertices[i * 3], result.mHullVertices[i * 3 + 1], result.mHullVertices[i * 3 + 2]);
-
-			if (m_transformSubShapes)
-			{
-				vertex -= centroid;
-			}
-			vertices.push_back(vertex);
-		}
-
-		// build convex shape
-
-		btCollisionShape* convexShape = new btConvexHullShape(
-			&(vertices[0].getX()), vertices.size(), sizeof(btVector3));
-		m_convexShapes.push_back(convexShape);
-
-		convexShape->setMargin(m_compoundShape->getMargin());
-
-		if (m_transformSubShapes)
-		{
-			btTransform trans;
-			trans.setIdentity();
-			trans.setOrigin(centroid);
-
-			// add convex shape
-
-			m_compoundShape->addChildShape(trans, convexShape);
-		}
-		else
-		{
-			btTransform trans;
-			trans.setIdentity();
-			//trans.setOrigin(centroid);
-
-			// add convex shape
-
-			m_compoundShape->addChildShape(trans, convexShape);
-
-			//m_compoundShape->addChildShape(convexShape);
-		}
-	}
-
-	void processDecomposition(int part)
-	{
-		btGImpactMeshShapePart::TrimeshPrimitiveManager* trimeshInterface =
-			m_compoundShape->getTrimeshInterface(part);
-
-		trimeshInterface->lock();
-
-		//collect vertices
-		btAlignedObjectArray<float> vertices;
-		vertices.reserve(trimeshInterface->get_vertex_count() * 3);
-
-		for (int vi = 0; vi < trimeshInterface->get_vertex_count(); vi++)
-		{
-			btVector3 vec;
-			trimeshInterface->get_vertex(vi, vec);
-			vertices.push_back(vec[0]);
-			vertices.push_back(vec[1]);
-			vertices.push_back(vec[2]);
-		}
-
-		//collect indices
-		btAlignedObjectArray<unsigned int> indices;
-		indices.reserve(trimeshInterface->get_primitive_count() * 3);
-
-		for (int i = 0; i < trimeshInterface->get_primitive_count(); i++)
-		{
-			unsigned int i0, i1, i2;
-			trimeshInterface->get_indices(i, i0, i1, i2);
-			indices.push_back(i0);
-			indices.push_back(i1);
-			indices.push_back(i2);
-		}
-
-		trimeshInterface->unlock();
-
-		unsigned int depth = 5;
-		float cpercent = 5;
-		float ppercent = 15;
-		unsigned int maxv = 16;
-		float skinWidth = 0.0f;
-
-		ConvexDecomposition::DecompDesc desc;
-		desc.mVcount = trimeshInterface->get_vertex_count();
-		desc.mVertices = &vertices[0];
-		desc.mTcount = trimeshInterface->get_primitive_count();
-		desc.mIndices = &indices[0];
-		desc.mDepth = depth;
-		desc.mCpercent = cpercent;
-		desc.mPpercent = ppercent;
-		desc.mMaxVertices = maxv;
-		desc.mSkinWidth = skinWidth;
-		desc.mCallback = this;
-
-		//convexDecomposition.performConvexDecomposition(desc);
-
-		ConvexBuilder cb(desc.mCallback);
-		cb.process(desc);
-	}
-};
-
-void btGImpactConvexDecompositionShape::buildConvexDecomposition(bool transformSubShapes)
-{
-	m_decomposition = new GIM_ConvexDecomposition(this, transformSubShapes);
-
-	int part_count = m_trimeshInterfaces.size();
-	for (int i = 0; i < part_count; i++)
-	{
-		m_decomposition->processDecomposition(i);
-	}
-
-	postUpdate();
-}
-
-btGImpactConvexDecompositionShape::~btGImpactConvexDecompositionShape()
-{
-	delete m_decomposition;
-}
-void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const
-{
-	int part_count = m_trimeshInterfaces.size();
-	for (int part = 0; part < part_count; part++)
-	{
-		void* ptr = (void*)&m_trimeshInterfaces[part];
-
-		btGImpactMeshShapePart::TrimeshPrimitiveManager* trimeshInterface =
-			static_cast<btGImpactMeshShapePart::TrimeshPrimitiveManager*>(ptr);
-
-		trimeshInterface->lock();
-
-		btPrimitiveTriangle triangle;
-
-		int i = trimeshInterface->get_primitive_count();
-		while (i--)
-		{
-			trimeshInterface->get_primitive_triangle(i, triangle);
-			callback->processTriangle(triangle.m_vertices, part, i);
-		}
-
-		trimeshInterface->unlock();
-	}
-}

+ 0 - 79
ThirdParty/Bullet/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.h

@@ -1,79 +0,0 @@
-/*! \file btGImpactConvexDecompositionShape.h
-\author Francisco León Nájera
-*/
-/*
-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: [email protected]
-
-
-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.
-*/
-
-#ifndef GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
-#define GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
-
-#include "BulletCollision/Gimpact/btGImpactShape.h"  // box tree class
-
-//! This class creates a decomposition from a trimesh.
-/*!
-
-*/
-class btGImpactConvexDecompositionShape : public btGImpactCompoundShape
-{
-protected:
-	btAlignedObjectArray<btGImpactMeshShapePart::TrimeshPrimitiveManager> m_trimeshInterfaces;
-
-	class GIM_ConvexDecomposition* m_decomposition;
-
-	void buildConvexDecomposition(bool transformSubShapes);
-
-public:
-	btGImpactConvexDecompositionShape(
-		btStridingMeshInterface* meshInterface,
-		const btVector3& mesh_scale,
-		btScalar margin = btScalar(0.01), bool children_has_transform = true)
-		: btGImpactCompoundShape(children_has_transform)
-	{
-		m_collisionMargin = margin;
-
-		btGImpactMeshShapePart::TrimeshPrimitiveManager triInterface;
-		triInterface.m_meshInterface = meshInterface;
-		triInterface.m_scale = mesh_scale;
-		triInterface.m_margin = btScalar(1.0);
-
-		//add parts
-		int part_count = meshInterface->getNumSubParts();
-		for (int i = 0; i < part_count; i++)
-		{
-			triInterface.m_part = i;
-			m_trimeshInterfaces.push_back(triInterface);
-		}
-
-		m_decomposition = 0;
-
-		buildConvexDecomposition(children_has_transform);
-	}
-
-	virtual ~btGImpactConvexDecompositionShape();
-
-	SIMD_FORCE_INLINE btGImpactMeshShapePart::TrimeshPrimitiveManager* getTrimeshInterface(int part)
-	{
-		return &m_trimeshInterfaces[part];
-	}
-
-	virtual void processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
-};
-
-#endif  //GIMPACT_MESH_SHAPE_H

+ 0 - 55
ThirdParty/Bullet/Extras/HACD/CMakeLists.txt

@@ -1,55 +0,0 @@
-INCLUDE_DIRECTORIES(
- ${BULLET_PHYSICS_SOURCE_DIR}/Extras/HACD
-)
-
-SET(HACD_SRCS
-	hacdGraph.cpp
-	hacdHACD.cpp
-	hacdICHull.cpp
-	hacdManifoldMesh.cpp
-)
-
-SET(HACD_HDRS
-	hacdCircularList.h
-	hacdGraph.h
-	hacdHACD.h
-	hacdICHull.h
-	hacdManifoldMesh.h
-	hacdVector.h
-	hacdVersion.h
-	hacdCircularList.inl
-	hacdVector.inl
-)
-
-ADD_LIBRARY(HACD ${HACD_SRCS} ${HACD_HDRS})
-SET_TARGET_PROPERTIES(HACD PROPERTIES VERSION ${BULLET_VERSION})
-SET_TARGET_PROPERTIES(HACD PROPERTIES SOVERSION ${BULLET_VERSION})
-
-#IF (BUILD_SHARED_LIBS)
-#  TARGET_LINK_LIBRARIES(HACD BulletCollision LinearMath)
-#ENDIF (BUILD_SHARED_LIBS)
-
-IF (INSTALL_EXTRA_LIBS)
-	IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-		#FILES_MATCHING requires CMake 2.6
-		IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-			IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS HACD DESTINATION .)
-			ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS HACD
-                                        RUNTIME DESTINATION bin
-                                        LIBRARY DESTINATION lib${LIB_SUFFIX}
-                                        ARCHIVE DESTINATION lib${LIB_SUFFIX})
-
-				INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-					DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.inl" PATTERN
-					".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
-			ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-		ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-
-		IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-			SET_TARGET_PROPERTIES(HACD PROPERTIES FRAMEWORK true)
-			SET_TARGET_PROPERTIES(HACD PROPERTIES PUBLIC_HEADER "${HACD_HDRS}")
-		ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-	ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-ENDIF (INSTALL_EXTRA_LIBS)

+ 0 - 13
ThirdParty/Bullet/Extras/HACD/LICENSE.txt

@@ -1,13 +0,0 @@
-Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 86
ThirdParty/Bullet/Extras/HACD/hacdCircularList.h

@@ -1,86 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_CIRCULAR_LIST_H
-#define HACD_CIRCULAR_LIST_H
-#include <stdlib.h>
-#include "hacdVersion.h"
-namespace HACD
-{
-//!	CircularListElement class.
-template <typename T>
-class CircularListElement
-{
-public:
-	T& GetData() { return m_data; }
-	const T& GetData() const { return m_data; }
-	CircularListElement<T>*& GetNext() { return m_next; }
-	CircularListElement<T>*& GetPrev() { return m_prev; }
-	const CircularListElement<T>*& GetNext() const { return m_next; }
-	const CircularListElement<T>*& GetPrev() const { return m_prev; }
-	//!	Constructor
-	CircularListElement(const T& data) { m_data = data; }
-	CircularListElement(void) {}
-	//! Destructor
-	~CircularListElement(void) {}
-
-private:
-	T m_data;
-	CircularListElement<T>* m_next;
-	CircularListElement<T>* m_prev;
-
-	CircularListElement(const CircularListElement& rhs);
-};
-
-//!	CircularList class.
-template <typename T>
-class CircularList
-{
-public:
-	CircularListElement<T>*& GetHead() { return m_head; }
-	const CircularListElement<T>* GetHead() const { return m_head; }
-	bool IsEmpty() const { return (m_size == 0); }
-	size_t GetSize() const { return m_size; }
-	const T& GetData() const { return m_head->GetData(); }
-	T& GetData() { return m_head->GetData(); }
-	bool Delete();
-	bool Delete(CircularListElement<T>* element);
-	CircularListElement<T>* Add(const T* data = 0);
-	CircularListElement<T>* Add(const T& data);
-	bool Next();
-	bool Prev();
-	void Clear()
-	{
-		while (Delete())
-			;
-	};
-	const CircularList& operator=(const CircularList& rhs);
-	//!	Constructor
-	CircularList()
-	{
-		m_head = 0;
-		m_size = 0;
-	}
-	CircularList(const CircularList& rhs);
-	//! Destructor
-	virtual ~CircularList(void) { Clear(); };
-
-private:
-	CircularListElement<T>* m_head;  //!< a pointer to the head of the circular list
-	size_t m_size;                   //!< number of element in the circular list
-};
-}  // namespace HACD
-#include "hacdCircularList.inl"
-#endif

+ 0 - 163
ThirdParty/Bullet/Extras/HACD/hacdCircularList.inl

@@ -1,163 +0,0 @@
-#pragma once
-#ifndef HACD_CIRCULAR_LIST_INL
-#define HACD_CIRCULAR_LIST_INL
-#include<stdlib.h>
-#include "hacdVersion.h"
-namespace HACD
-{
-	template < typename T > 
-	inline bool CircularList<T>::Delete(CircularListElement<T> * element)
-	{
-        if (!element)
-        {
-            return false;
-        }
-		if (m_size > 1)
-		{
-			CircularListElement<T> * next = element->GetNext();
-			CircularListElement<T> * prev = element->GetPrev();
-			delete element;
-			m_size--;
-            if (element == m_head)
-            {
-                m_head = next;
-            }
-			next->GetPrev() = prev;
-			prev->GetNext() = next;
-			return true;
-		}
-		else if (m_size == 1)
-		{
-			delete m_head;
-			m_size--;
-			m_head = 0;
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-    
-	template < typename T > 
-	inline bool CircularList<T>::Delete()
-	{
-		if (m_size > 1)
-		{
-			CircularListElement<T> * next = m_head->GetNext();
-			CircularListElement<T> * prev = m_head->GetPrev();
-			delete m_head;
-			m_size--;
-			m_head = next;
-			next->GetPrev() = prev;
-			prev->GetNext() = next;
-			return true;
-		}
-		else if (m_size == 1)
-		{
-			delete m_head;
-			m_size--;
-			m_head = 0;
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	template < typename T > 
-	inline CircularListElement<T> * CircularList<T>::Add(const T * data)
-	{
-		if (m_size == 0)
-		{
-			if (data)
-			{
-				m_head = new CircularListElement<T>(*data);
-			}
-			else
-			{
-				m_head = new CircularListElement<T>();
-			}
-			m_head->GetNext() = m_head->GetPrev() = m_head;
-		}
-		else
-		{
-			CircularListElement<T> * next = m_head->GetNext();
-			CircularListElement<T> * element = m_head;
-			if (data)
-			{
-				m_head = new CircularListElement<T>(*data);
-			}
-			else
-			{
-				m_head = new CircularListElement<T>;
-			}
-			m_head->GetNext() = next;
-			m_head->GetPrev() = element;
-			element->GetNext() = m_head;
-			next->GetPrev() = m_head;
-		}
-		m_size++;
-		return m_head;
-	}
-	template < typename T > 
-	inline CircularListElement<T> * CircularList<T>::Add(const T & data)
-	{
-		const T * pData = &data;
-		return Add(pData);
-	}
-	template < typename T > 
-	inline bool CircularList<T>::Next()
-	{
-		if (m_size == 0)
-		{
-			return false;
-		}
-		m_head = m_head->GetNext();
-		return true;
-	}
-	template < typename T > 
-	inline bool CircularList<T>::Prev()
-	{
-		if (m_size == 0)
-		{
-			return false;
-		}
-		m_head = m_head->GetPrev();
-		return true;
-	}
-	template < typename T > 
-	inline CircularList<T>::CircularList(const CircularList& rhs)
-	{
-		if (rhs.m_size > 0)
-		{
-			CircularListElement<T> * current = rhs.m_head;
-			do
-			{
-				current = current->GetNext();
-				Add(current->GetData());
-			}
-			while ( current != rhs.m_head );
-		}
-	}
-    template < typename T > 
-	inline const CircularList<T>& CircularList<T>::operator=(const CircularList& rhs)
-	{
-        if (&rhs != this)
-        {
-            Clear();
-            if (rhs.m_size > 0)
-            {
-                CircularListElement<T> * current = rhs.m_head;
-                do
-                {
-                    current = current->GetNext();
-                    Add(current->GetData());
-                }
-                while ( current != rhs.m_head );
-            }
-        }
-        return (*this);
-	}
-}
-#endif

+ 0 - 290
ThirdParty/Bullet/Extras/HACD/hacdGraph.cpp

@@ -1,290 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "hacdGraph.h"
-namespace HACD
-{
-GraphEdge::GraphEdge()
-{
-	m_convexHull = 0;
-	m_v1 = -1;
-	m_v2 = -1;
-	m_name = -1;
-	m_error = 0;
-	m_surf = 0;
-	m_perimeter = 0;
-	m_concavity = 0;
-	m_volume = 0;
-	m_deleted = false;
-}
-
-GraphVertex::GraphVertex()
-{
-	m_convexHull = 0;
-	m_name = -1;
-	m_cc = -1;
-	m_error = 0;
-	m_surf = 0;
-	m_perimeter = 0;
-	m_concavity = 0;
-	m_volume = 0;
-	m_deleted = false;
-}
-
-bool GraphVertex::DeleteEdge(long name)
-{
-	std::set<long>::iterator it = m_edges.find(name);
-	if (it != m_edges.end())
-	{
-		m_edges.erase(it);
-		return true;
-	}
-	return false;
-}
-
-Graph::Graph()
-{
-	m_nV = 0;
-	m_nE = 0;
-	m_nCCs = 0;
-}
-
-Graph::~Graph()
-{
-}
-
-void Graph::Allocate(size_t nV, size_t nE)
-{
-	m_nV = nV;
-	m_edges.reserve(nE);
-	m_vertices.resize(nV);
-	for (size_t i = 0; i < nV; i++)
-	{
-		m_vertices[i].m_name = static_cast<long>(i);
-	}
-}
-
-long Graph::AddVertex()
-{
-	size_t name = m_vertices.size();
-	m_vertices.resize(name + 1);
-	m_vertices[name].m_name = static_cast<long>(name);
-	m_nV++;
-	return static_cast<long>(name);
-}
-
-long Graph::AddEdge(long v1, long v2)
-{
-	size_t name = m_edges.size();
-	m_edges.push_back(GraphEdge());
-	m_edges[name].m_name = static_cast<long>(name);
-	m_edges[name].m_v1 = v1;
-	m_edges[name].m_v2 = v2;
-	m_vertices[v1].AddEdge(static_cast<long>(name));
-	m_vertices[v2].AddEdge(static_cast<long>(name));
-	m_nE++;
-	return static_cast<long>(name);
-}
-
-bool Graph::DeleteEdge(long name)
-{
-	if (name < static_cast<long>(m_edges.size()))
-	{
-		long v1 = m_edges[name].m_v1;
-		long v2 = m_edges[name].m_v2;
-		m_edges[name].m_deleted = true;
-		m_vertices[v1].DeleteEdge(name);
-		m_vertices[v2].DeleteEdge(name);
-		delete m_edges[name].m_convexHull;
-		m_edges[name].m_distPoints.clear();
-		m_edges[name].m_boudaryEdges.clear();
-		m_edges[name].m_convexHull = 0;
-		m_nE--;
-		return true;
-	}
-	return false;
-}
-bool Graph::DeleteVertex(long name)
-{
-	if (name < static_cast<long>(m_vertices.size()))
-	{
-		m_vertices[name].m_deleted = true;
-		m_vertices[name].m_edges.clear();
-		m_vertices[name].m_ancestors = std::vector<long>();
-		delete m_vertices[name].m_convexHull;
-		m_vertices[name].m_distPoints.clear();
-		m_vertices[name].m_boudaryEdges.clear();
-		m_vertices[name].m_convexHull = 0;
-		m_nV--;
-		return true;
-	}
-	return false;
-}
-bool Graph::EdgeCollapse(long v1, long v2)
-{
-	long edgeToDelete = GetEdgeID(v1, v2);
-	if (edgeToDelete >= 0)
-	{
-		// delete the edge (v1, v2)
-		DeleteEdge(edgeToDelete);
-		// add v2 to v1 ancestors
-		m_vertices[v1].m_ancestors.push_back(v2);
-		// add v2's ancestors to v1's ancestors
-		m_vertices[v1].m_ancestors.insert(m_vertices[v1].m_ancestors.begin(),
-										  m_vertices[v2].m_ancestors.begin(),
-										  m_vertices[v2].m_ancestors.end());
-		// update adjacency information
-		std::set<long>& v1Edges = m_vertices[v1].m_edges;
-		std::set<long>::const_iterator ed(m_vertices[v2].m_edges.begin());
-		std::set<long>::const_iterator itEnd(m_vertices[v2].m_edges.end());
-		long b = -1;
-		for (; ed != itEnd; ++ed)
-		{
-			if (m_edges[*ed].m_v1 == v2)
-			{
-				b = m_edges[*ed].m_v2;
-			}
-			else
-			{
-				b = m_edges[*ed].m_v1;
-			}
-			if (GetEdgeID(v1, b) >= 0)
-			{
-				m_edges[*ed].m_deleted = true;
-				m_vertices[b].DeleteEdge(*ed);
-				m_nE--;
-			}
-			else
-			{
-				m_edges[*ed].m_v1 = v1;
-				m_edges[*ed].m_v2 = b;
-				v1Edges.insert(*ed);
-			}
-		}
-		// delete the vertex v2
-		DeleteVertex(v2);
-		return true;
-	}
-	return false;
-}
-
-long Graph::GetEdgeID(long v1, long v2) const
-{
-	if (v1 < static_cast<long>(m_vertices.size()) && !m_vertices[v1].m_deleted)
-	{
-		std::set<long>::const_iterator ed(m_vertices[v1].m_edges.begin());
-		std::set<long>::const_iterator itEnd(m_vertices[v1].m_edges.end());
-		for (; ed != itEnd; ++ed)
-		{
-			if ((m_edges[*ed].m_v1 == v2) ||
-				(m_edges[*ed].m_v2 == v2))
-			{
-				return m_edges[*ed].m_name;
-			}
-		}
-	}
-	return -1;
-}
-
-void Graph::Print() const
-{
-	std::cout << "-----------------------------" << std::endl;
-	std::cout << "vertices (" << m_nV << ")" << std::endl;
-	for (size_t v = 0; v < m_vertices.size(); ++v)
-	{
-		const GraphVertex& currentVertex = m_vertices[v];
-		if (!m_vertices[v].m_deleted)
-		{
-			std::cout << currentVertex.m_name << "\t";
-			std::set<long>::const_iterator ed(currentVertex.m_edges.begin());
-			std::set<long>::const_iterator itEnd(currentVertex.m_edges.end());
-			for (; ed != itEnd; ++ed)
-			{
-				std::cout << "(" << m_edges[*ed].m_v1 << "," << m_edges[*ed].m_v2 << ") ";
-			}
-			std::cout << std::endl;
-		}
-	}
-
-	std::cout << "vertices (" << m_nE << ")" << std::endl;
-	for (size_t e = 0; e < m_edges.size(); ++e)
-	{
-		const GraphEdge& currentEdge = m_edges[e];
-		if (!m_edges[e].m_deleted)
-		{
-			std::cout << currentEdge.m_name << "\t("
-					  << m_edges[e].m_v1 << ","
-					  << m_edges[e].m_v2 << ") " << std::endl;
-		}
-	}
-}
-void Graph::Clear()
-{
-	m_vertices.clear();
-	m_edges.clear();
-	m_nV = 0;
-	m_nE = 0;
-}
-
-long Graph::ExtractCCs()
-{
-	// all CCs to -1
-	for (size_t v = 0; v < m_vertices.size(); ++v)
-	{
-		if (!m_vertices[v].m_deleted)
-		{
-			m_vertices[v].m_cc = -1;
-		}
-	}
-
-	// we get the CCs
-	m_nCCs = 0;
-	long v2 = -1;
-	std::vector<long> temp;
-	for (size_t v = 0; v < m_vertices.size(); ++v)
-	{
-		if (!m_vertices[v].m_deleted && m_vertices[v].m_cc == -1)
-		{
-			m_vertices[v].m_cc = static_cast<long>(m_nCCs);
-			temp.clear();
-			temp.push_back(m_vertices[v].m_name);
-			while (temp.size())
-			{
-				long vertex = temp[temp.size() - 1];
-				temp.pop_back();
-				std::set<long>::const_iterator ed(m_vertices[vertex].m_edges.begin());
-				std::set<long>::const_iterator itEnd(m_vertices[vertex].m_edges.end());
-				for (; ed != itEnd; ++ed)
-				{
-					if (m_edges[*ed].m_v1 == vertex)
-					{
-						v2 = m_edges[*ed].m_v2;
-					}
-					else
-					{
-						v2 = m_edges[*ed].m_v1;
-					}
-					if (!m_vertices[v2].m_deleted && m_vertices[v2].m_cc == -1)
-					{
-						m_vertices[v2].m_cc = static_cast<long>(m_nCCs);
-						temp.push_back(v2);
-					}
-				}
-			}
-			m_nCCs++;
-		}
-	}
-	return static_cast<long>(m_nCCs);
-}
-}  // namespace HACD

+ 0 - 119
ThirdParty/Bullet/Extras/HACD/hacdGraph.h

@@ -1,119 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_GRAPH_H
-#define HACD_GRAPH_H
-#include "hacdVersion.h"
-#include "hacdVector.h"
-#include "hacdICHull.h"
-#include <map>
-#include <vector>
-#include <set>
-
-namespace HACD
-{
-class GraphVertex;
-class GraphEdge;
-class Graph;
-class HACD;
-
-class GraphVertex
-{
-public:
-	bool AddEdge(long name)
-	{
-		m_edges.insert(name);
-		return true;
-	}
-	bool DeleteEdge(long name);
-	GraphVertex();
-	~GraphVertex() { delete m_convexHull; };
-
-private:
-	long m_name;
-	long m_cc;
-	std::set<long> m_edges;
-	bool m_deleted;
-	std::vector<long> m_ancestors;
-	std::map<long, DPoint> m_distPoints;
-
-	Real m_error;
-	double m_surf;
-	double m_volume;
-	double m_perimeter;
-	double m_concavity;
-	ICHull* m_convexHull;
-	std::set<unsigned long long> m_boudaryEdges;
-
-	friend class GraphEdge;
-	friend class Graph;
-	friend class HACD;
-};
-
-class GraphEdge
-{
-public:
-	GraphEdge();
-	~GraphEdge() { delete m_convexHull; };
-
-private:
-	long m_name;
-	long m_v1;
-	long m_v2;
-	std::map<long, DPoint> m_distPoints;
-	Real m_error;
-	double m_surf;
-	double m_volume;
-	double m_perimeter;
-	double m_concavity;
-	ICHull* m_convexHull;
-	std::set<unsigned long long> m_boudaryEdges;
-	bool m_deleted;
-
-	friend class GraphVertex;
-	friend class Graph;
-	friend class HACD;
-};
-
-class Graph
-{
-public:
-	size_t GetNEdges() const { return m_nE; }
-	size_t GetNVertices() const { return m_nV; }
-	bool EdgeCollapse(long v1, long v2);
-	long AddVertex();
-	long AddEdge(long v1, long v2);
-	bool DeleteEdge(long name);
-	bool DeleteVertex(long name);
-	long GetEdgeID(long v1, long v2) const;
-	void Clear();
-	void Print() const;
-	long ExtractCCs();
-
-	Graph();
-	virtual ~Graph();
-	void Allocate(size_t nV, size_t nE);
-
-private:
-	size_t m_nCCs;
-	size_t m_nV;
-	size_t m_nE;
-	std::vector<GraphEdge> m_edges;
-	std::vector<GraphVertex> m_vertices;
-
-	friend class HACD;
-};
-}  // namespace HACD
-#endif

+ 0 - 851
ThirdParty/Bullet/Extras/HACD/hacdHACD.cpp

@@ -1,851 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif  //_CRT_SECURE_NO_WARNINGS
-
-#include <sstream>
-#include "hacdGraph.h"
-#include "hacdHACD.h"
-#include "hacdICHull.h"
-#include <string.h>
-#include <algorithm>
-#include <iterator>
-#include <limits>
-#include "assert.h"
-
-bool gCancelRequest = false;
-namespace HACD
-{
-double HACD::Concavity(ICHull& ch, std::map<long, DPoint>& distPoints)
-{
-	double concavity = 0.0;
-	double distance = 0.0;
-	std::map<long, DPoint>::iterator itDP(distPoints.begin());
-	std::map<long, DPoint>::iterator itDPEnd(distPoints.end());
-	for (; itDP != itDPEnd; ++itDP)
-	{
-		if (!(itDP->second).m_computed)
-		{
-			if (itDP->first >= 0)
-			{
-				distance = ch.ComputeDistance(itDP->first, m_points[itDP->first], m_normals[itDP->first], (itDP->second).m_computed, true);
-			}
-			else
-			{
-				distance = ch.ComputeDistance(itDP->first, m_facePoints[-itDP->first - 1], m_faceNormals[-itDP->first - 1], (itDP->second).m_computed, true);
-			}
-		}
-		else
-		{
-			distance = (itDP->second).m_dist;
-		}
-		if (concavity < distance)
-		{
-			concavity = distance;
-		}
-	}
-	return concavity;
-}
-
-void HACD::CreateGraph()
-{
-	// vertex to triangle adjacency information
-	std::vector<std::set<long> > vertexToTriangles;
-	vertexToTriangles.resize(m_nPoints);
-	for (size_t t = 0; t < m_nTriangles; ++t)
-	{
-		vertexToTriangles[m_triangles[t].X()].insert(static_cast<long>(t));
-		vertexToTriangles[m_triangles[t].Y()].insert(static_cast<long>(t));
-		vertexToTriangles[m_triangles[t].Z()].insert(static_cast<long>(t));
-	}
-
-	m_graph.Clear();
-	m_graph.Allocate(m_nTriangles, 5 * m_nTriangles);
-	unsigned long long tr1[3];
-	unsigned long long tr2[3];
-	long i1, j1, k1, i2, j2, k2;
-	long t1, t2;
-	for (size_t v = 0; v < m_nPoints; v++)
-	{
-		std::set<long>::const_iterator it1(vertexToTriangles[v].begin()), itEnd(vertexToTriangles[v].end());
-		for (; it1 != itEnd; ++it1)
-		{
-			t1 = *it1;
-			i1 = m_triangles[t1].X();
-			j1 = m_triangles[t1].Y();
-			k1 = m_triangles[t1].Z();
-			tr1[0] = GetEdgeIndex(i1, j1);
-			tr1[1] = GetEdgeIndex(j1, k1);
-			tr1[2] = GetEdgeIndex(k1, i1);
-			std::set<long>::const_iterator it2(it1);
-			for (++it2; it2 != itEnd; ++it2)
-			{
-				t2 = *it2;
-				i2 = m_triangles[t2].X();
-				j2 = m_triangles[t2].Y();
-				k2 = m_triangles[t2].Z();
-				tr2[0] = GetEdgeIndex(i2, j2);
-				tr2[1] = GetEdgeIndex(j2, k2);
-				tr2[2] = GetEdgeIndex(k2, i2);
-				int shared = 0;
-				for (int i = 0; i < 3; ++i)
-				{
-					for (int j = 0; j < 3; ++j)
-					{
-						if (tr1[i] == tr2[j])
-						{
-							shared++;
-						}
-					}
-				}
-				if (shared == 1)  // two triangles are connected if they share exactly one edge
-				{
-					m_graph.AddEdge(t1, t2);
-				}
-			}
-		}
-	}
-	if (m_ccConnectDist >= 0.0)
-	{
-		m_graph.ExtractCCs();
-		if (m_graph.m_nCCs > 1)
-		{
-			std::vector<std::set<long> > cc2V;
-			cc2V.resize(m_graph.m_nCCs);
-			long cc;
-			for (size_t t = 0; t < m_nTriangles; ++t)
-			{
-				cc = m_graph.m_vertices[t].m_cc;
-				cc2V[cc].insert(m_triangles[t].X());
-				cc2V[cc].insert(m_triangles[t].Y());
-				cc2V[cc].insert(m_triangles[t].Z());
-			}
-
-			for (size_t cc1 = 0; cc1 < m_graph.m_nCCs; ++cc1)
-			{
-				for (size_t cc2 = cc1 + 1; cc2 < m_graph.m_nCCs; ++cc2)
-				{
-					std::set<long>::const_iterator itV1(cc2V[cc1].begin()), itVEnd1(cc2V[cc1].end());
-					for (; itV1 != itVEnd1; ++itV1)
-					{
-						double distC1C2 = std::numeric_limits<double>::max();
-						double dist;
-						t1 = -1;
-						t2 = -1;
-						std::set<long>::const_iterator itV2(cc2V[cc2].begin()), itVEnd2(cc2V[cc2].end());
-						for (; itV2 != itVEnd2; ++itV2)
-						{
-							dist = (m_points[*itV1] - m_points[*itV2]).GetNorm();
-							if (dist < distC1C2)
-							{
-								distC1C2 = dist;
-								t1 = *vertexToTriangles[*itV1].begin();
-
-								std::set<long>::const_iterator it2(vertexToTriangles[*itV2].begin()),
-									it2End(vertexToTriangles[*itV2].end());
-								t2 = -1;
-								for (; it2 != it2End; ++it2)
-								{
-									if (*it2 != t1)
-									{
-										t2 = *it2;
-										break;
-									}
-								}
-							}
-						}
-						if (distC1C2 <= m_ccConnectDist && t1 > 0 && t2 > 0)
-						{
-							m_graph.AddEdge(t1, t2);
-						}
-					}
-				}
-			}
-		}
-	}
-}
-void HACD::InitializeDualGraph()
-{
-	long i, j, k;
-	Vec3<Real> u, v, w, normal;
-	delete[] m_normals;
-	m_normals = new Vec3<Real>[m_nPoints];
-	if (m_addFacesPoints)
-	{
-		delete[] m_facePoints;
-		delete[] m_faceNormals;
-		m_facePoints = new Vec3<Real>[m_nTriangles];
-		m_faceNormals = new Vec3<Real>[m_nTriangles];
-	}
-	memset(m_normals, 0, sizeof(Vec3<Real>) * m_nPoints);
-	for (unsigned long f = 0; f < m_nTriangles; f++)
-	{
-		if (m_callBack) (*m_callBack)("+ InitializeDualGraph\n", f, m_nTriangles, 0);
-
-		if (gCancelRequest)
-			return;
-
-		i = m_triangles[f].X();
-		j = m_triangles[f].Y();
-		k = m_triangles[f].Z();
-
-		m_graph.m_vertices[f].m_distPoints[i].m_distOnly = false;
-		m_graph.m_vertices[f].m_distPoints[j].m_distOnly = false;
-		m_graph.m_vertices[f].m_distPoints[k].m_distOnly = false;
-
-		ICHull* ch = new ICHull;
-		m_graph.m_vertices[f].m_convexHull = ch;
-		ch->AddPoint(m_points[i], i);
-		ch->AddPoint(m_points[j], j);
-		ch->AddPoint(m_points[k], k);
-		ch->SetDistPoints(&m_graph.m_vertices[f].m_distPoints);
-
-		u = m_points[j] - m_points[i];
-		v = m_points[k] - m_points[i];
-		w = m_points[k] - m_points[j];
-		normal = u ^ v;
-
-		m_normals[i] += normal;
-		m_normals[j] += normal;
-		m_normals[k] += normal;
-
-		m_graph.m_vertices[f].m_surf = normal.GetNorm();
-		m_graph.m_vertices[f].m_perimeter = u.GetNorm() + v.GetNorm() + w.GetNorm();
-
-		normal.Normalize();
-
-		m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex(i, j));
-		m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex(j, k));
-		m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex(k, i));
-		if (m_addFacesPoints)
-		{
-			m_faceNormals[f] = normal;
-			m_facePoints[f] = (m_points[i] + m_points[j] + m_points[k]) / 3.0;
-			m_graph.m_vertices[f].m_distPoints[-static_cast<long>(f) - 1].m_distOnly = true;
-		}
-		if (m_addExtraDistPoints)
-		{  // we need a kd-tree structure to accelerate this part!
-			long i1, j1, k1;
-			Vec3<Real> u1, v1, normal1;
-			normal = -normal;
-			double distance = 0.0;
-			double distMin = 0.0;
-			size_t faceIndex = m_nTriangles;
-			Vec3<Real> seedPoint((m_points[i] + m_points[j] + m_points[k]) / 3.0);
-			long nhit = 0;
-			for (size_t f1 = 0; f1 < m_nTriangles; f1++)
-			{
-				i1 = m_triangles[f1].X();
-				j1 = m_triangles[f1].Y();
-				k1 = m_triangles[f1].Z();
-				u1 = m_points[j1] - m_points[i1];
-				v1 = m_points[k1] - m_points[i1];
-				normal1 = (u1 ^ v1);
-				if (normal * normal1 > 0.0)
-				{
-					nhit = IntersectRayTriangle(Vec3<double>(seedPoint.X(), seedPoint.Y(), seedPoint.Z()),
-												Vec3<double>(normal.X(), normal.Y(), normal.Z()),
-												Vec3<double>(m_points[i1].X(), m_points[i1].Y(), m_points[i1].Z()),
-												Vec3<double>(m_points[j1].X(), m_points[j1].Y(), m_points[j1].Z()),
-												Vec3<double>(m_points[k1].X(), m_points[k1].Y(), m_points[k1].Z()),
-												distance);
-					if ((nhit == 1) && ((distMin > distance) || (faceIndex == m_nTriangles)))
-					{
-						distMin = distance;
-						faceIndex = f1;
-					}
-				}
-			}
-			if (faceIndex < m_nTriangles)
-			{
-				i1 = m_triangles[faceIndex].X();
-				j1 = m_triangles[faceIndex].Y();
-				k1 = m_triangles[faceIndex].Z();
-				m_graph.m_vertices[f].m_distPoints[i1].m_distOnly = true;
-				m_graph.m_vertices[f].m_distPoints[j1].m_distOnly = true;
-				m_graph.m_vertices[f].m_distPoints[k1].m_distOnly = true;
-				if (m_addFacesPoints)
-				{
-					m_graph.m_vertices[f].m_distPoints[-static_cast<long>(faceIndex) - 1].m_distOnly = true;
-				}
-			}
-		}
-	}
-	for (size_t v = 0; v < m_nPoints; v++)
-	{
-		m_normals[v].Normalize();
-	}
-}
-
-void HACD::NormalizeData()
-{
-	if (m_nPoints == 0)
-	{
-		return;
-	}
-	m_barycenter = m_points[0];
-	Vec3<Real> min = m_points[0];
-	Vec3<Real> max = m_points[0];
-	Real x, y, z;
-	for (size_t v = 1; v < m_nPoints; v++)
-	{
-		m_barycenter += m_points[v];
-		x = m_points[v].X();
-		y = m_points[v].Y();
-		z = m_points[v].Z();
-		if (x < min.X())
-			min.X() = x;
-		else if (x > max.X())
-			max.X() = x;
-		if (y < min.Y())
-			min.Y() = y;
-		else if (y > max.Y())
-			max.Y() = y;
-		if (z < min.Z())
-			min.Z() = z;
-		else if (z > max.Z())
-			max.Z() = z;
-	}
-	m_barycenter /= static_cast<Real>(m_nPoints);
-	m_diag = (max - min).GetNorm();
-	const Real invDiag = static_cast<Real>(2.0 * m_scale / m_diag);
-	if (m_diag != 0.0)
-	{
-		for (size_t v = 0; v < m_nPoints; v++)
-		{
-			m_points[v] = (m_points[v] - m_barycenter) * invDiag;
-		}
-	}
-}
-void HACD::DenormalizeData()
-{
-	if (m_nPoints == 0)
-	{
-		return;
-	}
-	if (m_diag != 0.0)
-	{
-		const Real diag = static_cast<Real>(m_diag / (2.0 * m_scale));
-		for (size_t v = 0; v < m_nPoints; v++)
-		{
-			m_points[v] = m_points[v] * diag + m_barycenter;
-		}
-	}
-}
-HACD::HACD(void)
-{
-	m_convexHulls = 0;
-	m_triangles = 0;
-	m_points = 0;
-	m_normals = 0;
-	m_nTriangles = 0;
-	m_nPoints = 0;
-	m_nClusters = 0;
-	m_concavity = 0.0;
-	m_diag = 1.0;
-	m_barycenter = Vec3<Real>(0.0, 0.0, 0.0);
-	m_alpha = 0.1;
-	m_beta = 0.1;
-	m_nVerticesPerCH = 30;
-	m_callBack = 0;
-	m_addExtraDistPoints = false;
-	m_addNeighboursDistPoints = false;
-	m_scale = 1000.0;
-	m_partition = 0;
-	m_nMinClusters = 3;
-	m_facePoints = 0;
-	m_faceNormals = 0;
-	m_ccConnectDist = 30;
-}
-HACD::~HACD(void)
-{
-	delete[] m_normals;
-	delete[] m_convexHulls;
-	delete[] m_partition;
-	delete[] m_facePoints;
-	delete[] m_faceNormals;
-}
-int iteration = 0;
-void HACD::ComputeEdgeCost(size_t e)
-{
-	GraphEdge& gE = m_graph.m_edges[e];
-	long v1 = gE.m_v1;
-	long v2 = gE.m_v2;
-
-	if (m_graph.m_vertices[v2].m_distPoints.size() > m_graph.m_vertices[v1].m_distPoints.size())
-	{
-		gE.m_v1 = v2;
-		gE.m_v2 = v1;
-		//std::swap<long>(v1, v2);
-		std::swap(v1, v2);
-	}
-	GraphVertex& gV1 = m_graph.m_vertices[v1];
-	GraphVertex& gV2 = m_graph.m_vertices[v2];
-
-	// delete old convex-hull
-	delete gE.m_convexHull;
-	// create the edge's convex-hull
-	ICHull* ch = new ICHull;
-	gE.m_convexHull = ch;
-	(*ch) = (*gV1.m_convexHull);
-
-	// update distPoints
-	gE.m_distPoints = gV1.m_distPoints;
-	std::map<long, DPoint>::iterator itDP(gV2.m_distPoints.begin());
-	std::map<long, DPoint>::iterator itDPEnd(gV2.m_distPoints.end());
-	std::map<long, DPoint>::iterator itDP1;
-
-	for (; itDP != itDPEnd; ++itDP)
-	{
-		itDP1 = gE.m_distPoints.find(itDP->first);
-		if (itDP1 == gE.m_distPoints.end())
-		{
-			gE.m_distPoints[itDP->first].m_distOnly = (itDP->second).m_distOnly;
-			if (!(itDP->second).m_distOnly)
-			{
-				ch->AddPoint(m_points[itDP->first], itDP->first);
-			}
-		}
-		else
-		{
-			if ((itDP1->second).m_distOnly && !(itDP->second).m_distOnly)
-			{
-				gE.m_distPoints[itDP->first].m_distOnly = false;
-				ch->AddPoint(m_points[itDP->first], itDP->first);
-			}
-		}
-	}
-
-	ch->SetDistPoints(&gE.m_distPoints);
-	// create the convex-hull
-	while (ch->Process() == ICHullErrorInconsistent)  // if we face problems when constructing the visual-hull. really ugly!!!!
-	{
-		//			if (m_callBack) (*m_callBack)("\t Problem with convex-hull construction [HACD::ComputeEdgeCost]\n", 0.0, 0.0, 0);
-		ch = new ICHull;
-		CircularList<TMMVertex>& verticesCH = (gE.m_convexHull)->GetMesh().m_vertices;
-		size_t nV = verticesCH.GetSize();
-		long ptIndex = 0;
-		verticesCH.Next();
-		for (size_t v = 1; v < nV; ++v)
-		{
-			ptIndex = verticesCH.GetHead()->GetData().m_name;
-			if (ptIndex != ICHull::sc_dummyIndex /* && ptIndex < m_nPoints*/)
-				ch->AddPoint(m_points[ptIndex], ptIndex);
-			verticesCH.Next();
-		}
-		delete gE.m_convexHull;
-		gE.m_convexHull = ch;
-	}
-	double volume = 0.0;
-	double concavity = 0.0;
-	if (ch->IsFlat())
-	{
-		bool insideHull;
-		std::map<long, DPoint>::iterator itDP(gE.m_distPoints.begin());
-		std::map<long, DPoint>::iterator itDPEnd(gE.m_distPoints.end());
-		for (; itDP != itDPEnd; ++itDP)
-		{
-			if (itDP->first >= 0)
-			{
-				concavity = std::max<double>(concavity, ch->ComputeDistance(itDP->first, m_points[itDP->first], m_normals[itDP->first], insideHull, false));
-			}
-		}
-	}
-	else
-	{
-		if (m_addNeighboursDistPoints)
-		{  // add distance points from adjacent clusters
-			std::set<long> eEdges;
-			std::set_union(gV1.m_edges.begin(),
-						   gV1.m_edges.end(),
-						   gV2.m_edges.begin(),
-						   gV2.m_edges.end(),
-						   std::inserter(eEdges, eEdges.begin()));
-
-			std::set<long>::const_iterator ed(eEdges.begin());
-			std::set<long>::const_iterator itEnd(eEdges.end());
-			long a, b, c;
-			for (; ed != itEnd; ++ed)
-			{
-				a = m_graph.m_edges[*ed].m_v1;
-				b = m_graph.m_edges[*ed].m_v2;
-				if (a != v2 && a != v1)
-				{
-					c = a;
-				}
-				else if (b != v2 && b != v1)
-				{
-					c = b;
-				}
-				else
-				{
-					c = -1;
-				}
-				if (c > 0)
-				{
-					GraphVertex& gVC = m_graph.m_vertices[c];
-					std::map<long, DPoint>::iterator itDP(gVC.m_distPoints.begin());
-					std::map<long, DPoint>::iterator itDPEnd(gVC.m_distPoints.end());
-					std::map<long, DPoint>::iterator itDP1;
-					for (; itDP != itDPEnd; ++itDP)
-					{
-						itDP1 = gE.m_distPoints.find(itDP->first);
-						if (itDP1 == gE.m_distPoints.end())
-						{
-							if (itDP->first >= 0 && itDP1 == gE.m_distPoints.end() && ch->IsInside(m_points[itDP->first]))
-							{
-								gE.m_distPoints[itDP->first].m_distOnly = true;
-							}
-							else if (itDP->first < 0 && ch->IsInside(m_facePoints[-itDP->first - 1]))
-							{
-								gE.m_distPoints[itDP->first].m_distOnly = true;
-							}
-						}
-					}
-				}
-			}
-		}
-		concavity = Concavity(*ch, gE.m_distPoints);
-	}
-
-	// compute boudary edges
-	double perimeter = 0.0;
-	double surf = 1.0;
-	if (m_alpha > 0.0)
-	{
-		gE.m_boudaryEdges.clear();
-		std::set_symmetric_difference(gV1.m_boudaryEdges.begin(),
-									  gV1.m_boudaryEdges.end(),
-									  gV2.m_boudaryEdges.begin(),
-									  gV2.m_boudaryEdges.end(),
-									  std::inserter(gE.m_boudaryEdges,
-													gE.m_boudaryEdges.begin()));
-
-		std::set<unsigned long long>::const_iterator itBE(gE.m_boudaryEdges.begin());
-		std::set<unsigned long long>::const_iterator itBEEnd(gE.m_boudaryEdges.end());
-		for (; itBE != itBEEnd; ++itBE)
-		{
-			perimeter += (m_points[static_cast<long>((*itBE) >> 32)] -
-						  m_points[static_cast<long>((*itBE) & 0xFFFFFFFFULL)])
-							 .GetNorm();
-		}
-		surf = gV1.m_surf + gV2.m_surf;
-	}
-	double ratio = perimeter * perimeter / (4.0 * sc_pi * surf);
-	gE.m_volume = (m_beta == 0.0) ? 0.0 : ch->ComputeVolume() / pow(m_scale, 3.0);  // cluster's volume
-	gE.m_surf = surf;                                                               // cluster's area
-	gE.m_perimeter = perimeter;                                                     // cluster's perimeter
-	gE.m_concavity = concavity;                                                     // cluster's concavity
-	gE.m_error = static_cast<Real>(concavity + m_alpha * ratio + m_beta * volume);  // cluster's priority
-}
-bool HACD::InitializePriorityQueue()
-{
-	m_pqueue.reserve(m_graph.m_nE + 100);
-	for (size_t e = 0; e < m_graph.m_nE; ++e)
-	{
-		ComputeEdgeCost(static_cast<long>(e));
-		m_pqueue.push(GraphEdgePriorityQueue(static_cast<long>(e), m_graph.m_edges[e].m_error));
-	}
-	return true;
-}
-void HACD::Simplify()
-{
-	long v1 = -1;
-	long v2 = -1;
-	double progressOld = -1.0;
-	double progress = 0.0;
-	double globalConcavity = 0.0;
-	char msg[1024];
-	double ptgStep = 1.0;
-	while ((globalConcavity < m_concavity) &&
-		   (m_graph.GetNVertices() > m_nMinClusters) &&
-		   (m_graph.GetNEdges() > 0))
-	{
-		progress = 100.0 - m_graph.GetNVertices() * 100.0 / m_nTriangles;
-		if (fabs(progress - progressOld) > ptgStep && m_callBack)
-		{
-			sprintf(msg, "%3.2f %% V = %lu \t C = %f \t \t \r", progress, static_cast<unsigned long>(m_graph.GetNVertices()), globalConcavity);
-			(*m_callBack)(msg, progress, globalConcavity, m_graph.GetNVertices());
-			progressOld = progress;
-			if (progress > 99.0)
-			{
-				ptgStep = 0.01;
-			}
-			else if (progress > 90.0)
-			{
-				ptgStep = 0.1;
-			}
-		}
-
-		GraphEdgePriorityQueue currentEdge(0, 0.0);
-		bool done = false;
-		do
-		{
-			done = false;
-			if (m_pqueue.size() == 0)
-			{
-				done = true;
-				break;
-			}
-			currentEdge = m_pqueue.top();
-			m_pqueue.pop();
-		} while (m_graph.m_edges[currentEdge.m_name].m_deleted ||
-				 m_graph.m_edges[currentEdge.m_name].m_error != currentEdge.m_priority);
-
-		if (m_graph.m_edges[currentEdge.m_name].m_concavity < m_concavity && !done)
-		{
-			globalConcavity = std::max<double>(globalConcavity, m_graph.m_edges[currentEdge.m_name].m_concavity);
-			v1 = m_graph.m_edges[currentEdge.m_name].m_v1;
-			v2 = m_graph.m_edges[currentEdge.m_name].m_v2;
-			// update vertex info
-			m_graph.m_vertices[v1].m_error = m_graph.m_edges[currentEdge.m_name].m_error;
-			m_graph.m_vertices[v1].m_surf = m_graph.m_edges[currentEdge.m_name].m_surf;
-			m_graph.m_vertices[v1].m_volume = m_graph.m_edges[currentEdge.m_name].m_volume;
-			m_graph.m_vertices[v1].m_concavity = m_graph.m_edges[currentEdge.m_name].m_concavity;
-			m_graph.m_vertices[v1].m_perimeter = m_graph.m_edges[currentEdge.m_name].m_perimeter;
-			m_graph.m_vertices[v1].m_distPoints = m_graph.m_edges[currentEdge.m_name].m_distPoints;
-			(*m_graph.m_vertices[v1].m_convexHull) = (*m_graph.m_edges[currentEdge.m_name].m_convexHull);
-			(m_graph.m_vertices[v1].m_convexHull)->SetDistPoints(&(m_graph.m_vertices[v1].m_distPoints));
-			m_graph.m_vertices[v1].m_boudaryEdges = m_graph.m_edges[currentEdge.m_name].m_boudaryEdges;
-
-			// We apply the optimal ecol
-			//				std::cout << "v1 " << v1 << " v2 " << v2 << std::endl;
-			m_graph.EdgeCollapse(v1, v2);
-			// recompute the adjacent edges costs
-			std::set<long>::const_iterator itE(m_graph.m_vertices[v1].m_edges.begin()),
-				itEEnd(m_graph.m_vertices[v1].m_edges.end());
-			for (; itE != itEEnd; ++itE)
-			{
-				size_t e = *itE;
-				ComputeEdgeCost(static_cast<long>(e));
-				m_pqueue.push(GraphEdgePriorityQueue(static_cast<long>(e), m_graph.m_edges[e].m_error));
-			}
-		}
-		else
-		{
-			break;
-		}
-	}
-	while (!m_pqueue.empty())
-	{
-		m_pqueue.pop();
-	}
-
-	m_cVertices.clear();
-	m_nClusters = m_graph.GetNVertices();
-	m_cVertices.reserve(m_nClusters);
-	for (size_t p = 0, v = 0; v != m_graph.m_vertices.size(); ++v)
-	{
-		if (!m_graph.m_vertices[v].m_deleted)
-		{
-			if (m_callBack)
-			{
-				char msg[1024];
-				sprintf(msg, "\t CH \t %lu \t %lf \t %lf\n", static_cast<unsigned long>(p), m_graph.m_vertices[v].m_concavity, m_graph.m_vertices[v].m_error);
-				(*m_callBack)(msg, 0.0, 0.0, m_nClusters);
-				p++;
-			}
-			m_cVertices.push_back(static_cast<long>(v));
-		}
-	}
-	if (m_callBack)
-	{
-		sprintf(msg, "# clusters =  %lu \t C = %f\n", static_cast<unsigned long>(m_nClusters), globalConcavity);
-		(*m_callBack)(msg, progress, globalConcavity, m_graph.GetNVertices());
-	}
-}
-
-bool HACD::Compute(bool fullCH, bool exportDistPoints)
-{
-	gCancelRequest = false;
-
-	if (!m_points || !m_triangles || !m_nPoints || !m_nTriangles)
-	{
-		return false;
-	}
-	size_t nV = m_nTriangles;
-	if (m_callBack)
-	{
-		std::ostringstream msg;
-		msg << "+ Mesh" << std::endl;
-		msg << "\t # vertices                     \t" << m_nPoints << std::endl;
-		msg << "\t # triangles                    \t" << m_nTriangles << std::endl;
-		msg << "+ Parameters" << std::endl;
-		msg << "\t min # of clusters              \t" << m_nMinClusters << std::endl;
-		msg << "\t max concavity                  \t" << m_concavity << std::endl;
-		msg << "\t compacity weigth               \t" << m_alpha << std::endl;
-		msg << "\t volume weigth                  \t" << m_beta << std::endl;
-		msg << "\t # vertices per convex-hull     \t" << m_nVerticesPerCH << std::endl;
-		msg << "\t scale                          \t" << m_scale << std::endl;
-		msg << "\t add extra distance points      \t" << m_addExtraDistPoints << std::endl;
-		msg << "\t add neighbours distance points \t" << m_addNeighboursDistPoints << std::endl;
-		msg << "\t add face distance points       \t" << m_addFacesPoints << std::endl;
-		msg << "\t produce full convex-hulls      \t" << fullCH << std::endl;
-		msg << "\t max. distance to connect CCs   \t" << m_ccConnectDist << std::endl;
-		(*m_callBack)(msg.str().c_str(), 0.0, 0.0, nV);
-	}
-	if (m_callBack) (*m_callBack)("+ Normalizing Data\n", 0.0, 0.0, nV);
-	NormalizeData();
-	if (m_callBack) (*m_callBack)("+ Creating Graph\n", 0.0, 0.0, nV);
-	CreateGraph();
-	// Compute the surfaces and perimeters of all the faces
-	if (m_callBack) (*m_callBack)("+ Initializing Dual Graph\n", 0.0, 0.0, nV);
-	if (gCancelRequest)
-		return false;
-
-	InitializeDualGraph();
-	if (m_callBack) (*m_callBack)("+ Initializing Priority Queue\n", 0.0, 0.0, nV);
-	if (gCancelRequest)
-		return false;
-
-	InitializePriorityQueue();
-	// we simplify the graph
-	if (m_callBack) (*m_callBack)("+ Simplification ...\n", 0.0, 0.0, m_nTriangles);
-	Simplify();
-	if (m_callBack) (*m_callBack)("+ Denormalizing Data\n", 0.0, 0.0, m_nClusters);
-	DenormalizeData();
-	if (m_callBack) (*m_callBack)("+ Computing final convex-hulls\n", 0.0, 0.0, m_nClusters);
-	delete[] m_convexHulls;
-	m_convexHulls = new ICHull[m_nClusters];
-	delete[] m_partition;
-	m_partition = new long[m_nTriangles];
-	for (size_t p = 0; p != m_cVertices.size(); ++p)
-	{
-		size_t v = m_cVertices[p];
-		m_partition[v] = static_cast<long>(p);
-		for (size_t a = 0; a < m_graph.m_vertices[v].m_ancestors.size(); a++)
-		{
-			m_partition[m_graph.m_vertices[v].m_ancestors[a]] = static_cast<long>(p);
-		}
-		// compute the convex-hull
-		const std::map<long, DPoint>& pointsCH = m_graph.m_vertices[v].m_distPoints;
-		std::map<long, DPoint>::const_iterator itCH(pointsCH.begin());
-		std::map<long, DPoint>::const_iterator itCHEnd(pointsCH.end());
-		for (; itCH != itCHEnd; ++itCH)
-		{
-			if (!(itCH->second).m_distOnly)
-			{
-				m_convexHulls[p].AddPoint(m_points[itCH->first], itCH->first);
-			}
-		}
-		m_convexHulls[p].SetDistPoints(&m_graph.m_vertices[v].m_distPoints);
-		if (fullCH)
-		{
-			m_convexHulls[p].Process();
-		}
-		else
-		{
-			m_convexHulls[p].Process(static_cast<unsigned long>(m_nVerticesPerCH));
-		}
-		if (exportDistPoints)
-		{
-			itCH = pointsCH.begin();
-			for (; itCH != itCHEnd; ++itCH)
-			{
-				if ((itCH->second).m_distOnly)
-				{
-					if (itCH->first >= 0)
-					{
-						m_convexHulls[p].AddPoint(m_points[itCH->first], itCH->first);
-					}
-					else
-					{
-						m_convexHulls[p].AddPoint(m_facePoints[-itCH->first - 1], itCH->first);
-					}
-				}
-			}
-		}
-	}
-	return true;
-}
-
-size_t HACD::GetNTrianglesCH(size_t numCH) const
-{
-	if (numCH >= m_nClusters)
-	{
-		return 0;
-	}
-	return m_convexHulls[numCH].GetMesh().GetNTriangles();
-}
-size_t HACD::GetNPointsCH(size_t numCH) const
-{
-	if (numCH >= m_nClusters)
-	{
-		return 0;
-	}
-	return m_convexHulls[numCH].GetMesh().GetNVertices();
-}
-
-bool HACD::GetCH(size_t numCH, Vec3<Real>* const points, Vec3<long>* const triangles)
-{
-	if (numCH >= m_nClusters)
-	{
-		return false;
-	}
-	m_convexHulls[numCH].GetMesh().GetIFS(points, triangles);
-	return true;
-}
-
-bool HACD::Save(const char* fileName, bool uniColor, long numCluster) const
-{
-	std::ofstream fout(fileName);
-	if (fout.is_open())
-	{
-		if (m_callBack)
-		{
-			char msg[1024];
-			sprintf(msg, "Saving %s\n", fileName);
-			(*m_callBack)(msg, 0.0, 0.0, m_graph.GetNVertices());
-		}
-		Material mat;
-		if (numCluster < 0)
-		{
-			for (size_t p = 0; p != m_nClusters; ++p)
-			{
-				if (!uniColor)
-				{
-					mat.m_diffuseColor.X() = mat.m_diffuseColor.Y() = mat.m_diffuseColor.Z() = 0.0;
-					while (mat.m_diffuseColor.X() == mat.m_diffuseColor.Y() ||
-						   mat.m_diffuseColor.Z() == mat.m_diffuseColor.Y() ||
-						   mat.m_diffuseColor.Z() == mat.m_diffuseColor.X())
-					{
-						mat.m_diffuseColor.X() = (rand() % 100) / 100.0;
-						mat.m_diffuseColor.Y() = (rand() % 100) / 100.0;
-						mat.m_diffuseColor.Z() = (rand() % 100) / 100.0;
-					}
-				}
-				m_convexHulls[p].GetMesh().SaveVRML2(fout, mat);
-			}
-		}
-		else if (numCluster < static_cast<long>(m_cVertices.size()))
-		{
-			m_convexHulls[numCluster].GetMesh().SaveVRML2(fout, mat);
-		}
-		fout.close();
-		return true;
-	}
-	else
-	{
-		if (m_callBack)
-		{
-			char msg[1024];
-			sprintf(msg, "Error saving %s\n", fileName);
-			(*m_callBack)(msg, 0.0, 0.0, m_graph.GetNVertices());
-		}
-		return false;
-	}
-}
-}  // namespace HACD

+ 0 - 285
ThirdParty/Bullet/Extras/HACD/hacdHACD.h

@@ -1,285 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_HACD_H
-#define HACD_HACD_H
-#include "hacdVersion.h"
-#include "hacdVector.h"
-#include "hacdGraph.h"
-#include "hacdICHull.h"
-#include <set>
-#include <vector>
-#include <queue>
-#include <functional>
-
-namespace HACD
-{
-const double sc_pi = 3.14159265;
-class HACD;
-
-// just to be able to set the capcity of the container
-
-template <class _Ty, class _Container = std::vector<_Ty>, class _Pr = std::less<typename _Container::value_type> >
-class reservable_priority_queue : public std::priority_queue<_Ty, _Container, _Pr>
-{
-	typedef typename std::priority_queue<_Ty, _Container, _Pr>::size_type size_type;
-
-public:
-	reservable_priority_queue(size_type capacity = 0) { reserve(capacity); };
-	void reserve(size_type capacity) { this->c.reserve(capacity); }
-	size_type capacity() const { return this->c.capacity(); }
-};
-
-//! priority queque element
-class GraphEdgePriorityQueue
-{
-public:
-	//! Constructor
-	//! @param name edge's id
-	//! @param priority edge's priority
-	GraphEdgePriorityQueue(long name, Real priority)
-	{
-		m_name = name;
-		m_priority = priority;
-	}
-	//! Destructor
-	~GraphEdgePriorityQueue(void) {}
-
-private:
-	long m_name;      //!< edge name
-	Real m_priority;  //!< priority
-					  //! Operator < for GraphEdgePQ
-	friend bool operator<(const GraphEdgePriorityQueue &lhs, const GraphEdgePriorityQueue &rhs);
-	//! Operator > for GraphEdgePQ
-	friend bool operator>(const GraphEdgePriorityQueue &lhs, const GraphEdgePriorityQueue &rhs);
-	friend class HACD;
-};
-inline bool operator<(const GraphEdgePriorityQueue &lhs, const GraphEdgePriorityQueue &rhs)
-{
-	return lhs.m_priority < rhs.m_priority;
-}
-inline bool operator>(const GraphEdgePriorityQueue &lhs, const GraphEdgePriorityQueue &rhs)
-{
-	return lhs.m_priority > rhs.m_priority;
-}
-typedef bool (*CallBackFunction)(const char *, double, double, size_t);
-
-//! Provides an implementation of the Hierarchical Approximate Convex Decomposition (HACD) technique described in "A Simple and Efficient Approach for 3D Mesh Approximate Convex Decomposition" Game Programming Gems 8 - Chapter 2.8, p.202. A short version of the chapter was published in ICIP09 and is available at ftp://ftp.elet.polimi.it/users/Stefano.Tubaro/ICIP_USB_Proceedings_v2/pdfs/0003501.pdf
-class HACD
-{
-public:
-	//! Gives the triangles partitionas an array of size m_nTriangles where the i-th element specifies the cluster to which belong the i-th triangle
-	//! @return triangles partition
-	const long *GetPartition() const { return m_partition; }
-	//! Sets the scale factor
-	//! @param scale scale factor
-	void SetScaleFactor(double scale) { m_scale = scale; }
-	//! Gives the scale factor
-	//! @return scale factor
-	double GetScaleFactor() const { return m_scale; }
-	//! Sets the call-back function
-	//! @param callBack pointer to the call-back function
-	void SetCallBack(CallBackFunction callBack) { m_callBack = callBack; }
-	//! Gives the call-back function
-	//! @return pointer to the call-back function
-	CallBackFunction GetCallBack() const { return m_callBack; }
-
-	//! Specifies whether faces points should be added when computing the concavity
-	//! @param addFacesPoints true = faces points should be added
-	void SetAddFacesPoints(bool addFacesPoints) { m_addFacesPoints = addFacesPoints; }
-	//! Specifies wheter faces points should be added when computing the concavity
-	//! @return true = faces points should be added
-	bool GetAddFacesPoints() const { return m_addFacesPoints; }
-	//! Specifies whether extra points should be added when computing the concavity
-	//! @param addExteraDistPoints true = extra points should be added
-	void SetAddExtraDistPoints(bool addExtraDistPoints) { m_addExtraDistPoints = addExtraDistPoints; }
-	//! Specifies wheter extra points should be added when computing the concavity
-	//! @return true = extra points should be added
-	bool GetAddExtraDistPoints() const { return m_addExtraDistPoints; }
-	//! Specifies whether extra points should be added when computing the concavity
-	//! @param addExteraDistPoints true = extra points should be added
-	void SetAddNeighboursDistPoints(bool addNeighboursDistPoints) { m_addNeighboursDistPoints = addNeighboursDistPoints; }
-	//! Specifies wheter extra points should be added when computing the concavity
-	//! @return true = extra points should be added
-	bool GetAddNeighboursDistPoints() const { return m_addNeighboursDistPoints; }
-	//! Sets the points of the input mesh (Remark: the input points will be scaled and shifted. Use DenormalizeData() to invert those operations)
-	//! @param points pointer to the input points
-	void SetPoints(Vec3<Real> *points) { m_points = points; }
-	//! Gives the points of the input mesh (Remark: the input points will be scaled and shifted. Use DenormalizeData() to invert those operations)
-	//! @return pointer to the input points
-	const Vec3<Real> *GetPoints() const { return m_points; }
-	//! Sets the triangles of the input mesh.
-	//! @param triangles points pointer to the input points
-	void SetTriangles(Vec3<long> *triangles) { m_triangles = triangles; }
-	//! Gives the triangles in the input mesh
-	//! @return pointer to the input triangles
-	const Vec3<long> *GetTriangles() const { return m_triangles; }
-	//! Sets the number of points in the input mesh.
-	//! @param nPoints number of points the input mesh
-	void SetNPoints(size_t nPoints) { m_nPoints = nPoints; }
-	//! Gives the number of points in the input mesh.
-	//! @return number of points the input mesh
-	size_t GetNPoints() const { return m_nPoints; }
-	//! Sets the number of triangles in the input mesh.
-	//! @param nTriangles number of triangles in the input mesh
-	void SetNTriangles(size_t nTriangles) { m_nTriangles = nTriangles; }
-	//! Gives the number of triangles in the input mesh.
-	//! @return number of triangles the input mesh
-	size_t GetNTriangles() const { return m_nTriangles; }
-	//! Sets the minimum number of clusters to be generated.
-	//! @param nClusters minimum number of clusters
-	void SetNClusters(size_t nClusters) { m_nMinClusters = nClusters; }
-	//! Gives the number of generated clusters.
-	//! @return number of generated clusters
-	size_t GetNClusters() const { return m_nClusters; }
-	//! Sets the maximum allowed concavity.
-	//! @param concavity maximum concavity
-	void SetConcavity(double concavity) { m_concavity = concavity; }
-	//! Gives the maximum allowed concavity.
-	//! @return maximum concavity
-	double GetConcavity() const { return m_concavity; }
-	//! Sets the maximum allowed distance to get CCs connected.
-	//! @param concavity maximum distance to get CCs connected
-	void SetConnectDist(double ccConnectDist) { m_ccConnectDist = ccConnectDist; }
-	//! Gives the maximum allowed distance to get CCs connected.
-	//! @return maximum distance to get CCs connected
-	double GetConnectDist() const { return m_ccConnectDist; }
-	//! Sets the volume weight.
-	//! @param beta volume weight
-	void SetVolumeWeight(double beta) { m_beta = beta; }
-	//! Gives the volume weight.
-	//! @return volume weight
-	double GetVolumeWeight() const { return m_beta; }
-	//! Sets the compacity weight (i.e. parameter alpha in ftp://ftp.elet.polimi.it/users/Stefano.Tubaro/ICIP_USB_Proceedings_v2/pdfs/0003501.pdf).
-	//! @param alpha compacity weight
-	void SetCompacityWeight(double alpha) { m_alpha = alpha; }
-	//! Gives the compacity weight (i.e. parameter alpha in ftp://ftp.elet.polimi.it/users/Stefano.Tubaro/ICIP_USB_Proceedings_v2/pdfs/0003501.pdf).
-	//! @return compacity weight
-	double GetCompacityWeight() const { return m_alpha; }
-	//! Sets the maximum number of vertices for each generated convex-hull.
-	//! @param nVerticesPerCH maximum # vertices per CH
-	void SetNVerticesPerCH(size_t nVerticesPerCH) { m_nVerticesPerCH = nVerticesPerCH; }
-	//! Gives the maximum number of vertices for each generated convex-hull.
-	//! @return maximum # vertices per CH
-	size_t GetNVerticesPerCH() const { return m_nVerticesPerCH; }
-	//! Gives the number of vertices for the cluster number numCH.
-	//! @return number of vertices
-	size_t GetNPointsCH(size_t numCH) const;
-	//! Gives the number of triangles for the cluster number numCH.
-	//! @param numCH cluster's number
-	//! @return number of triangles
-	size_t GetNTrianglesCH(size_t numCH) const;
-	//! Gives the vertices and the triangles of the cluster number numCH.
-	//! @param numCH cluster's number
-	//! @param points pointer to the vector of points to be filled
-	//! @param triangles pointer to the vector of triangles to be filled
-	//! @return true if sucess
-	bool GetCH(size_t numCH, Vec3<Real> *const points, Vec3<long> *const triangles);
-	//! Computes the HACD decomposition.
-	//! @param fullCH specifies whether to generate convex-hulls with a full or limited (i.e. < m_nVerticesPerCH) number of vertices
-	//! @param exportDistPoints specifies wheter distance points should ne exported or not (used only for debugging).
-	//! @return true if sucess
-	bool Compute(bool fullCH = false, bool exportDistPoints = false);
-	//! Saves the generated convex-hulls in a VRML 2.0 file.
-	//! @param fileName the output file name
-	//! @param uniColor specifies whether the different convex-hulls should have the same color or not
-	//! @param numCluster specifies the cluster to be saved, if numCluster < 0 export all clusters
-	//! @return true if sucess
-	bool Save(const char *fileName, bool uniColor, long numCluster = -1) const;
-	//! Shifts and scales to the data to have all the coordinates between 0.0 and 1000.0.
-	void NormalizeData();
-	//! Inverse the operations applied by NormalizeData().
-	void DenormalizeData();
-	//! Constructor.
-	HACD(void);
-	//! Destructor.
-	~HACD(void);
-
-private:
-	//! Gives the edge index.
-	//! @param a first vertex id
-	//! @param b second vertex id
-	//! @return edge's index
-	static unsigned long long GetEdgeIndex(unsigned long long a, unsigned long long b)
-	{
-		if (a > b)
-			return (a << 32) + b;
-		else
-			return (b << 32) + a;
-	}
-	//! Computes the concavity of a cluster.
-	//! @param ch the cluster's convex-hull
-	//! @param distPoints the cluster's points
-	//! @return cluster's concavity
-	double Concavity(ICHull &ch, std::map<long, DPoint> &distPoints);
-	//! Computes the perimeter of a cluster.
-	//! @param triIndices the cluster's triangles
-	//! @param distPoints the cluster's points
-	//! @return cluster's perimeter
-	double ComputePerimeter(const std::vector<long> &triIndices) const;
-	//! Creates the Graph by associating to each mesh triangle a vertex in the graph and to each couple of adjacent triangles an edge in the graph.
-	void CreateGraph();
-	//! Initializes the graph costs and computes the vertices normals
-	void InitializeDualGraph();
-	//! Computes the cost of an edge
-	//! @param e edge's id
-	void ComputeEdgeCost(size_t e);
-	//! Initializes the priority queue
-	//! @param fast specifies whether fast mode is used
-	//! @return true if success
-	bool InitializePriorityQueue();
-	//! Cleans the intersection between convex-hulls
-	void CleanClusters();
-	//! Computes convex-hulls from partition information
-	//! @param fullCH specifies whether to generate convex-hulls with a full or limited (i.e. < m_nVerticesPerCH) number of vertices
-	void ComputeConvexHulls(bool fullCH);
-	//! Simplifies the graph
-	//! @param fast specifies whether fast mode is used
-	void Simplify();
-
-private:
-	double m_scale;                 //>! scale factor used for NormalizeData() and DenormalizeData()
-	Vec3<long> *m_triangles;        //>! pointer the triangles array
-	Vec3<Real> *m_points;           //>! pointer the points array
-	Vec3<Real> *m_facePoints;       //>! pointer to the faces points array
-	Vec3<Real> *m_faceNormals;      //>! pointer to the faces normals array
-	Vec3<Real> *m_normals;          //>! pointer the normals array
-	size_t m_nTriangles;            //>! number of triangles in the original mesh
-	size_t m_nPoints;               //>! number of vertices in the original mesh
-	size_t m_nClusters;             //>! number of clusters
-	size_t m_nMinClusters;          //>! minimum number of clusters
-	double m_ccConnectDist;         //>! maximum allowed distance to connect CCs
-	double m_concavity;             //>! maximum concavity
-	double m_alpha;                 //>! compacity weigth
-	double m_beta;                  //>! volume weigth
-	double m_diag;                  //>! length of the BB diagonal
-	Vec3<Real> m_barycenter;        //>! barycenter of the mesh
-	std::vector<long> m_cVertices;  //>! array of vertices each belonging to a different cluster
-	ICHull *m_convexHulls;          //>! convex-hulls associated with the final HACD clusters
-	Graph m_graph;                  //>! simplification graph
-	size_t m_nVerticesPerCH;        //>! maximum number of vertices per convex-hull
-	reservable_priority_queue<GraphEdgePriorityQueue,
-							  std::vector<GraphEdgePriorityQueue>,
-							  std::greater<std::vector<GraphEdgePriorityQueue>::value_type> >
-		m_pqueue;  //!> priority queue
-	HACD(const HACD &rhs);
-	CallBackFunction m_callBack;     //>! call-back function
-	long *m_partition;               //>! array of size m_nTriangles where the i-th element specifies the cluster to which belong the i-th triangle
-	bool m_addFacesPoints;           //>! specifies whether to add faces points or not
-	bool m_addExtraDistPoints;       //>! specifies whether to add extra points for concave shapes or not
-	bool m_addNeighboursDistPoints;  //>! specifies whether to add extra points from adjacent clusters or not
-};
-}  // namespace HACD
-#endif

+ 0 - 1020
ThirdParty/Bullet/Extras/HACD/hacdICHull.cpp

@@ -1,1020 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "hacdICHull.h"
-#include <limits>
-#include <algorithm>
-
-namespace HACD
-{
-const long ICHull::sc_dummyIndex = std::numeric_limits<long>::max();
-ICHull::ICHull(void)
-{
-	m_distPoints = 0;
-	m_isFlat = false;
-	m_dummyVertex = 0;
-}
-bool ICHull::AddPoints(const Vec3<Real> *points, size_t nPoints)
-{
-	if (!points)
-	{
-		return false;
-	}
-	CircularListElement<TMMVertex> *vertex = NULL;
-	for (size_t i = 0; i < nPoints; i++)
-	{
-		vertex = m_mesh.AddVertex();
-		vertex->GetData().m_pos.X() = points[i].X();
-		vertex->GetData().m_pos.Y() = points[i].Y();
-		vertex->GetData().m_pos.Z() = points[i].Z();
-		vertex->GetData().m_name = static_cast<long>(i);
-	}
-	return true;
-}
-bool ICHull::AddPoints(std::vector<Vec3<Real> > points)
-{
-	CircularListElement<TMMVertex> *vertex = NULL;
-	for (size_t i = 0; i < points.size(); i++)
-	{
-		vertex = m_mesh.AddVertex();
-		vertex->GetData().m_pos.X() = points[i].X();
-		vertex->GetData().m_pos.Y() = points[i].Y();
-		vertex->GetData().m_pos.Z() = points[i].Z();
-	}
-	return true;
-}
-
-bool ICHull::AddPoint(const Vec3<Real> &point, long id)
-{
-	if (AddPoints(&point, 1))
-	{
-		m_mesh.m_vertices.GetData().m_name = id;
-		return true;
-	}
-	return false;
-}
-
-ICHullError ICHull::Process()
-{
-	unsigned long addedPoints = 0;
-	if (m_mesh.GetNVertices() < 3)
-	{
-		return ICHullErrorNotEnoughPoints;
-	}
-	if (m_mesh.GetNVertices() == 3)
-	{
-		m_isFlat = true;
-		CircularListElement<TMMTriangle> *t1 = m_mesh.AddTriangle();
-		CircularListElement<TMMTriangle> *t2 = m_mesh.AddTriangle();
-		CircularListElement<TMMVertex> *v0 = m_mesh.m_vertices.GetHead();
-		CircularListElement<TMMVertex> *v1 = v0->GetNext();
-		CircularListElement<TMMVertex> *v2 = v1->GetNext();
-		// Compute the normal to the plane
-		Vec3<Real> p0 = v0->GetData().m_pos;
-		Vec3<Real> p1 = v1->GetData().m_pos;
-		Vec3<Real> p2 = v2->GetData().m_pos;
-		m_normal = (p1 - p0) ^ (p2 - p0);
-		m_normal.Normalize();
-		t1->GetData().m_vertices[0] = v0;
-		t1->GetData().m_vertices[1] = v1;
-		t1->GetData().m_vertices[2] = v2;
-		t2->GetData().m_vertices[0] = v1;
-		t2->GetData().m_vertices[1] = v2;
-		t2->GetData().m_vertices[2] = v2;
-		return ICHullErrorOK;
-	}
-	if (m_isFlat)
-	{
-		m_mesh.m_edges.Clear();
-		m_mesh.m_triangles.Clear();
-		m_isFlat = false;
-	}
-	if (m_mesh.GetNTriangles() == 0)  // we have to create the first polyhedron
-	{
-		ICHullError res = DoubleTriangle();
-		if (res != ICHullErrorOK)
-		{
-			return res;
-		}
-		else
-		{
-			addedPoints += 3;
-		}
-	}
-	CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-	// go to the first added and not processed vertex
-	while (!(vertices.GetHead()->GetPrev()->GetData().m_tag))
-	{
-		vertices.Prev();
-	}
-	while (!vertices.GetData().m_tag)  // not processed
-	{
-		vertices.GetData().m_tag = true;
-		if (ProcessPoint())
-		{
-			addedPoints++;
-			CleanUp(addedPoints);
-			vertices.Next();
-			if (!GetMesh().CheckConsistancy())
-			{
-				return ICHullErrorInconsistent;
-			}
-		}
-	}
-	if (m_isFlat)
-	{
-		std::vector<CircularListElement<TMMTriangle> *> trianglesToDuplicate;
-		size_t nT = m_mesh.GetNTriangles();
-		for (size_t f = 0; f < nT; f++)
-		{
-			TMMTriangle &currentTriangle = m_mesh.m_triangles.GetHead()->GetData();
-			if (currentTriangle.m_vertices[0]->GetData().m_name == sc_dummyIndex ||
-				currentTriangle.m_vertices[1]->GetData().m_name == sc_dummyIndex ||
-				currentTriangle.m_vertices[2]->GetData().m_name == sc_dummyIndex)
-			{
-				m_trianglesToDelete.push_back(m_mesh.m_triangles.GetHead());
-				for (int k = 0; k < 3; k++)
-				{
-					for (int h = 0; h < 2; h++)
-					{
-						if (currentTriangle.m_edges[k]->GetData().m_triangles[h] == m_mesh.m_triangles.GetHead())
-						{
-							currentTriangle.m_edges[k]->GetData().m_triangles[h] = 0;
-							break;
-						}
-					}
-				}
-			}
-			else
-			{
-				trianglesToDuplicate.push_back(m_mesh.m_triangles.GetHead());
-			}
-			m_mesh.m_triangles.Next();
-		}
-		size_t nE = m_mesh.GetNEdges();
-		for (size_t e = 0; e < nE; e++)
-		{
-			TMMEdge &currentEdge = m_mesh.m_edges.GetHead()->GetData();
-			if (currentEdge.m_triangles[0] == 0 && currentEdge.m_triangles[1] == 0)
-			{
-				m_edgesToDelete.push_back(m_mesh.m_edges.GetHead());
-			}
-			m_mesh.m_edges.Next();
-		}
-		m_mesh.m_vertices.Delete(m_dummyVertex);
-		m_dummyVertex = 0;
-		size_t nV = m_mesh.GetNVertices();
-		CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-		for (size_t v = 0; v < nV; ++v)
-		{
-			vertices.GetData().m_tag = false;
-			vertices.Next();
-		}
-		CleanEdges();
-		CleanTriangles();
-		CircularListElement<TMMTriangle> *newTriangle;
-		for (size_t t = 0; t < trianglesToDuplicate.size(); t++)
-		{
-			newTriangle = m_mesh.AddTriangle();
-			newTriangle->GetData().m_vertices[0] = trianglesToDuplicate[t]->GetData().m_vertices[1];
-			newTriangle->GetData().m_vertices[1] = trianglesToDuplicate[t]->GetData().m_vertices[0];
-			newTriangle->GetData().m_vertices[2] = trianglesToDuplicate[t]->GetData().m_vertices[2];
-		}
-	}
-	return ICHullErrorOK;
-}
-ICHullError ICHull::Process(unsigned long nPointsCH)
-{
-	unsigned long addedPoints = 0;
-	if (nPointsCH < 3 || m_mesh.GetNVertices() < 3)
-	{
-		return ICHullErrorNotEnoughPoints;
-	}
-	if (m_mesh.GetNVertices() == 3)
-	{
-		m_isFlat = true;
-		CircularListElement<TMMTriangle> *t1 = m_mesh.AddTriangle();
-		CircularListElement<TMMTriangle> *t2 = m_mesh.AddTriangle();
-		CircularListElement<TMMVertex> *v0 = m_mesh.m_vertices.GetHead();
-		CircularListElement<TMMVertex> *v1 = v0->GetNext();
-		CircularListElement<TMMVertex> *v2 = v1->GetNext();
-		// Compute the normal to the plane
-		Vec3<Real> p0 = v0->GetData().m_pos;
-		Vec3<Real> p1 = v1->GetData().m_pos;
-		Vec3<Real> p2 = v2->GetData().m_pos;
-		m_normal = (p1 - p0) ^ (p2 - p0);
-		m_normal.Normalize();
-		t1->GetData().m_vertices[0] = v0;
-		t1->GetData().m_vertices[1] = v1;
-		t1->GetData().m_vertices[2] = v2;
-		t2->GetData().m_vertices[0] = v1;
-		t2->GetData().m_vertices[1] = v0;
-		t2->GetData().m_vertices[2] = v2;
-		return ICHullErrorOK;
-	}
-
-	if (m_isFlat)
-	{
-		m_mesh.m_triangles.Clear();
-		m_mesh.m_edges.Clear();
-		m_isFlat = false;
-	}
-
-	if (m_mesh.GetNTriangles() == 0)  // we have to create the first polyhedron
-	{
-		ICHullError res = DoubleTriangle();
-		if (res != ICHullErrorOK)
-		{
-			return res;
-		}
-		else
-		{
-			addedPoints += 3;
-		}
-	}
-	CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-	while (!vertices.GetData().m_tag && addedPoints < nPointsCH)  // not processed
-	{
-		if (!FindMaxVolumePoint())
-		{
-			break;
-		}
-		vertices.GetData().m_tag = true;
-		if (ProcessPoint())
-		{
-			addedPoints++;
-			CleanUp(addedPoints);
-			if (!GetMesh().CheckConsistancy())
-			{
-				return ICHullErrorInconsistent;
-			}
-			vertices.Next();
-		}
-	}
-	// delete remaining points
-	while (!vertices.GetData().m_tag)
-	{
-		if (vertices.GetHead() == m_dummyVertex)
-			m_dummyVertex = 0;
-		vertices.Delete();
-	}
-	if (m_isFlat)
-	{
-		std::vector<CircularListElement<TMMTriangle> *> trianglesToDuplicate;
-		size_t nT = m_mesh.GetNTriangles();
-		for (size_t f = 0; f < nT; f++)
-		{
-			TMMTriangle &currentTriangle = m_mesh.m_triangles.GetHead()->GetData();
-			if (currentTriangle.m_vertices[0]->GetData().m_name == sc_dummyIndex ||
-				currentTriangle.m_vertices[1]->GetData().m_name == sc_dummyIndex ||
-				currentTriangle.m_vertices[2]->GetData().m_name == sc_dummyIndex)
-			{
-				m_trianglesToDelete.push_back(m_mesh.m_triangles.GetHead());
-				for (int k = 0; k < 3; k++)
-				{
-					for (int h = 0; h < 2; h++)
-					{
-						if (currentTriangle.m_edges[k]->GetData().m_triangles[h] == m_mesh.m_triangles.GetHead())
-						{
-							currentTriangle.m_edges[k]->GetData().m_triangles[h] = 0;
-							break;
-						}
-					}
-				}
-			}
-			else
-			{
-				trianglesToDuplicate.push_back(m_mesh.m_triangles.GetHead());
-			}
-			m_mesh.m_triangles.Next();
-		}
-		size_t nE = m_mesh.GetNEdges();
-		for (size_t e = 0; e < nE; e++)
-		{
-			TMMEdge &currentEdge = m_mesh.m_edges.GetHead()->GetData();
-			if (currentEdge.m_triangles[0] == 0 && currentEdge.m_triangles[1] == 0)
-			{
-				m_edgesToDelete.push_back(m_mesh.m_edges.GetHead());
-			}
-			m_mesh.m_edges.Next();
-		}
-		m_mesh.m_vertices.Delete(m_dummyVertex);
-		m_dummyVertex = 0;
-		size_t nV = m_mesh.GetNVertices();
-		CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-		for (size_t v = 0; v < nV; ++v)
-		{
-			vertices.GetData().m_tag = false;
-			vertices.Next();
-		}
-		CleanEdges();
-		CleanTriangles();
-		CircularListElement<TMMTriangle> *newTriangle;
-		for (size_t t = 0; t < trianglesToDuplicate.size(); t++)
-		{
-			newTriangle = m_mesh.AddTriangle();
-			newTriangle->GetData().m_vertices[0] = trianglesToDuplicate[t]->GetData().m_vertices[1];
-			newTriangle->GetData().m_vertices[1] = trianglesToDuplicate[t]->GetData().m_vertices[0];
-			newTriangle->GetData().m_vertices[2] = trianglesToDuplicate[t]->GetData().m_vertices[2];
-		}
-	}
-	return ICHullErrorOK;
-}
-bool ICHull::FindMaxVolumePoint()
-{
-	CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-	CircularListElement<TMMVertex> *vMaxVolume = 0;
-	CircularListElement<TMMVertex> *vHeadPrev = vertices.GetHead()->GetPrev();
-
-	double maxVolume = 0.0;
-	double volume = 0.0;
-
-	while (!vertices.GetData().m_tag)  // not processed
-	{
-		if (ComputePointVolume(volume, false))
-		{
-			if (maxVolume < volume)
-			{
-				maxVolume = volume;
-				vMaxVolume = vertices.GetHead();
-			}
-			vertices.Next();
-		}
-	}
-	CircularListElement<TMMVertex> *vHead = vHeadPrev->GetNext();
-	vertices.GetHead() = vHead;
-
-	if (!vMaxVolume)
-	{
-		return false;
-	}
-
-	if (vMaxVolume != vHead)
-	{
-		Vec3<Real> pos = vHead->GetData().m_pos;
-		long id = vHead->GetData().m_name;
-		vHead->GetData().m_pos = vMaxVolume->GetData().m_pos;
-		vHead->GetData().m_name = vMaxVolume->GetData().m_name;
-		vMaxVolume->GetData().m_pos = pos;
-		vHead->GetData().m_name = id;
-	}
-
-	return true;
-}
-ICHullError ICHull::DoubleTriangle()
-{
-	// find three non colinear points
-	m_isFlat = false;
-	CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-	CircularListElement<TMMVertex> *v0 = vertices.GetHead();
-	while (Colinear(v0->GetData().m_pos,
-					v0->GetNext()->GetData().m_pos,
-					v0->GetNext()->GetNext()->GetData().m_pos))
-	{
-		if ((v0 = v0->GetNext()) == vertices.GetHead())
-		{
-			return ICHullErrorCoplanarPoints;
-		}
-	}
-	CircularListElement<TMMVertex> *v1 = v0->GetNext();
-	CircularListElement<TMMVertex> *v2 = v1->GetNext();
-	// mark points as processed
-	v0->GetData().m_tag = v1->GetData().m_tag = v2->GetData().m_tag = true;
-
-	// create two triangles
-	CircularListElement<TMMTriangle> *f0 = MakeFace(v0, v1, v2, 0);
-	MakeFace(v2, v1, v0, f0);
-
-	// find a fourth non-coplanar point to form tetrahedron
-	CircularListElement<TMMVertex> *v3 = v2->GetNext();
-	vertices.GetHead() = v3;
-
-	double vol = Volume(v0->GetData().m_pos, v1->GetData().m_pos, v2->GetData().m_pos, v3->GetData().m_pos);
-	while (vol == 0.0 && !v3->GetNext()->GetData().m_tag)
-	{
-		v3 = v3->GetNext();
-		vol = Volume(v0->GetData().m_pos, v1->GetData().m_pos, v2->GetData().m_pos, v3->GetData().m_pos);
-	}
-	if (vol == 0.0)
-	{
-		// compute the barycenter
-		Vec3<Real> bary(0.0, 0.0, 0.0);
-		CircularListElement<TMMVertex> *vBary = v0;
-		do
-		{
-			bary += vBary->GetData().m_pos;
-		} while ((vBary = vBary->GetNext()) != v0);
-		bary /= static_cast<Real>(vertices.GetSize());
-
-		// Compute the normal to the plane
-		Vec3<Real> p0 = v0->GetData().m_pos;
-		Vec3<Real> p1 = v1->GetData().m_pos;
-		Vec3<Real> p2 = v2->GetData().m_pos;
-		m_normal = (p1 - p0) ^ (p2 - p0);
-		m_normal.Normalize();
-		// add dummy vertex placed at (bary + normal)
-		vertices.GetHead() = v2;
-		Vec3<Real> newPt = bary + m_normal;
-		AddPoint(newPt, sc_dummyIndex);
-		m_dummyVertex = vertices.GetHead();
-		m_isFlat = true;
-		v3 = v2->GetNext();
-		vol = Volume(v0->GetData().m_pos, v1->GetData().m_pos, v2->GetData().m_pos, v3->GetData().m_pos);
-		return ICHullErrorOK;
-	}
-	else if (v3 != vertices.GetHead())
-	{
-		TMMVertex temp;
-		temp.m_name = v3->GetData().m_name;
-		temp.m_pos = v3->GetData().m_pos;
-		v3->GetData().m_name = vertices.GetHead()->GetData().m_name;
-		v3->GetData().m_pos = vertices.GetHead()->GetData().m_pos;
-		vertices.GetHead()->GetData().m_name = temp.m_name;
-		vertices.GetHead()->GetData().m_pos = temp.m_pos;
-	}
-	return ICHullErrorOK;
-}
-CircularListElement<TMMTriangle> *ICHull::MakeFace(CircularListElement<TMMVertex> *v0,
-												   CircularListElement<TMMVertex> *v1,
-												   CircularListElement<TMMVertex> *v2,
-												   CircularListElement<TMMTriangle> *fold)
-{
-	CircularListElement<TMMEdge> *e0;
-	CircularListElement<TMMEdge> *e1;
-	CircularListElement<TMMEdge> *e2;
-	long index = 0;
-	if (!fold)  // if first face to be created
-	{
-		e0 = m_mesh.AddEdge();  // create the three edges
-		e1 = m_mesh.AddEdge();
-		e2 = m_mesh.AddEdge();
-	}
-	else  // otherwise re-use existing edges (in reverse order)
-	{
-		e0 = fold->GetData().m_edges[2];
-		e1 = fold->GetData().m_edges[1];
-		e2 = fold->GetData().m_edges[0];
-		index = 1;
-	}
-	e0->GetData().m_vertices[0] = v0;
-	e0->GetData().m_vertices[1] = v1;
-	e1->GetData().m_vertices[0] = v1;
-	e1->GetData().m_vertices[1] = v2;
-	e2->GetData().m_vertices[0] = v2;
-	e2->GetData().m_vertices[1] = v0;
-	// create the new face
-	CircularListElement<TMMTriangle> *f = m_mesh.AddTriangle();
-	f->GetData().m_edges[0] = e0;
-	f->GetData().m_edges[1] = e1;
-	f->GetData().m_edges[2] = e2;
-	f->GetData().m_vertices[0] = v0;
-	f->GetData().m_vertices[1] = v1;
-	f->GetData().m_vertices[2] = v2;
-	// link edges to face f
-	e0->GetData().m_triangles[index] = e1->GetData().m_triangles[index] = e2->GetData().m_triangles[index] = f;
-	return f;
-}
-CircularListElement<TMMTriangle> *ICHull::MakeConeFace(CircularListElement<TMMEdge> *e, CircularListElement<TMMVertex> *p)
-{
-	// create two new edges if they don't already exist
-	CircularListElement<TMMEdge> *newEdges[2];
-	for (int i = 0; i < 2; ++i)
-	{
-		if (!(newEdges[i] = e->GetData().m_vertices[i]->GetData().m_duplicate))
-		{  // if the edge doesn't exits add it and mark the vertex as duplicated
-			newEdges[i] = m_mesh.AddEdge();
-			newEdges[i]->GetData().m_vertices[0] = e->GetData().m_vertices[i];
-			newEdges[i]->GetData().m_vertices[1] = p;
-			e->GetData().m_vertices[i]->GetData().m_duplicate = newEdges[i];
-		}
-	}
-	// make the new face
-	CircularListElement<TMMTriangle> *newFace = m_mesh.AddTriangle();
-	newFace->GetData().m_edges[0] = e;
-	newFace->GetData().m_edges[1] = newEdges[0];
-	newFace->GetData().m_edges[2] = newEdges[1];
-	MakeCCW(newFace, e, p);
-	for (int i = 0; i < 2; ++i)
-	{
-		for (int j = 0; j < 2; ++j)
-		{
-			if (!newEdges[i]->GetData().m_triangles[j])
-			{
-				newEdges[i]->GetData().m_triangles[j] = newFace;
-				break;
-			}
-		}
-	}
-	return newFace;
-}
-bool ICHull::ComputePointVolume(double &totalVolume, bool markVisibleFaces)
-{
-	// mark visible faces
-	CircularListElement<TMMTriangle> *fHead = m_mesh.GetTriangles().GetHead();
-	CircularListElement<TMMTriangle> *f = fHead;
-	CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-	CircularListElement<TMMVertex> *vertex0 = vertices.GetHead();
-	bool visible = false;
-	Vec3<double> pos0 = Vec3<double>(vertex0->GetData().m_pos.X(),
-									 vertex0->GetData().m_pos.Y(),
-									 vertex0->GetData().m_pos.Z());
-	double vol = 0.0;
-	totalVolume = 0.0;
-	Vec3<double> ver0, ver1, ver2;
-	do
-	{
-		ver0.X() = f->GetData().m_vertices[0]->GetData().m_pos.X();
-		ver0.Y() = f->GetData().m_vertices[0]->GetData().m_pos.Y();
-		ver0.Z() = f->GetData().m_vertices[0]->GetData().m_pos.Z();
-		ver1.X() = f->GetData().m_vertices[1]->GetData().m_pos.X();
-		ver1.Y() = f->GetData().m_vertices[1]->GetData().m_pos.Y();
-		ver1.Z() = f->GetData().m_vertices[1]->GetData().m_pos.Z();
-		ver2.X() = f->GetData().m_vertices[2]->GetData().m_pos.X();
-		ver2.Y() = f->GetData().m_vertices[2]->GetData().m_pos.Y();
-		ver2.Z() = f->GetData().m_vertices[2]->GetData().m_pos.Z();
-		vol = Volume(ver0, ver1, ver2, pos0);
-		if (vol < 0.0)
-		{
-			vol = fabs(vol);
-			totalVolume += vol;
-			if (markVisibleFaces)
-			{
-				f->GetData().m_visible = true;
-				m_trianglesToDelete.push_back(f);
-			}
-			visible = true;
-		}
-		f = f->GetNext();
-	} while (f != fHead);
-
-	if (m_trianglesToDelete.size() == m_mesh.m_triangles.GetSize())
-	{
-		for (size_t i = 0; i < m_trianglesToDelete.size(); i++)
-		{
-			m_trianglesToDelete[i]->GetData().m_visible = false;
-		}
-		visible = false;
-	}
-	// if no faces visible from p then p is inside the hull
-	if (!visible && markVisibleFaces)
-	{
-		if (vertices.GetHead() == m_dummyVertex)
-			m_dummyVertex = 0;
-		vertices.Delete();
-		m_trianglesToDelete.clear();
-		return false;
-	}
-	return true;
-}
-bool ICHull::ProcessPoint()
-{
-	double totalVolume = 0.0;
-	if (!ComputePointVolume(totalVolume, true))
-	{
-		return false;
-	}
-	// Mark edges in interior of visible region for deletion.
-	// Create a new face based on each border edge
-	CircularListElement<TMMVertex> *v0 = m_mesh.GetVertices().GetHead();
-	CircularListElement<TMMEdge> *eHead = m_mesh.GetEdges().GetHead();
-	CircularListElement<TMMEdge> *e = eHead;
-	CircularListElement<TMMEdge> *tmp = 0;
-	long nvisible = 0;
-	m_edgesToDelete.clear();
-	m_edgesToUpdate.clear();
-	do
-	{
-		tmp = e->GetNext();
-		nvisible = 0;
-		for (int k = 0; k < 2; k++)
-		{
-			if (e->GetData().m_triangles[k]->GetData().m_visible)
-			{
-				nvisible++;
-			}
-		}
-		if (nvisible == 2)
-		{
-			m_edgesToDelete.push_back(e);
-		}
-		else if (nvisible == 1)
-		{
-			e->GetData().m_newFace = MakeConeFace(e, v0);
-			m_edgesToUpdate.push_back(e);
-		}
-		e = tmp;
-	} while (e != eHead);
-	return true;
-}
-bool ICHull::MakeCCW(CircularListElement<TMMTriangle> *f,
-					 CircularListElement<TMMEdge> *e,
-					 CircularListElement<TMMVertex> *v)
-{
-	// the visible face adjacent to e
-	CircularListElement<TMMTriangle> *fv;
-	if (e->GetData().m_triangles[0]->GetData().m_visible)
-	{
-		fv = e->GetData().m_triangles[0];
-	}
-	else
-	{
-		fv = e->GetData().m_triangles[1];
-	}
-
-	//  set vertex[0] and vertex[1] to have the same orientation as the corresponding vertices of fv.
-	long i;  // index of e->m_vertices[0] in fv
-	CircularListElement<TMMVertex> *v0 = e->GetData().m_vertices[0];
-	CircularListElement<TMMVertex> *v1 = e->GetData().m_vertices[1];
-	for (i = 0; fv->GetData().m_vertices[i] != v0; i++)
-		;
-
-	if (fv->GetData().m_vertices[(i + 1) % 3] != e->GetData().m_vertices[1])
-	{
-		f->GetData().m_vertices[0] = v1;
-		f->GetData().m_vertices[1] = v0;
-	}
-	else
-	{
-		f->GetData().m_vertices[0] = v0;
-		f->GetData().m_vertices[1] = v1;
-		// swap edges
-		CircularListElement<TMMEdge> *tmp = f->GetData().m_edges[0];
-		f->GetData().m_edges[0] = f->GetData().m_edges[1];
-		f->GetData().m_edges[1] = tmp;
-	}
-	f->GetData().m_vertices[2] = v;
-	return true;
-}
-bool ICHull::CleanUp(unsigned long &addedPoints)
-{
-	bool r0 = CleanEdges();
-	bool r1 = CleanTriangles();
-	bool r2 = CleanVertices(addedPoints);
-	return r0 && r1 && r2;
-}
-bool ICHull::CleanEdges()
-{
-	// integrate the new faces into the data structure
-	CircularListElement<TMMEdge> *e;
-	const std::vector<CircularListElement<TMMEdge> *>::iterator itEndUpdate = m_edgesToUpdate.end();
-	for (std::vector<CircularListElement<TMMEdge> *>::iterator it = m_edgesToUpdate.begin(); it != itEndUpdate; ++it)
-	{
-		e = *it;
-		if (e->GetData().m_newFace)
-		{
-			if (e->GetData().m_triangles[0]->GetData().m_visible)
-			{
-				e->GetData().m_triangles[0] = e->GetData().m_newFace;
-			}
-			else
-			{
-				e->GetData().m_triangles[1] = e->GetData().m_newFace;
-			}
-			e->GetData().m_newFace = 0;
-		}
-	}
-	// delete edges maked for deletion
-	CircularList<TMMEdge> &edges = m_mesh.GetEdges();
-	const std::vector<CircularListElement<TMMEdge> *>::iterator itEndDelete = m_edgesToDelete.end();
-	for (std::vector<CircularListElement<TMMEdge> *>::iterator it = m_edgesToDelete.begin(); it != itEndDelete; ++it)
-	{
-		edges.Delete(*it);
-	}
-	m_edgesToDelete.clear();
-	m_edgesToUpdate.clear();
-	return true;
-}
-bool ICHull::CleanTriangles()
-{
-	CircularList<TMMTriangle> &triangles = m_mesh.GetTriangles();
-	const std::vector<CircularListElement<TMMTriangle> *>::iterator itEndDelete = m_trianglesToDelete.end();
-	for (std::vector<CircularListElement<TMMTriangle> *>::iterator it = m_trianglesToDelete.begin(); it != itEndDelete; ++it)
-	{
-		if (m_distPoints)
-		{
-			if (m_isFlat)
-			{
-				// to be updated
-			}
-			else
-			{
-				std::set<long>::const_iterator itPEnd((*it)->GetData().m_incidentPoints.end());
-				std::set<long>::const_iterator itP((*it)->GetData().m_incidentPoints.begin());
-				std::map<long, DPoint>::iterator itPoint;
-				for (; itP != itPEnd; ++itP)
-				{
-					itPoint = m_distPoints->find(*itP);
-					if (itPoint != m_distPoints->end())
-					{
-						itPoint->second.m_computed = false;
-					}
-				}
-			}
-		}
-		triangles.Delete(*it);
-	}
-	m_trianglesToDelete.clear();
-	return true;
-}
-bool ICHull::CleanVertices(unsigned long &addedPoints)
-{
-	// mark all vertices incident to some undeleted edge as on the hull
-	CircularList<TMMEdge> &edges = m_mesh.GetEdges();
-	CircularListElement<TMMEdge> *e = edges.GetHead();
-	size_t nE = edges.GetSize();
-	for (size_t i = 0; i < nE; i++)
-	{
-		e->GetData().m_vertices[0]->GetData().m_onHull = true;
-		e->GetData().m_vertices[1]->GetData().m_onHull = true;
-		e = e->GetNext();
-	}
-	// delete all the vertices that have been processed but are not on the hull
-	CircularList<TMMVertex> &vertices = m_mesh.GetVertices();
-	CircularListElement<TMMVertex> *vHead = vertices.GetHead();
-	CircularListElement<TMMVertex> *v = vHead;
-	v = v->GetPrev();
-	do
-	{
-		if (v->GetData().m_tag && !v->GetData().m_onHull)
-		{
-			CircularListElement<TMMVertex> *tmp = v->GetPrev();
-			if (tmp == m_dummyVertex)
-				m_dummyVertex = 0;
-			vertices.Delete(v);
-			v = tmp;
-			addedPoints--;
-		}
-		else
-		{
-			v->GetData().m_duplicate = 0;
-			v->GetData().m_onHull = false;
-			v = v->GetPrev();
-		}
-	} while (v->GetData().m_tag && v != vHead);
-	return true;
-}
-void ICHull::Clear()
-{
-	m_mesh.Clear();
-	m_edgesToDelete = std::vector<CircularListElement<TMMEdge> *>();
-	m_edgesToUpdate = std::vector<CircularListElement<TMMEdge> *>();
-	m_trianglesToDelete = std::vector<CircularListElement<TMMTriangle> *>();
-	m_isFlat = false;
-}
-const ICHull &ICHull::operator=(ICHull &rhs)
-{
-	if (&rhs != this)
-	{
-		m_mesh.Copy(rhs.m_mesh);
-		m_edgesToDelete = rhs.m_edgesToDelete;
-		m_edgesToUpdate = rhs.m_edgesToUpdate;
-		m_trianglesToDelete = rhs.m_trianglesToDelete;
-		m_isFlat = rhs.m_isFlat;
-	}
-	return (*this);
-}
-double ICHull::ComputeVolume()
-{
-	size_t nV = m_mesh.m_vertices.GetSize();
-	if (nV == 0 || m_isFlat)
-	{
-		return 0.0;
-	}
-	Vec3<double> bary(0.0, 0.0, 0.0);
-	for (size_t v = 0; v < nV; v++)
-	{
-		bary.X() += m_mesh.m_vertices.GetHead()->GetData().m_pos.X();
-		bary.Y() += m_mesh.m_vertices.GetHead()->GetData().m_pos.Y();
-		bary.Z() += m_mesh.m_vertices.GetHead()->GetData().m_pos.Z();
-		m_mesh.m_vertices.Next();
-	}
-	bary /= static_cast<double>(nV);
-
-	size_t nT = m_mesh.m_triangles.GetSize();
-	Vec3<double> ver0, ver1, ver2;
-	double totalVolume = 0.0;
-	for (size_t t = 0; t < nT; t++)
-	{
-		ver0.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.X();
-		ver0.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Y();
-		ver0.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Z();
-		ver1.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.X();
-		ver1.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Y();
-		ver1.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Z();
-		ver2.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.X();
-		ver2.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Y();
-		ver2.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Z();
-		totalVolume += Volume(ver0, ver1, ver2, bary);
-		m_mesh.m_triangles.Next();
-	}
-	return totalVolume;
-}
-bool ICHull::IsInside(const Vec3<Real> &pt0)
-{
-	const Vec3<double> pt(pt0.X(), pt0.Y(), pt0.Z());
-	if (m_isFlat)
-	{
-		size_t nT = m_mesh.m_triangles.GetSize();
-		Vec3<double> ver0, ver1, ver2, a, b, c;
-		double u, v;
-		for (size_t t = 0; t < nT; t++)
-		{
-			ver0.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.X();
-			ver0.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Y();
-			ver0.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Z();
-			ver1.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.X();
-			ver1.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Y();
-			ver1.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Z();
-			ver2.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.X();
-			ver2.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Y();
-			ver2.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Z();
-			a = ver1 - ver0;
-			b = ver2 - ver0;
-			c = pt - ver0;
-			u = c * a;
-			v = c * b;
-			if (u >= 0.0 && u <= 1.0 && v >= 0.0 && u + v <= 1.0)
-			{
-				return true;
-			}
-			m_mesh.m_triangles.Next();
-		}
-		return false;
-	}
-	else
-	{
-		size_t nT = m_mesh.m_triangles.GetSize();
-		Vec3<double> ver0, ver1, ver2;
-		for (size_t t = 0; t < nT; t++)
-		{
-			ver0.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.X();
-			ver0.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Y();
-			ver0.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Z();
-			ver1.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.X();
-			ver1.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Y();
-			ver1.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Z();
-			ver2.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.X();
-			ver2.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Y();
-			ver2.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Z();
-			if (Volume(ver0, ver1, ver2, pt) < 0.0)
-			{
-				return false;
-			}
-			m_mesh.m_triangles.Next();
-		}
-		return true;
-	}
-}
-double ICHull::ComputeDistance(long name, const Vec3<Real> &pt, const Vec3<Real> &normal, bool &insideHull, bool updateIncidentPoints)
-{
-	Vec3<double> ptNormal(static_cast<double>(normal.X()),
-						  static_cast<double>(normal.Y()),
-						  static_cast<double>(normal.Z()));
-	Vec3<double> p0(static_cast<double>(pt.X()),
-					static_cast<double>(pt.Y()),
-					static_cast<double>(pt.Z()));
-
-	if (m_isFlat)
-	{
-		double distance = 0.0;
-		Vec3<double> chNormal(static_cast<double>(m_normal.X()),
-							  static_cast<double>(m_normal.Y()),
-							  static_cast<double>(m_normal.Z()));
-		ptNormal -= (ptNormal * chNormal) * chNormal;
-		if (ptNormal.GetNorm() > 0.0)
-		{
-			ptNormal.Normalize();
-			long nameVE1;
-			long nameVE2;
-			Vec3<double> pa, pb, d0, d1, d2, d3;
-			Vec3<double> p1 = p0 + ptNormal;
-			Vec3<double> p2, p3;
-			double mua, mub, s;
-			const double EPS = 0.00000000001;
-			size_t nE = m_mesh.GetNEdges();
-			for (size_t e = 0; e < nE; e++)
-			{
-				TMMEdge &currentEdge = m_mesh.m_edges.GetHead()->GetData();
-				nameVE1 = currentEdge.m_vertices[0]->GetData().m_name;
-				nameVE2 = currentEdge.m_vertices[1]->GetData().m_name;
-				if (currentEdge.m_triangles[0] == 0 || currentEdge.m_triangles[1] == 0)
-				{
-					if (nameVE1 == name || nameVE2 == name)
-					{
-						return 0.0;
-					}
-					/*
-                        if (debug) std::cout << "V" << name 
-                                             << " E "  << nameVE1 << " " << nameVE2 << std::endl;
-                         */
-
-					p2.X() = currentEdge.m_vertices[0]->GetData().m_pos.X();
-					p2.Y() = currentEdge.m_vertices[0]->GetData().m_pos.Y();
-					p2.Z() = currentEdge.m_vertices[0]->GetData().m_pos.Z();
-					p3.X() = currentEdge.m_vertices[1]->GetData().m_pos.X();
-					p3.Y() = currentEdge.m_vertices[1]->GetData().m_pos.Y();
-					p3.Z() = currentEdge.m_vertices[1]->GetData().m_pos.Z();
-					d0 = p3 - p2;
-					if (d0.GetNorm() > 0.0)
-					{
-						if (IntersectLineLine(p0, p1, p2, p3, pa, pb, mua, mub))
-						{
-							d1 = pa - p2;
-							d2 = pa - pb;
-							d3 = pa - p0;
-							mua = d1.GetNorm() / d0.GetNorm();
-							mub = d1 * d0;
-							s = d3 * ptNormal;
-							if (d2.GetNorm() < EPS && mua <= 1.0 && mub >= 0.0 && s > 0.0)
-							{
-								distance = std::max<double>(distance, d3.GetNorm());
-							}
-						}
-					}
-				}
-				m_mesh.m_edges.Next();
-			}
-		}
-		return distance;
-	}
-	else
-	{
-		Vec3<double> ptNormal(static_cast<double>(normal.X()),
-							  static_cast<double>(normal.Y()),
-							  static_cast<double>(normal.Z()));
-
-		Vec3<double> impact;
-		long nhit;
-		double dist;
-		double distance = 0.0;
-		size_t nT = m_mesh.GetNTriangles();
-		insideHull = false;
-		CircularListElement<TMMTriangle> *face = 0;
-		Vec3<double> ver0, ver1, ver2;
-		for (size_t f = 0; f < nT; f++)
-		{
-			TMMTriangle &currentTriangle = m_mesh.m_triangles.GetHead()->GetData();
-			/*
-				if (debug) std::cout << "T " << currentTriangle.m_vertices[0]->GetData().m_name << " "
-														  << currentTriangle.m_vertices[1]->GetData().m_name << " "
-														  << currentTriangle.m_vertices[2]->GetData().m_name << std::endl;
-     */
-			if (currentTriangle.m_vertices[0]->GetData().m_name == name ||
-				currentTriangle.m_vertices[1]->GetData().m_name == name ||
-				currentTriangle.m_vertices[2]->GetData().m_name == name)
-			{
-				nhit = 1;
-				dist = 0.0;
-			}
-			else
-			{
-				ver0.X() = currentTriangle.m_vertices[0]->GetData().m_pos.X();
-				ver0.Y() = currentTriangle.m_vertices[0]->GetData().m_pos.Y();
-				ver0.Z() = currentTriangle.m_vertices[0]->GetData().m_pos.Z();
-				ver1.X() = currentTriangle.m_vertices[1]->GetData().m_pos.X();
-				ver1.Y() = currentTriangle.m_vertices[1]->GetData().m_pos.Y();
-				ver1.Z() = currentTriangle.m_vertices[1]->GetData().m_pos.Z();
-				ver2.X() = currentTriangle.m_vertices[2]->GetData().m_pos.X();
-				ver2.Y() = currentTriangle.m_vertices[2]->GetData().m_pos.Y();
-				ver2.Z() = currentTriangle.m_vertices[2]->GetData().m_pos.Z();
-				nhit = IntersectRayTriangle(p0, ptNormal, ver0, ver1, ver2, dist);
-			}
-
-			if (nhit == 1 && distance <= dist)
-			{
-				distance = dist;
-				insideHull = true;
-				face = m_mesh.m_triangles.GetHead();
-				/*
-					std::cout << name << " -> T " << currentTriangle.m_vertices[0]->GetData().m_name << " "
-												  << currentTriangle.m_vertices[1]->GetData().m_name << " "
-												  << currentTriangle.m_vertices[2]->GetData().m_name << " Dist "
-												  << dist << " P " << currentTriangle.m_normal * normal << std::endl;
-*/
-				if (dist > 0.1)
-				{
-					break;
-				}
-			}
-			m_mesh.m_triangles.Next();
-		}
-		if (updateIncidentPoints && face && m_distPoints)
-		{
-			(*m_distPoints)[name].m_dist = static_cast<Real>(distance);
-			face->GetData().m_incidentPoints.insert(name);
-		}
-		return distance;
-	}
-}
-}  // namespace HACD

+ 0 - 120
ThirdParty/Bullet/Extras/HACD/hacdICHull.h

@@ -1,120 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_ICHULL_H
-#define HACD_ICHULL_H
-#include "hacdVersion.h"
-#include "hacdManifoldMesh.h"
-#include "hacdVector.h"
-#include <vector>
-#include <map>
-namespace HACD
-{
-class DPoint;
-class HACD;
-//!	Incremental Convex Hull algorithm (cf. http://maven.smith.edu/~orourke/books/ftp.html ).
-enum ICHullError
-{
-	ICHullErrorOK = 0,
-	ICHullErrorCoplanarPoints,
-	ICHullErrorNoVolume,
-	ICHullErrorInconsistent,
-	ICHullErrorNotEnoughPoints
-};
-class ICHull
-{
-public:
-	//!
-	bool IsFlat() { return m_isFlat; }
-	//!
-	std::map<long, DPoint> *GetDistPoints() const { return m_distPoints; }
-	//!
-	void SetDistPoints(std::map<long, DPoint> *distPoints) { m_distPoints = distPoints; }
-	//! Returns the computed mesh
-	TMMesh &GetMesh() { return m_mesh; }
-	//!	Add one point to the convex-hull
-	bool AddPoint(const Vec3<Real> &point) { return AddPoints(&point, 1); }
-	//!	Add one point to the convex-hull
-	bool AddPoint(const Vec3<Real> &point, long id);
-	//!	Add points to the convex-hull
-	bool AddPoints(const Vec3<Real> *points, size_t nPoints);
-	bool AddPoints(std::vector<Vec3<Real> > points);
-	//!
-	ICHullError Process();
-	//!
-	ICHullError Process(unsigned long nPointsCH);
-	//!
-	double ComputeVolume();
-	//!
-	bool IsInside(const Vec3<Real> &pt0);
-	//!
-	double ComputeDistance(long name, const Vec3<Real> &pt, const Vec3<Real> &normal, bool &insideHull, bool updateIncidentPoints);
-	//!
-	const ICHull &operator=(ICHull &rhs);
-
-	//!	Constructor
-	ICHull(void);
-	//! Destructor
-	virtual ~ICHull(void){};
-
-private:
-	//!	DoubleTriangle builds the initial double triangle.  It first finds 3 noncollinear points and makes two faces out of them, in opposite order. It then finds a fourth point that is not coplanar with that face.  The vertices are stored in the face structure in counterclockwise order so that the volume between the face and the point is negative. Lastly, the 3 newfaces to the fourth point are constructed and the data structures are cleaned up.
-	ICHullError DoubleTriangle();
-	//!	MakeFace creates a new face structure from three vertices (in ccw order).  It returns a pointer to the face.
-	CircularListElement<TMMTriangle> *MakeFace(CircularListElement<TMMVertex> *v0,
-											   CircularListElement<TMMVertex> *v1,
-											   CircularListElement<TMMVertex> *v2,
-											   CircularListElement<TMMTriangle> *fold);
-	//!
-	CircularListElement<TMMTriangle> *MakeConeFace(CircularListElement<TMMEdge> *e, CircularListElement<TMMVertex> *v);
-	//!
-	bool ProcessPoint();
-	//!
-	bool ComputePointVolume(double &totalVolume, bool markVisibleFaces);
-	//!
-	bool FindMaxVolumePoint();
-	//!
-	bool CleanEdges();
-	//!
-	bool CleanVertices(unsigned long &addedPoints);
-	//!
-	bool CleanTriangles();
-	//!
-	bool CleanUp(unsigned long &addedPoints);
-	//!
-	bool MakeCCW(CircularListElement<TMMTriangle> *f,
-				 CircularListElement<TMMEdge> *e,
-				 CircularListElement<TMMVertex> *v);
-	void Clear();
-
-private:
-	static const long sc_dummyIndex;
-	static const double sc_distMin;
-	TMMesh m_mesh;
-	std::vector<CircularListElement<TMMEdge> *> m_edgesToDelete;
-	std::vector<CircularListElement<TMMEdge> *> m_edgesToUpdate;
-	std::vector<CircularListElement<TMMTriangle> *> m_trianglesToDelete;
-	std::map<long, DPoint> *m_distPoints;
-	CircularListElement<TMMVertex> *m_dummyVertex;
-	Vec3<Real> m_normal;
-	bool m_isFlat;
-
-	ICHull(const ICHull &rhs);
-
-	friend class HACD;
-};
-
-}  // namespace HACD
-#endif

+ 0 - 582
ThirdParty/Bullet/Extras/HACD/hacdManifoldMesh.cpp

@@ -1,582 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "hacdManifoldMesh.h"
-using namespace std;
-
-namespace HACD
-{
-Material::Material(void)
-{
-	m_diffuseColor.X() = 0.5;
-	m_diffuseColor.Y() = 0.5;
-	m_diffuseColor.Z() = 0.5;
-	m_specularColor.X() = 0.5;
-	m_specularColor.Y() = 0.5;
-	m_specularColor.Z() = 0.5;
-	m_ambientIntensity = 0.4;
-	m_emissiveColor.X() = 0.0;
-	m_emissiveColor.Y() = 0.0;
-	m_emissiveColor.Z() = 0.0;
-	m_shininess = 0.4;
-	m_transparency = 0.0;
-}
-
-TMMVertex::TMMVertex(void)
-{
-	m_name = 0;
-	m_id = 0;
-	m_duplicate = 0;
-	m_onHull = false;
-	m_tag = false;
-}
-TMMVertex::~TMMVertex(void)
-{
-}
-TMMEdge::TMMEdge(void)
-{
-	m_id = 0;
-	m_triangles[0] = m_triangles[1] = m_newFace = 0;
-	m_vertices[0] = m_vertices[1] = 0;
-}
-TMMEdge::~TMMEdge(void)
-{
-}
-TMMTriangle::TMMTriangle(void)
-{
-	m_id = 0;
-	for (int i = 0; i < 3; i++)
-	{
-		m_edges[i] = 0;
-		m_vertices[0] = 0;
-	}
-	m_visible = false;
-}
-TMMTriangle::~TMMTriangle(void)
-{
-}
-TMMesh::TMMesh(void)
-{
-	m_barycenter = Vec3<Real>(0, 0, 0);
-	m_diag = 1;
-}
-TMMesh::~TMMesh(void)
-{
-}
-
-void TMMesh::Print()
-{
-	size_t nV = m_vertices.GetSize();
-	std::cout << "-----------------------------" << std::endl;
-	std::cout << "vertices (" << nV << ")" << std::endl;
-	for (size_t v = 0; v < nV; v++)
-	{
-		const TMMVertex &currentVertex = m_vertices.GetData();
-		std::cout << currentVertex.m_id << ", "
-				  << currentVertex.m_pos.X() << ", "
-				  << currentVertex.m_pos.Y() << ", "
-				  << currentVertex.m_pos.Z() << std::endl;
-		m_vertices.Next();
-	}
-
-	size_t nE = m_edges.GetSize();
-	std::cout << "edges (" << nE << ")" << std::endl;
-	for (size_t e = 0; e < nE; e++)
-	{
-		const TMMEdge &currentEdge = m_edges.GetData();
-		const CircularListElement<TMMVertex> *v0 = currentEdge.m_vertices[0];
-		const CircularListElement<TMMVertex> *v1 = currentEdge.m_vertices[1];
-		const CircularListElement<TMMTriangle> *f0 = currentEdge.m_triangles[0];
-		const CircularListElement<TMMTriangle> *f1 = currentEdge.m_triangles[1];
-
-		std::cout << "-> (" << v0->GetData().m_name << ", " << v1->GetData().m_name << ")" << std::endl;
-		std::cout << "-> F0 (" << f0->GetData().m_vertices[0]->GetData().m_name << ", "
-				  << f0->GetData().m_vertices[1]->GetData().m_name << ", "
-				  << f0->GetData().m_vertices[2]->GetData().m_name << ")" << std::endl;
-		std::cout << "-> F1 (" << f1->GetData().m_vertices[0]->GetData().m_name << ", "
-				  << f1->GetData().m_vertices[1]->GetData().m_name << ", "
-				  << f1->GetData().m_vertices[2]->GetData().m_name << ")" << std::endl;
-		m_edges.Next();
-	}
-	size_t nT = m_triangles.GetSize();
-	std::cout << "triangles (" << nT << ")" << std::endl;
-	for (size_t t = 0; t < nT; t++)
-	{
-		const TMMTriangle &currentTriangle = m_triangles.GetData();
-		const CircularListElement<TMMVertex> *v0 = currentTriangle.m_vertices[0];
-		const CircularListElement<TMMVertex> *v1 = currentTriangle.m_vertices[1];
-		const CircularListElement<TMMVertex> *v2 = currentTriangle.m_vertices[2];
-		const CircularListElement<TMMEdge> *e0 = currentTriangle.m_edges[0];
-		const CircularListElement<TMMEdge> *e1 = currentTriangle.m_edges[1];
-		const CircularListElement<TMMEdge> *e2 = currentTriangle.m_edges[2];
-
-		std::cout << "-> (" << v0->GetData().m_name << ", " << v1->GetData().m_name << ", " << v2->GetData().m_name << ")" << std::endl;
-
-		std::cout << "-> E0 (" << e0->GetData().m_vertices[0]->GetData().m_name << ", "
-				  << e0->GetData().m_vertices[1]->GetData().m_name << ")" << std::endl;
-		std::cout << "-> E1 (" << e1->GetData().m_vertices[0]->GetData().m_name << ", "
-				  << e1->GetData().m_vertices[1]->GetData().m_name << ")" << std::endl;
-		std::cout << "-> E2 (" << e2->GetData().m_vertices[0]->GetData().m_name << ", "
-				  << e2->GetData().m_vertices[1]->GetData().m_name << ")" << std::endl;
-		m_triangles.Next();
-	}
-}
-bool TMMesh::Save(const char *fileName)
-{
-	std::ofstream fout(fileName);
-	std::cout << "Saving " << fileName << std::endl;
-	if (SaveVRML2(fout))
-	{
-		fout.close();
-		return true;
-	}
-	return false;
-}
-bool TMMesh::SaveVRML2(std::ofstream &fout)
-{
-	return SaveVRML2(fout, Material());
-}
-bool TMMesh::SaveVRML2(std::ofstream &fout, const Material &material)
-{
-	if (fout.is_open())
-	{
-		size_t nV = m_vertices.GetSize();
-		size_t nT = m_triangles.GetSize();
-		fout << "#VRML V2.0 utf8" << std::endl;
-		fout << "" << std::endl;
-		fout << "# Vertices: " << nV << std::endl;
-		fout << "# Triangles: " << nT << std::endl;
-		fout << "" << std::endl;
-		fout << "Group {" << std::endl;
-		fout << "	children [" << std::endl;
-		fout << "		Shape {" << std::endl;
-		fout << "			appearance Appearance {" << std::endl;
-		fout << "				material Material {" << std::endl;
-		fout << "					diffuseColor " << material.m_diffuseColor.X() << " "
-			 << material.m_diffuseColor.Y() << " "
-			 << material.m_diffuseColor.Z() << std::endl;
-		fout << "					ambientIntensity " << material.m_ambientIntensity << std::endl;
-		fout << "					specularColor " << material.m_specularColor.X() << " "
-			 << material.m_specularColor.Y() << " "
-			 << material.m_specularColor.Z() << std::endl;
-		fout << "					emissiveColor " << material.m_emissiveColor.X() << " "
-			 << material.m_emissiveColor.Y() << " "
-			 << material.m_emissiveColor.Z() << std::endl;
-		fout << "					shininess " << material.m_shininess << std::endl;
-		fout << "					transparency " << material.m_transparency << std::endl;
-		fout << "				}" << std::endl;
-		fout << "			}" << std::endl;
-		fout << "			geometry IndexedFaceSet {" << std::endl;
-		fout << "				ccw TRUE" << std::endl;
-		fout << "				solid TRUE" << std::endl;
-		fout << "				convex TRUE" << std::endl;
-		if (GetNVertices() > 0)
-		{
-			fout << "				coord DEF co Coordinate {" << std::endl;
-			fout << "					point [" << std::endl;
-			for (size_t v = 0; v < nV; v++)
-			{
-				TMMVertex &currentVertex = m_vertices.GetData();
-				fout << "						" << currentVertex.m_pos.X() << " "
-					 << currentVertex.m_pos.Y() << " "
-					 << currentVertex.m_pos.Z() << "," << std::endl;
-				currentVertex.m_id = v;
-				m_vertices.Next();
-			}
-			fout << "					]" << std::endl;
-			fout << "				}" << std::endl;
-		}
-		if (GetNTriangles() > 0)
-		{
-			fout << "				coordIndex [ " << std::endl;
-			for (size_t f = 0; f < nT; f++)
-			{
-				TMMTriangle &currentTriangle = m_triangles.GetData();
-				fout << "						" << currentTriangle.m_vertices[0]->GetData().m_id << ", "
-					 << currentTriangle.m_vertices[1]->GetData().m_id << ", "
-					 << currentTriangle.m_vertices[2]->GetData().m_id << ", -1," << std::endl;
-				m_triangles.Next();
-			}
-			fout << "				]" << std::endl;
-		}
-		fout << "			}" << std::endl;
-		fout << "		}" << std::endl;
-		fout << "	]" << std::endl;
-		fout << "}" << std::endl;
-	}
-	return true;
-}
-void TMMesh::GetIFS(Vec3<Real> *const points, Vec3<long> *const triangles)
-{
-	size_t nV = m_vertices.GetSize();
-	size_t nT = m_triangles.GetSize();
-
-	for (size_t v = 0; v < nV; v++)
-	{
-		points[v] = m_vertices.GetData().m_pos;
-		m_vertices.GetData().m_id = v;
-		m_vertices.Next();
-	}
-	for (size_t f = 0; f < nT; f++)
-	{
-		TMMTriangle &currentTriangle = m_triangles.GetData();
-		triangles[f].X() = static_cast<long>(currentTriangle.m_vertices[0]->GetData().m_id);
-		triangles[f].Y() = static_cast<long>(currentTriangle.m_vertices[1]->GetData().m_id);
-		triangles[f].Z() = static_cast<long>(currentTriangle.m_vertices[2]->GetData().m_id);
-		m_triangles.Next();
-	}
-}
-void TMMesh::Clear()
-{
-	m_vertices.Clear();
-	m_edges.Clear();
-	m_triangles.Clear();
-}
-void TMMesh::Copy(TMMesh &mesh)
-{
-	Clear();
-	// updating the id's
-	size_t nV = mesh.m_vertices.GetSize();
-	size_t nE = mesh.m_edges.GetSize();
-	size_t nT = mesh.m_triangles.GetSize();
-	for (size_t v = 0; v < nV; v++)
-	{
-		mesh.m_vertices.GetData().m_id = v;
-		mesh.m_vertices.Next();
-	}
-	for (size_t e = 0; e < nE; e++)
-	{
-		mesh.m_edges.GetData().m_id = e;
-		mesh.m_edges.Next();
-	}
-	for (size_t f = 0; f < nT; f++)
-	{
-		mesh.m_triangles.GetData().m_id = f;
-		mesh.m_triangles.Next();
-	}
-	// copying data
-	m_vertices = mesh.m_vertices;
-	m_edges = mesh.m_edges;
-	m_triangles = mesh.m_triangles;
-
-	// generating mapping
-	CircularListElement<TMMVertex> **vertexMap = new CircularListElement<TMMVertex> *[nV];
-	CircularListElement<TMMEdge> **edgeMap = new CircularListElement<TMMEdge> *[nE];
-	CircularListElement<TMMTriangle> **triangleMap = new CircularListElement<TMMTriangle> *[nT];
-	for (size_t v = 0; v < nV; v++)
-	{
-		vertexMap[v] = m_vertices.GetHead();
-		m_vertices.Next();
-	}
-	for (size_t e = 0; e < nE; e++)
-	{
-		edgeMap[e] = m_edges.GetHead();
-		m_edges.Next();
-	}
-	for (size_t f = 0; f < nT; f++)
-	{
-		triangleMap[f] = m_triangles.GetHead();
-		m_triangles.Next();
-	}
-
-	// updating pointers
-	for (size_t v = 0; v < nV; v++)
-	{
-		if (vertexMap[v]->GetData().m_duplicate)
-		{
-			vertexMap[v]->GetData().m_duplicate = edgeMap[vertexMap[v]->GetData().m_duplicate->GetData().m_id];
-		}
-	}
-	for (size_t e = 0; e < nE; e++)
-	{
-		if (edgeMap[e]->GetData().m_newFace)
-		{
-			edgeMap[e]->GetData().m_newFace = triangleMap[edgeMap[e]->GetData().m_newFace->GetData().m_id];
-		}
-		if (nT > 0)
-		{
-			for (int f = 0; f < 2; f++)
-			{
-				if (edgeMap[e]->GetData().m_triangles[f])
-				{
-					edgeMap[e]->GetData().m_triangles[f] = triangleMap[edgeMap[e]->GetData().m_triangles[f]->GetData().m_id];
-				}
-			}
-		}
-		for (int v = 0; v < 2; v++)
-		{
-			if (edgeMap[e]->GetData().m_vertices[v])
-			{
-				edgeMap[e]->GetData().m_vertices[v] = vertexMap[edgeMap[e]->GetData().m_vertices[v]->GetData().m_id];
-			}
-		}
-	}
-	for (size_t f = 0; f < nT; f++)
-	{
-		if (nE > 0)
-		{
-			for (int e = 0; e < 3; e++)
-			{
-				if (triangleMap[f]->GetData().m_edges[e])
-				{
-					triangleMap[f]->GetData().m_edges[e] = edgeMap[triangleMap[f]->GetData().m_edges[e]->GetData().m_id];
-				}
-			}
-		}
-		for (int v = 0; v < 3; v++)
-		{
-			if (triangleMap[f]->GetData().m_vertices[v])
-			{
-				triangleMap[f]->GetData().m_vertices[v] = vertexMap[triangleMap[f]->GetData().m_vertices[v]->GetData().m_id];
-			}
-		}
-	}
-	delete[] vertexMap;
-	delete[] edgeMap;
-	delete[] triangleMap;
-}
-long IntersectRayTriangle(const Vec3<double> &P0, const Vec3<double> &dir,
-						  const Vec3<double> &V0, const Vec3<double> &V1,
-						  const Vec3<double> &V2, double &t)
-{
-	Vec3<double> edge1, edge2, edge3;
-	double det, invDet;
-	edge1 = V1 - V2;
-	edge2 = V2 - V0;
-	Vec3<double> pvec = dir ^ edge2;
-	det = edge1 * pvec;
-	if (det == 0.0)
-		return 0;
-	invDet = 1.0 / det;
-	Vec3<double> tvec = P0 - V0;
-	Vec3<double> qvec = tvec ^ edge1;
-	t = (edge2 * qvec) * invDet;
-	if (t < 0.0)
-	{
-		return 0;
-	}
-	edge3 = V0 - V1;
-	Vec3<double> I(P0 + t * dir);
-	Vec3<double> s0 = (I - V0) ^ edge3;
-	Vec3<double> s1 = (I - V1) ^ edge1;
-	Vec3<double> s2 = (I - V2) ^ edge2;
-	if (s0 * s1 > -1e-9 && s2 * s1 > -1e-9)
-	{
-		return 1;
-	}
-	return 0;
-}
-
-bool IntersectLineLine(const Vec3<double> &p1, const Vec3<double> &p2,
-					   const Vec3<double> &p3, const Vec3<double> &p4,
-					   Vec3<double> &pa, Vec3<double> &pb,
-					   double &mua, double &mub)
-{
-	Vec3<double> p13, p43, p21;
-	double d1343, d4321, d1321, d4343, d2121;
-	double numer, denom;
-
-	p13.X() = p1.X() - p3.X();
-	p13.Y() = p1.Y() - p3.Y();
-	p13.Z() = p1.Z() - p3.Z();
-	p43.X() = p4.X() - p3.X();
-	p43.Y() = p4.Y() - p3.Y();
-	p43.Z() = p4.Z() - p3.Z();
-	if (p43.X() == 0.0 && p43.Y() == 0.0 && p43.Z() == 0.0)
-		return false;
-	p21.X() = p2.X() - p1.X();
-	p21.Y() = p2.Y() - p1.Y();
-	p21.Z() = p2.Z() - p1.Z();
-	if (p21.X() == 0.0 && p21.Y() == 0.0 && p21.Z() == 0.0)
-		return false;
-
-	d1343 = p13.X() * p43.X() + p13.Y() * p43.Y() + p13.Z() * p43.Z();
-	d4321 = p43.X() * p21.X() + p43.Y() * p21.Y() + p43.Z() * p21.Z();
-	d1321 = p13.X() * p21.X() + p13.Y() * p21.Y() + p13.Z() * p21.Z();
-	d4343 = p43.X() * p43.X() + p43.Y() * p43.Y() + p43.Z() * p43.Z();
-	d2121 = p21.X() * p21.X() + p21.Y() * p21.Y() + p21.Z() * p21.Z();
-
-	denom = d2121 * d4343 - d4321 * d4321;
-	if (denom == 0.0)
-		return false;
-	numer = d1343 * d4321 - d1321 * d4343;
-
-	mua = numer / denom;
-	mub = (d1343 + d4321 * (mua)) / d4343;
-
-	pa.X() = p1.X() + mua * p21.X();
-	pa.Y() = p1.Y() + mua * p21.Y();
-	pa.Z() = p1.Z() + mua * p21.Z();
-	pb.X() = p3.X() + mub * p43.X();
-	pb.Y() = p3.Y() + mub * p43.Y();
-	pb.Z() = p3.Z() + mub * p43.Z();
-
-	return true;
-}
-
-long IntersectRayTriangle2(const Vec3<double> &P0, const Vec3<double> &dir,
-						   const Vec3<double> &V0, const Vec3<double> &V1,
-						   const Vec3<double> &V2, double &r)
-{
-	Vec3<double> u, v, n;  // triangle vectors
-	Vec3<double> w0, w;    // ray vectors
-	double a, b;           // params to calc ray-plane intersect
-
-	// get triangle edge vectors and plane normal
-	u = V1 - V0;
-	v = V2 - V0;
-	n = u ^ v;               // cross product
-	if (n.GetNorm() == 0.0)  // triangle is degenerate
-		return -1;           // do not deal with this case
-
-	w0 = P0 - V0;
-	a = -n * w0;
-	b = n * dir;
-	if (fabs(b) <= 0.0)
-	{                  // ray is parallel to triangle plane
-		if (a == 0.0)  // ray lies in triangle plane
-			return 2;
-		else
-			return 0;  // ray disjoint from plane
-	}
-
-	// get intersect point of ray with triangle plane
-	r = a / b;
-	if (r < 0.0)   // ray goes away from triangle
-		return 0;  // => no intersect
-	// for a segment, also test if (r > 1.0) => no intersect
-
-	Vec3<double> I = P0 + r * dir;  // intersect point of ray and plane
-
-	// is I inside T?
-	double uu, uv, vv, wu, wv, D;
-	uu = u * u;
-	uv = u * v;
-	vv = v * v;
-	w = I - V0;
-	wu = w * u;
-	wv = w * v;
-	D = uv * uv - uu * vv;
-
-	// get and test parametric coords
-	double s, t;
-	s = (uv * wv - vv * wu) / D;
-	if (s < 0.0 || s > 1.0)  // I is outside T
-		return 0;
-	t = (uv * wu - uu * wv) / D;
-	if (t < 0.0 || (s + t) > 1.0)  // I is outside T
-		return 0;
-	return 1;  // I is in T
-}
-
-bool TMMesh::CheckConsistancy()
-{
-	size_t nE = m_edges.GetSize();
-	size_t nT = m_triangles.GetSize();
-	for (size_t e = 0; e < nE; e++)
-	{
-		for (int f = 0; f < 2; f++)
-		{
-			if (!m_edges.GetHead()->GetData().m_triangles[f])
-			{
-				return false;
-			}
-		}
-		m_edges.Next();
-	}
-
-	for (size_t f = 0; f < nT; f++)
-	{
-		for (int e = 0; e < 3; e++)
-		{
-			int found = 0;
-			for (int k = 0; k < 2; k++)
-			{
-				if (m_triangles.GetHead()->GetData().m_edges[e]->GetData().m_triangles[k] == m_triangles.GetHead())
-				{
-					found++;
-				}
-			}
-			if (found != 1)
-			{
-				return false;
-			}
-		}
-		m_triangles.Next();
-	}
-
-	return true;
-}
-bool TMMesh::Normalize()
-{
-	size_t nV = m_vertices.GetSize();
-	if (nV == 0)
-	{
-		return false;
-	}
-	m_barycenter = m_vertices.GetHead()->GetData().m_pos;
-	Vec3<Real> min = m_barycenter;
-	Vec3<Real> max = m_barycenter;
-	Real x, y, z;
-	for (size_t v = 1; v < nV; v++)
-	{
-		m_barycenter += m_vertices.GetHead()->GetData().m_pos;
-		x = m_vertices.GetHead()->GetData().m_pos.X();
-		y = m_vertices.GetHead()->GetData().m_pos.Y();
-		z = m_vertices.GetHead()->GetData().m_pos.Z();
-		if (x < min.X())
-			min.X() = x;
-		else if (x > max.X())
-			max.X() = x;
-		if (y < min.Y())
-			min.Y() = y;
-		else if (y > max.Y())
-			max.Y() = y;
-		if (z < min.Z())
-			min.Z() = z;
-		else if (z > max.Z())
-			max.Z() = z;
-		m_vertices.Next();
-	}
-	m_barycenter /= static_cast<Real>(nV);
-	m_diag = static_cast<Real>(0.001 * (max - min).GetNorm());
-	const Real invDiag = static_cast<Real>(1.0 / m_diag);
-	if (m_diag != 0.0)
-	{
-		for (size_t v = 0; v < nV; v++)
-		{
-			m_vertices.GetHead()->GetData().m_pos = (m_vertices.GetHead()->GetData().m_pos - m_barycenter) * invDiag;
-			m_vertices.Next();
-		}
-	}
-	return true;
-}
-bool TMMesh::Denormalize()
-{
-	size_t nV = m_vertices.GetSize();
-	if (nV == 0)
-	{
-		return false;
-	}
-	if (m_diag != 0.0)
-	{
-		for (size_t v = 0; v < nV; v++)
-		{
-			m_vertices.GetHead()->GetData().m_pos = m_vertices.GetHead()->GetData().m_pos * m_diag + m_barycenter;
-			m_vertices.Next();
-		}
-	}
-	return false;
-}
-}  // namespace HACD

+ 0 - 251
ThirdParty/Bullet/Extras/HACD/hacdManifoldMesh.h

@@ -1,251 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
-All rights reserved.
-
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_MANIFOLD_MESH_H
-#define HACD_MANIFOLD_MESH_H
-#include <iostream>
-#include <fstream>
-#include "hacdVersion.h"
-#include "hacdCircularList.h"
-#include "hacdVector.h"
-#include <set>
-namespace HACD
-{
-class TMMTriangle;
-class TMMEdge;
-class TMMesh;
-class ICHull;
-class HACD;
-
-class DPoint
-{
-public:
-	DPoint(Real dist = 0, bool computed = false, bool distOnly = false)
-		: m_dist(dist),
-		  m_computed(computed),
-		  m_distOnly(distOnly){};
-	~DPoint(){};
-
-private:
-	Real m_dist;
-	bool m_computed;
-	bool m_distOnly;
-	friend class TMMTriangle;
-	friend class TMMesh;
-	friend class GraphVertex;
-	friend class GraphEdge;
-	friend class Graph;
-	friend class ICHull;
-	friend class HACD;
-};
-
-//!	Vertex data structure used in a triangular manifold mesh (TMM).
-class TMMVertex
-{
-public:
-	TMMVertex(void);
-	~TMMVertex(void);
-
-private:
-	Vec3<Real> m_pos;
-	long m_name;
-	size_t m_id;
-	CircularListElement<TMMEdge> *m_duplicate;  // pointer to incident cone edge (or NULL)
-	bool m_onHull;
-	bool m_tag;
-	TMMVertex(const TMMVertex &rhs);
-
-	friend class HACD;
-	friend class ICHull;
-	friend class TMMesh;
-	friend class TMMTriangle;
-	friend class TMMEdge;
-};
-
-//!	Edge data structure used in a triangular manifold mesh (TMM).
-class TMMEdge
-{
-public:
-	TMMEdge(void);
-	~TMMEdge(void);
-
-private:
-	size_t m_id;
-	CircularListElement<TMMTriangle> *m_triangles[2];
-	CircularListElement<TMMVertex> *m_vertices[2];
-	CircularListElement<TMMTriangle> *m_newFace;
-
-	TMMEdge(const TMMEdge &rhs);
-
-	friend class HACD;
-	friend class ICHull;
-	friend class TMMTriangle;
-	friend class TMMVertex;
-	friend class TMMesh;
-};
-
-//!	Triangle data structure used in a triangular manifold mesh (TMM).
-class TMMTriangle
-{
-public:
-	TMMTriangle(void);
-	~TMMTriangle(void);
-
-private:
-	size_t m_id;
-	CircularListElement<TMMEdge> *m_edges[3];
-	CircularListElement<TMMVertex> *m_vertices[3];
-	std::set<long> m_incidentPoints;
-	bool m_visible;
-
-	TMMTriangle(const TMMTriangle &rhs);
-
-	friend class HACD;
-	friend class ICHull;
-	friend class TMMesh;
-	friend class TMMVertex;
-	friend class TMMEdge;
-};
-
-class Material
-{
-public:
-	Material(void);
-	~Material(void) {}
-	//    private:
-	Vec3<double> m_diffuseColor;
-	double m_ambientIntensity;
-	Vec3<double> m_specularColor;
-	Vec3<double> m_emissiveColor;
-	double m_shininess;
-	double m_transparency;
-
-	friend class TMMesh;
-	friend class HACD;
-};
-
-//!	triangular manifold mesh data structure.
-class TMMesh
-{
-public:
-	//! Returns the number of vertices>
-	inline size_t GetNVertices() const { return m_vertices.GetSize(); }
-	//! Returns the number of edges
-	inline size_t GetNEdges() const { return m_edges.GetSize(); }
-	//! Returns the number of triangles
-	inline size_t GetNTriangles() const { return m_triangles.GetSize(); }
-	//! Returns the vertices circular list
-	inline const CircularList<TMMVertex> &GetVertices() const { return m_vertices; }
-	//! Returns the edges circular list
-	inline const CircularList<TMMEdge> &GetEdges() const { return m_edges; }
-	//! Returns the triangles circular list
-	inline const CircularList<TMMTriangle> &GetTriangles() const { return m_triangles; }
-	//! Returns the vertices circular list
-	inline CircularList<TMMVertex> &GetVertices() { return m_vertices; }
-	//! Returns the edges circular list
-	inline CircularList<TMMEdge> &GetEdges() { return m_edges; }
-	//! Returns the triangles circular list
-	inline CircularList<TMMTriangle> &GetTriangles() { return m_triangles; }
-	//! Add vertex to the mesh
-	CircularListElement<TMMVertex> *AddVertex() { return m_vertices.Add(); }
-	//! Add vertex to the mesh
-	CircularListElement<TMMEdge> *AddEdge() { return m_edges.Add(); }
-	//! Add vertex to the mesh
-	CircularListElement<TMMTriangle> *AddTriangle() { return m_triangles.Add(); }
-	//! Print mesh information
-	void Print();
-	//!
-	void GetIFS(Vec3<Real> *const points, Vec3<long> *const triangles);
-	//! Save mesh
-	bool Save(const char *fileName);
-	//! Save mesh to VRML 2.0 format
-	bool SaveVRML2(std::ofstream &fout);
-	//! Save mesh to VRML 2.0 format
-	bool SaveVRML2(std::ofstream &fout, const Material &material);
-	//!
-	void Clear();
-	//!
-	void Copy(TMMesh &mesh);
-	//!
-	bool CheckConsistancy();
-	//!
-	bool Normalize();
-	//!
-	bool Denormalize();
-	//!	Constructor
-	TMMesh(void);
-	//! Destructor
-	virtual ~TMMesh(void);
-
-private:
-	CircularList<TMMVertex> m_vertices;
-	CircularList<TMMEdge> m_edges;
-	CircularList<TMMTriangle> m_triangles;
-	Real m_diag;              //>! length of the BB diagonal
-	Vec3<Real> m_barycenter;  //>! barycenter of the mesh
-
-	// not defined
-	TMMesh(const TMMesh &rhs);
-	friend class ICHull;
-	friend class HACD;
-};
-//! IntersectRayTriangle(): intersect a ray with a 3D triangle
-//!    Input:  a ray R, and a triangle T
-//!    Output: *I = intersection point (when it exists)
-//!             0 = disjoint (no intersect)
-//!             1 = intersect in unique point I1
-long IntersectRayTriangle(const Vec3<double> &P0, const Vec3<double> &dir,
-						  const Vec3<double> &V0, const Vec3<double> &V1,
-						  const Vec3<double> &V2, double &t);
-
-// intersect_RayTriangle(): intersect a ray with a 3D triangle
-//    Input:  a ray R, and a triangle T
-//    Output: *I = intersection point (when it exists)
-//    Return: -1 = triangle is degenerate (a segment or point)
-//             0 = disjoint (no intersect)
-//             1 = intersect in unique point I1
-//             2 = are in the same plane
-long IntersectRayTriangle2(const Vec3<double> &P0, const Vec3<double> &dir,
-						   const Vec3<double> &V0, const Vec3<double> &V1,
-						   const Vec3<double> &V2, double &r);
-
-/*
-     Calculate the line segment PaPb that is the shortest route between
-     two lines P1P2 and P3P4. Calculate also the values of mua and mub where
-     Pa = P1 + mua (P2 - P1)
-     Pb = P3 + mub (P4 - P3)
-     Return FALSE if no solution exists.
-     */
-bool IntersectLineLine(const Vec3<double> &p1, const Vec3<double> &p2,
-					   const Vec3<double> &p3, const Vec3<double> &p4,
-					   Vec3<double> &pa, Vec3<double> &pb,
-					   double &mua, double &mub);
-}  // namespace HACD
-#endif

+ 0 - 68
ThirdParty/Bullet/Extras/HACD/hacdVector.h

@@ -1,68 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_VECTOR_H
-#define HACD_VECTOR_H
-#include <math.h>
-#include <iostream>
-#include "hacdVersion.h"
-
-namespace HACD
-{
-typedef double Real;
-//!	Vector dim 3.
-template <typename T>
-class Vec3
-{
-public:
-	T& X();
-	T& Y();
-	T& Z();
-	const T& X() const;
-	const T& Y() const;
-	const T& Z() const;
-	void Normalize();
-	T GetNorm() const;
-	void operator=(const Vec3& rhs);
-	void operator+=(const Vec3& rhs);
-	void operator-=(const Vec3& rhs);
-	void operator-=(T a);
-	void operator+=(T a);
-	void operator/=(T a);
-	void operator*=(T a);
-	Vec3 operator^(const Vec3& rhs) const;
-	T operator*(const Vec3& rhs) const;
-	Vec3 operator+(const Vec3& rhs) const;
-	Vec3 operator-(const Vec3& rhs) const;
-	Vec3 operator-() const;
-	Vec3 operator*(T rhs) const;
-	Vec3 operator/(T rhs) const;
-	Vec3();
-	Vec3(T a);
-	Vec3(T x, T y, T z);
-	Vec3(const Vec3& rhs);
-	/*virtual*/ ~Vec3(void);
-
-private:
-	T m_data[3];
-};
-template <typename T>
-bool Colinear(const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c);
-template <typename T>
-const T Volume(const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c, const Vec3<T>& d);
-
-}  // namespace HACD
-#include "hacdVector.inl"  // template implementation
-#endif

+ 0 - 178
ThirdParty/Bullet/Extras/HACD/hacdVector.inl

@@ -1,178 +0,0 @@
-#pragma once
-#ifndef HACD_VECTOR_INL
-#define HACD_VECTOR_INL
-namespace HACD
-{
-	template <typename T> 
-	inline Vec3<T> operator*(T lhs, const Vec3<T> & rhs)
-	{
-		return Vec3<T>(lhs * rhs.X(), lhs * rhs.Y(), lhs * rhs.Z());
-	}
-	template <typename T> 
-	inline T & Vec3<T>::X() 
-	{
-		return m_data[0];
-	}
-	template <typename T>	
-	inline  T &	Vec3<T>::Y() 
-	{
-		return m_data[1];
-	}
-	template <typename T>	
-	inline  T &	Vec3<T>::Z() 
-	{
-		return m_data[2];
-	}
-	template <typename T>	
-	inline  const T & Vec3<T>::X() const 
-	{
-		return m_data[0];
-	}
-	template <typename T>	
-	inline  const T & Vec3<T>::Y() const 
-	{
-		return m_data[1];
-	}
-	template <typename T>	
-	inline  const T & Vec3<T>::Z() const 
-	{
-		return m_data[2];
-	}
-	template <typename T>	
-	inline  void Vec3<T>::Normalize()
-	{
-		T n = sqrt(m_data[0]*m_data[0]+m_data[1]*m_data[1]+m_data[2]*m_data[2]);
-		if (n != 0.0) (*this) /= n;
-	}
-	template <typename T>	
-	inline  T Vec3<T>::GetNorm() const 
-	{ 
-		return sqrt(m_data[0]*m_data[0]+m_data[1]*m_data[1]+m_data[2]*m_data[2]);
-	}
-	template <typename T>	
-	inline  void Vec3<T>::operator= (const Vec3 & rhs)
-	{ 
-		this->m_data[0] = rhs.m_data[0]; 
-		this->m_data[1] = rhs.m_data[1]; 
-		this->m_data[2] = rhs.m_data[2]; 
-	}
-	template <typename T>	
-	inline  void Vec3<T>::operator+=(const Vec3 & rhs)
-	{ 
-		this->m_data[0] += rhs.m_data[0]; 
-		this->m_data[1] += rhs.m_data[1]; 
-		this->m_data[2] += rhs.m_data[2]; 
-	}     
-	template <typename T>  
-	inline void Vec3<T>::operator-=(const Vec3 & rhs)
-	{ 
-		this->m_data[0] -= rhs.m_data[0]; 
-		this->m_data[1] -= rhs.m_data[1]; 
-		this->m_data[2] -= rhs.m_data[2]; 
-	}
-	template <typename T>  
-	inline void Vec3<T>::operator-=(T a)
-	{ 
-		this->m_data[0] -= a; 
-		this->m_data[1] -= a; 
-		this->m_data[2] -= a; 
-	}
-	template <typename T>  
-	inline void Vec3<T>::operator+=(T a)
-	{ 
-		this->m_data[0] += a; 
-		this->m_data[1] += a; 
-		this->m_data[2] += a; 
-	}
-	template <typename T>  
-	inline void Vec3<T>::operator/=(T a)
-	{ 
-		this->m_data[0] /= a; 
-		this->m_data[1] /= a; 
-		this->m_data[2] /= a; 
-	}
-	template <typename T>  
-	inline void Vec3<T>::operator*=(T a)
-	{ 
-		this->m_data[0] *= a; 
-		this->m_data[1] *= a; 
-		this->m_data[2] *= a; 
-	}  
-	template <typename T>	
-	inline Vec3<T> Vec3<T>::operator^ (const Vec3<T> & rhs) const
-	{
-		return Vec3<T>(m_data[1] * rhs.m_data[2] - m_data[2] * rhs.m_data[1],
-					   m_data[2] * rhs.m_data[0] - m_data[0] * rhs.m_data[2],
-					   m_data[0] * rhs.m_data[1] - m_data[1] * rhs.m_data[0]);
-	}
-	template <typename T>
-	inline T Vec3<T>::operator*(const Vec3<T> & rhs) const
-	{
-		return (m_data[0] * rhs.m_data[0] + m_data[1] * rhs.m_data[1] + m_data[2] * rhs.m_data[2]);
-	}        
-	template <typename T>
-	inline Vec3<T> Vec3<T>::operator+(const Vec3<T> & rhs) const
-	{
-		return Vec3<T>(m_data[0] + rhs.m_data[0],m_data[1] + rhs.m_data[1],m_data[2] + rhs.m_data[2]);
-	}
-	template <typename T> 
-	inline  Vec3<T> Vec3<T>::operator-(const Vec3<T> & rhs) const
-	{
-		return Vec3<T>(m_data[0] - rhs.m_data[0],m_data[1] - rhs.m_data[1],m_data[2] - rhs.m_data[2]) ;
-	}     
-	template <typename T> 
-	inline  Vec3<T> Vec3<T>::operator-() const
-	{
-		return Vec3<T>(-m_data[0],-m_data[1],-m_data[2]) ;
-	}     
-
-	template <typename T> 
-	inline Vec3<T> Vec3<T>::operator*(T rhs) const
-	{
-		return Vec3<T>(rhs * this->m_data[0], rhs * this->m_data[1], rhs * this->m_data[2]);
-	}
-	template <typename T>
-	inline Vec3<T> Vec3<T>::operator/ (T rhs) const
-	{
-		return Vec3<T>(m_data[0] / rhs, m_data[1] / rhs, m_data[2] / rhs);
-	}
-	template <typename T>
-	inline Vec3<T>::Vec3(T a) 
-	{ 
-		m_data[0] = m_data[1] = m_data[2] = a; 
-	}
-	template <typename T>
-	inline Vec3<T>::Vec3(T x, T y, T z)
-	{
-		m_data[0] = x;
-		m_data[1] = y;
-		m_data[2] = z;
-	}
-	template <typename T>
-	inline Vec3<T>::Vec3(const Vec3 & rhs)
-	{		
-		m_data[0] = rhs.m_data[0];
-		m_data[1] = rhs.m_data[1];
-		m_data[2] = rhs.m_data[2];
-	}
-	template <typename T>
-	inline Vec3<T>::~Vec3(void){};
-
-	template <typename T>
-	inline Vec3<T>::Vec3() {}
-    
-    template<typename T>
-    inline bool Colinear(const Vec3<T> & a, const Vec3<T> & b, const Vec3<T> & c)
-    {
-        return  ((c.Z() - a.Z()) * (b.Y() - a.Y()) - (b.Z() - a.Z()) * (c.Y() - a.Y()) == 0.0 /*EPS*/) &&
-                ((b.Z() - a.Z()) * (c.X() - a.X()) - (b.X() - a.X()) * (c.Z() - a.Z()) == 0.0 /*EPS*/) &&
-                ((b.X() - a.X()) * (c.Y() - a.Y()) - (b.Y() - a.Y()) * (c.X() - a.X()) == 0.0 /*EPS*/);
-    }
-    
-    template<typename T>
-    inline const T Volume(const Vec3<T> & a, const Vec3<T> & b, const Vec3<T> & c, const Vec3<T> & d)
-    {
-        return (a-d) * ((b-d) ^ (c-d));
-    }
-}
-#endif //HACD_VECTOR_INL

+ 0 - 20
ThirdParty/Bullet/Extras/HACD/hacdVersion.h

@@ -1,20 +0,0 @@
-/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
- All rights reserved.
- 
- 
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 
- 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#pragma once
-#ifndef HACD_VERSION_H
-#define HACD_VERSION_H
-#define HACD_VERSION_MAJOR 0
-#define HACD_VERSION_MINOR 0
-#endif

+ 0 - 12
ThirdParty/Bullet/Extras/HACD/premake4.lua

@@ -1,12 +0,0 @@
-	project "HACD"
-		
-	kind "StaticLib"
-	
-	includedirs {"."}
-    if os.is("Linux") then
-        buildoptions{"-fPIC"}
-    end
-	files {
-		"**.cpp",
-		"**.h"
-	}

+ 0 - 15
ThirdParty/Bullet/Extras/InverseDynamics/BulletInverseDynamicsUtilsCommon.h

@@ -1,15 +0,0 @@
-#ifndef BULLET_INVERSE_DYNAMICS_UTILS_COMMON_H
-#define BULLET_INVERSE_DYNAMICS_UTILS_COMMON_H
-#include "CoilCreator.hpp"
-#include "MultiBodyTreeCreator.hpp"
-#include "btMultiBodyFromURDF.hpp"
-#include "DillCreator.hpp"
-#include "MultiBodyTreeDebugGraph.hpp"
-#include "btMultiBodyTreeCreator.hpp"
-#include "IDRandomUtil.hpp"
-#include "SimpleTreeCreator.hpp"
-#include "invdyn_bullet_comparison.hpp"
-#include "MultiBodyNameMap.hpp"
-#include "User2InternalIndex.hpp"
-
-#endif  //BULLET_INVERSE_DYNAMICS_UTILS_COMMON_H

+ 0 - 50
ThirdParty/Bullet/Extras/InverseDynamics/CMakeLists.txt

@@ -1,50 +0,0 @@
-INCLUDE_DIRECTORIES(
-	${BULLET_PHYSICS_SOURCE_DIR}/src
-)
-
-ADD_LIBRARY(
-BulletInverseDynamicsUtils
-CloneTreeCreator.cpp
-CoilCreator.cpp
-MultiBodyTreeCreator.cpp
-btMultiBodyTreeCreator.cpp
-DillCreator.cpp
-MultiBodyTreeDebugGraph.cpp
-invdyn_bullet_comparison.cpp
-IDRandomUtil.cpp
-RandomTreeCreator.cpp
-SimpleTreeCreator.cpp
-MultiBodyNameMap.cpp
-User2InternalIndex.cpp
-)
-
-SET_TARGET_PROPERTIES(BulletInverseDynamicsUtils PROPERTIES VERSION ${BULLET_VERSION})
-SET_TARGET_PROPERTIES(BulletInverseDynamicsUtils PROPERTIES SOVERSION ${BULLET_VERSION})
-
-IF (BUILD_SHARED_LIBS)
-	TARGET_LINK_LIBRARIES(BulletInverseDynamicsUtils BulletInverseDynamics BulletDynamics BulletCollision Bullet3Common LinearMath)
-ENDIF (BUILD_SHARED_LIBS)
-
-IF (INSTALL_EXTRA_LIBS)
-	IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-		#FILES_MATCHING requires CMake 2.6
-		IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-			IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS BulletInverseDynamicsUtils  DESTINATION .)
-			ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-				INSTALL(TARGETS BulletInverseDynamicsUtils
-                                        RUNTIME DESTINATION bin
-                                        LIBRARY DESTINATION lib${LIB_SUFFIX}
-                                        ARCHIVE DESTINATION lib${LIB_SUFFIX})
-				INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h"  PATTERN
-".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
-			ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-		ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-
-		IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-			SET_TARGET_PROPERTIES(BulletInverseDynamicsUtils  PROPERTIES FRAMEWORK true)
-			SET_TARGET_PROPERTIES(BulletInverseDynamicsUtils PROPERTIES PUBLIC_HEADER "BulletInverseDynamicsUtilsCommon.h" )
-		ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
-	ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
-ENDIF (INSTALL_EXTRA_LIBS)

+ 0 - 59
ThirdParty/Bullet/Extras/InverseDynamics/CloneTreeCreator.cpp

@@ -1,59 +0,0 @@
-#include "CloneTreeCreator.hpp"
-
-#include <cstdio>
-
-namespace btInverseDynamics
-{
-#define CHECK_NULLPTR()                                  \
-	do                                                   \
-	{                                                    \
-		if (m_reference == 0x0)                          \
-		{                                                \
-			bt_id_error_message("m_reference == 0x0\n"); \
-			return -1;                                   \
-		}                                                \
-	} while (0)
-
-#define TRY(x)                                             \
-	do                                                     \
-	{                                                      \
-		if (x == -1)                                       \
-		{                                                  \
-			bt_id_error_message("error calling " #x "\n"); \
-			return -1;                                     \
-		}                                                  \
-	} while (0)
-CloneTreeCreator::CloneTreeCreator(const MultiBodyTree* reference)
-{
-	m_reference = reference;
-}
-
-CloneTreeCreator::~CloneTreeCreator() {}
-
-int CloneTreeCreator::getNumBodies(int* num_bodies) const
-{
-	CHECK_NULLPTR();
-	*num_bodies = m_reference->numBodies();
-	return 0;
-}
-
-int CloneTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
-							  vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
-							  vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
-							  mat33* body_I_body, int* user_int, void** user_ptr) const
-{
-	CHECK_NULLPTR();
-	TRY(m_reference->getParentIndex(body_index, parent_index));
-	TRY(m_reference->getJointType(body_index, joint_type));
-	TRY(m_reference->getParentRParentBodyRef(body_index, parent_r_parent_body_ref));
-	TRY(m_reference->getBodyTParentRef(body_index, body_T_parent_ref));
-	TRY(m_reference->getBodyAxisOfMotion(body_index, body_axis_of_motion));
-	TRY(m_reference->getBodyMass(body_index, mass));
-	TRY(m_reference->getBodyFirstMassMoment(body_index, body_r_body_com));
-	TRY(m_reference->getBodySecondMassMoment(body_index, body_I_body));
-	TRY(m_reference->getUserInt(body_index, user_int));
-	TRY(m_reference->getUserPtr(body_index, user_ptr));
-
-	return 0;
-}
-}  // namespace btInverseDynamics

+ 0 - 29
ThirdParty/Bullet/Extras/InverseDynamics/CloneTreeCreator.hpp

@@ -1,29 +0,0 @@
-#ifndef CLONETREE_CREATOR_HPP_
-#define CLONETREE_CREATOR_HPP_
-
-#include "BulletInverseDynamics/IDConfig.hpp"
-#include "MultiBodyTreeCreator.hpp"
-
-namespace btInverseDynamics
-{
-/// Generate an identical multibody tree from a reference system.
-class CloneTreeCreator : public MultiBodyTreeCreator
-{
-public:
-	/// ctor
-	/// @param reference the MultiBodyTree to clone
-	CloneTreeCreator(const MultiBodyTree* reference);
-	~CloneTreeCreator();
-	///\copydoc MultiBodyTreeCreator::getNumBodies
-	int getNumBodies(int* num_bodies) const;
-	///\copydoc MultiBodyTreeCreator::getBody
-	int getBody(const int body_index, int* parent_index, JointType* joint_type,
-				vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref, vec3* body_axis_of_motion,
-				idScalar* mass, vec3* body_r_body_com, mat33* body_I_body, int* user_int,
-				void** user_ptr) const;
-
-private:
-	const MultiBodyTree* m_reference;
-};
-}  // namespace btInverseDynamics
-#endif  // CLONETREE_CREATOR_HPP_

+ 0 - 73
ThirdParty/Bullet/Extras/InverseDynamics/CoilCreator.cpp

@@ -1,73 +0,0 @@
-#include <cmath>
-
-#include "CoilCreator.hpp"
-
-namespace btInverseDynamics
-{
-CoilCreator::CoilCreator(int n) : m_num_bodies(n), m_parent(n)
-{
-	for (int i = 0; i < m_num_bodies; i++)
-	{
-		m_parent[i] = i - 1;
-	}
-
-	// DH parameters (that's what's in the paper ...)
-	const idScalar theta_DH = 0;
-	const idScalar d_DH = 0.0;
-	const idScalar a_DH = 1.0 / m_num_bodies;
-	const idScalar alpha_DH = 5.0 * BT_ID_PI / m_num_bodies;
-	getVecMatFromDH(theta_DH, d_DH, a_DH, alpha_DH, &m_parent_r_parent_body_ref,
-					&m_body_T_parent_ref);
-	// always z-axis
-	m_body_axis_of_motion(0) = 0.0;
-	m_body_axis_of_motion(1) = 0.0;
-	m_body_axis_of_motion(2) = 1.0;
-
-	m_mass = 1.0 / m_num_bodies;
-	m_body_r_body_com(0) = 1.0 / (2.0 * m_num_bodies);
-	m_body_r_body_com(1) = 0.0;
-	m_body_r_body_com(2) = 0.0;
-
-	m_body_I_body(0, 0) = 1e-4 / (2.0 * m_num_bodies);
-	m_body_I_body(0, 1) = 0.0;
-	m_body_I_body(0, 2) = 0.0;
-	m_body_I_body(1, 0) = 0.0;
-	m_body_I_body(1, 1) = (3e-4 + 4.0 / BT_ID_POW(m_num_bodies, 2)) / (12.0 * m_num_bodies);
-	m_body_I_body(1, 2) = 0.0;
-	m_body_I_body(2, 0) = 0.0;
-	m_body_I_body(2, 1) = 0.0;
-	m_body_I_body(2, 2) = m_body_I_body(1, 1);
-}
-
-CoilCreator::~CoilCreator() {}
-
-int CoilCreator::getNumBodies(int* num_bodies) const
-{
-	*num_bodies = m_num_bodies;
-	return 0;
-}
-
-int CoilCreator::getBody(int body_index, int* parent_index, JointType* joint_type,
-						 vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
-						 vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
-						 mat33* body_I_body, int* user_int, void** user_ptr) const
-{
-	if (body_index < 0 || body_index >= m_num_bodies)
-	{
-		bt_id_error_message("invalid body index %d\n", body_index);
-		return -1;
-	}
-	*parent_index = m_parent[body_index];
-	*joint_type = REVOLUTE;
-	*parent_r_parent_body_ref = m_parent_r_parent_body_ref;
-	*body_T_parent_ref = m_body_T_parent_ref;
-	*body_axis_of_motion = m_body_axis_of_motion;
-	*mass = m_mass;
-	*body_r_body_com = m_body_r_body_com;
-	*body_I_body = m_body_I_body;
-
-	*user_int = 0;
-	*user_ptr = 0;
-	return 0;
-}
-}  // namespace btInverseDynamics

+ 0 - 41
ThirdParty/Bullet/Extras/InverseDynamics/CoilCreator.hpp

@@ -1,41 +0,0 @@
-#ifndef COILCREATOR_HPP_
-#define COILCREATOR_HPP_
-
-#include "MultiBodyTreeCreator.hpp"
-
-namespace btInverseDynamics
-{
-/// Creator class for building a "coil" system as intruduced as benchmark example in
-/// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n))
-/// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.",  The International
-/// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628.
-///
-/// This is a serial chain, with an initial configuration resembling a coil.
-class CoilCreator : public MultiBodyTreeCreator
-{
-public:
-	/// ctor.
-	/// @param n the number of bodies in the system
-	CoilCreator(int n);
-	/// dtor
-	~CoilCreator();
-	// \copydoc MultiBodyTreeCreator::getNumBodies
-	int getNumBodies(int* num_bodies) const;
-	// \copydoc MultiBodyTreeCreator::getBody
-	int getBody(const int body_index, int* parent_index, JointType* joint_type,
-				vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref, vec3* body_axis_of_motion,
-				idScalar* mass, vec3* body_r_body_com, mat33* body_I_body, int* user_int,
-				void** user_ptr) const;
-
-private:
-	int m_num_bodies;
-	std::vector<int> m_parent;
-	vec3 m_parent_r_parent_body_ref;
-	mat33 m_body_T_parent_ref;
-	vec3 m_body_axis_of_motion;
-	idScalar m_mass;
-	vec3 m_body_r_body_com;
-	mat33 m_body_I_body;
-};
-}  // namespace btInverseDynamics
-#endif

+ 0 - 136
ThirdParty/Bullet/Extras/InverseDynamics/DillCreator.cpp

@@ -1,136 +0,0 @@
-#include "DillCreator.hpp"
-#include <cmath>
-namespace btInverseDynamics
-{
-DillCreator::DillCreator(int level)
-	: m_level(level),
-	  m_num_bodies(BT_ID_POW(2, level))
-{
-	m_parent.resize(m_num_bodies);
-	m_parent_r_parent_body_ref.resize(m_num_bodies);
-	m_body_T_parent_ref.resize(m_num_bodies);
-	m_body_axis_of_motion.resize(m_num_bodies);
-	m_mass.resize(m_num_bodies);
-	m_body_r_body_com.resize(m_num_bodies);
-	m_body_I_body.resize(m_num_bodies);
-
-	// generate names (for debugging)
-	for (int i = 0; i < m_num_bodies; i++)
-	{
-		m_parent[i] = i - 1;
-
-		// all z-axis (DH convention)
-		m_body_axis_of_motion[i](0) = 0.0;
-		m_body_axis_of_motion[i](1) = 0.0;
-		m_body_axis_of_motion[i](2) = 1.0;
-	}
-
-	// recursively build data structures
-	m_current_body = 0;
-	const int parent = -1;
-	const idScalar d_DH = 0.0;
-	const idScalar a_DH = 0.0;
-	const idScalar alpha_DH = 0.0;
-
-	if (-1 == recurseDill(m_level, parent, d_DH, a_DH, alpha_DH))
-	{
-		bt_id_error_message("recurseDill failed\n");
-		abort();
-	}
-}
-
-DillCreator::~DillCreator() {}
-
-int DillCreator::getNumBodies(int* num_bodies) const
-{
-	*num_bodies = m_num_bodies;
-	return 0;
-}
-
-int DillCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
-						 vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
-						 vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
-						 mat33* body_I_body, int* user_int, void** user_ptr) const
-{
-	if (body_index < 0 || body_index >= m_num_bodies)
-	{
-		bt_id_error_message("invalid body index %d\n", body_index);
-		return -1;
-	}
-	*parent_index = m_parent[body_index];
-	*joint_type = REVOLUTE;
-	*parent_r_parent_body_ref = m_parent_r_parent_body_ref[body_index];
-	*body_T_parent_ref = m_body_T_parent_ref[body_index];
-	*body_axis_of_motion = m_body_axis_of_motion[body_index];
-	*mass = m_mass[body_index];
-	*body_r_body_com = m_body_r_body_com[body_index];
-	*body_I_body = m_body_I_body[body_index];
-
-	*user_int = 0;
-	*user_ptr = 0;
-	return 0;
-}
-
-int DillCreator::recurseDill(const int level, const int parent, const idScalar d_DH_in,
-							 const idScalar a_DH_in, const idScalar alpha_DH_in)
-{
-	if (level < 0)
-	{
-		bt_id_error_message("invalid level parameter (%d)\n", level);
-		return -1;
-	}
-
-	if (m_current_body >= m_num_bodies || m_current_body < 0)
-	{
-		bt_id_error_message("invalid body parameter (%d, num_bodies: %d)\n", m_current_body,
-							m_num_bodies);
-		return -1;
-	}
-
-	idScalar size = BT_ID_MAX(level, 1);
-	const int body = m_current_body;
-	//  length = 0.1 * size;
-	//  with = 2 * 0.01 * size;
-
-	/// these parameters are from the paper ...
-	/// TODO: add proper citation
-	m_parent[body] = parent;
-	m_mass[body] = 0.1 * BT_ID_POW(size, 3);
-	m_body_r_body_com[body](0) = 0.05 * size;
-	m_body_r_body_com[body](1) = 0;
-	m_body_r_body_com[body](2) = 0;
-	// initialization
-	for (int i = 0; i < 3; i++)
-	{
-		m_parent_r_parent_body_ref[body](i) = 0;
-		for (int j = 0; j < 3; j++)
-		{
-			m_body_I_body[body](i, j) = 0.0;
-			m_body_T_parent_ref[body](i, j) = 0.0;
-		}
-	}
-        const idScalar size_5 = std::pow(size, 5);
-        m_body_I_body[body](0, 0) = size_5 / 0.2e6;
-        m_body_I_body[body](1, 1) = size_5 * 403 / 1.2e6;
-	m_body_I_body[body](2, 2) = m_body_I_body[body](1, 1);
-
-	getVecMatFromDH(0, 0, a_DH_in, alpha_DH_in, &m_parent_r_parent_body_ref[body],
-					&m_body_T_parent_ref[body]);
-
-	// attach "level" Dill systems of levels 1...level
-	for (int i = 1; i <= level; i++)
-	{
-		idScalar d_DH = 0.01 * size;
-		if (i == level)
-		{
-			d_DH = 0.0;
-		}
-		const idScalar a_DH = i * 0.1;
-		const idScalar alpha_DH = i * BT_ID_PI / 3.0;
-		m_current_body++;
-		recurseDill(i - 1, body, d_DH, a_DH, alpha_DH);
-	}
-
-	return 0;  // ok!
-}
-}  // namespace btInverseDynamics

+ 0 - 47
ThirdParty/Bullet/Extras/InverseDynamics/DillCreator.hpp

@@ -1,47 +0,0 @@
-#ifndef DILLCREATOR_HPP_
-#define DILLCREATOR_HPP_
-
-#include "MultiBodyTreeCreator.hpp"
-
-namespace btInverseDynamics
-{
-/// Creator class for building a "Dill" system as intruduced as benchmark example in
-/// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n))
-/// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.",  The International
-/// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628.
-///
-/// This is a self-similar branched tree, somewhat resembling a dill plant
-class DillCreator : public MultiBodyTreeCreator
-{
-public:
-	/// ctor
-	/// @param levels the number of dill levels
-	DillCreator(int levels);
-	/// dtor
-	~DillCreator();
-	///\copydoc MultiBodyTreeCreator::getNumBodies
-	int getNumBodies(int* num_bodies) const;
-	///\copydoc MultiBodyTreeCreator::getBody
-	int getBody(const int body_index, int* parent_index, JointType* joint_type,
-				vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref, vec3* body_axis_of_motion,
-				idScalar* mass, vec3* body_r_body_com, mat33* body_I_body, int* user_int,
-				void** user_ptr) const;
-
-private:
-	/// recursively generate dill bodies.
-	/// TODO better documentation
-	int recurseDill(const int levels, const int parent, const idScalar d_DH_in,
-					const idScalar a_DH_in, const idScalar alpha_DH_in);
-	int m_level;
-	int m_num_bodies;
-	idArray<int>::type m_parent;
-	idArray<vec3>::type m_parent_r_parent_body_ref;
-	idArray<mat33>::type m_body_T_parent_ref;
-	idArray<vec3>::type m_body_axis_of_motion;
-	idArray<idScalar>::type m_mass;
-	idArray<vec3>::type m_body_r_body_com;
-	idArray<mat33>::type m_body_I_body;
-	int m_current_body;
-};
-}  // namespace btInverseDynamics
-#endif

+ 0 - 76
ThirdParty/Bullet/Extras/InverseDynamics/IDRandomUtil.cpp

@@ -1,76 +0,0 @@
-#include <cmath>
-#include <cstdlib>
-#include <ctime>
-
-#include "BulletInverseDynamics/IDConfig.hpp"
-#include "BulletInverseDynamics/IDMath.hpp"
-#include "IDRandomUtil.hpp"
-
-namespace btInverseDynamics
-{
-// constants for random mass and inertia generation
-// these are arbitrary positive values.
-static const float mass_min = 0.001;
-static const float mass_max = 1.0;
-
-void randomInit() { srand(time(NULL)); }
-void randomInit(unsigned seed) { srand(seed); }
-
-int randomInt(int low, int high) { return rand() % (high + 1 - low) + low; }
-
-float randomFloat(float low, float high)
-{
-	return low + static_cast<float>(rand()) / RAND_MAX * (high - low);
-}
-
-float randomMass() { return randomFloat(mass_min, mass_max); }
-
-vec3 randomInertiaPrincipal()
-{
-	vec3 inertia;
-	do
-	{
-		inertia(0) = randomFloat(mass_min, mass_max);
-		inertia(1) = randomFloat(mass_min, mass_max);
-		inertia(2) = randomFloat(mass_min, mass_max);
-	} while (inertia(0) + inertia(1) < inertia(2) || inertia(0) + inertia(2) < inertia(1) ||
-			 inertia(1) + inertia(2) < inertia(0));
-	return inertia;
-}
-
-mat33 randomInertiaMatrix()
-{
-	// generate random valid inertia matrix by first getting valid components
-	// along major axes and then rotating by random amount
-	vec3 principal = randomInertiaPrincipal();
-	mat33 rot(transformX(randomFloat(-BT_ID_PI, BT_ID_PI)) * transformY(randomFloat(-BT_ID_PI, BT_ID_PI)) *
-			  transformZ(randomFloat(-BT_ID_PI, BT_ID_PI)));
-	mat33 inertia;
-	inertia(0, 0) = principal(0);
-	inertia(0, 1) = 0;
-	inertia(0, 2) = 0;
-	inertia(1, 0) = 0;
-	inertia(1, 1) = principal(1);
-	inertia(1, 2) = 0;
-	inertia(2, 0) = 0;
-	inertia(2, 1) = 0;
-	inertia(2, 2) = principal(2);
-	return rot * inertia * rot.transpose();
-}
-
-vec3 randomAxis()
-{
-	vec3 axis;
-	idScalar length;
-	do
-	{
-		axis(0) = randomFloat(-1.0, 1.0);
-		axis(1) = randomFloat(-1.0, 1.0);
-		axis(2) = randomFloat(-1.0, 1.0);
-
-		length = BT_ID_SQRT(BT_ID_POW(axis(0), 2) + BT_ID_POW(axis(1), 2) + BT_ID_POW(axis(2), 2));
-	} while (length < 0.01);
-
-	return axis / length;
-}
-}  // namespace btInverseDynamics

+ 0 - 37
ThirdParty/Bullet/Extras/InverseDynamics/IDRandomUtil.hpp

@@ -1,37 +0,0 @@
-#ifndef ID_RANDOM_UTIL_HPP_
-#define ID_RANDOM_UTIL_HPP_
-#include "BulletInverseDynamics/IDConfig.hpp"
-namespace btInverseDynamics
-{
-/// seed random number generator using time()
-void randomInit();
-/// seed random number generator with identical value to get repeatable results
-void randomInit(unsigned seed);
-/// Generate (not quite) uniformly distributed random integers in [low, high]
-/// Note: this is a low-quality implementation using only rand(), as
-/// C++11 <random> is not supported in bullet.
-/// The results will *not* be perfectly uniform.
-/// \param low is the lower bound (inclusive)
-/// \param high is the lower bound (inclusive)
-/// \return a random number within [\param low, \param high]
-int randomInt(int low, int high);
-/// Generate a (not quite) uniformly distributed random floats in [low, high]
-/// Note: this is a low-quality implementation using only rand(), as
-/// C++11 <random> is not supported in bullet.
-/// The results will *not* be perfectly uniform.
-/// \param low is the lower bound (inclusive)
-/// \param high is the lower bound (inclusive)
-/// \return a random number within [\param low, \param high]
-float randomFloat(float low, float high);
-
-/// generate a random valid mass value
-/// \returns random mass
-float randomMass();
-/// generate a random valid vector of principal moments of inertia
-vec3 randomInertiaPrincipal();
-/// generate a random valid moment of inertia matrix
-mat33 randomInertiaMatrix();
-/// generate a random unit vector
-vec3 randomAxis();
-}  // namespace btInverseDynamics
-#endif

+ 0 - 12
ThirdParty/Bullet/Extras/InverseDynamics/LICENSE.txt

@@ -1,12 +0,0 @@
-Bullet Continuous Collision Detection and Physics Library
-http://bulletphysics.org
-
-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.

Some files were not shown because too many files changed in this diff