Change default endpoint angle to be 0

This commit is contained in:
Grant Sanderson
2023-01-10 15:32:05 -08:00
parent 0c3367f27b
commit e189df81b1
2 changed files with 8 additions and 19 deletions

View File

@ -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"]

View File

@ -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);