mirror of
https://github.com/3b1b/manim.git
synced 2025-07-28 20:43:56 +08:00
Save triangulation along with points
This commit is contained in:
@ -281,8 +281,7 @@ class SVGMobject(VMobject):
|
||||
matrix[:, 1] *= -1
|
||||
|
||||
for mob in mobject.family_members_with_points():
|
||||
# TODO, directly apply matrix?
|
||||
mob.set_points(np.dot(mob.get_points(), matrix))
|
||||
mob.apply_matrix(matrix.T)
|
||||
mobject.shift(x * RIGHT + y * UP)
|
||||
except:
|
||||
pass
|
||||
@ -355,10 +354,13 @@ class VMobjectFromSVGPathstring(VMobject):
|
||||
# higher up to Mobject somehow.
|
||||
hasher = hashlib.sha256(self.path_string.encode())
|
||||
path_hash = hasher.hexdigest()[:16]
|
||||
filepath = os.path.join(get_mobject_data_dir(), f"{path_hash}.npy")
|
||||
points_filepath = os.path.join(get_mobject_data_dir(), f"{path_hash}_points.npy")
|
||||
tris_filepath = os.path.join(get_mobject_data_dir(), f"{path_hash}_tris.npy")
|
||||
|
||||
if os.path.exists(filepath):
|
||||
self.set_points(np.load(filepath))
|
||||
if os.path.exists(points_filepath) and os.path.exists(tris_filepath):
|
||||
self.set_points(np.load(points_filepath))
|
||||
self.triangulation = np.load(tris_filepath)
|
||||
self.needs_new_triangulation = False
|
||||
else:
|
||||
self.relative_point = np.array(ORIGIN)
|
||||
for command, coord_string in self.get_commands_and_coord_strings():
|
||||
@ -373,7 +375,8 @@ class VMobjectFromSVGPathstring(VMobject):
|
||||
# SVG treats y-coordinate differently
|
||||
self.stretch(-1, 1, about_point=ORIGIN)
|
||||
# Save to a file for future use
|
||||
np.save(filepath, self.get_points())
|
||||
np.save(points_filepath, self.get_points())
|
||||
np.save(tris_filepath, self.get_triangulation())
|
||||
check_and_fix_percent_bug(self)
|
||||
|
||||
def get_commands_and_coord_strings(self):
|
||||
|
Reference in New Issue
Block a user