Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to rapier 0.13.0 #273

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 56 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
### 0.13.0 (2024-05-05)

Several stability improvements are added as part of this release.
See [rapier#625](https://github.com/dimforge/rapier/pull/625) for overviews of the most important improvements.

#### Modified

- The `castShape` and `castCollider` functions have been modified to add a `targetDistance` parameter. This parameter
indicates the distance below which a hit is detected.
- Rename `RayIntersection.toi` to `.timeOfImpact` for better clarity.
- Rename `RayColliderIntersection.toi` to `.timeOfImpact` for better clarity.
- Rename `RayColliderToi` to `RayColliderHit`.
- Rename `RayColliderHit.toi` to `.timeOfImpact` for better clarity.
- Rename `ShapeTOI` to `ShapeCastHit`.
- Rename `ShapeColliderTOI` to `ColliderShapeCastHit`.
- Rename `ShapeCastHit.toi` to `.timeOfImpact`.

#### Added

- Fix the kinematic character controller getting stuck against vertical walls.
- Add `KinematicCharacterController.normalNudgeFactor` and `.setNormalNudgeFactor` so set a coefficient used for
avoiding having the character controller get stuck on penetrations.
- Add `RigidBody.softCcdPrediction`, `.setSoftCcdPrediction`, and `RigidBodyDesc.setSoftCcdPrediction` for configuring
soft-ccd on the rigid-body. See [rapier#625](https://github.com/dimforge/rapier/pull/625) for additional details on
soft-ccd.
- 3D version only: add `TriMeshFlags::FIX_INTERNAL_EDGES` and `HeightFieldFlags::FIX_INTERNAL_EDGES` for enabling
internal edges correction (which is no longer enabled by default). The flags have been added as an optional parameter
when building the shapes.
- Add `Collider.contactSkin`, `.setContactSkin`, and `ColliderDesc.setContactSkin` for configuring the collider’s
contact skin. See [rapier#625](https://github.com/dimforge/rapier/pull/625) for additional details on contact skins.
- Add `World.lengthUnit` which can be used to indicate the typical size of dynamic objects (e.g. 100 pixels instead of
1 meter). This helps the physics engine adjust internal thresholds for better results.

#### Fixed

- Fix an issue where the reported contact force are lower than their actual value.

### 0.12.0 (2024-01-28)

The main highlight of this release is the implementation of a new non-linear constraints solver for better stability
Expand Down Expand Up @@ -63,7 +100,8 @@ without affecting performance of the other parts of the simulation.
attached colliders) without removing it from the physics world.
- Add `Collider.isEnabled, Collider.setEnabled, ColliderDesc.setEnabled` to disable a collider without removing it
from the physics world.
- Add shape-specific methods to modify a collider’s size: `Collider.setRadius, setHalfExtents, setRoundRadius, setHalfHeight`.
- Add shape-specific methods to modify a collider’s
size: `Collider.setRadius, setHalfExtents, setRoundRadius, setHalfHeight`.

#### Modified

Expand Down Expand Up @@ -188,7 +226,8 @@ to the `master` branch.
automatically wake-up the rigid-bodies attached to the inserted joint.
- Add a `filter` callback to all the scene queries. Use this for filtering more fine-grained than collision groups.
- Add `collider.shape` that represents the shape of a collider. This is a more convenient way of reading the collider’s
shape properties. Modifying this shape will have no effect unless `collider.setShape` is called with the modified shape.
shape properties. Modifying this shape will have no effect unless `collider.setShape` is called with the modified
shape.
- Add `Collider.containsPoint`, `.projectPoint`, `.intersectsRay`, `.castShape`, `.castCollider`, `.intersectsShape`,
`.contactShape`, `.contactCollider`, `.castRay`, `.castRayAndGetNormal`.
- Add `Shape.containsPoint`, `.projectPoint`, `.intersectsRay`, `.castShape`, `.intersectsShape`,
Expand Down Expand Up @@ -287,7 +326,8 @@ This release was broken and has been unpublished.

### v0.7.0

The typescripts bindings for Rapier have a [brand new user-guide](https://rapier.rs/docs/user_guides/javascript/getting_started_js)
The typescripts bindings for Rapier have
a [brand new user-guide](https://rapier.rs/docs/user_guides/javascript/getting_started_js)
covering all the features of the physics engine!

### Breaking change
Expand All @@ -306,8 +346,10 @@ covering all the features of the physics engine!

- Add `Ray.pointAt(t)` that conveniently computes `ray.origin + ray.dir * t`.
- Add access to joint motors by defining each joint with its own class deriving from `Joint`. Each joint now
have its relevant motor configuration methods: `configurMotorModel, configureMotorVelocity, configureMotorPosition, configureMotor`.
- Add `World.collidersWithAabbIntersectingAabb` for retrieving the handles of all the colliders intersecting the given AABB.
have its relevant motor configuration
methods: `configurMotorModel, configureMotorVelocity, configureMotorPosition, configureMotor`.
- Add `World.collidersWithAabbIntersectingAabb` for retrieving the handles of all the colliders intersecting the given
AABB.
- Add many missing methods for reading/modifying a rigid-body state after its creation:
- `RigidBody.lockTranslations`
- `RigidBody.lockRotations`
Expand Down Expand Up @@ -336,25 +378,29 @@ covering all the features of the physics engine!
- `Collider.setTranslationWrtParent`
- `Collider.setRotation`
- `Collider.setRotationWrtParent`
- Add `ColliderDesc.setMassProperties` for setting explicitly the mass properties of the collider being built (instead of relying on density).
- Add `ColliderDesc.setMassProperties` for setting explicitly the mass properties of the collider being built (instead
of relying on density).

#### Modified

- Colliders are no longer required to be attached to a rigid-body. Therefore, the second argument of `World.createCollider`
- Colliders are no longer required to be attached to a rigid-body. Therefore, the second argument
of `World.createCollider`
is now optional.

### v0.6.0

#### Breaking changes

- The `BodyStatus::Kinematic` variant has been replaced by `BodyStatus::KinematicPositionBased` and
`BodyStatus::KinematicVelocityBased`. Position-based kinematic bodies are controlled by setting (at each frame) the next
`BodyStatus::KinematicVelocityBased`. Position-based kinematic bodies are controlled by setting (at each frame) the
next
kinematic position of the rigid-body (just like before), and the velocity-based kinematic bodies are controlled
by setting (at each frame) the velocity of the rigid-body.
- The `RigidBodyDesc.newKinematic` has been replaced by `RigidBodyDesc.newKinematicPositionBased` and
`RigidBodyDesc.newKinematicVelocityBased` in order to build a position-based or velocity-based kinematic body.
- All contact and intersection events are now disabled by default. The can be enabled for each collider individually
by setting its `ActiveEvents`: `ColliderDesc.setActiveEvents(ActiveEvents.PROXIMITY_EVENTS | ActiveEvents.ContactEvents)`.
by setting
its `ActiveEvents`: `ColliderDesc.setActiveEvents(ActiveEvents.PROXIMITY_EVENTS | ActiveEvents.ContactEvents)`.

#### Added

Expand Down Expand Up @@ -491,7 +537,7 @@ Breaking changes related to scene queries:
- The `QueryPipeline.castRay` method now takes two additional parameters: a boolean indicating if the ray should not
propagate if it starts inside of a shape, and a bit mask indicating the group the ray is part of and these it
interacts with.
- The `World.castRay` and `QueryPipeline.castRay` now return a struct of type `RayColliderToi`
- The `World.castRay` and `QueryPipeline.castRay` now return a struct of type `RayColliderHit`
which no longer contains the normal at the hit point. Use the new methods `World.castRayAndGetNormal`
or `QueryPipeline.castRayAndGetNormal` in order to retrieve the normal too.

Expand Down
54 changes: 31 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ codegen-units = 1
#lto = true

[patch.crates-io]
# rapier2d = { path = "../rapier/crates/rapier2d" }
# rapier3d = { path = "../rapier/crates/rapier3d" }
#rapier2d = { path = "../rapier/crates/rapier2d" }
#rapier3d = { path = "../rapier/crates/rapier3d" }
#parry2d = { path = "../parry/crates/parry2d" }
#parry3d = { path = "../parry/crates/parry3d" }
#nalgebra = { path = "../nalgebra" }
Expand Down
4 changes: 2 additions & 2 deletions rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dimforge_rapier2d" # Can't be named rapier2d which conflicts with the dependency.
version = "0.12.0"
version = "0.13.0"
authors = ["Sébastien Crozet <[email protected]>"]
description = "2-dimensional physics engine in Rust - official JS bindings."
documentation = "https://rapier.rs/rustdoc/rapier2d/index.html"
Expand All @@ -23,7 +23,7 @@ required-features = ["dim2"]


[dependencies]
rapier2d = { version = "0.18.0", features = ["wasm-bindgen", "serde-serialize", "enhanced-determinism", "debug-render"] }
rapier2d = { version = "0.19.0", features = ["wasm-bindgen", "serde-serialize", "enhanced-determinism", "debug-render"] }
ref-cast = "1"
wasm-bindgen = "0.2.90"
js-sys = "0.3"
Expand Down
6 changes: 3 additions & 3 deletions rapier2d/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"pkg/rapier_wasm2d.d.ts:RawPointColliderProjection",
"pkg/rapier_wasm2d.d.ts:RawPointProjection",
"pkg/rapier_wasm2d.d.ts:RawRayColliderIntersection",
"pkg/rapier_wasm2d.d.ts:RawRayColliderToi",
"pkg/rapier_wasm2d.d.ts:RawRayColliderHit",
"pkg/rapier_wasm2d.d.ts:RawRayIntersection",
"pkg/rapier_wasm2d.d.ts:RawShapeColliderTOI",
"pkg/rapier_wasm2d.d.ts:RawColliderShapeCastHit",
"pkg/rapier_wasm2d.d.ts:RawShapeContact",
"pkg/rapier_wasm2d.d.ts:RawShapeTOI",
"pkg/rapier_wasm2d.d.ts:RawShapeCastHit",
"pkg/rapier_wasm2d.d.ts:RawQueryPipeline",
"pkg/rapier_wasm2d.d.ts:RawDeserializedWorld",
"pkg/rapier_wasm2d.d.ts:RawDebugRenderPipeline",
Expand Down
4 changes: 2 additions & 2 deletions rapier3d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dimforge_rapier3d" # Can't be named rapier3d which conflicts with the dependency.
version = "0.12.0"
version = "0.13.0"
authors = ["Sébastien Crozet <[email protected]>"]
description = "3-dimensional physics engine in Rust - official JS bindings."
documentation = "https://rapier.rs/rustdoc/rapier2d/index.html"
Expand All @@ -23,7 +23,7 @@ required-features = ["dim3"]


[dependencies]
rapier3d = { version = "0.18.0", features = ["wasm-bindgen", "serde-serialize", "enhanced-determinism", "debug-render"] }
rapier3d = { version = "0.19.0", features = ["wasm-bindgen", "serde-serialize", "enhanced-determinism", "debug-render"] }
ref-cast = "1"
wasm-bindgen = "^0.2.90"
js-sys = "0.3"
Expand Down
6 changes: 3 additions & 3 deletions rapier3d/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"pkg/rapier_wasm3d.d.ts:RawPointColliderProjection",
"pkg/rapier_wasm3d.d.ts:RawPointProjection",
"pkg/rapier_wasm3d.d.ts:RawRayColliderIntersection",
"pkg/rapier_wasm3d.d.ts:RawRayColliderToi",
"pkg/rapier_wasm3d.d.ts:RawRayColliderHit",
"pkg/rapier_wasm3d.d.ts:RawRayIntersection",
"pkg/rapier_wasm3d.d.ts:RawShapeColliderTOI",
"pkg/rapier_wasm3d.d.ts:RawColliderShapeCastHit",
"pkg/rapier_wasm3d.d.ts:RawShapeContact",
"pkg/rapier_wasm3d.d.ts:RawShapeTOI",
"pkg/rapier_wasm3d.d.ts:RawShapeCastHit",
"pkg/rapier_wasm3d.d.ts:RawQueryPipeline",
"pkg/rapier_wasm3d.d.ts:RawDeserializedWorld",
"pkg/rapier_wasm3d.d.ts:RawDebugRenderPipeline",
Expand Down
24 changes: 24 additions & 0 deletions src.ts/control/character_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ export class KinematicCharacterController {
this.raw.setOffset(value);
}

/// Increase this number if your character appears to get stuck when sliding against surfaces.
///
/// This is a small distance applied to the movement toward the contact normals of shapes hit
/// by the character controller. This helps shape-casting not getting stuck in an always-penetrating
/// state during the sliding calculation.
///
/// This value should remain fairly small since it can introduce artificial "bumps" when sliding
/// along a flat surface.
public normalNudgeFactor(): number {
return this.raw.normalNudgeFactor();
}

/// Increase this number if your character appears to get stuck when sliding against surfaces.
///
/// This is a small distance applied to the movement toward the contact normals of shapes hit
/// by the character controller. This helps shape-casting not getting stuck in an always-penetrating
/// state during the sliding calculation.
///
/// This value should remain fairly small since it can introduce artificial "bumps" when sliding
/// along a flat surface.
public setNormalNudgeFactor(value: number) {
this.raw.setNormalNudgeFactor(value);
}

/**
* Is sliding against obstacles enabled?
*/
Expand Down
Loading
Loading