├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── pull_request_template.md └── workflows │ ├── ccpp.yml │ ├── jira-link.yaml │ ├── pre-commit.yml │ └── stale.yaml ├── .gitignore ├── .gitmodules ├── .pre-commit-config.yaml ├── .yamato ├── sonar.yml └── yamato-config.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── README.md.meta ├── TestVhacd ├── .gitignore ├── Assets │ ├── Scenes.meta │ └── Scenes │ │ ├── SampleScene.unity │ │ └── SampleScene.unity.meta ├── Packages │ ├── manifest.json │ └── packages-lock.json └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── PackageManagerSettings.asset │ ├── Physics2DSettings.asset │ ├── PresetManager.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityConnectSettings.asset │ ├── VFXManager.asset │ ├── VersionControlSettings.asset │ └── XRSettings.asset ├── Third Party Notices.md ├── bin-no-ocl-omp └── osx │ └── testVHACD ├── bin-no-ocl ├── osx │ └── testVHACD ├── win32 │ └── testVHACD.exe └── win64 │ └── testVHACD.exe ├── bin ├── .DS_Store ├── osx │ └── testVHACD ├── win32 │ └── testVHACD.exe └── win64 │ └── testVHACD.exe ├── com.unity.robotics.vhacd ├── Editor.meta ├── Runtime.meta ├── Runtime │ ├── LICENSE.MD │ ├── LICENSE.MD.meta │ ├── VHACD.cs │ ├── VHACD.cs.meta │ ├── liblibvhacd.dylib │ ├── liblibvhacd.dylib.meta │ ├── liblibvhacd.so │ ├── liblibvhacd.so.meta │ ├── libvhacd.dll │ ├── libvhacd.dll.meta │ ├── vhacd.asmdef │ └── vhacd.asmdef.meta ├── Tests.meta ├── Tests │ ├── Editor.meta │ ├── Editor │ │ ├── PlayerBuildTests.cs │ │ ├── PlayerBuildTests.cs.meta │ │ ├── Unity.Robotics.Vhacd.Editor.Tests.asmdef │ │ └── Unity.Robotics.Vhacd.Editor.Tests.asmdef.meta │ ├── Runtime.meta │ └── Runtime │ │ ├── SmokeTests.cs │ │ ├── SmokeTests.cs.meta │ │ ├── Unity.Robotics.Vhacd.Runtime.Tests.asmdef │ │ └── Unity.Robotics.Vhacd.Runtime.Tests.asmdef.meta ├── package.json └── package.json.meta ├── doc ├── acd.png ├── chvsacd.png ├── ecdvsacd.png ├── snapshots_1.png ├── snapshots_2.png ├── snapshots_3.png ├── snapshots_4.png └── snapshots_5.png ├── install └── run.py ├── scripts └── cmake_common.cmake ├── snapshots ├── Figure1_a_OriginalMeshp.jpg ├── Figure1_b_ConvexHullp.jpg ├── Figure1_c_ACDp.jpg ├── Figure2_a_BunnyECD.jpg ├── Figure2_b_BunnyACD.jpg ├── V-HACD_V1.0vsV2.0.png ├── acd.png ├── chvsacd.png ├── ecdvsacd.png ├── logo.png ├── snapshots.png ├── snapshots_1.png ├── snapshots_2.png ├── snapshots_3.png ├── snapshots_4.png └── snapshots_5.png └── src ├── .vscode └── settings.json ├── CMakeLists.txt ├── VHACD_Lib ├── CMakeLists.txt ├── cl │ └── vhacdKernels.cl ├── cmake │ └── vhacd-config.cmake ├── inc │ ├── FloatMath.h │ ├── btAlignedAllocator.h │ ├── btAlignedObjectArray.h │ ├── btConvexHullComputer.h │ ├── btMinMax.h │ ├── btScalar.h │ ├── btVector3.h │ ├── vhacdCircularList.h │ ├── vhacdCircularList.inl │ ├── vhacdICHull.h │ ├── vhacdManifoldMesh.h │ ├── vhacdMesh.h │ ├── vhacdMutex.h │ ├── vhacdRaycastMesh.h │ ├── vhacdSArray.h │ ├── vhacdTimer.h │ ├── vhacdVHACD.h │ ├── vhacdVector.h │ ├── vhacdVector.inl │ └── vhacdVolume.h ├── public │ └── VHACD.h └── src │ ├── FloatMath.cpp │ ├── FloatMath.inl │ ├── VHACD-ASYNC.cpp │ ├── VHACD.cpp │ ├── btAlignedAllocator.cpp │ ├── btConvexHullComputer.cpp │ ├── vhacdICHull.cpp │ ├── vhacdManifoldMesh.cpp │ ├── vhacdMesh.cpp │ ├── vhacdRaycastMesh.cpp │ └── vhacdVolume.cpp ├── dll ├── CMakeLists.txt └── src │ └── dll.cpp └── test ├── CMakeLists.txt ├── inc └── oclHelper.h └── src ├── main.cpp └── oclHelper.cpp /.editorconfig: -------------------------------------------------------------------------------- 1 | ; see http://editorconfig.org/ for docs on this file 2 | ; See https://github.com/dotnet/format for dotnet format 3 | 4 | root = true 5 | 6 | [*] 7 | ignore_if_in_header = This code was generated by a tool| 8 | indent_style = space 9 | indent_size = 4 10 | ; uncomment to help with sharing files across os's (i.e. network share or through local vm) 11 | #end_of_line = lf 12 | ; avoid a bom, which causes endless problems with naive text tooling 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | ; keeping auto-format enabled helps avoid merge hell for projects without CI-based format validation 17 | #disable_auto_format = true 18 | 19 | [*.cs] 20 | ; uncomment to enable full formatting of c# files 21 | formatters = generic, uncrustify 22 | 23 | [*.asmdef] 24 | scrape_api = true 25 | 26 | [**/Tests/**.asmdef] 27 | scrape_api = false 28 | 29 | [*.Tests.asmdef] 30 | scrape_api = false 31 | 32 | [*.md] 33 | indent_size = 2 34 | ; trailing whitespace is unfortunately significant in markdown 35 | trim_trailing_whitespace = false 36 | ; uncomment to enable basic formatting of markdown files 37 | #formatters = generic 38 | 39 | [{Makefile,makefile}] 40 | ; tab characters are part of the Makefile format 41 | indent_style = tab 42 | 43 | [*.asmdef] 44 | indent_size = 4 45 | 46 | [*.json] 47 | indent_size = 2 48 | 49 | [*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}] 50 | end_of_line = crlf 51 | 52 | ; this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited. 53 | ; the settings are meant to closely match what VS does to minimize unnecessary diffs. 54 | [*.{vcxproj,vcxproj.filters}] 55 | indent_style = space 56 | indent_size = 2 57 | end_of_line = crlf 58 | charset = utf-8-bom 59 | trim_trailing_whitespace = true 60 | insert_final_newline = false 61 | ; must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21) 62 | [*.{csproj,pyproj,props,targets}] 63 | indent_style = space 64 | indent_size = 2 65 | end_of_line = crlf 66 | charset = utf-8-bom 67 | trim_trailing_whitespace = true 68 | insert_final_newline = false 69 | [*.{sln,sln.template}] 70 | indent_style = tab 71 | indent_size = 4 72 | end_of_line = crlf 73 | charset = utf-8 74 | trim_trailing_whitespace = true 75 | insert_final_newline = false 76 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | **To Reproduce** 15 | 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Console logs / stack traces** 23 | 24 | Please wrap in [triple backticks (```)](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) to make it easier to read. 25 | 26 | **Expected behavior** 27 | 28 | A clear and concise description of what you expected to happen. 29 | 30 | **Screenshots** 31 | 32 | If applicable, add screenshots or videos to help explain your problem. 33 | 34 | **Environment (please complete the following information, where applicable):** 35 | 36 | - Unity Version: [e.g. Unity 2020.2.0f1] 37 | - Unity machine OS + version: [e.g. Windows 10] 38 | - Branch or version: [e.g. v0.2.0] 39 | 40 | **Additional context** 41 | 42 | Add any other context about the problem here. 43 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Unity Robotics Forum 4 | url: https://forum.unity.com/forums/robotics.623/ 5 | about: Discussions and questions about Unity Robotics tools, demos, or integrations. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like** 15 | 16 | A clear and concise description of what you want to happen. 17 | 18 | **Describe alternatives you've considered** 19 | 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | 22 | **Additional context** 23 | 24 | Add any other context or screenshots about the feature request here. 25 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Proposed change(s) 2 | 3 | Describe the changes made in this PR. 4 | 5 | ### Useful links (GitHub issues, JIRA tickets, forum threads, etc.) 6 | 7 | Provide any relevant links here. 8 | 9 | ### Types of change(s) 10 | 11 | - [ ] Bug fix 12 | - [ ] New feature 13 | - [ ] Code refactor 14 | - [ ] Documentation update 15 | - [ ] Other (please describe) 16 | 17 | ## Testing and Verification 18 | 19 | Please describe the tests that you ran to verify your changes. Please also provide instructions and Unity project files as appropriate so we can reproduce the test environment. 20 | 21 | ### Test Configuration: 22 | - Unity Version: [e.g. Unity 2020.2.0f1] 23 | - Unity machine OS + version: [e.g. Windows 10] 24 | 25 | ## Checklist 26 | - [ ] Ensured this PR is up-to-date with the `dev` branch 27 | - [ ] Created this PR to target the `dev` branch 28 | - [ ] Updated the [Changelog](../CHANGELOG.md) and described changes in the [Unreleased section](../CHANGELOG.md#unreleased) 29 | - [ ] Updated the documentation as appropriate 30 | 31 | ## Other comments -------------------------------------------------------------------------------- /.github/workflows/ccpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | 7 | build: 8 | strategy: 9 | matrix: 10 | platform: [ubuntu-latest, macos-latest, windows-latest] 11 | include: 12 | - platform: windows-latest 13 | cmake_type: "Visual Studio 16 2019" 14 | dll_name: "Release/libvhacd.dll" 15 | target_dll_name: "libvhacd.dll" 16 | - platform: ubuntu-latest 17 | cmake_type: "Unix Makefiles" 18 | dll_name: "liblibvhacd.so" 19 | target_dll_name: "liblibvhacd.so" 20 | - platform: macos-latest 21 | cmake_type: "Unix Makefiles" 22 | dll_name: "liblibvhacd.dylib" 23 | target_dll_name: "liblibvhacd.bundle" 24 | 25 | runs-on: ${{ matrix.platform }} 26 | 27 | steps: 28 | - uses: actions/checkout@v1 29 | - uses: ilammy/msvc-dev-cmd@v1.5.0 30 | 31 | - name: configure 32 | run: | 33 | mkdir build 34 | cd build 35 | cmake -G "${{ matrix.cmake_type }}" ../src 36 | - name: build 37 | run: cmake --build build --config Release 38 | 39 | - uses: actions/upload-artifact@v1 40 | with: 41 | name: ${{ matrix.platform }} 42 | path: build/dll/${{ matrix.dll_name }} 43 | 44 | create_release: 45 | runs-on: ubuntu-latest 46 | 47 | needs: [build] 48 | 49 | steps: 50 | - uses: actions/checkout@v1 51 | 52 | - name: make release 53 | uses: actions/create-release@v1.0.0 54 | id: create_release 55 | env: 56 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 57 | with: 58 | draft: true 59 | tag_name: ${{ github.ref }} 60 | release_name: build of ${{ github.sha }} 61 | 62 | - uses: actions/download-artifact@v1 63 | with: 64 | name: ubuntu-latest 65 | 66 | - uses: actions/download-artifact@v1 67 | with: 68 | name: windows-latest 69 | 70 | - uses: actions/download-artifact@v1 71 | with: 72 | name: macos-latest 73 | -------------------------------------------------------------------------------- /.github/workflows/jira-link.yaml: -------------------------------------------------------------------------------- 1 | name: jira-link 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, reopened, synchronize] 6 | 7 | jobs: 8 | jira-link: 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - name: check pull request title and source branch name 12 | run: | 13 | echo "Checking pull request with title ${{ github.event.pull_request.title }} from source branch ${{ github.event.pull_request.head.ref }}" 14 | if ! [[ "${{ github.event.pull_request.title }}" =~ ^AIRO-[0-9]+[[:space:]].*$ ]] && ! [[ "${{ github.event.pull_request.head.ref }}" =~ ^AIRO-[0-9]+.*$ ]] 15 | then 16 | echo -e "Please make sure one of the following is true:\n \ 17 | 1. the pull request title starts with 'AIRO-xxxx ', e.g. 'AIRO-1024 My Pull Request'\n \ 18 | 2. the source branch starts with 'AIRO-xxx', e.g. 'AIRO-1024-my-branch'" 19 | exit 1 20 | else 21 | echo "Completed checking" 22 | fi 23 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | name: pre-commit 2 | 3 | on: 4 | pull_request: 5 | 6 | jobs: 7 | pre-commit: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions/setup-python@v2 12 | with: 13 | python-version: 3.7.x 14 | - uses: actions/setup-dotnet@v1 15 | with: 16 | dotnet-version: '6.0.x' 17 | include-prerelease: true 18 | - uses: pre-commit/action@v2.0.0 19 | -------------------------------------------------------------------------------- /.github/workflows/stale.yaml: -------------------------------------------------------------------------------- 1 | name: 'Stale issue handler' 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: '0 17 * * *' # 17:00 UTC; 10:00 PDT 6 | 7 | permissions: 8 | issues: write 9 | 10 | jobs: 11 | stale: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/stale@v4.0.0 15 | id: stale 16 | with: 17 | stale-issue-label: 'stale' 18 | stale-issue-message: 'This issue has been marked stale because it has been open for 14 days with no activity. Please remove the stale label or comment on this issue, or the issue will be automatically closed in the next 14 days.' 19 | days-before-stale: 14 20 | days-before-pr-stale: -1 21 | days-before-close: 14 22 | days-before-pr-close: -1 23 | exempt-issue-labels: 'blocked,must,should,keep,pinned,work-in-progress,request,announcement' 24 | close-issue-message: 'This issue has been marked stale for 14 days and will now be closed. If this issue is still valid, please ping a maintainer.' 25 | - name: Print outputs 26 | run: echo ${{ join(steps.stale.outputs.*, ',') }} 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data/ 2 | data2/ 3 | build/ 4 | **/*.vs 5 | **/*.pdb 6 | CMakeFiles 7 | **/.DS_Store 8 | **/.vscode/ 9 | **/.idea/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "v-hacd-data"] 2 | path = v-hacd-data 3 | url = https://github.com/kmammou/v-hacd-data.git 4 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.0.1 4 | hooks: 5 | - id: mixed-line-ending 6 | exclude: > 7 | (?x)^( 8 | .*cs.meta| 9 | .*.css| 10 | .*.meta| 11 | .*.mat| 12 | .*.preset| 13 | .*.lighting 14 | )$ 15 | args: [--fix=lf] 16 | 17 | - id: trailing-whitespace 18 | name: trailing-whitespace-markdown 19 | types: [markdown] 20 | - id: check-merge-conflict 21 | args: [--assume-in-merge] 22 | - id: check-yaml 23 | # Won't handle the templating in yamato 24 | exclude: \.yamato/.* 25 | 26 | 27 | - repo: https://github.com/dotnet/format 28 | rev: v5.1.225507 29 | hooks: 30 | - id: dotnet-format 31 | entry: dotnet-format whitespace 32 | args: [--folder, --include] 33 | -------------------------------------------------------------------------------- /.yamato/sonar.yml: -------------------------------------------------------------------------------- 1 | csharp: 2 | name: Sonarqube C# Scan 3 | agent: 4 | type: Unity::metal::macmini 5 | image: package-ci/mac 6 | flavor: m1.mac 7 | variables: 8 | PROJECT_PATH: TestVhacd 9 | SONARQUBE_PROJECT_KEY: ai-robotics-vhacd-csharp 10 | SONARQUBE_PROJECT_BASE_DIR: /Users/bokken/build/output/Unity-Technologies/VHACD/com.unity.robotics.vhacd 11 | MSBUILD_SLN_PATH: ./TestVhacd/TestVhacd.sln 12 | PROJECT_ROOT: /Users/bokken/build/output/Unity-Technologies/VHACD/ 13 | UNITY_VERSION: 2020.3.21f1 14 | commands: 15 | - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-npm 16 | - unity-downloader-cli -u $UNITY_VERSION -c Editor 17 | - brew install mono corretto 18 | - curl https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.2.1.31210/sonar-scanner-msbuild-5.2.1.31210-net46.zip -o sonar-scanner-msbuild-net46.zip -L 19 | - unzip sonar-scanner-msbuild-net46.zip -d ~/sonar-scanner-msbuild 20 | - chmod a+x ~/sonar-scanner-msbuild/sonar-scanner-4.6.1.2450/bin/sonar-scanner 21 | - .Editor/Unity.app/Contents/MacOS/Unity -projectPath $PROJECT_PATH -batchmode -quit -nographics -logFile - -executeMethod "UnityEditor.SyncVS.SyncSolution" 22 | - command: | 23 | cd $PROJECT_PATH 24 | for file in *.csproj; do sed -i.backup "s/^[[:blank:]]*false<\/ReferenceOutputAssembly>/true<\/ReferenceOutputAssembly>/g" $file; rm $file.backup; done 25 | cd $PROJECT_ROOT 26 | - mono ~/sonar-scanner-msbuild/SonarScanner.MSBuild.exe begin /k:$SONARQUBE_PROJECT_KEY /d:sonar.host.url=$SONARQUBE_ENDPOINT_URL_PRD /d:sonar.login=$SONARQUBE_TOKEN_PRD /d:sonar.projectBaseDir=$SONARQUBE_PROJECT_BASE_DIR 27 | - msbuild $MSBUILD_SLN_PATH 28 | - mono ~/sonar-scanner-msbuild/SonarScanner.MSBuild.exe end /d:sonar.login=$SONARQUBE_TOKEN_PRD 29 | triggers: 30 | cancel_old_ci: true 31 | expression: | 32 | ((pull_request.target eq "main" OR pull_request.target eq "dev") 33 | AND NOT pull_request.push.changes.all match "**/*.md") OR 34 | (push.branch eq "main" OR push.branch eq "dev") 35 | standard: 36 | name: Sonarqube Standard Scan 37 | agent: 38 | type: Unity::VM 39 | image: robotics/ci-ubuntu20:latest 40 | flavor: i1.large 41 | variables: 42 | SONARQUBE_PROJECT_KEY: ai-robotics-vhacd-standard 43 | ROOT_DIR: /home/bokken/build/output/Unity-Technologies/VHACD 44 | SRC_DIR: /home/bokken/build/output/Unity-Technologies/VHACD/src 45 | BUILD_WRAPPER_DIR: /home/bokken/build/output/Unity-Technologies/VHACD/build_wrapper_output_directory 46 | commands: 47 | - curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip -o sonar-scanner-linux.zip -L 48 | - unzip sonar-scanner-linux.zip -d ~/sonar-scanner 49 | - curl $SONARQUBE_ENDPOINT_URL_PRD/static/cpp/build-wrapper-linux-x86.zip -o sonar-build-wrapper-linux.zip -L 50 | - unzip sonar-build-wrapper-linux.zip -d ~/sonar-build-wrapper 51 | - mkdir build 52 | - cd build 53 | - cmake $SRC_DIR 54 | - ~/sonar-build-wrapper/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_DIR make 55 | - cd $ROOT_DIR 56 | - ~/sonar-scanner/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY -Dsonar.sources=$SRC_FOLDER -Dsonar.host.url=$SONARQUBE_ENDPOINT_URL_PRD -Dsonar.login=$SONARQUBE_TOKEN_PRD -Dsonar.cfamily.build-wrapper-output=$BUILD_WRAPPER_DIR 57 | triggers: 58 | cancel_old_ci: true 59 | expression: | 60 | ((pull_request.target eq "main" OR pull_request.target eq "dev") 61 | AND NOT pull_request.push.changes.all match "**/*.md") OR 62 | (push.branch eq "main" OR push.branch eq "dev") -------------------------------------------------------------------------------- /.yamato/yamato-config.yml: -------------------------------------------------------------------------------- 1 | # {% assign platforms = "linux mac windows" | split: " " %} 2 | {% assign platforms = "linux mac" | split: " " %} 3 | 4 | {% for platform in platforms %} 5 | {{platform}}: 6 | name: VHACD Unit Tests ({{platform}}) 7 | agent: 8 | {% if platform == "linux" %} 9 | type: Unity::VM 10 | image: robotics/ci-ubuntu20:v0.1.0-795910 11 | flavor: i1.large 12 | {% elsif platform == "mac" %} 13 | type: Unity::metal::macmini 14 | image: package-ci/mac 15 | flavor: m1.mac 16 | # {% elsif platform == "windows" %} 17 | # type: Unity::VM 18 | # image: slough-ops/win10-base:stable 19 | # flavor: b1.medium 20 | {% endif %} 21 | variables: 22 | COVERAGE_EXPECTED: 0 23 | PATH: /root/.local/bin:/home/bokken/bin:/home/bokken/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin:/home/bokken/.npm-global/bin 24 | commands: 25 | - git submodule update --init --recursive 26 | - python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade 27 | - unity-downloader-cli -u 2020.3.21f1 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published 28 | - git clone git@github.cds.internal.unity3d.com:unity/utr.git utr 29 | - utr/utr --testproject=./TestVhacd --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --enable-code-coverage --coverage-results-path=../test-results --coverage-options="assemblyFilters:+Unity.Robotics.VHACD,+Unity.Robotics.VHACD.Editor;generateHtmlReport;generateBadgeReport;generateAdditionalMetrics" 30 | # check test coverage 31 | - command: | 32 | linecoverage=$(cat test-results/Report/Summary.xml | grep Linecoverage | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') 33 | echo "Line coverage: $linecoverage%" 34 | if (( $(echo "$linecoverage < $COVERAGE_EXPECTED" | bc -l) )) 35 | then echo "ERROR: Code coverage is under threshold of $COVERAGE_EXPECTED%" && exit 1 36 | fi 37 | triggers: 38 | cancel_old_ci: true 39 | expression: | 40 | ((pull_request.target eq "main" OR pull_request.target eq "dev") 41 | AND NOT pull_request.push.changes.all match "**/*.md") OR 42 | (push.branch eq "main" OR push.branch eq "dev") 43 | artifacts: 44 | logs: 45 | paths: 46 | - "test-results/**/*" 47 | {% endfor %} -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this repository will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 6 | 7 | ## Unreleased 8 | 9 | ### Upgrade Notes 10 | 11 | ### Known Issues 12 | 13 | ### Added 14 | 15 | Added Sonarqube Scanner, multiplatform Yamato testing 16 | 17 | ### Changed 18 | 19 | ### Deprecated 20 | 21 | ### Removed 22 | 23 | ### Fixed 24 | 25 | ## [0.0.1-preview] - 2021-12-14 26 | 27 | ### Upgrade Notes 28 | 29 | ### Known Issues 30 | 31 | ### Added 32 | 33 | ### Changed 34 | 35 | Created VHACD Unity package 36 | 37 | ### Deprecated 38 | 39 | ### Removed 40 | 41 | ### Fixed -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | At this time, the repo is not accepting external contributions in the form of PRs. The Unity Robotics packages and all of its features are in active development, and significant changes are expected in future releases. 4 | 5 | We encourage you to submit bugs, suggestions, and feedback as [GitHub issues](https://github.com/Unity-Technologies/VHACD/issues). -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VHACD 2 | 3 | [![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE.md) 4 | ![Unity](https://img.shields.io/badge/unity-2020.2+-brightgreen) 5 | 6 | --- 7 | 8 | We're currently working on lots of things! Please take a short moment fill out our [survey](https://unitysoftware.co1.qualtrics.com/jfe/form/SV_0ojVkDVW0nNrHkW) to help us identify what products and packages to build next. 9 | 10 | --- 11 | 12 | ## The V-HACD library decomposes a 3D surface into a set of "near" convex parts. 13 | 14 | ![Approximate convex decomposition of "Camel"](https://github.com/kmammou/v-hacd/raw/master/doc/acd.png) 15 | 16 | ## Installation 17 | 18 | 1. Using Unity 2020.2 or later, open the Package Manager from `Window` -> `Package Manager`. 19 | 2. In the Package Manager window, find and click the + button in the upper lefthand corner of the window. Select `Add package from git URL....` 20 | 21 | ![image](https://user-images.githubusercontent.com/29758400/110989310-8ea36180-8326-11eb-8318-f67ee200a23d.png) 22 | 23 | 3. Enter the git URL for the desired package. Note: you can append a version tag to the end of the git url, like `#v0.4.0` or `#v0.5.0`, to declare a specific package version, or exclude the tag to get the latest from the package's `main` branch. 24 | 25 | ``` 26 | https://github.com/Unity-Technologies/VHACD.git?path=/com.unity.robotics.vhacd 27 | ``` 28 | 29 | 4. Click `Add`. 30 | 31 | To install from a local clone of the repository, see [installing a local package](https://docs.unity3d.com/Manual/upm-ui-local.html) in the Unity manual. 32 | 33 | --- 34 | 35 | ## Why do we need approximate convex decomposition? 36 | 37 | Collision detection is essential for [realistic physical interactions](https://www.youtube.com/watch?v=oyjE5L4-1lQ) in video games and computer animation. In order to ensure real-time interactivity with the player/user, video game and 3D modeling software developers usually approximate the 3D models composing the scene (e.g. animated characters, static objects...) by a set of simple convex shapes such as ellipsoids, capsules or convex-hulls. In practice, these simple shapes provide poor approximations for concave surfaces and generate false collision detection. 38 | 39 | ![Convex-hull vs. ACD](https://raw.githubusercontent.com/kmammou/v-hacd/master/doc/chvsacd.png) 40 | 41 | A second approach consists in computing an exact convex decomposition of a surface S, which consists in partitioning it into a minimal set of convex sub-surfaces. Exact convex decomposition algorithms are NP-hard and non-practical since they produce a high number of clusters. To overcome these limitations, the exact convexity constraint is relaxed and an approximate convex decomposition of S is instead computed. Here, the goal is to determine a partition of the mesh triangles with a minimal number of clusters, while ensuring that each cluster has a concavity lower than a user defined threshold. 42 | 43 | ![ACD vs. ECD](https://raw.githubusercontent.com/kmammou/v-hacd/master/doc/ecdvsacd.png) 44 | 45 | 46 | ## Parameters 47 | | Parameter name | Description | Default value | Range | 48 | | ------------- | ------------- | ------------- | ---- | 49 | | resolution | maximum number of voxels generated during the voxelization stage | 100,000 | 10,000-64,000,000 | 50 | | depth | maximum number of clipping stages. During each split stage, all the model parts (with a concavity higher than the user defined threshold) are clipped according the "best" clipping plane | 20 | 1-32 | 51 | | concavity | maximum concavity | 0.0025 | 0.0-1.0 | 52 | | planeDownsampling | controls the granularity of the search for the "best" clipping plane | 4 | 1-16 | 53 | | convexhullDownsampling | controls the precision of the convex-hull generation process during the clipping plane selection stage | 4 | 1-16 | 54 | | alpha | controls the bias toward clipping along symmetry planes | 0.05 | 0.0-1.0 | 55 | | beta | controls the bias toward clipping along revolution axes | 0.05 | 0.0-1.0 | 56 | | gamma | maximum allowed concavity during the merge stage | 0.00125 | 0.0-1.0 | 57 | | pca | enable/disable normalizing the mesh before applying the convex decomposition | 0 | 0-1 | 58 | | mode | 0: voxel-based approximate convex decomposition, 1: tetrahedron-based approximate convex decomposition | 0 | 0-1 | 59 | | maxNumVerticesPerCH | controls the maximum number of triangles per convex-hull | 64 | 4-1024 | 60 | | minVolumePerCH | controls the adaptive sampling of the generated convex-hulls | 0.0001 | 0.0-0.01 | 61 | 62 | --- 63 | 64 | ## Support 65 | For questions or discussions about Unity Robotics package installations or how to best set up and integrate your robotics projects, please create a new thread on the [Unity Robotics forum](https://forum.unity.com/forums/robotics.623/) and make sure to include as much detail as possible. 66 | 67 | For feature requests, bugs, or other issues, please file a [GitHub issue](https://github.com/Unity-Technologies/v-hacd-unity/issues) using the provided templates and the Robotics team will investigate as soon as possible. 68 | 69 | ## More from Unity Robotics 70 | Visit the [Robotics Hub](https://github.com/Unity-Technologies/Unity-Robotics-Hub) for more tutorials, tools, and information on robotics simulation in Unity! 71 | 72 | ## License 73 | [Apache 2.0](LICENSE) -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 022e2bf9bcd6a7b43a75571e48ae13c3 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TestVhacd/.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Uncomment this line if you wish to ignore the asset store tools plugin 18 | # /[Aa]ssets/AssetStoreTools* 19 | 20 | # Autogenerated Jetbrains Rider plugin 21 | /[Aa]ssets/Plugins/Editor/JetBrains* 22 | 23 | # Visual Studio cache directory 24 | .vs/ 25 | 26 | .DS_Store 27 | 28 | # Gradle cache directory 29 | .gradle/ 30 | 31 | # Autogenerated VS/MD/Consulo solution and project files 32 | ExportedObj/ 33 | .consulo/ 34 | *.csproj 35 | *.unityproj 36 | *.sln 37 | *.suo 38 | *.tmp 39 | *.user 40 | *.userprefs 41 | *.pidb 42 | *.booproj 43 | *.svd 44 | *.pdb 45 | *.mdb 46 | *.opendb 47 | *.VC.db 48 | 49 | # Unity3D generated meta files 50 | *.pidb.meta 51 | *.pdb.meta 52 | *.mdb.meta 53 | 54 | # Unity3D generated file on crash reports 55 | sysinfo.txt 56 | 57 | # Builds 58 | *.apk 59 | *.aab 60 | *.unitypackage 61 | 62 | # Crashlytics generated file 63 | crashlytics-build.properties 64 | 65 | # Packed Addressables 66 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 67 | 68 | # Temporary auto-generated Android Assets 69 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 70 | /[Aa]ssets/[Ss]treamingAssets/aa/* 71 | 72 | .DS_Store 73 | 74 | #Example URDF folder 75 | TestModel/ 76 | 77 | # Build and Deploy 78 | deploy/* 79 | .DS_Store 80 | -------------------------------------------------------------------------------- /TestVhacd/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 298132b38a28d4a18b9710b8fcffe92a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TestVhacd/Assets/Scenes/SampleScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 705507994} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 2 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &705507993 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInternal: {fileID: 0} 129 | serializedVersion: 6 130 | m_Component: 131 | - component: {fileID: 705507995} 132 | - component: {fileID: 705507994} 133 | m_Layer: 0 134 | m_Name: Directional Light 135 | m_TagString: Untagged 136 | m_Icon: {fileID: 0} 137 | m_NavMeshLayer: 0 138 | m_StaticEditorFlags: 0 139 | m_IsActive: 1 140 | --- !u!108 &705507994 141 | Light: 142 | m_ObjectHideFlags: 0 143 | m_CorrespondingSourceObject: {fileID: 0} 144 | m_PrefabInternal: {fileID: 0} 145 | m_GameObject: {fileID: 705507993} 146 | m_Enabled: 1 147 | serializedVersion: 8 148 | m_Type: 1 149 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 150 | m_Intensity: 1 151 | m_Range: 10 152 | m_SpotAngle: 30 153 | m_CookieSize: 10 154 | m_Shadows: 155 | m_Type: 2 156 | m_Resolution: -1 157 | m_CustomResolution: -1 158 | m_Strength: 1 159 | m_Bias: 0.05 160 | m_NormalBias: 0.4 161 | m_NearPlane: 0.2 162 | m_Cookie: {fileID: 0} 163 | m_DrawHalo: 0 164 | m_Flare: {fileID: 0} 165 | m_RenderMode: 0 166 | m_CullingMask: 167 | serializedVersion: 2 168 | m_Bits: 4294967295 169 | m_Lightmapping: 1 170 | m_LightShadowCasterMode: 0 171 | m_AreaSize: {x: 1, y: 1} 172 | m_BounceIntensity: 1 173 | m_ColorTemperature: 6570 174 | m_UseColorTemperature: 0 175 | m_ShadowRadius: 0 176 | m_ShadowAngle: 0 177 | --- !u!4 &705507995 178 | Transform: 179 | m_ObjectHideFlags: 0 180 | m_CorrespondingSourceObject: {fileID: 0} 181 | m_PrefabInternal: {fileID: 0} 182 | m_GameObject: {fileID: 705507993} 183 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 184 | m_LocalPosition: {x: 0, y: 3, z: 0} 185 | m_LocalScale: {x: 1, y: 1, z: 1} 186 | m_Children: [] 187 | m_Father: {fileID: 0} 188 | m_RootOrder: 1 189 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 190 | --- !u!1 &963194225 191 | GameObject: 192 | m_ObjectHideFlags: 0 193 | m_CorrespondingSourceObject: {fileID: 0} 194 | m_PrefabInternal: {fileID: 0} 195 | serializedVersion: 6 196 | m_Component: 197 | - component: {fileID: 963194228} 198 | - component: {fileID: 963194227} 199 | - component: {fileID: 963194226} 200 | m_Layer: 0 201 | m_Name: Main Camera 202 | m_TagString: MainCamera 203 | m_Icon: {fileID: 0} 204 | m_NavMeshLayer: 0 205 | m_StaticEditorFlags: 0 206 | m_IsActive: 1 207 | --- !u!81 &963194226 208 | AudioListener: 209 | m_ObjectHideFlags: 0 210 | m_CorrespondingSourceObject: {fileID: 0} 211 | m_PrefabInternal: {fileID: 0} 212 | m_GameObject: {fileID: 963194225} 213 | m_Enabled: 1 214 | --- !u!20 &963194227 215 | Camera: 216 | m_ObjectHideFlags: 0 217 | m_CorrespondingSourceObject: {fileID: 0} 218 | m_PrefabInternal: {fileID: 0} 219 | m_GameObject: {fileID: 963194225} 220 | m_Enabled: 1 221 | serializedVersion: 2 222 | m_ClearFlags: 1 223 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 224 | m_projectionMatrixMode: 1 225 | m_SensorSize: {x: 36, y: 24} 226 | m_LensShift: {x: 0, y: 0} 227 | m_GateFitMode: 2 228 | m_FocalLength: 50 229 | m_NormalizedViewPortRect: 230 | serializedVersion: 2 231 | x: 0 232 | y: 0 233 | width: 1 234 | height: 1 235 | near clip plane: 0.3 236 | far clip plane: 1000 237 | field of view: 60 238 | orthographic: 0 239 | orthographic size: 5 240 | m_Depth: -1 241 | m_CullingMask: 242 | serializedVersion: 2 243 | m_Bits: 4294967295 244 | m_RenderingPath: -1 245 | m_TargetTexture: {fileID: 0} 246 | m_TargetDisplay: 0 247 | m_TargetEye: 3 248 | m_HDR: 1 249 | m_AllowMSAA: 1 250 | m_AllowDynamicResolution: 0 251 | m_ForceIntoRT: 0 252 | m_OcclusionCulling: 1 253 | m_StereoConvergence: 10 254 | m_StereoSeparation: 0.022 255 | --- !u!4 &963194228 256 | Transform: 257 | m_ObjectHideFlags: 0 258 | m_CorrespondingSourceObject: {fileID: 0} 259 | m_PrefabInternal: {fileID: 0} 260 | m_GameObject: {fileID: 963194225} 261 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 262 | m_LocalPosition: {x: 0, y: 1, z: -10} 263 | m_LocalScale: {x: 1, y: 1, z: 1} 264 | m_Children: [] 265 | m_Father: {fileID: 0} 266 | m_RootOrder: 0 267 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 268 | -------------------------------------------------------------------------------- /TestVhacd/Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TestVhacd/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "1.13.5", 4 | "com.unity.ide.rider": "2.0.7", 5 | "com.unity.ide.visualstudio": "2.0.11", 6 | "com.unity.ide.vscode": "1.2.4", 7 | "com.unity.robotics.vhacd": "file:../../com.unity.robotics.vhacd", 8 | "com.unity.test-framework": "1.1.29", 9 | "com.unity.textmeshpro": "3.0.6", 10 | "com.unity.timeline": "1.4.8", 11 | "com.unity.ugui": "1.0.0", 12 | "com.unity.modules.ai": "1.0.0", 13 | "com.unity.modules.androidjni": "1.0.0", 14 | "com.unity.modules.animation": "1.0.0", 15 | "com.unity.modules.assetbundle": "1.0.0", 16 | "com.unity.modules.audio": "1.0.0", 17 | "com.unity.modules.cloth": "1.0.0", 18 | "com.unity.modules.director": "1.0.0", 19 | "com.unity.modules.imageconversion": "1.0.0", 20 | "com.unity.modules.imgui": "1.0.0", 21 | "com.unity.modules.jsonserialize": "1.0.0", 22 | "com.unity.modules.particlesystem": "1.0.0", 23 | "com.unity.modules.physics": "1.0.0", 24 | "com.unity.modules.physics2d": "1.0.0", 25 | "com.unity.modules.screencapture": "1.0.0", 26 | "com.unity.modules.terrain": "1.0.0", 27 | "com.unity.modules.terrainphysics": "1.0.0", 28 | "com.unity.modules.tilemap": "1.0.0", 29 | "com.unity.modules.ui": "1.0.0", 30 | "com.unity.modules.uielements": "1.0.0", 31 | "com.unity.modules.umbra": "1.0.0", 32 | "com.unity.modules.unityanalytics": "1.0.0", 33 | "com.unity.modules.unitywebrequest": "1.0.0", 34 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 35 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 36 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 37 | "com.unity.modules.unitywebrequestwww": "1.0.0", 38 | "com.unity.modules.vehicles": "1.0.0", 39 | "com.unity.modules.video": "1.0.0", 40 | "com.unity.modules.vr": "1.0.0", 41 | "com.unity.modules.wind": "1.0.0", 42 | "com.unity.modules.xr": "1.0.0" 43 | }, 44 | "testables": [ 45 | "com.unity.robotics.vhacd" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_SerializeInlineMappingsOnOneLine: 1 -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.3.21f1 2 | m_EditorVersionWithRevision: 2020.3.21f1 (a38c86f6690f) 3 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /TestVhacd/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /Third Party Notices.md: -------------------------------------------------------------------------------- 1 | Component name: jasonmeisel/v-hacd-unity 2 | 3 | License Type: BSD 3-clause 4 | 5 | ``` 6 | Copyright (c) 2017-2020, Jason Meisel 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | 15 | Redistributions in binary form must reproduce the above copyright notice, this 16 | list of conditions and the following disclaimer in the documentation and/or 17 | other materials provided with the distribution. 18 | 19 | Neither the name of the copyright holder nor the names of its contributors 20 | may be used to endorse or promote products derived from this software without 21 | specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | ``` 34 | 35 | --- 36 | 37 | Component name: kmammou/v-hacd 38 | 39 | License Type: BSD 3-clause 40 | 41 | ``` 42 | Copyright (c) 2011, Khaled Mamou (kmamou at gmail dot com) 43 | All rights reserved. 44 | 45 | Redistribution and use in source and binary forms, with or without modification, 46 | are permitted provided that the following conditions are met: 47 | 48 | Redistributions of source code must retain the above copyright notice, this 49 | list of conditions and the following disclaimer. 50 | 51 | Redistributions in binary form must reproduce the above copyright notice, this 52 | list of conditions and the following disclaimer in the documentation and/or 53 | other materials provided with the distribution. 54 | 55 | Neither the name of the copyright holder nor the names of its contributors 56 | may be used to endorse or promote products derived from this software without 57 | specific prior written permission. 58 | 59 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 60 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 61 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 62 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 63 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 64 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 65 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 66 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 67 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 68 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 69 | ``` -------------------------------------------------------------------------------- /bin-no-ocl-omp/osx/testVHACD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin-no-ocl-omp/osx/testVHACD -------------------------------------------------------------------------------- /bin-no-ocl/osx/testVHACD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin-no-ocl/osx/testVHACD -------------------------------------------------------------------------------- /bin-no-ocl/win32/testVHACD.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin-no-ocl/win32/testVHACD.exe -------------------------------------------------------------------------------- /bin-no-ocl/win64/testVHACD.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin-no-ocl/win64/testVHACD.exe -------------------------------------------------------------------------------- /bin/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin/.DS_Store -------------------------------------------------------------------------------- /bin/osx/testVHACD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin/osx/testVHACD -------------------------------------------------------------------------------- /bin/win32/testVHACD.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin/win32/testVHACD.exe -------------------------------------------------------------------------------- /bin/win64/testVHACD.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/bin/win64/testVHACD.exe -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60cbacf497efa4529ba5ff00c90e588c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 926c2a7dc7f1546b9926e929b2feb39c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/LICENSE.MD: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2011, Khaled Mamou (kmamou at gmail dot com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/LICENSE.MD.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7251e877ef5d543d2b72461f9b0019e3 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/VHACD.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using UnityEngine; 6 | 7 | namespace MeshProcess 8 | { 9 | public class VHACD : MonoBehaviour 10 | { 11 | [System.Serializable] 12 | public unsafe struct Parameters 13 | { 14 | public void Init() 15 | { 16 | m_resolution = 100000; 17 | m_concavity = 0.001; 18 | m_planeDownsampling = 4; 19 | m_convexhullDownsampling = 4; 20 | m_alpha = 0.05; 21 | m_beta = 0.05; 22 | m_pca = 0; 23 | m_mode = 0; // 0: voxel-based (recommended), 1: tetrahedron-based 24 | m_maxNumVerticesPerCH = 64; 25 | m_minVolumePerCH = 0.0001; 26 | m_callback = null; 27 | m_logger = null; 28 | m_convexhullApproximation = 1; 29 | m_oclAcceleration = 0; 30 | m_maxConvexHulls = 1024; 31 | m_projectHullVertices = true; // This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results 32 | } 33 | 34 | [Tooltip("maximum concavity")] 35 | [Range(0, 1)] 36 | public double m_concavity; 37 | 38 | [Tooltip("controls the bias toward clipping along symmetry planes")] 39 | [Range(0, 1)] 40 | public double m_alpha; 41 | 42 | [Tooltip("controls the bias toward clipping along revolution axes")] 43 | [Range(0, 1)] 44 | public double m_beta; 45 | 46 | [Tooltip("controls the adaptive sampling of the generated convex-hulls")] 47 | [Range(0, 0.01f)] 48 | public double m_minVolumePerCH; 49 | 50 | public void* m_callback; 51 | public void* m_logger; 52 | 53 | [Tooltip("maximum number of voxels generated during the voxelization stage")] 54 | [Range(10000, 64000000)] 55 | public uint m_resolution; 56 | 57 | [Tooltip("controls the maximum number of triangles per convex-hull")] 58 | [Range(4, 1024)] 59 | public uint m_maxNumVerticesPerCH; 60 | 61 | [Tooltip("controls the granularity of the search for the \"best\" clipping plane")] 62 | [Range(1, 16)] 63 | public uint m_planeDownsampling; 64 | 65 | [Tooltip("controls the precision of the convex-hull generation process during the clipping plane selection stage")] 66 | [Range(1, 16)] 67 | public uint m_convexhullDownsampling; 68 | 69 | [Tooltip("enable/disable normalizing the mesh before applying the convex decomposition")] 70 | [Range(0, 1)] 71 | public uint m_pca; 72 | 73 | [Tooltip("0: voxel-based (recommended), 1: tetrahedron-based")] 74 | [Range(0, 1)] 75 | public uint m_mode; 76 | 77 | [Range(0, 1)] 78 | public uint m_convexhullApproximation; 79 | 80 | [Range(0, 1)] 81 | public uint m_oclAcceleration; 82 | 83 | public uint m_maxConvexHulls; 84 | 85 | [Tooltip("This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results")] 86 | public bool m_projectHullVertices; 87 | }; 88 | 89 | unsafe struct ConvexHull 90 | { 91 | public double* m_points; 92 | public uint* m_triangles; 93 | public uint m_nPoints; 94 | public uint m_nTriangles; 95 | public double m_volume; 96 | public fixed double m_center[3]; 97 | }; 98 | 99 | [DllImport("libvhacd")] static extern unsafe void* CreateVHACD(); 100 | 101 | [DllImport("libvhacd")] static extern unsafe void DestroyVHACD(void* pVHACD); 102 | 103 | [DllImport("libvhacd")] 104 | static extern unsafe bool ComputeFloat( 105 | void* pVHACD, 106 | float* points, 107 | uint countPoints, 108 | uint* triangles, 109 | uint countTriangles, 110 | Parameters* parameters); 111 | 112 | [DllImport("libvhacd")] 113 | static extern unsafe bool ComputeDouble( 114 | void* pVHACD, 115 | double* points, 116 | uint countPoints, 117 | uint* triangles, 118 | uint countTriangles, 119 | Parameters* parameters); 120 | 121 | [DllImport("libvhacd")] static extern unsafe uint GetNConvexHulls(void* pVHACD); 122 | 123 | [DllImport("libvhacd")] 124 | static extern unsafe void GetConvexHull( 125 | void* pVHACD, 126 | uint index, 127 | ConvexHull* ch); 128 | 129 | public Parameters m_parameters; 130 | 131 | public VHACD() { m_parameters.Init(); } 132 | 133 | [ContextMenu("Generate Convex Meshes")] 134 | public unsafe List GenerateConvexMeshes(Mesh mesh = null) 135 | { 136 | if (mesh == null) 137 | { 138 | mesh = GetComponent().sharedMesh; 139 | } 140 | var vhacd = CreateVHACD(); 141 | var parameters = m_parameters; 142 | 143 | var verts = mesh.vertices; 144 | var tris = mesh.triangles; 145 | fixed (Vector3* pVerts = verts) 146 | fixed (int* pTris = tris) 147 | { 148 | ComputeFloat( 149 | vhacd, 150 | (float*)pVerts, (uint)verts.Length, 151 | (uint*)pTris, (uint)tris.Length / 3, 152 | ¶meters); 153 | } 154 | 155 | var numHulls = GetNConvexHulls(vhacd); 156 | List convexMesh = new List((int)numHulls); 157 | foreach (var index in Enumerable.Range(0, (int)numHulls)) 158 | { 159 | ConvexHull hull; 160 | GetConvexHull(vhacd, (uint)index, &hull); 161 | 162 | var hullMesh = new Mesh(); 163 | var hullVerts = new Vector3[hull.m_nPoints]; 164 | fixed (Vector3* pHullVerts = hullVerts) 165 | { 166 | var pComponents = hull.m_points; 167 | var pVerts = pHullVerts; 168 | 169 | for (var pointCount = hull.m_nPoints; pointCount != 0; --pointCount) 170 | { 171 | pVerts->x = (float)pComponents[0]; 172 | pVerts->y = (float)pComponents[1]; 173 | pVerts->z = (float)pComponents[2]; 174 | 175 | pVerts += 1; 176 | pComponents += 3; 177 | } 178 | } 179 | 180 | hullMesh.SetVertices(hullVerts); 181 | 182 | var indices = new int[hull.m_nTriangles * 3]; 183 | Marshal.Copy((System.IntPtr)hull.m_triangles, indices, 0, indices.Length); 184 | hullMesh.SetTriangles(indices, 0); 185 | 186 | 187 | convexMesh.Add(hullMesh); 188 | } 189 | return convexMesh; 190 | } 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/VHACD.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 845ffa358c43240dda6ed5379b4f0c8e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/liblibvhacd.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/com.unity.robotics.vhacd/Runtime/liblibvhacd.dylib -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/liblibvhacd.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94c2c889690e246e8af1941d40e09b36 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 1 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Standalone: OSXUniversal 27 | second: 28 | enabled: 1 29 | settings: {} 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/liblibvhacd.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/com.unity.robotics.vhacd/Runtime/liblibvhacd.so -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/liblibvhacd.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47c08989d7bad470487e2f72442e442f 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux64: 0 21 | Exclude OSXUniversal: 1 22 | Exclude WebGL: 1 23 | Exclude Win: 1 24 | Exclude Win64: 1 25 | Exclude WindowsStoreApps: 1 26 | - first: 27 | Any: 28 | second: 29 | enabled: 0 30 | settings: {} 31 | - first: 32 | Editor: Editor 33 | second: 34 | enabled: 1 35 | settings: 36 | CPU: x86_64 37 | DefaultValueInitialized: true 38 | OS: Linux 39 | - first: 40 | Standalone: Linux64 41 | second: 42 | enabled: 1 43 | settings: 44 | CPU: AnyCPU 45 | - first: 46 | Standalone: OSXUniversal 47 | second: 48 | enabled: 0 49 | settings: 50 | CPU: None 51 | - first: 52 | Standalone: Win 53 | second: 54 | enabled: 0 55 | settings: 56 | CPU: AnyCPU 57 | - first: 58 | Standalone: Win64 59 | second: 60 | enabled: 0 61 | settings: 62 | CPU: AnyCPU 63 | - first: 64 | WebGL: WebGL 65 | second: 66 | enabled: 0 67 | settings: {} 68 | - first: 69 | Windows Store Apps: WindowsStoreApps 70 | second: 71 | enabled: 0 72 | settings: 73 | CPU: X86 74 | DontProcess: true 75 | PlaceholderPath: 76 | SDK: AnySDK 77 | ScriptingBackend: AnyScriptingBackend 78 | userData: 79 | assetBundleName: 80 | assetBundleVariant: 81 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/libvhacd.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/com.unity.robotics.vhacd/Runtime/libvhacd.dll -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/libvhacd.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d1723769ada3482b80ae4dd6837ab53 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux64: 0 21 | Exclude OSXUniversal: 0 22 | Exclude WebGL: 1 23 | Exclude Win: 1 24 | Exclude Win64: 0 25 | Exclude WindowsStoreApps: 1 26 | - first: 27 | Any: 28 | second: 29 | enabled: 0 30 | settings: {} 31 | - first: 32 | Editor: Editor 33 | second: 34 | enabled: 1 35 | settings: 36 | CPU: x86_64 37 | DefaultValueInitialized: true 38 | OS: Windows 39 | - first: 40 | Standalone: Linux64 41 | second: 42 | enabled: 1 43 | settings: 44 | CPU: AnyCPU 45 | - first: 46 | Standalone: OSXUniversal 47 | second: 48 | enabled: 1 49 | settings: 50 | CPU: AnyCPU 51 | - first: 52 | Standalone: Win 53 | second: 54 | enabled: 0 55 | settings: 56 | CPU: None 57 | - first: 58 | Standalone: Win64 59 | second: 60 | enabled: 1 61 | settings: 62 | CPU: AnyCPU 63 | - first: 64 | Windows Store Apps: WindowsStoreApps 65 | second: 66 | enabled: 0 67 | settings: 68 | CPU: X86 69 | DontProcess: false 70 | PlaceholderPath: 71 | SDK: AnySDK 72 | ScriptingBackend: AnyScriptingBackend 73 | userData: 74 | assetBundleName: 75 | assetBundleVariant: 76 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/vhacd.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vhacd", 3 | "rootNamespace": "VHACD", 4 | "references": [], 5 | "includePlatforms": [ 6 | ], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": true, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Runtime/vhacd.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0dc65aa46d174cbab72d2bfef413320 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c16d5ba53ad84bfd8d4a20a21975353 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd25fcad2d3d04d6789278bd0cab8460 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Editor/PlayerBuildTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using UnityEditor; 5 | using UnityEditor.Build.Reporting; 6 | using UnityEditor.TestTools; 7 | using UnityEngine; 8 | using UnityEngine.TestTools; 9 | 10 | namespace BuildTests 11 | { 12 | public class PlayerBuilder 13 | { 14 | List m_EditorBuildSettingsScenes = new List(); 15 | BuildSummary m_Summary; 16 | string m_BuildPath = "Build"; 17 | 18 | [SetUp] 19 | public void SetUp() 20 | { 21 | } 22 | 23 | [UnityPlatform(RuntimePlatform.WindowsEditor)] 24 | [RequirePlatformSupport(BuildTarget.StandaloneWindows64)] 25 | [Test] 26 | public void BuildPlayerStandaloneWindows64() 27 | { 28 | BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, m_BuildPath, BuildOptions.None, out _, out m_Summary); 29 | Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, " BuildTarget.StandaloneWindows64 failed to build"); 30 | } 31 | 32 | [RequirePlatformSupport(BuildTarget.StandaloneLinux64)] 33 | [Test] 34 | public void BuildPlayerLinux() 35 | { 36 | BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64, m_BuildPath, BuildOptions.None, out _, out m_Summary); 37 | Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build"); 38 | } 39 | 40 | [UnityPlatform(RuntimePlatform.OSXEditor)] 41 | [RequirePlatformSupport(BuildTarget.StandaloneOSX)] 42 | [Test] 43 | public void BuildPlayerOSX() 44 | { 45 | BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, m_BuildPath, BuildOptions.None, out _, out m_Summary); 46 | Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build"); 47 | } 48 | 49 | void BuildPlayer(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, string buildOutputPath, BuildOptions buildOptions, 50 | out BuildReport buildReport, out BuildSummary buildSummary) 51 | { 52 | BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); 53 | buildPlayerOptions.locationPathName = buildOutputPath; 54 | buildPlayerOptions.target = buildTarget; 55 | buildPlayerOptions.options = buildOptions; 56 | buildPlayerOptions.targetGroup = buildTargetGroup; 57 | 58 | buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions); 59 | buildSummary = buildReport.summary; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Editor/PlayerBuildTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d88b03900df3849b183b22238ac5022b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Editor/Unity.Robotics.Vhacd.Editor.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Unity.Robotics.Vhacd.Editor.Tests", 3 | "rootNamespace": "Unity.Robotics.EditorTests.Vhacd", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "vhacd" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": true, 15 | "precompiledReferences": [ 16 | "nunit.framework.dll" 17 | ], 18 | "autoReferenced": false, 19 | "defineConstraints": [ 20 | "UNITY_INCLUDE_TESTS" 21 | ], 22 | "versionDefines": [], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Editor/Unity.Robotics.Vhacd.Editor.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53c7ddf62910a4aad81affc5270bced4 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fc15060ad68643d0bf0436042a27547 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Runtime/SmokeTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using UnityEngine; 5 | using UnityEngine.TestTools; 6 | 7 | public class SmokeTests 8 | { 9 | // A Test behaves as an ordinary method 10 | [Test] 11 | public void SmokeTestsSimplePasses() 12 | { 13 | // Use the Assert class to test conditions 14 | } 15 | 16 | // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use 17 | // `yield return null;` to skip a frame. 18 | [UnityTest] 19 | public IEnumerator SmokeTestsWithEnumeratorPasses() 20 | { 21 | // Use the Assert class to test conditions. 22 | // Use yield to skip a frame. 23 | yield return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Runtime/SmokeTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e335a2bb11e6544389488036520b56cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Runtime/Unity.Robotics.Vhacd.Runtime.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Unity.Robotics.Vhacd.Runtime.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "vhacd" 7 | ], 8 | "includePlatforms": [], 9 | "excludePlatforms": [], 10 | "allowUnsafeCode": false, 11 | "overrideReferences": true, 12 | "precompiledReferences": [ 13 | "nunit.framework.dll" 14 | ], 15 | "autoReferenced": false, 16 | "defineConstraints": [ 17 | "UNITY_INCLUDE_TESTS" 18 | ], 19 | "versionDefines": [], 20 | "noEngineReferences": false 21 | } -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/Tests/Runtime/Unity.Robotics.Vhacd.Runtime.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc54ff7e216fc4415b5a21bb9115a58e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.unity.robotics.vhacd", 3 | "version": "0.0.1-preview", 4 | "displayName": "VHACD", 5 | "description": "", 6 | "unity": "2020.3", 7 | "unityRelease": "19f1" 8 | } 9 | -------------------------------------------------------------------------------- /com.unity.robotics.vhacd/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bece70ee13b874e1b9d0a20a25213f62 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /doc/acd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/acd.png -------------------------------------------------------------------------------- /doc/chvsacd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/chvsacd.png -------------------------------------------------------------------------------- /doc/ecdvsacd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/ecdvsacd.png -------------------------------------------------------------------------------- /doc/snapshots_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/snapshots_1.png -------------------------------------------------------------------------------- /doc/snapshots_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/snapshots_2.png -------------------------------------------------------------------------------- /doc/snapshots_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/snapshots_3.png -------------------------------------------------------------------------------- /doc/snapshots_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/snapshots_4.png -------------------------------------------------------------------------------- /doc/snapshots_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/doc/snapshots_5.png -------------------------------------------------------------------------------- /install/run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import os 4 | import shutil 5 | import subprocess 6 | 7 | def cmake(platform_dir, src_dir, arg): 8 | if not(os.path.exists(platform_dir)): 9 | os.mkdir(platform_dir) 10 | os.chdir(platform_dir) # go to platform directory 11 | cmd = "cmake " + arg + " ../" + src_dir 12 | print("cmd") 13 | subprocess.call(cmd, shell=True) # run cmake 14 | 15 | def clean(platform_dir): 16 | if os.path.exists(platform_dir): 17 | shutil.rmtree(platform_dir) 18 | 19 | if __name__ == '__main__': 20 | src_dir = '../src/' # source code directory 21 | bin_dir = '../build/' # binary directory 22 | 23 | if not(os.path.exists(bin_dir)): # binary directory is created if not found 24 | print("Creating bin directory: " + bin_dir) 25 | os.mkdir(bin_dir) 26 | 27 | platform = sys.platform 28 | cmd = "" 29 | 30 | if (platform == 'darwin'): # platform directory is created if not found 31 | platform = 'mac' 32 | cmd = '-G Xcode' 33 | 34 | platform_dir = bin_dir + platform 35 | 36 | if len(sys.argv) == 1: 37 | print("Invalid arguments to run: please specify --cmake or --clean") 38 | sys.exit(-1) 39 | else: 40 | for arg in sys.argv: 41 | if (arg == '--cmake'): 42 | cmake(platform_dir, src_dir, cmd) 43 | elif (arg == '--clean'): 44 | clean(platform_dir) 45 | -------------------------------------------------------------------------------- /scripts/cmake_common.cmake: -------------------------------------------------------------------------------- 1 | message("[VHACD] Generating " ${PROJECT_NAME} "...") 2 | file(GLOB PROJECT_INC_FILES "inc/*.h" "public/*.h") 3 | file(GLOB PROJECT_INL_FILES "inc/*.inl") 4 | file(GLOB PROJECT_CPP_FILES "src/*.cpp") 5 | file(GLOB PROJECT_C_FILES "src/*.c") 6 | file(GLOB PROJECT_CL_FILES "cl/*.cl") 7 | source_group (Inc FILES ${PROJECT_INC_FILES}) 8 | source_group (Inl FILES ${PROJECT_INL_FILES}) 9 | source_group (Src FILES ${PROJECT_CPP_FILES} ) 10 | source_group (SrcC FILES ${PROJECT_C_FILES} ) 11 | source_group (CL FILES ${PROJECT_CL_FILES}) 12 | 13 | #include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/inc) 14 | message("[VHACD] \t INC_FILES: ${PROJECT_INC_FILES}") 15 | message("[VHACD] \t INL_FILES: ${PROJECT_INL_FILES}") 16 | message("[VHACD] \t CPP_FILES: ${PROJECT_CPP_FILES}") 17 | message("[VHACD] \t C_FILES: ${PROJECT_C_FILES}") 18 | message("[VHACD] \t CL_FILES: ${PROJECT_CL_FILES}") 19 | -------------------------------------------------------------------------------- /snapshots/Figure1_a_OriginalMeshp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/Figure1_a_OriginalMeshp.jpg -------------------------------------------------------------------------------- /snapshots/Figure1_b_ConvexHullp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/Figure1_b_ConvexHullp.jpg -------------------------------------------------------------------------------- /snapshots/Figure1_c_ACDp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/Figure1_c_ACDp.jpg -------------------------------------------------------------------------------- /snapshots/Figure2_a_BunnyECD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/Figure2_a_BunnyECD.jpg -------------------------------------------------------------------------------- /snapshots/Figure2_b_BunnyACD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/Figure2_b_BunnyACD.jpg -------------------------------------------------------------------------------- /snapshots/V-HACD_V1.0vsV2.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/V-HACD_V1.0vsV2.0.png -------------------------------------------------------------------------------- /snapshots/acd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/acd.png -------------------------------------------------------------------------------- /snapshots/chvsacd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/chvsacd.png -------------------------------------------------------------------------------- /snapshots/ecdvsacd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/ecdvsacd.png -------------------------------------------------------------------------------- /snapshots/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/logo.png -------------------------------------------------------------------------------- /snapshots/snapshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/snapshots.png -------------------------------------------------------------------------------- /snapshots/snapshots_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/snapshots_1.png -------------------------------------------------------------------------------- /snapshots/snapshots_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/snapshots_2.png -------------------------------------------------------------------------------- /snapshots/snapshots_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/snapshots_3.png -------------------------------------------------------------------------------- /snapshots/snapshots_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/snapshots_4.png -------------------------------------------------------------------------------- /snapshots/snapshots_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/VHACD/854b3d820901804c338365c63f067ad7f1c4b9c0/snapshots/snapshots_5.png -------------------------------------------------------------------------------- /src/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake.configureOnOpen": true, 3 | "C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools" 4 | } -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) 2 | project(VHACD) 3 | option(NO_OPENCL "NO_OPENCL" OFF) 4 | option(NO_OPENMP "NO_OPENMP" OFF) 5 | 6 | message("NO_OPENCL " ${NO_OPENCL}) 7 | message("NO_OPENMP " ${NO_OPENMP}) 8 | 9 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 10 | 11 | #set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 12 | set(CompilerFlags 13 | CMAKE_CXX_FLAGS 14 | CMAKE_CXX_FLAGS_DEBUG 15 | CMAKE_CXX_FLAGS_RELEASE 16 | CMAKE_CXX_FLAGS_MINSIZEREL 17 | CMAKE_CXX_FLAGS_RELWITHDEBINFO 18 | CMAKE_C_FLAGS 19 | CMAKE_C_FLAGS_DEBUG 20 | CMAKE_C_FLAGS_RELEASE 21 | CMAKE_C_FLAGS_MINSIZEREL 22 | CMAKE_C_FLAGS_RELWITHDEBINFO 23 | ) 24 | foreach(CompilerFlag ${CompilerFlags}) 25 | string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") 26 | set(${CompilerFlag} "${${CompilerFlag}}" CACHE STRING "msvc compiler flags" FORCE) 27 | message("MSVC flags: ${CompilerFlag}:${${CompilerFlag}}") 28 | endforeach() 29 | 30 | #set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/output" CACHE PATH "project install prefix" FORCE) 31 | set(CMAKE_COMMON_INC "${CMAKE_SOURCE_DIR}/../scripts/cmake_common.cmake") 32 | add_subdirectory ("${CMAKE_SOURCE_DIR}/VHACD_Lib") 33 | add_subdirectory ("${CMAKE_SOURCE_DIR}/test") 34 | add_subdirectory ("${CMAKE_SOURCE_DIR}/dll") 35 | -------------------------------------------------------------------------------- /src/VHACD_Lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(VHACD_LIB CXX C) 2 | include(${CMAKE_COMMON_INC}) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | if (NOT NO_OPENCL) 7 | #include(FindOpenCL OPTIONAL) 8 | find_package(OpenCL) 9 | endif() 10 | if (NOT NO_OPENMP) 11 | #include(FindOpenMP OPTIONAL) 12 | find_package(OpenMP) 13 | endif() 14 | if(OPENMP_FOUND) 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 17 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 18 | endif() 19 | set(LIB_TYPE "STATIC" CACHE STRING "STATIC, SHARED or MODULE?") 20 | message("[VHACD] \t LIB_TYPE " ${LIB_TYPE}) 21 | add_library(vhacd ${LIB_TYPE} ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES} ${PROJECT_CL_FILES}) 22 | 23 | if (OpenCL_FOUND) 24 | target_include_directories(vhacd PRIVATE "${OpenCL_INCLUDE_DIR}") 25 | target_link_libraries(vhacd PRIVATE "${OpenCL_LIBRARY}") 26 | target_compile_definitions(vhacd PRIVATE -DOPENCL_FOUND=1 ) 27 | target_compile_definitions(vhacd PRIVATE -DOPENCL_CL_FILES="${PROJECT_CL_FILES}" ) 28 | endif() 29 | 30 | 31 | target_include_directories(vhacd PUBLIC 32 | $ 33 | $ # /include/mylib 34 | ) 35 | 36 | 37 | message("[VHACD] \t -> CMAKE_INSTALL_PREFIX " ${CMAKE_INSTALL_PREFIX}) 38 | install(TARGETS vhacd EXPORT vhacd-targets DESTINATION lib) 39 | install(FILES ${PROJECT_INC_FILES} DESTINATION include) 40 | install(FILES ${PROJECT_INL_FILES} DESTINATION include) 41 | 42 | 43 | set(VHACD_LIB_VERSION 3.2.0) 44 | include(CMakePackageConfigHelpers) 45 | write_basic_package_version_file( 46 | "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config-version.cmake" 47 | VERSION ${VHACD_LIB_VERSION} 48 | COMPATIBILITY AnyNewerVersion 49 | ) 50 | 51 | export(EXPORT vhacd-targets NAMESPACE :: 52 | FILE "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-targets.cmake" 53 | ) 54 | 55 | configure_file(cmake/vhacd-config.cmake 56 | "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config.cmake" 57 | COPYONLY 58 | ) 59 | 60 | set(ConfigPackageLocation lib/cmake/vhacd) 61 | install(EXPORT vhacd-targets 62 | FILE 63 | vhacd-targets.cmake 64 | DESTINATION 65 | ${ConfigPackageLocation} 66 | NAMESPACE :: 67 | ) 68 | install( 69 | FILES 70 | "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config.cmake" 71 | "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config-version.cmake" 72 | DESTINATION 73 | ${ConfigPackageLocation} 74 | COMPONENT 75 | Devel 76 | ) 77 | 78 | -------------------------------------------------------------------------------- /src/VHACD_Lib/cl/vhacdKernels.cl: -------------------------------------------------------------------------------- 1 | __kernel void ComputePartialVolumes(__global short4 * voxels, 2 | const int numVoxels, 3 | const float4 plane, 4 | const float4 minBB, 5 | const float4 scale, 6 | __local uint4 * localPartialVolumes, 7 | __global uint4 * partialVolumes) 8 | { 9 | int localId = get_local_id(0); 10 | int groupSize = get_local_size(0); 11 | int i0 = get_global_id(0) << 2; 12 | float4 voxel; 13 | uint4 v; 14 | 15 | voxel = convert_float4(voxels[i0]); 16 | v.s0 = (dot(plane, mad(scale, voxel, minBB)) >= 0.0f) * (i0 < numVoxels); 17 | voxel = convert_float4(voxels[i0 + 1]); 18 | v.s1 = (dot(plane, mad(scale, voxel, minBB)) >= 0.0f) * (i0 + 1 < numVoxels); 19 | voxel = convert_float4(voxels[i0 + 2]); 20 | v.s2 = (dot(plane, mad(scale, voxel, minBB)) >= 0.0f) * (i0 + 2 < numVoxels); 21 | voxel = convert_float4(voxels[i0 + 3]); 22 | v.s3 = (dot(plane, mad(scale, voxel, minBB)) >= 0.0f) * (i0 + 3 < numVoxels); 23 | 24 | localPartialVolumes[localId] = v; 25 | barrier(CLK_LOCAL_MEM_FENCE); 26 | 27 | for (int i = groupSize >> 1; i > 0; i >>= 1) 28 | { 29 | if (localId < i) 30 | { 31 | localPartialVolumes[localId] += localPartialVolumes[localId + i]; 32 | } 33 | barrier(CLK_LOCAL_MEM_FENCE); 34 | } 35 | if (localId == 0) 36 | { 37 | partialVolumes[get_group_id(0)] = localPartialVolumes[0]; 38 | } 39 | } 40 | __kernel void ComputePartialSums(__global uint4 * data, 41 | const int dataSize, 42 | __local uint4 * partialSums) 43 | { 44 | 45 | int globalId = get_global_id(0); 46 | int localId = get_local_id(0); 47 | int groupSize = get_local_size(0); 48 | int i; 49 | if (globalId < dataSize) 50 | { 51 | partialSums[localId] = data[globalId]; 52 | } 53 | else 54 | { 55 | partialSums[localId] = (0, 0, 0, 0); 56 | } 57 | barrier(CLK_LOCAL_MEM_FENCE); 58 | for (i = groupSize >> 1; i > 0; i >>= 1) 59 | { 60 | if (localId < i) 61 | { 62 | partialSums[localId] += partialSums[localId + i]; 63 | } 64 | barrier(CLK_LOCAL_MEM_FENCE); 65 | } 66 | if (localId == 0) 67 | { 68 | data[get_group_id(0)] = partialSums[0]; 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/VHACD_Lib/cmake/vhacd-config.cmake: -------------------------------------------------------------------------------- 1 | 2 | find_package(OpenCL) 3 | find_package(OpenMP) 4 | include("${CMAKE_CURRENT_LIST_DIR}/vhacd-targets.cmake") -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/btAlignedAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Bullet Continuous Collision Detection and Physics Library 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ 4 | 5 | This software is provided 'as-is', without any express or implied warranty. 6 | In no event will the authors be held liable for any damages arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it freely, 9 | subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 | 3. This notice may not be removed or altered from any source distribution. 14 | */ 15 | 16 | #ifndef BT_ALIGNED_ALLOCATOR 17 | #define BT_ALIGNED_ALLOCATOR 18 | 19 | ///we probably replace this with our own aligned memory allocator 20 | ///so we replace _aligned_malloc and _aligned_free with our own 21 | ///that is better portable and more predictable 22 | 23 | #include "btScalar.h" 24 | //#define BT_DEBUG_MEMORY_ALLOCATIONS 1 25 | #ifdef BT_DEBUG_MEMORY_ALLOCATIONS 26 | 27 | #define btAlignedAlloc(a, b) \ 28 | btAlignedAllocInternal(a, b, __LINE__, __FILE__) 29 | 30 | #define btAlignedFree(ptr) \ 31 | btAlignedFreeInternal(ptr, __LINE__, __FILE__) 32 | 33 | void* btAlignedAllocInternal(size_t size, int32_t alignment, int32_t line, char* filename); 34 | 35 | void btAlignedFreeInternal(void* ptr, int32_t line, char* filename); 36 | 37 | #else 38 | void* btAlignedAllocInternal(size_t size, int32_t alignment); 39 | void btAlignedFreeInternal(void* ptr); 40 | 41 | #define btAlignedAlloc(size, alignment) btAlignedAllocInternal(size, alignment) 42 | #define btAlignedFree(ptr) btAlignedFreeInternal(ptr) 43 | 44 | #endif 45 | typedef int32_t size_type; 46 | 47 | typedef void*(btAlignedAllocFunc)(size_t size, int32_t alignment); 48 | typedef void(btAlignedFreeFunc)(void* memblock); 49 | typedef void*(btAllocFunc)(size_t size); 50 | typedef void(btFreeFunc)(void* memblock); 51 | 52 | ///The developer can let all Bullet memory allocations go through a custom memory allocator, using btAlignedAllocSetCustom 53 | void btAlignedAllocSetCustom(btAllocFunc* allocFunc, btFreeFunc* freeFunc); 54 | ///If the developer has already an custom aligned allocator, then btAlignedAllocSetCustomAligned can be used. The default aligned allocator pre-allocates extra memory using the non-aligned allocator, and instruments it. 55 | void btAlignedAllocSetCustomAligned(btAlignedAllocFunc* allocFunc, btAlignedFreeFunc* freeFunc); 56 | 57 | ///The btAlignedAllocator is a portable class for aligned memory allocations. 58 | ///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using btAlignedAllocSetCustom and btAlignedAllocSetCustomAligned. 59 | template 60 | class btAlignedAllocator { 61 | 62 | typedef btAlignedAllocator self_type; 63 | 64 | public: 65 | //just going down a list: 66 | btAlignedAllocator() {} 67 | /* 68 | btAlignedAllocator( const self_type & ) {} 69 | */ 70 | 71 | template 72 | btAlignedAllocator(const btAlignedAllocator&) {} 73 | 74 | typedef const T* const_pointer; 75 | typedef const T& const_reference; 76 | typedef T* pointer; 77 | typedef T& reference; 78 | typedef T value_type; 79 | 80 | pointer address(reference ref) const { return &ref; } 81 | const_pointer address(const_reference ref) const { return &ref; } 82 | pointer allocate(size_type n, const_pointer* hint = 0) 83 | { 84 | (void)hint; 85 | return reinterpret_cast(btAlignedAlloc(sizeof(value_type) * n, Alignment)); 86 | } 87 | void construct(pointer ptr, const value_type& value) { new (ptr) value_type(value); } 88 | void deallocate(pointer ptr) 89 | { 90 | btAlignedFree(reinterpret_cast(ptr)); 91 | } 92 | void destroy(pointer ptr) { ptr->~value_type(); } 93 | 94 | template 95 | struct rebind { 96 | typedef btAlignedAllocator other; 97 | }; 98 | template 99 | self_type& operator=(const btAlignedAllocator&) { return *this; } 100 | 101 | friend bool operator==(const self_type&, const self_type&) { return true; } 102 | }; 103 | 104 | #endif //BT_ALIGNED_ALLOCATOR 105 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/btConvexHullComputer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net 3 | 4 | This software is provided 'as-is', without any express or implied warranty. 5 | In no event will the authors be held liable for any damages arising from the use of this software. 6 | Permission is granted to anyone to use this software for any purpose, 7 | including commercial applications, and to alter it and redistribute it freely, 8 | subject to the following restrictions: 9 | 10 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 11 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 12 | 3. This notice may not be removed or altered from any source distribution. 13 | */ 14 | 15 | #ifndef BT_CONVEX_HULL_COMPUTER_H 16 | #define BT_CONVEX_HULL_COMPUTER_H 17 | 18 | #include "btAlignedObjectArray.h" 19 | #include "btVector3.h" 20 | 21 | /// Convex hull implementation based on Preparata and Hong 22 | /// See http://code.google.com/p/bullet/issues/detail?id=275 23 | /// Ole Kniemeyer, MAXON Computer GmbH 24 | class btConvexHullComputer { 25 | private: 26 | btScalar compute(const void* coords, bool doubleCoords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp); 27 | 28 | public: 29 | class Edge { 30 | private: 31 | int32_t next; 32 | int32_t reverse; 33 | int32_t targetVertex; 34 | 35 | friend class btConvexHullComputer; 36 | 37 | public: 38 | int32_t getSourceVertex() const 39 | { 40 | return (this + reverse)->targetVertex; 41 | } 42 | 43 | int32_t getTargetVertex() const 44 | { 45 | return targetVertex; 46 | } 47 | 48 | const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex 49 | { 50 | return this + next; 51 | } 52 | 53 | const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face 54 | { 55 | return (this + reverse)->getNextEdgeOfVertex(); 56 | } 57 | 58 | const Edge* getReverseEdge() const 59 | { 60 | return this + reverse; 61 | } 62 | }; 63 | 64 | // Vertices of the output hull 65 | btAlignedObjectArray vertices; 66 | 67 | // Edges of the output hull 68 | btAlignedObjectArray edges; 69 | 70 | // Faces of the convex hull. Each entry is an index into the "edges" array pointing to an edge of the face. Faces are planar n-gons 71 | btAlignedObjectArray faces; 72 | 73 | /* 74 | Compute convex hull of "count" vertices stored in "coords". "stride" is the difference in bytes 75 | between the addresses of consecutive vertices. If "shrink" is positive, the convex hull is shrunken 76 | by that amount (each face is moved by "shrink" length units towards the center along its normal). 77 | If "shrinkClamp" is positive, "shrink" is clamped to not exceed "shrinkClamp * innerRadius", where "innerRadius" 78 | is the minimum distance of a face to the center of the convex hull. 79 | 80 | The returned value is the amount by which the hull has been shrunken. If it is negative, the amount was so large 81 | that the resulting convex hull is empty. 82 | 83 | The output convex hull can be found in the member variables "vertices", "edges", "faces". 84 | */ 85 | btScalar compute(const float* coords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp) 86 | { 87 | return compute(coords, false, stride, count, shrink, shrinkClamp); 88 | } 89 | 90 | // same as above, but double precision 91 | btScalar compute(const double* coords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp) 92 | { 93 | return compute(coords, true, stride, count, shrink, shrinkClamp); 94 | } 95 | }; 96 | 97 | #endif //BT_CONVEX_HULL_COMPUTER_H 98 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/btMinMax.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ 3 | 4 | This software is provided 'as-is', without any express or implied warranty. 5 | In no event will the authors be held liable for any damages arising from the use of this software. 6 | Permission is granted to anyone to use this software for any purpose, 7 | including commercial applications, and to alter it and redistribute it freely, 8 | subject to the following restrictions: 9 | 10 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 11 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 12 | 3. This notice may not be removed or altered from any source distribution. 13 | */ 14 | 15 | #ifndef BT_GEN_MINMAX_H 16 | #define BT_GEN_MINMAX_H 17 | 18 | #include "btScalar.h" 19 | 20 | template 21 | SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) 22 | { 23 | return a < b ? a : b; 24 | } 25 | 26 | template 27 | SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) 28 | { 29 | return a > b ? a : b; 30 | } 31 | 32 | template 33 | SIMD_FORCE_INLINE const T& btClamped(const T& a, const T& lb, const T& ub) 34 | { 35 | return a < lb ? lb : (ub < a ? ub : a); 36 | } 37 | 38 | template 39 | SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) 40 | { 41 | if (b < a) { 42 | a = b; 43 | } 44 | } 45 | 46 | template 47 | SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) 48 | { 49 | if (a < b) { 50 | a = b; 51 | } 52 | } 53 | 54 | template 55 | SIMD_FORCE_INLINE void btClamp(T& a, const T& lb, const T& ub) 56 | { 57 | if (a < lb) { 58 | a = lb; 59 | } 60 | else if (ub < a) { 61 | a = ub; 62 | } 63 | } 64 | 65 | #endif //BT_GEN_MINMAX_H 66 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdCircularList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_CIRCULAR_LIST_H 17 | #define VHACD_CIRCULAR_LIST_H 18 | #include 19 | namespace VHACD { 20 | //! CircularListElement class. 21 | template 22 | class CircularListElement { 23 | public: 24 | T& GetData() { return m_data; } 25 | const T& GetData() const { return m_data; } 26 | CircularListElement*& GetNext() { return m_next; } 27 | CircularListElement*& GetPrev() { return m_prev; } 28 | const CircularListElement*& GetNext() const { return m_next; } 29 | const CircularListElement*& GetPrev() const { return m_prev; } 30 | //! Constructor 31 | CircularListElement(const T& data) { m_data = data; } 32 | CircularListElement(void) {} 33 | //! Destructor 34 | ~CircularListElement(void) {} 35 | private: 36 | T m_data; 37 | CircularListElement* m_next; 38 | CircularListElement* m_prev; 39 | 40 | CircularListElement(const CircularListElement& rhs); 41 | }; 42 | //! CircularList class. 43 | template 44 | class CircularList { 45 | public: 46 | CircularListElement*& GetHead() { return m_head; } 47 | const CircularListElement* GetHead() const { return m_head; } 48 | bool IsEmpty() const { return (m_size == 0); } 49 | size_t GetSize() const { return m_size; } 50 | const T& GetData() const { return m_head->GetData(); } 51 | T& GetData() { return m_head->GetData(); } 52 | bool Delete(); 53 | bool Delete(CircularListElement* element); 54 | CircularListElement* Add(const T* data = 0); 55 | CircularListElement* Add(const T& data); 56 | bool Next(); 57 | bool Prev(); 58 | void Clear() 59 | { 60 | while (Delete()) 61 | ; 62 | }; 63 | const CircularList& operator=(const CircularList& rhs); 64 | //! Constructor 65 | CircularList() 66 | { 67 | m_head = 0; 68 | m_size = 0; 69 | } 70 | CircularList(const CircularList& rhs); 71 | //! Destructor 72 | ~CircularList(void) { Clear(); }; 73 | private: 74 | CircularListElement* m_head; //!< a pointer to the head of the circular list 75 | size_t m_size; //!< number of element in the circular list 76 | }; 77 | } 78 | #include "vhacdCircularList.inl" 79 | #endif // VHACD_CIRCULAR_LIST_H -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdCircularList.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef HACD_CIRCULAR_LIST_INL 3 | #define HACD_CIRCULAR_LIST_INL 4 | namespace VHACD 5 | { 6 | template < typename T > 7 | inline bool CircularList::Delete(CircularListElement * element) 8 | { 9 | if (!element) 10 | { 11 | return false; 12 | } 13 | if (m_size > 1) 14 | { 15 | CircularListElement * next = element->GetNext(); 16 | CircularListElement * prev = element->GetPrev(); 17 | delete element; 18 | m_size--; 19 | if (element == m_head) 20 | { 21 | m_head = next; 22 | } 23 | next->GetPrev() = prev; 24 | prev->GetNext() = next; 25 | return true; 26 | } 27 | else if (m_size == 1) 28 | { 29 | delete m_head; 30 | m_size--; 31 | m_head = 0; 32 | return true; 33 | } 34 | else 35 | { 36 | return false; 37 | } 38 | } 39 | 40 | template < typename T > 41 | inline bool CircularList::Delete() 42 | { 43 | if (m_size > 1) 44 | { 45 | CircularListElement * next = m_head->GetNext(); 46 | CircularListElement * prev = m_head->GetPrev(); 47 | delete m_head; 48 | m_size--; 49 | m_head = next; 50 | next->GetPrev() = prev; 51 | prev->GetNext() = next; 52 | return true; 53 | } 54 | else if (m_size == 1) 55 | { 56 | delete m_head; 57 | m_size--; 58 | m_head = 0; 59 | return true; 60 | } 61 | else 62 | { 63 | return false; 64 | } 65 | } 66 | template < typename T > 67 | inline CircularListElement * CircularList::Add(const T * data) 68 | { 69 | if (m_size == 0) 70 | { 71 | if (data) 72 | { 73 | m_head = new CircularListElement(*data); 74 | } 75 | else 76 | { 77 | m_head = new CircularListElement(); 78 | } 79 | m_head->GetNext() = m_head->GetPrev() = m_head; 80 | } 81 | else 82 | { 83 | CircularListElement * next = m_head->GetNext(); 84 | CircularListElement * element = m_head; 85 | if (data) 86 | { 87 | m_head = new CircularListElement(*data); 88 | } 89 | else 90 | { 91 | m_head = new CircularListElement(); 92 | } 93 | m_head->GetNext() = next; 94 | m_head->GetPrev() = element; 95 | element->GetNext() = m_head; 96 | next->GetPrev() = m_head; 97 | } 98 | m_size++; 99 | return m_head; 100 | } 101 | template < typename T > 102 | inline CircularListElement * CircularList::Add(const T & data) 103 | { 104 | const T * pData = &data; 105 | return Add(pData); 106 | } 107 | template < typename T > 108 | inline bool CircularList::Next() 109 | { 110 | if (m_size == 0) 111 | { 112 | return false; 113 | } 114 | m_head = m_head->GetNext(); 115 | return true; 116 | } 117 | template < typename T > 118 | inline bool CircularList::Prev() 119 | { 120 | if (m_size == 0) 121 | { 122 | return false; 123 | } 124 | m_head = m_head->GetPrev(); 125 | return true; 126 | } 127 | template < typename T > 128 | inline CircularList::CircularList(const CircularList& rhs) 129 | { 130 | if (rhs.m_size > 0) 131 | { 132 | CircularListElement * current = rhs.m_head; 133 | do 134 | { 135 | current = current->GetNext(); 136 | Add(current->GetData()); 137 | } 138 | while ( current != rhs.m_head ); 139 | } 140 | } 141 | template < typename T > 142 | inline const CircularList& CircularList::operator=(const CircularList& rhs) 143 | { 144 | if (&rhs != this) 145 | { 146 | Clear(); 147 | if (rhs.m_size > 0) 148 | { 149 | CircularListElement * current = rhs.m_head; 150 | do 151 | { 152 | current = current->GetNext(); 153 | Add(current->GetData()); 154 | } 155 | while ( current != rhs.m_head ); 156 | } 157 | } 158 | return (*this); 159 | } 160 | } 161 | #endif -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdICHull.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_ICHULL_H 17 | #define VHACD_ICHULL_H 18 | #include "vhacdManifoldMesh.h" 19 | #include "vhacdVector.h" 20 | 21 | namespace VHACD { 22 | //! Incremental Convex Hull algorithm (cf. http://cs.smith.edu/~orourke/books/ftp.html ). 23 | enum ICHullError { 24 | ICHullErrorOK = 0, 25 | ICHullErrorCoplanarPoints, 26 | ICHullErrorNoVolume, 27 | ICHullErrorInconsistent, 28 | ICHullErrorNotEnoughPoints 29 | }; 30 | class ICHull { 31 | public: 32 | static const double sc_eps; 33 | //! 34 | bool IsFlat() { return m_isFlat; } 35 | //! Returns the computed mesh 36 | TMMesh& GetMesh() { return m_mesh; } 37 | //! Add one point to the convex-hull 38 | bool AddPoint(const Vec3& point) { return AddPoints(&point, 1); } 39 | //! Add one point to the convex-hull 40 | bool AddPoint(const Vec3& point, int32_t id); 41 | //! Add points to the convex-hull 42 | bool AddPoints(const Vec3* points, size_t nPoints); 43 | //! 44 | ICHullError Process(); 45 | //! 46 | ICHullError Process(const uint32_t nPointsCH, const double minVolume = 0.0); 47 | //! 48 | bool IsInside(const Vec3& pt0, const double eps = 0.0); 49 | //! 50 | const ICHull& operator=(ICHull& rhs); 51 | 52 | //! Constructor 53 | ICHull(); 54 | //! Destructor 55 | ~ICHull(void){}; 56 | 57 | private: 58 | //! DoubleTriangle builds the initial double triangle. It first finds 3 noncollinear points and makes two faces out of them, in opposite order. It then finds a fourth point that is not coplanar with that face. The vertices are stored in the face structure in counterclockwise order so that the volume between the face and the point is negative. Lastly, the 3 newfaces to the fourth point are constructed and the data structures are cleaned up. 59 | ICHullError DoubleTriangle(); 60 | //! MakeFace creates a new face structure from three vertices (in ccw order). It returns a pointer to the face. 61 | CircularListElement* MakeFace(CircularListElement* v0, 62 | CircularListElement* v1, 63 | CircularListElement* v2, 64 | CircularListElement* fold); 65 | //! 66 | CircularListElement* MakeConeFace(CircularListElement* e, CircularListElement* v); 67 | //! 68 | bool ProcessPoint(); 69 | //! 70 | bool ComputePointVolume(double& totalVolume, bool markVisibleFaces); 71 | //! 72 | bool FindMaxVolumePoint(const double minVolume = 0.0); 73 | //! 74 | bool CleanEdges(); 75 | //! 76 | bool CleanVertices(uint32_t& addedPoints); 77 | //! 78 | bool CleanTriangles(); 79 | //! 80 | bool CleanUp(uint32_t& addedPoints); 81 | //! 82 | bool MakeCCW(CircularListElement* f, 83 | CircularListElement* e, 84 | CircularListElement* v); 85 | void Clear(); 86 | 87 | private: 88 | static const int32_t sc_dummyIndex; 89 | TMMesh m_mesh; 90 | SArray*> m_edgesToDelete; 91 | SArray*> m_edgesToUpdate; 92 | SArray*> m_trianglesToDelete; 93 | Vec3 m_normal; 94 | bool m_isFlat; 95 | ICHull(const ICHull& rhs); 96 | }; 97 | } 98 | #endif // VHACD_ICHULL_H 99 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdManifoldMesh.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_MANIFOLD_MESH_H 17 | #define VHACD_MANIFOLD_MESH_H 18 | #include "vhacdCircularList.h" 19 | #include "vhacdSArray.h" 20 | #include "vhacdVector.h" 21 | namespace VHACD { 22 | class TMMTriangle; 23 | class TMMEdge; 24 | class TMMesh; 25 | class ICHull; 26 | 27 | //! Vertex data structure used in a triangular manifold mesh (TMM). 28 | class TMMVertex { 29 | public: 30 | void Initialize(); 31 | TMMVertex(void); 32 | ~TMMVertex(void); 33 | 34 | private: 35 | Vec3 m_pos; 36 | int32_t m_name; 37 | size_t m_id; 38 | CircularListElement* m_duplicate; // pointer to incident cone edge (or NULL) 39 | bool m_onHull; 40 | bool m_tag; 41 | TMMVertex(const TMMVertex& rhs); 42 | friend class ICHull; 43 | friend class TMMesh; 44 | friend class TMMTriangle; 45 | friend class TMMEdge; 46 | }; 47 | 48 | //! Edge data structure used in a triangular manifold mesh (TMM). 49 | class TMMEdge { 50 | public: 51 | void Initialize(); 52 | TMMEdge(void); 53 | ~TMMEdge(void); 54 | 55 | private: 56 | size_t m_id; 57 | CircularListElement* m_triangles[2]; 58 | CircularListElement* m_vertices[2]; 59 | CircularListElement* m_newFace; 60 | TMMEdge(const TMMEdge& rhs); 61 | friend class ICHull; 62 | friend class TMMTriangle; 63 | friend class TMMVertex; 64 | friend class TMMesh; 65 | }; 66 | 67 | //! Triangle data structure used in a triangular manifold mesh (TMM). 68 | class TMMTriangle { 69 | public: 70 | void Initialize(); 71 | TMMTriangle(void); 72 | ~TMMTriangle(void); 73 | 74 | private: 75 | size_t m_id; 76 | CircularListElement* m_edges[3]; 77 | CircularListElement* m_vertices[3]; 78 | bool m_visible; 79 | 80 | TMMTriangle(const TMMTriangle& rhs); 81 | friend class ICHull; 82 | friend class TMMesh; 83 | friend class TMMVertex; 84 | friend class TMMEdge; 85 | }; 86 | //! triangular manifold mesh data structure. 87 | class TMMesh { 88 | public: 89 | //! Returns the number of vertices> 90 | inline size_t GetNVertices() const { return m_vertices.GetSize(); } 91 | //! Returns the number of edges 92 | inline size_t GetNEdges() const { return m_edges.GetSize(); } 93 | //! Returns the number of triangles 94 | inline size_t GetNTriangles() const { return m_triangles.GetSize(); } 95 | //! Returns the vertices circular list 96 | inline const CircularList& GetVertices() const { return m_vertices; } 97 | //! Returns the edges circular list 98 | inline const CircularList& GetEdges() const { return m_edges; } 99 | //! Returns the triangles circular list 100 | inline const CircularList& GetTriangles() const { return m_triangles; } 101 | //! Returns the vertices circular list 102 | inline CircularList& GetVertices() { return m_vertices; } 103 | //! Returns the edges circular list 104 | inline CircularList& GetEdges() { return m_edges; } 105 | //! Returns the triangles circular list 106 | inline CircularList& GetTriangles() { return m_triangles; } 107 | //! Add vertex to the mesh 108 | CircularListElement* AddVertex() { return m_vertices.Add(); } 109 | //! Add vertex to the mesh 110 | CircularListElement* AddEdge() { return m_edges.Add(); } 111 | //! Add vertex to the mesh 112 | CircularListElement* AddTriangle() { return m_triangles.Add(); } 113 | //! Print mesh information 114 | void Print(); 115 | //! 116 | void GetIFS(Vec3* const points, Vec3* const triangles); 117 | //! 118 | void Clear(); 119 | //! 120 | void Copy(TMMesh& mesh); 121 | //! 122 | bool CheckConsistancy(); 123 | //! 124 | bool Normalize(); 125 | //! 126 | bool Denormalize(); 127 | //! Constructor 128 | TMMesh(); 129 | //! Destructor 130 | virtual ~TMMesh(void); 131 | 132 | private: 133 | CircularList m_vertices; 134 | CircularList m_edges; 135 | CircularList m_triangles; 136 | 137 | // not defined 138 | TMMesh(const TMMesh& rhs); 139 | friend class ICHull; 140 | }; 141 | } 142 | #endif // VHACD_MANIFOLD_MESH_H -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdMesh.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_MESH_H 17 | #define VHACD_MESH_H 18 | #include "vhacdSArray.h" 19 | #include "vhacdVector.h" 20 | 21 | #define VHACD_DEBUG_MESH 22 | 23 | namespace VHACD { 24 | enum AXIS { 25 | AXIS_X = 0, 26 | AXIS_Y = 1, 27 | AXIS_Z = 2 28 | }; 29 | struct Plane { 30 | double m_a; 31 | double m_b; 32 | double m_c; 33 | double m_d; 34 | AXIS m_axis; 35 | short m_index; 36 | }; 37 | #ifdef VHACD_DEBUG_MESH 38 | struct Material { 39 | 40 | Vec3 m_diffuseColor; 41 | double m_ambientIntensity; 42 | Vec3 m_specularColor; 43 | Vec3 m_emissiveColor; 44 | double m_shininess; 45 | double m_transparency; 46 | Material(void) 47 | { 48 | m_diffuseColor.X() = 0.5; 49 | m_diffuseColor.Y() = 0.5; 50 | m_diffuseColor.Z() = 0.5; 51 | m_specularColor.X() = 0.5; 52 | m_specularColor.Y() = 0.5; 53 | m_specularColor.Z() = 0.5; 54 | m_ambientIntensity = 0.4; 55 | m_emissiveColor.X() = 0.0; 56 | m_emissiveColor.Y() = 0.0; 57 | m_emissiveColor.Z() = 0.0; 58 | m_shininess = 0.4; 59 | m_transparency = 0.0; 60 | }; 61 | }; 62 | #endif // VHACD_DEBUG_MESH 63 | 64 | //! Triangular mesh data structure 65 | class Mesh { 66 | public: 67 | void AddPoint(const Vec3& pt) { m_points.PushBack(pt); }; 68 | void SetPoint(size_t index, const Vec3& pt) { m_points[index] = pt; }; 69 | const Vec3& GetPoint(size_t index) const { return m_points[index]; }; 70 | Vec3& GetPoint(size_t index) { return m_points[index]; }; 71 | size_t GetNPoints() const { return m_points.Size(); }; 72 | double* GetPoints() { return (double*)m_points.Data(); } // ugly 73 | const double* const GetPoints() const { return (double*)m_points.Data(); } // ugly 74 | const Vec3* const GetPointsBuffer() const { return m_points.Data(); } // 75 | Vec3* const GetPointsBuffer() { return m_points.Data(); } // 76 | void AddTriangle(const Vec3& tri) { m_triangles.PushBack(tri); }; 77 | void SetTriangle(size_t index, const Vec3& tri) { m_triangles[index] = tri; }; 78 | const Vec3& GetTriangle(size_t index) const { return m_triangles[index]; }; 79 | Vec3& GetTriangle(size_t index) { return m_triangles[index]; }; 80 | size_t GetNTriangles() const { return m_triangles.Size(); }; 81 | int32_t* GetTriangles() { return (int32_t*)m_triangles.Data(); } // ugly 82 | const int32_t* const GetTriangles() const { return (int32_t*)m_triangles.Data(); } // ugly 83 | const Vec3* const GetTrianglesBuffer() const { return m_triangles.Data(); } 84 | Vec3* const GetTrianglesBuffer() { return m_triangles.Data(); } 85 | const Vec3& GetCenter() const { return m_center; } 86 | const Vec3& GetMinBB() const { return m_minBB; } 87 | const Vec3& GetMaxBB() const { return m_maxBB; } 88 | void ClearPoints() { m_points.Clear(); } 89 | void ClearTriangles() { m_triangles.Clear(); } 90 | void Clear() 91 | { 92 | ClearPoints(); 93 | ClearTriangles(); 94 | } 95 | void ResizePoints(size_t nPts) { m_points.Resize(nPts); } 96 | void ResizeTriangles(size_t nTri) { m_triangles.Resize(nTri); } 97 | void CopyPoints(SArray >& points) const { points = m_points; } 98 | double GetDiagBB() const { return m_diag; } 99 | double ComputeVolume() const; 100 | void ComputeConvexHull(const double* const pts, 101 | const size_t nPts); 102 | void Clip(const Plane& plane, 103 | SArray >& positivePart, 104 | SArray >& negativePart) const; 105 | bool IsInside(const Vec3& pt) const; 106 | double ComputeDiagBB(); 107 | Vec3 &ComputeCenter(void); 108 | 109 | #ifdef VHACD_DEBUG_MESH 110 | bool LoadOFF(const std::string& fileName, bool invert); 111 | bool SaveVRML2(const std::string& fileName) const; 112 | bool SaveVRML2(std::ofstream& fout, const Material& material) const; 113 | bool SaveOFF(const std::string& fileName) const; 114 | #endif // VHACD_DEBUG_MESH 115 | 116 | //! Constructor. 117 | Mesh(); 118 | //! Destructor. 119 | ~Mesh(void); 120 | 121 | private: 122 | SArray > m_points; 123 | SArray > m_triangles; 124 | Vec3 m_minBB; 125 | Vec3 m_maxBB; 126 | Vec3 m_center; 127 | double m_diag; 128 | }; 129 | } 130 | #endif -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdMutex.h: -------------------------------------------------------------------------------- 1 | /*! 2 | ** 3 | ** Copyright (c) 2009 by John W. Ratcliff mailto:jratcliffscarab@gmail.com 4 | ** 5 | ** Portions of this source has been released with the PhysXViewer application, as well as 6 | ** Rocket, CreateDynamics, ODF, and as a number of sample code snippets. 7 | ** 8 | ** If you find this code useful or you are feeling particularily generous I would 9 | ** ask that you please go to http://www.amillionpixels.us and make a donation 10 | ** to Troy DeMolay. 11 | ** 12 | ** DeMolay is a youth group for young men between the ages of 12 and 21. 13 | ** It teaches strong moral principles, as well as leadership skills and 14 | ** public speaking. The donations page uses the 'pay for pixels' paradigm 15 | ** where, in this case, a pixel is only a single penny. Donations can be 16 | ** made for as small as $4 or as high as a $100 block. Each person who donates 17 | ** will get a link to their own site as well as acknowledgement on the 18 | ** donations blog located here http://www.amillionpixels.blogspot.com/ 19 | ** 20 | ** If you wish to contact me you can use the following methods: 21 | ** 22 | ** Skype ID: jratcliff63367 23 | ** Yahoo: jratcliff63367 24 | ** AOL: jratcliff1961 25 | ** email: jratcliffscarab@gmail.com 26 | ** 27 | ** 28 | ** The MIT license: 29 | ** 30 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 31 | ** of this software and associated documentation files (the "Software"), to deal 32 | ** in the Software without restriction, including without limitation the rights 33 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 34 | ** copies of the Software, and to permit persons to whom the Software is furnished 35 | ** to do so, subject to the following conditions: 36 | ** 37 | ** The above copyright notice and this permission notice shall be included in all 38 | ** copies or substantial portions of the Software. 39 | 40 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 43 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 44 | ** WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 45 | ** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | 47 | */ 48 | 49 | #pragma once 50 | #ifndef VHACD_MUTEX_H 51 | #define VHACD_MUTEX_H 52 | 53 | #if defined(WIN32) 54 | 55 | #ifndef _WIN32_WINNT 56 | #define _WIN32_WINNT 0x400 57 | #endif 58 | #include 59 | #pragma comment(lib, "winmm.lib") 60 | #endif 61 | 62 | #if defined(__linux__) 63 | //#include 64 | #include 65 | #include 66 | #include 67 | #define __stdcall 68 | #endif 69 | 70 | #if defined(__APPLE__) || defined(__linux__) 71 | #include 72 | #endif 73 | 74 | #if defined(__APPLE__) 75 | #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE 76 | #endif 77 | 78 | #define VHACD_DEBUG 79 | 80 | //#define VHACD_NDEBUG 81 | #ifdef VHACD_NDEBUG 82 | #define VHACD_VERIFY(x) (x) 83 | #else 84 | #define VHACD_VERIFY(x) assert((x)) 85 | #endif 86 | 87 | namespace VHACD { 88 | class Mutex { 89 | public: 90 | Mutex(void) 91 | { 92 | #if defined(WIN32) || defined(_XBOX) 93 | InitializeCriticalSection(&m_mutex); 94 | #elif defined(__APPLE__) || defined(__linux__) 95 | pthread_mutexattr_t mutexAttr; // Mutex Attribute 96 | VHACD_VERIFY(pthread_mutexattr_init(&mutexAttr) == 0); 97 | VHACD_VERIFY(pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0); 98 | VHACD_VERIFY(pthread_mutex_init(&m_mutex, &mutexAttr) == 0); 99 | VHACD_VERIFY(pthread_mutexattr_destroy(&mutexAttr) == 0); 100 | #endif 101 | } 102 | ~Mutex(void) 103 | { 104 | #if defined(WIN32) || defined(_XBOX) 105 | DeleteCriticalSection(&m_mutex); 106 | #elif defined(__APPLE__) || defined(__linux__) 107 | VHACD_VERIFY(pthread_mutex_destroy(&m_mutex) == 0); 108 | #endif 109 | } 110 | void Lock(void) 111 | { 112 | #if defined(WIN32) || defined(_XBOX) 113 | EnterCriticalSection(&m_mutex); 114 | #elif defined(__APPLE__) || defined(__linux__) 115 | VHACD_VERIFY(pthread_mutex_lock(&m_mutex) == 0); 116 | #endif 117 | } 118 | bool TryLock(void) 119 | { 120 | #if defined(WIN32) || defined(_XBOX) 121 | bool bRet = false; 122 | //assert(("TryEnterCriticalSection seems to not work on XP???", 0)); 123 | bRet = TryEnterCriticalSection(&m_mutex) ? true : false; 124 | return bRet; 125 | #elif defined(__APPLE__) || defined(__linux__) 126 | int32_t result = pthread_mutex_trylock(&m_mutex); 127 | return (result == 0); 128 | #endif 129 | } 130 | 131 | void Unlock(void) 132 | { 133 | #if defined(WIN32) || defined(_XBOX) 134 | LeaveCriticalSection(&m_mutex); 135 | #elif defined(__APPLE__) || defined(__linux__) 136 | VHACD_VERIFY(pthread_mutex_unlock(&m_mutex) == 0); 137 | #endif 138 | } 139 | 140 | private: 141 | #if defined(WIN32) || defined(_XBOX) 142 | CRITICAL_SECTION m_mutex; 143 | #elif defined(__APPLE__) || defined(__linux__) 144 | pthread_mutex_t m_mutex; 145 | #endif 146 | }; 147 | } 148 | #endif // VHACD_MUTEX_H 149 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdRaycastMesh.h: -------------------------------------------------------------------------------- 1 | #ifndef RAYCAST_MESH_H 2 | 3 | #define RAYCAST_MESH_H 4 | 5 | #include 6 | 7 | namespace VHACD 8 | { 9 | 10 | // Very simple brute force raycast against a triangle mesh. Tests every triangle; no hierachy. 11 | // Does a deep copy, always does calculations with full double float precision 12 | class RaycastMesh 13 | { 14 | public: 15 | static RaycastMesh * createRaycastMesh(uint32_t vcount, // The number of vertices in the source triangle mesh 16 | const double *vertices, // The array of vertex positions in the format x1,y1,z1..x2,y2,z2.. etc. 17 | uint32_t tcount, // The number of triangles in the source triangle mesh 18 | const uint32_t *indices); // The triangle indices in the format of i1,i2,i3 ... i4,i5,i6, ... 19 | 20 | static RaycastMesh * createRaycastMesh(uint32_t vcount, // The number of vertices in the source triangle mesh 21 | const float *vertices, // The array of vertex positions in the format x1,y1,z1..x2,y2,z2.. etc. 22 | uint32_t tcount, // The number of triangles in the source triangle mesh 23 | const uint32_t *indices); // The triangle indices in the format of i1,i2,i3 ... i4,i5,i6, ... 24 | 25 | 26 | virtual bool raycast(const double *from, // The starting point of the raycast 27 | const double *to, // The ending point of the raycast 28 | const double *closestToPoint, // The point to match the nearest hit location (can just be the 'from' location of no specific point) 29 | double *hitLocation, // The point where the ray hit nearest to the 'closestToPoint' location 30 | double *hitDistance) = 0; // The distance the ray traveled to the hit location 31 | 32 | virtual void release(void) = 0; 33 | protected: 34 | virtual ~RaycastMesh(void) { }; 35 | }; 36 | 37 | } // end of VHACD namespace 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdSArray.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_SARRAY_H 17 | #define VHACD_SARRAY_H 18 | #include 19 | #include 20 | #include 21 | 22 | #define SARRAY_DEFAULT_MIN_SIZE 16 23 | 24 | namespace VHACD { 25 | //! SArray. 26 | template 27 | class SArray { 28 | public: 29 | T& operator[](size_t i) 30 | { 31 | T* const data = Data(); 32 | return data[i]; 33 | } 34 | const T& operator[](size_t i) const 35 | { 36 | const T* const data = Data(); 37 | return data[i]; 38 | } 39 | size_t Size() const 40 | { 41 | return m_size; 42 | } 43 | T* const Data() 44 | { 45 | return (m_maxSize == N) ? m_data0 : m_data; 46 | } 47 | const T* const Data() const 48 | { 49 | return (m_maxSize == N) ? m_data0 : m_data; 50 | } 51 | void Clear() 52 | { 53 | m_size = 0; 54 | delete[] m_data; 55 | m_data = 0; 56 | m_maxSize = N; 57 | } 58 | void PopBack() 59 | { 60 | --m_size; 61 | } 62 | void Allocate(size_t size) 63 | { 64 | if (size > m_maxSize) { 65 | T* temp = new T[size]; 66 | memcpy(temp, Data(), m_size * sizeof(T)); 67 | delete[] m_data; 68 | m_data = temp; 69 | m_maxSize = size; 70 | } 71 | } 72 | void Resize(size_t size) 73 | { 74 | Allocate(size); 75 | m_size = size; 76 | } 77 | 78 | void PushBack(const T& value) 79 | { 80 | if (m_size == m_maxSize) { 81 | size_t maxSize = (m_maxSize << 1); 82 | T* temp = new T[maxSize]; 83 | memcpy(temp, Data(), m_maxSize * sizeof(T)); 84 | delete[] m_data; 85 | m_data = temp; 86 | m_maxSize = maxSize; 87 | } 88 | T* const data = Data(); 89 | data[m_size++] = value; 90 | } 91 | bool Find(const T& value, size_t& pos) 92 | { 93 | T* const data = Data(); 94 | for (pos = 0; pos < m_size; ++pos) 95 | if (value == data[pos]) 96 | return true; 97 | return false; 98 | } 99 | bool Insert(const T& value) 100 | { 101 | size_t pos; 102 | if (Find(value, pos)) 103 | return false; 104 | PushBack(value); 105 | return true; 106 | } 107 | bool Erase(const T& value) 108 | { 109 | size_t pos; 110 | T* const data = Data(); 111 | if (Find(value, pos)) { 112 | for (size_t j = pos + 1; j < m_size; ++j) 113 | data[j - 1] = data[j]; 114 | --m_size; 115 | return true; 116 | } 117 | return false; 118 | } 119 | void operator=(const SArray& rhs) 120 | { 121 | if (m_maxSize < rhs.m_size) { 122 | delete[] m_data; 123 | m_maxSize = rhs.m_maxSize; 124 | m_data = new T[m_maxSize]; 125 | } 126 | m_size = rhs.m_size; 127 | memcpy(Data(), rhs.Data(), m_size * sizeof(T)); 128 | } 129 | void Initialize() 130 | { 131 | m_data = 0; 132 | m_size = 0; 133 | m_maxSize = N; 134 | } 135 | SArray(const SArray& rhs) 136 | { 137 | m_data = 0; 138 | m_size = 0; 139 | m_maxSize = N; 140 | *this = rhs; 141 | } 142 | SArray() 143 | { 144 | Initialize(); 145 | } 146 | ~SArray() 147 | { 148 | delete[] m_data; 149 | } 150 | 151 | private: 152 | T m_data0[N]; 153 | T* m_data; 154 | size_t m_size; 155 | size_t m_maxSize; 156 | }; 157 | } 158 | #endif -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdTimer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_TIMER_H 17 | #define VHACD_TIMER_H 18 | 19 | #ifdef _WIN32 20 | #ifndef WIN32_LEAN_AND_MEAN 21 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 22 | #endif 23 | #include 24 | #elif __MACH__ 25 | #include 26 | #include 27 | #else 28 | #include 29 | #include 30 | #endif 31 | 32 | namespace VHACD { 33 | #ifdef _WIN32 34 | class Timer { 35 | public: 36 | Timer(void) 37 | { 38 | m_start.QuadPart = 0; 39 | m_stop.QuadPart = 0; 40 | QueryPerformanceFrequency(&m_freq); 41 | }; 42 | ~Timer(void){}; 43 | void Tic() 44 | { 45 | QueryPerformanceCounter(&m_start); 46 | } 47 | void Toc() 48 | { 49 | QueryPerformanceCounter(&m_stop); 50 | } 51 | double GetElapsedTime() // in ms 52 | { 53 | LARGE_INTEGER delta; 54 | delta.QuadPart = m_stop.QuadPart - m_start.QuadPart; 55 | return (1000.0 * delta.QuadPart) / (double)m_freq.QuadPart; 56 | } 57 | 58 | private: 59 | LARGE_INTEGER m_start; 60 | LARGE_INTEGER m_stop; 61 | LARGE_INTEGER m_freq; 62 | }; 63 | 64 | #elif __MACH__ 65 | class Timer { 66 | public: 67 | Timer(void) 68 | { 69 | memset(this, 0, sizeof(Timer)); 70 | host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &m_cclock); 71 | }; 72 | ~Timer(void) 73 | { 74 | mach_port_deallocate(mach_task_self(), m_cclock); 75 | }; 76 | void Tic() 77 | { 78 | clock_get_time(m_cclock, &m_start); 79 | } 80 | void Toc() 81 | { 82 | clock_get_time(m_cclock, &m_stop); 83 | } 84 | double GetElapsedTime() // in ms 85 | { 86 | return 1000.0 * (m_stop.tv_sec - m_start.tv_sec + (1.0E-9) * (m_stop.tv_nsec - m_start.tv_nsec)); 87 | } 88 | 89 | private: 90 | clock_serv_t m_cclock; 91 | mach_timespec_t m_start; 92 | mach_timespec_t m_stop; 93 | }; 94 | #else 95 | class Timer { 96 | public: 97 | Timer(void) 98 | { 99 | memset(this, 0, sizeof(Timer)); 100 | }; 101 | ~Timer(void){}; 102 | void Tic() 103 | { 104 | clock_gettime(CLOCK_REALTIME, &m_start); 105 | } 106 | void Toc() 107 | { 108 | clock_gettime(CLOCK_REALTIME, &m_stop); 109 | } 110 | double GetElapsedTime() // in ms 111 | { 112 | return 1000.0 * (m_stop.tv_sec - m_start.tv_sec + (1.0E-9) * (m_stop.tv_nsec - m_start.tv_nsec)); 113 | } 114 | 115 | private: 116 | struct timespec m_start; 117 | struct timespec m_stop; 118 | }; 119 | #endif 120 | } 121 | #endif // VHACD_TIMER_H 122 | -------------------------------------------------------------------------------- /src/VHACD_Lib/inc/vhacdVector.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_VECTOR_H 17 | #define VHACD_VECTOR_H 18 | #include 19 | #include 20 | 21 | namespace VHACD { 22 | //! Vector dim 3. 23 | template 24 | class Vec3 { 25 | public: 26 | T& operator[](size_t i) { return m_data[i]; } 27 | const T& operator[](size_t i) const { return m_data[i]; } 28 | T& X(); 29 | T& Y(); 30 | T& Z(); 31 | const T& X() const; 32 | const T& Y() const; 33 | const T& Z() const; 34 | void Normalize(); 35 | T GetNorm() const; 36 | void operator=(const Vec3& rhs); 37 | void operator+=(const Vec3& rhs); 38 | void operator-=(const Vec3& rhs); 39 | void operator-=(T a); 40 | void operator+=(T a); 41 | void operator/=(T a); 42 | void operator*=(T a); 43 | Vec3 operator^(const Vec3& rhs) const; 44 | T operator*(const Vec3& rhs) const; 45 | Vec3 operator+(const Vec3& rhs) const; 46 | Vec3 operator-(const Vec3& rhs) const; 47 | Vec3 operator-() const; 48 | Vec3 operator*(T rhs) const; 49 | Vec3 operator/(T rhs) const; 50 | bool operator<(const Vec3& rhs) const; 51 | bool operator>(const Vec3& rhs) const; 52 | Vec3(); 53 | Vec3(T a); 54 | Vec3(T x, T y, T z); 55 | Vec3(const Vec3& rhs); 56 | /*virtual*/ ~Vec3(void); 57 | 58 | // Compute the center of this bounding box and return the diagonal length 59 | T GetCenter(const Vec3 &bmin, const Vec3 &bmax) 60 | { 61 | X() = (bmin.X() + bmax.X())*0.5; 62 | Y() = (bmin.Y() + bmax.Y())*0.5; 63 | Z() = (bmin.Z() + bmax.Z())*0.5; 64 | T dx = bmax.X() - bmin.X(); 65 | T dy = bmax.Y() - bmin.Y(); 66 | T dz = bmax.Z() - bmin.Z(); 67 | T diagonal = T(sqrt(dx*dx + dy*dy + dz*dz)); 68 | return diagonal; 69 | } 70 | 71 | // Update the min/max values relative to this point 72 | void UpdateMinMax(Vec3 &bmin,Vec3 &bmax) const 73 | { 74 | if (X() < bmin.X()) 75 | { 76 | bmin.X() = X(); 77 | } 78 | if (Y() < bmin.Y()) 79 | { 80 | bmin.Y() = Y(); 81 | } 82 | if (Z() < bmin.Z()) 83 | { 84 | bmin.Z() = Z(); 85 | } 86 | if (X() > bmax.X()) 87 | { 88 | bmax.X() = X(); 89 | } 90 | if (X() > bmax.X()) 91 | { 92 | bmax.X() = X(); 93 | } 94 | if (Y() > bmax.Y()) 95 | { 96 | bmax.Y() = Y(); 97 | } 98 | if (Z() > bmax.Z()) 99 | { 100 | bmax.Z() = Z(); 101 | } 102 | } 103 | 104 | // Returns the squared distance between these two points 105 | T GetDistanceSquared(const Vec3 &p) const 106 | { 107 | T dx = X() - p.X(); 108 | T dy = Y() - p.Y(); 109 | T dz = Z() - p.Z(); 110 | return dx*dx + dy*dy + dz*dz; 111 | } 112 | 113 | T GetDistance(const Vec3 &p) const 114 | { 115 | return sqrt(GetDistanceSquared(p)); 116 | } 117 | 118 | // Returns the raw vector data as a pointer 119 | T* GetData(void) 120 | { 121 | return m_data; 122 | } 123 | private: 124 | T m_data[3]; 125 | }; 126 | //! Vector dim 2. 127 | template 128 | class Vec2 { 129 | public: 130 | T& operator[](size_t i) { return m_data[i]; } 131 | const T& operator[](size_t i) const { return m_data[i]; } 132 | T& X(); 133 | T& Y(); 134 | const T& X() const; 135 | const T& Y() const; 136 | void Normalize(); 137 | T GetNorm() const; 138 | void operator=(const Vec2& rhs); 139 | void operator+=(const Vec2& rhs); 140 | void operator-=(const Vec2& rhs); 141 | void operator-=(T a); 142 | void operator+=(T a); 143 | void operator/=(T a); 144 | void operator*=(T a); 145 | T operator^(const Vec2& rhs) const; 146 | T operator*(const Vec2& rhs) const; 147 | Vec2 operator+(const Vec2& rhs) const; 148 | Vec2 operator-(const Vec2& rhs) const; 149 | Vec2 operator-() const; 150 | Vec2 operator*(T rhs) const; 151 | Vec2 operator/(T rhs) const; 152 | Vec2(); 153 | Vec2(T a); 154 | Vec2(T x, T y); 155 | Vec2(const Vec2& rhs); 156 | /*virtual*/ ~Vec2(void); 157 | 158 | private: 159 | T m_data[2]; 160 | }; 161 | 162 | template 163 | const bool Colinear(const Vec3& a, const Vec3& b, const Vec3& c); 164 | template 165 | const T ComputeVolume4(const Vec3& a, const Vec3& b, const Vec3& c, const Vec3& d); 166 | } 167 | #include "vhacdVector.inl" // template implementation 168 | #endif -------------------------------------------------------------------------------- /src/VHACD_Lib/public/VHACD.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #pragma once 16 | #ifndef VHACD_H 17 | #define VHACD_H 18 | 19 | #define VHACD_VERSION_MAJOR 2 20 | #define VHACD_VERSION_MINOR 3 21 | 22 | // Changes for version 2.3 23 | // 24 | // m_gamma : Has been removed. This used to control the error metric to merge convex hulls. Now it uses the 'm_maxConvexHulls' value instead. 25 | // m_maxConvexHulls : This is the maximum number of convex hulls to produce from the merge operation; replaces 'm_gamma'. 26 | // 27 | // Note that decomposition depth is no longer a user provided value. It is now derived from the 28 | // maximum number of hulls requested. 29 | // 30 | // As a convenience to the user, each convex hull produced now includes the volume of the hull as well as it's center. 31 | // 32 | // This version supports a convenience method to automatically make V-HACD run asynchronously in a background thread. 33 | // To get a fully asynchronous version, call 'CreateVHACD_ASYNC' instead of 'CreateVHACD'. You get the same interface however, 34 | // now when computing convex hulls, it is no longer a blocking operation. All callback messages are still returned 35 | // in the application's thread so you don't need to worry about mutex locks or anything in that case. 36 | // To tell if the operation is complete, the application should call 'IsReady'. This will return true if 37 | // the last approximation operation is complete and will dispatch any pending messages. 38 | // If you call 'Compute' while a previous operation was still running, it will automatically cancel the last request 39 | // and begin a new one. To cancel a currently running approximation just call 'Cancel'. 40 | #include 41 | 42 | namespace VHACD { 43 | class IVHACD { 44 | public: 45 | class IUserCallback { 46 | public: 47 | virtual ~IUserCallback(){}; 48 | virtual void Update(const double overallProgress, 49 | const double stageProgress, 50 | const double operationProgress, 51 | const char* const stage, 52 | const char* const operation) 53 | = 0; 54 | }; 55 | 56 | class IUserLogger { 57 | public: 58 | virtual ~IUserLogger(){}; 59 | virtual void Log(const char* const msg) = 0; 60 | }; 61 | 62 | class ConvexHull { 63 | public: 64 | double* m_points; 65 | uint32_t* m_triangles; 66 | uint32_t m_nPoints; 67 | uint32_t m_nTriangles; 68 | double m_volume; 69 | double m_center[3]; 70 | }; 71 | 72 | class Parameters { 73 | public: 74 | Parameters(void) { Init(); } 75 | void Init(void) 76 | { 77 | m_resolution = 100000; 78 | m_concavity = 0.001; 79 | m_planeDownsampling = 4; 80 | m_convexhullDownsampling = 4; 81 | m_alpha = 0.05; 82 | m_beta = 0.05; 83 | m_pca = 0; 84 | m_mode = 0; // 0: voxel-based (recommended), 1: tetrahedron-based 85 | m_maxNumVerticesPerCH = 64; 86 | m_minVolumePerCH = 0.0001; 87 | m_callback = 0; 88 | m_logger = 0; 89 | m_convexhullApproximation = true; 90 | m_oclAcceleration = true; 91 | m_maxConvexHulls = 1024; 92 | m_projectHullVertices = true; // This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results 93 | } 94 | double m_concavity; 95 | double m_alpha; 96 | double m_beta; 97 | double m_minVolumePerCH; 98 | IUserCallback* m_callback; 99 | IUserLogger* m_logger; 100 | uint32_t m_resolution; 101 | uint32_t m_maxNumVerticesPerCH; 102 | uint32_t m_planeDownsampling; 103 | uint32_t m_convexhullDownsampling; 104 | uint32_t m_pca; 105 | uint32_t m_mode; 106 | uint32_t m_convexhullApproximation; 107 | uint32_t m_oclAcceleration; 108 | uint32_t m_maxConvexHulls; 109 | bool m_projectHullVertices; 110 | }; 111 | 112 | virtual void Cancel() = 0; 113 | virtual bool Compute(const float* const points, 114 | const uint32_t countPoints, 115 | const uint32_t* const triangles, 116 | const uint32_t countTriangles, 117 | const Parameters& params) 118 | = 0; 119 | virtual bool Compute(const double* const points, 120 | const uint32_t countPoints, 121 | const uint32_t* const triangles, 122 | const uint32_t countTriangles, 123 | const Parameters& params) 124 | = 0; 125 | virtual uint32_t GetNConvexHulls() const = 0; 126 | virtual void GetConvexHull(const uint32_t index, ConvexHull& ch) const = 0; 127 | virtual void Clean(void) = 0; // release internally allocated memory 128 | virtual void Release(void) = 0; // release IVHACD 129 | virtual bool OCLInit(void* const oclDevice, 130 | IUserLogger* const logger = 0) 131 | = 0; 132 | virtual bool OCLRelease(IUserLogger* const logger = 0) = 0; 133 | 134 | // Will compute the center of mass of the convex hull decomposition results and return it 135 | // in 'centerOfMass'. Returns false if the center of mass could not be computed. 136 | virtual bool ComputeCenterOfMass(double centerOfMass[3]) const = 0; 137 | 138 | // In synchronous mode (non-multi-threaded) the state is always 'ready' 139 | // In asynchronous mode, this returns true if the background thread is not still actively computing 140 | // a new solution. In an asynchronous config the 'IsReady' call will report any update or log 141 | // messages in the caller's current thread. 142 | virtual bool IsReady(void) const 143 | { 144 | return true; 145 | } 146 | 147 | protected: 148 | virtual ~IVHACD(void) {} 149 | }; 150 | IVHACD* CreateVHACD(void); 151 | IVHACD* CreateVHACD_ASYNC(void); 152 | } 153 | #endif // VHACD_H 154 | -------------------------------------------------------------------------------- /src/VHACD_Lib/src/FloatMath.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "FloatMath.h" 8 | #include 9 | 10 | #define REAL float 11 | 12 | #include "FloatMath.inl" 13 | 14 | #undef REAL 15 | #define REAL double 16 | 17 | #include "FloatMath.inl" 18 | -------------------------------------------------------------------------------- /src/VHACD_Lib/src/VHACD-ASYNC.cpp: -------------------------------------------------------------------------------- 1 | #include "../public/VHACD.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define ENABLE_ASYNC 1 12 | 13 | #define HACD_ALLOC(x) malloc(x) 14 | #define HACD_FREE(x) free(x) 15 | #define HACD_ASSERT(x) assert(x) 16 | 17 | namespace VHACD 18 | { 19 | 20 | class MyHACD_API : public VHACD::IVHACD, public VHACD::IVHACD::IUserCallback, VHACD::IVHACD::IUserLogger 21 | { 22 | public: 23 | MyHACD_API(void) 24 | { 25 | mVHACD = VHACD::CreateVHACD(); 26 | } 27 | 28 | virtual ~MyHACD_API(void) 29 | { 30 | releaseHACD(); 31 | Cancel(); 32 | mVHACD->Release(); 33 | } 34 | 35 | 36 | virtual bool Compute(const double* const _points, 37 | const uint32_t countPoints, 38 | const uint32_t* const _triangles, 39 | const uint32_t countTriangles, 40 | const Parameters& _desc) final 41 | { 42 | #if ENABLE_ASYNC 43 | Cancel(); // if we previously had a solution running; cancel it. 44 | releaseHACD(); 45 | 46 | // We need to copy the input vertices and triangles into our own buffers so we can operate 47 | // on them safely from the background thread. 48 | mVertices = (double *)HACD_ALLOC(sizeof(double)*countPoints * 3); 49 | mIndices = (uint32_t *)HACD_ALLOC(sizeof(uint32_t)*countTriangles * 3); 50 | memcpy(mVertices, _points, sizeof(double)*countPoints * 3); 51 | memcpy(mIndices, _triangles, sizeof(uint32_t)*countTriangles * 3); 52 | mRunning = true; 53 | mThread = new std::thread([this, countPoints, countTriangles, _desc]() 54 | { 55 | ComputeNow(mVertices, countPoints, mIndices, countTriangles, _desc); 56 | mRunning = false; 57 | }); 58 | #else 59 | releaseHACD(); 60 | ComputeNow(_points, countPoints, _triangles, countTriangles, _desc); 61 | #endif 62 | return true; 63 | } 64 | 65 | bool ComputeNow(const double* const points, 66 | const uint32_t countPoints, 67 | const uint32_t* const triangles, 68 | const uint32_t countTriangles, 69 | const Parameters& _desc) 70 | { 71 | uint32_t ret = 0; 72 | 73 | mHullCount = 0; 74 | mCallback = _desc.m_callback; 75 | mLogger = _desc.m_logger; 76 | 77 | IVHACD::Parameters desc = _desc; 78 | // Set our intercepting callback interfaces if non-null 79 | desc.m_callback = desc.m_callback ? this : nullptr; 80 | desc.m_logger = desc.m_logger ? this : nullptr; 81 | 82 | if ( countPoints ) 83 | { 84 | bool ok = mVHACD->Compute(points, countPoints, triangles, countTriangles, desc); 85 | if (ok) 86 | { 87 | ret = mVHACD->GetNConvexHulls(); 88 | mHulls = new IVHACD::ConvexHull[ret]; 89 | for (uint32_t i = 0; i < ret; i++) 90 | { 91 | VHACD::IVHACD::ConvexHull vhull; 92 | mVHACD->GetConvexHull(i, vhull); 93 | VHACD::IVHACD::ConvexHull h; 94 | h.m_nPoints = vhull.m_nPoints; 95 | h.m_points = (double *)HACD_ALLOC(sizeof(double) * 3 * h.m_nPoints); 96 | memcpy(h.m_points, vhull.m_points, sizeof(double) * 3 * h.m_nPoints); 97 | h.m_nTriangles = vhull.m_nTriangles; 98 | h.m_triangles = (uint32_t *)HACD_ALLOC(sizeof(uint32_t) * 3 * h.m_nTriangles); 99 | memcpy(h.m_triangles, vhull.m_triangles, sizeof(uint32_t) * 3 * h.m_nTriangles); 100 | h.m_volume = vhull.m_volume; 101 | h.m_center[0] = vhull.m_center[0]; 102 | h.m_center[1] = vhull.m_center[1]; 103 | h.m_center[2] = vhull.m_center[2]; 104 | mHulls[i] = h; 105 | if (mCancel) 106 | { 107 | ret = 0; 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | 114 | mHullCount = ret; 115 | return ret ? true : false; 116 | } 117 | 118 | void releaseHull(VHACD::IVHACD::ConvexHull &h) 119 | { 120 | HACD_FREE((void *)h.m_triangles); 121 | HACD_FREE((void *)h.m_points); 122 | h.m_triangles = nullptr; 123 | h.m_points = nullptr; 124 | } 125 | 126 | virtual void GetConvexHull(const uint32_t index, VHACD::IVHACD::ConvexHull& ch) const final 127 | { 128 | if ( index < mHullCount ) 129 | { 130 | ch = mHulls[index]; 131 | } 132 | } 133 | 134 | void releaseHACD(void) // release memory associated with the last HACD request 135 | { 136 | for (uint32_t i=0; iCancel(); // Set the cancel signal to the base VHACD 165 | } 166 | if (mThread) 167 | { 168 | mThread->join(); // Wait for the thread to fully exit before we delete the instance 169 | delete mThread; 170 | mThread = nullptr; 171 | Log("Convex Decomposition thread canceled\n"); 172 | } 173 | mCancel = false; // clear the cancel semaphore 174 | } 175 | 176 | virtual bool Compute(const float* const points, 177 | const uint32_t countPoints, 178 | const uint32_t* const triangles, 179 | const uint32_t countTriangles, 180 | const Parameters& params) final 181 | { 182 | 183 | double *vertices = (double *)HACD_ALLOC(sizeof(double)*countPoints * 3); 184 | const float *source = points; 185 | double *dest = vertices; 186 | for (uint32_t i = 0; i < countPoints; i++) 187 | { 188 | dest[0] = source[0]; 189 | dest[1] = source[1]; 190 | dest[2] = source[2]; 191 | dest += 3; 192 | source += 3; 193 | } 194 | 195 | bool ret = Compute(vertices, countPoints, triangles, countTriangles, params); 196 | HACD_FREE(vertices); 197 | return ret; 198 | } 199 | 200 | virtual uint32_t GetNConvexHulls() const final 201 | { 202 | processPendingMessages(); 203 | return mHullCount; 204 | } 205 | 206 | virtual void Clean(void) final // release internally allocated memory 207 | { 208 | Cancel(); 209 | releaseHACD(); 210 | mVHACD->Clean(); 211 | } 212 | 213 | virtual void Release(void) final // release IVHACD 214 | { 215 | delete this; 216 | } 217 | 218 | virtual bool OCLInit(void* const oclDevice, 219 | IVHACD::IUserLogger* const logger = 0) final 220 | { 221 | return mVHACD->OCLInit(oclDevice, logger); 222 | } 223 | 224 | virtual bool OCLRelease(IVHACD::IUserLogger* const logger = 0) final 225 | { 226 | return mVHACD->OCLRelease(logger); 227 | } 228 | 229 | virtual void Update(const double overallProgress, 230 | const double stageProgress, 231 | const double operationProgress, 232 | const char* const stage, 233 | const char* const operation) final 234 | { 235 | mMessageMutex.lock(); 236 | mHaveUpdateMessage = true; 237 | mOverallProgress = overallProgress; 238 | mStageProgress = stageProgress; 239 | mOperationProgress = operationProgress; 240 | mStage = std::string(stage); 241 | mOperation = std::string(operation); 242 | mMessageMutex.unlock(); 243 | } 244 | 245 | virtual void Log(const char* const msg) final 246 | { 247 | mMessageMutex.lock(); 248 | mHaveLogMessage = true; 249 | mMessage = std::string(msg); 250 | mMessageMutex.unlock(); 251 | } 252 | 253 | virtual bool IsReady(void) const final 254 | { 255 | processPendingMessages(); 256 | return !mRunning; 257 | } 258 | 259 | // As a convenience for the calling application we only send it update and log messages from it's own main 260 | // thread. This reduces the complexity burden on the caller by making sure it only has to deal with log 261 | // messages in it's main application thread. 262 | void processPendingMessages(void) const 263 | { 264 | // If we have a new update message and the user has specified a callback we send the message and clear the semaphore 265 | if (mHaveUpdateMessage && mCallback) 266 | { 267 | mMessageMutex.lock(); 268 | mCallback->Update(mOverallProgress, mStageProgress, mOperationProgress, mStage.c_str(), mOperation.c_str()); 269 | mHaveUpdateMessage = false; 270 | mMessageMutex.unlock(); 271 | } 272 | // If we have a new log message and the user has specified a callback we send the message and clear the semaphore 273 | if (mHaveLogMessage && mLogger) 274 | { 275 | mMessageMutex.lock(); 276 | mLogger->Log(mMessage.c_str()); 277 | mHaveLogMessage = false; 278 | mMessageMutex.unlock(); 279 | } 280 | } 281 | 282 | // Will compute the center of mass of the convex hull decomposition results and return it 283 | // in 'centerOfMass'. Returns false if the center of mass could not be computed. 284 | virtual bool ComputeCenterOfMass(double centerOfMass[3]) const 285 | { 286 | bool ret = false; 287 | 288 | centerOfMass[0] = 0; 289 | centerOfMass[1] = 0; 290 | centerOfMass[2] = 0; 291 | 292 | if (mVHACD && IsReady() ) 293 | { 294 | ret = mVHACD->ComputeCenterOfMass(centerOfMass); 295 | } 296 | return ret; 297 | } 298 | 299 | private: 300 | double *mVertices{ nullptr }; 301 | uint32_t *mIndices{ nullptr }; 302 | std::atomic< uint32_t> mHullCount{ 0 }; 303 | VHACD::IVHACD::ConvexHull *mHulls{ nullptr }; 304 | VHACD::IVHACD::IUserCallback *mCallback{ nullptr }; 305 | VHACD::IVHACD::IUserLogger *mLogger{ nullptr }; 306 | VHACD::IVHACD *mVHACD{ nullptr }; 307 | std::thread *mThread{ nullptr }; 308 | std::atomic< bool > mRunning{ false }; 309 | std::atomic mCancel{ false }; 310 | 311 | // Thread safe caching mechanism for messages and update status. 312 | // This is so that caller always gets messages in his own thread 313 | // Member variables are marked as 'mutable' since the message dispatch function 314 | // is called from const query methods. 315 | mutable std::mutex mMessageMutex; 316 | mutable std::atomic< bool > mHaveUpdateMessage{ false }; 317 | mutable std::atomic< bool > mHaveLogMessage{ false }; 318 | mutable double mOverallProgress{ 0 }; 319 | mutable double mStageProgress{ 0 }; 320 | mutable double mOperationProgress{ 0 }; 321 | mutable std::string mStage; 322 | mutable std::string mOperation; 323 | mutable std::string mMessage; 324 | }; 325 | 326 | IVHACD* CreateVHACD_ASYNC(void) 327 | { 328 | MyHACD_API *m = new MyHACD_API; 329 | return static_cast(m); 330 | } 331 | 332 | 333 | }; // end of VHACD namespace 334 | 335 | -------------------------------------------------------------------------------- /src/VHACD_Lib/src/btAlignedAllocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Bullet Continuous Collision Detection and Physics Library 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ 4 | 5 | This software is provided 'as-is', without any express or implied warranty. 6 | In no event will the authors be held liable for any damages arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it freely, 9 | subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 | 3. This notice may not be removed or altered from any source distribution. 14 | */ 15 | 16 | #include "btAlignedAllocator.h" 17 | 18 | #ifdef _MSC_VER 19 | #pragma warning(disable:4311 4302) 20 | #endif 21 | 22 | int32_t gNumAlignedAllocs = 0; 23 | int32_t gNumAlignedFree = 0; 24 | int32_t gTotalBytesAlignedAllocs = 0; //detect memory leaks 25 | 26 | static void* btAllocDefault(size_t size) 27 | { 28 | return malloc(size); 29 | } 30 | 31 | static void btFreeDefault(void* ptr) 32 | { 33 | free(ptr); 34 | } 35 | 36 | static btAllocFunc* sAllocFunc = btAllocDefault; 37 | static btFreeFunc* sFreeFunc = btFreeDefault; 38 | 39 | #if defined(BT_HAS_ALIGNED_ALLOCATOR) 40 | #include 41 | static void* btAlignedAllocDefault(size_t size, int32_t alignment) 42 | { 43 | return _aligned_malloc(size, (size_t)alignment); 44 | } 45 | 46 | static void btAlignedFreeDefault(void* ptr) 47 | { 48 | _aligned_free(ptr); 49 | } 50 | #elif defined(__CELLOS_LV2__) 51 | #include 52 | 53 | static inline void* btAlignedAllocDefault(size_t size, int32_t alignment) 54 | { 55 | return memalign(alignment, size); 56 | } 57 | 58 | static inline void btAlignedFreeDefault(void* ptr) 59 | { 60 | free(ptr); 61 | } 62 | #else 63 | static inline void* btAlignedAllocDefault(size_t size, int32_t alignment) 64 | { 65 | void* ret; 66 | char* real; 67 | unsigned long offset; 68 | 69 | real = (char*)sAllocFunc(size + sizeof(void*) + (alignment - 1)); 70 | if (real) { 71 | offset = (alignment - (unsigned long)(real + sizeof(void*))) & (alignment - 1); 72 | ret = (void*)((real + sizeof(void*)) + offset); 73 | *((void**)(ret)-1) = (void*)(real); 74 | } 75 | else { 76 | ret = (void*)(real); 77 | } 78 | return (ret); 79 | } 80 | 81 | static inline void btAlignedFreeDefault(void* ptr) 82 | { 83 | void* real; 84 | 85 | if (ptr) { 86 | real = *((void**)(ptr)-1); 87 | sFreeFunc(real); 88 | } 89 | } 90 | #endif 91 | 92 | static btAlignedAllocFunc* sAlignedAllocFunc = btAlignedAllocDefault; 93 | static btAlignedFreeFunc* sAlignedFreeFunc = btAlignedFreeDefault; 94 | 95 | void btAlignedAllocSetCustomAligned(btAlignedAllocFunc* allocFunc, btAlignedFreeFunc* freeFunc) 96 | { 97 | sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault; 98 | sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault; 99 | } 100 | 101 | void btAlignedAllocSetCustom(btAllocFunc* allocFunc, btFreeFunc* freeFunc) 102 | { 103 | sAllocFunc = allocFunc ? allocFunc : btAllocDefault; 104 | sFreeFunc = freeFunc ? freeFunc : btFreeDefault; 105 | } 106 | 107 | #ifdef BT_DEBUG_MEMORY_ALLOCATIONS 108 | //this generic allocator provides the total allocated number of bytes 109 | #include 110 | 111 | void* btAlignedAllocInternal(size_t size, int32_t alignment, int32_t line, char* filename) 112 | { 113 | void* ret; 114 | char* real; 115 | unsigned long offset; 116 | 117 | gTotalBytesAlignedAllocs += size; 118 | gNumAlignedAllocs++; 119 | 120 | real = (char*)sAllocFunc(size + 2 * sizeof(void*) + (alignment - 1)); 121 | if (real) { 122 | offset = (alignment - (unsigned long)(real + 2 * sizeof(void*))) & (alignment - 1); 123 | ret = (void*)((real + 2 * sizeof(void*)) + offset); 124 | *((void**)(ret)-1) = (void*)(real); 125 | *((int32_t*)(ret)-2) = size; 126 | } 127 | else { 128 | ret = (void*)(real); //?? 129 | } 130 | 131 | printf("allocation#%d at address %x, from %s,line %d, size %d\n", gNumAlignedAllocs, real, filename, line, size); 132 | 133 | int32_t* ptr = (int32_t*)ret; 134 | *ptr = 12; 135 | return (ret); 136 | } 137 | 138 | void btAlignedFreeInternal(void* ptr, int32_t line, char* filename) 139 | { 140 | 141 | void* real; 142 | gNumAlignedFree++; 143 | 144 | if (ptr) { 145 | real = *((void**)(ptr)-1); 146 | int32_t size = *((int32_t*)(ptr)-2); 147 | gTotalBytesAlignedAllocs -= size; 148 | 149 | printf("free #%d at address %x, from %s,line %d, size %d\n", gNumAlignedFree, real, filename, line, size); 150 | 151 | sFreeFunc(real); 152 | } 153 | else { 154 | printf("NULL ptr\n"); 155 | } 156 | } 157 | 158 | #else //BT_DEBUG_MEMORY_ALLOCATIONS 159 | 160 | void* btAlignedAllocInternal(size_t size, int32_t alignment) 161 | { 162 | gNumAlignedAllocs++; 163 | void* ptr; 164 | ptr = sAlignedAllocFunc(size, alignment); 165 | // printf("btAlignedAllocInternal %d, %x\n",size,ptr); 166 | return ptr; 167 | } 168 | 169 | void btAlignedFreeInternal(void* ptr) 170 | { 171 | if (!ptr) { 172 | return; 173 | } 174 | 175 | gNumAlignedFree++; 176 | // printf("btAlignedFreeInternal %x\n",ptr); 177 | sAlignedFreeFunc(ptr); 178 | } 179 | 180 | #endif //BT_DEBUG_MEMORY_ALLOCATIONS 181 | -------------------------------------------------------------------------------- /src/VHACD_Lib/src/vhacdManifoldMesh.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #include "vhacdManifoldMesh.h" 16 | namespace VHACD { 17 | TMMVertex::TMMVertex(void) 18 | { 19 | Initialize(); 20 | } 21 | void TMMVertex::Initialize() 22 | { 23 | m_name = 0; 24 | m_id = 0; 25 | m_duplicate = 0; 26 | m_onHull = false; 27 | m_tag = false; 28 | } 29 | 30 | TMMVertex::~TMMVertex(void) 31 | { 32 | } 33 | TMMEdge::TMMEdge(void) 34 | { 35 | Initialize(); 36 | } 37 | void TMMEdge::Initialize() 38 | { 39 | m_id = 0; 40 | m_triangles[0] = m_triangles[1] = m_newFace = 0; 41 | m_vertices[0] = m_vertices[1] = 0; 42 | } 43 | TMMEdge::~TMMEdge(void) 44 | { 45 | } 46 | void TMMTriangle::Initialize() 47 | { 48 | m_id = 0; 49 | for (int32_t i = 0; i < 3; i++) { 50 | m_edges[i] = 0; 51 | m_vertices[0] = 0; 52 | } 53 | m_visible = false; 54 | } 55 | TMMTriangle::TMMTriangle(void) 56 | { 57 | Initialize(); 58 | } 59 | TMMTriangle::~TMMTriangle(void) 60 | { 61 | } 62 | TMMesh::TMMesh() 63 | { 64 | } 65 | TMMesh::~TMMesh(void) 66 | { 67 | } 68 | void TMMesh::GetIFS(Vec3* const points, Vec3* const triangles) 69 | { 70 | size_t nV = m_vertices.GetSize(); 71 | size_t nT = m_triangles.GetSize(); 72 | 73 | for (size_t v = 0; v < nV; v++) { 74 | points[v] = m_vertices.GetData().m_pos; 75 | m_vertices.GetData().m_id = v; 76 | m_vertices.Next(); 77 | } 78 | for (size_t f = 0; f < nT; f++) { 79 | TMMTriangle& currentTriangle = m_triangles.GetData(); 80 | triangles[f].X() = static_cast(currentTriangle.m_vertices[0]->GetData().m_id); 81 | triangles[f].Y() = static_cast(currentTriangle.m_vertices[1]->GetData().m_id); 82 | triangles[f].Z() = static_cast(currentTriangle.m_vertices[2]->GetData().m_id); 83 | m_triangles.Next(); 84 | } 85 | } 86 | void TMMesh::Clear() 87 | { 88 | m_vertices.Clear(); 89 | m_edges.Clear(); 90 | m_triangles.Clear(); 91 | } 92 | void TMMesh::Copy(TMMesh& mesh) 93 | { 94 | Clear(); 95 | // updating the id's 96 | size_t nV = mesh.m_vertices.GetSize(); 97 | size_t nE = mesh.m_edges.GetSize(); 98 | size_t nT = mesh.m_triangles.GetSize(); 99 | for (size_t v = 0; v < nV; v++) { 100 | mesh.m_vertices.GetData().m_id = v; 101 | mesh.m_vertices.Next(); 102 | } 103 | for (size_t e = 0; e < nE; e++) { 104 | mesh.m_edges.GetData().m_id = e; 105 | mesh.m_edges.Next(); 106 | } 107 | for (size_t f = 0; f < nT; f++) { 108 | mesh.m_triangles.GetData().m_id = f; 109 | mesh.m_triangles.Next(); 110 | } 111 | // copying data 112 | m_vertices = mesh.m_vertices; 113 | m_edges = mesh.m_edges; 114 | m_triangles = mesh.m_triangles; 115 | 116 | // generate mapping 117 | CircularListElement** vertexMap = new CircularListElement*[nV]; 118 | CircularListElement** edgeMap = new CircularListElement*[nE]; 119 | CircularListElement** triangleMap = new CircularListElement*[nT]; 120 | for (size_t v = 0; v < nV; v++) { 121 | vertexMap[v] = m_vertices.GetHead(); 122 | m_vertices.Next(); 123 | } 124 | for (size_t e = 0; e < nE; e++) { 125 | edgeMap[e] = m_edges.GetHead(); 126 | m_edges.Next(); 127 | } 128 | for (size_t f = 0; f < nT; f++) { 129 | triangleMap[f] = m_triangles.GetHead(); 130 | m_triangles.Next(); 131 | } 132 | 133 | // updating pointers 134 | for (size_t v = 0; v < nV; v++) { 135 | if (vertexMap[v]->GetData().m_duplicate) { 136 | vertexMap[v]->GetData().m_duplicate = edgeMap[vertexMap[v]->GetData().m_duplicate->GetData().m_id]; 137 | } 138 | } 139 | for (size_t e = 0; e < nE; e++) { 140 | if (edgeMap[e]->GetData().m_newFace) { 141 | edgeMap[e]->GetData().m_newFace = triangleMap[edgeMap[e]->GetData().m_newFace->GetData().m_id]; 142 | } 143 | if (nT > 0) { 144 | for (int32_t f = 0; f < 2; f++) { 145 | if (edgeMap[e]->GetData().m_triangles[f]) { 146 | edgeMap[e]->GetData().m_triangles[f] = triangleMap[edgeMap[e]->GetData().m_triangles[f]->GetData().m_id]; 147 | } 148 | } 149 | } 150 | for (int32_t v = 0; v < 2; v++) { 151 | if (edgeMap[e]->GetData().m_vertices[v]) { 152 | edgeMap[e]->GetData().m_vertices[v] = vertexMap[edgeMap[e]->GetData().m_vertices[v]->GetData().m_id]; 153 | } 154 | } 155 | } 156 | for (size_t f = 0; f < nT; f++) { 157 | if (nE > 0) { 158 | for (int32_t e = 0; e < 3; e++) { 159 | if (triangleMap[f]->GetData().m_edges[e]) { 160 | triangleMap[f]->GetData().m_edges[e] = edgeMap[triangleMap[f]->GetData().m_edges[e]->GetData().m_id]; 161 | } 162 | } 163 | } 164 | for (int32_t v = 0; v < 3; v++) { 165 | if (triangleMap[f]->GetData().m_vertices[v]) { 166 | triangleMap[f]->GetData().m_vertices[v] = vertexMap[triangleMap[f]->GetData().m_vertices[v]->GetData().m_id]; 167 | } 168 | } 169 | } 170 | delete[] vertexMap; 171 | delete[] edgeMap; 172 | delete[] triangleMap; 173 | } 174 | bool TMMesh::CheckConsistancy() 175 | { 176 | size_t nE = m_edges.GetSize(); 177 | size_t nT = m_triangles.GetSize(); 178 | for (size_t e = 0; e < nE; e++) { 179 | for (int32_t f = 0; f < 2; f++) { 180 | if (!m_edges.GetHead()->GetData().m_triangles[f]) { 181 | return false; 182 | } 183 | } 184 | m_edges.Next(); 185 | } 186 | for (size_t f = 0; f < nT; f++) { 187 | for (int32_t e = 0; e < 3; e++) { 188 | int32_t found = 0; 189 | for (int32_t k = 0; k < 2; k++) { 190 | if (m_triangles.GetHead()->GetData().m_edges[e]->GetData().m_triangles[k] == m_triangles.GetHead()) { 191 | found++; 192 | } 193 | } 194 | if (found != 1) { 195 | return false; 196 | } 197 | } 198 | m_triangles.Next(); 199 | } 200 | return true; 201 | } 202 | } -------------------------------------------------------------------------------- /src/VHACD_Lib/src/vhacdRaycastMesh.cpp: -------------------------------------------------------------------------------- 1 | #include "vhacdRaycastMesh.h" 2 | #include 3 | #include 4 | 5 | namespace RAYCAST_MESH 6 | { 7 | 8 | /* a = b - c */ 9 | #define vector(a,b,c) \ 10 | (a)[0] = (b)[0] - (c)[0]; \ 11 | (a)[1] = (b)[1] - (c)[1]; \ 12 | (a)[2] = (b)[2] - (c)[2]; 13 | 14 | #define innerProduct(v,q) \ 15 | ((v)[0] * (q)[0] + \ 16 | (v)[1] * (q)[1] + \ 17 | (v)[2] * (q)[2]) 18 | 19 | #define crossProduct(a,b,c) \ 20 | (a)[0] = (b)[1] * (c)[2] - (c)[1] * (b)[2]; \ 21 | (a)[1] = (b)[2] * (c)[0] - (c)[2] * (b)[0]; \ 22 | (a)[2] = (b)[0] * (c)[1] - (c)[0] * (b)[1]; 23 | 24 | 25 | static inline bool rayIntersectsTriangle(const double *p,const double *d,const double *v0,const double *v1,const double *v2,double &t) 26 | { 27 | double e1[3],e2[3],h[3],s[3],q[3]; 28 | double a,f,u,v; 29 | 30 | vector(e1,v1,v0); 31 | vector(e2,v2,v0); 32 | crossProduct(h,d,e2); 33 | a = innerProduct(e1,h); 34 | 35 | if (a > -0.00001 && a < 0.00001) 36 | return(false); 37 | 38 | f = 1/a; 39 | vector(s,p,v0); 40 | u = f * (innerProduct(s,h)); 41 | 42 | if (u < 0.0 || u > 1.0) 43 | return(false); 44 | 45 | crossProduct(q,s,e1); 46 | v = f * innerProduct(d,q); 47 | if (v < 0.0 || u + v > 1.0) 48 | return(false); 49 | // at this stage we can compute t to find out where 50 | // the intersection point is on the line 51 | t = f * innerProduct(e2,q); 52 | if (t > 0) // ray intersection 53 | return(true); 54 | else // this means that there is a line intersection 55 | // but not a ray intersection 56 | return (false); 57 | } 58 | 59 | static double getPointDistance(const double *p1, const double *p2) 60 | { 61 | double dx = p1[0] - p2[0]; 62 | double dy = p1[1] - p2[1]; 63 | double dz = p1[2] - p2[2]; 64 | return sqrt(dx*dx + dy*dy + dz*dz); 65 | } 66 | 67 | class MyRaycastMesh : public VHACD::RaycastMesh 68 | { 69 | public: 70 | 71 | template 72 | MyRaycastMesh(uint32_t vcount, 73 | const T *vertices, 74 | uint32_t tcount, 75 | const uint32_t *indices) 76 | { 77 | mVcount = vcount; 78 | mVertices = new double[mVcount * 3]; 79 | for (uint32_t i = 0; i < mVcount; i++) 80 | { 81 | mVertices[i * 3 + 0] = vertices[0]; 82 | mVertices[i * 3 + 1] = vertices[1]; 83 | mVertices[i * 3 + 2] = vertices[2]; 84 | vertices += 3; 85 | } 86 | mTcount = tcount; 87 | mIndices = new uint32_t[mTcount * 3]; 88 | for (uint32_t i = 0; i < mTcount; i++) 89 | { 90 | mIndices[i * 3 + 0] = indices[0]; 91 | mIndices[i * 3 + 1] = indices[1]; 92 | mIndices[i * 3 + 2] = indices[2]; 93 | indices += 3; 94 | } 95 | } 96 | 97 | 98 | ~MyRaycastMesh(void) 99 | { 100 | delete[]mVertices; 101 | delete[]mIndices; 102 | } 103 | 104 | virtual void release(void) 105 | { 106 | delete this; 107 | } 108 | 109 | virtual bool raycast(const double *from, // The starting point of the raycast 110 | const double *to, // The ending point of the raycast 111 | const double *closestToPoint, // The point to match the nearest hit location (can just be the 'from' location of no specific point) 112 | double *hitLocation, // The point where the ray hit nearest to the 'closestToPoint' location 113 | double *hitDistance) final // The distance the ray traveled to the hit location 114 | { 115 | bool ret = false; 116 | 117 | double dir[3]; 118 | 119 | dir[0] = to[0] - from[0]; 120 | dir[1] = to[1] - from[1]; 121 | dir[2] = to[2] - from[2]; 122 | 123 | double distance = sqrt( dir[0]*dir[0] + dir[1]*dir[1]+dir[2]*dir[2] ); 124 | if ( distance < 0.0000000001f ) return false; 125 | double recipDistance = 1.0f / distance; 126 | dir[0]*=recipDistance; 127 | dir[1]*=recipDistance; 128 | dir[2]*=recipDistance; 129 | const uint32_t *indices = mIndices; 130 | const double *vertices = mVertices; 131 | double nearestDistance = distance; 132 | 133 | for (uint32_t tri=0; tri(m); 196 | } 197 | 198 | RaycastMesh * RaycastMesh::createRaycastMesh(uint32_t vcount, // The number of vertices in the source triangle mesh 199 | const float *vertices, // The array of vertex positions in the format x1,y1,z1..x2,y2,z2.. etc. 200 | uint32_t tcount, // The number of triangles in the source triangle mesh 201 | const uint32_t *indices) // The triangle indices in the format of i1,i2,i3 ... i4,i5,i6, ... 202 | { 203 | MyRaycastMesh *m = new MyRaycastMesh(vcount, vertices, tcount, indices); 204 | return static_cast(m); 205 | } 206 | 207 | 208 | } // end of VHACD namespace -------------------------------------------------------------------------------- /src/dll/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(VHACD_DLL) 2 | include(${CMAKE_COMMON_INC}) 3 | 4 | if (NOT NO_OPENCL) 5 | find_package(OpenCL QUIET) 6 | endif() 7 | if (NOT NO_OPENMP) 8 | find_package(OpenMP QUIET) 9 | endif() 10 | if(OPENMP_FOUND) 11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 13 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 14 | endif() 15 | 16 | add_library(libvhacd SHARED ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES}) 17 | 18 | target_include_directories(libvhacd PRIVATE ${CMAKE_SOURCE_DIR}/VHACD_Lib/public) 19 | target_link_libraries(libvhacd vhacd) 20 | 21 | if (OpenCL_FOUND) 22 | include_directories("${OpenCL_INCLUDE_DIRS}") 23 | add_definitions( -DOPENCL_FOUND=1 ) 24 | target_link_libraries(libvhacd ${OpenCL_LIBRARIES}) 25 | endif() 26 | 27 | if (NOT WIN32 AND NOT APPLE) 28 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") 29 | target_link_libraries(libvhacd rt) 30 | endif() 31 | 32 | -------------------------------------------------------------------------------- /src/dll/src/dll.cpp: -------------------------------------------------------------------------------- 1 | #include "VHACD.h" 2 | 3 | #ifdef WIN32 4 | #define EXTERN extern "C" __declspec(dllexport) 5 | #else 6 | #define EXTERN extern "C" 7 | #endif 8 | 9 | EXTERN void* CreateVHACD() 10 | { 11 | return VHACD::CreateVHACD(); 12 | } 13 | 14 | EXTERN void DestroyVHACD(void* pVHACD) 15 | { 16 | auto vhacd = (VHACD::IVHACD*)pVHACD; 17 | vhacd->Clean(); 18 | vhacd->Release(); 19 | } 20 | 21 | EXTERN bool ComputeFloat( 22 | void* pVHACD, 23 | const float* const points, 24 | const uint32_t countPoints, 25 | const uint32_t* const triangles, 26 | const uint32_t countTriangles, 27 | const void* params) 28 | { 29 | auto vhacd = (VHACD::IVHACD*)pVHACD; 30 | return vhacd->Compute(points, countPoints, triangles, countTriangles, *(VHACD::IVHACD::Parameters const *)params); 31 | } 32 | 33 | EXTERN bool ComputeDouble( 34 | void* pVHACD, 35 | const double* const points, 36 | const uint32_t countPoints, 37 | const uint32_t* const triangles, 38 | const uint32_t countTriangles, 39 | const void* params) 40 | { 41 | auto vhacd = (VHACD::IVHACD*)pVHACD; 42 | return vhacd->Compute(points, countPoints, triangles, countTriangles, *(VHACD::IVHACD::Parameters const *)params); 43 | } 44 | 45 | EXTERN uint32_t GetNConvexHulls( 46 | void* pVHACD 47 | ) 48 | { 49 | auto vhacd = (VHACD::IVHACD*)pVHACD; 50 | return vhacd->GetNConvexHulls(); 51 | } 52 | 53 | EXTERN void GetConvexHull( 54 | void* pVHACD, 55 | const uint32_t index, 56 | void* ch) 57 | { 58 | auto vhacd = (VHACD::IVHACD*)pVHACD; 59 | return vhacd->GetConvexHull(index, *(VHACD::IVHACD::ConvexHull *)ch); 60 | } 61 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(VHACD_TEST) 2 | include(${CMAKE_COMMON_INC}) 3 | 4 | if (NOT NO_OPENCL) 5 | find_package(OpenCL QUIET) 6 | endif() 7 | if (NOT NO_OPENMP) 8 | find_package(OpenMP QUIET) 9 | endif() 10 | if(OPENMP_FOUND) 11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 13 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 14 | endif() 15 | 16 | 17 | add_executable(testVHACD ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES}) 18 | 19 | target_include_directories(testVHACD PRIVATE ${CMAKE_SOURCE_DIR}/VHACD_Lib/public ${CMAKE_CURRENT_SOURCE_DIR}/inc) 20 | target_link_libraries(testVHACD vhacd) 21 | 22 | if (OpenCL_FOUND) 23 | include_directories("${OpenCL_INCLUDE_DIRS}") 24 | add_definitions( -DOPENCL_FOUND=1 ) 25 | target_link_libraries(testVHACD ${OpenCL_LIBRARIES}) 26 | endif() 27 | 28 | if (NOT WIN32 AND NOT APPLE) 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") 30 | target_link_libraries(testVHACD rt) 31 | endif() 32 | 33 | -------------------------------------------------------------------------------- /src/test/inc/oclHelper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 2 | All rights reserved. 3 | 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | */ 15 | #ifdef OPENCL_FOUND 16 | 17 | #pragma once 18 | #ifndef OCL_HELPER_H 19 | #define OCL_HELPER_H 20 | 21 | #include 22 | #include 23 | 24 | #ifdef __MACH__ 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class OCLHelper { 31 | public: 32 | OCLHelper(void){}; 33 | ~OCLHelper(void){}; 34 | bool InitPlatform(const unsigned int platformIndex = 0); 35 | bool InitDevice(const unsigned int deviceIndex); 36 | bool GetPlatformsInfo(std::vector& info, const std::string& indentation); 37 | bool GetDevicesInfo(std::vector& info, const std::string& indentation); 38 | cl_platform_id* GetPlatform() { return &m_platform; } 39 | const cl_platform_id* GetPlatform() const { return &m_platform; } 40 | cl_device_id* GetDevice() { return &m_device; } 41 | const cl_device_id* GetDevice() const { return &m_device; } 42 | private: 43 | cl_platform_id m_platform; 44 | cl_device_id m_device; 45 | cl_int m_lastError; 46 | }; 47 | 48 | #endif // OCL_HELPER_H 49 | 50 | #endif //OPENCL_FOUND 51 | --------------------------------------------------------------------------------