aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs5
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs12
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs19
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs39
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs59
5 files changed, 69 insertions, 65 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index f525e9e..25aa4dc 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -158,9 +158,10 @@ namespace OpenSim.Region.Physics.Manager
158 158
159 public virtual bool Building { get; set; } 159 public virtual bool Building { get; set; }
160 160
161 public virtual ContactData ContactData 161 public virtual void getContactData(ref ContactData cdata)
162 { 162 {
163 get { return new ContactData(0, 0); } 163 cdata.mu = 0;
164 cdata.bounce = 0;
164 } 165 }
165 166
166 public abstract bool Stopped { get; } 167 public abstract bool Stopped { get; }
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 793e281..94cadb2 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -136,7 +136,8 @@ namespace OpenSim.Region.Physics.OdePlugin
136 public UUID m_uuid; 136 public UUID m_uuid;
137 public bool bad = false; 137 public bool bad = false;
138 138
139 public ContactData AvatarContactData = new ContactData(10f, 0.3f); 139 float mu;
140 float bounce;
140 141
141 public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor) 142 public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
142 { 143 {
@@ -168,8 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
168 m_density = density; 169 m_density = density;
169 m_mass = 80f; // sure we have a default 170 m_mass = 80f; // sure we have a default
170 171
171 AvatarContactData.mu = parent_scene.AvatarFriction; 172 mu = parent_scene.AvatarFriction;
172 AvatarContactData.bounce = parent_scene.AvatarBounce; 173 bounce = parent_scene.AvatarBounce;
173 174
174 walkDivisor = walk_divisor; 175 walkDivisor = walk_divisor;
175 runDivisor = rundivisor; 176 runDivisor = rundivisor;
@@ -190,9 +191,10 @@ namespace OpenSim.Region.Physics.OdePlugin
190 set { return; } 191 set { return; }
191 } 192 }
192 193
193 public override ContactData ContactData 194 public override void getContactData(ref ContactData cdata)
194 { 195 {
195 get { return AvatarContactData; } 196 cdata.mu = mu;
197 cdata.bounce = bounce;
196 } 198 }
197 199
198 public override bool Building { get; set; } 200 public override bool Building { get; set; }
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index 0fabb56..d0b4546 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -119,25 +119,22 @@ namespace OpenSim.Region.Physics.OdePlugin
119 // auxiliar 119 // auxiliar
120 private float m_lmEfect = 0; // current linear motor eficiency 120 private float m_lmEfect = 0; // current linear motor eficiency
121 private float m_amEfect = 0; // current angular motor eficiency 121 private float m_amEfect = 0; // current angular motor eficiency
122 private float m_ffactor = 1.0f;
122 123
123 public bool EngineActive 124 public float FrictionFactor
124 { 125 {
125 get 126 get
126 { 127 {
127 if (m_lmEfect > 0.01) 128 return m_ffactor;
128 return true;
129 return false;
130 } 129 }
131 } 130 }
132 131
133
134 public ODEDynamics(OdePrim rootp) 132 public ODEDynamics(OdePrim rootp)
135 { 133 {
136 rootPrim = rootp; 134 rootPrim = rootp;
137 _pParentScene = rootPrim._parent_scene; 135 _pParentScene = rootPrim._parent_scene;
138 } 136 }
139 137
140
141 public void DoSetVehicle(VehicleData vd) 138 public void DoSetVehicle(VehicleData vd)
142 { 139 {
143 140
@@ -212,6 +209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
212 209
213 m_lmEfect = 0; 210 m_lmEfect = 0;
214 m_amEfect = 0; 211 m_amEfect = 0;
212 m_ffactor = 1.0f;
215 } 213 }
216 214
217 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) 215 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
@@ -329,6 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin
329 if (len > 30.0f) 327 if (len > 30.0f)
330 m_linearMotorDirection *= (30.0f / len); 328 m_linearMotorDirection *= (30.0f / len);
331 m_lmEfect = 1.0f; // turn it on 329 m_lmEfect = 1.0f; // turn it on
330 m_ffactor = 0.01f;
332 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 331 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
333 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 332 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
334 d.BodyEnable(rootPrim.Body); 333 d.BodyEnable(rootPrim.Body);
@@ -379,6 +378,7 @@ namespace OpenSim.Region.Physics.OdePlugin
379 if (len > 30.0f) 378 if (len > 30.0f)
380 m_linearMotorDirection *= (30.0f / len); 379 m_linearMotorDirection *= (30.0f / len);
381 m_lmEfect = 1.0f; // turn it on 380 m_lmEfect = 1.0f; // turn it on
381 m_ffactor = 0.01f;
382 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 382 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
383 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 383 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
384 d.BodyEnable(rootPrim.Body); 384 d.BodyEnable(rootPrim.Body);
@@ -425,6 +425,7 @@ namespace OpenSim.Region.Physics.OdePlugin
425 float invtimestep = _pParentScene.ODE_STEPSIZE; 425 float invtimestep = _pParentScene.ODE_STEPSIZE;
426 m_lmEfect = 0; 426 m_lmEfect = 0;
427 m_amEfect = 0; 427 m_amEfect = 0;
428 m_ffactor = 1f;
428 429
429 m_linearMotorDirection = Vector3.Zero; 430 m_linearMotorDirection = Vector3.Zero;
430 m_angularMotorDirection = Vector3.Zero; 431 m_angularMotorDirection = Vector3.Zero;
@@ -602,6 +603,7 @@ namespace OpenSim.Region.Physics.OdePlugin
602 { 603 {
603 m_lmEfect = 0; 604 m_lmEfect = 0;
604 m_amEfect = 0; 605 m_amEfect = 0;
606 m_ffactor = 1f;
605 } 607 }
606 608
607 public static Vector3 Xrot(Quaternion rot) 609 public static Vector3 Xrot(Quaternion rot)
@@ -752,9 +754,14 @@ namespace OpenSim.Region.Physics.OdePlugin
752 force.Z += tmpV.Z; 754 force.Z += tmpV.Z;
753 } 755 }
754 m_lmEfect *= (1.0f - 1.0f / m_linearMotorDecayTimescale); 756 m_lmEfect *= (1.0f - 1.0f / m_linearMotorDecayTimescale);
757
758 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
755 } 759 }
756 else 760 else
761 {
757 m_lmEfect = 0; 762 m_lmEfect = 0;
763 m_ffactor = 1f;
764 }
758 765
759 // friction 766 // friction
760 if (curLocalVel.X != 0 || curLocalVel.Y != 0 || curLocalVel.Z != 0) 767 if (curLocalVel.X != 0 || curLocalVel.Y != 0 || curLocalVel.Z != 0)
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index e5fa1d7..db07565 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -187,7 +187,8 @@ namespace OpenSim.Region.Physics.OdePlugin
187 public ODEDynamics m_vehicle; 187 public ODEDynamics m_vehicle;
188 188
189 internal int m_material = (int)Material.Wood; 189 internal int m_material = (int)Material.Wood;
190 protected ContactData primContactData = new ContactData { mu = 0f, bounce = 0.1f }; 190 private float mu;
191 private float bounce;
191 192
192 /// <summary> 193 /// <summary>
193 /// Is this prim subject to physics? Even if not, it's still solid for collision purposes. 194 /// Is this prim subject to physics? Even if not, it's still solid for collision purposes.
@@ -218,25 +219,23 @@ namespace OpenSim.Region.Physics.OdePlugin
218 } 219 }
219 } 220 }
220 221
221 public override ContactData ContactData 222 public override void getContactData(ref ContactData cdata)
222 { 223 {
223 get 224 cdata.mu = mu;
225 cdata.bounce = bounce;
226
227 if (m_isphysical)
224 { 228 {
225 if (m_isphysical) 229 ODEDynamics veh;
226 { 230 if (_parent != null)
227 ODEDynamics veh; 231 veh = ((OdePrim)_parent).m_vehicle;
228 if (_parent != null) 232 else
229 veh = ((OdePrim)_parent).m_vehicle; 233 veh = m_vehicle;
230 else
231 veh = m_vehicle;
232 234
233 if (veh != null) 235 if (veh != null && veh.Type != Vehicle.TYPE_NONE)
234 if (veh.Type != Vehicle.TYPE_NONE && veh.EngineActive) 236 cdata.mu *= veh.FrictionFactor;
235 return new ContactData(0, 0);
236 }
237 return primContactData;
238 } 237 }
239 } 238 }
240 239
241 public override int PhysicsActorType 240 public override int PhysicsActorType
242 { 241 {
@@ -745,8 +744,8 @@ namespace OpenSim.Region.Physics.OdePlugin
745 public override void SetMaterial(int pMaterial) 744 public override void SetMaterial(int pMaterial)
746 { 745 {
747 m_material = pMaterial; 746 m_material = pMaterial;
748 primContactData.mu = _parent_scene.m_materialContactsData[pMaterial].mu; 747 mu = _parent_scene.m_materialContactsData[pMaterial].mu;
749 primContactData.bounce = _parent_scene.m_materialContactsData[pMaterial].bounce; 748 bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
750 } 749 }
751 750
752 public void setPrimForRemoval() 751 public void setPrimForRemoval()
@@ -899,8 +898,8 @@ namespace OpenSim.Region.Physics.OdePlugin
899 m_isSelected = false; 898 m_isSelected = false;
900 m_delaySelect = false; 899 m_delaySelect = false;
901 900
902 primContactData.mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu; 901 mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu;
903 primContactData.bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; 902 bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce;
904 903
905 CalcPrimBodyData(); 904 CalcPrimBodyData();
906 905
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 129db5d..884a5a7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -163,8 +163,6 @@ namespace OpenSim.Region.Physics.OdePlugin
163 const float comumSoftContactERP = 0.1f; 163 const float comumSoftContactERP = 0.1f;
164 const float comumContactCFM = 0.0001f; 164 const float comumContactCFM = 0.0001f;
165 165
166 float frictionScale = 1.0f;
167
168 float frictionMovementMult = 0.3f; 166 float frictionMovementMult = 0.3f;
169 167
170 float TerrainBounce = 0.1f; 168 float TerrainBounce = 0.1f;
@@ -450,33 +448,30 @@ namespace OpenSim.Region.Physics.OdePlugin
450 ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); 448 ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
451 GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); 449 GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
452 450
453 m_materialContactsData[(int)Material.Stone].mu = frictionScale * 0.8f; 451 m_materialContactsData[(int)Material.Stone].mu = 0.8f;
454 m_materialContactsData[(int)Material.Stone].bounce = 0.4f; 452 m_materialContactsData[(int)Material.Stone].bounce = 0.4f;
455 453
456 m_materialContactsData[(int)Material.Metal].mu = frictionScale * 0.3f; 454 m_materialContactsData[(int)Material.Metal].mu = 0.3f;
457 m_materialContactsData[(int)Material.Metal].bounce = 0.4f; 455 m_materialContactsData[(int)Material.Metal].bounce = 0.4f;
458 456
459 m_materialContactsData[(int)Material.Glass].mu = frictionScale * 0.2f; 457 m_materialContactsData[(int)Material.Glass].mu = 0.2f;
460 m_materialContactsData[(int)Material.Glass].bounce = 0.7f; 458 m_materialContactsData[(int)Material.Glass].bounce = 0.7f;
461 459
462 m_materialContactsData[(int)Material.Wood].mu = frictionScale * 0.6f; 460 m_materialContactsData[(int)Material.Wood].mu = 0.6f;
463 m_materialContactsData[(int)Material.Wood].bounce = 0.5f; 461 m_materialContactsData[(int)Material.Wood].bounce = 0.5f;
464 462
465 m_materialContactsData[(int)Material.Flesh].mu = frictionScale * 0.9f; 463 m_materialContactsData[(int)Material.Flesh].mu = 0.9f;
466 m_materialContactsData[(int)Material.Flesh].bounce = 0.3f; 464 m_materialContactsData[(int)Material.Flesh].bounce = 0.3f;
467 465
468 m_materialContactsData[(int)Material.Plastic].mu = frictionScale * 0.4f; 466 m_materialContactsData[(int)Material.Plastic].mu = 0.4f;
469 m_materialContactsData[(int)Material.Plastic].bounce = 0.7f; 467 m_materialContactsData[(int)Material.Plastic].bounce = 0.7f;
470 468
471 m_materialContactsData[(int)Material.Rubber].mu = frictionScale * 0.9f; 469 m_materialContactsData[(int)Material.Rubber].mu = 0.9f;
472 m_materialContactsData[(int)Material.Rubber].bounce = 0.95f; 470 m_materialContactsData[(int)Material.Rubber].bounce = 0.95f;
473 471
474 m_materialContactsData[(int)Material.light].mu = 0.0f; 472 m_materialContactsData[(int)Material.light].mu = 0.0f;
475 m_materialContactsData[(int)Material.light].bounce = 0.0f; 473 m_materialContactsData[(int)Material.light].bounce = 0.0f;
476 474
477 TerrainFriction *= frictionScale;
478// AvatarFriction *= frictionScale;
479
480 // Set the gravity,, don't disable things automatically (we set it explicitly on some things) 475 // Set the gravity,, don't disable things automatically (we set it explicitly on some things)
481 476
482 d.WorldSetGravity(world, gravityx, gravityy, gravityz); 477 d.WorldSetGravity(world, gravityx, gravityy, gravityz);
@@ -562,13 +557,6 @@ namespace OpenSim.Region.Physics.OdePlugin
562 } 557 }
563 558
564 559
565 /// <summary>
566 /// This is our near callback. A geometry is near a body
567 /// </summary>
568 /// <param name="space">The space that contains the geoms. Remember, spaces are also geoms</param>
569 /// <param name="g1">a geometry or space</param>
570 /// <param name="g2">another geometry or space</param>
571 ///
572 560
573 private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) 561 private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom)
574 { 562 {
@@ -580,7 +568,13 @@ namespace OpenSim.Region.Physics.OdePlugin
580 return true; 568 return true;
581 } 569 }
582 570
583 571 /// <summary>
572 /// This is our near callback. A geometry is near a body
573 /// </summary>
574 /// <param name="space">The space that contains the geoms. Remember, spaces are also geoms</param>
575 /// <param name="g1">a geometry or space</param>
576 /// <param name="g2">another geometry or space</param>
577 ///
584 578
585 private void near(IntPtr space, IntPtr g1, IntPtr g2) 579 private void near(IntPtr space, IntPtr g1, IntPtr g2)
586 { 580 {
@@ -699,8 +693,8 @@ namespace OpenSim.Region.Physics.OdePlugin
699 // big messy collision analises 693 // big messy collision analises
700 float mu = 0; 694 float mu = 0;
701 float bounce = 0; 695 float bounce = 0;
702 ContactData contactdata1; 696 ContactData contactdata1 = new ContactData(0, 0);
703 ContactData contactdata2; 697 ContactData contactdata2 = new ContactData(0, 0);
704 bool erpSoft = false; 698 bool erpSoft = false;
705 699
706 String name = null; 700 String name = null;
@@ -714,8 +708,9 @@ namespace OpenSim.Region.Physics.OdePlugin
714 switch (p2.PhysicsActorType) 708 switch (p2.PhysicsActorType)
715 { 709 {
716 case (int)ActorTypes.Agent: 710 case (int)ActorTypes.Agent:
717 contactdata1 = p1.ContactData; 711 p1.getContactData(ref contactdata1);
718 contactdata2 = p2.ContactData; 712 p2.getContactData(ref contactdata2);
713
719 bounce = contactdata1.bounce * contactdata2.bounce; 714 bounce = contactdata1.bounce * contactdata2.bounce;
720 715
721 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); 716 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@@ -727,8 +722,8 @@ namespace OpenSim.Region.Physics.OdePlugin
727 p2.CollidingObj = true; 722 p2.CollidingObj = true;
728 break; 723 break;
729 case (int)ActorTypes.Prim: 724 case (int)ActorTypes.Prim:
730 contactdata1 = p1.ContactData; 725 p1.getContactData(ref contactdata1);
731 contactdata2 = p2.ContactData; 726 p2.getContactData(ref contactdata2);
732 bounce = contactdata1.bounce * contactdata2.bounce; 727 bounce = contactdata1.bounce * contactdata2.bounce;
733 728
734 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); 729 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@@ -749,8 +744,8 @@ namespace OpenSim.Region.Physics.OdePlugin
749 switch (p2.PhysicsActorType) 744 switch (p2.PhysicsActorType)
750 { 745 {
751 case (int)ActorTypes.Agent: 746 case (int)ActorTypes.Agent:
752 contactdata1 = p1.ContactData; 747 p1.getContactData(ref contactdata1);
753 contactdata2 = p2.ContactData; 748 p2.getContactData(ref contactdata2);
754 bounce = contactdata1.bounce * contactdata2.bounce; 749 bounce = contactdata1.bounce * contactdata2.bounce;
755 750
756 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); 751 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@@ -768,8 +763,8 @@ namespace OpenSim.Region.Physics.OdePlugin
768 p1.CollidingObj = true; 763 p1.CollidingObj = true;
769 p2.CollidingObj = true; 764 p2.CollidingObj = true;
770 } 765 }
771 contactdata1 = p1.ContactData; 766 p1.getContactData(ref contactdata1);
772 contactdata2 = p2.ContactData; 767 p2.getContactData(ref contactdata2);
773 bounce = contactdata1.bounce * contactdata2.bounce; 768 bounce = contactdata1.bounce * contactdata2.bounce;
774 erpSoft = true; 769 erpSoft = true;
775 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); 770 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@@ -784,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin
784 if (name == "Terrain") 779 if (name == "Terrain")
785 { 780 {
786 erpSoft = true; 781 erpSoft = true;
787 contactdata1 = p1.ContactData; 782 p1.getContactData(ref contactdata1);
788 bounce = contactdata1.bounce * TerrainBounce; 783 bounce = contactdata1.bounce * TerrainBounce;
789 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); 784 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
790 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) 785 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
@@ -811,7 +806,7 @@ namespace OpenSim.Region.Physics.OdePlugin
811 { 806 {
812 erpSoft = true; 807 erpSoft = true;
813 p2.CollidingGround = true; 808 p2.CollidingGround = true;
814 contactdata2 = p2.ContactData; 809 p2.getContactData(ref contactdata2);
815 bounce = contactdata2.bounce * TerrainBounce; 810 bounce = contactdata2.bounce * TerrainBounce;
816 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); 811 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
817 812