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

[REQUEST] SDF Xor operation #1748

Open
MysteryPancake opened this issue Jan 8, 2024 · 1 comment
Open

[REQUEST] SDF Xor operation #1748

MysteryPancake opened this issue Jan 8, 2024 · 1 comment

Comments

@MysteryPancake
Copy link

Currently OpenVDB supports the following SDF operations:

SDF Union:
min(d1, d2)

SDF Intersection:
max(d1, d2)

SDF Difference (usually named SDF Subtraction):
max(-d1, d2)

However, it doesn't support the XOR operation described by Inigo Quilez:
max(min(d1, d2), -max(d1, d2))

This operation finds regions where the sign mismatches.

image

It would be nice to include all standard SDF operations in OpenVDB.

@ghurstunither
Copy link
Contributor

As a workaround you can find the symmetric difference with

csgUnionCopy(csgDifferenceCopy(grid1, grid2), csgDifferenceCopy(grid2, grid1))

or

csgDifferenceCopy(csgUnionCopy(grid1, grid2), csgIntersectionCopy(grid1, grid2))

For an in-place workaround, this might be the most efficient:

gridint = csgIntersectionCopy(grid1, grid2);
csgUnion(grid1, grid2);
csgDifference(grid1, gridint);

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

No branches or pull requests

2 participants