From 280090a7c906f6d6cef9f9a8a04186de27f15b26 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 1 Feb 2023 11:24:46 -0800 Subject: [PATCH] Small reorganization to VMobject.get_shader_wrapper_list, and default to fill border being drawn up front --- manimlib/mobject/types/vectorized_mobject.py | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 481c6128..8af35fe1 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -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)