mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 21:08:53 +00:00
Fix non-winding-fill orientation
This commit is contained in:
parent
c6c23a1fe7
commit
a33b24310e
2 changed files with 5 additions and 3 deletions
|
@ -1053,8 +1053,10 @@ class VMobject(Mobject):
|
||||||
null2 = (iti[0::3] - 1 == iti[1::3]) & (iti[0::3] - 2 == iti[2::3])
|
null2 = (iti[0::3] - 1 == iti[1::3]) & (iti[0::3] - 2 == iti[2::3])
|
||||||
inner_tri_indices = iti[~(null1 | null2).repeat(3)]
|
inner_tri_indices = iti[~(null1 | null2).repeat(3)]
|
||||||
|
|
||||||
outer_tri_indices = self.get_outer_vert_indices()
|
ovi = self.get_outer_vert_indices()
|
||||||
tri_indices = np.hstack([outer_tri_indices, inner_tri_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.triangulation = tri_indices
|
||||||
self.needs_new_triangulation = False
|
self.needs_new_triangulation = False
|
||||||
return tri_indices
|
return tri_indices
|
||||||
|
|
|
@ -31,7 +31,7 @@ const vec2 SIMPLE_QUADRATIC[3] = vec2[3](
|
||||||
|
|
||||||
void emit_triangle(vec3 points[3], vec4 v_color[3]){
|
void emit_triangle(vec3 points[3], vec4 v_color[3]){
|
||||||
vec3 unit_normal = get_unit_normal(points[0], points[1], points[2]);
|
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++){
|
for(int i = 0; i < 3; i++){
|
||||||
uv_coords = SIMPLE_QUADRATIC[i];
|
uv_coords = SIMPLE_QUADRATIC[i];
|
||||||
|
|
Loading…
Add table
Reference in a new issue