preparation for CommandLogging for PhysicsServer.
This commit is contained in:
@@ -1041,7 +1041,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int toggle = 1;
|
static int toggle = 1;
|
||||||
if (1)
|
if (renderGrid)
|
||||||
{
|
{
|
||||||
if (!pauseSimulation)
|
if (!pauseSimulation)
|
||||||
processProfileData(s_profWindow,false);
|
processProfileData(s_profWindow,false);
|
||||||
|
|||||||
@@ -108,6 +108,24 @@ struct InternalBodyHandle : public InteralBodyData
|
|||||||
return m_nextFreeHandle;
|
return m_nextFreeHandle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
struct CommandLogger
|
||||||
|
{
|
||||||
|
FILE* m_file;
|
||||||
|
|
||||||
|
void logCommand(SharedMemoryBlock* testBlock1)
|
||||||
|
{
|
||||||
|
//fwrite(buf,buffSize+sizeof(int),1,m_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandLogger(const char* fileName)
|
||||||
|
{
|
||||||
|
m_file = fopen(fileName,"wb");
|
||||||
|
}
|
||||||
|
virtual ~CommandLogger()
|
||||||
|
{
|
||||||
|
fclose(m_file);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct PhysicsServerInternalData
|
struct PhysicsServerInternalData
|
||||||
{
|
{
|
||||||
@@ -200,6 +218,7 @@ struct PhysicsServerInternalData
|
|||||||
|
|
||||||
SharedMemoryInterface* m_sharedMemory;
|
SharedMemoryInterface* m_sharedMemory;
|
||||||
SharedMemoryBlock* m_testBlock1;
|
SharedMemoryBlock* m_testBlock1;
|
||||||
|
CommandLogger* m_commandLogger;
|
||||||
bool m_isConnected;
|
bool m_isConnected;
|
||||||
btScalar m_physicsDeltaTime;
|
btScalar m_physicsDeltaTime;
|
||||||
btAlignedObjectArray<btMultiBodyJointFeedback*> m_multiBodyJointFeedbacks;
|
btAlignedObjectArray<btMultiBodyJointFeedback*> m_multiBodyJointFeedbacks;
|
||||||
@@ -240,6 +259,7 @@ struct PhysicsServerInternalData
|
|||||||
PhysicsServerInternalData()
|
PhysicsServerInternalData()
|
||||||
:m_sharedMemory(0),
|
:m_sharedMemory(0),
|
||||||
m_testBlock1(0),
|
m_testBlock1(0),
|
||||||
|
m_commandLogger(0),
|
||||||
m_isConnected(false),
|
m_isConnected(false),
|
||||||
m_physicsDeltaTime(1./240.),
|
m_physicsDeltaTime(1./240.),
|
||||||
m_dynamicsWorld(0),
|
m_dynamicsWorld(0),
|
||||||
@@ -332,6 +352,12 @@ PhysicsServerSharedMemory::PhysicsServerSharedMemory()
|
|||||||
PhysicsServerSharedMemory::~PhysicsServerSharedMemory()
|
PhysicsServerSharedMemory::~PhysicsServerSharedMemory()
|
||||||
{
|
{
|
||||||
deleteDynamicsWorld();
|
deleteDynamicsWorld();
|
||||||
|
if (m_data->m_commandLogger)
|
||||||
|
{
|
||||||
|
delete m_data->m_commandLogger;
|
||||||
|
m_data->m_commandLogger = 0;
|
||||||
|
}
|
||||||
|
|
||||||
delete m_data;
|
delete m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +477,7 @@ bool PhysicsServerSharedMemory::connectSharedMemory( struct GUIHelperInterface*
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool allowCreation = true;
|
bool allowCreation = true;
|
||||||
bool allowConnectToExistingSharedMemory = false;
|
|
||||||
|
|
||||||
if (m_data->m_isConnected)
|
if (m_data->m_isConnected)
|
||||||
{
|
{
|
||||||
@@ -489,6 +515,7 @@ bool PhysicsServerSharedMemory::connectSharedMemory( struct GUIHelperInterface*
|
|||||||
b3Error("Cannot connect to shared memory");
|
b3Error("Cannot connect to shared memory");
|
||||||
m_data->m_isConnected = false;
|
m_data->m_isConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_data->m_isConnected;
|
return m_data->m_isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,11 +750,17 @@ void PhysicsServerSharedMemory::processClientCommands()
|
|||||||
///we ignore overflow of integer for now
|
///we ignore overflow of integer for now
|
||||||
if (m_data->m_testBlock1->m_numClientCommands> m_data->m_testBlock1->m_numProcessedClientCommands)
|
if (m_data->m_testBlock1->m_numClientCommands> m_data->m_testBlock1->m_numProcessedClientCommands)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//until we implement a proper ring buffer, we assume always maximum of 1 outstanding commands
|
//until we implement a proper ring buffer, we assume always maximum of 1 outstanding commands
|
||||||
btAssert(m_data->m_testBlock1->m_numClientCommands==m_data->m_testBlock1->m_numProcessedClientCommands+1);
|
btAssert(m_data->m_testBlock1->m_numClientCommands==m_data->m_testBlock1->m_numProcessedClientCommands+1);
|
||||||
|
|
||||||
const SharedMemoryCommand& clientCmd =m_data->m_testBlock1->m_clientCommands[0];
|
const SharedMemoryCommand& clientCmd =m_data->m_testBlock1->m_clientCommands[0];
|
||||||
|
if (m_data->m_commandLogger)
|
||||||
|
{
|
||||||
|
m_data->m_commandLogger->logCommand(m_data->m_testBlock1);
|
||||||
|
}
|
||||||
|
|
||||||
m_data->m_testBlock1->m_numProcessedClientCommands++;
|
m_data->m_testBlock1->m_numProcessedClientCommands++;
|
||||||
|
|
||||||
//no timestamp yet
|
//no timestamp yet
|
||||||
@@ -1678,3 +1711,21 @@ void PhysicsServerSharedMemory::removePickingConstraint()
|
|||||||
m_data->m_pickingMultiBodyPoint2Point = 0;
|
m_data->m_pickingMultiBodyPoint2Point = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhysicsServerSharedMemory::enableCommandLogging(bool enable, const char* fileName)
|
||||||
|
{
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
if (0==m_data->m_commandLogger)
|
||||||
|
{
|
||||||
|
m_data->m_commandLogger = new CommandLogger(fileName);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (0!=m_data->m_commandLogger)
|
||||||
|
{
|
||||||
|
delete m_data->m_commandLogger;
|
||||||
|
m_data->m_commandLogger = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ public:
|
|||||||
void physicsDebugDraw(int debugDrawFlags);
|
void physicsDebugDraw(int debugDrawFlags);
|
||||||
void renderScene();
|
void renderScene();
|
||||||
|
|
||||||
|
void enableCommandLogging(bool enable, const char* fileName);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ public:
|
|||||||
|
|
||||||
virtual void stepSimulation(float deltaTime);
|
virtual void stepSimulation(float deltaTime);
|
||||||
|
|
||||||
|
void enableCommandLogging()
|
||||||
|
{
|
||||||
|
m_physicsServer.enableCommandLogging(true,"BulletPhysicsCommandLog.bin");
|
||||||
|
}
|
||||||
|
|
||||||
virtual void resetCamera()
|
virtual void resetCamera()
|
||||||
{
|
{
|
||||||
@@ -190,18 +193,7 @@ void PhysicsServerExample::physicsDebugDraw(int debugDrawFlags)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int gSharedMemoryKey;
|
|
||||||
|
|
||||||
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options)
|
|
||||||
{
|
|
||||||
PhysicsServerExample* example = new PhysicsServerExample(options.m_guiHelper);
|
|
||||||
if (gSharedMemoryKey>=0)
|
|
||||||
{
|
|
||||||
example->setSharedMemoryKey(gSharedMemoryKey);
|
|
||||||
}
|
|
||||||
return example;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
btVector3 PhysicsServerExample::getRayTo(int x,int y)
|
btVector3 PhysicsServerExample::getRayTo(int x,int y)
|
||||||
{
|
{
|
||||||
@@ -267,3 +259,20 @@ btVector3 PhysicsServerExample::getRayTo(int x,int y)
|
|||||||
return rayTo;
|
return rayTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern int gSharedMemoryKey;
|
||||||
|
|
||||||
|
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options)
|
||||||
|
{
|
||||||
|
PhysicsServerExample* example = new PhysicsServerExample(options.m_guiHelper);
|
||||||
|
if (gSharedMemoryKey>=0)
|
||||||
|
{
|
||||||
|
example->setSharedMemoryKey(gSharedMemoryKey);
|
||||||
|
}
|
||||||
|
if (options.m_option & PHYSICS_SERVER_ENABLE_COMMAND_LOGGING)
|
||||||
|
{
|
||||||
|
example->enableCommandLogging();
|
||||||
|
}
|
||||||
|
return example;
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef PHYSICS_SERVER_EXAMPLE_H
|
#ifndef PHYSICS_SERVER_EXAMPLE_H
|
||||||
#define PHYSICS_SERVER_EXAMPLE_H
|
#define PHYSICS_SERVER_EXAMPLE_H
|
||||||
|
|
||||||
|
enum PhysicsServerOptions
|
||||||
|
{
|
||||||
|
PHYSICS_SERVER_ENABLE_COMMAND_LOGGING=1,
|
||||||
|
};
|
||||||
|
|
||||||
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options);
|
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user