Skip to content

Commit bc262c0

Browse files
committed
Import ShaderWrapper in necessary methods
1 parent 46d0a36 commit bc262c0

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

manim/mobject/opengl_mobject.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from ..utils.space_ops import angle_of_vector
3232
from ..utils.space_ops import get_norm
3333
from ..utils.space_ops import rotation_matrix_transpose
34-
from ..renderer.shader_wrapper import ShaderWrapper
3534

3635

3736
class OpenGLMobject:
@@ -95,7 +94,8 @@ def __init__(
9594
# self.init_event_listners()
9695
self.init_points()
9796
self.init_colors()
98-
self.init_shader_data()
97+
98+
self.shader_indices = None
9999

100100
if self.depth_test:
101101
self.apply_depth_test()
@@ -1380,23 +1380,12 @@ def set_color_by_xyz_func(
13801380

13811381
# For shader data
13821382

1383-
def init_shader_data(self):
1384-
# TODO, only call this when needed?
1385-
self.shader_data = np.zeros(len(self.get_points()), dtype=self.shader_dtype)
1386-
self.shader_indices = None
1387-
self.shader_wrapper = ShaderWrapper(
1388-
vert_data=self.shader_data,
1389-
shader_folder=self.__class__.shader_folder,
1390-
texture_paths=self.texture_paths,
1391-
depth_test=self.depth_test,
1392-
render_primitive=self.render_primitive,
1393-
)
1394-
13951383
# def refresh_shader_wrapper_id(self):
13961384
# self.shader_wrapper.refresh_id()
13971385
# return self
13981386

13991387
def get_shader_wrapper(self):
1388+
from ..renderer.shader_wrapper import ShaderWrapper
14001389
self.shader_wrapper = ShaderWrapper(
14011390
vert_data=self.get_shader_data(),
14021391
vert_indices=self.get_shader_vert_indices(),

manim/mobject/types/opengl_vectorized_mobject.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
from ...utils.space_ops import z_to_vector
3434

35-
from ...renderer.shader_wrapper import ShaderWrapper
3635

3736
JOINT_TYPE_MAP = {
3837
"auto": 0,
@@ -41,6 +40,7 @@
4140
"miter": 3,
4241
}
4342

43+
4444
class OpenGLVMobject(OpenGLMobject):
4545
fill_dtype = [
4646
("point", np.float32, (3,)),
@@ -918,6 +918,8 @@ def flip(self, *args, **kwargs):
918918

919919
# For shaders
920920
def init_shader_data(self):
921+
from ...renderer.shader_wrapper import ShaderWrapper
922+
921923
self.fill_data = np.zeros(0, dtype=self.fill_dtype)
922924
self.stroke_data = np.zeros(0, dtype=self.stroke_dtype)
923925
self.fill_shader_wrapper = ShaderWrapper(
@@ -938,6 +940,8 @@ def refresh_shader_wrapper_id(self):
938940
return self
939941

940942
def get_fill_shader_wrapper(self):
943+
from ...renderer.shader_wrapper import ShaderWrapper
944+
941945
return ShaderWrapper(
942946
vert_data=self.get_fill_shader_data(),
943947
vert_indices=self.get_triangulation(),
@@ -948,6 +952,8 @@ def get_fill_shader_wrapper(self):
948952
)
949953

950954
def get_stroke_shader_wrapper(self):
955+
from ...renderer.shader_wrapper import ShaderWrapper
956+
951957
return ShaderWrapper(
952958
vert_data=self.get_stroke_shader_data(),
953959
shader_folder="quadratic_bezier_stroke",
@@ -957,6 +963,8 @@ def get_stroke_shader_wrapper(self):
957963
)
958964

959965
def get_shader_wrapper_list(self):
966+
from ...renderer.shader_wrapper import ShaderWrapper
967+
960968
# Build up data lists
961969
fill_shader_wrappers = []
962970
stroke_shader_wrappers = []

0 commit comments

Comments
 (0)