Autoformat selection for soft body, btDbvt related classes (no code change, just layout using Visual Studio)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -62,13 +62,13 @@ public:
|
||||
F_OneSided, ///Face normals are taken as it is
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
///eVSolver : velocities solvers
|
||||
struct eVSolver { enum _ {
|
||||
Linear, ///Linear solver
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
///ePSolver : positions solvers
|
||||
struct ePSolver { enum _ {
|
||||
Linear, ///Linear solver
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
SContacts, ///Soft contacts solver
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
///eSolverPresets
|
||||
struct eSolverPresets { enum _ {
|
||||
Positions,
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
Default = Positions,
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
///eFeature
|
||||
struct eFeature { enum _ {
|
||||
None,
|
||||
@@ -94,20 +94,20 @@ public:
|
||||
Face,
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
typedef btAlignedObjectArray<eVSolver::_> tVSolverArray;
|
||||
typedef btAlignedObjectArray<ePSolver::_> tPSolverArray;
|
||||
|
||||
|
||||
//
|
||||
// Flags
|
||||
//
|
||||
|
||||
|
||||
///fCollision
|
||||
struct fCollision { enum _ {
|
||||
RVSmask = 0x000f, ///Rigid versus soft mask
|
||||
SDF_RS = 0x0001, ///SDF based rigid vs soft
|
||||
CL_RS = 0x0002, ///Cluster vs convex rigid vs soft
|
||||
|
||||
|
||||
SVSmask = 0x00f0, ///Rigid versus soft mask
|
||||
VF_SS = 0x0010, ///Vertex vs face soft vs soft handling
|
||||
CL_SS = 0x0020, ///Cluster vs cluster soft vs soft handling
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
Default = SDF_RS,
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
///fMaterial
|
||||
struct fMaterial { enum _ {
|
||||
DebugDraw = 0x0001, /// Enable debug draw
|
||||
@@ -123,11 +123,11 @@ public:
|
||||
Default = DebugDraw,
|
||||
END
|
||||
};};
|
||||
|
||||
|
||||
//
|
||||
// API Types
|
||||
//
|
||||
|
||||
|
||||
/* sRayCast */
|
||||
struct sRayCast
|
||||
{
|
||||
@@ -136,13 +136,13 @@ public:
|
||||
int index; /// feature index
|
||||
btScalar fraction; /// time of impact fraction (rayorg+(rayto-rayfrom)*fraction)
|
||||
};
|
||||
|
||||
|
||||
/* ImplicitFn */
|
||||
struct ImplicitFn
|
||||
{
|
||||
virtual btScalar Eval(const btVector3& x)=0;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Internal types
|
||||
//
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
btScalar m_kVST; // Volume stiffness coefficient [0,1]
|
||||
int m_flags; // Flags
|
||||
};
|
||||
|
||||
|
||||
/* Feature */
|
||||
struct Feature : Element
|
||||
{
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
btScalar m_adamping;
|
||||
btScalar m_matching;
|
||||
bool m_collide;
|
||||
Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
|
||||
Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
|
||||
};
|
||||
/* Impulse */
|
||||
struct Impulse
|
||||
@@ -307,109 +307,109 @@ public:
|
||||
int m_asDrift:1;
|
||||
Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0) {}
|
||||
Impulse operator -() const
|
||||
{
|
||||
{
|
||||
Impulse i=*this;
|
||||
i.m_velocity=-i.m_velocity;
|
||||
i.m_drift=-i.m_drift;
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
Impulse operator*(btScalar x) const
|
||||
{
|
||||
{
|
||||
Impulse i=*this;
|
||||
i.m_velocity*=x;
|
||||
i.m_drift*=x;
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
/* Body */
|
||||
struct Body
|
||||
{
|
||||
Cluster* m_soft;
|
||||
btRigidBody* m_rigid;
|
||||
Body() : m_soft(0),m_rigid(0) {}
|
||||
Body(Cluster* p) : m_soft(p),m_rigid(0) {}
|
||||
Body(btRigidBody* p) : m_soft(0),m_rigid(p) {}
|
||||
Body() : m_soft(0),m_rigid(0) {}
|
||||
Body(Cluster* p) : m_soft(p),m_rigid(0) {}
|
||||
Body(btRigidBody* p) : m_soft(0),m_rigid(p) {}
|
||||
void activate() const
|
||||
{
|
||||
{
|
||||
if(m_rigid) m_rigid->activate();
|
||||
}
|
||||
}
|
||||
const btMatrix3x3& invWorldInertia() const
|
||||
{
|
||||
{
|
||||
static const btMatrix3x3 iwi(0,0,0,0,0,0,0,0,0);
|
||||
if(m_rigid) return(m_rigid->getInvInertiaTensorWorld());
|
||||
if(m_soft) return(m_soft->m_invwi);
|
||||
return(iwi);
|
||||
}
|
||||
}
|
||||
btScalar invMass() const
|
||||
{
|
||||
{
|
||||
if(m_rigid) return(m_rigid->getInvMass());
|
||||
if(m_soft) return(m_soft->m_imass);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
const btTransform& xform() const
|
||||
{
|
||||
{
|
||||
static const btTransform identity=btTransform::getIdentity();
|
||||
if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
|
||||
if(m_soft) return(m_soft->m_framexform);
|
||||
return(identity);
|
||||
}
|
||||
}
|
||||
btVector3 linearVelocity() const
|
||||
{
|
||||
{
|
||||
if(m_rigid) return(m_rigid->getLinearVelocity());
|
||||
if(m_soft) return(m_soft->m_lv);
|
||||
return(btVector3(0,0,0));
|
||||
}
|
||||
}
|
||||
btVector3 angularVelocity(const btVector3& rpos) const
|
||||
{
|
||||
{
|
||||
if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
|
||||
if(m_soft) return(cross(m_soft->m_av,rpos));
|
||||
return(btVector3(0,0,0));
|
||||
}
|
||||
}
|
||||
btVector3 angularVelocity() const
|
||||
{
|
||||
{
|
||||
if(m_rigid) return(m_rigid->getAngularVelocity());
|
||||
if(m_soft) return(m_soft->m_av);
|
||||
return(btVector3(0,0,0));
|
||||
}
|
||||
}
|
||||
btVector3 velocity(const btVector3& rpos) const
|
||||
{
|
||||
{
|
||||
return(linearVelocity()+angularVelocity(rpos));
|
||||
}
|
||||
}
|
||||
void applyVImpulse(const btVector3& impulse,const btVector3& rpos) const
|
||||
{
|
||||
{
|
||||
if(m_rigid) m_rigid->applyImpulse(impulse,rpos);
|
||||
if(m_soft) btSoftBody::clusterVImpulse(m_soft,rpos,impulse);
|
||||
}
|
||||
}
|
||||
void applyDImpulse(const btVector3& impulse,const btVector3& rpos) const
|
||||
{
|
||||
{
|
||||
if(m_rigid) m_rigid->applyImpulse(impulse,rpos);
|
||||
if(m_soft) btSoftBody::clusterDImpulse(m_soft,rpos,impulse);
|
||||
}
|
||||
}
|
||||
void applyImpulse(const Impulse& impulse,const btVector3& rpos) const
|
||||
{
|
||||
{
|
||||
if(impulse.m_asVelocity) applyVImpulse(impulse.m_velocity,rpos);
|
||||
if(impulse.m_asDrift) applyDImpulse(impulse.m_drift,rpos);
|
||||
}
|
||||
}
|
||||
void applyVAImpulse(const btVector3& impulse) const
|
||||
{
|
||||
{
|
||||
if(m_rigid) m_rigid->applyTorqueImpulse(impulse);
|
||||
if(m_soft) btSoftBody::clusterVAImpulse(m_soft,impulse);
|
||||
}
|
||||
}
|
||||
void applyDAImpulse(const btVector3& impulse) const
|
||||
{
|
||||
{
|
||||
if(m_rigid) m_rigid->applyTorqueImpulse(impulse);
|
||||
if(m_soft) btSoftBody::clusterDAImpulse(m_soft,impulse);
|
||||
}
|
||||
}
|
||||
void applyAImpulse(const Impulse& impulse) const
|
||||
{
|
||||
{
|
||||
if(impulse.m_asVelocity) applyVAImpulse(impulse.m_velocity);
|
||||
if(impulse.m_asDrift) applyDAImpulse(impulse.m_drift);
|
||||
}
|
||||
}
|
||||
void applyDCImpulse(const btVector3& impulse) const
|
||||
{
|
||||
{
|
||||
if(m_rigid) m_rigid->applyCentralImpulse(impulse);
|
||||
if(m_soft) btSoftBody::clusterDCImpulse(m_soft,impulse);
|
||||
}
|
||||
}
|
||||
};
|
||||
/* Joint */
|
||||
struct Joint
|
||||
@@ -420,12 +420,12 @@ public:
|
||||
Contact,
|
||||
};};
|
||||
struct Specs
|
||||
{
|
||||
Specs() : erp(1),cfm(1),split(1) {}
|
||||
{
|
||||
Specs() : erp(1),cfm(1),split(1) {}
|
||||
btScalar erp;
|
||||
btScalar cfm;
|
||||
btScalar split;
|
||||
};
|
||||
};
|
||||
Body m_bodies[2];
|
||||
btVector3 m_refs[2];
|
||||
btScalar m_cfm;
|
||||
@@ -436,7 +436,7 @@ public:
|
||||
btMatrix3x3 m_massmatrix;
|
||||
bool m_delete;
|
||||
virtual ~Joint() {}
|
||||
Joint() : m_delete(false) {}
|
||||
Joint() : m_delete(false) {}
|
||||
virtual void Prepare(btScalar dt,int iterations);
|
||||
virtual void Solve(btScalar dt,btScalar sor)=0;
|
||||
virtual void Terminate(btScalar dt)=0;
|
||||
@@ -446,9 +446,9 @@ public:
|
||||
struct LJoint : Joint
|
||||
{
|
||||
struct Specs : Joint::Specs
|
||||
{
|
||||
{
|
||||
btVector3 position;
|
||||
};
|
||||
};
|
||||
btVector3 m_rpos[2];
|
||||
void Prepare(btScalar dt,int iterations);
|
||||
void Solve(btScalar dt,btScalar sor);
|
||||
@@ -459,17 +459,17 @@ public:
|
||||
struct AJoint : Joint
|
||||
{
|
||||
struct IControl
|
||||
{
|
||||
{
|
||||
virtual void Prepare(AJoint*) {}
|
||||
virtual btScalar Speed(AJoint*,btScalar current) { return(current); }
|
||||
static IControl* Default() { static IControl def;return(&def); }
|
||||
};
|
||||
};
|
||||
struct Specs : Joint::Specs
|
||||
{
|
||||
Specs() : icontrol(IControl::Default()) {}
|
||||
{
|
||||
Specs() : icontrol(IControl::Default()) {}
|
||||
btVector3 axis;
|
||||
IControl* icontrol;
|
||||
};
|
||||
};
|
||||
btVector3 m_axis[2];
|
||||
IControl* m_icontrol;
|
||||
void Prepare(btScalar dt,int iterations);
|
||||
@@ -534,24 +534,24 @@ public:
|
||||
};
|
||||
/// RayFromToCaster takes a ray from, ray to (instead of direction!)
|
||||
struct RayFromToCaster : btDbvt::ICollide
|
||||
{
|
||||
{
|
||||
btVector3 m_rayFrom;
|
||||
btVector3 m_rayTo;
|
||||
btVector3 m_rayNormalizedDirection;
|
||||
btScalar m_mint;
|
||||
Face* m_face;
|
||||
int m_tests;
|
||||
RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt);
|
||||
RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt);
|
||||
void Process(const btDbvtNode* leaf);
|
||||
|
||||
|
||||
static inline btScalar rayFromToTriangle(const btVector3& rayFrom,
|
||||
const btVector3& rayTo,
|
||||
const btVector3& rayNormalizedDirection,
|
||||
const btVector3& a,
|
||||
const btVector3& b,
|
||||
const btVector3& c,
|
||||
btScalar maxt=SIMD_INFINITY);
|
||||
};
|
||||
const btVector3& rayTo,
|
||||
const btVector3& rayNormalizedDirection,
|
||||
const btVector3& a,
|
||||
const btVector3& b,
|
||||
const btVector3& c,
|
||||
btScalar maxt=SIMD_INFINITY);
|
||||
};
|
||||
|
||||
//
|
||||
// Typedef's
|
||||
@@ -597,15 +597,15 @@ public:
|
||||
btDbvt m_fdbvt; // Faces tree
|
||||
btDbvt m_cdbvt; // Clusters tree
|
||||
tClusterArray m_clusters; // Clusters
|
||||
|
||||
|
||||
//
|
||||
// Api
|
||||
//
|
||||
|
||||
|
||||
/* ctor */
|
||||
btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count,
|
||||
const btVector3* x,
|
||||
const btScalar* m);
|
||||
const btVector3* x,
|
||||
const btScalar* m);
|
||||
/* dtor */
|
||||
virtual ~btSoftBody();
|
||||
/* Check for existing link */
|
||||
@@ -625,51 +625,51 @@ public:
|
||||
bool checkLink( int node0,
|
||||
int node1) const;
|
||||
bool checkLink( const Node* node0,
|
||||
const Node* node1) const;
|
||||
const Node* node1) const;
|
||||
/* Check for existring face */
|
||||
bool checkFace( int node0,
|
||||
int node1,
|
||||
int node2) const;
|
||||
int node1,
|
||||
int node2) const;
|
||||
/* Append material */
|
||||
Material* appendMaterial();
|
||||
/* Append note */
|
||||
void appendNote( const char* text,
|
||||
const btVector3& o,
|
||||
const btVector4& c=btVector4(1,0,0,0),
|
||||
Node* n0=0,
|
||||
Node* n1=0,
|
||||
Node* n2=0,
|
||||
Node* n3=0);
|
||||
const btVector3& o,
|
||||
const btVector4& c=btVector4(1,0,0,0),
|
||||
Node* n0=0,
|
||||
Node* n1=0,
|
||||
Node* n2=0,
|
||||
Node* n3=0);
|
||||
void appendNote( const char* text,
|
||||
const btVector3& o,
|
||||
Node* feature);
|
||||
const btVector3& o,
|
||||
Node* feature);
|
||||
void appendNote( const char* text,
|
||||
const btVector3& o,
|
||||
Link* feature);
|
||||
const btVector3& o,
|
||||
Link* feature);
|
||||
void appendNote( const char* text,
|
||||
const btVector3& o,
|
||||
Face* feature);
|
||||
const btVector3& o,
|
||||
Face* feature);
|
||||
/* Append node */
|
||||
void appendNode( const btVector3& x,btScalar m);
|
||||
/* Append link */
|
||||
void appendLink(int model=-1,Material* mat=0);
|
||||
void appendLink( int node0,
|
||||
int node1,
|
||||
Material* mat=0,
|
||||
bool bcheckexist=false);
|
||||
int node1,
|
||||
Material* mat=0,
|
||||
bool bcheckexist=false);
|
||||
void appendLink( Node* node0,
|
||||
Node* node1,
|
||||
Material* mat=0,
|
||||
bool bcheckexist=false);
|
||||
Node* node1,
|
||||
Material* mat=0,
|
||||
bool bcheckexist=false);
|
||||
/* Append face */
|
||||
void appendFace(int model=-1,Material* mat=0);
|
||||
void appendFace( int node0,
|
||||
int node1,
|
||||
int node2,
|
||||
Material* mat=0);
|
||||
int node1,
|
||||
int node2,
|
||||
Material* mat=0);
|
||||
/* Append anchor */
|
||||
void appendAnchor( int node,
|
||||
btRigidBody* body);
|
||||
btRigidBody* body);
|
||||
/* Append linear joint */
|
||||
void appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
|
||||
void appendLinearJoint(const LJoint::Specs& specs,Body body=Body());
|
||||
@@ -682,7 +682,7 @@ public:
|
||||
void addForce( const btVector3& force);
|
||||
/* Add force (or gravity) to a node of the body */
|
||||
void addForce( const btVector3& force,
|
||||
int node);
|
||||
int node);
|
||||
/* Add velocity to the entire body */
|
||||
void addVelocity( const btVector3& velocity);
|
||||
|
||||
@@ -691,17 +691,17 @@ public:
|
||||
|
||||
/* Add velocity to a node of the body */
|
||||
void addVelocity( const btVector3& velocity,
|
||||
int node);
|
||||
int node);
|
||||
/* Set mass */
|
||||
void setMass( int node,
|
||||
btScalar mass);
|
||||
btScalar mass);
|
||||
/* Get mass */
|
||||
btScalar getMass( int node) const;
|
||||
/* Get total mass */
|
||||
btScalar getTotalMass() const;
|
||||
/* Set total mass (weighted by previous masses) */
|
||||
void setTotalMass( btScalar mass,
|
||||
bool fromfaces=false);
|
||||
bool fromfaces=false);
|
||||
/* Set total density */
|
||||
void setTotalDensity(btScalar density);
|
||||
/* Transform */
|
||||
@@ -714,7 +714,7 @@ public:
|
||||
void scale( const btVector3& scl);
|
||||
/* Set current state as pose */
|
||||
void setPose( bool bvolume,
|
||||
bool bframe);
|
||||
bool bframe);
|
||||
/* Return the volume */
|
||||
btScalar getVolume() const;
|
||||
/* Cluster count */
|
||||
@@ -734,7 +734,7 @@ public:
|
||||
static void clusterDCImpulse(Cluster* cluster,const btVector3& impulse);
|
||||
/* Generate bending constraints based on distance in the adjency graph */
|
||||
int generateBendingConstraints( int distance,
|
||||
Material* mat=0);
|
||||
Material* mat=0);
|
||||
/* Randomize constraints to reduce solver bias */
|
||||
void randomizeConstraints();
|
||||
/* Release clusters */
|
||||
@@ -747,11 +747,11 @@ public:
|
||||
/* CutLink */
|
||||
bool cutLink(int node0,int node1,btScalar position);
|
||||
bool cutLink(const Node* node0,const Node* node1,btScalar position);
|
||||
|
||||
|
||||
///Ray casting using rayFrom and rayTo in worldspace, (not direction!)
|
||||
bool rayTest(const btVector3& rayFrom,
|
||||
const btVector3& rayTo,
|
||||
sRayCast& results);
|
||||
const btVector3& rayTo,
|
||||
sRayCast& results);
|
||||
/* Solver presets */
|
||||
void setSolver(eSolverPresets::_ preset);
|
||||
/* predictMotion */
|
||||
@@ -769,11 +769,11 @@ public:
|
||||
/* defaultCollisionHandlers */
|
||||
void defaultCollisionHandler(btCollisionObject* pco);
|
||||
void defaultCollisionHandler(btSoftBody* psb);
|
||||
|
||||
|
||||
//
|
||||
// Cast
|
||||
//
|
||||
|
||||
|
||||
static const btSoftBody* upcast(const btCollisionObject* colObj)
|
||||
{
|
||||
if (colObj->getInternalType()==CO_SOFT_BODY)
|
||||
@@ -803,7 +803,7 @@ public:
|
||||
void indicesToPointers(const int* map=0);
|
||||
|
||||
int rayTest(const btVector3& rayFrom,const btVector3& rayTo,
|
||||
btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
|
||||
btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
|
||||
void initializeFaceTree();
|
||||
btVector3 evaluateCom() const;
|
||||
bool checkContact(btRigidBody* prb,const btVector3& x,btScalar margin,btSoftBody::sCti& cti) const;
|
||||
@@ -826,7 +826,7 @@ public:
|
||||
static void VSolve_Links(btSoftBody* psb,btScalar kst);
|
||||
static psolver_t getSolver(ePSolver::_ solver);
|
||||
static vsolver_t getSolver(eVSolver::_ solver);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,27 +50,27 @@ btSoftBodyConcaveCollisionAlgorithm::~btSoftBodyConcaveCollisionAlgorithm()
|
||||
|
||||
|
||||
btSoftBodyTriangleCallback::btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped):
|
||||
m_dispatcher(dispatcher),
|
||||
m_dispatchInfoPtr(0)
|
||||
m_dispatcher(dispatcher),
|
||||
m_dispatchInfoPtr(0)
|
||||
{
|
||||
m_softBody = (btSoftBody*) (isSwapped? body1:body0);
|
||||
m_triBody = isSwapped? body0:body1;
|
||||
|
||||
//
|
||||
// create the manifold from the dispatcher 'manifold pool'
|
||||
//
|
||||
// m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
|
||||
|
||||
clearCache();
|
||||
//
|
||||
// create the manifold from the dispatcher 'manifold pool'
|
||||
//
|
||||
// m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
|
||||
|
||||
clearCache();
|
||||
}
|
||||
|
||||
btSoftBodyTriangleCallback::~btSoftBodyTriangleCallback()
|
||||
{
|
||||
clearCache();
|
||||
// m_dispatcher->releaseManifold( m_manifoldPtr );
|
||||
|
||||
// m_dispatcher->releaseManifold( m_manifoldPtr );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void btSoftBodyTriangleCallback::clearCache()
|
||||
{
|
||||
@@ -88,13 +88,13 @@ void btSoftBodyTriangleCallback::clearCache()
|
||||
|
||||
void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||
{
|
||||
//just for debugging purposes
|
||||
//just for debugging purposes
|
||||
//printf("triangle %d",m_triangleCount++);
|
||||
btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
|
||||
btCollisionAlgorithmConstructionInfo ci;
|
||||
ci.m_dispatcher1 = m_dispatcher;
|
||||
|
||||
///debug drawing of the overlapping triangles
|
||||
///debug drawing of the overlapping triangles
|
||||
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
|
||||
{
|
||||
btVector3 color(255,255,0);
|
||||
@@ -107,7 +107,7 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
|
||||
btTriIndex triIndex(partId,triangleIndex,0);
|
||||
btHashKey<btTriIndex> triKey(triIndex.getUid());
|
||||
|
||||
|
||||
|
||||
btTriIndex* shapeIndex = m_shapeCache[triKey];
|
||||
if (shapeIndex)
|
||||
{
|
||||
@@ -116,13 +116,13 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
|
||||
|
||||
//copy over user pointers to temporary shape
|
||||
tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
|
||||
|
||||
|
||||
btCollisionShape* tmpShape = ob->getCollisionShape();
|
||||
ob->internalSetTemporaryCollisionShape( tm );
|
||||
|
||||
|
||||
|
||||
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
|
||||
|
||||
|
||||
colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||
colAlgo->~btCollisionAlgorithm();
|
||||
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
||||
@@ -133,56 +133,56 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
|
||||
//aabb filter is already applied!
|
||||
|
||||
//btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
|
||||
|
||||
// if (m_softBody->getCollisionShape()->getShapeType()==
|
||||
|
||||
// if (m_softBody->getCollisionShape()->getShapeType()==
|
||||
{
|
||||
// btVector3 other;
|
||||
// btVector3 other;
|
||||
btVector3 normal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
|
||||
normal.normalize();
|
||||
normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION;
|
||||
// other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
|
||||
// other+=normal*22.f;
|
||||
// other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
|
||||
// other+=normal*22.f;
|
||||
btVector3 pts[6] = {triangle[0]+normal,
|
||||
triangle[1]+normal,
|
||||
triangle[2]+normal,
|
||||
triangle[0]-normal,
|
||||
triangle[1]-normal,
|
||||
triangle[2]-normal};
|
||||
triangle[2]+normal,
|
||||
triangle[0]-normal,
|
||||
triangle[1]-normal,
|
||||
triangle[2]-normal};
|
||||
|
||||
btConvexHullShape* tm = new btConvexHullShape(&pts[0].getX(),6);
|
||||
|
||||
|
||||
// btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other);
|
||||
|
||||
// btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other);
|
||||
|
||||
//btTriangleShape tm(triangle[0],triangle[1],triangle[2]);
|
||||
// tm.setMargin(m_collisionMarginTriangle);
|
||||
|
||||
// tm.setMargin(m_collisionMarginTriangle);
|
||||
|
||||
//copy over user pointers to temporary shape
|
||||
tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
|
||||
|
||||
|
||||
btCollisionShape* tmpShape = ob->getCollisionShape();
|
||||
ob->internalSetTemporaryCollisionShape( tm );
|
||||
|
||||
|
||||
|
||||
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
|
||||
///this should use the btDispatcher, so the actual registered algorithm is used
|
||||
// btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
|
||||
|
||||
//m_resultOut->setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||
// cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||
// cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||
// cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||
// cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||
colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||
colAlgo->~btCollisionAlgorithm();
|
||||
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
||||
|
||||
|
||||
|
||||
|
||||
ob->internalSetTemporaryCollisionShape( tmpShape );
|
||||
triIndex.m_childShape = tm;
|
||||
m_shapeCache.insert(triKey,triIndex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void btSoftBodyTriangleCallback::setTimeStepAndCounters(btScalar collisionMargin
|
||||
m_collisionMarginTriangle = collisionMarginTriangle+btScalar(BT_SOFTBODY_TRIANGLE_EXTRUSION);
|
||||
m_resultOut = resultOut;
|
||||
|
||||
|
||||
|
||||
btVector3 aabbWorldSpaceMin,aabbWorldSpaceMax;
|
||||
m_softBody->getAabb(aabbWorldSpaceMin,aabbWorldSpaceMax);
|
||||
btVector3 halfExtents = (aabbWorldSpaceMax-aabbWorldSpaceMin)*btScalar(0.5);
|
||||
@@ -217,8 +217,8 @@ void btSoftBodyConcaveCollisionAlgorithm::clearCache()
|
||||
|
||||
void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
btCollisionObject* convexBody = m_isSwapped ? body1 : body0;
|
||||
btCollisionObject* triBody = m_isSwapped ? body0 : body1;
|
||||
|
||||
@@ -228,26 +228,26 @@ void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* b
|
||||
|
||||
btCollisionObject* triOb = triBody;
|
||||
btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
|
||||
|
||||
// if (convexBody->getCollisionShape()->isConvex())
|
||||
|
||||
// if (convexBody->getCollisionShape()->isConvex())
|
||||
{
|
||||
btScalar collisionMarginTriangle = concaveShape->getMargin();
|
||||
|
||||
// resultOut->setPersistentManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
||||
|
||||
// resultOut->setPersistentManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
||||
m_btSoftBodyTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
|
||||
|
||||
//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
|
||||
//m_dispatcher->clearManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
||||
|
||||
// m_btSoftBodyTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
|
||||
// m_btSoftBodyTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
|
||||
|
||||
|
||||
concaveShape->processAllTriangles( &m_btSoftBodyTriangleCallback,m_btSoftBodyTriangleCallback.getAabbMin(),m_btSoftBodyTriangleCallback.getAabbMax());
|
||||
|
||||
// resultOut->refreshContactPoints();
|
||||
|
||||
|
||||
// resultOut->refreshContactPoints();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -287,7 +287,7 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
||||
|
||||
btScalar m_ccdSphereRadius;
|
||||
btScalar m_hitFraction;
|
||||
|
||||
|
||||
|
||||
LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction)
|
||||
:m_ccdSphereFromTrans(from),
|
||||
@@ -296,8 +296,8 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
||||
m_hitFraction(hitFraction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
|
||||
{
|
||||
(void)partId;
|
||||
@@ -327,9 +327,9 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (triBody->getCollisionShape()->isConcave())
|
||||
{
|
||||
btVector3 rayAabbMin = convexFromLocal.getOrigin();
|
||||
@@ -349,12 +349,12 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
||||
btCollisionObject* concavebody = triBody;
|
||||
|
||||
btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
|
||||
|
||||
|
||||
if (triangleMesh)
|
||||
{
|
||||
triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (raycastCallback.m_hitFraction < convexbody->getHitFraction())
|
||||
|
||||
@@ -35,7 +35,7 @@ struct btTriIndex
|
||||
{
|
||||
int m_PartIdTriangleIndex;
|
||||
class btCollisionShape* m_childShape;
|
||||
|
||||
|
||||
btTriIndex(int partId,int triangleIndex,btCollisionShape* shape)
|
||||
{
|
||||
m_PartIdTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
|
||||
@@ -75,11 +75,11 @@ class btSoftBodyTriangleCallback : public btTriangleCallback
|
||||
btScalar m_collisionMarginTriangle;
|
||||
|
||||
btHashMap<btHashKey<btTriIndex>,btTriIndex> m_shapeCache;
|
||||
|
||||
|
||||
public:
|
||||
int m_triangleCount;
|
||||
|
||||
// btPersistentManifold* m_manifoldPtr;
|
||||
int m_triangleCount;
|
||||
|
||||
// btPersistentManifold* m_manifoldPtr;
|
||||
|
||||
btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
|
||||
|
||||
@@ -88,7 +88,7 @@ int m_triangleCount;
|
||||
virtual ~btSoftBodyTriangleCallback();
|
||||
|
||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
|
||||
|
||||
|
||||
void clearCache();
|
||||
|
||||
SIMD_FORCE_INLINE const btVector3& getAabbMin() const
|
||||
|
||||
@@ -22,57 +22,57 @@ subject to the following restrictions:
|
||||
|
||||
//
|
||||
static void drawVertex( btIDebugDraw* idraw,
|
||||
const btVector3& x,btScalar s,const btVector3& c)
|
||||
{
|
||||
idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
|
||||
idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
|
||||
idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
|
||||
}
|
||||
const btVector3& x,btScalar s,const btVector3& c)
|
||||
{
|
||||
idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
|
||||
idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
|
||||
idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
|
||||
}
|
||||
|
||||
//
|
||||
static void drawBox( btIDebugDraw* idraw,
|
||||
const btVector3& mins,
|
||||
const btVector3& maxs,
|
||||
const btVector3& color)
|
||||
const btVector3& mins,
|
||||
const btVector3& maxs,
|
||||
const btVector3& color)
|
||||
{
|
||||
const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),maxs.y(),maxs.z()),
|
||||
btVector3(mins.x(),maxs.y(),maxs.z())};
|
||||
idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
|
||||
idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
|
||||
idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
|
||||
idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
|
||||
idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
|
||||
idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
|
||||
const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),maxs.y(),maxs.z()),
|
||||
btVector3(mins.x(),maxs.y(),maxs.z())};
|
||||
idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
|
||||
idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
|
||||
idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
|
||||
idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
|
||||
idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
|
||||
idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
|
||||
}
|
||||
|
||||
//
|
||||
static void drawTree( btIDebugDraw* idraw,
|
||||
const btDbvtNode* node,
|
||||
int depth,
|
||||
const btVector3& ncolor,
|
||||
const btVector3& lcolor,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
const btDbvtNode* node,
|
||||
int depth,
|
||||
const btVector3& ncolor,
|
||||
const btVector3& lcolor,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
if(node)
|
||||
if(node)
|
||||
{
|
||||
if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
|
||||
if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
|
||||
{
|
||||
drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
}
|
||||
if(depth>=mindepth)
|
||||
if(depth>=mindepth)
|
||||
{
|
||||
const btScalar scl=(btScalar)(node->isinternal()?1:1);
|
||||
const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl;
|
||||
const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl;
|
||||
drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
|
||||
const btScalar scl=(btScalar)(node->isinternal()?1:1);
|
||||
const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl;
|
||||
const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl;
|
||||
drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,25 +81,25 @@ if(node)
|
||||
template <typename T>
|
||||
static inline T sum(const btAlignedObjectArray<T>& items)
|
||||
{
|
||||
T v;
|
||||
if(items.size())
|
||||
T v;
|
||||
if(items.size())
|
||||
{
|
||||
v=items[0];
|
||||
for(int i=1,ni=items.size();i<ni;++i)
|
||||
v=items[0];
|
||||
for(int i=1,ni=items.size();i<ni;++i)
|
||||
{
|
||||
v+=items[i];
|
||||
v+=items[i];
|
||||
}
|
||||
}
|
||||
return(v);
|
||||
return(v);
|
||||
}
|
||||
|
||||
//
|
||||
template <typename T,typename Q>
|
||||
static inline void add(btAlignedObjectArray<T>& items,const Q& value)
|
||||
{
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
{
|
||||
items[i]+=value;
|
||||
items[i]+=value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ for(int i=0,ni=items.size();i<ni;++i)
|
||||
template <typename T,typename Q>
|
||||
static inline void mul(btAlignedObjectArray<T>& items,const Q& value)
|
||||
{
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
{
|
||||
items[i]*=value;
|
||||
items[i]*=value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ for(int i=0,ni=items.size();i<ni;++i)
|
||||
template <typename T>
|
||||
static inline T average(const btAlignedObjectArray<T>& items)
|
||||
{
|
||||
const btScalar n=(btScalar)(items.size()>0?items.size():1);
|
||||
return(sum(items)/n);
|
||||
const btScalar n=(btScalar)(items.size()>0?items.size():1);
|
||||
return(sum(items)/n);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -136,27 +136,27 @@ static inline btScalar tetravolume(const btVector3& x0,
|
||||
//
|
||||
#if 0
|
||||
static btVector3 stresscolor(btScalar stress)
|
||||
{
|
||||
{
|
||||
static const btVector3 spectrum[]= { btVector3(1,0,1),
|
||||
btVector3(0,0,1),
|
||||
btVector3(0,1,1),
|
||||
btVector3(0,1,0),
|
||||
btVector3(1,1,0),
|
||||
btVector3(1,0,0),
|
||||
btVector3(1,0,0)};
|
||||
btVector3(0,0,1),
|
||||
btVector3(0,1,1),
|
||||
btVector3(0,1,0),
|
||||
btVector3(1,1,0),
|
||||
btVector3(1,0,0),
|
||||
btVector3(1,0,0)};
|
||||
static const int ncolors=sizeof(spectrum)/sizeof(spectrum[0])-1;
|
||||
static const btScalar one=1;
|
||||
stress=btMax<btScalar>(0,btMin<btScalar>(1,stress))*ncolors;
|
||||
const int sel=(int)stress;
|
||||
const btScalar frc=stress-sel;
|
||||
return(spectrum[sel]+(spectrum[sel+1]-spectrum[sel])*frc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int drawflags)
|
||||
btIDebugDraw* idraw,
|
||||
int drawflags)
|
||||
{
|
||||
const btScalar scl=(btScalar)0.1;
|
||||
const btScalar nscl=scl*5;
|
||||
@@ -251,29 +251,29 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
const btVector3 x[]={f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x};
|
||||
const btVector3 c=(x[0]+x[1]+x[2])/3;
|
||||
idraw->drawTriangle((x[0]-c)*scl+c,
|
||||
(x[1]-c)*scl+c,
|
||||
(x[2]-c)*scl+c,
|
||||
col,alp);
|
||||
(x[1]-c)*scl+c,
|
||||
(x[2]-c)*scl+c,
|
||||
col,alp);
|
||||
}
|
||||
}
|
||||
/* Clusters */
|
||||
if(0!=(drawflags&fDrawFlags::Clusters))
|
||||
{
|
||||
{
|
||||
srand(1806);
|
||||
for(i=0;i<psb->m_clusters.size();++i)
|
||||
{
|
||||
{
|
||||
if(psb->m_clusters[i]->m_collide)
|
||||
{
|
||||
{
|
||||
btVector3 color( rand()/(btScalar)RAND_MAX,
|
||||
rand()/(btScalar)RAND_MAX,
|
||||
rand()/(btScalar)RAND_MAX);
|
||||
rand()/(btScalar)RAND_MAX,
|
||||
rand()/(btScalar)RAND_MAX);
|
||||
color=color.normalized()*0.75;
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
vertices.resize(psb->m_clusters[i]->m_nodes.size());
|
||||
for(j=0,nj=vertices.size();j<nj;++j)
|
||||
{
|
||||
{
|
||||
vertices[j]=psb->m_clusters[i]->m_nodes[j]->m_x;
|
||||
}
|
||||
}
|
||||
HullDesc hdsc(QF_TRIANGLES,vertices.size(),&vertices[0]);
|
||||
HullResult hres;
|
||||
HullLibrary hlib;
|
||||
@@ -284,32 +284,32 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
mul(hres.m_OutputVertices,(btScalar)1);
|
||||
add(hres.m_OutputVertices,center);
|
||||
for(j=0;j<(int)hres.mNumFaces;++j)
|
||||
{
|
||||
{
|
||||
const int idx[]={hres.m_Indices[j*3+0],hres.m_Indices[j*3+1],hres.m_Indices[j*3+2]};
|
||||
idraw->drawTriangle(hres.m_OutputVertices[idx[0]],
|
||||
hres.m_OutputVertices[idx[1]],
|
||||
hres.m_OutputVertices[idx[2]],
|
||||
color,1);
|
||||
}
|
||||
hlib.ReleaseResult(hres);
|
||||
hres.m_OutputVertices[idx[1]],
|
||||
hres.m_OutputVertices[idx[2]],
|
||||
color,1);
|
||||
}
|
||||
hlib.ReleaseResult(hres);
|
||||
}
|
||||
/* Velocities */
|
||||
#if 0
|
||||
#if 0
|
||||
for(int j=0;j<psb->m_clusters[i].m_nodes.size();++j)
|
||||
{
|
||||
{
|
||||
const btSoftBody::Cluster& c=psb->m_clusters[i];
|
||||
const btVector3 r=c.m_nodes[j]->m_x-c.m_com;
|
||||
const btVector3 v=c.m_lv+cross(c.m_av,r);
|
||||
idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/* Frame */
|
||||
btSoftBody::Cluster& c=*psb->m_clusters[i];
|
||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(10,0,0),btVector3(1,0,0));
|
||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,10,0),btVector3(0,1,0));
|
||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,0,10),btVector3(0,0,1));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Notes */
|
||||
if(0!=(drawflags&fDrawFlags::Notes))
|
||||
{
|
||||
@@ -318,9 +318,9 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
const btSoftBody::Note& n=psb->m_notes[i];
|
||||
btVector3 p=n.m_offset;
|
||||
for(int j=0;j<n.m_rank;++j)
|
||||
{
|
||||
{
|
||||
p+=n.m_nodes[j]->m_x*n.m_coords[j];
|
||||
}
|
||||
}
|
||||
idraw->draw3dText(p,n.m_text);
|
||||
}
|
||||
}
|
||||
@@ -333,33 +333,33 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
/* Joints */
|
||||
if(0!=(drawflags&fDrawFlags::Joints))
|
||||
{
|
||||
for(i=0;i<psb->m_joints.size();++i)
|
||||
for(i=0;i<psb->m_joints.size();++i)
|
||||
{
|
||||
const btSoftBody::Joint* pj=psb->m_joints[i];
|
||||
switch(pj->Type())
|
||||
const btSoftBody::Joint* pj=psb->m_joints[i];
|
||||
switch(pj->Type())
|
||||
{
|
||||
case btSoftBody::Joint::eType::Linear:
|
||||
{
|
||||
const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj;
|
||||
const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
|
||||
idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
|
||||
idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
|
||||
drawVertex(idraw,a0,0.25,btVector3(1,1,0));
|
||||
drawVertex(idraw,a1,0.25,btVector3(0,1,1));
|
||||
const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj;
|
||||
const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
|
||||
idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
|
||||
idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
|
||||
drawVertex(idraw,a0,0.25,btVector3(1,1,0));
|
||||
drawVertex(idraw,a1,0.25,btVector3(0,1,1));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case btSoftBody::Joint::eType::Angular:
|
||||
{
|
||||
const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj;
|
||||
const btVector3 o0=pj->m_bodies[0].xform().getOrigin();
|
||||
const btVector3 o1=pj->m_bodies[1].xform().getOrigin();
|
||||
const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
|
||||
idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
|
||||
idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
|
||||
const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj;
|
||||
const btVector3 o0=pj->m_bodies[0].xform().getOrigin();
|
||||
const btVector3 o1=pj->m_bodies[1].xform().getOrigin();
|
||||
const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
|
||||
idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
|
||||
idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,10 +368,10 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
bool masses,
|
||||
bool areas,
|
||||
bool /*stress*/)
|
||||
btIDebugDraw* idraw,
|
||||
bool masses,
|
||||
bool areas,
|
||||
bool /*stress*/)
|
||||
{
|
||||
for(int i=0;i<psb->m_nodes.size();++i)
|
||||
{
|
||||
@@ -394,34 +394,34 @@ void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawNodeTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
|
||||
drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawFaceTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
|
||||
drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawClusterTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
|
||||
drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
||||
btIDebugDraw* idraw)
|
||||
btIDebugDraw* idraw)
|
||||
{
|
||||
if(psb->m_pose.m_bframe)
|
||||
{
|
||||
@@ -445,9 +445,9 @@ void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, const btVector3& from,
|
||||
const btVector3& to,
|
||||
int res,
|
||||
int fixeds)
|
||||
const btVector3& to,
|
||||
int res,
|
||||
int fixeds)
|
||||
{
|
||||
/* Create nodes */
|
||||
const int r=res+2;
|
||||
@@ -477,13 +477,13 @@ btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, cons
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags)
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags)
|
||||
{
|
||||
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
||||
/* Create nodes */
|
||||
@@ -554,83 +554,83 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags,
|
||||
float* tex_coords)
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags,
|
||||
float* tex_coords)
|
||||
{
|
||||
|
||||
/*
|
||||
*
|
||||
* corners:
|
||||
*
|
||||
* [0][0] corner00 ------- corner01 [resx][0]
|
||||
* | |
|
||||
* | |
|
||||
* [0][resy] corner10 -------- corner11 [resx][resy]
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* "fixedgs" map:
|
||||
*
|
||||
* corner00 --> +1
|
||||
* corner01 --> +2
|
||||
* corner10 --> +4
|
||||
* corner11 --> +8
|
||||
* upper middle --> +16
|
||||
* left middle --> +32
|
||||
* right middle --> +64
|
||||
* lower middle --> +128
|
||||
* center --> +256
|
||||
*
|
||||
*
|
||||
* tex_coords size (resx-1)*(resy-1)*12
|
||||
*
|
||||
*
|
||||
*
|
||||
* SINGLE QUAD INTERNALS
|
||||
*
|
||||
* 1) btSoftBody's nodes and links,
|
||||
* diagonal link is optional ("gendiags")
|
||||
*
|
||||
*
|
||||
* node00 ------ node01
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* node10 node11
|
||||
*
|
||||
*
|
||||
*
|
||||
* 2) Faces:
|
||||
* two triangles,
|
||||
* UV Coordinates (hier example for single quad)
|
||||
*
|
||||
* (0,1) (0,1) (1,1)
|
||||
* 1 |\ 3 \-----| 2
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* 2 |-----\ 3 \| 1
|
||||
* (0,0) (1,0) (1,0)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* corners:
|
||||
*
|
||||
* [0][0] corner00 ------- corner01 [resx][0]
|
||||
* | |
|
||||
* | |
|
||||
* [0][resy] corner10 -------- corner11 [resx][resy]
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* "fixedgs" map:
|
||||
*
|
||||
* corner00 --> +1
|
||||
* corner01 --> +2
|
||||
* corner10 --> +4
|
||||
* corner11 --> +8
|
||||
* upper middle --> +16
|
||||
* left middle --> +32
|
||||
* right middle --> +64
|
||||
* lower middle --> +128
|
||||
* center --> +256
|
||||
*
|
||||
*
|
||||
* tex_coords size (resx-1)*(resy-1)*12
|
||||
*
|
||||
*
|
||||
*
|
||||
* SINGLE QUAD INTERNALS
|
||||
*
|
||||
* 1) btSoftBody's nodes and links,
|
||||
* diagonal link is optional ("gendiags")
|
||||
*
|
||||
*
|
||||
* node00 ------ node01
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* node10 node11
|
||||
*
|
||||
*
|
||||
*
|
||||
* 2) Faces:
|
||||
* two triangles,
|
||||
* UV Coordinates (hier example for single quad)
|
||||
*
|
||||
* (0,1) (0,1) (1,1)
|
||||
* 1 |\ 3 \-----| 2
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* 2 |-----\ 3 \| 1
|
||||
* (0,0) (1,0) (1,0)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
||||
/* Create nodes */
|
||||
@@ -675,12 +675,12 @@ btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
{
|
||||
const bool mdx=(ix+1)<rx;
|
||||
const bool mdy=(iy+1)<ry;
|
||||
|
||||
|
||||
int node00=IDX(ix,iy);
|
||||
int node01=IDX(ix+1,iy);
|
||||
int node10=IDX(ix,iy+1);
|
||||
int node11=IDX(ix+1,iy+1);
|
||||
|
||||
|
||||
if(mdx) psb->appendLink(node00,node01);
|
||||
if(mdy) psb->appendLink(node00,node10);
|
||||
if(mdx&&mdy)
|
||||
@@ -716,32 +716,32 @@ btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
float btSoftBodyHelpers::CalculateUV(int resx,int resy,int ix,int iy,int id)
|
||||
{
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* node00 --- node01
|
||||
* | |
|
||||
* node10 --- node11
|
||||
*
|
||||
*
|
||||
* ID map:
|
||||
*
|
||||
* node00 s --> 0
|
||||
* node00 t --> 1
|
||||
*
|
||||
* node01 s --> 3
|
||||
* node01 t --> 1
|
||||
*
|
||||
* node10 s --> 0
|
||||
* node10 t --> 2
|
||||
*
|
||||
* node11 s --> 3
|
||||
* node11 t --> 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
*
|
||||
*
|
||||
* node00 --- node01
|
||||
* | |
|
||||
* node10 --- node11
|
||||
*
|
||||
*
|
||||
* ID map:
|
||||
*
|
||||
* node00 s --> 0
|
||||
* node00 t --> 1
|
||||
*
|
||||
* node01 s --> 3
|
||||
* node01 t --> 1
|
||||
*
|
||||
* node10 s --> 0
|
||||
* node10 t --> 2
|
||||
*
|
||||
* node11 s --> 3
|
||||
* node11 t --> 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
float tc=0.0f;
|
||||
float tc=0.0f;
|
||||
if (id == 0) {
|
||||
tc = (1.0f/((resx-1))*ix);
|
||||
}
|
||||
@@ -754,12 +754,12 @@ float tc=0.0f;
|
||||
else if (id==3) {
|
||||
tc = (1.0f/((resx-1))*(ix+1));
|
||||
}
|
||||
return tc;
|
||||
return tc;
|
||||
}
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,const btVector3& center,
|
||||
const btVector3& radius,
|
||||
int res)
|
||||
const btVector3& radius,
|
||||
int res)
|
||||
{
|
||||
struct Hammersley
|
||||
{
|
||||
@@ -790,8 +790,8 @@ btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,c
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar* vertices,
|
||||
const int* triangles,
|
||||
int ntriangles)
|
||||
const int* triangles,
|
||||
int ntriangles)
|
||||
{
|
||||
int maxidx=0;
|
||||
int i,j,ni;
|
||||
@@ -832,7 +832,7 @@ btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices,
|
||||
int nvertices)
|
||||
int nvertices)
|
||||
{
|
||||
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
|
||||
HullResult hres;
|
||||
|
||||
@@ -46,74 +46,74 @@ struct btSoftBodyHelpers
|
||||
{
|
||||
/* Draw body */
|
||||
static void Draw( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int drawflags=fDrawFlags::Std);
|
||||
btIDebugDraw* idraw,
|
||||
int drawflags=fDrawFlags::Std);
|
||||
/* Draw body infos */
|
||||
static void DrawInfos( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
bool masses,
|
||||
bool areas,
|
||||
bool stress);
|
||||
btIDebugDraw* idraw,
|
||||
bool masses,
|
||||
bool areas,
|
||||
bool stress);
|
||||
/* Draw node tree */
|
||||
static void DrawNodeTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth=0,
|
||||
int maxdepth=-1);
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth=0,
|
||||
int maxdepth=-1);
|
||||
/* Draw face tree */
|
||||
static void DrawFaceTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth=0,
|
||||
int maxdepth=-1);
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth=0,
|
||||
int maxdepth=-1);
|
||||
/* Draw cluster tree */
|
||||
static void DrawClusterTree(btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth=0,
|
||||
int maxdepth=-1);
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth=0,
|
||||
int maxdepth=-1);
|
||||
/* Draw rigid frame */
|
||||
static void DrawFrame( btSoftBody* psb,
|
||||
btIDebugDraw* idraw);
|
||||
btIDebugDraw* idraw);
|
||||
/* Create a rope */
|
||||
static btSoftBody* CreateRope( btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& from,
|
||||
const btVector3& to,
|
||||
int res,
|
||||
int fixeds);
|
||||
const btVector3& from,
|
||||
const btVector3& to,
|
||||
int res,
|
||||
int fixeds);
|
||||
/* Create a patch */
|
||||
static btSoftBody* CreatePatch(btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags);
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags);
|
||||
/* Create a patch with UV Texture Coordinates */
|
||||
static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags,
|
||||
float* tex_coords=0);
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags,
|
||||
float* tex_coords=0);
|
||||
static float CalculateUV(int resx,int resy,int ix,int iy,int id);
|
||||
/* Create an ellipsoid */
|
||||
static btSoftBody* CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& center,
|
||||
const btVector3& radius,
|
||||
int res);
|
||||
const btVector3& center,
|
||||
const btVector3& radius,
|
||||
int res);
|
||||
/* Create from trimesh */
|
||||
static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo,
|
||||
const btScalar* vertices,
|
||||
const int* triangles,
|
||||
int ntriangles);
|
||||
const btScalar* vertices,
|
||||
const int* triangles,
|
||||
int ntriangles);
|
||||
/* Create from convex-hull */
|
||||
static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3* vertices,
|
||||
int nvertices);
|
||||
const btVector3* vertices,
|
||||
int nvertices);
|
||||
};
|
||||
|
||||
#endif //SOFT_BODY_HELPERS_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,10 +29,10 @@ btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfigura
|
||||
|
||||
mem = btAlignedAlloc(sizeof(btSoftSoftCollisionAlgorithm::CreateFunc),16);
|
||||
m_softSoftCreateFunc = new(mem) btSoftSoftCollisionAlgorithm::CreateFunc;
|
||||
|
||||
|
||||
mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
|
||||
m_softRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
|
||||
|
||||
|
||||
mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
|
||||
m_swappedSoftRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
|
||||
m_swappedSoftRigidConvexCreateFunc->m_swapped=true;
|
||||
@@ -40,20 +40,20 @@ btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfigura
|
||||
#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS
|
||||
mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
|
||||
m_softRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::CreateFunc;
|
||||
|
||||
|
||||
mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
|
||||
m_swappedSoftRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::SwappedCreateFunc;
|
||||
m_swappedSoftRigidConcaveCreateFunc->m_swapped=true;
|
||||
#endif
|
||||
|
||||
//replace pool by a new one, with potential larger size
|
||||
|
||||
|
||||
if (m_ownsCollisionAlgorithmPool && m_collisionAlgorithmPool)
|
||||
{
|
||||
int curElemSize = m_collisionAlgorithmPool->getElementSize();
|
||||
///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
|
||||
|
||||
|
||||
|
||||
|
||||
int maxSize0 = sizeof(btSoftSoftCollisionAlgorithm);
|
||||
int maxSize1 = sizeof(btSoftRigidCollisionAlgorithm);
|
||||
int maxSize2 = sizeof(btSoftBodyConcaveCollisionAlgorithm);
|
||||
@@ -92,7 +92,7 @@ btSoftBodyRigidBodyCollisionConfiguration::~btSoftBodyRigidBodyCollisionConfigur
|
||||
btAlignedFree( m_swappedSoftRigidConcaveCreateFunc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation
|
||||
btCollisionAlgorithmCreateFunc* btSoftBodyRigidBodyCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ class btSoftBodyRigidBodyCollisionConfiguration : public btDefaultCollisionConfi
|
||||
btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConvexCreateFunc;
|
||||
btCollisionAlgorithmCreateFunc* m_softRigidConcaveCreateFunc;
|
||||
btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConcaveCreateFunc;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
|
||||
|
||||
@@ -35,13 +35,13 @@ m_isSwapped(isSwapped)
|
||||
|
||||
btSoftRigidCollisionAlgorithm::~btSoftRigidCollisionAlgorithm()
|
||||
{
|
||||
|
||||
|
||||
//m_softBody->m_overlappingRigidBodies.remove(m_rigidCollisionObject);
|
||||
|
||||
/*if (m_ownManifold)
|
||||
{
|
||||
if (m_manifoldPtr)
|
||||
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||
if (m_manifoldPtr)
|
||||
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ void btSoftRigidCollisionAlgorithm::processCollision (btCollisionObject* body0,b
|
||||
|
||||
btSoftBody* softBody = m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0;
|
||||
btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1;
|
||||
|
||||
|
||||
softBody->defaultCollisionHandler(rigidCollisionObject);
|
||||
|
||||
|
||||
|
||||
@@ -28,15 +28,15 @@ class btSoftBody;
|
||||
/// btSoftRigidCollisionAlgorithm provides collision detection between btSoftBody and btRigidBody
|
||||
class btSoftRigidCollisionAlgorithm : public btCollisionAlgorithm
|
||||
{
|
||||
// bool m_ownManifold;
|
||||
// btPersistentManifold* m_manifoldPtr;
|
||||
// bool m_ownManifold;
|
||||
// btPersistentManifold* m_manifoldPtr;
|
||||
|
||||
btSoftBody* m_softBody;
|
||||
btCollisionObject* m_rigidCollisionObject;
|
||||
|
||||
///for rigid versus soft (instead of soft versus rigid), we use this swapped boolean
|
||||
bool m_isSwapped;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
btSoftRigidCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
//we don't add any manifolds
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||
{
|
||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
||||
|
||||
@@ -28,17 +28,17 @@ subject to the following restrictions:
|
||||
btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
|
||||
:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
|
||||
{
|
||||
m_drawFlags = fDrawFlags::Std;
|
||||
m_drawNodeTree = true;
|
||||
m_drawFaceTree = false;
|
||||
m_drawClusterTree = false;
|
||||
m_sbi.m_broadphase = pairCache;
|
||||
m_sbi.m_dispatcher = dispatcher;
|
||||
m_sbi.m_sparsesdf.Initialize();
|
||||
m_sbi.m_sparsesdf.Reset();
|
||||
m_drawFlags = fDrawFlags::Std;
|
||||
m_drawNodeTree = true;
|
||||
m_drawFaceTree = false;
|
||||
m_drawClusterTree = false;
|
||||
m_sbi.m_broadphase = pairCache;
|
||||
m_sbi.m_dispatcher = dispatcher;
|
||||
m_sbi.m_sparsesdf.Initialize();
|
||||
m_sbi.m_sparsesdf.Reset();
|
||||
|
||||
}
|
||||
|
||||
|
||||
btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld()
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ void btSoftRigidDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
|
||||
psb->predictMotion(timeStep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
|
||||
{
|
||||
btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep );
|
||||
@@ -71,7 +71,7 @@ void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
|
||||
void btSoftRigidDynamicsWorld::updateSoftBodies()
|
||||
{
|
||||
BT_PROFILE("updateSoftBodies");
|
||||
|
||||
|
||||
for ( int i=0;i<m_softBodies.size();i++)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
|
||||
@@ -82,12 +82,12 @@ void btSoftRigidDynamicsWorld::updateSoftBodies()
|
||||
void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints()
|
||||
{
|
||||
BT_PROFILE("solveSoftConstraints");
|
||||
|
||||
|
||||
if(m_softBodies.size())
|
||||
{
|
||||
{
|
||||
btSoftBody::solveClusters(m_softBodies);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(int i=0;i<m_softBodies.size();++i)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
|
||||
@@ -100,8 +100,8 @@ void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body)
|
||||
m_softBodies.push_back(body);
|
||||
|
||||
btCollisionWorld::addCollisionObject(body,
|
||||
btBroadphaseProxy::DefaultFilter,
|
||||
btBroadphaseProxy::AllFilter);
|
||||
btBroadphaseProxy::DefaultFilter,
|
||||
btBroadphaseProxy::AllFilter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef btAlignedObjectArray<btSoftBody*> btSoftBodyArray;
|
||||
|
||||
class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld
|
||||
{
|
||||
|
||||
|
||||
btSoftBodyArray m_softBodies;
|
||||
int m_drawFlags;
|
||||
bool m_drawNodeTree;
|
||||
@@ -32,9 +32,9 @@ class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld
|
||||
btSoftBodyWorldInfo m_sbi;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual void predictUnconstraintMotion(btScalar timeStep);
|
||||
|
||||
|
||||
virtual void internalSingleStepSimulation( btScalar timeStep);
|
||||
|
||||
void updateSoftBodies();
|
||||
@@ -43,17 +43,17 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
|
||||
|
||||
virtual ~btSoftRigidDynamicsWorld();
|
||||
|
||||
|
||||
virtual void debugDrawWorld();
|
||||
|
||||
|
||||
void addSoftBody(btSoftBody* body);
|
||||
|
||||
void removeSoftBody(btSoftBody* body);
|
||||
|
||||
|
||||
int getDrawFlags() const { return(m_drawFlags); }
|
||||
void setDrawFlags(int f) { m_drawFlags=f; }
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
return m_sbi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
btSoftBodyArray& getSoftBodyArray()
|
||||
{
|
||||
return m_softBodies;
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
return m_softBodies;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_SOFT_RIGID_DYNAMICS_WORLD_H
|
||||
|
||||
@@ -33,7 +33,7 @@ class btSoftSoftCollisionAlgorithm : public btCollisionAlgorithm
|
||||
btSoftBody* m_softBody0;
|
||||
btSoftBody* m_softBody1;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
btSoftSoftCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||
: btCollisionAlgorithm(ci) {}
|
||||
|
||||
@@ -23,139 +23,139 @@ subject to the following restrictions:
|
||||
// Modified Paul Hsieh hash
|
||||
template <const int DWORDLEN>
|
||||
unsigned int HsiehHash(const void* pdata)
|
||||
{
|
||||
{
|
||||
const unsigned short* data=(const unsigned short*)pdata;
|
||||
unsigned hash=DWORDLEN<<2,tmp;
|
||||
for(int i=0;i<DWORDLEN;++i)
|
||||
{
|
||||
{
|
||||
hash += data[0];
|
||||
tmp = (data[1]<<11)^hash;
|
||||
hash = (hash<<16)^tmp;
|
||||
data += 2;
|
||||
hash += hash>>11;
|
||||
}
|
||||
}
|
||||
hash^=hash<<3;hash+=hash>>5;
|
||||
hash^=hash<<4;hash+=hash>>17;
|
||||
hash^=hash<<25;hash+=hash>>6;
|
||||
return(hash);
|
||||
}
|
||||
}
|
||||
|
||||
template <const int CELLSIZE>
|
||||
struct btSparseSdf
|
||||
{
|
||||
{
|
||||
//
|
||||
// Inner types
|
||||
//
|
||||
struct IntFrac
|
||||
{
|
||||
{
|
||||
int b;
|
||||
int i;
|
||||
btScalar f;
|
||||
};
|
||||
};
|
||||
struct Cell
|
||||
{
|
||||
{
|
||||
btScalar d[CELLSIZE+1][CELLSIZE+1][CELLSIZE+1];
|
||||
int c[3];
|
||||
int puid;
|
||||
unsigned hash;
|
||||
btCollisionShape* pclient;
|
||||
Cell* next;
|
||||
};
|
||||
};
|
||||
//
|
||||
// Fields
|
||||
//
|
||||
|
||||
|
||||
btAlignedObjectArray<Cell*> cells;
|
||||
btScalar voxelsz;
|
||||
int puid;
|
||||
int ncells;
|
||||
int nprobes;
|
||||
int nqueries;
|
||||
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
void Initialize(int hashsize=2383)
|
||||
{
|
||||
{
|
||||
cells.resize(hashsize,0);
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
//
|
||||
void Reset()
|
||||
{
|
||||
{
|
||||
for(int i=0,ni=cells.size();i<ni;++i)
|
||||
{
|
||||
{
|
||||
Cell* pc=cells[i];
|
||||
cells[i]=0;
|
||||
while(pc)
|
||||
{
|
||||
{
|
||||
Cell* pn=pc->next;
|
||||
delete pc;
|
||||
pc=pn;
|
||||
}
|
||||
}
|
||||
}
|
||||
voxelsz =0.25;
|
||||
puid =0;
|
||||
ncells =0;
|
||||
nprobes =1;
|
||||
nqueries =1;
|
||||
}
|
||||
}
|
||||
//
|
||||
void GarbageCollect(int lifetime=256)
|
||||
{
|
||||
{
|
||||
const int life=puid-lifetime;
|
||||
for(int i=0;i<cells.size();++i)
|
||||
{
|
||||
{
|
||||
Cell*& root=cells[i];
|
||||
Cell* pp=0;
|
||||
Cell* pc=root;
|
||||
while(pc)
|
||||
{
|
||||
{
|
||||
Cell* pn=pc->next;
|
||||
if(pc->puid<life)
|
||||
{
|
||||
{
|
||||
if(pp) pp->next=pn; else root=pn;
|
||||
delete pc;pc=pp;--ncells;
|
||||
}
|
||||
pp=pc;pc=pn;
|
||||
}
|
||||
pp=pc;pc=pn;
|
||||
}
|
||||
}
|
||||
//printf("GC[%d]: %d cells, PpQ: %f\r\n",puid,ncells,nprobes/(btScalar)nqueries);
|
||||
nqueries=1;
|
||||
nprobes=1;
|
||||
++puid; /* TODO: Reset puid's when int range limit is reached */
|
||||
/* else setup a priority list... */
|
||||
}
|
||||
/* else setup a priority list... */
|
||||
}
|
||||
//
|
||||
int RemoveReferences(btCollisionShape* pcs)
|
||||
{
|
||||
{
|
||||
int refcount=0;
|
||||
for(int i=0;i<cells.size();++i)
|
||||
{
|
||||
{
|
||||
Cell*& root=cells[i];
|
||||
Cell* pp=0;
|
||||
Cell* pc=root;
|
||||
while(pc)
|
||||
{
|
||||
{
|
||||
Cell* pn=pc->next;
|
||||
if(pc->pclient==pcs)
|
||||
{
|
||||
{
|
||||
if(pp) pp->next=pn; else root=pn;
|
||||
delete pc;pc=pp;++refcount;
|
||||
}
|
||||
pp=pc;pc=pn;
|
||||
}
|
||||
pp=pc;pc=pn;
|
||||
}
|
||||
return(refcount);
|
||||
}
|
||||
return(refcount);
|
||||
}
|
||||
//
|
||||
btScalar Evaluate( const btVector3& x,
|
||||
btCollisionShape* shape,
|
||||
btVector3& normal,
|
||||
btScalar margin)
|
||||
{
|
||||
btCollisionShape* shape,
|
||||
btVector3& normal,
|
||||
btScalar margin)
|
||||
{
|
||||
/* Lookup cell */
|
||||
const btVector3 scx=x/voxelsz;
|
||||
const IntFrac ix=Decompose(scx.x());
|
||||
@@ -166,19 +166,19 @@ struct btSparseSdf
|
||||
Cell* c=root;
|
||||
++nqueries;
|
||||
while(c)
|
||||
{
|
||||
{
|
||||
++nprobes;
|
||||
if( (c->hash==h) &&
|
||||
(c->c[0]==ix.b) &&
|
||||
(c->c[1]==iy.b) &&
|
||||
(c->c[2]==iz.b) &&
|
||||
(c->pclient==shape))
|
||||
{ break; }
|
||||
else
|
||||
{ c=c->next; }
|
||||
}
|
||||
{ break; }
|
||||
else
|
||||
{ c=c->next; }
|
||||
}
|
||||
if(!c)
|
||||
{
|
||||
{
|
||||
++nprobes;
|
||||
++ncells;
|
||||
c=new Cell();
|
||||
@@ -187,82 +187,82 @@ struct btSparseSdf
|
||||
c->hash=h;
|
||||
c->c[0]=ix.b;c->c[1]=iy.b;c->c[2]=iz.b;
|
||||
BuildCell(*c);
|
||||
}
|
||||
}
|
||||
c->puid=puid;
|
||||
/* Extract infos */
|
||||
const int o[]={ ix.i,iy.i,iz.i};
|
||||
const btScalar d[]={ c->d[o[0]+0][o[1]+0][o[2]+0],
|
||||
c->d[o[0]+1][o[1]+0][o[2]+0],
|
||||
c->d[o[0]+1][o[1]+1][o[2]+0],
|
||||
c->d[o[0]+0][o[1]+1][o[2]+0],
|
||||
c->d[o[0]+0][o[1]+0][o[2]+1],
|
||||
c->d[o[0]+1][o[1]+0][o[2]+1],
|
||||
c->d[o[0]+1][o[1]+1][o[2]+1],
|
||||
c->d[o[0]+0][o[1]+1][o[2]+1]};
|
||||
c->d[o[0]+1][o[1]+0][o[2]+0],
|
||||
c->d[o[0]+1][o[1]+1][o[2]+0],
|
||||
c->d[o[0]+0][o[1]+1][o[2]+0],
|
||||
c->d[o[0]+0][o[1]+0][o[2]+1],
|
||||
c->d[o[0]+1][o[1]+0][o[2]+1],
|
||||
c->d[o[0]+1][o[1]+1][o[2]+1],
|
||||
c->d[o[0]+0][o[1]+1][o[2]+1]};
|
||||
/* Normal */
|
||||
#if 1
|
||||
#if 1
|
||||
const btScalar gx[]={ d[1]-d[0],d[2]-d[3],
|
||||
d[5]-d[4],d[6]-d[7]};
|
||||
d[5]-d[4],d[6]-d[7]};
|
||||
const btScalar gy[]={ d[3]-d[0],d[2]-d[1],
|
||||
d[7]-d[4],d[6]-d[5]};
|
||||
d[7]-d[4],d[6]-d[5]};
|
||||
const btScalar gz[]={ d[4]-d[0],d[5]-d[1],
|
||||
d[7]-d[3],d[6]-d[2]};
|
||||
d[7]-d[3],d[6]-d[2]};
|
||||
normal.setX(Lerp( Lerp(gx[0],gx[1],iy.f),
|
||||
Lerp(gx[2],gx[3],iy.f),iz.f));
|
||||
Lerp(gx[2],gx[3],iy.f),iz.f));
|
||||
normal.setY(Lerp( Lerp(gy[0],gy[1],ix.f),
|
||||
Lerp(gy[2],gy[3],ix.f),iz.f));
|
||||
Lerp(gy[2],gy[3],ix.f),iz.f));
|
||||
normal.setZ(Lerp( Lerp(gz[0],gz[1],ix.f),
|
||||
Lerp(gz[2],gz[3],ix.f),iy.f));
|
||||
Lerp(gz[2],gz[3],ix.f),iy.f));
|
||||
normal = normal.normalized();
|
||||
#else
|
||||
#else
|
||||
normal = btVector3(d[1]-d[0],d[3]-d[0],d[4]-d[0]).normalized();
|
||||
#endif
|
||||
#endif
|
||||
/* Distance */
|
||||
const btScalar d0=Lerp(Lerp(d[0],d[1],ix.f),
|
||||
Lerp(d[3],d[2],ix.f),iy.f);
|
||||
Lerp(d[3],d[2],ix.f),iy.f);
|
||||
const btScalar d1=Lerp(Lerp(d[4],d[5],ix.f),
|
||||
Lerp(d[7],d[6],ix.f),iy.f);
|
||||
Lerp(d[7],d[6],ix.f),iy.f);
|
||||
return(Lerp(d0,d1,iz.f)-margin);
|
||||
}
|
||||
}
|
||||
//
|
||||
void BuildCell(Cell& c)
|
||||
{
|
||||
{
|
||||
const btVector3 org=btVector3( (btScalar)c.c[0],
|
||||
(btScalar)c.c[1],
|
||||
(btScalar)c.c[2]) *
|
||||
CELLSIZE*voxelsz;
|
||||
(btScalar)c.c[1],
|
||||
(btScalar)c.c[2]) *
|
||||
CELLSIZE*voxelsz;
|
||||
for(int k=0;k<=CELLSIZE;++k)
|
||||
{
|
||||
{
|
||||
const btScalar z=voxelsz*k+org.z();
|
||||
for(int j=0;j<=CELLSIZE;++j)
|
||||
{
|
||||
{
|
||||
const btScalar y=voxelsz*j+org.y();
|
||||
for(int i=0;i<=CELLSIZE;++i)
|
||||
{
|
||||
{
|
||||
const btScalar x=voxelsz*i+org.x();
|
||||
c.d[i][j][k]=DistanceToShape( btVector3(x,y,z),
|
||||
c.pclient);
|
||||
}
|
||||
c.pclient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
static inline btScalar DistanceToShape(const btVector3& x,
|
||||
btCollisionShape* shape)
|
||||
{
|
||||
btCollisionShape* shape)
|
||||
{
|
||||
btTransform unit;
|
||||
unit.setIdentity();
|
||||
if(shape->isConvex())
|
||||
{
|
||||
{
|
||||
btGjkEpaSolver2::sResults res;
|
||||
btConvexShape* csh=static_cast<btConvexShape*>(shape);
|
||||
return(btGjkEpaSolver2::SignedDistance(x,0,csh,unit,res));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
//
|
||||
static inline IntFrac Decompose(btScalar x)
|
||||
{
|
||||
{
|
||||
/* That one need a lot of improvements... */
|
||||
/* Remove test, faster floor... */
|
||||
IntFrac r;
|
||||
@@ -272,18 +272,18 @@ struct btSparseSdf
|
||||
const btScalar k=(x-r.b)*CELLSIZE;
|
||||
r.i=(int)k;r.f=k-r.i;r.b-=o;
|
||||
return(r);
|
||||
}
|
||||
}
|
||||
//
|
||||
static inline btScalar Lerp(btScalar a,btScalar b,btScalar t)
|
||||
{
|
||||
{
|
||||
return(a+(b-a)*t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
static inline unsigned int Hash(int x,int y,int z,btCollisionShape* shape)
|
||||
{
|
||||
{
|
||||
struct btS
|
||||
{
|
||||
int x,y,z;
|
||||
@@ -291,16 +291,16 @@ struct btSparseSdf
|
||||
};
|
||||
|
||||
btS myset;
|
||||
|
||||
|
||||
myset.x=x;myset.y=y;myset.z=z;myset.p=shape;
|
||||
const void* ptr = &myset;
|
||||
|
||||
unsigned int result = HsiehHash<sizeof(btS)/4> (ptr);
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user