mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Don't get rid of null curves each frame, instead do it once for SVG mobjects.
This commit is contained in:
parent
cf8790eefa
commit
a4d4ae9b47
2 changed files with 4 additions and 6 deletions
|
@ -329,7 +329,7 @@ class VMobjectFromSVGPathstring(VMobject):
|
||||||
|
|
||||||
def __init__(self, path_string, **kwargs):
|
def __init__(self, path_string, **kwargs):
|
||||||
self.path_string = path_string
|
self.path_string = path_string
|
||||||
VMobject.__init__(self, **kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def init_points(self):
|
def init_points(self):
|
||||||
# TODO, move this caching operation
|
# TODO, move this caching operation
|
||||||
|
@ -355,10 +355,10 @@ class VMobjectFromSVGPathstring(VMobject):
|
||||||
self.subdivide_sharp_curves()
|
self.subdivide_sharp_curves()
|
||||||
# SVG treats y-coordinate differently
|
# SVG treats y-coordinate differently
|
||||||
self.stretch(-1, 1, about_point=ORIGIN)
|
self.stretch(-1, 1, about_point=ORIGIN)
|
||||||
|
# Get rid of any null curves
|
||||||
|
self.points = self.get_points_without_null_curves()
|
||||||
# Save to a file for future use
|
# Save to a file for future use
|
||||||
np.save(filepath, self.points)
|
np.save(filepath, self.points)
|
||||||
# Faster rendering
|
|
||||||
self.lock_triangulation()
|
|
||||||
|
|
||||||
def get_commands_and_coord_strings(self):
|
def get_commands_and_coord_strings(self):
|
||||||
all_commands = list(self.get_command_to_function_map().keys())
|
all_commands = list(self.get_command_to_function_map().keys())
|
||||||
|
|
|
@ -608,8 +608,6 @@ class VMobject(Mobject):
|
||||||
|
|
||||||
def get_points_without_null_curves(self, atol=1e-9):
|
def get_points_without_null_curves(self, atol=1e-9):
|
||||||
nppc = self.n_points_per_curve
|
nppc = self.n_points_per_curve
|
||||||
if len(self.points) <= nppc + 1:
|
|
||||||
return self.points
|
|
||||||
distinct_curves = reduce(op.or_, [
|
distinct_curves = reduce(op.or_, [
|
||||||
(abs(self.points[i::nppc] - self.points[0::nppc]) > atol).any(1)
|
(abs(self.points[i::nppc] - self.points[0::nppc]) > atol).any(1)
|
||||||
for i in range(1, nppc)
|
for i in range(1, nppc)
|
||||||
|
@ -912,7 +910,7 @@ class VMobject(Mobject):
|
||||||
if len(stroke_width) > 1:
|
if len(stroke_width) > 1:
|
||||||
stroke_width = self.stretched_style_array_matching_points(stroke_width)
|
stroke_width = self.stretched_style_array_matching_points(stroke_width)
|
||||||
|
|
||||||
points = self.get_points_without_null_curves()
|
points = self.points
|
||||||
nppc = self.n_points_per_curve
|
nppc = self.n_points_per_curve
|
||||||
|
|
||||||
data = self.get_blank_shader_data_array(len(points), "stroke_data")
|
data = self.get_blank_shader_data_array(len(points), "stroke_data")
|
||||||
|
|
Loading…
Add table
Reference in a new issue