aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
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 0d1adcb..90ad098 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1229,6 +1229,102 @@ namespace OpenSim.Region.Framework.Scenes
1229 1229
1230 #endregion 1230 #endregion
1231 1231
1232 public void GetResourcesCosts(SceneObjectPart apart,
1233 out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost)
1234 {
1235 // this information may need to be cached
1236
1237 float cost;
1238 float tmpcost;
1239
1240 bool ComplexCost = false;
1241
1242 SceneObjectPart p;
1243 SceneObjectPart[] parts;
1244
1245 lock (m_parts)
1246 {
1247 parts = m_parts.GetArray();
1248 }
1249
1250 int nparts = parts.Length;
1251
1252
1253 for (int i = 0; i < nparts; i++)
1254 {
1255 p = parts[i];
1256
1257 if (p.UsesComplexCost)
1258 {
1259 ComplexCost = true;
1260 break;
1261 }
1262 }
1263
1264 if (ComplexCost)
1265 {
1266 linksetResCost = 0;
1267 linksetPhysCost = 0;
1268 partCost = 0;
1269 partPhysCost = 0;
1270
1271 for (int i = 0; i < nparts; i++)
1272 {
1273 p = parts[i];
1274
1275 cost = p.StreamingCost;
1276 tmpcost = p.SimulationCost;
1277 if (tmpcost > cost)
1278 cost = tmpcost;
1279 tmpcost = p.PhysicsCost;
1280 if (tmpcost > cost)
1281 cost = tmpcost;
1282
1283 linksetPhysCost += tmpcost;
1284 linksetResCost += cost;
1285
1286 if (p == apart)
1287 {
1288 partCost = cost;
1289 partPhysCost = tmpcost;
1290 }
1291 }
1292 }
1293 else
1294 {
1295 partPhysCost = 1.0f;
1296 partCost = 1.0f;
1297 linksetResCost = (float)nparts;
1298 linksetPhysCost = linksetResCost;
1299 }
1300 }
1301
1302 public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost)
1303 {
1304 SceneObjectPart p;
1305 SceneObjectPart[] parts;
1306
1307 lock (m_parts)
1308 {
1309 parts = m_parts.GetArray();
1310 }
1311
1312 int nparts = parts.Length;
1313
1314 PhysCost = 0;
1315 StreamCost = 0;
1316 SimulCost = 0;
1317
1318 for (int i = 0; i < nparts; i++)
1319 {
1320 p = parts[i];
1321
1322 StreamCost += p.StreamingCost;
1323 SimulCost += p.SimulationCost;
1324 PhysCost += p.PhysicsCost;
1325 }
1326 }
1327
1232 public void SaveScriptedState(XmlTextWriter writer) 1328 public void SaveScriptedState(XmlTextWriter writer)
1233 { 1329 {
1234 SaveScriptedState(writer, false); 1330 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; }