aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs1
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs509
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs6
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs8
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs1
-rw-r--r--OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs84
-rw-r--r--OpenSim/Region/UserStatistics/Clients_report.cs27
-rw-r--r--OpenSim/Region/UserStatistics/Default_Report.cs27
-rw-r--r--OpenSim/Region/UserStatistics/IStatsReport.cs1
-rw-r--r--OpenSim/Region/UserStatistics/LogLinesAJAX.cs29
-rw-r--r--OpenSim/Region/UserStatistics/Prototype_distributor.cs31
-rw-r--r--OpenSim/Region/UserStatistics/Sessions_Report.cs5
-rw-r--r--OpenSim/Region/UserStatistics/SimStatsAJAX.cs59
-rw-r--r--OpenSim/Region/UserStatistics/Updater_distributor.cs4
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs25
19 files changed, 670 insertions, 191 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index da59eab..60b7190 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -301,6 +301,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
301 UrlData urlData = m_RequestMap[request]; 301 UrlData urlData = m_RequestMap[request];
302 if (!urlData.requests[request].responseSent) 302 if (!urlData.requests[request].responseSent)
303 { 303 {
304 string responseBody = body;
305 if (urlData.requests[request].responseType.Equals("text/plain"))
306 {
307 string value;
308 if (urlData.requests[request].headers.TryGetValue("user-agent", out value))
309 {
310 if (value != null && value.IndexOf("MSIE") >= 0)
311 {
312 // wrap the html escaped response if the target client is IE
313 // It ignores "text/plain" if the body is html
314 responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>";
315 }
316 }
317 }
318
304 urlData.requests[request].responseCode = status; 319 urlData.requests[request].responseCode = status;
305 urlData.requests[request].responseBody = body; 320 urlData.requests[request].responseBody = body;
306 //urlData.requests[request].ev.Set(); 321 //urlData.requests[request].ev.Set();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0fe9842..f037348 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4226,6 +4226,7 @@ namespace OpenSim.Region.Framework.Scenes
4226 result.distance = distance2; 4226 result.distance = distance2;
4227 result.HitTF = true; 4227 result.HitTF = true;
4228 result.ipoint = q; 4228 result.ipoint = q;
4229 result.face = i;
4229 //m_log.Info("[FACE]:" + i.ToString()); 4230 //m_log.Info("[FACE]:" + i.ToString());
4230 //m_log.Info("[POINT]: " + q.ToString()); 4231 //m_log.Info("[POINT]: " + q.ToString());
4231 //m_log.Info("[DIST]: " + distance2.ToString()); 4232 //m_log.Info("[DIST]: " + distance2.ToString());
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
index 49b1730..f63d83c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
@@ -27,6 +27,7 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.Runtime.InteropServices;
30using System.Text; 31using System.Text;
31 32
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -130,10 +131,12 @@ private sealed class BulletConstraintXNA : BulletConstraint
130 } 131 }
131} 132}
132 internal int m_maxCollisions; 133 internal int m_maxCollisions;
133 internal CollisionDesc[] m_collisionArray; 134 internal CollisionDesc[] UpdatedCollisions;
134 135 internal int LastCollisionDesc = 0;
135 internal int m_maxUpdatesPerFrame; 136 internal int m_maxUpdatesPerFrame;
136 internal EntityProperties[] m_updateArray; 137 internal int LastEntityProperty = 0;
138
139 internal EntityProperties[] UpdatedObjects;
137 140
138 private static int m_collisionsThisFrame; 141 private static int m_collisionsThisFrame;
139 private BSScene PhysicsScene { get; set; } 142 private BSScene PhysicsScene { get; set; }
@@ -900,7 +903,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
900 CollisionShape shape1 = (pShape as BulletShapeXNA).shape; 903 CollisionShape shape1 = (pShape as BulletShapeXNA).shape;
901 904
902 // TODO: Turn this from a reference copy to a Value Copy. 905 // TODO: Turn this from a reference copy to a Value Copy.
903 BulletShapeXNA shape2 = new BulletShapeXNA(shape1, BSPhysicsShapeType.SHAPE_UNKNOWN); 906 BulletShapeXNA shape2 = new BulletShapeXNA(shape1, BSShapeTypeFromBroadPhaseNativeType(shape1.GetShapeType()));
904 907
905 return shape2; 908 return shape2;
906 } 909 }
@@ -922,9 +925,9 @@ private sealed class BulletConstraintXNA : BulletConstraint
922 CollisionShape shape = (pShape as BulletShapeXNA).shape; 925 CollisionShape shape = (pShape as BulletShapeXNA).shape;
923 //UpdateSingleAabb(world, shape); 926 //UpdateSingleAabb(world, shape);
924 // TODO: Feed Update array into null 927 // TODO: Feed Update array into null
925 SimMotionState motionState = new SimMotionState(world, pLocalID, mat, null); 928 SimMotionState motionState = new SimMotionState(this, pLocalID, mat, null);
926 RigidBody body = new RigidBody(0,motionState,shape,IndexedVector3.Zero); 929 RigidBody body = new RigidBody(0,motionState,shape,IndexedVector3.Zero);
927 RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(0, new SimMotionState(world, pLocalID, mat, null),shape,IndexedVector3.Zero) 930 RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(0, motionState, shape, IndexedVector3.Zero)
928 { 931 {
929 m_mass = 0 932 m_mass = 0
930 }; 933 };
@@ -1039,8 +1042,8 @@ private sealed class BulletConstraintXNA : BulletConstraint
1039 ) 1042 )
1040 { 1043 {
1041 1044
1042 m_updateArray = updateArray; 1045 UpdatedObjects = updateArray;
1043 m_collisionArray = collisionArray; 1046 UpdatedCollisions = collisionArray;
1044 /* TODO */ 1047 /* TODO */
1045 ConfigurationParameters[] configparms = new ConfigurationParameters[1]; 1048 ConfigurationParameters[] configparms = new ConfigurationParameters[1];
1046 configparms[0] = parms; 1049 configparms[0] = parms;
@@ -1135,10 +1138,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
1135 SequentialImpulseConstraintSolver m_solver = new SequentialImpulseConstraintSolver(); 1138 SequentialImpulseConstraintSolver m_solver = new SequentialImpulseConstraintSolver();
1136 1139
1137 DiscreteDynamicsWorld world = new DiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, cci); 1140 DiscreteDynamicsWorld world = new DiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, cci);
1138 1141
1139
1140 world.UpdatedObjects = BSAPIXNA.GetBulletXNAEntityStruct(BSAPIXNA.BulletSimEntityStructToByteArray(updateArray, updateArray.Length));
1141 world.UpdatedCollisions = BSAPIXNA.GetBulletXNACollisionStruct(BSAPIXNA.BulletSimCollisionStructToByteArray(collisionArray, collisionArray.Length));
1142 world.LastCollisionDesc = 0; 1142 world.LastCollisionDesc = 0;
1143 world.LastEntityProperty = 0; 1143 world.LastEntityProperty = 0;
1144 1144
@@ -1332,7 +1332,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
1332 { 1332 {
1333 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; 1333 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1334 CollisionShape shape = collisionObject.GetCollisionShape(); 1334 CollisionShape shape = collisionObject.GetCollisionShape();
1335 return new BulletShapeXNA(shape,BSPhysicsShapeType.SHAPE_UNKNOWN); 1335 return new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType()));
1336 } 1336 }
1337 1337
1338 //(PhysicsScene.World.ptr, nativeShapeData) 1338 //(PhysicsScene.World.ptr, nativeShapeData)
@@ -1395,10 +1395,148 @@ private sealed class BulletConstraintXNA : BulletConstraint
1395 CollisionShape ret = null; 1395 CollisionShape ret = null;
1396 ret = compoundshape.GetChildShape(pii); 1396 ret = compoundshape.GetChildShape(pii);
1397 compoundshape.RemoveChildShapeByIndex(pii); 1397 compoundshape.RemoveChildShapeByIndex(pii);
1398 return new BulletShapeXNA(ret, BSPhysicsShapeType.SHAPE_UNKNOWN); 1398 return new BulletShapeXNA(ret, BSShapeTypeFromBroadPhaseNativeType(ret.GetShapeType()));
1399 }
1400
1401 public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) {
1402 /* TODO */
1403 if (cShape == null)
1404 return null;
1405 CompoundShape compoundShape = (cShape as BulletShapeXNA).shape as CompoundShape;
1406 CollisionShape shape = compoundShape.GetChildShape(indx);
1407 BulletShape retShape = new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType()));
1408
1409
1410 return null;
1411 }
1412
1413 public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin)
1414 {
1415 switch (pin)
1416 {
1417 case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE:
1418 return BSPhysicsShapeType.SHAPE_BOX;
1419 break;
1420 case BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE:
1421 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1422 break;
1423
1424 case BroadphaseNativeTypes.TETRAHEDRAL_SHAPE_PROXYTYPE:
1425 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1426 break;
1427 case BroadphaseNativeTypes.CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE:
1428 return BSPhysicsShapeType.SHAPE_MESH;
1429 break;
1430 case BroadphaseNativeTypes.CONVEX_HULL_SHAPE_PROXYTYPE:
1431 return BSPhysicsShapeType.SHAPE_HULL;
1432 break;
1433 case BroadphaseNativeTypes.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
1434 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1435 break;
1436 case BroadphaseNativeTypes.CUSTOM_POLYHEDRAL_SHAPE_TYPE:
1437 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1438 break;
1439 //implicit convex shapes
1440 case BroadphaseNativeTypes.IMPLICIT_CONVEX_SHAPES_START_HERE:
1441 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1442 break;
1443 case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE:
1444 return BSPhysicsShapeType.SHAPE_SPHERE;
1445 break;
1446 case BroadphaseNativeTypes.MULTI_SPHERE_SHAPE_PROXYTYPE:
1447 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1448 break;
1449 case BroadphaseNativeTypes.CAPSULE_SHAPE_PROXYTYPE:
1450 return BSPhysicsShapeType.SHAPE_CAPSULE;
1451 break;
1452 case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE:
1453 return BSPhysicsShapeType.SHAPE_CONE;
1454 break;
1455 case BroadphaseNativeTypes.CONVEX_SHAPE_PROXYTYPE:
1456 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1457 break;
1458 case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE:
1459 return BSPhysicsShapeType.SHAPE_CYLINDER;
1460 break;
1461 case BroadphaseNativeTypes.UNIFORM_SCALING_SHAPE_PROXYTYPE:
1462 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1463 break;
1464 case BroadphaseNativeTypes.MINKOWSKI_SUM_SHAPE_PROXYTYPE:
1465 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1466 break;
1467 case BroadphaseNativeTypes.MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE:
1468 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1469 break;
1470 case BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE:
1471 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1472 break;
1473 case BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE:
1474 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1475 break;
1476 case BroadphaseNativeTypes.CUSTOM_CONVEX_SHAPE_TYPE:
1477 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1478 break;
1479 //concave shape
1480 case BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE:
1481 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1482 break;
1483 //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
1484 case BroadphaseNativeTypes.TRIANGLE_MESH_SHAPE_PROXYTYPE:
1485 return BSPhysicsShapeType.SHAPE_MESH;
1486 break;
1487 case BroadphaseNativeTypes.SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
1488 return BSPhysicsShapeType.SHAPE_MESH;
1489 break;
1490 ///used for demo integration FAST/Swift collision library and Bullet
1491 case BroadphaseNativeTypes.FAST_CONCAVE_MESH_PROXYTYPE:
1492 return BSPhysicsShapeType.SHAPE_MESH;
1493 break;
1494 //terrain
1495 case BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE:
1496 return BSPhysicsShapeType.SHAPE_HEIGHTMAP;
1497 break;
1498 ///Used for GIMPACT Trimesh integration
1499 case BroadphaseNativeTypes.GIMPACT_SHAPE_PROXYTYPE:
1500 return BSPhysicsShapeType.SHAPE_MESH;
1501 break;
1502 ///Multimaterial mesh
1503 case BroadphaseNativeTypes.MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE:
1504 return BSPhysicsShapeType.SHAPE_MESH;
1505 break;
1506
1507 case BroadphaseNativeTypes.EMPTY_SHAPE_PROXYTYPE:
1508 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1509 break;
1510 case BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE:
1511 return BSPhysicsShapeType.SHAPE_GROUNDPLANE;
1512 break;
1513 case BroadphaseNativeTypes.CUSTOM_CONCAVE_SHAPE_TYPE:
1514 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1515 break;
1516 case BroadphaseNativeTypes.CONCAVE_SHAPES_END_HERE:
1517 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1518 break;
1519
1520 case BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE:
1521 return BSPhysicsShapeType.SHAPE_COMPOUND;
1522 break;
1523
1524 case BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE:
1525 return BSPhysicsShapeType.SHAPE_MESH;
1526 break;
1527 case BroadphaseNativeTypes.HFFLUID_SHAPE_PROXYTYPE:
1528 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1529 break;
1530 case BroadphaseNativeTypes.HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE:
1531 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1532 break;
1533 case BroadphaseNativeTypes.INVALID_SHAPE_PROXYTYPE:
1534 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1535 break;
1536 }
1537 return BSPhysicsShapeType.SHAPE_UNKNOWN;
1399 } 1538 }
1400 1539
1401 public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) { /* TODO */ return null; }
1402 public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape) { /* TODO */ } 1540 public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape) { /* TODO */ }
1403 public override void UpdateChildTransform(BulletShape pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb) { /* TODO */ } 1541 public override void UpdateChildTransform(BulletShape pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb) { /* TODO */ }
1404 1542
@@ -1636,11 +1774,21 @@ private sealed class BulletConstraintXNA : BulletConstraint
1636 return epic; 1774 return epic;
1637 } 1775 }
1638 1776
1639 private static int PhysicsStepint(BulletWorld pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, 1777 private int PhysicsStepint(BulletWorld pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount,
1640 out EntityProperties[] updatedEntities, out int collidersCount, out CollisionDesc[] colliders, int maxCollisions, int maxUpdates) 1778 out EntityProperties[] updatedEntities, out int collidersCount, out CollisionDesc[] colliders, int maxCollisions, int maxUpdates)
1641 { 1779 {
1642 int numSimSteps = 0; 1780 int numSimSteps = 0;
1781 Array.Clear(UpdatedObjects, 0, UpdatedObjects.Length);
1782 Array.Clear(UpdatedCollisions, 0, UpdatedCollisions.Length);
1783 LastEntityProperty=0;
1784
1785
1786
1787
1788
1643 1789
1790 LastCollisionDesc=0;
1791
1644 updatedEntityCount = 0; 1792 updatedEntityCount = 0;
1645 collidersCount = 0; 1793 collidersCount = 0;
1646 1794
@@ -1651,8 +1799,6 @@ private sealed class BulletConstraintXNA : BulletConstraint
1651 1799
1652 world.LastCollisionDesc = 0; 1800 world.LastCollisionDesc = 0;
1653 world.LastEntityProperty = 0; 1801 world.LastEntityProperty = 0;
1654 world.UpdatedObjects = new BulletXNA.EntityProperties[maxUpdates];
1655 world.UpdatedCollisions = new BulletXNA.CollisionDesc[maxCollisions];
1656 numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); 1802 numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep);
1657 int updates = 0; 1803 int updates = 0;
1658 1804
@@ -1675,7 +1821,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
1675 IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); 1821 IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB();
1676 IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A 1822 IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A
1677 1823
1678 RecordCollision(world, objA, objB, contactPoint, contactNormal); 1824 RecordCollision(this, objA, objB, contactPoint, contactNormal,manifoldPoint.GetDistance());
1679 m_collisionsThisFrame ++; 1825 m_collisionsThisFrame ++;
1680 if (m_collisionsThisFrame >= 9999999) 1826 if (m_collisionsThisFrame >= 9999999)
1681 break; 1827 break;
@@ -1683,15 +1829,16 @@ private sealed class BulletConstraintXNA : BulletConstraint
1683 1829
1684 } 1830 }
1685 1831
1686 updatedEntityCount = world.LastEntityProperty; 1832 updatedEntityCount = LastEntityProperty;
1687 updatedEntities = GetBulletSimEntityStruct(BulletXNAEntityStructToByteArray(world.UpdatedObjects, world.LastEntityProperty)); 1833 updatedEntities = UpdatedObjects;
1834
1688 1835
1689 1836
1690 1837
1691 1838
1692 collidersCount = world.LastCollisionDesc; 1839 collidersCount = LastCollisionDesc;
1693 colliders = 1840 colliders = UpdatedCollisions;
1694 GetBulletSimCollisionStruct(BulletXNACollisionStructToByteArray(world.UpdatedCollisions, world.LastCollisionDesc));//new List<BulletXNA.CollisionDesc>(world.UpdatedCollisions); 1841
1695 1842
1696 } 1843 }
1697 else 1844 else
@@ -1699,8 +1846,8 @@ private sealed class BulletConstraintXNA : BulletConstraint
1699 //if (updatedEntities is null) 1846 //if (updatedEntities is null)
1700 //updatedEntities = new List<BulletXNA.EntityProperties>(); 1847 //updatedEntities = new List<BulletXNA.EntityProperties>();
1701 //updatedEntityCount = 0; 1848 //updatedEntityCount = 0;
1702 //if (colliders is null) 1849
1703 //colliders = new List<BulletXNA.CollisionDesc>(); 1850
1704 //collidersCount = 0; 1851 //collidersCount = 0;
1705 1852
1706 updatedEntities = new EntityProperties[0]; 1853 updatedEntities = new EntityProperties[0];
@@ -1711,8 +1858,64 @@ private sealed class BulletConstraintXNA : BulletConstraint
1711 } 1858 }
1712 return numSimSteps; 1859 return numSimSteps;
1713 } 1860 }
1714 1861 public void RecordGhostCollisions(PairCachingGhostObject obj)
1715 private static void RecordCollision(CollisionWorld world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm) 1862 {
1863 /*
1864 *void BulletSim::RecordGhostCollisions(btPairCachingGhostObject* obj)
1865{
1866 btManifoldArray manifoldArray;
1867 btBroadphasePairArray& pairArray = obj->getOverlappingPairCache()->getOverlappingPairArray();
1868 int numPairs = pairArray.size();
1869
1870 // For all the pairs of sets of contact points
1871 for (int i=0; i < numPairs; i++)
1872 {
1873 if (m_collisionsThisFrame >= m_maxCollisionsPerFrame)
1874 break;
1875
1876 manifoldArray.clear();
1877 const btBroadphasePair& pair = pairArray[i];
1878
1879 // The real representation is over in the world pair cache
1880 btBroadphasePair* collisionPair = m_worldData.dynamicsWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
1881 if (!collisionPair)
1882 continue;
1883
1884 if (collisionPair->m_algorithm)
1885 collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
1886
1887 // The collision pair has sets of collision points (manifolds)
1888 for (int j=0; j < manifoldArray.size(); j++)
1889 {
1890 btPersistentManifold* contactManifold = manifoldArray[j];
1891 int numContacts = contactManifold->getNumContacts();
1892
1893 const btCollisionObject* objA = static_cast<const btCollisionObject*>(contactManifold->getBody0());
1894 const btCollisionObject* objB = static_cast<const btCollisionObject*>(contactManifold->getBody1());
1895
1896 // TODO: this is a more thurough check than the regular collision code --
1897 // here we find the penetrating contact in the manifold but for regular
1898 // collisions we assume the first point in the manifold is good enough.
1899 // Decide of this extra checking is required or if first point is good enough.
1900 for (int p=0; p < numContacts; p++)
1901 {
1902 const btManifoldPoint& pt = contactManifold->getContactPoint(p);
1903 // If a penetrating contact, this is a hit
1904 if (pt.getDistance()<0.f)
1905 {
1906 const btVector3& contactPoint = pt.getPositionWorldOnA();
1907 const btVector3& normalOnA = -pt.m_normalWorldOnB;
1908 RecordCollision(objA, objB, contactPoint, normalOnA, pt.getDistance());
1909 // Only one contact point for each set of colliding objects
1910 break;
1911 }
1912 }
1913 }
1914 }
1915}
1916 */
1917 }
1918 private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration)
1716 { 1919 {
1717 1920
1718 IndexedVector3 contactNormal = norm; 1921 IndexedVector3 contactNormal = norm;
@@ -1733,12 +1936,14 @@ private sealed class BulletConstraintXNA : BulletConstraint
1733 1936
1734 ulong collisionID = ((ulong) idA << 32) | idB; 1937 ulong collisionID = ((ulong) idA << 32) | idB;
1735 1938
1736 BulletXNA.CollisionDesc cDesc = new BulletXNA.CollisionDesc() 1939 CollisionDesc cDesc = new CollisionDesc()
1737 { 1940 {
1738 aID = idA, 1941 aID = idA,
1739 bID = idB, 1942 bID = idB,
1740 point = contact, 1943 point = new Vector3(contact.X,contact.Y,contact.Z),
1741 normal = contactNormal 1944 normal = new Vector3(contactNormal.X,contactNormal.Y,contactNormal.Z),
1945 penetration = penetration
1946
1742 }; 1947 };
1743 if (world.LastCollisionDesc < world.UpdatedCollisions.Length) 1948 if (world.LastCollisionDesc < world.UpdatedCollisions.Length)
1744 world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc); 1949 world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc);
@@ -1764,7 +1969,8 @@ private sealed class BulletConstraintXNA : BulletConstraint
1764 return ent; 1969 return ent;
1765 } 1970 }
1766 1971
1767 public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) { /* TODO */ return false; } 1972 public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) { /* TODO */
1973 return false; }
1768 1974
1769 public override Vector3 GetLocalScaling(BulletShape pShape) 1975 public override Vector3 GetLocalScaling(BulletShape pShape)
1770 { 1976 {
@@ -1800,160 +2006,131 @@ private sealed class BulletConstraintXNA : BulletConstraint
1800 } 2006 }
1801 return false; 2007 return false;
1802 } 2008 }
1803 2009}
1804 public static unsafe BulletXNA.CollisionDesc[] GetBulletXNACollisionStruct(byte[] buffer) 2010
2011
2012
2013
2014 public class SimMotionState : DefaultMotionState
1805 { 2015 {
1806 int count = buffer.Length/sizeof (BulletXNA.CollisionDesc); 2016 public RigidBody Rigidbody;
1807 BulletXNA.CollisionDesc[] result = new BulletXNA.CollisionDesc[count]; 2017 public Vector3 ZeroVect;
1808 BulletXNA.CollisionDesc* ptr; 2018
1809 fixed (byte* localBytes = new byte[buffer.Length]) 2019 private IndexedMatrix m_xform;
2020
2021 private EntityProperties m_properties;
2022 private EntityProperties m_lastProperties;
2023 private BSAPIXNA m_world;
2024
2025 const float POSITION_TOLERANCE = 0.05f;
2026 const float VELOCITY_TOLERANCE = 0.001f;
2027 const float ROTATION_TOLERANCE = 0.01f;
2028 const float ANGULARVELOCITY_TOLERANCE = 0.01f;
2029
2030 public SimMotionState(BSAPIXNA pWorld, uint id, IndexedMatrix starTransform, object frameUpdates)
1810 { 2031 {
1811 for (int i = 0; i < buffer.Length; i++) 2032 IndexedQuaternion OrientationQuaterion = starTransform.GetRotation();
1812 { 2033 m_properties = new EntityProperties()
1813 localBytes[i] = buffer[i]; 2034 {
1814 } 2035 ID = id,
1815 for (int i=0;i<count;i++) 2036 Position = new Vector3(starTransform._origin.X, starTransform._origin.Y,starTransform._origin.Z),
2037 Rotation = new Quaternion(OrientationQuaterion.X,OrientationQuaterion.Y,OrientationQuaterion.Z,OrientationQuaterion.W)
2038 };
2039 m_lastProperties = new EntityProperties()
1816 { 2040 {
1817 ptr = (BulletXNA.CollisionDesc*) (localBytes + sizeof (BulletXNA.CollisionDesc)*i); 2041 ID = id,
1818 result[i] = new BulletXNA.CollisionDesc(); 2042 Position = new Vector3(starTransform._origin.X, starTransform._origin.Y, starTransform._origin.Z),
1819 result[i] = *ptr; 2043 Rotation = new Quaternion(OrientationQuaterion.X, OrientationQuaterion.Y, OrientationQuaterion.Z, OrientationQuaterion.W)
1820 } 2044 };
2045 m_world = pWorld;
2046 m_xform = starTransform;
1821 } 2047 }
1822 return result;
1823 }
1824 2048
1825 public static unsafe CollisionDesc[] GetBulletSimCollisionStruct(byte[] buffer) 2049 public override void GetWorldTransform(out IndexedMatrix worldTrans)
1826 {
1827 int count = buffer.Length / sizeof(CollisionDesc);
1828 CollisionDesc[] result = new CollisionDesc[count];
1829 CollisionDesc* ptr;
1830 fixed (byte* localBytes = new byte[buffer.Length])
1831 { 2050 {
1832 for (int i = 0; i < buffer.Length; i++) 2051 worldTrans = m_xform;
1833 {
1834 localBytes[i] = buffer[i];
1835 }
1836 for (int i = 0; i < count; i++)
1837 {
1838 ptr = (CollisionDesc*)(localBytes + sizeof(CollisionDesc) * i);
1839 result[i] = new CollisionDesc();
1840 result[i] = *ptr;
1841 }
1842 } 2052 }
1843 return result; 2053
1844 } 2054 public override void SetWorldTransform(IndexedMatrix worldTrans)
1845 public static unsafe byte[] BulletSimCollisionStructToByteArray(CollisionDesc[] CollisionDescArray, int count)
1846 {
1847 int arrayLength = CollisionDescArray.Length > count ? count : CollisionDescArray.Length;
1848 byte[] byteArray = new byte[sizeof(CollisionDesc) * arrayLength];
1849 fixed (CollisionDesc* floatPointer = CollisionDescArray)
1850 { 2055 {
1851 fixed (byte* bytePointer = byteArray) 2056 SetWorldTransform(ref worldTrans);
1852 {
1853 CollisionDesc* read = floatPointer;
1854 CollisionDesc* write = (CollisionDesc*)bytePointer;
1855 for (int i = 0; i < arrayLength; i++)
1856 {
1857 *write++ = *read++;
1858 }
1859 }
1860 } 2057 }
1861 return byteArray; 2058
1862 } 2059 public override void SetWorldTransform(ref IndexedMatrix worldTrans)
1863 public static unsafe byte[] BulletXNACollisionStructToByteArray(BulletXNA.CollisionDesc[] CollisionDescArray, int count)
1864 {
1865 int arrayLength = CollisionDescArray.Length > count ? count : CollisionDescArray.Length;
1866 byte[] byteArray = new byte[sizeof(BulletXNA.CollisionDesc) * arrayLength];
1867 fixed (BulletXNA.CollisionDesc* floatPointer = CollisionDescArray)
1868 { 2060 {
1869 fixed (byte* bytePointer = byteArray) 2061 SetWorldTransform(ref worldTrans, false);
1870 {
1871 BulletXNA.CollisionDesc* read = floatPointer;
1872 BulletXNA.CollisionDesc* write = (BulletXNA.CollisionDesc*)bytePointer;
1873 for (int i = 0; i < arrayLength; i++)
1874 {
1875 *write++ = *read++;
1876 }
1877 }
1878 } 2062 }
1879 return byteArray; 2063 public void SetWorldTransform(ref IndexedMatrix worldTrans, bool force)
1880 }
1881 public static unsafe BulletXNA.EntityProperties[] GetBulletXNAEntityStruct(byte[] buffer)
1882 {
1883 int count = buffer.Length / sizeof(BulletXNA.EntityProperties);
1884 BulletXNA.EntityProperties[] result = new BulletXNA.EntityProperties[count];
1885 BulletXNA.EntityProperties* ptr;
1886 fixed (byte* localBytes = new byte[buffer.Length])
1887 { 2064 {
1888 for (int i = 0; i < buffer.Length; i++) 2065 m_xform = worldTrans;
1889 { 2066 // Put the new transform into m_properties
1890 localBytes[i] = buffer[i]; 2067 IndexedQuaternion OrientationQuaternion = m_xform.GetRotation();
1891 } 2068 IndexedVector3 LinearVelocityVector = Rigidbody.GetLinearVelocity();
1892 for (int i = 0; i < count; i++) 2069 IndexedVector3 AngularVelocityVector = Rigidbody.GetAngularVelocity();
2070 m_properties.Position = new Vector3(m_xform._origin.X, m_xform._origin.Y, m_xform._origin.Z);
2071 m_properties.Rotation = new Quaternion(OrientationQuaternion.X, OrientationQuaternion.Y,
2072 OrientationQuaternion.Z, OrientationQuaternion.W);
2073 // A problem with stock Bullet is that we don't get an event when an object is deactivated.
2074 // This means that the last non-zero values for linear and angular velocity
2075 // are left in the viewer who does dead reconning and the objects look like
2076 // they float off.
2077 // BulletSim ships with a patch to Bullet which creates such an event.
2078 m_properties.Velocity = new Vector3(LinearVelocityVector.X, LinearVelocityVector.Y, LinearVelocityVector.Z);
2079 m_properties.RotationalVelocity = new Vector3(AngularVelocityVector.X, AngularVelocityVector.Y, AngularVelocityVector.Z);
2080
2081 if (force
2082
2083 || !AlmostEqual(ref m_lastProperties.Position, ref m_properties.Position, POSITION_TOLERANCE)
2084 || !AlmostEqual(ref m_properties.Rotation, ref m_lastProperties.Rotation, ROTATION_TOLERANCE)
2085 // If the Velocity and AngularVelocity are zero, most likely the object has
2086 // been deactivated. If they both are zero and they have become zero recently,
2087 // make sure a property update is sent so the zeros make it to the viewer.
2088 || ((m_properties.Velocity == ZeroVect && m_properties.RotationalVelocity == ZeroVect)
2089 &&
2090 (m_properties.Velocity != m_lastProperties.Velocity ||
2091 m_properties.RotationalVelocity != m_lastProperties.RotationalVelocity))
2092 // If Velocity and AngularVelocity are non-zero but have changed, send an update.
2093 || !AlmostEqual(ref m_properties.Velocity, ref m_lastProperties.Velocity, VELOCITY_TOLERANCE)
2094 ||
2095 !AlmostEqual(ref m_properties.RotationalVelocity, ref m_lastProperties.RotationalVelocity,
2096 ANGULARVELOCITY_TOLERANCE)
2097 )
2098
2099
1893 { 2100 {
1894 ptr = (BulletXNA.EntityProperties*)(localBytes + sizeof(BulletXNA.EntityProperties) * i); 2101 // Add this update to the list of updates for this frame.
1895 result[i] = new BulletXNA.EntityProperties(); 2102 m_lastProperties = m_properties;
1896 result[i] = *ptr; 2103 if (m_world.LastEntityProperty < m_world.UpdatedObjects.Length)
2104 m_world.UpdatedObjects[m_world.LastEntityProperty++]=(m_properties);
2105
2106 //(*m_updatesThisFrame)[m_properties.ID] = &m_properties;
1897 } 2107 }
1898 } 2108
1899 return result; 2109
1900 } 2110
1901 2111
1902 public static unsafe EntityProperties[] GetBulletSimEntityStruct(byte[] buffer) 2112 }
1903 { 2113 public override void SetRigidBody(RigidBody body)
1904 int count = buffer.Length / sizeof(EntityProperties);
1905 EntityProperties[] result = new EntityProperties[count];
1906 EntityProperties* ptr;
1907 fixed (byte* localBytes = new byte[buffer.Length])
1908 { 2114 {
1909 for (int i = 0; i < buffer.Length; i++) 2115 Rigidbody = body;
1910 {
1911 localBytes[i] = buffer[i];
1912 }
1913 for (int i = 0; i < count; i++)
1914 {
1915 ptr = (EntityProperties*)(localBytes + sizeof(EntityProperties) * i);
1916 result[i] = new EntityProperties();
1917 result[i] = *ptr;
1918 }
1919 } 2116 }
1920 return result; 2117 internal static bool AlmostEqual(ref Vector3 v1, ref Vector3 v2, float nEpsilon)
1921 }
1922 public static unsafe byte[] BulletSimEntityStructToByteArray(EntityProperties[] CollisionDescArray, int count)
1923 {
1924 int arrayLength = CollisionDescArray.Length > count ? count : CollisionDescArray.Length;
1925 byte[] byteArray = new byte[sizeof(EntityProperties) * arrayLength];
1926 fixed (EntityProperties* floatPointer = CollisionDescArray)
1927 { 2118 {
1928 fixed (byte* bytePointer = byteArray) 2119 return
1929 { 2120 (((v1.X - nEpsilon) < v2.X) && (v2.X < (v1.X + nEpsilon))) &&
1930 EntityProperties* read = floatPointer; 2121 (((v1.Y - nEpsilon) < v2.Y) && (v2.Y < (v1.Y + nEpsilon))) &&
1931 EntityProperties* write = (EntityProperties*)bytePointer; 2122 (((v1.Z - nEpsilon) < v2.Z) && (v2.Z < (v1.Z + nEpsilon)));
1932 for (int i = 0; i < arrayLength; i++)
1933 {
1934 *write++ = *read++;
1935 }
1936 }
1937 } 2123 }
1938 return byteArray; 2124
1939 } 2125 internal static bool AlmostEqual(ref Quaternion v1, ref Quaternion v2, float nEpsilon)
1940 public static unsafe byte[] BulletXNAEntityStructToByteArray(BulletXNA.EntityProperties[] CollisionDescArray, int count)
1941 {
1942 int arrayLength = CollisionDescArray.Length > count ? count : CollisionDescArray.Length;
1943 byte[] byteArray = new byte[sizeof(BulletXNA.EntityProperties) * arrayLength];
1944 fixed (BulletXNA.EntityProperties* floatPointer = CollisionDescArray)
1945 { 2126 {
1946 fixed (byte* bytePointer = byteArray) 2127 return
1947 { 2128 (((v1.X - nEpsilon) < v2.X) && (v2.X < (v1.X + nEpsilon))) &&
1948 BulletXNA.EntityProperties* read = floatPointer; 2129 (((v1.Y - nEpsilon) < v2.Y) && (v2.Y < (v1.Y + nEpsilon))) &&
1949 BulletXNA.EntityProperties* write = (BulletXNA.EntityProperties*)bytePointer; 2130 (((v1.Z - nEpsilon) < v2.Z) && (v2.Z < (v1.Z + nEpsilon))) &&
1950 for (int i = 0; i < arrayLength; i++) 2131 (((v1.W - nEpsilon) < v2.W) && (v2.W < (v1.W + nEpsilon)));
1951 {
1952 *write++ = *read++;
1953 }
1954 }
1955 } 2132 }
1956 return byteArray; 2133
1957 } 2134 }
1958} 2135}
1959} 2136
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index fe7891e..f1ef449 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -1190,8 +1190,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1190 // set directly on the vehicle. 1190 // set directly on the vehicle.
1191 private void MoveAngular(float pTimestep) 1191 private void MoveAngular(float pTimestep)
1192 { 1192 {
1193 // VehicleRotationalVelocity = Vector3.Zero;
1194
1195 ComputeAngularTurning(pTimestep); 1193 ComputeAngularTurning(pTimestep);
1196 1194
1197 ComputeAngularVerticalAttraction(); 1195 ComputeAngularVerticalAttraction();
@@ -1201,7 +1199,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1201 ComputeAngularBanking(); 1199 ComputeAngularBanking();
1202 1200
1203 // ================================================================== 1201 // ==================================================================
1204 if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 1202 if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.0001f))
1205 { 1203 {
1206 // The vehicle is not adding anything angular wise. 1204 // The vehicle is not adding anything angular wise.
1207 VehicleRotationalVelocity = Vector3.Zero; 1205 VehicleRotationalVelocity = Vector3.Zero;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 9460daf..06186b0 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -334,7 +334,7 @@ public static class BSParam
334 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, 334 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); },
335 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), 335 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
336 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , 336 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
337 0.3f, // set to zero to disable 337 0.0f, // set to zero to disable
338 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, 338 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
339 (s) => { return CcdMotionThreshold; }, 339 (s) => { return CcdMotionThreshold; },
340 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, 340 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); },
@@ -345,8 +345,8 @@ public static class BSParam
345 (s) => { return CcdSweptSphereRadius; }, 345 (s) => { return CcdSweptSphereRadius; },
346 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, 346 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); },
347 (s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ), 347 (s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ),
348 new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" , 348 new ParameterDefn("ContactProcessingThreshold", "Distance above which contacts can be discarded (0 means no discard)" ,
349 0.1f, 349 0.0f,
350 (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); }, 350 (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); },
351 (s) => { return ContactProcessingThreshold; }, 351 (s) => { return ContactProcessingThreshold; },
352 (s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); }, 352 (s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); },
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index f80084a..8b00a33 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -363,7 +363,11 @@ public sealed class BSPrim : BSPhysObject
363 // not get it through the terrain 363 // not get it through the terrain
364 _position.Z = targetHeight; 364 _position.Z = targetHeight;
365 if (inTaintTime) 365 if (inTaintTime)
366 {
366 ForcePosition = _position; 367 ForcePosition = _position;
368 }
369 // If we are throwing the object around, zero its other forces
370 ZeroMotion(inTaintTime);
367 ret = true; 371 ret = true;
368 } 372 }
369 373
@@ -1639,10 +1643,12 @@ public sealed class BSPrim : BSPhysObject
1639 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1643 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1640 1644
1641 // The sanity check can change the velocity and/or position. 1645 // The sanity check can change the velocity and/or position.
1642 if (IsPhysical && PositionSanityCheck(true)) 1646 if (IsPhysical && PositionSanityCheck(true /* inTaintTime */ ))
1643 { 1647 {
1644 entprop.Position = _position; 1648 entprop.Position = _position;
1645 entprop.Velocity = _velocity; 1649 entprop.Velocity = _velocity;
1650 entprop.RotationalVelocity = _rotationalVelocity;
1651 entprop.Acceleration = _acceleration;
1646 } 1652 }
1647 1653
1648 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG 1654 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 35dba9b..cb304b6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -917,8 +917,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
917 foreach (uint lID in xlIDs) 917 foreach (uint lID in xlIDs)
918 { 918 {
919 BSPhysObject theObject = null; 919 BSPhysObject theObject = null;
920 PhysObjects.TryGetValue(lID, out theObject); 920 if (PhysObjects.TryGetValue(lID, out theObject))
921 thisParam.onObject(this, theObject, xval); 921 thisParam.onObject(this, theObject, xval);
922 } 922 }
923 } 923 }
924 } 924 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 667cc09..1be2776 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -12091,12 +12091,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12091 radius = Math.Abs(maxY); 12091 radius = Math.Abs(maxY);
12092 if (Math.Abs(maxZ) > radius) 12092 if (Math.Abs(maxZ) > radius)
12093 radius = Math.Abs(maxZ); 12093 radius = Math.Abs(maxZ);
12094 12094 radius = radius*1.413f;
12095 Vector3 ac = group.AbsolutePosition - rayStart; 12095 Vector3 ac = group.AbsolutePosition - rayStart;
12096 Vector3 bc = group.AbsolutePosition - rayEnd; 12096 Vector3 bc = group.AbsolutePosition - rayEnd;
12097 12097
12098 double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); 12098 double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd));
12099 12099
12100 // Too far off ray, don't bother 12100 // Too far off ray, don't bother
12101 if (d > radius) 12101 if (d > radius)
12102 return; 12102 return;
@@ -12106,11 +12106,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12106 if (d2 > 0) 12106 if (d2 > 0)
12107 return; 12107 return;
12108 12108
12109 ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart));
12109 EntityIntersection intersection = group.TestIntersection(ray, true, false); 12110 EntityIntersection intersection = group.TestIntersection(ray, true, false);
12110 // Miss. 12111 // Miss.
12111 if (!intersection.HitTF) 12112 if (!intersection.HitTF)
12112 return; 12113 return;
12113 12114
12115 Vector3 b1 = group.AbsolutePosition + new Vector3(minX, minY, minZ);
12116 Vector3 b2 = group.AbsolutePosition + new Vector3(maxX, maxY, maxZ);
12117 //m_log.DebugFormat("[LLCASTRAY]: min<{0},{1},{2}>, max<{3},{4},{5}> = hitp<{6},{7},{8}>", b1.X,b1.Y,b1.Z,b2.X,b2.Y,b2.Z,intersection.ipoint.X,intersection.ipoint.Y,intersection.ipoint.Z);
12118 if (!(intersection.ipoint.X >= b1.X && intersection.ipoint.X <= b2.X &&
12119 intersection.ipoint.Y >= b1.Y && intersection.ipoint.Y <= b2.Y &&
12120 intersection.ipoint.Z >= b1.Z && intersection.ipoint.Z <= b2.Z))
12121 return;
12122
12114 ContactResult result = new ContactResult (); 12123 ContactResult result = new ContactResult ();
12115 result.ConsumerID = group.LocalId; 12124 result.ConsumerID = group.LocalId;
12116// result.Depth = intersection.distance; 12125// result.Depth = intersection.distance;
@@ -12384,8 +12393,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12384 if (checkPhysical || checkNonPhysical || detectPhantom) 12393 if (checkPhysical || checkNonPhysical || detectPhantom)
12385 { 12394 {
12386 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); 12395 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom);
12387 foreach (ContactResult r in objectHits) 12396 for (int iter = 0; iter < objectHits.Length; iter++)
12388 results.Add(r); 12397 {
12398 // Redistance the Depth because the Scene RayCaster returns distance from center to make the rezzing code simpler.
12399 objectHits[iter].Depth = Vector3.Distance(objectHits[iter].Pos, rayStart);
12400 results.Add(objectHits[iter]);
12401 }
12389 } 12402 }
12390 } 12403 }
12391 12404
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 002e852..9d20c9e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using System.Globalization; 31using System.Globalization;
32using System.Reflection; 32using System.Reflection;
33using System.IO; 33using System.IO;
34using System.Linq;
35using System.Text; 34using System.Text;
36using Microsoft.CSharp; 35using Microsoft.CSharp;
37//using Microsoft.JScript; 36//using Microsoft.JScript;
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
index 3243a9a..6a1112c 100644
--- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
+++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33using Mono.Data.SqliteClient; 33using Mono.Data.SqliteClient;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenMetaverse.StructuredData;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework.Monitoring; 38using OpenSim.Framework.Monitoring;
@@ -51,7 +52,6 @@ namespace OpenSim.Region.UserStatistics
51 52
52 public Hashtable ProcessModel(Hashtable pParams) 53 public Hashtable ProcessModel(Hashtable pParams)
53 { 54 {
54
55 List<Scene> m_scene = (List<Scene>)pParams["Scenes"]; 55 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
56 56
57 Hashtable nh = new Hashtable(); 57 Hashtable nh = new Hashtable();
@@ -129,6 +129,86 @@ namespace OpenSim.Region.UserStatistics
129 return output.ToString(); 129 return output.ToString();
130 } 130 }
131 131
132 /// <summary>
133 /// Convert active connections information to JSON string. Returns a structure:
134 /// <pre>
135 /// {"regionName": {
136 /// "presenceName": {
137 /// "name": "presenceName",
138 /// "position": "<x,y,z>",
139 /// "isRoot": "false",
140 /// "throttle": {
141 /// },
142 /// "queue": {
143 /// }
144 /// },
145 /// ... // multiple presences in the scene
146 /// },
147 /// ... // multiple regions in the sim
148 /// }
149 ///
150 /// </pre>
151 /// </summary>
152 /// <param name="pModelResult"></param>
153 /// <returns></returns>
154 public string RenderJson(Hashtable pModelResult)
155 {
156 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
157
158 OSDMap regionInfo = new OSDMap();
159 foreach (Scene scene in all_scenes)
160 {
161 OSDMap sceneInfo = new OpenMetaverse.StructuredData.OSDMap();
162 List<ScenePresence> avatarInScene = scene.GetScenePresences();
163 foreach (ScenePresence av in avatarInScene)
164 {
165 OSDMap presenceInfo = new OSDMap();
166 presenceInfo.Add("Name", new OSDString(av.Name));
167
168 Dictionary<string,string> queues = new Dictionary<string, string>();
169 if (av.ControllingClient is IStatsCollector)
170 {
171 IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
172 queues = decodeQueueReport(isClient.Report());
173 }
174 OSDMap queueInfo = new OpenMetaverse.StructuredData.OSDMap();
175 foreach (KeyValuePair<string, string> kvp in queues) {
176 queueInfo.Add(kvp.Key, new OSDString(kvp.Value));
177 }
178 sceneInfo.Add("queues", queueInfo);
179
180 if (av.IsChildAgent)
181 presenceInfo.Add("isRoot", new OSDString("false"));
182 else
183 presenceInfo.Add("isRoot", new OSDString("true"));
184
185 if (av.AbsolutePosition == DefaultNeighborPosition)
186 {
187 presenceInfo.Add("position", new OSDString("<0, 0, 0>"));
188 }
189 else
190 {
191 presenceInfo.Add("position", new OSDString(string.Format("<{0},{1},{2}>",
192 (int)av.AbsolutePosition.X,
193 (int) av.AbsolutePosition.Y,
194 (int) av.AbsolutePosition.Z)) );
195 }
196
197 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
198 OSDMap throttleInfo = new OpenMetaverse.StructuredData.OSDMap();
199 foreach (string throttlename in throttles.Keys)
200 {
201 throttleInfo.Add(throttlename, new OSDString(throttles[throttlename].ToString()));
202 }
203 presenceInfo.Add("throttle", throttleInfo);
204
205 sceneInfo.Add(av.Name, presenceInfo);
206 }
207 regionInfo.Add(scene.RegionInfo.RegionName, sceneInfo);
208 }
209 return regionInfo.ToString();
210 }
211
132 public Dictionary<string, int> DecodeClientThrottles(byte[] throttle) 212 public Dictionary<string, int> DecodeClientThrottles(byte[] throttle)
133 { 213 {
134 Dictionary<string, int> returndict = new Dictionary<string, int>(); 214 Dictionary<string, int> returndict = new Dictionary<string, int>();
@@ -203,7 +283,7 @@ namespace OpenSim.Region.UserStatistics
203 returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++; 283 returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++;
204 returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++; 284 returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++;
205 returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++; 285 returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++;
206 returndic.Add("Asset", rep.Substring((7 * pos), 8)); 286 returndic.Add("Asset", rep.Substring((7 * pos), 8));
207 /* 287 /*
208 * return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}", 288 * return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
209 SendQueue.Count(), 289 SendQueue.Count(),
diff --git a/OpenSim/Region/UserStatistics/Clients_report.cs b/OpenSim/Region/UserStatistics/Clients_report.cs
index b2bb33b..4a6f7be 100644
--- a/OpenSim/Region/UserStatistics/Clients_report.cs
+++ b/OpenSim/Region/UserStatistics/Clients_report.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using Mono.Data.SqliteClient; 32using Mono.Data.SqliteClient;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenMetaverse.StructuredData;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35 36
36namespace OpenSim.Region.UserStatistics 37namespace OpenSim.Region.UserStatistics
@@ -44,6 +45,32 @@ namespace OpenSim.Region.UserStatistics
44 get { return "Client"; } 45 get { return "Client"; }
45 } 46 }
46 47
48 /// <summary>
49 /// Return summar information in the form:
50 /// <pre>
51 /// {"totalUsers": "34",
52 /// "totalSessions": "233",
53 /// ...
54 /// }
55 /// </pre>
56 /// </summary>
57 /// <param name="pModelResult"></param>
58 /// <returns></returns>
59 public string RenderJson(Hashtable pModelResult) {
60 stats_default_page_values values = (stats_default_page_values) pModelResult["hdata"];
61
62 OSDMap summaryInfo = new OpenMetaverse.StructuredData.OSDMap();
63 summaryInfo.Add("totalUsers", new OSDString(values.total_num_users.ToString()));
64 summaryInfo.Add("totalSessions", new OSDString(values.total_num_sessions.ToString()));
65 summaryInfo.Add("averageClientFPS", new OSDString(values.avg_client_fps.ToString()));
66 summaryInfo.Add("averageClientMem", new OSDString(values.avg_client_mem_use.ToString()));
67 summaryInfo.Add("averageSimFPS", new OSDString(values.avg_sim_fps.ToString()));
68 summaryInfo.Add("averagePingTime", new OSDString(values.avg_ping.ToString()));
69 summaryInfo.Add("totalKBOut", new OSDString(values.total_kb_out.ToString()));
70 summaryInfo.Add("totalKBIn", new OSDString(values.total_kb_in.ToString()));
71 return summaryInfo.ToString();
72 }
73
47 public Hashtable ProcessModel(Hashtable pParams) 74 public Hashtable ProcessModel(Hashtable pParams)
48 { 75 {
49 SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"]; 76 SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];
diff --git a/OpenSim/Region/UserStatistics/Default_Report.cs b/OpenSim/Region/UserStatistics/Default_Report.cs
index cdc615c..fabe3d4 100644
--- a/OpenSim/Region/UserStatistics/Default_Report.cs
+++ b/OpenSim/Region/UserStatistics/Default_Report.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33using Mono.Data.SqliteClient; 33using Mono.Data.SqliteClient;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenMetaverse.StructuredData;
35using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
36using OpenSim.Framework.Monitoring; 37using OpenSim.Framework.Monitoring;
37 38
@@ -230,6 +231,31 @@ TD.align_top { vertical-align: top; }
230 return returnstruct; 231 return returnstruct;
231 } 232 }
232 233
234 /// <summary>
235 /// Return summar information in the form:
236 /// <pre>
237 /// {"totalUsers": "34",
238 /// "totalSessions": "233",
239 /// ...
240 /// }
241 /// </pre>
242 /// </summary>
243 /// <param name="pModelResult"></param>
244 /// <returns></returns>
245 public string RenderJson(Hashtable pModelResult) {
246 stats_default_page_values values = (stats_default_page_values) pModelResult["hdata"];
247
248 OSDMap summaryInfo = new OSDMap();
249 summaryInfo.Add("totalUsers", new OSDString(values.total_num_users.ToString()));
250 summaryInfo.Add("totalSessions", new OSDString(values.total_num_sessions.ToString()));
251 summaryInfo.Add("averageClientFPS", new OSDString(values.avg_client_fps.ToString()));
252 summaryInfo.Add("averageClientMem", new OSDString(values.avg_client_mem_use.ToString()));
253 summaryInfo.Add("averageSimFPS", new OSDString(values.avg_sim_fps.ToString()));
254 summaryInfo.Add("averagePingTime", new OSDString(values.avg_ping.ToString()));
255 summaryInfo.Add("totalKBOut", new OSDString(values.total_kb_out.ToString()));
256 summaryInfo.Add("totalKBIn", new OSDString(values.total_kb_in.ToString()));
257 return summaryInfo.ToString();
258 }
233 } 259 }
234 260
235 public struct stats_default_page_values 261 public struct stats_default_page_values
@@ -247,4 +273,5 @@ TD.align_top { vertical-align: top; }
247 public Dictionary<UUID, USimStatsData> sim_stat_data; 273 public Dictionary<UUID, USimStatsData> sim_stat_data;
248 public Dictionary<string, IStatsController> stats_reports; 274 public Dictionary<string, IStatsController> stats_reports;
249 } 275 }
276
250} 277}
diff --git a/OpenSim/Region/UserStatistics/IStatsReport.cs b/OpenSim/Region/UserStatistics/IStatsReport.cs
index e0ecce4..80c4487 100644
--- a/OpenSim/Region/UserStatistics/IStatsReport.cs
+++ b/OpenSim/Region/UserStatistics/IStatsReport.cs
@@ -34,5 +34,6 @@ namespace OpenSim.Region.UserStatistics
34 string ReportName { get; } 34 string ReportName { get; }
35 Hashtable ProcessModel(Hashtable pParams); 35 Hashtable ProcessModel(Hashtable pParams);
36 string RenderView(Hashtable pModelResult); 36 string RenderView(Hashtable pModelResult);
37 string RenderJson(Hashtable pModelResult);
37 } 38 }
38} 39}
diff --git a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs
index 74de46b..4d45b80 100644
--- a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs
+++ b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs
@@ -33,6 +33,7 @@ using System.Text;
33using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
34using Mono.Data.SqliteClient; 34using Mono.Data.SqliteClient;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework.Monitoring; 38using OpenSim.Framework.Monitoring;
38 39
@@ -125,6 +126,34 @@ namespace OpenSim.Region.UserStatistics
125 return output.ToString(); 126 return output.ToString();
126 } 127 }
127 128
129 /// <summary>
130 /// Return the last log lines. Output in the format:
131 /// <pre>
132 /// {"logLines": [
133 /// "line1",
134 /// "line2",
135 /// ...
136 /// ]
137 /// }
138 /// </pre>
139 /// </summary>
140 /// <param name="pModelResult"></param>
141 /// <returns></returns>
142 public string RenderJson(Hashtable pModelResult)
143 {
144 OSDMap logInfo = new OpenMetaverse.StructuredData.OSDMap();
145
146 OSDArray logLines = new OpenMetaverse.StructuredData.OSDArray();
147 string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n");
148 string[] result = Regex.Split(tmp, "\n");
149 for (int i = 0; i < result.Length; i++)
150 {
151 logLines.Add(new OSDString(result[i]));
152 }
153 logInfo.Add("logLines", logLines);
154 return logInfo.ToString();
155 }
156
128 #endregion 157 #endregion
129 } 158 }
130} 159}
diff --git a/OpenSim/Region/UserStatistics/Prototype_distributor.cs b/OpenSim/Region/UserStatistics/Prototype_distributor.cs
index 53ae557..6f8b2aa 100644
--- a/OpenSim/Region/UserStatistics/Prototype_distributor.cs
+++ b/OpenSim/Region/UserStatistics/Prototype_distributor.cs
@@ -36,7 +36,18 @@ namespace OpenSim.Region.UserStatistics
36{ 36{
37 public class Prototype_distributor : IStatsController 37 public class Prototype_distributor : IStatsController
38 { 38 {
39 private string prototypejs=string.Empty; 39 private string jsFileName = "prototype.js";
40 private string prototypejs = string.Empty;
41
42 public Prototype_distributor()
43 {
44 jsFileName = "prototype.js";
45 }
46
47 public Prototype_distributor(string jsName)
48 {
49 jsFileName = jsName;
50 }
40 51
41 public string ReportName 52 public string ReportName
42 { 53 {
@@ -45,20 +56,24 @@ namespace OpenSim.Region.UserStatistics
45 public Hashtable ProcessModel(Hashtable pParams) 56 public Hashtable ProcessModel(Hashtable pParams)
46 { 57 {
47 Hashtable pResult = new Hashtable(); 58 Hashtable pResult = new Hashtable();
48 if (prototypejs.Length == 0) 59 pResult["js"] = jsFileName;
60 return pResult;
61 }
62
63 public string RenderView(Hashtable pModelResult)
64 {
65 string fileName = (string)pModelResult["js"];
66 using (StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/" + fileName, FileMode.Open)))
49 { 67 {
50 StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
51 prototypejs = fs.ReadToEnd(); 68 prototypejs = fs.ReadToEnd();
52 fs.Close(); 69 fs.Close();
53 fs.Dispose();
54 } 70 }
55 pResult["js"] = prototypejs; 71 return prototypejs;
56 return pResult;
57 } 72 }
58 73
59 public string RenderView(Hashtable pModelResult) 74 public string RenderJson(Hashtable pModelResult)
60 { 75 {
61 return pModelResult["js"].ToString(); 76 return "{}";
62 } 77 }
63 78
64 } 79 }
diff --git a/OpenSim/Region/UserStatistics/Sessions_Report.cs b/OpenSim/Region/UserStatistics/Sessions_Report.cs
index 1a2d460..0e94912 100644
--- a/OpenSim/Region/UserStatistics/Sessions_Report.cs
+++ b/OpenSim/Region/UserStatistics/Sessions_Report.cs
@@ -278,6 +278,11 @@ TD.align_top { vertical-align: top; }
278 public DateTime start_time; 278 public DateTime start_time;
279 } 279 }
280 280
281 public string RenderJson(Hashtable pModelResult)
282 {
283 return "{}";
284 }
281 #endregion 285 #endregion
282 } 286 }
287
283} 288}
diff --git a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs
index 28051fb..ad848a1 100644
--- a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs
+++ b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33using Mono.Data.SqliteClient; 33using Mono.Data.SqliteClient;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenMetaverse.StructuredData;
35using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
36using OpenSim.Framework.Monitoring; 37using OpenSim.Framework.Monitoring;
37 38
@@ -218,6 +219,64 @@ namespace OpenSim.Region.UserStatistics
218 return output.ToString(); 219 return output.ToString();
219 } 220 }
220 221
222 /// <summary>
223 /// Return stat information for all regions in the sim. Returns data of the form:
224 /// <pre>
225 /// {"REGIONNAME": {
226 /// "region": "REGIONNAME",
227 /// "timeDilation": "101",
228 /// ... // the rest of the stat info
229 /// },
230 /// ... // entries for each region
231 /// }
232 /// </pre>
233 /// </summary>
234 /// <param name="pModelResult"></param>
235 /// <returns></returns>
236 public string RenderJson(Hashtable pModelResult)
237 {
238 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
239 Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
240
241 OSDMap allStatsInfo = new OpenMetaverse.StructuredData.OSDMap();
242 foreach (USimStatsData sdata in sdatadic.Values)
243 {
244 OSDMap statsInfo = new OpenMetaverse.StructuredData.OSDMap();
245 string regionName = "unknown";
246 foreach (Scene sn in all_scenes)
247 {
248 if (sn.RegionInfo.RegionID == sdata.RegionId)
249 {
250 regionName = sn.RegionInfo.RegionName;
251 break;
252 }
253 }
254 statsInfo.Add("region", new OSDString(regionName));
255 statsInfo.Add("timeDilation", new OSDString(sdata.TimeDilation.ToString()));
256 statsInfo.Add("simFPS", new OSDString(sdata.SimFps.ToString()));
257 statsInfo.Add("physicsFPS", new OSDString(sdata.PhysicsFps.ToString()));
258 statsInfo.Add("agentUpdates", new OSDString(sdata.AgentUpdates.ToString()));
259 statsInfo.Add("rootAgents", new OSDString(sdata.RootAgents.ToString()));
260 statsInfo.Add("childAgents", new OSDString(sdata.ChildAgents.ToString()));
261 statsInfo.Add("totalPrims", new OSDString(sdata.TotalPrims.ToString()));
262 statsInfo.Add("activePrims", new OSDString(sdata.ActivePrims.ToString()));
263 statsInfo.Add("activeScripts", new OSDString(sdata.ActiveScripts.ToString()));
264 statsInfo.Add("scriptLinesPerSec", new OSDString(sdata.ScriptLinesPerSecond.ToString()));
265 statsInfo.Add("totalFrameTime", new OSDString(sdata.TotalFrameTime.ToString()));
266 statsInfo.Add("agentFrameTime", new OSDString(sdata.AgentFrameTime.ToString()));
267 statsInfo.Add("physicsFrameTime", new OSDString(sdata.PhysicsFrameTime.ToString()));
268 statsInfo.Add("otherFrameTime", new OSDString(sdata.OtherFrameTime.ToString()));
269 statsInfo.Add("outPacketsPerSec", new OSDString(sdata.OutPacketsPerSecond.ToString()));
270 statsInfo.Add("inPacketsPerSec", new OSDString(sdata.InPacketsPerSecond.ToString()));
271 statsInfo.Add("unackedByptes", new OSDString(sdata.UnackedBytes.ToString()));
272 statsInfo.Add("pendingDownloads", new OSDString(sdata.PendingDownloads.ToString()));
273 statsInfo.Add("pendingUploads", new OSDString(sdata.PendingUploads.ToString()));
274
275 allStatsInfo.Add(regionName, statsInfo);
276 }
277 return allStatsInfo.ToString();
278 }
279
221 #endregion 280 #endregion
222 } 281 }
223} 282}
diff --git a/OpenSim/Region/UserStatistics/Updater_distributor.cs b/OpenSim/Region/UserStatistics/Updater_distributor.cs
index 9593cc9..601e06b 100644
--- a/OpenSim/Region/UserStatistics/Updater_distributor.cs
+++ b/OpenSim/Region/UserStatistics/Updater_distributor.cs
@@ -62,5 +62,9 @@ namespace OpenSim.Region.UserStatistics
62 return pModelResult["js"].ToString(); 62 return pModelResult["js"].ToString();
63 } 63 }
64 64
65 public string RenderJson(Hashtable pModelResult) {
66 return "{}";
67 }
68
65 } 69 }
66} \ No newline at end of file 70} \ No newline at end of file
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index 64cb577..438ef48 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -121,6 +121,10 @@ namespace OpenSim.Region.UserStatistics
121 reports.Add("clients.report", clientReport); 121 reports.Add("clients.report", clientReport);
122 reports.Add("sessions.report", sessionsReport); 122 reports.Add("sessions.report", sessionsReport);
123 123
124 reports.Add("sim.css", new Prototype_distributor("sim.css"));
125 reports.Add("sim.html", new Prototype_distributor("sim.html"));
126 reports.Add("jquery.js", new Prototype_distributor("jquery.js"));
127
124 //// 128 ////
125 // Add Your own Reports here (Do Not Modify Lines here Devs!) 129 // Add Your own Reports here (Do Not Modify Lines here Devs!)
126 //// 130 ////
@@ -255,9 +259,12 @@ namespace OpenSim.Region.UserStatistics
255 string regpath = request["uri"].ToString(); 259 string regpath = request["uri"].ToString();
256 int response_code = 404; 260 int response_code = 404;
257 string contenttype = "text/html"; 261 string contenttype = "text/html";
262 bool jsonFormatOutput = false;
258 263
259 string strOut = string.Empty; 264 string strOut = string.Empty;
260 265
266 // The request patch should be "/SStats/reportName" where 'reportName'
267 // is one of the names added to the 'reports' hashmap.
261 regpath = regpath.Remove(0, 8); 268 regpath = regpath.Remove(0, 8);
262 if (regpath.Length == 0) regpath = "default.report"; 269 if (regpath.Length == 0) regpath = "default.report";
263 if (reports.ContainsKey(regpath)) 270 if (reports.ContainsKey(regpath))
@@ -265,6 +272,9 @@ namespace OpenSim.Region.UserStatistics
265 IStatsController rep = reports[regpath]; 272 IStatsController rep = reports[regpath];
266 Hashtable repParams = new Hashtable(); 273 Hashtable repParams = new Hashtable();
267 274
275 if (request.ContainsKey("json"))
276 jsonFormatOutput = true;
277
268 if (request.ContainsKey("requestvars")) 278 if (request.ContainsKey("requestvars"))
269 repParams["RequestVars"] = request["requestvars"]; 279 repParams["RequestVars"] = request["requestvars"];
270 else 280 else
@@ -284,13 +294,26 @@ namespace OpenSim.Region.UserStatistics
284 294
285 concurrencyCounter++; 295 concurrencyCounter++;
286 296
287 strOut = rep.RenderView(rep.ProcessModel(repParams)); 297 if (jsonFormatOutput)
298 {
299 strOut = rep.RenderJson(rep.ProcessModel(repParams));
300 contenttype = "text/json";
301 }
302 else
303 {
304 strOut = rep.RenderView(rep.ProcessModel(repParams));
305 }
288 306
289 if (regpath.EndsWith("js")) 307 if (regpath.EndsWith("js"))
290 { 308 {
291 contenttype = "text/javascript"; 309 contenttype = "text/javascript";
292 } 310 }
293 311
312 if (regpath.EndsWith("css"))
313 {
314 contenttype = "text/css";
315 }
316
294 concurrencyCounter--; 317 concurrencyCounter--;
295 318
296 response_code = 200; 319 response_code = 200;