Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
platform: [ubuntu-latest, macos-latest, windows-latest]
include:
- platform: windows-latest
cmake_type: "Visual Studio 16 2019"
cmake_type: "Visual Studio 17 2022"
dll_name: "Release/libvhacd.dll"
target_dll_name: "libvhacd.dll"
- platform: ubuntu-latest
Expand All @@ -32,14 +32,14 @@ jobs:
run: |
mkdir build
cd build
cmake -G "${{ matrix.cmake_type }}" ../src
cmake -G "${{ matrix.cmake_type }}" -DCMAKE_BUILD_TYPE=Release ../src
- name: build
run: cmake --build build --config Release

- uses: actions/upload-artifact@v1
with:
name: ${{ matrix.platform }}
path: build/dll/${{ matrix.dll_name }}
path: build/${{ matrix.dll_name }}

create_release:
runs-on: ubuntu-latest
Expand Down
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this repository will be documented in this file.

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).

## [0.0.2-preview] - 2023

### Upgrade Notes

Updated to v-hacd 4.1

### Known Issues

### Added

### Changed

v-hacd is now up-to-date with the latest version 4.1

### Deprecated

### Removed

### Fixed

## Unreleased

### Upgrade Notes
Expand Down Expand Up @@ -38,4 +58,4 @@ Created VHACD Unity package

### Removed

### Fixed
### Fixed
Binary file removed bin-no-ocl-omp/osx/testVHACD
Binary file not shown.
Binary file removed bin-no-ocl/osx/testVHACD
Binary file not shown.
Binary file removed bin-no-ocl/win32/testVHACD.exe
Binary file not shown.
Binary file removed bin-no-ocl/win64/testVHACD.exe
Binary file not shown.
Binary file removed bin/.DS_Store
Binary file not shown.
Binary file removed bin/osx/testVHACD
Binary file not shown.
Binary file removed bin/win32/testVHACD.exe
Binary file not shown.
Binary file removed bin/win64/testVHACD.exe
Binary file not shown.
122 changes: 61 additions & 61 deletions com.unity.robotics.vhacd/Runtime/VHACD.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
Expand All @@ -8,92 +8,86 @@ namespace MeshProcess
{
public class VHACD : MonoBehaviour
{
[System.Serializable]
// Should match `enum class FillMode` in VHACD.h
[Serializable]
public enum FillMode
{
FLOOD_FILL, // 0
SURFACE_ONLY, // 1
RAYCAST_FILL // 2
}

[Serializable]
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Parameters
{
public void Init()
{
m_resolution = 100000;
m_concavity = 0.001;
m_planeDownsampling = 4;
m_convexhullDownsampling = 4;
m_alpha = 0.05;
m_beta = 0.05;
m_pca = 0;
m_mode = 0; // 0: voxel-based (recommended), 1: tetrahedron-based
m_maxNumVerticesPerCH = 64;
m_minVolumePerCH = 0.0001;
m_callback = null;
m_logger = null;
m_convexhullApproximation = 1;
m_oclAcceleration = 0;
m_maxConvexHulls = 1024;
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
m_taskRunner = null;
m_maxConvexHulls = 32;
m_resolution = 100000;
m_minimumVolumePercentErrorAllowed = 1;
m_maxRecursionDepth = 10;
m_shrinkWrap = true;
m_fillMode = FillMode.FLOOD_FILL;
m_maxNumVerticesPerCH = 64;
m_asyncACD = true;
m_minEdgeLength = 2;
m_findBestPlane = false;
}

[Tooltip("maximum concavity")]
[Range(0, 1)]
public double m_concavity;

[Tooltip("controls the bias toward clipping along symmetry planes")]
[Range(0, 1)]
public double m_alpha;

[Tooltip("controls the bias toward clipping along revolution axes")]
[Range(0, 1)]
public double m_beta;

[Tooltip("controls the adaptive sampling of the generated convex-hulls")]
[Range(0, 0.01f)]
public double m_minVolumePerCH;

public void* m_callback;
public void* m_logger;
public void* m_taskRunner;

[Tooltip("maximum number of voxels generated during the voxelization stage")]
[Tooltip("The maximum number of convex hulls to produce. Performance sensitive: adding more MeshColliders slows down Unity at runtime.")]
[Range(1, 2048)]
public uint m_maxConvexHulls;

[Tooltip("Maximum number of voxels generated during the voxelization stage. Higher value increases generation time.")]
[Range(10000, 64000000)]
public uint m_resolution;

[Tooltip("controls the maximum number of triangles per convex-hull")]
[Range(4, 1024)]
public uint m_maxNumVerticesPerCH;

[Tooltip("controls the granularity of the search for the \"best\" clipping plane")]
[Range(1, 16)]
public uint m_planeDownsampling;
[Tooltip(
"If the voxels are within X% of the volume of the hull, we consider this a close enough approximation.")]
[Range(0.001f, 10)]
public double m_minimumVolumePercentErrorAllowed;

[Tooltip("controls the precision of the convex-hull generation process during the clipping plane selection stage")]
[Range(1, 16)]
public uint m_convexhullDownsampling;
[Tooltip("Maximum recursion depth. Default value is 10.")]
[Range(1, 15)]
public uint m_maxRecursionDepth;

[Tooltip("enable/disable normalizing the mesh before applying the convex decomposition")]
[Range(0, 1)]
public uint m_pca;
[Tooltip(
"This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results. Default is true.")]
public bool m_shrinkWrap;

[Tooltip("0: voxel-based (recommended), 1: tetrahedron-based")]
[Range(0, 1)]
public uint m_mode;
[Tooltip("How to fill the interior of the voxelized mesh")]
public FillMode m_fillMode;

[Range(0, 1)]
public uint m_convexhullApproximation;
[Tooltip("Controls the maximum number of triangles per convex-hull")]
[Range(4, 1024)]
public uint m_maxNumVerticesPerCH;

[Range(0, 1)]
public uint m_oclAcceleration;
[Tooltip("Whether or not to run asynchronously, taking advantage of additional cores")]
public bool m_asyncACD;

public uint m_maxConvexHulls;
[Tooltip("Minimum size of a voxel edge. Default value is 2 voxels.")]
[Range(1, 16)]
public uint m_minEdgeLength;

[Tooltip("This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results")]
public bool m_projectHullVertices;
};
[Tooltip("If false, splits hulls in the middle. If true, tries to find optimal split plane location. False by default.")]
public bool m_findBestPlane;
}

[StructLayout(LayoutKind.Sequential)]
unsafe struct ConvexHull
{
public double* m_points;
public uint* m_triangles;
public uint m_nPoints;
public uint m_nTriangles;
public double m_volume;
public fixed double m_center[3];
};

[DllImport("libvhacd")] static extern unsafe void* CreateVHACD();
Expand Down Expand Up @@ -124,7 +118,11 @@ static extern unsafe bool ComputeDouble(
static extern unsafe void GetConvexHull(
void* pVHACD,
uint index,
ConvexHull* ch);
ConvexHull* convexHull);

[DllImport("libvhacd")]
static extern unsafe void FreeConvexHull(
ConvexHull* convexHull);

public Parameters m_parameters;

Expand Down Expand Up @@ -183,8 +181,10 @@ public unsafe List<Mesh> GenerateConvexMeshes(Mesh mesh = null)
Marshal.Copy((System.IntPtr)hull.m_triangles, indices, 0, indices.Length);
hullMesh.SetTriangles(indices, 0);


convexMesh.Add(hullMesh);

FreeConvexHull(&hull);
}

