Skip to content

Commit f4a17a5

Browse files
committed
Revert changes to vectorized_mobject.py
1 parent e3a4fb5 commit f4a17a5

File tree

1 file changed

+22
-115
lines changed

1 file changed

+22
-115
lines changed

manim/mobject/types/vectorized_mobject.py

Lines changed: 22 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
]
1212

1313

14-
from ... import config
1514
import itertools as it
1615
import sys
1716
import colour
@@ -45,22 +44,6 @@
4544

4645

4746
class VMobject(Mobject):
48-
fill_dtype = [
49-
("point", np.float32, (3,)),
50-
("unit_normal", np.float32, (3,)),
51-
("color", np.float32, (4,)),
52-
("vert_index", np.float32, (1,)),
53-
]
54-
55-
stroke_dtype = [
56-
("point", np.float32, (3,)),
57-
("prev_point", np.float32, (3,)),
58-
("next_point", np.float32, (3,)),
59-
("unit_normal", np.float32, (3,)),
60-
("stroke_width", np.float32, (1,)),
61-
("color", np.float32, (4,)),
62-
]
63-
6447
def __init__(
6548
self,
6649
fill_color=None,
@@ -113,51 +96,8 @@ def __init__(
11396
self.shade_in_3d = shade_in_3d
11497
self.tolerance_for_point_equality = tolerance_for_point_equality
11598
self.n_points_per_cubic_curve = n_points_per_cubic_curve
116-
11799
Mobject.__init__(self, **kwargs)
118100

119-
def init_gl_data(self):
120-
self.needs_new_triangulation = True
121-
self.joint_type = "auto"
122-
self.flat_stroke = True
123-
self.data["points"] = np.zeros(0)
124-
self.data["unit_normal"] = np.array([[0.0, 0.0, 1.0]])
125-
self.data["stroke_width"] = np.array([[4]])
126-
127-
def init_gl_points(self):
128-
self.data["points"] = np.array(
129-
[
130-
[1.0, 1.0, 0.0],
131-
[0.5, 1.0, 0.0],
132-
[0.0, 1.0, 0.0],
133-
[0.0, 1.0, 0.0],
134-
[-0.5, 1.0, 0.0],
135-
[-1.0, 1.0, 0.0],
136-
[-1.0, 1.0, 0.0],
137-
[-1.0, 0.5, 0.0],
138-
[-1.0, 0.0, 0.0],
139-
[-1.0, 0.0, 0.0],
140-
[-1.0, -0.5, 0.0],
141-
[-1.0, -1.0, 0.0],
142-
[-1.0, -1.0, 0.0],
143-
[-0.5, -1.0, 0.0],
144-
[0.0, -1.0, 0.0],
145-
[0.0, -1.0, 0.0],
146-
[0.5, -1.0, 0.0],
147-
[1.0, -1.0, 0.0],
148-
[1.0, -1.0, 0.0],
149-
[1.0, -0.5, 0.0],
150-
[1.0, 0.0, 0.0],
151-
[1.0, 0.0, 0.0],
152-
[1.0, 0.5, 0.0],
153-
[1.0, 1.0, 0.0],
154-
]
155-
)
156-
157-
def init_gl_colors(self):
158-
self.data["stroke_rgba"] = np.array([[1.0, 1.0, 1.0, 1.0]])
159-
self.data["fill_rgba"] = np.array([[1.0, 1.0, 1.0, 0.0]])
160-
161101
def get_group_class(self):
162102
return VGroup
163103

@@ -513,18 +453,8 @@ def set_shade_in_3d(self, value=True, z_index_as_group=False):
513453

514454
# Points
515455
def set_points(self, points):
516-
if config["use_opengl_renderer"]:
517-
if len(points) == len(self.data["points"]):
518-
self.data["points"][:] = points
519-
elif isinstance(points, np.ndarray):
520-
self.data["points"] = points.copy()
521-
else:
522-
self.data["points"] = np.array(points)
523-
self.refresh_bounding_box()
524-
return self
525-
else:
526-
self.points = np.array(points)
527-
return self
456+
self.points = np.array(points)
457+
return self
528458

529459
def get_points(self):
530460
return np.array(self.points)
@@ -545,27 +475,15 @@ def set_anchors_and_handles(
545475
VMobject
546476
for chaining.
547477
"""
548-
if config["use_opengl_renderer"]:
549-
handles = handles1
550-
anchors2 = handles2
551-
assert len(anchors1) == len(handles) == len(anchors2)
552-
nppc = 3
553-
new_points = np.zeros((nppc * len(anchors1), self.dim))
554-
arrays = [anchors1, handles, anchors2]
555-
for index, array in enumerate(arrays):
556-
new_points[index::nppc] = array
557-
self.set_points(new_points)
558-
return self
559-
else:
560-
assert len(anchors1) == len(handles1) == len(handles2) == len(anchors2)
561-
nppcc = self.n_points_per_cubic_curve # 4
562-
total_len = nppcc * len(anchors1)
563-
self.points = np.zeros((total_len, self.dim))
564-
# the following will, from the four sets, dispatch them in points such that self.points = [anchors1[0], handles1[0], handles2[0], anchors1[0], anchors1[1], handles1[1], ...]
565-
arrays = [anchors1, handles1, handles2, anchors2]
566-
for index, array in enumerate(arrays):
567-
self.points[index::nppcc] = array
568-
return self
478+
assert len(anchors1) == len(handles1) == len(handles2) == len(anchors2)
479+
nppcc = self.n_points_per_cubic_curve # 4
480+
total_len = nppcc * len(anchors1)
481+
self.points = np.zeros((total_len, self.dim))
482+
# the following will, from the four sets, dispatch them in points such that self.points = [anchors1[0], handles1[0], handles2[0], anchors1[0], anchors1[1], handles1[1], ...]
483+
arrays = [anchors1, handles1, handles2, anchors2]
484+
for index, array in enumerate(arrays):
485+
self.points[index::nppcc] = array
486+
return self
569487

570488
def clear_points(self):
571489
self.points = np.zeros((0, self.dim))
@@ -721,28 +639,17 @@ def set_points_as_corners(self, points: Iterable[float]) -> "VMobject":
721639
VMobject
722640
self. For chaining purposes.
723641
"""
724-
if config["use_opengl_renderer"]:
725-
nppc = self.n_points_per_curve
726-
points = np.array(points)
727-
self.set_anchors_and_handles(
728-
*[
729-
interpolate(points[:-1], points[1:], a)
730-
for a in np.linspace(0, 1, nppc)
731-
]
732-
)
733-
return self
734-
else:
735-
nppcc = self.n_points_per_cubic_curve
736-
points = np.array(points)
737-
# This will set the handles aligned with the anchors.
738-
# Id est, a bezier curve will be the segment from the two anchors such that the handles belongs to this segment.
739-
self.set_anchors_and_handles(
740-
*[
741-
interpolate(points[:-1], points[1:], a)
742-
for a in np.linspace(0, 1, nppcc)
743-
]
744-
)
745-
return self
642+
nppcc = self.n_points_per_cubic_curve
643+
points = np.array(points)
644+
# This will set the handles aligned with the anchors.
645+
# Id est, a bezier curve will be the segment from the two anchors such that the handles belongs to this segment.
646+
self.set_anchors_and_handles(
647+
*[
648+
interpolate(points[:-1], points[1:], a)
649+
for a in np.linspace(0, 1, nppcc)
650+
]
651+
)
652+
return self
746653

747654
def set_points_smoothly(self, points):
748655
self.set_points_as_corners(points)

0 commit comments

Comments
 (0)