disable RTC update for Physics Server by default
This commit is contained in:
@@ -234,6 +234,9 @@ static ExampleEntry gDefaultExamples[]=
|
|||||||
PhysicsClientCreateFunc, eCLIENTEXAMPLE_SERVER),
|
PhysicsClientCreateFunc, eCLIENTEXAMPLE_SERVER),
|
||||||
ExampleEntry(1,"Physics Server", "Create a physics server that communicates with a physics client over shared memory",
|
ExampleEntry(1,"Physics Server", "Create a physics server that communicates with a physics client over shared memory",
|
||||||
PhysicsServerCreateFunc),
|
PhysicsServerCreateFunc),
|
||||||
|
ExampleEntry(1,"Physics Server (RTC)", "Create a physics server that communicates with a physics client over shared memory. At each update, the Physics Server will continue calling 'stepSimulation' based on the real-time clock (RTC).",
|
||||||
|
PhysicsServerCreateFunc,PHYSICS_SERVER_USE_RTC_CLOCK),
|
||||||
|
|
||||||
ExampleEntry(1,"Physics Server (Logging)", "Create a physics server that communicates with a physics client over shared memory. It will log all commands to a file.",
|
ExampleEntry(1,"Physics Server (Logging)", "Create a physics server that communicates with a physics client over shared memory. It will log all commands to a file.",
|
||||||
PhysicsServerCreateFunc,PHYSICS_SERVER_ENABLE_COMMAND_LOGGING),
|
PhysicsServerCreateFunc,PHYSICS_SERVER_ENABLE_COMMAND_LOGGING),
|
||||||
ExampleEntry(1,"Physics Server (Replay Log)", "Create a physics server that replay a command log from disk.",
|
ExampleEntry(1,"Physics Server (Replay Log)", "Create a physics server that replay a command log from disk.",
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ static ExampleEntryPhysicsServer gDefaultExamplesPhysicsServer[]=
|
|||||||
|
|
||||||
ExampleEntryPhysicsServer(1,"Physics Server", "Create a physics server that communicates with a physics client over shared memory",
|
ExampleEntryPhysicsServer(1,"Physics Server", "Create a physics server that communicates with a physics client over shared memory",
|
||||||
PhysicsServerCreateFunc),
|
PhysicsServerCreateFunc),
|
||||||
|
ExampleEntryPhysicsServer(1,"Physics Server (RTC)", "Create a physics server that communicates with a physics client over shared memory. At each update, the Physics Server will continue calling 'stepSimulation' based on the real-time clock (RTC).",
|
||||||
|
PhysicsServerCreateFunc,PHYSICS_SERVER_USE_RTC_CLOCK),
|
||||||
|
|
||||||
ExampleEntryPhysicsServer(1,"Physics Server (Logging)", "Create a physics server that communicates with a physics client over shared memory. It will log all commands to a file.",
|
ExampleEntryPhysicsServer(1,"Physics Server (Logging)", "Create a physics server that communicates with a physics client over shared memory. It will log all commands to a file.",
|
||||||
PhysicsServerCreateFunc,PHYSICS_SERVER_ENABLE_COMMAND_LOGGING),
|
PhysicsServerCreateFunc,PHYSICS_SERVER_ENABLE_COMMAND_LOGGING),
|
||||||
ExampleEntryPhysicsServer(1,"Physics Server (Replay Log)", "Create a physics server that replay a command log from disk.",
|
ExampleEntryPhysicsServer(1,"Physics Server (Replay Log)", "Create a physics server that replay a command log from disk.",
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ class PhysicsServerExample : public SharedMemoryCommon
|
|||||||
bool m_isConnected;
|
bool m_isConnected;
|
||||||
btClock m_clock;
|
btClock m_clock;
|
||||||
bool m_replay;
|
bool m_replay;
|
||||||
|
int m_options;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PhysicsServerExample(GUIHelperInterface* helper, SharedMemoryInterface* sharedMem=0);
|
PhysicsServerExample(GUIHelperInterface* helper, SharedMemoryInterface* sharedMem=0, int options=0);
|
||||||
|
|
||||||
virtual ~PhysicsServerExample();
|
virtual ~PhysicsServerExample();
|
||||||
|
|
||||||
@@ -133,12 +134,13 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PhysicsServerExample::PhysicsServerExample(GUIHelperInterface* helper, SharedMemoryInterface* sharedMem)
|
PhysicsServerExample::PhysicsServerExample(GUIHelperInterface* helper, SharedMemoryInterface* sharedMem, int options)
|
||||||
:SharedMemoryCommon(helper),
|
:SharedMemoryCommon(helper),
|
||||||
m_physicsServer(sharedMem),
|
m_physicsServer(sharedMem),
|
||||||
m_wantsShutdown(false),
|
m_wantsShutdown(false),
|
||||||
m_isConnected(false),
|
m_isConnected(false),
|
||||||
m_replay(false)
|
m_replay(false),
|
||||||
|
m_options(options)
|
||||||
{
|
{
|
||||||
b3Printf("Started PhysicsServer\n");
|
b3Printf("Started PhysicsServer\n");
|
||||||
}
|
}
|
||||||
@@ -188,11 +190,7 @@ bool PhysicsServerExample::wantsTermination()
|
|||||||
|
|
||||||
void PhysicsServerExample::stepSimulation(float deltaTime)
|
void PhysicsServerExample::stepSimulation(float deltaTime)
|
||||||
{
|
{
|
||||||
if (m_replay)
|
if (m_options == PHYSICS_SERVER_USE_RTC_CLOCK)
|
||||||
{
|
|
||||||
for (int i=0;i<100;i++)
|
|
||||||
m_physicsServer.processClientCommands();
|
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
btClock rtc;
|
btClock rtc;
|
||||||
btScalar endTime = rtc.getTimeMilliseconds() + deltaTime*btScalar(800);
|
btScalar endTime = rtc.getTimeMilliseconds() + deltaTime*btScalar(800);
|
||||||
@@ -201,6 +199,10 @@ void PhysicsServerExample::stepSimulation(float deltaTime)
|
|||||||
{
|
{
|
||||||
m_physicsServer.processClientCommands();
|
m_physicsServer.processClientCommands();
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
for (int i=0;i<100;i++)
|
||||||
|
m_physicsServer.processClientCommands();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +290,7 @@ extern int gSharedMemoryKey;
|
|||||||
|
|
||||||
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options)
|
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options)
|
||||||
{
|
{
|
||||||
PhysicsServerExample* example = new PhysicsServerExample(options.m_guiHelper, options.m_sharedMem);
|
PhysicsServerExample* example = new PhysicsServerExample(options.m_guiHelper, options.m_sharedMem, options.m_option);
|
||||||
if (gSharedMemoryKey>=0)
|
if (gSharedMemoryKey>=0)
|
||||||
{
|
{
|
||||||
example->setSharedMemoryKey(gSharedMemoryKey);
|
example->setSharedMemoryKey(gSharedMemoryKey);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ enum PhysicsServerOptions
|
|||||||
{
|
{
|
||||||
PHYSICS_SERVER_ENABLE_COMMAND_LOGGING=1,
|
PHYSICS_SERVER_ENABLE_COMMAND_LOGGING=1,
|
||||||
PHYSICS_SERVER_REPLAY_FROM_COMMAND_LOG=2,
|
PHYSICS_SERVER_REPLAY_FROM_COMMAND_LOG=2,
|
||||||
|
PHYSICS_SERVER_USE_RTC_CLOCK = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options);
|
class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options);
|
||||||
|
|||||||
Reference in New Issue
Block a user