Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More accurate Z sorting of Shapes #60

Merged
merged 2 commits into from
Jun 14, 2019
Merged

Conversation

bendablegears
Copy link
Contributor

Zdog now correctly discards the final overlapping point in a closed path. Fixes #26 for Ellipses, Rounded Rectangles, and custom path Shapes. Fixing that caused Z fighting with co-planar Hemispheres and Cones, so those now calculate a better average Z.

Composite shapes use volume to find Z. Shapes with closed paths ignore doubled final point when averaging Z.
@desandro
Copy link
Member

desandro commented Jun 7, 2019

A lot of great work here. Thank you so much. I've got some ideas on how to refactor this. Are you interested in implementing them? Otherwise, I can pull your changes and handle it myself.

  • Run npm install and make lint to lint JS
  • Add Vector.isSame method and use it
  • Several shapes don't actually need calculation, as the renderOrigin.z could be used as the center of the shape: Rect, RoundedRect, Polygon, Box, Cylinder. I wonder if its worth hard-coding this in.

jslint doesn't complain anymore. Vector class has useful isSame function.
@bendablegears
Copy link
Contributor Author

I addressed the first two points in a second commit. I'll leave the decision on the other shapes' Z sorting to you.

@desandro desandro merged commit cfe9671 into metafizzy:master Jun 14, 2019
@desandro
Copy link
Member

Thanks so much for this work here. This will go out in the next release of Zdog. If you like stickers, please email me yo@metafizzy.co so I can send some your way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Distance before z-index fighting occurs
2 participants