Skip to content

Commit b28b6a5

Browse files
committed
Major Bug Fixes
- Several fixes to BeginContact and EndContact - Makes fixture<->particle collision distance use radius instead of diameter - Makes b2ParticleSystem forces clear in b2World::ClearForces() - Fixes elastic directional bias
1 parent 7f20402 commit b28b6a5

File tree

3 files changed

+132
-61
lines changed

3 files changed

+132
-61
lines changed

liquidfun/Box2D/Box2D/Common/b2Settings.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ typedef unsigned long long uint64;
8282
#endif
8383
#endif
8484

85+
8586
/// @file
8687
/// Global tuning constants based on meters-kilograms-seconds (MKS) units.
8788
///
8889

90+
8991
// Collision
9092

9193
/// The maximum number of contact points between two convex shapes. Do
@@ -196,6 +198,14 @@ typedef unsigned long long uint64;
196198
/// The time into the future that collisions against barrier particles will be detected.
197199
#define b2_barrierCollisionTime 2.5f
198200

201+
/// Multiplier for the radius of a particle when colliding with a fixture.
202+
/// Originally the diameter was used, so a multiplier of 2 would restore that behaviour.
203+
#define b2_fixtureParticleCollisionRadiusScaler 1
204+
205+
/// Prevents directional bias when solving elastic triads
206+
#define b2_elasticPreserveVelocity
207+
208+
199209
// Sleep
200210

201211
/// The time that a body must be still before it will go to sleep.
@@ -207,6 +217,7 @@ typedef unsigned long long uint64;
207217
/// A body cannot sleep if its angular velocity is above this tolerance.
208218
#define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
209219

220+
210221
// Memory Allocation
211222

212223
/// Implement this function to use your own memory allocator.
@@ -236,9 +247,11 @@ void b2SetNumAllocs(const int32 numAllocs);
236247
/// Get number of calls to b2Alloc minus number of calls to b2Free.
237248
int32 b2GetNumAllocs();
238249

250+
239251
/// Logging function.
240252
void b2Log(const char* string, ...);
241253

254+
242255
/// Version numbering scheme.
243256
/// See http://en.wikipedia.org/wiki/Software_versioning
244257
struct b2Version

liquidfun/Box2D/Box2D/Dynamics/b2World.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,11 @@ void b2World::ClearForces()
10571057
body->m_force.SetZero();
10581058
body->m_torque = 0.0f;
10591059
}
1060+
1061+
for (b2ParticleSystem* p = m_particleSystemList; p; p = p->GetNext())
1062+
{
1063+
p->m_hasForce = false;
1064+
}
10601065
}
10611066

10621067
struct b2WorldQueryWrapper

0 commit comments

Comments
 (0)