aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2008-12-14 14:30:28 +0000
committerTeravus Ovares2008-12-14 14:30:28 +0000
commit8ad6f575ebc23f0c7b282b9ec2543bce26287e54 (patch)
treeab424abb19a070cce386a5013b3d5452dbdf9bc2 /OpenSim/Region/Environment
parentAdded ATTACH_HUD_* constants fixes Mantis #2823 (diff)
downloadopensim-SC_OLD-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.zip
opensim-SC_OLD-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.tar.gz
opensim-SC_OLD-8ad6f575ebc23f0c7b282b9ec2543bce26287e54.tar.bz2
opensim-SC_OLD-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 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs58
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs62
2 files changed, 120 insertions, 0 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>