some more work on costs
parent
b4adf652e7
commit
ae8e089b9c
|
@ -845,9 +845,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
public string GetObjectCost(string request, string path,
|
||||
string param, IOSHttpRequest httpRequest,
|
||||
IOSHttpResponse httpResponse)
|
||||
{
|
||||
// see being triggered but see no efect .. have something wrong ??
|
||||
//
|
||||
{
|
||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||
OSDMap resp = new OSDMap();
|
||||
|
||||
|
@ -856,19 +854,29 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
for (int i = 0; i < object_ids.Count; i++)
|
||||
{
|
||||
UUID uuid = object_ids[i].AsUUID();
|
||||
|
||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
|
||||
|
||||
// only see root parts .. so guess should go by SOG only
|
||||
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;
|
||||
object_data["resource_cost"] = 1.0f;
|
||||
object_data["physics_cost"] = 1.0f;
|
||||
object_data["linked_set_physics_cost"] = 1.0f;
|
||||
grp.GetResourcesCosts(part, out linksetCost, out linksetPhysCost, out partCost, out partPhysCost);
|
||||
|
||||
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++)
|
||||
{
|
||||
UUID uuid = object_ids[i].AsUUID();
|
||||
float Physc;
|
||||
float simulc;
|
||||
float streamc;
|
||||
|
||||
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
|
||||
if (obj != null)
|
||||
SceneObjectGroup grp = m_Scene.GetGroupByPrim(uuid);
|
||||
if (grp != null)
|
||||
{
|
||||
phys += 0.1f; // just to see...
|
||||
stream += 0.2f;
|
||||
simul += 0.5f;
|
||||
grp.GetSelectedCosts(out Physc, out streamc, out simulc);
|
||||
phys += Physc;
|
||||
stream += streamc;
|
||||
simul += simulc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -920,12 +932,12 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
{
|
||||
UUID uuid = object_ids[i].AsUUID();
|
||||
|
||||
SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
|
||||
if (obj != null)
|
||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
|
||||
if (part != null)
|
||||
{
|
||||
phys += 0.1f;
|
||||
stream += 0.2f;
|
||||
simul += 0.5f;
|
||||
phys += part.PhysicsCost;
|
||||
stream += part.StreamingCost;
|
||||
simul += part.SimulationCost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1231,6 +1231,102 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
#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)
|
||||
{
|
||||
SaveScriptedState(writer, false);
|
||||
|
|
|
@ -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
|
||||
public byte DefaultPhysicsShapeType()
|
||||
{
|
||||
|
@ -1428,6 +1436,60 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
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
|
||||
{
|
||||
get { return m_physicsShapeType; }
|
||||
|
|
Loading…
Reference in New Issue