BSParam.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyrightD
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using System.Text;
  31. using OpenSim.Region.Physics.Manager;
  32. using OpenMetaverse;
  33. using Nini.Config;
  34. namespace OpenSim.Region.Physics.BulletSPlugin
  35. {
  36. public static class BSParam
  37. {
  38. private static string LogHeader = "[BULLETSIM PARAMETERS]";
  39. // Tuning notes:
  40. // From: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=6575
  41. // Contact points can be added even if the distance is positive. The constraint solver can deal with
  42. // contacts with positive distances as well as negative (penetration). Contact points are discarded
  43. // if the distance exceeds a certain threshold.
  44. // Bullet has a contact processing threshold and a contact breaking threshold.
  45. // If the distance is larger than the contact breaking threshold, it will be removed after one frame.
  46. // If the distance is larger than the contact processing threshold, the constraint solver will ignore it.
  47. // This is separate/independent from the collision margin. The collision margin increases the object a bit
  48. // to improve collision detection performance and accuracy.
  49. // ===================
  50. // From:
  51. public static bool UseSeparatePhysicsThread { get; private set; }
  52. public static float PhysicsTimeStep { get; private set; }
  53. // Level of Detail values kept as float because that's what the Meshmerizer wants
  54. public static float MeshLOD { get; private set; }
  55. public static float MeshCircularLOD { get; private set; }
  56. public static float MeshMegaPrimLOD { get; private set; }
  57. public static float MeshMegaPrimThreshold { get; private set; }
  58. public static float SculptLOD { get; private set; }
  59. public static int CrossingFailuresBeforeOutOfBounds { get; private set; }
  60. public static float UpdateVelocityChangeThreshold { get; private set; }
  61. public static float MinimumObjectMass { get; private set; }
  62. public static float MaximumObjectMass { get; private set; }
  63. public static float MaxLinearVelocity { get; private set; }
  64. public static float MaxLinearVelocitySquared { get; private set; }
  65. public static float MaxAngularVelocity { get; private set; }
  66. public static float MaxAngularVelocitySquared { get; private set; }
  67. public static float MaxAddForceMagnitude { get; private set; }
  68. public static float MaxAddForceMagnitudeSquared { get; private set; }
  69. public static float DensityScaleFactor { get; private set; }
  70. public static float LinearDamping { get; private set; }
  71. public static float AngularDamping { get; private set; }
  72. public static float DeactivationTime { get; private set; }
  73. public static float LinearSleepingThreshold { get; private set; }
  74. public static float AngularSleepingThreshold { get; private set; }
  75. public static float CcdMotionThreshold { get; private set; }
  76. public static float CcdSweptSphereRadius { get; private set; }
  77. public static float ContactProcessingThreshold { get; private set; }
  78. public static bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed
  79. public static bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes
  80. public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects
  81. public static bool ShouldRemoveZeroWidthTriangles { get; private set; }
  82. public static bool ShouldUseBulletHACD { get; set; }
  83. public static bool ShouldUseSingleConvexHullForPrims { get; set; }
  84. public static bool ShouldUseGImpactShapeForPrims { get; set; }
  85. public static bool ShouldUseAssetHulls { get; set; }
  86. public static float TerrainImplementation { get; set; }
  87. public static int TerrainMeshMagnification { get; private set; }
  88. public static float TerrainFriction { get; private set; }
  89. public static float TerrainHitFraction { get; private set; }
  90. public static float TerrainRestitution { get; private set; }
  91. public static float TerrainContactProcessingThreshold { get; private set; }
  92. public static float TerrainCollisionMargin { get; private set; }
  93. public static float DefaultFriction { get; private set; }
  94. public static float DefaultDensity { get; private set; }
  95. public static float DefaultRestitution { get; private set; }
  96. public static float CollisionMargin { get; private set; }
  97. public static float Gravity { get; private set; }
  98. // Physics Engine operation
  99. public static float MaxPersistantManifoldPoolSize { get; private set; }
  100. public static float MaxCollisionAlgorithmPoolSize { get; private set; }
  101. public static bool ShouldDisableContactPoolDynamicAllocation { get; private set; }
  102. public static bool ShouldForceUpdateAllAabbs { get; private set; }
  103. public static bool ShouldRandomizeSolverOrder { get; private set; }
  104. public static bool ShouldSplitSimulationIslands { get; private set; }
  105. public static bool ShouldEnableFrictionCaching { get; private set; }
  106. public static float NumberOfSolverIterations { get; private set; }
  107. public static bool UseSingleSidedMeshes { get; private set; }
  108. public static float GlobalContactBreakingThreshold { get; private set; }
  109. // Avatar parameters
  110. public static float AvatarFriction { get; private set; }
  111. public static float AvatarStandingFriction { get; private set; }
  112. public static float AvatarAlwaysRunFactor { get; private set; }
  113. public static float AvatarDensity { get; private set; }
  114. public static float AvatarRestitution { get; private set; }
  115. public static float AvatarCapsuleWidth { get; private set; }
  116. public static float AvatarCapsuleDepth { get; private set; }
  117. public static float AvatarCapsuleHeight { get; private set; }
  118. public static float AvatarHeightLowFudge { get; private set; }
  119. public static float AvatarHeightMidFudge { get; private set; }
  120. public static float AvatarHeightHighFudge { get; private set; }
  121. public static float AvatarContactProcessingThreshold { get; private set; }
  122. public static float AvatarStopZeroThreshold { get; private set; }
  123. public static int AvatarJumpFrames { get; private set; }
  124. public static float AvatarBelowGroundUpCorrectionMeters { get; private set; }
  125. public static float AvatarStepHeight { get; private set; }
  126. public static float AvatarStepApproachFactor { get; private set; }
  127. public static float AvatarStepForceFactor { get; private set; }
  128. public static float AvatarStepUpCorrectionFactor { get; private set; }
  129. public static int AvatarStepSmoothingSteps { get; private set; }
  130. // Vehicle parameters
  131. public static float VehicleMaxLinearVelocity { get; private set; }
  132. public static float VehicleMaxLinearVelocitySquared { get; private set; }
  133. public static float VehicleMaxAngularVelocity { get; private set; }
  134. public static float VehicleMaxAngularVelocitySq { get; private set; }
  135. public static float VehicleAngularDamping { get; private set; }
  136. public static float VehicleFriction { get; private set; }
  137. public static float VehicleRestitution { get; private set; }
  138. public static Vector3 VehicleLinearFactor { get; private set; }
  139. public static Vector3 VehicleAngularFactor { get; private set; }
  140. public static Vector3 VehicleInertiaFactor { get; private set; }
  141. public static float VehicleGroundGravityFudge { get; private set; }
  142. public static float VehicleAngularBankingTimescaleFudge { get; private set; }
  143. public static bool VehicleEnableLinearDeflection { get; private set; }
  144. public static bool VehicleLinearDeflectionNotCollidingNoZ { get; private set; }
  145. public static bool VehicleEnableAngularVerticalAttraction { get; private set; }
  146. public static int VehicleAngularVerticalAttractionAlgorithm { get; private set; }
  147. public static bool VehicleEnableAngularDeflection { get; private set; }
  148. public static bool VehicleEnableAngularBanking { get; private set; }
  149. // Convex Hulls
  150. public static int CSHullMaxDepthSplit { get; private set; }
  151. public static int CSHullMaxDepthSplitForSimpleShapes { get; private set; }
  152. public static float CSHullConcavityThresholdPercent { get; private set; }
  153. public static float CSHullVolumeConservationThresholdPercent { get; private set; }
  154. public static int CSHullMaxVertices { get; private set; }
  155. public static float CSHullMaxSkinWidth { get; private set; }
  156. public static float BHullMaxVerticesPerHull { get; private set; } // 100
  157. public static float BHullMinClusters { get; private set; } // 2
  158. public static float BHullCompacityWeight { get; private set; } // 0.1
  159. public static float BHullVolumeWeight { get; private set; } // 0.0
  160. public static float BHullConcavity { get; private set; } // 100
  161. public static bool BHullAddExtraDistPoints { get; private set; } // false
  162. public static bool BHullAddNeighboursDistPoints { get; private set; } // false
  163. public static bool BHullAddFacesPoints { get; private set; } // false
  164. public static bool BHullShouldAdjustCollisionMargin { get; private set; } // false
  165. // Linkset implementation parameters
  166. public static float LinksetImplementation { get; private set; }
  167. public static bool LinksetOffsetCenterOfMass { get; private set; }
  168. public static bool LinkConstraintUseFrameOffset { get; private set; }
  169. public static bool LinkConstraintEnableTransMotor { get; private set; }
  170. public static float LinkConstraintTransMotorMaxVel { get; private set; }
  171. public static float LinkConstraintTransMotorMaxForce { get; private set; }
  172. public static float LinkConstraintERP { get; private set; }
  173. public static float LinkConstraintCFM { get; private set; }
  174. public static float LinkConstraintSolverIterations { get; private set; }
  175. public static float PID_D { get; private set; } // derivative
  176. public static float PID_P { get; private set; } // proportional
  177. // Various constants that come from that other virtual world that shall not be named.
  178. public const float MinGravityZ = -1f;
  179. public const float MaxGravityZ = 28f;
  180. public const float MinFriction = 0f;
  181. public const float MaxFriction = 255f;
  182. public const float MinDensity = 0.01f;
  183. public const float MaxDensity = 22587f;
  184. public const float MinRestitution = 0f;
  185. public const float MaxRestitution = 1f;
  186. // =====================================================================================
  187. // =====================================================================================
  188. // Base parameter definition that gets and sets parameter values via a string
  189. public abstract class ParameterDefnBase
  190. {
  191. public string name; // string name of the parameter
  192. public string desc; // a short description of what the parameter means
  193. public ParameterDefnBase(string pName, string pDesc)
  194. {
  195. name = pName;
  196. desc = pDesc;
  197. }
  198. // Set the parameter value to the default
  199. public abstract void AssignDefault(BSScene s);
  200. // Get the value as a string
  201. public abstract string GetValue(BSScene s);
  202. // Set the value to this string value
  203. public abstract void SetValue(BSScene s, string valAsString);
  204. // set the value on a particular object (usually sets in physics engine)
  205. public abstract void SetOnObject(BSScene s, BSPhysObject obj);
  206. public abstract bool HasSetOnObject { get; }
  207. }
  208. // Specific parameter definition for a parameter of a specific type.
  209. public delegate T PGetValue<T>(BSScene s);
  210. public delegate void PSetValue<T>(BSScene s, T val);
  211. public delegate void PSetOnObject<T>(BSScene scene, BSPhysObject obj);
  212. public sealed class ParameterDefn<T> : ParameterDefnBase
  213. {
  214. private T defaultValue;
  215. private PSetValue<T> setter;
  216. private PGetValue<T> getter;
  217. private PSetOnObject<T> objectSet;
  218. public ParameterDefn(string pName, string pDesc, T pDefault, PGetValue<T> pGetter, PSetValue<T> pSetter)
  219. : base(pName, pDesc)
  220. {
  221. defaultValue = pDefault;
  222. setter = pSetter;
  223. getter = pGetter;
  224. objectSet = null;
  225. }
  226. public ParameterDefn(string pName, string pDesc, T pDefault, PGetValue<T> pGetter, PSetValue<T> pSetter, PSetOnObject<T> pObjSetter)
  227. : base(pName, pDesc)
  228. {
  229. defaultValue = pDefault;
  230. setter = pSetter;
  231. getter = pGetter;
  232. objectSet = pObjSetter;
  233. }
  234. // Simple parameter variable where property name is the same as the INI file name
  235. // and the value is only a simple get and set.
  236. public ParameterDefn(string pName, string pDesc, T pDefault)
  237. : base(pName, pDesc)
  238. {
  239. defaultValue = pDefault;
  240. setter = (s, v) => { SetValueByName(s, name, v); };
  241. getter = (s) => { return GetValueByName(s, name); };
  242. objectSet = null;
  243. }
  244. // Use reflection to find the property named 'pName' in BSParam and assign 'val' to same.
  245. private void SetValueByName(BSScene s, string pName, T val)
  246. {
  247. PropertyInfo prop = typeof(BSParam).GetProperty(pName, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
  248. if (prop == null)
  249. {
  250. // This should only be output when someone adds a new INI parameter and misspells the name.
  251. s.Logger.ErrorFormat("{0} SetValueByName: did not find '{1}'. Verify specified property name is the same as the given INI parameters name.", LogHeader, pName);
  252. }
  253. else
  254. {
  255. prop.SetValue(null, val, null);
  256. }
  257. }
  258. // Use reflection to find the property named 'pName' in BSParam and return the value in same.
  259. private T GetValueByName(BSScene s, string pName)
  260. {
  261. PropertyInfo prop = typeof(BSParam).GetProperty(pName, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
  262. if (prop == null)
  263. {
  264. // This should only be output when someone adds a new INI parameter and misspells the name.
  265. s.Logger.ErrorFormat("{0} GetValueByName: did not find '{1}'. Verify specified property name is the same as the given INI parameter name.", LogHeader, pName);
  266. }
  267. return (T)prop.GetValue(null, null);
  268. }
  269. public override void AssignDefault(BSScene s)
  270. {
  271. setter(s, defaultValue);
  272. }
  273. public override string GetValue(BSScene s)
  274. {
  275. return getter(s).ToString();
  276. }
  277. public override void SetValue(BSScene s, string valAsString)
  278. {
  279. // Get the generic type of the setter
  280. Type genericType = setter.GetType().GetGenericArguments()[0];
  281. // Find the 'Parse' method on that type
  282. System.Reflection.MethodInfo parser = null;
  283. try
  284. {
  285. parser = genericType.GetMethod("Parse", new Type[] { typeof(String) } );
  286. }
  287. catch (Exception e)
  288. {
  289. s.Logger.ErrorFormat("{0} Exception getting parser for type '{1}': {2}", LogHeader, genericType, e);
  290. parser = null;
  291. }
  292. if (parser != null)
  293. {
  294. // Parse the input string
  295. try
  296. {
  297. T setValue = (T)parser.Invoke(genericType, new Object[] { valAsString });
  298. // Store the parsed value
  299. setter(s, setValue);
  300. // s.Logger.DebugFormat("{0} Parameter {1} = {2}", LogHeader, name, setValue);
  301. }
  302. catch
  303. {
  304. s.Logger.ErrorFormat("{0} Failed parsing parameter value '{1}' as type '{2}'", LogHeader, valAsString, genericType);
  305. }
  306. }
  307. else
  308. {
  309. s.Logger.ErrorFormat("{0} Could not find parameter parser for type '{1}'", LogHeader, genericType);
  310. }
  311. }
  312. public override bool HasSetOnObject
  313. {
  314. get { return objectSet != null; }
  315. }
  316. public override void SetOnObject(BSScene s, BSPhysObject obj)
  317. {
  318. if (objectSet != null)
  319. objectSet(s, obj);
  320. }
  321. }
  322. // List of all of the externally visible parameters.
  323. // For each parameter, this table maps a text name to getter and setters.
  324. // To add a new externally referencable/settable parameter, add the paramter storage
  325. // location somewhere in the program and make an entry in this table with the
  326. // getters and setters.
  327. // It is easiest to find an existing definition and copy it.
  328. //
  329. // A ParameterDefn<T>() takes the following parameters:
  330. // -- the text name of the parameter. This is used for console input and ini file.
  331. // -- a short text description of the parameter. This shows up in the console listing.
  332. // -- a default value
  333. // -- a delegate for getting the value
  334. // -- a delegate for setting the value
  335. // -- an optional delegate to update the value in the world. Most often used to
  336. // push the new value to an in-world object.
  337. //
  338. // The single letter parameters for the delegates are:
  339. // s = BSScene
  340. // o = BSPhysObject
  341. // v = value (appropriate type)
  342. private static ParameterDefnBase[] ParameterDefinitions =
  343. {
  344. new ParameterDefn<bool>("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat",
  345. false ),
  346. new ParameterDefn<float>("PhysicsTimeStep", "If separate thread, seconds to simulate each interval",
  347. 0.089f ),
  348. new ParameterDefn<bool>("MeshSculptedPrim", "Whether to create meshes for sculpties",
  349. true,
  350. (s) => { return ShouldMeshSculptedPrim; },
  351. (s,v) => { ShouldMeshSculptedPrim = v; } ),
  352. new ParameterDefn<bool>("ForceSimplePrimMeshing", "If true, only use primitive meshes for objects",
  353. false,
  354. (s) => { return ShouldForceSimplePrimMeshing; },
  355. (s,v) => { ShouldForceSimplePrimMeshing = v; } ),
  356. new ParameterDefn<bool>("UseHullsForPhysicalObjects", "If true, create hulls for physical objects",
  357. true,
  358. (s) => { return ShouldUseHullsForPhysicalObjects; },
  359. (s,v) => { ShouldUseHullsForPhysicalObjects = v; } ),
  360. new ParameterDefn<bool>("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes",
  361. true ),
  362. new ParameterDefn<bool>("ShouldUseBulletHACD", "If true, use the Bullet version of HACD",
  363. false ),
  364. new ParameterDefn<bool>("ShouldUseSingleConvexHullForPrims", "If true, use a single convex hull shape for physical prims",
  365. true ),
  366. new ParameterDefn<bool>("ShouldUseGImpactShapeForPrims", "If true, use a GImpact shape for prims with cuts and twists",
  367. false ),
  368. new ParameterDefn<bool>("ShouldUseAssetHulls", "If true, use hull if specified in the mesh asset info",
  369. true ),
  370. new ParameterDefn<int>("CrossingFailuresBeforeOutOfBounds", "How forgiving we are about getting into adjactent regions",
  371. 5 ),
  372. new ParameterDefn<float>("UpdateVelocityChangeThreshold", "Change in updated velocity required before reporting change to simulator",
  373. 0.1f ),
  374. new ParameterDefn<float>("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
  375. 32f,
  376. (s) => { return MeshLOD; },
  377. (s,v) => { MeshLOD = v; } ),
  378. new ParameterDefn<float>("MeshLevelOfDetailCircular", "Level of detail for prims with circular cuts or shapes",
  379. 32f,
  380. (s) => { return MeshCircularLOD; },
  381. (s,v) => { MeshCircularLOD = v; } ),
  382. new ParameterDefn<float>("MeshLevelOfDetailMegaPrimThreshold", "Size (in meters) of a mesh before using MeshMegaPrimLOD",
  383. 10f,
  384. (s) => { return MeshMegaPrimThreshold; },
  385. (s,v) => { MeshMegaPrimThreshold = v; } ),
  386. new ParameterDefn<float>("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters",
  387. 32f,
  388. (s) => { return MeshMegaPrimLOD; },
  389. (s,v) => { MeshMegaPrimLOD = v; } ),
  390. new ParameterDefn<float>("SculptLevelOfDetail", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
  391. 32f,
  392. (s) => { return SculptLOD; },
  393. (s,v) => { SculptLOD = v; } ),
  394. new ParameterDefn<int>("MaxSubStep", "In simulation step, maximum number of substeps",
  395. 10,
  396. (s) => { return s.m_maxSubSteps; },
  397. (s,v) => { s.m_maxSubSteps = (int)v; } ),
  398. new ParameterDefn<float>("FixedTimeStep", "In simulation step, seconds of one substep (1/60)",
  399. 1f / 60f,
  400. (s) => { return s.m_fixedTimeStep; },
  401. (s,v) => { s.m_fixedTimeStep = v; } ),
  402. new ParameterDefn<float>("NominalFrameRate", "The base frame rate we claim",
  403. 55f,
  404. (s) => { return s.NominalFrameRate; },
  405. (s,v) => { s.NominalFrameRate = (int)v; } ),
  406. new ParameterDefn<int>("MaxCollisionsPerFrame", "Max collisions returned at end of each frame",
  407. 2048,
  408. (s) => { return s.m_maxCollisionsPerFrame; },
  409. (s,v) => { s.m_maxCollisionsPerFrame = (int)v; } ),
  410. new ParameterDefn<int>("MaxUpdatesPerFrame", "Max updates returned at end of each frame",
  411. 8000,
  412. (s) => { return s.m_maxUpdatesPerFrame; },
  413. (s,v) => { s.m_maxUpdatesPerFrame = (int)v; } ),
  414. new ParameterDefn<float>("MinObjectMass", "Minimum object mass (0.0001)",
  415. 0.0001f,
  416. (s) => { return MinimumObjectMass; },
  417. (s,v) => { MinimumObjectMass = v; } ),
  418. new ParameterDefn<float>("MaxObjectMass", "Maximum object mass (10000.01)",
  419. 10000.01f,
  420. (s) => { return MaximumObjectMass; },
  421. (s,v) => { MaximumObjectMass = v; } ),
  422. new ParameterDefn<float>("MaxLinearVelocity", "Maximum velocity magnitude that can be assigned to an object",
  423. 1000.0f,
  424. (s) => { return MaxLinearVelocity; },
  425. (s,v) => { MaxLinearVelocity = v; MaxLinearVelocitySquared = v * v; } ),
  426. new ParameterDefn<float>("MaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to an object",
  427. 1000.0f,
  428. (s) => { return MaxAngularVelocity; },
  429. (s,v) => { MaxAngularVelocity = v; MaxAngularVelocitySquared = v * v; } ),
  430. // LL documentation says thie number should be 20f for llApplyImpulse and 200f for llRezObject
  431. new ParameterDefn<float>("MaxAddForceMagnitude", "Maximum force that can be applied by llApplyImpulse (SL says 20f)",
  432. 20000.0f,
  433. (s) => { return MaxAddForceMagnitude; },
  434. (s,v) => { MaxAddForceMagnitude = v; MaxAddForceMagnitudeSquared = v * v; } ),
  435. // Density is passed around as 100kg/m3. This scales that to 1kg/m3.
  436. // Reduce by power of 100 because Bullet doesn't seem to handle objects with large mass very well
  437. new ParameterDefn<float>("DensityScaleFactor", "Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)",
  438. 0.01f ),
  439. new ParameterDefn<float>("PID_D", "Derivitive factor for motion smoothing",
  440. 2200f ),
  441. new ParameterDefn<float>("PID_P", "Parameteric factor for motion smoothing",
  442. 900f ),
  443. new ParameterDefn<float>("DefaultFriction", "Friction factor used on new objects",
  444. 0.2f,
  445. (s) => { return DefaultFriction; },
  446. (s,v) => { DefaultFriction = v; s.UnmanagedParams[0].defaultFriction = v; } ),
  447. // For historical reasons, the viewer and simulator multiply the density by 100
  448. new ParameterDefn<float>("DefaultDensity", "Density for new objects" ,
  449. 1000.0006836f, // Aluminum g/cm3 * 100
  450. (s) => { return DefaultDensity; },
  451. (s,v) => { DefaultDensity = v; s.UnmanagedParams[0].defaultDensity = v; } ),
  452. new ParameterDefn<float>("DefaultRestitution", "Bouncyness of an object" ,
  453. 0f,
  454. (s) => { return DefaultRestitution; },
  455. (s,v) => { DefaultRestitution = v; s.UnmanagedParams[0].defaultRestitution = v; } ),
  456. new ParameterDefn<float>("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!)",
  457. 0.04f,
  458. (s) => { return CollisionMargin; },
  459. (s,v) => { CollisionMargin = v; s.UnmanagedParams[0].collisionMargin = v; } ),
  460. new ParameterDefn<float>("Gravity", "Vertical force of gravity (negative means down)",
  461. -9.80665f,
  462. (s) => { return Gravity; },
  463. (s,v) => { Gravity = v; s.UnmanagedParams[0].gravity = v; },
  464. (s,o) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,Gravity)); } ),
  465. new ParameterDefn<float>("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)",
  466. 0f,
  467. (s) => { return LinearDamping; },
  468. (s,v) => { LinearDamping = v; },
  469. (s,o) => { s.PE.SetDamping(o.PhysBody, LinearDamping, AngularDamping); } ),
  470. new ParameterDefn<float>("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)",
  471. 0f,
  472. (s) => { return AngularDamping; },
  473. (s,v) => { AngularDamping = v; },
  474. (s,o) => { s.PE.SetDamping(o.PhysBody, LinearDamping, AngularDamping); } ),
  475. new ParameterDefn<float>("DeactivationTime", "Seconds before considering an object potentially static",
  476. 0.2f,
  477. (s) => { return DeactivationTime; },
  478. (s,v) => { DeactivationTime = v; },
  479. (s,o) => { s.PE.SetDeactivationTime(o.PhysBody, DeactivationTime); } ),
  480. new ParameterDefn<float>("LinearSleepingThreshold", "Seconds to measure linear movement before considering static",
  481. 0.8f,
  482. (s) => { return LinearSleepingThreshold; },
  483. (s,v) => { LinearSleepingThreshold = v;},
  484. (s,o) => { s.PE.SetSleepingThresholds(o.PhysBody, LinearSleepingThreshold, AngularSleepingThreshold); } ),
  485. new ParameterDefn<float>("AngularSleepingThreshold", "Seconds to measure angular movement before considering static",
  486. 1.0f,
  487. (s) => { return AngularSleepingThreshold; },
  488. (s,v) => { AngularSleepingThreshold = v;},
  489. (s,o) => { s.PE.SetSleepingThresholds(o.PhysBody, LinearSleepingThreshold, AngularSleepingThreshold); } ),
  490. new ParameterDefn<float>("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
  491. 0.0f, // set to zero to disable
  492. (s) => { return CcdMotionThreshold; },
  493. (s,v) => { CcdMotionThreshold = v;},
  494. (s,o) => { s.PE.SetCcdMotionThreshold(o.PhysBody, CcdMotionThreshold); } ),
  495. new ParameterDefn<float>("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
  496. 0.2f,
  497. (s) => { return CcdSweptSphereRadius; },
  498. (s,v) => { CcdSweptSphereRadius = v;},
  499. (s,o) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, CcdSweptSphereRadius); } ),
  500. new ParameterDefn<float>("ContactProcessingThreshold", "Distance above which contacts can be discarded (0 means no discard)" ,
  501. 0.0f,
  502. (s) => { return ContactProcessingThreshold; },
  503. (s,v) => { ContactProcessingThreshold = v;},
  504. (s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ),
  505. new ParameterDefn<float>("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
  506. (float)BSTerrainPhys.TerrainImplementation.Mesh ),
  507. new ParameterDefn<int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" ,
  508. 2 ),
  509. new ParameterDefn<float>("TerrainFriction", "Factor to reduce movement against terrain surface" ,
  510. 0.3f ),
  511. new ParameterDefn<float>("TerrainHitFraction", "Distance to measure hit collisions" ,
  512. 0.8f ),
  513. new ParameterDefn<float>("TerrainRestitution", "Bouncyness" ,
  514. 0f ),
  515. new ParameterDefn<float>("TerrainContactProcessingThreshold", "Distance from terrain to stop processing collisions" ,
  516. 0.0f ),
  517. new ParameterDefn<float>("TerrainCollisionMargin", "Margin where collision checking starts" ,
  518. 0.08f ),
  519. new ParameterDefn<float>("AvatarFriction", "Factor to reduce movement against an avatar. Changed on avatar recreation.",
  520. 0.2f ),
  521. new ParameterDefn<float>("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.",
  522. 0.95f ),
  523. new ParameterDefn<float>("AvatarAlwaysRunFactor", "Speed multiplier if avatar is set to always run",
  524. 1.3f ),
  525. // For historical reasons, density is reported * 100
  526. new ParameterDefn<float>("AvatarDensity", "Density of an avatar. Changed on avatar recreation. Scaled times 100.",
  527. 3500f) , // 3.5 * 100
  528. new ParameterDefn<float>("AvatarRestitution", "Bouncyness. Changed on avatar recreation.",
  529. 0f ),
  530. new ParameterDefn<float>("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule",
  531. 0.6f ) ,
  532. new ParameterDefn<float>("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule",
  533. 0.45f ),
  534. new ParameterDefn<float>("AvatarCapsuleHeight", "Default height of space around avatar",
  535. 1.5f ),
  536. new ParameterDefn<float>("AvatarHeightLowFudge", "A fudge factor to make small avatars stand on the ground",
  537. -0.2f ),
  538. new ParameterDefn<float>("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground",
  539. 0.1f ),
  540. new ParameterDefn<float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground",
  541. 0.1f ),
  542. new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
  543. 0.1f ),
  544. new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",
  545. 0.1f ),
  546. new ParameterDefn<float>("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground",
  547. 1.0f ),
  548. new ParameterDefn<int>("AvatarJumpFrames", "Number of frames to allow jump forces. Changes jump height.",
  549. 4 ),
  550. new ParameterDefn<float>("AvatarStepHeight", "Height of a step obstacle to consider step correction",
  551. 0.6f ) ,
  552. new ParameterDefn<float>("AvatarStepApproachFactor", "Factor to control angle of approach to step (0=straight on)",
  553. 0.6f ),
  554. new ParameterDefn<float>("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step",
  555. 1.0f ),
  556. new ParameterDefn<float>("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step",
  557. 1.0f ),
  558. new ParameterDefn<int>("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs",
  559. 2 ),
  560. new ParameterDefn<float>("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle",
  561. 1000.0f,
  562. (s) => { return (float)VehicleMaxLinearVelocity; },
  563. (s,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySquared = v * v; } ),
  564. new ParameterDefn<float>("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle",
  565. 12.0f,
  566. (s) => { return (float)VehicleMaxAngularVelocity; },
  567. (s,v) => { VehicleMaxAngularVelocity = v; VehicleMaxAngularVelocitySq = v * v; } ),
  568. new ParameterDefn<float>("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
  569. 0.0f ),
  570. new ParameterDefn<Vector3>("VehicleLinearFactor", "Fraction of physical linear changes applied to vehicle (<0,0,0> to <1,1,1>)",
  571. new Vector3(1f, 1f, 1f) ),
  572. new ParameterDefn<Vector3>("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (<0,0,0> to <1,1,1>)",
  573. new Vector3(1f, 1f, 1f) ),
  574. new ParameterDefn<Vector3>("VehicleInertiaFactor", "Fraction of physical inertia applied (<0,0,0> to <1,1,1>)",
  575. new Vector3(1f, 1f, 1f) ),
  576. new ParameterDefn<float>("VehicleFriction", "Friction of vehicle on the ground (0.0 - 1.0)",
  577. 0.0f ),
  578. new ParameterDefn<float>("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)",
  579. 0.0f ),
  580. new ParameterDefn<float>("VehicleGroundGravityFudge", "Factor to multiply gravity if a ground vehicle is probably on the ground (0.0 - 1.0)",
  581. 0.2f ),
  582. new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.",
  583. 60.0f ),
  584. new ParameterDefn<bool>("VehicleEnableLinearDeflection", "Turn on/off vehicle linear deflection effect",
  585. true ),
  586. new ParameterDefn<bool>("VehicleLinearDeflectionNotCollidingNoZ", "Turn on/off linear deflection Z effect on non-colliding vehicles",
  587. true ),
  588. new ParameterDefn<bool>("VehicleEnableAngularVerticalAttraction", "Turn on/off vehicle angular vertical attraction effect",
  589. true ),
  590. new ParameterDefn<int>("VehicleAngularVerticalAttractionAlgorithm", "Select vertical attraction algo. You need to look at the source.",
  591. 0 ),
  592. new ParameterDefn<bool>("VehicleEnableAngularDeflection", "Turn on/off vehicle angular deflection effect",
  593. true ),
  594. new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect",
  595. true ),
  596. new ParameterDefn<float>("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
  597. 0f,
  598. (s) => { return MaxPersistantManifoldPoolSize; },
  599. (s,v) => { MaxPersistantManifoldPoolSize = v; s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ),
  600. new ParameterDefn<float>("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)",
  601. 0f,
  602. (s) => { return MaxCollisionAlgorithmPoolSize; },
  603. (s,v) => { MaxCollisionAlgorithmPoolSize = v; s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ),
  604. new ParameterDefn<bool>("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count",
  605. false,
  606. (s) => { return ShouldDisableContactPoolDynamicAllocation; },
  607. (s,v) => { ShouldDisableContactPoolDynamicAllocation = v;
  608. s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = NumericBool(v); } ),
  609. new ParameterDefn<bool>("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step",
  610. false,
  611. (s) => { return ShouldForceUpdateAllAabbs; },
  612. (s,v) => { ShouldForceUpdateAllAabbs = v; s.UnmanagedParams[0].shouldForceUpdateAllAabbs = NumericBool(v); } ),
  613. new ParameterDefn<bool>("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction",
  614. true,
  615. (s) => { return ShouldRandomizeSolverOrder; },
  616. (s,v) => { ShouldRandomizeSolverOrder = v; s.UnmanagedParams[0].shouldRandomizeSolverOrder = NumericBool(v); } ),
  617. new ParameterDefn<bool>("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands",
  618. true,
  619. (s) => { return ShouldSplitSimulationIslands; },
  620. (s,v) => { ShouldSplitSimulationIslands = v; s.UnmanagedParams[0].shouldSplitSimulationIslands = NumericBool(v); } ),
  621. new ParameterDefn<bool>("ShouldEnableFrictionCaching", "Enable friction computation caching",
  622. true,
  623. (s) => { return ShouldEnableFrictionCaching; },
  624. (s,v) => { ShouldEnableFrictionCaching = v; s.UnmanagedParams[0].shouldEnableFrictionCaching = NumericBool(v); } ),
  625. new ParameterDefn<float>("NumberOfSolverIterations", "Number of internal iterations (0 means default)",
  626. 0f, // zero says use Bullet default
  627. (s) => { return NumberOfSolverIterations; },
  628. (s,v) => { NumberOfSolverIterations = v; s.UnmanagedParams[0].numberOfSolverIterations = v; } ),
  629. new ParameterDefn<bool>("UseSingleSidedMeshes", "Whether to compute collisions based on single sided meshes.",
  630. true,
  631. (s) => { return UseSingleSidedMeshes; },
  632. (s,v) => { UseSingleSidedMeshes = v; s.UnmanagedParams[0].useSingleSidedMeshes = NumericBool(v); } ),
  633. new ParameterDefn<float>("GlobalContactBreakingThreshold", "Amount of shape radius before breaking a collision contact (0 says Bullet default (0.2))",
  634. 0f,
  635. (s) => { return GlobalContactBreakingThreshold; },
  636. (s,v) => { GlobalContactBreakingThreshold = v; s.UnmanagedParams[0].globalContactBreakingThreshold = v; } ),
  637. new ParameterDefn<int>("CSHullMaxDepthSplit", "CS impl: max depth to split for hull. 1-10 but > 7 is iffy",
  638. 7 ),
  639. new ParameterDefn<int>("CSHullMaxDepthSplitForSimpleShapes", "CS impl: max depth setting for simple prim shapes",
  640. 2 ),
  641. new ParameterDefn<float>("CSHullConcavityThresholdPercent", "CS impl: concavity threshold percent (0-20)",
  642. 5f ),
  643. new ParameterDefn<float>("CSHullVolumeConservationThresholdPercent", "percent volume conservation to collapse hulls (0-30)",
  644. 5f ),
  645. new ParameterDefn<int>("CSHullMaxVertices", "CS impl: maximum number of vertices in output hulls. Keep < 50.",
  646. 32 ),
  647. new ParameterDefn<float>("CSHullMaxSkinWidth", "CS impl: skin width to apply to output hulls.",
  648. 0f ),
  649. new ParameterDefn<float>("BHullMaxVerticesPerHull", "Bullet impl: max number of vertices per created hull",
  650. 200f ),
  651. new ParameterDefn<float>("BHullMinClusters", "Bullet impl: minimum number of hulls to create per mesh",
  652. 10f ),
  653. new ParameterDefn<float>("BHullCompacityWeight", "Bullet impl: weight factor for how compact to make hulls",
  654. 20f ),
  655. new ParameterDefn<float>("BHullVolumeWeight", "Bullet impl: weight factor for volume in created hull",
  656. 0.1f ),
  657. new ParameterDefn<float>("BHullConcavity", "Bullet impl: weight factor for how convex a created hull can be",
  658. 10f ),
  659. new ParameterDefn<bool>("BHullAddExtraDistPoints", "Bullet impl: whether to add extra vertices for long distance vectors",
  660. true ),
  661. new ParameterDefn<bool>("BHullAddNeighboursDistPoints", "Bullet impl: whether to add extra vertices between neighbor hulls",
  662. true ),
  663. new ParameterDefn<bool>("BHullAddFacesPoints", "Bullet impl: whether to add extra vertices to break up hull faces",
  664. true ),
  665. new ParameterDefn<bool>("BHullShouldAdjustCollisionMargin", "Bullet impl: whether to shrink resulting hulls to account for collision margin",
  666. false ),
  667. new ParameterDefn<float>("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)",
  668. (float)BSLinkset.LinksetImplementation.Compound ),
  669. new ParameterDefn<bool>("LinksetOffsetCenterOfMass", "If 'true', compute linkset center-of-mass and offset linkset position to account for same",
  670. true ),
  671. new ParameterDefn<bool>("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.",
  672. false ),
  673. new ParameterDefn<bool>("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints",
  674. true ),
  675. new ParameterDefn<float>("LinkConstraintTransMotorMaxVel", "Maximum velocity to be applied by translational motor in linkset constraints",
  676. 5.0f ),
  677. new ParameterDefn<float>("LinkConstraintTransMotorMaxForce", "Maximum force to be applied by translational motor in linkset constraints",
  678. 0.1f ),
  679. new ParameterDefn<float>("LinkConstraintCFM", "Amount constraint can be violated. 0=no violation, 1=infinite. Default=0.1",
  680. 0.1f ),
  681. new ParameterDefn<float>("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2",
  682. 0.1f ),
  683. new ParameterDefn<float>("LinkConstraintSolverIterations", "Number of solver iterations when computing constraint. (0 = Bullet default)",
  684. 40 ),
  685. new ParameterDefn<int>("PhysicsMetricFrames", "Frames between outputting detailed phys metrics. (0 is off)",
  686. 0,
  687. (s) => { return s.PhysicsMetricDumpFrames; },
  688. (s,v) => { s.PhysicsMetricDumpFrames = v; } ),
  689. new ParameterDefn<float>("ResetBroadphasePool", "Setting this is any value resets the broadphase collision pool",
  690. 0f,
  691. (s) => { return 0f; },
  692. (s,v) => { BSParam.ResetBroadphasePoolTainted(s, v, false /* inTaintTime */); } ),
  693. new ParameterDefn<float>("ResetConstraintSolver", "Setting this is any value resets the constraint solver",
  694. 0f,
  695. (s) => { return 0f; },
  696. (s,v) => { BSParam.ResetConstraintSolverTainted(s, v); } ),
  697. };
  698. // Convert a boolean to our numeric true and false values
  699. public static float NumericBool(bool b)
  700. {
  701. return (b ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse);
  702. }
  703. // Convert numeric true and false values to a boolean
  704. public static bool BoolNumeric(float b)
  705. {
  706. return (b == ConfigurationParameters.numericTrue ? true : false);
  707. }
  708. // Search through the parameter definitions and return the matching
  709. // ParameterDefn structure.
  710. // Case does not matter as names are compared after converting to lower case.
  711. // Returns 'false' if the parameter is not found.
  712. internal static bool TryGetParameter(string paramName, out ParameterDefnBase defn)
  713. {
  714. bool ret = false;
  715. ParameterDefnBase foundDefn = null;
  716. string pName = paramName.ToLower();
  717. foreach (ParameterDefnBase parm in ParameterDefinitions)
  718. {
  719. if (pName == parm.name.ToLower())
  720. {
  721. foundDefn = parm;
  722. ret = true;
  723. break;
  724. }
  725. }
  726. defn = foundDefn;
  727. return ret;
  728. }
  729. // Pass through the settable parameters and set the default values
  730. internal static void SetParameterDefaultValues(BSScene physicsScene)
  731. {
  732. foreach (ParameterDefnBase parm in ParameterDefinitions)
  733. {
  734. parm.AssignDefault(physicsScene);
  735. }
  736. }
  737. // Get user set values out of the ini file.
  738. internal static void SetParameterConfigurationValues(BSScene physicsScene, IConfig cfg)
  739. {
  740. foreach (ParameterDefnBase parm in ParameterDefinitions)
  741. {
  742. parm.SetValue(physicsScene, cfg.GetString(parm.name, parm.GetValue(physicsScene)));
  743. }
  744. }
  745. internal static PhysParameterEntry[] SettableParameters = new PhysParameterEntry[1];
  746. // This creates an array in the correct format for returning the list of
  747. // parameters. This is used by the 'list' option of the 'physics' command.
  748. internal static void BuildParameterTable()
  749. {
  750. if (SettableParameters.Length < ParameterDefinitions.Length)
  751. {
  752. List<PhysParameterEntry> entries = new List<PhysParameterEntry>();
  753. for (int ii = 0; ii < ParameterDefinitions.Length; ii++)
  754. {
  755. ParameterDefnBase pd = ParameterDefinitions[ii];
  756. entries.Add(new PhysParameterEntry(pd.name, pd.desc));
  757. }
  758. // make the list alphabetical for ease of finding anything
  759. entries.Sort((ppe1, ppe2) => { return ppe1.name.CompareTo(ppe2.name); });
  760. SettableParameters = entries.ToArray();
  761. }
  762. }
  763. // =====================================================================
  764. // =====================================================================
  765. // There are parameters that, when set, cause things to happen in the physics engine.
  766. // This causes the broadphase collision cache to be cleared.
  767. private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v, bool inTaintTime)
  768. {
  769. BSScene physScene = pPhysScene;
  770. physScene.TaintedObject(inTaintTime, "BSParam.ResetBroadphasePoolTainted", delegate()
  771. {
  772. physScene.PE.ResetBroadphasePool(physScene.World);
  773. });
  774. }
  775. // This causes the constraint solver cache to be cleared and reset.
  776. private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v)
  777. {
  778. BSScene physScene = pPhysScene;
  779. physScene.TaintedObject(BSScene.DetailLogZero, "BSParam.ResetConstraintSolver", delegate()
  780. {
  781. physScene.PE.ResetConstraintSolver(physScene.World);
  782. });
  783. }
  784. }
  785. }