aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-04-03 05:50:13 +0100
committerJustin Clark-Casey (justincc)2012-04-03 05:51:38 +0100
commit746829967315cc82560a855a4772e45888bf8fbe (patch)
tree1e21d5c27101cb505a4ac4bcdf6e356f2e409d52
parentImplement bulk inventory update over CAPS (not recursive by design, (diff)
downloadopensim-SC-746829967315cc82560a855a4772e45888bf8fbe.zip
opensim-SC-746829967315cc82560a855a4772e45888bf8fbe.tar.gz
opensim-SC-746829967315cc82560a855a4772e45888bf8fbe.tar.bz2
opensim-SC-746829967315cc82560a855a4772e45888bf8fbe.tar.xz
Eliminate race condition where many callers would check SOP.PhysicsActor != null then assume it was still not null in later code.
Another thread could come and turn off physics for a part (null PhysicsActor) at any point. Had to turn off localCopy on warp3D CoreModules section in prebuild.xml since on current nant this copies all DLLs in bin/ which can be a very large number with compiled DLLs No obvious reason for doing that copy - nothing else does it.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs140
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs207
-rw-r--r--prebuild.xml2
6 files changed, 209 insertions, 155 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 427a49d..86e10d4 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework.Capabilities;
36using OpenSim.Framework.Client; 36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Physics.Manager;
39using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
40 41
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
@@ -1803,10 +1804,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1803 { 1804 {
1804 if (!grp.IsDeleted) 1805 if (!grp.IsDeleted)
1805 { 1806 {
1806 if (grp.RootPart.PhysActor != null) 1807 PhysicsActor pa = grp.RootPart.PhysActor;
1807 { 1808 if (pa != null)
1808 grp.RootPart.PhysActor.CrossingFailure(); 1809 pa.CrossingFailure();
1809 }
1810 } 1810 }
1811 1811
1812 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); 1812 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 06f7c0f..29825a2 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -642,10 +642,6 @@ namespace OpenSim.Region.Framework.Scenes
642 642
643 #endregion Region Settings 643 #endregion Region Settings
644 644
645 MainConsole.Instance.Commands.AddCommand("Estates", false, "reload estate",
646 "reload estate",
647 "Reload the estate data", HandleReloadEstate);
648
649 //Bind Storage Manager functions to some land manager functions for this scene 645 //Bind Storage Manager functions to some land manager functions for this scene
650 EventManager.OnLandObjectAdded += 646 EventManager.OnLandObjectAdded +=
651 new EventManager.LandObjectAdded(simDataService.StoreLandObject); 647 new EventManager.LandObjectAdded(simDataService.StoreLandObject);
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 8a05772..0098add 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -306,7 +306,8 @@ namespace OpenSim.Region.Framework.Scenes
306 if (rot != null) 306 if (rot != null)
307 sceneObject.UpdateGroupRotationR((Quaternion)rot); 307 sceneObject.UpdateGroupRotationR((Quaternion)rot);
308 308
309 if (sceneObject.RootPart.PhysActor != null && sceneObject.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) 309 PhysicsActor pa = sceneObject.RootPart.PhysActor;
310 if (pa != null && pa.IsPhysical && vel != Vector3.Zero)
310 { 311 {
311 sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); 312 sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false);
312 sceneObject.Velocity = vel; 313 sceneObject.Velocity = vel;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 04b3766..87fdc41 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -523,16 +523,21 @@ namespace OpenSim.Region.Framework.Scenes
523 { 523 {
524 m_isSelected = value; 524 m_isSelected = value;
525 // Tell physics engine that group is selected 525 // Tell physics engine that group is selected
526 if (m_rootPart.PhysActor != null) 526
527 PhysicsActor pa = m_rootPart.PhysActor;
528 if (pa != null)
527 { 529 {
528 m_rootPart.PhysActor.Selected = value; 530 pa.Selected = value;
531
529 // Pass it on to the children. 532 // Pass it on to the children.
530 SceneObjectPart[] parts = m_parts.GetArray(); 533 SceneObjectPart[] parts = m_parts.GetArray();
531 for (int i = 0; i < parts.Length; i++) 534 for (int i = 0; i < parts.Length; i++)
532 { 535 {
533 SceneObjectPart child = parts[i]; 536 SceneObjectPart child = parts[i];
534 if (child.PhysActor != null) 537
535 child.PhysActor.Selected = value; 538 PhysicsActor childPa = child.PhysActor;
539 if (childPa != null)
540 childPa.Selected = value;
536 } 541 }
537 } 542 }
538 } 543 }
@@ -1478,7 +1483,8 @@ namespace OpenSim.Region.Framework.Scenes
1478 } 1483 }
1479 1484
1480 // Need to duplicate the physics actor as well 1485 // Need to duplicate the physics actor as well
1481 if (part.PhysActor != null && userExposed) 1486 PhysicsActor originalPartPa = part.PhysActor;
1487 if (originalPartPa != null && userExposed)
1482 { 1488 {
1483 PrimitiveBaseShape pbs = newPart.Shape; 1489 PrimitiveBaseShape pbs = newPart.Shape;
1484 1490
@@ -1489,10 +1495,10 @@ namespace OpenSim.Region.Framework.Scenes
1489 newPart.AbsolutePosition, 1495 newPart.AbsolutePosition,
1490 newPart.Scale, 1496 newPart.Scale,
1491 newPart.RotationOffset, 1497 newPart.RotationOffset,
1492 part.PhysActor.IsPhysical, 1498 originalPartPa.IsPhysical,
1493 newPart.LocalId); 1499 newPart.LocalId);
1494 1500
1495 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); 1501 newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true);
1496 } 1502 }
1497 } 1503 }
1498 1504
@@ -1564,45 +1570,53 @@ namespace OpenSim.Region.Framework.Scenes
1564 } 1570 }
1565 else 1571 else
1566 { 1572 {
1567 if (RootPart.PhysActor != null) 1573 PhysicsActor pa = RootPart.PhysActor;
1574
1575 if (pa != null)
1568 { 1576 {
1569 RootPart.PhysActor.AddForce(impulse, true); 1577 pa.AddForce(impulse, true);
1570 m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); 1578 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
1571 } 1579 }
1572 } 1580 }
1573 } 1581 }
1574 1582
1575 public void applyAngularImpulse(Vector3 impulse) 1583 public void applyAngularImpulse(Vector3 impulse)
1576 { 1584 {
1577 if (RootPart.PhysActor != null) 1585 PhysicsActor pa = RootPart.PhysActor;
1586
1587 if (pa != null)
1578 { 1588 {
1579 if (!IsAttachment) 1589 if (!IsAttachment)
1580 { 1590 {
1581 RootPart.PhysActor.AddAngularForce(impulse, true); 1591 pa.AddAngularForce(impulse, true);
1582 m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); 1592 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
1583 } 1593 }
1584 } 1594 }
1585 } 1595 }
1586 1596
1587 public void setAngularImpulse(Vector3 impulse) 1597 public void setAngularImpulse(Vector3 impulse)
1588 { 1598 {
1589 if (RootPart.PhysActor != null) 1599 PhysicsActor pa = RootPart.PhysActor;
1600
1601 if (pa != null)
1590 { 1602 {
1591 if (!IsAttachment) 1603 if (!IsAttachment)
1592 { 1604 {
1593 RootPart.PhysActor.Torque = impulse; 1605 pa.Torque = impulse;
1594 m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); 1606 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
1595 } 1607 }
1596 } 1608 }
1597 } 1609 }
1598 1610
1599 public Vector3 GetTorque() 1611 public Vector3 GetTorque()
1600 { 1612 {
1601 if (RootPart.PhysActor != null) 1613 PhysicsActor pa = RootPart.PhysActor;
1614
1615 if (pa != null)
1602 { 1616 {
1603 if (!IsAttachment) 1617 if (!IsAttachment)
1604 { 1618 {
1605 Vector3 torque = RootPart.PhysActor.Torque; 1619 Vector3 torque = pa.Torque;
1606 return torque; 1620 return torque;
1607 } 1621 }
1608 } 1622 }
@@ -1622,19 +1636,23 @@ namespace OpenSim.Region.Framework.Scenes
1622 } 1636 }
1623 else 1637 else
1624 { 1638 {
1625 if (RootPart.PhysActor != null) 1639 PhysicsActor pa = RootPart.PhysActor;
1640
1641 if (pa != null)
1626 { 1642 {
1627 RootPart.PhysActor.PIDTarget = target; 1643 pa.PIDTarget = target;
1628 RootPart.PhysActor.PIDTau = tau; 1644 pa.PIDTau = tau;
1629 RootPart.PhysActor.PIDActive = true; 1645 pa.PIDActive = true;
1630 } 1646 }
1631 } 1647 }
1632 } 1648 }
1633 1649
1634 public void stopMoveToTarget() 1650 public void stopMoveToTarget()
1635 { 1651 {
1636 if (RootPart.PhysActor != null) 1652 PhysicsActor pa = RootPart.PhysActor;
1637 RootPart.PhysActor.PIDActive = false; 1653
1654 if (pa != null)
1655 pa.PIDActive = false;
1638 } 1656 }
1639 1657
1640 /// <summary> 1658 /// <summary>
@@ -1645,18 +1663,20 @@ namespace OpenSim.Region.Framework.Scenes
1645 /// <param name="tau">Number of seconds over which to reach target</param> 1663 /// <param name="tau">Number of seconds over which to reach target</param>
1646 public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) 1664 public void SetHoverHeight(float height, PIDHoverType hoverType, float tau)
1647 { 1665 {
1648 if (RootPart.PhysActor != null) 1666 PhysicsActor pa = RootPart.PhysActor;
1667
1668 if (pa != null)
1649 { 1669 {
1650 if (height != 0f) 1670 if (height != 0f)
1651 { 1671 {
1652 RootPart.PhysActor.PIDHoverHeight = height; 1672 pa.PIDHoverHeight = height;
1653 RootPart.PhysActor.PIDHoverType = hoverType; 1673 pa.PIDHoverType = hoverType;
1654 RootPart.PhysActor.PIDTau = tau; 1674 pa.PIDTau = tau;
1655 RootPart.PhysActor.PIDHoverActive = true; 1675 pa.PIDHoverActive = true;
1656 } 1676 }
1657 else 1677 else
1658 { 1678 {
1659 RootPart.PhysActor.PIDHoverActive = false; 1679 pa.PIDHoverActive = false;
1660 } 1680 }
1661 } 1681 }
1662 } 1682 }
@@ -2094,10 +2114,10 @@ namespace OpenSim.Region.Framework.Scenes
2094 linkPart.ParentID = 0; 2114 linkPart.ParentID = 0;
2095 linkPart.LinkNum = 0; 2115 linkPart.LinkNum = 0;
2096 2116
2097 if (linkPart.PhysActor != null) 2117 PhysicsActor linkPartPa = linkPart.PhysActor;
2098 { 2118
2099 m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); 2119 if (linkPartPa != null)
2100 } 2120 m_scene.PhysicsScene.RemovePrim(linkPartPa);
2101 2121
2102 // We need to reset the child part's position 2122 // We need to reset the child part's position
2103 // ready for life as a separate object after being a part of another object 2123 // ready for life as a separate object after being a part of another object
@@ -2188,17 +2208,19 @@ namespace OpenSim.Region.Framework.Scenes
2188 { 2208 {
2189 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 2209 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
2190 { 2210 {
2191 if (m_rootPart.PhysActor != null) 2211 PhysicsActor pa = m_rootPart.PhysActor;
2212
2213 if (pa != null)
2192 { 2214 {
2193 if (m_rootPart.PhysActor.IsPhysical) 2215 if (pa.IsPhysical)
2194 { 2216 {
2195 if (!m_rootPart.BlockGrab) 2217 if (!m_rootPart.BlockGrab)
2196 { 2218 {
2197 Vector3 llmoveforce = pos - AbsolutePosition; 2219 Vector3 llmoveforce = pos - AbsolutePosition;
2198 Vector3 grabforce = llmoveforce; 2220 Vector3 grabforce = llmoveforce;
2199 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; 2221 grabforce = (grabforce / 10) * pa.Mass;
2200 m_rootPart.PhysActor.AddForce(grabforce, true); 2222 pa.AddForce(grabforce, true);
2201 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2223 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
2202 } 2224 }
2203 } 2225 }
2204 else 2226 else
@@ -2228,9 +2250,11 @@ namespace OpenSim.Region.Framework.Scenes
2228 { 2250 {
2229 if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) 2251 if (m_scene.EventManager.TriggerGroupSpinStart(UUID))
2230 { 2252 {
2231 if (m_rootPart.PhysActor != null) 2253 PhysicsActor pa = m_rootPart.PhysActor;
2254
2255 if (pa != null)
2232 { 2256 {
2233 if (m_rootPart.PhysActor.IsPhysical) 2257 if (pa.IsPhysical)
2234 { 2258 {
2235 m_rootPart.IsWaitingForFirstSpinUpdatePacket = true; 2259 m_rootPart.IsWaitingForFirstSpinUpdatePacket = true;
2236 } 2260 }
@@ -2271,12 +2295,13 @@ namespace OpenSim.Region.Framework.Scenes
2271 // but it will result in over-shoot or under-shoot of the target orientation. 2295 // but it will result in over-shoot or under-shoot of the target orientation.
2272 // For the end user, this means that ctrl+shift+drag can be used for relative, 2296 // For the end user, this means that ctrl+shift+drag can be used for relative,
2273 // but not absolute, adjustments of orientation for physical prims. 2297 // but not absolute, adjustments of orientation for physical prims.
2274
2275 if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) 2298 if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation))
2276 { 2299 {
2277 if (m_rootPart.PhysActor != null) 2300 PhysicsActor pa = m_rootPart.PhysActor;
2301
2302 if (pa != null)
2278 { 2303 {
2279 if (m_rootPart.PhysActor.IsPhysical) 2304 if (pa.IsPhysical)
2280 { 2305 {
2281 if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) 2306 if (m_rootPart.IsWaitingForFirstSpinUpdatePacket)
2282 { 2307 {
@@ -2302,9 +2327,9 @@ namespace OpenSim.Region.Framework.Scenes
2302 2327
2303 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); 2328 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
2304 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); 2329 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
2305 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor 2330 spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor
2306 m_rootPart.PhysActor.AddAngularForce(spinforce,true); 2331 pa.AddAngularForce(spinforce,true);
2307 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2332 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
2308 } 2333 }
2309 } 2334 }
2310 else 2335 else
@@ -2478,8 +2503,10 @@ namespace OpenSim.Region.Framework.Scenes
2478 { 2503 {
2479 part.UpdateShape(shapeBlock); 2504 part.UpdateShape(shapeBlock);
2480 2505
2481 if (part.PhysActor != null) 2506 PhysicsActor pa = m_rootPart.PhysActor;
2482 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2507
2508 if (pa != null)
2509 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
2483 } 2510 }
2484 } 2511 }
2485 2512
@@ -2502,7 +2529,9 @@ namespace OpenSim.Region.Framework.Scenes
2502 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); 2529 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
2503 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); 2530 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
2504 2531
2505 if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) 2532 PhysicsActor pa = m_rootPart.PhysActor;
2533
2534 if (pa != null && pa.IsPhysical)
2506 { 2535 {
2507 scale.X = Math.Min(scale.X, Scene.m_maxPhys); 2536 scale.X = Math.Min(scale.X, Scene.m_maxPhys);
2508 scale.Y = Math.Min(scale.Y, Scene.m_maxPhys); 2537 scale.Y = Math.Min(scale.Y, Scene.m_maxPhys);
@@ -2528,7 +2557,7 @@ namespace OpenSim.Region.Framework.Scenes
2528 float f = 1.0f; 2557 float f = 1.0f;
2529 float a = 1.0f; 2558 float a = 1.0f;
2530 2559
2531 if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) 2560 if (pa != null && pa.IsPhysical)
2532 { 2561 {
2533 if (oldSize.X * x > m_scene.m_maxPhys) 2562 if (oldSize.X * x > m_scene.m_maxPhys)
2534 { 2563 {
@@ -2893,10 +2922,13 @@ namespace OpenSim.Region.Framework.Scenes
2893 2922
2894 m_rootPart.StoreUndoState(); 2923 m_rootPart.StoreUndoState();
2895 m_rootPart.UpdateRotation(rot); 2924 m_rootPart.UpdateRotation(rot);
2896 if (m_rootPart.PhysActor != null) 2925
2926 PhysicsActor pa = m_rootPart.PhysActor;
2927
2928 if (pa != null)
2897 { 2929 {
2898 m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; 2930 pa.Orientation = m_rootPart.RotationOffset;
2899 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2931 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
2900 } 2932 }
2901 2933
2902 SceneObjectPart[] parts = m_parts.GetArray(); 2934 SceneObjectPart[] parts = m_parts.GetArray();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 439b718..2b1fba0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -151,6 +151,14 @@ namespace OpenSim.Region.Framework.Scenes
151 public int[] PayPrice = {-2,-2,-2,-2,-2}; 151 public int[] PayPrice = {-2,-2,-2,-2,-2};
152 152
153 [XmlIgnore] 153 [XmlIgnore]
154 /// <summary>
155 /// The representation of this part in the physics scene.
156 /// </summary>
157 /// <remarks>
158 /// If you use this property more than once in a section of code then you must take a reference and use that.
159 /// If another thread is simultaneously turning physics off on this part then this refernece could become
160 /// null at any time.
161 /// </remarks>
154 public PhysicsActor PhysActor 162 public PhysicsActor PhysActor
155 { 163 {
156 get { return m_physActor; } 164 get { return m_physActor; }
@@ -522,10 +530,11 @@ namespace OpenSim.Region.Framework.Scenes
522 set 530 set
523 { 531 {
524 m_name = value; 532 m_name = value;
525 if (PhysActor != null) 533
526 { 534 PhysicsActor pa = PhysActor;
527 PhysActor.SOPName = value; 535
528 } 536 if (pa != null)
537 pa.SOPName = value;
529 } 538 }
530 } 539 }
531 540
@@ -535,10 +544,11 @@ namespace OpenSim.Region.Framework.Scenes
535 set 544 set
536 { 545 {
537 m_material = (Material)value; 546 m_material = (Material)value;
538 if (PhysActor != null) 547
539 { 548 PhysicsActor pa = PhysActor;
540 PhysActor.SetMaterial((int)value); 549
541 } 550 if (pa != null)
551 pa.SetMaterial((int)value);
542 } 552 }
543 } 553 }
544 554
@@ -669,9 +679,7 @@ namespace OpenSim.Region.Framework.Scenes
669 // If this is a linkset, we don't want the physics engine mucking up our group position here. 679 // If this is a linkset, we don't want the physics engine mucking up our group position here.
670 PhysicsActor actor = PhysActor; 680 PhysicsActor actor = PhysActor;
671 if (actor != null && ParentID == 0) 681 if (actor != null && ParentID == 0)
672 {
673 m_groupPosition = actor.Position; 682 m_groupPosition = actor.Position;
674 }
675 683
676 if (ParentGroup.IsAttachment) 684 if (ParentGroup.IsAttachment)
677 { 685 {
@@ -979,7 +987,7 @@ namespace OpenSim.Region.Framework.Scenes
979 if (Shape.SculptEntry) 987 if (Shape.SculptEntry)
980 CheckSculptAndLoad(); 988 CheckSculptAndLoad();
981 else 989 else
982 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 990 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
983 } 991 }
984 } 992 }
985 } 993 }
@@ -1505,12 +1513,14 @@ namespace OpenSim.Region.Framework.Scenes
1505 } 1513 }
1506 1514
1507 // Basic Physics can also return null as well as an exception catch. 1515 // Basic Physics can also return null as well as an exception catch.
1508 if (PhysActor != null) 1516 PhysicsActor pa = PhysActor;
1517
1518 if (pa != null)
1509 { 1519 {
1510 PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 1520 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
1511 PhysActor.SetMaterial(Material); 1521 pa.SetMaterial(Material);
1512 DoPhysicsPropertyUpdate(RigidBody, true); 1522 DoPhysicsPropertyUpdate(RigidBody, true);
1513 PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); 1523 pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
1514 } 1524 }
1515 } 1525 }
1516 } 1526 }
@@ -1731,23 +1741,25 @@ namespace OpenSim.Region.Framework.Scenes
1731 } 1741 }
1732 else 1742 else
1733 { 1743 {
1734 if (PhysActor != null) 1744 PhysicsActor pa = PhysActor;
1745
1746 if (pa != null)
1735 { 1747 {
1736 if (UsePhysics != PhysActor.IsPhysical || isNew) 1748 if (UsePhysics != pa.IsPhysical || isNew)
1737 { 1749 {
1738 if (PhysActor.IsPhysical) // implies UsePhysics==false for this block 1750 if (pa.IsPhysical) // implies UsePhysics==false for this block
1739 { 1751 {
1740 if (!isNew) 1752 if (!isNew)
1741 ParentGroup.Scene.RemovePhysicalPrim(1); 1753 ParentGroup.Scene.RemovePhysicalPrim(1);
1742 1754
1743 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 1755 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
1744 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; 1756 pa.OnOutOfBounds -= PhysicsOutOfBounds;
1745 PhysActor.delink(); 1757 pa.delink();
1746 1758
1747 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) 1759 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew))
1748 { 1760 {
1749 // destroy all joints connected to this now deactivated body 1761 // destroy all joints connected to this now deactivated body
1750 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); 1762 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa);
1751 } 1763 }
1752 1764
1753 // stop client-side interpolation of all joint proxy objects that have just been deleted 1765 // stop client-side interpolation of all joint proxy objects that have just been deleted
@@ -1766,7 +1778,7 @@ namespace OpenSim.Region.Framework.Scenes
1766 //RotationalVelocity = new Vector3(0, 0, 0); 1778 //RotationalVelocity = new Vector3(0, 0, 0);
1767 } 1779 }
1768 1780
1769 PhysActor.IsPhysical = UsePhysics; 1781 pa.IsPhysical = UsePhysics;
1770 1782
1771 // If we're not what we're supposed to be in the physics scene, recreate ourselves. 1783 // If we're not what we're supposed to be in the physics scene, recreate ourselves.
1772 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 1784 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
@@ -1779,13 +1791,15 @@ namespace OpenSim.Region.Framework.Scenes
1779 { 1791 {
1780 ParentGroup.Scene.AddPhysicalPrim(1); 1792 ParentGroup.Scene.AddPhysicalPrim(1);
1781 1793
1782 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 1794 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
1783 PhysActor.OnOutOfBounds += PhysicsOutOfBounds; 1795 pa.OnOutOfBounds += PhysicsOutOfBounds;
1784 if (ParentID != 0 && ParentID != LocalId) 1796 if (ParentID != 0 && ParentID != LocalId)
1785 { 1797 {
1786 if (ParentGroup.RootPart.PhysActor != null) 1798 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
1799
1800 if (parentPa != null)
1787 { 1801 {
1788 PhysActor.link(ParentGroup.RootPart.PhysActor); 1802 pa.link(parentPa);
1789 } 1803 }
1790 } 1804 }
1791 } 1805 }
@@ -1797,7 +1811,7 @@ namespace OpenSim.Region.Framework.Scenes
1797 if (Shape.SculptEntry) 1811 if (Shape.SculptEntry)
1798 CheckSculptAndLoad(); 1812 CheckSculptAndLoad();
1799 else 1813 else
1800 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 1814 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
1801 } 1815 }
1802 } 1816 }
1803 } 1817 }
@@ -1908,24 +1922,30 @@ namespace OpenSim.Region.Framework.Scenes
1908 1922
1909 public Vector3 GetGeometricCenter() 1923 public Vector3 GetGeometricCenter()
1910 { 1924 {
1911 if (PhysActor != null) 1925 PhysicsActor pa = PhysActor;
1912 return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); 1926
1927 if (pa != null)
1928 return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z);
1913 else 1929 else
1914 return new Vector3(0, 0, 0); 1930 return new Vector3(0, 0, 0);
1915 } 1931 }
1916 1932
1917 public float GetMass() 1933 public float GetMass()
1918 { 1934 {
1919 if (PhysActor != null) 1935 PhysicsActor pa = PhysActor;
1920 return PhysActor.Mass; 1936
1937 if (pa != null)
1938 return pa.Mass;
1921 else 1939 else
1922 return 0; 1940 return 0;
1923 } 1941 }
1924 1942
1925 public Vector3 GetForce() 1943 public Vector3 GetForce()
1926 { 1944 {
1927 if (PhysActor != null) 1945 PhysicsActor pa = PhysActor;
1928 return PhysActor.Force; 1946
1947 if (pa != null)
1948 return pa.Force;
1929 else 1949 else
1930 return Vector3.Zero; 1950 return Vector3.Zero;
1931 } 1951 }
@@ -2556,9 +2576,11 @@ namespace OpenSim.Region.Framework.Scenes
2556 2576
2557 public void PhysicsRequestingTerseUpdate() 2577 public void PhysicsRequestingTerseUpdate()
2558 { 2578 {
2559 if (PhysActor != null) 2579 PhysicsActor pa = PhysActor;
2580
2581 if (pa != null)
2560 { 2582 {
2561 Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); 2583 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0);
2562 2584
2563 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) 2585 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
2564 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) 2586 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
@@ -2570,6 +2592,7 @@ namespace OpenSim.Region.Framework.Scenes
2570 } 2592 }
2571 //ParentGroup.RootPart.m_groupPosition = newpos; 2593 //ParentGroup.RootPart.m_groupPosition = newpos;
2572 } 2594 }
2595
2573 ScheduleTerseUpdate(); 2596 ScheduleTerseUpdate();
2574 } 2597 }
2575 2598
@@ -2660,7 +2683,9 @@ namespace OpenSim.Region.Framework.Scenes
2660 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys); 2683 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
2661 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys); 2684 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
2662 2685
2663 if (PhysActor != null && PhysActor.IsPhysical) 2686 PhysicsActor pa = PhysActor;
2687
2688 if (pa != null && pa.IsPhysical)
2664 { 2689 {
2665 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys); 2690 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
2666 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys); 2691 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
@@ -2809,12 +2834,14 @@ namespace OpenSim.Region.Framework.Scenes
2809 m_shape.SculptData = texture.Data; 2834 m_shape.SculptData = texture.Data;
2810 } 2835 }
2811 2836
2812 if (PhysActor != null) 2837 PhysicsActor pa = PhysActor;
2838
2839 if (pa != null)
2813 { 2840 {
2814 // Update the physics actor with the new loaded sculpt data and set the taint signal. 2841 // Update the physics actor with the new loaded sculpt data and set the taint signal.
2815 PhysActor.Shape = m_shape; 2842 pa.Shape = m_shape;
2816 2843
2817 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 2844 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
2818 } 2845 }
2819 } 2846 }
2820 } 2847 }
@@ -3072,10 +3099,10 @@ namespace OpenSim.Region.Framework.Scenes
3072 3099
3073 public void SetBuoyancy(float fvalue) 3100 public void SetBuoyancy(float fvalue)
3074 { 3101 {
3075 if (PhysActor != null) 3102 PhysicsActor pa = PhysActor;
3076 { 3103
3077 PhysActor.Buoyancy = fvalue; 3104 if (pa != null)
3078 } 3105 pa.Buoyancy = fvalue;
3079 } 3106 }
3080 3107
3081 public void SetDieAtEdge(bool p) 3108 public void SetDieAtEdge(bool p)
@@ -3088,57 +3115,50 @@ namespace OpenSim.Region.Framework.Scenes
3088 3115
3089 public void SetFloatOnWater(int floatYN) 3116 public void SetFloatOnWater(int floatYN)
3090 { 3117 {
3091 if (PhysActor != null) 3118 PhysicsActor pa = PhysActor;
3092 { 3119
3093 if (floatYN == 1) 3120 if (pa != null)
3094 { 3121 pa.FloatOnWater = floatYN == 1;
3095 PhysActor.FloatOnWater = true;
3096 }
3097 else
3098 {
3099 PhysActor.FloatOnWater = false;
3100 }
3101 }
3102 } 3122 }
3103 3123
3104 public void SetForce(Vector3 force) 3124 public void SetForce(Vector3 force)
3105 { 3125 {
3106 if (PhysActor != null) 3126 PhysicsActor pa = PhysActor;
3107 { 3127
3108 PhysActor.Force = force; 3128 if (pa != null)
3109 } 3129 pa.Force = force;
3110 } 3130 }
3111 3131
3112 public void SetVehicleType(int type) 3132 public void SetVehicleType(int type)
3113 { 3133 {
3114 if (PhysActor != null) 3134 PhysicsActor pa = PhysActor;
3115 { 3135
3116 PhysActor.VehicleType = type; 3136 if (pa != null)
3117 } 3137 pa.VehicleType = type;
3118 } 3138 }
3119 3139
3120 public void SetVehicleFloatParam(int param, float value) 3140 public void SetVehicleFloatParam(int param, float value)
3121 { 3141 {
3122 if (PhysActor != null) 3142 PhysicsActor pa = PhysActor;
3123 { 3143
3124 PhysActor.VehicleFloatParam(param, value); 3144 if (pa != null)
3125 } 3145 pa.VehicleFloatParam(param, value);
3126 } 3146 }
3127 3147
3128 public void SetVehicleVectorParam(int param, Vector3 value) 3148 public void SetVehicleVectorParam(int param, Vector3 value)
3129 { 3149 {
3130 if (PhysActor != null) 3150 PhysicsActor pa = PhysActor;
3131 { 3151
3132 PhysActor.VehicleVectorParam(param, value); 3152 if (pa != null)
3133 } 3153 pa.VehicleVectorParam(param, value);
3134 } 3154 }
3135 3155
3136 public void SetVehicleRotationParam(int param, Quaternion rotation) 3156 public void SetVehicleRotationParam(int param, Quaternion rotation)
3137 { 3157 {
3138 if (PhysActor != null) 3158 PhysicsActor pa = PhysActor;
3139 { 3159
3140 PhysActor.VehicleRotationParam(param, rotation); 3160 if (pa != null)
3141 } 3161 pa.VehicleRotationParam(param, rotation);
3142 } 3162 }
3143 3163
3144 /// <summary> 3164 /// <summary>
@@ -4226,6 +4246,8 @@ namespace OpenSim.Region.Framework.Scenes
4226 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4246 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4227 return; 4247 return;
4228 4248
4249 PhysicsActor pa = PhysActor;
4250
4229 // Special cases for VD. VD can only be called from a script 4251 // Special cases for VD. VD can only be called from a script
4230 // and can't be combined with changes to other states. So we can rely 4252 // and can't be combined with changes to other states. So we can rely
4231 // that... 4253 // that...
@@ -4241,8 +4263,9 @@ namespace OpenSim.Region.Framework.Scenes
4241 { 4263 {
4242 SetVD = false; // Switch it of for the course of this routine 4264 SetVD = false; // Switch it of for the course of this routine
4243 VolumeDetectActive = false; // and also permanently 4265 VolumeDetectActive = false; // and also permanently
4244 if (PhysActor != null) 4266
4245 PhysActor.SetVolumeDetect(0); // Let physics know about it too 4267 if (pa != null)
4268 pa.SetVolumeDetect(0); // Let physics know about it too
4246 } 4269 }
4247 else 4270 else
4248 { 4271 {
@@ -4357,9 +4380,9 @@ namespace OpenSim.Region.Framework.Scenes
4357 // Defensive programming calls for a check here. 4380 // Defensive programming calls for a check here.
4358 // Better would be throwing an exception that could be catched by a unit test as the internal 4381 // Better would be throwing an exception that could be catched by a unit test as the internal
4359 // logic should make sure, this Physactor is always here. 4382 // logic should make sure, this Physactor is always here.
4360 if (this.PhysActor != null) 4383 if (pa != null)
4361 { 4384 {
4362 PhysActor.SetVolumeDetect(1); 4385 pa.SetVolumeDetect(1);
4363 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active 4386 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4364 this.VolumeDetectActive = true; 4387 this.VolumeDetectActive = true;
4365 } 4388 }
@@ -4368,11 +4391,8 @@ namespace OpenSim.Region.Framework.Scenes
4368 { 4391 {
4369 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like 4392 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4370 // (mumbles, well, at least if you have infinte CPU powers :-)) 4393 // (mumbles, well, at least if you have infinte CPU powers :-))
4371 PhysicsActor pa = this.PhysActor;
4372 if (pa != null) 4394 if (pa != null)
4373 {
4374 PhysActor.SetVolumeDetect(0); 4395 PhysActor.SetVolumeDetect(0);
4375 }
4376 4396
4377 this.VolumeDetectActive = false; 4397 this.VolumeDetectActive = false;
4378 } 4398 }
@@ -4385,6 +4405,7 @@ namespace OpenSim.Region.Framework.Scenes
4385 { 4405 {
4386 RemFlag(PrimFlags.TemporaryOnRez); 4406 RemFlag(PrimFlags.TemporaryOnRez);
4387 } 4407 }
4408
4388 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4409 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4389 4410
4390 if (ParentGroup != null) 4411 if (ParentGroup != null)
@@ -4453,10 +4474,12 @@ namespace OpenSim.Region.Framework.Scenes
4453 m_shape.PathTwist = shapeBlock.PathTwist; 4474 m_shape.PathTwist = shapeBlock.PathTwist;
4454 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; 4475 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin;
4455 4476
4456 if (PhysActor != null) 4477 PhysicsActor pa = PhysActor;
4478
4479 if (pa != null)
4457 { 4480 {
4458 PhysActor.Shape = m_shape; 4481 pa.Shape = m_shape;
4459 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 4482 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4460 } 4483 }
4461 4484
4462 // This is what makes vehicle trailers work 4485 // This is what makes vehicle trailers work
@@ -4598,6 +4621,8 @@ namespace OpenSim.Region.Framework.Scenes
4598 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 4621 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
4599 } 4622 }
4600 4623
4624 PhysicsActor pa = PhysActor;
4625
4601 if ( 4626 if (
4602 ((AggregateScriptEvents & scriptEvents.collision) != 0) || 4627 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4603 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || 4628 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
@@ -4609,18 +4634,18 @@ namespace OpenSim.Region.Framework.Scenes
4609 ) 4634 )
4610 { 4635 {
4611 // subscribe to physics updates. 4636 // subscribe to physics updates.
4612 if (PhysActor != null) 4637 if (pa != null)
4613 { 4638 {
4614 PhysActor.OnCollisionUpdate += PhysicsCollision; 4639 pa.OnCollisionUpdate += PhysicsCollision;
4615 PhysActor.SubscribeEvents(1000); 4640 pa.SubscribeEvents(1000);
4616 } 4641 }
4617 } 4642 }
4618 else 4643 else
4619 { 4644 {
4620 if (PhysActor != null) 4645 if (pa != null)
4621 { 4646 {
4622 PhysActor.UnSubscribeEvents(); 4647 pa.UnSubscribeEvents();
4623 PhysActor.OnCollisionUpdate -= PhysicsCollision; 4648 pa.OnCollisionUpdate -= PhysicsCollision;
4624 } 4649 }
4625 } 4650 }
4626 4651
diff --git a/prebuild.xml b/prebuild.xml
index a8b735c..6a90d64 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1455,7 +1455,7 @@
1455 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/> 1455 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
1456 <Reference name="OpenMetaverse" path="../../../bin/"/> 1456 <Reference name="OpenMetaverse" path="../../../bin/"/>
1457 <Reference name="CSJ2K" path="../../../bin/"/> 1457 <Reference name="CSJ2K" path="../../../bin/"/>
1458 <Reference name="Warp3D" path="../../../bin/" localCopy="true"/> 1458 <Reference name="Warp3D" path="../../../bin/"/>
1459 <Reference name="OpenSim.Capabilities"/> 1459 <Reference name="OpenSim.Capabilities"/>
1460 <Reference name="OpenSim.Data"/> 1460 <Reference name="OpenSim.Data"/>
1461 <Reference name="OpenSim.Framework"/> 1461 <Reference name="OpenSim.Framework"/>