diff options
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 85 |
1 files changed, 66 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 305a930..b4336c3 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -281,38 +281,85 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
281 | break; | 281 | break; |
282 | } | 282 | } |
283 | 283 | ||
284 | if (name1 == "Terrain" || name2 == "Terrain") | 284 | // we don't want prim or avatar to explode |
285 | #region InterPenetration Handling - Unintended physics explosions | ||
286 | if (contacts[i].depth >= 0.08f) | ||
285 | { | 287 | { |
286 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 288 | if (contacts[i].depth >= 1.00f) |
287 | { | 289 | { |
288 | AvatarMovementTerrainContact.geom = contacts[i]; | 290 | //MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString()); |
289 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); | ||
290 | } | 291 | } |
291 | else | 292 | // If you interpenetrate a prim with an agent |
293 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Prim) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Prim)) | ||
292 | { | 294 | { |
293 | TerrainContact.geom = contacts[i]; | 295 | |
294 | joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); | 296 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) |
297 | { | ||
298 | p2.CollidingObj = true; | ||
299 | contacts[i].depth = 0.003f; | ||
300 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); | ||
301 | contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); | ||
302 | |||
303 | } | ||
304 | else | ||
305 | { | ||
306 | contacts[i].depth = 0.0000000f; | ||
307 | } | ||
308 | if (p1.PhysicsActorType == (int)ActorTypes.Agent) | ||
309 | { | ||
310 | p1.CollidingObj = true; | ||
311 | contacts[i].depth = 0.003f; | ||
312 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); | ||
313 | contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2)); | ||
314 | } | ||
315 | else | ||
316 | { | ||
317 | contacts[i].depth = 0.0000000f; | ||
318 | } | ||
319 | } | ||
320 | // If you interpenetrate a prim with another prim | ||
321 | if (p1.PhysicsActorType == (int)ActorTypes.Prim && p2.PhysicsActorType == (int)ActorTypes.Prim) | ||
322 | { | ||
323 | // Don't collide, one or both prim will explode. | ||
324 | contacts[i].depth = 0.0f; | ||
295 | } | 325 | } |
296 | } | 326 | } |
297 | else | 327 | #endregion |
328 | |||
329 | if (contacts[i].depth > 0f) | ||
298 | { | 330 | { |
299 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 331 | if (name1 == "Terrain" || name2 == "Terrain") |
300 | { | 332 | { |
301 | AvatarMovementprimContact.geom = contacts[i]; | 333 | |
302 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); | 334 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) |
335 | { | ||
336 | AvatarMovementTerrainContact.geom = contacts[i]; | ||
337 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); | ||
338 | |||
339 | } | ||
340 | else | ||
341 | { | ||
342 | TerrainContact.geom = contacts[i]; | ||
343 | joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); | ||
344 | } | ||
303 | } | 345 | } |
304 | else | 346 | else |
305 | { | 347 | { |
306 | contact.geom = contacts[i]; | 348 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) |
307 | joint = d.JointCreateContact(world, contactgroup, ref contact); | 349 | { |
350 | AvatarMovementprimContact.geom = contacts[i]; | ||
351 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); | ||
352 | |||
353 | } | ||
354 | else | ||
355 | { | ||
356 | contact.geom = contacts[i]; | ||
357 | joint = d.JointCreateContact(world, contactgroup, ref contact); | ||
358 | } | ||
308 | } | 359 | } |
360 | d.JointAttach(joint, b1, b2); | ||
309 | } | 361 | } |
310 | 362 | ||
311 | |||
312 | d.JointAttach(joint, b1, b2); | ||
313 | |||
314 | |||
315 | |||
316 | if (count > 3) | 363 | if (count > 3) |
317 | { | 364 | { |
318 | p2.ThrottleUpdates = true; | 365 | p2.ThrottleUpdates = true; |
@@ -334,7 +381,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
334 | } | 381 | } |
335 | // If the sim is running slow this frame, | 382 | // If the sim is running slow this frame, |
336 | // don't process collision for prim! | 383 | // don't process collision for prim! |
337 | if (timeStep < (m_SkipFramesAtms / 2)) | 384 | if (timeStep < (m_SkipFramesAtms / 3)) |
338 | { | 385 | { |
339 | foreach (OdePrim chr in _activeprims) | 386 | foreach (OdePrim chr in _activeprims) |
340 | { | 387 | { |