clean up
This commit is contained in:
parent
6177b4629d
commit
eb5b8df825
9 changed files with 69 additions and 71 deletions
|
|
@ -76,11 +76,11 @@ typedef struct Soak
|
|||
|
||||
int completedCount;
|
||||
int failureCount;
|
||||
long long totalSteps;
|
||||
int totalSteps;
|
||||
int maxSteps;
|
||||
|
||||
// Mesh contact updates by manifold count, rough wave only
|
||||
long long manifoldCounts[B3_CONTACT_MANIFOLD_COUNT_BUCKETS];
|
||||
int manifoldCounts[B3_MAX_MANIFOLDS];
|
||||
|
||||
ShapeStats stats[e_meshDropShapeCount];
|
||||
Failure failures[MAX_REPORTED_FAILURES];
|
||||
|
|
@ -144,7 +144,7 @@ static int RunGeneration( Soak* soak, int generation, uint32_t seed, MeshDropSha
|
|||
if ( soak->settings.rough )
|
||||
{
|
||||
b3Counters counters = b3World_GetCounters( worldId );
|
||||
for ( int i = 0; i < B3_CONTACT_MANIFOLD_COUNT_BUCKETS; ++i )
|
||||
for ( int i = 0; i < B3_MAX_MANIFOLDS; ++i )
|
||||
{
|
||||
manifoldCounts[i] += counters.manifoldCounts[i];
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ static void SoakWorker( void* context )
|
|||
soak->shapeFilter >= 0 ? (MeshDropShape)soak->shapeFilter : (MeshDropShape)( generation % e_meshDropShapeCount );
|
||||
|
||||
int failureKind = -1;
|
||||
long long manifoldCounts[B3_CONTACT_MANIFOLD_COUNT_BUCKETS] = { 0 };
|
||||
long long manifoldCounts[B3_MAX_MANIFOLDS] = { 0 };
|
||||
int steps = RunGeneration( soak, generation, seed, shape, bodies, depth, &failureKind, manifoldCounts );
|
||||
|
||||
int depthCounts[MESH_DROP_DEPTH_LEVEL_COUNT];
|
||||
|
|
@ -228,7 +228,7 @@ static void SoakWorker( void* context )
|
|||
soak->completedCount += 1;
|
||||
soak->totalSteps += steps;
|
||||
soak->maxSteps = b3MaxInt( soak->maxSteps, steps );
|
||||
for ( int i = 0; i < B3_CONTACT_MANIFOLD_COUNT_BUCKETS; ++i )
|
||||
for ( int i = 0; i < B3_MAX_MANIFOLDS; ++i )
|
||||
{
|
||||
soak->manifoldCounts[i] += manifoldCounts[i];
|
||||
}
|
||||
|
|
@ -685,14 +685,14 @@ int main( int argc, char** argv )
|
|||
if ( settings.rough )
|
||||
{
|
||||
long long total = 0;
|
||||
for ( int i = 0; i < B3_CONTACT_MANIFOLD_COUNT_BUCKETS; ++i )
|
||||
for ( int i = 0; i < B3_MAX_MANIFOLDS; ++i )
|
||||
{
|
||||
total += soak.manifoldCounts[i];
|
||||
}
|
||||
|
||||
// The last bucket is the cap, so it holds every contact that was reduced
|
||||
printf( "contact updates by manifold count:" );
|
||||
for ( int i = 0; i < B3_CONTACT_MANIFOLD_COUNT_BUCKETS; ++i )
|
||||
for ( int i = 0; i < B3_MAX_MANIFOLDS; ++i )
|
||||
{
|
||||
printf( " %d: %.1f%%", i + 1, total > 0 ? 100.0 * soak.manifoldCounts[i] / total : 0.0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@ B3_API float b3GetLengthUnitsPerMeter( void );
|
|||
/// dropped using heuristics until this number is reached.
|
||||
#define B3_MAX_MANIFOLDS 8
|
||||
|
||||
/// Number of contact point buckets for counting the number of contact points per
|
||||
/// shape contact pair. This is just for reporting and doesn't affect simulation.
|
||||
#define B3_CONTACT_MANIFOLD_COUNT_BUCKETS B3_MAX_MANIFOLDS
|
||||
|
||||
/// A small length used as a collision and constraint tolerance. Usually it is
|
||||
/// chosen to be numerically significant, but visually insignificant. In meters.
|
||||
/// @warning modifying this can have a significant impact on stability
|
||||
|
|
|
|||
|
|
@ -573,50 +573,50 @@ B3_API b3ShapeDef b3DefaultShapeDef( void );
|
|||
/// @ingroup world
|
||||
typedef struct b3Profile
|
||||
{
|
||||
float step; //
|
||||
float pairs; //
|
||||
float collide; //
|
||||
float solve; //
|
||||
float solverSetup; //
|
||||
float constraints; //
|
||||
float prepareConstraints; //
|
||||
float integrateVelocities; //
|
||||
float warmStart; //
|
||||
float solveImpulses; //
|
||||
float integratePositions; //
|
||||
float relaxImpulses; //
|
||||
float restitution; //
|
||||
float storeImpulses; //
|
||||
float splitIslands; //
|
||||
float transforms; //
|
||||
float sensorHits; //
|
||||
float jointEvents; //
|
||||
float hitEvents; //
|
||||
float refit; //
|
||||
float bullets; //
|
||||
float sleepIslands; //
|
||||
float sensors; //
|
||||
float step; ///<
|
||||
float pairs; ///<
|
||||
float collide; ///<
|
||||
float solve; ///<
|
||||
float solverSetup; ///<
|
||||
float constraints; ///<
|
||||
float prepareConstraints; ///<
|
||||
float integrateVelocities; ///<
|
||||
float warmStart; ///<
|
||||
float solveImpulses; ///<
|
||||
float integratePositions; ///<
|
||||
float relaxImpulses; ///<
|
||||
float restitution; ///<
|
||||
float storeImpulses; ///<
|
||||
float splitIslands; ///<
|
||||
float transforms; ///<
|
||||
float sensorHits; ///<
|
||||
float jointEvents; ///<
|
||||
float hitEvents; ///<
|
||||
float refit; ///<
|
||||
float bullets; ///<
|
||||
float sleepIslands; ///<
|
||||
float sensors; ///<
|
||||
} b3Profile;
|
||||
|
||||
/// Counters that give details of the simulation size.
|
||||
/// @ingroup world
|
||||
typedef struct b3Counters
|
||||
{
|
||||
int64_t byteCount; //
|
||||
int bodyCount; //
|
||||
int shapeCount; //
|
||||
int contactCount; //
|
||||
int jointCount; //
|
||||
int islandCount; //
|
||||
int stackUsed; //
|
||||
int arenaCapacity; //
|
||||
int staticTreeHeight; //
|
||||
int treeHeight; //
|
||||
int satCallCount; //
|
||||
int satCacheHitCount; //
|
||||
int taskCount; //
|
||||
int colorCounts[24]; //
|
||||
int manifoldCounts[B3_CONTACT_MANIFOLD_COUNT_BUCKETS]; //
|
||||
int64_t byteCount; ///<
|
||||
int bodyCount; ///<
|
||||
int shapeCount; ///<
|
||||
int contactCount; ///<
|
||||
int jointCount; ///<
|
||||
int islandCount; ///<
|
||||
int stackUsed; ///<
|
||||
int arenaCapacity; ///<
|
||||
int staticTreeHeight; ///<
|
||||
int treeHeight; ///<
|
||||
int satCallCount; ///<
|
||||
int satCacheHitCount; ///<
|
||||
int taskCount; ///<
|
||||
int colorCounts[24]; ///<
|
||||
int manifoldCounts[B3_MAX_MANIFOLDS]; ///<
|
||||
|
||||
/// Number of contacts touched by the collide pass
|
||||
/// graph contacts + awake-set non-touching
|
||||
|
|
|
|||
|
|
@ -545,7 +545,8 @@ public:
|
|||
{
|
||||
PickRay pickRay = m_camera->BuildPickRay( m_context->mouseX, m_context->mouseY );
|
||||
|
||||
b3RayResult result = b3World_CastRayClosest( m_worldId, pickRay.origin, pickRay.translation, b3DefaultQueryFilter() );
|
||||
b3RayResult result =
|
||||
b3World_CastRayClosest( m_worldId, pickRay.origin, pickRay.translation, b3DefaultQueryFilter() );
|
||||
|
||||
if ( result.hit )
|
||||
{
|
||||
|
|
@ -563,17 +564,18 @@ public:
|
|||
// The last bucket is the cap, so it holds every contact that was reduced
|
||||
b3Counters counters = b3World_GetCounters( m_worldId );
|
||||
int contactCount = 0;
|
||||
for ( int i = 0; i < B3_CONTACT_MANIFOLD_COUNT_BUCKETS; ++i )
|
||||
for ( int i = 0; i < B3_MAX_MANIFOLDS; ++i )
|
||||
{
|
||||
contactCount += counters.manifoldCounts[i];
|
||||
}
|
||||
DrawTextLine( "contacts at the manifold cap: %d of %d", counters.manifoldCounts[B3_MAX_MANIFOLDS - 1], contactCount );
|
||||
DrawTextLine( "contacts at the manifold cap: %d of %d", counters.manifoldCounts[B3_MAX_MANIFOLDS - 1],
|
||||
contactCount );
|
||||
|
||||
if ( m_depth.maxIndex >= 0 )
|
||||
{
|
||||
int index = m_depth.maxIndex;
|
||||
DrawTextLine( "deepest: (%d, %d) %.1f slop at step %d", index / MESH_DROP_GRID_COUNT, index % MESH_DROP_GRID_COUNT,
|
||||
m_depth.maxDepth / B3_LINEAR_SLOP, m_depth.maxStep );
|
||||
DrawTextLine( "deepest: (%d, %d) %.1f slop at step %d", index / MESH_DROP_GRID_COUNT,
|
||||
index % MESH_DROP_GRID_COUNT, m_depth.maxDepth / B3_LINEAR_SLOP, m_depth.maxStep );
|
||||
}
|
||||
|
||||
float tunnelHeight = GetMeshDropTunnelHeight();
|
||||
|
|
|
|||
|
|
@ -186,17 +186,11 @@ void CreateMeshDropBodies( b3WorldId worldId, MeshDropSettings settings, uint32_
|
|||
shapeDef.filter.maskBits = 1;
|
||||
}
|
||||
|
||||
#ifdef NDEBUG
|
||||
int increment = 1;
|
||||
#else
|
||||
int increment = 2;
|
||||
#endif
|
||||
|
||||
uint32_t state = seed;
|
||||
int index = 0;
|
||||
for ( int i = 0; i < MESH_DROP_GRID_COUNT; i += increment )
|
||||
for ( int i = 0; i < MESH_DROP_GRID_COUNT; ++i )
|
||||
{
|
||||
for ( int j = 0; j < MESH_DROP_GRID_COUNT; j += increment )
|
||||
for ( int j = 0; j < MESH_DROP_GRID_COUNT; ++j )
|
||||
{
|
||||
// Draw for every body so a solo body gets the same velocity it has in the full drop
|
||||
b3Vec3 linearVelocity = RandomVec3Uniform( &state, -1.0f, 1.0f );
|
||||
|
|
|
|||
|
|
@ -29,7 +29,14 @@ typedef enum MeshDropShape
|
|||
e_meshDropShapeCount
|
||||
} MeshDropShape;
|
||||
|
||||
// Bodies per axis. A debug build drops a smaller patch at the same spacing so the samples app stays
|
||||
// responsive. The soak tools run in release and keep the full grid.
|
||||
#ifdef NDEBUG
|
||||
#define MESH_DROP_GRID_COUNT 32
|
||||
#else
|
||||
#define MESH_DROP_GRID_COUNT 16
|
||||
#endif
|
||||
|
||||
#define MESH_DROP_BODY_COUNT ( MESH_DROP_GRID_COUNT * MESH_DROP_GRID_COUNT )
|
||||
#define MESH_DROP_DEPTH_LEVEL_COUNT 4
|
||||
|
||||
|
|
|
|||
|
|
@ -1670,7 +1670,7 @@ static int b3CollideMeshTriangles( b3Cluster** clustersOut, const b3Shape* shape
|
|||
|
||||
int keptCount = 0;
|
||||
|
||||
// If there are more than 8 manifolds then find the best per octant region.
|
||||
// If there are 8 or more manifolds then find the best per octant region.
|
||||
if ( manifoldCapacity >= 8 )
|
||||
{
|
||||
int octantClusters[8] = { B3_NULL_INDEX, B3_NULL_INDEX, B3_NULL_INDEX, B3_NULL_INDEX,
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ static void b3CollideTask( int startIndex, int endIndex, int workerIndex, void*
|
|||
|
||||
// Diagnostics
|
||||
taskContext->recycledContactCount += 1;
|
||||
int bucketIndex = b3MinInt( manifoldCount, B3_CONTACT_MANIFOLD_COUNT_BUCKETS );
|
||||
int bucketIndex = b3MinInt( manifoldCount, B3_MAX_MANIFOLDS );
|
||||
if ( bucketIndex > 0 )
|
||||
{
|
||||
taskContext->manifoldCounts[bucketIndex - 1] += 1;
|
||||
|
|
@ -748,7 +748,7 @@ static void b3CollideTask( int startIndex, int endIndex, int workerIndex, void*
|
|||
transformA, shapeB,
|
||||
bodySimB->localCenter, transformB, isFast, taskContext->arena );
|
||||
|
||||
int bucketIndex = b3MinInt( contact->manifoldCount, B3_CONTACT_MANIFOLD_COUNT_BUCKETS );
|
||||
int bucketIndex = b3MinInt( contact->manifoldCount, B3_MAX_MANIFOLDS );
|
||||
if ( bucketIndex > 0 )
|
||||
{
|
||||
taskContext->manifoldCounts[bucketIndex - 1] += 1;
|
||||
|
|
@ -910,15 +910,14 @@ static void b3Collide( b3StepContext* context )
|
|||
b3BitSet* bitSet = &world->taskContexts.data[0].contactStateBitSet;
|
||||
world->satCallCount = satMultiplier * world->taskContexts.data[0].satCallCount;
|
||||
world->satCacheHitCount = satMultiplier * world->taskContexts.data[0].satCacheHitCount;
|
||||
memcpy( world->manifoldCounts, world->taskContexts.data[0].manifoldCounts,
|
||||
B3_CONTACT_MANIFOLD_COUNT_BUCKETS * sizeof( int ) );
|
||||
memcpy( world->manifoldCounts, world->taskContexts.data[0].manifoldCounts, B3_MAX_MANIFOLDS * sizeof( int ) );
|
||||
|
||||
for ( int i = 1; i < world->workerCount; ++i )
|
||||
{
|
||||
b3InPlaceUnion( bitSet, &world->taskContexts.data[i].contactStateBitSet );
|
||||
world->satCallCount += world->taskContexts.data[i].satCallCount;
|
||||
world->satCacheHitCount += world->taskContexts.data[i].satCacheHitCount;
|
||||
for ( int j = 0; j < B3_CONTACT_MANIFOLD_COUNT_BUCKETS; ++j )
|
||||
for ( int j = 0; j < B3_MAX_MANIFOLDS; ++j )
|
||||
{
|
||||
world->manifoldCounts[j] += world->taskContexts.data[i].manifoldCounts[j];
|
||||
}
|
||||
|
|
@ -2642,7 +2641,7 @@ b3Counters b3World_GetCounters( b3WorldId worldId )
|
|||
|
||||
s.satCallCount = world->satCallCount;
|
||||
s.satCacheHitCount = world->satCacheHitCount;
|
||||
memcpy( s.manifoldCounts, world->manifoldCounts, B3_CONTACT_MANIFOLD_COUNT_BUCKETS * sizeof( int ) );
|
||||
memcpy( s.manifoldCounts, world->manifoldCounts, B3_MAX_MANIFOLDS * sizeof( int ) );
|
||||
s.stackUsed = world->stack.maxAllocation;
|
||||
s.byteCount = (int64_t)b3GetWorldByteCount( world, false );
|
||||
s.taskCount = world->taskCount;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ typedef struct b3TaskContext
|
|||
b3DebugLine lines[B3_DEBUG_LINE_CAPACITY];
|
||||
int lineCount;
|
||||
|
||||
int manifoldCounts[B3_CONTACT_MANIFOLD_COUNT_BUCKETS];
|
||||
int manifoldCounts[B3_MAX_MANIFOLDS];
|
||||
// Prevent false sharing
|
||||
char cacheLine[64];
|
||||
} b3TaskContext;
|
||||
|
|
@ -254,7 +254,7 @@ typedef struct b3World
|
|||
b3Profile profile;
|
||||
int satCallCount;
|
||||
int satCacheHitCount;
|
||||
int manifoldCounts[B3_CONTACT_MANIFOLD_COUNT_BUCKETS];
|
||||
int manifoldCounts[B3_MAX_MANIFOLDS];
|
||||
|
||||
b3Capacity maxCapacity;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue