A community-maintained Python framework for creating mathematical animations.
Improve line rendering performance by decreasing redundant subdivision count (#3893)
nitzanbuenoce1fff645d2b
diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.pyindex 86238551f..7b30f9a7a 100644--- a/manim/mobject/three_d/three_dimensions.py+++ b/manim/mobject/three_d/three_dimensions.py@@ -895,6 +895,12 @@ class Line3D(Cylinder):The thickness of the line.colorThe color of the line.+ resolution+ The resolution of the line.+ By default this value is the number of points the line will sampled at.+ If you want the line to also come out checkered, use a tuple.+ For example, for a line made of 24 points with 4 checker points on each+ cylinder, pass the tuple (4, 24).Examples--------@@ -915,9 +921,11 @@ class Line3D(Cylinder):end: np.ndarray = RIGHT,thickness: float = 0.02,color: ParsableManimColor | None = None,+ resolution: int | Sequence[int] = 24,**kwargs,):self.thickness = thickness+ self.resolution = (2, resolution) if isinstance(resolution, int) else resolutionself.set_start_and_end_attrs(start, end, **kwargs)if color is not None:self.set_color(color)@@ -951,6 +959,7 @@ class Line3D(Cylinder):height=np.linalg.norm(self.vect),radius=self.thickness,direction=self.direction,+ resolution=self.resolution,**kwargs,)self.shift((self.start + self.end) / 2)@@ -1122,6 +1131,8 @@ class Arrow3D(Line3D):The base radius of the conical tip.colorThe color of the arrow.+ resolution+ The resolution of the arrow line.Examples--------@@ -1148,10 +1159,16 @@ class Arrow3D(Line3D):height: float = 0.3,base_radius: float = 0.08,color: ParsableManimColor = WHITE,+ resolution: int | Sequence[int] = 24,**kwargs,) -> None:super().__init__(- start=start, end=end, thickness=thickness, color=color, **kwargs+ start=start,+ end=end,+ thickness=thickness,+ color=color,+ resolution=resolution,+ **kwargs,)self.length = np.linalg.norm(self.vect)diff --git a/tests/test_graphical_units/control_data/threed/AddFixedInFrameMobjects.npz b/tests/test_graphical_units/control_data/threed/AddFixedInFrameMobjects.npzindex 08ca1e595..7387d9f23 100644Binary files a/tests/test_graphical_units/control_data/threed/AddFixedInFrameMobjects.npz and b/tests/test_graphical_units/control_data/threed/AddFixedInFrameMobjects.npz differdiff --git a/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz b/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npzindex 4e6e101e7..f91b970ef 100644Binary files a/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz and b/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Arrow3D.npz b/tests/test_graphical_units/control_data/threed/Arrow3D.npzindex a4fc4c510..a4a6c9b87 100644Binary files a/tests/test_graphical_units/control_data/threed/Arrow3D.npz and b/tests/test_graphical_units/control_data/threed/Arrow3D.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Axes.npz b/tests/test_graphical_units/control_data/threed/Axes.npzindex 206b28697..287a866dd 100644Binary files a/tests/test_graphical_units/control_data/threed/Axes.npz and b/tests/test_graphical_units/control_data/threed/Axes.npz differdiff --git a/tests/test_graphical_units/control_data/threed/CameraMove.npz b/tests/test_graphical_units/control_data/threed/CameraMove.npzindex 23ccfb73b..a88491356 100644Binary files a/tests/test_graphical_units/control_data/threed/CameraMove.npz and b/tests/test_graphical_units/control_data/threed/CameraMove.npz differdiff --git a/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz b/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npzindex 8628c6cb0..fc365464f 100644Binary files a/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz and b/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Cone.npz b/tests/test_graphical_units/control_data/threed/Cone.npzindex 66f315afc..59a856f5a 100644Binary files a/tests/test_graphical_units/control_data/threed/Cone.npz and b/tests/test_graphical_units/control_data/threed/Cone.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Cube.npz b/tests/test_graphical_units/control_data/threed/Cube.npzindex 8a7d147db..a955b37ee 100644Binary files a/tests/test_graphical_units/control_data/threed/Cube.npz and b/tests/test_graphical_units/control_data/threed/Cube.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Cylinder.npz b/tests/test_graphical_units/control_data/threed/Cylinder.npzindex f25388545..bd42a1d91 100644Binary files a/tests/test_graphical_units/control_data/threed/Cylinder.npz and b/tests/test_graphical_units/control_data/threed/Cylinder.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Dot3D.npz b/tests/test_graphical_units/control_data/threed/Dot3D.npzindex 4593a97c0..351dab60e 100644Binary files a/tests/test_graphical_units/control_data/threed/Dot3D.npz and b/tests/test_graphical_units/control_data/threed/Dot3D.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Line3D.npz b/tests/test_graphical_units/control_data/threed/Line3D.npzindex ccf2bb20a..174b9a06e 100644Binary files a/tests/test_graphical_units/control_data/threed/Line3D.npz and b/tests/test_graphical_units/control_data/threed/Line3D.npz differdiff --git a/tests/test_graphical_units/control_data/threed/MovingVertices.npz b/tests/test_graphical_units/control_data/threed/MovingVertices.npzindex 04006a76e..2da8e3a25 100644Binary files a/tests/test_graphical_units/control_data/threed/MovingVertices.npz and b/tests/test_graphical_units/control_data/threed/MovingVertices.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Sphere.npz b/tests/test_graphical_units/control_data/threed/Sphere.npzindex 58cd44267..c007a0baa 100644Binary files a/tests/test_graphical_units/control_data/threed/Sphere.npz and b/tests/test_graphical_units/control_data/threed/Sphere.npz differdiff --git a/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz b/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npzindex 3a8539352..e3b4a5e95 100644Binary files a/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz and b/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Torus.npz b/tests/test_graphical_units/control_data/threed/Torus.npzindex e50dd86de..f973dea17 100644Binary files a/tests/test_graphical_units/control_data/threed/Torus.npz and b/tests/test_graphical_units/control_data/threed/Torus.npz differdiff --git a/tests/test_graphical_units/control_data/threed/Y_Direction.npz b/tests/test_graphical_units/control_data/threed/Y_Direction.npzindex b4f0b39e5..7e3187910 100644Binary files a/tests/test_graphical_units/control_data/threed/Y_Direction.npz and b/tests/test_graphical_units/control_data/threed/Y_Direction.npz differ