diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 184 |
3 files changed, 133 insertions, 61 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 17e041d..606b13e 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -780,7 +780,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
780 | } | 780 | } |
781 | if (flying) | 781 | if (flying) |
782 | { | 782 | { |
783 | vec.Z += (9.8f*m_mass); | 783 | vec.Z += ((-1 * _parent_scene.gravityz)*m_mass); |
784 | } | 784 | } |
785 | 785 | ||
786 | 786 | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index d1f1074..37a8b77 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -1155,14 +1155,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1155 | 1155 | ||
1156 | if (m_buoyancy > 0) | 1156 | if (m_buoyancy > 0) |
1157 | { | 1157 | { |
1158 | fz = ((9.8f * m_buoyancy) * m_mass); | 1158 | fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass); |
1159 | 1159 | ||
1160 | //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); | 1160 | //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); |
1161 | //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (9.8f * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); | 1161 | //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); |
1162 | } | 1162 | } |
1163 | else | 1163 | else |
1164 | { | 1164 | { |
1165 | fz = (-1 * ((9.8f * (-1 * m_buoyancy)) * m_mass)); | 1165 | fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass)); |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | 1168 | ||
@@ -1171,7 +1171,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1171 | if (m_usePID) | 1171 | if (m_usePID) |
1172 | { | 1172 | { |
1173 | // If we're using the PID controller, then we have no gravity | 1173 | // If we're using the PID controller, then we have no gravity |
1174 | fz = 9.8f * this.Mass; | 1174 | fz = (-1 * _parent_scene.gravityz) * this.Mass; |
1175 | 1175 | ||
1176 | // no lock; for now it's only called from within Simulate() | 1176 | // no lock; for now it's only called from within Simulate() |
1177 | 1177 | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 0dc865d..873abc7 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -127,8 +127,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
127 | private const uint m_regionWidth = Constants.RegionSize; | 127 | private const uint m_regionWidth = Constants.RegionSize; |
128 | private const uint m_regionHeight = Constants.RegionSize; | 128 | private const uint m_regionHeight = Constants.RegionSize; |
129 | 129 | ||
130 | private static float ODE_STEPSIZE = 0.020f; | 130 | private float ODE_STEPSIZE = 0.020f; |
131 | private static float metersInSpace = 29.9f; | 131 | private float metersInSpace = 29.9f; |
132 | |||
133 | public float gravityx = 0f; | ||
134 | public float gravityy = 0f; | ||
135 | public float gravityz = -9.8f; | ||
136 | |||
137 | private float contactsurfacelayer = 0.001f; | ||
138 | |||
139 | private int worldHashspaceLow = -4; | ||
140 | private int worldHashspaceHigh = 128; | ||
141 | |||
142 | private int smallHashspaceLow = -4; | ||
143 | private int smallHashspaceHigh = 66; | ||
132 | 144 | ||
133 | private float waterlevel = 0f; | 145 | private float waterlevel = 0f; |
134 | private int framecount = 0; | 146 | private int framecount = 0; |
@@ -139,6 +151,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
139 | 151 | ||
140 | private IntPtr WaterGeom = (IntPtr)0; | 152 | private IntPtr WaterGeom = (IntPtr)0; |
141 | 153 | ||
154 | private float nmTerrainContactFriction = 255.0f; | ||
155 | private float nmTerrainContactBounce = 0.1f; | ||
156 | private float nmTerrainContactERP = 0.1025f; | ||
157 | |||
158 | private float mTerrainContactFriction = 75f; | ||
159 | private float mTerrainContactBounce = 0.1f; | ||
160 | private float mTerrainContactERP = 0.05025f; | ||
161 | |||
162 | private float nmAvatarObjectContactFriction = 250f; | ||
163 | private float nmAvatarObjectContactBounce = 0.1f; | ||
164 | |||
165 | private float mAvatarObjectContactFriction = 75f; | ||
166 | private float mAvatarObjectContactBounce = 0.1f; | ||
167 | |||
168 | |||
142 | private float[] _heightmap; | 169 | private float[] _heightmap; |
143 | 170 | ||
144 | private float[] _watermap; | 171 | private float[] _watermap; |
@@ -188,7 +215,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
188 | 215 | ||
189 | //private IntPtr tmpSpace; | 216 | //private IntPtr tmpSpace; |
190 | // split static geometry collision handling into spaces of 30 meters | 217 | // split static geometry collision handling into spaces of 30 meters |
191 | public IntPtr[,] staticPrimspace = new IntPtr[(int) (300/metersInSpace),(int) (300/metersInSpace)]; | 218 | public IntPtr[,] staticPrimspace; |
192 | 219 | ||
193 | public static Object OdeLock = new Object(); | 220 | public static Object OdeLock = new Object(); |
194 | 221 | ||
@@ -208,25 +235,94 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
208 | nearCallback = near; | 235 | nearCallback = near; |
209 | triCallback = TriCallback; | 236 | triCallback = TriCallback; |
210 | triArrayCallback = TriArrayCallback; | 237 | triArrayCallback = TriArrayCallback; |
211 | /* | 238 | |
212 | contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP; | 239 | |
213 | contact.surface.mu = 10.0f; | 240 | |
214 | contact.surface.bounce = 0.9f; | 241 | |
215 | contact.surface.soft_erp = 0.005f; | 242 | lock (OdeLock) |
216 | contact.surface.soft_cfm = 0.00003f; | 243 | { |
217 | */ | 244 | |
245 | // Creat the world and the first space | ||
246 | world = d.WorldCreate(); | ||
247 | space = d.HashSpaceCreate(IntPtr.Zero); | ||
248 | |||
249 | contactgroup = d.JointGroupCreate(0); | ||
250 | //contactgroup | ||
251 | |||
252 | |||
253 | |||
254 | |||
255 | d.WorldSetAutoDisableFlag(world, false); | ||
256 | |||
257 | } | ||
258 | |||
259 | // zero out a heightmap array float array (single dimention [flattened])) | ||
260 | _heightmap = new float[514*514]; | ||
261 | _watermap = new float[258 * 258]; | ||
262 | |||
263 | // Zero out the prim spaces array (we split our space into smaller spaces so | ||
264 | // we can hit test less. | ||
265 | |||
266 | } | ||
267 | |||
268 | |||
269 | // Initialize the mesh plugin | ||
270 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
271 | { | ||
272 | mesher = meshmerizer; | ||
273 | m_config = config; | ||
274 | if (m_config != null) | ||
275 | { | ||
276 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; | ||
277 | if (physicsconfig != null) | ||
278 | { | ||
279 | gravityx = physicsconfig.GetFloat("world_gravityx", 0f); | ||
280 | gravityy = physicsconfig.GetFloat("world_gravityy", 0f); | ||
281 | gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); | ||
282 | |||
283 | worldHashspaceLow = physicsconfig.GetInt("world_hashspace_low", -4); | ||
284 | worldHashspaceHigh = physicsconfig.GetInt("world_hashspace_high", 128); | ||
285 | |||
286 | metersInSpace = physicsconfig.GetFloat("meters_in_small_space", 29.9f); | ||
287 | smallHashspaceLow = physicsconfig.GetInt("small_hashspace_size_low", -4); | ||
288 | smallHashspaceHigh = physicsconfig.GetInt("small_hashspace_size_high", 66); | ||
289 | |||
290 | contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", 0.001f); | ||
291 | |||
292 | nmTerrainContactFriction = physicsconfig.GetFloat("nm_terraincontact_friction", 255.0f); | ||
293 | nmTerrainContactBounce = physicsconfig.GetFloat("nm_terraincontact_bounce", 0.1f); | ||
294 | nmTerrainContactERP = physicsconfig.GetFloat("nm_terraincontact_erp", 0.1025f); | ||
295 | |||
296 | mTerrainContactFriction = physicsconfig.GetFloat("m_terraincontact_friction", 75f); | ||
297 | mTerrainContactBounce = physicsconfig.GetFloat("m_terraincontact_bounce", 0.1f); | ||
298 | mTerrainContactERP = physicsconfig.GetFloat("m_terraincontact_erp", 0.05025f); | ||
299 | |||
300 | nmAvatarObjectContactFriction = physicsconfig.GetFloat("objectcontact_friction", 250f); | ||
301 | nmAvatarObjectContactBounce = physicsconfig.GetFloat("objectcontact_bounce", 0.2f); | ||
302 | |||
303 | mAvatarObjectContactFriction = physicsconfig.GetFloat("m_avatarobjectcontact_friction", 75f); | ||
304 | mAvatarObjectContactBounce = physicsconfig.GetFloat("m_avatarobjectcontact_bounce", 0.1f); | ||
305 | |||
306 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f); | ||
307 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10); | ||
308 | |||
309 | } | ||
310 | |||
311 | } | ||
312 | |||
313 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | ||
218 | 314 | ||
219 | // Centeral contact friction and bounce | 315 | // Centeral contact friction and bounce |
220 | contact.surface.mu = 250.0f; | 316 | contact.surface.mu = nmAvatarObjectContactFriction; |
221 | contact.surface.bounce = 0.2f; | 317 | contact.surface.bounce = nmAvatarObjectContactBounce; |
222 | 318 | ||
223 | // Terrain contact friction and Bounce | 319 | // Terrain contact friction and Bounce |
224 | // This is the *non* moving version. Use this when an avatar | 320 | // This is the *non* moving version. Use this when an avatar |
225 | // isn't moving to keep it in place better | 321 | // isn't moving to keep it in place better |
226 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; | 322 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; |
227 | TerrainContact.surface.mu = 255.0f; | 323 | TerrainContact.surface.mu = nmTerrainContactFriction; |
228 | TerrainContact.surface.bounce = 0.1f; | 324 | TerrainContact.surface.bounce = nmTerrainContactBounce; |
229 | TerrainContact.surface.soft_erp = 0.1025f; | 325 | TerrainContact.surface.soft_erp = nmTerrainContactERP; |
230 | 326 | ||
231 | WaterContact.surface.mode |= (d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM); | 327 | WaterContact.surface.mode |= (d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM); |
232 | WaterContact.surface.mu = 0f; // No friction | 328 | WaterContact.surface.mu = 0f; // No friction |
@@ -238,46 +334,29 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
238 | // THis is the *non* moving version of friction and bounce | 334 | // THis is the *non* moving version of friction and bounce |
239 | // Use this when an avatar comes in contact with a prim | 335 | // Use this when an avatar comes in contact with a prim |
240 | // and is moving | 336 | // and is moving |
241 | AvatarMovementprimContact.surface.mu = 75.0f; | 337 | AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction; |
242 | AvatarMovementprimContact.surface.bounce = 0.1f; | 338 | AvatarMovementprimContact.surface.bounce = mAvatarObjectContactBounce; |
243 | 339 | ||
244 | // Terrain contact friction bounce and various error correcting calculations | 340 | // Terrain contact friction bounce and various error correcting calculations |
245 | // Use this when an avatar is in contact with the terrain and moving. | 341 | // Use this when an avatar is in contact with the terrain and moving. |
246 | AvatarMovementTerrainContact.surface.mode |= d.ContactFlags.SoftERP; | 342 | AvatarMovementTerrainContact.surface.mode |= d.ContactFlags.SoftERP; |
247 | AvatarMovementTerrainContact.surface.mu = 75.0f; | 343 | AvatarMovementTerrainContact.surface.mu = mTerrainContactFriction; |
248 | AvatarMovementTerrainContact.surface.bounce = 0.05f; | 344 | AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce; |
249 | AvatarMovementTerrainContact.surface.soft_erp = 0.05025f; | 345 | AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP; |
250 | |||
251 | lock (OdeLock) | ||
252 | { | ||
253 | 346 | ||
254 | // Creat the world and the first space | 347 | d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh); |
255 | world = d.WorldCreate(); | ||
256 | space = d.HashSpaceCreate(IntPtr.Zero); | ||
257 | d.HashSpaceSetLevels(space, -4, 128); | ||
258 | contactgroup = d.JointGroupCreate(0); | ||
259 | //contactgroup | ||
260 | 348 | ||
349 | // Set the gravity,, don't disable things automatically (we set it explicitly on some things) | ||
261 | 350 | ||
262 | // Set the gravity,, don't disable things automatically (we set it explicitly on some things) | 351 | d.WorldSetGravity(world, gravityx, gravityy, gravityz); |
352 | d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); | ||
263 | 353 | ||
264 | d.WorldSetGravity(world, 0.0f, 0.0f, -9.8f); | 354 | // Set how many steps we go without running collision testing |
265 | d.WorldSetAutoDisableFlag(world, false); | 355 | // This is in addition to the step size. |
266 | d.WorldSetContactSurfaceLayer(world, 0.001f); | 356 | // Essentially Steps * m_physicsiterations |
267 | 357 | d.WorldSetQuickStepNumIterations(world, m_physicsiterations); | |
268 | // Set how many steps we go without running collision testing | 358 | //d.WorldSetContactMaxCorrectingVel(world, 1000.0f); |
269 | // This is in addition to the step size. | ||
270 | // Essentially Steps * m_physicsiterations | ||
271 | d.WorldSetQuickStepNumIterations(world, m_physicsiterations); | ||
272 | ///d.WorldSetContactMaxCorrectingVel(world, 1000.0f); | ||
273 | } | ||
274 | 359 | ||
275 | // zero out a heightmap array float array (single dimention [flattened])) | ||
276 | _heightmap = new float[514*514]; | ||
277 | _watermap = new float[258 * 258]; | ||
278 | |||
279 | // Zero out the prim spaces array (we split our space into smaller spaces so | ||
280 | // we can hit test less. | ||
281 | for (int i = 0; i < staticPrimspace.GetLength(0); i++) | 360 | for (int i = 0; i < staticPrimspace.GetLength(0); i++) |
282 | { | 361 | { |
283 | for (int j = 0; j < staticPrimspace.GetLength(1); j++) | 362 | for (int j = 0; j < staticPrimspace.GetLength(1); j++) |
@@ -285,14 +364,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
285 | staticPrimspace[i, j] = IntPtr.Zero; | 364 | staticPrimspace[i, j] = IntPtr.Zero; |
286 | } | 365 | } |
287 | } | 366 | } |
288 | } | ||
289 | 367 | ||
290 | |||
291 | // Initialize the mesh plugin | ||
292 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
293 | { | ||
294 | mesher = meshmerizer; | ||
295 | m_config = config; | ||
296 | } | 368 | } |
297 | 369 | ||
298 | internal void waitForSpaceUnlock(IntPtr space) | 370 | internal void waitForSpaceUnlock(IntPtr space) |
@@ -649,8 +721,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
649 | { | 721 | { |
650 | 722 | ||
651 | } | 723 | } |
652 | WaterContact.surface.soft_cfm = 0.0000f; | 724 | //WaterContact.surface.soft_cfm = 0.0000f; |
653 | WaterContact.surface.soft_erp = 0.00000f; | 725 | //WaterContact.surface.soft_erp = 0.00000f; |
654 | if (contacts[i].depth > 0.1f) | 726 | if (contacts[i].depth > 0.1f) |
655 | { | 727 | { |
656 | contacts[i].depth *= 52; | 728 | contacts[i].depth *= 52; |
@@ -1345,7 +1417,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1345 | if (newspace == IntPtr.Zero) | 1417 | if (newspace == IntPtr.Zero) |
1346 | { | 1418 | { |
1347 | newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); | 1419 | newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); |
1348 | d.HashSpaceSetLevels(newspace, -4, 66); | 1420 | d.HashSpaceSetLevels(newspace, smallHashspaceLow, smallHashspaceHigh); |
1349 | } | 1421 | } |
1350 | 1422 | ||
1351 | return newspace; | 1423 | return newspace; |