diff options
author | Robert Adams | 2011-07-22 15:23:57 -0700 |
---|---|---|
committer | Mic Bowman | 2011-07-22 15:23:57 -0700 |
commit | 869883f2dc51f2b2210ccf8fd41f3de0c07e39fc (patch) | |
tree | 9da95f3b54517e3025ca7f248ccb8103bbee9bb0 | |
parent | Merge branch 'bulletsim' of ssh://opensimulator.org/var/git/opensim into bull... (diff) | |
download | opensim-SC_OLD-869883f2dc51f2b2210ccf8fd41f3de0c07e39fc.zip opensim-SC_OLD-869883f2dc51f2b2210ccf8fd41f3de0c07e39fc.tar.gz opensim-SC_OLD-869883f2dc51f2b2210ccf8fd41f3de0c07e39fc.tar.bz2 opensim-SC_OLD-869883f2dc51f2b2210ccf8fd41f3de0c07e39fc.tar.xz |
BulletSim: fix buoyancy for prims. Start of configurable physics parameters.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 97 | ||||
-rwxr-xr-x | bin/BulletSim-x86_64.dll | bin | 754176 -> 754688 bytes | |||
-rwxr-xr-x | bin/BulletSim.dll | bin | 654336 -> 654336 bytes | |||
-rwxr-xr-x | bin/libBulletSim.so | bin | 1734582 -> 1734638 bytes |
5 files changed, 92 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index dbd7285..82361ad 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -107,7 +107,7 @@ public class BSCharacter : PhysicsActor | |||
107 | shapeData.Velocity = _velocity; | 107 | shapeData.Velocity = _velocity; |
108 | shapeData.Scale = _scale; | 108 | shapeData.Scale = _scale; |
109 | shapeData.Mass = _mass; | 109 | shapeData.Mass = _mass; |
110 | shapeData.Buoyancy = isFlying ? 0f : 1f; | 110 | shapeData.Buoyancy = isFlying ? 1f : 0f; |
111 | shapeData.Static = ShapeData.numericFalse; | 111 | shapeData.Static = ShapeData.numericFalse; |
112 | 112 | ||
113 | // do actual create at taint time | 113 | // do actual create at taint time |
@@ -258,7 +258,7 @@ public class BSCharacter : PhysicsActor | |||
258 | _scene.TaintedObject(delegate() | 258 | _scene.TaintedObject(delegate() |
259 | { | 259 | { |
260 | // simulate flying by changing the effect of gravity | 260 | // simulate flying by changing the effect of gravity |
261 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 0f : 1f); | 261 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 1f : 0f); |
262 | }); | 262 | }); |
263 | } | 263 | } |
264 | } | 264 | } |
@@ -296,7 +296,13 @@ public class BSCharacter : PhysicsActor | |||
296 | } | 296 | } |
297 | public override float Buoyancy { | 297 | public override float Buoyancy { |
298 | get { return _buoyancy; } | 298 | get { return _buoyancy; } |
299 | set { _buoyancy = value; } | 299 | set { _buoyancy = value; |
300 | _scene.TaintedObject(delegate() | ||
301 | { | ||
302 | // simulate flying by changing the effect of gravity | ||
303 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); | ||
304 | }); | ||
305 | } | ||
300 | } | 306 | } |
301 | 307 | ||
302 | // Used for MoveTo | 308 | // Used for MoveTo |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 062945f..7c11f2b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -37,7 +37,6 @@ using OpenMetaverse; | |||
37 | using OpenSim.Region.Framework; | 37 | using OpenSim.Region.Framework; |
38 | 38 | ||
39 | // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) | 39 | // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) |
40 | // Fix folding up feet | ||
41 | // Parameterize BulletSim. Pass a structure of parameters to the C++ code. Capsule size, friction, ... | 40 | // Parameterize BulletSim. Pass a structure of parameters to the C++ code. Capsule size, friction, ... |
42 | // Adjust character capsule size when height is adjusted (ScenePresence.SetHeight) | 41 | // Adjust character capsule size when height is adjusted (ScenePresence.SetHeight) |
43 | // Test sculpties | 42 | // Test sculpties |
@@ -108,6 +107,31 @@ public class BSScene : PhysicsScene | |||
108 | private List<TaintCallback> _taintedObjects; | 107 | private List<TaintCallback> _taintedObjects; |
109 | private Object _taintLock = new Object(); | 108 | private Object _taintLock = new Object(); |
110 | 109 | ||
110 | // A pointer to an instance if this structure is passed to the C++ code | ||
111 | // Format of this structure must match the definition in the C++ code | ||
112 | private struct ConfigurationParameters | ||
113 | { | ||
114 | public float defaultFriction; | ||
115 | public float defaultDensity; | ||
116 | public float collisionMargin; | ||
117 | public float gravity; | ||
118 | |||
119 | public float linearDamping; | ||
120 | public float angularDamping; | ||
121 | public float deactivationTime; | ||
122 | public float linearSleepingThreshold; | ||
123 | public float angularSleepingThreshold; | ||
124 | |||
125 | public float terrainFriction; | ||
126 | public float terrainHitFriction; | ||
127 | public float terrainRestitution; | ||
128 | public float avatarFriction; | ||
129 | public float avatarCapsuleRadius; | ||
130 | public float avatarCapsuleHeight; | ||
131 | } | ||
132 | ConfigurationParameters m_params; | ||
133 | GCHandle m_paramsHandle; | ||
134 | |||
111 | private BulletSimAPI.DebugLogCallback debugLogCallbackHandle; | 135 | private BulletSimAPI.DebugLogCallback debugLogCallbackHandle; |
112 | 136 | ||
113 | public BSScene(string identifier) | 137 | public BSScene(string identifier) |
@@ -116,16 +140,12 @@ public class BSScene : PhysicsScene | |||
116 | 140 | ||
117 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 141 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
118 | { | 142 | { |
119 | if (config != null) | 143 | m_params = new ConfigurationParameters(); |
120 | { | 144 | m_paramsHandle = GCHandle.Alloc(m_params, GCHandleType.Pinned); |
121 | IConfig pConfig = config.Configs["BulletSim"]; | 145 | |
122 | if (pConfig != null) | 146 | // Set default values for physics parameters plus any overrides from the ini file |
123 | { | 147 | GetInitialParameterValues(config); |
124 | DefaultFriction = pConfig.GetFloat("Friction", DefaultFriction); | 148 | |
125 | DefaultDensity = pConfig.GetFloat("Density", DefaultDensity); | ||
126 | // TODO: a lot more parameters that are passed to BulletSim | ||
127 | } | ||
128 | } | ||
129 | // if Debug, enable logging from the unmanaged code | 149 | // if Debug, enable logging from the unmanaged code |
130 | if (m_log.IsDebugEnabled) | 150 | if (m_log.IsDebugEnabled) |
131 | { | 151 | { |
@@ -134,9 +154,6 @@ public class BSScene : PhysicsScene | |||
134 | BulletSimAPI.SetDebugLogCallback(debugLogCallbackHandle); | 154 | BulletSimAPI.SetDebugLogCallback(debugLogCallbackHandle); |
135 | } | 155 | } |
136 | 156 | ||
137 | _meshSculptedPrim = true; // mesh sculpted prims | ||
138 | _forceSimplePrimMeshing = false; // use complex meshing if called for | ||
139 | |||
140 | _taintedObjects = new List<TaintCallback>(); | 157 | _taintedObjects = new List<TaintCallback>(); |
141 | 158 | ||
142 | mesher = meshmerizer; | 159 | mesher = meshmerizer; |
@@ -155,6 +172,58 @@ public class BSScene : PhysicsScene | |||
155 | m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject()); | 172 | m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject()); |
156 | } | 173 | } |
157 | 174 | ||
175 | private void GetInitialParameterValues(IConfigSource config) | ||
176 | { | ||
177 | _meshSculptedPrim = true; // mesh sculpted prims | ||
178 | _forceSimplePrimMeshing = false; // use complex meshing if called for | ||
179 | |||
180 | // Set the default values for the physics parameters | ||
181 | m_params.defaultFriction = 0.70f; | ||
182 | m_params.defaultDensity = 10.000006836f; // Aluminum g/cm3 | ||
183 | m_params.collisionMargin = 0.0f; | ||
184 | m_params.gravity = -9.80665f; | ||
185 | |||
186 | m_params.linearDamping = 0.1f; | ||
187 | m_params.angularDamping = 0.85f; | ||
188 | m_params.deactivationTime = 0.2f; | ||
189 | m_params.linearSleepingThreshold = 0.8f; | ||
190 | m_params.angularSleepingThreshold = 1.0f; | ||
191 | |||
192 | m_params.terrainFriction = 0.85f; | ||
193 | m_params.terrainHitFriction = 0.8f; | ||
194 | m_params.terrainRestitution = 0.2f; | ||
195 | m_params.avatarFriction = 0.85f; | ||
196 | m_params.avatarCapsuleRadius = 0.37f; | ||
197 | m_params.avatarCapsuleHeight = 1.5f; // 2.140599f | ||
198 | |||
199 | if (config != null) | ||
200 | { | ||
201 | // If there are specifications in the ini file, use those values | ||
202 | IConfig pConfig = config.Configs["BulletSim"]; | ||
203 | if (pConfig != null) | ||
204 | { | ||
205 | _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", true); | ||
206 | _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", false); | ||
207 | |||
208 | m_params.defaultFriction = pConfig.GetFloat("DefaultFriction", m_params.defaultFriction); | ||
209 | m_params.defaultDensity = pConfig.GetFloat("DefaultDensity", m_params.defaultDensity); | ||
210 | m_params.collisionMargin = pConfig.GetFloat("CollisionMargin", m_params.collisionMargin); | ||
211 | m_params.gravity = pConfig.GetFloat("Gravity", m_params.gravity); | ||
212 | m_params.linearDamping = pConfig.GetFloat("LinearDamping", m_params.linearDamping); | ||
213 | m_params.angularDamping = pConfig.GetFloat("AngularDamping", m_params.angularDamping); | ||
214 | m_params.deactivationTime = pConfig.GetFloat("DeactivationTime", m_params.deactivationTime); | ||
215 | m_params.linearSleepingThreshold = pConfig.GetFloat("LinearSleepingThreshold", m_params.linearSleepingThreshold); | ||
216 | m_params.angularSleepingThreshold = pConfig.GetFloat("AngularSleepingThreshold", m_params.angularSleepingThreshold); | ||
217 | m_params.terrainFriction = pConfig.GetFloat("TerrainFriction", m_params.terrainFriction); | ||
218 | m_params.terrainHitFriction = pConfig.GetFloat("TerrainHitFriction", m_params.terrainHitFriction); | ||
219 | m_params.terrainRestitution = pConfig.GetFloat("TerrainRestitution", m_params.terrainRestitution); | ||
220 | m_params.avatarFriction = pConfig.GetFloat("AvatarFriction", m_params.avatarFriction); | ||
221 | m_params.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", m_params.avatarCapsuleRadius); | ||
222 | m_params.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", m_params.avatarCapsuleHeight); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
158 | // Called directly from unmanaged code so don't do much | 227 | // Called directly from unmanaged code so don't do much |
159 | private void BulletLogger(string msg) | 228 | private void BulletLogger(string msg) |
160 | { | 229 | { |
diff --git a/bin/BulletSim-x86_64.dll b/bin/BulletSim-x86_64.dll index 6370984..6e1b9f0 100755 --- a/bin/BulletSim-x86_64.dll +++ b/bin/BulletSim-x86_64.dll | |||
Binary files differ | |||
diff --git a/bin/BulletSim.dll b/bin/BulletSim.dll index 2918130..c9f9637 100755 --- a/bin/BulletSim.dll +++ b/bin/BulletSim.dll | |||
Binary files differ | |||
diff --git a/bin/libBulletSim.so b/bin/libBulletSim.so index 56c4103..8da2c9f 100755 --- a/bin/libBulletSim.so +++ b/bin/libBulletSim.so | |||
Binary files differ | |||