Skip to content

Commit b864f53

Browse files
authored
Friction and restitution mixing rules (#811)
get/set max linear velocity
1 parent e7cb9f0 commit b864f53

File tree

11 files changed

+298
-238
lines changed

11 files changed

+298
-238
lines changed

include/box2d/base.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,26 @@
4444
*/
4545

4646
/// Prototype for user allocation function
47-
/// @param size the allocation size in bytes
48-
/// @param alignment the required alignment, guaranteed to be a power of 2
47+
/// @param size the allocation size in bytes
48+
/// @param alignment the required alignment, guaranteed to be a power of 2
4949
typedef void* b2AllocFcn( unsigned int size, int alignment );
5050

5151
/// Prototype for user free function
52-
/// @param mem the memory previously allocated through `b2AllocFcn`
52+
/// @param mem the memory previously allocated through `b2AllocFcn`
5353
typedef void b2FreeFcn( void* mem );
5454

5555
/// Prototype for the user assert callback. Return 0 to skip the debugger break.
5656
typedef int b2AssertFcn( const char* condition, const char* fileName, int lineNumber );
5757

5858
/// This allows the user to override the allocation functions. These should be
59-
/// set during application startup.
59+
/// set during application startup.
6060
B2_API void b2SetAllocator( b2AllocFcn* allocFcn, b2FreeFcn* freeFcn );
6161

6262
/// @return the total bytes allocated by Box2D
6363
B2_API int b2GetByteCount( void );
6464

6565
/// Override the default assert callback
66-
/// @param assertFcn a non-null assert callback
66+
/// @param assertFcn a non-null assert callback
6767
B2_API void b2SetAssertFcn( b2AssertFcn* assertFcn );
6868

6969
/// Version numbering scheme.

include/box2d/box2d.h

Lines changed: 89 additions & 83 deletions
Large diffs are not rendered by default.

include/box2d/collision.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef struct b2Hull b2Hull;
2626
*/
2727

2828
/// The maximum number of vertices on a convex polygon. Changing this affects performance even if you
29-
/// don't use more vertices.
29+
/// don't use more vertices.
3030
#define b2_maxPolygonVertices 8
3131

3232
/// Low level ray-cast input data
@@ -43,8 +43,8 @@ typedef struct b2RayCastInput
4343
} b2RayCastInput;
4444

4545
/// Low level shape cast input in generic form. This allows casting an arbitrary point
46-
/// cloud wrap with a radius. For example, a circle is a single point with a non-zero radius.
47-
/// A capsule is two points with a non-zero radius. A box is four points with a zero radius.
46+
/// cloud wrap with a radius. For example, a circle is a single point with a non-zero radius.
47+
/// A capsule is two points with a non-zero radius. A box is four points with a zero radius.
4848
typedef struct b2ShapeCastInput
4949
{
5050
/// A point cloud to cast
@@ -106,7 +106,7 @@ typedef struct b2Circle
106106
} b2Circle;
107107

