diff options
author | Robert Adams | 2013-01-25 16:00:17 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-27 12:50:05 -0800 |
commit | ddef8f16e58471d19baa63f14134b25309cf2570 (patch) | |
tree | f7f520bf8613ff818701392958572f73f4b2b91e | |
parent | BulletSim: parameterize several vehicle debugging values: physical linear and... (diff) | |
download | opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.zip opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.tar.gz opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.tar.bz2 opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.tar.xz |
BulletSim: first attempt at reporting top colliders
5 files changed, 43 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 5c531fc..06b4620 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -597,8 +597,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
597 | // Moderate angular movement introduced by Bullet. | 597 | // Moderate angular movement introduced by Bullet. |
598 | // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. | 598 | // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. |
599 | // Maybe compute linear and angular factor and damping from params. | 599 | // Maybe compute linear and angular factor and damping from params. |
600 | float angularDamping = BSParam.VehicleAngularDamping; | 600 | PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, BSParam.VehicleAngularDamping); |
601 | PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping); | ||
602 | PhysicsScene.PE.SetLinearFactor(Prim.PhysBody, BSParam.VehicleLinearFactorV); | 601 | PhysicsScene.PE.SetLinearFactor(Prim.PhysBody, BSParam.VehicleLinearFactorV); |
603 | PhysicsScene.PE.SetAngularFactorV(Prim.PhysBody, BSParam.VehicleAngularFactorV); | 602 | PhysicsScene.PE.SetAngularFactorV(Prim.PhysBody, BSParam.VehicleAngularFactorV); |
604 | 603 | ||
@@ -615,8 +614,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
615 | // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. | 614 | // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. |
616 | PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero); | 615 | PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero); |
617 | 616 | ||
618 | VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4},grav={5}", | 617 | VDetailLog("{0},BSDynamics.Refresh,mass={1},inert={2},grav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", |
619 | Prim.LocalID, m_vehicleMass, Prim.Inertia, angularDamping, m_VehicleGravity); | 618 | Prim.LocalID, m_vehicleMass, Prim.Inertia, m_VehicleGravity, |
619 | BSParam.VehicleAngularDamping, BSParam.VehicleFriction, BSParam.VehicleRestitution, | ||
620 | BSParam.VehicleLinearFactor, BSParam.VehicleAngularFactor | ||
621 | ); | ||
620 | } | 622 | } |
621 | else | 623 | else |
622 | { | 624 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 285d4a2..5e8143c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -95,6 +95,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
95 | SubscribedEventsMs = 0; | 95 | SubscribedEventsMs = 0; |
96 | CollidingStep = 0; | 96 | CollidingStep = 0; |
97 | CollidingGroundStep = 0; | 97 | CollidingGroundStep = 0; |
98 | CollisionAccumulation = 0; | ||
99 | CollisionScore = 0; | ||
98 | } | 100 | } |
99 | 101 | ||
100 | // Tell the object to clean up. | 102 | // Tell the object to clean up. |
@@ -239,6 +241,9 @@ public abstract class BSPhysObject : PhysicsActor | |||
239 | // The collision flags we think are set in Bullet | 241 | // The collision flags we think are set in Bullet |
240 | protected CollisionFlags CurrentCollisionFlags { get; set; } | 242 | protected CollisionFlags CurrentCollisionFlags { get; set; } |
241 | 243 | ||
244 | // Count of collisions for this object | ||
245 | protected long CollisionAccumulation { get; set; } | ||
246 | |||
242 | public override bool IsColliding { | 247 | public override bool IsColliding { |
243 | get { return (CollidingStep == PhysicsScene.SimulationStep); } | 248 | get { return (CollidingStep == PhysicsScene.SimulationStep); } |
244 | set { | 249 | set { |
@@ -300,6 +305,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
300 | return ret; | 305 | return ret; |
301 | } | 306 | } |
302 | 307 | ||
308 | CollisionAccumulation++; | ||
309 | |||
303 | // if someone has subscribed for collision events.... | 310 | // if someone has subscribed for collision events.... |
304 | if (SubscribedEvents()) { | 311 | if (SubscribedEvents()) { |
305 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 312 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
@@ -386,6 +393,16 @@ public abstract class BSPhysObject : PhysicsActor | |||
386 | public override bool SubscribedEvents() { | 393 | public override bool SubscribedEvents() { |
387 | return (SubscribedEventsMs > 0); | 394 | return (SubscribedEventsMs > 0); |
388 | } | 395 | } |
396 | // Because 'CollisionScore' is calls many times while sorting it should not be recomputed | ||
397 | // each time called. So this is built to be light weight for each collision and to do | ||
398 | // all the processing when the user asks for the info. | ||
399 | public void ComputeCollisionScore() | ||
400 | { | ||
401 | // Scale the collision count by the time since the last collision | ||
402 | long timeAgo = PhysicsScene.SimulationStep - CollidingStep + 1; | ||
403 | CollisionScore = CollisionAccumulation / timeAgo; | ||
404 | } | ||
405 | public override float CollisionScore { get; set; } | ||
389 | 406 | ||
390 | #endregion // Collisions | 407 | #endregion // Collisions |
391 | 408 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 99903f5..17fddd7 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -59,7 +59,6 @@ public sealed class BSPrim : BSPhysObject | |||
59 | private OMV.Vector3 _force; | 59 | private OMV.Vector3 _force; |
60 | private OMV.Vector3 _velocity; | 60 | private OMV.Vector3 _velocity; |
61 | private OMV.Vector3 _torque; | 61 | private OMV.Vector3 _torque; |
62 | private float _collisionScore; | ||
63 | private OMV.Vector3 _acceleration; | 62 | private OMV.Vector3 _acceleration; |
64 | private OMV.Quaternion _orientation; | 63 | private OMV.Quaternion _orientation; |
65 | private int _physicsActorType; | 64 | private int _physicsActorType; |
@@ -644,11 +643,6 @@ public sealed class BSPrim : BSPhysObject | |||
644 | // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); | 643 | // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); |
645 | } | 644 | } |
646 | } | 645 | } |
647 | public override float CollisionScore { | ||
648 | get { return _collisionScore; } | ||
649 | set { _collisionScore = value; | ||
650 | } | ||
651 | } | ||
652 | public override OMV.Vector3 Acceleration { | 646 | public override OMV.Vector3 Acceleration { |
653 | get { return _acceleration; } | 647 | get { return _acceleration; } |
654 | set { _acceleration = value; } | 648 | set { _acceleration = value; } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index cb304b6..4442650 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Linq; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using System.Runtime.InteropServices; | 31 | using System.Runtime.InteropServices; |
31 | using System.Text; | 32 | using System.Text; |
@@ -697,7 +698,21 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
697 | 698 | ||
698 | public override Dictionary<uint, float> GetTopColliders() | 699 | public override Dictionary<uint, float> GetTopColliders() |
699 | { | 700 | { |
700 | return new Dictionary<uint, float>(); | 701 | Dictionary<uint, float> topColliders; |
702 | |||
703 | lock (PhysObjects) | ||
704 | { | ||
705 | foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects) | ||
706 | { | ||
707 | kvp.Value.ComputeCollisionScore(); | ||
708 | } | ||
709 | |||
710 | List<BSPhysObject> orderedPrims = new List<BSPhysObject>(PhysObjects.Values); | ||
711 | orderedPrims.OrderByDescending(p => p.CollisionScore).Take(25); | ||
712 | topColliders = orderedPrims.ToDictionary(p => p.LocalID, p => p.CollisionScore); | ||
713 | } | ||
714 | |||
715 | return topColliders; | ||
701 | } | 716 | } |
702 | 717 | ||
703 | public override bool IsThreaded { get { return false; } } | 718 | public override bool IsThreaded { get { return false; } } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 7917795..a95e169 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | |||
@@ -1,5 +1,9 @@ | |||
1 | CURRENT PRIORITIES | 1 | CURRENT PRIORITIES |
2 | ================================================= | 2 | ================================================= |
3 | One sided meshes? Should terrain be built into a closed shape? | ||
4 | When meshes get partially wedged into the terrain, they cannot push themselves out. | ||
5 | It is possible that Bullet processes collisions whether entering or leaving a mesh. | ||
6 | Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869 | ||
3 | Deleting a linkset while standing on the root will leave the physical shape of the root behind. | 7 | Deleting a linkset while standing on the root will leave the physical shape of the root behind. |
4 | Not sure if it is because standing on it. Done with large prim linksets. | 8 | Not sure if it is because standing on it. Done with large prim linksets. |
5 | Vehicle angular vertical attraction | 9 | Vehicle angular vertical attraction |