diff options
author | UbitUmarov | 2012-02-08 23:14:53 +0000 |
---|---|---|
committer | UbitUmarov | 2012-02-08 23:14:53 +0000 |
commit | 6af01f6767838235091b9e34cdaea05951d68f68 (patch) | |
tree | 18bbf9186fee6aa6884ef824c8dc7e8aed47773a /OpenSim/Region/Framework/Scenes | |
parent | first change in SOP. in AddPrimShape(..) give physics the world rotation and ... (diff) | |
download | opensim-SC_OLD-6af01f6767838235091b9e34cdaea05951d68f68.zip opensim-SC_OLD-6af01f6767838235091b9e34cdaea05951d68f68.tar.gz opensim-SC_OLD-6af01f6767838235091b9e34cdaea05951d68f68.tar.bz2 opensim-SC_OLD-6af01f6767838235091b9e34cdaea05951d68f68.tar.xz |
initial introdution of physics actor building control.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 47 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 |
3 files changed, 58 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ec5cf32..456e86b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4766,7 +4766,7 @@ Environment.Exit(1); | |||
4766 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4766 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4767 | if (wasUsingPhysics) | 4767 | if (wasUsingPhysics) |
4768 | { | 4768 | { |
4769 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock | 4769 | jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock |
4770 | } | 4770 | } |
4771 | } | 4771 | } |
4772 | 4772 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 46c4d7b..2a3d735 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1281,7 +1281,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | 1281 | ||
1282 | m_rootPart.SetParentLocalId(0); | 1282 | m_rootPart.SetParentLocalId(0); |
1283 | AttachmentPoint = (byte)0; | 1283 | AttachmentPoint = (byte)0; |
1284 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | 1284 | // must check if buildind should be true or false here |
1285 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1285 | HasGroupChanged = true; | 1286 | HasGroupChanged = true; |
1286 | RootPart.Rezzed = DateTime.Now; | 1287 | RootPart.Rezzed = DateTime.Now; |
1287 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | 1288 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); |
@@ -1581,21 +1582,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
1581 | public void ApplyPhysics() | 1582 | public void ApplyPhysics() |
1582 | { | 1583 | { |
1583 | // Apply physics to the root prim | 1584 | // Apply physics to the root prim |
1584 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | 1585 | // m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); |
1585 | 1586 | ||
1586 | // Apply physics to child prims | 1587 | // Apply physics to child prims |
1587 | SceneObjectPart[] parts = m_parts.GetArray(); | 1588 | SceneObjectPart[] parts = m_parts.GetArray(); |
1588 | if (parts.Length > 1) | 1589 | if (parts.Length > 1) |
1589 | { | 1590 | { |
1591 | ResetChildPrimPhysicsPositions(); | ||
1592 | |||
1593 | // Apply physics to the root prim | ||
1594 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1590 | for (int i = 0; i < parts.Length; i++) | 1595 | for (int i = 0; i < parts.Length; i++) |
1591 | { | 1596 | { |
1592 | SceneObjectPart part = parts[i]; | 1597 | SceneObjectPart part = parts[i]; |
1593 | if (part.LocalId != m_rootPart.LocalId) | 1598 | if (part.LocalId != m_rootPart.LocalId) |
1594 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1599 | // part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); |
1595 | } | 1600 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1596 | 1601 | ||
1602 | } | ||
1597 | // Hack to get the physics scene geometries in the right spot | 1603 | // Hack to get the physics scene geometries in the right spot |
1598 | ResetChildPrimPhysicsPositions(); | 1604 | // ResetChildPrimPhysicsPositions(); |
1605 | if (m_rootPart.PhysActor != null) | ||
1606 | m_rootPart.PhysActor.Building = false; | ||
1607 | } | ||
1608 | else | ||
1609 | { | ||
1610 | // Apply physics to the root prim | ||
1611 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1599 | } | 1612 | } |
1600 | } | 1613 | } |
1601 | 1614 | ||
@@ -1829,13 +1842,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1829 | pbs, | 1842 | pbs, |
1830 | newPart.AbsolutePosition, | 1843 | newPart.AbsolutePosition, |
1831 | newPart.Scale, | 1844 | newPart.Scale, |
1832 | newPart.RotationOffset, | 1845 | //newPart.RotationOffset, |
1846 | newPart.GetWorldRotation(), | ||
1833 | part.PhysActor.IsPhysical, | 1847 | part.PhysActor.IsPhysical, |
1834 | newPart.LocalId); | 1848 | newPart.LocalId); |
1835 | 1849 | ||
1836 | newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); | 1850 | newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); |
1837 | } | 1851 | } |
1838 | } | 1852 | } |
1853 | if (dupe.m_rootPart.PhysActor != null && userExposed) | ||
1854 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
1839 | 1855 | ||
1840 | if (userExposed) | 1856 | if (userExposed) |
1841 | { | 1857 | { |
@@ -2849,12 +2865,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2849 | } | 2865 | } |
2850 | } | 2866 | } |
2851 | 2867 | ||
2868 | /* | ||
2852 | RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 2869 | RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); |
2853 | for (int i = 0; i < parts.Length; i++) | 2870 | for (int i = 0; i < parts.Length; i++) |
2854 | { | 2871 | { |
2855 | if (parts[i] != RootPart) | 2872 | if (parts[i] != RootPart) |
2856 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 2873 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); |
2857 | } | 2874 | } |
2875 | */ | ||
2876 | if (parts.Length > 1) | ||
2877 | { | ||
2878 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
2879 | |||
2880 | for (int i = 0; i < parts.Length; i++) | ||
2881 | { | ||
2882 | |||
2883 | if (parts[i].UUID != m_rootPart.UUID) | ||
2884 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
2885 | } | ||
2886 | |||
2887 | if (m_rootPart.PhysActor != null) | ||
2888 | m_rootPart.PhysActor.Building = false; | ||
2889 | } | ||
2890 | else | ||
2891 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2892 | |||
2858 | } | 2893 | } |
2859 | } | 2894 | } |
2860 | 2895 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1696dc5..577c0d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -1503,7 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1503 | /// </summary> | 1503 | /// </summary> |
1504 | /// <param name="rootObjectFlags"></param> | 1504 | /// <param name="rootObjectFlags"></param> |
1505 | /// <param name="VolumeDetectActive"></param> | 1505 | /// <param name="VolumeDetectActive"></param> |
1506 | public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) | 1506 | // public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) |
1507 | public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building) | ||
1507 | { | 1508 | { |
1508 | if (!ParentGroup.Scene.CollidablePrims) | 1509 | if (!ParentGroup.Scene.CollidablePrims) |
1509 | return; | 1510 | return; |
@@ -1557,6 +1558,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1557 | PhysActor.SetMaterial(Material); | 1558 | PhysActor.SetMaterial(Material); |
1558 | DoPhysicsPropertyUpdate(RigidBody, true); | 1559 | DoPhysicsPropertyUpdate(RigidBody, true); |
1559 | PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | 1560 | PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); |
1561 | if (!building) | ||
1562 | PhysActor.Building = false; | ||
1560 | } | 1563 | } |
1561 | } | 1564 | } |
1562 | } | 1565 | } |
@@ -1792,6 +1795,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | if (!isNew) | 1795 | if (!isNew) |
1793 | ParentGroup.Scene.RemovePhysicalPrim(1); | 1796 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1794 | 1797 | ||
1798 | Velocity = new Vector3(0, 0, 0); | ||
1799 | Acceleration = new Vector3(0, 0, 0); | ||
1800 | AngularVelocity = new Vector3(0, 0, 0); | ||
1801 | |||
1795 | PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 1802 | PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1796 | PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; | 1803 | PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; |
1797 | PhysActor.delink(); | 1804 | PhysActor.delink(); |
@@ -4268,7 +4275,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4268 | /// <param name="SetTemporary"></param> | 4275 | /// <param name="SetTemporary"></param> |
4269 | /// <param name="SetPhantom"></param> | 4276 | /// <param name="SetPhantom"></param> |
4270 | /// <param name="SetVD"></param> | 4277 | /// <param name="SetVD"></param> |
4271 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4278 | // public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) |
4279 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) | ||
4272 | { | 4280 | { |
4273 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4281 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
4274 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4282 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -4286,6 +4294,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4286 | // that... | 4294 | // that... |
4287 | // ... if VD is changed, all others are not. | 4295 | // ... if VD is changed, all others are not. |
4288 | // ... if one of the others is changed, VD is not. | 4296 | // ... if one of the others is changed, VD is not. |
4297 | // do this first | ||
4298 | if (building && PhysActor != null && PhysActor.Building != building) | ||
4299 | PhysActor.Building = building; | ||
4289 | if (SetVD) // VD is active, special logic applies | 4300 | if (SetVD) // VD is active, special logic applies |
4290 | { | 4301 | { |
4291 | // State machine logic for VolumeDetect | 4302 | // State machine logic for VolumeDetect |
@@ -4448,6 +4459,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4448 | } | 4459 | } |
4449 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4460 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4450 | 4461 | ||
4462 | // and last in case we have a new actor and not building | ||
4463 | if (PhysActor != null && PhysActor.Building != building) | ||
4464 | PhysActor.Building = building; | ||
4451 | if (ParentGroup != null) | 4465 | if (ParentGroup != null) |
4452 | { | 4466 | { |
4453 | ParentGroup.HasGroupChanged = true; | 4467 | ParentGroup.HasGroupChanged = true; |