Improved CharacterDemo/KinematicCharacterController, dynamic objects will bounce off.
Don't create a todo list for doxygen by default (the chaotic todo's would confuse most developers) Improve support for small objects, by having dynamic contact breaking thresholds. Still needs small internal timestep and some GJK improvements.
This commit is contained in:
@@ -92,7 +92,7 @@ void CharacterDemo::initPhysics()
|
|||||||
btScalar characterWidth =1.75;
|
btScalar characterWidth =1.75;
|
||||||
btConvexShape* capsule = new btCapsuleShape(characterWidth,characterHeight);
|
btConvexShape* capsule = new btCapsuleShape(characterWidth,characterHeight);
|
||||||
m_ghostObject->setCollisionShape (capsule);
|
m_ghostObject->setCollisionShape (capsule);
|
||||||
m_ghostObject->setCollisionFlags (btCollisionObject::CF_NO_CONTACT_RESPONSE);
|
m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
|
||||||
|
|
||||||
btScalar stepHeight = btScalar(0.35);
|
btScalar stepHeight = btScalar(0.35);
|
||||||
m_character = new KinematicCharacterController (m_ghostObject,capsule,stepHeight);
|
m_character = new KinematicCharacterController (m_ghostObject,capsule,stepHeight);
|
||||||
@@ -103,7 +103,7 @@ void CharacterDemo::initPhysics()
|
|||||||
|
|
||||||
|
|
||||||
///only collide with static for now (no interaction with dynamic objects)
|
///only collide with static for now (no interaction with dynamic objects)
|
||||||
m_dynamicsWorld->addCollisionObject(m_ghostObject,btBroadphaseProxy::DebrisFilter, btBroadphaseProxy::StaticFilter);
|
m_dynamicsWorld->addCollisionObject(m_ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
|
|||||||
@@ -8,14 +8,12 @@
|
|||||||
#include "LinearMath/btDefaultMotionState.h"
|
#include "LinearMath/btDefaultMotionState.h"
|
||||||
#include "KinematicCharacterController.h"
|
#include "KinematicCharacterController.h"
|
||||||
|
|
||||||
/* TODO:
|
///@todo Interact with dynamic objects,
|
||||||
* Interact with dynamic objects
|
///Ride kinematicly animated platforms properly
|
||||||
* Ride kinematicly animated platforms properly
|
///More realistic (or maybe just a config option) falling
|
||||||
* More realistic (or maybe just a config option) falling
|
/// -> Should integrate falling velocity manually and use that in stepDown()
|
||||||
* -> Should integrate falling velocity manually and use that in stepDown()
|
///Support jumping
|
||||||
* Support jumping
|
///Support ducking
|
||||||
* Support ducking
|
|
||||||
*/
|
|
||||||
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
|
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ void ConcaveDemo::initPhysics()
|
|||||||
createCollisionLocalStoreMemory,
|
createCollisionLocalStoreMemory,
|
||||||
maxNumOutstandingTasks));
|
maxNumOutstandingTasks));
|
||||||
#else
|
#else
|
||||||
///todo other platform threading
|
///@todo show other platform threading
|
||||||
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
|
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
|
||||||
///Libspe2 SPU support will be available soon
|
///Libspe2 SPU support will be available soon
|
||||||
///pthreads version
|
///pthreads version
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
createCollisionLocalStoreMemory,
|
createCollisionLocalStoreMemory,
|
||||||
maxNumOutstandingTasks));
|
maxNumOutstandingTasks));
|
||||||
#else
|
#else
|
||||||
///todo other platform threading
|
///@todo other platform threading
|
||||||
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
|
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
|
||||||
///Libspe2 SPU support will be available soon
|
///Libspe2 SPU support will be available soon
|
||||||
///pthreads version
|
///pthreads version
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
#define USE_ORIGINAL 1
|
#define USE_ORIGINAL 1
|
||||||
#ifndef USE_ORIGINAL
|
#ifndef USE_ORIGINAL
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
|
||||||
#endif //USE_ORIGINAL
|
#endif //USE_ORIGINAL
|
||||||
|
|
||||||
static bool gRefMode = false;
|
static bool gRefMode = false;
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ subject to the following restrictions:
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// September 2006: VehicleDemo is work in progress, this file is mostly just a placeholder
|
///September 2006: VehicleDemo is work in progress, this file is mostly just a placeholder
|
||||||
/// This VehicleDemo file is very early in development, please check it later
|
///This VehicleDemo file is very early in development, please check it later
|
||||||
/// One todo is a basic engine model:
|
///@todo is a basic engine model:
|
||||||
/// A function that maps user input (throttle) into torque/force applied on the wheels
|
///A function that maps user input (throttle) into torque/force applied on the wheels
|
||||||
/// with gears etc.
|
///with gears etc.
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
|
#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
|
||||||
|
|
||||||
|
|||||||
2
Doxyfile
2
Doxyfile
@@ -207,7 +207,7 @@ ENABLED_SECTIONS =
|
|||||||
# disable (NO) the todo list. This list is created by putting \todo
|
# disable (NO) the todo list. This list is created by putting \todo
|
||||||
# commands in the documentation.
|
# commands in the documentation.
|
||||||
|
|
||||||
GENERATE_TODOLIST = YES
|
GENERATE_TODOLIST = NO
|
||||||
|
|
||||||
# The GENERATE_TESTLIST tag can be used to enable (YES) or
|
# The GENERATE_TESTLIST tag can be used to enable (YES) or
|
||||||
# disable (NO) the test list. This list is created by putting \test
|
# disable (NO) the test list. This list is created by putting \test
|
||||||
|
|||||||
@@ -13,11 +13,8 @@ subject to the following restrictions:
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Some TODO items:
|
///@todo fix naming conflicts with BulletUnnamed-* across executions -> need to generate a real unique name.
|
||||||
* fix naming conflicts with BulletUnnamed-* across executions -> need to generate a real unique name.
|
///@todo double check geometry sharing
|
||||||
* double check geometry sharing
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "ColladaConverter.h"
|
#include "ColladaConverter.h"
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
@@ -430,7 +427,7 @@ bool ColladaConverter::convert()
|
|||||||
|
|
||||||
domPhysics_modelRef model = *(domPhysics_modelRef*)&ref;
|
domPhysics_modelRef model = *(domPhysics_modelRef*)&ref;
|
||||||
|
|
||||||
//todo: group some shared functionality in following 2 'blocks'.
|
///@todo: group some shared functionality in following 2 'blocks'.
|
||||||
for (r=0;r<instancePhysicsModelRef->getInstance_rigid_body_array().getCount();r++)
|
for (r=0;r<instancePhysicsModelRef->getInstance_rigid_body_array().getCount();r++)
|
||||||
{
|
{
|
||||||
domInstance_rigid_bodyRef instRigidbodyRef = instancePhysicsModelRef->getInstance_rigid_body_array()[r];
|
domInstance_rigid_bodyRef instRigidbodyRef = instancePhysicsModelRef->getInstance_rigid_body_array()[r];
|
||||||
|
|||||||
@@ -2308,25 +2308,25 @@ int shareedge(const int3 &a,const int3 &b)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tri;
|
class btHullTriangle;
|
||||||
|
|
||||||
Array<Tri*> tris;
|
Array<btHullTriangle*> tris;
|
||||||
|
|
||||||
class Tri : public int3
|
class btHullTriangle : public int3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int3 n;
|
int3 n;
|
||||||
int id;
|
int id;
|
||||||
int vmax;
|
int vmax;
|
||||||
float rise;
|
float rise;
|
||||||
Tri(int a,int b,int c):int3(a,b,c),n(-1,-1,-1)
|
btHullTriangle(int a,int b,int c):int3(a,b,c),n(-1,-1,-1)
|
||||||
{
|
{
|
||||||
id = tris.count;
|
id = tris.count;
|
||||||
tris.Add(this);
|
tris.Add(this);
|
||||||
vmax=-1;
|
vmax=-1;
|
||||||
rise = 0.0f;
|
rise = 0.0f;
|
||||||
}
|
}
|
||||||
~Tri()
|
~btHullTriangle()
|
||||||
{
|
{
|
||||||
assert(tris[id]==this);
|
assert(tris[id]==this);
|
||||||
tris[id]=NULL;
|
tris[id]=NULL;
|
||||||
@@ -2335,7 +2335,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int &Tri::neib(int a,int b)
|
int &btHullTriangle::neib(int a,int b)
|
||||||
{
|
{
|
||||||
static int er=-1;
|
static int er=-1;
|
||||||
int i;
|
int i;
|
||||||
@@ -2349,7 +2349,7 @@ int &Tri::neib(int a,int b)
|
|||||||
assert(0);
|
assert(0);
|
||||||
return er;
|
return er;
|
||||||
}
|
}
|
||||||
void b2bfix(Tri* s,Tri*t)
|
void b2bfix(btHullTriangle* s,btHullTriangle*t)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<3;i++)
|
for(i=0;i<3;i++)
|
||||||
@@ -2365,14 +2365,14 @@ void b2bfix(Tri* s,Tri*t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeb2b(Tri* s,Tri*t)
|
void removeb2b(btHullTriangle* s,btHullTriangle*t)
|
||||||
{
|
{
|
||||||
b2bfix(s,t);
|
b2bfix(s,t);
|
||||||
delete s;
|
delete s;
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkit(Tri *t)
|
void checkit(btHullTriangle *t)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
assert(tris[t->id]==t);
|
assert(tris[t->id]==t);
|
||||||
@@ -2386,17 +2386,17 @@ void checkit(Tri *t)
|
|||||||
assert( tris[t->n[i]]->neib(b,a) == t->id);
|
assert( tris[t->n[i]]->neib(b,a) == t->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void extrude(Tri *t0,int v)
|
void extrude(btHullTriangle *t0,int v)
|
||||||
{
|
{
|
||||||
int3 t= *t0;
|
int3 t= *t0;
|
||||||
int n = tris.count;
|
int n = tris.count;
|
||||||
Tri* ta = new Tri(v,t[1],t[2]);
|
btHullTriangle* ta = new btHullTriangle(v,t[1],t[2]);
|
||||||
ta->n = int3(t0->n[0],n+1,n+2);
|
ta->n = int3(t0->n[0],n+1,n+2);
|
||||||
tris[t0->n[0]]->neib(t[1],t[2]) = n+0;
|
tris[t0->n[0]]->neib(t[1],t[2]) = n+0;
|
||||||
Tri* tb = new Tri(v,t[2],t[0]);
|
btHullTriangle* tb = new btHullTriangle(v,t[2],t[0]);
|
||||||
tb->n = int3(t0->n[1],n+2,n+0);
|
tb->n = int3(t0->n[1],n+2,n+0);
|
||||||
tris[t0->n[1]]->neib(t[2],t[0]) = n+1;
|
tris[t0->n[1]]->neib(t[2],t[0]) = n+1;
|
||||||
Tri* tc = new Tri(v,t[0],t[1]);
|
btHullTriangle* tc = new btHullTriangle(v,t[0],t[1]);
|
||||||
tc->n = int3(t0->n[2],n+0,n+1);
|
tc->n = int3(t0->n[2],n+0,n+1);
|
||||||
tris[t0->n[2]]->neib(t[0],t[1]) = n+2;
|
tris[t0->n[2]]->neib(t[0],t[1]) = n+2;
|
||||||
checkit(ta);
|
checkit(ta);
|
||||||
@@ -2409,10 +2409,10 @@ void extrude(Tri *t0,int v)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tri *extrudable(float epsilon)
|
btHullTriangle *extrudable(float epsilon)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Tri *t=NULL;
|
btHullTriangle *t=NULL;
|
||||||
for(i=0;i<tris.count;i++)
|
for(i=0;i<tris.count;i++)
|
||||||
{
|
{
|
||||||
if(!t || (tris[i] && t->rise<tris[i]->rise))
|
if(!t || (tris[i] && t->rise<tris[i]->rise))
|
||||||
@@ -2489,23 +2489,23 @@ int calchullgen(float3 *verts,int verts_count, int vlimit)
|
|||||||
|
|
||||||
|
|
||||||
float3 center = (verts[p[0]]+verts[p[1]]+verts[p[2]]+verts[p[3]]) /4.0f; // a valid interior point
|
float3 center = (verts[p[0]]+verts[p[1]]+verts[p[2]]+verts[p[3]]) /4.0f; // a valid interior point
|
||||||
Tri *t0 = new Tri(p[2],p[3],p[1]); t0->n=int3(2,3,1);
|
btHullTriangle *t0 = new btHullTriangle(p[2],p[3],p[1]); t0->n=int3(2,3,1);
|
||||||
Tri *t1 = new Tri(p[3],p[2],p[0]); t1->n=int3(3,2,0);
|
btHullTriangle *t1 = new btHullTriangle(p[3],p[2],p[0]); t1->n=int3(3,2,0);
|
||||||
Tri *t2 = new Tri(p[0],p[1],p[3]); t2->n=int3(0,1,3);
|
btHullTriangle *t2 = new btHullTriangle(p[0],p[1],p[3]); t2->n=int3(0,1,3);
|
||||||
Tri *t3 = new Tri(p[1],p[0],p[2]); t3->n=int3(1,0,2);
|
btHullTriangle *t3 = new btHullTriangle(p[1],p[0],p[2]); t3->n=int3(1,0,2);
|
||||||
isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1;
|
isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1;
|
||||||
checkit(t0);checkit(t1);checkit(t2);checkit(t3);
|
checkit(t0);checkit(t1);checkit(t2);checkit(t3);
|
||||||
|
|
||||||
for(j=0;j<tris.count;j++)
|
for(j=0;j<tris.count;j++)
|
||||||
{
|
{
|
||||||
Tri *t=tris[j];
|
btHullTriangle *t=tris[j];
|
||||||
assert(t);
|
assert(t);
|
||||||
assert(t->vmax<0);
|
assert(t->vmax<0);
|
||||||
float3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
float3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
||||||
t->vmax = maxdirsterid(verts,verts_count,n,allow);
|
t->vmax = maxdirsterid(verts,verts_count,n,allow);
|
||||||
t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
|
t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
|
||||||
}
|
}
|
||||||
Tri *te;
|
btHullTriangle *te;
|
||||||
vlimit-=4;
|
vlimit-=4;
|
||||||
while(vlimit >0 && (te=extrudable(epsilon)))
|
while(vlimit >0 && (te=extrudable(epsilon)))
|
||||||
{
|
{
|
||||||
@@ -2532,7 +2532,7 @@ int calchullgen(float3 *verts,int verts_count, int vlimit)
|
|||||||
int3 nt=*tris[j];
|
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 )
|
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 )
|
||||||
{
|
{
|
||||||
Tri *nb = tris[tris[j]->n[0]];
|
btHullTriangle *nb = tris[tris[j]->n[0]];
|
||||||
assert(nb);assert(!hasvert(*nb,v));assert(nb->id<j);
|
assert(nb);assert(!hasvert(*nb,v));assert(nb->id<j);
|
||||||
extrude(nb,v);
|
extrude(nb,v);
|
||||||
j=tris.count;
|
j=tris.count;
|
||||||
@@ -2541,7 +2541,7 @@ int calchullgen(float3 *verts,int verts_count, int vlimit)
|
|||||||
j=tris.count;
|
j=tris.count;
|
||||||
while(j--)
|
while(j--)
|
||||||
{
|
{
|
||||||
Tri *t=tris[j];
|
btHullTriangle *t=tris[j];
|
||||||
if(!t) continue;
|
if(!t) continue;
|
||||||
if(t->vmax>=0) break;
|
if(t->vmax>=0) break;
|
||||||
float3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
float3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
||||||
@@ -2586,14 +2586,14 @@ int calchullpbev(float3 *verts,int verts_count,int vlimit, Array<Plane> &planes,
|
|||||||
for(i=0;i<tris.count;i++)if(tris[i])
|
for(i=0;i<tris.count;i++)if(tris[i])
|
||||||
{
|
{
|
||||||
Plane p;
|
Plane p;
|
||||||
Tri *t = tris[i];
|
btHullTriangle *t = tris[i];
|
||||||
p.normal = TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
p.normal = TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
||||||
p.dist = -dot(p.normal, verts[(*t)[0]]);
|
p.dist = -dot(p.normal, verts[(*t)[0]]);
|
||||||
planes.Add(p);
|
planes.Add(p);
|
||||||
for(j=0;j<3;j++)
|
for(j=0;j<3;j++)
|
||||||
{
|
{
|
||||||
if(t->n[j]<t->id) continue;
|
if(t->n[j]<t->id) continue;
|
||||||
Tri *s = tris[t->n[j]];
|
btHullTriangle *s = tris[t->n[j]];
|
||||||
REAL3 snormal = TriNormal(verts[(*s)[0]],verts[(*s)[1]],verts[(*s)[2]]);
|
REAL3 snormal = TriNormal(verts[(*s)[0]],verts[(*s)[1]],verts[(*s)[2]]);
|
||||||
if(dot(snormal,p.normal)>=cos(bevangle*DEG2RAD)) continue;
|
if(dot(snormal,p.normal)>=cos(bevangle*DEG2RAD)) continue;
|
||||||
REAL3 n = normalize(snormal+p.normal);
|
REAL3 n = normalize(snormal+p.normal);
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
|
|||||||
KinematicFilter = 4,
|
KinematicFilter = 4,
|
||||||
DebrisFilter = 8,
|
DebrisFilter = 8,
|
||||||
SensorTrigger = 16,
|
SensorTrigger = 16,
|
||||||
|
CharacterFilter = 32,
|
||||||
AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
|
AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||||
|
|
||||||
|
|
||||||
SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle)
|
SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold)
|
||||||
:m_sphere(sphere),
|
:m_sphere(sphere),
|
||||||
m_triangle(triangle)
|
m_triangle(triangle),
|
||||||
|
m_contactBreakingThreshold(contactBreakingThreshold)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,7 +41,7 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Res
|
|||||||
//move sphere into triangle space
|
//move sphere into triangle space
|
||||||
btTransform sphereInTr = transformB.inverseTimes(transformA);
|
btTransform sphereInTr = transformB.inverseTimes(transformA);
|
||||||
|
|
||||||
if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact))
|
if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold))
|
||||||
{
|
{
|
||||||
if (swapResults)
|
if (swapResults)
|
||||||
{
|
{
|
||||||
@@ -93,7 +94,7 @@ bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
///combined discrete/continuous sphere-triangle
|
///combined discrete/continuous sphere-triangle
|
||||||
bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact)
|
bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
|
||||||
{
|
{
|
||||||
|
|
||||||
const btVector3* vertices = &m_triangle->getVertexPtr(0);
|
const btVector3* vertices = &m_triangle->getVertexPtr(0);
|
||||||
@@ -115,10 +116,7 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
|
|||||||
normal *= btScalar(-1.);
|
normal *= btScalar(-1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
///@todo: move this gContactBreakingThreshold into a proper structure
|
btScalar contactMargin = contactBreakingThreshold;
|
||||||
extern btScalar gContactBreakingThreshold;
|
|
||||||
|
|
||||||
btScalar contactMargin = gContactBreakingThreshold;
|
|
||||||
bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
|
bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
|
||||||
bool isInsideShellPlane = distanceFromPlane < r;
|
bool isInsideShellPlane = distanceFromPlane < r;
|
||||||
|
|
||||||
|
|||||||
@@ -30,19 +30,19 @@ struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface
|
|||||||
{
|
{
|
||||||
virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
|
virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
|
||||||
|
|
||||||
SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle);
|
SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle, btScalar contactBreakingThreshold);
|
||||||
|
|
||||||
virtual ~SphereTriangleDetector() {};
|
virtual ~SphereTriangleDetector() {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact);
|
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold);
|
||||||
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
||||||
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
||||||
|
|
||||||
btSphereShape* m_sphere;
|
btSphereShape* m_sphere;
|
||||||
btTriangleShape* m_triangle;
|
btTriangleShape* m_triangle;
|
||||||
|
btScalar m_contactBreakingThreshold;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //SPHERE_TRIANGLE_DETECTOR_H
|
#endif //SPHERE_TRIANGLE_DETECTOR_H
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
|
|||||||
|
|
||||||
btCollisionObject* body0 = (btCollisionObject*)b0;
|
btCollisionObject* body0 = (btCollisionObject*)b0;
|
||||||
btCollisionObject* body1 = (btCollisionObject*)b1;
|
btCollisionObject* body1 = (btCollisionObject*)b1;
|
||||||
|
|
||||||
|
btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
|
||||||
|
|
||||||
void* mem = 0;
|
void* mem = 0;
|
||||||
|
|
||||||
@@ -89,7 +91,7 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
|
|||||||
mem = btAlignedAlloc(sizeof(btPersistentManifold),16);
|
mem = btAlignedAlloc(sizeof(btPersistentManifold),16);
|
||||||
|
|
||||||
}
|
}
|
||||||
btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0);
|
btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold);
|
||||||
manifold->m_index1a = m_manifoldsPtr.size();
|
manifold->m_index1a = m_manifoldsPtr.size();
|
||||||
m_manifoldsPtr.push_back(manifold);
|
m_manifoldsPtr.push_back(manifold);
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ public:
|
|||||||
CF_STATIC_OBJECT= 1,
|
CF_STATIC_OBJECT= 1,
|
||||||
CF_KINEMATIC_OBJECT= 2,
|
CF_KINEMATIC_OBJECT= 2,
|
||||||
CF_NO_CONTACT_RESPONSE = 4,
|
CF_NO_CONTACT_RESPONSE = 4,
|
||||||
CF_CUSTOM_MATERIAL_CALLBACK = 8//this allows per-triangle material (friction/restitution)
|
CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle material (friction/restitution)
|
||||||
|
CF_CHARACTER_OBJECT = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CollisionObjectTypes
|
enum CollisionObjectTypes
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* co
|
|||||||
|
|
||||||
/// report a contact. internally this will be kept persistent, and contact reduction is done
|
/// report a contact. internally this will be kept persistent, and contact reduction is done
|
||||||
resultOut->setPersistentManifold(m_manifoldPtr);
|
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||||
SphereTriangleDetector detector(sphere,triangle);
|
SphereTriangleDetector detector(sphere,triangle, m_manifoldPtr->getContactBreakingThreshold());
|
||||||
|
|
||||||
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
||||||
input.m_maximumDistanceSquared = btScalar(1e30);///@todo: tighter bounds
|
input.m_maximumDistanceSquared = btScalar(1e30);///@todo: tighter bounds
|
||||||
|
|||||||
@@ -42,8 +42,14 @@ void btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) con
|
|||||||
center = (aabbMin+aabbMax)*btScalar(0.5);
|
center = (aabbMin+aabbMax)*btScalar(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btScalar btCollisionShape::getContactBreakingThreshold() const
|
||||||
|
{
|
||||||
|
///@todo make this 0.1 configurable
|
||||||
|
return getAngularMotionDisc() * btScalar(0.1);
|
||||||
|
}
|
||||||
btScalar btCollisionShape::getAngularMotionDisc() const
|
btScalar btCollisionShape::getAngularMotionDisc() const
|
||||||
{
|
{
|
||||||
|
///@todo cache this value, to improve performance
|
||||||
btVector3 center;
|
btVector3 center;
|
||||||
btScalar disc;
|
btScalar disc;
|
||||||
getBoundingSphere(center,disc);
|
getBoundingSphere(center,disc);
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public:
|
|||||||
///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
|
///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
|
||||||
virtual btScalar getAngularMotionDisc() const;
|
virtual btScalar getAngularMotionDisc() const;
|
||||||
|
|
||||||
|
virtual btScalar getContactBreakingThreshold() const;
|
||||||
|
|
||||||
|
|
||||||
///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep)
|
///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep)
|
||||||
///result is conservative
|
///result is conservative
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ protected:
|
|||||||
//! Creates a new contact point
|
//! Creates a new contact point
|
||||||
SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(btCollisionObject* body0,btCollisionObject* body1)
|
SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
|
m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
|
||||||
return m_manifoldPtr;
|
return m_manifoldPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "btPersistentManifold.h"
|
#include "btPersistentManifold.h"
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
btScalar gContactBreakingThreshold = btScalar(0.02);
|
btScalar gContactBreakingThreshold = btScalar(0.02);
|
||||||
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
||||||
@@ -66,7 +66,7 @@ void btPersistentManifold::clearUserCache(btManifoldPoint& pt)
|
|||||||
printf("error in clearUserCache\n");
|
printf("error in clearUserCache\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(occurance<=0);
|
btAssert(occurance<=0);
|
||||||
#endif //DEBUG_PERSISTENCY
|
#endif //DEBUG_PERSISTENCY
|
||||||
|
|
||||||
if (pt.m_userPersistentData && gContactDestroyedCallback)
|
if (pt.m_userPersistentData && gContactDestroyedCallback)
|
||||||
@@ -164,7 +164,7 @@ int btPersistentManifold::getCacheEntry(const btManifoldPoint& newPoint) const
|
|||||||
|
|
||||||
int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint)
|
int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint)
|
||||||
{
|
{
|
||||||
assert(validContactDistance(newPoint));
|
btAssert(validContactDistance(newPoint));
|
||||||
|
|
||||||
int insertIndex = getNumContacts();
|
int insertIndex = getNumContacts();
|
||||||
if (insertIndex == MANIFOLD_CACHE_SIZE)
|
if (insertIndex == MANIFOLD_CACHE_SIZE)
|
||||||
@@ -190,7 +190,7 @@ int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint)
|
|||||||
|
|
||||||
btScalar btPersistentManifold::getContactBreakingThreshold() const
|
btScalar btPersistentManifold::getContactBreakingThreshold() const
|
||||||
{
|
{
|
||||||
return gContactBreakingThreshold;
|
return m_contactBreakingThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
struct btCollisionResult;
|
struct btCollisionResult;
|
||||||
|
|
||||||
///contact breaking and merging threshold
|
///maximum contact breaking and merging threshold
|
||||||
extern btScalar gContactBreakingThreshold;
|
extern btScalar gContactBreakingThreshold;
|
||||||
|
|
||||||
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
||||||
@@ -52,6 +52,8 @@ ATTRIBUTE_ALIGNED16( class) btPersistentManifold
|
|||||||
/// void* will allow any rigidbody class
|
/// void* will allow any rigidbody class
|
||||||
void* m_body0;
|
void* m_body0;
|
||||||
void* m_body1;
|
void* m_body1;
|
||||||
|
btScalar m_contactBreakingThreshold;
|
||||||
|
|
||||||
int m_cachedPoints;
|
int m_cachedPoints;
|
||||||
|
|
||||||
|
|
||||||
@@ -68,10 +70,11 @@ public:
|
|||||||
|
|
||||||
btPersistentManifold();
|
btPersistentManifold();
|
||||||
|
|
||||||
btPersistentManifold(void* body0,void* body1,int bla)
|
btPersistentManifold(void* body0,void* body1,int bla, btScalar contactBreakingThreshold)
|
||||||
: m_body0(body0),m_body1(body1),m_cachedPoints(0)
|
: m_body0(body0),m_body1(body1),m_cachedPoints(0),
|
||||||
|
m_contactBreakingThreshold(contactBreakingThreshold)
|
||||||
{
|
{
|
||||||
(void)bla;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void* getBody0() { return m_body0;}
|
SIMD_FORCE_INLINE void* getBody0() { return m_body0;}
|
||||||
|
|||||||
Reference in New Issue
Block a user