Bring back assertions fix non convexity in exported mesh

This commit is contained in:
sergeypdev 2025-02-01 00:21:29 +04:00
parent 76f3b9ef75
commit ba686422a8
3 changed files with 17 additions and 16 deletions

1
.gitattributes vendored
View File

@ -2,3 +2,4 @@
*.glb filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text

View File

@ -305,30 +305,30 @@ get_convex :: proc(assetman: ^Asset_Manager, path: cstring) -> (result: Loaded_C
}
face.normal = plane.normal
// for index in indices[3:] {
// assert(
// abs(collision.signed_distance_plane(vertices[index].pos, plane)) < 0.01,
// "mesh has non planar faces",
// )
// }
for index in indices[3:] {
assert(
abs(collision.signed_distance_plane(vertices[index].pos, plane)) < 0.01,
"mesh has non planar faces",
)
}
// first_vert_pos := vertices[indices[0]].pos
first_vert_pos := vertices[indices[0]].pos
for i in 0 ..< len(indices) {
edge_idx := halfedge.Edge_Index(first_edge_idx + i)
prev_edge_relative := i == 0 ? len(indices) - 1 : i - 1
next_edge_relative := (i + 1) % len(indices)
i1, i2 := indices[i], indices[next_edge_relative]
v1, _ := &vertices[i1], &vertices[i2]
v1, v2 := &vertices[i1], &vertices[i2]
// assert(
// lg.dot(
// lg.cross(v1.pos - first_vert_pos, v2.pos - first_vert_pos),
// plane.normal,
// ) >=
// 0,
// "non convex face or non ccw winding",
// )
assert(
lg.dot(
lg.cross(v1.pos - first_vert_pos, v2.pos - first_vert_pos),
plane.normal,
) >=
0,
"non convex face or non ccw winding",
)
if v1.edge == -1 {
v1.edge = edge_idx

Binary file not shown.