fixed a few issues, removed dependency from BulletDynamics to Extras/ConvexHull
This commit is contained in:
@@ -25,6 +25,8 @@ subject to the following restrictions:
|
|||||||
#include "../GimpactTestDemo/BunnyMesh.h"
|
#include "../GimpactTestDemo/BunnyMesh.h"
|
||||||
#include "../GimpactTestDemo/TorusMesh.h"
|
#include "../GimpactTestDemo/TorusMesh.h"
|
||||||
#include <stdio.h> //printf debugging
|
#include <stdio.h> //printf debugging
|
||||||
|
#include "../../Extras/ConvexHull/btConvexHull.h"
|
||||||
|
|
||||||
|
|
||||||
static float gCollisionMargin = 0.05f/*0.05f*/;
|
static float gCollisionMargin = 0.05f/*0.05f*/;
|
||||||
#include "SoftDemo.h"
|
#include "SoftDemo.h"
|
||||||
@@ -39,6 +41,37 @@ extern int glutScreenHeight;
|
|||||||
const int maxProxies = 32766;
|
const int maxProxies = 32766;
|
||||||
const int maxOverlap = 65535;
|
const int maxOverlap = 65535;
|
||||||
|
|
||||||
|
//
|
||||||
|
btSoftBody* CreateFromConvexHull( btSoftBody::ISoftBody* isoftbody,
|
||||||
|
const btVector3* vertices,
|
||||||
|
int nvertices)
|
||||||
|
{
|
||||||
|
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
|
||||||
|
HullResult hres;
|
||||||
|
HullLibrary hlib;/*??*/
|
||||||
|
hdsc.mMaxVertices=nvertices;
|
||||||
|
hlib.CreateConvexHull(hdsc,hres);
|
||||||
|
btSoftBody* psb=btSoftBody::Create( isoftbody,
|
||||||
|
(int)hres.mNumOutputVertices,
|
||||||
|
hres.mOutputVertices,0);
|
||||||
|
for(int i=0;i<(int)hres.mNumFaces;++i)
|
||||||
|
{
|
||||||
|
const int idx[]={ hres.mIndices[i*3+0],
|
||||||
|
hres.mIndices[i*3+1],
|
||||||
|
hres.mIndices[i*3+2]};
|
||||||
|
if(idx[0]<idx[1]) psb->AppendLink( idx[0],idx[1],
|
||||||
|
1,btSoftBody::eLType::Structural);
|
||||||
|
if(idx[1]<idx[2]) psb->AppendLink( idx[1],idx[2],
|
||||||
|
1,btSoftBody::eLType::Structural);
|
||||||
|
if(idx[2]<idx[0]) psb->AppendLink( idx[2],idx[0],
|
||||||
|
1,btSoftBody::eLType::Structural);
|
||||||
|
psb->AppendFace(idx[0],idx[1],idx[2]);
|
||||||
|
}
|
||||||
|
hlib.ReleaseResult(hres);
|
||||||
|
psb->RandomizeConstraints();
|
||||||
|
return(psb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
const int gNumObjects = 1;
|
const int gNumObjects = 1;
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ ADD_LIBRARY(LibBulletCollision
|
|||||||
CollisionDispatch/btDefaultCollisionConfiguration.h
|
CollisionDispatch/btDefaultCollisionConfiguration.h
|
||||||
CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
|
CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
|
||||||
CollisionDispatch/btSphereSphereCollisionAlgorithm.h
|
CollisionDispatch/btSphereSphereCollisionAlgorithm.h
|
||||||
|
CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp
|
||||||
|
CollisionDispatch/btBoxBoxCollisionAlgorithm.h
|
||||||
|
CollisionDispatch/btBoxBoxDetector.cpp
|
||||||
|
CollisionDispatch/btBoxBoxDetector.h
|
||||||
CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
|
CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
|
||||||
CollisionDispatch/btSphereBoxCollisionAlgorithm.h
|
CollisionDispatch/btSphereBoxCollisionAlgorithm.h
|
||||||
CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp
|
CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ subject to the following restrictions:
|
|||||||
///btSoftBodyHelpers.cpp by Nathanael Presson
|
///btSoftBodyHelpers.cpp by Nathanael Presson
|
||||||
|
|
||||||
#include "btSoftBody.h"
|
#include "btSoftBody.h"
|
||||||
#include "Extras/ConvexHull/btConvexHull.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -356,36 +355,7 @@ for(int i=0;i<vtx.size();++i)
|
|||||||
return(CreateFromConvexHull(isoftbody,&vtx[0],vtx.size()));
|
return(CreateFromConvexHull(isoftbody,&vtx[0],vtx.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
btSoftBody* CreateFromConvexHull( btSoftBody::ISoftBody* isoftbody,
|
|
||||||
const btVector3* vertices,
|
|
||||||
int nvertices)
|
|
||||||
{
|
|
||||||
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
|
|
||||||
HullResult hres;
|
|
||||||
HullLibrary hlib;/*??*/
|
|
||||||
hdsc.mMaxVertices=nvertices;
|
|
||||||
hlib.CreateConvexHull(hdsc,hres);
|
|
||||||
btSoftBody* psb=btSoftBody::Create( isoftbody,
|
|
||||||
(int)hres.mNumOutputVertices,
|
|
||||||
hres.mOutputVertices,0);
|
|
||||||
for(int i=0;i<(int)hres.mNumFaces;++i)
|
|
||||||
{
|
|
||||||
const int idx[]={ hres.mIndices[i*3+0],
|
|
||||||
hres.mIndices[i*3+1],
|
|
||||||
hres.mIndices[i*3+2]};
|
|
||||||
if(idx[0]<idx[1]) psb->AppendLink( idx[0],idx[1],
|
|
||||||
1,btSoftBody::eLType::Structural);
|
|
||||||
if(idx[1]<idx[2]) psb->AppendLink( idx[1],idx[2],
|
|
||||||
1,btSoftBody::eLType::Structural);
|
|
||||||
if(idx[2]<idx[0]) psb->AppendLink( idx[2],idx[0],
|
|
||||||
1,btSoftBody::eLType::Structural);
|
|
||||||
psb->AppendFace(idx[0],idx[1],idx[2]);
|
|
||||||
}
|
|
||||||
hlib.ReleaseResult(hres);
|
|
||||||
psb->RandomizeConstraints();
|
|
||||||
return(psb);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
btSoftBody* CreateFromTriMesh( btSoftBody::ISoftBody* isoftbody,
|
btSoftBody* CreateFromTriMesh( btSoftBody::ISoftBody* isoftbody,
|
||||||
|
|||||||
Reference in New Issue
Block a user