diff options
author | UbitUmarov | 2012-04-04 15:43:07 +0100 |
---|---|---|
committer | UbitUmarov | 2012-04-04 15:43:07 +0100 |
commit | 823895b997c13458fa70c7a75490afdcb680886e (patch) | |
tree | 6dec6536893525430c182852d631fb912515081a /OpenSim/Region/Framework/Scenes | |
parent | Merge branch 'master' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff) | |
parent | Fix the last merge artefacts (diff) | |
download | opensim-SC_OLD-823895b997c13458fa70c7a75490afdcb680886e.zip opensim-SC_OLD-823895b997c13458fa70c7a75490afdcb680886e.tar.gz opensim-SC_OLD-823895b997c13458fa70c7a75490afdcb680886e.tar.bz2 opensim-SC_OLD-823895b997c13458fa70c7a75490afdcb680886e.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 123 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 153 |
4 files changed, 169 insertions, 114 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 539ca14..df37b98 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -666,10 +666,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
666 | 666 | ||
667 | #endregion Region Settings | 667 | #endregion Region Settings |
668 | 668 | ||
669 | MainConsole.Instance.Commands.AddCommand("Estates", false, "reload estate", | ||
670 | "reload estate", | ||
671 | "Reload the estate data", HandleReloadEstate); | ||
672 | |||
673 | //Bind Storage Manager functions to some land manager functions for this scene | 669 | //Bind Storage Manager functions to some land manager functions for this scene |
674 | EventManager.OnLandObjectAdded += | 670 | EventManager.OnLandObjectAdded += |
675 | new EventManager.LandObjectAdded(simDataService.StoreLandObject); | 671 | new EventManager.LandObjectAdded(simDataService.StoreLandObject); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 9fdbc54..cd4bd42 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -348,7 +348,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
348 | if (rot != null) | 348 | if (rot != null) |
349 | sceneObject.UpdateGroupRotationR((Quaternion)rot); | 349 | sceneObject.UpdateGroupRotationR((Quaternion)rot); |
350 | 350 | ||
351 | if (sceneObject.RootPart.PhysActor != null && sceneObject.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) | 351 | PhysicsActor pa = sceneObject.RootPart.PhysActor; |
352 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) | ||
352 | { | 353 | { |
353 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | 354 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); |
354 | sceneObject.Velocity = vel; | 355 | sceneObject.Velocity = vel; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 11fd721..5f33452 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -725,16 +725,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
725 | { | 725 | { |
726 | m_isSelected = value; | 726 | m_isSelected = value; |
727 | // Tell physics engine that group is selected | 727 | // Tell physics engine that group is selected |
728 | if (m_rootPart.PhysActor != null) | 728 | |
729 | PhysicsActor pa = m_rootPart.PhysActor; | ||
730 | if (pa != null) | ||
729 | { | 731 | { |
730 | m_rootPart.PhysActor.Selected = value; | 732 | pa.Selected = value; |
733 | |||
731 | // Pass it on to the children. | 734 | // Pass it on to the children. |
732 | SceneObjectPart[] parts = m_parts.GetArray(); | 735 | SceneObjectPart[] parts = m_parts.GetArray(); |
733 | for (int i = 0; i < parts.Length; i++) | 736 | for (int i = 0; i < parts.Length; i++) |
734 | { | 737 | { |
735 | SceneObjectPart child = parts[i]; | 738 | SceneObjectPart child = parts[i]; |
736 | if (child.PhysActor != null) | 739 | |
737 | child.PhysActor.Selected = value; | 740 | PhysicsActor childPa = child.PhysActor; |
741 | if (childPa != null) | ||
742 | childPa.Selected = value; | ||
738 | } | 743 | } |
739 | } | 744 | } |
740 | if (RootPart.KeyframeMotion != null) | 745 | if (RootPart.KeyframeMotion != null) |
@@ -2166,22 +2171,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2166 | } | 2171 | } |
2167 | else | 2172 | else |
2168 | { | 2173 | { |
2169 | if (RootPart.PhysActor != null) | 2174 | PhysicsActor pa = RootPart.PhysActor; |
2175 | |||
2176 | if (pa != null) | ||
2170 | { | 2177 | { |
2171 | RootPart.PhysActor.AddForce(impulse, true); | 2178 | pa.AddForce(impulse, true); |
2172 | m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); | 2179 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2173 | } | 2180 | } |
2174 | } | 2181 | } |
2175 | } | 2182 | } |
2176 | 2183 | ||
2177 | public void applyAngularImpulse(Vector3 impulse) | 2184 | public void setAngularImpulse(Vector3 impulse) |
2178 | { | 2185 | { |
2179 | if (RootPart.PhysActor != null) | 2186 | PhysicsActor pa = RootPart.PhysActor; |
2187 | |||
2188 | if (pa != null) | ||
2180 | { | 2189 | { |
2181 | if (!IsAttachment) | 2190 | if (!IsAttachment) |
2182 | { | 2191 | { |
2183 | RootPart.PhysActor.AddAngularForce(impulse, true); | 2192 | pa.Torque = impulse; |
2184 | m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); | 2193 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2185 | } | 2194 | } |
2186 | } | 2195 | } |
2187 | } | 2196 | } |
@@ -2204,19 +2213,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2204 | } | 2213 | } |
2205 | else | 2214 | else |
2206 | { | 2215 | { |
2207 | if (RootPart.PhysActor != null) | 2216 | PhysicsActor pa = RootPart.PhysActor; |
2217 | |||
2218 | if (pa != null) | ||
2208 | { | 2219 | { |
2209 | RootPart.PhysActor.PIDTarget = target; | 2220 | pa.PIDTarget = target; |
2210 | RootPart.PhysActor.PIDTau = tau; | 2221 | pa.PIDTau = tau; |
2211 | RootPart.PhysActor.PIDActive = true; | 2222 | pa.PIDActive = true; |
2212 | } | 2223 | } |
2213 | } | 2224 | } |
2214 | } | 2225 | } |
2215 | 2226 | ||
2216 | public void stopMoveToTarget() | 2227 | public void stopMoveToTarget() |
2217 | { | 2228 | { |
2218 | if (RootPart.PhysActor != null) | 2229 | PhysicsActor pa = RootPart.PhysActor; |
2219 | RootPart.PhysActor.PIDActive = false; | 2230 | |
2231 | if (pa != null) | ||
2232 | pa.PIDActive = false; | ||
2220 | } | 2233 | } |
2221 | 2234 | ||
2222 | public void rotLookAt(Quaternion target, float strength, float damping) | 2235 | public void rotLookAt(Quaternion target, float strength, float damping) |
@@ -2267,18 +2280,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2267 | /// <param name="tau">Number of seconds over which to reach target</param> | 2280 | /// <param name="tau">Number of seconds over which to reach target</param> |
2268 | public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) | 2281 | public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) |
2269 | { | 2282 | { |
2270 | if (RootPart.PhysActor != null) | 2283 | PhysicsActor pa = RootPart.PhysActor; |
2284 | |||
2285 | if (pa != null) | ||
2271 | { | 2286 | { |
2272 | if (height != 0f) | 2287 | if (height != 0f) |
2273 | { | 2288 | { |
2274 | RootPart.PhysActor.PIDHoverHeight = height; | 2289 | pa.PIDHoverHeight = height; |
2275 | RootPart.PhysActor.PIDHoverType = hoverType; | 2290 | pa.PIDHoverType = hoverType; |
2276 | RootPart.PhysActor.PIDTau = tau; | 2291 | pa.PIDTau = tau; |
2277 | RootPart.PhysActor.PIDHoverActive = true; | 2292 | pa.PIDHoverActive = true; |
2278 | } | 2293 | } |
2279 | else | 2294 | else |
2280 | { | 2295 | { |
2281 | RootPart.PhysActor.PIDHoverActive = false; | 2296 | pa.PIDHoverActive = false; |
2282 | } | 2297 | } |
2283 | } | 2298 | } |
2284 | } | 2299 | } |
@@ -2771,10 +2786,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2771 | linkPart.ParentID = 0; | 2786 | linkPart.ParentID = 0; |
2772 | linkPart.LinkNum = 0; | 2787 | linkPart.LinkNum = 0; |
2773 | 2788 | ||
2774 | if (linkPart.PhysActor != null) | 2789 | PhysicsActor linkPartPa = linkPart.PhysActor; |
2775 | { | 2790 | |
2776 | m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); | 2791 | if (linkPartPa != null) |
2777 | } | 2792 | m_scene.PhysicsScene.RemovePrim(linkPartPa); |
2778 | 2793 | ||
2779 | // We need to reset the child part's position | 2794 | // We need to reset the child part's position |
2780 | // ready for life as a separate object after being a part of another object | 2795 | // ready for life as a separate object after being a part of another object |
@@ -2875,17 +2890,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2875 | { | 2890 | { |
2876 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 2891 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2877 | { | 2892 | { |
2878 | if (m_rootPart.PhysActor != null) | 2893 | PhysicsActor pa = m_rootPart.PhysActor; |
2894 | |||
2895 | if (pa != null) | ||
2879 | { | 2896 | { |
2880 | if (m_rootPart.PhysActor.IsPhysical) | 2897 | if (pa.IsPhysical) |
2881 | { | 2898 | { |
2882 | if (!m_rootPart.BlockGrab) | 2899 | if (!m_rootPart.BlockGrab) |
2883 | { | 2900 | { |
2884 | Vector3 llmoveforce = pos - AbsolutePosition; | 2901 | Vector3 llmoveforce = pos - AbsolutePosition; |
2885 | Vector3 grabforce = llmoveforce; | 2902 | Vector3 grabforce = llmoveforce; |
2886 | grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; | 2903 | grabforce = (grabforce / 10) * pa.Mass; |
2887 | m_rootPart.PhysActor.AddForce(grabforce, true); | 2904 | pa.AddForce(grabforce, true); |
2888 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 2905 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2889 | } | 2906 | } |
2890 | } | 2907 | } |
2891 | else | 2908 | else |
@@ -2915,9 +2932,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2915 | { | 2932 | { |
2916 | if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) | 2933 | if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) |
2917 | { | 2934 | { |
2918 | if (m_rootPart.PhysActor != null) | 2935 | PhysicsActor pa = m_rootPart.PhysActor; |
2936 | |||
2937 | if (pa != null) | ||
2919 | { | 2938 | { |
2920 | if (m_rootPart.PhysActor.IsPhysical) | 2939 | if (pa.IsPhysical) |
2921 | { | 2940 | { |
2922 | m_rootPart.IsWaitingForFirstSpinUpdatePacket = true; | 2941 | m_rootPart.IsWaitingForFirstSpinUpdatePacket = true; |
2923 | } | 2942 | } |
@@ -2958,12 +2977,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2958 | // but it will result in over-shoot or under-shoot of the target orientation. | 2977 | // but it will result in over-shoot or under-shoot of the target orientation. |
2959 | // For the end user, this means that ctrl+shift+drag can be used for relative, | 2978 | // For the end user, this means that ctrl+shift+drag can be used for relative, |
2960 | // but not absolute, adjustments of orientation for physical prims. | 2979 | // but not absolute, adjustments of orientation for physical prims. |
2961 | |||
2962 | if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) | 2980 | if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) |
2963 | { | 2981 | { |
2964 | if (m_rootPart.PhysActor != null) | 2982 | PhysicsActor pa = m_rootPart.PhysActor; |
2983 | |||
2984 | if (pa != null) | ||
2965 | { | 2985 | { |
2966 | if (m_rootPart.PhysActor.IsPhysical) | 2986 | if (pa.IsPhysical) |
2967 | { | 2987 | { |
2968 | if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) | 2988 | if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) |
2969 | { | 2989 | { |
@@ -2989,9 +3009,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2989 | 3009 | ||
2990 | //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); | 3010 | //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); |
2991 | Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); | 3011 | Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); |
2992 | spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor | 3012 | spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor |
2993 | m_rootPart.PhysActor.AddAngularForce(spinforce,true); | 3013 | pa.AddAngularForce(spinforce,true); |
2994 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3014 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2995 | } | 3015 | } |
2996 | } | 3016 | } |
2997 | else | 3017 | else |
@@ -3199,8 +3219,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3199 | { | 3219 | { |
3200 | part.UpdateShape(shapeBlock); | 3220 | part.UpdateShape(shapeBlock); |
3201 | 3221 | ||
3202 | if (part.PhysActor != null) | 3222 | PhysicsActor pa = m_rootPart.PhysActor; |
3203 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); | 3223 | |
3224 | if (pa != null) | ||
3225 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
3204 | } | 3226 | } |
3205 | } | 3227 | } |
3206 | 3228 | ||
@@ -3218,7 +3240,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3218 | scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); | 3240 | scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); |
3219 | scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); | 3241 | scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); |
3220 | 3242 | ||
3221 | if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) | 3243 | PhysicsActor pa = m_rootPart.PhysActor; |
3244 | |||
3245 | if (pa != null && pa.IsPhysical) | ||
3222 | { | 3246 | { |
3223 | scale.X = Math.Min(scale.X, Scene.m_maxPhys); | 3247 | scale.X = Math.Min(scale.X, Scene.m_maxPhys); |
3224 | scale.Y = Math.Min(scale.Y, Scene.m_maxPhys); | 3248 | scale.Y = Math.Min(scale.Y, Scene.m_maxPhys); |
@@ -3243,7 +3267,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3243 | float f = 1.0f; | 3267 | float f = 1.0f; |
3244 | float a = 1.0f; | 3268 | float a = 1.0f; |
3245 | 3269 | ||
3246 | if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) | 3270 | if (pa != null && pa.IsPhysical) |
3247 | { | 3271 | { |
3248 | if (oldSize.X * x > m_scene.m_maxPhys) | 3272 | if (oldSize.X * x > m_scene.m_maxPhys) |
3249 | { | 3273 | { |
@@ -3558,13 +3582,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3558 | // needs to be called with phys building true | 3582 | // needs to be called with phys building true |
3559 | Quaternion axRot = rot; | 3583 | Quaternion axRot = rot; |
3560 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3584 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3561 | 3585 | ||
3562 | //Don't use UpdateRotation because it schedules an update prematurely | 3586 | //Don't use UpdateRotation because it schedules an update prematurely |
3563 | m_rootPart.RotationOffset = rot; | 3587 | m_rootPart.RotationOffset = rot; |
3564 | if (m_rootPart.PhysActor != null) | 3588 | |
3589 | PhysicsActor pa = m_rootPart.PhysActor; | ||
3590 | |||
3591 | if (pa != null) | ||
3565 | { | 3592 | { |
3566 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; | 3593 | pa.Orientation = m_rootPart.RotationOffset; |
3567 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3594 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
3568 | } | 3595 | } |
3569 | 3596 | ||
3570 | SceneObjectPart[] parts = m_parts.GetArray(); | 3597 | SceneObjectPart[] parts = m_parts.GetArray(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cfa3cd4..aed25a7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -152,6 +152,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
152 | public int[] PayPrice = {-2,-2,-2,-2,-2}; | 152 | public int[] PayPrice = {-2,-2,-2,-2,-2}; |
153 | 153 | ||
154 | [XmlIgnore] | 154 | [XmlIgnore] |
155 | /// <summary> | ||
156 | /// The representation of this part in the physics scene. | ||
157 | /// </summary> | ||
158 | /// <remarks> | ||
159 | /// If you use this property more than once in a section of code then you must take a reference and use that. | ||
160 | /// If another thread is simultaneously turning physics off on this part then this refernece could become | ||
161 | /// null at any time. | ||
162 | /// </remarks> | ||
155 | public PhysicsActor PhysActor | 163 | public PhysicsActor PhysActor |
156 | { | 164 | { |
157 | get { return m_physActor; } | 165 | get { return m_physActor; } |
@@ -555,10 +563,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
555 | set | 563 | set |
556 | { | 564 | { |
557 | m_name = value; | 565 | m_name = value; |
558 | if (PhysActor != null) | 566 | |
559 | { | 567 | PhysicsActor pa = PhysActor; |
560 | PhysActor.SOPName = value; | 568 | |
561 | } | 569 | if (pa != null) |
570 | pa.SOPName = value; | ||
562 | } | 571 | } |
563 | } | 572 | } |
564 | 573 | ||
@@ -1017,7 +1026,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1017 | if (Shape.SculptEntry) | 1026 | if (Shape.SculptEntry) |
1018 | CheckSculptAndLoad(); | 1027 | CheckSculptAndLoad(); |
1019 | else | 1028 | else |
1020 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 1029 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
1021 | } | 1030 | } |
1022 | } | 1031 | } |
1023 | } | 1032 | } |
@@ -1780,7 +1789,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1780 | impulse = newimpulse; | 1789 | impulse = newimpulse; |
1781 | } | 1790 | } |
1782 | 1791 | ||
1783 | ParentGroup.applyAngularImpulse(impulse); | 1792 | ParentGroup.setAngularImpulse(impulse); |
1784 | } | 1793 | } |
1785 | 1794 | ||
1786 | /// <summary> | 1795 | /// <summary> |
@@ -1868,33 +1877,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
1868 | } | 1877 | } |
1869 | 1878 | ||
1870 | // Basic Physics can also return null as well as an exception catch. | 1879 | // Basic Physics can also return null as well as an exception catch. |
1871 | if (PhysActor != null) | 1880 | PhysicsActor pa = PhysActor; |
1881 | |||
1882 | if (pa != null) | ||
1872 | { | 1883 | { |
1873 | PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 1884 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
1874 | PhysActor.SetMaterial(Material); | 1885 | pa.SetMaterial(Material); |
1875 | 1886 | ||
1876 | // if root part apply vehicle | 1887 | // if root part apply vehicle |
1877 | if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) | 1888 | if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) |
1878 | m_vehicle.SetVehicle(PhysActor); | 1889 | m_vehicle.SetVehicle(pa); |
1879 | 1890 | ||
1880 | DoPhysicsPropertyUpdate(isPhysical, true); | 1891 | DoPhysicsPropertyUpdate(isPhysical, true); |
1881 | if(VolumeDetectActive) // change if not the default only | 1892 | if(VolumeDetectActive) // change if not the default only |
1882 | PhysActor.SetVolumeDetect(1); | 1893 | pa.SetVolumeDetect(1); |
1883 | 1894 | ||
1884 | if (!building) | 1895 | if (!building) |
1885 | PhysActor.Building = false; | 1896 | pa.Building = false; |
1886 | 1897 | ||
1887 | Velocity = velocity; | 1898 | Velocity = velocity; |
1888 | AngularVelocity = rotationalVelocity; | 1899 | AngularVelocity = rotationalVelocity; |
1889 | PhysActor.Velocity = velocity; | 1900 | pa.Velocity = velocity; |
1890 | PhysActor.RotationalVelocity = rotationalVelocity; | 1901 | pa.RotationalVelocity = rotationalVelocity; |
1891 | 1902 | ||
1892 | // if not vehicle and root part apply force and torque | 1903 | // if not vehicle and root part apply force and torque |
1893 | if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) | 1904 | if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) |
1894 | && LocalId == ParentGroup.RootPart.LocalId) | 1905 | && LocalId == ParentGroup.RootPart.LocalId) |
1895 | { | 1906 | { |
1896 | PhysActor.Force = Force; | 1907 | pa.Force = Force; |
1897 | PhysActor.Torque = Torque; | 1908 | pa.Torque = Torque; |
1898 | } | 1909 | } |
1899 | } | 1910 | } |
1900 | } | 1911 | } |
@@ -2125,11 +2136,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2125 | } | 2136 | } |
2126 | else | 2137 | else |
2127 | { | 2138 | { |
2128 | if (PhysActor != null) | 2139 | PhysicsActor pa = PhysActor; |
2140 | |||
2141 | if (pa != null) | ||
2129 | { | 2142 | { |
2130 | if (UsePhysics != PhysActor.IsPhysical || isNew) | 2143 | if (UsePhysics != pa.IsPhysical || isNew) |
2131 | { | 2144 | { |
2132 | if (PhysActor.IsPhysical) | 2145 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
2133 | { | 2146 | { |
2134 | if (!isNew) // implies UsePhysics==false for this block | 2147 | if (!isNew) // implies UsePhysics==false for this block |
2135 | { | 2148 | { |
@@ -2173,9 +2186,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2173 | 2186 | ||
2174 | if (ParentID != 0 && ParentID != LocalId) | 2187 | if (ParentID != 0 && ParentID != LocalId) |
2175 | { | 2188 | { |
2176 | if (ParentGroup.RootPart.PhysActor != null) | 2189 | ParentGroup.Scene.AddPhysicalPrim(1); |
2190 | |||
2191 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
2192 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
2193 | if (ParentID != 0 && ParentID != LocalId) | ||
2177 | { | 2194 | { |
2178 | PhysActor.link(ParentGroup.RootPart.PhysActor); | 2195 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2196 | |||
2197 | if (parentPa != null) | ||
2198 | { | ||
2199 | pa.link(parentPa); | ||
2200 | } | ||
2179 | } | 2201 | } |
2180 | } | 2202 | } |
2181 | } | 2203 | } |
@@ -2191,7 +2213,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2191 | if (Shape.SculptEntry) | 2213 | if (Shape.SculptEntry) |
2192 | CheckSculptAndLoad(); | 2214 | CheckSculptAndLoad(); |
2193 | else | 2215 | else |
2194 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 2216 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2195 | } | 2217 | } |
2196 | } | 2218 | } |
2197 | } | 2219 | } |
@@ -2302,23 +2324,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2302 | 2324 | ||
2303 | public Vector3 GetGeometricCenter() | 2325 | public Vector3 GetGeometricCenter() |
2304 | { | 2326 | { |
2305 | if (PhysActor != null) | 2327 | PhysicsActor pa = PhysActor; |
2306 | return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); | 2328 | |
2329 | if (pa != null) | ||
2330 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | ||
2307 | else | 2331 | else |
2308 | return new Vector3(0, 0, 0); | 2332 | return new Vector3(0, 0, 0); |
2309 | } | 2333 | } |
2310 | 2334 | ||
2311 | public float GetMass() | 2335 | public float GetMass() |
2312 | { | 2336 | { |
2313 | if (PhysActor != null) | 2337 | PhysicsActor pa = PhysActor; |
2314 | return PhysActor.Mass; | 2338 | |
2339 | if (pa != null) | ||
2340 | return pa.Mass; | ||
2315 | else | 2341 | else |
2316 | return 0; | 2342 | return 0; |
2317 | } | 2343 | } |
2318 | 2344 | ||
2319 | public Vector3 GetForce() | 2345 | public Vector3 GetForce() |
2320 | { | 2346 | { |
2321 | return Force; | 2347 | return Force; |
2322 | } | 2348 | } |
2323 | 2349 | ||
2324 | /// <summary> | 2350 | /// <summary> |
@@ -2947,9 +2973,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2947 | 2973 | ||
2948 | public void PhysicsRequestingTerseUpdate() | 2974 | public void PhysicsRequestingTerseUpdate() |
2949 | { | 2975 | { |
2950 | if (PhysActor != null) | 2976 | PhysicsActor pa = PhysActor; |
2977 | |||
2978 | if (pa != null) | ||
2951 | { | 2979 | { |
2952 | Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); | 2980 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2953 | 2981 | ||
2954 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2982 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2955 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2983 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
@@ -2961,6 +2989,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2961 | } | 2989 | } |
2962 | //ParentGroup.RootPart.m_groupPosition = newpos; | 2990 | //ParentGroup.RootPart.m_groupPosition = newpos; |
2963 | } | 2991 | } |
2992 | |||
2964 | ScheduleTerseUpdate(); | 2993 | ScheduleTerseUpdate(); |
2965 | } | 2994 | } |
2966 | 2995 | ||
@@ -3052,7 +3081,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3052 | scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys); | 3081 | scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys); |
3053 | scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys); | 3082 | scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys); |
3054 | 3083 | ||
3055 | if (PhysActor != null && PhysActor.IsPhysical) | 3084 | PhysicsActor pa = PhysActor; |
3085 | |||
3086 | if (pa != null && pa.IsPhysical) | ||
3056 | { | 3087 | { |
3057 | scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys); | 3088 | scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys); |
3058 | scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys); | 3089 | scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys); |
@@ -3214,12 +3245,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3214 | m_shape.SculptData = texture.Data; | 3245 | m_shape.SculptData = texture.Data; |
3215 | } | 3246 | } |
3216 | 3247 | ||
3217 | if (PhysActor != null) | 3248 | PhysicsActor pa = PhysActor; |
3249 | |||
3250 | if (pa != null) | ||
3218 | { | 3251 | { |
3219 | // Update the physics actor with the new loaded sculpt data and set the taint signal. | 3252 | // Update the physics actor with the new loaded sculpt data and set the taint signal. |
3220 | PhysActor.Shape = m_shape; | 3253 | pa.Shape = m_shape; |
3221 | 3254 | ||
3222 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 3255 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); |
3223 | } | 3256 | } |
3224 | } | 3257 | } |
3225 | } | 3258 | } |
@@ -3495,17 +3528,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3495 | 3528 | ||
3496 | public void SetFloatOnWater(int floatYN) | 3529 | public void SetFloatOnWater(int floatYN) |
3497 | { | 3530 | { |
3498 | if (PhysActor != null) | 3531 | PhysicsActor pa = PhysActor; |
3499 | { | 3532 | |
3500 | if (floatYN == 1) | 3533 | if (pa != null) |
3501 | { | 3534 | pa.FloatOnWater = floatYN == 1; |
3502 | PhysActor.FloatOnWater = true; | ||
3503 | } | ||
3504 | else | ||
3505 | { | ||
3506 | PhysActor.FloatOnWater = false; | ||
3507 | } | ||
3508 | } | ||
3509 | } | 3535 | } |
3510 | 3536 | ||
3511 | public void SetForce(Vector3 force) | 3537 | public void SetForce(Vector3 force) |
@@ -4793,6 +4819,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4793 | } | 4819 | } |
4794 | } | 4820 | } |
4795 | 4821 | ||
4822 | PhysicsActor pa = PhysActor; | ||
4796 | if (SetVD) | 4823 | if (SetVD) |
4797 | { | 4824 | { |
4798 | // If the above logic worked (this is urgent candidate to unit tests!) | 4825 | // If the above logic worked (this is urgent candidate to unit tests!) |
@@ -4800,9 +4827,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4800 | // Defensive programming calls for a check here. | 4827 | // Defensive programming calls for a check here. |
4801 | // Better would be throwing an exception that could be catched by a unit test as the internal | 4828 | // Better would be throwing an exception that could be catched by a unit test as the internal |
4802 | // logic should make sure, this Physactor is always here. | 4829 | // logic should make sure, this Physactor is always here. |
4803 | if (this.PhysActor != null) | 4830 | if (pa != null) |
4804 | { | 4831 | { |
4805 | PhysActor.SetVolumeDetect(1); | 4832 | pa.SetVolumeDetect(1); |
4806 | // AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4833 | // AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
4807 | this.VolumeDetectActive = true; | 4834 | this.VolumeDetectActive = true; |
4808 | } | 4835 | } |
@@ -4811,12 +4838,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
4811 | { | 4838 | { |
4812 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like | 4839 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like |
4813 | // (mumbles, well, at least if you have infinte CPU powers :-)) | 4840 | // (mumbles, well, at least if you have infinte CPU powers :-)) |
4814 | if (this.PhysActor != null) | 4841 | if (pa != null) |
4815 | { | 4842 | { |
4816 | PhysActor.SetVolumeDetect(0); | 4843 | pa.SetVolumeDetect(0); |
4844 | this.VolumeDetectActive = false; | ||
4817 | } | 4845 | } |
4818 | |||
4819 | this.VolumeDetectActive = false; | ||
4820 | } | 4846 | } |
4821 | 4847 | ||
4822 | if (SetTemporary) | 4848 | if (SetTemporary) |
@@ -4827,11 +4853,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4827 | { | 4853 | { |
4828 | RemFlag(PrimFlags.TemporaryOnRez); | 4854 | RemFlag(PrimFlags.TemporaryOnRez); |
4829 | } | 4855 | } |
4856 | |||
4830 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4857 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4831 | 4858 | ||
4832 | // and last in case we have a new actor and not building | 4859 | // and last in case we have a new actor and not building |
4833 | if (PhysActor != null && PhysActor.Building != building) | 4860 | if (pa != null && pa.Building != building) |
4834 | PhysActor.Building = building; | 4861 | pa.Building = building; |
4835 | if (ParentGroup != null) | 4862 | if (ParentGroup != null) |
4836 | { | 4863 | { |
4837 | ParentGroup.HasGroupChanged = true; | 4864 | ParentGroup.HasGroupChanged = true; |
@@ -4898,10 +4925,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4898 | m_shape.PathTwist = shapeBlock.PathTwist; | 4925 | m_shape.PathTwist = shapeBlock.PathTwist; |
4899 | m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; | 4926 | m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; |
4900 | 4927 | ||
4901 | if (PhysActor != null) | 4928 | PhysicsActor pa = PhysActor; |
4929 | |||
4930 | if (pa != null) | ||
4902 | { | 4931 | { |
4903 | PhysActor.Shape = m_shape; | 4932 | pa.Shape = m_shape; |
4904 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 4933 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); |
4905 | } | 4934 | } |
4906 | 4935 | ||
4907 | // This is what makes vehicle trailers work | 4936 | // This is what makes vehicle trailers work |
@@ -5043,6 +5072,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5043 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5072 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
5044 | } | 5073 | } |
5045 | 5074 | ||
5075 | PhysicsActor pa = PhysActor; | ||
5076 | |||
5046 | if ( | 5077 | if ( |
5047 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | 5078 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5048 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | 5079 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || |
@@ -5054,18 +5085,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5054 | ) | 5085 | ) |
5055 | { | 5086 | { |
5056 | // subscribe to physics updates. | 5087 | // subscribe to physics updates. |
5057 | if (PhysActor != null) | 5088 | if (pa != null) |
5058 | { | 5089 | { |
5059 | PhysActor.OnCollisionUpdate += PhysicsCollision; | 5090 | pa.OnCollisionUpdate += PhysicsCollision; |
5060 | PhysActor.SubscribeEvents(1000); | 5091 | pa.SubscribeEvents(1000); |
5061 | } | 5092 | } |
5062 | } | 5093 | } |
5063 | else | 5094 | else |
5064 | { | 5095 | { |
5065 | if (PhysActor != null) | 5096 | if (pa != null) |
5066 | { | 5097 | { |
5067 | PhysActor.UnSubscribeEvents(); | 5098 | pa.UnSubscribeEvents(); |
5068 | PhysActor.OnCollisionUpdate -= PhysicsCollision; | 5099 | pa.OnCollisionUpdate -= PhysicsCollision; |
5069 | } | 5100 | } |
5070 | } | 5101 | } |
5071 | 5102 | ||