diff options
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 410 |
1 files changed, 199 insertions, 211 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs index 79e2986..353db44 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | |||
@@ -224,7 +224,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
224 | public float bodyPIDG = 25; | 224 | public float bodyPIDG = 25; |
225 | 225 | ||
226 | public int geomCrossingFailuresBeforeOutofbounds = 5; | 226 | public int geomCrossingFailuresBeforeOutofbounds = 5; |
227 | public int geomRegionFence = 0; | 227 | public float geomRegionFence = 0.0f; |
228 | 228 | ||
229 | public float bodyMotorJointMaxforceTensor = 2; | 229 | public float bodyMotorJointMaxforceTensor = 2; |
230 | 230 | ||
@@ -264,8 +264,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
264 | private readonly DoubleDictionary<Vector3, IntPtr, IntPtr> RegionTerrain = new DoubleDictionary<Vector3, IntPtr, IntPtr>(); | 264 | private readonly DoubleDictionary<Vector3, IntPtr, IntPtr> RegionTerrain = new DoubleDictionary<Vector3, IntPtr, IntPtr>(); |
265 | private readonly Dictionary<IntPtr,float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>(); | 265 | private readonly Dictionary<IntPtr,float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>(); |
266 | 266 | ||
267 | private d.Contact contact; | 267 | private d.Contact ContactCopy; // local copy that can be modified |
268 | private d.Contact TerrainContact; | 268 | private d.Contact TerrainContact; |
269 | private d.Contact AvatarStaticprimContact; // was 'contact' | ||
269 | private d.Contact AvatarMovementprimContact; | 270 | private d.Contact AvatarMovementprimContact; |
270 | private d.Contact AvatarMovementTerrainContact; | 271 | private d.Contact AvatarMovementTerrainContact; |
271 | private d.Contact WaterContact; | 272 | private d.Contact WaterContact; |
@@ -448,7 +449,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
448 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); | 449 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); |
449 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); | 450 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); |
450 | geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); | 451 | geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); |
451 | geomRegionFence = physicsconfig.GetInt("region_border_fence", 0); | 452 | geomRegionFence = physicsconfig.GetFloat("region_border_fence", 0.0f); |
452 | 453 | ||
453 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f); | 454 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f); |
454 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20); | 455 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20); |
@@ -491,167 +492,143 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
491 | 492 | ||
492 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | 493 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; |
493 | 494 | ||
494 | // Centeral contact friction and bounce | 495 | // Avatar static on a Prim parameters |
495 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why | 496 | AvatarStaticprimContact.surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
496 | // an avatar falls through in Z but not in X or Y when walking on a prim. | 497 | AvatarStaticprimContact.surface.mu = 255.0f; |
497 | contact.surface.mode |= d.ContactFlags.SoftERP; | 498 | AvatarStaticprimContact.surface.bounce = 0.0f; |
498 | contact.surface.mu = nmAvatarObjectContactFriction; | 499 | AvatarStaticprimContact.surface.soft_cfm = 0.0f; |
499 | contact.surface.bounce = nmAvatarObjectContactBounce; | 500 | AvatarStaticprimContact.surface.soft_erp = 0.30f; // If this is too small static Av will fall through a sloping prim. 1.0 prevents fall-thru |
500 | contact.surface.soft_cfm = 0.010f; | 501 | |
501 | contact.surface.soft_erp = 0.010f; | 502 | // Avatar moving on a Prim parameters |
502 | 503 | AvatarMovementprimContact.surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; | |
503 | // Terrain contact friction and Bounce | 504 | AvatarMovementprimContact.surface.mu = 255.0f; |
504 | // This is the *non* moving version. Use this when an avatar | 505 | AvatarMovementprimContact.surface.bounce = 0.0f; |
505 | // isn't moving to keep it in place better | 506 | AvatarMovementprimContact.surface.soft_cfm = 0.0f; // if this is 0.01 then prims become phantom to Avs! |
506 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; | 507 | AvatarMovementprimContact.surface.soft_erp = 0.3f; |
507 | TerrainContact.surface.mu = nmTerrainContactFriction; | 508 | |
508 | TerrainContact.surface.bounce = nmTerrainContactBounce; | 509 | // Static Avatar on Terrain parameters |
509 | TerrainContact.surface.soft_erp = nmTerrainContactERP; | 510 | // Keeps Avatar in place better |
510 | 511 | TerrainContact.surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; | |
512 | TerrainContact.surface.mu = 255.0f; | ||
513 | TerrainContact.surface.bounce = 0.0f; | ||
514 | TerrainContact.surface.soft_cfm = 0.0f; | ||
515 | TerrainContact.surface.soft_erp = 0.05f; | ||
516 | |||
517 | // Moving Avatar on Terrain parameters | ||
518 | AvatarMovementTerrainContact.surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; | ||
519 | AvatarMovementTerrainContact.surface.mu = 75f; | ||
520 | AvatarMovementTerrainContact.surface.bounce = 0.0f; | ||
521 | AvatarMovementTerrainContact.surface.soft_cfm = 0.0f; | ||
522 | AvatarMovementTerrainContact.surface.soft_erp = 0.05f; | ||
523 | |||
524 | // Avatar or prim the the water, this may not be used, possibly water is same as air? | ||
511 | WaterContact.surface.mode |= (d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM); | 525 | WaterContact.surface.mode |= (d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM); |
512 | WaterContact.surface.mu = 0f; // No friction | 526 | WaterContact.surface.mu = 0.0f; // No friction |
513 | WaterContact.surface.bounce = 0.0f; // No bounce | 527 | WaterContact.surface.bounce = 0.0f; // No bounce |
514 | WaterContact.surface.soft_cfm = 0.010f; | 528 | WaterContact.surface.soft_cfm = 0.010f; |
515 | WaterContact.surface.soft_erp = 0.010f; | 529 | WaterContact.surface.soft_erp = 0.010f; |
516 | 530 | ||
517 | // Prim contact friction and bounce | ||
518 | // THis is the *non* moving version of friction and bounce | ||
519 | // Use this when an avatar comes in contact with a prim | ||
520 | // and is moving | ||
521 | AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction; | ||
522 | AvatarMovementprimContact.surface.bounce = mAvatarObjectContactBounce; | ||
523 | |||
524 | // Terrain contact friction bounce and various error correcting calculations | ||
525 | // Use this when an avatar is in contact with the terrain and moving. | ||
526 | AvatarMovementTerrainContact.surface.mode |= d.ContactFlags.SoftERP; | ||
527 | AvatarMovementTerrainContact.surface.mu = mTerrainContactFriction; | ||
528 | AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce; | ||
529 | AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP; | ||
530 | |||
531 | |||
532 | /* | ||
533 | <summary></summary> | ||
534 | Stone = 0, | ||
535 | /// <summary></summary> | ||
536 | Metal = 1, | ||
537 | /// <summary></summary> | ||
538 | Glass = 2, | ||
539 | /// <summary></summary> | ||
540 | Wood = 3, | ||
541 | /// <summary></summary> | ||
542 | Flesh = 4, | ||
543 | /// <summary></summary> | ||
544 | Plastic = 5, | ||
545 | /// <summary></summary> | ||
546 | Rubber = 6 | ||
547 | */ | ||
548 | 531 | ||
532 | // Prim static or moving on a prim, depends on material type | ||
549 | m_materialContacts = new d.Contact[7,2]; | 533 | m_materialContacts = new d.Contact[7,2]; |
550 | 534 | // V 1 = Sliding; 0 = static or fell onto | |
551 | m_materialContacts[(int)Material.Stone, 0] = new d.Contact(); | 535 | m_materialContacts[(int)Material.Stone, 0] = new d.Contact(); |
552 | m_materialContacts[(int)Material.Stone, 0].surface.mode |= d.ContactFlags.SoftERP; | 536 | m_materialContacts[(int)Material.Stone, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
553 | m_materialContacts[(int)Material.Stone, 0].surface.mu = nmAvatarObjectContactFriction; | 537 | m_materialContacts[(int)Material.Stone, 0].surface.mu = 60f; // friction, 1 = slippery, 255 = no slip |
554 | m_materialContacts[(int)Material.Stone, 0].surface.bounce = nmAvatarObjectContactBounce; | 538 | m_materialContacts[(int)Material.Stone, 0].surface.bounce = 0.0f; |
555 | m_materialContacts[(int)Material.Stone, 0].surface.soft_cfm = 0.010f; | 539 | m_materialContacts[(int)Material.Stone, 0].surface.soft_cfm = 0.0f; |
556 | m_materialContacts[(int)Material.Stone, 0].surface.soft_erp = 0.010f; | 540 | m_materialContacts[(int)Material.Stone, 0].surface.soft_erp = 0.50f; // erp also changes friction, more erp=less friction |
557 | 541 | ||
558 | m_materialContacts[(int)Material.Stone, 1] = new d.Contact(); | 542 | m_materialContacts[(int)Material.Stone, 1] = new d.Contact(); |
559 | m_materialContacts[(int)Material.Stone, 1].surface.mode |= d.ContactFlags.SoftERP; | 543 | m_materialContacts[(int)Material.Stone, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
560 | m_materialContacts[(int)Material.Stone, 1].surface.mu = mAvatarObjectContactFriction; | 544 | m_materialContacts[(int)Material.Stone, 1].surface.mu = 40f; |
561 | m_materialContacts[(int)Material.Stone, 1].surface.bounce = mAvatarObjectContactBounce; | 545 | m_materialContacts[(int)Material.Stone, 1].surface.bounce = 0.0f; |
562 | m_materialContacts[(int)Material.Stone, 1].surface.soft_cfm = 0.010f; | 546 | m_materialContacts[(int)Material.Stone, 1].surface.soft_cfm = 0.0f; |
563 | m_materialContacts[(int)Material.Stone, 1].surface.soft_erp = 0.010f; | 547 | m_materialContacts[(int)Material.Stone, 1].surface.soft_erp = 0.50f; |
564 | 548 | ||
565 | m_materialContacts[(int)Material.Metal, 0] = new d.Contact(); | 549 | m_materialContacts[(int)Material.Metal, 0] = new d.Contact(); |
566 | m_materialContacts[(int)Material.Metal, 0].surface.mode |= d.ContactFlags.SoftERP; | 550 | m_materialContacts[(int)Material.Metal, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
567 | m_materialContacts[(int)Material.Metal, 0].surface.mu = nmAvatarObjectContactFriction; | 551 | m_materialContacts[(int)Material.Metal, 0].surface.mu = 15f; |
568 | m_materialContacts[(int)Material.Metal, 0].surface.bounce = nmAvatarObjectContactBounce; | 552 | m_materialContacts[(int)Material.Metal, 0].surface.bounce = 0.2f; |
569 | m_materialContacts[(int)Material.Metal, 0].surface.soft_cfm = 0.010f; | 553 | m_materialContacts[(int)Material.Metal, 0].surface.soft_cfm = 0.0f; |
570 | m_materialContacts[(int)Material.Metal, 0].surface.soft_erp = 0.010f; | 554 | m_materialContacts[(int)Material.Metal, 0].surface.soft_erp = 0.50f; |
571 | 555 | ||
572 | m_materialContacts[(int)Material.Metal, 1] = new d.Contact(); | 556 | m_materialContacts[(int)Material.Metal, 1] = new d.Contact(); |
573 | m_materialContacts[(int)Material.Metal, 1].surface.mode |= d.ContactFlags.SoftERP; | 557 | m_materialContacts[(int)Material.Metal, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
574 | m_materialContacts[(int)Material.Metal, 1].surface.mu = mAvatarObjectContactFriction; | 558 | m_materialContacts[(int)Material.Metal, 1].surface.mu = 10f; |
575 | m_materialContacts[(int)Material.Metal, 1].surface.bounce = mAvatarObjectContactBounce; | 559 | m_materialContacts[(int)Material.Metal, 1].surface.bounce = 0.2f; |
576 | m_materialContacts[(int)Material.Metal, 1].surface.soft_cfm = 0.010f; | 560 | m_materialContacts[(int)Material.Metal, 1].surface.soft_cfm = 0.0f; |
577 | m_materialContacts[(int)Material.Metal, 1].surface.soft_erp = 0.010f; | 561 | m_materialContacts[(int)Material.Metal, 1].surface.soft_erp = 0.50f; |
578 | 562 | ||
579 | m_materialContacts[(int)Material.Glass, 0] = new d.Contact(); | 563 | m_materialContacts[(int)Material.Glass, 0] = new d.Contact(); |
580 | m_materialContacts[(int)Material.Glass, 0].surface.mode |= d.ContactFlags.SoftERP; | 564 | m_materialContacts[(int)Material.Glass, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
581 | m_materialContacts[(int)Material.Glass, 0].surface.mu = 1f; | 565 | m_materialContacts[(int)Material.Glass, 0].surface.mu = 7.5f; |
582 | m_materialContacts[(int)Material.Glass, 0].surface.bounce = 0.5f; | 566 | m_materialContacts[(int)Material.Glass, 0].surface.bounce = 0.0f; |
583 | m_materialContacts[(int)Material.Glass, 0].surface.soft_cfm = 0.010f; | 567 | m_materialContacts[(int)Material.Glass, 0].surface.soft_cfm = 0.0f; |
584 | m_materialContacts[(int)Material.Glass, 0].surface.soft_erp = 0.010f; | 568 | m_materialContacts[(int)Material.Glass, 0].surface.soft_erp = 0.50f; |
585 | 569 | ||
586 | /* | ||
587 | private float nmAvatarObjectContactFriction = 250f; | ||
588 | private float nmAvatarObjectContactBounce = 0.1f; | ||
589 | |||
590 | private float mAvatarObjectContactFriction = 75f; | ||
591 | private float mAvatarObjectContactBounce = 0.1f; | ||
592 | */ | ||
593 | m_materialContacts[(int)Material.Glass, 1] = new d.Contact(); | 570 | m_materialContacts[(int)Material.Glass, 1] = new d.Contact(); |
594 | m_materialContacts[(int)Material.Glass, 1].surface.mode |= d.ContactFlags.SoftERP; | 571 | m_materialContacts[(int)Material.Glass, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
595 | m_materialContacts[(int)Material.Glass, 1].surface.mu = 1f; | 572 | m_materialContacts[(int)Material.Glass, 1].surface.mu = 5f; |
596 | m_materialContacts[(int)Material.Glass, 1].surface.bounce = 0.5f; | 573 | m_materialContacts[(int)Material.Glass, 1].surface.bounce = 0.0f; |
597 | m_materialContacts[(int)Material.Glass, 1].surface.soft_cfm = 0.010f; | 574 | m_materialContacts[(int)Material.Glass, 1].surface.soft_cfm = 0.0f; |
598 | m_materialContacts[(int)Material.Glass, 1].surface.soft_erp = 0.010f; | 575 | m_materialContacts[(int)Material.Glass, 1].surface.soft_erp = 0.50f; |
599 | 576 | ||
600 | m_materialContacts[(int)Material.Wood, 0] = new d.Contact(); | 577 | m_materialContacts[(int)Material.Wood, 0] = new d.Contact(); |
601 | m_materialContacts[(int)Material.Wood, 0].surface.mode |= d.ContactFlags.SoftERP; | 578 | m_materialContacts[(int)Material.Wood, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
602 | m_materialContacts[(int)Material.Wood, 0].surface.mu = nmAvatarObjectContactFriction; | 579 | m_materialContacts[(int)Material.Wood, 0].surface.mu = 45f; |
603 | m_materialContacts[(int)Material.Wood, 0].surface.bounce = nmAvatarObjectContactBounce; | 580 | m_materialContacts[(int)Material.Wood, 0].surface.bounce = 0.1f; |
604 | m_materialContacts[(int)Material.Wood, 0].surface.soft_cfm = 0.010f; | 581 | m_materialContacts[(int)Material.Wood, 0].surface.soft_cfm = 0.0f; |
605 | m_materialContacts[(int)Material.Wood, 0].surface.soft_erp = 0.010f; | 582 | m_materialContacts[(int)Material.Wood, 0].surface.soft_erp = 0.50f; |
606 | 583 | ||
607 | m_materialContacts[(int)Material.Wood, 1] = new d.Contact(); | 584 | m_materialContacts[(int)Material.Wood, 1] = new d.Contact(); |
608 | m_materialContacts[(int)Material.Wood, 1].surface.mode |= d.ContactFlags.SoftERP; | 585 | m_materialContacts[(int)Material.Wood, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
609 | m_materialContacts[(int)Material.Wood, 1].surface.mu = mAvatarObjectContactFriction; | 586 | m_materialContacts[(int)Material.Wood, 1].surface.mu = 30f; |
610 | m_materialContacts[(int)Material.Wood, 1].surface.bounce = mAvatarObjectContactBounce; | 587 | m_materialContacts[(int)Material.Wood, 1].surface.bounce = 0.1f; |
611 | m_materialContacts[(int)Material.Wood, 1].surface.soft_cfm = 0.010f; | 588 | m_materialContacts[(int)Material.Wood, 1].surface.soft_cfm = 0.0f; |
612 | m_materialContacts[(int)Material.Wood, 1].surface.soft_erp = 0.010f; | 589 | m_materialContacts[(int)Material.Wood, 1].surface.soft_erp = 0.50f; |
613 | 590 | ||
614 | m_materialContacts[(int)Material.Flesh, 0] = new d.Contact(); | 591 | m_materialContacts[(int)Material.Flesh, 0] = new d.Contact(); |
615 | m_materialContacts[(int)Material.Flesh, 0].surface.mode |= d.ContactFlags.SoftERP; | 592 | m_materialContacts[(int)Material.Flesh, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
616 | m_materialContacts[(int)Material.Flesh, 0].surface.mu = nmAvatarObjectContactFriction; | 593 | m_materialContacts[(int)Material.Flesh, 0].surface.mu = 150f; |
617 | m_materialContacts[(int)Material.Flesh, 0].surface.bounce = nmAvatarObjectContactBounce; | 594 | m_materialContacts[(int)Material.Flesh, 0].surface.bounce = 0.0f; |
618 | m_materialContacts[(int)Material.Flesh, 0].surface.soft_cfm = 0.010f; | 595 | m_materialContacts[(int)Material.Flesh, 0].surface.soft_cfm = 0.0f; |
619 | m_materialContacts[(int)Material.Flesh, 0].surface.soft_erp = 0.010f; | 596 | m_materialContacts[(int)Material.Flesh, 0].surface.soft_erp = 0.50f; |
620 | 597 | ||
621 | m_materialContacts[(int)Material.Flesh, 1] = new d.Contact(); | 598 | m_materialContacts[(int)Material.Flesh, 1] = new d.Contact(); |
622 | m_materialContacts[(int)Material.Flesh, 1].surface.mode |= d.ContactFlags.SoftERP; | 599 | m_materialContacts[(int)Material.Flesh, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
623 | m_materialContacts[(int)Material.Flesh, 1].surface.mu = mAvatarObjectContactFriction; | 600 | m_materialContacts[(int)Material.Flesh, 1].surface.mu = 100f; |
624 | m_materialContacts[(int)Material.Flesh, 1].surface.bounce = mAvatarObjectContactBounce; | 601 | m_materialContacts[(int)Material.Flesh, 1].surface.bounce = 0.0f; |
625 | m_materialContacts[(int)Material.Flesh, 1].surface.soft_cfm = 0.010f; | 602 | m_materialContacts[(int)Material.Flesh, 1].surface.soft_cfm = 0.0f; |
626 | m_materialContacts[(int)Material.Flesh, 1].surface.soft_erp = 0.010f; | 603 | m_materialContacts[(int)Material.Flesh, 1].surface.soft_erp = 0.50f; |
627 | 604 | ||
628 | m_materialContacts[(int)Material.Plastic, 0] = new d.Contact(); | 605 | m_materialContacts[(int)Material.Plastic, 0] = new d.Contact(); |
629 | m_materialContacts[(int)Material.Plastic, 0].surface.mode |= d.ContactFlags.SoftERP; | 606 | m_materialContacts[(int)Material.Plastic, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
630 | m_materialContacts[(int)Material.Plastic, 0].surface.mu = nmAvatarObjectContactFriction; | 607 | m_materialContacts[(int)Material.Plastic, 0].surface.mu = 30f; |
631 | m_materialContacts[(int)Material.Plastic, 0].surface.bounce = nmAvatarObjectContactBounce; | 608 | m_materialContacts[(int)Material.Plastic, 0].surface.bounce = 0.2f; |
632 | m_materialContacts[(int)Material.Plastic, 0].surface.soft_cfm = 0.010f; | 609 | m_materialContacts[(int)Material.Plastic, 0].surface.soft_cfm = 0.0f; |
633 | m_materialContacts[(int)Material.Plastic, 0].surface.soft_erp = 0.010f; | 610 | m_materialContacts[(int)Material.Plastic, 0].surface.soft_erp = 0.50f; |
634 | 611 | ||
635 | m_materialContacts[(int)Material.Plastic, 1] = new d.Contact(); | 612 | m_materialContacts[(int)Material.Plastic, 1] = new d.Contact(); |
636 | m_materialContacts[(int)Material.Plastic, 1].surface.mode |= d.ContactFlags.SoftERP; | 613 | m_materialContacts[(int)Material.Plastic, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
637 | m_materialContacts[(int)Material.Plastic, 1].surface.mu = mAvatarObjectContactFriction; | 614 | m_materialContacts[(int)Material.Plastic, 1].surface.mu = 20f; |
638 | m_materialContacts[(int)Material.Plastic, 1].surface.bounce = mAvatarObjectContactBounce; | 615 | m_materialContacts[(int)Material.Plastic, 1].surface.bounce = 0.2f; |
639 | m_materialContacts[(int)Material.Plastic, 1].surface.soft_cfm = 0.010f; | 616 | m_materialContacts[(int)Material.Plastic, 1].surface.soft_cfm = 0.0f; |
640 | m_materialContacts[(int)Material.Plastic, 1].surface.soft_erp = 0.010f; | 617 | m_materialContacts[(int)Material.Plastic, 1].surface.soft_erp = 0.50f; |
641 | 618 | ||
642 | m_materialContacts[(int)Material.Rubber, 0] = new d.Contact(); | 619 | m_materialContacts[(int)Material.Rubber, 0] = new d.Contact(); |
643 | m_materialContacts[(int)Material.Rubber, 0].surface.mode |= d.ContactFlags.SoftERP; | 620 | m_materialContacts[(int)Material.Rubber, 0].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
644 | m_materialContacts[(int)Material.Rubber, 0].surface.mu = nmAvatarObjectContactFriction; | 621 | m_materialContacts[(int)Material.Rubber, 0].surface.mu = 150f; |
645 | m_materialContacts[(int)Material.Rubber, 0].surface.bounce = nmAvatarObjectContactBounce; | 622 | m_materialContacts[(int)Material.Rubber, 0].surface.bounce = 0.7f; |
646 | m_materialContacts[(int)Material.Rubber, 0].surface.soft_cfm = 0.010f; | 623 | m_materialContacts[(int)Material.Rubber, 0].surface.soft_cfm = 0.0f; |
647 | m_materialContacts[(int)Material.Rubber, 0].surface.soft_erp = 0.010f; | 624 | m_materialContacts[(int)Material.Rubber, 0].surface.soft_erp = 0.50f; |
648 | 625 | ||
649 | m_materialContacts[(int)Material.Rubber, 1] = new d.Contact(); | 626 | m_materialContacts[(int)Material.Rubber, 1] = new d.Contact(); |
650 | m_materialContacts[(int)Material.Rubber, 1].surface.mode |= d.ContactFlags.SoftERP; | 627 | m_materialContacts[(int)Material.Rubber, 1].surface.mode = d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP | d.ContactFlags.Bounce; |
651 | m_materialContacts[(int)Material.Rubber, 1].surface.mu = mAvatarObjectContactFriction; | 628 | m_materialContacts[(int)Material.Rubber, 1].surface.mu = 100f; |
652 | m_materialContacts[(int)Material.Rubber, 1].surface.bounce = mAvatarObjectContactBounce; | 629 | m_materialContacts[(int)Material.Rubber, 1].surface.bounce = 0.7f; |
653 | m_materialContacts[(int)Material.Rubber, 1].surface.soft_cfm = 0.010f; | 630 | m_materialContacts[(int)Material.Rubber, 1].surface.soft_cfm = 0.0f; |
654 | m_materialContacts[(int)Material.Rubber, 1].surface.soft_erp = 0.010f; | 631 | m_materialContacts[(int)Material.Rubber, 1].surface.soft_erp = 0.50f; |
655 | 632 | ||
656 | d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh); | 633 | d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh); |
657 | 634 | ||
@@ -660,10 +637,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
660 | d.WorldSetGravity(world, gravityx, gravityy, gravityz); | 637 | d.WorldSetGravity(world, gravityx, gravityy, gravityz); |
661 | d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); | 638 | d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); |
662 | 639 | ||
640 | |||
641 | d.WorldSetLinearDampingThreshold(world, 256f); | ||
663 | d.WorldSetLinearDamping(world, 256f); | 642 | d.WorldSetLinearDamping(world, 256f); |
664 | d.WorldSetAngularDamping(world, 256f); | 643 | // d.WorldSetLinearDampingThreshold(world, 0.01f); |
644 | // d.WorldSetLinearDamping(world, 0.1f); | ||
665 | d.WorldSetAngularDampingThreshold(world, 256f); | 645 | d.WorldSetAngularDampingThreshold(world, 256f); |
666 | d.WorldSetLinearDampingThreshold(world, 256f); | 646 | d.WorldSetAngularDamping(world, 256f); |
667 | d.WorldSetMaxAngularSpeed(world, 256f); | 647 | d.WorldSetMaxAngularSpeed(world, 256f); |
668 | 648 | ||
669 | // Set how many steps we go without running collision testing | 649 | // Set how many steps we go without running collision testing |
@@ -713,7 +693,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
713 | 693 | ||
714 | // Test if we're colliding a geom with a space. | 694 | // Test if we're colliding a geom with a space. |
715 | // If so we have to drill down into the space recursively | 695 | // If so we have to drill down into the space recursively |
716 | 696 | //Console.WriteLine("near -----------"); //## | |
717 | if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) | 697 | if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) |
718 | { | 698 | { |
719 | if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) | 699 | if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) |
@@ -819,7 +799,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
819 | if (p2.CollisionScore + count >= float.MaxValue) | 799 | if (p2.CollisionScore + count >= float.MaxValue) |
820 | p2.CollisionScore = 0; | 800 | p2.CollisionScore = 0; |
821 | p2.CollisionScore += count; | 801 | p2.CollisionScore += count; |
822 | |||
823 | for (int i = 0; i < count; i++) | 802 | for (int i = 0; i < count; i++) |
824 | { | 803 | { |
825 | d.ContactGeom curContact = contacts[i]; | 804 | d.ContactGeom curContact = contacts[i]; |
@@ -835,7 +814,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
835 | 814 | ||
836 | //m_log.Warn("[CCOUNT]: " + count); | 815 | //m_log.Warn("[CCOUNT]: " + count); |
837 | IntPtr joint; | 816 | IntPtr joint; |
838 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. | 817 | // If we're colliding with terrain, use 'TerrainContact' instead of AvatarStaticprimContact. |
839 | // allows us to have different settings | 818 | // allows us to have different settings |
840 | 819 | ||
841 | // We only need to test p2 for 'jump crouch purposes' | 820 | // We only need to test p2 for 'jump crouch purposes' |
@@ -844,9 +823,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
844 | // Testing if the collision is at the feet of the avatar | 823 | // Testing if the collision is at the feet of the avatar |
845 | 824 | ||
846 | //m_log.DebugFormat("[PHYSICS]: {0} - {1} - {2} - {3}", curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); | 825 | //m_log.DebugFormat("[PHYSICS]: {0} - {1} - {2} - {3}", curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); |
847 | if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)) | 826 | //#@ if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)) |
848 | p2.IsColliding = true; | 827 | //#@ p2.IsColliding = true; |
849 | } | 828 | if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)){ //## |
829 | p2.IsColliding = true; //## | ||
830 | }else{ | ||
831 | |||
832 | } //## | ||
833 | } | ||
850 | else | 834 | else |
851 | { | 835 | { |
852 | p2.IsColliding = true; | 836 | p2.IsColliding = true; |
@@ -881,9 +865,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
881 | //This is disabled at the moment only because it needs more tweaking | 865 | //This is disabled at the moment only because it needs more tweaking |
882 | //It will eventually be uncommented | 866 | //It will eventually be uncommented |
883 | /* | 867 | /* |
884 | if (contact.depth >= 1.00f) | 868 | if (AvatarStaticprimContact.depth >= 1.00f) |
885 | { | 869 | { |
886 | //m_log.Debug("[PHYSICS]: " + contact.depth.ToString()); | 870 | //m_log.Debug("[PHYSICS]: " + AvatarStaticprimContact.depth.ToString()); |
887 | } | 871 | } |
888 | 872 | ||
889 | //If you interpenetrate a prim with an agent | 873 | //If you interpenetrate a prim with an agent |
@@ -893,37 +877,37 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
893 | p2.PhysicsActorType == (int) ActorTypes.Prim)) | 877 | p2.PhysicsActorType == (int) ActorTypes.Prim)) |
894 | { | 878 | { |
895 | 879 | ||
896 | //contact.depth = contact.depth * 4.15f; | 880 | //AvatarStaticprimContact.depth = AvatarStaticprimContact.depth * 4.15f; |
897 | /* | 881 | /* |
898 | if (p2.PhysicsActorType == (int) ActorTypes.Agent) | 882 | if (p2.PhysicsActorType == (int) ActorTypes.Agent) |
899 | { | 883 | { |
900 | p2.CollidingObj = true; | 884 | p2.CollidingObj = true; |
901 | contact.depth = 0.003f; | 885 | AvatarStaticprimContact.depth = 0.003f; |
902 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); | 886 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); |
903 | OdeCharacter character = (OdeCharacter) p2; | 887 | OdeCharacter character = (OdeCharacter) p2; |
904 | character.SetPidStatus(true); | 888 | character.SetPidStatus(true); |
905 | contact.pos = new d.Vector3(contact.pos.X + (p1.Size.X / 2), contact.pos.Y + (p1.Size.Y / 2), contact.pos.Z + (p1.Size.Z / 2)); | 889 | AvatarStaticprimContact.pos = new d.Vector3(AvatarStaticprimContact.pos.X + (p1.Size.X / 2), AvatarStaticprimContact.pos.Y + (p1.Size.Y / 2), AvatarStaticprimContact.pos.Z + (p1.Size.Z / 2)); |
906 | 890 | ||
907 | } | 891 | } |
908 | else | 892 | else |
909 | { | 893 | { |
910 | 894 | ||
911 | //contact.depth = 0.0000000f; | 895 | //AvatarStaticprimContact.depth = 0.0000000f; |
912 | } | 896 | } |
913 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) | 897 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) |
914 | { | 898 | { |
915 | 899 | ||
916 | p1.CollidingObj = true; | 900 | p1.CollidingObj = true; |
917 | contact.depth = 0.003f; | 901 | AvatarStaticprimContact.depth = 0.003f; |
918 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); | 902 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); |
919 | contact.pos = new d.Vector3(contact.pos.X + (p2.Size.X / 2), contact.pos.Y + (p2.Size.Y / 2), contact.pos.Z + (p2.Size.Z / 2)); | 903 | AvatarStaticprimContact.pos = new d.Vector3(AvatarStaticprimContact.pos.X + (p2.Size.X / 2), AvatarStaticprimContact.pos.Y + (p2.Size.Y / 2), AvatarStaticprimContact.pos.Z + (p2.Size.Z / 2)); |
920 | OdeCharacter character = (OdeCharacter)p1; | 904 | OdeCharacter character = (OdeCharacter)p1; |
921 | character.SetPidStatus(true); | 905 | character.SetPidStatus(true); |
922 | } | 906 | } |
923 | else | 907 | else |
924 | { | 908 | { |
925 | 909 | ||
926 | //contact.depth = 0.0000000f; | 910 | //AvatarStaticprimContact.depth = 0.0000000f; |
927 | } | 911 | } |
928 | 912 | ||
929 | 913 | ||
@@ -948,7 +932,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
948 | //AddPhysicsActorTaint(p2); | 932 | //AddPhysicsActorTaint(p2); |
949 | //} | 933 | //} |
950 | 934 | ||
951 | //if (contact.depth >= 0.25f) | 935 | //if (AvatarStaticprimContact.depth >= 0.25f) |
952 | //{ | 936 | //{ |
953 | // Don't collide, one or both prim will expld. | 937 | // Don't collide, one or both prim will expld. |
954 | 938 | ||
@@ -966,13 +950,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
966 | //AddPhysicsActorTaint(p2); | 950 | //AddPhysicsActorTaint(p2); |
967 | //} | 951 | //} |
968 | 952 | ||
969 | //contact.depth = contact.depth / 8f; | 953 | //AvatarStaticprimContact.depth = AvatarStaticprimContact.depth / 8f; |
970 | //contact.normal = new d.Vector3(0, 0, 1); | 954 | //AvatarStaticprimContact.normal = new d.Vector3(0, 0, 1); |
971 | //} | 955 | //} |
972 | //if (op1.m_disabled || op2.m_disabled) | 956 | //if (op1.m_disabled || op2.m_disabled) |
973 | //{ | 957 | //{ |
974 | //Manually disabled objects stay disabled | 958 | //Manually disabled objects stay disabled |
975 | //contact.depth = 0f; | 959 | //AvatarStaticprimContact.depth = 0f; |
976 | //} | 960 | //} |
977 | #endregion | 961 | #endregion |
978 | } | 962 | } |
@@ -980,7 +964,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
980 | #endregion | 964 | #endregion |
981 | if (curContact.depth >= 1.00f) | 965 | if (curContact.depth >= 1.00f) |
982 | { | 966 | { |
983 | //m_log.Info("[P]: " + contact.depth.ToString()); | 967 | //m_log.Info("[P]: " + AvatarStaticprimContact.depth.ToString()); |
984 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent && | 968 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent && |
985 | p1.PhysicsActorType == (int) ActorTypes.Unknown) || | 969 | p1.PhysicsActorType == (int) ActorTypes.Unknown) || |
986 | (p1.PhysicsActorType == (int) ActorTypes.Agent && | 970 | (p1.PhysicsActorType == (int) ActorTypes.Agent && |
@@ -1049,14 +1033,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1049 | 1033 | ||
1050 | if (!skipThisContact) | 1034 | if (!skipThisContact) |
1051 | { | 1035 | { |
1036 | // Add contact joints with materials params---------------------------------- | ||
1037 | // p1 is what is being hit, p2 is the physical object doing the hitting | ||
1038 | int material = (int) Material.Wood; | ||
1039 | int movintYN = 0; // 1 = Sliding; 0 = static or fell onto | ||
1040 | if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f) movintYN = 1; | ||
1041 | |||
1052 | // If we're colliding against terrain | 1042 | // If we're colliding against terrain |
1053 | if (name1 == "Terrain" || name2 == "Terrain") | 1043 | if (name1 == "Terrain" || name2 == "Terrain") |
1054 | { | 1044 | { |
1055 | // If we're moving | 1045 | // If we're moving |
1056 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && | 1046 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && (movintYN == 1)) |
1057 | (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | ||
1058 | { | 1047 | { |
1059 | // Use the movement terrain contact | 1048 | //$ Av walk/run on terrain (not falling) Use the Avatar movement terrain contact |
1060 | AvatarMovementTerrainContact.geom = curContact; | 1049 | AvatarMovementTerrainContact.geom = curContact; |
1061 | _perloopContact.Add(curContact); | 1050 | _perloopContact.Add(curContact); |
1062 | if (m_global_contactcount < maxContactsbeforedeath) | 1051 | if (m_global_contactcount < maxContactsbeforedeath) |
@@ -1069,7 +1058,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1069 | { | 1058 | { |
1070 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) | 1059 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) |
1071 | { | 1060 | { |
1072 | // Use the non moving terrain contact | 1061 | //$ Av standing on terrain, Use the non moving Avata terrain contact |
1073 | TerrainContact.geom = curContact; | 1062 | TerrainContact.geom = curContact; |
1074 | _perloopContact.Add(curContact); | 1063 | _perloopContact.Add(curContact); |
1075 | if (m_global_contactcount < maxContactsbeforedeath) | 1064 | if (m_global_contactcount < maxContactsbeforedeath) |
@@ -1082,19 +1071,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1082 | { | 1071 | { |
1083 | if (p2.PhysicsActorType == (int)ActorTypes.Prim && p1.PhysicsActorType == (int)ActorTypes.Prim) | 1072 | if (p2.PhysicsActorType == (int)ActorTypes.Prim && p1.PhysicsActorType == (int)ActorTypes.Prim) |
1084 | { | 1073 | { |
1085 | // prim prim contact | 1074 | //& THIS NEVER HAPPENS? prim prim contact In terrain contact? |
1086 | // int pj294950 = 0; | 1075 | // int pj294950 = 0; |
1087 | int movintYN = 0; | ||
1088 | int material = (int) Material.Wood; | ||
1089 | // prim terrain contact | 1076 | // prim terrain contact |
1090 | if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f) | ||
1091 | { | ||
1092 | movintYN = 1; | ||
1093 | } | ||
1094 | 1077 | ||
1095 | if (p2 is OdePrim) | 1078 | if (p2 is OdePrim) |
1096 | material = ((OdePrim)p2).m_material; | 1079 | material = ((OdePrim)p2).m_material; |
1097 | |||
1098 | //m_log.DebugFormat("Material: {0}", material); | 1080 | //m_log.DebugFormat("Material: {0}", material); |
1099 | m_materialContacts[material, movintYN].geom = curContact; | 1081 | m_materialContacts[material, movintYN].geom = curContact; |
1100 | _perloopContact.Add(curContact); | 1082 | _perloopContact.Add(curContact); |
@@ -1109,38 +1091,32 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1109 | } | 1091 | } |
1110 | else | 1092 | else |
1111 | { | 1093 | { |
1112 | 1094 | //$ prim on terrain contact | |
1113 | int movintYN = 0; | ||
1114 | // prim terrain contact | ||
1115 | if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f) | ||
1116 | { | ||
1117 | movintYN = 1; | ||
1118 | } | ||
1119 | |||
1120 | int material = (int)Material.Wood; | ||
1121 | |||
1122 | if (p2 is OdePrim) | 1095 | if (p2 is OdePrim) |
1123 | material = ((OdePrim)p2).m_material; | 1096 | material = ((OdePrim)p2).m_material; |
1124 | //m_log.DebugFormat("Material: {0}", material); | 1097 | //m_log.DebugFormat("Material: {0}", material); |
1125 | m_materialContacts[material, movintYN].geom = curContact; | 1098 | m_materialContacts[material, movintYN].geom = curContact; |
1126 | _perloopContact.Add(curContact); | 1099 | _perloopContact.Add(curContact); |
1127 | 1100 | ||
1101 | ContactCopy = m_materialContacts[material, movintYN]; | ||
1102 | if(movintYN == 1) | ||
1103 | { | ||
1104 | // prevent excessive slide on terrain | ||
1105 | ContactCopy.surface.mu = m_materialContacts[material, movintYN].surface.mu * 30.0f; | ||
1106 | } | ||
1107 | |||
1128 | if (m_global_contactcount < maxContactsbeforedeath) | 1108 | if (m_global_contactcount < maxContactsbeforedeath) |
1129 | { | 1109 | { |
1130 | joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]); | 1110 | joint = d.JointCreateContact(world, contactgroup, ref ContactCopy); |
1131 | m_global_contactcount++; | 1111 | m_global_contactcount++; |
1132 | |||
1133 | } | 1112 | } |
1134 | } | 1113 | } |
1135 | } | 1114 | } |
1136 | } | 1115 | } |
1137 | //if (p2.PhysicsActorType == (int)ActorTypes.Prim) | ||
1138 | //{ | ||
1139 | //m_log.Debug("[PHYSICS]: prim contacting with ground"); | ||
1140 | //} | ||
1141 | } | 1116 | } |
1142 | else if (name1 == "Water" || name2 == "Water") | 1117 | else if (name1 == "Water" || name2 == "Water") |
1143 | { | 1118 | { |
1119 | //$ This never happens! Perhaps water is treated like air? | ||
1144 | /* | 1120 | /* |
1145 | if ((p2.PhysicsActorType == (int) ActorTypes.Prim)) | 1121 | if ((p2.PhysicsActorType == (int) ActorTypes.Prim)) |
1146 | { | 1122 | { |
@@ -1154,8 +1130,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1154 | if (curContact.depth > 0.1f) | 1130 | if (curContact.depth > 0.1f) |
1155 | { | 1131 | { |
1156 | curContact.depth *= 52; | 1132 | curContact.depth *= 52; |
1157 | //contact.normal = new d.Vector3(0, 0, 1); | 1133 | //AvatarStaticprimContact.normal = new d.Vector3(0, 0, 1); |
1158 | //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f); | 1134 | //AvatarStaticprimContact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f); |
1159 | } | 1135 | } |
1160 | WaterContact.geom = curContact; | 1136 | WaterContact.geom = curContact; |
1161 | _perloopContact.Add(curContact); | 1137 | _perloopContact.Add(curContact); |
@@ -1164,17 +1140,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1164 | joint = d.JointCreateContact(world, contactgroup, ref WaterContact); | 1140 | joint = d.JointCreateContact(world, contactgroup, ref WaterContact); |
1165 | m_global_contactcount++; | 1141 | m_global_contactcount++; |
1166 | } | 1142 | } |
1167 | //m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth); | 1143 | //m_log.Info("[PHYSICS]: Prim Water Contact" + AvatarStaticprimContact.depth); |
1168 | } | 1144 | } |
1169 | else | 1145 | else |
1170 | { | 1146 | { |
1171 | // we're colliding with prim or avatar | 1147 | |
1148 | // no terrain and no water, we're colliding with prim or avatar | ||
1172 | // check if we're moving | 1149 | // check if we're moving |
1173 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent)) | 1150 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent)) |
1174 | { | 1151 | { |
1175 | if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 1152 | //$ Avatar on Prim or other Avatar |
1153 | if (movintYN == 1) | ||
1176 | { | 1154 | { |
1177 | // Use the Movement prim contact | 1155 | // Use the AV Movement / prim contact |
1178 | AvatarMovementprimContact.geom = curContact; | 1156 | AvatarMovementprimContact.geom = curContact; |
1179 | _perloopContact.Add(curContact); | 1157 | _perloopContact.Add(curContact); |
1180 | if (m_global_contactcount < maxContactsbeforedeath) | 1158 | if (m_global_contactcount < maxContactsbeforedeath) |
@@ -1185,34 +1163,43 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1185 | } | 1163 | } |
1186 | else | 1164 | else |
1187 | { | 1165 | { |
1188 | // Use the non movement contact | 1166 | // Use the Av non movement / prim contact |
1189 | contact.geom = curContact; | 1167 | AvatarStaticprimContact.geom = curContact; |
1190 | _perloopContact.Add(curContact); | 1168 | _perloopContact.Add(curContact); |
1169 | ContactCopy = AvatarStaticprimContact; // local copy so we can change locally | ||
1191 | 1170 | ||
1192 | if (m_global_contactcount < maxContactsbeforedeath) | 1171 | if (m_global_contactcount < maxContactsbeforedeath) |
1193 | { | 1172 | { |
1194 | joint = d.JointCreateContact(world, contactgroup, ref contact); | 1173 | if (curContact.depth > 0.2) |
1174 | { // embedded, eject slowly | ||
1175 | ContactCopy.surface.soft_erp = 0.1f; | ||
1176 | ContactCopy.surface.soft_cfm = 0.1f; | ||
1177 | } | ||
1178 | else | ||
1179 | { // keep on the surface | ||
1180 | ContactCopy.surface.soft_erp = 0.3f; | ||
1181 | ContactCopy.surface.soft_cfm = 0.0f; | ||
1182 | } | ||
1183 | joint = d.JointCreateContact(world, contactgroup, ref ContactCopy); | ||
1195 | m_global_contactcount++; | 1184 | m_global_contactcount++; |
1196 | } | 1185 | } |
1197 | } | 1186 | } |
1198 | } | 1187 | } |
1199 | else if (p2.PhysicsActorType == (int)ActorTypes.Prim) | 1188 | else if (p2.PhysicsActorType == (int)ActorTypes.Prim) |
1200 | { | 1189 | { |
1190 | //$ Prim on Prim | ||
1201 | //p1.PhysicsActorType | 1191 | //p1.PhysicsActorType |
1202 | int material = (int)Material.Wood; | ||
1203 | 1192 | ||
1204 | if (p2 is OdePrim) | 1193 | if (p2 is OdePrim) material = ((OdePrim)p2).m_material; |
1205 | material = ((OdePrim)p2).m_material; | ||
1206 | |||
1207 | //m_log.DebugFormat("Material: {0}", material); | 1194 | //m_log.DebugFormat("Material: {0}", material); |
1208 | m_materialContacts[material, 0].geom = curContact; | 1195 | |
1196 | m_materialContacts[material, movintYN].geom = curContact; | ||
1209 | _perloopContact.Add(curContact); | 1197 | _perloopContact.Add(curContact); |
1210 | 1198 | ||
1211 | if (m_global_contactcount < maxContactsbeforedeath) | 1199 | if (m_global_contactcount < maxContactsbeforedeath) |
1212 | { | 1200 | { |
1213 | joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]); | 1201 | joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]); |
1214 | m_global_contactcount++; | 1202 | m_global_contactcount++; |
1215 | |||
1216 | } | 1203 | } |
1217 | } | 1204 | } |
1218 | } | 1205 | } |
@@ -1235,8 +1222,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1235 | } | 1222 | } |
1236 | //m_log.Debug(count.ToString()); | 1223 | //m_log.Debug(count.ToString()); |
1237 | //m_log.Debug("near: A collision was detected between {1} and {2}", 0, name1, name2); | 1224 | //m_log.Debug("near: A collision was detected between {1} and {2}", 0, name1, name2); |
1238 | } | 1225 | } // end for i.. loop |
1239 | } | 1226 | } // end near |
1240 | 1227 | ||
1241 | private bool checkDupe(d.ContactGeom contactGeom, int atype) | 1228 | private bool checkDupe(d.ContactGeom contactGeom, int atype) |
1242 | { | 1229 | { |
@@ -1566,7 +1553,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1566 | removeprims = new List<OdePrim>(); | 1553 | removeprims = new List<OdePrim>(); |
1567 | } | 1554 | } |
1568 | removeprims.Add(chr); | 1555 | removeprims.Add(chr); |
1569 | m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!"); | 1556 | /// Commented this because it triggers on every bullet |
1557 | //m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!"); | ||
1570 | } | 1558 | } |
1571 | } | 1559 | } |
1572 | } | 1560 | } |
@@ -1729,7 +1717,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1729 | } | 1717 | } |
1730 | 1718 | ||
1731 | private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, | 1719 | private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, |
1732 | IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) | 1720 | IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, uint localid) |
1733 | { | 1721 | { |
1734 | 1722 | ||
1735 | Vector3 pos = position; | 1723 | Vector3 pos = position; |
@@ -1739,7 +1727,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1739 | OdePrim newPrim; | 1727 | OdePrim newPrim; |
1740 | lock (OdeLock) | 1728 | lock (OdeLock) |
1741 | { | 1729 | { |
1742 | newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, ode); | 1730 | newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, ode, localid); |
1743 | 1731 | ||
1744 | lock (_prims) | 1732 | lock (_prims) |
1745 | _prims.Add(newPrim); | 1733 | _prims.Add(newPrim); |
@@ -1761,13 +1749,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1761 | } | 1749 | } |
1762 | 1750 | ||
1763 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 1751 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
1764 | Vector3 size, Quaternion rotation) //To be removed | 1752 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
1765 | { | ||
1766 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
1767 | } | ||
1768 | |||
1769 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
1770 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
1771 | { | 1753 | { |
1772 | PhysicsActor result; | 1754 | PhysicsActor result; |
1773 | IMesh mesh = null; | 1755 | IMesh mesh = null; |
@@ -1775,7 +1757,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1775 | if (needsMeshing(pbs)) | 1757 | if (needsMeshing(pbs)) |
1776 | mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); | 1758 | mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); |
1777 | 1759 | ||
1778 | result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); | 1760 | result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, localid); |
1779 | 1761 | ||
1780 | return result; | 1762 | return result; |
1781 | } | 1763 | } |
@@ -2206,6 +2188,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2206 | { | 2188 | { |
2207 | if (prim.prim_geom != IntPtr.Zero) | 2189 | if (prim.prim_geom != IntPtr.Zero) |
2208 | { | 2190 | { |
2191 | |||
2192 | //string tPA; | ||
2193 | //geom_name_map.TryGetValue(prim.prim_geom, out tPA); | ||
2194 | //Console.WriteLine("**** Remove {0}", tPA); | ||
2195 | if(geom_name_map.ContainsKey(prim.prim_geom)) geom_name_map.Remove(prim.prim_geom); | ||
2196 | if(actor_name_map.ContainsKey(prim.prim_geom)) actor_name_map.Remove(prim.prim_geom); | ||
2209 | d.GeomDestroy(prim.prim_geom); | 2197 | d.GeomDestroy(prim.prim_geom); |
2210 | prim.prim_geom = IntPtr.Zero; | 2198 | prim.prim_geom = IntPtr.Zero; |
2211 | } | 2199 | } |