Hyperspeedcube
Hyperspeedcube copied to clipboard
3D twist gizmo ignores "show frontfaces" and "show backfaces" settings
Guide
This will actually be nontrivial to do because the gizmo triangles are not oriented. The easiest way to do this is to specify tangent vectors for twist gizmo vertices, since the compute shader is already using them on the GPU to decide which verts to cull. (We've just ignoring the result for gizmo vertices because they don't currently have tangent vectors.)
- In
hyperpuzzle/src/puzzle/mesh.rs, inMesh::add_gizmo_vertex(), add tangent vectors to the mesh (similar toadd_puzzle_vertex()above). You'll have to add a parameteruv_tangents: [impl VectorRef; 2]. - In
hyperpuzzle/src/builder/twist_system.rs, inTwistSystemBuilder::build_gizmo(), on thelet vertex_mapline, compute the two tangent vectors for the polygon of the twist gizmo. The error handling will be easier if you convert the functional-styleflat_map()andmap()into traditionalforloops. Usespace.get(polygon).as_face()?.tangent_vectors()?to get the tangent vectors for the polygon. - Make sure the tangent vectors are facing the right way relative to some point inside the polyhedron, which you can get by averaging all vertices of the polyhedron (probably something like
space.get(polyhedron).vertex_set()). Seehyperpuzzle/src/builder/shape.rsbuild_shape_polygons()for an example. It's a good idea to make the triangles face the right way in 3D too, since that'll help with #58. Feel free to factor out parts intohyperpuzzle/src/util.rsif you can find a nice way to do it. - That should just work?