diff options
author | UbitUmarov | 2016-07-13 22:29:09 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-13 22:29:09 +0100 |
commit | 00687d5b0fef803bfebed5da2b1841890b589900 (patch) | |
tree | 5d95ca7d3c16d61c21042cd82ca27db0c3419dc8 /OpenSim | |
parent | Oops that was not slower (diff) | |
download | opensim-SC-00687d5b0fef803bfebed5da2b1841890b589900.zip opensim-SC-00687d5b0fef803bfebed5da2b1841890b589900.tar.gz opensim-SC-00687d5b0fef803bfebed5da2b1841890b589900.tar.bz2 opensim-SC-00687d5b0fef803bfebed5da2b1841890b589900.tar.xz |
use geometric center and not sog root position in culling
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 32 |
2 files changed, 25 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index c6190dd..2f5d3c8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -4115,12 +4115,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4115 | 4115 | ||
4116 | if(!inview) | 4116 | if(!inview) |
4117 | { | 4117 | { |
4118 | Vector3 partpos = grp.AbsolutePosition; | 4118 | float bradius = grp.GetBoundsRadius(); // needs to be called before getBoundsCenter |
4119 | Vector3 partpos = grp.AbsolutePosition + grp.getBoundsCenter(); | ||
4119 | // float dcam = (partpos - mycamera).LengthSquared(); | 4120 | // float dcam = (partpos - mycamera).LengthSquared(); |
4120 | float dpos = (partpos - mypos).LengthSquared(); | 4121 | float dpos = (partpos - mypos).LengthSquared(); |
4121 | // if(dcam < dpos) | 4122 | // if(dcam < dpos) |
4122 | // dpos = dcam; | 4123 | // dpos = dcam; |
4123 | dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius(); | 4124 | dpos = (float)Math.Sqrt(dpos) - bradius; |
4124 | if(dpos > cullingrange) | 4125 | if(dpos > cullingrange) |
4125 | continue; | 4126 | continue; |
4126 | 4127 | ||
@@ -4418,13 +4419,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4418 | if(grp.IsDeleted || grp.IsAttachment) | 4419 | if(grp.IsDeleted || grp.IsAttachment) |
4419 | continue; | 4420 | continue; |
4420 | 4421 | ||
4421 | Vector3 grppos = grp.AbsolutePosition; | 4422 | float bradius = grp.GetBoundsRadius(); // needs to be called before getBoundsCenter |
4423 | Vector3 grppos = grp.AbsolutePosition + grp.getBoundsCenter(); | ||
4422 | // float dcam = (grppos - mycamera).LengthSquared(); | 4424 | // float dcam = (grppos - mycamera).LengthSquared(); |
4423 | float dpos = (grppos - mypos).LengthSquared(); | 4425 | float dpos = (grppos - mypos).LengthSquared(); |
4424 | // if(dcam < dpos) | 4426 | // if(dcam < dpos) |
4425 | // dpos = dcam; | 4427 | // dpos = dcam; |
4426 | 4428 | ||
4427 | dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius(); | 4429 | dpos = (float)Math.Sqrt(dpos) - bradius; |
4428 | 4430 | ||
4429 | bool inview; | 4431 | bool inview; |
4430 | lock(GroupsInView) | 4432 | lock(GroupsInView) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1a40ed9..722905f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1573,6 +1573,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1573 | m_boundsRadius = null; | 1573 | m_boundsRadius = null; |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | private Vector3 m_boundsCenter; | ||
1577 | public Vector3 getBoundsCenter() | ||
1578 | { | ||
1579 | // this needs to be called after GetBoundsRadius() so its updated | ||
1580 | return m_boundsCenter; | ||
1581 | } | ||
1576 | public float GetBoundsRadius() | 1582 | public float GetBoundsRadius() |
1577 | { | 1583 | { |
1578 | // this may need more threading work | 1584 | // this may need more threading work |
@@ -1582,6 +1588,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1582 | SceneObjectPart p; | 1588 | SceneObjectPart p; |
1583 | SceneObjectPart[] parts; | 1589 | SceneObjectPart[] parts; |
1584 | float partR; | 1590 | float partR; |
1591 | Vector3 offset = Vector3.Zero; | ||
1585 | lock (m_parts) | 1592 | lock (m_parts) |
1586 | { | 1593 | { |
1587 | parts = m_parts.GetArray(); | 1594 | parts = m_parts.GetArray(); |
@@ -1593,10 +1600,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1593 | p = parts[i]; | 1600 | p = parts[i]; |
1594 | partR = 0.5f * p.Scale.Length(); | 1601 | partR = 0.5f * p.Scale.Length(); |
1595 | if(p != RootPart) | 1602 | if(p != RootPart) |
1603 | { | ||
1596 | partR += p.OffsetPosition.Length(); | 1604 | partR += p.OffsetPosition.Length(); |
1605 | offset += p.OffsetPosition; | ||
1606 | } | ||
1597 | if(partR > res) | 1607 | if(partR > res) |
1598 | res = partR; | 1608 | res = partR; |
1599 | } | 1609 | } |
1610 | if(parts.Length > 1) | ||
1611 | { | ||
1612 | offset /= parts.Length; // basicly geometric center | ||
1613 | offset = offset * RootPart.RotationOffset; | ||
1614 | } | ||
1615 | m_boundsCenter = offset; | ||
1600 | m_boundsRadius = res; | 1616 | m_boundsRadius = res; |
1601 | return res; | 1617 | return res; |
1602 | } | 1618 | } |
@@ -4646,26 +4662,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4646 | 4662 | ||
4647 | Vector3 gc = Vector3.Zero; | 4663 | Vector3 gc = Vector3.Zero; |
4648 | 4664 | ||
4649 | int nparts = m_parts.Count; | ||
4650 | if (nparts <= 1) | ||
4651 | return gc; | ||
4652 | |||
4653 | SceneObjectPart[] parts = m_parts.GetArray(); | 4665 | SceneObjectPart[] parts = m_parts.GetArray(); |
4654 | nparts = parts.Length; // just in case it changed | 4666 | int nparts = parts.Length; |
4655 | if (nparts <= 1) | 4667 | if (nparts < 2) |
4656 | return gc; | 4668 | return gc; |
4657 | 4669 | ||
4658 | Vector3 pPos; | ||
4659 | |||
4660 | // average all parts positions | 4670 | // average all parts positions |
4661 | for (int i = 0; i < nparts; i++) | 4671 | for (int i = 0; i < nparts; i++) |
4662 | { | 4672 | { |
4663 | if (parts[i] != RootPart) | 4673 | if (parts[i] != RootPart) |
4664 | { | 4674 | gc += parts[i].OffsetPosition; |
4665 | pPos = parts[i].OffsetPosition; | ||
4666 | gc += pPos; | ||
4667 | } | ||
4668 | |||
4669 | } | 4675 | } |
4670 | gc /= nparts; | 4676 | gc /= nparts; |
4671 | 4677 | ||