Only recalculate outer_vert_indices when points are resized

This commit is contained in:
Grant Sanderson 2023-02-02 14:29:37 -08:00
parent b9d6dcd67d
commit bd89056c8e

View file

@ -1053,13 +1053,22 @@ class VMobject(Mobject):
vmob.pointwise_become_partial(self, a, b)
return vmob
def resize_points(
self,
new_length: int,
resize_func: Callable[[np.ndarray, int], np.ndarray] = resize_array
) -> Self:
super().resize_points(new_length, resize_func)
n_curves = self.get_num_curves()
# Creates the pattern (0, 1, 2, 2, 3, 4, 4, 5, 6, ...)
self.outer_vert_indices = (np.arange(1, 3 * n_curves + 1) * 2) // 3
return self
def get_outer_vert_indices(self) -> np.ndarray:
"""
Returns the pattern (0, 1, 2, 2, 3, 4, 4, 5, 6, ...)
"""
n_curves = self.get_num_curves()
if len(self.outer_vert_indices) != 3 * n_curves:
self.outer_vert_indices = (np.arange(1, 3 * n_curves + 1) * 2) // 3
return self.outer_vert_indices
# Data for shaders that may need refreshing