update bullet so it actually works

Moved the addSourceDirectory for physics/Bullet into the Engine/Source/CMakeLists.txt file that way it can actually appear where we expect it to in the solution explorer.
This commit is contained in:
marauder2k7 2026-06-03 15:08:51 +01:00
parent c7be48130a
commit 13fa178cf6
5986 changed files with 1811270 additions and 453803 deletions

View file

@ -22,7 +22,10 @@ IF (INSTALL_EXTRA_LIBS)
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
INSTALL(TARGETS GIMPACTUtils DESTINATION .)
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
INSTALL(TARGETS GIMPACTUtils DESTINATION lib${LIB_SUFFIX})
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)

View file

@ -0,0 +1,11 @@
Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
email: projectileman@yahoo.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -26,17 +26,16 @@ subject to the following restrictions:
class GIM_ConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
{
protected:
btGImpactConvexDecompositionShape * m_compoundShape;
btGImpactConvexDecompositionShape* m_compoundShape;
btAlignedObjectArray<btCollisionShape*> m_convexShapes;
public:
int mBaseCount;
int mHullCount;
int mBaseCount;
int mHullCount;
bool m_transformSubShapes;
GIM_ConvexDecomposition(btGImpactConvexDecompositionShape * compoundShape,bool transformSubShapes)
GIM_ConvexDecomposition(btGImpactConvexDecompositionShape* compoundShape, bool transformSubShapes)
{
mBaseCount = 0;
mHullCount = 0;
@ -47,43 +46,39 @@ public:
virtual ~GIM_ConvexDecomposition()
{
int i;
for (i=0;i<m_convexShapes.size();i++)
for (i = 0; i < m_convexShapes.size(); i++)
{
btCollisionShape* shape = m_convexShapes[i];
delete shape;
}
}
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult& result)
{
//calc centroid, to shift vertices around center of mass
btVector3 centroid(0,0,0);
btVector3 centroid(0, 0, 0);
btAlignedObjectArray<btVector3> vertices;
if(m_transformSubShapes)
if (m_transformSubShapes)
{
//const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullVcount; i++)
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]);
btVector3 vertex(result.mHullVertices[i * 3], result.mHullVertices[i * 3 + 1], result.mHullVertices[i * 3 + 2]);
centroid += vertex;
}
centroid *= 1.f/(float(result.mHullVcount) );
centroid *= 1.f / (float(result.mHullVcount));
}
// collect vertices
for (unsigned int i=0; i<result.mHullVcount; i++)
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]);
btVector3 vertex(result.mHullVertices[i * 3], result.mHullVertices[i * 3 + 1], result.mHullVertices[i * 3 + 2]);
if(m_transformSubShapes)
if (m_transformSubShapes)
{
vertex -= centroid ;
vertex -= centroid;
}
vertices.push_back(vertex);
}
@ -91,12 +86,12 @@ public:
// build convex shape
btCollisionShape* convexShape = new btConvexHullShape(
&(vertices[0].getX()),vertices.size(),sizeof(btVector3));
&(vertices[0].getX()), vertices.size(), sizeof(btVector3));
m_convexShapes.push_back(convexShape);
convexShape->setMargin(m_compoundShape->getMargin());
if(m_transformSubShapes)
if (m_transformSubShapes)
{
btTransform trans;
trans.setIdentity();
@ -104,7 +99,7 @@ public:
// add convex shape
m_compoundShape->addChildShape(trans,convexShape);
m_compoundShape->addChildShape(trans, convexShape);
}
else
{
@ -114,7 +109,7 @@ public:
// add convex shape
m_compoundShape->addChildShape(trans,convexShape);
m_compoundShape->addChildShape(trans, convexShape);
//m_compoundShape->addChildShape(convexShape);
}
@ -122,35 +117,32 @@ public:
void processDecomposition(int part)
{
btGImpactMeshShapePart::TrimeshPrimitiveManager * trimeshInterface =
m_compoundShape->getTrimeshInterface(part);
btGImpactMeshShapePart::TrimeshPrimitiveManager* trimeshInterface =
m_compoundShape->getTrimeshInterface(part);
trimeshInterface->lock();
//collect vertices
btAlignedObjectArray<float> vertices;
vertices.reserve(trimeshInterface->get_vertex_count()*3);
vertices.reserve(trimeshInterface->get_vertex_count() * 3);
for(int vi = 0;vi<trimeshInterface->get_vertex_count();vi++)
for (int vi = 0; vi < trimeshInterface->get_vertex_count(); vi++)
{
btVector3 vec;
trimeshInterface->get_vertex(vi,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);
indices.reserve(trimeshInterface->get_primitive_count() * 3);
for(int i = 0;i<trimeshInterface->get_primitive_count();i++)
for (int i = 0; i < trimeshInterface->get_primitive_count(); i++)
{
unsigned int i0, i1,i2;
trimeshInterface->get_indices(i,i0,i1,i2);
unsigned int i0, i1, i2;
trimeshInterface->get_indices(i, i0, i1, i2);
indices.push_back(i0);
indices.push_back(i1);
indices.push_back(i2);
@ -158,25 +150,22 @@ public:
trimeshInterface->unlock();
unsigned int depth = 5;
float cpercent = 5;
float ppercent = 15;
unsigned int maxv = 16;
float skinWidth = 0.0f;
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.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);
@ -184,21 +173,14 @@ public:
ConvexBuilder cb(desc.mCallback);
cb.process(desc);
}
};
void btGImpactConvexDecompositionShape::buildConvexDecomposition(bool transformSubShapes)
{
m_decomposition = new GIM_ConvexDecomposition(this,transformSubShapes);
m_decomposition = new GIM_ConvexDecomposition(this, transformSubShapes);
int part_count = m_trimeshInterfaces.size();
for (int i = 0;i<part_count ;i++ )
for (int i = 0; i < part_count; i++)
{
m_decomposition->processDecomposition(i);
}
@ -210,31 +192,27 @@ btGImpactConvexDecompositionShape::~btGImpactConvexDecompositionShape()
{
delete m_decomposition;
}
void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
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++ )
for (int part = 0; part < part_count; part++)
{
void * ptr = (void * )&m_trimeshInterfaces[part];
void* ptr = (void*)&m_trimeshInterfaces[part];
btGImpactMeshShapePart::TrimeshPrimitiveManager * trimeshInterface =
static_cast<btGImpactMeshShapePart::TrimeshPrimitiveManager *>(ptr);
btGImpactMeshShapePart::TrimeshPrimitiveManager* trimeshInterface =
static_cast<btGImpactMeshShapePart::TrimeshPrimitiveManager*>(ptr);
trimeshInterface->lock();
btPrimitiveTriangle triangle;
int i = trimeshInterface->get_primitive_count();
while(i--)
while (i--)
{
trimeshInterface->get_primitive_triangle(i,triangle);
callback->processTriangle(triangle.m_vertices,part,i);
trimeshInterface->get_primitive_triangle(i, triangle);
callback->processTriangle(triangle.m_vertices, part, i);
}
trimeshInterface->unlock();
}
}

