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

3D twist gizmo ignores "show frontfaces" and "show backfaces" settings #67

Open
HactarCE opened this issue Nov 25, 2024 · 0 comments
Open
Labels
type: bug Something isn't working v2

Comments

@HactarCE
Copy link
Owner

HactarCE commented Nov 25, 2024

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.)

  1. In hyperpuzzle/src/puzzle/mesh.rs, in Mesh::add_gizmo_vertex(), add tangent vectors to the mesh (similar to add_puzzle_vertex() above). You'll have to add a parameter uv_tangents: [impl VectorRef; 2].
  2. In hyperpuzzle/src/builder/twist_system.rs, in TwistSystemBuilder::build_gizmo(), on the let vertex_map line, compute the two tangent vectors for the polygon of the twist gizmo. The error handling will be easier if you convert the functional-style flat_map() and map() into traditional for loops. Use space.get(polygon).as_face()?.tangent_vectors()? to get the tangent vectors for the polygon.
  3. 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()). See hyperpuzzle/src/builder/shape.rs build_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 Clicking on back of twist gizmo should click in reverse #58. Feel free to factor out parts into hyperpuzzle/src/util.rs if you can find a nice way to do it.
  4. That should just work?
@HactarCE HactarCE added type: bug Something isn't working v2 labels Nov 25, 2024
@HactarCE HactarCE changed the title 3D twist gizmo ignroes "show frontfaces" and "show backfaces" settings 3D twist gizmo ignores "show frontfaces" and "show backfaces" settings Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working v2
Projects
None yet
Development

No branches or pull requests

1 participant