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.Material = (byte)material;
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
responsedata["int_response_code"] = 200; //501; //410; //404;

View File

@ -470,12 +470,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
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);
item = m_scene.InventoryService.GetItem(item);
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)
{
// 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.
gobj.RootPart.SetParentLocalId(0);

View File

@ -118,59 +118,56 @@ namespace OpenSim.Region.DataSnapshot.Providers
{
SceneObjectPart m_rootPart = obj.RootPart;
if (m_rootPart != null)
ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y);
XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", "");
node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
node.InnerText = obj.UUID.ToString();
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "title", "");
node.InnerText = m_rootPart.Name;
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
node.InnerText = m_rootPart.Description;
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", "");
node.InnerText = String.Format("{0:x}", (uint)m_rootPart.Flags);
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "regionuuid", "");
node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString();
xmlobject.AppendChild(node);
if (land != null && land.LandData != null)
{
ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y);
XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", "");
node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
node.InnerText = obj.UUID.ToString();
node = nodeFactory.CreateNode(XmlNodeType.Element, "parceluuid", "");
node.InnerText = land.LandData.GlobalID.ToString();
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "title", "");
node.InnerText = m_rootPart.Name;
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
node.InnerText = m_rootPart.Description;
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", "");
node.InnerText = String.Format("{0:x}", (uint)m_rootPart.Flags);
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "regionuuid", "");
node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString();
xmlobject.AppendChild(node);
if (land != null && land.LandData != null)
{
node = nodeFactory.CreateNode(XmlNodeType.Element, "parceluuid", "");
node.InnerText = land.LandData.GlobalID.ToString();
xmlobject.AppendChild(node);
}
else
{
// Something is wrong with this object. Let's not list it.
m_log.WarnFormat("[DATASNAPSHOT]: Bad data for object {0} ({1}) in region {2}", obj.Name, obj.UUID, m_scene.RegionInfo.RegionName);
continue;
}
node = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
Vector3 loc = obj.AbsolutePosition;
node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString();
xmlobject.AppendChild(node);
string bestImage = GuessImage(obj);
if (bestImage != string.Empty)
{
node = nodeFactory.CreateNode(XmlNodeType.Element, "image", "");
node.InnerText = bestImage;
xmlobject.AppendChild(node);
}
parent.AppendChild(xmlobject);
}
else
{
// Something is wrong with this object. Let's not list it.
m_log.WarnFormat("[DATASNAPSHOT]: Bad data for object {0} ({1}) in region {2}", obj.Name, obj.UUID, m_scene.RegionInfo.RegionName);
continue;
}
node = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
Vector3 loc = obj.AbsolutePosition;
node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString();
xmlobject.AppendChild(node);
string bestImage = GuessImage(obj);
if (bestImage != string.Empty)
{
node = nodeFactory.CreateNode(XmlNodeType.Element, "image", "");
node.InnerText = bestImage;
xmlobject.AppendChild(node);
}
parent.AppendChild(xmlobject);
}
#pragma warning disable 0612
}

View File

@ -191,10 +191,6 @@ namespace OpenSim.Region.Framework.Scenes
if (part == null)
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
// 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

View File