View file

@ -24,32 +24,28 @@ subject to the following restrictions:
#ifndef GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
#define GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
#include "BulletCollision/Gimpact/btGImpactShape.h" // box tree class
#include "BulletCollision/Gimpact/btGImpactShape.h" // box tree class
//! This class creates a decomposition from a trimesh.
/*!
*/
class btGImpactConvexDecompositionShape : public btGImpactCompoundShape
class btGImpactConvexDecompositionShape : public btGImpactCompoundShape
{
protected:
btAlignedObjectArray<btGImpactMeshShapePart::TrimeshPrimitiveManager> m_trimeshInterfaces;
class GIM_ConvexDecomposition* m_decomposition;
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)
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;
@ -59,7 +55,7 @@ public:
//add parts
int part_count = meshInterface->getNumSubParts();
for (int i=0;i< part_count;i++ )
for (int i = 0; i < part_count; i++)
{
triInterface.m_part = i;
m_trimeshInterfaces.push_back(triInterface);
@ -72,16 +68,12 @@ public:
virtual ~btGImpactConvexDecompositionShape();
SIMD_FORCE_INLINE btGImpactMeshShapePart::TrimeshPrimitiveManager * getTrimeshInterface(int part)
SIMD_FORCE_INLINE btGImpactMeshShapePart::TrimeshPrimitiveManager* getTrimeshInterface(int part)
{
return &m_trimeshInterfaces[part];
}
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
virtual void processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
};
#endif //GIMPACT_MESH_SHAPE_H
#endif //GIMPACT_MESH_SHAPE_H