Skip to content

Commit dfaeab2

Browse files
authored
Merge pull request #3 from tomekzaw/restitution
Add restitution (elasticity)
2 parents 426d940 + 2198243 commit dfaeab2

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
@@ -62,6 +62,11 @@ export interface b2FixtureDef {
6262
**/
6363
friction: number;
6464

65+
/**
66+
* The restitution (elasticity) usually in the range [0,1].
67+
**/
68+
restitution: number;
69+
6570
/**
6671
* The shape, this must be set. The shape will be cloned, so you can create the shape on the stack.
6772
**/

0 commit comments

Comments
 (0)