@@ -1938,24 +1938,32 @@ def pointwise_become_partial(
1938
1938
upper_residue ,
1939
1939
)
1940
1940
else :
1941
+ # Copy points if self.points is vmobject.points before setting
1942
+ # self.points = np.empty(...) to avoid in-place modification
1943
+ vmobject_points = (
1944
+ vmobject .points .copy ()
1945
+ if self .points is vmobject .points
1946
+ else vmobject .points
1947
+ )
1948
+
1941
1949
# Allocate space for (upper_index-lower_index+1) Bézier curves.
1942
1950
self .points = np .empty ((nppc * (upper_index - lower_index + 1 ), self .dim ))
1943
1951
# Look at the "lower_index"-th Bezier curve and select its part from
1944
1952
# t=lower_residue to t=1. This is the first curve in self.points.
1945
1953
self .points [:nppc ] = partial_bezier_points (
1946
- vmobject . points [nppc * lower_index : nppc * (lower_index + 1 )],
1954
+ vmobject_points [nppc * lower_index : nppc * (lower_index + 1 )],
1947
1955
lower_residue ,
1948
1956
1 ,
1949
1957
)
1950
1958
# If there are more curves between the "lower_index"-th and the
1951
1959
# "upper_index"-th Béziers, add them all to self.points.
1952
- self .points [nppc :- nppc ] = vmobject . points [
1960
+ self .points [nppc :- nppc ] = vmobject_points [
1953
1961
nppc * (lower_index + 1 ) : nppc * upper_index
1954
1962
]
1955
1963
# Look at the "upper_index"-th Bézier curve and select its part from
1956
1964
# t=0 to t=upper_residue. This is the last curve in self.points.
1957
1965
self .points [- nppc :] = partial_bezier_points (
1958
- vmobject . points [nppc * upper_index : nppc * (upper_index + 1 )],
1966
+ vmobject_points [nppc * upper_index : nppc * (upper_index + 1 )],
1959
1967
0 ,
1960
1968
upper_residue ,
1961
1969
)
0 commit comments