diff options
author | UbitUmarov | 2012-03-16 15:33:49 +0000 |
---|---|---|
committer | UbitUmarov | 2012-03-16 15:33:49 +0000 |
commit | ae8e089b9c73a6a675038759e3e3f9491819eb72 (patch) | |
tree | 73845e4fc4254b1dbddd090634ab01a50c3c93f9 | |
parent | Merge branch 'ubitwork' (diff) | |
download | opensim-SC_OLD-ae8e089b9c73a6a675038759e3e3f9491819eb72.zip opensim-SC_OLD-ae8e089b9c73a6a675038759e3e3f9491819eb72.tar.gz opensim-SC_OLD-ae8e089b9c73a6a675038759e3e3f9491819eb72.tar.bz2 opensim-SC_OLD-ae8e089b9c73a6a675038759e3e3f9491819eb72.tar.xz |
some more work on costs
3 files changed, 192 insertions, 22 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 5542680..dfd5c98 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -845,9 +845,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
845 | public string GetObjectCost(string request, string path, | 845 | public string GetObjectCost(string request, string path, |
846 | string param, IOSHttpRequest httpRequest, | 846 | string param, IOSHttpRequest httpRequest, |
847 | IOSHttpResponse httpResponse) | 847 | IOSHttpResponse httpResponse) |
848 | { | 848 | { |
849 | // see being triggered but see no efect .. have something wrong ?? | ||
850 | // | ||
851 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 849 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
852 | OSDMap resp = new OSDMap(); | 850 | OSDMap resp = new OSDMap(); |
853 | 851 | ||
@@ -856,19 +854,29 @@ namespace OpenSim.Region.ClientStack.Linden | |||
856 | for (int i = 0; i < object_ids.Count; i++) | 854 | for (int i = 0; i < object_ids.Count; i++) |
857 | { | 855 | { |
858 | UUID uuid = object_ids[i].AsUUID(); | 856 | UUID uuid = object_ids[i].AsUUID(); |
857 | |||
858 | SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); | ||
859 | 859 | ||
860 | // only see root parts .. so guess should go by SOG only | 860 | if (part != null) |
861 | SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); | ||
862 | if (obj != null) | ||
863 | { | 861 | { |
864 | OSDMap object_data = new OSDMap(); | 862 | SceneObjectGroup grp = part.ParentGroup; |
863 | if (grp != null) | ||
864 | { | ||
865 | float linksetCost; | ||
866 | float linksetPhysCost; | ||
867 | float partCost; | ||
868 | float partPhysCost; | ||
865 | 869 | ||
866 | object_data["linked_set_resource_cost"] = 1.0f; | 870 | grp.GetResourcesCosts(part, out linksetCost, out linksetPhysCost, out partCost, out partPhysCost); |
867 | object_data["resource_cost"] = 1.0f; | ||
868 | object_data["physics_cost"] = 1.0f; | ||
869 | object_data["linked_set_physics_cost"] = 1.0f; | ||
870 | 871 | ||
871 | resp[uuid.ToString()] = object_data; | 872 | OSDMap object_data = new OSDMap(); |
873 | object_data["linked_set_resource_cost"] = linksetCost; | ||
874 | object_data["resource_cost"] = partCost; | ||
875 | object_data["physics_cost"] = partPhysCost; | ||
876 | object_data["linked_set_physics_cost"] = linksetPhysCost; | ||
877 | |||
878 | resp[uuid.ToString()] = object_data; | ||
879 | } | ||
872 | } | 880 | } |
873 | } | 881 | } |
874 | 882 | ||
@@ -899,13 +907,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
899 | for (int i = 0; i < object_ids.Count; i++) | 907 | for (int i = 0; i < object_ids.Count; i++) |
900 | { | 908 | { |
901 | UUID uuid = object_ids[i].AsUUID(); | 909 | UUID uuid = object_ids[i].AsUUID(); |
910 | float Physc; | ||
911 | float simulc; | ||
912 | float streamc; | ||
902 | 913 | ||
903 | SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); | 914 | SceneObjectGroup grp = m_Scene.GetGroupByPrim(uuid); |
904 | if (obj != null) | 915 | if (grp != null) |
905 | { | 916 | { |
906 | phys += 0.1f; // just to see... | 917 | grp.GetSelectedCosts(out Physc, out streamc, out simulc); |
907 | stream += 0.2f; | 918 | phys += Physc; |
908 | simul += 0.5f; | 919 | stream += streamc; |
920 | simul += simulc; | ||
909 | } | 921 | } |
910 | } | 922 | } |
911 | } | 923 | } |
@@ -920,12 +932,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
920 | { | 932 | { |
921 | UUID uuid = object_ids[i].AsUUID(); | 933 | UUID uuid = object_ids[i].AsUUID(); |
922 | 934 | ||
923 | SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); | 935 | SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); |
924 | if (obj != null) | 936 | if (part != null) |
925 | { | 937 | { |
926 | phys += 0.1f; | 938 | phys += part.PhysicsCost; |
927 | stream += 0.2f; | 939 | stream += part.StreamingCost; |
928 | simul += 0.5f; | 940 | simul += part.SimulationCost; |
929 | } | 941 | } |
930 | } | 942 | } |
931 | } | 943 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5507aa0..3e4d552 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1231,6 +1231,102 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | 1231 | ||
1232 | #endregion | 1232 | #endregion |
1233 | 1233 | ||
1234 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1235 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1236 | { | ||
1237 | // this information may need to be cached | ||
1238 | |||
1239 | float cost; | ||
1240 | float tmpcost; | ||
1241 | |||
1242 | bool ComplexCost = false; | ||
1243 | |||
1244 | SceneObjectPart p; | ||
1245 | SceneObjectPart[] parts; | ||
1246 | |||
1247 | lock (m_parts) | ||
1248 | { | ||
1249 | parts = m_parts.GetArray(); | ||
1250 | } | ||
1251 | |||
1252 | int nparts = parts.Length; | ||
1253 | |||
1254 | |||
1255 | for (int i = 0; i < nparts; i++) | ||
1256 | { | ||
1257 | p = parts[i]; | ||
1258 | |||
1259 | if (p.UsesComplexCost) | ||
1260 | { | ||
1261 | ComplexCost = true; | ||
1262 | break; | ||
1263 | } | ||
1264 | } | ||
1265 | |||
1266 | if (ComplexCost) | ||
1267 | { | ||
1268 | linksetResCost = 0; | ||
1269 | linksetPhysCost = 0; | ||
1270 | partCost = 0; | ||
1271 | partPhysCost = 0; | ||
1272 | |||
1273 | for (int i = 0; i < nparts; i++) | ||
1274 | { | ||
1275 | p = parts[i]; | ||
1276 | |||
1277 | cost = p.StreamingCost; | ||
1278 | tmpcost = p.SimulationCost; | ||
1279 | if (tmpcost > cost) | ||
1280 | cost = tmpcost; | ||
1281 | tmpcost = p.PhysicsCost; | ||
1282 | if (tmpcost > cost) | ||
1283 | cost = tmpcost; | ||
1284 | |||
1285 | linksetPhysCost += tmpcost; | ||
1286 | linksetResCost += cost; | ||
1287 | |||
1288 | if (p == apart) | ||
1289 | { | ||
1290 | partCost = cost; | ||
1291 | partPhysCost = tmpcost; | ||
1292 | } | ||
1293 | } | ||
1294 | } | ||
1295 | else | ||
1296 | { | ||
1297 | partPhysCost = 1.0f; | ||
1298 | partCost = 1.0f; | ||
1299 | linksetResCost = (float)nparts; | ||
1300 | linksetPhysCost = linksetResCost; | ||
1301 | } | ||
1302 | } | ||
1303 | |||
1304 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1305 | { | ||
1306 | SceneObjectPart p; | ||
1307 | SceneObjectPart[] parts; | ||
1308 | |||
1309 | lock (m_parts) | ||
1310 | { | ||
1311 | parts = m_parts.GetArray(); | ||
1312 | } | ||
1313 | |||
1314 | int nparts = parts.Length; | ||
1315 | |||
1316 | PhysCost = 0; | ||
1317 | StreamCost = 0; | ||
1318 | SimulCost = 0; | ||
1319 | |||
1320 | for (int i = 0; i < nparts; i++) | ||
1321 | { | ||
1322 | p = parts[i]; | ||
1323 | |||
1324 | StreamCost += p.StreamingCost; | ||
1325 | SimulCost += p.SimulationCost; | ||
1326 | PhysCost += p.PhysicsCost; | ||
1327 | } | ||
1328 | } | ||
1329 | |||
1234 | public void SaveScriptedState(XmlTextWriter writer) | 1330 | public void SaveScriptedState(XmlTextWriter writer) |
1235 | { | 1331 | { |
1236 | SaveScriptedState(writer, false); | 1332 | SaveScriptedState(writer, false); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f188e8d..fbe959a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -1416,6 +1416,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | // not a propriety to move to methods place later | 1418 | // not a propriety to move to methods place later |
1419 | private bool HasMesh() | ||
1420 | { | ||
1421 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1422 | return true; | ||
1423 | return false; | ||
1424 | } | ||
1425 | |||
1426 | // not a propriety to move to methods place later | ||
1419 | public byte DefaultPhysicsShapeType() | 1427 | public byte DefaultPhysicsShapeType() |
1420 | { | 1428 | { |
1421 | byte type; | 1429 | byte type; |
@@ -1428,6 +1436,60 @@ namespace OpenSim.Region.Framework.Scenes | |||
1428 | return type; | 1436 | return type; |
1429 | } | 1437 | } |
1430 | 1438 | ||
1439 | [XmlIgnore] | ||
1440 | public bool UsesComplexCost | ||
1441 | { | ||
1442 | get | ||
1443 | { | ||
1444 | byte pst = PhysicsShapeType; | ||
1445 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1446 | return true; | ||
1447 | return false; | ||
1448 | } | ||
1449 | } | ||
1450 | |||
1451 | [XmlIgnore] | ||
1452 | public float PhysicsCost | ||
1453 | { | ||
1454 | get | ||
1455 | { | ||
1456 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1457 | return 0; | ||
1458 | |||
1459 | float cost = 0.1f; | ||
1460 | if (PhysActor != null) | ||
1461 | // cost += PhysActor.Cost; | ||
1462 | |||
1463 | if ((Flags & PrimFlags.Physics) != 0) | ||
1464 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1465 | return cost; | ||
1466 | } | ||
1467 | } | ||
1468 | |||
1469 | [XmlIgnore] | ||
1470 | public float StreamingCost | ||
1471 | { | ||
1472 | get | ||
1473 | { | ||
1474 | |||
1475 | |||
1476 | return 0.1f; | ||
1477 | } | ||
1478 | } | ||
1479 | |||
1480 | [XmlIgnore] | ||
1481 | public float SimulationCost | ||
1482 | { | ||
1483 | get | ||
1484 | { | ||
1485 | // ignoring scripts. Don't like considering them for this | ||
1486 | if((Flags & PrimFlags.Physics) != 0) | ||
1487 | return 1.0f; | ||
1488 | |||
1489 | return 0.5f; | ||
1490 | } | ||
1491 | } | ||
1492 | |||
1431 | public byte PhysicsShapeType | 1493 | public byte PhysicsShapeType |
1432 | { | 1494 | { |
1433 | get { return m_physicsShapeType; } | 1495 | get { return m_physicsShapeType; } |