mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 13:01:00 +00:00
Allow alignment/interpolation/etc. between mobjects with different data keys
This commit is contained in:
parent
a58772db87
commit
d04d451c6a
1 changed files with 8 additions and 5 deletions
|
@ -1126,7 +1126,7 @@ class Mobject(object):
|
||||||
# Separate out how points are treated so that subclasses
|
# Separate out how points are treated so that subclasses
|
||||||
# can handle that case differently if they choose
|
# can handle that case differently if they choose
|
||||||
mob1.align_points(mob2)
|
mob1.align_points(mob2)
|
||||||
for key in mob1.data:
|
for key in mob1.data.keys() & mob2.data.keys():
|
||||||
if key == "points":
|
if key == "points":
|
||||||
continue
|
continue
|
||||||
arr1 = mob1.data[key]
|
arr1 = mob1.data[key]
|
||||||
|
@ -1209,6 +1209,8 @@ class Mobject(object):
|
||||||
continue
|
continue
|
||||||
if len(self.data[key]) == 0:
|
if len(self.data[key]) == 0:
|
||||||
continue
|
continue
|
||||||
|
if key not in mobject1.data or key not in mobject2.data:
|
||||||
|
continue
|
||||||
|
|
||||||
if key in ("points", "bounding_box"):
|
if key in ("points", "bounding_box"):
|
||||||
func = path_func
|
func = path_func
|
||||||
|
@ -1266,10 +1268,11 @@ class Mobject(object):
|
||||||
|
|
||||||
def lock_matching_data(self, mobject1, mobject2):
|
def lock_matching_data(self, mobject1, mobject2):
|
||||||
for sm, sm1, sm2 in zip(self.get_family(), mobject1.get_family(), mobject2.get_family()):
|
for sm, sm1, sm2 in zip(self.get_family(), mobject1.get_family(), mobject2.get_family()):
|
||||||
sm.lock_data([
|
keys = sm.data.keys() & sm1.data.keys() & sm2.data.keys()
|
||||||
key for key in sm.data
|
sm.lock_data(list(filter(
|
||||||
if np.all(sm1.data[key] == sm2.data[key])
|
lambda key: np.all(sm1.data[key] == sm2.data[key]),
|
||||||
])
|
keys,
|
||||||
|
)))
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def unlock_data(self):
|
def unlock_data(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue