aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
authorUbitUmarov2019-01-25 20:52:46 +0000
committerUbitUmarov2019-01-25 20:52:46 +0000
commit80487467594379f65f7e5358a43789a8e6c5648b (patch)
tree3de7ae8855306da27a7c1c2c496c656a01de95d9 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
parentcleanup dead code (diff)
downloadopensim-SC-80487467594379f65f7e5358a43789a8e6c5648b.zip
opensim-SC-80487467594379f65f7e5358a43789a8e6c5648b.tar.gz
opensim-SC-80487467594379f65f7e5358a43789a8e6c5648b.tar.bz2
opensim-SC-80487467594379f65f7e5358a43789a8e6c5648b.tar.xz
changes on sog boundingbox and other cleanup
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs473
1 files changed, 178 insertions, 295 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 39a1779..7d5bbbf 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -431,29 +431,47 @@ namespace OpenSim.Region.Framework.Scenes
431 { 431 {
432 get 432 get
433 { 433 {
434 Vector3 minScale = new Vector3(Constants.MaximumRegionSize, Constants.MaximumRegionSize, Constants.MaximumRegionSize); 434 Vector3 finalScale = new Vector3();
435 Vector3 maxScale = Vector3.Zero;
436 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
437 435
438 SceneObjectPart[] parts = m_parts.GetArray(); 436 SceneObjectPart[] parts = m_parts.GetArray();
439 for (int i = 0; i < parts.Length; i++) 437 SceneObjectPart part;
440 { 438 Vector3 partscale;
441 SceneObjectPart part = parts[i];
442 Vector3 partscale = part.Scale;
443 Vector3 partoffset = part.OffsetPosition;
444 439
445 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; 440 float ftmp;
446 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; 441 float minScaleX = float.MaxValue;
447 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; 442 float minScaleY = float.MaxValue;
443 float minScaleZ = float.MaxValue;
444 float maxScaleX = 0f;
445 float maxScaleY = 0f;
446 float maxScaleZ = 0f;
448 447
449 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; 448 for (int i = 0; i < parts.Length; i++)
450 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; 449 {
451 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; 450 part = parts[i];
451 partscale = part.Scale + part.OffsetPosition;
452
453 ftmp = partscale.X;
454 if (ftmp < minScaleX)
455 minScaleX = ftmp;
456 if (ftmp > maxScaleX)
457 maxScaleX = ftmp;
458
459 ftmp = partscale.Y;
460 if (ftmp < minScaleY)
461 minScaleY = ftmp;
462 if (ftmp > maxScaleY)
463 maxScaleY = ftmp;
464
465 ftmp = partscale.Z;
466 if (ftmp < minScaleZ)
467 minScaleZ = ftmp;
468 if (ftmp > maxScaleZ)
469 maxScaleZ = ftmp;
452 } 470 }
453 471
454 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; 472 finalScale.X = (minScaleX > maxScaleX) ? minScaleX : maxScaleX;
455 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; 473 finalScale.Y = (minScaleY > maxScaleY) ? minScaleY : maxScaleY;
456 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; 474 finalScale.Z = (minScaleZ > maxScaleZ) ? minScaleZ : maxScaleZ;
457 475
458 return finalScale; 476 return finalScale;
459 } 477 }
@@ -1507,13 +1525,80 @@ namespace OpenSim.Region.Framework.Scenes
1507 return result; 1525 return result;
1508 } 1526 }
1509 1527
1510 /// <summary> 1528 public void GetBoundingBox(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ)
1511 /// Gets a vector representing the size of the bounding box containing all the prims in the group 1529 {
1512 /// Treats all prims as rectangular, so no shape (cut etc) is taken into account 1530 uint rootid = RootPart.LocalId;
1513 /// offsetHeight is the offset in the Z axis from the centre of the bounding box to the centre of the root prim 1531 Vector3 scale = RootPart.Scale * 0.5f;
1514 /// </summary> 1532
1515 /// <returns></returns> 1533 minX = -scale.X;
1516 public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) 1534 maxX = scale.X;
1535 minY = -scale.Y;
1536 maxY = scale.Y;
1537 minZ = -scale.Z;
1538 maxZ = scale.Z;
1539
1540 SceneObjectPart[] parts = m_parts.GetArray();
1541 SceneObjectPart part;
1542 for (int i = 0; i < parts.Length; ++i)
1543 {
1544 part = parts[i];
1545 if(part.LocalId == rootid)
1546 continue;
1547
1548 Vector3 offset = part.OffsetPosition;
1549 scale = part.Scale * 0.5f;
1550
1551 Matrix4 m = Matrix4.CreateFromQuaternion(part.RotationOffset);
1552 Vector3 a = m.AtAxis;
1553 a.X = Math.Abs(a.X);
1554 a.Y = Math.Abs(a.Y);
1555 a.Z = Math.Abs(a.Z);
1556
1557 float tmpS = Vector3.Dot(a, scale);
1558 float tmp = offset.X - tmpS;
1559 if (tmp < minX)
1560 minX = tmp;
1561
1562 tmp = offset.X + tmpS;
1563 if (tmp > maxX)
1564 maxX = tmp;
1565
1566 a = m.LeftAxis;
1567 a.X = Math.Abs(a.X);
1568 a.Y = Math.Abs(a.Y);
1569 a.Z = Math.Abs(a.Z);
1570 tmpS = Vector3.Dot(a, scale);
1571
1572 tmp = offset.Y - tmpS;
1573 if (tmp < minY)
1574 minY = tmp;
1575
1576 tmp = offset.Y + tmpS;
1577 if (tmp > maxY)
1578 maxY = tmp;
1579
1580 a = m.UpAxis;
1581 a.X = Math.Abs(a.X);
1582 a.Y = Math.Abs(a.Y);
1583 a.Z = Math.Abs(a.Z);
1584
1585 tmpS = Vector3.Dot(a, scale);
1586 tmp = offset.Z - tmpS;
1587 if (tmp < minZ)
1588 minZ = tmp;
1589
1590 tmp = offset.Z + tmpS;
1591 if (tmp > maxZ)
1592 maxZ = tmp;
1593 }
1594 }
1595 /// <summary>
1596 /// Gets a vector representing the size of the bounding box containing all the prims in the group
1597 /// Treats all prims as rectangular, so no shape (cut etc) is taken into account
1598 /// offsetHeight is the offset in the Z axis from the centre of the bounding box to the centre of the root prim
1599 /// </summary>
1600 /// <returns></returns>
1601 public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ)
1517 { 1602 {
1518 maxX = float.MinValue; 1603 maxX = float.MinValue;
1519 maxY = float.MinValue; 1604 maxY = float.MinValue;
@@ -1522,238 +1607,57 @@ namespace OpenSim.Region.Framework.Scenes
1522 minY = float.MaxValue; 1607 minY = float.MaxValue;
1523 minZ = float.MaxValue; 1608 minZ = float.MaxValue;
1524 1609
1610 Vector3 absPos = AbsolutePosition;
1525 SceneObjectPart[] parts = m_parts.GetArray(); 1611 SceneObjectPart[] parts = m_parts.GetArray();
1526 foreach (SceneObjectPart part in parts) 1612 SceneObjectPart part;
1613 for(int i = 0; i< parts.Length; ++i)
1527 { 1614 {
1528 Vector3 worldPos = part.GetWorldPosition(); 1615 part = parts[i];
1529 Vector3 offset = worldPos - AbsolutePosition; 1616 Vector3 offset = part.GetWorldPosition() - absPos;
1530 Quaternion worldRot; 1617 Vector3 scale = part.Scale * 0.5f;
1531 if (part.ParentID == 0)
1532 {
1533 worldRot = part.RotationOffset;
1534 }
1535 else
1536 {
1537 worldRot = part.GetWorldRotation();
1538 }
1539 1618
1540 Vector3 frontTopLeft; 1619 Matrix4 m = Matrix4.CreateFromQuaternion(part.GetWorldRotation());
1541 Vector3 frontTopRight; 1620 Vector3 a = m.AtAxis;
1542 Vector3 frontBottomLeft; 1621 a.X = Math.Abs(a.X);
1543 Vector3 frontBottomRight; 1622 a.Y = Math.Abs(a.Y);
1544 1623 a.Z = Math.Abs(a.Z);
1545 Vector3 backTopLeft;
1546 Vector3 backTopRight;
1547 Vector3 backBottomLeft;
1548 Vector3 backBottomRight;
1549
1550 // Vector3[] corners = new Vector3[8];
1551
1552 Vector3 orig = Vector3.Zero;
1553
1554 frontTopLeft.X = orig.X - (part.Scale.X / 2);
1555 frontTopLeft.Y = orig.Y - (part.Scale.Y / 2);
1556 frontTopLeft.Z = orig.Z + (part.Scale.Z / 2);
1557
1558 frontTopRight.X = orig.X - (part.Scale.X / 2);
1559 frontTopRight.Y = orig.Y + (part.Scale.Y / 2);
1560 frontTopRight.Z = orig.Z + (part.Scale.Z / 2);
1561
1562 frontBottomLeft.X = orig.X - (part.Scale.X / 2);
1563 frontBottomLeft.Y = orig.Y - (part.Scale.Y / 2);
1564 frontBottomLeft.Z = orig.Z - (part.Scale.Z / 2);
1565
1566 frontBottomRight.X = orig.X - (part.Scale.X / 2);
1567 frontBottomRight.Y = orig.Y + (part.Scale.Y / 2);
1568 frontBottomRight.Z = orig.Z - (part.Scale.Z / 2);
1569
1570 backTopLeft.X = orig.X + (part.Scale.X / 2);
1571 backTopLeft.Y = orig.Y - (part.Scale.Y / 2);
1572 backTopLeft.Z = orig.Z + (part.Scale.Z / 2);
1573
1574 backTopRight.X = orig.X + (part.Scale.X / 2);
1575 backTopRight.Y = orig.Y + (part.Scale.Y / 2);
1576 backTopRight.Z = orig.Z + (part.Scale.Z / 2);
1577
1578 backBottomLeft.X = orig.X + (part.Scale.X / 2);
1579 backBottomLeft.Y = orig.Y - (part.Scale.Y / 2);
1580 backBottomLeft.Z = orig.Z - (part.Scale.Z / 2);
1581
1582 backBottomRight.X = orig.X + (part.Scale.X / 2);
1583 backBottomRight.Y = orig.Y + (part.Scale.Y / 2);
1584 backBottomRight.Z = orig.Z - (part.Scale.Z / 2);
1585
1586
1587
1588 //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z);
1589 //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z);
1590 //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z);
1591 //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z);
1592 //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z);
1593 //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z);
1594 //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z);
1595 //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z);
1596
1597 //for (int i = 0; i < 8; i++)
1598 //{
1599 // corners[i] = corners[i] * worldRot;
1600 // corners[i] += offset;
1601
1602 // if (corners[i].X > maxX)
1603 // maxX = corners[i].X;
1604 // if (corners[i].X < minX)
1605 // minX = corners[i].X;
1606
1607 // if (corners[i].Y > maxY)
1608 // maxY = corners[i].Y;
1609 // if (corners[i].Y < minY)
1610 // minY = corners[i].Y;
1611
1612 // if (corners[i].Z > maxZ)
1613 // maxZ = corners[i].Y;
1614 // if (corners[i].Z < minZ)
1615 // minZ = corners[i].Z;
1616 //}
1617
1618 frontTopLeft = frontTopLeft * worldRot;
1619 frontTopRight = frontTopRight * worldRot;
1620 frontBottomLeft = frontBottomLeft * worldRot;
1621 frontBottomRight = frontBottomRight * worldRot;
1622
1623 backBottomLeft = backBottomLeft * worldRot;
1624 backBottomRight = backBottomRight * worldRot;
1625 backTopLeft = backTopLeft * worldRot;
1626 backTopRight = backTopRight * worldRot;
1627
1628
1629 frontTopLeft += offset;
1630 frontTopRight += offset;
1631 frontBottomLeft += offset;
1632 frontBottomRight += offset;
1633
1634 backBottomLeft += offset;
1635 backBottomRight += offset;
1636 backTopLeft += offset;
1637 backTopRight += offset;
1638
1639 //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z);
1640 //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z);
1641 //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z);
1642 //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z);
1643 //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z);
1644 //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z);
1645 //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z);
1646 //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z);
1647
1648 if (frontTopRight.X > maxX)
1649 maxX = frontTopRight.X;
1650 if (frontTopLeft.X > maxX)
1651 maxX = frontTopLeft.X;
1652 if (frontBottomRight.X > maxX)
1653 maxX = frontBottomRight.X;
1654 if (frontBottomLeft.X > maxX)
1655 maxX = frontBottomLeft.X;
1656
1657 if (backTopRight.X > maxX)
1658 maxX = backTopRight.X;
1659 if (backTopLeft.X > maxX)
1660 maxX = backTopLeft.X;
1661 if (backBottomRight.X > maxX)
1662 maxX = backBottomRight.X;
1663 if (backBottomLeft.X > maxX)
1664 maxX = backBottomLeft.X;
1665
1666 if (frontTopRight.X < minX)
1667 minX = frontTopRight.X;
1668 if (frontTopLeft.X < minX)
1669 minX = frontTopLeft.X;
1670 if (frontBottomRight.X < minX)
1671 minX = frontBottomRight.X;
1672 if (frontBottomLeft.X < minX)
1673 minX = frontBottomLeft.X;
1674
1675 if (backTopRight.X < minX)
1676 minX = backTopRight.X;
1677 if (backTopLeft.X < minX)
1678 minX = backTopLeft.X;
1679 if (backBottomRight.X < minX)
1680 minX = backBottomRight.X;
1681 if (backBottomLeft.X < minX)
1682 minX = backBottomLeft.X;
1683 1624
1684 // 1625 float tmpS = Vector3.Dot(a, scale);
1685 if (frontTopRight.Y > maxY) 1626 float tmp = offset.X - tmpS;
1686 maxY = frontTopRight.Y; 1627 if (tmp < minX)
1687 if (frontTopLeft.Y > maxY) 1628 minX = tmp;
1688 maxY = frontTopLeft.Y;
1689 if (frontBottomRight.Y > maxY)
1690 maxY = frontBottomRight.Y;
1691 if (frontBottomLeft.Y > maxY)
1692 maxY = frontBottomLeft.Y;
1693
1694 if (backTopRight.Y > maxY)
1695 maxY = backTopRight.Y;
1696 if (backTopLeft.Y > maxY)
1697 maxY = backTopLeft.Y;
1698 if (backBottomRight.Y > maxY)
1699 maxY = backBottomRight.Y;
1700 if (backBottomLeft.Y > maxY)
1701 maxY = backBottomLeft.Y;
1702
1703 if (frontTopRight.Y < minY)
1704 minY = frontTopRight.Y;
1705 if (frontTopLeft.Y < minY)
1706 minY = frontTopLeft.Y;
1707 if (frontBottomRight.Y < minY)
1708 minY = frontBottomRight.Y;
1709 if (frontBottomLeft.Y < minY)
1710 minY = frontBottomLeft.Y;
1711
1712 if (backTopRight.Y < minY)
1713 minY = backTopRight.Y;
1714 if (backTopLeft.Y < minY)
1715 minY = backTopLeft.Y;
1716 if (backBottomRight.Y < minY)
1717 minY = backBottomRight.Y;
1718 if (backBottomLeft.Y < minY)
1719 minY = backBottomLeft.Y;
1720 1629
1721 // 1630 tmp = offset.X + tmpS;
1722 if (frontTopRight.Z > maxZ) 1631 if (tmp > maxX)
1723 maxZ = frontTopRight.Z; 1632 maxX = tmp;
1724 if (frontTopLeft.Z > maxZ) 1633
1725 maxZ = frontTopLeft.Z; 1634 a = m.LeftAxis;
1726 if (frontBottomRight.Z > maxZ) 1635 a.X = Math.Abs(a.X);
1727 maxZ = frontBottomRight.Z; 1636 a.Y = Math.Abs(a.Y);
1728 if (frontBottomLeft.Z > maxZ) 1637 a.Z = Math.Abs(a.Z);
1729 maxZ = frontBottomLeft.Z; 1638 tmpS = Vector3.Dot(a, scale);
1730 1639
1731 if (backTopRight.Z > maxZ) 1640 tmp = offset.Y - tmpS;
1732 maxZ = backTopRight.Z; 1641 if (tmp < minY)
1733 if (backTopLeft.Z > maxZ) 1642 minY = tmp;
1734 maxZ = backTopLeft.Z; 1643
1735 if (backBottomRight.Z > maxZ) 1644 tmp = offset.Y + tmpS;
1736 maxZ = backBottomRight.Z; 1645 if (tmp > maxY)
1737 if (backBottomLeft.Z > maxZ) 1646 maxY = tmp;
1738 maxZ = backBottomLeft.Z; 1647
1739 1648 a = m.UpAxis;
1740 if (frontTopRight.Z < minZ) 1649 a.X = Math.Abs(a.X);
1741 minZ = frontTopRight.Z; 1650 a.Y = Math.Abs(a.Y);
1742 if (frontTopLeft.Z < minZ) 1651 a.Z = Math.Abs(a.Z);
1743 minZ = frontTopLeft.Z; 1652
1744 if (frontBottomRight.Z < minZ) 1653 tmpS = Vector3.Dot(a, scale);
1745 minZ = frontBottomRight.Z; 1654 tmp = offset.Z - tmpS;
1746 if (frontBottomLeft.Z < minZ) 1655 if (tmp < minZ)
1747 minZ = frontBottomLeft.Z; 1656 minZ = tmp;
1748 1657
1749 if (backTopRight.Z < minZ) 1658 tmp = offset.Z + tmpS;
1750 minZ = backTopRight.Z; 1659 if (tmp > maxZ)
1751 if (backTopLeft.Z < minZ) 1660 maxZ = tmp;
1752 minZ = backTopLeft.Z;
1753 if (backBottomRight.Z < minZ)
1754 minZ = backBottomRight.Z;
1755 if (backBottomLeft.Z < minZ)
1756 minZ = backBottomLeft.Z;
1757 } 1661 }
1758 } 1662 }
1759 1663
@@ -1795,12 +1699,26 @@ namespace OpenSim.Region.Framework.Scenes
1795 } 1699 }
1796 1700
1797 private Vector3 m_boundsCenter; 1701 private Vector3 m_boundsCenter;
1798 public Vector3 getBoundsCenter() 1702 private Vector3 m_LastCenterOffset;
1703 private Vector3 last_boundsRot = new Vector3(-10, -10, -10);
1704 public Vector3 getCenterOffset()
1799 { 1705 {
1800 // math is done in GetBoundsRadius(); 1706 // math is done in GetBoundsRadius();
1801 if(m_boundsRadius == null) 1707 if(m_boundsRadius == null)
1802 GetBoundsRadius(); 1708 GetBoundsRadius();
1803 return m_boundsCenter; 1709
1710 Quaternion rot = m_rootPart.RotationOffset;
1711 if (last_boundsRot.X != rot.X ||
1712 last_boundsRot.Y != rot.Y ||
1713 last_boundsRot.Z != rot.Z)
1714 {
1715 m_LastCenterOffset = m_boundsCenter * rot;
1716 last_boundsRot.X = rot.X;
1717 last_boundsRot.Y = rot.Y;
1718 last_boundsRot.Z = rot.Z;
1719 }
1720
1721 return m_rootPart.GroupPosition + m_LastCenterOffset;
1804 } 1722 }
1805 1723
1806 private float m_areaFactor; 1724 private float m_areaFactor;
@@ -1819,14 +1737,10 @@ namespace OpenSim.Region.Framework.Scenes
1819 { 1737 {
1820 float res = 0; 1738 float res = 0;
1821 float areaF = 0; 1739 float areaF = 0;
1822 SceneObjectPart p;
1823 SceneObjectPart[] parts;
1824 float partR; 1740 float partR;
1825 Vector3 offset = Vector3.Zero; 1741 Vector3 offset = Vector3.Zero;
1826 lock (m_parts) 1742 SceneObjectPart p;
1827 { 1743 SceneObjectPart[] parts = m_parts.GetArray();
1828 parts = m_parts.GetArray();
1829 }
1830 1744
1831 int nparts = parts.Length; 1745 int nparts = parts.Length;
1832 for (int i = 0; i < nparts; i++) 1746 for (int i = 0; i < nparts; i++)
@@ -1846,11 +1760,10 @@ namespace OpenSim.Region.Framework.Scenes
1846 if(parts.Length > 1) 1760 if(parts.Length > 1)
1847 { 1761 {
1848 offset /= parts.Length; // basicly geometric center 1762 offset /= parts.Length; // basicly geometric center
1849 offset = offset * RootPart.RotationOffset;
1850 } 1763 }
1851 1764
1852 areaF = 10.0f / areaF; // scale it 1765 areaF = 0.5f / areaF; // scale it
1853 areaF = Util.Clamp(areaF, 0.001f, 1000f); // clamp it 1766 areaF = Util.Clamp(areaF, 0.05f, 100f); // clamp it
1854 1767
1855 m_areaFactor = (float)Math.Sqrt(areaF); 1768 m_areaFactor = (float)Math.Sqrt(areaF);
1856 m_boundsCenter = offset; 1769 m_boundsCenter = offset;
@@ -1872,16 +1785,9 @@ namespace OpenSim.Region.Framework.Scenes
1872 bool ComplexCost = false; 1785 bool ComplexCost = false;
1873 1786
1874 SceneObjectPart p; 1787 SceneObjectPart p;
1875 SceneObjectPart[] parts; 1788 SceneObjectPart[] parts = m_parts.GetArray();
1876
1877 lock (m_parts)
1878 {
1879 parts = m_parts.GetArray();
1880 }
1881 1789
1882 int nparts = parts.Length; 1790 int nparts = parts.Length;
1883
1884
1885 for (int i = 0; i < nparts; i++) 1791 for (int i = 0; i < nparts; i++)
1886 { 1792 {
1887 p = parts[i]; 1793 p = parts[i];
@@ -2478,7 +2384,6 @@ namespace OpenSim.Region.Framework.Scenes
2478 backup_group.RootPart.Velocity = RootPart.Velocity; 2384 backup_group.RootPart.Velocity = RootPart.Velocity;
2479 backup_group.RootPart.Acceleration = RootPart.Acceleration; 2385 backup_group.RootPart.Acceleration = RootPart.Acceleration;
2480 backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; 2386 backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
2481 backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
2482 HasGroupChanged = false; 2387 HasGroupChanged = false;
2483 GroupContainsForeignPrims = false; 2388 GroupContainsForeignPrims = false;
2484 2389
@@ -2588,30 +2493,10 @@ namespace OpenSim.Region.Framework.Scenes
2588 { 2493 {
2589 newPart = dupe.m_rootPart; 2494 newPart = dupe.m_rootPart;
2590 } 2495 }
2591/*
2592 bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0);
2593 bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0);
2594 2496
2595 // Need to duplicate the physics actor as well
2596 if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive))
2597 {
2598 PrimitiveBaseShape pbs = newPart.Shape;
2599 newPart.PhysActor
2600 = m_scene.PhysicsScene.AddPrimShape(
2601 string.Format("{0}/{1}", newPart.Name, newPart.UUID),
2602 pbs,
2603 newPart.AbsolutePosition,
2604 newPart.Scale,
2605 newPart.GetWorldRotation(),
2606 isphys,
2607 isphan,
2608 newPart.LocalId);
2609
2610 newPart.DoPhysicsPropertyUpdate(isphys, true);
2611 */
2612 if (userExposed) 2497 if (userExposed)
2613 newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); 2498 newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true);
2614// } 2499
2615 // copy keyframemotion 2500 // copy keyframemotion
2616 if (part.KeyframeMotion != null) 2501 if (part.KeyframeMotion != null)
2617 newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); 2502 newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe);
@@ -2619,8 +2504,6 @@ namespace OpenSim.Region.Framework.Scenes
2619 2504
2620 if (userExposed) 2505 if (userExposed)
2621 { 2506 {
2622// done above dupe.UpdateParentIDs();
2623
2624 if (dupe.m_rootPart.PhysActor != null) 2507 if (dupe.m_rootPart.PhysActor != null)
2625 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building 2508 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building
2626 2509
@@ -4015,7 +3898,7 @@ namespace OpenSim.Region.Framework.Scenes
4015 3898
4016 for (int i = 0; i < parts.Length; i++) 3899 for (int i = 0; i < parts.Length; i++)
4017 { 3900 {
4018 if (parts[i].LocalId != m_rootPart.LocalId) 3901 if (parts[i].UUID != m_rootPart.UUID)
4019 parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); 3902 parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true);
4020 } 3903 }
4021 3904