Skip to content

Composite zsort issue fix - #122

Open
mikz30 wants to merge 3 commits into
Inochi2D:mainfrom
mikz30:composite_zsort
Open

Composite zsort issue fix#122
mikz30 wants to merge 3 commits into
Inochi2D:mainfrom
mikz30:composite_zsort

Conversation

@mikz30

@mikz30 mikz30 commented Aug 11, 2026

Copy link
Copy Markdown

Description

This PR tries to fix Issue #121 cleanly. I observed how zsorting with Composite and its descendants on Inochi2d Creator works and here's the difference to current inox2d implementation.

  • The highest level Composite on a branch appears to isolate all its descendants from root zsorting instead of just its closest children level nodes.
  • Lower Composites' zsorts are handled the same way as a normal type of node.
Current Inox2d After fix Inochi2d Creator
image image image

I used the pre-order iterator and a stack to keep track of ancestors on current node's branch, starting from the highest Composite, while managing a hashmap of lists which are to replace zsorted_children_list. During both RenderCtx initialization and per frame update method. Finally, skip on nested composites when drawing instead of panicking, as their descendants's zsort calculation rely on them, we don't draw them but have to keep them.

Other Notes

Funny enough this made puppet.end_frame() slight faster on simplest examples, although will not be as obvious on real puppets. I have only tested it on Midori (the one with meshgroups and nested composites) for real case puppet. I can't overcome compatibility issue with most models, so I'd like to please ask anyone viewing this PR to test with different models. Thank you very much.

Suggestions are welcome.

mikz30 added 3 commits August 5, 2026 13:33
- Try to follow the inochi2d creator composite zsort behaviour I observed: all composite descendants' zsort must be sorted together; (TODO) for nested composites, only the top one is an active composite, treat the rest as a normal node in zsorting.
- Use a stack to keep track of descendents (optimization needed)
- add readable variable naming
…ppet.end_frame(). No further optimization until PR review.

- Improved comments for readability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant