mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Don't use @stash_mobject_pointers on copy, be more explicit
This commit is contained in:
parent
bf2a609246
commit
1bd6a77151
1 changed files with 7 additions and 4 deletions
|
@ -591,19 +591,22 @@ class Mobject(object):
|
|||
result._shaders_initialized = False
|
||||
result._data_has_changed = True
|
||||
|
||||
@stash_mobject_pointers
|
||||
def copy(self, deep: bool = False):
|
||||
if deep:
|
||||
return self.deepcopy()
|
||||
|
||||
result = copy.copy(self)
|
||||
|
||||
# The line above is only a shallow copy, so the internal
|
||||
# data which are numpyu arrays or other mobjects still
|
||||
result.parents = []
|
||||
result.target = None
|
||||
result.save_state = None
|
||||
|
||||
# copy.copy is only a shallow copy, so the internal
|
||||
# data which are numpy arrays or other mobjects still
|
||||
# need to be further copied.
|
||||
result.data = self.data.copy()
|
||||
result.uniforms = {
|
||||
key: np.array(value)
|
||||
key: value.copy() if isinstance(value, np.ndarray) else value
|
||||
for key, value in self.uniforms.items()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue