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