bool CCharShape::CheckPolyhedronCollision (TCharNode *node, TMatrix modelMatrix, TMatrix invModelMatrix, TPolyhedron ph) { TMatrix newModelMatrix, newInvModelMatrix; TCharNode *child; TPolyhedron newph; bool hit = false; MultiplyMatrices (newModelMatrix, modelMatrix, node->trans); MultiplyMatrices (newInvModelMatrix, node->invtrans, invModelMatrix); if (node->visible) { newph = CopyPolyhedron (ph); TransPolyhedron (newInvModelMatrix, newph); hit = IntersectPolyhedron (newph); FreePolyhedron (newph); } if (hit == true) return hit; child = node->child; while (child != NULL) { hit = CheckPolyhedronCollision (child, newModelMatrix, newInvModelMatrix, ph); if (hit == true) return hit; child = child->next; } return false; }
bool CCharShape::CheckCollision (TPolyhedron ph) { TCharNode *node; TMatrix mat, invmat; MakeIdentityMatrix (mat); MakeIdentityMatrix (invmat); if (GetNode (0, &node) == false) return false; return CheckPolyhedronCollision (node, mat, invmat, ph); }
bool CCharShape::CheckCollision (const TPolyhedron& ph) { TMatrix mat, invmat; MakeIdentityMatrix (mat); MakeIdentityMatrix (invmat); TCharNode *node = GetNode(0); if (node == NULL) return false; return CheckPolyhedronCollision (node, mat, invmat, ph); }
bool CCharShape::CheckPolyhedronCollision(const TCharNode *node, const TMatrix<4, 4>& modelMatrix, const TMatrix<4, 4>& invModelMatrix, const TPolyhedron& ph) { bool hit = false; TMatrix<4, 4> newModelMatrix = modelMatrix * node->trans; TMatrix<4, 4> newInvModelMatrix = node->invtrans * invModelMatrix; if (node->visible) { TPolyhedron newph = ph; TransPolyhedron (newInvModelMatrix, newph); hit = IntersectPolyhedron (newph); } if (hit == true) return hit; const TCharNode *child = node->child; while (child != NULL) { hit = CheckPolyhedronCollision (child, newModelMatrix, newInvModelMatrix, ph); if (hit == true) return hit; child = child->next; } return false; }
bool CCharShape::CheckCollision (const TPolyhedron& ph) { TCharNode *node = GetNode(0); if (node == NULL) return false; const TMatrix<4, 4>& identity = TMatrix<4, 4>::getIdentity(); return CheckPolyhedronCollision(node, identity, identity, ph); }