Prevent merging non flat meshes together

This commit is contained in:
James Lambert 2023-12-02 13:58:08 -07:00
parent cbcb78def9
commit 00cb4d0018
2 changed files with 5 additions and 5 deletions

View file

@ -64,7 +64,7 @@ unsigned screenClipperClipBoundary(struct ScreenClipper* clipper, struct Vector4
float posReference = direction < 0 ? -pos : pos; float posReference = direction < 0 ? -pos : pos;
int wasInside = oppositeSide ? (posReference > wReference) : (posReference < wReference); int wasInside = oppositeSide ? (posReference > wReference) : (posReference < wReference);
for (unsigned i = 0; i < pointCount; ++i) { for (unsigned i = 0; i < pointCount && outputPointCount < MAX_NEAR_POLYGON_SIZE; ++i) {
struct Vector4* current = &input[i]; struct Vector4* current = &input[i];
pos = VECTOR3_AS_ARRAY(current)[axis]; pos = VECTOR3_AS_ARRAY(current)[axis];
@ -79,7 +79,7 @@ unsigned screenClipperClipBoundary(struct ScreenClipper* clipper, struct Vector4
++outputPointCount; ++outputPointCount;
} }
if (isInside) { if (isInside && outputPointCount < MAX_NEAR_POLYGON_SIZE) {
output[outputPointCount] = input[i]; output[outputPointCount] = input[i];
++outputPointCount; ++outputPointCount;
} }
@ -102,8 +102,8 @@ void screenClipperBoundingPoints(struct ScreenClipper* clipper, struct Vector3*
return; return;
} }
struct Vector4 clipBuffer[16]; struct Vector4 clipBuffer[MAX_NEAR_POLYGON_SIZE];
struct Vector4 clipBufferSwap[16]; struct Vector4 clipBufferSwap[MAX_NEAR_POLYGON_SIZE];
for (unsigned i = 0; i < pointCount; ++i) { for (unsigned i = 0; i < pointCount; ++i) {
matrixVec3Mul(clipper->pointTransform, &input[i], &clipBuffer[i]); matrixVec3Mul(clipper->pointTransform, &input[i], &clipBuffer[i]);

View file

@ -20,7 +20,7 @@ local portalable_surfaces = {
local signal_elements = {} local signal_elements = {}
local coplanar_tolerance = 0.1 local coplanar_tolerance = 0.01
local function is_coplanar(mesh, plane) local function is_coplanar(mesh, plane)
for _, vertex in pairs(mesh.vertices) do for _, vertex in pairs(mesh.vertices) do