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

Added 3D brush outline shearing and fixed triangle selection #2529

Open
wants to merge 32 commits into
base: next
Choose a base branch
from

Conversation

Nestorboy
Copy link

@Nestorboy Nestorboy commented Oct 28, 2024

• Rewrote how the brush outline is transformed by computing a custom matrix to allow for shearing.
• Added a function to mesh.js and cube.js to compute a texel to local matrix for the brush outline.
• Fixed issue where the brush uv position would get truncated before being transformed to a world position for the outline, causing it to select the wrong triangle.

blockbench_shearing

Copy link

netlify bot commented Oct 28, 2024

Deploy Preview for blockbench-dev ready!

Name Link
🔨 Latest commit f60f4ab
🔍 Latest deploy log https://app.netlify.com/sites/blockbench-dev/deploys/6727fbf46078650008bc7dbe
😎 Deploy Preview https://deploy-preview-2529--blockbench-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Nestorboy
Copy link
Author

Nestorboy commented Oct 28, 2024

@JannisX11 there's some code duplication in mesh.js where I compute the brush matrix from the bary coords. Should it be moved to some particular location or is it fine?

@JannisX11
Copy link
Owner

Yeah, you can use a closure inside the TexelToLocalMatrix function to handle that duplicated code. Also make sure to not modify the passed uv parameter directly, as it may still be used for something else after calling the function. TexelToLocalMatrix should be texelToLocalMatrix, following lower camel case.

I noticed two issues when testing this feature initially:

  • Brush outlines no longer work on cubes
  • Higher pixel density textures no longer work, the brush outline displays too large. Texture resolutions can be higher than the UV resolution, and the brush outline should support that.

• Renamed TexelToLocalMatrix function to texelToLocalMatrix.
• Renamed truncateOffset parameter to truncate_offset.
@Nestorboy
Copy link
Author

Thank you Jannis for taking the time to test this and giving me some pointers and advice regarding my code!

I've gone over and fixed the issues you discovered, and realized that there were some other small code cleanups I could do. At this point I believe it's ready to be reviewed and merged so I'll turn it into a regular PR instead of a draft.

GitHub Desktop seems to only have let me create a new branch from master, so I accidentally included a commit from master branch which next doesn't have. It might not matter much, but would you mind syncing the next branch?

@Nestorboy Nestorboy marked this pull request as ready for review October 31, 2024 22:33
@Nestorboy
Copy link
Author

Nestorboy commented Nov 3, 2024

I realized I never accounted for the soft brush not doing any form of snapping, so I've fixed that too. I also made the code behave more similarly to the previous implementation where the truncation was done before the UVToLocal function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants