Skip to content

Commit

Permalink
feature: bump version to 1.3.5 and add max_hull_vertices parameter to…
Browse files Browse the repository at this point in the history
… convex_decomposition function
  • Loading branch information
aelmiger committed Jul 16, 2024
1 parent b0107f3 commit e133251
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
requires-python = ">=3.8"
license = {text = "GPLv3"}

version = "1.3.4"
version = "1.3.5"

dynamic = ["dependencies"]

Expand Down
12 changes: 11 additions & 1 deletion syclops/utility/blender_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,15 @@ 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.
Args:
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.
"""
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e133251

Please sign in to comment.