diff --git a/.github/workflows/deploy_to_pypi.yaml b/.github/workflows/deploy_to_pypi.yaml index 857a2ca..e1f1bd9 100644 --- a/.github/workflows/deploy_to_pypi.yaml +++ b/.github/workflows/deploy_to_pypi.yaml @@ -115,3 +115,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ + skip_existing: true diff --git a/pyproject.toml b/pyproject.toml index abf34ab..10f3424 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ readme = "README.md" requires-python = ">=3.8" license = {text = "GPLv3"} -version = "1.3.4" +version = "1.3.5" dynamic = ["dependencies"] diff --git a/requirements.txt b/requirements.txt index 4603416..16c4abb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ filelock==3.9.0 GitPython==3.1.29 jsonschema==4.17.3 opencv-python==4.6.0.66 +numpy==1.23.5 Pillow==9.4.0 PyYAML==6.0.1 requests==2.27.1 diff --git a/syclops/utility/blender_utils.py b/syclops/utility/blender_utils.py index 31efb1a..7fd6e8f 100644 --- a/syclops/utility/blender_utils.py +++ b/syclops/utility/blender_utils.py @@ -398,6 +398,7 @@ def convex_decomposition( obj_pointer: ObjPointer, conv_hull_collection_pointer: ObjPointer, quality: float = 90, + max_hull_vertices: int = 100, ) -> List[bpy.types.Object]: """Decompose an object into convex hulls for physics simulation. @@ -405,7 +406,7 @@ def convex_decomposition( obj_pointer (ObjPointer): Pointer to object to decompose. conv_hull_collection_pointer (ObjPointer): Pointer to collection to store convex hulls in. quality (float, optional): Quality of the convex decomposition. Defaults to 90. - + max_hull_vertices (int, optional): Maximum number of vertices in a convex hull. Defaults to 256. Returns: list[bpy.types.Object]: List of convex hulls. """ @@ -436,6 +437,15 @@ def convex_decomposition( # Create the mesh data mesh.from_pydata(convex_hull[0], [], convex_hull[1]) + # Num vertices of mesh + num_vertices = len(mesh.vertices) + if num_vertices > max_hull_vertices: + decimate_factor = max_hull_vertices / num_vertices + + # Decimate the mesh if it has too many vertices + decimate_mesh(convex_obj, decimate_factor) + + # Update the mesh and object mesh.update() convex_obj.select_set(True)