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