diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 8cd0160686..c6db7af8bc 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -134,6 +134,7 @@ namespace OpenSim.Region.Framework.Scenes private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) { + if (entity == null) return double.NaN; ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { @@ -144,7 +145,17 @@ namespace OpenSim.Region.Framework.Scenes // Use group position for child prims Vector3 entityPos = entity.AbsolutePosition; if (entity is SceneObjectPart) - entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; + { + SceneObjectGroup group = m_scene.GetGroupByPrim(entity.LocalId); + if (group == null) + { + entityPos = entity.AbsolutePosition; + } + else + { + entityPos = group.AbsolutePosition; + } + } else entityPos = entity.AbsolutePosition;