Fix stl parser bug
This commit is contained in:
parent
7fd66963ca
commit
dc7cb9d0d2
1 changed files with 14 additions and 1 deletions
|
|
@ -81,11 +81,12 @@ pub const Mesh = struct {
|
||||||
indices[i] = new_idx;
|
indices[i] = new_idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// skip attribute bytes
|
||||||
|
offset += 2;
|
||||||
try triangle_vertices.append(allocator, indices);
|
try triangle_vertices.append(allocator, indices);
|
||||||
try triangle_normals.append(allocator, normal);
|
try triangle_normals.append(allocator, normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
std.debug.print("{}", .{vertices});
|
|
||||||
return .{
|
return .{
|
||||||
.triangle_vertices = triangle_vertices,
|
.triangle_vertices = triangle_vertices,
|
||||||
.triangle_normals = triangle_normals,
|
.triangle_normals = triangle_normals,
|
||||||
|
|
@ -150,4 +151,16 @@ test "Test binary stl is parsed correctly" {
|
||||||
vec3.Vec3F64.init(1, 1, 1),
|
vec3.Vec3F64.init(1, 1, 1),
|
||||||
1e-12,
|
1e-12,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
try std.testing.expect(vec3.vec3ApproxEq(
|
||||||
|
mesh.triangle_normals.items[0],
|
||||||
|
vec3.Vec3F64.init(1, 0, 0),
|
||||||
|
1e-12,
|
||||||
|
));
|
||||||
|
|
||||||
|
try std.testing.expect(vec3.vec3ApproxEq(
|
||||||
|
mesh.triangle_normals.items[1],
|
||||||
|
vec3.Vec3F64.init(0, -0.7071067690849304, 0.7071067690849304),
|
||||||
|
1e-12,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue