28 using System.Collections.Generic;
29 using System.Reflection;
32 using OpenSim.Region.PhysicsModules.SharedBase;
37 namespace OpenSim.
Region.PhysicsModule.BulletS
39 public static class BSParam
41 private static string LogHeader =
"[BULLETSIM PARAMETERS]";
63 public static bool Active {
get;
private set; }
65 public static bool UseSeparatePhysicsThread {
get;
private set; }
66 public static float PhysicsTimeStep {
get;
private set; }
69 public static float MeshLOD {
get;
private set; }
70 public static float MeshCircularLOD {
get;
private set; }
71 public static float MeshMegaPrimLOD {
get;
private set; }
72 public static float MeshMegaPrimThreshold {
get;
private set; }
73 public static float SculptLOD {
get;
private set; }
75 public static int CrossingFailuresBeforeOutOfBounds {
get;
private set; }
76 public static float UpdateVelocityChangeThreshold {
get;
private set; }
78 public static float MinimumObjectMass {
get;
private set; }
79 public static float MaximumObjectMass {
get;
private set; }
80 public static float MaxLinearVelocity {
get;
private set; }
81 public static float MaxLinearVelocitySquared {
get;
private set; }
82 public static float MaxAngularVelocity {
get;
private set; }
83 public static float MaxAngularVelocitySquared {
get;
private set; }
84 public static float MaxAddForceMagnitude {
get;
private set; }
85 public static float MaxAddForceMagnitudeSquared {
get;
private set; }
86 public static float DensityScaleFactor {
get;
private set; }
88 public static float LinearDamping {
get;
private set; }
89 public static float AngularDamping {
get;
private set; }
90 public static float DeactivationTime {
get;
private set; }
91 public static float LinearSleepingThreshold {
get;
private set; }
92 public static float AngularSleepingThreshold {
get;
private set; }
93 public static float CcdMotionThreshold {
get;
private set; }
94 public static float CcdSweptSphereRadius {
get;
private set; }
95 public static float ContactProcessingThreshold {
get;
private set; }
97 public static bool ShouldMeshSculptedPrim {
get;
private set; }
98 public static bool ShouldForceSimplePrimMeshing {
get;
private set; }
99 public static bool ShouldUseHullsForPhysicalObjects {
get;
private set; }
100 public static bool ShouldRemoveZeroWidthTriangles {
get;
private set; }
101 public static bool ShouldUseBulletHACD {
get; set; }
102 public static bool ShouldUseSingleConvexHullForPrims {
get; set; }
103 public static bool ShouldUseGImpactShapeForPrims {
get; set; }
104 public static bool ShouldUseAssetHulls {
get; set; }
106 public static float TerrainImplementation {
get; set; }
107 public static int TerrainMeshMagnification {
get;
private set; }
108 public static float TerrainGroundPlane {
get;
private set; }
109 public static float TerrainFriction {
get;
private set; }
110 public static float TerrainHitFraction {
get;
private set; }
111 public static float TerrainRestitution {
get;
private set; }
112 public static float TerrainContactProcessingThreshold {
get;
private set; }
113 public static float TerrainCollisionMargin {
get;
private set; }
115 public static float DefaultFriction {
get;
private set; }
116 public static float DefaultDensity {
get;
private set; }
117 public static float DefaultRestitution {
get;
private set; }
118 public static float CollisionMargin {
get;
private set; }
119 public static float Gravity {
get;
private set; }
122 public static float MaxPersistantManifoldPoolSize {
get;
private set; }
123 public static float MaxCollisionAlgorithmPoolSize {
get;
private set; }
124 public static bool ShouldDisableContactPoolDynamicAllocation {
get;
private set; }
125 public static bool ShouldForceUpdateAllAabbs {
get;
private set; }
126 public static bool ShouldRandomizeSolverOrder {
get;
private set; }
127 public static bool ShouldSplitSimulationIslands {
get;
private set; }
128 public static bool ShouldEnableFrictionCaching {
get;
private set; }
129 public static float NumberOfSolverIterations {
get;
private set; }
130 public static bool UseSingleSidedMeshes {
get;
private set; }
131 public static float GlobalContactBreakingThreshold {
get;
private set; }
132 public static float PhysicsUnmanLoggingFrames {
get;
private set; }
135 public static bool AvatarToAvatarCollisionsByDefault {
get;
private set; }
136 public static float AvatarFriction {
get;
private set; }
137 public static float AvatarStandingFriction {
get;
private set; }
138 public static float AvatarAlwaysRunFactor {
get;
private set; }
139 public static float AvatarDensity {
get;
private set; }
140 public static float AvatarRestitution {
get;
private set; }
141 public static int AvatarShape {
get;
private set; }
142 public static float AvatarCapsuleWidth {
get;
private set; }
143 public static float AvatarCapsuleDepth {
get;
private set; }
144 public static float AvatarCapsuleHeight {
get;
private set; }
145 public static bool AvatarUseBefore09SizeComputation {
get;
private set; }
146 public static float AvatarHeightLowFudge {
get;
private set; }
147 public static float AvatarHeightMidFudge {
get;
private set; }
148 public static float AvatarHeightHighFudge {
get;
private set; }
149 public static float AvatarFlyingGroundMargin {
get;
private set; }
150 public static float AvatarFlyingGroundUpForce {
get;
private set; }
151 public static float AvatarTerminalVelocity {
get;
private set; }
152 public static float AvatarContactProcessingThreshold {
get;
private set; }
153 public static float AvatarAddForcePushFactor {
get;
private set; }
154 public static float AvatarStopZeroThreshold {
get;
private set; }
155 public static float AvatarStopZeroThresholdSquared {
get;
private set; }
156 public static int AvatarJumpFrames {
get;
private set; }
157 public static float AvatarBelowGroundUpCorrectionMeters {
get;
private set; }
158 public static float AvatarStepHeight {
get;
private set; }
159 public static float AvatarStepAngle {
get;
private set; }
160 public static float AvatarStepGroundFudge {
get;
private set; }
161 public static float AvatarStepApproachFactor {
get;
private set; }
162 public static float AvatarStepForceFactor {
get;
private set; }
163 public static float AvatarStepUpCorrectionFactor {
get;
private set; }
164 public static int AvatarStepSmoothingSteps {
get;
private set; }
167 public static float VehicleMaxLinearVelocity {
get;
private set; }
168 public static float VehicleMaxLinearVelocitySquared {
get;
private set; }
169 public static float VehicleMinLinearVelocity {
get;
private set; }
170 public static float VehicleMinLinearVelocitySquared {
get;
private set; }
171 public static float VehicleMaxAngularVelocity {
get;
private set; }
172 public static float VehicleMaxAngularVelocitySq {
get;
private set; }
173 public static float VehicleAngularDamping {
get;
private set; }
174 public static float VehicleFriction {
get;
private set; }
175 public static float VehicleRestitution {
get;
private set; }
176 public static Vector3 VehicleLinearFactor {
get;
private set; }
177 public static Vector3 VehicleAngularFactor {
get;
private set; }
178 public static Vector3 VehicleInertiaFactor {
get;
private set; }
179 public static float VehicleGroundGravityFudge {
get;
private set; }
180 public static float VehicleAngularBankingTimescaleFudge {
get;
private set; }
181 public static bool VehicleEnableLinearDeflection {
get;
private set; }
182 public static bool VehicleLinearDeflectionNotCollidingNoZ {
get;
private set; }
183 public static bool VehicleEnableAngularVerticalAttraction {
get;
private set; }
184 public static int VehicleAngularVerticalAttractionAlgorithm {
get;
private set; }
185 public static bool VehicleEnableAngularDeflection {
get;
private set; }
186 public static bool VehicleEnableAngularBanking {
get;
private set; }
190 public static int CSHullMaxDepthSplit {
get;
private set; }
191 public static int CSHullMaxDepthSplitForSimpleShapes {
get;
private set; }
192 public static float CSHullConcavityThresholdPercent {
get;
private set; }
193 public static float CSHullVolumeConservationThresholdPercent {
get;
private set; }
194 public static int CSHullMaxVertices {
get;
private set; }
195 public static float CSHullMaxSkinWidth {
get;
private set; }
196 public static float BHullMaxVerticesPerHull {
get;
private set; }
197 public static float BHullMinClusters {
get;
private set; }
198 public static float BHullCompacityWeight {
get;
private set; }
199 public static float BHullVolumeWeight {
get;
private set; }
200 public static float BHullConcavity {
get;
private set; }
201 public static bool BHullAddExtraDistPoints {
get;
private set; }
202 public static bool BHullAddNeighboursDistPoints {
get;
private set; }
203 public static bool BHullAddFacesPoints {
get;
private set; }
204 public static bool BHullShouldAdjustCollisionMargin {
get;
private set; }
205 public static float WhichHACD {
get;
private set; }
209 public static float VHACDresolution {
get;
private set; }
210 public static float VHACDdepth {
get;
private set; }
211 public static float VHACDconcavity {
get;
private set; }
212 public static float VHACDplaneDownsampling {
get;
private set; }
213 public static float VHACDconvexHullDownsampling {
get;
private set; }
214 public static float VHACDalpha {
get;
private set; }
215 public static float VHACDbeta {
get;
private set; }
216 public static float VHACDgamma {
get;
private set; }
217 public static float VHACDpca {
get;
private set; }
218 public static float VHACDmode {
get;
private set; }
219 public static float VHACDmaxNumVerticesPerCH {
get;
private set; }
220 public static float VHACDminVolumePerCH {
get;
private set; }
223 public static float LinksetImplementation {
get;
private set; }
224 public static bool LinksetOffsetCenterOfMass {
get;
private set; }
225 public static bool LinkConstraintUseFrameOffset {
get;
private set; }
226 public static bool LinkConstraintEnableTransMotor {
get;
private set; }
227 public static float LinkConstraintTransMotorMaxVel {
get;
private set; }
228 public static float LinkConstraintTransMotorMaxForce {
get;
private set; }
229 public static float LinkConstraintERP {
get;
private set; }
230 public static float LinkConstraintCFM {
get;
private set; }
231 public static float LinkConstraintSolverIterations {
get;
private set; }
233 public static float PID_D {
get;
private set; }
234 public static float PID_P {
get;
private set; }
236 public static float DebugNumber {
get;
private set; }
239 public const float MinGravityZ = -1f;
240 public const float MaxGravityZ = 28f;
241 public const float MinFriction = 0f;
242 public const float MaxFriction = 255f;
243 public const float MinDensity = 0.01f;
244 public const float MaxDensity = 22587f;
245 public const float MinRestitution = 0f;
246 public const float MaxRestitution = 1f;
262 public abstract void AssignDefault(
BSScene s);
264 public abstract string GetValue(
BSScene s);
266 public abstract void SetValue(
BSScene s,
string valAsString);
269 public abstract bool HasSetOnObject {
get; }
273 public delegate T PGetValue<T>(
BSScene s);
274 public delegate
void PSetValue<T>(
BSScene s, T val);
278 private T defaultValue;
279 private PSetValue<T> setter;
280 private PGetValue<T> getter;
281 private PSetOnObject<T> objectSet;
282 public ParameterDefn(
string pName,
string pDesc, T pDefault, PGetValue<T> pGetter, PSetValue<T> pSetter)
285 defaultValue = pDefault;
290 public ParameterDefn(
string pName,
string pDesc, T pDefault, PGetValue<T> pGetter, PSetValue<T> pSetter, PSetOnObject<T> pObjSetter)
293 defaultValue = pDefault;
296 objectSet = pObjSetter;
303 defaultValue = pDefault;
304 setter = (s, v) => { SetValueByName(s, name, v); };
305 getter = (s) => {
return GetValueByName(s, name); };
309 private void SetValueByName(
BSScene s,
string pName, T val)
311 PropertyInfo prop = typeof(BSParam).GetProperty(pName, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
315 s.Logger.ErrorFormat(
"{0} SetValueByName: did not find '{1}'. Verify specified property name is the same as the given INI parameters name.", LogHeader, pName);
319 prop.SetValue(null, val, null);
323 private T GetValueByName(BSScene s,
string pName)
325 PropertyInfo prop = typeof(BSParam).GetProperty(pName, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
329 s.Logger.ErrorFormat(
"{0} GetValueByName: did not find '{1}'. Verify specified property name is the same as the given INI parameter name.", LogHeader, pName);
331 return (T)prop.GetValue(null, null);
335 setter(s, defaultValue);
339 return getter(s).ToString();
344 Type genericType = setter.GetType().GetGenericArguments()[0];
346 System.Reflection.MethodInfo
parser = null;
349 parser = genericType.GetMethod(
"Parse",
new Type[] { typeof(String) } );
353 s.Logger.ErrorFormat(
"{0} Exception getting parser for type '{1}': {2}", LogHeader, genericType, e);
361 T setValue = (T)parser.Invoke(genericType,
new Object[] { valAsString });
368 s.Logger.ErrorFormat(
"{0} Failed parsing parameter value '{1}' as type '{2}'", LogHeader, valAsString, genericType);
373 s.Logger.ErrorFormat(
"{0} Could not find parameter parser for type '{1}'", LogHeader, genericType);
376 public override bool HasSetOnObject
378 get {
return objectSet != null; }
382 if (objectSet != null)
407 private static ParameterDefnBase[] ParameterDefinitions =
409 new ParameterDefn<bool>(
"Active",
"If 'true', false then physics is not active",
411 new ParameterDefn<bool>(
"UseSeparatePhysicsThread",
"If 'true', the physics engine runs independent from the simulator heartbeat",
413 new ParameterDefn<float>(
"PhysicsTimeStep",
"If separate thread, seconds to simulate each interval",
416 new ParameterDefn<bool>(
"MeshSculptedPrim",
"Whether to create meshes for sculpties",
418 (s) => {
return ShouldMeshSculptedPrim; },
419 (s,v) => { ShouldMeshSculptedPrim = v; } ),
420 new ParameterDefn<bool>(
"ForceSimplePrimMeshing",
"If true, only use primitive meshes for objects",
422 (s) => {
return ShouldForceSimplePrimMeshing; },
423 (s,v) => { ShouldForceSimplePrimMeshing = v; } ),
424 new ParameterDefn<bool>(
"UseHullsForPhysicalObjects",
"If true, create hulls for physical objects",
426 (s) => {
return ShouldUseHullsForPhysicalObjects; },
427 (s,v) => { ShouldUseHullsForPhysicalObjects = v; } ),
428 new ParameterDefn<bool>(
"ShouldRemoveZeroWidthTriangles",
"If true, remove degenerate triangles from meshes",
430 new ParameterDefn<bool>(
"ShouldUseBulletHACD",
"If true, use the Bullet version of HACD",
432 new ParameterDefn<bool>(
"ShouldUseSingleConvexHullForPrims",
"If true, use a single convex hull shape for physical prims",
434 new ParameterDefn<bool>(
"ShouldUseGImpactShapeForPrims",
"If true, use a GImpact shape for prims with cuts and twists",
436 new ParameterDefn<bool>(
"ShouldUseAssetHulls",
"If true, use hull if specified in the mesh asset info",
439 new ParameterDefn<int>(
"CrossingFailuresBeforeOutOfBounds",
"How forgiving we are about getting into adjactent regions",
441 new ParameterDefn<float>(
"UpdateVelocityChangeThreshold",
"Change in updated velocity required before reporting change to simulator",
444 new ParameterDefn<float>(
"MeshLevelOfDetail",
"Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
446 (s) => {
return MeshLOD; },
447 (s,v) => { MeshLOD = v; } ),
448 new ParameterDefn<float>(
"MeshLevelOfDetailCircular",
"Level of detail for prims with circular cuts or shapes",
450 (s) => {
return MeshCircularLOD; },
451 (s,v) => { MeshCircularLOD = v; } ),
452 new ParameterDefn<float>(
"MeshLevelOfDetailMegaPrimThreshold",
"Size (in meters) of a mesh before using MeshMegaPrimLOD",
454 (s) => {
return MeshMegaPrimThreshold; },
455 (s,v) => { MeshMegaPrimThreshold = v; } ),
456 new ParameterDefn<float>(
"MeshLevelOfDetailMegaPrim",
"Level of detail to render meshes larger than threshold meters",
458 (s) => {
return MeshMegaPrimLOD; },
459 (s,v) => { MeshMegaPrimLOD = v; } ),
460 new ParameterDefn<float>(
"SculptLevelOfDetail",
"Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
462 (s) => {
return SculptLOD; },
463 (s,v) => { SculptLOD = v; } ),
465 new ParameterDefn<int>(
"MaxSubStep",
"In simulation step, maximum number of substeps",
467 (s) => {
return s.m_maxSubSteps; },
468 (s,v) => { s.m_maxSubSteps = (int)v; } ),
469 new ParameterDefn<float>(
"FixedTimeStep",
"In simulation step, seconds of one substep (1/60)",
471 (s) => {
return s.m_fixedTimeStep; },
472 (s,v) => { s.m_fixedTimeStep = v; } ),
473 new ParameterDefn<float>(
"NominalFrameRate",
"The base frame rate we claim",
475 (s) => {
return s.NominalFrameRate; },
476 (s,v) => { s.NominalFrameRate = (int)v; } ),
477 new ParameterDefn<int>(
"MaxCollisionsPerFrame",
"Max collisions returned at end of each frame",
479 (s) => {
return s.m_maxCollisionsPerFrame; },
480 (s,v) => { s.m_maxCollisionsPerFrame = (int)v; } ),
481 new ParameterDefn<int>(
"MaxUpdatesPerFrame",
"Max updates returned at end of each frame",
483 (s) => {
return s.m_maxUpdatesPerFrame; },
484 (s,v) => { s.m_maxUpdatesPerFrame = (int)v; } ),
486 new ParameterDefn<float>(
"MinObjectMass",
"Minimum object mass (0.0001)",
488 (s) => {
return MinimumObjectMass; },
489 (s,v) => { MinimumObjectMass = v; } ),
490 new ParameterDefn<float>(
"MaxObjectMass",
"Maximum object mass (10000.01)",
492 (s) => {
return MaximumObjectMass; },
493 (s,v) => { MaximumObjectMass = v; } ),
494 new ParameterDefn<float>(
"MaxLinearVelocity",
"Maximum velocity magnitude that can be assigned to an object",
496 (s) => {
return MaxLinearVelocity; },
497 (s,v) => { MaxLinearVelocity = v; MaxLinearVelocitySquared = v * v; } ),
498 new ParameterDefn<float>(
"MaxAngularVelocity",
"Maximum rotational velocity magnitude that can be assigned to an object",
500 (s) => {
return MaxAngularVelocity; },
501 (s,v) => { MaxAngularVelocity = v; MaxAngularVelocitySquared = v * v; } ),
503 new ParameterDefn<float>(
"MaxAddForceMagnitude",
"Maximum force that can be applied by llApplyImpulse (SL says 20f)",
505 (s) => {
return MaxAddForceMagnitude; },
506 (s,v) => { MaxAddForceMagnitude = v; MaxAddForceMagnitudeSquared = v * v; } ),
509 new ParameterDefn<float>(
"DensityScaleFactor",
"Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)",
512 new ParameterDefn<float>(
"PID_D",
"Derivitive factor for motion smoothing",
514 new ParameterDefn<float>(
"PID_P",
"Parameteric factor for motion smoothing",
517 new ParameterDefn<float>(
"DefaultFriction",
"Friction factor used on new objects",
519 (s) => {
return DefaultFriction; },
520 (s,v) => { DefaultFriction = v; s.UnmanagedParams[0].defaultFriction = v; } ),
522 new ParameterDefn<float>(
"DefaultDensity",
"Density for new objects" ,
524 (s) => {
return DefaultDensity; },
525 (s,v) => { DefaultDensity = v; s.UnmanagedParams[0].defaultDensity = v; } ),
526 new ParameterDefn<float>(
"DefaultRestitution",
"Bouncyness of an object" ,
528 (s) => {
return DefaultRestitution; },
529 (s,v) => { DefaultRestitution = v; s.UnmanagedParams[0].defaultRestitution = v; } ),
530 new ParameterDefn<float>(
"CollisionMargin",
"Margin around objects before collisions are calculated (must be zero!)",
532 (s) => {
return CollisionMargin; },
533 (s,v) => { CollisionMargin = v; s.UnmanagedParams[0].collisionMargin = v; } ),
534 new ParameterDefn<float>(
"Gravity",
"Vertical force of gravity (negative means down)",
536 (s) => {
return Gravity; },
537 (s,v) => { Gravity = v; s.UnmanagedParams[0].gravity = v; },
538 (s,o) => { s.PE.SetGravity(o.PhysBody,
new Vector3(0f,0f,Gravity)); } ),
541 new ParameterDefn<float>(
"LinearDamping",
"Factor to damp linear movement per second (0.0 - 1.0)",
543 (s) => {
return LinearDamping; },
544 (s,v) => { LinearDamping = v; },
545 (s,o) => { s.PE.SetDamping(o.PhysBody, LinearDamping, AngularDamping); } ),
546 new ParameterDefn<float>(
"AngularDamping",
"Factor to damp angular movement per second (0.0 - 1.0)",
548 (s) => {
return AngularDamping; },
549 (s,v) => { AngularDamping = v; },
550 (s,o) => { s.PE.SetDamping(o.PhysBody, LinearDamping, AngularDamping); } ),
551 new ParameterDefn<float>(
"DeactivationTime",
"Seconds before considering an object potentially static",
553 (s) => {
return DeactivationTime; },
554 (s,v) => { DeactivationTime = v; },
555 (s,o) => { s.PE.SetDeactivationTime(o.PhysBody, DeactivationTime); } ),
556 new ParameterDefn<float>(
"LinearSleepingThreshold",
"Seconds to measure linear movement before considering static",
558 (s) => {
return LinearSleepingThreshold; },
559 (s,v) => { LinearSleepingThreshold = v;},
560 (s,o) => { s.PE.SetSleepingThresholds(o.PhysBody, LinearSleepingThreshold, AngularSleepingThreshold); } ),
561 new ParameterDefn<float>(
"AngularSleepingThreshold",
"Seconds to measure angular movement before considering static",
563 (s) => {
return AngularSleepingThreshold; },
564 (s,v) => { AngularSleepingThreshold = v;},
565 (s,o) => { s.PE.SetSleepingThresholds(o.PhysBody, LinearSleepingThreshold, AngularSleepingThreshold); } ),
566 new ParameterDefn<float>(
"CcdMotionThreshold",
"Continuious collision detection threshold (0 means no CCD)" ,
568 (s) => {
return CcdMotionThreshold; },
569 (s,v) => { CcdMotionThreshold = v;},
570 (s,o) => { s.PE.SetCcdMotionThreshold(o.PhysBody, CcdMotionThreshold); } ),
571 new ParameterDefn<float>(
"CcdSweptSphereRadius",
"Continuious collision detection test radius" ,
573 (s) => {
return CcdSweptSphereRadius; },
574 (s,v) => { CcdSweptSphereRadius = v;},
575 (s,o) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, CcdSweptSphereRadius); } ),
576 new ParameterDefn<float>(
"ContactProcessingThreshold",
"Distance above which contacts can be discarded (0 means no discard)" ,
578 (s) => {
return ContactProcessingThreshold; },
579 (s,v) => { ContactProcessingThreshold = v;},
580 (s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ),
582 new ParameterDefn<float>(
"TerrainImplementation",
"Type of shape to use for terrain (0=heightmap, 1=mesh)",
583 (
float)BSTerrainPhys.TerrainImplementation.Heightmap ),
584 new ParameterDefn<
int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" ,
586 new ParameterDefn<
float>("TerrainGroundPlane", "Altitude of ground plane used to keep things from falling to infinity" ,
588 new ParameterDefn<
float>("TerrainFriction", "Factor to reduce movement against terrain surface" ,
590 new ParameterDefn<
float>("TerrainHitFraction", "Distance to measure hit collisions" ,
592 new ParameterDefn<
float>("TerrainRestitution", "Bouncyness" ,
594 new ParameterDefn<
float>("TerrainContactProcessingThreshold", "Distance from terrain to stop processing collisions" ,
596 new ParameterDefn<
float>("TerrainCollisionMargin", "Margin where collision checking starts" ,
599 new ParameterDefn<
bool>("AvatarToAvatarCollisionsByDefault", "Should avatars collide with other avatars by default?",
601 new ParameterDefn<
float>("AvatarFriction", "Factor to reduce movement against an avatar.
Changed on avatar recreation.",
603 new ParameterDefn<
float>("AvatarStandingFriction", "Avatar friction when standing.
Changed on avatar recreation.",
605 new ParameterDefn<
float>("AvatarAlwaysRunFactor", "Speed multiplier if avatar is set to always run",
608 new ParameterDefn<
float>("AvatarDensity", "Density of an avatar.
Changed on avatar recreation. Scaled times 100.",
610 new ParameterDefn<
float>("AvatarRestitution", "Bouncyness.
Changed on avatar recreation.",
612 new ParameterDefn<
int>("AvatarShape", "Code for avatar physical shape: 0:capsule, 1:cube, 2:ovoid, 2:mesh",
613 BSShapeCollection.AvatarShapeCube ) ,
614 new ParameterDefn<
float>("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule",
616 new ParameterDefn<
float>("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule",
618 new ParameterDefn<
float>("AvatarCapsuleHeight", "Default height of space around avatar",
620 new ParameterDefn<
bool>("AvatarUseBefore09SizeComputation", "Use the old fudge method of computing avatar capsule size",
622 new ParameterDefn<
float>("AvatarHeightLowFudge", "A fudge factor to make small avatars stand on the ground",
624 new ParameterDefn<
float>("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground",
626 new ParameterDefn<
float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground",
628 new ParameterDefn<
float>("AvatarFlyingGroundMargin", "Meters avatar is kept above the ground when flying",
630 new ParameterDefn<
float>("AvatarFlyingGroundUpForce", "Upward force applied to the avatar to keep it at flying ground margin",
632 new ParameterDefn<
float>("AvatarTerminalVelocity", "Terminal Velocity of falling avatar",
634 new ParameterDefn<
float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
636 new ParameterDefn<
float>("AvatarAddForcePushFactor", "BSCharacter.AddForce is multiplied by this and mass to be like other physics engines",
638 new ParameterDefn<
float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",
640 (s) => {
return (
float)AvatarStopZeroThreshold; },
641 (s,v) => { AvatarStopZeroThreshold = v; AvatarStopZeroThresholdSquared = v * v; } ),
642 new ParameterDefn<float>(
"AvatarBelowGroundUpCorrectionMeters",
"Meters to move avatar up if it seems to be below ground",
644 new ParameterDefn<int>(
"AvatarJumpFrames",
"Number of frames to allow jump forces. Changes jump height.",
646 new ParameterDefn<float>(
"AvatarStepHeight",
"Height of a step obstacle to consider step correction",
648 new ParameterDefn<float>(
"AvatarStepAngle",
"The angle (in radians) for a vertical surface to be considered a step",
650 new ParameterDefn<float>(
"AvatarStepGroundFudge",
"Fudge factor subtracted from avatar base when comparing collision height",
652 new ParameterDefn<float>(
"AvatarStepApproachFactor",
"Factor to control angle of approach to step (0=straight on)",
654 new ParameterDefn<float>(
"AvatarStepForceFactor",
"Controls the amount of force up applied to step up onto a step",
656 new ParameterDefn<float>(
"AvatarStepUpCorrectionFactor",
"Multiplied by height of step collision to create up movement at step",
658 new ParameterDefn<int>(
"AvatarStepSmoothingSteps",
"Number of frames after a step collision that we continue walking up stairs",
661 new ParameterDefn<float>(
"VehicleMaxLinearVelocity",
"Maximum velocity magnitude that can be assigned to a vehicle",
663 (s) => {
return (
float)VehicleMaxLinearVelocity; },
664 (s,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySquared = v * v; } ),
665 new ParameterDefn<float>(
"VehicleMinLinearVelocity",
"Maximum velocity magnitude that can be assigned to a vehicle",
667 (s) => {
return (
float)VehicleMinLinearVelocity; },
668 (s,v) => { VehicleMinLinearVelocity = v; VehicleMinLinearVelocitySquared = v * v; } ),
669 new ParameterDefn<float>(
"VehicleMaxAngularVelocity",
"Maximum rotational velocity magnitude that can be assigned to a vehicle",
671 (s) => {
return (
float)VehicleMaxAngularVelocity; },
672 (s,v) => { VehicleMaxAngularVelocity = v; VehicleMaxAngularVelocitySq = v * v; } ),
673 new ParameterDefn<float>(
"VehicleAngularDamping",
"Factor to damp vehicle angular movement per second (0.0 - 1.0)",
675 new ParameterDefn<Vector3>(
"VehicleLinearFactor",
"Fraction of physical linear changes applied to vehicle (<0,0,0> to <1,1,1>)",
676 new Vector3(1f, 1f, 1f) ),
677 new ParameterDefn<Vector3>(
"VehicleAngularFactor",
"Fraction of physical angular changes applied to vehicle (<0,0,0> to <1,1,1>)",
678 new Vector3(1f, 1f, 1f) ),
679 new ParameterDefn<Vector3>(
"VehicleInertiaFactor",
"Fraction of physical inertia applied (<0,0,0> to <1,1,1>)",
680 new Vector3(1f, 1f, 1f) ),
681 new ParameterDefn<float>(
"VehicleFriction",
"Friction of vehicle on the ground (0.0 - 1.0)",
683 new ParameterDefn<float>(
"VehicleRestitution",
"Bouncyness factor for vehicles (0.0 - 1.0)",
685 new ParameterDefn<float>(
"VehicleGroundGravityFudge",
"Factor to multiply gravity if a ground vehicle is probably on the ground (0.0 - 1.0)",
687 new ParameterDefn<float>(
"VehicleAngularBankingTimescaleFudge",
"Factor to multiple angular banking timescale. Tune to increase realism.",
689 new ParameterDefn<bool>(
"VehicleEnableLinearDeflection",
"Turn on/off vehicle linear deflection effect",
691 new ParameterDefn<bool>(
"VehicleLinearDeflectionNotCollidingNoZ",
"Turn on/off linear deflection Z effect on non-colliding vehicles",
693 new ParameterDefn<bool>(
"VehicleEnableAngularVerticalAttraction",
"Turn on/off vehicle angular vertical attraction effect",
695 new ParameterDefn<int>(
"VehicleAngularVerticalAttractionAlgorithm",
"Select vertical attraction algo. You need to look at the source.",
697 new ParameterDefn<bool>(
"VehicleEnableAngularDeflection",
"Turn on/off vehicle angular deflection effect",
699 new ParameterDefn<bool>(
"VehicleEnableAngularBanking",
"Turn on/off vehicle angular banking effect",
702 new ParameterDefn<float>(
"MaxPersistantManifoldPoolSize",
"Number of manifolds pooled (0 means default of 4096)",
704 (s) => {
return MaxPersistantManifoldPoolSize; },
705 (s,v) => { MaxPersistantManifoldPoolSize = v; s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ),
706 new ParameterDefn<float>(
"MaxCollisionAlgorithmPoolSize",
"Number of collisions pooled (0 means default of 4096)",
708 (s) => {
return MaxCollisionAlgorithmPoolSize; },
709 (s,v) => { MaxCollisionAlgorithmPoolSize = v; s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ),
710 new ParameterDefn<bool>(
"ShouldDisableContactPoolDynamicAllocation",
"Enable to allow large changes in object count",
712 (s) => {
return ShouldDisableContactPoolDynamicAllocation; },
713 (s,v) => { ShouldDisableContactPoolDynamicAllocation = v;
714 s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = NumericBool(v); } ),
715 new ParameterDefn<bool>(
"ShouldForceUpdateAllAabbs",
"Enable to recomputer AABBs every simulator step",
717 (s) => {
return ShouldForceUpdateAllAabbs; },
718 (s,v) => { ShouldForceUpdateAllAabbs = v; s.UnmanagedParams[0].shouldForceUpdateAllAabbs = NumericBool(v); } ),
719 new ParameterDefn<bool>(
"ShouldRandomizeSolverOrder",
"Enable for slightly better stacking interaction",
721 (s) => {
return ShouldRandomizeSolverOrder; },
722 (s,v) => { ShouldRandomizeSolverOrder = v; s.UnmanagedParams[0].shouldRandomizeSolverOrder = NumericBool(v); } ),
723 new ParameterDefn<bool>(
"ShouldSplitSimulationIslands",
"Enable splitting active object scanning islands",
725 (s) => {
return ShouldSplitSimulationIslands; },
726 (s,v) => { ShouldSplitSimulationIslands = v; s.UnmanagedParams[0].shouldSplitSimulationIslands = NumericBool(v); } ),
727 new ParameterDefn<bool>(
"ShouldEnableFrictionCaching",
"Enable friction computation caching",
729 (s) => {
return ShouldEnableFrictionCaching; },
730 (s,v) => { ShouldEnableFrictionCaching = v; s.UnmanagedParams[0].shouldEnableFrictionCaching = NumericBool(v); } ),
731 new ParameterDefn<float>(
"NumberOfSolverIterations",
"Number of internal iterations (0 means default)",
733 (s) => {
return NumberOfSolverIterations; },
734 (s,v) => { NumberOfSolverIterations = v; s.UnmanagedParams[0].numberOfSolverIterations = v; } ),
735 new ParameterDefn<bool>(
"UseSingleSidedMeshes",
"Whether to compute collisions based on single sided meshes.",
737 (s) => {
return UseSingleSidedMeshes; },
738 (s,v) => { UseSingleSidedMeshes = v; s.UnmanagedParams[0].useSingleSidedMeshes = NumericBool(v); } ),
739 new ParameterDefn<float>(
"GlobalContactBreakingThreshold",
"Amount of shape radius before breaking a collision contact (0 says Bullet default (0.2))",
741 (s) => {
return GlobalContactBreakingThreshold; },
742 (s,v) => { GlobalContactBreakingThreshold = v; s.UnmanagedParams[0].globalContactBreakingThreshold = v; } ),
743 new ParameterDefn<float>(
"PhysicsUnmanLoggingFrames",
"If non-zero, frames between output of detailed unmanaged physics statistics",
745 (s) => {
return PhysicsUnmanLoggingFrames; },
746 (s,v) => { PhysicsUnmanLoggingFrames = v; s.UnmanagedParams[0].physicsLoggingFrames = v; } ),
748 new ParameterDefn<int>(
"CSHullMaxDepthSplit",
"CS impl: max depth to split for hull. 1-10 but > 7 is iffy",
750 new ParameterDefn<int>(
"CSHullMaxDepthSplitForSimpleShapes",
"CS impl: max depth setting for simple prim shapes",
752 new ParameterDefn<float>(
"CSHullConcavityThresholdPercent",
"CS impl: concavity threshold percent (0-20)",
754 new ParameterDefn<float>(
"CSHullVolumeConservationThresholdPercent",
"percent volume conservation to collapse hulls (0-30)",
756 new ParameterDefn<int>(
"CSHullMaxVertices",
"CS impl: maximum number of vertices in output hulls. Keep < 50.",
758 new ParameterDefn<float>(
"CSHullMaxSkinWidth",
"CS impl: skin width to apply to output hulls.",
761 new ParameterDefn<float>(
"BHullMaxVerticesPerHull",
"Bullet impl: max number of vertices per created hull",
763 new ParameterDefn<float>(
"BHullMinClusters",
"Bullet impl: minimum number of hulls to create per mesh",
765 new ParameterDefn<float>(
"BHullCompacityWeight",
"Bullet impl: weight factor for how compact to make hulls",
767 new ParameterDefn<float>(
"BHullVolumeWeight",
"Bullet impl: weight factor for volume in created hull",
769 new ParameterDefn<float>(
"BHullConcavity",
"Bullet impl: weight factor for how convex a created hull can be",
771 new ParameterDefn<bool>(
"BHullAddExtraDistPoints",
"Bullet impl: whether to add extra vertices for long distance vectors",
773 new ParameterDefn<bool>(
"BHullAddNeighboursDistPoints",
"Bullet impl: whether to add extra vertices between neighbor hulls",
775 new ParameterDefn<bool>(
"BHullAddFacesPoints",
"Bullet impl: whether to add extra vertices to break up hull faces",
777 new ParameterDefn<bool>(
"BHullShouldAdjustCollisionMargin",
"Bullet impl: whether to shrink resulting hulls to account for collision margin",
780 new ParameterDefn<float>(
"WhichHACD",
"zero if Bullet HACD, non-zero says VHACD",
782 new ParameterDefn<float>(
"VHACDresolution",
"max number of voxels generated during voxelization stage",
784 new ParameterDefn<float>(
"VHACDdepth",
"max number of clipping stages",
786 new ParameterDefn<float>(
"VHACDconcavity",
"maximum concavity",
788 new ParameterDefn<float>(
"VHACDplaneDownsampling",
"granularity of search for best clipping plane",
790 new ParameterDefn<float>(
"VHACDconvexHullDownsampling",
"precision of hull gen process",
792 new ParameterDefn<float>(
"VHACDalpha",
"bias toward clipping along symmetry planes",
794 new ParameterDefn<float>(
"VHACDbeta",
"bias toward clipping along revolution axis",
796 new ParameterDefn<float>(
"VHACDgamma",
"max concavity when merging",
798 new ParameterDefn<float>(
"VHACDpca",
"on/off normalizing mesh before decomp",
800 new ParameterDefn<float>(
"VHACDmode",
"0:voxel based, 1: tetrahedron based",
802 new ParameterDefn<float>(
"VHACDmaxNumVerticesPerCH",
"max triangles per convex hull",
804 new ParameterDefn<float>(
"VHACDminVolumePerCH",
"sampling of generated convex hulls",
807 new ParameterDefn<float>(
"LinksetImplementation",
"Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)",
808 (
float)BSLinkset.LinksetImplementation.Compound ),
809 new ParameterDefn<
bool>("LinksetOffsetCenterOfMass", "If 'true', compute linkset center-of-mass and offset linkset position to account for same",
811 new ParameterDefn<
bool>("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.",
813 new ParameterDefn<
bool>("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints",
815 new ParameterDefn<
float>("LinkConstraintTransMotorMaxVel", "Maximum velocity to be applied by translational motor in linkset constraints",
817 new ParameterDefn<
float>("LinkConstraintTransMotorMaxForce", "Maximum force to be applied by translational motor in linkset constraints",
819 new ParameterDefn<
float>("LinkConstraintCFM", "Amount constraint can be violated. 0=no violation, 1=infinite. Default=0.1",
821 new ParameterDefn<
float>("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2",
823 new ParameterDefn<
float>("LinkConstraintSolverIterations", "Number of solver iterations when computing constraint. (0 = Bullet default)",
826 new ParameterDefn<
float>("DebugNumber", "A console setable number sometimes used for debugging",
829 new ParameterDefn<
int>("PhysicsMetricFrames", "Frames between outputting detailed phys metrics. (0 is off)",
831 (s) => {
return s.PhysicsMetricDumpFrames; },
832 (s,v) => { s.PhysicsMetricDumpFrames = v; } ),
833 new ParameterDefn<float>(
"ResetBroadphasePool",
"Setting this is any value resets the broadphase collision pool",
835 (s) => {
return 0f; },
836 (s,v) => { BSParam.ResetBroadphasePoolTainted(s, v,
false ); } ),
837 new ParameterDefn<float>(
"ResetConstraintSolver",
"Setting this is any value resets the constraint solver",
839 (s) => {
return 0f; },
840 (s,v) => { BSParam.ResetConstraintSolverTainted(s, v); } ),
844 public static float NumericBool(
bool b)
846 return (b ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse);
850 public static bool BoolNumeric(
float b)
852 return (b == ConfigurationParameters.numericTrue ?
true :
false);
859 internal static bool TryGetParameter(
string paramName, out ParameterDefnBase defn)
862 ParameterDefnBase foundDefn = null;
863 string pName = paramName.ToLower();
865 foreach (ParameterDefnBase parm
in ParameterDefinitions)
867 if (pName == parm.name.ToLower())
879 internal static void SetParameterDefaultValues(BSScene physicsScene)
881 foreach (ParameterDefnBase parm
in ParameterDefinitions)
883 parm.AssignDefault(physicsScene);
888 internal static void SetParameterConfigurationValues(BSScene physicsScene, IConfig cfg)
890 foreach (ParameterDefnBase parm
in ParameterDefinitions)
892 parm.SetValue(physicsScene, cfg.GetString(parm.name, parm.GetValue(physicsScene)));
900 internal static void BuildParameterTable()
902 if (SettableParameters.Length < ParameterDefinitions.Length)
904 List<PhysParameterEntry> entries =
new List<PhysParameterEntry>();
905 for (
int ii = 0; ii < ParameterDefinitions.Length; ii++)
907 ParameterDefnBase pd = ParameterDefinitions[ii];
912 entries.Sort((ppe1, ppe2) => {
return ppe1.name.CompareTo(ppe2.name); });
914 SettableParameters = entries.ToArray();
922 private static void ResetBroadphasePoolTainted(BSScene pPhysScene,
float v,
bool inTaintTime)
924 BSScene physScene = pPhysScene;
925 physScene.TaintedObject(inTaintTime,
"BSParam.ResetBroadphasePoolTainted", delegate()
927 physScene.PE.ResetBroadphasePool(physScene.World);
932 private static void ResetConstraintSolverTainted(BSScene pPhysScene,
float v)
934 BSScene physScene = pPhysScene;
935 physScene.TaintedObject(BSScene.DetailLogZero,
"BSParam.ResetConstraintSolver", delegate()
937 physScene.PE.ResetConstraintSolver(physScene.World);
override void SetOnObject(BSScene s, BSPhysObject obj)
ParameterDefn(string pName, string pDesc, T pDefault, PGetValue< T > pGetter, PSetValue< T > pSetter, PSetOnObject< T > pObjSetter)
override void SetValue(BSScene s, string valAsString)
override void AssignDefault(BSScene s)
ParameterDefn(string pName, string pDesc, T pDefault, PGetValue< T > pGetter, PSetValue< T > pSetter)
ParameterDefn(string pName, string pDesc, T pDefault)
ParameterDefnBase(string pName, string pDesc)
override string GetValue(BSScene s)