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

Alternative Block Detection Algorithm for Meshswap #434

Open
StandingPadAnimations opened this issue Jun 25, 2023 · 1 comment
Open

Alternative Block Detection Algorithm for Meshswap #434

StandingPadAnimations opened this issue Jun 25, 2023 · 1 comment
Labels
enhancement Feature requests or new functionality suggestions

Comments

@StandingPadAnimations
Copy link
Collaborator

StandingPadAnimations commented Jun 25, 2023

As it stands, meshswap has some some known bugs regarding stuff like block rotation (and performance, but that's a separate issue). I was curious and wanted to see where meshswap goes wrong in the algorithm. As it stands however, the algorithm for meshswap isn't really readable, nor is it documented.

Due to those issues, I decided to draft a new algorithm from scratch. I'll be linking a PDF that goes in detail (be warned though, it uses a fair amount of mathematical notation and phrasing), but here's some gifs that illustrate what it does. For cubic blocks, given a face, we first try to get the face across from that given face (in the opposite direction of course), then the faces that are adjacent to the given face. We can further confirm that faces are part of the same block by using the normals (we assume for our purposes that they're lines) and seeing how they intersect each other.
Cubic blocks

For non-cubic blocks, given a face, we find a face that intersects the given face. If such a face exists, we create a line where they intersect. We then create a new line that's parallel to the top of the OBJ (if the OBJ had a bounding box, the top face of that box would be the top of the OBJ). We can then use these lines to determine if the block is straight or rotated, and we can use the rotation of the former line to determine the block's actual rotation.
Non-Cubic Blocks

The advantages of this algorithm are:

  • A block can be determined with one face
  • Rotation is basically free (although some cubic blocks like doors might need some extra info as they're special when it comes to rotation)
  • It's been designed with geometry nodes in mind, which opens the door to a geometry nodes based meshswap.

There are some disadvantages though:

  • It's based on assumptions about the OBJ and how it was exported (though these assumptions are pretty sound)
  • The block's dimensions must be known ahead of time

PDF going in further depth
Source files

@StandingPadAnimations StandingPadAnimations added the enhancement Feature requests or new functionality suggestions label Jun 25, 2023
@StandingPadAnimations
Copy link
Collaborator Author

I've revised the paper to fix some issues and as such updated the link accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests or new functionality suggestions
Projects
None yet
Development

No branches or pull requests

1 participant