aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorUbitUmarov2012-03-16 15:33:49 +0000
committerUbitUmarov2012-03-16 15:33:49 +0000
commitae8e089b9c73a6a675038759e3e3f9491819eb72 (patch)
tree73845e4fc4254b1dbddd090634ab01a50c3c93f9 /OpenSim/Region/Framework
parentMerge branch 'ubitwork' (diff)
downloadopensim-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
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs96
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs62
2 files changed, 158 insertions, 0 deletions
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; }