diff options
author | UbitUmarov | 2012-02-25 22:20:25 +0000 |
---|---|---|
committer | UbitUmarov | 2012-02-25 22:20:25 +0000 |
commit | e07440d0c53fdc8e90f4887242e3b21049a729c0 (patch) | |
tree | cba4154ec1678c27aa9b4adf1c9a80088554dac1 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | Merge branch 'master' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff) | |
download | opensim-SC-e07440d0c53fdc8e90f4887242e3b21049a729c0.zip opensim-SC-e07440d0c53fdc8e90f4887242e3b21049a729c0.tar.gz opensim-SC-e07440d0c53fdc8e90f4887242e3b21049a729c0.tar.bz2 opensim-SC-e07440d0c53fdc8e90f4887242e3b21049a729c0.tar.xz |
changed SOP Force and Torque, adding XML (de/)serialization, also changed Buoyance. PLEASE trap deserialization from inventory etc, making force and torque vector3.Zero, unless we want then to rez moving. (needs checking/testing as usual)
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 93 |
1 files changed, 81 insertions, 12 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dd9431b..f35a27e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -294,6 +294,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
294 | protected Vector3 m_lastAngularVelocity; | 294 | protected Vector3 m_lastAngularVelocity; |
295 | protected int m_lastTerseSent; | 295 | protected int m_lastTerseSent; |
296 | protected float m_buoyancy = 0.0f; | 296 | protected float m_buoyancy = 0.0f; |
297 | protected Vector3 m_force; | ||
298 | protected Vector3 m_torque; | ||
297 | 299 | ||
298 | /// <summary> | 300 | /// <summary> |
299 | /// Stores media texture data | 301 | /// Stores media texture data |
@@ -1302,14 +1304,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
1302 | 1304 | ||
1303 | public float Buoyancy | 1305 | public float Buoyancy |
1304 | { | 1306 | { |
1305 | get { return m_buoyancy; } | 1307 | get |
1308 | { | ||
1309 | if (ParentID != 0 && ParentGroup != null) | ||
1310 | m_buoyancy = ParentGroup.RootPart.Buoyancy; | ||
1311 | return m_buoyancy; | ||
1312 | } | ||
1306 | set | 1313 | set |
1307 | { | 1314 | { |
1308 | m_buoyancy = value; | 1315 | m_buoyancy = value; |
1309 | if (PhysActor != null) | 1316 | if (ParentID != 0) |
1310 | { | 1317 | { |
1318 | if (ParentGroup != null) | ||
1319 | ParentGroup.RootPart.Buoyancy = value; | ||
1320 | } | ||
1321 | else if (PhysActor != null) | ||
1311 | PhysActor.Buoyancy = value; | 1322 | PhysActor.Buoyancy = value; |
1323 | } | ||
1324 | } | ||
1325 | |||
1326 | public Vector3 Force | ||
1327 | { | ||
1328 | get | ||
1329 | { | ||
1330 | if (ParentID != 0 && ParentGroup != null) | ||
1331 | m_force = ParentGroup.RootPart.Force; | ||
1332 | return m_force; | ||
1333 | } | ||
1334 | |||
1335 | set | ||
1336 | { | ||
1337 | m_force = value; | ||
1338 | if (ParentID != 0) | ||
1339 | { | ||
1340 | if (ParentGroup != null) | ||
1341 | ParentGroup.RootPart.Force = value; | ||
1312 | } | 1342 | } |
1343 | else if (PhysActor != null) | ||
1344 | PhysActor.Force = value; | ||
1345 | } | ||
1346 | } | ||
1347 | |||
1348 | public Vector3 Torque | ||
1349 | { | ||
1350 | get | ||
1351 | { | ||
1352 | if (ParentID != 0 && ParentGroup != null) | ||
1353 | m_torque = ParentGroup.RootPart.Torque; | ||
1354 | return m_torque; | ||
1355 | } | ||
1356 | |||
1357 | set | ||
1358 | { | ||
1359 | m_torque = value; | ||
1360 | if (ParentID != 0) | ||
1361 | { | ||
1362 | if (ParentGroup != null) | ||
1363 | ParentGroup.RootPart.Torque = value; | ||
1364 | } | ||
1365 | else if (PhysActor != null) | ||
1366 | PhysActor.Torque = value; | ||
1313 | } | 1367 | } |
1314 | } | 1368 | } |
1315 | 1369 | ||
@@ -1488,20 +1542,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1488 | /// </summary> | 1542 | /// </summary> |
1489 | /// <param name="impulsei">Vector force</param> | 1543 | /// <param name="impulsei">Vector force</param> |
1490 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1544 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1491 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 1545 | |
1546 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
1547 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1492 | { | 1548 | { |
1493 | Vector3 impulse = impulsei; | 1549 | Vector3 torque = torquei; |
1494 | 1550 | ||
1495 | if (localGlobalTF) | 1551 | if (localGlobalTF) |
1496 | { | 1552 | { |
1553 | /* | ||
1497 | Quaternion grot = GetWorldRotation(); | 1554 | Quaternion grot = GetWorldRotation(); |
1498 | Quaternion AXgrot = grot; | 1555 | Quaternion AXgrot = grot; |
1499 | Vector3 AXimpulsei = impulsei; | 1556 | Vector3 AXimpulsei = impulsei; |
1500 | Vector3 newimpulse = AXimpulsei * AXgrot; | 1557 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1501 | impulse = newimpulse; | 1558 | */ |
1559 | torque *= GetWorldRotation(); | ||
1502 | } | 1560 | } |
1503 | 1561 | ||
1504 | ParentGroup.setAngularImpulse(impulse); | 1562 | Torque = torque; |
1505 | } | 1563 | } |
1506 | 1564 | ||
1507 | /// <summary> | 1565 | /// <summary> |
@@ -1571,14 +1629,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1571 | 1629 | ||
1572 | DoPhysicsPropertyUpdate(RigidBody, true); | 1630 | DoPhysicsPropertyUpdate(RigidBody, true); |
1573 | PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | 1631 | PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); |
1632 | |||
1633 | if (!building) | ||
1634 | PhysActor.Building = false; | ||
1574 | 1635 | ||
1575 | Velocity = velocity; | 1636 | Velocity = velocity; |
1576 | AngularVelocity = rotationalVelocity; | 1637 | AngularVelocity = rotationalVelocity; |
1577 | PhysActor.Velocity = velocity; | 1638 | PhysActor.Velocity = velocity; |
1578 | PhysActor.RotationalVelocity = rotationalVelocity; | 1639 | PhysActor.RotationalVelocity = rotationalVelocity; |
1579 | 1640 | ||
1580 | if (!building) | 1641 | // if not vehicle and root part apply force and torque |
1581 | PhysActor.Building = false; | 1642 | if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) |
1643 | && LocalId == ParentGroup.RootPart.LocalId) | ||
1644 | { | ||
1645 | PhysActor.Force = Force; | ||
1646 | PhysActor.Torque = Torque; | ||
1647 | } | ||
1582 | } | 1648 | } |
1583 | } | 1649 | } |
1584 | } | 1650 | } |
@@ -2002,10 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2002 | 2068 | ||
2003 | public Vector3 GetForce() | 2069 | public Vector3 GetForce() |
2004 | { | 2070 | { |
2005 | if (PhysActor != null) | 2071 | return Force; |
2006 | return PhysActor.Force; | ||
2007 | else | ||
2008 | return Vector3.Zero; | ||
2009 | } | 2072 | } |
2010 | 2073 | ||
2011 | /// <summary> | 2074 | /// <summary> |
@@ -3150,10 +3213,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3150 | 3213 | ||
3151 | public void SetBuoyancy(float fvalue) | 3214 | public void SetBuoyancy(float fvalue) |
3152 | { | 3215 | { |
3216 | Buoyancy = fvalue; | ||
3217 | /* | ||
3153 | if (PhysActor != null) | 3218 | if (PhysActor != null) |
3154 | { | 3219 | { |
3155 | PhysActor.Buoyancy = fvalue; | 3220 | PhysActor.Buoyancy = fvalue; |
3156 | } | 3221 | } |
3222 | */ | ||
3157 | } | 3223 | } |
3158 | 3224 | ||
3159 | public void SetDieAtEdge(bool p) | 3225 | public void SetDieAtEdge(bool p) |
@@ -3181,10 +3247,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3181 | 3247 | ||
3182 | public void SetForce(Vector3 force) | 3248 | public void SetForce(Vector3 force) |
3183 | { | 3249 | { |
3250 | Force = force; | ||
3251 | /* | ||
3184 | if (PhysActor != null) | 3252 | if (PhysActor != null) |
3185 | { | 3253 | { |
3186 | PhysActor.Force = force; | 3254 | PhysActor.Force = force; |
3187 | } | 3255 | } |
3256 | */ | ||
3188 | } | 3257 | } |
3189 | 3258 | ||
3190 | public SOPVehicle sopVehicle | 3259 | public SOPVehicle sopVehicle |