mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
be more defensive in FBXGeometry::convexHullContains
This commit is contained in:
parent
f57332e4be
commit
47fb85eaeb
1 changed files with 5 additions and 1 deletions
|
@ -78,10 +78,14 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
||||||
|
|
||||||
auto checkEachPrimitive = [=](FBXMesh& mesh, QVector<int> indices, int primitiveSize) -> bool {
|
auto checkEachPrimitive = [=](FBXMesh& mesh, QVector<int> indices, int primitiveSize) -> bool {
|
||||||
// Check whether the point is "behind" all the primitives.
|
// Check whether the point is "behind" all the primitives.
|
||||||
|
int verticesSize = mesh.vertices.size();
|
||||||
for (int j = 0;
|
for (int j = 0;
|
||||||
j < indices.size() - 2; // -2 in case the vertices aren't the right size -- we access j + 2 below
|
j < indices.size() - 2; // -2 in case the vertices aren't the right size -- we access j + 2 below
|
||||||
j += primitiveSize) {
|
j += primitiveSize) {
|
||||||
if (!isPointBehindTrianglesPlane(point,
|
if (indices[j] < verticesSize &&
|
||||||
|
indices[j + 1] < verticesSize &&
|
||||||
|
indices[j + 2] < verticesSize &&
|
||||||
|
!isPointBehindTrianglesPlane(point,
|
||||||
mesh.vertices[indices[j]],
|
mesh.vertices[indices[j]],
|
||||||
mesh.vertices[indices[j + 1]],
|
mesh.vertices[indices[j + 1]],
|
||||||
mesh.vertices[indices[j + 2]])) {
|
mesh.vertices[indices[j + 2]])) {
|
||||||
|
|
Loading…
Reference in a new issue