Hexasphere integration#1944
Hexasphere integration#1944OptimisticPeach wants to merge 13 commits intobevyengine:mainfrom OptimisticPeach:hexasphere_integration
Conversation
Changes made: - Swap Y/Z when calculating UV coordinates - Correct mapping in the UV coordinates - Fix type in Azimuth
It compiles, and the subdivision code is there.
Removes dependency on hexasphere
|
@aevyrie, would you like to be added as a reviewer to this? It touches on your geometry work quite closely. |
|
Sure, just be aware I'm very time limited at the moment, so it could be delayed. |
| fn float(&mut self, _: &str) -> &mut LinearInterpolator { | ||
| &mut self.lerp | ||
| } | ||
| fn float2(&mut self, _: &str) -> &mut SphericalInterpolator { |
There was a problem hiding this comment.
Note that this could be incorrect: it would spherically interpolate 2D attributes which doesn't make sense for something like UV coordinates. I believe that changing this to be a linear interpolator would make more sense.
|
I looked through this PR, though most of it is lost on me without comments. I'd be happy to take a closer look when you get to that stage. 🙂 I've collected some questions I had after reading your post and perusing the draft PR. I understand that the intent is to provide subdivision methods for spheres and planar surfaces?
I like this, but I'm curious how this will work for non-primitive meshes? E.g. what happens when I load up a gltf, access the mesh, and |
It's a lot of code to document, and I'd rather get the actual code down before I start to write documentation (given how tedious it can be to document code well). I think it might be beneficial to document the public API however, since that's what I really want comments on.
I originally designed it to work for spheres, however I later realized that it could be extended to any arbitrary mesh of triangles. It doesn't support more interesting subdivision however, as though interpolation is done only over two vertices and a percent value. Would adding that capability be of value?
Here's what the subdivide function will do:
So we're just modifying the original mesh, meaning that if someone wants to create a different one, they have to copy the mesh beforehand. |
I'm sure the public API docs you mention will cover this. I also understand this is still a draft. 🙂
Could you clarify what the "Sphere" in I'm also thinking about the implications for 3d primitives. How do we prevent users from grabbing this subdivide function, not realizing it isn't necessarily going to give them an accurate result? The results are probably going to be fine in most cases, but I think this API "misuse" is worth considering. |
It refers to spherical interpolation: https://en.wikipedia.org/wiki/Slerp#Geometric_Slerp, which will interpolate around a unit circle/sphere/hypersphere.
No, it is doing no such thing (since we can't assume the mesh will have vertex normals). Instead it interpolates positions only. Adding access to other attributes while interpolating might be something to explore though.
Well,
This is a good point; most people would expect something like a blender subdivide, whereas this essentially offers static LOD. Doing that however, would require more interpolation parameters to do better spline-style interpolation. Is this something we would want? Additionally an issue with this is in meshes without indices, which makes it incredibly difficult to figure out edges to work with (and we can't implement a HashMap/Set based solution since |
|
Thanks for clarifying! Maybe it would make more sense to build this off of 3d primitives, so we know exactly what type is being meshed and subdivided? That way the |
Documented a few items, still missing a few more though.
It compiles, and the subdivision code is there.
Removes dependency on hexasphere
Documented a few items, still missing a few more though.
Also fixes the PR; this hadn't been updated in a while.
|
I accidentally deleted the branch while trying to get new commits onto it. I'm going to finish making the commits I intended on doing before I open a new PR though. Specifically, I'm going to add code for generating the new shapes as described in the geometric primitives RFC along with documenting them. I'll probably give them APIs adjacent to the current Sorry for the confusion! |
This integrates the hexasphere code as discussed in #1595.
This is a draft PR because I have yet to implement any other prebuilt shapes, such as a plane, or a UV sphere.
Additionally, it is lacking documentation, which will be added prior to the PR being merged.
Please let me know what you think about the API though:
There are multiple interpolators available:
IdentityInterpolator- Returns LHS.LinearInterpolatorNormalizedLinearInterpolatorSphericalInterpolator.Individually, these all implement
AttributeInterpolator<A>, as long asAmake sense for them.Interpolators are grouped together under a type which implements
Interpolator, after which we then let the interpolator group (I've suffixed these types with-Group) choose the adequate interpolator based on the name and type of attribute.My apologies for the monstrous size of this PR!
Additionally, there was an issue when committing my changes on the
cargo.tomlnot sure what happened there.