aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs131
1 files changed, 79 insertions, 52 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 76d7746..1a6907d 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -160,8 +160,8 @@ namespace OpenSim.Region.Physics.OdePlugin
160 private Random fluidRandomizer = new Random(Environment.TickCount); 160 private Random fluidRandomizer = new Random(Environment.TickCount);
161 161
162 const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; 162 const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
163 const float comumContactERP = 0.6f; 163 const float MaxERP = 0.8f;
164 const float comumSoftContactERP = 0.1f; 164 const float minERP = 0.1f;
165 const float comumContactCFM = 0.0001f; 165 const float comumContactCFM = 0.0001f;
166 166
167 float frictionMovementMult = 0.3f; 167 float frictionMovementMult = 0.3f;
@@ -169,7 +169,6 @@ namespace OpenSim.Region.Physics.OdePlugin
169 float TerrainBounce = 0.1f; 169 float TerrainBounce = 0.1f;
170 float TerrainFriction = 0.3f; 170 float TerrainFriction = 0.3f;
171 171
172 public float AvatarBounce = 0.3f;
173 public float AvatarFriction = 0;// 0.9f * 0.5f; 172 public float AvatarFriction = 0;// 0.9f * 0.5f;
174 173
175 private const uint m_regionWidth = Constants.RegionSize; 174 private const uint m_regionWidth = Constants.RegionSize;
@@ -528,7 +527,7 @@ namespace OpenSim.Region.Physics.OdePlugin
528 527
529 // sets a global contact for a joint for contactgeom , and base contact description) 528 // sets a global contact for a joint for contactgeom , and base contact description)
530 529
531 private IntPtr CreateContacJoint(ref d.ContactGeom contactGeom, float mu, float bounce, bool softerp) 530 private IntPtr CreateContacJoint(ref d.ContactGeom contactGeom, float mu, float bounce,float cfm,float erp)
532 { 531 {
533 if (GlobalContactsArray == IntPtr.Zero || m_global_contactcount >= maxContactsbeforedeath) 532 if (GlobalContactsArray == IntPtr.Zero || m_global_contactcount >= maxContactsbeforedeath)
534 return IntPtr.Zero; 533 return IntPtr.Zero;
@@ -546,11 +545,8 @@ namespace OpenSim.Region.Physics.OdePlugin
546 newcontact.surface.mode = comumContactFlags; 545 newcontact.surface.mode = comumContactFlags;
547 newcontact.surface.mu = mu; 546 newcontact.surface.mu = mu;
548 newcontact.surface.bounce = bounce; 547 newcontact.surface.bounce = bounce;
549 newcontact.surface.soft_cfm = comumContactCFM; 548 newcontact.surface.soft_cfm = cfm;
550 if (softerp) 549 newcontact.surface.soft_erp = erp;
551 newcontact.surface.soft_erp = comumSoftContactERP;
552 else
553 newcontact.surface.soft_erp = comumContactERP;
554 550
555 IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * d.Contact.unmanagedSizeOf)); 551 IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * d.Contact.unmanagedSizeOf));
556 Marshal.StructureToPtr(newcontact, contact, true); 552 Marshal.StructureToPtr(newcontact, contact, true);
@@ -694,9 +690,11 @@ namespace OpenSim.Region.Physics.OdePlugin
694 // big messy collision analises 690 // big messy collision analises
695 float mu = 0; 691 float mu = 0;
696 float bounce = 0; 692 float bounce = 0;
693 float cfm = 0.0001f;
694 float erp = 0.1f;
695
697 ContactData contactdata1 = new ContactData(0, 0, false); 696 ContactData contactdata1 = new ContactData(0, 0, false);
698 ContactData contactdata2 = new ContactData(0, 0, false); 697 ContactData contactdata2 = new ContactData(0, 0, false);
699 bool erpSoft = false;
700 698
701 String name = null; 699 String name = null;
702 bool dop1foot = false; 700 bool dop1foot = false;
@@ -706,59 +704,65 @@ namespace OpenSim.Region.Physics.OdePlugin
706 switch (p1.PhysicsActorType) 704 switch (p1.PhysicsActorType)
707 { 705 {
708 case (int)ActorTypes.Agent: 706 case (int)ActorTypes.Agent:
709 switch (p2.PhysicsActorType)
710 { 707 {
711 case (int)ActorTypes.Agent: 708 bounce = 0;
712 p1.getContactData(ref contactdata1); 709 mu = 0;
713 p2.getContactData(ref contactdata2); 710 cfm = 0.0001f;
714
715 bounce = contactdata1.bounce * contactdata2.bounce;
716
717 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
718 711
719 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) 712 switch (p2.PhysicsActorType)
720 mu *= frictionMovementMult; 713 {
714 case (int)ActorTypes.Agent:
715/*
716 p1.getContactData(ref contactdata1);
717 p2.getContactData(ref contactdata2);
721 718
722 erpSoft = contactdata1.softcolide | contactdata2.softcolide; 719 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
723 p1.CollidingObj = true;
724 p2.CollidingObj = true;
725 break;
726 case (int)ActorTypes.Prim:
727 p1.getContactData(ref contactdata1);
728 p2.getContactData(ref contactdata2);
729 bounce = contactdata1.bounce * contactdata2.bounce;
730
731 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
732 720
733 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) 721 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
734 mu *= frictionMovementMult; 722 mu *= frictionMovementMult;
735 if (p2.Velocity.LengthSquared() > 0.0f) 723*/
724 p1.CollidingObj = true;
736 p2.CollidingObj = true; 725 p2.CollidingObj = true;
726 break;
727 case (int)ActorTypes.Prim:
728/*
729 p1.getContactData(ref contactdata1);
730 p2.getContactData(ref contactdata2);
737 731
738 erpSoft = contactdata1.softcolide | contactdata2.softcolide;
739 732
740 dop1foot = true; 733 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
741 break; 734
742 default: 735 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
743 ignore=true; // avatar to terrain and water ignored 736 mu *= frictionMovementMult;
744 break; 737 */
738 if (p2.Velocity.LengthSquared() > 0.0f)
739 p2.CollidingObj = true;
740
741 dop1foot = true;
742 break;
743 default:
744 ignore = true; // avatar to terrain and water ignored
745 break;
746 }
747 break;
745 } 748 }
746 break;
747 749
748 case (int)ActorTypes.Prim: 750 case (int)ActorTypes.Prim:
749 switch (p2.PhysicsActorType) 751 switch (p2.PhysicsActorType)
750 { 752 {
751 case (int)ActorTypes.Agent: 753 case (int)ActorTypes.Agent:
752 p1.getContactData(ref contactdata1); 754// p1.getContactData(ref contactdata1);
753 p2.getContactData(ref contactdata2); 755// p2.getContactData(ref contactdata2);
754 bounce = contactdata1.bounce * contactdata2.bounce; 756
755 757 bounce = 0;
758 mu = 0;
759 cfm = 0.0001f;
760/*
756 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); 761 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
757 762
758 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) 763 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
759 mu *= frictionMovementMult; 764 mu *= frictionMovementMult;
760 765*/
761 erpSoft = contactdata1.softcolide | contactdata2.softcolide;
762 dop2foot = true; 766 dop2foot = true;
763 if (p1.Velocity.LengthSquared() > 0.0f) 767 if (p1.Velocity.LengthSquared() > 0.0f)
764 p1.CollidingObj = true; 768 p1.CollidingObj = true;
@@ -772,9 +776,16 @@ namespace OpenSim.Region.Physics.OdePlugin
772 p1.getContactData(ref contactdata1); 776 p1.getContactData(ref contactdata1);
773 p2.getContactData(ref contactdata2); 777 p2.getContactData(ref contactdata2);
774 bounce = contactdata1.bounce * contactdata2.bounce; 778 bounce = contactdata1.bounce * contactdata2.bounce;
775 erpSoft = contactdata1.softcolide | contactdata2.softcolide;
776 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); 779 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
777 780
781 cfm = p1.Mass;
782 if (cfm > p2.Mass)
783 cfm = p2.Mass;
784 cfm = (float)Math.Sqrt(cfm);
785 cfm *= 0.0001f;
786 if (cfm > 0.8f)
787 cfm = 0.8f;
788
778 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) 789 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
779 mu *= frictionMovementMult; 790 mu *= frictionMovementMult;
780 791
@@ -789,12 +800,17 @@ namespace OpenSim.Region.Physics.OdePlugin
789 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); 800 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
790 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) 801 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
791 mu *= frictionMovementMult; 802 mu *= frictionMovementMult;
792 erpSoft = contactdata1.softcolide;
793 p1.CollidingGround = true; 803 p1.CollidingGround = true;
804 cfm = p1.Mass;
805 cfm = (float)Math.Sqrt(cfm);
806 cfm *= 0.0001f;
807 if (cfm > 0.8f)
808 cfm = 0.8f;
809
794 } 810 }
795 else if (name == "Water") 811 else if (name == "Water")
796 { 812 {
797 erpSoft = true; 813 ignore = true;
798 } 814 }
799 } 815 }
800 else 816 else
@@ -814,7 +830,11 @@ namespace OpenSim.Region.Physics.OdePlugin
814 p2.getContactData(ref contactdata2); 830 p2.getContactData(ref contactdata2);
815 bounce = contactdata2.bounce * TerrainBounce; 831 bounce = contactdata2.bounce * TerrainBounce;
816 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); 832 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
817 erpSoft = contactdata2.softcolide; 833 cfm = p2.Mass;
834 cfm = (float)Math.Sqrt(cfm);
835 cfm *= 0.0001f;
836 if (cfm > 0.8f)
837 cfm = 0.8f;
818 838
819 if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) 839 if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
820 mu *= frictionMovementMult; 840 mu *= frictionMovementMult;
@@ -826,7 +846,7 @@ namespace OpenSim.Region.Physics.OdePlugin
826 else if (name == "Water" && 846 else if (name == "Water" &&
827 (p2.PhysicsActorType == (int)ActorTypes.Prim || p2.PhysicsActorType == (int)ActorTypes.Agent)) 847 (p2.PhysicsActorType == (int)ActorTypes.Prim || p2.PhysicsActorType == (int)ActorTypes.Agent))
828 { 848 {
829 erpSoft = true; 849 ignore = true;
830 } 850 }
831 } 851 }
832 else 852 else
@@ -847,7 +867,14 @@ namespace OpenSim.Region.Physics.OdePlugin
847 if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f) 867 if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f)
848 p2.IsColliding = true; 868 p2.IsColliding = true;
849 869
850 Joint = CreateContacJoint(ref curContact, mu, bounce, erpSoft); 870
871 erp = curContact.depth;
872 if (erp < minERP)
873 erp = minERP;
874 else if (erp > MaxERP)
875 erp = MaxERP;
876
877 Joint = CreateContacJoint(ref curContact, mu, bounce,cfm,erp);
851 d.JointAttach(Joint, b1, b2); 878 d.JointAttach(Joint, b1, b2);
852 879
853 if (++m_global_contactcount >= maxContactsbeforedeath) 880 if (++m_global_contactcount >= maxContactsbeforedeath)