gfx-rs / genmesh

A library of mesh generation utilities.
Apache License 2.0
122 stars 29 forks source link

feature: Add an into() bevy mesh, example viewer. #76

Open shanecelis opened 1 year ago

shanecelis commented 1 year ago

Add a cargo feature "into_bevy_mesh" that will provide a From implementation so generators like Cube can be turned into a bevy Mesh. This doesn't add any dependencies on the default features. It does add dependencies on bevy_render and glam when the feature is enabled.

Add an example called "viewer" that uses this feature to view the generators. It's a small bevy app with some camera control. I did discover a bug in a cone normal so plus one for visualization.

shanecelis commented 1 year ago

Here are some screenshots of the viewer and the cone with and without the normal fix.

cone-normal-bug cone-normal-fix

kvark commented 1 year ago

Thank you for the PR! I think this functionality is useful, but it should probably not live in genmesh itself. Problem is genmesh depending on bevy. This problem is two-fold:

  1. Bevy should be a consumer of genmesh, and thus depend on it, not the other way around
  2. Bevy version becomes a part of genmesh public API. E.g. once Bevy-0.11 is released, this code in genmesh becomes dead weight, and only pushes genmesh to publish another breaking release, which we'd want as little as possible.
shanecelis commented 1 year ago

Thanks for looking it over. I'll consider adding a PR to bevy with a "genmesh" feature. It's really the orphan rules that force this kind of feature to live in genmesh or bevy, but I agree bevy would be the right place for it to live.