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

Add csg boolean operators using elalish/manifold. #91748

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
59 changes: 59 additions & 0 deletions modules/csg/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,65 @@ Import("env_modules")
env_csg = env_modules.Clone()

# Godot source files

if env_csg["disable_exceptions"]:
# Enable exceptions for only manifold.
if env_csg.msvc:
env_csg.Append(CPPDEFINES=[("_HAS_EXCEPTIONS", 1)], CCFLAGS=["/EHsc"])
else:
env_csg.Append(CXXFLAGS=["-fexceptions"])


thirdparty_dir = "#thirdparty/manifold/"
thirdparty_sources = [
thirdparty_dir + file
for file in [
"src/polygon/src/polygon.cpp",
"src/manifold/src/constructors.cpp",
"src/manifold/src/edge_op.cpp",
"src/manifold/src/face_op.cpp",
"src/manifold/src/impl.cpp",
"src/manifold/src/boolean_result.cpp",
"src/manifold/src/boolean3.cpp",
"src/manifold/src/manifold.cpp",
"src/manifold/src/properties.cpp",
"src/manifold/src/smoothing.cpp",
"src/manifold/src/sort.cpp",
"src/collider/src/collider.cpp",
"src/manifold/src/subdivision.cpp",
"src/manifold/src/csg_tree.cpp",
"src/cross_section/src/cross_section.cpp",
"src/third_party/quickhull/QuickHull.cpp",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good practice for me, since I haven't seen a large project integrate our library this way before. I would like to make it easier if possible, and more modular. I take it you don't want to integrate us as a submodule?

If you're not interested in 2D tools or convex hulls, it should be possible to drop those dependencies, but we could probably structure our library better for doing this. @pca006132 do you know any way to allow e.g. building Manifold without quickhull, so that the Manifold::ConvexHull methods are just stubs?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some kind of #if will work, change them to throwing exceptions when user don't want to compile quickhull.

Copy link
Member Author

@fire fire May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule, Godot Engine vendors its entire dependencies because it makes development much easier for contributors and for CI/CD. I am interested in the other libraries, but it would be best if I can find ways to shrink the binary size.

Although, if your quickhull is good, @lawnjelly has been in that area and could evaluate the quality if it's useful.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to hear your evaluation - in fact we have a GSoC contributor who just started and is looking into improving our hulling - either using a different dependency or writing a new one. opencax/GSoC#89

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest my best experience is with https://github.com/SarahWeiii/CoACD for convex hulling.

]
]

env_csg.Append(CPPDEFINES=["THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CPP"])
if env["platform"] == "web":
env_csg.Append(CPPDEFINES=["_LIBCUDACXX_HAS_THREAD_API_EXTERNAL", "_LIBCUDACXX_HAS_THREAD_API_CUDA"])
env_csg.Append(CCFLAGS=["-sDISABLE_EXCEPTION_CATCHING=0"])
env_csg.Append(LINKFLAGS=["-sERROR_ON_UNDEFINED_SYMBOLS=0"])

env_csg.Prepend(
CPPPATH=[
thirdparty_dir + path
for path in [
"src/third_party/quickhull",
"src/manifold/include",
"src/utilities/include",
"src/cross_section/include",
"src/polygon/include",
"src/collider/include",
"thirdparty/thrust/dependencies/libcudacxx/include",
"thirdparty/thrust",
"thirdparty/glm",
]
]
)

env_thirdparty = env_csg.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)

env_csg.add_source_files(env.modules_sources, "*.cpp")
if env.editor_build:
env_csg.add_source_files(env.modules_sources, "editor/*.cpp")
Loading
Loading