aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs152
1 files changed, 98 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index cfa3cd4..83b0b18 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,25 @@ 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;
571 }
572 }
573
574 public byte Material
575 {
576 get { return (byte) m_material; }
577 set
578 {
579 m_material = (Material)value;
580
581 PhysicsActor pa = PhysActor;
582
583 if (pa != null)
584 pa.SetMaterial((int)value);
562 } 585 }
563 } 586 }
564 587
@@ -1017,7 +1040,7 @@ namespace OpenSim.Region.Framework.Scenes
1017 if (Shape.SculptEntry) 1040 if (Shape.SculptEntry)
1018 CheckSculptAndLoad(); 1041 CheckSculptAndLoad();
1019 else 1042 else
1020 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 1043 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
1021 } 1044 }
1022 } 1045 }
1023 } 1046 }
@@ -1868,33 +1891,35 @@ namespace OpenSim.Region.Framework.Scenes
1868 } 1891 }
1869 1892
1870 // Basic Physics can also return null as well as an exception catch. 1893 // Basic Physics can also return null as well as an exception catch.
1871 if (PhysActor != null) 1894 PhysicsActor pa = PhysActor;
1895
1896 if (pa != null)
1872 { 1897 {
1873 PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 1898 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
1874 PhysActor.SetMaterial(Material); 1899 pa.SetMaterial(Material);
1875 1900
1876 // if root part apply vehicle 1901 // if root part apply vehicle
1877 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) 1902 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
1878 m_vehicle.SetVehicle(PhysActor); 1903 m_vehicle.SetVehicle(pa);
1879 1904
1880 DoPhysicsPropertyUpdate(isPhysical, true); 1905 DoPhysicsPropertyUpdate(isPhysical, true);
1881 if(VolumeDetectActive) // change if not the default only 1906 if(VolumeDetectActive) // change if not the default only
1882 PhysActor.SetVolumeDetect(1); 1907 pa.SetVolumeDetect(1);
1883 1908
1884 if (!building) 1909 if (!building)
1885 PhysActor.Building = false; 1910 pa.Building = false;
1886 1911
1887 Velocity = velocity; 1912 Velocity = velocity;
1888 AngularVelocity = rotationalVelocity; 1913 AngularVelocity = rotationalVelocity;
1889 PhysActor.Velocity = velocity; 1914 pa.Velocity = velocity;
1890 PhysActor.RotationalVelocity = rotationalVelocity; 1915 pa.RotationalVelocity = rotationalVelocity;
1891 1916
1892 // if not vehicle and root part apply force and torque 1917 // if not vehicle and root part apply force and torque
1893 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) 1918 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE)
1894 && LocalId == ParentGroup.RootPart.LocalId) 1919 && LocalId == ParentGroup.RootPart.LocalId)
1895 { 1920 {
1896 PhysActor.Force = Force; 1921 pa.Force = Force;
1897 PhysActor.Torque = Torque; 1922 pa.Torque = Torque;
1898 } 1923 }
1899 } 1924 }
1900 } 1925 }
@@ -2125,11 +2150,13 @@ namespace OpenSim.Region.Framework.Scenes
2125 } 2150 }
2126 else 2151 else
2127 { 2152 {
2128 if (PhysActor != null) 2153 PhysicsActor pa = PhysActor;
2154
2155 if (pa != null)
2129 { 2156 {
2130 if (UsePhysics != PhysActor.IsPhysical || isNew) 2157 if (UsePhysics != pa.IsPhysical || isNew)
2131 { 2158 {
2132 if (PhysActor.IsPhysical) 2159 if (pa.IsPhysical) // implies UsePhysics==false for this block
2133 { 2160 {
2134 if (!isNew) // implies UsePhysics==false for this block 2161 if (!isNew) // implies UsePhysics==false for this block
2135 { 2162 {
@@ -2173,9 +2200,18 @@ namespace OpenSim.Region.Framework.Scenes
2173 2200
2174 if (ParentID != 0 && ParentID != LocalId) 2201 if (ParentID != 0 && ParentID != LocalId)
2175 { 2202 {
2176 if (ParentGroup.RootPart.PhysActor != null) 2203 ParentGroup.Scene.AddPhysicalPrim(1);
2204
2205 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
2206 pa.OnOutOfBounds += PhysicsOutOfBounds;
2207 if (ParentID != 0 && ParentID != LocalId)
2177 { 2208 {
2178 PhysActor.link(ParentGroup.RootPart.PhysActor); 2209 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
2210
2211 if (parentPa != null)
2212 {
2213 pa.link(parentPa);
2214 }
2179 } 2215 }
2180 } 2216 }
2181 } 2217 }
@@ -2191,7 +2227,7 @@ namespace OpenSim.Region.Framework.Scenes
2191 if (Shape.SculptEntry) 2227 if (Shape.SculptEntry)
2192 CheckSculptAndLoad(); 2228 CheckSculptAndLoad();
2193 else 2229 else
2194 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 2230 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
2195 } 2231 }
2196 } 2232 }
2197 } 2233 }
@@ -2302,23 +2338,27 @@ namespace OpenSim.Region.Framework.Scenes
2302 2338
2303 public Vector3 GetGeometricCenter() 2339 public Vector3 GetGeometricCenter()
2304 { 2340 {
2305 if (PhysActor != null) 2341 PhysicsActor pa = PhysActor;
2306 return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); 2342
2343 if (pa != null)
2344 return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z);
2307 else 2345 else
2308 return new Vector3(0, 0, 0); 2346 return new Vector3(0, 0, 0);
2309 } 2347 }
2310 2348
2311 public float GetMass() 2349 public float GetMass()
2312 { 2350 {
2313 if (PhysActor != null) 2351 PhysicsActor pa = PhysActor;
2314 return PhysActor.Mass; 2352
2353 if (pa != null)
2354 return pa.Mass;
2315 else 2355 else
2316 return 0; 2356 return 0;
2317 } 2357 }
2318 2358
2319 public Vector3 GetForce() 2359 public Vector3 GetForce()
2320 { 2360 {
2321 return Force; 2361 return Force;
2322 } 2362 }
2323 2363
2324 /// <summary> 2364 /// <summary>
@@ -2947,9 +2987,11 @@ namespace OpenSim.Region.Framework.Scenes
2947 2987
2948 public void PhysicsRequestingTerseUpdate() 2988 public void PhysicsRequestingTerseUpdate()
2949 { 2989 {
2950 if (PhysActor != null) 2990 PhysicsActor pa = PhysActor;
2991
2992 if (pa != null)
2951 { 2993 {
2952 Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); 2994 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0);
2953 2995
2954 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) 2996 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
2955 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) 2997 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
@@ -2961,6 +3003,7 @@ namespace OpenSim.Region.Framework.Scenes
2961 } 3003 }
2962 //ParentGroup.RootPart.m_groupPosition = newpos; 3004 //ParentGroup.RootPart.m_groupPosition = newpos;
2963 } 3005 }
3006
2964 ScheduleTerseUpdate(); 3007 ScheduleTerseUpdate();
2965 } 3008 }
2966 3009
@@ -3052,7 +3095,9 @@ namespace OpenSim.Region.Framework.Scenes
3052 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys); 3095 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
3053 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys); 3096 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
3054 3097
3055 if (PhysActor != null && PhysActor.IsPhysical) 3098 PhysicsActor pa = PhysActor;
3099
3100 if (pa != null && pa.IsPhysical)
3056 { 3101 {
3057 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys); 3102 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
3058 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys); 3103 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
@@ -3214,12 +3259,14 @@ namespace OpenSim.Region.Framework.Scenes
3214 m_shape.SculptData = texture.Data; 3259 m_shape.SculptData = texture.Data;
3215 } 3260 }
3216 3261
3217 if (PhysActor != null) 3262 PhysicsActor pa = PhysActor;
3263
3264 if (pa != null)
3218 { 3265 {
3219 // Update the physics actor with the new loaded sculpt data and set the taint signal. 3266 // Update the physics actor with the new loaded sculpt data and set the taint signal.
3220 PhysActor.Shape = m_shape; 3267 pa.Shape = m_shape;
3221 3268
3222 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 3269 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
3223 } 3270 }
3224 } 3271 }
3225 } 3272 }
@@ -3495,17 +3542,10 @@ namespace OpenSim.Region.Framework.Scenes
3495 3542
3496 public void SetFloatOnWater(int floatYN) 3543 public void SetFloatOnWater(int floatYN)
3497 { 3544 {
3498 if (PhysActor != null) 3545 PhysicsActor pa = PhysActor;
3499 { 3546
3500 if (floatYN == 1) 3547 if (pa != null)
3501 { 3548 pa.FloatOnWater = floatYN == 1;
3502 PhysActor.FloatOnWater = true;
3503 }
3504 else
3505 {
3506 PhysActor.FloatOnWater = false;
3507 }
3508 }
3509 } 3549 }
3510 3550
3511 public void SetForce(Vector3 force) 3551 public void SetForce(Vector3 force)
@@ -4800,7 +4840,7 @@ namespace OpenSim.Region.Framework.Scenes
4800 // Defensive programming calls for a check here. 4840 // 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 4841 // 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. 4842 // logic should make sure, this Physactor is always here.
4803 if (this.PhysActor != null) 4843 if (pa != null)
4804 { 4844 {
4805 PhysActor.SetVolumeDetect(1); 4845 PhysActor.SetVolumeDetect(1);
4806// AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active 4846// AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
@@ -4814,7 +4854,6 @@ namespace OpenSim.Region.Framework.Scenes
4814 if (this.PhysActor != null) 4854 if (this.PhysActor != null)
4815 { 4855 {
4816 PhysActor.SetVolumeDetect(0); 4856 PhysActor.SetVolumeDetect(0);
4817 }
4818 4857
4819 this.VolumeDetectActive = false; 4858 this.VolumeDetectActive = false;
4820 } 4859 }
@@ -4827,6 +4866,7 @@ namespace OpenSim.Region.Framework.Scenes
4827 { 4866 {
4828 RemFlag(PrimFlags.TemporaryOnRez); 4867 RemFlag(PrimFlags.TemporaryOnRez);
4829 } 4868 }
4869
4830 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4870 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4831 4871
4832 // and last in case we have a new actor and not building 4872 // and last in case we have a new actor and not building
@@ -4898,10 +4938,12 @@ namespace OpenSim.Region.Framework.Scenes
4898 m_shape.PathTwist = shapeBlock.PathTwist; 4938 m_shape.PathTwist = shapeBlock.PathTwist;
4899 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; 4939 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin;
4900 4940
4901 if (PhysActor != null) 4941 PhysicsActor pa = PhysActor;
4942
4943 if (pa != null)
4902 { 4944 {
4903 PhysActor.Shape = m_shape; 4945 pa.Shape = m_shape;
4904 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 4946 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4905 } 4947 }
4906 4948
4907 // This is what makes vehicle trailers work 4949 // This is what makes vehicle trailers work
@@ -5043,6 +5085,8 @@ namespace OpenSim.Region.Framework.Scenes
5043 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 5085 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
5044 } 5086 }
5045 5087
5088 PhysicsActor pa = PhysActor;
5089
5046 if ( 5090 if (
5047 ((AggregateScriptEvents & scriptEvents.collision) != 0) || 5091 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5048 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || 5092 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
@@ -5054,18 +5098,18 @@ namespace OpenSim.Region.Framework.Scenes
5054 ) 5098 )
5055 { 5099 {
5056 // subscribe to physics updates. 5100 // subscribe to physics updates.
5057 if (PhysActor != null) 5101 if (pa != null)
5058 { 5102 {
5059 PhysActor.OnCollisionUpdate += PhysicsCollision; 5103 pa.OnCollisionUpdate += PhysicsCollision;
5060 PhysActor.SubscribeEvents(1000); 5104 pa.SubscribeEvents(1000);
5061 } 5105 }
5062 } 5106 }
5063 else 5107 else
5064 { 5108 {
5065 if (PhysActor != null) 5109 if (pa != null)
5066 { 5110 {
5067 PhysActor.UnSubscribeEvents(); 5111 pa.UnSubscribeEvents();
5068 PhysActor.OnCollisionUpdate -= PhysicsCollision; 5112 pa.OnCollisionUpdate -= PhysicsCollision;
5069 } 5113 }
5070 } 5114 }
5071 5115