Skip to content

Commit 189be32

Browse files
committed
feat(rapier): deprecate erp; add contactNaturalFrequency
1 parent dae630f commit 189be32

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

libs/core/src/lib/utils/object-events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const NgtObjectEventsOutputs = [
6565

6666
/**
6767
* @deprecated Use NgtObjectEventsInputs and NgtObjectEventsOutputs instead along with NgtObjectEvents
68-
* @since 2.5.3. Will be removed in 3.0.0
68+
* @since 2.6.0 Will be removed in 3.0.0
6969
*/
7070
export const NgtObjectEventsHostDirective = {
7171
directive: NgtObjectEvents,

libs/rapier/src/lib/physics.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const defaultOptions: NgtrPhysicsOptions = {
4040
predictionDistance: 0.002,
4141
minIslandSize: 128,
4242
maxCcdSubsteps: 1,
43+
contactNaturalFrequency: 30,
4344
erp: 0.8,
4445
lengthUnit: 1,
4546
colliders: 'cuboid',
@@ -97,7 +98,7 @@ export class NgtrPhysics {
9798
private minIslandSize = pick(this.options, 'minIslandSize');
9899
private maxCcdSubsteps = pick(this.options, 'maxCcdSubsteps');
99100
private predictionDistance = pick(this.options, 'predictionDistance');
100-
private erp = pick(this.options, 'erp');
101+
private contactNaturalFrequency = pick(this.options, 'contactNaturalFrequency');
101102
private lengthUnit = pick(this.options, 'lengthUnit');
102103
private timeStep = pick(this.options, 'timeStep');
103104
private interpolate = pick(this.options, 'interpolate');
@@ -180,11 +181,7 @@ export class NgtrPhysics {
180181
world.proxy.integrationParameters.minIslandSize = this.minIslandSize();
181182
world.proxy.integrationParameters.maxCcdSubsteps = this.maxCcdSubsteps();
182183
world.proxy.integrationParameters.normalizedPredictionDistance = this.predictionDistance();
183-
/**
184-
* NOTE: we don't know if this is the correct way to set for contact_natural_frequency or not.
185-
* but at least, it gets the `contact_erp` value to be very close with setting `erp`
186-
*/
187-
world.proxy.integrationParameters.contact_natural_frequency = this.erp() * 1_000;
184+
world.proxy.integrationParameters.contact_natural_frequency = this.contactNaturalFrequency();
188185
world.proxy.lengthUnit = this.lengthUnit();
189186
}
190187

libs/rapier/src/lib/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,25 @@ export interface NgtrPhysicsOptions {
7878
*/
7979
maxCcdSubsteps: number;
8080

81+
/**
82+
* Directly affects the erp (Error Reduction Parameter) which is the proportion (between 0 and 1) of the positional error to be corrected at each time step.
83+
*
84+
* The higher the value, the more the physics engine will try to correct the positional error.
85+
*
86+
* This property is currently undocumented in rapier docs.
87+
*
88+
* @defaultValue 30
89+
*/
90+
contactNaturalFrequency: number;
91+
8192
/**
8293
* The Error Reduction Parameter in between 0 and 1, is the proportion of the positional error to be corrected at each time step.
8394
*
8495
* @defaultValue 0.8
96+
* @deprecated This is a noop. Use `contactNaturalFrequency` instead
97+
* @since 2.6.0 Will be removed in 3.0.0
98+
* @see {contactNaturalFrequency}
99+
* @see https://github.com/dimforge/rapier/pull/651 for more information about contactNaturalFrequency
85100
*/
86101
erp: number;
87102

0 commit comments

Comments
 (0)