diff options
author | Teravus Ovares | 2008-12-14 14:30:28 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-12-14 14:30:28 +0000 |
commit | 8ad6f575ebc23f0c7b282b9ec2543bce26287e54 (patch) | |
tree | ab424abb19a070cce386a5013b3d5452dbdf9bc2 /OpenSim | |
parent | Added ATTACH_HUD_* constants fixes Mantis #2823 (diff) | |
download | opensim-SC-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.zip opensim-SC-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.tar.gz opensim-SC-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.tar.bz2 opensim-SC-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.tar.xz |
* Implements the torque/Rotational Impulse methods in the PhysicsAPI and the ODEPlugin and pipes them to their respective LSL method.
* NBody will need to be updated, this is an API change. Torque property and AddAngularForce
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 58 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 62 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 83 | ||||
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSPrim.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 18 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 |
11 files changed, 287 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index fabf276..cc99929 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -1466,6 +1466,64 @@ namespace OpenSim.Region.Environment.Scenes | |||
1466 | } | 1466 | } |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | public void applyAngularImpulse(PhysicsVector impulse) | ||
1470 | { | ||
1471 | // We check if rootpart is null here because scripts don't delete if you delete the host. | ||
1472 | // This means that unfortunately, we can pass a null physics actor to Simulate! | ||
1473 | // Make sure we don't do that! | ||
1474 | SceneObjectPart rootpart = m_rootPart; | ||
1475 | if (rootpart != null) | ||
1476 | { | ||
1477 | if (rootpart.PhysActor != null) | ||
1478 | { | ||
1479 | if (!IsAttachment) | ||
1480 | { | ||
1481 | rootpart.PhysActor.AddAngularForce(impulse, true); | ||
1482 | m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); | ||
1483 | } | ||
1484 | } | ||
1485 | } | ||
1486 | } | ||
1487 | |||
1488 | public void setAngularImpulse(PhysicsVector impulse) | ||
1489 | { | ||
1490 | // We check if rootpart is null here because scripts don't delete if you delete the host. | ||
1491 | // This means that unfortunately, we can pass a null physics actor to Simulate! | ||
1492 | // Make sure we don't do that! | ||
1493 | SceneObjectPart rootpart = m_rootPart; | ||
1494 | if (rootpart != null) | ||
1495 | { | ||
1496 | if (rootpart.PhysActor != null) | ||
1497 | { | ||
1498 | if (!IsAttachment) | ||
1499 | { | ||
1500 | rootpart.PhysActor.Torque = impulse; | ||
1501 | m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); | ||
1502 | } | ||
1503 | } | ||
1504 | } | ||
1505 | } | ||
1506 | |||
1507 | public Vector3 GetTorque() | ||
1508 | { | ||
1509 | // We check if rootpart is null here because scripts don't delete if you delete the host. | ||
1510 | // This means that unfortunately, we can pass a null physics actor to Simulate! | ||
1511 | // Make sure we don't do that! | ||
1512 | SceneObjectPart rootpart = m_rootPart; | ||
1513 | if (rootpart != null) | ||
1514 | { | ||
1515 | if (rootpart.PhysActor != null) | ||
1516 | { | ||
1517 | if (!IsAttachment) | ||
1518 | { | ||
1519 | PhysicsVector torque = rootpart.PhysActor.Torque; | ||
1520 | return new Vector3(torque.X, torque.Y, torque.Z); | ||
1521 | } | ||
1522 | } | ||
1523 | } | ||
1524 | return Vector3.Zero; | ||
1525 | } | ||
1526 | |||
1469 | public void moveToTarget(Vector3 target, float tau) | 1527 | public void moveToTarget(Vector3 target, float tau) |
1470 | { | 1528 | { |
1471 | SceneObjectPart rootpart = m_rootPart; | 1529 | SceneObjectPart rootpart = m_rootPart; |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index efc9289..5a43df6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -1180,6 +1180,68 @@ if (m_shape != null) { | |||
1180 | } | 1180 | } |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | |||
1184 | /// <summary> | ||
1185 | /// hook to the physics scene to apply angular impulse | ||
1186 | /// This is sent up to the group, which then finds the root prim | ||
1187 | /// and applies the force on the root prim of the group | ||
1188 | /// </summary> | ||
1189 | /// <param name="impulsei">Vector force</param> | ||
1190 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | ||
1191 | public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) | ||
1192 | { | ||
1193 | PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); | ||
1194 | |||
1195 | if (localGlobalTF) | ||
1196 | { | ||
1197 | Quaternion grot = GetWorldRotation(); | ||
1198 | Quaternion AXgrot = grot; | ||
1199 | Vector3 AXimpulsei = impulsei; | ||
1200 | Vector3 newimpulse = AXimpulsei * AXgrot; | ||
1201 | impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); | ||
1202 | } | ||
1203 | |||
1204 | if (m_parentGroup != null) | ||
1205 | { | ||
1206 | m_parentGroup.applyAngularImpulse(impulse); | ||
1207 | } | ||
1208 | } | ||
1209 | |||
1210 | /// <summary> | ||
1211 | /// hook to the physics scene to apply angular impulse | ||
1212 | /// This is sent up to the group, which then finds the root prim | ||
1213 | /// and applies the force on the root prim of the group | ||
1214 | /// </summary> | ||
1215 | /// <param name="impulsei">Vector force</param> | ||
1216 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | ||
1217 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | ||
1218 | { | ||
1219 | PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); | ||
1220 | |||
1221 | if (localGlobalTF) | ||
1222 | { | ||
1223 | Quaternion grot = GetWorldRotation(); | ||
1224 | Quaternion AXgrot = grot; | ||
1225 | Vector3 AXimpulsei = impulsei; | ||
1226 | Vector3 newimpulse = AXimpulsei * AXgrot; | ||
1227 | impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); | ||
1228 | } | ||
1229 | |||
1230 | if (m_parentGroup != null) | ||
1231 | { | ||
1232 | m_parentGroup.setAngularImpulse(impulse); | ||
1233 | } | ||
1234 | } | ||
1235 | |||
1236 | public Vector3 GetTorque() | ||
1237 | { | ||
1238 | if (m_parentGroup != null) | ||
1239 | { | ||
1240 | m_parentGroup.GetTorque(); | ||
1241 | } | ||
1242 | return Vector3.Zero; | ||
1243 | } | ||
1244 | |||
1183 | /// <summary> | 1245 | /// <summary> |
1184 | /// Apply physics to this part. | 1246 | /// Apply physics to this part. |
1185 | /// </summary> | 1247 | /// </summary> |
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 9954798..013c9cf 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | |||
@@ -381,6 +381,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
381 | set { _velocity = value; } | 381 | set { _velocity = value; } |
382 | } | 382 | } |
383 | 383 | ||
384 | public override PhysicsVector Torque | ||
385 | { | ||
386 | get { return PhysicsVector.Zero; } | ||
387 | set { return; } | ||
388 | } | ||
389 | |||
384 | public override float CollisionScore | 390 | public override float CollisionScore |
385 | { | 391 | { |
386 | get { return 0f; } | 392 | get { return 0f; } |
@@ -426,6 +432,10 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
426 | { | 432 | { |
427 | } | 433 | } |
428 | 434 | ||
435 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
436 | { | ||
437 | } | ||
438 | |||
429 | public override void SetMomentum(PhysicsVector momentum) | 439 | public override void SetMomentum(PhysicsVector momentum) |
430 | { | 440 | { |
431 | } | 441 | } |
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 20c556f..4f1afdd 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -1134,6 +1134,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
1134 | public override void AddForce(PhysicsVector force, bool pushforce) | 1134 | public override void AddForce(PhysicsVector force, bool pushforce) |
1135 | { | 1135 | { |
1136 | } | 1136 | } |
1137 | public override PhysicsVector Torque | ||
1138 | { | ||
1139 | get { return PhysicsVector.Zero; } | ||
1140 | set { return; } | ||
1141 | } | ||
1142 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
1143 | { | ||
1144 | } | ||
1137 | 1145 | ||
1138 | public override void SetMomentum(PhysicsVector momentum) | 1146 | public override void SetMomentum(PhysicsVector momentum) |
1139 | { | 1147 | { |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 3c094ad..fd02057 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -185,6 +185,7 @@ namespace OpenSim.Region.Physics.Manager | |||
185 | public abstract PhysicsVector GeometricCenter { get; } | 185 | public abstract PhysicsVector GeometricCenter { get; } |
186 | public abstract PhysicsVector CenterOfMass { get; } | 186 | public abstract PhysicsVector CenterOfMass { get; } |
187 | public abstract PhysicsVector Velocity { get; set; } | 187 | public abstract PhysicsVector Velocity { get; set; } |
188 | public abstract PhysicsVector Torque { get; set; } | ||
188 | public abstract float CollisionScore { get; set;} | 189 | public abstract float CollisionScore { get; set;} |
189 | public abstract PhysicsVector Acceleration { get; } | 190 | public abstract PhysicsVector Acceleration { get; } |
190 | public abstract Quaternion Orientation { get; set; } | 191 | public abstract Quaternion Orientation { get; set; } |
@@ -204,6 +205,7 @@ namespace OpenSim.Region.Physics.Manager | |||
204 | public abstract bool PIDActive { set;} | 205 | public abstract bool PIDActive { set;} |
205 | public abstract float PIDTau { set; } | 206 | public abstract float PIDTau { set; } |
206 | public abstract void AddForce(PhysicsVector force, bool pushforce); | 207 | public abstract void AddForce(PhysicsVector force, bool pushforce); |
208 | public abstract void AddAngularForce(PhysicsVector force, bool pushforce); | ||
207 | public abstract void SetMomentum(PhysicsVector momentum); | 209 | public abstract void SetMomentum(PhysicsVector momentum); |
208 | public abstract void SubscribeEvents(int ms); | 210 | public abstract void SubscribeEvents(int ms); |
209 | public abstract void UnSubscribeEvents(); | 211 | public abstract void UnSubscribeEvents(); |
@@ -331,6 +333,12 @@ namespace OpenSim.Region.Physics.Manager | |||
331 | set { return; } | 333 | set { return; } |
332 | } | 334 | } |
333 | 335 | ||
336 | public override PhysicsVector Torque | ||
337 | { | ||
338 | get { return PhysicsVector.Zero; } | ||
339 | set { return; } | ||
340 | } | ||
341 | |||
334 | public override float CollisionScore | 342 | public override float CollisionScore |
335 | { | 343 | { |
336 | get { return 0f; } | 344 | get { return 0f; } |
@@ -404,6 +412,11 @@ namespace OpenSim.Region.Physics.Manager | |||
404 | { | 412 | { |
405 | } | 413 | } |
406 | 414 | ||
415 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
416 | { | ||
417 | |||
418 | } | ||
419 | |||
407 | public override PhysicsVector RotationalVelocity | 420 | public override PhysicsVector RotationalVelocity |
408 | { | 421 | { |
409 | get { return PhysicsVector.Zero; } | 422 | get { return PhysicsVector.Zero; } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index de09691..f2906cf 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -605,6 +605,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | public override PhysicsVector Torque | ||
609 | { | ||
610 | get { return PhysicsVector.Zero; } | ||
611 | set { return; } | ||
612 | } | ||
613 | |||
608 | public override float CollisionScore | 614 | public override float CollisionScore |
609 | { | 615 | { |
610 | get { return 0f; } | 616 | get { return 0f; } |
@@ -665,6 +671,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
665 | //m_lastUpdateSent = false; | 671 | //m_lastUpdateSent = false; |
666 | } | 672 | } |
667 | 673 | ||
674 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
675 | { | ||
676 | |||
677 | } | ||
678 | |||
668 | /// <summary> | 679 | /// <summary> |
669 | /// After all of the forces add up with 'add force' we apply them with doForce | 680 | /// After all of the forces add up with 'add force' we apply them with doForce |
670 | /// </summary> | 681 | /// </summary> |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index eeef893..6f5abfa 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -47,6 +47,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
47 | 47 | ||
48 | public PhysicsVector _position; | 48 | public PhysicsVector _position; |
49 | private PhysicsVector _velocity; | 49 | private PhysicsVector _velocity; |
50 | private PhysicsVector _torque = new PhysicsVector(0,0,0); | ||
50 | private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); | 51 | private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); |
51 | private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); | 52 | private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); |
52 | private PhysicsVector m_rotationalVelocity; | 53 | private PhysicsVector m_rotationalVelocity; |
@@ -56,7 +57,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
56 | private Quaternion _orientation; | 57 | private Quaternion _orientation; |
57 | private PhysicsVector m_taintposition; | 58 | private PhysicsVector m_taintposition; |
58 | private PhysicsVector m_taintsize; | 59 | private PhysicsVector m_taintsize; |
59 | private PhysicsVector m_taintVelocity = PhysicsVector.Zero; | 60 | private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); |
61 | private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); | ||
60 | private Quaternion m_taintrot; | 62 | private Quaternion m_taintrot; |
61 | private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); | 63 | private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); |
62 | private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); | 64 | private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); |
@@ -102,8 +104,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
102 | private CollisionLocker ode; | 104 | private CollisionLocker ode; |
103 | 105 | ||
104 | private bool m_taintforce = false; | 106 | private bool m_taintforce = false; |
107 | private bool m_taintaddangularforce = false; | ||
105 | private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); | 108 | private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); |
106 | private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); | 109 | private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); |
110 | private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); | ||
107 | 111 | ||
108 | private IMesh _mesh; | 112 | private IMesh _mesh; |
109 | private PrimitiveBaseShape _pbs; | 113 | private PrimitiveBaseShape _pbs; |
@@ -838,6 +842,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
838 | if (m_taintforce) | 842 | if (m_taintforce) |
839 | changeAddForce(timestep); | 843 | changeAddForce(timestep); |
840 | 844 | ||
845 | if (m_taintaddangularforce) | ||
846 | changeAddAngularForce(timestep); | ||
847 | |||
848 | if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) | ||
849 | changeSetTorque(timestep); | ||
850 | |||
841 | if (m_taintdisable) | 851 | if (m_taintdisable) |
842 | changedisable(timestep); | 852 | changedisable(timestep); |
843 | 853 | ||
@@ -2058,6 +2068,49 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2058 | 2068 | ||
2059 | } | 2069 | } |
2060 | 2070 | ||
2071 | |||
2072 | |||
2073 | public void changeSetTorque(float timestamp) | ||
2074 | { | ||
2075 | if (!m_isSelected) | ||
2076 | { | ||
2077 | if (IsPhysical && Body != IntPtr.Zero) | ||
2078 | { | ||
2079 | d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); | ||
2080 | } | ||
2081 | } | ||
2082 | |||
2083 | m_taintTorque = new PhysicsVector(0, 0, 0); | ||
2084 | } | ||
2085 | |||
2086 | public void changeAddAngularForce(float timestamp) | ||
2087 | { | ||
2088 | if (!m_isSelected) | ||
2089 | { | ||
2090 | lock (m_angularforcelist) | ||
2091 | { | ||
2092 | //m_log.Info("[PHYSICS]: dequeing forcelist"); | ||
2093 | if (IsPhysical) | ||
2094 | { | ||
2095 | PhysicsVector iforce = new PhysicsVector(); | ||
2096 | for (int i = 0; i < m_angularforcelist.Count; i++) | ||
2097 | { | ||
2098 | iforce = iforce + (m_angularforcelist[i] * 100); | ||
2099 | } | ||
2100 | d.BodyEnable(Body); | ||
2101 | d.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z); | ||
2102 | |||
2103 | } | ||
2104 | m_angularforcelist.Clear(); | ||
2105 | } | ||
2106 | |||
2107 | m_collisionscore = 0; | ||
2108 | m_interpenetrationcount = 0; | ||
2109 | } | ||
2110 | |||
2111 | m_taintaddangularforce = false; | ||
2112 | } | ||
2113 | |||
2061 | private void changevelocity(float timestep) | 2114 | private void changevelocity(float timestep) |
2062 | { | 2115 | { |
2063 | if (!m_isSelected) | 2116 | if (!m_isSelected) |
@@ -2070,7 +2123,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2070 | d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); | 2123 | d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); |
2071 | } | 2124 | } |
2072 | } | 2125 | } |
2073 | 2126 | ||
2074 | //resetCollisionAccounting(); | 2127 | //resetCollisionAccounting(); |
2075 | } | 2128 | } |
2076 | m_taintVelocity = PhysicsVector.Zero; | 2129 | m_taintVelocity = PhysicsVector.Zero; |
@@ -2216,6 +2269,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2216 | } | 2269 | } |
2217 | } | 2270 | } |
2218 | 2271 | ||
2272 | public override PhysicsVector Torque | ||
2273 | { | ||
2274 | get | ||
2275 | { | ||
2276 | if (!m_isphysical || Body == IntPtr.Zero) | ||
2277 | return new PhysicsVector(0,0,0); | ||
2278 | |||
2279 | return _torque; | ||
2280 | } | ||
2281 | |||
2282 | set | ||
2283 | { | ||
2284 | m_taintTorque = value; | ||
2285 | _parent_scene.AddPhysicsActorTaint(this); | ||
2286 | } | ||
2287 | } | ||
2288 | |||
2219 | public override float CollisionScore | 2289 | public override float CollisionScore |
2220 | { | 2290 | { |
2221 | get { return m_collisionscore; } | 2291 | get { return m_collisionscore; } |
@@ -2252,6 +2322,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2252 | //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); | 2322 | //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); |
2253 | } | 2323 | } |
2254 | 2324 | ||
2325 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
2326 | { | ||
2327 | m_angularforcelist.Add(force); | ||
2328 | m_taintaddangularforce = true; | ||
2329 | } | ||
2330 | |||
2255 | public override PhysicsVector RotationalVelocity | 2331 | public override PhysicsVector RotationalVelocity |
2256 | { | 2332 | { |
2257 | get | 2333 | get |
@@ -2323,7 +2399,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2323 | d.Quaternion ori = d.BodyGetQuaternion(Body); | 2399 | d.Quaternion ori = d.BodyGetQuaternion(Body); |
2324 | d.Vector3 vel = d.BodyGetLinearVel(Body); | 2400 | d.Vector3 vel = d.BodyGetLinearVel(Body); |
2325 | d.Vector3 rotvel = d.BodyGetAngularVel(Body); | 2401 | d.Vector3 rotvel = d.BodyGetAngularVel(Body); |
2326 | 2402 | d.Vector3 torque = d.BodyGetTorque(Body); | |
2403 | _torque.setValues(torque.X, torque.Y, torque.Z); | ||
2327 | PhysicsVector l_position = new PhysicsVector(); | 2404 | PhysicsVector l_position = new PhysicsVector(); |
2328 | 2405 | ||
2329 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) | 2406 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) |
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs index ab66d4c..4230a57 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | |||
@@ -211,6 +211,12 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
211 | set { _target_velocity = value; } | 211 | set { _target_velocity = value; } |
212 | } | 212 | } |
213 | 213 | ||
214 | public override PhysicsVector Torque | ||
215 | { | ||
216 | get { return PhysicsVector.Zero; } | ||
217 | set { return; } | ||
218 | } | ||
219 | |||
214 | public override float CollisionScore | 220 | public override float CollisionScore |
215 | { | 221 | { |
216 | get { return 0f; } | 222 | get { return 0f; } |
@@ -255,6 +261,10 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
255 | { | 261 | { |
256 | } | 262 | } |
257 | 263 | ||
264 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
265 | { | ||
266 | } | ||
267 | |||
258 | public override void SetMomentum(PhysicsVector momentum) | 268 | public override void SetMomentum(PhysicsVector momentum) |
259 | { | 269 | { |
260 | } | 270 | } |
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs index fdd095f..bf96c35 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs | |||
@@ -211,6 +211,16 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
211 | { | 211 | { |
212 | } | 212 | } |
213 | 213 | ||
214 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
215 | { | ||
216 | } | ||
217 | |||
218 | public override PhysicsVector Torque | ||
219 | { | ||
220 | get { return PhysicsVector.Zero; } | ||
221 | set { return; } | ||
222 | } | ||
223 | |||
214 | public override void SetMomentum(PhysicsVector momentum) | 224 | public override void SetMomentum(PhysicsVector momentum) |
215 | { | 225 | { |
216 | } | 226 | } |
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 940c9bc..6502827 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | |||
@@ -417,6 +417,14 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
417 | public override void AddForce(PhysicsVector force, bool pushforce) | 417 | public override void AddForce(PhysicsVector force, bool pushforce) |
418 | { | 418 | { |
419 | } | 419 | } |
420 | public override PhysicsVector Torque | ||
421 | { | ||
422 | get { return PhysicsVector.Zero; } | ||
423 | set { return; } | ||
424 | } | ||
425 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
426 | { | ||
427 | } | ||
420 | 428 | ||
421 | public override void link(PhysicsActor obj) | 429 | public override void link(PhysicsActor obj) |
422 | { | 430 | { |
@@ -625,6 +633,12 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
625 | set { _velocity = value; } | 633 | set { _velocity = value; } |
626 | } | 634 | } |
627 | 635 | ||
636 | public override PhysicsVector Torque | ||
637 | { | ||
638 | get { return PhysicsVector.Zero; } | ||
639 | set { return; } | ||
640 | } | ||
641 | |||
628 | public override float CollisionScore | 642 | public override float CollisionScore |
629 | { | 643 | { |
630 | get { return 0f; } | 644 | get { return 0f; } |
@@ -666,6 +680,10 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
666 | { | 680 | { |
667 | } | 681 | } |
668 | 682 | ||
683 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
684 | { | ||
685 | } | ||
686 | |||
669 | public override void SetMomentum(PhysicsVector momentum) | 687 | public override void SetMomentum(PhysicsVector momentum) |
670 | { | 688 | { |
671 | } | 689 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 68b92a4..84def93 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -1951,26 +1951,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1951 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 1951 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
1952 | { | 1952 | { |
1953 | m_host.AddScriptLPS(1); | 1953 | m_host.AddScriptLPS(1); |
1954 | NotImplemented("llApplyRotationalImpulse"); | 1954 | m_host.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); |
1955 | |||
1955 | } | 1956 | } |
1956 | 1957 | ||
1957 | public void llSetTorque(LSL_Vector torque, int local) | 1958 | public void llSetTorque(LSL_Vector torque, int local) |
1958 | { | 1959 | { |
1959 | m_host.AddScriptLPS(1); | 1960 | m_host.AddScriptLPS(1); |
1960 | NotImplemented("llSetTorque"); | 1961 | m_host.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); |
1961 | } | 1962 | } |
1962 | 1963 | ||
1963 | public LSL_Vector llGetTorque() | 1964 | public LSL_Vector llGetTorque() |
1964 | { | 1965 | { |
1965 | m_host.AddScriptLPS(1); | 1966 | m_host.AddScriptLPS(1); |
1966 | NotImplemented("llGetTorque"); | 1967 | Vector3 torque = m_host.GetTorque(); |
1967 | return new LSL_Vector(); | 1968 | return new LSL_Vector(torque.X,torque.Y,torque.Z); |
1968 | } | 1969 | } |
1969 | 1970 | ||
1970 | public void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local) | 1971 | public void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local) |
1971 | { | 1972 | { |
1972 | m_host.AddScriptLPS(1); | 1973 | m_host.AddScriptLPS(1); |
1973 | NotImplemented("llSetForceAndTorque"); | 1974 | llSetForce(force, local); |
1975 | llSetTorque(torque, local); | ||
1974 | } | 1976 | } |
1975 | 1977 | ||
1976 | public LSL_Vector llGetVel() | 1978 | public LSL_Vector llGetVel() |