Skip to content

armgit / manim

Public Imported from GitHub
0

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.py
index 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.
color
The 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 resolution
self.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.
color
The 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.npz
index 08ca1e595..7387d9f23 100644
Binary files a/tests/test_graphical_units/control_data/threed/AddFixedInFrameMobjects.npz and b/tests/test_graphical_units/control_data/threed/AddFixedInFrameMobjects.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz b/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz
index 4e6e101e7..f91b970ef 100644
Binary files a/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz and b/tests/test_graphical_units/control_data/threed/AmbientCameraMove.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Arrow3D.npz b/tests/test_graphical_units/control_data/threed/Arrow3D.npz
index a4fc4c510..a4a6c9b87 100644
Binary files a/tests/test_graphical_units/control_data/threed/Arrow3D.npz and b/tests/test_graphical_units/control_data/threed/Arrow3D.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Axes.npz b/tests/test_graphical_units/control_data/threed/Axes.npz
index 206b28697..287a866dd 100644
Binary files a/tests/test_graphical_units/control_data/threed/Axes.npz and b/tests/test_graphical_units/control_data/threed/Axes.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/CameraMove.npz b/tests/test_graphical_units/control_data/threed/CameraMove.npz
index 23ccfb73b..a88491356 100644
Binary files a/tests/test_graphical_units/control_data/threed/CameraMove.npz and b/tests/test_graphical_units/control_data/threed/CameraMove.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz b/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz
index 8628c6cb0..fc365464f 100644
Binary files a/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz and b/tests/test_graphical_units/control_data/threed/CameraMoveAxes.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Cone.npz b/tests/test_graphical_units/control_data/threed/Cone.npz
index 66f315afc..59a856f5a 100644
Binary files a/tests/test_graphical_units/control_data/threed/Cone.npz and b/tests/test_graphical_units/control_data/threed/Cone.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Cube.npz b/tests/test_graphical_units/control_data/threed/Cube.npz
index 8a7d147db..a955b37ee 100644
Binary files a/tests/test_graphical_units/control_data/threed/Cube.npz and b/tests/test_graphical_units/control_data/threed/Cube.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Cylinder.npz b/tests/test_graphical_units/control_data/threed/Cylinder.npz
index f25388545..bd42a1d91 100644
Binary files a/tests/test_graphical_units/control_data/threed/Cylinder.npz and b/tests/test_graphical_units/control_data/threed/Cylinder.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Dot3D.npz b/tests/test_graphical_units/control_data/threed/Dot3D.npz
index 4593a97c0..351dab60e 100644
Binary files a/tests/test_graphical_units/control_data/threed/Dot3D.npz and b/tests/test_graphical_units/control_data/threed/Dot3D.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Line3D.npz b/tests/test_graphical_units/control_data/threed/Line3D.npz
index ccf2bb20a..174b9a06e 100644
Binary files a/tests/test_graphical_units/control_data/threed/Line3D.npz and b/tests/test_graphical_units/control_data/threed/Line3D.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/MovingVertices.npz b/tests/test_graphical_units/control_data/threed/MovingVertices.npz
index 04006a76e..2da8e3a25 100644
Binary files a/tests/test_graphical_units/control_data/threed/MovingVertices.npz and b/tests/test_graphical_units/control_data/threed/MovingVertices.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Sphere.npz b/tests/test_graphical_units/control_data/threed/Sphere.npz
index 58cd44267..c007a0baa 100644
Binary files a/tests/test_graphical_units/control_data/threed/Sphere.npz and b/tests/test_graphical_units/control_data/threed/Sphere.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz b/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz
index 3a8539352..e3b4a5e95 100644
Binary files a/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz and b/tests/test_graphical_units/control_data/threed/SurfaceColorscale.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Torus.npz b/tests/test_graphical_units/control_data/threed/Torus.npz
index e50dd86de..f973dea17 100644
Binary files a/tests/test_graphical_units/control_data/threed/Torus.npz and b/tests/test_graphical_units/control_data/threed/Torus.npz differ
diff --git a/tests/test_graphical_units/control_data/threed/Y_Direction.npz b/tests/test_graphical_units/control_data/threed/Y_Direction.npz
index b4f0b39e5..7e3187910 100644
Binary 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