diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a248a19..040bbfe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## 0.18.0 (30 Oct. 2022) +### Added +- Add the accessor `RapierContext::physics_scale()` to read the physics scale + that was set when initializing the plugin. +- Add `RapierConfiguration::force_update_from_transform_changes` to force the transform + updates even if it is equal to the transform that was previously set. Useful for + rollback in networked applications described in [#261](https://github.com/dimforge/bevy_rapier/pull/261). +- Add `Collider::trimesh_with_flags` to create a triangle mesh collider with custom pre-processing + flags. + +### Fix +- Reset the `ExternalImpulse` component after each step automatically. +- Fix `transform_to_iso` to preserve identical rotations instead of + converting to an intermediate axis-angle representation. +- Fix **internal edges** of 3D triangle meshes or 3D heightfields generating invalid contacts + preventing balls from moving straight. Be sure to set the triangle mesh flag + `TriMeshFlags::MERGE_DUPLICATE_VERTICES` when creating the collider if your mesh have duplicated + vertices. + +### Modified +- Rename `AABB` to `Aabb` to comply with Rust’s style guide. + ## 0.17.0 (02 Oct. 2022) ### Added - Add a **kinematic character controller** implementation. This feature is accessible in two different ways: diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index 48d27ac7..a39e8546 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_rapier2d" -version = "0.17.0" +version = "0.18.0" authors = ["Sébastien Crozet "] description = "2-dimensional physics engine in Rust, official Bevy plugin." documentation = "http://docs.rs/bevy_rapier2d" @@ -32,7 +32,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ] bevy = { version = "0.8.0", default-features = false, features = ["bevy_asset", "bevy_scene"] } nalgebra = { version = "^0.31.1", features = [ "convert-glam021" ] } # Don't enable the default features because we don't need the ColliderSet/RigidBodySet -rapier2d = "0.15.0" +rapier2d = "0.16.0" bitflags = "1" #bevy_prototype_debug_lines = { version = "0.6", optional = true } log = "0.4" diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index 57508479..9c7ddef4 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_rapier3d" -version = "0.17.0" +version = "0.18.0" authors = ["Sébastien Crozet "] description = "3-dimensional physics engine in Rust, official Bevy plugin." documentation = "http://docs.rs/bevy_rapier3d" @@ -32,7 +32,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ] bevy = { version = "0.8.0", default-features = false, features = ["bevy_asset", "bevy_scene"] } nalgebra = { version = "^0.31.1", features = [ "convert-glam021" ] } # Don't enable the default features because we don't need the ColliderSet/RigidBodySet -rapier3d = "0.15.0" +rapier3d = "0.16.0" bitflags = "1" #bevy_prototype_debug_lines = { version = "0.6", features = ["3d"], optional = true } log = "0.4" diff --git a/src/geometry/collider_impl.rs b/src/geometry/collider_impl.rs index ecddab10..64acbcc4 100644 --- a/src/geometry/collider_impl.rs +++ b/src/geometry/collider_impl.rs @@ -11,7 +11,7 @@ use rapier::prelude::{FeatureId, Point, Ray, SharedShape, Vector, DIM}; use super::shape_views::*; #[cfg(feature = "dim3")] use crate::geometry::ComputedColliderShape; -use crate::geometry::{Collider, PointProjection, RayIntersection, VHACDParameters}; +use crate::geometry::{Collider, PointProjection, RayIntersection, TriMeshFlags, VHACDParameters}; use crate::math::{Real, Rot, Vect}; impl Collider { @@ -156,6 +156,17 @@ impl Collider { SharedShape::trimesh(vertices, indices).into() } + /// Initializes a collider 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, + indices: Vec<[u32; 3]>, + flags: TriMeshFlags, + ) -> Self { + let vertices = vertices.into_iter().map(|v| v.into()).collect(); + SharedShape::trimesh_with_flags(vertices, indices, flags).into() + } + /// Initializes a collider with a Bevy Mesh. /// /// Returns `None` if the index buffer or vertex buffer of the mesh are in an incompatible format. @@ -163,9 +174,10 @@ impl Collider { pub fn from_bevy_mesh(mesh: &Mesh, collider_shape: &ComputedColliderShape) -> Option { let vertices_indices = extract_mesh_vertices_indices(mesh); match collider_shape { - ComputedColliderShape::TriMesh => { - vertices_indices.map(|(vtx, idx)| SharedShape::trimesh(vtx, idx).into()) - } + ComputedColliderShape::TriMesh => vertices_indices.map(|(vtx, idx)| { + SharedShape::trimesh_with_flags(vtx, idx, TriMeshFlags::MERGE_DUPLICATE_VERTICES) + .into() + }), ComputedColliderShape::ConvexDecomposition(params) => { vertices_indices.map(|(vtx, idx)| { SharedShape::convex_decomposition_with_params(&vtx, &idx, params).into() diff --git a/src/plugin/context.rs b/src/plugin/context.rs index 3b31b0f5..341e0e5c 100644 --- a/src/plugin/context.rs +++ b/src/plugin/context.rs @@ -3,11 +3,10 @@ use std::collections::HashMap; use std::sync::RwLock; use rapier::prelude::{ - BroadPhase, CCDSolver, ColliderHandle, ColliderSet, EventHandler, FeatureId, - ImpulseJointHandle, ImpulseJointSet, IntegrationParameters, IslandManager, + Aabb as RapierAabb, BroadPhase, CCDSolver, ColliderHandle, ColliderSet, EventHandler, + FeatureId, ImpulseJointHandle, ImpulseJointSet, IntegrationParameters, IslandManager, MultibodyJointHandle, MultibodyJointSet, NarrowPhase, PhysicsHooks, PhysicsPipeline, QueryFilter as RapierQueryFilter, QueryPipeline, Ray, Real, RigidBodyHandle, RigidBodySet, - AABB, }; use crate::geometry::{Collider, PointProjection, RayIntersection, Toi}; @@ -708,19 +707,19 @@ impl RapierContext { }) } - /// Finds all entities of all the colliders with an AABB intersecting the given AABB. + /// Finds all entities of all the colliders with an Aabb intersecting the given Aabb. pub fn colliders_with_aabb_intersecting_aabb( &self, aabb: Aabb, mut callback: impl FnMut(Entity) -> bool, ) { #[cfg(feature = "dim2")] - let scaled_aabb = AABB { + let scaled_aabb = RapierAabb { mins: (aabb.min().xy() / self.physics_scale).into(), maxs: (aabb.max().xy() / self.physics_scale).into(), }; #[cfg(feature = "dim3")] - let scaled_aabb = AABB { + let scaled_aabb = RapierAabb { mins: (aabb.min() / self.physics_scale).into(), maxs: (aabb.max() / self.physics_scale).into(), }; diff --git a/src/plugin/narrow_phase.rs b/src/plugin/narrow_phase.rs index 24400be4..001ef60e 100644 --- a/src/plugin/narrow_phase.rs +++ b/src/plugin/narrow_phase.rs @@ -222,12 +222,12 @@ impl<'a> ContactView<'a> { /// The feature ID of the first shape involved in the contact. pub fn fid1(&self) -> u32 { - self.raw.fid1 + self.raw.fid1.0 } /// The feature ID of the second shape involved in the contact. pub fn fid2(&self) -> u32 { - self.raw.fid2 + self.raw.fid2.0 } /// The impulse, along the contact normal, applied by this contact to the first collider's rigid-body.