aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares2008-03-25 03:36:31 +0000
committerTeravus Ovares2008-03-25 03:36:31 +0000
commita21112cceedfc93840b935feae4ad8725c4afb48 (patch)
tree43efce03cfc00168c04579e1cf3611eebde8ebde
parentAdded monodevelop support to runprebuild.sh (diff)
downloadopensim-SC_OLD-a21112cceedfc93840b935feae4ad8725c4afb48.zip
opensim-SC_OLD-a21112cceedfc93840b935feae4ad8725c4afb48.tar.gz
opensim-SC_OLD-a21112cceedfc93840b935feae4ad8725c4afb48.tar.bz2
opensim-SC_OLD-a21112cceedfc93840b935feae4ad8725c4afb48.tar.xz
* Adds llMoveToTarget and llStopMoveToTarget support to the ODEPlugin.
* It doesn't generate at_target events, because they don't exist yet in the script engine. * The Tau is different, however, compatible with scripts I tested. * Not perfect... but pretty good.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs21
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs18
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs3
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs3
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs9
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs3
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs124
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs6
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs6
10 files changed, 193 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2875874..2f2a1be 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -694,6 +694,25 @@ namespace OpenSim.Region.Environment.Scenes
694 } 694 }
695 } 695 }
696 696
697 public void moveToTarget(LLVector3 target, float tau)
698 {
699 SceneObjectPart rootpart = m_rootPart;
700 if (rootpart != null)
701 {
702 rootpart.PhysActor.PIDTarget = new PhysicsVector(target.X, target.Y, target.Z);
703 rootpart.PhysActor.PIDTau = tau;
704 rootpart.PhysActor.PIDActive = true;
705 }
706 }
707 public void stopMoveToTarget()
708 {
709 SceneObjectPart rootpart = m_rootPart;
710 if (rootpart != null)
711 {
712 rootpart.PhysActor.PIDActive = false;
713 }
714 }
715
697 public void SetRootPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) 716 public void SetRootPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
698 { 717 {
699 part.LastOwnerID = part.OwnerID; 718 part.LastOwnerID = part.OwnerID;
@@ -2019,5 +2038,7 @@ namespace OpenSim.Region.Environment.Scenes
2019 } 2038 }
2020 } 2039 }
2021 } 2040 }
2041
2042
2022 } 2043 }
2023} 2044}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 48177dc..cbefc19 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -586,6 +586,24 @@ namespace OpenSim.Region.Environment.Scenes
586 } 586 }
587 } 587 }
588 588
589 public void MoveToTarget(LLVector3 target, float tau)
590 {
591 if (tau > 0)
592 {
593 m_parentGroup.moveToTarget(target, tau);
594 }
595 else
596 {
597 StopMoveToTarget();
598 }
599
600 }
601
602 public void StopMoveToTarget()
603 {
604 m_parentGroup.stopMoveToTarget();
605 }
606
589 public void TriggerScriptChangedEvent(Changed val) 607 public void TriggerScriptChangedEvent(Changed val)
590 { 608 {
591 if (m_parentGroup != null) 609 if (m_parentGroup != null)
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 8459fbc..16ec66e 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -390,5 +390,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
390 public override void CrossingFailure() 390 public override void CrossingFailure()
391 { 391 {
392 } 392 }
393 public override PhysicsVector PIDTarget { set { return; } }
394 public override bool PIDActive { set { return; } }
395 public override float PIDTau { set { return; } }
393 } 396 }
394} 397}
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index f100ab0..bc777e2 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -992,6 +992,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
992 { 992 {
993 993
994 } 994 }
995 public override PhysicsVector PIDTarget { set { return; } }
996 public override bool PIDActive { set { return; } }
997 public override float PIDTau { set { return; } }
995 } 998 }
996 999
997 /// <summary> 1000 /// <summary>
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index c63e1f7..b40635c 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -180,6 +180,10 @@ namespace OpenSim.Region.Physics.Manager
180 public abstract PhysicsVector RotationalVelocity { get; set; } 180 public abstract PhysicsVector RotationalVelocity { get; set; }
181 public abstract bool Kinematic { get; set; } 181 public abstract bool Kinematic { get; set; }
182 public abstract float Buoyancy { get; set; } 182 public abstract float Buoyancy { get; set; }
183 public abstract PhysicsVector PIDTarget { set;}
184 public abstract bool PIDActive { set;}
185 public abstract float PIDTau { set; }
186
183 187
184 public abstract void AddForce(PhysicsVector force); 188 public abstract void AddForce(PhysicsVector force);
185 public abstract void SetMomentum(PhysicsVector momentum); 189 public abstract void SetMomentum(PhysicsVector momentum);
@@ -343,6 +347,7 @@ namespace OpenSim.Region.Physics.Manager
343 { 347 {
344 } 348 }
345 349
350
346 public override void AddForce(PhysicsVector force) 351 public override void AddForce(PhysicsVector force)
347 { 352 {
348 } 353 }
@@ -353,6 +358,10 @@ namespace OpenSim.Region.Physics.Manager
353 set { return; } 358 set { return; }
354 } 359 }
355 360
361 public override PhysicsVector PIDTarget { set { return; } }
362 public override bool PIDActive { set { return; } }
363 public override float PIDTau { set { return; } }
364
356 public override void SetMomentum(PhysicsVector momentum) 365 public override void SetMomentum(PhysicsVector momentum)
357 { 366 {
358 } 367 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 30f0b06..b870a77 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -852,5 +852,8 @@ namespace OpenSim.Region.Physics.OdePlugin
852 public override void CrossingFailure() 852 public override void CrossingFailure()
853 { 853 {
854 } 854 }
855 public override PhysicsVector PIDTarget { set { return; } }
856 public override bool PIDActive { set { return; } }
857 public override float PIDTau { set { return; } }
855 } 858 }
856} 859}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index ddadc98..43a7272 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -46,11 +46,17 @@ namespace OpenSim.Region.Physics.OdePlugin
46 private PhysicsVector m_rotationalVelocity; 46 private PhysicsVector m_rotationalVelocity;
47 private PhysicsVector _size; 47 private PhysicsVector _size;
48 private PhysicsVector _acceleration; 48 private PhysicsVector _acceleration;
49 private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
49 private Quaternion _orientation; 50 private Quaternion _orientation;
50 private PhysicsVector m_taintposition; 51 private PhysicsVector m_taintposition;
51 private PhysicsVector m_taintsize; 52 private PhysicsVector m_taintsize;
52 private PhysicsVector m_taintVelocity = PhysicsVector.Zero; 53 private PhysicsVector m_taintVelocity = PhysicsVector.Zero;
53 private Quaternion m_taintrot; 54 private Quaternion m_taintrot;
55
56 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0);
57 private float m_PIDTau = 0f;
58 private bool m_usePID = false;
59
54 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 60 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
55 | CollisionCategories.Space 61 | CollisionCategories.Space
56 | CollisionCategories.Body 62 | CollisionCategories.Body
@@ -1079,31 +1085,138 @@ namespace OpenSim.Region.Physics.OdePlugin
1079 1085
1080 public void Move(float timestep) 1086 public void Move(float timestep)
1081 { 1087 {
1088 float fx = 0;
1089 float fy = 0;
1090 float fz = 0;
1082 1091
1083 if (IsPhysical && Body != (IntPtr)0 && !m_isSelected) 1092 if (IsPhysical && Body != (IntPtr)0 && !m_isSelected)
1084 { 1093 {
1094 float PID_D = 2200.0f;
1095 float PID_P = 900.0f;
1096
1097
1085 float m_mass = CalculateMass(); 1098 float m_mass = CalculateMass();
1099
1100 fz = 0f;
1086 //m_log.Info(m_collisionFlags.ToString()); 1101 //m_log.Info(m_collisionFlags.ToString());
1102
1103
1104
1105
1087 if (m_buoyancy != 0) 1106 if (m_buoyancy != 0)
1088 { 1107 {
1089 float buoyancy = 0f; 1108
1090 if (m_buoyancy > 0) 1109 if (m_buoyancy > 0)
1091 { 1110 {
1092 buoyancy = ((9.8f * m_buoyancy) * m_mass); 1111 fz = ((9.8f * m_buoyancy) * m_mass);
1093 1112
1094 //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); 1113 //d.Vector3 l_velocity = d.BodyGetLinearVel(Body);
1095 //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (9.8f * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); 1114 //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (9.8f * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString());
1096 } 1115 }
1097 else 1116 else
1098 { 1117 {
1099 buoyancy = (-1 * ((9.8f * (-1 * m_buoyancy)) * m_mass)); 1118 fz = (-1 * ((9.8f * (-1 * m_buoyancy)) * m_mass));
1119 }
1120
1121
1122 }
1123
1124 if (m_usePID)
1125 {
1126
1127 // If we're using the PID controller, then we have no gravity
1128 fz = ((9.8f) * this.Mass );
1129
1130 // no lock; for now it's only called from within Simulate()
1131
1132 // If the PID Controller isn't active then we set our force
1133 // calculating base velocity to the current position
1134 if (System.Environment.OSVersion.Platform == PlatformID.Unix)
1135 {
1136 PID_D = 3200.0f;
1137 PID_P = 1400.0f;
1138 }
1139 else
1140 {
1141 PID_D = 2200.0f;
1142 PID_P = 900.0f;
1143 }
1144 PID_D = 1.0f;
1145 PID_P = 1.0f;
1146
1147
1148 //PidStatus = true;
1149
1150 PhysicsVector vec = new PhysicsVector();
1151 d.Vector3 vel = d.BodyGetLinearVel(Body);
1152
1153
1154 d.Vector3 pos = d.BodyGetPosition(Body);
1155 _target_velocity =
1156 new PhysicsVector(
1157 (m_PIDTarget.X - pos.X) / m_PIDTau,
1158 (m_PIDTarget.Y - pos.Y) / m_PIDTau,
1159 (m_PIDTarget.Z - pos.Z) / m_PIDTau
1160 );
1161
1162
1163 // if velocity is zero, use position control; otherwise, velocity control
1164
1165 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
1166 {
1167 // keep track of where we stopped. No more slippin' & slidin'
1168
1169
1170 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1171 // react to the physics scene by moving it's position.
1172 // Avatar to Avatar collisions
1173 // Prim to avatar collisions
1174
1175
1176 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1177 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1178 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1179 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
1180 d.BodySetLinearVel(Body, 0, 0, 0);
1181 d.BodyAddForce(Body, 0, 0, fz);
1182 return;
1183
1184 }
1185 else
1186 {
1187
1188 _zeroFlag = false;
1189
1190 // We're flying and colliding with something
1191 fx = ((_target_velocity.X / m_PIDTau) - vel.X) * (PID_D / 6);
1192 fy = ((_target_velocity.Y / m_PIDTau) - vel.Y) * (PID_D / 6);
1193
1194
1195
1196
1197 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
1198
1199 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1100 } 1200 }
1101 d.BodyAddForce(Body, 0, 0, buoyancy);
1102 1201
1202 }
1203
1204 fx *= m_mass;
1205 fy *= m_mass;
1206 //fz *= m_mass;
1207
1208 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
1209 if (fx != 0 || fy != 0 || fz != 0)
1210 {
1211 //m_taintdisable = true;
1212 //base.RaiseOutOfBounds(Position);
1213 //d.BodySetLinearVel(Body, fx, fy, 0f);
1214 d.BodyAddForce(Body, fx, fy, fz);
1103 } 1215 }
1104 } 1216 }
1105 else 1217 else
1106 { 1218 {
1219 _zeroPosition = d.BodyGetPosition(Body);
1107 return; 1220 return;
1108 } 1221 }
1109 } 1222 }
@@ -1952,5 +2065,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1952 public override void SetMomentum(PhysicsVector momentum) 2065 public override void SetMomentum(PhysicsVector momentum)
1953 { 2066 {
1954 } 2067 }
2068 public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } }
2069 public override bool PIDActive { set { m_usePID = value; } }
2070 public override float PIDTau { set { m_PIDTau = (value * 0.6f); } }
1955 } 2071 }
1956} 2072}
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
index 57fcbe4..12b2d8f 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
@@ -518,6 +518,9 @@ namespace OpenSim.Region.Physics.POSPlugin
518 { 518 {
519 519
520 } 520 }
521 public override PhysicsVector PIDTarget { set { return; } }
522 public override bool PIDActive { set { return; } }
523 public override float PIDTau { set { return; } }
521 } 524 }
522 525
523 public class POSPrim : PhysicsActor 526 public class POSPrim : PhysicsActor
@@ -711,5 +714,8 @@ namespace OpenSim.Region.Physics.POSPlugin
711 public override void CrossingFailure() 714 public override void CrossingFailure()
712 { 715 {
713 } 716 }
717 public override PhysicsVector PIDTarget { set { return; } }
718 public override bool PIDActive { set { return; } }
719 public override float PIDTau { set { return; } }
714 } 720 }
715} 721}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 3541b5c..2d00bdb 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -433,6 +433,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
433 { 433 {
434 434
435 } 435 }
436 public override PhysicsVector PIDTarget { set { return; } }
437 public override bool PIDActive { set { return; } }
438 public override float PIDTau { set { return; } }
436 } 439 }
437 440
438 441
@@ -650,5 +653,8 @@ namespace OpenSim.Region.Physics.PhysXPlugin
650 public override void CrossingFailure() 653 public override void CrossingFailure()
651 { 654 {
652 } 655 }
656 public override PhysicsVector PIDTarget { set { return; } }
657 public override bool PIDActive { set { return; } }
658 public override float PIDTau { set { return; } }
653 } 659 }
654} 660}
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 82d67d4..73d901d 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -1097,13 +1097,15 @@ namespace OpenSim.Region.ScriptEngine.Common
1097 public void llMoveToTarget(LSL_Types.Vector3 target, double tau) 1097 public void llMoveToTarget(LSL_Types.Vector3 target, double tau)
1098 { 1098 {
1099 m_host.AddScriptLPS(1); 1099 m_host.AddScriptLPS(1);
1100 NotImplemented("llMoveToTarget"); 1100 m_host.MoveToTarget(new LLVector3((float)target.x, (float)target.y, (float)target.z), (float)tau);
1101 //NotImplemented("llMoveToTarget");
1101 } 1102 }
1102 1103
1103 public void llStopMoveToTarget() 1104 public void llStopMoveToTarget()
1104 { 1105 {
1105 m_host.AddScriptLPS(1); 1106 m_host.AddScriptLPS(1);
1106 NotImplemented("llStopMoveToTarget"); 1107 m_host.StopMoveToTarget();
1108 //NotImplemented("llStopMoveToTarget");
1107 } 1109 }
1108 1110
1109 public void llApplyImpulse(LSL_Types.Vector3 force, int local) 1111 public void llApplyImpulse(LSL_Types.Vector3 force, int local)