aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs70
1 files changed, 34 insertions, 36 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
index 9cef3d5..de7e879 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
@@ -138,7 +138,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
138 ); 138 );
139 // we do land collisions not ode | CollisionCategories.Land); 139 // we do land collisions not ode | CollisionCategories.Land);
140 public IntPtr Body = IntPtr.Zero; 140 public IntPtr Body = IntPtr.Zero;
141 private ODEScene _parent_scene; 141 private ODEScene m_parent_scene;
142 private IntPtr capsule = IntPtr.Zero; 142 private IntPtr capsule = IntPtr.Zero;
143 public IntPtr collider = IntPtr.Zero; 143 public IntPtr collider = IntPtr.Zero;
144 144
@@ -169,6 +169,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
169 { 169 {
170 m_uuid = UUID.Random(); 170 m_uuid = UUID.Random();
171 m_localID = localID; 171 m_localID = localID;
172 m_parent_scene = parent_scene;
172 173
173 timeStep = parent_scene.ODE_STEPSIZE; 174 timeStep = parent_scene.ODE_STEPSIZE;
174 invtimeStep = 1 / timeStep; 175 invtimeStep = 1 / timeStep;
@@ -187,13 +188,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
187 } 188 }
188 else 189 else
189 { 190 {
190 _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f); 191 _position = new Vector3(((float)m_parent_scene.WorldExtents.X * 0.5f), ((float)m_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
191 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); 192 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
192 } 193 }
193 194
194 _parent_scene = parent_scene;
195
196
197 m_size.X = pSize.X; 195 m_size.X = pSize.X;
198 m_size.Y = pSize.Y; 196 m_size.Y = pSize.Y;
199 m_size.Z = pSize.Z; 197 m_size.Z = pSize.Z;
@@ -213,7 +211,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
213 // force lower density for testing 211 // force lower density for testing
214 m_density = 3.0f; 212 m_density = 3.0f;
215 213
216 mu = parent_scene.AvatarFriction; 214 mu = m_parent_scene.AvatarFriction;
217 215
218 walkDivisor = walk_divisor; 216 walkDivisor = walk_divisor;
219 runDivisor = rundivisor; 217 runDivisor = rundivisor;
@@ -437,11 +435,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
437 { 435 {
438 if (value.Z > 9999999f) 436 if (value.Z > 9999999f)
439 { 437 {
440 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 438 value.Z = m_parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
441 } 439 }
442 if (value.Z < -100f) 440 if (value.Z < -100f)
443 { 441 {
444 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 442 value.Z = m_parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
445 } 443 }
446 AddChange(changes.Position, value); 444 AddChange(changes.Position, value);
447 } 445 }
@@ -704,7 +702,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
704 { 702 {
705 if (pushforce) 703 if (pushforce)
706 { 704 {
707 AddChange(changes.Force, force * m_density / (_parent_scene.ODE_STEPSIZE * 28f)); 705 AddChange(changes.Force, force * m_density / (m_parent_scene.ODE_STEPSIZE * 28f));
708 } 706 }
709 else 707 else
710 { 708 {
@@ -751,9 +749,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
751 AvaAvaSizeYsq = 0.5f * sy; 749 AvaAvaSizeYsq = 0.5f * sy;
752 AvaAvaSizeYsq *= AvaAvaSizeYsq; 750 AvaAvaSizeYsq *= AvaAvaSizeYsq;
753 751
754 _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); 752 m_parent_scene.waitForSpaceUnlock(m_parent_scene.CharsSpace);
755 753
756 collider = d.HashSpaceCreate(_parent_scene.CharsSpace); 754 collider = d.HashSpaceCreate(m_parent_scene.CharsSpace);
757 d.HashSpaceSetLevels(collider, -4, 3); 755 d.HashSpaceSetLevels(collider, -4, 3);
758 d.SpaceSetSublevel(collider, 3); 756 d.SpaceSetSublevel(collider, 3);
759 d.SpaceSetCleanup(collider, false); 757 d.SpaceSetCleanup(collider, false);
@@ -772,10 +770,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
772 770
773 d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z); 771 d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z);
774 772
775 PID_D = basePID_D * m_mass / _parent_scene.ODE_STEPSIZE; 773 PID_D = basePID_D * m_mass / m_parent_scene.ODE_STEPSIZE;
776 PID_P = basePID_P * m_mass / _parent_scene.ODE_STEPSIZE; 774 PID_P = basePID_P * m_mass / m_parent_scene.ODE_STEPSIZE;
777 775
778 Body = d.BodyCreate(_parent_scene.world); 776 Body = d.BodyCreate(m_parent_scene.world);
779 777
780 _zeroFlag = false; 778 _zeroFlag = false;
781 m_pidControllerActive = true; 779 m_pidControllerActive = true;
@@ -795,7 +793,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
795 793
796 // The purpose of the AMotor here is to keep the avatar's physical 794 // The purpose of the AMotor here is to keep the avatar's physical
797 // surrogate from rotating while moving 795 // surrogate from rotating while moving
798 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); 796 Amotor = d.JointCreateAMotor(m_parent_scene.world, IntPtr.Zero);
799 d.JointAttach(Amotor, Body, IntPtr.Zero); 797 d.JointAttach(Amotor, Body, IntPtr.Zero);
800 798
801 d.JointSetAMotorMode(Amotor, 0); 799 d.JointSetAMotorMode(Amotor, 0);
@@ -854,8 +852,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
854 //kill the Geoms 852 //kill the Geoms
855 if (capsule != IntPtr.Zero) 853 if (capsule != IntPtr.Zero)
856 { 854 {
857 _parent_scene.actor_name_map.Remove(capsule); 855 m_parent_scene.actor_name_map.Remove(capsule);
858 _parent_scene.waitForSpaceUnlock(collider); 856 m_parent_scene.waitForSpaceUnlock(collider);
859 d.GeomDestroy(capsule); 857 d.GeomDestroy(capsule);
860 capsule = IntPtr.Zero; 858 capsule = IntPtr.Zero;
861 } 859 }
@@ -1049,20 +1047,20 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1049 fixbody = true; 1047 fixbody = true;
1050 localpos.X = 0.1f; 1048 localpos.X = 0.1f;
1051 } 1049 }
1052 else if (localpos.X > _parent_scene.WorldExtents.X - 0.1f) 1050 else if (localpos.X > m_parent_scene.WorldExtents.X - 0.1f)
1053 { 1051 {
1054 fixbody = true; 1052 fixbody = true;
1055 localpos.X = _parent_scene.WorldExtents.X - 0.1f; 1053 localpos.X = m_parent_scene.WorldExtents.X - 0.1f;
1056 } 1054 }
1057 if (localpos.Y < 0.0f) 1055 if (localpos.Y < 0.0f)
1058 { 1056 {
1059 fixbody = true; 1057 fixbody = true;
1060 localpos.Y = 0.1f; 1058 localpos.Y = 0.1f;
1061 } 1059 }
1062 else if (localpos.Y > _parent_scene.WorldExtents.Y - 0.1) 1060 else if (localpos.Y > m_parent_scene.WorldExtents.Y - 0.1)
1063 { 1061 {
1064 fixbody = true; 1062 fixbody = true;
1065 localpos.Y = _parent_scene.WorldExtents.Y - 0.1f; 1063 localpos.Y = m_parent_scene.WorldExtents.Y - 0.1f;
1066 } 1064 }
1067 if (fixbody) 1065 if (fixbody)
1068 { 1066 {
@@ -1107,7 +1105,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1107 posch.Y += vel.Y * ftmp; 1105 posch.Y += vel.Y * ftmp;
1108 } 1106 }
1109 1107
1110 float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y); 1108 float terrainheight = m_parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
1111 if (chrminZ < terrainheight) 1109 if (chrminZ < terrainheight)
1112 { 1110 {
1113 if (ctz.Z < 0) 1111 if (ctz.Z < 0)
@@ -1119,7 +1117,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1119 m_haveLastFallVel = true; 1117 m_haveLastFallVel = true;
1120 } 1118 }
1121 1119
1122 Vector3 n = _parent_scene.GetTerrainNormalAtXY(posch.X, posch.Y); 1120 Vector3 n = m_parent_scene.GetTerrainNormalAtXY(posch.X, posch.Y);
1123 float depth = terrainheight - chrminZ; 1121 float depth = terrainheight - chrminZ;
1124 1122
1125 vec.Z = depth * PID_P * 50; 1123 vec.Z = depth * PID_P * 50;
@@ -1215,7 +1213,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1215 break; 1213 break;
1216 1214
1217 case PIDHoverType.GroundAndWater: 1215 case PIDHoverType.GroundAndWater:
1218 float waterHeight = _parent_scene.GetWaterLevel(); 1216 float waterHeight = m_parent_scene.GetWaterLevel();
1219 if (terrainheight > waterHeight) 1217 if (terrainheight > waterHeight)
1220 m_targetHoverHeight = terrainheight + m_PIDHoverHeight; 1218 m_targetHoverHeight = terrainheight + m_PIDHoverHeight;
1221 else 1219 else
@@ -1381,7 +1379,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1381 vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f; 1379 vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
1382 // hack for breaking on fall 1380 // hack for breaking on fall
1383 if (ctz.Z == -9999f) 1381 if (ctz.Z == -9999f)
1384 vec.Z += -vel.Z * PID_D - _parent_scene.gravityz * m_mass; 1382 vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass;
1385 } 1383 }
1386 } 1384 }
1387 } 1385 }
@@ -1407,7 +1405,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1407 1405
1408 if (flying || hoverPIDActive) 1406 if (flying || hoverPIDActive)
1409 { 1407 {
1410 vec.Z -= _parent_scene.gravityz * m_mass; 1408 vec.Z -= m_parent_scene.gravityz * m_mass;
1411 1409
1412 if(!hoverPIDActive) 1410 if(!hoverPIDActive)
1413 { 1411 {
@@ -1585,7 +1583,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1585 public override void UnSubscribeEvents() 1583 public override void UnSubscribeEvents()
1586 { 1584 {
1587 m_eventsubscription = 0; 1585 m_eventsubscription = 0;
1588 _parent_scene.RemoveCollisionEventReporting(this); 1586 m_parent_scene.RemoveCollisionEventReporting(this);
1589 lock(CollisionEventsThisFrame) 1587 lock(CollisionEventsThisFrame)
1590 CollisionEventsThisFrame.Clear(); 1588 CollisionEventsThisFrame.Clear();
1591 } 1589 }
@@ -1594,7 +1592,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1594 { 1592 {
1595 lock(CollisionEventsThisFrame) 1593 lock(CollisionEventsThisFrame)
1596 CollisionEventsThisFrame.AddCollider(CollidedWith, contact); 1594 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1597 _parent_scene.AddCollisionEventReporting(this); 1595 m_parent_scene.AddCollisionEventReporting(this);
1598 } 1596 }
1599 1597
1600 public void SendCollisions(int timestep) 1598 public void SendCollisions(int timestep)
@@ -1645,14 +1643,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1645 1643
1646 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); 1644 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
1647 1645
1648 _parent_scene.actor_name_map[collider] = (PhysicsActor)this; 1646 m_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
1649 _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; 1647 m_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
1650 _parent_scene.AddCharacter(this); 1648 m_parent_scene.AddCharacter(this);
1651 } 1649 }
1652 else 1650 else
1653 { 1651 {
1654 _parent_scene.RemoveCollisionEventReporting(this); 1652 m_parent_scene.RemoveCollisionEventReporting(this);
1655 _parent_scene.RemoveCharacter(this); 1653 m_parent_scene.RemoveCharacter(this);
1656 // destroy avatar capsule and related ODE data 1654 // destroy avatar capsule and related ODE data
1657 AvatarGeomAndBodyDestroy(); 1655 AvatarGeomAndBodyDestroy();
1658 } 1656 }
@@ -1699,8 +1697,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1699// Velocity = Vector3.Zero; 1697// Velocity = Vector3.Zero;
1700 m_targetVelocity = Vector3.Zero; 1698 m_targetVelocity = Vector3.Zero;
1701 1699
1702 _parent_scene.actor_name_map[collider] = (PhysicsActor)this; 1700 m_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
1703 _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; 1701 m_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
1704 } 1702 }
1705 m_freemove = false; 1703 m_freemove = false;
1706 m_pidControllerActive = true; 1704 m_pidControllerActive = true;
@@ -2008,7 +2006,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2008 2006
2009 public void AddChange(changes what, object arg) 2007 public void AddChange(changes what, object arg)
2010 { 2008 {
2011 _parent_scene.AddChange((PhysicsActor)this, what, arg); 2009 m_parent_scene.AddChange((PhysicsActor)this, what, arg);
2012 } 2010 }
2013 2011
2014 private struct strAvatarSize 2012 private struct strAvatarSize