DestroyVHACD(vhacd);
Expand Down
Binary file modified com.unity.robotics.vhacd/Runtime/liblibvhacd.dylib
Binary file not shown.
Binary file modified com.unity.robotics.vhacd/Runtime/liblibvhacd.so
Binary file not shown.
Binary file modified com.unity.robotics.vhacd/Runtime/libvhacd.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion com.unity.robotics.vhacd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.unity.robotics.vhacd",
"version": "0.0.1-preview",
"version": "0.0.2-preview",
"displayName": "VHACD",
"description": "",
"unity": "2020.3",
Expand Down
18 changes: 0 additions & 18 deletions scripts/cmake_common.cmake

This file was deleted.

23 changes: 12 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
project(VHACD)
option(NO_OPENCL "NO_OPENCL" OFF)
option(NO_OPENMP "NO_OPENMP" OFF)

message("NO_OPENCL " ${NO_OPENCL})
message("NO_OPENMP " ${NO_OPENMP})
# This project requires C++11.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
Expand All @@ -20,15 +19,17 @@ set(CompilerFlags
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
)
)

foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
set(${CompilerFlag} "${${CompilerFlag}}" CACHE STRING "msvc compiler flags" FORCE)
message("MSVC flags: ${CompilerFlag}:${${CompilerFlag}}")
endforeach()

#set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/output" CACHE PATH "project install prefix" FORCE)
set(CMAKE_COMMON_INC "${CMAKE_SOURCE_DIR}/../scripts/cmake_common.cmake")
add_subdirectory ("${CMAKE_SOURCE_DIR}/VHACD_Lib")
add_subdirectory ("${CMAKE_SOURCE_DIR}/test")
add_subdirectory ("${CMAKE_SOURCE_DIR}/dll")
include_directories(${CMAKE_SOURCE_DIR}/inc)

add_library(libvhacd SHARED ${CMAKE_SOURCE_DIR}/dll/dll.cpp)

# VHACD.h is a header-only library. Implementation needs this define flag.
target_compile_definitions(libvhacd PRIVATE ENABLE_VHACD_IMPLEMENTATION=1)
77 changes: 0 additions & 77 deletions src/VHACD_Lib/CMakeLists.txt

This file was deleted.

Loading