Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions manimlib/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,32 @@ def assemble_render_groups(self):
same type are grouped together, so this function creates
Groups of all clusters of adjacent Mobjects in the scene
"""
transparent = []
opaque = []
for mob in self.mobjects:
for fam in mob.get_family():
if "rgba" in fam.data_dtype.names and any(op < 1 for op in fam.get_opacities()):
transparent.append(mob)
else:
opaque.append(mob)

batches = batch_by_property(
self.mobjects,
opaque,
lambda m: str(type(m)) + str(m.get_shader_wrapper(self.camera.ctx).get_id()) + str(m.z_index)
)

# render the furthest objects first but preserve user specified z index
transparent.sort(key=lambda m: (m.z_index, m.get_center()[2]))
batches_transparent = batch_by_property(
transparent,
lambda m: str(type(m)) + str(m.get_shader_wrapper(self.camera.ctx).get_id()) + str(m.z_index)
)

for group in self.render_groups:
group.clear()
self.render_groups = [
batch[0].get_group_class()(*batch)
for batch, key in batches
for batch, key in batches + batches_transparent
]

@staticmethod
Expand Down