From f2132329a358db2c66c29501d35ef54eae8d6eed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 15 Oct 2011 01:20:40 +0100 Subject: refactor: make methods that do not need to be public in ODE private or internal to aid code reading/analysis. Remove some unused method arguments --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 133 ++++++++++++++++----------- 1 file changed, 81 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin/OdeScene.cs') diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index e8689a6..355d30b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -193,9 +193,30 @@ namespace OpenSim.Region.Physics.OdePlugin private readonly HashSet _characters = new HashSet(); private readonly HashSet _prims = new HashSet(); private readonly HashSet _activeprims = new HashSet(); - private readonly HashSet _taintedPrimH = new HashSet(); + + /// + /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH + /// private readonly Object _taintedPrimLock = new Object(); + + /// + /// List of tainted prims. + /// + /// + /// A tainted prim is one that has taints to process before performing any other operations. The list is + /// cleared after processing. + /// private readonly List _taintedPrimL = new List(); + + /// + /// HashSet of tainted prims. + /// + /// + /// A tainted prim is one that has taints to process before performing any other operations. The hashset is + /// cleared after processing. + /// + private readonly HashSet _taintedPrimH = new HashSet(); + private readonly HashSet _taintedActors = new HashSet(); private readonly List _perloopContact = new List(); @@ -257,6 +278,9 @@ namespace OpenSim.Region.Physics.OdePlugin // split static geometry collision handling into spaces of 30 meters public IntPtr[,] staticPrimspace; + /// + /// Used to lock the entire physics scene. Locked during the main part of Simulate() + /// public Object OdeLock; public IMesher mesher; @@ -643,15 +667,15 @@ namespace OpenSim.Region.Physics.OdePlugin //while (d.SpaceLockQuery(space)) { } // Wait and do nothing } - /// - /// Debug space message for printing the space that a prim/avatar is in. - /// - /// - /// Returns which split up space the given position is in. - public string whichspaceamIin(Vector3 pos) - { - return calculateSpaceForGeom(pos).ToString(); - } +// /// +// /// Debug space message for printing the space that a prim/avatar is in. +// /// +// /// +// /// Returns which split up space the given position is in. +// public string whichspaceamIin(Vector3 pos) +// { +// return calculateSpaceForGeom(pos).ToString(); +// } #region Collision Detection @@ -1402,7 +1426,7 @@ namespace OpenSim.Region.Physics.OdePlugin // } } - public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) + private int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) { /* String name1 = null; String name2 = null; @@ -1421,7 +1445,7 @@ namespace OpenSim.Region.Physics.OdePlugin return 1; } - public int TriCallback(IntPtr trimesh, IntPtr refObject, int triangleIndex) + private int TriCallback(IntPtr trimesh, IntPtr refObject, int triangleIndex) { // String name1 = null; // String name2 = null; @@ -1552,7 +1576,7 @@ namespace OpenSim.Region.Physics.OdePlugin } // Recovered for use by fly height. Kitto Flora - public float GetTerrainHeightAtXY(float x, float y) + internal float GetTerrainHeightAtXY(float x, float y) { int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; @@ -1610,7 +1634,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// Add actor to the list that should receive collision events in the simulate loop. /// /// - public void AddCollisionEventReporting(PhysicsActor obj) + internal void AddCollisionEventReporting(PhysicsActor obj) { lock (_collisionEventPrim) { @@ -1623,7 +1647,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// Remove actor from the list that should receive collision events in the simulate loop. /// /// - public void RemoveCollisionEventReporting(PhysicsActor obj) + internal void RemoveCollisionEventReporting(PhysicsActor obj) { lock (_collisionEventPrim) { @@ -1647,7 +1671,13 @@ namespace OpenSim.Region.Physics.OdePlugin return newAv; } - public void AddCharacter(OdeCharacter chr) + public override void RemoveAvatar(PhysicsActor actor) + { + //m_log.Debug("[PHYSICS]:ODELOCK"); + ((OdeCharacter) actor).Destroy(); + } + + internal void AddCharacter(OdeCharacter chr) { lock (_characters) { @@ -1660,7 +1690,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public void RemoveCharacter(OdeCharacter chr) + internal void RemoveCharacter(OdeCharacter chr) { lock (_characters) { @@ -1671,7 +1701,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public void BadCharacter(OdeCharacter chr) + internal void BadCharacter(OdeCharacter chr) { lock (_badCharacter) { @@ -1680,12 +1710,6 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public override void RemoveAvatar(PhysicsActor actor) - { - //m_log.Debug("[PHYSICS]:ODELOCK"); - ((OdeCharacter) actor).Destroy(); - } - private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, PrimitiveBaseShape pbs, bool isphysical, uint localID) { @@ -1705,13 +1729,17 @@ namespace OpenSim.Region.Physics.OdePlugin return newPrim; } - public void addActivePrim(OdePrim activatePrim) + /// + /// Make this prim subject to physics. + /// + /// + internal void ActivatePrim(OdePrim prim) { // adds active prim.. (ones that should be iterated over in collisions_optimized lock (_activeprims) { - if (!_activeprims.Contains(activatePrim)) - _activeprims.Add(activatePrim); + if (!_activeprims.Contains(prim)) + _activeprims.Add(prim); //else // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); } @@ -2084,12 +2112,14 @@ namespace OpenSim.Region.Physics.OdePlugin return new Vector3(axis.X, axis.Y, axis.Z); } - public void remActivePrim(OdePrim deactivatePrim) + /// + /// Stop this prim being subject to physics + /// + /// + internal void DeactivatePrim(OdePrim prim) { lock (_activeprims) - { - _activeprims.Remove(deactivatePrim); - } + _activeprims.Remove(prim); } public override void RemovePrim(PhysicsActor prim) @@ -2121,7 +2151,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// that the space was using. /// /// - public void RemovePrimThreadLocked(OdePrim prim) + internal void RemovePrimThreadLocked(OdePrim prim) { //Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); lock (prim) @@ -2217,7 +2247,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// Takes a space pointer and zeros out the array we're using to hold the spaces /// /// - public void resetSpaceArrayItemToZero(IntPtr pSpace) + private void resetSpaceArrayItemToZero(IntPtr pSpace) { for (int x = 0; x < staticPrimspace.GetLength(0); x++) { @@ -2229,10 +2259,10 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public void resetSpaceArrayItemToZero(int arrayitemX, int arrayitemY) - { - staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero; - } +// private void resetSpaceArrayItemToZero(int arrayitemX, int arrayitemY) +// { +// staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero; +// } /// /// Called when a static prim moves. Allocates a space for the prim based on its position @@ -2241,7 +2271,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// the position that the geom moved to /// a pointer to the space it was in before it was moved. /// a pointer to the new space it's in - public IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace) + internal IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace) { // Called from setting the Position and Size of an ODEPrim so // it's already in locked space. @@ -2372,7 +2402,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// /// A pointer to the created space - public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) + internal IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) { // creating a new space for prim and inserting it into main space. staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); @@ -2388,7 +2418,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// /// a pointer to the space. This could be a new space or reused space. - public IntPtr calculateSpaceForGeom(Vector3 pos) + internal IntPtr calculateSpaceForGeom(Vector3 pos) { int[] xyspace = calculateSpaceArrayItemFromPos(pos); //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); @@ -2400,7 +2430,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// /// an array item based on the position - public int[] calculateSpaceArrayItemFromPos(Vector3 pos) + internal int[] calculateSpaceArrayItemFromPos(Vector3 pos) { int[] returnint = new int[2]; @@ -2427,7 +2457,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// /// - public bool needsMeshing(PrimitiveBaseShape pbs) + internal bool needsMeshing(PrimitiveBaseShape pbs) { // most of this is redundant now as the mesher will return null if it cant mesh a prim // but we still need to check for sculptie meshing being enabled so this is the most @@ -2705,7 +2735,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); else { // Console.WriteLine("Simulate calls ProcessTaints for {0}", prim.Name); - prim.ProcessTaints(timeStep); + prim.ProcessTaints(); } processedtaints = true; @@ -2910,7 +2940,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); /// /// Called by the main Simulate() loop if NINJA joints are active. Should not be called from anywhere else. /// - protected void SimulatePendingNINJAJoints() + private void SimulatePendingNINJAJoints() { // Create pending joints, if possible @@ -3101,7 +3131,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); /// Called as part of the Simulate() loop if NINJA physics is active. Must only be called from there. /// /// - protected void SimulateActorPendingJoints(OdePrim actor) + private void SimulateActorPendingJoints(OdePrim actor) { // If an actor moved, move its joint proxy objects as well. // There seems to be an event PhysicsActor.OnPositionUpdate that could be used @@ -3138,7 +3168,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); } #region ODE Specific Terrain Fixes - public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) + private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) { float[] returnarr = new float[262144]; float[,] resultarr = new float[(int)WorldExtents.X, (int)WorldExtents.Y]; @@ -3251,7 +3281,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); return returnarr; } - public float[] ResizeTerrain512Interpolation(float[] heightMap) + private float[] ResizeTerrain512Interpolation(float[] heightMap) { float[] returnarr = new float[262144]; float[,] resultarr = new float[512,512]; @@ -3419,7 +3449,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); } } - public void SetTerrain(float[] heightMap, Vector3 pOffset) + private void SetTerrain(float[] heightMap, Vector3 pOffset) { // this._heightmap[i] = (double)heightMap[i]; // dbm (danx0r) -- creating a buffer zone of one extra sample all around @@ -3548,7 +3578,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); { } - public float GetWaterLevel() + internal float GetWaterLevel() { return waterlevel; } @@ -3623,7 +3653,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); randomizeWater(waterlevel); } - public void randomizeWater(float baseheight) + private void randomizeWater(float baseheight) { const uint heightmapWidth = m_regionWidth + 2; const uint heightmapHeight = m_regionHeight + 2; @@ -3675,9 +3705,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); d.GeomSetRotation(WaterGeom, ref R); d.GeomSetPosition(WaterGeom, 128, 128, 0); - } - } public override void Dispose() @@ -3724,6 +3752,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); } } } + return returncolliders; } -- cgit v1.1