Eliminate pointless checks of SOG.RootPart != null

It's never possible for SOG to have no RootPart, except in the first few picosends of the big bang when it's pulled from region persistence or deserialized
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-09-01 02:09:41 +01:00
parent 10d883dc88
commit 7eca929686
12 changed files with 126 additions and 212 deletions

View File

@ -322,8 +322,6 @@ namespace OpenSim.Region.ClientStack.Linden
rootpart.NextOwnerMask = next_owner_mask; rootpart.NextOwnerMask = next_owner_mask;
rootpart.Material = (byte)material; rootpart.Material = (byte)material;
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["int_response_code"] = 200; //501; //410; //404;

View File

@ -470,12 +470,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return; return;
} }
if (null == att.RootPart)
{
m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!");
return;
}
InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
item = m_scene.InventoryService.GetItem(item); item = m_scene.InventoryService.GetItem(item);
bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);

View File

@ -1772,7 +1772,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
foreach (SceneObjectGroup gobj in m_attachments) foreach (SceneObjectGroup gobj in m_attachments)
{ {
// If the prim group is null then something must have happened to it! // If the prim group is null then something must have happened to it!
if (gobj != null && gobj.RootPart != null) if (gobj != null)
{ {
// Set the parent localID to 0 so it transfers over properly. // Set the parent localID to 0 so it transfers over properly.
gobj.RootPart.SetParentLocalId(0); gobj.RootPart.SetParentLocalId(0);

View File

@ -118,8 +118,6 @@ namespace OpenSim.Region.DataSnapshot.Providers
{ {
SceneObjectPart m_rootPart = obj.RootPart; SceneObjectPart m_rootPart = obj.RootPart;
if (m_rootPart != null)
{
ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y); ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y);
XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", ""); XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", "");
@ -171,7 +169,6 @@ namespace OpenSim.Region.DataSnapshot.Providers
parent.AppendChild(xmlobject); parent.AppendChild(xmlobject);
} }
}
#pragma warning disable 0612 #pragma warning disable 0612
} }
} }

View File

@ -191,10 +191,6 @@ namespace OpenSim.Region.Framework.Scenes
if (part == null) if (part == null)
return; return;
// The prim is in the process of being deleted.
if (null == part.ParentGroup.RootPart)
return;
// A deselect packet contains all the local prims being deselected. However, since selection is still // A deselect packet contains all the local prims being deselected. However, since selection is still
// group based we only want the root prim to trigger a full update - otherwise on objects with many prims // group based we only want the root prim to trigger a full update - otherwise on objects with many prims
// we end up sending many duplicate ObjectUpdates // we end up sending many duplicate ObjectUpdates

View File