@ -1743,14 +1743,6 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectGroup group in PrimsFromDB)
{
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);
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.Flags &= ~PrimFlags.Scripted;
@ -4215,7 +4207,7 @@ namespace OpenSim.Region.Framework.Scenes
// their scripts will actually run.
// -- Leaf, Tue Aug 12 14:17:05 EDT 2008
SceneObjectPart parent = part.ParentGroup.RootPart;
if (parent != null && part.ParentGroup.IsAttachment)
if (part.ParentGroup.IsAttachment)
return ScriptDanger(parent, parent.GetWorldPosition());
else
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)
{
delete = true;
} else {
}
else
{
ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
if (parcel == null || parcel.LandData.Name == "NO LAND")

View File

@ -362,7 +362,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </returns>
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;
if (Entities.ContainsKey(sceneObject.UUID))

View File

@ -254,14 +254,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public override string Name
{
get
{
if (RootPart == null)
return String.Empty;
else
return RootPart.Name;
}
get { return RootPart.Name; }
set { RootPart.Name = value; }
}
@ -1054,7 +1047,7 @@ namespace OpenSim.Region.Framework.Scenes
{
part.SetParent(this);
part.LinkNum = m_parts.Add(part.UUID, part);
if (part.LinkNum == 2 && RootPart != null)
if (part.LinkNum == 2)
RootPart.LinkNum = 1;
}
@ -1537,137 +1530,93 @@ namespace OpenSim.Region.Framework.Scenes
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)
ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
avatar.PushForce(impulse);
}
avatar.PushForce(impulse);
}
else
}
else
{
if (RootPart.PhysActor != null)
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.AddForce(impulse, true);
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
}
RootPart.PhysActor.AddForce(impulse, true);
m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
}
}
public void applyAngularImpulse(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 (RootPart.PhysActor != null)
{
if (rootpart.PhysActor != null)
if (!IsAttachment)
{
if (!IsAttachment)
{
rootpart.PhysActor.AddAngularForce(impulse, true);
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
}
RootPart.PhysActor.AddAngularForce(impulse, true);
m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
}
}
public void setAngularImpulse(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 (RootPart.PhysActor != null)
{
if (rootpart.PhysActor != null)
if (!IsAttachment)
{
if (!IsAttachment)
{
rootpart.PhysActor.Torque = impulse;
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
}
RootPart.PhysActor.Torque = impulse;
m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
}
}
public Vector3 GetTorque()
{
// 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 (RootPart.PhysActor != null)
{
if (rootpart.PhysActor != null)
if (!IsAttachment)
{
if (!IsAttachment)
{
Vector3 torque = rootpart.PhysActor.Torque;
return torque;
}
Vector3 torque = RootPart.PhysActor.Torque;
return torque;
}
}
return Vector3.Zero;
}
public void moveToTarget(Vector3 target, float tau)
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
if (IsAttachment)
{
if (IsAttachment)
ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
avatar.MoveToTarget(target, false);
}
avatar.MoveToTarget(target, false);
}
else
}
else
{
if (RootPart.PhysActor != null)
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.PIDTarget = target;
rootpart.PhysActor.PIDTau = tau;
rootpart.PhysActor.PIDActive = true;
}
RootPart.PhysActor.PIDTarget = target;
RootPart.PhysActor.PIDTau = tau;
RootPart.PhysActor.PIDActive = true;
}
}
}
public void stopMoveToTarget()
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.PIDActive = false;
}
}
if (RootPart.PhysActor != null)
RootPart.PhysActor.PIDActive = false;
}
public void stopLookAt()
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.APIDActive = false;
}
}
if (RootPart.PhysActor != null)
RootPart.PhysActor.APIDActive = false;
}
/// <summary>
@ -1678,22 +1627,18 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="tau">Number of seconds over which to reach target</param>
public void SetHoverHeight(float height, PIDHoverType hoverType, float tau)
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
if (RootPart.PhysActor != null)
{
if (rootpart.PhysActor != null)
if (height != 0f)
{
if (height != 0f)
{
rootpart.PhysActor.PIDHoverHeight = height;
rootpart.PhysActor.PIDHoverType = hoverType;
rootpart.PhysActor.PIDTau = tau;
rootpart.PhysActor.PIDHoverActive = true;
}
else
{
rootpart.PhysActor.PIDHoverActive = false;
}
RootPart.PhysActor.PIDHoverHeight = height;
RootPart.PhysActor.PIDHoverType = hoverType;
RootPart.PhysActor.PIDTau = tau;
RootPart.PhysActor.PIDHoverActive = true;
}
else
{
RootPart.PhysActor.PIDHoverActive = false;
}
}
}
@ -3056,28 +3001,23 @@ namespace OpenSim.Region.Framework.Scenes
int yaxis = 4;
int zaxis = 8;
if (m_rootPart != null)
{
setX = ((axis & xaxis) != 0) ? true : false;
setY = ((axis & yaxis) != 0) ? true : false;
setZ = ((axis & zaxis) != 0) ? true : false;
setX = ((axis & xaxis) != 0) ? true : false;
setY = ((axis & yaxis) != 0) ? true : false;
setZ = ((axis & zaxis) != 0) ? true : false;
float setval = (rotate10 > 0) ? 1f : 0f;
float setval = (rotate10 > 0) ? 1f : 0f;
if (setX)
m_rootPart.RotationAxis.X = setval;
if (setY)
m_rootPart.RotationAxis.Y = setval;
if (setZ)
m_rootPart.RotationAxis.Z = setval;
if (setX)
RootPart.RotationAxis.X = setval;
if (setY)
RootPart.RotationAxis.Y = setval;
if (setZ)
RootPart.RotationAxis.Z = setval;
if (setX || setY || setZ)
{
m_rootPart.SetPhysicsAxisRotation();
}
}
if (setX || setY || setZ)
RootPart.SetPhysicsAxisRotation();
}
public int registerRotTargetWaypoint(Quaternion target, float tolerance)
{
scriptRotTarget waypoint = new scriptRotTarget();
@ -3205,7 +3145,13 @@ namespace OpenSim.Region.Framework.Scenes
foreach (uint idx in m_rotTargets.Keys)
{
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 > Math.PI) angle = (Math.PI * 2 - angle);
if (angle <= target.tolerance)

View File

@ -381,7 +381,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
{
SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
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 (new_group == null)
continue;
if (new_group.RootPart == null)
continue;
// objects rezzed with this method are die_at_edge by default.
new_group.RootPart.SetDieAtEdge(true);
@ -6983,10 +6981,7 @@ 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.
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;

View File

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

View File

@ -99,11 +99,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount);
part = part.ParentGroup.RootPart;
if (part != null)
{
money(part.LocalId, agentID, amount);
}
money(part.LocalId, agentID, amount);
}
/// <summary>