From e189df81b156cfe0b9465ba90d7a99536c1af2b8 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 10 Jan 2023 15:32:05 -0800 Subject: [PATCH] Change default endpoint angle to be 0 --- manimlib/mobject/types/vectorized_mobject.py | 14 ++++++-------- manimlib/shaders/quadratic_bezier_stroke/geom.glsl | 13 ++----------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index fbea2fe3..525ae9f5 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -1071,18 +1071,16 @@ class VMobject(Mobject): sgn = np.sign(cross2d(vect_to_vert, vect_from_vert)) self.data["joint_angle"][:, 0] = sgn * angle - # To communicate to the shader that a given anchor point - # sits at the end of a curve, we set its angle equal - # to something outside the range [-pi, pi]. - # An arbitrary constant is used + # If a given anchor point sits at the end of a curve, + # we set its angle equal to 0 ends_mismatch = (a1[-1] != a0[0]).any() if ends_mismatch: - self.data["joint_angle"][0] = DISJOINT_CONST - self.data["joint_angle"][-1] = DISJOINT_CONST + self.data["joint_angle"][0] = 0 + self.data["joint_angle"][-1] = 0 mis_matches = (a0[1:] != a1[:-1]).any(1) - self.data["joint_angle"][3::3][mis_matches] = DISJOINT_CONST - self.data["joint_angle"][2:-1:3][mis_matches] = DISJOINT_CONST + self.data["joint_angle"][3::3][mis_matches] = 0 + self.data["joint_angle"][2:-1:3][mis_matches] = 0 return self.data["joint_angle"] diff --git a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl index 4a5d009f..38bdf10b 100644 --- a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl +++ b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl @@ -42,7 +42,6 @@ const int BEVEL_JOINT = 2; const int MITER_JOINT = 3; const float PI = 3.141592653; -const float DISJOINT_CONST = 404.0; const float ANGLE_THRESHOLD = 1e-3; @@ -152,18 +151,10 @@ void main() { } } - // Set joint information + // Set joint information, potentially recomputing based on perspective float angle_from_prev = v_joint_angle[0]; float angle_to_next = v_joint_angle[2]; - if(angle_from_prev == DISJOINT_CONST){ - // TODO, add anti-aliasing patch to curve start - angle_from_prev = 0.0; - } - if(angle_to_next == DISJOINT_CONST){ - // TODO, add anti-aliasing patch to curve end - angle_to_next = 0.0; - } - // Recompute angles based on perspective + if(angle_from_prev > 0.0 && unit_normal != vec3(0.0, 0.0, 1.0)){ vec3 v01 = verts[1] - verts[0]; vec3 from_prev = rotate(v01, angle_from_prev, unit_normal);