BulletSim: Parameterize nominal frame rate (55) and add parameters to dynamially turn on/off detailed, unmanaged data dumping of prims and vehicles.

0.7.5-pf-bulletsim
Robert Adams 2012-12-27 18:19:25 -08:00
parent 7a5f598399
commit c1e7539c77
4 changed files with 21 additions and 5 deletions

View File

@ -822,6 +822,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
if (!IsActive) return;
if (PhysicsScene.VehiclePhysicalLoggingEnabled)
BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, Prim.PhysBody.ptr);
ForgetKnownVehicleProperties();
MoveLinear(pTimestep);
@ -836,6 +839,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// for the physics engine to note the changes so an UpdateProperties event will happen.
PushKnownChanged();
if (PhysicsScene.VehiclePhysicalLoggingEnabled)
BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, Prim.PhysBody.ptr);
VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
Prim.LocalID, VehiclePosition, Prim.Force, VehicleVelocity, VehicleRotationalVelocity);
}

View File

@ -212,6 +212,11 @@ public static class BSParam
(s,cf,p,v) => { s.m_fixedTimeStep = cf.GetFloat(p, v); },
(s) => { return (float)s.m_fixedTimeStep; },
(s,p,l,v) => { s.m_fixedTimeStep = v; } ),
new ParameterDefn("NominalFrameRate", "The base frame rate we claim",
55f,
(s,cf,p,v) => { s.NominalFrameRate = cf.GetInt(p, (int)v); },
(s) => { return (float)s.NominalFrameRate; },
(s,p,l,v) => { s.NominalFrameRate = (int)v; } ),
new ParameterDefn("MaxCollisionsPerFrame", "Max collisions returned at end of each frame",
2048f,
(s,cf,p,v) => { s.m_maxCollisionsPerFrame = cf.GetInt(p, (int)v); },

View File

@ -758,8 +758,8 @@ public sealed class BSPrim : BSPhysObject
// For compound based linksets, this enables and disables interactions of the children.
Linkset.Refresh(this);
DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}",
LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), CurrentCollisionFlags, PhysBody, PhysShape);
DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},cType={6},body={7},shape={8}",
LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), CurrentCollisionFlags, PhysBody.collisionType, PhysBody, PhysShape);
}
// "Making dynamic" means changing to and from static.

View File

@ -74,6 +74,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
internal int m_maxSubSteps;
internal float m_fixedTimeStep;
internal long m_simulationStep = 0;
internal float NominalFrameRate { get; set; }
public long SimulationStep { get { return m_simulationStep; } }
internal int m_taintsToProcessPerStep;
internal float LastTimeStep { get; private set; }
@ -162,6 +163,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
private string m_physicsLoggingPrefix;
private int m_physicsLoggingFileMinutes;
private bool m_physicsLoggingDoFlush;
private bool m_physicsPhysicalDumpEnabled;
// 'true' of the vehicle code is to log lots of details
public bool VehicleLoggingEnabled { get; private set; }
public bool VehiclePhysicalLoggingEnabled { get; private set; }
@ -272,6 +274,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
m_physicsPhysicalDumpEnabled = pConfig.GetBoolean("PhysicsPhysicalDumpEnabled", false);
// Very detailed logging for vehicle debugging
VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
VehiclePhysicalLoggingEnabled = pConfig.GetBoolean("VehiclePhysicalLoggingEnabled", false);
@ -488,7 +491,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
// Only enable this in a limited test world with few objects.
// BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG
if (m_physicsPhysicalDumpEnabled)
BulletSimAPI.DumpAllInfo2(World.ptr);
// step the physical world one interval
m_simulationStep++;
@ -587,12 +591,13 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
// Only enable this in a limited test world with few objects.
// BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG
if (m_physicsPhysicalDumpEnabled)
BulletSimAPI.DumpAllInfo2(World.ptr);
// The physics engine returns the number of milliseconds it simulated this call.
// These are summed and normalized to one second and divided by 1000 to give the reported physics FPS.
// Multiply by 55 to give a nominal frame rate of 55.
return (float)numSubSteps * m_fixedTimeStep * 1000f * 55f;
return (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate;
}
// Something has collided