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

0.7.4.1
Justin Clark-Casey (justincc) 2012-04-21 03:23:51 +01:00
parent 77a7de87e1
commit f609594595
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>
private void AddChildPrim(OdePrim prim)
{
//Console.WriteLine("AddChildPrim " + Name);
if (LocalID != prim.LocalID)
{
if (LocalID == prim.LocalID)
return;
if (Body == IntPtr.Zero)
{
Body = d.BodyCreate(_parent_scene.world);
setMass();
}
if (Body != IntPtr.Zero)
{
lock (childrenPrim)
{
if (!childrenPrim.Contains(prim))
{
if (childrenPrim.Contains(prim))
return;
//Console.WriteLine("childrenPrim.Add " + prim);
childrenPrim.Add(prim);
@ -1165,19 +1165,21 @@ Console.WriteLine("ZProcessTaints for " + Name);
{
createAMotor(m_angularlock);
}
d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
if (m_vehicle.Type != Vehicle.TYPE_NONE)
m_vehicle.Enable(Body, _parent_scene);
_parent_scene.ActivatePrim(this);
}
}
}
}
}
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)
lock (childrenPrim)
{