108108
/// A solid capsule can be viewed as two semicircles connected
109-
/// by a rectangle.
109+
/// by a rectangle.
110110
typedef struct b2Capsule
111111
{
112112
/// Local center of the first semicircle
@@ -123,8 +123,8 @@ typedef struct b2Capsule
123123
/// the left of each edge.
124124
/// Polygons have a maximum number of vertices equal to b2_maxPolygonVertices.
125125
/// In most cases you should not need many vertices for a convex polygon.
126-
/// @warning DO NOT fill this out manually, instead use a helper function like
127-
/// b2MakePolygon or b2MakeBox.
126+
/// @warning DO NOT fill this out manually, instead use a helper function like
127+
/// b2MakePolygon or b2MakeBox.
128128
typedef struct b2Polygon
129129
{
130130
/// The polygon vertices
@@ -263,7 +263,7 @@ B2_API b2CastOutput b2ShapeCastSegment( const b2ShapeCastInput* input, const b2S
263263
B2_API b2CastOutput b2ShapeCastPolygon( const b2ShapeCastInput* input, const b2Polygon* shape );
264264

265265
/// A convex hull. Used to create convex polygons.
266-
/// @warning Do not modify these values directly, instead use b2ComputeHull()
266+
/// @warning Do not modify these values directly, instead use b2ComputeHull()
267267
typedef struct b2Hull
268268
{
269269
/// The final points of the hull
@@ -280,7 +280,7 @@ typedef struct b2Hull
280280
/// - less than 3 points
281281
/// - more than b2_maxPolygonVertices points
282282
/// This welds close points and removes collinear points.
283-
/// @warning Do not modify a hull once it has been computed
283+
/// @warning Do not modify a hull once it has been computed
284284
B2_API b2Hull b2ComputeHull( const b2Vec2* points, int32_t count );
285285

286286
/// This determines if a hull is valid. Checks for:
@@ -337,7 +337,7 @@ typedef struct b2DistanceProxy
337337
} b2DistanceProxy;
338338

339339
/// Used to warm start b2Distance. Set count to zero on first call or
340-
/// use zero initialization.
340+
/// use zero initialization.
341341
typedef struct b2DistanceCache
342342
{
343343
/// The number of stored simplex points
@@ -401,7 +401,7 @@ typedef struct b2Simplex
401401

402402
/// Compute the closest points between two shapes represented as point clouds.
403403
/// b2DistanceCache cache is input/output. On the first call set b2DistanceCache.count to zero.
404-
/// The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0 for these.
404+
/// The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0 for these.
405405
B2_API b2DistanceOutput b2ShapeDistance( b2DistanceCache* cache, const b2DistanceInput* input, b2Simplex* simplexes,
406406
int simplexCapacity );
407407

@@ -484,15 +484,15 @@ B2_API b2TOIOutput b2TimeOfImpact( const b2TOIInput* input );
484484
typedef struct b2ManifoldPoint
485485
{
486486
/// Location of the contact point in world space. Subject to precision loss at large coordinates.
487-
/// @note Should only be used for debugging.
487+
/// @note Should only be used for debugging.
488488
b2Vec2 point;
489489

490490
/// Location of the contact point relative to bodyA's origin in world space
491-
/// @note When used internally to the Box2D solver, this is relative to the center of mass.
491+
/// @note When used internally to the Box2D solver, this is relative to the center of mass.
492492
b2Vec2 anchorA;
493493

494494
/// Location of the contact point relative to bodyB's origin in world space
495-
/// @note When used internally to the Box2D solver, this is relative to the center of mass.
495+
/// @note When used internally to the Box2D solver, this is relative to the center of mass.
496496
b2Vec2 anchorB;
497497

498498
/// The separation of the contact point, negative if penetrating
@@ -505,7 +505,7 @@ typedef struct b2ManifoldPoint
505505
float tangentImpulse;
506506

507507
/// The maximum normal impulse applied during sub-stepping
508-
/// This could be a bool to indicate the point is confirmed (may be a speculative point)
508+
/// This could be a bool to indicate the point is confirmed (may be a speculative point)
509509
float maxNormalImpulse;
510510

511511
/// Relative normal velocity pre-solve. Used for hit events. If the normal impulse is
@@ -603,7 +603,7 @@ B2_API b2Manifold b2CollideChainSegmentAndPolygon( const b2ChainSegment* segment
603603
#define b2_defaultCategoryBits ( 1 )
604604

605605
/// Convenience mask bits to use when you don't need collision filtering and just want
606-
/// all results.
606+
/// all results.
607607
#define b2_defaultMaskBits ( UINT64_MAX )
608608

609609
/// A node in the dynamic tree. This is private data placed here for performance reasons.
@@ -720,12 +720,12 @@ typedef float b2TreeRayCastCallbackFcn( const b2RayCastInput* input, int32_t pro
720720
/// The callback also performs the any collision filtering. This has performance
721721
/// roughly equal to k * log(n), where k is the number of collisions and n is the
722722
/// number of proxies in the tree.
723-
/// Bit-wise filtering using mask bits can greatly improve performance in some scenarios.
724-
/// @param tree the dynamic tree to ray cast
723+
/// Bit-wise filtering using mask bits can greatly improve performance in some scenarios.
724+
/// @param tree the dynamic tree to ray cast
725725
/// @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1)
726-
/// @param maskBits filter bits: `bool accept = (maskBits & node->categoryBits) != 0;`
726+
/// @param maskBits filter bits: `bool accept = (maskBits & node->categoryBits) != 0;`
727727
/// @param callback a callback class that is called for each proxy that is hit by the ray
728-
/// @param context user context that is passed to the callback
728+
/// @param context user context that is passed to the callback
729729
B2_API void b2DynamicTree_RayCast( const b2DynamicTree* tree, const b2RayCastInput* input, uint64_t maskBits,
730730
b2TreeRayCastCallbackFcn* callback, void* context );
731731

@@ -741,11 +741,11 @@ typedef float b2TreeShapeCastCallbackFcn( const b2ShapeCastInput* input, int32_t
741741
/// The callback also performs the any collision filtering. This has performance
742742
/// roughly equal to k * log(n), where k is the number of collisions and n is the
743743
/// number of proxies in the tree.
744-
/// @param tree the dynamic tree to ray cast
744+
/// @param tree the dynamic tree to ray cast
745745
/// @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
746-
/// @param maskBits filter bits: `bool accept = (maskBits & node->categoryBits) != 0;`
746+
/// @param maskBits filter bits: `bool accept = (maskBits & node->categoryBits) != 0;`
747747
/// @param callback a callback class that is called for each proxy that is hit by the shape
748-
/// @param context user context that is passed to the callback
748+
/// @param context user context that is passed to the callback
749749
B2_API void b2DynamicTree_ShapeCast( const b2DynamicTree* tree, const b2ShapeCastInput* input, uint64_t maskBits,
750750
b2TreeShapeCastCallbackFcn* callback, void* context );
751751

include/box2d/math_functions.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static const b2Mat22 b2Mat22_zero = { { 0.0f, 0.0f }, { 0.0f, 0.0f } };
7878

7979
/// Compute an approximate arctangent in the range [-pi, pi]
8080
/// This is hand coded for cross platform determinism. The atan2f
81-
/// function in the standard library is not cross platform deterministic.
81+
/// function in the standard library is not cross platform deterministic.
8282
B2_API float b2Atan2( float y, float x );
8383

8484
/// @return the minimum of two floats
@@ -279,7 +279,7 @@ B2_INLINE b2Vec2 b2Normalize( b2Vec2 v )
279279
}
280280

281281
/// Convert a vector into a unit vector if possible, otherwise returns the zero vector. Also
282-
/// outputs the length.
282+
/// outputs the length.
283283
B2_INLINE b2Vec2 b2GetLengthAndNormalize( float* length, b2Vec2 v )
284284
{
285285
*length = b2Length( v );
@@ -303,8 +303,8 @@ B2_INLINE b2Rot b2NormalizeRot( b2Rot q )
303303
}
304304

305305
/// Integration rotation from angular velocity
306-
/// @param q1 initial rotation
307-
/// @param deltaAngle the angular displacement in radians
306+
/// @param q1 initial rotation
307+
/// @param deltaAngle the angular displacement in radians
308308
B2_INLINE b2Rot b2IntegrateRotation( b2Rot q1, float deltaAngle )
309309
{
310310
// dc/dt = -omega * sin(t)
@@ -363,9 +363,9 @@ B2_INLINE b2Rot b2NLerp( b2Rot q1, b2Rot q2, float t )
363363
}
364364

365365
/// Compute the angular velocity necessary to rotate between two rotations over a give time
366-
/// @param q1 initial rotation
367-
/// @param q2 final rotation
368-
/// @param inv_h inverse time step
366+
/// @param q1 initial rotation
367+
/// @param q2 final rotation
368+
/// @param inv_h inverse time step
369369
B2_INLINE float b2ComputeAngularVelocity( b2Rot q1, b2Rot q2, float inv_h )
370370
{
371371
// ds/dt = omega * cos(t)
@@ -609,8 +609,8 @@ B2_API bool b2AABB_IsValid( b2AABB aabb );
609609

610610
/// Box2D bases all length units on meters, but you may need different units for your game.
611611
/// You can set this value to use different units. This should be done at application startup
612-
/// and only modified once. Default value is 1.
613-
/// @warning This must be modified before any calls to Box2D
612+
/// and only modified once. Default value is 1.
613+
/// @warning This must be modified before any calls to Box2D
614614
B2_API void b2SetLengthUnitsPerMeter( float lengthUnits );
615615

616616
/// Get the current length units per meter.

0 commit comments

Comments
 (0)