Fixes 03 (#40)
Fixes #33, #34, #35, #37, #39, #41, #42, #43 Also fixes b3Body_SetMassData inertia tensor.
This commit is contained in:
parent
29bf523ce7
commit
655799893a
25 changed files with 771 additions and 151 deletions
|
|
@ -704,22 +704,25 @@ instead of bodies. Since you can attach multiple shapes to a body, this allows f
|
|||
possible setups. For example, you can make a vehicle that is heavier in the back.
|
||||
|
||||
### Density
|
||||
|
||||
The shape density is used to compute the mass properties of the parent
|
||||
body. The density can be zero or positive. You should generally use
|
||||
similar densities for all your shapes. This will improve stacking
|
||||
stability.
|
||||
|
||||
The mass of a body is not adjusted when you set the density. You must
|
||||
call `b3Body_ApplyMassFromShapes()` for this to occur. Generally you should establish
|
||||
the shape density in `b3ShapeDef` and avoid modifying it later because this
|
||||
can be expensive, especially on a compound body.
|
||||
You may adjust the density of an existing body. You may choose to update the body mass immediately
|
||||
or defer for a later call to `b3Body_ApplyMassFromShapes()`. Generally you should establish
|
||||
the shape density in `b3ShapeDef` and avoid modifying it later because this can be expensive,
|
||||
especially on a body with many shapes.
|
||||
|
||||
```c
|
||||
b3Shape_SetDensity(myShapeId, 5.0f, true);
|
||||
bool updateMass = false;
|
||||
b3Shape_SetDensity(myShapeId, 5.0f, updateMass);
|
||||
b3Body_ApplyMassFromShapes(myBodyId);
|
||||
```
|
||||
|
||||
### Friction
|
||||
|
||||
Friction is used to make objects slide along each other realistically.
|
||||
Box3D supports static and dynamic friction, but uses the same parameter
|
||||
for both. Box3D attempts to simulate friction accurately and the friction
|
||||
|
|
@ -745,6 +748,7 @@ shapeDef.baseMaterial.friction = 0.5f;
|
|||
```
|
||||
|
||||
### Restitution
|
||||
|
||||
[Restitution](https://en.wikipedia.org/wiki/Coefficient_of_restitution) is used to make
|
||||
objects bounce. The restitution value is
|
||||
usually set to be between 0 and 1. Consider dropping a ball on a table.
|
||||
|
|
@ -772,6 +776,7 @@ shapeDef.baseMaterial.restitution = 0.3f;
|
|||
```
|
||||
|
||||
### Friction and Restitution Callbacks
|
||||
|
||||
Advanced users can override friction and restitution mixing using `b3FrictionCallback`
|
||||
and `b3RestitutionCallback`. These should be very lightweight functions because they
|
||||
are called frequently. The callbacks receive the two friction (or restitution) values
|
||||
|
|
@ -794,6 +799,7 @@ worldDef.frictionCallback = MyFrictionCallback;
|
|||
```
|
||||
|
||||
### Filtering {#filtering}
|
||||
|
||||
Collision filtering allows you to efficiently prevent collision between shapes.
|
||||
For example, say you make a character that rides a bicycle. You want the
|
||||
bicycle to collide with the terrain and the character to collide with
|
||||
|
|
@ -866,6 +872,7 @@ Collision groups have a higher priority than categories and masks.
|
|||
|
||||
Note that additional collision filtering occurs automatically in Box3D. Here is a
|
||||
list:
|
||||
|
||||
- A shape on a static body can only collide with a dynamic body.
|
||||
- A shape on a kinematic body can only collide with a dynamic body.
|
||||
- Shapes on the same body never collide with each other.
|
||||
|
|
@ -878,6 +885,7 @@ an existing shape using `b3Shape_GetFilter()` and
|
|||
it causes contacts to be destroyed.
|
||||
|
||||
### Sensors
|
||||
|
||||
Sometimes game logic needs to know when two shapes overlap yet there
|
||||
should be no collision response. This is done by using sensors. A sensor
|
||||
is a shape that detects overlap but does not produce a response.
|
||||
|
|
|
|||
Loading…
Reference in a new issue