HPL1: remove optimisations in collider creation

this fixes a problem with an entrance being blocked by wrong colliders
This commit is contained in:
grisenti 2022-09-02 18:37:27 +02:00 committed by Eugene Sandulenko
parent d0dbf8fb5a
commit 4a52032bde
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -257,11 +257,7 @@ void cCollideShapeNewton::CreateFromVertices(const unsigned int *apIndexArray, i
const float *apVertexArray, int alVtxStride, int alVtxNum) {
float vTriVec[9];
bool bOptimize = false;
bool bCreatedPlane = false;
cPlanef plane;
mpNewtonCollision = NewtonCreateTreeCollision(mpNewtonWorld, NULL);
mpNewtonCollision = NewtonCreateTreeCollision(mpNewtonWorld, 0);
// Log("-- Creating mesh collision.:\n");
NewtonTreeCollisionBeginBuild(mpNewtonCollision);
for (int tri = 0; tri < alIndexNum; tri += 3) {
@ -274,34 +270,10 @@ void cCollideShapeNewton::CreateFromVertices(const unsigned int *apIndexArray, i
vTriVec[idx * 3 + 2] = apVertexArray[lVtx + 2];
}
if (bOptimize == false) {
cPlanef tempPlane;
cVector3f vP1(vTriVec[0 + 0], vTriVec[0 + 1], vTriVec[0 + 2]);
cVector3f vP2(vTriVec[1 * 3 + 0], vTriVec[1 * 3 + 1], vTriVec[1 * 3 + 2]);
cVector3f vP3(vTriVec[2 * 3 + 0], vTriVec[2 * 3 + 1], vTriVec[2 * 3 + 2]);
tempPlane.FromPoints(vP1, vP2, vP3);
// Log("P1: %s P2: %s P3: %s\n",vP1.ToString().c_str(),vP2.ToString().c_str(),vP3.ToString().c_str());
// Log("Plane: a: %f b: %f c: %f d: %f\n",tempPlane.a,tempPlane.b,tempPlane.c,tempPlane.d);
if (bCreatedPlane == false) {
plane = tempPlane;
bCreatedPlane = true;
} else {
if (std::abs(plane.a - tempPlane.a) > 0.001f ||
std::abs(plane.b - tempPlane.b) > 0.001f ||
std::abs(plane.c - tempPlane.c) > 0.001f ||
std::abs(plane.d - tempPlane.d) > 0.001f) {
bOptimize = true;
}
}
}
NewtonTreeCollisionAddFace(mpNewtonCollision, 3, vTriVec, sizeof(float) * 3, 1);
}
NewtonTreeCollisionEndBuild(mpNewtonCollision, bOptimize ? 1 : 0);
NewtonTreeCollisionEndBuild(mpNewtonCollision, false);
// Set bounding box size
mBoundingVolume.AddArrayPoints(apVertexArray, alVtxNum);