Fix non-winding-fill orientation

This commit is contained in:
Grant Sanderson 2023-01-26 12:15:30 -08:00
parent c6c23a1fe7
commit a33b24310e
2 changed files with 5 additions and 3 deletions

View file

@ -1053,8 +1053,10 @@ class VMobject(Mobject):
null2 = (iti[0::3] - 1 == iti[1::3]) & (iti[0::3] - 2 == iti[2::3])
inner_tri_indices = iti[~(null1 | null2).repeat(3)]
outer_tri_indices = self.get_outer_vert_indices()
tri_indices = np.hstack([outer_tri_indices, inner_tri_indices])
ovi = self.get_outer_vert_indices()
# Flip outer triangles with negative orientation
ovi[0::3][concave_parts], ovi[2::3][concave_parts] = ovi[2::3][concave_parts], ovi[0::3][concave_parts]
tri_indices = np.hstack([ovi, inner_tri_indices])
self.triangulation = tri_indices
self.needs_new_triangulation = False
return tri_indices

View file

@ -31,7 +31,7 @@ const vec2 SIMPLE_QUADRATIC[3] = vec2[3](
void emit_triangle(vec3 points[3], vec4 v_color[3]){
vec3 unit_normal = get_unit_normal(points[0], points[1], points[2]);
orientation = sign(unit_normal.z);
orientation = winding ? sign(unit_normal.z) : 1.0;
for(int i = 0; i < 3; i++){
uv_coords = SIMPLE_QUADRATIC[i];