Skip to content

feat: add experimental support for a shape type dedicated to voxels#336

Merged
sebcrozet merged 19 commits intomasterfrom
voxels
Apr 24, 2025
Merged

feat: add experimental support for a shape type dedicated to voxels#336
sebcrozet merged 19 commits intomasterfrom
voxels

Conversation

@sebcrozet
Copy link
Member

@sebcrozet sebcrozet commented Apr 17, 2025

This PRs adds partial support of a new Voxels shape. This shape type is designed to handle efficiently, and without "internal edges" artifacts, collision detection with objects defined as a set of voxels. Each Voxels shape is free to have their own voxel size; and can be rotated/translated arbitrarily as a whole. The voxel size can be different along each axis (i.e. it can be a rectangle instead of just a cube).

This feature is still experimental as it is missing some elements. The following is supported:

  • Ray-casting.
  • Point-projection (very unoptimized).
  • Contact-manifold generation with convex shapes.
  • Conversion from and to meshes/polylines.
  • Conversion to outlines for debug-rendering.
  • Dynamic addition or removal of individual voxels.

Notable features that are currently missing are:

  • Collision-detection with non-convex shapes (or compound shapes).
  • Shape-casting.
image image

@sebcrozet sebcrozet merged commit 876b625 into master Apr 24, 2025
7 checks passed
@sebcrozet sebcrozet deleted the voxels branch April 24, 2025 08:17
Jondolf added a commit to avianphysics/avian that referenced this pull request Jun 18, 2025
# Objective

Parry added support for a cool new [`Voxels` shape](dimforge/parry#336) for efficient voxelized geometry without ghost collision problems caused by internal edges. We should add support for this too!

## Solution

- Update to Parry 0.21
- Add `Collider::shape_mut`
- Add `Collider::voxels`
- Add `Collider::voxels_from_points`
- Add `Collider::voxelized_polyline` (2D)
- Add `Collider::voxelized_trimesh` (3D)
- Add `Collider::voxelized_trimesh_from_mesh` (3D)
- Add `Collider::voxelized_convex_decomposition`
- Add `Collider::voxelized_convex_decomposition_with_config`
- Add `Collider::voxelized_convex_decomposition_from_mesh` (3D)
- Add `ColliderConstructor::Voxels`
- Add `ColliderConstructor::VoxelizedPolyline`
- Add `ColliderConstructor::VoxelizedTrimesh`
- Add `ColliderConstructor::VoxelizedTrimeshFromMesh`

The update to Parry 0.21 also made `SharedShape::trimesh` and `SharedShape::trimesh_with_flags` fallible. To support this, `Collider::trimesh` and `Collider::trimesh_with_config` now panic for degenerate input, but there are also `Collider::try_trimesh` and `Collider::try_trimesh_with_config` versions that return a `Result`.

---

## Migration Guide

`Collider::trimesh` and `Collider::trimesh_with_config` can now panic for degenerate input. Use `Collider::try_trimesh` and `Collider::try_trimesh_with_config` to instead get a `Result` and handle error cases manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant