Skip to content

Commit

Permalink
Major Bug Fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Manamongods committed Sep 2, 2021
1 parent 7f20402 commit b28b6a5
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 61 deletions.
13 changes: 13 additions & 0 deletions liquidfun/Box2D/Box2D/Common/b2Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ typedef unsigned long long uint64;
#endif
#endif


/// @file
/// Global tuning constants based on meters-kilograms-seconds (MKS) units.
///


// Collision

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

/// Multiplier for the radius of a particle when colliding with a fixture.
/// Originally the diameter was used, so a multiplier of 2 would restore that behaviour.
#define b2_fixtureParticleCollisionRadiusScaler 1

/// Prevents directional bias when solving elastic triads
#define b2_elasticPreserveVelocity


// Sleep

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


// Memory Allocation

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


/// Logging function.
void b2Log(const char* string, ...);


/// Version numbering scheme.
/// See http://en.wikipedia.org/wiki/Software_versioning
struct b2Version
Expand Down
5 changes: 5 additions & 0 deletions liquidfun/Box2D/Box2D/Dynamics/b2World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,11 @@ void b2World::ClearForces()
body->m_force.SetZero();
body->m_torque = 0.0f;
}

for (b2ParticleSystem* p = m_particleSystemList; p; p = p->GetNext())
{
p->m_hasForce = false;
}
}

struct b2WorldQueryWrapper
Expand Down
Loading

0 comments on commit b28b6a5

Please sign in to comment.