@@ -88,7 +88,7 @@
|
||||
by default.
|
||||
|
||||
### Added
|
||||
- Debug-renderer: add rendering of contacts, solver contacts, and collider AABBs
|
||||
- Debug-renderer: add rendering of contacts, solver contacts, and collider Aabbs
|
||||
- Add `MultibodyJointSet::attached_joints` to return all the multibody joints attached to a given rigid-body.
|
||||
|
||||
## v0.12.0 (30 Apr. 2022)
|
||||
|
||||
@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
|
||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||
num-traits = "0.2"
|
||||
nalgebra = "0.31"
|
||||
parry2d-f64 = "0.10"
|
||||
parry2d-f64 = "^0.11.1"
|
||||
simba = "0.7"
|
||||
approx = "0.5"
|
||||
rayon = { version = "1", optional = true }
|
||||
|
||||
@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
|
||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||
num-traits = "0.2"
|
||||
nalgebra = "0.31"
|
||||
parry2d = "0.10"
|
||||
parry2d = "^0.11.1"
|
||||
simba = "0.7"
|
||||
approx = "0.5"
|
||||
rayon = { version = "1", optional = true }
|
||||
|
||||
@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
|
||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||
num-traits = "0.2"
|
||||
nalgebra = "0.31"
|
||||
parry3d-f64 = "0.10"
|
||||
parry3d-f64 = "^0.11.1"
|
||||
simba = "0.7"
|
||||
approx = "0.5"
|
||||
rayon = { version = "1", optional = true }
|
||||
|
||||
@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
|
||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||
num-traits = "0.2"
|
||||
nalgebra = "0.31"
|
||||
parry3d = "0.10"
|
||||
parry3d = "^0.11.1"
|
||||
simba = "0.7"
|
||||
approx = "0.5"
|
||||
rayon = { version = "1", optional = true }
|
||||
|
||||
@@ -34,6 +34,7 @@ mod heightfield3;
|
||||
mod joints3;
|
||||
// mod joints3;
|
||||
mod character_controller3;
|
||||
mod debug_internal_edges3;
|
||||
mod keva3;
|
||||
mod locked_rotations3;
|
||||
mod newton_cradle3;
|
||||
@@ -114,6 +115,7 @@ pub fn main() {
|
||||
debug_dynamic_collider_add3::init_world,
|
||||
),
|
||||
("(Debug) friction", debug_friction3::init_world),
|
||||
("(Debug) internal edges", debug_internal_edges3::init_world),
|
||||
("(Debug) triangle", debug_triangle3::init_world),
|
||||
("(Debug) trimesh", debug_trimesh3::init_world),
|
||||
("(Debug) cylinder", debug_cylinder3::init_world),
|
||||
|
||||
60
examples3d/debug_internal_edges3.rs
Normal file
60
examples3d/debug_internal_edges3.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* World
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
let heights = DMatrix::zeros(100, 100);
|
||||
let heightfield = HeightField::new(heights, vector![60.0, 1.0, 60.0]);
|
||||
let rotation = vector![0.0, 0.0, 0.0]; // vector![-0.1, 0.0, 0.0];
|
||||
colliders
|
||||
.insert(ColliderBuilder::new(SharedShape::new(heightfield.clone())).rotation(rotation));
|
||||
|
||||
// let mut trimesh = TriMesh::from(heightfield);
|
||||
// trimesh.set_flags(TriMeshFlags::MERGE_DUPLICATE_VERTICES)
|
||||
// colliders.insert(ColliderBuilder::new(SharedShape::new(trimesh.clone())).rotation(rotation));
|
||||
// // NOTE: we add a sensor just because we want the testbed to display the mesh’s wireframe.
|
||||
// colliders.insert(
|
||||
// ColliderBuilder::new(SharedShape::new(trimesh))
|
||||
// .sensor(true)
|
||||
// .rotation(rotation),
|
||||
// );
|
||||
|
||||
// Dynamic rigid bodies.
|
||||
let rigid_body = RigidBodyBuilder::dynamic()
|
||||
.translation(vector![4.0, 0.5, 0.0])
|
||||
.linvel(vector![0.0, -40.0, 20.0])
|
||||
.can_sleep(false);
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::ball(0.5);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::dynamic()
|
||||
.translation(vector![0.0, 0.5, 0.0])
|
||||
.linvel(vector![0.0, -4.0, 20.0])
|
||||
.can_sleep(false);
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(0.5, 0.5, 0.5);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::dynamic()
|
||||
.translation(vector![8.0, 0.2, 0.0])
|
||||
.linvel(vector![0.0, -4.0, 20.0])
|
||||
.can_sleep(false);
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider =
|
||||
ColliderBuilder::cylinder(0.5, 0.2).rotation(vector![0.0, 0.0, std::f32::consts::PI / 2.0]);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![10.0, 10.0, 10.0], Point::origin());
|
||||
}
|
||||
@@ -38,7 +38,11 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
|
||||
let rigid_body = RigidBodyBuilder::fixed();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::trimesh(vertices, indices);
|
||||
let collider = ColliderBuilder::trimesh_with_flags(
|
||||
vertices,
|
||||
indices,
|
||||
TriMeshFlags::MERGE_DUPLICATE_VERTICES,
|
||||
);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,7 +17,7 @@ use parry::utils::hashmap::HashMap;
|
||||
/// the interactions between far-away objects. This means that objects
|
||||
/// that are very far away will still have some of their endpoints swapped
|
||||
/// within the SAP data-structure. This results in poor scaling because this
|
||||
/// results in lots of swapping between endpoints of AABBs that won't ever
|
||||
/// results in lots of swapping between endpoints of Aabbs that won't ever
|
||||
/// actually interact.
|
||||
///
|
||||
/// The first optimization to address this problem is to use the Multi-SAP
|
||||
@@ -25,7 +25,7 @@ use parry::utils::hashmap::HashMap;
|
||||
/// the spaces into equally-sized subspaces (grid cells). Each subspace, which we call
|
||||
/// a "region" contains an SAP instance (i.e. there SAP axes responsible for
|
||||
/// collecting endpoints and swapping them when they move to detect interaction pairs).
|
||||
/// Each AABB is inserted in all the regions it intersects.
|
||||
/// Each Aabb is inserted in all the regions it intersects.
|
||||
/// This prevents the far-away problem because two objects that are far away will
|
||||
/// be located on different regions. So their endpoints will never meet.
|
||||
///
|
||||
@@ -39,10 +39,10 @@ use parry::utils::hashmap::HashMap;
|
||||
/// replace the grid by a hierarchical grid. A hierarchical grid is composed of
|
||||
/// several layers. And each layer have different region sizes. For example all
|
||||
/// the regions on layer 0 will have the size 1x1x1. All the regions on the layer
|
||||
/// 1 will have the size 10x10x10, etc. That way, a given AABB will be inserted
|
||||
/// 1 will have the size 10x10x10, etc. That way, a given Aabb will be inserted
|
||||
/// on the layer that has regions big enough to avoid the large-object problem.
|
||||
/// For example a 20x20x20 object will be inserted in the layer with region
|
||||
/// of size 10x10x10, resulting in only 8 regions being intersect by the AABB.
|
||||
/// of size 10x10x10, resulting in only 8 regions being intersect by the Aabb.
|
||||
/// (If it was inserted in the layer with regions of size 1x1x1, it would have intersected
|
||||
/// 8000 regions, which is a problem performancewise.)
|
||||
///
|
||||
@@ -53,14 +53,14 @@ use parry::utils::hashmap::HashMap;
|
||||
/// way. So we need a way to do inter-layer interference detection. There is a lot ways of doing
|
||||
/// this: performing inter-layer Multi-Box-Pruning passes is one example (but this is not what we do).
|
||||
/// In our implementation, we do the following:
|
||||
/// - The AABB bounds of each region of the layer `n` are inserted into the corresponding larger region
|
||||
/// - The Aabb bounds of each region of the layer `n` are inserted into the corresponding larger region
|
||||
/// of the layer `n + 1`.
|
||||
/// - When an AABB in the region of the layer `n + 1` intersects the AABB corresponding to one of the
|
||||
/// regions at the smaller layer `n`, we add that AABB to that smaller region.
|
||||
/// So in the end it means that a given AABB will be inserted into all the region it intersects at
|
||||
/// - When an Aabb in the region of the layer `n + 1` intersects the Aabb corresponding to one of the
|
||||
/// regions at the smaller layer `n`, we add that Aabb to that smaller region.
|
||||
/// So in the end it means that a given Aabb will be inserted into all the region it intersects at
|
||||
/// the layer `n`. And it will also be inserted into all the regions it intersects at the smaller layers
|
||||
/// (the layers `< n`), but only for the regions that already exist (so we don't have to discretize
|
||||
/// our AABB into the layers `< n`). This involves a fair amount of bookkeeping unfortunately, but
|
||||
/// our Aabb into the layers `< n`). This involves a fair amount of bookkeeping unfortunately, but
|
||||
/// this has the benefit of keep the overall complexity of the algorithm O(1) in the typical specially
|
||||
/// coherent scenario.
|
||||
///
|
||||
@@ -68,10 +68,10 @@ use parry::utils::hashmap::HashMap;
|
||||
/// - There is one `SAPLayer` per layer of the hierarchical grid.
|
||||
/// - Each `SAPLayer` contains multiple `SAPRegion` (each being a region of the grid represented by that layer).
|
||||
/// - Each `SAPRegion` contains three `SAPAxis`, representing the "classical" SAP algorithm running on this region.
|
||||
/// - Each `SAPAxis` maintains a sorted list of `SAPEndpoints` representing the endpoints of the AABBs intersecting
|
||||
/// - Each `SAPAxis` maintains a sorted list of `SAPEndpoints` representing the endpoints of the Aabbs intersecting
|
||||
/// the bounds on the `SAPRegion` containing this `SAPAxis`.
|
||||
/// - A set of `SAPProxy` are maintained separately. It contains the AABBs of all the colliders managed by this
|
||||
/// broad-phase, as well as the AABBs of all the regions part of this broad-phase.
|
||||
/// - A set of `SAPProxy` are maintained separately. It contains the Aabbs of all the colliders managed by this
|
||||
/// broad-phase, as well as the Aabbs of all the regions part of this broad-phase.
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone)]
|
||||
pub struct BroadPhase {
|
||||
@@ -151,7 +151,7 @@ impl BroadPhase {
|
||||
/// Pre-deletes a proxy from this broad-phase.
|
||||
///
|
||||
/// The removal of a proxy is a semi-lazy process. It will mark
|
||||
/// the proxy as predeleted, and will set its AABB as +infinity.
|
||||
/// the proxy as predeleted, and will set its Aabb as +infinity.
|
||||
/// After this method has been called with all the proxies to
|
||||
/// remove, the `complete_removal` method MUST be called to
|
||||
/// complete the removal of these proxies, by actually removing them
|
||||
@@ -355,7 +355,7 @@ impl BroadPhase {
|
||||
if aabb.mins.coords.iter().any(|e| !e.is_finite())
|
||||
|| aabb.maxs.coords.iter().any(|e| !e.is_finite())
|
||||
{
|
||||
// Reject AABBs with non-finite values.
|
||||
// Reject Aabbs with non-finite values.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -401,11 +401,11 @@ impl BroadPhase {
|
||||
let layer = &mut self.layers[layer_id as usize];
|
||||
|
||||
// Preupdate the collider in the layer.
|
||||
// We need to use both the prev AABB and the new AABB for this update, to
|
||||
// handle special cases where one AABB has left a region that doesn’t contain
|
||||
// any other modified AABBs.
|
||||
// We need to use both the prev Aabb and the new Aabb for this update, to
|
||||
// handle special cases where one Aabb has left a region that doesn’t contain
|
||||
// any other modified Aabbs.
|
||||
// If the combination of both previous and new aabbs isn’t more than 25% bigger
|
||||
// than the new AABB, we just merge them to save some computation times (to avoid
|
||||
// than the new Aabb, we just merge them to save some computation times (to avoid
|
||||
// discretizing twice the area at their intersection. If it’s bigger than 25% then
|
||||
// we discretize both aabbs individually.
|
||||
let merged_aabbs = prev_aabb.merged(&aabb);
|
||||
@@ -501,7 +501,7 @@ impl BroadPhase {
|
||||
|
||||
/// Propagate regions from the smallest layers up to the larger layers.
|
||||
///
|
||||
/// Whenever a region is created on a layer `n`, then its AABB must be
|
||||
/// Whenever a region is created on a layer `n`, then its Aabb must be
|
||||
/// added to its larger layer so we can detect when an object
|
||||
/// in a larger layer may start interacting with objects in a smaller
|
||||
/// layer.
|
||||
@@ -551,7 +551,7 @@ impl BroadPhase {
|
||||
// order to account for the fact that a big proxy moved.
|
||||
// NOTE: this 2nd point could probably be improved: instead of updating
|
||||
// all the subregions, we could perhaps just update the subregions
|
||||
// that crosses the boundary of the AABB of the big proxies that
|
||||
// that crosses the boundary of the Aabb of the big proxies that
|
||||
// moved in they layer `n`.
|
||||
let mut layer_id = Some(self.largest_layer);
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ impl SAPAxis {
|
||||
.retain(|endpt| endpt.is_sentinel() || existing_proxies[endpt.proxy() as usize])
|
||||
}
|
||||
|
||||
/// Removes from this axis all the endpoints corresponding to a proxy with an AABB mins/maxs values
|
||||
/// Removes from this axis all the endpoints corresponding to a proxy with an Aabb mins/maxs values
|
||||
/// equal to DELETED_AABB_VALUE, indicating that the endpoints should be deleted.
|
||||
///
|
||||
/// Returns the number of deleted proxies such that `proxy.layer_depth <= layer_depth`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{SAPProxies, SAPProxy, SAPRegion, SAPRegionPool};
|
||||
use crate::geometry::broad_phase_multi_sap::DELETED_AABB_VALUE;
|
||||
use crate::geometry::{SAPProxyIndex, AABB};
|
||||
use crate::geometry::{Aabb, SAPProxyIndex};
|
||||
use crate::math::{Point, Real};
|
||||
use parry::bounding_volume::BoundingVolume;
|
||||
use parry::utils::hashmap::{Entry, HashMap};
|
||||
@@ -215,8 +215,8 @@ impl SAPLayer {
|
||||
pub fn preupdate_collider(
|
||||
&mut self,
|
||||
proxy_id: u32,
|
||||
aabb_to_discretize: &AABB,
|
||||
actual_aabb: Option<&AABB>,
|
||||
aabb_to_discretize: &Aabb,
|
||||
actual_aabb: Option<&Aabb>,
|
||||
proxies: &mut SAPProxies,
|
||||
pool: &mut SAPRegionPool,
|
||||
) {
|
||||
@@ -241,15 +241,15 @@ impl SAPLayer {
|
||||
let region = region_proxy.data.as_region_mut();
|
||||
|
||||
// NOTE: sometimes, rounding errors will generate start/end indices
|
||||
// that lie outside of the actual region’s AABB.
|
||||
// that lie outside of the actual region’s Aabb.
|
||||
// TODO: is there a smarter, more efficient way of dealing with this?
|
||||
if !region_proxy.aabb.intersects(aabb_to_discretize) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(actual_aabb) = actual_aabb {
|
||||
// NOTE: if the actual AABB doesn't intersect the
|
||||
// region’s AABB, then we need to delete the
|
||||
// NOTE: if the actual Aabb doesn't intersect the
|
||||
// region’s Aabb, then we need to delete the
|
||||
// proxy from that region because it means that
|
||||
// during the last update the proxy intersected
|
||||
// that region, but it doesn't intersect it any
|
||||
@@ -267,12 +267,12 @@ impl SAPLayer {
|
||||
}
|
||||
|
||||
pub fn predelete_proxy(&mut self, proxies: &mut SAPProxies, proxy_index: SAPProxyIndex) {
|
||||
// Discretize the AABB to find the regions that need to be invalidated.
|
||||
// Discretize the Aabb to find the regions that need to be invalidated.
|
||||
let proxy_aabb = &mut proxies[proxy_index].aabb;
|
||||
let start = super::point_key(proxy_aabb.mins, self.region_width);
|
||||
let end = super::point_key(proxy_aabb.maxs, self.region_width);
|
||||
|
||||
// Set the AABB of the proxy to a very large value.
|
||||
// Set the Aabb of the proxy to a very large value.
|
||||
proxy_aabb.mins.coords.fill(DELETED_AABB_VALUE);
|
||||
proxy_aabb.maxs.coords.fill(DELETED_AABB_VALUE);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::NEXT_FREE_SENTINEL;
|
||||
use crate::geometry::broad_phase_multi_sap::SAPRegion;
|
||||
use crate::geometry::ColliderHandle;
|
||||
use parry::bounding_volume::AABB;
|
||||
use parry::bounding_volume::Aabb;
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
pub type SAPProxyIndex = u32;
|
||||
@@ -51,7 +51,7 @@ impl SAPProxyData {
|
||||
#[derive(Clone)]
|
||||
pub struct SAPProxy {
|
||||
pub data: SAPProxyData,
|
||||
pub aabb: AABB,
|
||||
pub aabb: Aabb,
|
||||
pub next_free: SAPProxyIndex,
|
||||
// TODO: pack the layer_id and layer_depth into a single u16?
|
||||
pub layer_id: u8,
|
||||
@@ -59,7 +59,7 @@ pub struct SAPProxy {
|
||||
}
|
||||
|
||||
impl SAPProxy {
|
||||
pub fn collider(handle: ColliderHandle, aabb: AABB, layer_id: u8, layer_depth: i8) -> Self {
|
||||
pub fn collider(handle: ColliderHandle, aabb: Aabb, layer_id: u8, layer_depth: i8) -> Self {
|
||||
Self {
|
||||
data: SAPProxyData::Collider(handle),
|
||||
aabb,
|
||||
@@ -69,7 +69,7 @@ impl SAPProxy {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn subregion(subregion: Box<SAPRegion>, aabb: AABB, layer_id: u8, layer_depth: i8) -> Self {
|
||||
pub fn subregion(subregion: Box<SAPRegion>, aabb: Aabb, layer_id: u8, layer_depth: i8) -> Self {
|
||||
Self {
|
||||
data: SAPProxyData::Region(Some(subregion)),
|
||||
aabb,
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::{SAPAxis, SAPProxies};
|
||||
use crate::geometry::SAPProxyIndex;
|
||||
use crate::math::DIM;
|
||||
use bit_vec::BitVec;
|
||||
use parry::bounding_volume::AABB;
|
||||
use parry::bounding_volume::Aabb;
|
||||
use parry::utils::hashmap::HashMap;
|
||||
|
||||
pub type SAPRegionPool = Vec<Box<SAPRegion>>;
|
||||
@@ -25,7 +25,7 @@ pub struct SAPRegion {
|
||||
}
|
||||
|
||||
impl SAPRegion {
|
||||
pub fn new(bounds: AABB) -> Self {
|
||||
pub fn new(bounds: Aabb) -> Self {
|
||||
let axes = [
|
||||
SAPAxis::new(bounds.mins.x, bounds.maxs.x),
|
||||
SAPAxis::new(bounds.mins.y, bounds.maxs.y),
|
||||
@@ -44,7 +44,7 @@ impl SAPRegion {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn recycle(bounds: AABB, mut old: Box<Self>) -> Box<Self> {
|
||||
pub fn recycle(bounds: Aabb, mut old: Box<Self>) -> Box<Self> {
|
||||
// Correct the bounds
|
||||
for i in 0..DIM {
|
||||
// Make sure the axis is empty (it may still contain
|
||||
@@ -73,7 +73,7 @@ impl SAPRegion {
|
||||
old
|
||||
}
|
||||
|
||||
pub fn recycle_or_new(bounds: AABB, pool: &mut Vec<Box<Self>>) -> Box<Self> {
|
||||
pub fn recycle_or_new(bounds: Aabb, pool: &mut Vec<Box<Self>>) -> Box<Self> {
|
||||
if let Some(old) = pool.pop() {
|
||||
Self::recycle(bounds, old)
|
||||
} else {
|
||||
@@ -177,7 +177,7 @@ impl SAPRegion {
|
||||
false
|
||||
} else {
|
||||
// Here we need a second update if all proxies exit this region. In this case, we need
|
||||
// to delete the final proxy, but the region may not have AABBs overlapping it, so it
|
||||
// to delete the final proxy, but the region may not have Aabbs overlapping it, so it
|
||||
// wouldn't get an update otherwise.
|
||||
self.update_count = 2;
|
||||
true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::math::{Point, Real, Vector};
|
||||
use parry::bounding_volume::AABB;
|
||||
use parry::bounding_volume::Aabb;
|
||||
|
||||
pub(crate) const NUM_SENTINELS: usize = 1;
|
||||
pub(crate) const NEXT_FREE_SENTINEL: u32 = u32::MAX;
|
||||
@@ -30,26 +30,26 @@ pub(crate) fn point_key(point: Point<Real>, region_width: Real) -> Point<i32> {
|
||||
.into()
|
||||
}
|
||||
|
||||
pub(crate) fn region_aabb(index: Point<i32>, region_width: Real) -> AABB {
|
||||
pub(crate) fn region_aabb(index: Point<i32>, region_width: Real) -> Aabb {
|
||||
let mins = index.coords.map(|i| i as Real * region_width).into();
|
||||
let maxs = mins + Vector::repeat(region_width);
|
||||
AABB::new(mins, maxs)
|
||||
Aabb::new(mins, maxs)
|
||||
}
|
||||
|
||||
pub(crate) fn region_width(depth: i8) -> Real {
|
||||
(REGION_WIDTH_BASE * REGION_WIDTH_POWER_BASIS.powi(depth as i32)).min(MAX_AABB_EXTENT)
|
||||
}
|
||||
|
||||
/// Computes the depth of the layer the given AABB should be part of.
|
||||
/// Computes the depth of the layer the given Aabb should be part of.
|
||||
///
|
||||
/// The idea here is that an AABB should be part of a layer which has
|
||||
/// regions large enough so that one AABB doesn't crosses too many
|
||||
/// The idea here is that an Aabb should be part of a layer which has
|
||||
/// regions large enough so that one Aabb doesn't crosses too many
|
||||
/// regions. But the regions must also not be too large, otherwise
|
||||
/// we are loosing the benefits of Multi-SAP.
|
||||
///
|
||||
/// If the code bellow, we select a layer such that each region can
|
||||
/// contain at least a chain of 10 contiguous objects with that AABB.
|
||||
pub(crate) fn layer_containing_aabb(aabb: &AABB) -> i8 {
|
||||
/// contain at least a chain of 10 contiguous objects with that Aabb.
|
||||
pub(crate) fn layer_containing_aabb(aabb: &Aabb) -> i8 {
|
||||
// Max number of elements of this size we would like one region to be able to contain.
|
||||
const NUM_ELEMENTS_PER_DIMENSION: Real = 10.0;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ use crate::math::{AngVector, Isometry, Point, Real, Rotation, Vector, DIM};
|
||||
use crate::parry::transformation::vhacd::VHACDParameters;
|
||||
use crate::pipeline::{ActiveEvents, ActiveHooks};
|
||||
use na::Unit;
|
||||
use parry::bounding_volume::AABB;
|
||||
use parry::shape::Shape;
|
||||
use parry::bounding_volume::Aabb;
|
||||
use parry::shape::{Shape, TriMeshFlags};
|
||||
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone)]
|
||||
@@ -348,13 +348,13 @@ impl Collider {
|
||||
}
|
||||
|
||||
/// Compute the axis-aligned bounding box of this collider.
|
||||
pub fn compute_aabb(&self) -> AABB {
|
||||
pub fn compute_aabb(&self) -> Aabb {
|
||||
self.shape.compute_aabb(&self.pos)
|
||||
}
|
||||
|
||||
/// Compute the axis-aligned bounding box of this collider moving from its current position
|
||||
/// to the given `next_position`
|
||||
pub fn compute_swept_aabb(&self, next_position: &Isometry<Real>) -> AABB {
|
||||
pub fn compute_swept_aabb(&self, next_position: &Isometry<Real>) -> Aabb {
|
||||
self.shape.compute_swept_aabb(&self.pos, next_position)
|
||||
}
|
||||
|
||||
@@ -550,6 +550,16 @@ impl ColliderBuilder {
|
||||
Self::new(SharedShape::trimesh(vertices, indices))
|
||||
}
|
||||
|
||||
/// Initializes a collider builder with a triangle mesh shape defined by its vertex and index buffers and
|
||||
/// flags controlling its pre-processing.
|
||||
pub fn trimesh_with_flags(
|
||||
vertices: Vec<Point<Real>>,
|
||||
indices: Vec<[u32; 3]>,
|
||||
flags: TriMeshFlags,
|
||||
) -> Self {
|
||||
Self::new(SharedShape::trimesh_with_flags(vertices, indices, flags))
|
||||
}
|
||||
|
||||
/// Initializes a collider builder with a compound shape obtained from the decomposition of
|
||||
/// the given trimesh (in 3D) or polyline (in 2D) into convex parts.
|
||||
pub fn convex_decomposition(vertices: &[Point<Real>], indices: &[[u32; DIM]]) -> Self {
|
||||
|
||||
@@ -150,3 +150,17 @@ bitflags! {
|
||||
const NONE = 0;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for Group {
|
||||
#[inline]
|
||||
fn from(val: u32) -> Self {
|
||||
unsafe { Self::from_bits_unchecked(val) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Group> for u32 {
|
||||
#[inline]
|
||||
fn from(val: Group) -> Self {
|
||||
val.bits()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ pub type Cylinder = parry::shape::Cylinder;
|
||||
#[cfg(feature = "dim3")]
|
||||
pub type Cone = parry::shape::Cone;
|
||||
/// An axis-aligned bounding box.
|
||||
pub type AABB = parry::bounding_volume::AABB;
|
||||
pub type Aabb = parry::bounding_volume::Aabb;
|
||||
/// A ray that can be cast against colliders.
|
||||
pub type Ray = parry::query::Ray;
|
||||
/// The intersection between a ray and a collider.
|
||||
@@ -178,7 +178,7 @@ impl ContactForceEvent {
|
||||
|
||||
pub(crate) use self::broad_phase_multi_sap::SAPProxyIndex;
|
||||
pub(crate) use self::narrow_phase::ContactManifoldIndex;
|
||||
pub(crate) use parry::partitioning::QBVH;
|
||||
pub(crate) use parry::partitioning::Qbvh;
|
||||
pub use parry::shape::*;
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
|
||||
@@ -30,7 +30,7 @@ bitflags::bitflags! {
|
||||
const SOLVER_CONTACTS = 1 << 4;
|
||||
/// If this flag is set, the geometric contacts will be rendered.
|
||||
const CONTACTS = 1 << 5;
|
||||
/// If this flag is set, the AABBs of colliders will be rendered.
|
||||
/// If this flag is set, the Aabbs of colliders will be rendered.
|
||||
const COLLIDER_AABBS = 1 << 6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ pub struct DebugRenderStyle {
|
||||
pub contact_normal_color: DebugColor,
|
||||
/// The length of the contact normals.
|
||||
pub contact_normal_length: Real,
|
||||
/// The color of the colliders AABBs.
|
||||
/// The color of the colliders Aabbs.
|
||||
pub collider_aabb_color: DebugColor,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::dynamics::{IslandManager, RigidBodyHandle};
|
||||
use crate::geometry::{
|
||||
Collider, ColliderHandle, InteractionGroups, PointProjection, Ray, RayIntersection, AABB, QBVH,
|
||||
Aabb, Collider, ColliderHandle, InteractionGroups, PointProjection, Qbvh, Ray, RayIntersection,
|
||||
};
|
||||
use crate::math::{Isometry, Point, Real, Vector};
|
||||
use crate::{dynamics::RigidBodySet, geometry::ColliderSet};
|
||||
use parry::partitioning::QBVHDataGenerator;
|
||||
use parry::partitioning::QbvhDataGenerator;
|
||||
use parry::query::details::{
|
||||
IntersectionCompositeShapeShapeBestFirstVisitor,
|
||||
NonlinearTOICompositeShapeShapeBestFirstVisitor, PointCompositeShapeProjBestFirstVisitor,
|
||||
@@ -17,6 +17,7 @@ use parry::query::visitors::{
|
||||
};
|
||||
use parry::query::{DefaultQueryDispatcher, NonlinearRigidMotion, QueryDispatcher, TOI};
|
||||
use parry::shape::{FeatureId, Shape, TypedSimdCompositeShape};
|
||||
use parry::utils::DefaultStorage;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A pipeline for performing queries on all the colliders of a scene.
|
||||
@@ -28,7 +29,7 @@ pub struct QueryPipeline {
|
||||
serde(skip, default = "crate::geometry::default_query_dispatcher")
|
||||
)]
|
||||
query_dispatcher: Arc<dyn QueryDispatcher>,
|
||||
qbvh: QBVH<ColliderHandle>,
|
||||
qbvh: Qbvh<ColliderHandle>,
|
||||
tree_built: bool,
|
||||
dilation_factor: Real,
|
||||
}
|
||||
@@ -245,6 +246,7 @@ pub enum QueryPipelineMode {
|
||||
impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> {
|
||||
type PartShape = dyn Shape;
|
||||
type PartId = ColliderHandle;
|
||||
type QbvhStorage = DefaultStorage;
|
||||
|
||||
fn map_typed_part_at(
|
||||
&self,
|
||||
@@ -266,7 +268,7 @@ impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> {
|
||||
self.map_typed_part_at(shape_id, f);
|
||||
}
|
||||
|
||||
fn typed_qbvh(&self) -> &QBVH<ColliderHandle> {
|
||||
fn typed_qbvh(&self) -> &Qbvh<ColliderHandle> {
|
||||
&self.query_pipeline.qbvh
|
||||
}
|
||||
}
|
||||
@@ -307,7 +309,7 @@ impl QueryPipeline {
|
||||
{
|
||||
Self {
|
||||
query_dispatcher: Arc::new(d),
|
||||
qbvh: QBVH::new(),
|
||||
qbvh: Qbvh::new(),
|
||||
tree_built: false,
|
||||
dilation_factor: 0.01,
|
||||
}
|
||||
@@ -347,13 +349,13 @@ impl QueryPipeline {
|
||||
mode: QueryPipelineMode,
|
||||
}
|
||||
|
||||
impl<'a> QBVHDataGenerator<ColliderHandle> for DataGenerator<'a> {
|
||||
impl<'a> QbvhDataGenerator<ColliderHandle> for DataGenerator<'a> {
|
||||
fn size_hint(&self) -> usize {
|
||||
self.colliders.len()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn for_each(&mut self, mut f: impl FnMut(ColliderHandle, AABB)) {
|
||||
fn for_each(&mut self, mut f: impl FnMut(ColliderHandle, Aabb)) {
|
||||
match self.mode {
|
||||
QueryPipelineMode::CurrentPosition => {
|
||||
for (h, co) in self.colliders.iter() {
|
||||
@@ -673,10 +675,10 @@ impl QueryPipeline {
|
||||
.map(|h| (h.1 .1 .0, h.1 .0, h.1 .1 .1))
|
||||
}
|
||||
|
||||
/// Finds all handles of all the colliders with an AABB intersecting the given AABB.
|
||||
/// Finds all handles of all the colliders with an Aabb intersecting the given Aabb.
|
||||
pub fn colliders_with_aabb_intersecting_aabb(
|
||||
&self,
|
||||
aabb: &AABB,
|
||||
aabb: &Aabb,
|
||||
mut callback: impl FnMut(&ColliderHandle) -> bool,
|
||||
) {
|
||||
let mut visitor = BoundingVolumeIntersectionsVisitor::new(aabb, &mut callback);
|
||||
|
||||
Reference in New Issue
Block a user