aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs226
1 files changed, 113 insertions, 113 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 37a8b77..f1886e4 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -111,7 +111,7 @@ namespace OpenSim.Region.Physics.OdePlugin
111 private IntPtr _linkJointGroup = (IntPtr)0; 111 private IntPtr _linkJointGroup = (IntPtr)0;
112 private PhysicsActor _parent = null; 112 private PhysicsActor _parent = null;
113 private PhysicsActor m_taintparent = null; 113 private PhysicsActor m_taintparent = null;
114 114
115 private bool iscolliding = false; 115 private bool iscolliding = false;
116 private bool m_isphysical = false; 116 private bool m_isphysical = false;
117 private bool m_isSelected = false; 117 private bool m_isSelected = false;
@@ -202,7 +202,7 @@ namespace OpenSim.Region.Physics.OdePlugin
202 m_taintadd = true; 202 m_taintadd = true;
203 _parent_scene.AddPhysicsActorTaint(this); 203 _parent_scene.AddPhysicsActorTaint(this);
204 // don't do .add() here; old geoms get recycled with the same hash 204 // don't do .add() here; old geoms get recycled with the same hash
205 205
206 } 206 }
207 207
208 public override int PhysicsActorType 208 public override int PhysicsActorType
@@ -232,9 +232,9 @@ namespace OpenSim.Region.Physics.OdePlugin
232 public override bool Selected 232 public override bool Selected
233 { 233 {
234 set { 234 set {
235 // This only makes the object not collidable if the object 235 // This only makes the object not collidable if the object
236 // is physical or the object is modified somehow *IN THE FUTURE* 236 // is physical or the object is modified somehow *IN THE FUTURE*
237 // without this, if an avatar selects prim, they can walk right 237 // without this, if an avatar selects prim, they can walk right
238 // through it while it's selected 238 // through it while it's selected
239 239
240 if ((m_isphysical && !_zeroFlag) || !value) 240 if ((m_isphysical && !_zeroFlag) || !value)
@@ -262,7 +262,7 @@ namespace OpenSim.Region.Physics.OdePlugin
262 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 262 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
263 } 263 }
264 //m_log.Warn("Setting Geom to: " + prim_geom); 264 //m_log.Warn("Setting Geom to: " + prim_geom);
265 265
266 } 266 }
267 267
268 public void enableBodySoft() 268 public void enableBodySoft()
@@ -277,7 +277,7 @@ namespace OpenSim.Region.Physics.OdePlugin
277 public void disableBodySoft() 277 public void disableBodySoft()
278 { 278 {
279 m_disabled = true; 279 m_disabled = true;
280 280
281 if (m_isphysical) 281 if (m_isphysical)
282 if (Body != (IntPtr)0) 282 if (Body != (IntPtr)0)
283 d.BodyDisable(Body); 283 d.BodyDisable(Body);
@@ -307,7 +307,7 @@ namespace OpenSim.Region.Physics.OdePlugin
307 307
308 d.BodySetAutoDisableFlag(Body, true); 308 d.BodySetAutoDisableFlag(Body, true);
309 d.BodySetAutoDisableSteps(Body, 20); 309 d.BodySetAutoDisableSteps(Body, 20);
310 310
311 m_interpenetrationcount = 0; 311 m_interpenetrationcount = 0;
312 m_collisionscore = 0; 312 m_collisionscore = 0;
313 m_disabled = false; 313 m_disabled = false;
@@ -327,7 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin
327 { 327 {
328 float volume = 0; 328 float volume = 0;
329 329
330 // No material is passed to the physics engines yet.. soo.. 330 // No material is passed to the physics engines yet.. soo..
331 // we're using the m_density constant in the class definition 331 // we're using the m_density constant in the class definition
332 332
333 333
@@ -340,7 +340,7 @@ namespace OpenSim.Region.Physics.OdePlugin
340 340
341 volume = _size.X*_size.Y*_size.Z; 341 volume = _size.X*_size.Y*_size.Z;
342 342
343 // If the user has 'hollowed out' 343 // If the user has 'hollowed out'
344 // ProfileHollow is one of those 0 to 50000 values :P 344 // ProfileHollow is one of those 0 to 50000 values :P
345 // we like percentages better.. so turning into a percentage 345 // we like percentages better.. so turning into a percentage
346 346
@@ -415,7 +415,7 @@ namespace OpenSim.Region.Physics.OdePlugin
415 // We don't know what the shape is yet, so use default 415 // We don't know what the shape is yet, so use default
416 volume = _size.X * _size.Y * _size.Z; 416 volume = _size.X * _size.Y * _size.Z;
417 } 417 }
418 // If the user has 'hollowed out' 418 // If the user has 'hollowed out'
419 // ProfileHollow is one of those 0 to 50000 values :P 419 // ProfileHollow is one of those 0 to 50000 values :P
420 // we like percentages better.. so turning into a percentage 420 // we like percentages better.. so turning into a percentage
421 421
@@ -427,8 +427,8 @@ namespace OpenSim.Region.Physics.OdePlugin
427 float hollowVolume = 0; 427 float hollowVolume = 0;
428 switch (_pbs.HollowShape) 428 switch (_pbs.HollowShape)
429 { 429 {
430 430
431 case HollowShape.Same: 431 case HollowShape.Same:
432 case HollowShape.Circle: 432 case HollowShape.Circle:
433 // Hollow shape is a perfect cyllinder in respect to the cube's scale 433 // Hollow shape is a perfect cyllinder in respect to the cube's scale
434 // Cyllinder hollow volume calculation 434 // Cyllinder hollow volume calculation
@@ -447,7 +447,7 @@ namespace OpenSim.Region.Physics.OdePlugin
447 hollowVolume = hollowsizex * hollowsizey * hollowsizez; 447 hollowVolume = hollowsizex * hollowsizey * hollowsizez;
448 break; 448 break;
449 449
450 450
451 451
452 case HollowShape.Triangle: 452 case HollowShape.Triangle:
453 // Equilateral Triangular Prism volume hollow calculation 453 // Equilateral Triangular Prism volume hollow calculation
@@ -465,7 +465,7 @@ namespace OpenSim.Region.Physics.OdePlugin
465 volume = volume - hollowVolume; 465 volume = volume - hollowVolume;
466 } 466 }
467 break; 467 break;
468 468
469 case ProfileShape.HalfCircle: 469 case ProfileShape.HalfCircle:
470 if (_pbs.PathCurve == (byte)Extrusion.Curve1) 470 if (_pbs.PathCurve == (byte)Extrusion.Curve1)
471 { 471 {
@@ -490,13 +490,13 @@ namespace OpenSim.Region.Physics.OdePlugin
490 } 490 }
491 break; 491 break;
492 case ProfileShape.EquilateralTriangle: 492 case ProfileShape.EquilateralTriangle:
493 /* 493 /*
494 v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h 494 v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h
495 495
496 // seed mesh 496 // seed mesh
497 Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f); 497 Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f);
498 Vertex PM = new Vertex(+0.5f, 0f, 0.0f); 498 Vertex PM = new Vertex(+0.5f, 0f, 0.0f);
499 Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f); 499 Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f);
500 */ 500 */
501 float xA = -0.25f * _size.X; 501 float xA = -0.25f * _size.X;
502 float yA = -0.45f * _size.Y; 502 float yA = -0.45f * _size.Y;
@@ -509,7 +509,7 @@ namespace OpenSim.Region.Physics.OdePlugin
509 509
510 volume = (float)((Math.Abs((xB * yA - xA * yB) + (xC * yB - xB * yC) + (xA * yC - xC * yA)) / 2) * _size.Z); 510 volume = (float)((Math.Abs((xB * yA - xA * yB) + (xC * yB - xB * yC) + (xA * yC - xC * yA)) / 2) * _size.Z);
511 511
512 // If the user has 'hollowed out' 512 // If the user has 'hollowed out'
513 // ProfileHollow is one of those 0 to 50000 values :P 513 // ProfileHollow is one of those 0 to 50000 values :P
514 // we like percentages better.. so turning into a percentage 514 // we like percentages better.. so turning into a percentage
515 float fhollowFactor = ((float)_pbs.ProfileHollow / 1.9f); 515 float fhollowFactor = ((float)_pbs.ProfileHollow / 1.9f);
@@ -521,7 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin
521 float hollowVolume = 0; 521 float hollowVolume = 0;
522 switch (_pbs.HollowShape) 522 switch (_pbs.HollowShape)
523 { 523 {
524 524
525 case HollowShape.Same: 525 case HollowShape.Same:
526 case HollowShape.Triangle: 526 case HollowShape.Triangle:
527 // Equilateral Triangular Prism volume hollow calculation 527 // Equilateral Triangular Prism volume hollow calculation
@@ -550,7 +550,7 @@ namespace OpenSim.Region.Physics.OdePlugin
550 hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount); 550 hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount);
551 break; 551 break;
552 552
553 553
554 default: 554 default:
555 hollowVolume = 0; 555 hollowVolume = 0;
556 break; 556 break;
@@ -560,7 +560,7 @@ namespace OpenSim.Region.Physics.OdePlugin
560 break; 560 break;
561 561
562 default: 562 default:
563 // we don't have all of the volume formulas yet so 563 // we don't have all of the volume formulas yet so
564 // use the common volume formula for all 564 // use the common volume formula for all
565 volume = _size.X*_size.Y*_size.Z; 565 volume = _size.X*_size.Y*_size.Z;
566 break; 566 break;
@@ -568,7 +568,7 @@ namespace OpenSim.Region.Physics.OdePlugin
568 568
569 // Calculate Path cut effect on volume 569 // Calculate Path cut effect on volume
570 // Not exact, in the triangle hollow example 570 // Not exact, in the triangle hollow example
571 // They should never be zero or less then zero.. 571 // They should never be zero or less then zero..
572 // we'll ignore it if it's less then zero 572 // we'll ignore it if it's less then zero
573 573
574 // ProfileEnd and ProfileBegin are values 574 // ProfileEnd and ProfileBegin are values
@@ -672,11 +672,11 @@ namespace OpenSim.Region.Physics.OdePlugin
672 672
673 public void setMesh(OdeScene parent_scene, IMesh mesh) 673 public void setMesh(OdeScene parent_scene, IMesh mesh)
674 { 674 {
675 // This sleeper is there to moderate how long it takes between 675 // This sleeper is there to moderate how long it takes between
676 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object 676 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
677 677
678 Thread.Sleep(10); 678 Thread.Sleep(10);
679 679
680 //Kill Body so that mesh can re-make the geom 680 //Kill Body so that mesh can re-make the geom
681 if (IsPhysical && Body != (IntPtr) 0) 681 if (IsPhysical && Body != (IntPtr) 0)
682 { 682 {
@@ -694,9 +694,9 @@ namespace OpenSim.Region.Physics.OdePlugin
694 3*sizeof (int)); 694 3*sizeof (int));
695 d.GeomTriMeshDataPreprocess(_triMeshData); 695 d.GeomTriMeshDataPreprocess(_triMeshData);
696 696
697 697
698 _parent_scene.waitForSpaceUnlock(m_targetSpace); 698 _parent_scene.waitForSpaceUnlock(m_targetSpace);
699 699
700 try 700 try
701 { 701 {
702 if (prim_geom == (IntPtr)0) 702 if (prim_geom == (IntPtr)0)
@@ -706,7 +706,7 @@ namespace OpenSim.Region.Physics.OdePlugin
706 } 706 }
707 catch (AccessViolationException) 707 catch (AccessViolationException)
708 { 708 {
709 709
710 m_log.Error("[PHYSICS]: MESH LOCKED"); 710 m_log.Error("[PHYSICS]: MESH LOCKED");
711 return; 711 return;
712 } 712 }
@@ -715,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin
715 // Recreate the body 715 // Recreate the body
716 m_interpenetrationcount = 0; 716 m_interpenetrationcount = 0;
717 m_collisionscore = 0; 717 m_collisionscore = 0;
718 718
719 enableBody(); 719 enableBody();
720 720
721 } 721 }
@@ -724,7 +724,7 @@ namespace OpenSim.Region.Physics.OdePlugin
724 public void ProcessTaints(float timestep) 724 public void ProcessTaints(float timestep)
725 { 725 {
726 726
727 727
728 if (m_taintadd) 728 if (m_taintadd)
729 { 729 {
730 changeadd(timestep); 730 changeadd(timestep);
@@ -779,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin
779 } 779 }
780 780
781 private void changeAngularLock(float timestep) 781 private void changeAngularLock(float timestep)
782 { 782 {
783 // do we have a Physical object? 783 // do we have a Physical object?
784 if (Body != IntPtr.Zero) 784 if (Body != IntPtr.Zero)
785 { 785 {
@@ -809,7 +809,7 @@ namespace OpenSim.Region.Physics.OdePlugin
809 809
810 private void changelink(float timestep) 810 private void changelink(float timestep)
811 { 811 {
812 812
813 if (_parent == null && m_taintparent != null) 813 if (_parent == null && m_taintparent != null)
814 { 814 {
815 if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) 815 if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
@@ -834,14 +834,14 @@ namespace OpenSim.Region.Physics.OdePlugin
834 m_linkJoint = (IntPtr)0; 834 m_linkJoint = (IntPtr)0;
835 835
836 } 836 }
837 837
838 838
839 _parent = m_taintparent; 839 _parent = m_taintparent;
840 } 840 }
841 841
842 private void changeSelectedStatus(float timestep) 842 private void changeSelectedStatus(float timestep)
843 { 843 {
844 844
845 if (m_taintselected) 845 if (m_taintselected)
846 { 846 {
847 847
@@ -849,9 +849,9 @@ namespace OpenSim.Region.Physics.OdePlugin
849 m_collisionCategories = CollisionCategories.Selected; 849 m_collisionCategories = CollisionCategories.Selected;
850 m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space); 850 m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
851 851
852 // We do the body disable soft twice because 'in theory' a collision could have happened 852 // We do the body disable soft twice because 'in theory' a collision could have happened
853 // in between the disabling and the collision properties setting 853 // in between the disabling and the collision properties setting
854 // which would wake the physical body up from a soft disabling and potentially cause it to fall 854 // which would wake the physical body up from a soft disabling and potentially cause it to fall
855 // through the ground. 855 // through the ground.
856 856
857 if (m_isphysical) 857 if (m_isphysical)
@@ -873,9 +873,9 @@ namespace OpenSim.Region.Physics.OdePlugin
873 } 873 }
874 else 874 else
875 { 875 {
876 876
877 m_collisionCategories = CollisionCategories.Geom; 877 m_collisionCategories = CollisionCategories.Geom;
878 878
879 if (m_isphysical) 879 if (m_isphysical)
880 m_collisionCategories |= CollisionCategories.Body; 880 m_collisionCategories |= CollisionCategories.Body;
881 881
@@ -898,10 +898,10 @@ namespace OpenSim.Region.Physics.OdePlugin
898 enableBodySoft(); 898 enableBodySoft();
899 } 899 }
900 900
901 901
902 } 902 }
903 903
904 904
905 resetCollisionAccounting(); 905 resetCollisionAccounting();
906 m_isSelected = m_taintselected; 906 m_isSelected = m_taintselected;
907 } 907 }
@@ -918,21 +918,21 @@ namespace OpenSim.Region.Physics.OdePlugin
918 m_taintselected = m_isSelected; 918 m_taintselected = m_isSelected;
919 919
920 m_taintsize = _size; 920 m_taintsize = _size;
921 921
922 922
923 m_taintshape = false; 923 m_taintshape = false;
924 924
925 m_taintforce = false; 925 m_taintforce = false;
926 926
927 m_taintdisable = false; 927 m_taintdisable = false;
928 928
929 m_taintVelocity = PhysicsVector.Zero; 929 m_taintVelocity = PhysicsVector.Zero;
930 } 930 }
931 public void changeadd(float timestep) 931 public void changeadd(float timestep)
932 { 932 {
933 933
934 934
935 935
936 int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 936 int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
937 IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); 937 IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position);
938 938
@@ -941,7 +941,7 @@ namespace OpenSim.Region.Physics.OdePlugin
941 941
942 m_targetSpace = targetspace; 942 m_targetSpace = targetspace;
943 943
944 944
945 945
946 if (_mesh != null) 946 if (_mesh != null)
947 { 947 {
@@ -1010,7 +1010,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1010 { 1010 {
1011 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); 1011 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
1012 ode.dunlock(_parent_scene.world); 1012 ode.dunlock(_parent_scene.world);
1013 return; 1013 return;
1014 } 1014 }
1015 } 1015 }
1016 } 1016 }
@@ -1060,7 +1060,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1060 1060
1061 1061
1062 } 1062 }
1063 1063
1064 _parent_scene.geom_name_map[prim_geom] = this.m_primName; 1064 _parent_scene.geom_name_map[prim_geom] = this.m_primName;
1065 _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; 1065 _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
1066 1066
@@ -1072,7 +1072,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1072 } 1072 }
1073 public void changemove(float timestep) 1073 public void changemove(float timestep)
1074 { 1074 {
1075 1075
1076 1076
1077 1077
1078 if (m_isphysical) 1078 if (m_isphysical)
@@ -1080,7 +1080,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1080 // This is a fallback.. May no longer be necessary. 1080 // This is a fallback.. May no longer be necessary.
1081 if (Body == (IntPtr) 0) 1081 if (Body == (IntPtr) 0)
1082 enableBody(); 1082 enableBody();
1083 //Prim auto disable after 20 frames, 1083 //Prim auto disable after 20 frames,
1084 //if you move it, re-enable the prim manually. 1084 //if you move it, re-enable the prim manually.
1085 if (_parent != null) 1085 if (_parent != null)
1086 { 1086 {
@@ -1102,7 +1102,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1102 } 1102 }
1103 } 1103 }
1104 d.BodyEnable(Body); 1104 d.BodyEnable(Body);
1105 1105
1106 } 1106 }
1107 else 1107 else
1108 { 1108 {
@@ -1122,10 +1122,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1122 d.SpaceAdd(m_targetSpace, prim_geom); 1122 d.SpaceAdd(m_targetSpace, prim_geom);
1123 } 1123 }
1124 } 1124 }
1125 1125
1126 1126
1127 changeSelectedStatus(timestep); 1127 changeSelectedStatus(timestep);
1128 1128
1129 resetCollisionAccounting(); 1129 resetCollisionAccounting();
1130 m_taintposition = _position; 1130 m_taintposition = _position;
1131 } 1131 }
@@ -1140,42 +1140,42 @@ namespace OpenSim.Region.Physics.OdePlugin
1140 { 1140 {
1141 float PID_D = 2200.0f; 1141 float PID_D = 2200.0f;
1142 //float PID_P = 900.0f; 1142 //float PID_P = 900.0f;
1143 1143
1144 1144
1145 float m_mass = CalculateMass(); 1145 float m_mass = CalculateMass();
1146 1146
1147 fz = 0f; 1147 fz = 0f;
1148 //m_log.Info(m_collisionFlags.ToString()); 1148 //m_log.Info(m_collisionFlags.ToString());
1149 1149
1150 1150
1151 1151
1152 1152
1153 if (m_buoyancy != 0) 1153 if (m_buoyancy != 0)
1154 { 1154 {
1155 1155
1156 if (m_buoyancy > 0) 1156 if (m_buoyancy > 0)
1157 { 1157 {
1158 fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass); 1158 fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass);
1159 1159
1160 //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); 1160 //d.Vector3 l_velocity = d.BodyGetLinearVel(Body);
1161 //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); 1161 //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString());
1162 } 1162 }
1163 else 1163 else
1164 { 1164 {
1165 fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass)); 1165 fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass));
1166 } 1166 }
1167 1167
1168 1168
1169 } 1169 }
1170 1170
1171 if (m_usePID) 1171 if (m_usePID)
1172 { 1172 {
1173 // If we're using the PID controller, then we have no gravity 1173 // If we're using the PID controller, then we have no gravity
1174 fz = (-1 * _parent_scene.gravityz) * this.Mass; 1174 fz = (-1 * _parent_scene.gravityz) * this.Mass;
1175 1175
1176 // no lock; for now it's only called from within Simulate() 1176 // no lock; for now it's only called from within Simulate()
1177 1177
1178 // If the PID Controller isn't active then we set our force 1178 // If the PID Controller isn't active then we set our force
1179 // calculating base velocity to the current position 1179 // calculating base velocity to the current position
1180 if (Environment.OSVersion.Platform == PlatformID.Unix) 1180 if (Environment.OSVersion.Platform == PlatformID.Unix)
1181 { 1181 {
@@ -1189,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1189 } 1189 }
1190 PID_D = 35f; 1190 PID_D = 35f;
1191 1191
1192 1192
1193 //PID_P = 1.0f; 1193 //PID_P = 1.0f;
1194 float PID_G = 25; 1194 float PID_G = 25;
1195 1195
@@ -1197,7 +1197,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1197 { 1197 {
1198 PID_G = PID_G / m_PIDTau; 1198 PID_G = PID_G / m_PIDTau;
1199 } 1199 }
1200 1200
1201 1201
1202 if ((PID_G - m_PIDTau) <= 0) 1202 if ((PID_G - m_PIDTau) <= 0)
1203 { 1203 {
@@ -1205,15 +1205,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1205 } 1205 }
1206 //PidStatus = true; 1206 //PidStatus = true;
1207 1207
1208 1208
1209 1209
1210 1210
1211 PhysicsVector vec = new PhysicsVector(); 1211 PhysicsVector vec = new PhysicsVector();
1212 d.Vector3 vel = d.BodyGetLinearVel(Body); 1212 d.Vector3 vel = d.BodyGetLinearVel(Body);
1213 1213
1214 1214
1215 d.Vector3 pos = d.BodyGetPosition(Body); 1215 d.Vector3 pos = d.BodyGetPosition(Body);
1216 _target_velocity = 1216 _target_velocity =
1217 new PhysicsVector( 1217 new PhysicsVector(
1218 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1218 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1219 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1219 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
@@ -1222,18 +1222,18 @@ namespace OpenSim.Region.Physics.OdePlugin
1222 1222
1223 1223
1224 // if velocity is zero, use position control; otherwise, velocity control 1224 // if velocity is zero, use position control; otherwise, velocity control
1225 1225
1226 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f)) 1226 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
1227 { 1227 {
1228 // keep track of where we stopped. No more slippin' & slidin' 1228 // keep track of where we stopped. No more slippin' & slidin'
1229 1229
1230 1230
1231 // We only want to deactivate the PID Controller if we think we want to have our surrogate 1231 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1232 // react to the physics scene by moving it's position. 1232 // react to the physics scene by moving it's position.
1233 // Avatar to Avatar collisions 1233 // Avatar to Avatar collisions
1234 // Prim to avatar collisions 1234 // Prim to avatar collisions
1235 1235
1236 1236
1237 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2); 1237 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1238 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2); 1238 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1239 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P; 1239 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
@@ -1245,27 +1245,27 @@ namespace OpenSim.Region.Physics.OdePlugin
1245 } 1245 }
1246 else 1246 else
1247 { 1247 {
1248 1248
1249 _zeroFlag = false; 1249 _zeroFlag = false;
1250 1250
1251 // We're flying and colliding with something 1251 // We're flying and colliding with something
1252 fx = ((_target_velocity.X) - vel.X) * (PID_D); 1252 fx = ((_target_velocity.X) - vel.X) * (PID_D);
1253 fy = ((_target_velocity.Y) - vel.Y) * (PID_D); 1253 fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
1254
1255 1254
1256 1255
1257 1256
1257
1258 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; 1258 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
1259 1259
1260 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); 1260 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1261 } 1261 }
1262 1262
1263 } 1263 }
1264 1264
1265 fx *= m_mass; 1265 fx *= m_mass;
1266 fy *= m_mass; 1266 fy *= m_mass;
1267 //fz *= m_mass; 1267 //fz *= m_mass;
1268 1268
1269 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString()); 1269 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
1270 if (fx != 0 || fy != 0 || fz != 0) 1270 if (fx != 0 || fy != 0 || fz != 0)
1271 { 1271 {
@@ -1285,7 +1285,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1285 1285
1286 public void rotate(float timestep) 1286 public void rotate(float timestep)
1287 { 1287 {
1288 1288
1289 1289
1290 d.Quaternion myrot = new d.Quaternion(); 1290 d.Quaternion myrot = new d.Quaternion();
1291 myrot.W = _orientation.w; 1291 myrot.W = _orientation.w;
@@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1299 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) 1299 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0))
1300 createAMotor(m_angularlock); 1300 createAMotor(m_angularlock);
1301 } 1301 }
1302 1302
1303 resetCollisionAccounting(); 1303 resetCollisionAccounting();
1304 m_taintrot = _orientation; 1304 m_taintrot = _orientation;
1305 } 1305 }
@@ -1313,21 +1313,21 @@ namespace OpenSim.Region.Physics.OdePlugin
1313 1313
1314 public void changedisable(float timestep) 1314 public void changedisable(float timestep)
1315 { 1315 {
1316 1316
1317 m_disabled = true; 1317 m_disabled = true;
1318 if (Body != (IntPtr)0) 1318 if (Body != (IntPtr)0)
1319 { 1319 {
1320 d.BodyDisable(Body); 1320 d.BodyDisable(Body);
1321 Body = (IntPtr)0; 1321 Body = (IntPtr)0;
1322 } 1322 }
1323 1323
1324 1324
1325 m_taintdisable = false; 1325 m_taintdisable = false;
1326 } 1326 }
1327 1327
1328 public void changePhysicsStatus(float timestep) 1328 public void changePhysicsStatus(float timestep)
1329 { 1329 {
1330 1330
1331 1331
1332 if (m_isphysical == true) 1332 if (m_isphysical == true)
1333 { 1333 {
@@ -1352,7 +1352,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1352 1352
1353 public void changesize(float timestamp) 1353 public void changesize(float timestamp)
1354 { 1354 {
1355 1355
1356 //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) 1356 //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom))
1357 //{ 1357 //{
1358 // m_taintsize = _size; 1358 // m_taintsize = _size;
@@ -1369,7 +1369,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1369 { 1369 {
1370 // Cleanup meshing here 1370 // Cleanup meshing here
1371 } 1371 }
1372 //kill body to rebuild 1372 //kill body to rebuild
1373 if (IsPhysical && Body != (IntPtr) 0) 1373 if (IsPhysical && Body != (IntPtr) 0)
1374 { 1374 {
1375 disableBody(); 1375 disableBody();
@@ -1531,7 +1531,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1531 { 1531 {
1532 m_collisionFlags |= CollisionCategories.Water; 1532 m_collisionFlags |= CollisionCategories.Water;
1533 } 1533 }
1534 else 1534 else
1535 { 1535 {
1536 m_collisionFlags &= ~CollisionCategories.Water; 1536 m_collisionFlags &= ~CollisionCategories.Water;
1537 } 1537 }
@@ -1541,7 +1541,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1541 1541
1542 public void changeshape(float timestamp) 1542 public void changeshape(float timestamp)
1543 { 1543 {
1544 1544
1545 string oldname = _parent_scene.geom_name_map[prim_geom]; 1545 string oldname = _parent_scene.geom_name_map[prim_geom];
1546 1546
1547 // Cleanup of old prim geometry and Bodies 1547 // Cleanup of old prim geometry and Bodies
@@ -1579,7 +1579,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1579 // Re creates body on size. 1579 // Re creates body on size.
1580 // EnableBody also does setMass() 1580 // EnableBody also does setMass()
1581 enableBody(); 1581 enableBody();
1582 1582
1583 } 1583 }
1584 } 1584 }
1585 else 1585 else
@@ -1684,7 +1684,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1684 d.BodyEnable(Body); 1684 d.BodyEnable(Body);
1685 } 1685 }
1686 } 1686 }
1687 1687
1688 1688
1689 _parent_scene.geom_name_map[prim_geom] = oldname; 1689 _parent_scene.geom_name_map[prim_geom] = oldname;
1690 1690
@@ -1698,7 +1698,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1698 { 1698 {
1699 if (!m_isSelected) 1699 if (!m_isSelected)
1700 { 1700 {
1701 1701
1702 1702
1703 1703
1704 lock (m_forcelist) 1704 lock (m_forcelist)
@@ -1728,7 +1728,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1728 { 1728 {
1729 if (!m_isSelected) 1729 if (!m_isSelected)
1730 { 1730 {
1731 1731
1732 1732
1733 Thread.Sleep(20); 1733 Thread.Sleep(20);
1734 if (IsPhysical) 1734 if (IsPhysical)
@@ -1737,8 +1737,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1737 { 1737 {
1738 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); 1738 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
1739 } 1739 }
1740 } 1740 }
1741 1741
1742 //resetCollisionAccounting(); 1742 //resetCollisionAccounting();
1743 } 1743 }
1744 m_taintVelocity = PhysicsVector.Zero; 1744 m_taintVelocity = PhysicsVector.Zero;
@@ -1794,7 +1794,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1794 { 1794 {
1795 get { return _position; } 1795 get { return _position; }
1796 1796
1797 set { _position = value; 1797 set { _position = value;
1798 //m_log.Info("[PHYSICS]: " + _position.ToString()); 1798 //m_log.Info("[PHYSICS]: " + _position.ToString());
1799 } 1799 }
1800 } 1800 }
@@ -1838,7 +1838,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1838 { 1838 {
1839 get 1839 get
1840 { 1840 {
1841 // Averate previous velocity with the new one so 1841 // Averate previous velocity with the new one so
1842 // client object interpolation works a 'little' better 1842 // client object interpolation works a 'little' better
1843 PhysicsVector returnVelocity = new PhysicsVector(); 1843 PhysicsVector returnVelocity = new PhysicsVector();
1844 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; 1844 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
@@ -1849,7 +1849,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1849 set 1849 set
1850 { 1850 {
1851 _velocity = value; 1851 _velocity = value;
1852 1852
1853 m_taintVelocity = value; 1853 m_taintVelocity = value;
1854 _parent_scene.AddPhysicsActorTaint(this); 1854 _parent_scene.AddPhysicsActorTaint(this);
1855 } 1855 }
@@ -1898,11 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1898 if (_zeroFlag) 1898 if (_zeroFlag)
1899 return pv; 1899 return pv;
1900 m_lastUpdateSent = false; 1900 m_lastUpdateSent = false;
1901 1901
1902 if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) 1902 if (m_rotationalVelocity.IsIdentical(pv, 0.2f))
1903 return pv; 1903 return pv;
1904 1904
1905 return m_rotationalVelocity; 1905 return m_rotationalVelocity;
1906 } 1906 }
1907 set { m_rotationalVelocity = value; } 1907 set { m_rotationalVelocity = value; }
1908 } 1908 }
@@ -1948,7 +1948,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1948 } 1948 }
1949 1949
1950 public void UpdatePositionAndVelocity() 1950 public void UpdatePositionAndVelocity()
1951 { 1951 {
1952 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1952 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1953 if (_parent != null) 1953 if (_parent != null)
1954 { 1954 {
@@ -1963,7 +1963,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1963 d.Quaternion ori = d.BodyGetQuaternion(Body); 1963 d.Quaternion ori = d.BodyGetQuaternion(Body);
1964 d.Vector3 vel = d.BodyGetLinearVel(Body); 1964 d.Vector3 vel = d.BodyGetLinearVel(Body);
1965 d.Vector3 rotvel = d.BodyGetAngularVel(Body); 1965 d.Vector3 rotvel = d.BodyGetAngularVel(Body);
1966 1966
1967 PhysicsVector l_position = new PhysicsVector(); 1967 PhysicsVector l_position = new PhysicsVector();
1968 1968
1969 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1969 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
@@ -2000,16 +2000,16 @@ namespace OpenSim.Region.Physics.OdePlugin
2000 2000
2001 if (l_position.Z < 0) 2001 if (l_position.Z < 0)
2002 { 2002 {
2003 // This is so prim that get lost underground don't fall forever and suck up 2003 // This is so prim that get lost underground don't fall forever and suck up
2004 // 2004 //
2005 // Sim resources and memory. 2005 // Sim resources and memory.
2006 // Disables the prim's movement physics.... 2006 // Disables the prim's movement physics....
2007 // It's a hack and will generate a console message if it fails. 2007 // It's a hack and will generate a console message if it fails.
2008 2008
2009 //IsPhysical = false; 2009 //IsPhysical = false;
2010 if (_parent == null) 2010 if (_parent == null)
2011 base.RaiseOutOfBounds(_position); 2011 base.RaiseOutOfBounds(_position);
2012 2012
2013 _acceleration.X = 0; 2013 _acceleration.X = 0;
2014 _acceleration.Y = 0; 2014 _acceleration.Y = 0;
2015 _acceleration.Z = 0; 2015 _acceleration.Z = 0;
@@ -2020,10 +2020,10 @@ namespace OpenSim.Region.Physics.OdePlugin
2020 m_rotationalVelocity.X = 0; 2020 m_rotationalVelocity.X = 0;
2021 m_rotationalVelocity.Y = 0; 2021 m_rotationalVelocity.Y = 0;
2022 m_rotationalVelocity.Z = 0; 2022 m_rotationalVelocity.Z = 0;
2023 2023
2024 if (_parent == null) 2024 if (_parent == null)
2025 base.RequestPhysicsterseUpdate(); 2025 base.RequestPhysicsterseUpdate();
2026 2026
2027 m_throttleUpdates = false; 2027 m_throttleUpdates = false;
2028 throttleCounter = 0; 2028 throttleCounter = 0;
2029 _zeroFlag = true; 2029 _zeroFlag = true;
@@ -2065,10 +2065,10 @@ namespace OpenSim.Region.Physics.OdePlugin
2065 m_throttleUpdates = false; 2065 m_throttleUpdates = false;
2066 throttleCounter = 0; 2066 throttleCounter = 0;
2067 m_rotationalVelocity = pv; 2067 m_rotationalVelocity = pv;
2068 2068
2069 if (_parent == null) 2069 if (_parent == null)
2070 base.RequestPhysicsterseUpdate(); 2070 base.RequestPhysicsterseUpdate();
2071 2071
2072 m_lastUpdateSent = true; 2072 m_lastUpdateSent = true;
2073 } 2073 }
2074 } 2074 }
@@ -2087,11 +2087,11 @@ namespace OpenSim.Region.Physics.OdePlugin
2087 _velocity.X = vel.X; 2087 _velocity.X = vel.X;
2088 _velocity.Y = vel.Y; 2088 _velocity.Y = vel.Y;
2089 _velocity.Z = vel.Z; 2089 _velocity.Z = vel.Z;
2090 2090
2091 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2091 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2092 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); 2092 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
2093 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2093 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2094 2094
2095 if (_velocity.IsIdentical(pv, 0.5f)) 2095 if (_velocity.IsIdentical(pv, 0.5f))
2096 { 2096 {
2097 m_rotationalVelocity = pv; 2097 m_rotationalVelocity = pv;
@@ -2173,7 +2173,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2173 { 2173 {
2174 m_tensor = 5f; 2174 m_tensor = 5f;
2175 } 2175 }
2176 2176
2177 float axisnum = 3; 2177 float axisnum = 3;
2178 2178
2179 axisnum = (axisnum - (axis.X + axis.Y + axis.Z)); 2179 axisnum = (axisnum - (axis.X + axis.Y + axis.Z));
@@ -2222,7 +2222,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2222 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); 2222 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
2223 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); 2223 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
2224 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); 2224 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
2225 2225
2226 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); 2226 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
2227 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor); 2227 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor);
2228 } 2228 }