some more work on costs

avinationmerge
UbitUmarov 2012-03-16 15:33:49 +00:00
parent b4adf652e7
commit ae8e089b9c
3 changed files with 192 additions and 22 deletions

View File

@ -846,8 +846,6 @@ namespace OpenSim.Region.ClientStack.Linden
string param, IOSHttpRequest httpRequest, string param, IOSHttpRequest httpRequest,
IOSHttpResponse httpResponse) IOSHttpResponse httpResponse)
{ {
// see being triggered but see no efect .. have something wrong ??
//
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
OSDMap resp = new OSDMap(); OSDMap resp = new OSDMap();
@ -857,18 +855,28 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
UUID uuid = object_ids[i].AsUUID(); UUID uuid = object_ids[i].AsUUID();
// only see root parts .. so guess should go by SOG only SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
if (obj != null) if (part != null)
{ {
OSDMap object_data = new OSDMap(); SceneObjectGroup grp = part.ParentGroup;
if (grp != null)
{
float linksetCost;
float linksetPhysCost;
float partCost;
float partPhysCost;
object_data["linked_set_resource_cost"] = 1.0f; grp.GetResourcesCosts(part, out linksetCost, out linksetPhysCost, out partCost, out partPhysCost);
object_data["resource_cost"] = 1.0f;
object_data["physics_cost"] = 1.0f;
object_data["linked_set_physics_cost"] = 1.0f;
resp[uuid.ToString()] = object_data; OSDMap object_data = new OSDMap();
object_data["linked_set_resource_cost"] = linksetCost;
object_data["resource_cost"] = partCost;
object_data["physics_cost"] = partPhysCost;
object_data["linked_set_physics_cost"] = linksetPhysCost;
resp[uuid.ToString()] = object_data;
}
} }
} }
@ -899,13 +907,17 @@ namespace OpenSim.Region.ClientStack.Linden
for (int i = 0; i < object_ids.Count; i++) for (int i = 0; i < object_ids.Count; i++)
{ {
UUID uuid = object_ids[i].AsUUID(); UUID uuid = object_ids[i].AsUUID();
float Physc;
float simulc;
float streamc;
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); SceneObjectGroup grp = m_Scene.GetGroupByPrim(uuid);
if (obj != null) if (grp != null)
{ {
phys += 0.1f; // just to see... grp.GetSelectedCosts(out Physc, out streamc, out simulc);
stream += 0.2f; phys += Physc;
simul += 0.5f; stream += streamc;
simul += simulc;
} }
} }
} }
@ -920,12 +932,12 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
UUID uuid = object_ids[i].AsUUID(); UUID uuid = object_ids[i].AsUUID();
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
if (obj != null) if (part != null)
{ {
phys += 0.1f; phys += part.PhysicsCost;
stream += 0.2f; stream += part.StreamingCost;
simul += 0.5f; simul += part.SimulationCost;
} }
} }
} }

View File

@ -1231,6 +1231,102 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
public void GetResourcesCosts(SceneObjectPart apart,
out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost)
{
// this information may need to be cached
float cost;
float tmpcost;
bool ComplexCost = false;
SceneObjectPart p;
SceneObjectPart[] parts;
lock (m_parts)
{
parts = m_parts.GetArray();
}
int nparts = parts.Length;
for (int i = 0; i < nparts; i++)
{
p = parts[i];
if (p.UsesComplexCost)
{
ComplexCost = true;
break;
}
}
if (ComplexCost)
{
linksetResCost = 0;
linksetPhysCost = 0;
partCost = 0;
partPhysCost = 0;
for (int i = 0; i < nparts; i++)
{
p = parts[i];
cost = p.StreamingCost;
tmpcost = p.SimulationCost;
if (tmpcost > cost)
cost = tmpcost;
tmpcost = p.PhysicsCost;
if (tmpcost > cost)
cost = tmpcost;
linksetPhysCost += tmpcost;
linksetResCost += cost;
if (p == apart)
{
partCost = cost;
partPhysCost = tmpcost;
}
}
}
else
{
partPhysCost = 1.0f;
partCost = 1.0f;
linksetResCost = (float)nparts;
linksetPhysCost = linksetResCost;
}
}
public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost)
{
SceneObjectPart p;
SceneObjectPart[] parts;
lock (m_parts)
{
parts = m_parts.GetArray();
}
int nparts = parts.Length;
PhysCost = 0;
StreamCost = 0;
SimulCost = 0;
for (int i = 0; i < nparts; i++)
{
p = parts[i];
StreamCost += p.StreamingCost;
SimulCost += p.SimulationCost;
PhysCost += p.PhysicsCost;
}
}
public void SaveScriptedState(XmlTextWriter writer) public void SaveScriptedState(XmlTextWriter writer)
{ {
SaveScriptedState(writer, false); SaveScriptedState(writer, false);

View File

@ -1415,6 +1415,14 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// not a propriety to move to methods place later
private bool HasMesh()
{
if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh))
return true;
return false;
}
// not a propriety to move to methods place later // not a propriety to move to methods place later
public byte DefaultPhysicsShapeType() public byte DefaultPhysicsShapeType()
{ {
@ -1428,6 +1436,60 @@ namespace OpenSim.Region.Framework.Scenes
return type; return type;
} }
[XmlIgnore]
public bool UsesComplexCost
{
get
{
byte pst = PhysicsShapeType;
if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh())
return true;
return false;
}
}
[XmlIgnore]
public float PhysicsCost
{
get
{
if(PhysicsShapeType == (byte)PhysShapeType.none)
return 0;
float cost = 0.1f;
if (PhysActor != null)
// cost += PhysActor.Cost;
if ((Flags & PrimFlags.Physics) != 0)
cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3
return cost;
}
}
[XmlIgnore]
public float StreamingCost
{
get
{
return 0.1f;
}
}
[XmlIgnore]
public float SimulationCost
{
get
{
// ignoring scripts. Don't like considering them for this
if((Flags & PrimFlags.Physics) != 0)
return 1.0f;
return 0.5f;
}
}
public byte PhysicsShapeType public byte PhysicsShapeType
{ {
get { return m_physicsShapeType; } get { return m_physicsShapeType; }