Skip to content

Commit

Permalink
Remove workaround for normals not matching winding order (minetest#12460
Browse files Browse the repository at this point in the history
)

Co-authored-by: sfan5 <[email protected]>
  • Loading branch information
x2048 and sfan5 committed Jul 17, 2022
1 parent f090471 commit 7b6c4bf
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/client/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ void recalculateBoundingBox(scene::IMesh *src_mesh)

bool checkMeshNormals(scene::IMesh *mesh)
{
// Assume correct normals if this many first faces get it right.
static const u16 MAX_FACES_TO_CHECK = 9;

u32 buffer_count = mesh->getMeshBufferCount();

for (u32 i = 0; i < buffer_count; i++) {
Expand All @@ -346,19 +343,6 @@ bool checkMeshNormals(scene::IMesh *mesh)

if (!std::isfinite(length) || length < 1e-10f)
return false;

const u16 count = MYMIN(MAX_FACES_TO_CHECK * 3, buffer->getIndexCount() - 3);
for (u16 i = 0; i < count; i += 3) {

core::plane3df plane(buffer->getPosition(buffer->getIndices()[i]),
buffer->getPosition(buffer->getIndices()[i+1]),
buffer->getPosition(buffer->getIndices()[i+2]));

for (u16 j = 0; j < 3; j++)
if (plane.Normal.dotProduct(buffer->getNormal(buffer->getIndices()[i+j])) <= 0)
return false;
}

}

return true;
Expand Down

0 comments on commit 7b6c4bf

Please sign in to comment.