diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 140 |
1 files changed, 86 insertions, 54 deletions
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(); |