From 65c5efe43b68700bad94076d4cd421160203c5de Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 16 May 2008 01:22:11 +0000 Subject: Formatting cleanup. --- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 20 +- .../BulletXPlugin/TriangleIndexVertexArray.cs | 4 +- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 22 +- .../Region/Physics/Manager/PhysicsPluginManager.cs | 8 +- OpenSim/Region/Physics/Manager/PhysicsSensor.cs | 2 +- OpenSim/Region/Physics/Manager/ZeroMesher.cs | 4 +- OpenSim/Region/Physics/Meshing/HelperTypes.cs | 14 +- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 64 +++--- OpenSim/Region/Physics/Meshing/SimpleHull.cs | 2 +- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 62 +++--- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 226 ++++++++++----------- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 208 +++++++------------ OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 6 +- 13 files changed, 285 insertions(+), 357 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 9415fff..5ced2d1 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -282,9 +282,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin bool needsCollision;// = base.NeedsCollision(bodyA, bodyB); int c1 = 3; int c2 = 3; - + //////////////////////////////////////////////////////// - //BulletX Mesh Collisions + //BulletX Mesh Collisions //added by Jed zhu //data: May 07,2005 //////////////////////////////////////////////////////// @@ -302,9 +302,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin else needsCollision = base.NeedsCollision(bodyA, bodyB); - + #endregion - + //m_log.DebugFormat("[BulletX]: A collision was detected between {0} and {1} --> {2}", nameA, nameB, //needsCollision); @@ -705,7 +705,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } foreach (BulletXPrim prim in _prims.Values) { - //_height = HeightValue(prim.RigidBodyPosition); + //_height = HeightValue(prim.RigidBodyPosition); _height = _simFlatPlanet.HeightValue(prim.RigidBodyPosition); prim.ValidateHeight(_height); //if (_simFlatPlanet.heightIsNotValid(prim.RigidBodyPosition, out _height)) prim.ValidateHeight(_height); @@ -741,8 +741,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override bool IsThreaded { - get - { + get + { return (false); // for now we won't be multithreaded } } @@ -1380,17 +1380,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin /// public class BulletXPrim : BulletXActor { - //Density it will depends of material. + //Density it will depends of material. //For now all prims have the same density, all prims are made of water. Be water my friend! :D private const float _density = 1000.0f; private BulletXScene _parent_scene; private PhysicsVector m_prev_position = new PhysicsVector(0, 0, 0); private bool m_lastUpdateSent = false; - //added by jed zhu + //added by jed zhu private IMesh _mesh; public IMesh GetMesh() { return _mesh; } - + public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) diff --git a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs index 0902077..637cf6e 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs @@ -20,8 +20,8 @@ */ /* - This file contains a class TriangleIndexVertexArray. I tried using the class with the same name - from the BulletX implementation and found it unusable for the purpose of using triangle meshes + This file contains a class TriangleIndexVertexArray. I tried using the class with the same name + from the BulletX implementation and found it unusable for the purpose of using triangle meshes within BulletX as the implementation was painfully incomplete. The attempt to derive from the original class failed as viable members were hidden. Fiddling around with BulletX itself was not my intention. diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index c1dc91b..3cf2646 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -140,7 +140,7 @@ namespace OpenSim.Region.Physics.Manager // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. RequestTerseUpdate handler = OnRequestTerseUpdate; - + if (handler != null) { handler(); @@ -163,9 +163,9 @@ namespace OpenSim.Region.Physics.Manager public virtual void SendCollisionUpdate(EventArgs e) { CollisionUpdate handler = OnCollisionUpdate; - + if (handler != null) - { + { handler(e); } } @@ -205,9 +205,9 @@ namespace OpenSim.Region.Physics.Manager public class NullPhysicsActor : PhysicsActor { - public override bool Stopped - { - get{ return false; } + public override bool Stopped + { + get{ return false; } } public override PhysicsVector Position @@ -222,7 +222,7 @@ namespace OpenSim.Region.Physics.Manager set { return; } } - public override uint LocalID + public override uint LocalID { set { return; } } @@ -240,14 +240,14 @@ namespace OpenSim.Region.Physics.Manager public override float Buoyancy { get { return 0f; } - set { return; } + set { return; } } public override bool FloatOnWater { set { return; } } - + public override bool CollidingGround { get { return false; } @@ -297,7 +297,7 @@ namespace OpenSim.Region.Physics.Manager set { return; } } - public override float CollisionScore + public override float CollisionScore { get { return 0f; } } @@ -385,7 +385,7 @@ namespace OpenSim.Region.Physics.Manager public override void SubscribeEvents(int ms) { - + } public override void UnSubscribeEvents() { diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index b8ca180..6a71581 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.Physics.Manager _MeshPlugins.Add(plugHard.GetName(), plugHard); m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); - // And now walk all assemblies (DLLs effectively) and see if they are home + // And now walk all assemblies (DLLs effectively) and see if they are home // of a plugin that is of interest for us string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); string[] pluginFiles = Directory.GetFiles(path, "*.dll"); @@ -108,11 +108,11 @@ namespace OpenSim.Region.Physics.Manager private void AddPlugin(string FileName) { // TODO / NOTE - // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from + // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll' // using the LoadFrom context. The use of this context can result in unexpected behavior - // for serialization, casting and dependency resolution. In almost all cases, it is recommended - // that the LoadFrom context be avoided. This can be done by installing assemblies in the + // for serialization, casting and dependency resolution. In almost all cases, it is recommended + // that the LoadFrom context be avoided. This can be done by installing assemblies in the // Global Assembly Cache or in the ApplicationBase directory and using Assembly. // Load when explicitly loading assemblies. Assembly pluginAssembly = Assembly.LoadFrom(FileName); diff --git a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs b/OpenSim/Region/Physics/Manager/PhysicsSensor.cs index ce53108..add741b 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsSensor.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Physics.Manager { NONE = 0, AGENT = 1, - ACTIVE = 2, + ACTIVE = 2, PASSIVE = 3, SCRIPTED = 4 } diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs index b98cb35..b759213 100644 --- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs +++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs @@ -31,9 +31,9 @@ using OpenSim.Framework; /* * This is the zero mesher. * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer. - * Effectivly this is for switching off meshing and for testing as each physics machine should deal + * Effectivly this is for switching off meshing and for testing as each physics machine should deal * with the null pointer situation. - * But it's also a convenience thing, as physics machines can rely on having a mesher in any situation, even + * But it's also a convenience thing, as physics machines can rely on having a mesher in any situation, even * if it's a dump one like this. * Note, that this mesher is *not* living in a module but in the manager itself, so * it's always availabe and thus the default in case of configuration errors diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs index efc5968..584133c 100644 --- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs +++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs @@ -49,7 +49,7 @@ public class Quaternion } public Quaternion(Vertex axis, float angle) { - // using (* 0.5) instead of (/2) + // using (* 0.5) instead of (/2) w = (float)Math.Cos(angle * 0.5f); x = axis.X * (float)Math.Sin(angle * 0.5f); y = axis.Y * (float)Math.Sin(angle * 0.5f); @@ -65,8 +65,8 @@ public class Quaternion c.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z; return c; } - - + + public Matrix4 computeMatrix() { return new Matrix4(this); @@ -74,7 +74,7 @@ public class Quaternion public void normalize() { float mag = length(); - + w /= mag; x /= mag; y /= mag; @@ -367,7 +367,7 @@ public class Triangle // It is assumed, that the triangles vertices are already set correctly double p1x, p2x, p1y, p2y, p3x, p3y; - // Deviation of this routine: + // Deviation of this routine: // A circle has the general equation (M-p)^2=r^2, where M and p are vectors // this gives us three equations f(p)=r^2, each for one point p1, p2, p3 // putting respectively two equations together gives two equations @@ -378,7 +378,7 @@ public class Triangle // Now using the equations that are formed by the components of the vectors // and isolate Mx lets you make one equation that only holds My // The rest is straight forward and eaasy :-) - // + // /* helping variables for temporary results */ double c1, c2; @@ -496,7 +496,7 @@ public class Triangle v2 = vt; } - // Dumps a triangle in the "raw faces" format, blender can import. This is for visualisation and + // Dumps a triangle in the "raw faces" format, blender can import. This is for visualisation and // debugging purposes public String ToStringRaw() { diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 2e7ec15..4bf12c9 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -115,7 +115,7 @@ namespace OpenSim.Region.Physics.Meshing for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++) { // Background: A triangle mesh fulfills the delaunay condition if (iff!) - // each circumlocutory circle (i.e. the circle that touches all three corners) + // each circumlocutory circle (i.e. the circle that touches all three corners) // of each triangle is empty of other vertices. // Obviously a single (seeding) triangle fulfills this condition. // If we now add one vertex, we need to reconstruct all triangles, that @@ -132,7 +132,7 @@ namespace OpenSim.Region.Physics.Meshing // Reconstruction phase. First step, dissolve each triangle into it's simplices, // i.e. it's "border lines" // Goal is to find "inner" borders and delete them, while the hull gets conserved. - // Inner borders are special in the way that they always come twice, which is how we detect them + // Inner borders are special in the way that they always come twice, which is how we detect them foreach (Triangle t in influencedTriangles) { List newSimplices = t.GetSimplices(); @@ -142,8 +142,8 @@ namespace OpenSim.Region.Physics.Meshing // Now sort the simplices. That will make identical ones reside side by side in the list simplices.Sort(); - // Look for duplicate simplices here. - // Remember, they are directly side by side in the list right now, + // Look for duplicate simplices here. + // Remember, they are directly side by side in the list right now, // So we only check directly neighbours int iSimplex; List innerSimplices = new List(); @@ -162,7 +162,7 @@ namespace OpenSim.Region.Physics.Meshing } // each simplex still in the list belongs to the hull of the region in question - // The new vertex (yes, we still deal with verices here :-)) forms a triangle + // The new vertex (yes, we still deal with verices here :-)) forms a triangle // with each of these simplices. Build the new triangles and add them to the list foreach (Simplex s in simplices) { @@ -206,14 +206,14 @@ namespace OpenSim.Region.Physics.Meshing } break; - + default: if (hshape == HollowShape.Same) hshape= HollowShape.Square; break; } - + SimpleHull holeHull = null; if (hshape == HollowShape.Square) @@ -428,13 +428,13 @@ namespace OpenSim.Region.Physics.Meshing UInt16 pathShearY = primShape.PathShearY; Int16 twistTop = primShape.PathTwistBegin; Int16 twistBot = primShape.PathTwist; - + //m_log.Error("pathShear:" + primShape.PathShearX.ToString() + "," + primShape.PathShearY.ToString()); //m_log.Error("pathTaper:" + primShape.PathTaperX.ToString() + "," + primShape.PathTaperY.ToString()); //m_log.Error("ProfileBegin:" + primShape.ProfileBegin.ToString() + "," + primShape.ProfileBegin.ToString()); //m_log.Error("PathScale:" + primShape.PathScaleX.ToString() + "," + primShape.PathScaleY.ToString()); - + // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface // of a block are basically the same // They may be warped differently but the shape is identical @@ -469,7 +469,7 @@ namespace OpenSim.Region.Physics.Meshing if (fProfileBeginAngle < fProfileEndAngle) fProfileEndAngle -= 360.0; - // Note, that we don't want to cut out a triangle, even if this is a + // Note, that we don't want to cut out a triangle, even if this is a // good approximation for small cuts. Indeed we want to cut out an arc // and we approximate this arc by a polygon chain // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space @@ -559,7 +559,7 @@ namespace OpenSim.Region.Physics.Meshing extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100); //m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString()); } - + } if (taperY != 100) @@ -575,8 +575,8 @@ namespace OpenSim.Region.Physics.Meshing //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString()); } } - - + + if (pathShearX != 0) { if (pathShearX > 50) @@ -585,7 +585,7 @@ namespace OpenSim.Region.Physics.Meshing extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); // m_log.Warn("pushX: " + extr.pushX); } - else + else { extr.pushX = (float)pathShearX / 100; // m_log.Warn("pushX: " + extr.pushX); @@ -600,7 +600,7 @@ namespace OpenSim.Region.Physics.Meshing extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); //m_log.Warn("pushY: " + extr.pushY); } - else + else { extr.pushY = (float)pathShearY / 100; //m_log.Warn("pushY: " + extr.pushY); @@ -615,7 +615,7 @@ namespace OpenSim.Region.Physics.Meshing extr.twistTop = 360 - (-1 * extr.twistTop); } - + extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); } @@ -660,7 +660,7 @@ namespace OpenSim.Region.Physics.Meshing UInt16 pathShearY = primShape.PathShearY; Int16 twistBot = primShape.PathTwist; Int16 twistTop = primShape.PathTwistBegin; - + // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface // of a block are basically the same @@ -715,7 +715,7 @@ namespace OpenSim.Region.Physics.Meshing //Vertex Q1Q12 = new Vertex(-0.46f, -0.18f, 0.0f); //Vertex Q1Q13 = new Vertex(-0.43f, -0.24f, 0.0f); //Vertex Q1Q14 = new Vertex(-0.40f, -0.30f, 0.0f); - + SimpleHull outerHull = new SimpleHull(); //Clockwise around the quadrants //outerHull.AddVertex(Q1Q15); @@ -803,7 +803,7 @@ namespace OpenSim.Region.Physics.Meshing if (fProfileBeginAngle < fProfileEndAngle) fProfileEndAngle -= 360.0; - // Note, that we don't want to cut out a triangle, even if this is a + // Note, that we don't want to cut out a triangle, even if this is a // good approximation for small cuts. Indeed we want to cut out an arc // and we approximate this arc by a polygon chain // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space @@ -940,7 +940,7 @@ namespace OpenSim.Region.Physics.Meshing extr.pushY = (float)pathShearY / 100; //m_log.Warn("pushY: " + extr.pushY); } - + } if (twistTop != 0) @@ -949,9 +949,9 @@ namespace OpenSim.Region.Physics.Meshing if (extr.twistTop > 0) { extr.twistTop = 360 - (-1 * extr.twistTop); - + } - + extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); } @@ -967,7 +967,7 @@ namespace OpenSim.Region.Physics.Meshing } extr.twistMid = (float)(extr.twistMid * DEG_TO_RAD); } - + if (twistBot != 0) { extr.twistBot = 180 * ((float)twistBot / 100); @@ -1013,7 +1013,7 @@ namespace OpenSim.Region.Physics.Meshing Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f); Vertex PM = new Vertex(+0.5f, 0f, 0.0f); Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f); - + SimpleHull outerHull = new SimpleHull(); //outerHull.AddVertex(MM); @@ -1022,7 +1022,7 @@ namespace OpenSim.Region.Physics.Meshing outerHull.AddVertex(PP); outerHull.AddVertex(MM); outerHull.AddVertex(PM); - + // Deal with cuts now if ((profileBegin != 0) || (profileEnd != 0)) { @@ -1034,7 +1034,7 @@ namespace OpenSim.Region.Physics.Meshing if (fProfileBeginAngle < fProfileEndAngle) fProfileEndAngle -= 360.0; - // Note, that we don't want to cut out a triangle, even if this is a + // Note, that we don't want to cut out a triangle, even if this is a // good approximation for small cuts. Indeed we want to cut out an arc // and we approximate this arc by a polygon chain // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space @@ -1177,7 +1177,7 @@ namespace OpenSim.Region.Physics.Meshing extr.twistTop = 360 - (-1 * extr.twistTop); } - + extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); } @@ -1255,7 +1255,7 @@ namespace OpenSim.Region.Physics.Meshing // Base Faces of the Icosahedron (20) - SphereLODTriangle(v1, v2, v3, diameter, LOD, m); + SphereLODTriangle(v1, v2, v3, diameter, LOD, m); SphereLODTriangle(v4, v3, v2, diameter, LOD, m); SphereLODTriangle(v4, v5, v6, diameter, LOD, m); SphereLODTriangle(v4, v9, v5, diameter, LOD, m); @@ -1284,7 +1284,7 @@ namespace OpenSim.Region.Physics.Meshing v.Z *= size.Z; } - // This was built with the normals pointing inside.. + // This was built with the normals pointing inside.. // therefore we have to invert the normals foreach (Triangle t in m.triangles) { @@ -1308,7 +1308,7 @@ namespace OpenSim.Region.Physics.Meshing v.Y *= size.Y; v.Z *= size.Z; } - // This was built with the normals pointing inside.. + // This was built with the normals pointing inside.. // therefore we have to invert the normals foreach (Triangle t in sm.triangles) { @@ -1462,7 +1462,7 @@ namespace OpenSim.Region.Physics.Meshing default: mesh = CreateBoxMesh(primName, primShape, size); CalcNormals(mesh); - //Set default mesh to cube otherwise it'll return + //Set default mesh to cube otherwise it'll return // null and crash on the 'setMesh' method in the physics plugins. //mesh = null; break; @@ -1472,6 +1472,6 @@ namespace OpenSim.Region.Physics.Meshing return mesh; } - + } } diff --git a/OpenSim/Region/Physics/Meshing/SimpleHull.cs b/OpenSim/Region/Physics/Meshing/SimpleHull.cs index 2896d3b..5eeadae 100644 --- a/OpenSim/Region/Physics/Meshing/SimpleHull.cs +++ b/OpenSim/Region/Physics/Meshing/SimpleHull.cs @@ -337,7 +337,7 @@ namespace OpenSim.Region.Physics.Meshing } - if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition. + if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition. // In otherwords, subtractHull completely embraces baseHull { return result; diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 4165484..5024b5d 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -36,7 +36,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. /// - + public enum dParam : int { LowStop = 0, @@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.OdePlugin private CollisionCategories m_collisionFlags = (CollisionCategories.Geom | CollisionCategories.Space | CollisionCategories.Body - | CollisionCategories.Character + | CollisionCategories.Character | CollisionCategories.Land); public IntPtr Body; private OdeScene _parent_scene; @@ -145,7 +145,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_colliderarr[i] = false; } - CAPSULE_LENGTH = (size.Z - ((size.Z * height_fudge_factor))); + CAPSULE_LENGTH = (size.Z - ((size.Z * height_fudge_factor))); lock (OdeScene.OdeLock) { @@ -338,7 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin } /// - /// turn the PID controller on or off. + /// turn the PID controller on or off. /// The PID Controller will turn on all by itself in many situations /// /// @@ -354,7 +354,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// This 'puts' an avatar somewhere in the physics space. - /// Not really a good choice unless you 'know' it's a good + /// Not really a good choice unless you 'know' it's a good /// spot otherwise you're likely to orbit the avatar. /// public override PhysicsVector Position @@ -389,7 +389,7 @@ namespace OpenSim.Region.Physics.OdePlugin lock (OdeScene.OdeLock) { d.JointDestroy(Amotor); - + PhysicsVector SetSize = value; float prevCapsule = CAPSULE_LENGTH; float capsuleradius = CAPSULE_RADIUS; @@ -405,7 +405,7 @@ namespace OpenSim.Region.Physics.OdePlugin AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); Velocity = new PhysicsVector(0f, 0f, 0f); - + } _parent_scene.geom_name_map[Shell] = m_name; _parent_scene.actor_name_map[Shell] = (PhysicsActor) this; @@ -423,7 +423,7 @@ namespace OpenSim.Region.Physics.OdePlugin int dAMotorEuler = 1; _parent_scene.waitForSpaceUnlock(_parent_scene.space); Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); - + d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); d.GeomSetCollideBits(Shell, (int)m_collisionFlags); @@ -442,8 +442,8 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetBody(Shell, Body); - - // The purpose of the AMotor here is to keep the avatar's physical + + // The purpose of the AMotor here is to keep the avatar's physical // surrogate from rotating while moving Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); d.JointAttach(Amotor, Body, IntPtr.Zero); @@ -455,7 +455,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointSetAMotorAngle(Amotor, 0, 0); d.JointSetAMotorAngle(Amotor, 1, 0); d.JointSetAMotorAngle(Amotor, 2, 0); - + // These lowstops and high stops are effectively (no wiggle room) d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); @@ -464,23 +464,23 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); - // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the + // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the // capped cyllinder will fall over d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor); - + //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); //d.QfromR( //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068, - // + // //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); //standupStraight(); - - - + + + } - // + // /// /// Uses the capped cyllinder volume formula to calculate the avatar's mass. /// This may be used in calculations in the scene/scenepresence @@ -508,13 +508,13 @@ namespace OpenSim.Region.Physics.OdePlugin } -// This code is very useful. Written by DanX0r. We're just not using it right now. +// This code is very useful. Written by DanX0r. We're just not using it right now. // Commented out to prevent a warning. // // private void standupStraight() // { // // The purpose of this routine here is to quickly stabilize the Body while it's popped up in the air. -// // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you +// // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you // // change appearance and when you enter the simulator // // After this routine is done, the amotor stabilizes much quicker // d.Vector3 feet; @@ -558,7 +558,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (_zeroFlag) return new PhysicsVector(0f, 0f, 0f); m_lastUpdateSent = false; - return _velocity; + return _velocity; } set { @@ -601,7 +601,7 @@ namespace OpenSim.Region.Physics.OdePlugin } /// - /// Adds the force supplied to the Target Velocity + /// Adds the force supplied to the Target Velocity /// The PID controller takes this target velocity and tries to make it a reality /// /// @@ -616,7 +616,7 @@ namespace OpenSim.Region.Physics.OdePlugin // _target_velocity.Y += force.Y; //_target_velocity.Z += force.Z; } - else + else { m_pidControllerActive = true; _target_velocity.X += force.X; @@ -637,7 +637,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyAddForce(Body, force.X, force.Y, force.Z); //d.BodySetRotation(Body, ref m_StandUpRotation); //standupStraight(); - + } } @@ -655,16 +655,16 @@ namespace OpenSim.Region.Physics.OdePlugin { // no lock; for now it's only called from within Simulate() - // If the PID Controller isn't active then we set our force + // If the PID Controller isn't active then we set our force // calculating base velocity to the current position - + if (m_pidControllerActive == false) { _zeroPosition = d.BodyGetPosition(Body); } //PidStatus = true; - + PhysicsVector vec = new PhysicsVector(); d.Vector3 vel = d.BodyGetLinearVel(Body); float movementdivisor = 1f; @@ -798,13 +798,13 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.X = 0.0f; _velocity.Y = 0.0f; _velocity.Z = 0.0f; - + // Did we send out the 'stopped' message? if (!m_lastUpdateSent) { m_lastUpdateSent = true; //base.RequestPhysicsterseUpdate(); - + } } else @@ -815,7 +815,7 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.Y = (vec.Y); _velocity.Z = (vec.Z); - + if (_velocity.Z < -6 && !m_hackSentFall) { m_hackSentFall = true; @@ -849,7 +849,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomDestroy(Shell); _parent_scene.geom_name_map.Remove(Shell); - + //kill the body d.BodyDestroy(Body); } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 37a8b77..f1886e4 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -111,7 +111,7 @@ namespace OpenSim.Region.Physics.OdePlugin private IntPtr _linkJointGroup = (IntPtr)0; private PhysicsActor _parent = null; private PhysicsActor m_taintparent = null; - + private bool iscolliding = false; private bool m_isphysical = false; private bool m_isSelected = false; @@ -202,7 +202,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintadd = true; _parent_scene.AddPhysicsActorTaint(this); // don't do .add() here; old geoms get recycled with the same hash - + } public override int PhysicsActorType @@ -232,9 +232,9 @@ namespace OpenSim.Region.Physics.OdePlugin public override bool Selected { set { - // This only makes the object not collidable if the object + // This only makes the object not collidable if the object // is physical or the object is modified somehow *IN THE FUTURE* - // without this, if an avatar selects prim, they can walk right + // without this, if an avatar selects prim, they can walk right // through it while it's selected if ((m_isphysical && !_zeroFlag) || !value) @@ -262,7 +262,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); } //m_log.Warn("Setting Geom to: " + prim_geom); - + } public void enableBodySoft() @@ -277,7 +277,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void disableBodySoft() { m_disabled = true; - + if (m_isphysical) if (Body != (IntPtr)0) d.BodyDisable(Body); @@ -307,7 +307,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetAutoDisableFlag(Body, true); d.BodySetAutoDisableSteps(Body, 20); - + m_interpenetrationcount = 0; m_collisionscore = 0; m_disabled = false; @@ -327,7 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin { float volume = 0; - // No material is passed to the physics engines yet.. soo.. + // No material is passed to the physics engines yet.. soo.. // we're using the m_density constant in the class definition @@ -340,7 +340,7 @@ namespace OpenSim.Region.Physics.OdePlugin volume = _size.X*_size.Y*_size.Z; - // If the user has 'hollowed out' + // If the user has 'hollowed out' // ProfileHollow is one of those 0 to 50000 values :P // we like percentages better.. so turning into a percentage @@ -415,7 +415,7 @@ namespace OpenSim.Region.Physics.OdePlugin // We don't know what the shape is yet, so use default volume = _size.X * _size.Y * _size.Z; } - // If the user has 'hollowed out' + // If the user has 'hollowed out' // ProfileHollow is one of those 0 to 50000 values :P // we like percentages better.. so turning into a percentage @@ -427,8 +427,8 @@ namespace OpenSim.Region.Physics.OdePlugin float hollowVolume = 0; switch (_pbs.HollowShape) { - - case HollowShape.Same: + + case HollowShape.Same: case HollowShape.Circle: // Hollow shape is a perfect cyllinder in respect to the cube's scale // Cyllinder hollow volume calculation @@ -447,7 +447,7 @@ namespace OpenSim.Region.Physics.OdePlugin hollowVolume = hollowsizex * hollowsizey * hollowsizez; break; - + case HollowShape.Triangle: // Equilateral Triangular Prism volume hollow calculation @@ -465,7 +465,7 @@ namespace OpenSim.Region.Physics.OdePlugin volume = volume - hollowVolume; } break; - + case ProfileShape.HalfCircle: if (_pbs.PathCurve == (byte)Extrusion.Curve1) { @@ -490,13 +490,13 @@ namespace OpenSim.Region.Physics.OdePlugin } break; case ProfileShape.EquilateralTriangle: - /* + /* v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h - + // seed mesh Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f); Vertex PM = new Vertex(+0.5f, 0f, 0.0f); - Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f); + Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f); */ float xA = -0.25f * _size.X; float yA = -0.45f * _size.Y; @@ -509,7 +509,7 @@ namespace OpenSim.Region.Physics.OdePlugin volume = (float)((Math.Abs((xB * yA - xA * yB) + (xC * yB - xB * yC) + (xA * yC - xC * yA)) / 2) * _size.Z); - // If the user has 'hollowed out' + // If the user has 'hollowed out' // ProfileHollow is one of those 0 to 50000 values :P // we like percentages better.. so turning into a percentage float fhollowFactor = ((float)_pbs.ProfileHollow / 1.9f); @@ -521,7 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin float hollowVolume = 0; switch (_pbs.HollowShape) { - + case HollowShape.Same: case HollowShape.Triangle: // Equilateral Triangular Prism volume hollow calculation @@ -550,7 +550,7 @@ namespace OpenSim.Region.Physics.OdePlugin hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount); break; - + default: hollowVolume = 0; break; @@ -560,7 +560,7 @@ namespace OpenSim.Region.Physics.OdePlugin break; default: - // we don't have all of the volume formulas yet so + // we don't have all of the volume formulas yet so // use the common volume formula for all volume = _size.X*_size.Y*_size.Z; break; @@ -568,7 +568,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Calculate Path cut effect on volume // Not exact, in the triangle hollow example - // They should never be zero or less then zero.. + // They should never be zero or less then zero.. // we'll ignore it if it's less then zero // ProfileEnd and ProfileBegin are values @@ -672,11 +672,11 @@ namespace OpenSim.Region.Physics.OdePlugin public void setMesh(OdeScene parent_scene, IMesh mesh) { - // This sleeper is there to moderate how long it takes between + // This sleeper is there to moderate how long it takes between // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object - + Thread.Sleep(10); - + //Kill Body so that mesh can re-make the geom if (IsPhysical && Body != (IntPtr) 0) { @@ -694,9 +694,9 @@ namespace OpenSim.Region.Physics.OdePlugin 3*sizeof (int)); d.GeomTriMeshDataPreprocess(_triMeshData); - + _parent_scene.waitForSpaceUnlock(m_targetSpace); - + try { if (prim_geom == (IntPtr)0) @@ -706,7 +706,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (AccessViolationException) { - + m_log.Error("[PHYSICS]: MESH LOCKED"); return; } @@ -715,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Recreate the body m_interpenetrationcount = 0; m_collisionscore = 0; - + enableBody(); } @@ -724,7 +724,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void ProcessTaints(float timestep) { - + if (m_taintadd) { changeadd(timestep); @@ -779,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin } private void changeAngularLock(float timestep) - { + { // do we have a Physical object? if (Body != IntPtr.Zero) { @@ -809,7 +809,7 @@ namespace OpenSim.Region.Physics.OdePlugin private void changelink(float timestep) { - + if (_parent == null && m_taintparent != null) { if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) @@ -834,14 +834,14 @@ namespace OpenSim.Region.Physics.OdePlugin m_linkJoint = (IntPtr)0; } - + _parent = m_taintparent; } private void changeSelectedStatus(float timestep) { - + if (m_taintselected) { @@ -849,9 +849,9 @@ namespace OpenSim.Region.Physics.OdePlugin m_collisionCategories = CollisionCategories.Selected; m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space); - // We do the body disable soft twice because 'in theory' a collision could have happened + // We do the body disable soft twice because 'in theory' a collision could have happened // in between the disabling and the collision properties setting - // which would wake the physical body up from a soft disabling and potentially cause it to fall + // which would wake the physical body up from a soft disabling and potentially cause it to fall // through the ground. if (m_isphysical) @@ -873,9 +873,9 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - + m_collisionCategories = CollisionCategories.Geom; - + if (m_isphysical) m_collisionCategories |= CollisionCategories.Body; @@ -898,10 +898,10 @@ namespace OpenSim.Region.Physics.OdePlugin enableBodySoft(); } - + } - + resetCollisionAccounting(); m_isSelected = m_taintselected; } @@ -918,21 +918,21 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintselected = m_isSelected; m_taintsize = _size; - + m_taintshape = false; m_taintforce = false; - + m_taintdisable = false; m_taintVelocity = PhysicsVector.Zero; } public void changeadd(float timestep) { - - - + + + int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); @@ -941,7 +941,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_targetSpace = targetspace; - + if (_mesh != null) { @@ -1010,7 +1010,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); ode.dunlock(_parent_scene.world); - return; + return; } } } @@ -1060,7 +1060,7 @@ namespace OpenSim.Region.Physics.OdePlugin } - + _parent_scene.geom_name_map[prim_geom] = this.m_primName; _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; @@ -1072,7 +1072,7 @@ namespace OpenSim.Region.Physics.OdePlugin } public void changemove(float timestep) { - + if (m_isphysical) @@ -1080,7 +1080,7 @@ namespace OpenSim.Region.Physics.OdePlugin // This is a fallback.. May no longer be necessary. if (Body == (IntPtr) 0) enableBody(); - //Prim auto disable after 20 frames, + //Prim auto disable after 20 frames, //if you move it, re-enable the prim manually. if (_parent != null) { @@ -1102,7 +1102,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } d.BodyEnable(Body); - + } else { @@ -1122,10 +1122,10 @@ namespace OpenSim.Region.Physics.OdePlugin d.SpaceAdd(m_targetSpace, prim_geom); } } - + changeSelectedStatus(timestep); - + resetCollisionAccounting(); m_taintposition = _position; } @@ -1140,42 +1140,42 @@ namespace OpenSim.Region.Physics.OdePlugin { float PID_D = 2200.0f; //float PID_P = 900.0f; - - + + float m_mass = CalculateMass(); - + fz = 0f; //m_log.Info(m_collisionFlags.ToString()); - + if (m_buoyancy != 0) { - + if (m_buoyancy > 0) { fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass); - + //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); } - else + else { fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass)); } - + } if (m_usePID) { - // If we're using the PID controller, then we have no gravity + // If we're using the PID controller, then we have no gravity fz = (-1 * _parent_scene.gravityz) * this.Mass; // no lock; for now it's only called from within Simulate() - // If the PID Controller isn't active then we set our force + // If the PID Controller isn't active then we set our force // calculating base velocity to the current position if (Environment.OSVersion.Platform == PlatformID.Unix) { @@ -1189,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin } PID_D = 35f; - + //PID_P = 1.0f; float PID_G = 25; @@ -1197,7 +1197,7 @@ namespace OpenSim.Region.Physics.OdePlugin { PID_G = PID_G / m_PIDTau; } - + if ((PID_G - m_PIDTau) <= 0) { @@ -1205,15 +1205,15 @@ namespace OpenSim.Region.Physics.OdePlugin } //PidStatus = true; - + PhysicsVector vec = new PhysicsVector(); d.Vector3 vel = d.BodyGetLinearVel(Body); - + d.Vector3 pos = d.BodyGetPosition(Body); - _target_velocity = + _target_velocity = new PhysicsVector( (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), @@ -1222,18 +1222,18 @@ namespace OpenSim.Region.Physics.OdePlugin // if velocity is zero, use position control; otherwise, velocity control - + if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f)) { // keep track of where we stopped. No more slippin' & slidin' - - + + // We only want to deactivate the PID Controller if we think we want to have our surrogate // react to the physics scene by moving it's position. // Avatar to Avatar collisions // Prim to avatar collisions - + //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2); //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2); //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P; @@ -1245,27 +1245,27 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - + _zeroFlag = false; - + // We're flying and colliding with something fx = ((_target_velocity.X) - vel.X) * (PID_D); fy = ((_target_velocity.Y) - vel.Y) * (PID_D); - - - + + + // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); } - } + } fx *= m_mass; fy *= m_mass; //fz *= m_mass; - + //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString()); if (fx != 0 || fy != 0 || fz != 0) { @@ -1285,7 +1285,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void rotate(float timestep) { - + d.Quaternion myrot = new d.Quaternion(); myrot.W = _orientation.w; @@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) createAMotor(m_angularlock); } - + resetCollisionAccounting(); m_taintrot = _orientation; } @@ -1313,21 +1313,21 @@ namespace OpenSim.Region.Physics.OdePlugin public void changedisable(float timestep) { - + m_disabled = true; if (Body != (IntPtr)0) { d.BodyDisable(Body); Body = (IntPtr)0; } - + m_taintdisable = false; } public void changePhysicsStatus(float timestep) { - + if (m_isphysical == true) { @@ -1352,7 +1352,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void changesize(float timestamp) { - + //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) //{ // m_taintsize = _size; @@ -1369,7 +1369,7 @@ namespace OpenSim.Region.Physics.OdePlugin { // Cleanup meshing here } - //kill body to rebuild + //kill body to rebuild if (IsPhysical && Body != (IntPtr) 0) { disableBody(); @@ -1531,7 +1531,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_collisionFlags |= CollisionCategories.Water; } - else + else { m_collisionFlags &= ~CollisionCategories.Water; } @@ -1541,7 +1541,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void changeshape(float timestamp) { - + string oldname = _parent_scene.geom_name_map[prim_geom]; // Cleanup of old prim geometry and Bodies @@ -1579,7 +1579,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Re creates body on size. // EnableBody also does setMass() enableBody(); - + } } else @@ -1684,7 +1684,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyEnable(Body); } } - + _parent_scene.geom_name_map[prim_geom] = oldname; @@ -1698,7 +1698,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (!m_isSelected) { - + lock (m_forcelist) @@ -1728,7 +1728,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (!m_isSelected) { - + Thread.Sleep(20); if (IsPhysical) @@ -1737,8 +1737,8 @@ namespace OpenSim.Region.Physics.OdePlugin { d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); } - } - + } + //resetCollisionAccounting(); } m_taintVelocity = PhysicsVector.Zero; @@ -1794,7 +1794,7 @@ namespace OpenSim.Region.Physics.OdePlugin { get { return _position; } - set { _position = value; + set { _position = value; //m_log.Info("[PHYSICS]: " + _position.ToString()); } } @@ -1838,7 +1838,7 @@ namespace OpenSim.Region.Physics.OdePlugin { get { - // Averate previous velocity with the new one so + // Averate previous velocity with the new one so // client object interpolation works a 'little' better PhysicsVector returnVelocity = new PhysicsVector(); returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; @@ -1849,7 +1849,7 @@ namespace OpenSim.Region.Physics.OdePlugin set { _velocity = value; - + m_taintVelocity = value; _parent_scene.AddPhysicsActorTaint(this); } @@ -1898,11 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin if (_zeroFlag) return pv; m_lastUpdateSent = false; - + if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) return pv; - return m_rotationalVelocity; + return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } @@ -1948,7 +1948,7 @@ namespace OpenSim.Region.Physics.OdePlugin } public void UpdatePositionAndVelocity() - { + { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! if (_parent != null) { @@ -1963,7 +1963,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.Quaternion ori = d.BodyGetQuaternion(Body); d.Vector3 vel = d.BodyGetLinearVel(Body); d.Vector3 rotvel = d.BodyGetAngularVel(Body); - + PhysicsVector l_position = new PhysicsVector(); // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) @@ -2000,16 +2000,16 @@ namespace OpenSim.Region.Physics.OdePlugin if (l_position.Z < 0) { - // This is so prim that get lost underground don't fall forever and suck up - // + // This is so prim that get lost underground don't fall forever and suck up + // // Sim resources and memory. - // Disables the prim's movement physics.... + // Disables the prim's movement physics.... // It's a hack and will generate a console message if it fails. //IsPhysical = false; if (_parent == null) base.RaiseOutOfBounds(_position); - + _acceleration.X = 0; _acceleration.Y = 0; _acceleration.Z = 0; @@ -2020,10 +2020,10 @@ namespace OpenSim.Region.Physics.OdePlugin m_rotationalVelocity.X = 0; m_rotationalVelocity.Y = 0; m_rotationalVelocity.Z = 0; - + if (_parent == null) base.RequestPhysicsterseUpdate(); - + m_throttleUpdates = false; throttleCounter = 0; _zeroFlag = true; @@ -2065,10 +2065,10 @@ namespace OpenSim.Region.Physics.OdePlugin m_throttleUpdates = false; throttleCounter = 0; m_rotationalVelocity = pv; - + if (_parent == null) base.RequestPhysicsterseUpdate(); - + m_lastUpdateSent = true; } } @@ -2087,11 +2087,11 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.X = vel.X; _velocity.Y = vel.Y; _velocity.Z = vel.Z; - + _acceleration = ((_velocity - m_lastVelocity) / 0.1f); _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); - + if (_velocity.IsIdentical(pv, 0.5f)) { m_rotationalVelocity = pv; @@ -2173,7 +2173,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_tensor = 5f; } - + float axisnum = 3; axisnum = (axisnum - (axis.X + axis.Y + axis.Z)); @@ -2222,7 +2222,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); - + d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor); } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index d795e45..c663fb0 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -42,7 +42,7 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.OdePlugin { /// - /// ODE plugin + /// ODE plugin /// public class OdePlugin : IPhysicsPlugin { @@ -51,7 +51,6 @@ namespace OpenSim.Region.Physics.OdePlugin private CollisionLocker ode; private OdeScene _mScene; - public OdePlugin() { ode = new CollisionLocker(); @@ -81,15 +80,13 @@ namespace OpenSim.Region.Physics.OdePlugin } } - - public enum StatusIndicators : int + public enum StatusIndicators : int { Generic = 0, Start = 1, End = 2 } - public struct sCollisionData { public uint ColliderLocalId; @@ -165,7 +162,6 @@ namespace OpenSim.Region.Physics.OdePlugin private float mAvatarObjectContactFriction = 75f; private float mAvatarObjectContactBounce = 0.1f; - private float avPIDD = 3200f; private float avPIDP = 1400f; private float avCapRadius = 0.37f; @@ -175,13 +171,12 @@ namespace OpenSim.Region.Physics.OdePlugin private float avMovementDivisorWalk = 1.3f; private float avMovementDivisorRun = 0.8f; - private float[] _heightmap; private float[] _watermap; private float[] _origheightmap; - + private d.NearCallback nearCallback; public d.TriCallback triCallback; public d.TriArrayCallback triArrayCallback; @@ -200,7 +195,6 @@ namespace OpenSim.Region.Physics.OdePlugin private d.Contact AvatarMovementTerrainContact; private d.Contact WaterContact; - //Ckrinke: Comment out until used. We declare it, initialize it, but do not use it //Ckrinke private int m_randomizeWater = 200; private int m_physicsiterations = 10; @@ -233,7 +227,6 @@ namespace OpenSim.Region.Physics.OdePlugin private IConfigSource m_config; - /// /// Initiailizes the scene /// Sets many properties that ODE requires to be stable @@ -245,44 +238,34 @@ namespace OpenSim.Region.Physics.OdePlugin nearCallback = near; triCallback = TriCallback; triArrayCallback = TriArrayCallback; - - - lock (OdeLock) { - - // Creat the world and the first space + // Create the world and the first space world = d.WorldCreate(); space = d.HashSpaceCreate(IntPtr.Zero); - + contactgroup = d.JointGroupCreate(0); //contactgroup - - - d.WorldSetAutoDisableFlag(world, false); - } // zero out a heightmap array float array (single dimention [flattened])) _heightmap = new float[514*514]; _watermap = new float[258 * 258]; - // Zero out the prim spaces array (we split our space into smaller spaces so + // Zero out the prim spaces array (we split our space into smaller spaces so // we can hit test less. - } - // Initialize the mesh plugin public override void Initialise(IMesher meshmerizer, IConfigSource config) { mesher = meshmerizer; m_config = config; // Defaults - + if (Environment.OSVersion.Platform == PlatformID.Unix) { avPIDD = 3200.0f; @@ -349,10 +332,7 @@ namespace OpenSim.Region.Physics.OdePlugin avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); } - - } - } staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; @@ -361,8 +341,8 @@ namespace OpenSim.Region.Physics.OdePlugin contact.surface.mu = nmAvatarObjectContactFriction; contact.surface.bounce = nmAvatarObjectContactBounce; - // Terrain contact friction and Bounce - // This is the *non* moving version. Use this when an avatar + // Terrain contact friction and Bounce + // This is the *non* moving version. Use this when an avatar // isn't moving to keep it in place better TerrainContact.surface.mode |= d.ContactFlags.SoftERP; TerrainContact.surface.mu = nmTerrainContactFriction; @@ -376,7 +356,7 @@ namespace OpenSim.Region.Physics.OdePlugin WaterContact.surface.soft_erp = 0.010f; // Prim contact friction and bounce - // THis is the *non* moving version of friction and bounce + // THis is the *non* moving version of friction and bounce // Use this when an avatar comes in contact with a prim // and is moving AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction; @@ -409,7 +389,6 @@ namespace OpenSim.Region.Physics.OdePlugin staticPrimspace[i, j] = IntPtr.Zero; } } - } internal void waitForSpaceUnlock(IntPtr space) @@ -439,17 +418,17 @@ namespace OpenSim.Region.Physics.OdePlugin private void near(IntPtr space, IntPtr g1, IntPtr g2) { // no lock here! It's invoked from within Simulate(), which is thread-locked - - // Test if we're collidng a geom with a space. + + // Test if we're colliding a geom with a space. // If so we have to drill down into the space recursively if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) { if (g1 == (IntPtr)0 || g2 == (IntPtr)0) return; - // Separating static prim geometry spaces. - // We'll be calling near recursivly if one - // of them is a space to find all of the + // Separating static prim geometry spaces. + // We'll be calling near recursivly if one + // of them is a space to find all of the // contact points in the space try { @@ -462,13 +441,12 @@ namespace OpenSim.Region.Physics.OdePlugin } //Colliding a space or a geom with a space or a geom. so drill down - //Collide all geoms in each space.. + //Collide all geoms in each space.. //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); return; } - if (g1 == (IntPtr)0 || g2 == (IntPtr)0) return; @@ -499,23 +477,17 @@ namespace OpenSim.Region.Physics.OdePlugin int count = 0; try { - // Colliding Geom To Geom // This portion of the function 'was' blatantly ripped off from BoxStack.cs - - - if (g1 == g2) return; // Can't collide with yourself if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) return; - + lock (contacts) { - - count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); } } @@ -527,7 +499,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (AccessViolationException) { - + m_log.Warn("[PHYSICS]: Unable to collide test an object"); return; } @@ -539,6 +511,7 @@ namespace OpenSim.Region.Physics.OdePlugin { p1 = PANull; } + if (!actor_name_map.TryGetValue(g2, out p2)) { p2 = PANull; @@ -554,14 +527,10 @@ namespace OpenSim.Region.Physics.OdePlugin // If we're colliding with terrain, use 'TerrainContact' instead of contact. // allows us to have different settings - - // We only need to test p2 for 'jump crouch purposes' p2.IsColliding = true; //if ((framecount % m_returncollisions) == 0) - - switch (p1.PhysicsActorType) { @@ -588,41 +557,39 @@ namespace OpenSim.Region.Physics.OdePlugin { //This is disabled at the moment only because it needs more tweaking //It will eventually be uncommented - + if (contacts[i].depth >= 1.00f) { //m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString()); } - + //If you interpenetrate a prim with an agent if ((p2.PhysicsActorType == (int) ActorTypes.Agent && p1.PhysicsActorType == (int) ActorTypes.Prim) || (p1.PhysicsActorType == (int) ActorTypes.Agent && p2.PhysicsActorType == (int) ActorTypes.Prim)) { - - # region disabled code1 //contacts[i].depth = contacts[i].depth * 4.15f; /* if (p2.PhysicsActorType == (int) ActorTypes.Agent) - { + { p2.CollidingObj = true; contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); OdeCharacter character = (OdeCharacter) p2; character.SetPidStatus(true); contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); - + } else { - + //contacts[i].depth = 0.0000000f; } if (p1.PhysicsActorType == (int) ActorTypes.Agent) { - + p1.CollidingObj = true; contacts[i].depth = 0.003f; p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); @@ -632,14 +599,12 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - + //contacts[i].depth = 0.0000000f; } */ #endregion - } - // If you interpenetrate a prim with another prim if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) @@ -649,7 +614,6 @@ namespace OpenSim.Region.Physics.OdePlugin //OdePrim op2 = (OdePrim)p2; //op1.m_collisionscore++; //op2.m_collisionscore++; - //if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000) //{ @@ -658,11 +622,10 @@ namespace OpenSim.Region.Physics.OdePlugin //op2.m_taintdisable = true; //AddPhysicsActorTaint(p2); //} - + //if (contacts[i].depth >= 0.25f) //{ // Don't collide, one or both prim will expld. - //op1.m_interpenetrationcount++; //op2.m_interpenetrationcount++; @@ -678,17 +641,17 @@ namespace OpenSim.Region.Physics.OdePlugin //AddPhysicsActorTaint(p2); //} - //contacts[i].depth = contacts[i].depth / 8f; //contacts[i].normal = new d.Vector3(0, 0, 1); //} //if (op1.m_disabled || op2.m_disabled) //{ - //Manually disabled objects stay disabled + //Manually disabled objects stay disabled //contacts[i].depth = 0f; //} #endregion } + if (contacts[i].depth >= 1.00f) { //m_log.Info("[P]: " + contacts[i].depth.ToString()); @@ -713,6 +676,7 @@ namespace OpenSim.Region.Physics.OdePlugin else { } + if (p1.PhysicsActorType == (int) ActorTypes.Agent) { OdeCharacter character = (OdeCharacter)p1; @@ -738,7 +702,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (contacts[i].depth >= 0f) { - // If we're collidng against terrain + // If we're colliding against terrain if (name1 == "Terrain" || name2 == "Terrain") { // If we're moving @@ -760,12 +724,11 @@ namespace OpenSim.Region.Physics.OdePlugin { if ((p2.PhysicsActorType == (int)ActorTypes.Prim)) { - } else { - } + //WaterContact.surface.soft_cfm = 0.0000f; //WaterContact.surface.soft_erp = 0.00000f; if (contacts[i].depth > 0.1f) @@ -775,7 +738,7 @@ namespace OpenSim.Region.Physics.OdePlugin //contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f); } WaterContact.geom = contacts[i]; - + joint = d.JointCreateContact(world, contactgroup, ref WaterContact); //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); @@ -806,7 +769,7 @@ namespace OpenSim.Region.Physics.OdePlugin { // If there are more then 3 contact points, it's likely // that we've got a pile of objects - // + // // We don't want to send out hundreds of terse updates over and over again // so lets throttle them and send them again after it's somewhat sorted out. p2.ThrottleUpdates = true; @@ -814,7 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin //System.Console.WriteLine(count.ToString()); //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); } - } private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) @@ -831,7 +793,7 @@ namespace OpenSim.Region.Physics.OdePlugin { case ActorTypes.Agent: cc2 = (OdeCharacter)p2; - + obj1LocalID = cc2.m_localID; switch ((ActorTypes)p1.PhysicsActorType) { @@ -840,7 +802,7 @@ namespace OpenSim.Region.Physics.OdePlugin obj2LocalID = cc1.m_localID; cc1.AddCollisionEvent(cc2.m_localID, collisiondepth); //ctype = (int)CollisionCategories.Character; - + //if (cc1.CollidingObj) //cStartStop = (int)StatusIndicators.Generic; //else @@ -858,7 +820,7 @@ namespace OpenSim.Region.Physics.OdePlugin //cStartStop = (int)StatusIndicators.Generic; //else //cStartStop = (int)StatusIndicators.Start; - + //returncollisions = true; break; @@ -869,14 +831,12 @@ namespace OpenSim.Region.Physics.OdePlugin //returncollisions = true; break; } - - cc2.AddCollisionEvent(obj2LocalID, collisiondepth); break; case ActorTypes.Prim: cp2 = (OdePrim)p2; - + obj1LocalID = cp2.m_localID; switch ((ActorTypes)p1.PhysicsActorType) { @@ -891,7 +851,7 @@ namespace OpenSim.Region.Physics.OdePlugin //else //cStartStop = (int)StatusIndicators.Start; //returncollisions = true; - + break; case ActorTypes.Prim: cp1 = (OdePrim)p1; @@ -903,7 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin //cStartStop = (int)StatusIndicators.Generic; //else //cStartStop = (int)StatusIndicators.Start; - + //returncollisions = true; break; @@ -911,11 +871,11 @@ namespace OpenSim.Region.Physics.OdePlugin case ActorTypes.Unknown: obj2LocalID = 0; //ctype = (int)CollisionCategories.Land; - + //returncollisions = true; break; } - + cp2.AddCollisionEvent(obj2LocalID, collisiondepth); break; } @@ -999,7 +959,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// private void collision_optimized(float timeStep) { - + foreach (OdeCharacter chr in _characters) { // Reset the collision values to false @@ -1008,7 +968,7 @@ namespace OpenSim.Region.Physics.OdePlugin chr.IsColliding = false; chr.CollidingGround = false; chr.CollidingObj = false; - + // test the avatar's geometry for collision with the space // This will return near and the space that they are the closest to // And we'll run this again against the avatar and the space segment @@ -1029,15 +989,11 @@ namespace OpenSim.Region.Physics.OdePlugin //forcedZ = true; //} } - - lock (_activeprims) { - foreach (OdePrim chr in _activeprims) { - if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) { try @@ -1049,18 +1005,14 @@ namespace OpenSim.Region.Physics.OdePlugin else m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed"); } - } catch (AccessViolationException) { m_log.Warn("[PHYSICS]: Unable to space collide"); } - } - } } - } #endregion @@ -1077,7 +1029,6 @@ namespace OpenSim.Region.Physics.OdePlugin { if (!_collisionEventPrim.Contains(obj)) _collisionEventPrim.Add(obj); - } } @@ -1090,7 +1041,6 @@ namespace OpenSim.Region.Physics.OdePlugin } } - #region Add/Remove Entities public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size) @@ -1131,8 +1081,6 @@ namespace OpenSim.Region.Physics.OdePlugin rot.y = rotation.y; rot.z = rotation.z; - - OdePrim newPrim; lock (OdeLock) { @@ -1141,7 +1089,6 @@ namespace OpenSim.Region.Physics.OdePlugin _prims.Add(newPrim); } - return newPrim; } @@ -1178,11 +1125,9 @@ namespace OpenSim.Region.Physics.OdePlugin result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); - return result; } - public void remActivePrim(OdePrim deactivatePrim) { lock (_activeprims) @@ -1210,8 +1155,8 @@ namespace OpenSim.Region.Physics.OdePlugin /// This is called from within simulate but outside the locked portion /// We need to do our own locking here /// Essentially, we need to remove the prim from our space segment, whatever segment it's in. - /// - /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory + /// + /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory /// that the space was using. /// /// @@ -1226,7 +1171,6 @@ namespace OpenSim.Region.Physics.OdePlugin { prim.ResetTaints(); - if (prim.IsPhysical) { prim.disableBody(); @@ -1267,7 +1211,6 @@ namespace OpenSim.Region.Physics.OdePlugin { m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); } - } catch (AccessViolationException) { @@ -1297,8 +1240,6 @@ namespace OpenSim.Region.Physics.OdePlugin //} //} } - - } } } @@ -1337,12 +1278,11 @@ namespace OpenSim.Region.Physics.OdePlugin /// a pointer to the new space it's in public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) { - - // Called from setting the Position and Size of an ODEPrim so + // Called from setting the Position and Size of an ODEPrim so // it's already in locked space. // we don't want to remove the main space - // we don't need to test physical here because this function should + // we don't need to test physical here because this function should // never be called if the prim is physical(active) // All physical prim end up in the root space @@ -1399,7 +1339,7 @@ namespace OpenSim.Region.Physics.OdePlugin waitForSpaceUnlock(space); d.SpaceRemove(space, currentspace); // free up memory used by the space. - + //d.SpaceDestroy(currentspace); resetSpaceArrayItemToZero(currentspace); } @@ -1418,7 +1358,6 @@ namespace OpenSim.Region.Physics.OdePlugin { if (d.SpaceQuery(currentspace, geom)) { - if (d.GeomIsSpace(currentspace)) { waitForSpaceUnlock(currentspace); @@ -1453,8 +1392,8 @@ namespace OpenSim.Region.Physics.OdePlugin } } - // The routines in the Position and Size sections do the 'inserting' into the space, - // so all we have to do is make sure that the space that we're putting the prim into + // The routines in the Position and Size sections do the 'inserting' into the space, + // so all we have to do is make sure that the space that we're putting the prim into // is in the 'main' space. int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); IntPtr newspace = calculateSpaceForGeom(pos); @@ -1492,11 +1431,11 @@ namespace OpenSim.Region.Physics.OdePlugin public IntPtr calculateSpaceForGeom(PhysicsVector pos) { IntPtr locationbasedspace =IntPtr.Zero; - + int[] xyspace = calculateSpaceArrayItemFromPos(pos); //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]]; - + //locationbasedspace = space; return locationbasedspace; } @@ -1523,13 +1462,10 @@ namespace OpenSim.Region.Physics.OdePlugin if (returnint[1] < 0) returnint[1] = 0; - return returnint; } - #endregion - - + #endregion /// /// Routine to figure out if we need to mesh this prim with our mesher @@ -1564,7 +1500,6 @@ namespace OpenSim.Region.Physics.OdePlugin return false; } - /// /// Called after our prim properties are set Scale, position etc. /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex @@ -1586,7 +1521,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// This is our main simulate loop - /// It's thread locked by a Mutex in the scene. + /// It's thread locked by a Mutex in the scene. /// It holds Collisions, it instructs ODE to step through the physical reactions /// It moves the objects around in memory /// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup) @@ -1597,7 +1532,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (framecount >= int.MaxValue) framecount = 0; - + framecount++; float fps = 0; @@ -1605,12 +1540,11 @@ namespace OpenSim.Region.Physics.OdePlugin step_time += timeStep; - // If We're loaded down by something else, + // If We're loaded down by something else, // or debugging with the Visual Studio project on pause // skip a few frames to catch up gracefully. // without shooting the physicsactors all over the place - if (step_time >= m_SkipFramesAtms) { // Instead of trying to catch up, it'll do 5 physics frames only @@ -1623,7 +1557,7 @@ namespace OpenSim.Region.Physics.OdePlugin } lock (OdeLock) { - // Process 10 frames if the sim is running normal.. + // Process 10 frames if the sim is running normal.. // process 5 frames if the sim is running slow //try //{ @@ -1642,13 +1576,13 @@ namespace OpenSim.Region.Physics.OdePlugin //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size step_time = 0.09375f; fps = (step_time/ODE_STEPSIZE) * 1000; - + while (step_time > 0.0f) { //lock (ode) //{ //if (!ode.lockquery()) - //{ + //{ // ode.dlock(world); try { @@ -1661,9 +1595,8 @@ namespace OpenSim.Region.Physics.OdePlugin } } - bool processedtaints = false; - + lock (_taintedPrim) { foreach (OdePrim prim in _taintedPrim) @@ -1679,10 +1612,9 @@ namespace OpenSim.Region.Physics.OdePlugin processedtaints = true; prim.m_collisionscore = 0; } - + if (processedtaints) _taintedPrim = new List(); - } lock (_activeprims) @@ -1696,7 +1628,6 @@ namespace OpenSim.Region.Physics.OdePlugin //if ((framecount % m_randomizeWater) == 0) // randomizeWater(waterlevel); - collision_optimized(timeStep); @@ -1718,7 +1649,6 @@ namespace OpenSim.Region.Physics.OdePlugin pobj.SendCollisions(); break; } - } } @@ -1726,13 +1656,13 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointGroupEmpty(contactgroup); //ode.dunlock(world); - } + } catch (Exception e) { m_log.Error("[PHYSICS]: " + e.Message.ToString() + e.TargetSite.ToString()); ode.dunlock(world); } - + step_time -= ODE_STEPSIZE; i++; //} @@ -1765,7 +1695,6 @@ namespace OpenSim.Region.Physics.OdePlugin } } } - } return fps; } @@ -1780,7 +1709,7 @@ namespace OpenSim.Region.Physics.OdePlugin get { return (false); } } - #region ODE Specific Terrain Fixes + #region ODE Specific Terrain Fixes public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) { float[] returnarr = new float[262144]; @@ -1800,7 +1729,7 @@ namespace OpenSim.Region.Physics.OdePlugin // This particular way is quick but it only works on a multiple of the original // The idea behind this method can be described with the following diagrams - // second pass and third pass happen in the same loop really.. just separated + // second pass and third pass happen in the same loop really.. just separated // them to show what this does. // First Pass @@ -1893,6 +1822,7 @@ namespace OpenSim.Region.Physics.OdePlugin return returnarr; } + public float[] ResizeTerrain512Interpolation(float[] heightMap) { float[] returnarr = new float[262144]; @@ -1912,7 +1842,7 @@ namespace OpenSim.Region.Physics.OdePlugin // This particular way is quick but it only works on a multiple of the original // The idea behind this method can be described with the following diagrams - // second pass and third pass happen in the same loop really.. just separated + // second pass and third pass happen in the same loop really.. just separated // them to show what this does. // First Pass @@ -2139,7 +2069,6 @@ namespace OpenSim.Region.Physics.OdePlugin // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); } - lock (OdeLock) { if (!(WaterGeom == (IntPtr)0)) @@ -2183,7 +2112,6 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (OdeLock) { - foreach (OdePrim prm in _prims) { RemovePrim(prm); diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 9ca1b23..82ce144 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -171,12 +171,12 @@ namespace OpenSim.Region.Physics.POSPlugin { if (check_collision(c, _prims[i])) { - + return true; } } - + return false; } @@ -234,7 +234,7 @@ namespace OpenSim.Region.Physics.POSPlugin character.Position.Z += character._target_velocity.Z*timeStep; } - /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- + /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- /// Completely Bogus Collision Detection!!! /// better known as the CBCD algorithm -- cgit v1.1