Skip to content

Commit 2198243

Browse files
committed
Add restitution (elasticity)
1 parent c271062 commit 2198243

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cpp/JSIBox2dFixtureDef.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ namespace Box2d {
2727
getObject()->friction = value.asNumber();
2828
}
2929

30+
JSI_PROPERTY_SET(restitution) {
31+
getObject()->restitution = value.asNumber();
32+
}
33+
3034
JSI_EXPORT_PROPERTY_SETTERS(
3135
JSI_EXPORT_PROP_SET(JSIBox2dFixtureDef, shape),
3236
JSI_EXPORT_PROP_SET(JSIBox2dFixtureDef, density),
33-
JSI_EXPORT_PROP_SET(JSIBox2dFixtureDef, friction))
37+
JSI_EXPORT_PROP_SET(JSIBox2dFixtureDef, friction),
38+
JSI_EXPORT_PROP_SET(JSIBox2dFixtureDef, restitution))
3439

3540
/**
3641
* Constructor

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export interface b2FixtureDef {
4646
**/
4747
friction: number;
4848

49+
/**
50+
* The restitution (elasticity) usually in the range [0,1].
51+
**/
52+
restitution: number;
53+
4954
/**
5055
* The shape, this must be set. The shape will be cloned, so you can create the shape on the stack.
5156
**/

0 commit comments

Comments
 (0)