11use crate :: dynamics:: { CoefficientCombineRule , MassProperties , RigidBodyHandle } ;
2+ #[ cfg( feature = "dim3" ) ]
3+ use crate :: geometry:: HeightFieldFlags ;
24use crate :: geometry:: {
35 ActiveCollisionTypes , BroadPhaseProxyIndex , ColliderBroadPhaseData , ColliderChanges ,
46 ColliderFlags , ColliderMassProps , ColliderMaterial , ColliderParent , ColliderPosition ,
@@ -10,10 +12,8 @@ use crate::pipeline::{ActiveEvents, ActiveHooks};
1012use crate :: prelude:: ColliderEnabled ;
1113use na:: Unit ;
1214use parry:: bounding_volume:: { Aabb , BoundingVolume } ;
13- use parry:: shape:: { Shape , TriMeshBuilderError , TriMeshFlags } ;
14-
15- #[ cfg( feature = "dim3" ) ]
16- use crate :: geometry:: HeightFieldFlags ;
15+ use parry:: shape:: { Shape , TriMeshBuilderError , TriMeshFlags , VoxelPrimitiveGeometry } ;
16+ use parry:: transformation:: voxelization:: FillMode ;
1717
1818#[ cfg_attr( feature = "serde-serialize" , derive( Serialize , Deserialize ) ) ]
1919#[ derive( Clone , Debug ) ]
@@ -573,6 +573,36 @@ impl ColliderBuilder {
573573 Self :: new ( SharedShape :: halfspace ( outward_normal) )
574574 }
575575
576+ /// Initializes a collider made of voxels.
577+ ///
578+ /// Each voxel has the size `voxel_size` and centers given by `centers`.
579+ /// The `primitive_geometry` controls the behavior of collision detection at voxels boundaries.
580+ pub fn voxels (
581+ primitive_geometry : VoxelPrimitiveGeometry ,
582+ centers : & [ Point < Real > ] ,
583+ voxel_size : Real ,
584+ ) -> Self {
585+ Self :: new ( SharedShape :: voxels ( primitive_geometry, centers, voxel_size) )
586+ }
587+
588+ /// Initializes a voxels obtained from the decomposition of the given trimesh (in 3D)
589+ /// or polyline (in 2D) into voxelized convex parts.
590+ pub fn voxelized_mesh (
591+ primitive_geometry : VoxelPrimitiveGeometry ,
592+ vertices : & [ Point < Real > ] ,
593+ indices : & [ [ u32 ; DIM ] ] ,
594+ voxel_size : Real ,
595+ fill_mode : FillMode ,
596+ ) -> Self {
597+ Self :: new ( SharedShape :: voxelized_mesh (
598+ primitive_geometry,
599+ vertices,
600+ indices,
601+ voxel_size,
602+ fill_mode,
603+ ) )
604+ }
605+
576606 /// Initialize a new collider builder with a cylindrical shape defined by its half-height
577607 /// (along the Y axis) and its radius.
578608 #[ cfg( feature = "dim3" ) ]
0 commit comments