aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs582
1 files changed, 0 insertions, 582 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
deleted file mode 100755
index 69ac8cd..0000000
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ /dev/null
@@ -1,582 +0,0 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30
31using OpenSim.Region.Physics.Manager;
32
33using OpenMetaverse;
34using Nini.Config;
35
36namespace OpenSim.Region.Physics.BulletSPlugin
37{
38public static class BSParam
39{
40 // Level of Detail values kept as float because that's what the Meshmerizer wants
41 public static float MeshLOD { get; private set; }
42 public static float MeshMegaPrimLOD { get; private set; }
43 public static float MeshMegaPrimThreshold { get; private set; }
44 public static float SculptLOD { get; private set; }
45
46 public static float MinimumObjectMass { get; private set; }
47 public static float MaximumObjectMass { get; private set; }
48
49 public static float LinearDamping { get; private set; }
50 public static float AngularDamping { get; private set; }
51 public static float DeactivationTime { get; private set; }
52 public static float LinearSleepingThreshold { get; private set; }
53 public static float AngularSleepingThreshold { get; private set; }
54 public static float CcdMotionThreshold { get; private set; }
55 public static float CcdSweptSphereRadius { get; private set; }
56 public static float ContactProcessingThreshold { get; private set; }
57
58 public static bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed
59 public static bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes
60 public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects
61
62 public static float TerrainImplementation { get; private set; }
63 public static float TerrainFriction { get; private set; }
64 public static float TerrainHitFraction { get; private set; }
65 public static float TerrainRestitution { get; private set; }
66 public static float TerrainCollisionMargin { get; private set; }
67
68 // Avatar parameters
69 public static float AvatarFriction { get; private set; }
70 public static float AvatarStandingFriction { get; private set; }
71 public static float AvatarAlwaysRunFactor { get; private set; }
72 public static float AvatarDensity { get; private set; }
73 public static float AvatarRestitution { get; private set; }
74 public static float AvatarCapsuleWidth { get; private set; }
75 public static float AvatarCapsuleDepth { get; private set; }
76 public static float AvatarCapsuleHeight { get; private set; }
77 public static float AvatarContactProcessingThreshold { get; private set; }
78
79 public static float VehicleAngularDamping { get; private set; }
80
81 public static float LinksetImplementation { get; private set; }
82 public static float LinkConstraintUseFrameOffset { get; private set; }
83 public static float LinkConstraintEnableTransMotor { get; private set; }
84 public static float LinkConstraintTransMotorMaxVel { get; private set; }
85 public static float LinkConstraintTransMotorMaxForce { get; private set; }
86 public static float LinkConstraintERP { get; private set; }
87 public static float LinkConstraintCFM { get; private set; }
88 public static float LinkConstraintSolverIterations { get; private set; }
89
90 public static float PID_D { get; private set; } // derivative
91 public static float PID_P { get; private set; } // proportional
92
93 // Various constants that come from that other virtual world that shall not be named
94 public const float MinGravityZ = -1f;
95 public const float MaxGravityZ = 28f;
96 public const float MinFriction = 0f;
97 public const float MaxFriction = 255f;
98 public const float MinDensity = 0f;
99 public const float MaxDensity = 22587f;
100 public const float MinRestitution = 0f;
101 public const float MaxRestitution = 1f;
102 public const float MaxAddForceMagnitude = 20000f;
103
104 // ===========================================================================
105 public delegate void ParamUser(BSScene scene, IConfig conf, string paramName, float val);
106 public delegate float ParamGet(BSScene scene);
107 public delegate void ParamSet(BSScene scene, string paramName, uint localID, float val);
108 public delegate void SetOnObject(BSScene scene, BSPhysObject obj, float val);
109
110 public struct ParameterDefn
111 {
112 public string name; // string name of the parameter
113 public string desc; // a short description of what the parameter means
114 public float defaultValue; // default value if not specified anywhere else
115 public ParamUser userParam; // get the value from the configuration file
116 public ParamGet getter; // return the current value stored for this parameter
117 public ParamSet setter; // set the current value for this parameter
118 public SetOnObject onObject; // set the value on an object in the physical domain
119 public ParameterDefn(string n, string d, float v, ParamUser u, ParamGet g, ParamSet s)
120 {
121 name = n;
122 desc = d;
123 defaultValue = v;
124 userParam = u;
125 getter = g;
126 setter = s;
127 onObject = null;
128 }
129 public ParameterDefn(string n, string d, float v, ParamUser u, ParamGet g, ParamSet s, SetOnObject o)
130 {
131 name = n;
132 desc = d;
133 defaultValue = v;
134 userParam = u;
135 getter = g;
136 setter = s;
137 onObject = o;
138 }
139 }
140
141 // List of all of the externally visible parameters.
142 // For each parameter, this table maps a text name to getter and setters.
143 // To add a new externally referencable/settable parameter, add the paramter storage
144 // location somewhere in the program and make an entry in this table with the
145 // getters and setters.
146 // It is easiest to find an existing definition and copy it.
147 // Parameter values are floats. Booleans are converted to a floating value.
148 //
149 // A ParameterDefn() takes the following parameters:
150 // -- the text name of the parameter. This is used for console input and ini file.
151 // -- a short text description of the parameter. This shows up in the console listing.
152 // -- a default value (float)
153 // -- a delegate for fetching the parameter from the ini file.
154 // Should handle fetching the right type from the ini file and converting it.
155 // -- a delegate for getting the value as a float
156 // -- a delegate for setting the value from a float
157 // -- an optional delegate to update the value in the world. Most often used to
158 // push the new value to an in-world object.
159 //
160 // The single letter parameters for the delegates are:
161 // s = BSScene
162 // o = BSPhysObject
163 // p = string parameter name
164 // l = localID of referenced object
165 // v = value (float)
166 // cf = parameter configuration class (for fetching values from ini file)
167 private static ParameterDefn[] ParameterDefinitions =
168 {
169 new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties",
170 ConfigurationParameters.numericTrue,
171 (s,cf,p,v) => { ShouldMeshSculptedPrim = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
172 (s) => { return BSParam.NumericBool(ShouldMeshSculptedPrim); },
173 (s,p,l,v) => { ShouldMeshSculptedPrim = BSParam.BoolNumeric(v); } ),
174 new ParameterDefn("ForceSimplePrimMeshing", "If true, only use primitive meshes for objects",
175 ConfigurationParameters.numericFalse,
176 (s,cf,p,v) => { ShouldForceSimplePrimMeshing = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
177 (s) => { return BSParam.NumericBool(ShouldForceSimplePrimMeshing); },
178 (s,p,l,v) => { ShouldForceSimplePrimMeshing = BSParam.BoolNumeric(v); } ),
179 new ParameterDefn("UseHullsForPhysicalObjects", "If true, create hulls for physical objects",
180 ConfigurationParameters.numericTrue,
181 (s,cf,p,v) => { ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
182 (s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); },
183 (s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ),
184
185 new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
186 8f,
187 (s,cf,p,v) => { MeshLOD = (float)cf.GetInt(p, (int)v); },
188 (s) => { return MeshLOD; },
189 (s,p,l,v) => { MeshLOD = v; } ),
190 new ParameterDefn("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters",
191 16f,
192 (s,cf,p,v) => { MeshMegaPrimLOD = (float)cf.GetInt(p, (int)v); },
193 (s) => { return MeshMegaPrimLOD; },
194 (s,p,l,v) => { MeshMegaPrimLOD = v; } ),
195 new ParameterDefn("MeshLevelOfDetailMegaPrimThreshold", "Size (in meters) of a mesh before using MeshMegaPrimLOD",
196 10f,
197 (s,cf,p,v) => { MeshMegaPrimThreshold = (float)cf.GetInt(p, (int)v); },
198 (s) => { return MeshMegaPrimThreshold; },
199 (s,p,l,v) => { MeshMegaPrimThreshold = v; } ),
200 new ParameterDefn("SculptLevelOfDetail", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
201 32f,
202 (s,cf,p,v) => { SculptLOD = (float)cf.GetInt(p, (int)v); },
203 (s) => { return SculptLOD; },
204 (s,p,l,v) => { SculptLOD = v; } ),
205
206 new ParameterDefn("MaxSubStep", "In simulation step, maximum number of substeps",
207 10f,
208 (s,cf,p,v) => { s.m_maxSubSteps = cf.GetInt(p, (int)v); },
209 (s) => { return (float)s.m_maxSubSteps; },
210 (s,p,l,v) => { s.m_maxSubSteps = (int)v; } ),
211 new ParameterDefn("FixedTimeStep", "In simulation step, seconds of one substep (1/60)",
212 1f / 60f,
213 (s,cf,p,v) => { s.m_fixedTimeStep = cf.GetFloat(p, v); },
214 (s) => { return (float)s.m_fixedTimeStep; },
215 (s,p,l,v) => { s.m_fixedTimeStep = v; } ),
216 new ParameterDefn("NominalFrameRate", "The base frame rate we claim",
217 55f,
218 (s,cf,p,v) => { s.NominalFrameRate = cf.GetInt(p, (int)v); },
219 (s) => { return (float)s.NominalFrameRate; },
220 (s,p,l,v) => { s.NominalFrameRate = (int)v; } ),
221 new ParameterDefn("MaxCollisionsPerFrame", "Max collisions returned at end of each frame",
222 2048f,
223 (s,cf,p,v) => { s.m_maxCollisionsPerFrame = cf.GetInt(p, (int)v); },
224 (s) => { return (float)s.m_maxCollisionsPerFrame; },
225 (s,p,l,v) => { s.m_maxCollisionsPerFrame = (int)v; } ),
226 new ParameterDefn("MaxUpdatesPerFrame", "Max updates returned at end of each frame",
227 8000f,
228 (s,cf,p,v) => { s.m_maxUpdatesPerFrame = cf.GetInt(p, (int)v); },
229 (s) => { return (float)s.m_maxUpdatesPerFrame; },
230 (s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ),
231 new ParameterDefn("MaxTaintsToProcessPerStep", "Number of update taints to process before each simulation step",
232 500f,
233 (s,cf,p,v) => { s.m_taintsToProcessPerStep = cf.GetInt(p, (int)v); },
234 (s) => { return (float)s.m_taintsToProcessPerStep; },
235 (s,p,l,v) => { s.m_taintsToProcessPerStep = (int)v; } ),
236 new ParameterDefn("MinObjectMass", "Minimum object mass (0.0001)",
237 0.0001f,
238 (s,cf,p,v) => { MinimumObjectMass = cf.GetFloat(p, v); },
239 (s) => { return (float)MinimumObjectMass; },
240 (s,p,l,v) => { MinimumObjectMass = v; } ),
241 new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)",
242 10000.01f,
243 (s,cf,p,v) => { MaximumObjectMass = cf.GetFloat(p, v); },
244 (s) => { return (float)MaximumObjectMass; },
245 (s,p,l,v) => { MaximumObjectMass = v; } ),
246
247 new ParameterDefn("PID_D", "Derivitive factor for motion smoothing",
248 2200f,
249 (s,cf,p,v) => { PID_D = cf.GetFloat(p, v); },
250 (s) => { return (float)PID_D; },
251 (s,p,l,v) => { PID_D = v; } ),
252 new ParameterDefn("PID_P", "Parameteric factor for motion smoothing",
253 900f,
254 (s,cf,p,v) => { PID_P = cf.GetFloat(p, v); },
255 (s) => { return (float)PID_P; },
256 (s,p,l,v) => { PID_P = v; } ),
257
258 new ParameterDefn("DefaultFriction", "Friction factor used on new objects",
259 0.2f,
260 (s,cf,p,v) => { s.UnmanagedParams[0].defaultFriction = cf.GetFloat(p, v); },
261 (s) => { return s.UnmanagedParams[0].defaultFriction; },
262 (s,p,l,v) => { s.UnmanagedParams[0].defaultFriction = v; } ),
263 new ParameterDefn("DefaultDensity", "Density for new objects" ,
264 10.000006836f, // Aluminum g/cm3
265 (s,cf,p,v) => { s.UnmanagedParams[0].defaultDensity = cf.GetFloat(p, v); },
266 (s) => { return s.UnmanagedParams[0].defaultDensity; },
267 (s,p,l,v) => { s.UnmanagedParams[0].defaultDensity = v; } ),
268 new ParameterDefn("DefaultRestitution", "Bouncyness of an object" ,
269 0f,
270 (s,cf,p,v) => { s.UnmanagedParams[0].defaultRestitution = cf.GetFloat(p, v); },
271 (s) => { return s.UnmanagedParams[0].defaultRestitution; },
272 (s,p,l,v) => { s.UnmanagedParams[0].defaultRestitution = v; } ),
273 new ParameterDefn("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!)",
274 0.04f,
275 (s,cf,p,v) => { s.UnmanagedParams[0].collisionMargin = cf.GetFloat(p, v); },
276 (s) => { return s.UnmanagedParams[0].collisionMargin; },
277 (s,p,l,v) => { s.UnmanagedParams[0].collisionMargin = v; } ),
278 new ParameterDefn("Gravity", "Vertical force of gravity (negative means down)",
279 -9.80665f,
280 (s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); },
281 (s) => { return s.UnmanagedParams[0].gravity; },
282 (s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); },
283 (s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ),
284
285
286 new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)",
287 0f,
288 (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); },
289 (s) => { return LinearDamping; },
290 (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); },
291 (s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ),
292 new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)",
293 0f,
294 (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); },
295 (s) => { return AngularDamping; },
296 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); },
297 (s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ),
298 new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static",
299 0.2f,
300 (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); },
301 (s) => { return DeactivationTime; },
302 (s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); },
303 (s,o,v) => { s.PE.SetDeactivationTime(o.PhysBody, v); } ),
304 new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static",
305 0.8f,
306 (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); },
307 (s) => { return LinearSleepingThreshold; },
308 (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); },
309 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
310 new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static",
311 1.0f,
312 (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); },
313 (s) => { return AngularSleepingThreshold; },
314 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); },
315 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
316 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
317 0f, // set to zero to disable
318 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
319 (s) => { return CcdMotionThreshold; },
320 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); },
321 (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ),
322 new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
323 0f,
324 (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); },
325 (s) => { return CcdSweptSphereRadius; },
326 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); },
327 (s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ),
328 new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" ,
329 0.1f,
330 (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); },
331 (s) => { return ContactProcessingThreshold; },
332 (s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); },
333 (s,o,v) => { s.PE.SetContactProcessingThreshold(o.PhysBody, v); } ),
334
335 new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
336 (float)BSTerrainPhys.TerrainImplementation.Mesh,
337 (s,cf,p,v) => { TerrainImplementation = cf.GetFloat(p,v); },
338 (s) => { return TerrainImplementation; },
339 (s,p,l,v) => { TerrainImplementation = v; } ),
340 new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" ,
341 0.3f,
342 (s,cf,p,v) => { TerrainFriction = cf.GetFloat(p, v); },
343 (s) => { return TerrainFriction; },
344 (s,p,l,v) => { TerrainFriction = v; /* TODO: set on real terrain */} ),
345 new ParameterDefn("TerrainHitFraction", "Distance to measure hit collisions" ,
346 0.8f,
347 (s,cf,p,v) => { TerrainHitFraction = cf.GetFloat(p, v); },
348 (s) => { return TerrainHitFraction; },
349 (s,p,l,v) => { TerrainHitFraction = v; /* TODO: set on real terrain */ } ),
350 new ParameterDefn("TerrainRestitution", "Bouncyness" ,
351 0f,
352 (s,cf,p,v) => { TerrainRestitution = cf.GetFloat(p, v); },
353 (s) => { return TerrainRestitution; },
354 (s,p,l,v) => { TerrainRestitution = v; /* TODO: set on real terrain */ } ),
355 new ParameterDefn("TerrainCollisionMargin", "Margin where collision checking starts" ,
356 0.04f,
357 (s,cf,p,v) => { TerrainCollisionMargin = cf.GetFloat(p, v); },
358 (s) => { return TerrainCollisionMargin; },
359 (s,p,l,v) => { TerrainCollisionMargin = v; /* TODO: set on real terrain */ } ),
360
361 new ParameterDefn("AvatarFriction", "Factor to reduce movement against an avatar. Changed on avatar recreation.",
362 0.2f,
363 (s,cf,p,v) => { AvatarFriction = cf.GetFloat(p, v); },
364 (s) => { return AvatarFriction; },
365 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarFriction=x;}, p, l, v); } ),
366 new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.",
367 10.0f,
368 (s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
369 (s) => { return AvatarStandingFriction; },
370 (s,p,l,v) => { AvatarStandingFriction = v; } ),
371 new ParameterDefn("AvatarAlwaysRunFactor", "Speed multiplier if avatar is set to always run",
372 1.3f,
373 (s,cf,p,v) => { AvatarAlwaysRunFactor = cf.GetFloat(p, v); },
374 (s) => { return AvatarAlwaysRunFactor; },
375 (s,p,l,v) => { AvatarAlwaysRunFactor = v; } ),
376 new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.",
377 3.5f,
378 (s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); },
379 (s) => { return AvatarDensity; },
380 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarDensity=x;}, p, l, v); } ),
381 new ParameterDefn("AvatarRestitution", "Bouncyness. Changed on avatar recreation.",
382 0f,
383 (s,cf,p,v) => { AvatarRestitution = cf.GetFloat(p, v); },
384 (s) => { return AvatarRestitution; },
385 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarRestitution=x;}, p, l, v); } ),
386 new ParameterDefn("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule",
387 0.6f,
388 (s,cf,p,v) => { AvatarCapsuleWidth = cf.GetFloat(p, v); },
389 (s) => { return AvatarCapsuleWidth; },
390 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleWidth=x;}, p, l, v); } ),
391 new ParameterDefn("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule",
392 0.45f,
393 (s,cf,p,v) => { AvatarCapsuleDepth = cf.GetFloat(p, v); },
394 (s) => { return AvatarCapsuleDepth; },
395 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleDepth=x;}, p, l, v); } ),
396 new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar",
397 1.5f,
398 (s,cf,p,v) => { AvatarCapsuleHeight = cf.GetFloat(p, v); },
399 (s) => { return AvatarCapsuleHeight; },
400 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleHeight=x;}, p, l, v); } ),
401 new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
402 0.1f,
403 (s,cf,p,v) => { AvatarContactProcessingThreshold = cf.GetFloat(p, v); },
404 (s) => { return AvatarContactProcessingThreshold; },
405 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarContactProcessingThreshold=x;}, p, l, v); } ),
406
407 new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
408 0.95f,
409 (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); },
410 (s) => { return VehicleAngularDamping; },
411 (s,p,l,v) => { VehicleAngularDamping = v; } ),
412
413 new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
414 0f,
415 (s,cf,p,v) => { s.UnmanagedParams[0].maxPersistantManifoldPoolSize = cf.GetFloat(p, v); },
416 (s) => { return s.UnmanagedParams[0].maxPersistantManifoldPoolSize; },
417 (s,p,l,v) => { s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ),
418 new ParameterDefn("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)",
419 0f,
420 (s,cf,p,v) => { s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); },
421 (s) => { return s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize; },
422 (s,p,l,v) => { s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ),
423 new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count",
424 ConfigurationParameters.numericFalse,
425 (s,cf,p,v) => { s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
426 (s) => { return s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation; },
427 (s,p,l,v) => { s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = v; } ),
428 new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step",
429 ConfigurationParameters.numericFalse,
430 (s,cf,p,v) => { s.UnmanagedParams[0].shouldForceUpdateAllAabbs = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
431 (s) => { return s.UnmanagedParams[0].shouldForceUpdateAllAabbs; },
432 (s,p,l,v) => { s.UnmanagedParams[0].shouldForceUpdateAllAabbs = v; } ),
433 new ParameterDefn("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction",
434 ConfigurationParameters.numericTrue,
435 (s,cf,p,v) => { s.UnmanagedParams[0].shouldRandomizeSolverOrder = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
436 (s) => { return s.UnmanagedParams[0].shouldRandomizeSolverOrder; },
437 (s,p,l,v) => { s.UnmanagedParams[0].shouldRandomizeSolverOrder = v; } ),
438 new ParameterDefn("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands",
439 ConfigurationParameters.numericTrue,
440 (s,cf,p,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
441 (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; },
442 (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ),
443 new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching",
444 ConfigurationParameters.numericFalse,
445 (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
446 (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; },
447 (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ),
448 new ParameterDefn("NumberOfSolverIterations", "Number of internal iterations (0 means default)",
449 0f, // zero says use Bullet default
450 (s,cf,p,v) => { s.UnmanagedParams[0].numberOfSolverIterations = cf.GetFloat(p, v); },
451 (s) => { return s.UnmanagedParams[0].numberOfSolverIterations; },
452 (s,p,l,v) => { s.UnmanagedParams[0].numberOfSolverIterations = v; } ),
453
454 new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)",
455 (float)BSLinkset.LinksetImplementation.Compound,
456 (s,cf,p,v) => { LinksetImplementation = cf.GetFloat(p,v); },
457 (s) => { return LinksetImplementation; },
458 (s,p,l,v) => { LinksetImplementation = v; } ),
459 new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.",
460 ConfigurationParameters.numericFalse,
461 (s,cf,p,v) => { LinkConstraintUseFrameOffset = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
462 (s) => { return LinkConstraintUseFrameOffset; },
463 (s,p,l,v) => { LinkConstraintUseFrameOffset = v; } ),
464 new ParameterDefn("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints",
465 ConfigurationParameters.numericTrue,
466 (s,cf,p,v) => { LinkConstraintEnableTransMotor = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
467 (s) => { return LinkConstraintEnableTransMotor; },
468 (s,p,l,v) => { LinkConstraintEnableTransMotor = v; } ),
469 new ParameterDefn("LinkConstraintTransMotorMaxVel", "Maximum velocity to be applied by translational motor in linkset constraints",
470 5.0f,
471 (s,cf,p,v) => { LinkConstraintTransMotorMaxVel = cf.GetFloat(p, v); },
472 (s) => { return LinkConstraintTransMotorMaxVel; },
473 (s,p,l,v) => { LinkConstraintTransMotorMaxVel = v; } ),
474 new ParameterDefn("LinkConstraintTransMotorMaxForce", "Maximum force to be applied by translational motor in linkset constraints",
475 0.1f,
476 (s,cf,p,v) => { LinkConstraintTransMotorMaxForce = cf.GetFloat(p, v); },
477 (s) => { return LinkConstraintTransMotorMaxForce; },
478 (s,p,l,v) => { LinkConstraintTransMotorMaxForce = v; } ),
479 new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=no violation, 1=infinite. Default=0.1",
480 0.1f,
481 (s,cf,p,v) => { LinkConstraintCFM = cf.GetFloat(p, v); },
482 (s) => { return LinkConstraintCFM; },
483 (s,p,l,v) => { LinkConstraintCFM = v; } ),
484 new ParameterDefn("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2",
485 0.1f,
486 (s,cf,p,v) => { LinkConstraintERP = cf.GetFloat(p, v); },
487 (s) => { return LinkConstraintERP; },
488 (s,p,l,v) => { LinkConstraintERP = v; } ),
489 new ParameterDefn("LinkConstraintSolverIterations", "Number of solver iterations when computing constraint. (0 = Bullet default)",
490 40,
491 (s,cf,p,v) => { LinkConstraintSolverIterations = cf.GetFloat(p, v); },
492 (s) => { return LinkConstraintSolverIterations; },
493 (s,p,l,v) => { LinkConstraintSolverIterations = v; } ),
494
495 new ParameterDefn("PhysicsMetricFrames", "Frames between outputting detailed phys metrics. (0 is off)",
496 0f,
497 (s,cf,p,v) => { s.PhysicsMetricDumpFrames = cf.GetFloat(p, (int)v); },
498 (s) => { return (float)s.PhysicsMetricDumpFrames; },
499 (s,p,l,v) => { s.PhysicsMetricDumpFrames = (int)v; } ),
500 };
501
502 // Convert a boolean to our numeric true and false values
503 public static float NumericBool(bool b)
504 {
505 return (b ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse);
506 }
507
508 // Convert numeric true and false values to a boolean
509 public static bool BoolNumeric(float b)
510 {
511 return (b == ConfigurationParameters.numericTrue ? true : false);
512 }
513
514 // Search through the parameter definitions and return the matching
515 // ParameterDefn structure.
516 // Case does not matter as names are compared after converting to lower case.
517 // Returns 'false' if the parameter is not found.
518 internal static bool TryGetParameter(string paramName, out ParameterDefn defn)
519 {
520 bool ret = false;
521 ParameterDefn foundDefn = new ParameterDefn();
522 string pName = paramName.ToLower();
523
524 foreach (ParameterDefn parm in ParameterDefinitions)
525 {
526 if (pName == parm.name.ToLower())
527 {
528 foundDefn = parm;
529 ret = true;
530 break;
531 }
532 }
533 defn = foundDefn;
534 return ret;
535 }
536
537 // Pass through the settable parameters and set the default values
538 internal static void SetParameterDefaultValues(BSScene physicsScene)
539 {
540 foreach (ParameterDefn parm in ParameterDefinitions)
541 {
542 parm.setter(physicsScene, parm.name, PhysParameterEntry.APPLY_TO_NONE, parm.defaultValue);
543 }
544 }
545
546 // Get user set values out of the ini file.
547 internal static void SetParameterConfigurationValues(BSScene physicsScene, IConfig cfg)
548 {
549 foreach (ParameterDefn parm in ParameterDefinitions)
550 {
551 parm.userParam(physicsScene, cfg, parm.name, parm.defaultValue);
552 }
553 }
554
555 internal static PhysParameterEntry[] SettableParameters = new PhysParameterEntry[1];
556
557 // This creates an array in the correct format for returning the list of
558 // parameters. This is used by the 'list' option of the 'physics' command.
559 internal static void BuildParameterTable()
560 {
561 if (SettableParameters.Length < ParameterDefinitions.Length)
562 {
563 List<PhysParameterEntry> entries = new List<PhysParameterEntry>();
564 for (int ii = 0; ii < ParameterDefinitions.Length; ii++)
565 {
566 ParameterDefn pd = ParameterDefinitions[ii];
567 entries.Add(new PhysParameterEntry(pd.name, pd.desc));
568 }
569
570 // make the list in alphabetical order for estetic reasons
571 entries.Sort(delegate(PhysParameterEntry ppe1, PhysParameterEntry ppe2)
572 {
573 return ppe1.name.CompareTo(ppe2.name);
574 });
575
576 SettableParameters = entries.ToArray();
577 }
578 }
579
580
581}
582}