From a33b24310e3b33ab42a5c2e5bbe252dccd1c0d3d Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 26 Jan 2023 12:15:30 -0800 Subject: [PATCH] Fix non-winding-fill orientation --- manimlib/mobject/types/vectorized_mobject.py | 6 ++++-- manimlib/shaders/quadratic_bezier_fill/geom.glsl | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index d597e057..79b04bf6 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -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 diff --git a/manimlib/shaders/quadratic_bezier_fill/geom.glsl b/manimlib/shaders/quadratic_bezier_fill/geom.glsl index fae7998b..1326c365 100644 --- a/manimlib/shaders/quadratic_bezier_fill/geom.glsl +++ b/manimlib/shaders/quadratic_bezier_fill/geom.glsl @@ -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];