diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 53 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 94 |
2 files changed, 83 insertions, 64 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index d28e464..312fd9c 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -672,9 +672,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
672 | } | 672 | } |
673 | ode.dlock(_parent_scene.world); | 673 | ode.dlock(_parent_scene.world); |
674 | m_disabled = true; | 674 | m_disabled = true; |
675 | if (Body != (IntPtr) 0) | 675 | if (Body != (IntPtr)0) |
676 | { | ||
676 | d.BodyDisable(Body); | 677 | d.BodyDisable(Body); |
677 | 678 | Body = (IntPtr)0; | |
679 | } | ||
678 | ode.dunlock(_parent_scene.world); | 680 | ode.dunlock(_parent_scene.world); |
679 | 681 | ||
680 | m_taintdisable = false; | 682 | m_taintdisable = false; |
@@ -682,27 +684,30 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
682 | 684 | ||
683 | public void changePhysicsStatus(float timestap) | 685 | public void changePhysicsStatus(float timestap) |
684 | { | 686 | { |
685 | while (ode.lockquery()) | 687 | lock (ode) |
686 | { | 688 | { |
687 | } | 689 | while (ode.lockquery()) |
688 | ode.dlock(_parent_scene.world); | 690 | { |
691 | } | ||
692 | ode.dlock(_parent_scene.world); | ||
689 | 693 | ||
690 | if (m_isphysical == true) | 694 | if (m_isphysical == true) |
691 | { | ||
692 | if (Body == (IntPtr) 0) | ||
693 | { | 695 | { |
694 | enableBody(); | 696 | if (Body == (IntPtr)0) |
697 | { | ||
698 | enableBody(); | ||
699 | } | ||
695 | } | 700 | } |
696 | } | 701 | else |
697 | else | ||
698 | { | ||
699 | if (Body != (IntPtr) 0) | ||
700 | { | 702 | { |
701 | disableBody(); | 703 | if (Body != (IntPtr)0) |
704 | { | ||
705 | disableBody(); | ||
706 | } | ||
702 | } | 707 | } |
703 | } | ||
704 | 708 | ||
705 | ode.dunlock(_parent_scene.world); | 709 | ode.dunlock(_parent_scene.world); |
710 | } | ||
706 | 711 | ||
707 | resetCollisionAccounting(); | 712 | resetCollisionAccounting(); |
708 | m_taintPhysics = m_isphysical; | 713 | m_taintPhysics = m_isphysical; |
@@ -1279,18 +1284,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1279 | 1284 | ||
1280 | 1285 | ||
1281 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) | 1286 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) |
1282 | //if (vec.X < 0.0f) vec.X = 0.0f; | 1287 | //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } |
1283 | //if (vec.Y < 0.0f) vec.Y = 0.0f; | 1288 | //if (vec.Y < 0.0f) { vec.Y = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } |
1284 | //if (vec.X > 255.95f) vec.X = 255.95f; | 1289 | //if (vec.X > 255.95f) { vec.X = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } |
1285 | //if (vec.Y > 255.95f) vec.Y = 255.95f; | 1290 | //if (vec.Y > 255.95f) { vec.Y = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } |
1291 | |||
1286 | m_lastposition = _position; | 1292 | m_lastposition = _position; |
1287 | 1293 | ||
1288 | l_position.X = vec.X; | 1294 | l_position.X = vec.X; |
1289 | l_position.Y = vec.Y; | 1295 | l_position.Y = vec.Y; |
1290 | l_position.Z = vec.Z; | 1296 | l_position.Z = vec.Z; |
1291 | 1297 | ||
1292 | //if (l_position.X > 257f || l_position.X < -1f || l_position.Y > 257f || l_position.Y < -1f) | 1298 | if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f) |
1293 | //{ | 1299 | { |
1300 | base.RaiseOutOfBounds(_position); | ||
1301 | } | ||
1294 | //if (m_crossingfailures < 5) | 1302 | //if (m_crossingfailures < 5) |
1295 | //{ | 1303 | //{ |
1296 | //base.RequestPhysicsterseUpdate(); | 1304 | //base.RequestPhysicsterseUpdate(); |
@@ -1385,6 +1393,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1385 | m_lastUpdateSent = false; | 1393 | m_lastUpdateSent = false; |
1386 | if (!m_throttleUpdates || throttleCounter > 15) | 1394 | if (!m_throttleUpdates || throttleCounter > 15) |
1387 | { | 1395 | { |
1396 | |||
1388 | base.RequestPhysicsterseUpdate(); | 1397 | base.RequestPhysicsterseUpdate(); |
1389 | } | 1398 | } |
1390 | else | 1399 | else |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 0fd4f4d..c4d249d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -269,6 +269,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
269 | 269 | ||
270 | if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) | 270 | if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) |
271 | { | 271 | { |
272 | if (g1 == (IntPtr)0 || g2 == (IntPtr)0) | ||
273 | return; | ||
272 | // Separating static prim geometry spaces. | 274 | // Separating static prim geometry spaces. |
273 | // We'll be calling near recursivly if one | 275 | // We'll be calling near recursivly if one |
274 | // of them is a space to find all of the | 276 | // of them is a space to find all of the |
@@ -280,6 +282,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
280 | catch (System.AccessViolationException) | 282 | catch (System.AccessViolationException) |
281 | { | 283 | { |
282 | m_log.Warn("[PHYSICS]: Unable to collide test a space"); | 284 | m_log.Warn("[PHYSICS]: Unable to collide test a space"); |
285 | return; | ||
283 | } | 286 | } |
284 | //Colliding a space or a geom with a space or a geom. so drill down | 287 | //Colliding a space or a geom with a space or a geom. so drill down |
285 | 288 | ||
@@ -291,6 +294,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
291 | { | 294 | { |
292 | // Colliding Geom To Geom | 295 | // Colliding Geom To Geom |
293 | // This portion of the function 'was' blatantly ripped off from BoxStack.cs | 296 | // This portion of the function 'was' blatantly ripped off from BoxStack.cs |
297 | if (g1 == (IntPtr)0 || g2 == (IntPtr)0) | ||
298 | return; | ||
294 | 299 | ||
295 | IntPtr b1 = d.GeomGetBody(g1); | 300 | IntPtr b1 = d.GeomGetBody(g1); |
296 | IntPtr b2 = d.GeomGetBody(g2); | 301 | IntPtr b2 = d.GeomGetBody(g2); |
@@ -301,6 +306,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
301 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | 306 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) |
302 | return; | 307 | return; |
303 | 308 | ||
309 | |||
310 | |||
304 | d.GeomClassID id = d.GeomGetClass(g1); | 311 | d.GeomClassID id = d.GeomGetClass(g1); |
305 | 312 | ||
306 | String name1 = null; | 313 | String name1 = null; |
@@ -325,6 +332,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
325 | int count = 0; | 332 | int count = 0; |
326 | try | 333 | try |
327 | { | 334 | { |
335 | //m_log.Warn(g1.ToString() + "|" + g2.ToString()); | ||
328 | count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); | 336 | count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); |
329 | } | 337 | } |
330 | catch (SEHException) | 338 | catch (SEHException) |
@@ -335,7 +343,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
335 | } | 343 | } |
336 | catch (System.AccessViolationException) | 344 | catch (System.AccessViolationException) |
337 | { | 345 | { |
346 | |||
338 | m_log.Warn("[PHYSICS]: Unable to collide test an object"); | 347 | m_log.Warn("[PHYSICS]: Unable to collide test an object"); |
348 | return; | ||
339 | } | 349 | } |
340 | 350 | ||
341 | PhysicsActor p1; | 351 | PhysicsActor p1; |
@@ -438,48 +448,48 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
438 | // If you interpenetrate a prim with another prim | 448 | // If you interpenetrate a prim with another prim |
439 | if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) | 449 | if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) |
440 | { | 450 | { |
441 | OdePrim op1 = (OdePrim)p1; | 451 | //OdePrim op1 = (OdePrim)p1; |
442 | OdePrim op2 = (OdePrim)p2; | 452 | //OdePrim op2 = (OdePrim)p2; |
443 | op1.m_collisionscore++; | 453 | //op1.m_collisionscore++; |
444 | op2.m_collisionscore++; | 454 | //op2.m_collisionscore++; |
445 | 455 | ||
446 | 456 | ||
447 | if (op1.m_collisionscore > 80 || op2.m_collisionscore > 80) | 457 | //if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000) |
448 | { | 458 | //{ |
449 | op1.m_taintdisable = true; | 459 | //op1.m_taintdisable = true; |
450 | AddPhysicsActorTaint(p1); | 460 | //AddPhysicsActorTaint(p1); |
451 | op2.m_taintdisable = true; | 461 | //op2.m_taintdisable = true; |
452 | AddPhysicsActorTaint(p2); | 462 | //AddPhysicsActorTaint(p2); |
453 | } | 463 | //} |
454 | 464 | ||
455 | if (contacts[i].depth >= 0.25f) | 465 | //if (contacts[i].depth >= 0.25f) |
456 | { | 466 | //{ |
457 | // Don't collide, one or both prim will expld. | 467 | // Don't collide, one or both prim will expld. |
458 | 468 | ||
459 | 469 | ||
460 | op1.m_interpenetrationcount++; | 470 | //op1.m_interpenetrationcount++; |
461 | op2.m_interpenetrationcount++; | 471 | //op2.m_interpenetrationcount++; |
462 | interpenetrations_before_disable = 20; | 472 | //interpenetrations_before_disable = 200; |
463 | if (op1.m_interpenetrationcount >= interpenetrations_before_disable) | 473 | //if (op1.m_interpenetrationcount >= interpenetrations_before_disable) |
464 | { | 474 | //{ |
465 | op1.m_taintdisable = true; | 475 | //op1.m_taintdisable = true; |
466 | AddPhysicsActorTaint(p1); | 476 | //AddPhysicsActorTaint(p1); |
467 | } | 477 | //} |
468 | if (op2.m_interpenetrationcount >= interpenetrations_before_disable) | 478 | //if (op2.m_interpenetrationcount >= interpenetrations_before_disable) |
469 | { | 479 | //{ |
470 | op2.m_taintdisable = true; | 480 | // op2.m_taintdisable = true; |
471 | AddPhysicsActorTaint(p2); | 481 | //AddPhysicsActorTaint(p2); |
472 | } | 482 | //} |
473 | 483 | ||
474 | 484 | ||
475 | //contacts[i].depth = contacts[i].depth / 8f; | 485 | //contacts[i].depth = contacts[i].depth / 8f; |
476 | //contacts[i].normal = new d.Vector3(0, 0, 1); | 486 | //contacts[i].normal = new d.Vector3(0, 0, 1); |
477 | } | 487 | //} |
478 | if (op1.m_disabled || op2.m_disabled) | 488 | //if (op1.m_disabled || op2.m_disabled) |
479 | { | 489 | //{ |
480 | //Manually disabled objects stay disabled | 490 | //Manually disabled objects stay disabled |
481 | contacts[i].depth = 0f; | 491 | //contacts[i].depth = 0f; |
482 | } | 492 | //} |
483 | } | 493 | } |
484 | if (contacts[i].depth >= 1.00f) | 494 | if (contacts[i].depth >= 1.00f) |
485 | { | 495 | { |
@@ -720,9 +730,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
720 | { | 730 | { |
721 | OdePrim p = (OdePrim) prim; | 731 | OdePrim p = (OdePrim) prim; |
722 | 732 | ||
723 | //p.setPrimForRemoval(); | 733 | p.setPrimForRemoval(); |
724 | //AddPhysicsActorTaint(prim); | 734 | AddPhysicsActorTaint(prim); |
725 | RemovePrimThreadLocked(p); | 735 | //RemovePrimThreadLocked(p); |
726 | } | 736 | } |
727 | } | 737 | } |
728 | } | 738 | } |
@@ -760,8 +770,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
760 | //m_log.Warn(prim.m_targetSpace); | 770 | //m_log.Warn(prim.m_targetSpace); |
761 | 771 | ||
762 | 772 | ||
763 | if (prim.m_targetSpace != (IntPtr)0) | 773 | //if (prim.m_targetSpace != (IntPtr)0) |
764 | { | 774 | //{ |
765 | if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) | 775 | if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) |
766 | { | 776 | { |
767 | 777 | ||
@@ -769,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
769 | { | 779 | { |
770 | waitForSpaceUnlock(prim.m_targetSpace); | 780 | waitForSpaceUnlock(prim.m_targetSpace); |
771 | d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); | 781 | d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); |
772 | prim.m_targetSpace = space; | 782 | prim.m_targetSpace = (IntPtr) 0; |
773 | } | 783 | } |
774 | else | 784 | else |
775 | { | 785 | { |
@@ -778,7 +788,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
778 | } | 788 | } |
779 | 789 | ||
780 | } | 790 | } |
781 | } | 791 | //} |
782 | //m_log.Warn(prim.prim_geom); | 792 | //m_log.Warn(prim.prim_geom); |
783 | try | 793 | try |
784 | { | 794 | { |
@@ -1309,10 +1319,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1309 | bool processedtaints = false; | 1319 | bool processedtaints = false; |
1310 | foreach (OdePrim prim in _taintedPrim) | 1320 | foreach (OdePrim prim in _taintedPrim) |
1311 | { | 1321 | { |
1312 | //if (prim.m_taintremove) | 1322 | if (prim.m_taintremove) |
1313 | //{ | 1323 | { |
1314 | //RemovePrimThreadLocked(prim); | 1324 | RemovePrimThreadLocked(prim); |
1315 | //} | 1325 | } |
1316 | 1326 | ||
1317 | prim.ProcessTaints(timeStep); | 1327 | prim.ProcessTaints(timeStep); |
1318 | 1328 | ||