bug fix + make costs visible for testing

avinationmerge
UbitUmarov 2012-10-07 08:53:55 +01:00
parent a0b4e68060
commit 48d8fbc9ae
4 changed files with 86 additions and 42 deletions

View File

@ -1583,7 +1583,9 @@ namespace OpenSim.Region.Framework.Scenes
float cost = 0.1f; float cost = 0.1f;
if (PhysActor != null) if (PhysActor != null)
// cost += PhysActor.Cost; cost = PhysActor.PhysicsCost;
else
cost = 0.1f;
if ((Flags & PrimFlags.Physics) != 0) if ((Flags & PrimFlags.Physics) != 0)
cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3
@ -1596,9 +1598,12 @@ namespace OpenSim.Region.Framework.Scenes
{ {
get get
{ {
float cost;
if (PhysActor != null)
return 0.1f; cost = PhysActor.StreamCost;
else
cost = 1.0f;
return 1.0f;
} }
} }

View File

@ -315,6 +315,23 @@ namespace OpenSim.Region.Physics.Manager
} }
} }
public virtual float PhysicsCost
{
get
{
return 0.1f;
}
}
public virtual float StreamCost
{
get
{
return 1.0f;
}
}
/// <summary> /// <summary>
/// Velocity of this actor. /// Velocity of this actor.
/// </summary> /// </summary>

View File

@ -40,8 +40,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public float volume; public float volume;
public float physCost;
public float streamCost;
public byte shapetype; public byte shapetype;
public bool hasOBB; public bool hasOBB;
public bool hasMeshVolume; public bool hasMeshVolume;
@ -121,8 +119,14 @@ namespace OpenSim.Region.Physics.OdePlugin
public void Stop() public void Stop()
{ {
m_running = false; try
{
m_thread.Abort(); m_thread.Abort();
createqueue.Clear();
}
catch
{
}
} }
public void ChangeActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs, public void ChangeActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs,
@ -172,11 +176,16 @@ namespace OpenSim.Region.Physics.OdePlugin
if (repData.assetState != AssetState.needAsset) if (repData.assetState != AssetState.needAsset)
return; return;
if (repData.assetID == null || repData.assetID == UUID.Zero)
return;
repData.mesh = null; repData.mesh = null;
if (repData.assetID == null || repData.assetID == UUID.Zero)
{
repData.assetState = AssetState.noNeedAsset;
repData.comand = meshWorkerCmnds.changefull;
createqueue.Enqueue(repData);
return;
}
repData.assetState = AssetState.loadingAsset; repData.assetState = AssetState.loadingAsset;
repData.comand = meshWorkerCmnds.getmesh; repData.comand = meshWorkerCmnds.getmesh;
@ -211,9 +220,6 @@ namespace OpenSim.Region.Physics.OdePlugin
repData.OBBOffset = mesh.GetCentroid(); repData.OBBOffset = mesh.GetCentroid();
repData.OBB = mesh.GetOBB(); repData.OBB = mesh.GetOBB();
repData.hasOBB = true; repData.hasOBB = true;
repData.physCost = 0.0013f * (float)indexCount;
// todo
repData.streamCost = 1.0f;
mesh.releaseSourceMeshData(); mesh.releaseSourceMeshData();
} }
} }
@ -432,6 +438,9 @@ namespace OpenSim.Region.Physics.OdePlugin
else else
repData.assetState = AssetState.AssetFailed; repData.assetState = AssetState.AssetFailed;
} }
else
repData.assetState = AssetState.needAsset;
return false; return false;
} }
@ -828,14 +837,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (repData.hasOBB) if (repData.hasOBB)
{ {
Vector3 OBB = repData.OBB; Vector3 OBB = repData.OBB;
float pc = repData.physCost;
float psf = OBB.X * (OBB.Y + OBB.Z) + OBB.Y * OBB.Z;
psf *= 1.33f * .2f;
pc *= psf;
if (pc < 0.1f)
pc = 0.1f;
repData.physCost = pc;
} }
else else
{ {
@ -846,9 +847,6 @@ namespace OpenSim.Region.Physics.OdePlugin
repData.OBB = OBB; repData.OBB = OBB;
repData.OBBOffset = Vector3.Zero; repData.OBBOffset = Vector3.Zero;
repData.physCost = 0.1f;
repData.streamCost = 1.0f;
} }
CalculateBasicPrimVolume(repData); CalculateBasicPrimVolume(repData);

View File

@ -279,6 +279,22 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override float PhysicsCost
{
get
{
return m_physCost;
}
}
public override float StreamCost
{
get
{
return m_streamCost;
}
}
public override int PhysicsActorType public override int PhysicsActorType
{ {
get { return (int)ActorTypes.Prim; } get { return (int)ActorTypes.Prim; }
@ -1373,6 +1389,11 @@ namespace OpenSim.Region.Physics.OdePlugin
m_mesh = null; m_mesh = null;
return false; return false;
} }
m_physCost = 0.0013f * (float)indexCount;
// todo
m_streamCost = 1.0f;
return true; return true;
} }
@ -2058,7 +2079,23 @@ namespace OpenSim.Region.Physics.OdePlugin
m_OBBOffset.Y, m_OBBOffset.Y,
m_OBBOffset.Z); m_OBBOffset.Z);
primOOBradiusSQ = m_OBBOffset.LengthSquared(); primOOBradiusSQ = m_OBB.LengthSquared();
if (_triMeshData != IntPtr.Zero)
{
float pc = m_physCost;
float psf = primOOBradiusSQ;
psf *= 1.33f * .2f;
pc *= psf;
if (pc < 0.1f)
pc = 0.1f;
m_physCost = pc;
}
else
m_physCost = 0.1f;
m_streamCost = 1.0f;
} }
#endregion #endregion
@ -2717,10 +2754,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_OBBOffset = repData.OBBOffset; m_OBBOffset = repData.OBBOffset;
m_OBB = repData.OBB; m_OBB = repData.OBB;
// m_NoColide = repData.NoColide;
m_physCost = repData.physCost;
m_streamCost = repData.streamCost;
primVolume = repData.volume; primVolume = repData.volume;
CreateGeom(); CreateGeom();
@ -2793,9 +2826,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_OBBOffset = repData.OBBOffset; m_OBBOffset = repData.OBBOffset;
m_OBB = repData.OBB; m_OBB = repData.OBB;
m_physCost = repData.physCost;
m_streamCost = repData.streamCost;
primVolume = repData.volume; primVolume = repData.volume;
CreateGeom(); CreateGeom();
@ -2806,14 +2836,8 @@ namespace OpenSim.Region.Physics.OdePlugin
UpdatePrimBodyData(); UpdatePrimBodyData();
try
{
_parent_scene.actor_name_map[prim_geom] = this; _parent_scene.actor_name_map[prim_geom] = this;
}
catch
{
}
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
d.Quaternion myrot = new d.Quaternion(); d.Quaternion myrot = new d.Quaternion();