Small reorganization to VMobject.get_shader_wrapper_list, and default to fill border being drawn up front

This commit is contained in:
Grant Sanderson
2023-02-01 11:24:46 -08:00
parent b351c9f1c8
commit 280090a7c9

View File

@ -1282,27 +1282,29 @@ class VMobject(Mobject):
# Build up data lists
fill_datas = []
fill_border_datas = []
fill_indices = []
fill_border_datas = []
stroke_datas = []
back_stroke_datas = []
for submob in family:
submob.get_joint_products()
indices = submob.get_outer_vert_indices()
has_fill = submob.has_fill()
has_stroke = submob.has_stroke()
indices = submob.get_outer_vert_indices()
if has_stroke:
lst = back_stroke_datas if submob.stroke_behind else stroke_datas
lst.append(submob.data[stroke_names][indices])
if has_fill:
back_stroke = has_stroke and submob.stroke_behind
front_stroke = has_stroke and not submob.stroke_behind
if back_stroke:
back_stroke_datas.append(submob.data[stroke_names][indices])
if front_stroke:
stroke_datas.append(submob.data[stroke_names][indices])
if has_fill and self._use_winding_fill:
data = submob.data[fill_names]
data["base_point"][:] = data["point"][0]
if self._use_winding_fill:
fill_datas.append(data[indices])
else:
fill_datas.append(data)
fill_indices.append(submob.get_triangulation())
if not has_stroke and has_fill:
fill_datas.append(data[indices])
if has_fill and not self._use_winding_fill:
fill_datas.append(submob.data[fill_names])
fill_indices.append(submob.get_triangulation())
if has_fill and not front_stroke:
# Add fill border
names = list(stroke_names)
names[names.index('stroke_rgba')] = 'fill_rgba'
@ -1313,11 +1315,9 @@ class VMobject(Mobject):
fill_border_datas.append(border_stroke_data[indices])
shader_wrappers = [
self.back_stroke_shader_wrapper.read_in(
[*back_stroke_datas, *fill_border_datas]
),
self.back_stroke_shader_wrapper.read_in(back_stroke_datas),
self.fill_shader_wrapper.read_in(fill_datas, fill_indices or None),
self.stroke_shader_wrapper.read_in(stroke_datas),
self.stroke_shader_wrapper.read_in([*fill_border_datas, *stroke_datas]),
]
# TODO, account for submob uniforms separately?
self.uniforms.update(family[0].uniforms)