initialize time-step statistics in a world; rename profile function
This commit is contained in:
parent
16d351ecac
commit
cd6c7e188a
@ -19,13 +19,13 @@
|
||||
#include <bounce\bounce.h>
|
||||
|
||||
// We don't care for a profiler. This definition does nothing.
|
||||
bool b3PushProfileScope(const char* name)
|
||||
void b3BeginProfileScope(const char* name)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// We don't care for a profiler. This definition does nothing.
|
||||
void b3PopProfileScope()
|
||||
void b3EndProfileScope()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
// Add a profiler event to the queue.
|
||||
// Return true if the even has been added to the event queue
|
||||
// or false if the queue is full.
|
||||
// You can control the maximum number of profiler events using
|
||||
// MAX_PROFILER_EVENTS.
|
||||
bool PushEvent(const char* name);
|
||||
|
||||
// Remove the top profiler event.
|
||||
|
@ -21,30 +21,24 @@
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
extern u32 b3_allocCalls, b3_maxAllocCalls;
|
||||
extern u32 b3_convexCalls, b3_convexCacheHits;
|
||||
extern u32 b3_gjkCalls, b3_gjkIters, b3_gjkMaxIters;
|
||||
extern bool b3_convexCache;
|
||||
extern u32 b3_convexCalls, b3_convexCacheHits;
|
||||
|
||||
bool b3PushProfileScope(const char* name)
|
||||
void b3BeginProfileScope(const char* name)
|
||||
{
|
||||
return g_profiler->PushEvent(name);
|
||||
g_profiler->PushEvent(name);
|
||||
}
|
||||
|
||||
void b3PopProfileScope()
|
||||
void b3EndProfileScope()
|
||||
{
|
||||
g_profiler->PopEvent();
|
||||
}
|
||||
|
||||
Test::Test() : m_bodyDragger(&m_bodyRay, &m_world)
|
||||
{
|
||||
b3_allocCalls = 0;
|
||||
b3_gjkCalls = 0;
|
||||
b3_gjkIters = 0;
|
||||
b3_gjkMaxIters = 0;
|
||||
b3_convexCache = g_testSettings->convexCache;
|
||||
b3_convexCalls = 0;
|
||||
b3_convexCacheHits = 0;
|
||||
b3Draw_draw = g_draw;
|
||||
b3_convexCache = g_testSettings->convexCache;
|
||||
|
||||
m_world.SetContactListener(this);
|
||||
|
||||
@ -58,25 +52,12 @@ Test::Test() : m_bodyDragger(&m_bodyRay, &m_world)
|
||||
|
||||
Test::~Test()
|
||||
{
|
||||
b3_allocCalls = 0;
|
||||
b3_gjkCalls = 0;
|
||||
b3_gjkIters = 0;
|
||||
b3_gjkMaxIters = 0;
|
||||
b3_convexCache = false;
|
||||
b3_convexCalls = 0;
|
||||
b3_convexCacheHits = 0;
|
||||
b3Draw_draw = nullptr;
|
||||
}
|
||||
|
||||
void Test::Step()
|
||||
{
|
||||
b3_allocCalls = 0;
|
||||
b3_gjkCalls = 0;
|
||||
b3_gjkIters = 0;
|
||||
b3_gjkMaxIters = 0;
|
||||
b3_convexCache = g_testSettings->convexCache;
|
||||
b3_convexCalls = 0;
|
||||
b3_convexCacheHits = 0;
|
||||
|
||||
// Step
|
||||
float32 dt = g_testSettings->inv_hertz;
|
||||
|
@ -143,28 +143,25 @@ void b3Free(void* block);
|
||||
// from this software.
|
||||
void b3Log(const char* string, ...);
|
||||
|
||||
// You should implement this function to use your own profiler.
|
||||
bool b3PushProfileScope(const char* name);
|
||||
// You should implement this function to listen when a profile scope is opened.
|
||||
void b3BeginProfileScope(const char* name);
|
||||
|
||||
// You should implement this function to use your own profiler.
|
||||
void b3PopProfileScope();
|
||||
// You must implement this function if you have implemented b3BeginProfileScope.
|
||||
// Implement this function to listen when a profile scope is closed.
|
||||
void b3EndProfileScope();
|
||||
|
||||
//
|
||||
struct b3ProfileScope
|
||||
{
|
||||
b3ProfileScope(const char* name)
|
||||
{
|
||||
b = b3PushProfileScope(name);
|
||||
b3BeginProfileScope(name);
|
||||
}
|
||||
|
||||
~b3ProfileScope()
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
b3PopProfileScope();
|
||||
}
|
||||
b3EndProfileScope();
|
||||
}
|
||||
private:
|
||||
bool b;
|
||||
};
|
||||
|
||||
// The current version this software.
|
||||
|
@ -25,14 +25,24 @@
|
||||
#include <bounce/dynamics/joints/joint.h>
|
||||
#include <bounce/dynamics/time_step.h>
|
||||
|
||||
extern u32 b3_allocCalls;
|
||||
extern u32 b3_maxAllocCalls;
|
||||
extern u32 b3_allocCalls, b3_maxAllocCalls;
|
||||
extern u32 b3_convexCalls, b3_convexCacheHits;
|
||||
extern u32 b3_gjkCalls, b3_gjkIters, b3_gjkMaxIters;
|
||||
extern bool b3_convexCache;
|
||||
|
||||
b3World::b3World() : m_bodyBlocks(sizeof(b3Body))
|
||||
{
|
||||
b3_allocCalls = 0;
|
||||
b3_maxAllocCalls = 0;
|
||||
|
||||
b3_gjkCalls = 0;
|
||||
b3_gjkIters = 0;
|
||||
|
||||
b3_convexCalls = 0;
|
||||
b3_convexCacheHits = 0;
|
||||
|
||||
b3_convexCache = true;
|
||||
|
||||
m_flags = e_clearForcesFlag;
|
||||
m_sleeping = false;
|
||||
m_warmStarting = true;
|
||||
@ -49,8 +59,15 @@ b3World::~b3World()
|
||||
b->DestroyJoints();
|
||||
b = b->m_next;
|
||||
}
|
||||
|
||||
b3_allocCalls = 0;
|
||||
b3_maxAllocCalls = 0;
|
||||
|
||||
b3_gjkCalls = 0;
|
||||
b3_gjkIters = 0;
|
||||
|
||||
b3_convexCalls = 0;
|
||||
b3_convexCacheHits = 0;
|
||||
}
|
||||
|
||||
void b3World::SetSleeping(bool flag)
|
||||
@ -98,6 +115,16 @@ void b3World::Step(float32 dt, u32 velocityIterations, u32 positionIterations)
|
||||
{
|
||||
B3_PROFILE("Step");
|
||||
|
||||
// Clear statistics
|
||||
b3_allocCalls = 0;
|
||||
|
||||
b3_convexCalls = 0;
|
||||
b3_convexCacheHits = 0;
|
||||
|
||||
b3_gjkCalls = 0;
|
||||
b3_gjkIters = 0;
|
||||
b3_gjkMaxIters = 0;
|
||||
|
||||
if (m_flags & e_shapeAddedFlag)
|
||||
{
|
||||
// If new shapes were added new contacts might be created.
|
||||
|
Loading…
x
Reference in New Issue
Block a user