mirror of
https://github.com/overte-org/overte.git
synced 2025-06-20 01:00:18 +02:00
remove cruft
This commit is contained in:
parent
42d2d4bbe5
commit
dba7cadcae
1 changed files with 0 additions and 123 deletions
|
@ -65,129 +65,6 @@ bool applyPairwiseFilter(btManifoldPoint& cp,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: flipBackfaceTriangleNormals is registered as a sub-callback to Bullet's gContactAddedCallback feature
|
|
||||||
// when we detect MyAvatar is "stuck". It will reverse the triangles on the backface of mesh shapes, unless it thinks
|
|
||||||
// the old normal would be better at extracting MyAvatar out along its UP direction.
|
|
||||||
//
|
|
||||||
// KEEP THIS: flipBackfaceTriangleNormals is NOT USED, but KEEP THIS implemenation in case we want to use it.
|
|
||||||
bool flipBackfaceTriangleNormals(btManifoldPoint& cp,
|
|
||||||
const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0,
|
|
||||||
const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1) {
|
|
||||||
static int32_t numCalls = 0;
|
|
||||||
++numCalls;
|
|
||||||
// This callback is ONLY called on objects with btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK flag
|
|
||||||
// and the flagged object will always be sorted to Obj0. Hence the "other" is always Obj1.
|
|
||||||
const btCollisionObject* other = colObj1Wrap->m_collisionObject;
|
|
||||||
|
|
||||||
if (other->getCollisionShape()->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) {
|
|
||||||
// access the meshInterface
|
|
||||||
auto meshShape = static_cast<const btBvhTriangleMeshShape*>(other->getCollisionShape());
|
|
||||||
const btStridingMeshInterface* meshInterface = meshShape->getMeshInterface();
|
|
||||||
|
|
||||||
// figure out about how to navigate meshInterface
|
|
||||||
const uint8_t* vertexBase;
|
|
||||||
int32_t numverts;
|
|
||||||
PHY_ScalarType vertexType;
|
|
||||||
int32_t vertexStride;
|
|
||||||
const uint8_t* indexBase;
|
|
||||||
int32_t indexStride;
|
|
||||||
int32_t numFaces;
|
|
||||||
PHY_ScalarType indicesType;
|
|
||||||
int32_t subPart = colObj1Wrap->m_partId;
|
|
||||||
// NOTE: all arguments are being passed by reference except the bases (passed by pointer) and subPart (true input)
|
|
||||||
meshInterface->getLockedReadOnlyVertexIndexBase(&vertexBase, numverts, vertexType, vertexStride, &indexBase, indexStride, numFaces, indicesType, subPart);
|
|
||||||
|
|
||||||
// fetch the triangle vertices
|
|
||||||
int32_t triangleIndex = colObj1Wrap->m_index;
|
|
||||||
assert(vertexType == PHY_FLOAT); // all mesh vertex data is float...
|
|
||||||
// ...but indicesType can vary
|
|
||||||
btVector3 triangleVertex[3];
|
|
||||||
switch (indicesType) {
|
|
||||||
case PHY_INTEGER: {
|
|
||||||
uint32_t* triangleIndices = (uint32_t*)(indexBase + triangleIndex * indexStride);
|
|
||||||
float* triangleBase;
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[0] * vertexStride);
|
|
||||||
triangleVertex[0].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[1] * vertexStride);
|
|
||||||
triangleVertex[1].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[2] * vertexStride);
|
|
||||||
triangleVertex[2].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PHY_SHORT: {
|
|
||||||
uint16_t* triangleIndices = (uint16_t*)(indexBase + triangleIndex * indexStride);
|
|
||||||
float* triangleBase;
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[0] * vertexStride);
|
|
||||||
triangleVertex[0].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[1] * vertexStride);
|
|
||||||
triangleVertex[1].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[2] * vertexStride);
|
|
||||||
triangleVertex[2].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PHY_UCHAR: {
|
|
||||||
uint8_t* triangleIndices = (uint8_t*)(indexBase + triangleIndex * indexStride);
|
|
||||||
float* triangleBase;
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[0] * vertexStride);
|
|
||||||
triangleVertex[0].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[1] * vertexStride);
|
|
||||||
triangleVertex[1].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
triangleBase = (float*)(vertexBase + triangleIndices[2] * vertexStride);
|
|
||||||
triangleVertex[2].setValue(triangleBase[0], triangleBase[1], triangleBase[2]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute faceNormal
|
|
||||||
btVector3 meshScaling = meshInterface->getScaling();
|
|
||||||
triangleVertex[0] *= meshScaling;
|
|
||||||
triangleVertex[1] *= meshScaling;
|
|
||||||
triangleVertex[2] *= meshScaling;
|
|
||||||
btVector3 faceNormal = other->getWorldTransform().getBasis() * btCross(triangleVertex[1] - triangleVertex[0], triangleVertex[2] - triangleVertex[0]);
|
|
||||||
float nDotF = btDot(faceNormal, cp.m_normalWorldOnB);
|
|
||||||
if (nDotF <= 0.0f && faceNormal.length2() > EPSILON) {
|
|
||||||
faceNormal.normalize();
|
|
||||||
// flip the contact normal to be aligned with the face normal...
|
|
||||||
// ...but only if old normal does NOT point along obj0's UP
|
|
||||||
// (because we're "stuck" and UP is the likely path out)
|
|
||||||
btVector3 up = colObj0Wrap->m_collisionObject->getWorldTransform().getBasis() * LOCAL_UP_AXIS;
|
|
||||||
if (cp.m_normalWorldOnB.dot(up) <= 0.0f) {
|
|
||||||
nDotF = btDot(faceNormal, cp.m_normalWorldOnB);
|
|
||||||
cp.m_normalWorldOnB -= 2.0f * nDotF * faceNormal;
|
|
||||||
_appliedStuckRecoveryStrategy = true;
|
|
||||||
}
|
|
||||||
// Note: if we're flipping normals it means the "Are we stuck?" logic is concluding "Yes, we are".
|
|
||||||
// But when we flip the normals it typically causes the ContactManifold to discard the modified ManifoldPoint
|
|
||||||
// which in turn causes the "Are we stuck?" logic to incorrectly conclude "No, we are not".
|
|
||||||
// So we set '_appliedStuckRecoveryStrategy = true' here and use it later to stay in "stuck" state
|
|
||||||
// until flipping stops
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// KEEP THIS: in case we add support for concave shapes which delegate to temporary btTriangleShapes (such as btHeightfieldTerrainShape)
|
|
||||||
//else if (other->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE) {
|
|
||||||
// auto triShape = static_cast<const btTriangleShape*>(other->getCollisionShape());
|
|
||||||
// const btVector3* v = triShape->m_vertices1;
|
|
||||||
// btVector3 faceNormal = other->getWorldTransform().getBasis() * btCross(v[1] - v[0], v[2] - v[0]);
|
|
||||||
// float nDotF = btDot(faceNormal, cp.m_normalWorldOnB);
|
|
||||||
// if (nDotF <= 0.0f && faceNormal.length2() > EPSILON) {
|
|
||||||
// faceNormal.normalize();
|
|
||||||
// // flip the contact normal to be aligned with the face normal
|
|
||||||
// cp.m_normalWorldOnB += -2.0f * nDotF * faceNormal;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
// KEEP THIS
|
|
||||||
|
|
||||||
// NOTE: this ManifoldPoint is a candidate and hasn't been accepted yet into the final ContactManifold yet.
|
|
||||||
// So when we modify its parameters we can convince Bullet to discard it.
|
|
||||||
//
|
|
||||||
// by our own convention:
|
|
||||||
// return true when this ManifoldPoint has been modified in a way that would disable it
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_STATE_CHANGE
|
#ifdef DEBUG_STATE_CHANGE
|
||||||
#define SET_STATE(desiredState, reason) setState(desiredState, reason)
|
#define SET_STATE(desiredState, reason) setState(desiredState, reason)
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue