Allow the "debug scene set physics false|true" command to work when bulletsim physics is running in a separate thread.

This will also allow the "disable physics" setting in the region debug viewer dialog to work in this circumstance.
This commit is contained in:
Justin Clark-Casey (justincc)
2014-07-29 01:21:15 +01:00
parent df816b38ac
commit 3654ae8d8c
8 changed files with 78 additions and 39 deletions

View File

@@ -54,6 +54,14 @@ public static class BSParam
// ===================
// From:
/// <summary>
/// Set whether physics is active or not.
/// </summary>
/// <remarks>
/// Can be enabled and disabled to start and stop physics.
/// </remarks>
public static bool Active { get; private set; }
public static bool UseSeparatePhysicsThread { get; private set; }
public static float PhysicsTimeStep { get; private set; }
@@ -373,6 +381,8 @@ public static class BSParam
// v = value (appropriate type)
private static ParameterDefnBase[] ParameterDefinitions =
{
new ParameterDefn<bool>("Active", "If 'true', false then physics is not active",
false ),
new ParameterDefn<bool>("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat",
false ),
new ParameterDefn<float>("PhysicsTimeStep", "If separate thread, seconds to simulate each interval",

View File

@@ -821,7 +821,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
while (m_initialized)
{
int beginSimulationRealtimeMS = Util.EnvironmentTickCount();
DoPhysicsStep(BSParam.PhysicsTimeStep);
if (BSParam.Active)
DoPhysicsStep(BSParam.PhysicsTimeStep);
int simulationRealtimeMS = Util.EnvironmentTickCountSubtract(beginSimulationRealtimeMS);
int simulationTimeVsRealtimeDifferenceMS = ((int)(BSParam.PhysicsTimeStep*1000f)) - simulationRealtimeMS;