refactor: Simplify ODEPrim.AddChildPrim() by returning early where appropriate.

0.7.3-extended
Justin Clark-Casey (justincc) 2012-04-21 03:23:51 +01:00
parent d368a10cc7
commit 232f59749e
1 changed files with 113 additions and 111 deletions

View File

@ -1042,20 +1042,20 @@ Console.WriteLine("ZProcessTaints for " + Name);
/// <param name="prim">Child prim</param> /// <param name="prim">Child prim</param>
private void AddChildPrim(OdePrim prim) private void AddChildPrim(OdePrim prim)
{ {
//Console.WriteLine("AddChildPrim " + Name); if (LocalID == prim.LocalID)
if (LocalID != prim.LocalID) return;
{
if (Body == IntPtr.Zero) if (Body == IntPtr.Zero)
{ {
Body = d.BodyCreate(_parent_scene.world); Body = d.BodyCreate(_parent_scene.world);
setMass(); setMass();
} }
if (Body != IntPtr.Zero)
{
lock (childrenPrim) lock (childrenPrim)
{ {
if (!childrenPrim.Contains(prim)) if (childrenPrim.Contains(prim))
{ return;
//Console.WriteLine("childrenPrim.Add " + prim); //Console.WriteLine("childrenPrim.Add " + prim);
childrenPrim.Add(prim); childrenPrim.Add(prim);
@ -1165,19 +1165,21 @@ Console.WriteLine("ZProcessTaints for " + Name);
{ {
createAMotor(m_angularlock); createAMotor(m_angularlock);
} }
d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
if (m_vehicle.Type != Vehicle.TYPE_NONE) if (m_vehicle.Type != Vehicle.TYPE_NONE)
m_vehicle.Enable(Body, _parent_scene); m_vehicle.Enable(Body, _parent_scene);
_parent_scene.ActivatePrim(this); _parent_scene.ActivatePrim(this);
} }
} }
}
}
}
private void ChildSetGeom(OdePrim odePrim) private void ChildSetGeom(OdePrim odePrim)
{ {
// m_log.DebugFormat(
// "[ODE PRIM]: ChildSetGeom {0} {1} for {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID);
//if (IsPhysical && Body != IntPtr.Zero) //if (IsPhysical && Body != IntPtr.Zero)
lock (childrenPrim) lock (childrenPrim)
{ {