@ -1743,14 +1743,6 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectGroup group in PrimsFromDB) foreach (SceneObjectGroup group in PrimsFromDB)
{ {
EventManager.TriggerOnSceneObjectLoaded(group); EventManager.TriggerOnSceneObjectLoaded(group);
if (group.RootPart == null)
{
m_log.ErrorFormat(
"[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children",
group.Parts == null ? 0 : group.PrimCount);
}
AddRestoredSceneObject(group, true, true); AddRestoredSceneObject(group, true, true);
SceneObjectPart rootPart = group.GetChildPart(group.UUID); SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.Flags &= ~PrimFlags.Scripted; rootPart.Flags &= ~PrimFlags.Scripted;
@ -4215,7 +4207,7 @@ namespace OpenSim.Region.Framework.Scenes
// their scripts will actually run. // their scripts will actually run.
// -- Leaf, Tue Aug 12 14:17:05 EDT 2008 // -- Leaf, Tue Aug 12 14:17:05 EDT 2008
SceneObjectPart parent = part.ParentGroup.RootPart; SceneObjectPart parent = part.ParentGroup.RootPart;
if (parent != null && part.ParentGroup.IsAttachment) if (part.ParentGroup.IsAttachment)
return ScriptDanger(parent, parent.GetWorldPosition()); return ScriptDanger(parent, parent.GetWorldPosition());
else else
return ScriptDanger(part, part.GetWorldPosition()); return ScriptDanger(part, part.GetWorldPosition());
@ -5015,7 +5007,9 @@ namespace OpenSim.Region.Framework.Scenes
if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
{ {
delete = true; delete = true;
} else { }
else
{
ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
if (parcel == null || parcel.LandData.Name == "NO LAND") if (parcel == null || parcel.LandData.Name == "NO LAND")

View File

@ -362,7 +362,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </returns> /// </returns>
protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
{ {
if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) if (sceneObject == null || sceneObject.RootPart.UUID == UUID.Zero)
return false; return false;
if (Entities.ContainsKey(sceneObject.UUID)) if (Entities.ContainsKey(sceneObject.UUID))

View File

@ -254,14 +254,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public override string Name public override string Name
{ {
get get { return RootPart.Name; }
{
if (RootPart == null)
return String.Empty;
else
return RootPart.Name;
}
set { RootPart.Name = value; } set { RootPart.Name = value; }
} }
@ -1054,7 +1047,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
part.SetParent(this); part.SetParent(this);
part.LinkNum = m_parts.Add(part.UUID, part); part.LinkNum = m_parts.Add(part.UUID, part);
if (part.LinkNum == 2 && RootPart != null) if (part.LinkNum == 2)
RootPart.LinkNum = 1; RootPart.LinkNum = 1;
} }
@ -1536,12 +1529,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
public void applyImpulse(Vector3 impulse) public void applyImpulse(Vector3 impulse)
{
// We check if rootpart is null here because scripts don't delete if you delete the host.
// This means that unfortunately, we can pass a null physics actor to Simulate!
// Make sure we don't do that!
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{ {
if (IsAttachment) if (IsAttachment)
{ {
@ -1553,77 +1540,53 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
if (rootpart.PhysActor != null) if (RootPart.PhysActor != null)
{ {
rootpart.PhysActor.AddForce(impulse, true); RootPart.PhysActor.AddForce(impulse, true);
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
} }
} }
} }
public void applyAngularImpulse(Vector3 impulse) public void applyAngularImpulse(Vector3 impulse)
{ {
// We check if rootpart is null here because scripts don't delete if you delete the host. if (RootPart.PhysActor != null)
// This means that unfortunately, we can pass a null physics actor to Simulate!
// Make sure we don't do that!
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{ {
if (!IsAttachment) if (!IsAttachment)
{ {
rootpart.PhysActor.AddAngularForce(impulse, true); RootPart.PhysActor.AddAngularForce(impulse, true);
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
} }
} }
} }
public void setAngularImpulse(Vector3 impulse) public void setAngularImpulse(Vector3 impulse)
{ {
// We check if rootpart is null here because scripts don't delete if you delete the host. if (RootPart.PhysActor != null)
// This means that unfortunately, we can pass a null physics actor to Simulate!
// Make sure we don't do that!
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{ {
if (!IsAttachment) if (!IsAttachment)
{ {
rootpart.PhysActor.Torque = impulse; RootPart.PhysActor.Torque = impulse;
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
} }
} }
} }
public Vector3 GetTorque() public Vector3 GetTorque()
{ {
// We check if rootpart is null here because scripts don't delete if you delete the host. if (RootPart.PhysActor != null)
// This means that unfortunately, we can pass a null physics actor to Simulate!
// Make sure we don't do that!
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{ {
if (!IsAttachment) if (!IsAttachment)
{ {
Vector3 torque = rootpart.PhysActor.Torque; Vector3 torque = RootPart.PhysActor.Torque;
return torque; return torque;
} }
} }
}
return Vector3.Zero; return Vector3.Zero;
} }
public void moveToTarget(Vector3 target, float tau) public void moveToTarget(Vector3 target, float tau)
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{ {
if (IsAttachment) if (IsAttachment)
{ {
@ -1635,39 +1598,25 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
if (rootpart.PhysActor != null) if (RootPart.PhysActor != null)
{ {
rootpart.PhysActor.PIDTarget = target; RootPart.PhysActor.PIDTarget = target;
rootpart.PhysActor.PIDTau = tau; RootPart.PhysActor.PIDTau = tau;
rootpart.PhysActor.PIDActive = true; RootPart.PhysActor.PIDActive = true;
}
} }
} }
} }
public void stopMoveToTarget() public void stopMoveToTarget()
{ {
SceneObjectPart rootpart = m_rootPart; if (RootPart.PhysActor != null)
if (rootpart != null) RootPart.PhysActor.PIDActive = false;
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.PIDActive = false;
}
}
} }
public void stopLookAt() public void stopLookAt()
{ {
SceneObjectPart rootpart = m_rootPart; if (RootPart.PhysActor != null)
if (rootpart != null) RootPart.PhysActor.APIDActive = false;
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.APIDActive = false;
}
}
} }
/// <summary> /// <summary>
@ -1678,22 +1627,18 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="tau">Number of seconds over which to reach target</param> /// <param name="tau">Number of seconds over which to reach target</param>
public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) public void SetHoverHeight(float height, PIDHoverType hoverType, float tau)
{ {
SceneObjectPart rootpart = m_rootPart; if (RootPart.PhysActor != null)
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{ {
if (height != 0f) if (height != 0f)
{ {
rootpart.PhysActor.PIDHoverHeight = height; RootPart.PhysActor.PIDHoverHeight = height;
rootpart.PhysActor.PIDHoverType = hoverType; RootPart.PhysActor.PIDHoverType = hoverType;
rootpart.PhysActor.PIDTau = tau; RootPart.PhysActor.PIDTau = tau;
rootpart.PhysActor.PIDHoverActive = true; RootPart.PhysActor.PIDHoverActive = true;
} }
else else
{ {
rootpart.PhysActor.PIDHoverActive = false; RootPart.PhysActor.PIDHoverActive = false;
}
} }
} }
} }
@ -3056,8 +3001,6 @@ namespace OpenSim.Region.Framework.Scenes
int yaxis = 4; int yaxis = 4;
int zaxis = 8; int zaxis = 8;
if (m_rootPart != null)
{
setX = ((axis & xaxis) != 0) ? true : false; setX = ((axis & xaxis) != 0) ? true : false;
setY = ((axis & yaxis) != 0) ? true : false; setY = ((axis & yaxis) != 0) ? true : false;
setZ = ((axis & zaxis) != 0) ? true : false; setZ = ((axis & zaxis) != 0) ? true : false;
@ -3065,19 +3008,16 @@ namespace OpenSim.Region.Framework.Scenes
float setval = (rotate10 > 0) ? 1f : 0f; float setval = (rotate10 > 0) ? 1f : 0f;
if (setX) if (setX)
m_rootPart.RotationAxis.X = setval; RootPart.RotationAxis.X = setval;
if (setY) if (setY)
m_rootPart.RotationAxis.Y = setval; RootPart.RotationAxis.Y = setval;
if (setZ) if (setZ)
m_rootPart.RotationAxis.Z = setval; RootPart.RotationAxis.Z = setval;
if (setX || setY || setZ) if (setX || setY || setZ)
{ RootPart.SetPhysicsAxisRotation();
m_rootPart.SetPhysicsAxisRotation();
} }
}
}
public int registerRotTargetWaypoint(Quaternion target, float tolerance) public int registerRotTargetWaypoint(Quaternion target, float tolerance)
{ {
scriptRotTarget waypoint = new scriptRotTarget(); scriptRotTarget waypoint = new scriptRotTarget();
@ -3205,7 +3145,13 @@ namespace OpenSim.Region.Framework.Scenes
foreach (uint idx in m_rotTargets.Keys) foreach (uint idx in m_rotTargets.Keys)
{ {
scriptRotTarget target = m_rotTargets[idx]; scriptRotTarget target = m_rotTargets[idx];
double angle = Math.Acos(target.targetRot.X * m_rootPart.RotationOffset.X + target.targetRot.Y * m_rootPart.RotationOffset.Y + target.targetRot.Z * m_rootPart.RotationOffset.Z + target.targetRot.W * m_rootPart.RotationOffset.W) * 2; double angle
= Math.Acos(
target.targetRot.X * m_rootPart.RotationOffset.X
+ target.targetRot.Y * m_rootPart.RotationOffset.Y
+ target.targetRot.Z * m_rootPart.RotationOffset.Z
+ target.targetRot.W * m_rootPart.RotationOffset.W)
* 2;
if (angle < 0) angle = -angle; if (angle < 0) angle = -angle;
if (angle > Math.PI) angle = (Math.PI * 2 - angle); if (angle > Math.PI) angle = (Math.PI * 2 - angle);
if (angle <= target.tolerance) if (angle <= target.tolerance)

View File

@ -381,7 +381,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
{ {
SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
m_scene.DeleteSceneObject(selectedTree.ParentGroup, false); m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
m_scene.ForEachClient(delegate(IClientAPI controller) m_scene.ForEachClient(delegate(IClientAPI controller)
{ {

View File

@ -2767,8 +2767,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// If either of these are null, then there was an unknown error. // If either of these are null, then there was an unknown error.
if (new_group == null) if (new_group == null)
continue; continue;
if (new_group.RootPart == null)
continue;
// objects rezzed with this method are die_at_edge by default. // objects rezzed with this method are die_at_edge by default.
new_group.RootPart.SetDieAtEdge(true); new_group.RootPart.SetDieAtEdge(true);
@ -6983,11 +6981,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
// we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
SceneObjectPart rootPart = part.ParentGroup.RootPart; SceneObjectPart rootPart = part.ParentGroup.RootPart;
if (rootPart != null) // better safe than sorry
{
SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q));
} }
}
break; break;

View File

@ -673,7 +673,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (m_host.ParentGroup.RootPart != null)
m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
} }

View File

@ -99,12 +99,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount);
part = part.ParentGroup.RootPart; part = part.ParentGroup.RootPart;
if (part != null)
{
money(part.LocalId, agentID, amount); money(part.LocalId, agentID, amount);
} }
}
/// <summary> /// <summary>
/// Handles piping the proper stuff to The script engine for touching /// Handles piping the proper stuff to The script engine for touching