diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEApi.cs b/OpenSim/Region/PhysicsModules/Ode/ODEApi.cs index bf903ad538..3c56a2e1e8 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODEApi.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEApi.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.PhysicsModule.ODE using dReal = System.Single; //#endif - internal static class SafeNativeMethods + internal static class OdeNative { internal static dReal Infinity = dReal.MaxValue; internal static int NTotalBodies = 0; diff --git a/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs index a6a20c50c1..d834306813 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.PhysicsModule.ODE private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Vector3 _position; - private SafeNativeMethods.Vector3 _zeroPosition; + private OdeNative.Vector3 _zeroPosition; private bool _zeroFlag = false; private bool m_lastUpdateSent = false; private Vector3 _velocity; @@ -151,7 +151,7 @@ namespace OpenSim.Region.PhysicsModule.ODE internal IntPtr Shell { get; private set; } private IntPtr Amotor = IntPtr.Zero; - private SafeNativeMethods.Mass ShellMass; + private OdeNative.Mass ShellMass; private int m_eventsubscription = 0; private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); @@ -569,12 +569,12 @@ namespace OpenSim.Region.PhysicsModule.ODE float yTiltComponent = -movementVector.Y * m_tiltMagnitudeWhenProjectedOnXYPlane; //m_log.Debug("[ODE CHARACTER]: changing avatar tilt"); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, yTiltComponent); // same as lowstop - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, yTiltComponent); // same as lowstop + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop } /// @@ -812,11 +812,11 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_pidControllerActive == false) { - _zeroPosition = SafeNativeMethods.BodyGetPosition(Body); + _zeroPosition = OdeNative.BodyGetPosition(Body); } //PidStatus = true; - SafeNativeMethods.Vector3 localpos = SafeNativeMethods.BodyGetPosition(Body); + OdeNative.Vector3 localpos = OdeNative.BodyGetPosition(Body); Vector3 localPos = new Vector3(localpos.X, localpos.Y, localpos.Z); if (!localPos.IsFinite()) @@ -831,7 +831,7 @@ namespace OpenSim.Region.PhysicsModule.ODE } Vector3 vec = Vector3.Zero; - SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body); + OdeNative.Vector3 vel = OdeNative.BodyGetLinearVel(Body); // m_log.DebugFormat( // "[ODE CHARACTER]: Current velocity in Move() is <{0},{1},{2}>, target {3} for {4}", @@ -855,7 +855,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (!_zeroFlag) { _zeroFlag = true; - _zeroPosition = SafeNativeMethods.BodyGetPosition(Body); + _zeroPosition = OdeNative.BodyGetPosition(Body); } if (m_pidControllerActive) @@ -865,7 +865,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // Avatar to Avatar collisions // Prim to avatar collisions - SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body); + OdeNative.Vector3 pos = OdeNative.BodyGetPosition(Body); vec.X = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2); vec.Y = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y)* (PID_P * 2); if (flying) @@ -913,7 +913,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { // We're colliding with something and we're not flying but we're moving // This means we're walking or running. - SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body); + OdeNative.Vector3 pos = OdeNative.BodyGetPosition(Body); vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; @@ -947,7 +947,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (vec.IsFinite()) { // Apply the total force acting on this avatar - SafeNativeMethods.BodyAddForce(Body, vec.X, vec.Y, vec.Z); + OdeNative.BodyAddForce(Body, vec.X, vec.Y, vec.Z); if (!_zeroFlag) AlignAvatarTiltWithCurrentDirectionOfMovement(vec); @@ -963,7 +963,7 @@ namespace OpenSim.Region.PhysicsModule.ODE return; } - SafeNativeMethods.Vector3 newVel = SafeNativeMethods.BodyGetLinearVel(Body); + OdeNative.Vector3 newVel = OdeNative.BodyGetLinearVel(Body); if (newVel.X >= 256 || newVel.X <= 256 || newVel.Y >= 256 || newVel.Y <= 256 || newVel.Z >= 256 || newVel.Z <= 256) { // m_log.DebugFormat( @@ -979,7 +979,7 @@ namespace OpenSim.Region.PhysicsModule.ODE else newVel.Z = Util.Clamp(newVel.Z, -255f, 255f); - SafeNativeMethods.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); + OdeNative.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); } } @@ -992,16 +992,16 @@ namespace OpenSim.Region.PhysicsModule.ODE internal void UpdatePositionAndVelocity(List defects) { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - SafeNativeMethods.Vector3 newPos; + OdeNative.Vector3 newPos; try { - newPos = SafeNativeMethods.BodyGetPosition(Body); + newPos = OdeNative.BodyGetPosition(Body); } catch (NullReferenceException) { bad = true; defects.Add(this); - newPos = new SafeNativeMethods.Vector3(_position.X, _position.Y, _position.Z); + newPos = new OdeNative.Vector3(_position.X, _position.Y, _position.Z); base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! m_log.WarnFormat("[ODE CHARACTER]: Avatar Null reference for Avatar {0}, physical actor {1}", Name, m_uuid); @@ -1038,11 +1038,11 @@ namespace OpenSim.Region.PhysicsModule.ODE else { m_lastUpdateSent = false; - SafeNativeMethods.Vector3 newVelocity; + OdeNative.Vector3 newVelocity; try { - newVelocity = SafeNativeMethods.BodyGetLinearVel(Body); + newVelocity = OdeNative.BodyGetLinearVel(Body); } catch (NullReferenceException) { @@ -1109,14 +1109,14 @@ namespace OpenSim.Region.PhysicsModule.ODE } // lock (OdeScene.UniversalColliderSyncObject) - Shell = SafeNativeMethods.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); + Shell = OdeNative.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); - SafeNativeMethods.GeomSetCategoryBits(Shell, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(Shell, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(Shell, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(Shell, (uint)m_collisionFlags); - SafeNativeMethods.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); - Body = SafeNativeMethods.BodyCreate(_parent_scene.world); - SafeNativeMethods.BodySetPosition(Body, npositionX, npositionY, npositionZ); + OdeNative.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); + Body = OdeNative.BodyCreate(_parent_scene.world); + OdeNative.BodySetPosition(Body, npositionX, npositionY, npositionZ); _position.X = npositionX; _position.Y = npositionY; @@ -1124,45 +1124,45 @@ namespace OpenSim.Region.PhysicsModule.ODE m_taintPosition = _position; - SafeNativeMethods.BodySetMass(Body, ref ShellMass); - SafeNativeMethods.Matrix3 m_caprot; + OdeNative.BodySetMass(Body, ref ShellMass); + OdeNative.Matrix3 m_caprot; // 90 Stand up on the cap of the capped cyllinder if (_parent_scene.IsAvCapsuleTilted) { - SafeNativeMethods.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); + OdeNative.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); } else { - SafeNativeMethods.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2)); + OdeNative.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2)); } - SafeNativeMethods.GeomSetRotation(Shell, ref m_caprot); - SafeNativeMethods.BodySetRotation(Body, ref m_caprot); + OdeNative.GeomSetRotation(Shell, ref m_caprot); + OdeNative.BodySetRotation(Body, ref m_caprot); - SafeNativeMethods.GeomSetBody(Shell, Body); + OdeNative.GeomSetBody(Shell, Body); // The purpose of the AMotor here is to keep the avatar's physical // surrogate from rotating while moving - Amotor = SafeNativeMethods.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); - SafeNativeMethods.JointAttach(Amotor, Body, IntPtr.Zero); - SafeNativeMethods.JointSetAMotorMode(Amotor, dAMotorEuler); - SafeNativeMethods.JointSetAMotorNumAxes(Amotor, 3); - SafeNativeMethods.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); - SafeNativeMethods.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); - SafeNativeMethods.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 0, 0); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 1, 0); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 2, 0); + Amotor = OdeNative.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); + OdeNative.JointAttach(Amotor, Body, IntPtr.Zero); + OdeNative.JointSetAMotorMode(Amotor, dAMotorEuler); + OdeNative.JointSetAMotorNumAxes(Amotor, 3); + OdeNative.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); + OdeNative.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); + OdeNative.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); + OdeNative.JointSetAMotorAngle(Amotor, 0, 0); + OdeNative.JointSetAMotorAngle(Amotor, 1, 0); + OdeNative.JointSetAMotorAngle(Amotor, 2, 0); // These lowstops and high stops are effectively (no wiggle room) if (_parent_scene.IsAvCapsuleTilted) { - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); } else { @@ -1174,18 +1174,18 @@ namespace OpenSim.Region.PhysicsModule.ODE // to be comprehended in their entirety. #endregion AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop } // 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 - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor); //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); //d.QfromR( @@ -1224,7 +1224,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (Amotor != IntPtr.Zero) { // Kill the Amotor - SafeNativeMethods.JointDestroy(Amotor); + OdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } @@ -1234,14 +1234,14 @@ namespace OpenSim.Region.PhysicsModule.ODE if (Body != IntPtr.Zero) { //kill the body - SafeNativeMethods.BodyDestroy(Body); + OdeNative.BodyDestroy(Body); Body = IntPtr.Zero; } if (Shell != IntPtr.Zero) { // lock (OdeScene.UniversalColliderSyncObject) - SafeNativeMethods.GeomDestroy(Shell); + OdeNative.GeomDestroy(Shell); _parent_scene.geom_name_map.Remove(Shell); _parent_scene.actor_name_map.Remove(Shell); @@ -1332,7 +1332,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); + OdeNative.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); _position = m_taintPosition; } } @@ -1344,7 +1344,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // FIXME: This is not a good solution since it's subject to a race condition if a force is another // thread sets a new force while we're in this loop (since it could be obliterated by // m_taintForce = Vector3.Zero. Need to lock ProcessTaints() when we set a new tainted force. - SafeNativeMethods.BodyAddForce(Body, m_taintForce.X, m_taintForce.Y, m_taintForce.Z); + OdeNative.BodyAddForce(Body, m_taintForce.X, m_taintForce.Y, m_taintForce.Z); } m_taintForce = Vector3.Zero; diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs index 39aea59673..d01b59b335 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.PhysicsModule.ODE private float m_linearMotorDecayTimescale = 0; private float m_linearMotorTimescale = 0; private Vector3 m_lastLinearVelocityVector = Vector3.Zero; - private SafeNativeMethods.Vector3 m_lastPositionVector = new SafeNativeMethods.Vector3(); + private OdeNative.Vector3 m_lastPositionVector = new OdeNative.Vector3(); // private bool m_LinearMotorSetLastFrame = false; // private Vector3 m_linearMotorOffset = Vector3.Zero; @@ -611,7 +611,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { m_lastLinearVelocityVector = Vector3.Zero; m_lastAngularVelocity = Vector3.Zero; - m_lastPositionVector = SafeNativeMethods.BodyGetPosition(Body); + m_lastPositionVector = OdeNative.BodyGetPosition(Body); } internal void Step(float pTimestep, OdeScene pParentScene) @@ -631,8 +631,8 @@ namespace OpenSim.Region.PhysicsModule.ODE { if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant { - if (!SafeNativeMethods.BodyIsEnabled(Body)) - SafeNativeMethods.BodyEnable(Body); + if (!OdeNative.BodyIsEnabled(Body)) + OdeNative.BodyEnable(Body); // add drive to body Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep); @@ -662,7 +662,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // convert requested object velocity to world-referenced vector m_dir = m_lastLinearVelocityVector; - SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body); + OdeNative.Quaternion rot = OdeNative.BodyGetQuaternion(Body); Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object m_dir *= rotq; // apply obj rotation to velocity vector @@ -673,15 +673,15 @@ namespace OpenSim.Region.PhysicsModule.ODE Vector3 grav = Vector3.Zero; // There is some gravity, make a gravity force vector // that is applied after object velocity. - SafeNativeMethods.Mass objMass; - SafeNativeMethods.BodyGetMass(Body, out objMass); + OdeNative.Mass objMass; + OdeNative.BodyGetMass(Body, out objMass); // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy); // Preserve the current Z velocity - SafeNativeMethods.Vector3 vel_now = SafeNativeMethods.BodyGetLinearVel(Body); + OdeNative.Vector3 vel_now = OdeNative.BodyGetLinearVel(Body); m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity - SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body); + OdeNative.Vector3 pos = OdeNative.BodyGetPosition(Body); // Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); Vector3 posChange = new Vector3(); posChange.X = pos.X - m_lastPositionVector.X; @@ -693,33 +693,33 @@ namespace OpenSim.Region.PhysicsModule.ODE if (pos.X >= (m_BlockingEndPoint.X - (float)1)) { pos.X -= posChange.X + 1; - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, pos.Z); } if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) { pos.Y -= posChange.Y + 1; - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, pos.Z); } if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) { pos.Z -= posChange.Z + 1; - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, pos.Z); } if (pos.X <= 0) { pos.X += posChange.X + 1; - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, pos.Z); } if (pos.Y <= 0) { pos.Y += posChange.Y + 1; - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, pos.Z); } } if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y)) { pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2; - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, pos.Z); } // Check if hovering @@ -748,7 +748,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) { - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, m_VhoverTargetHeight); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, m_VhoverTargetHeight); } } else @@ -815,12 +815,12 @@ namespace OpenSim.Region.PhysicsModule.ODE m_dir.Z = 0; } - m_lastPositionVector = SafeNativeMethods.BodyGetPosition(Body); + m_lastPositionVector = OdeNative.BodyGetPosition(Body); // Apply velocity - SafeNativeMethods.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z); + OdeNative.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z); // apply gravity force - SafeNativeMethods.BodyAddForce(Body, grav.X, grav.Y, grav.Z); + OdeNative.BodyAddForce(Body, grav.X, grav.Y, grav.Z); // apply friction @@ -841,7 +841,7 @@ namespace OpenSim.Region.PhysicsModule.ODE */ // Get what the body is doing, this includes 'external' influences - SafeNativeMethods.Vector3 angularVelocity = SafeNativeMethods.BodyGetAngularVel(Body); + OdeNative.Vector3 angularVelocity = OdeNative.BodyGetAngularVel(Body); // Vector3 angularVelocity = Vector3.Zero; if (m_angularMotorApply > 0) @@ -874,7 +874,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep); // get present body rotation - SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body); + OdeNative.Quaternion rot = OdeNative.BodyGetQuaternion(Body); Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // make a vector pointing up Vector3 verterr = Vector3.Zero; @@ -923,7 +923,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) { - if (!SafeNativeMethods.BodyIsEnabled (Body)) SafeNativeMethods.BodyEnable (Body); + if (!OdeNative.BodyIsEnabled (Body)) OdeNative.BodyEnable (Body); } else { @@ -935,14 +935,14 @@ namespace OpenSim.Region.PhysicsModule.ODE m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; // Apply to the body - SafeNativeMethods.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); + OdeNative.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); } //end MoveAngular internal void LimitRotation(float timestep) { - SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body); + OdeNative.Quaternion rot = OdeNative.BodyGetQuaternion(Body); Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object - SafeNativeMethods.Quaternion m_rot = new SafeNativeMethods.Quaternion(); + OdeNative.Quaternion m_rot = new OdeNative.Quaternion(); bool changed = false; m_rot.X = rotq.X; m_rot.Y = rotq.Y; @@ -975,7 +975,7 @@ namespace OpenSim.Region.PhysicsModule.ODE changed = true; } if (changed) - SafeNativeMethods.BodySetQuaternion(Body, ref m_rot); + OdeNative.BodySetQuaternion(Body, ref m_rot); } } } diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs b/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs index d6aeb63cbc..9f2d011a42 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to // http://opensimulator.org/mantis/view.php?id=2750). - SafeNativeMethods.InitODE(); + OdeNative.InitODE(); m_scene = new OdeScene(scene, m_config, Name, Version); } diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs index 16b2551174..821039cbfe 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs @@ -212,7 +212,7 @@ namespace OpenSim.Region.PhysicsModule.ODE public IntPtr Body = IntPtr.Zero; private Vector3 _target_velocity; - private SafeNativeMethods.Mass pMass; + private OdeNative.Mass pMass; private int m_eventsubscription; private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); @@ -356,13 +356,13 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); } else { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } _parent_scene.geom_name_map[prim_geom] = Name; @@ -386,7 +386,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { if (IsPhysical && Body != IntPtr.Zero) { - SafeNativeMethods.BodyEnable(Body); + OdeNative.BodyEnable(Body); if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene); } @@ -401,7 +401,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (IsPhysical && Body != IntPtr.Zero) { - SafeNativeMethods.BodyDisable(Body); + OdeNative.BodyDisable(Body); } } @@ -415,22 +415,22 @@ namespace OpenSim.Region.PhysicsModule.ODE if (!childPrim) { // Sets the geom to a body - Body = SafeNativeMethods.BodyCreate(_parent_scene.world); + Body = OdeNative.BodyCreate(_parent_scene.world); setMass(); - SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z); - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + OdeNative.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + OdeNative.Quaternion myrot = new OdeNative.Quaternion(); myrot.X = _orientation.X; myrot.Y = _orientation.Y; myrot.Z = _orientation.Z; myrot.W = _orientation.W; - SafeNativeMethods.BodySetQuaternion(Body, ref myrot); - SafeNativeMethods.GeomSetBody(prim_geom, Body); + OdeNative.BodySetQuaternion(Body, ref myrot); + OdeNative.GeomSetBody(prim_geom, Body); if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); } else { @@ -438,14 +438,14 @@ namespace OpenSim.Region.PhysicsModule.ODE m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); } - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); - SafeNativeMethods.BodySetAutoDisableFlag(Body, true); - SafeNativeMethods.BodySetAutoDisableSteps(Body, body_autodisable_frames); + OdeNative.BodySetAutoDisableFlag(Body, true); + OdeNative.BodySetAutoDisableSteps(Body, body_autodisable_frames); // disconnect from world gravity so we can apply buoyancy - SafeNativeMethods.BodySetGravityMode (Body, false); + OdeNative.BodySetGravityMode (Body, false); m_interpenetrationcount = 0; m_collisionscore = 0; @@ -787,8 +787,8 @@ namespace OpenSim.Region.PhysicsModule.ODE //m_log.Info("[PHYSICS]: New Mass: " + newmass.ToString()); - SafeNativeMethods.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z); - SafeNativeMethods.BodySetMass(Body, ref pMass); + OdeNative.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z); + OdeNative.BodySetMass(Body, ref pMass); } } @@ -796,7 +796,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { if (Body != (IntPtr)0) { - SafeNativeMethods.BodySetAngularVel(Body, x, y, z); + OdeNative.BodySetAngularVel(Body, x, y, z); } } @@ -818,16 +818,16 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, 0); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } - SafeNativeMethods.BodyDestroy(Body); + OdeNative.BodyDestroy(Body); lock (childrenPrim) { if (childrenPrim.Count > 0) @@ -851,14 +851,14 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, 0); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } Body = IntPtr.Zero; @@ -915,10 +915,10 @@ namespace OpenSim.Region.PhysicsModule.ODE } else { - _triMeshData = SafeNativeMethods.GeomTriMeshDataCreate(); + _triMeshData = OdeNative.GeomTriMeshDataCreate(); - SafeNativeMethods.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); - SafeNativeMethods.GeomTriMeshDataPreprocess(_triMeshData); + OdeNative.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); + OdeNative.GeomTriMeshDataPreprocess(_triMeshData); m_MeshToTriMeshMap[mesh] = _triMeshData; } } @@ -926,7 +926,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // _parent_scene.waitForSpaceUnlock(m_targetSpace); try { - SetGeom(SafeNativeMethods.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null)); + SetGeom(OdeNative.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null)); } catch (AccessViolationException) { @@ -1032,7 +1032,7 @@ Console.WriteLine("ZProcessTaints for " + Name); { if (Amotor != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(Amotor); + OdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } } @@ -1107,7 +1107,7 @@ Console.WriteLine("ZProcessTaints for " + Name); if (Body == IntPtr.Zero) { - Body = SafeNativeMethods.BodyCreate(_parent_scene.world); + Body = OdeNative.BodyCreate(_parent_scene.world); setMass(); } @@ -1123,21 +1123,21 @@ Console.WriteLine("ZProcessTaints for " + Name); foreach (OdePrim prm in childrenPrim) { - SafeNativeMethods.Mass m2; - SafeNativeMethods.MassSetZero(out m2); - SafeNativeMethods.MassSetBoxTotal(out m2, prm.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); + OdeNative.Mass m2; + OdeNative.MassSetZero(out m2); + OdeNative.MassSetBoxTotal(out m2, prm.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); - SafeNativeMethods.Quaternion quat = new SafeNativeMethods.Quaternion(); + OdeNative.Quaternion quat = new OdeNative.Quaternion(); quat.W = prm._orientation.W; quat.X = prm._orientation.X; quat.Y = prm._orientation.Y; quat.Z = prm._orientation.Z; - SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.RfromQ(out mat, ref quat); - SafeNativeMethods.MassRotate(ref m2, ref mat); - SafeNativeMethods.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); - SafeNativeMethods.MassAdd(ref pMass, ref m2); + OdeNative.Matrix3 mat = new OdeNative.Matrix3(); + OdeNative.RfromQ(out mat, ref quat); + OdeNative.MassRotate(ref m2, ref mat); + OdeNative.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); + OdeNative.MassAdd(ref pMass, ref m2); } foreach (OdePrim prm in childrenPrim) @@ -1148,36 +1148,36 @@ Console.WriteLine("ZProcessTaints for " + Name); //Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); if (prm.m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prm.prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prm.prim_geom, (uint)prm.BadMeshAssetCollideBits); + OdeNative.GeomSetCategoryBits(prm.prim_geom, 0); + OdeNative.GeomSetCollideBits(prm.prim_geom, (uint)prm.BadMeshAssetCollideBits); } else { - SafeNativeMethods.GeomSetCategoryBits(prm.prim_geom, (uint)prm.m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prm.prim_geom, (uint)prm.m_collisionFlags); + OdeNative.GeomSetCategoryBits(prm.prim_geom, (uint)prm.m_collisionCategories); + OdeNative.GeomSetCollideBits(prm.prim_geom, (uint)prm.m_collisionFlags); } - SafeNativeMethods.Quaternion quat = new SafeNativeMethods.Quaternion(); + OdeNative.Quaternion quat = new OdeNative.Quaternion(); quat.W = prm._orientation.W; quat.X = prm._orientation.X; quat.Y = prm._orientation.Y; quat.Z = prm._orientation.Z; - SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.RfromQ(out mat, ref quat); + OdeNative.Matrix3 mat = new OdeNative.Matrix3(); + OdeNative.RfromQ(out mat, ref quat); if (Body != IntPtr.Zero) { - SafeNativeMethods.GeomSetBody(prm.prim_geom, Body); + OdeNative.GeomSetBody(prm.prim_geom, Body); prm.childPrim = true; - SafeNativeMethods.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); + OdeNative.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); //d.GeomSetOffsetPosition(prim.prim_geom, // (Position.X - prm.Position.X) - pMass.c.X, // (Position.Y - prm.Position.Y) - pMass.c.Y, // (Position.Z - prm.Position.Z) - pMass.c.Z); - SafeNativeMethods.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); + OdeNative.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); - SafeNativeMethods.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); - SafeNativeMethods.BodySetMass(Body, ref pMass); + OdeNative.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); + OdeNative.BodySetMass(Body, ref pMass); } else { @@ -1197,37 +1197,37 @@ Console.WriteLine("ZProcessTaints for " + Name); if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); } else { //Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name); - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); //Console.WriteLine(" Post GeomSetCategoryBits 2"); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } - SafeNativeMethods.Quaternion quat2 = new SafeNativeMethods.Quaternion(); + OdeNative.Quaternion quat2 = new OdeNative.Quaternion(); quat2.W = _orientation.W; quat2.X = _orientation.X; quat2.Y = _orientation.Y; quat2.Z = _orientation.Z; - SafeNativeMethods.Matrix3 mat2 = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.RfromQ(out mat2, ref quat2); - SafeNativeMethods.GeomSetBody(prim_geom, Body); - SafeNativeMethods.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); + OdeNative.Matrix3 mat2 = new OdeNative.Matrix3(); + OdeNative.RfromQ(out mat2, ref quat2); + OdeNative.GeomSetBody(prim_geom, Body); + OdeNative.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); //d.GeomSetOffsetPosition(prim.prim_geom, // (Position.X - prm.Position.X) - pMass.c.X, // (Position.Y - prm.Position.Y) - pMass.c.Y, // (Position.Z - prm.Position.Z) - pMass.c.Z); //d.GeomSetOffsetRotation(prim_geom, ref mat2); - SafeNativeMethods.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); - SafeNativeMethods.BodySetMass(Body, ref pMass); + OdeNative.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); + OdeNative.BodySetMass(Body, ref pMass); - SafeNativeMethods.BodySetAutoDisableFlag(Body, true); - SafeNativeMethods.BodySetAutoDisableSteps(Body, body_autodisable_frames); + OdeNative.BodySetAutoDisableFlag(Body, true); + OdeNative.BodySetAutoDisableSteps(Body, body_autodisable_frames); m_interpenetrationcount = 0; m_collisionscore = 0; @@ -1240,7 +1240,7 @@ Console.WriteLine("ZProcessTaints for " + Name); createAMotor(m_angularlock); } - SafeNativeMethods.BodySetPosition(Body, Position.X, Position.Y, Position.Z); + OdeNative.BodySetPosition(Body, Position.X, Position.Y, Position.Z); if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene); @@ -1370,13 +1370,13 @@ Console.WriteLine("ZProcessTaints for " + Name); if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, 0); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } if (IsPhysical) @@ -1400,21 +1400,21 @@ Console.WriteLine("ZProcessTaints for " + Name); if (m_assetFailed) { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); + OdeNative.GeomSetCategoryBits(prim_geom, 0); + OdeNative.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); } else { - SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } if (IsPhysical) { if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f); - SafeNativeMethods.BodySetForce(Body, 0, 0, 0); + OdeNative.BodySetLinearVel(Body, 0f, 0f, 0f); + OdeNative.BodySetForce(Body, 0, 0, 0); enableBodySoft(); } } @@ -1463,7 +1463,7 @@ Console.WriteLine("CreateGeom:"); try { //Console.WriteLine(" CreateGeom 1"); - SetGeom(SafeNativeMethods.CreateSphere(m_targetSpace, _size.X / 2)); + SetGeom(OdeNative.CreateSphere(m_targetSpace, _size.X / 2)); m_expectedCollisionContacts = 3; } catch (AccessViolationException) @@ -1478,7 +1478,7 @@ Console.WriteLine("CreateGeom:"); try { //Console.WriteLine(" CreateGeom 2"); - SetGeom(SafeNativeMethods.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); + SetGeom(OdeNative.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); m_expectedCollisionContacts = 4; } catch (AccessViolationException) @@ -1494,7 +1494,7 @@ Console.WriteLine("CreateGeom:"); try { //Console.WriteLine(" CreateGeom 3"); - SetGeom(SafeNativeMethods.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); + SetGeom(OdeNative.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); m_expectedCollisionContacts = 4; } catch (AccessViolationException) @@ -1510,7 +1510,7 @@ Console.WriteLine("CreateGeom:"); try { //Console.WriteLine(" CreateGeom 4"); - SetGeom(SafeNativeMethods.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); + SetGeom(OdeNative.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); m_expectedCollisionContacts = 4; } catch (AccessViolationException) @@ -1536,7 +1536,7 @@ Console.WriteLine("CreateGeom:"); { _parent_scene.geom_name_map.Remove(prim_geom); _parent_scene.actor_name_map.Remove(prim_geom); - SafeNativeMethods.GeomDestroy(prim_geom); + OdeNative.GeomDestroy(prim_geom); m_expectedCollisionContacts = 0; prim_geom = IntPtr.Zero; } @@ -1593,13 +1593,13 @@ Console.WriteLine("changeadd 1"); #endif CreateGeom(m_targetSpace, mesh); - SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + OdeNative.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + OdeNative.Quaternion myrot = new OdeNative.Quaternion(); myrot.X = _orientation.X; myrot.Y = _orientation.Y; myrot.Z = _orientation.Z; myrot.W = _orientation.W; - SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot); + OdeNative.GeomSetQuaternion(prim_geom, ref myrot); if (IsPhysical && Body == IntPtr.Zero) enableBody(); @@ -1627,14 +1627,14 @@ Console.WriteLine("changeadd 1"); { if (m_linkJoint != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(m_linkJoint); + OdeNative.JointDestroy(m_linkJoint); m_linkJoint = IntPtr.Zero; } } if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + OdeNative.BodySetPosition(Body, _position.X, _position.Y, _position.Z); if (_parent != null) { @@ -1643,12 +1643,12 @@ Console.WriteLine("changeadd 1"); { // KF: Fixed Joints were removed? Anyway - this Console.WriteLine does not show up, so routine is not used?? Console.WriteLine(" JointCreateFixed"); - m_linkJoint = SafeNativeMethods.JointCreateFixed(_parent_scene.world, _linkJointGroup); - SafeNativeMethods.JointAttach(m_linkJoint, Body, odParent.Body); - SafeNativeMethods.JointSetFixed(m_linkJoint); + m_linkJoint = OdeNative.JointCreateFixed(_parent_scene.world, _linkJointGroup); + OdeNative.JointAttach(m_linkJoint, Body, odParent.Body); + OdeNative.JointSetFixed(m_linkJoint); } } - SafeNativeMethods.BodyEnable(Body); + OdeNative.BodyEnable(Body); if (m_vehicle.Type != Vehicle.TYPE_NONE) { m_vehicle.Enable(Body, _parent_scene); @@ -1674,10 +1674,10 @@ Console.WriteLine(" JointCreateFixed"); // _parent_scene.waitForSpaceUnlock(m_targetSpace); - SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + OdeNative.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); // _parent_scene.waitForSpaceUnlock(m_targetSpace); - SafeNativeMethods.SpaceAdd(m_targetSpace, prim_geom); + OdeNative.SpaceAdd(m_targetSpace, prim_geom); changeSelectedStatus(); @@ -1704,7 +1704,7 @@ Console.WriteLine(" JointCreateFixed"); else { //Console.WriteLine("Move " + Name); - if (!SafeNativeMethods.BodyIsEnabled (Body)) SafeNativeMethods.BodyEnable (Body); // KF add 161009 + if (!OdeNative.BodyIsEnabled (Body)) OdeNative.BodyEnable (Body); // KF add 161009 float m_mass = CalculateMass(); @@ -1746,9 +1746,9 @@ Console.WriteLine(" JointCreateFixed"); //PidStatus = true; // PhysicsVector vec = new PhysicsVector(); - SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body); + OdeNative.Vector3 vel = OdeNative.BodyGetLinearVel(Body); - SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body); + OdeNative.Vector3 pos = OdeNative.BodyGetPosition(Body); _target_velocity = new Vector3( (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), @@ -1770,9 +1770,9 @@ Console.WriteLine(" JointCreateFixed"); //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; - SafeNativeMethods.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); - SafeNativeMethods.BodyAddForce(Body, 0, 0, fz); + OdeNative.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); + OdeNative.BodySetLinearVel(Body, 0, 0, 0); + OdeNative.BodyAddForce(Body, 0, 0, fz); return; } else @@ -1813,8 +1813,8 @@ Console.WriteLine(" JointCreateFixed"); } // Where are we, and where are we headed? - SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body); - SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body); + OdeNative.Vector3 pos = OdeNative.BodyGetPosition(Body); + OdeNative.Vector3 vel = OdeNative.BodyGetLinearVel(Body); // Non-Vehicles have a limited set of Hover options. // determine what our target height really is based on HoverType @@ -1856,9 +1856,9 @@ Console.WriteLine(" JointCreateFixed"); // Avatar to Avatar collisions // Prim to avatar collisions - SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); - SafeNativeMethods.BodySetLinearVel(Body, vel.X, vel.Y, 0); - SafeNativeMethods.BodyAddForce(Body, 0, 0, fz); + OdeNative.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); + OdeNative.BodySetLinearVel(Body, vel.X, vel.Y, 0); + OdeNative.BodyAddForce(Body, 0, 0, fz); return; } else @@ -1884,13 +1884,13 @@ Console.WriteLine(" JointCreateFixed"); //m_taintdisable = true; //base.RaiseOutOfBounds(Position); //d.BodySetLinearVel(Body, fx, fy, 0f); - if (!SafeNativeMethods.BodyIsEnabled(Body)) + if (!OdeNative.BodyIsEnabled(Body)) { // A physical body at rest on a surface will auto-disable after a while, // this appears to re-enable it incase the surface it is upon vanishes, // and the body should fall again. - SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f); - SafeNativeMethods.BodySetForce(Body, 0, 0, 0); + OdeNative.BodySetLinearVel(Body, 0f, 0f, 0f); + OdeNative.BodySetForce(Body, 0, 0, 0); enableBodySoft(); } @@ -1906,7 +1906,7 @@ Console.WriteLine(" JointCreateFixed"); fy = nmax; if (fy < nmin) fy = nmin; - SafeNativeMethods.BodyAddForce(Body, fx, fy, fz); + OdeNative.BodyAddForce(Body, fx, fy, fz); //Console.WriteLine("AddForce " + fx + "," + fy + "," + fz); } } @@ -1922,7 +1922,7 @@ Console.WriteLine(" JointCreateFixed"); private void rotate() { - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + OdeNative.Quaternion myrot = new OdeNative.Quaternion(); myrot.X = _orientation.X; myrot.Y = _orientation.Y; myrot.Z = _orientation.Z; @@ -1930,7 +1930,7 @@ Console.WriteLine(" JointCreateFixed"); if (Body != IntPtr.Zero) { // KF: If this is a root prim do BodySet - SafeNativeMethods.BodySetQuaternion(Body, ref myrot); + OdeNative.BodySetQuaternion(Body, ref myrot); if (IsPhysical) { // create or remove locks @@ -1940,7 +1940,7 @@ Console.WriteLine(" JointCreateFixed"); else { // daughter prim, do Geom set - SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot); + OdeNative.GeomSetQuaternion(prim_geom, ref myrot); } resetCollisionAccounting(); @@ -1962,7 +1962,7 @@ Console.WriteLine(" JointCreateFixed"); m_disabled = true; if (Body != IntPtr.Zero) { - SafeNativeMethods.BodyDisable(Body); + OdeNative.BodyDisable(Body); Body = IntPtr.Zero; } @@ -2051,10 +2051,10 @@ Console.WriteLine(" JointCreateFixed"); } } - if (SafeNativeMethods.SpaceQuery(m_targetSpace, prim_geom)) + if (OdeNative.SpaceQuery(m_targetSpace, prim_geom)) { // _parent_scene.waitForSpaceUnlock(m_targetSpace); - SafeNativeMethods.SpaceRemove(m_targetSpace, prim_geom); + OdeNative.SpaceRemove(m_targetSpace, prim_geom); } RemoveGeom(); @@ -2084,13 +2084,13 @@ Console.WriteLine(" JointCreateFixed"); } CreateGeom(m_targetSpace, mesh); - SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + OdeNative.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + OdeNative.Quaternion myrot = new OdeNative.Quaternion(); myrot.X = _orientation.X; myrot.Y = _orientation.Y; myrot.Z = _orientation.Z; myrot.W = _orientation.W; - SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot); + OdeNative.GeomSetQuaternion(prim_geom, ref myrot); //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); if (IsPhysical && Body == IntPtr.Zero && !childPrim) @@ -2098,7 +2098,7 @@ Console.WriteLine(" JointCreateFixed"); // Re creates body on size. // EnableBody also does setMass() enableBody(); - SafeNativeMethods.BodyEnable(Body); + OdeNative.BodyEnable(Body); } changeSelectedStatus(); @@ -2133,10 +2133,10 @@ Console.WriteLine(" JointCreateFixed"); } if (m_assetFailed) - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); + OdeNative.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); else - SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); + OdeNative.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); } /// /// Change prim in response to a shape taint. @@ -2190,14 +2190,14 @@ Console.WriteLine(" JointCreateFixed"); } CreateGeom(m_targetSpace, mesh); - SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + OdeNative.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + OdeNative.Quaternion myrot = new OdeNative.Quaternion(); //myrot.W = _orientation.w; myrot.W = _orientation.W; myrot.X = _orientation.X; myrot.Y = _orientation.Y; myrot.Z = _orientation.Z; - SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot); + OdeNative.GeomSetQuaternion(prim_geom, ref myrot); //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); if (IsPhysical && Body == IntPtr.Zero) @@ -2207,7 +2207,7 @@ Console.WriteLine(" JointCreateFixed"); enableBody(); if (Body != IntPtr.Zero) { - SafeNativeMethods.BodyEnable(Body); + OdeNative.BodyEnable(Body); } } @@ -2264,8 +2264,8 @@ Console.WriteLine(" JointCreateFixed"); m_taintforce = false; return; } - SafeNativeMethods.BodyEnable(Body); - SafeNativeMethods.BodyAddForce(Body, iforce.X, iforce.Y, iforce.Z); + OdeNative.BodyEnable(Body); + OdeNative.BodyAddForce(Body, iforce.X, iforce.Y, iforce.Z); } m_forcelist.Clear(); } @@ -2286,7 +2286,7 @@ Console.WriteLine(" JointCreateFixed"); { if (IsPhysical && Body != IntPtr.Zero) { - SafeNativeMethods.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); + OdeNative.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); } } @@ -2310,8 +2310,8 @@ Console.WriteLine(" JointCreateFixed"); { iforce = iforce + (m_angularforcelist[i] * 100); } - SafeNativeMethods.BodyEnable(Body); - SafeNativeMethods.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z); + OdeNative.BodyEnable(Body); + OdeNative.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z); } m_angularforcelist.Clear(); @@ -2339,7 +2339,7 @@ Console.WriteLine(" JointCreateFixed"); { if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); + OdeNative.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); } } @@ -2667,7 +2667,7 @@ Console.WriteLine(" JointCreateFixed"); } */ - SafeNativeMethods.AllocateODEDataForThread(0); + OdeNative.AllocateODEDataForThread(0); _position.X = Utils.Clamp(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); _position.Y = Utils.Clamp(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); @@ -2682,8 +2682,8 @@ Console.WriteLine(" JointCreateFixed"); if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); // stop it - SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + OdeNative.BodySetLinearVel(Body, 0, 0, 0); // stop it + OdeNative.BodySetPosition(Body, _position.X, _position.Y, _position.Z); } if(m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) @@ -2730,11 +2730,11 @@ Console.WriteLine(" JointCreateFixed"); float m_minvelocity = 0; if (Body != IntPtr.Zero) // FIXME -> or if it is a joint { - SafeNativeMethods.Vector3 vec = SafeNativeMethods.BodyGetPosition(Body); - SafeNativeMethods.Quaternion ori = SafeNativeMethods.BodyGetQuaternion(Body); - SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body); - SafeNativeMethods.Vector3 rotvel = SafeNativeMethods.BodyGetAngularVel(Body); - SafeNativeMethods.Vector3 torque = SafeNativeMethods.BodyGetTorque(Body); + OdeNative.Vector3 vec = OdeNative.BodyGetPosition(Body); + OdeNative.Quaternion ori = OdeNative.BodyGetQuaternion(Body); + OdeNative.Vector3 vel = OdeNative.BodyGetLinearVel(Body); + OdeNative.Vector3 rotvel = OdeNative.BodyGetAngularVel(Body); + OdeNative.Vector3 torque = OdeNative.BodyGetTorque(Body); _torque = new Vector3(torque.X, torque.Y, torque.Z); Vector3 l_position = Vector3.Zero; Quaternion l_orientation = Quaternion.Identity; @@ -2814,11 +2814,11 @@ Console.WriteLine(" JointCreateFixed"); else Util.Clamp(l_position.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); - SafeNativeMethods.BodySetPosition(Body, l_position.X, l_position.Y, l_position.Z); + OdeNative.BodySetPosition(Body, l_position.X, l_position.Y, l_position.Z); // stop it - SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0); - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); + OdeNative.BodySetAngularVel(Body, 0, 0, 0); + OdeNative.BodySetLinearVel(Body, 0, 0, 0); disableBodySoft(); _position = l_position; @@ -3011,7 +3011,7 @@ Console.WriteLine(" JointCreateFixed"); if (Amotor != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(Amotor); + OdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } @@ -3041,19 +3041,19 @@ Console.WriteLine(" JointCreateFixed"); if(axisnum == 0) return; // stop it - SafeNativeMethods.BodySetTorque(Body, 0, 0, 0); - SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0); + OdeNative.BodySetTorque(Body, 0, 0, 0); + OdeNative.BodySetAngularVel(Body, 0, 0, 0); - Amotor = SafeNativeMethods.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); - SafeNativeMethods.JointAttach(Amotor, Body, IntPtr.Zero); + Amotor = OdeNative.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); + OdeNative.JointAttach(Amotor, Body, IntPtr.Zero); - SafeNativeMethods.JointSetAMotorMode(Amotor, 0); + OdeNative.JointSetAMotorMode(Amotor, 0); - SafeNativeMethods.JointSetAMotorNumAxes(Amotor, axisnum); + OdeNative.JointSetAMotorNumAxes(Amotor, axisnum); // get current orientation to lock - SafeNativeMethods.Quaternion dcur = SafeNativeMethods.BodyGetQuaternion(Body); + OdeNative.Quaternion dcur = OdeNative.BodyGetQuaternion(Body); Quaternion curr; // crap convertion between identical things curr.X = dcur.X; curr.Y = dcur.Y; @@ -3066,17 +3066,17 @@ Console.WriteLine(" JointCreateFixed"); if (axisX) { ax = (new Vector3(1, 0, 0)) * curr; // rotate world X to current local X - SafeNativeMethods.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 0, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.LoStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.HiStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Bounce, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.CFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.StopCFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.StopERP, 0.8f); + OdeNative.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); + OdeNative.JointSetAMotorAngle(Amotor, 0, 0); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.LoStop, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.HiStop, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.Vel, 0); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.FudgeFactor, 0.0001f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.Bounce, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.CFM, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.FMax, 5e8f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.StopCFM, 0f); + OdeNative.JointSetAMotorParam(Amotor, (int)OdeNative.JointParam.StopERP, 0.8f); i++; j = 256; // move to next axis set } @@ -3084,17 +3084,17 @@ Console.WriteLine(" JointCreateFixed"); if (axisY) { ax = (new Vector3(0, 1, 0)) * curr; - SafeNativeMethods.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); - SafeNativeMethods.JointSetAMotorAngle(Amotor, i, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.LoStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.HiStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Bounce, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.CFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopCFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopERP, 0.8f); + OdeNative.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); + OdeNative.JointSetAMotorAngle(Amotor, i, 0); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.LoStop, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.HiStop, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.Vel, 0); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.FudgeFactor, 0.0001f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.Bounce, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.CFM, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.FMax, 5e8f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.StopCFM, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.StopERP, 0.8f); i++; j += 256; } @@ -3102,17 +3102,17 @@ Console.WriteLine(" JointCreateFixed"); if (axisZ) { ax = (new Vector3(0, 0, 1)) * curr; - SafeNativeMethods.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); - SafeNativeMethods.JointSetAMotorAngle(Amotor, i, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.LoStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.HiStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Bounce, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.CFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopCFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopERP, 0.8f); + OdeNative.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); + OdeNative.JointSetAMotorAngle(Amotor, i, 0); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.LoStop, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.HiStop, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.Vel, 0); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.FudgeFactor, 0.0001f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.Bounce, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.CFM, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.FMax, 5e8f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.StopCFM, 0f); + OdeNative.JointSetAMotorParam(Amotor, j + (int)OdeNative.JointParam.StopERP, 0.8f); } } diff --git a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs index c731c6c86e..892032620f 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs @@ -61,12 +61,12 @@ namespace OpenSim.Region.PhysicsModule.ODE /// /// ODE contact array to be filled by the collision testing /// - SafeNativeMethods.ContactGeom[] contacts = new SafeNativeMethods.ContactGeom[5]; + OdeNative.ContactGeom[] contacts = new OdeNative.ContactGeom[5]; /// /// ODE near callback delegate /// - private SafeNativeMethods.NearCallback nearCallback; + private OdeNative.NearCallback nearCallback; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private List m_contactResults = new List(); @@ -179,14 +179,14 @@ namespace OpenSim.Region.PhysicsModule.ODE len = 100f; // Create the ray - IntPtr ray = SafeNativeMethods.CreateRay(m_scene.space, len); - SafeNativeMethods.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); + IntPtr ray = OdeNative.CreateRay(m_scene.space, len); + OdeNative.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test - SafeNativeMethods.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); + OdeNative.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); // Remove Ray - SafeNativeMethods.GeomDestroy(ray); + OdeNative.GeomDestroy(ray); // Define default results bool hitYN = false; @@ -230,14 +230,14 @@ namespace OpenSim.Region.PhysicsModule.ODE len = 100f; // Create the ray - IntPtr ray = SafeNativeMethods.CreateRay(m_scene.space, len); - SafeNativeMethods.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); + IntPtr ray = OdeNative.CreateRay(m_scene.space, len); + OdeNative.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test - SafeNativeMethods.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); + OdeNative.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); // Remove Ray - SafeNativeMethods.GeomDestroy(ray); + OdeNative.GeomDestroy(ray); // Find closest contact and object. lock (m_contactResults) @@ -258,7 +258,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // return; // Raytest against AABBs of spaces first, then dig into the spaces it hits for actual geoms. - if (SafeNativeMethods.GeomIsSpace(g1) || SafeNativeMethods.GeomIsSpace(g2)) + if (OdeNative.GeomIsSpace(g1) || OdeNative.GeomIsSpace(g2)) { if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) return; @@ -269,7 +269,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // contact points in the space try { - SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); + OdeNative.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); } catch (AccessViolationException) { @@ -296,7 +296,7 @@ namespace OpenSim.Region.PhysicsModule.ODE lock (contacts) { - count = SafeNativeMethods.Collide(g1, g2, contacts.GetLength(0), contacts, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = OdeNative.Collide(g1, g2, contacts.GetLength(0), contacts, OdeNative.ContactGeom.unmanagedSizeOf); } } catch (SEHException) diff --git a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs index 8ffd1250b8..37a9d01989 100644 --- a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs +++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs @@ -336,7 +336,7 @@ namespace OpenSim.Region.PhysicsModule.ODE private bool m_filterCollisions = true; - private SafeNativeMethods.NearCallback nearCallback; + private OdeNative.NearCallback nearCallback; /// /// Avatars in the physics scene. @@ -366,7 +366,7 @@ namespace OpenSim.Region.PhysicsModule.ODE /// /// Keep record of contacts in the physics loop so that we can remove duplicates. /// - private readonly List _perloopContact = new List(); + private readonly List _perloopContact = new List(); /// /// A dictionary of actors that should receive collision events. @@ -404,17 +404,17 @@ namespace OpenSim.Region.PhysicsModule.ODE /// private readonly List defects = new List(); - private SafeNativeMethods.ContactGeom[] contacts; + private OdeNative.ContactGeom[] contacts; private readonly DoubleDictionary RegionTerrain = new DoubleDictionary(); private readonly Dictionary TerrainHeightFieldHeights = new Dictionary(); - private SafeNativeMethods.Contact contact; - private SafeNativeMethods.Contact TerrainContact; - private SafeNativeMethods.Contact AvatarMovementprimContact; - private SafeNativeMethods.Contact AvatarMovementTerrainContact; - private SafeNativeMethods.Contact WaterContact; - private SafeNativeMethods.Contact[,] m_materialContacts; + private OdeNative.Contact contact; + private OdeNative.Contact TerrainContact; + private OdeNative.Contact AvatarMovementprimContact; + private OdeNative.Contact AvatarMovementTerrainContact; + private OdeNative.Contact WaterContact; + private OdeNative.Contact[,] m_materialContacts; private int m_physicsiterations = 10; private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag @@ -452,8 +452,8 @@ namespace OpenSim.Region.PhysicsModule.ODE private bool avplanted = false; private bool av_av_collisions_off = false; - internal SafeNativeMethods.Vector3 xyz = new SafeNativeMethods.Vector3(128.1640f, 128.3079f, 25.7600f); - internal SafeNativeMethods.Vector3 hpr = new SafeNativeMethods.Vector3(125.5000f, -17.0000f, 0.0000f); + internal OdeNative.Vector3 xyz = new OdeNative.Vector3(128.1640f, 128.3079f, 25.7600f); + internal OdeNative.Vector3 hpr = new OdeNative.Vector3(125.5000f, -17.0000f, 0.0000f); private volatile int m_global_contactcount = 0; @@ -472,7 +472,7 @@ namespace OpenSim.Region.PhysicsModule.ODE public OdeScene(Scene pscene, IConfigSource psourceconfig, string pname, string pversion) { - SafeNativeMethods.AllocateODEDataForThread(~0U); + OdeNative.AllocateODEDataForThread(~0U); m_config = psourceconfig; m_frameWorkScene = pscene; @@ -518,11 +518,11 @@ namespace OpenSim.Region.PhysicsModule.ODE m_rayCastManager = new ODERayCastRequestManager(this); // Create the world and the first space - world = SafeNativeMethods.WorldCreate(); - space = SafeNativeMethods.HashSpaceCreate(IntPtr.Zero); - contactgroup = SafeNativeMethods.JointGroupCreate(0); + world = OdeNative.WorldCreate(); + space = OdeNative.HashSpaceCreate(IntPtr.Zero); + contactgroup = OdeNative.JointGroupCreate(0); - SafeNativeMethods.WorldSetAutoDisableFlag(world, false); + OdeNative.WorldSetAutoDisableFlag(world, false); } // Initialize from configs @@ -623,7 +623,7 @@ namespace OpenSim.Region.PhysicsModule.ODE } } - contacts = new SafeNativeMethods.ContactGeom[contactsPerCollision]; + contacts = new OdeNative.ContactGeom[contactsPerCollision]; spacesPerMeterX = 1.0f / metersInSpace; spacesPerMeterY = 1.0f / metersInSpace; @@ -652,7 +652,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // Centeral contact friction and bounce // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why // an avatar falls through in Z but not in X or Y when walking on a prim. - contact.surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + contact.surface.mode |= OdeNative.ContactFlags.SoftERP; contact.surface.mu = nmAvatarObjectContactFriction; contact.surface.bounce = nmAvatarObjectContactBounce; contact.surface.soft_cfm = 0.010f; @@ -661,12 +661,12 @@ namespace OpenSim.Region.PhysicsModule.ODE // 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 |= SafeNativeMethods.ContactFlags.SoftERP; + TerrainContact.surface.mode |= OdeNative.ContactFlags.SoftERP; TerrainContact.surface.mu = nmTerrainContactFriction; TerrainContact.surface.bounce = nmTerrainContactBounce; TerrainContact.surface.soft_erp = nmTerrainContactERP; - WaterContact.surface.mode |= (SafeNativeMethods.ContactFlags.SoftERP | SafeNativeMethods.ContactFlags.SoftCFM); + WaterContact.surface.mode |= (OdeNative.ContactFlags.SoftERP | OdeNative.ContactFlags.SoftCFM); WaterContact.surface.mu = 0f; // No friction WaterContact.surface.bounce = 0.0f; // No bounce WaterContact.surface.soft_cfm = 0.010f; @@ -681,7 +681,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // Terrain contact friction bounce and various error correcting calculations // Use this when an avatar is in contact with the terrain and moving. - AvatarMovementTerrainContact.surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + AvatarMovementTerrainContact.surface.mode |= OdeNative.ContactFlags.SoftERP; AvatarMovementTerrainContact.surface.mu = mTerrainContactFriction; AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce; AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP; @@ -703,38 +703,38 @@ namespace OpenSim.Region.PhysicsModule.ODE Rubber = 6 */ - m_materialContacts = new SafeNativeMethods.Contact[7,2]; + m_materialContacts = new OdeNative.Contact[7,2]; - m_materialContacts[(int)Material.Stone, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Stone, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Stone, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Stone, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Stone, 0].surface.mu = nmAvatarObjectContactFriction; m_materialContacts[(int)Material.Stone, 0].surface.bounce = nmAvatarObjectContactBounce; m_materialContacts[(int)Material.Stone, 0].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Stone, 0].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Stone, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Stone, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Stone, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Stone, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Stone, 1].surface.mu = mAvatarObjectContactFriction; m_materialContacts[(int)Material.Stone, 1].surface.bounce = mAvatarObjectContactBounce; m_materialContacts[(int)Material.Stone, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Stone, 1].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Metal, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Metal, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Metal, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Metal, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Metal, 0].surface.mu = nmAvatarObjectContactFriction; m_materialContacts[(int)Material.Metal, 0].surface.bounce = nmAvatarObjectContactBounce; m_materialContacts[(int)Material.Metal, 0].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Metal, 0].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Metal, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Metal, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Metal, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Metal, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Metal, 1].surface.mu = mAvatarObjectContactFriction; m_materialContacts[(int)Material.Metal, 1].surface.bounce = mAvatarObjectContactBounce; m_materialContacts[(int)Material.Metal, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Metal, 1].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Glass, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Glass, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Glass, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Glass, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Glass, 0].surface.mu = 1f; m_materialContacts[(int)Material.Glass, 0].surface.bounce = 0.5f; m_materialContacts[(int)Material.Glass, 0].surface.soft_cfm = 0.010f; @@ -747,83 +747,83 @@ namespace OpenSim.Region.PhysicsModule.ODE private float mAvatarObjectContactFriction = 75f; private float mAvatarObjectContactBounce = 0.1f; */ - m_materialContacts[(int)Material.Glass, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Glass, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Glass, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Glass, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Glass, 1].surface.mu = 1f; m_materialContacts[(int)Material.Glass, 1].surface.bounce = 0.5f; m_materialContacts[(int)Material.Glass, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Glass, 1].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Wood, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Wood, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Wood, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Wood, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Wood, 0].surface.mu = nmAvatarObjectContactFriction; m_materialContacts[(int)Material.Wood, 0].surface.bounce = nmAvatarObjectContactBounce; m_materialContacts[(int)Material.Wood, 0].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Wood, 0].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Wood, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Wood, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Wood, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Wood, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Wood, 1].surface.mu = mAvatarObjectContactFriction; m_materialContacts[(int)Material.Wood, 1].surface.bounce = mAvatarObjectContactBounce; m_materialContacts[(int)Material.Wood, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Wood, 1].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Flesh, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Flesh, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Flesh, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Flesh, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Flesh, 0].surface.mu = nmAvatarObjectContactFriction; m_materialContacts[(int)Material.Flesh, 0].surface.bounce = nmAvatarObjectContactBounce; m_materialContacts[(int)Material.Flesh, 0].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Flesh, 0].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Flesh, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Flesh, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Flesh, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Flesh, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Flesh, 1].surface.mu = mAvatarObjectContactFriction; m_materialContacts[(int)Material.Flesh, 1].surface.bounce = mAvatarObjectContactBounce; m_materialContacts[(int)Material.Flesh, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Flesh, 1].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Plastic, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Plastic, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Plastic, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Plastic, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Plastic, 0].surface.mu = nmAvatarObjectContactFriction; m_materialContacts[(int)Material.Plastic, 0].surface.bounce = nmAvatarObjectContactBounce; m_materialContacts[(int)Material.Plastic, 0].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Plastic, 0].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Plastic, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Plastic, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Plastic, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Plastic, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Plastic, 1].surface.mu = mAvatarObjectContactFriction; m_materialContacts[(int)Material.Plastic, 1].surface.bounce = mAvatarObjectContactBounce; m_materialContacts[(int)Material.Plastic, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Plastic, 1].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Rubber, 0] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Rubber, 0].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Rubber, 0] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Rubber, 0].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Rubber, 0].surface.mu = nmAvatarObjectContactFriction; m_materialContacts[(int)Material.Rubber, 0].surface.bounce = nmAvatarObjectContactBounce; m_materialContacts[(int)Material.Rubber, 0].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Rubber, 0].surface.soft_erp = 0.010f; - m_materialContacts[(int)Material.Rubber, 1] = new SafeNativeMethods.Contact(); - m_materialContacts[(int)Material.Rubber, 1].surface.mode |= SafeNativeMethods.ContactFlags.SoftERP; + m_materialContacts[(int)Material.Rubber, 1] = new OdeNative.Contact(); + m_materialContacts[(int)Material.Rubber, 1].surface.mode |= OdeNative.ContactFlags.SoftERP; m_materialContacts[(int)Material.Rubber, 1].surface.mu = mAvatarObjectContactFriction; m_materialContacts[(int)Material.Rubber, 1].surface.bounce = mAvatarObjectContactBounce; m_materialContacts[(int)Material.Rubber, 1].surface.soft_cfm = 0.010f; m_materialContacts[(int)Material.Rubber, 1].surface.soft_erp = 0.010f; - SafeNativeMethods.HashSpaceSetLevels(space, HashspaceLow, HashspaceHigh); + OdeNative.HashSpaceSetLevels(space, HashspaceLow, HashspaceHigh); // Set the gravity,, don't disable things automatically (we set it explicitly on some things) - SafeNativeMethods.WorldSetGravity(world, gravityx, gravityy, gravityz); - SafeNativeMethods.WorldSetContactSurfaceLayer(world, contactsurfacelayer); + OdeNative.WorldSetGravity(world, gravityx, gravityy, gravityz); + OdeNative.WorldSetContactSurfaceLayer(world, contactsurfacelayer); - SafeNativeMethods.WorldSetLinearDamping(world, 256f); - SafeNativeMethods.WorldSetAngularDamping(world, 256f); - SafeNativeMethods.WorldSetAngularDampingThreshold(world, 256f); - SafeNativeMethods.WorldSetLinearDampingThreshold(world, 256f); - SafeNativeMethods.WorldSetMaxAngularSpeed(world, 256f); + OdeNative.WorldSetLinearDamping(world, 256f); + OdeNative.WorldSetAngularDamping(world, 256f); + OdeNative.WorldSetAngularDampingThreshold(world, 256f); + OdeNative.WorldSetLinearDampingThreshold(world, 256f); + OdeNative.WorldSetMaxAngularSpeed(world, 256f); - SafeNativeMethods.WorldSetQuickStepNumIterations(world, m_physicsiterations); + OdeNative.WorldSetQuickStepNumIterations(world, m_physicsiterations); //d.WorldSetContactMaxCorrectingVel(world, 1000.0f); for (int i = 0; i < staticPrimspace.GetLength(0); i++) @@ -849,7 +849,7 @@ namespace OpenSim.Region.PhysicsModule.ODE /// /// private int CollideGeoms( - IntPtr geom1, IntPtr geom2, int maxContacts, SafeNativeMethods.ContactGeom[] contactsArray, int contactGeomSize) + IntPtr geom1, IntPtr geom2, int maxContacts, OdeNative.ContactGeom[] contactsArray, int contactGeomSize) { int count; @@ -859,7 +859,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (CollectStats) m_nativeCollisionStartTick = Util.EnvironmentTickCount(); - count = SafeNativeMethods.Collide(geom1, geom2, maxContacts, contactsArray, contactGeomSize); + count = OdeNative.Collide(geom1, geom2, maxContacts, contactsArray, contactGeomSize); } // We do this outside the lock so that any waiting threads aren't held up, though the effect is probably @@ -885,7 +885,7 @@ namespace OpenSim.Region.PhysicsModule.ODE m_nativeCollisionStartTick = Util.EnvironmentTickCount(); } - SafeNativeMethods.SpaceCollide2(space1, space2, data, nearCallback); + OdeNative.SpaceCollide2(space1, space2, data, nearCallback); if (CollectStats && m_inCollisionTiming) { @@ -916,7 +916,7 @@ namespace OpenSim.Region.PhysicsModule.ODE // Test if we're colliding a geom with a space. // If so we have to drill down into the space recursively - if (SafeNativeMethods.GeomIsSpace(g1) || SafeNativeMethods.GeomIsSpace(g2)) + if (OdeNative.GeomIsSpace(g1) || OdeNative.GeomIsSpace(g2)) { if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) return; @@ -945,8 +945,8 @@ namespace OpenSim.Region.PhysicsModule.ODE if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) return; - IntPtr b1 = SafeNativeMethods.GeomGetBody(g1); - IntPtr b2 = SafeNativeMethods.GeomGetBody(g2); + IntPtr b1 = OdeNative.GeomGetBody(g1); + IntPtr b2 = OdeNative.GeomGetBody(g2); // d.GeomClassID id = d.GeomGetClass(g1); @@ -973,10 +973,10 @@ namespace OpenSim.Region.PhysicsModule.ODE if (g1 == g2) return; // Can't collide with yourself - if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && SafeNativeMethods.AreConnectedExcluding(b1, b2, SafeNativeMethods.JointType.Contact)) + if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && OdeNative.AreConnectedExcluding(b1, b2, OdeNative.JointType.Contact)) return; - count = CollideGeoms(g1, g2, contacts.Length, contacts, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = CollideGeoms(g1, g2, contacts.Length, contacts, OdeNative.ContactGeom.unmanagedSizeOf); // All code after this is only relevant if we have any collisions if (count <= 0) @@ -1024,7 +1024,7 @@ namespace OpenSim.Region.PhysicsModule.ODE for (int i = 0; i < count; i++) { - SafeNativeMethods.ContactGeom curContact = contacts[i]; + OdeNative.ContactGeom curContact = contacts[i]; if (curContact.depth > maxDepthContact.PenetrationDepth) { @@ -1101,7 +1101,7 @@ namespace OpenSim.Region.PhysicsModule.ODE curContact.depth = 0.00000003f; p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f); curContact.pos = - new SafeNativeMethods.Vector3(curContact.pos.X + (p1.Size.X/2), + new OdeNative.Vector3(curContact.pos.X + (p1.Size.X/2), curContact.pos.Y + (p1.Size.Y/2), curContact.pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); @@ -1118,7 +1118,7 @@ namespace OpenSim.Region.PhysicsModule.ODE curContact.depth = 0.00000003f; p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f); curContact.pos = - new SafeNativeMethods.Vector3(curContact.pos.X + (p1.Size.X/2), + new OdeNative.Vector3(curContact.pos.X + (p1.Size.X/2), curContact.pos.Y + (p1.Size.Y/2), curContact.pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); @@ -1170,7 +1170,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); + joint = OdeNative.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); m_global_contactcount++; } } @@ -1184,7 +1184,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref TerrainContact); + joint = OdeNative.JointCreateContact(world, contactgroup, ref TerrainContact); m_global_contactcount++; } } @@ -1219,7 +1219,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]); + joint = OdeNative.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]); m_global_contactcount++; } } @@ -1245,7 +1245,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]); + joint = OdeNative.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]); m_global_contactcount++; } } @@ -1279,7 +1279,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref WaterContact); + joint = OdeNative.JointCreateContact(world, contactgroup, ref WaterContact); m_global_contactcount++; } //m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth); @@ -1296,7 +1296,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); + joint = OdeNative.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); m_global_contactcount++; } } @@ -1307,7 +1307,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref contact); + joint = OdeNative.JointCreateContact(world, contactgroup, ref contact); m_global_contactcount++; } } @@ -1328,7 +1328,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath) { - joint = SafeNativeMethods.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]); + joint = OdeNative.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]); m_global_contactcount++; } } @@ -1336,7 +1336,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (m_global_contactcount < maxContactsbeforedeath && joint != IntPtr.Zero) // stack collide! { - SafeNativeMethods.JointAttach(joint, b1, b2); + OdeNative.JointAttach(joint, b1, b2); m_global_contactcount++; } } @@ -1356,7 +1356,7 @@ namespace OpenSim.Region.PhysicsModule.ODE } } - private bool checkDupe(SafeNativeMethods.ContactGeom contactGeom, int atype) + private bool checkDupe(OdeNative.ContactGeom contactGeom, int atype) { if (!m_filterCollisions) return false; @@ -1365,7 +1365,7 @@ namespace OpenSim.Region.PhysicsModule.ODE ActorTypes at = (ActorTypes)atype; - foreach (SafeNativeMethods.ContactGeom contact in _perloopContact) + foreach (OdeNative.ContactGeom contact in _perloopContact) { //if ((contact.g1 == contactGeom.g1 && contact.g2 == contactGeom.g2)) //{ @@ -1552,7 +1552,7 @@ namespace OpenSim.Region.PhysicsModule.ODE List removeprims = null; foreach (OdePrim chr in _activeprims) { - if (chr.Body != IntPtr.Zero && SafeNativeMethods.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) + if (chr.Body != IntPtr.Zero && OdeNative.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) { try { @@ -1678,7 +1678,7 @@ namespace OpenSim.Region.PhysicsModule.ODE public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) { - SafeNativeMethods.AllocateODEDataForThread(0); + OdeNative.AllocateODEDataForThread(0); OdeCharacter newAv = new OdeCharacter( @@ -1701,7 +1701,7 @@ namespace OpenSim.Region.PhysicsModule.ODE lock (OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(0); + OdeNative.AllocateODEDataForThread(0); ((OdeCharacter) actor).Destroy(); } @@ -1758,7 +1758,7 @@ namespace OpenSim.Region.PhysicsModule.ODE OdePrim newPrim; lock (OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(0); + OdeNative.AllocateODEDataForThread(0); newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical); lock (_prims) @@ -1916,12 +1916,12 @@ namespace OpenSim.Region.PhysicsModule.ODE //{ //int adfadf = 0; //} - if (SafeNativeMethods.SpaceQuery(currentspace, geom) && currentspace != IntPtr.Zero) + if (OdeNative.SpaceQuery(currentspace, geom) && currentspace != IntPtr.Zero) { - if (SafeNativeMethods.GeomIsSpace(currentspace)) + if (OdeNative.GeomIsSpace(currentspace)) { // waitForSpaceUnlock(currentspace); - SafeNativeMethods.SpaceRemove(currentspace, geom); + OdeNative.SpaceRemove(currentspace, geom); } else { @@ -1931,13 +1931,13 @@ namespace OpenSim.Region.PhysicsModule.ODE } else { - IntPtr sGeomIsIn = SafeNativeMethods.GeomGetSpace(geom); + IntPtr sGeomIsIn = OdeNative.GeomGetSpace(geom); if (sGeomIsIn != IntPtr.Zero) { - if (SafeNativeMethods.GeomIsSpace(currentspace)) + if (OdeNative.GeomIsSpace(currentspace)) { // waitForSpaceUnlock(sGeomIsIn); - SafeNativeMethods.SpaceRemove(sGeomIsIn, geom); + OdeNative.SpaceRemove(sGeomIsIn, geom); } else { @@ -1948,13 +1948,13 @@ namespace OpenSim.Region.PhysicsModule.ODE } //If there are no more geometries in the sub-space, we don't need it in the main space anymore - if (SafeNativeMethods.SpaceGetNumGeoms(currentspace) == 0) + if (OdeNative.SpaceGetNumGeoms(currentspace) == 0) { if (currentspace != IntPtr.Zero) { - if (SafeNativeMethods.GeomIsSpace(currentspace)) + if (OdeNative.GeomIsSpace(currentspace)) { - SafeNativeMethods.SpaceRemove(space, currentspace); + OdeNative.SpaceRemove(space, currentspace); // free up memory used by the space. resetSpaceArrayItemToZero(currentspace); @@ -1972,12 +1972,12 @@ namespace OpenSim.Region.PhysicsModule.ODE // this is a physical object that got disabled. ;.; if (currentspace != IntPtr.Zero && geom != IntPtr.Zero) { - if (SafeNativeMethods.SpaceQuery(currentspace, geom)) + if (OdeNative.SpaceQuery(currentspace, geom)) { - if (SafeNativeMethods.GeomIsSpace(currentspace)) + if (OdeNative.GeomIsSpace(currentspace)) { // waitForSpaceUnlock(currentspace); - SafeNativeMethods.SpaceRemove(currentspace, geom); + OdeNative.SpaceRemove(currentspace, geom); } else { @@ -1987,13 +1987,13 @@ namespace OpenSim.Region.PhysicsModule.ODE } else { - IntPtr sGeomIsIn = SafeNativeMethods.GeomGetSpace(geom); + IntPtr sGeomIsIn = OdeNative.GeomGetSpace(geom); if (sGeomIsIn != IntPtr.Zero) { - if (SafeNativeMethods.GeomIsSpace(sGeomIsIn)) + if (OdeNative.GeomIsSpace(sGeomIsIn)) { // waitForSpaceUnlock(sGeomIsIn); - SafeNativeMethods.SpaceRemove(sGeomIsIn, geom); + OdeNative.SpaceRemove(sGeomIsIn, geom); } else { @@ -2014,7 +2014,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (newspace == IntPtr.Zero) { newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); - SafeNativeMethods.HashSpaceSetLevels(newspace, HashspaceLow, HashspaceHigh); + OdeNative.HashSpaceSetLevels(newspace, HashspaceLow, HashspaceHigh); } return newspace; @@ -2029,11 +2029,11 @@ namespace OpenSim.Region.PhysicsModule.ODE internal IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) { // creating a new space for prim and inserting it into main space. - staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = SafeNativeMethods.HashSpaceCreate(IntPtr.Zero); - SafeNativeMethods.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space); + staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = OdeNative.HashSpaceCreate(IntPtr.Zero); + OdeNative.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space); // waitForSpaceUnlock(space); - SafeNativeMethods.SpaceSetSublevel(space, 1); - SafeNativeMethods.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); + OdeNative.SpaceSetSublevel(space, 1); + OdeNative.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; } @@ -2253,7 +2253,7 @@ namespace OpenSim.Region.PhysicsModule.ODE m_log.InfoFormat("[Ode] start processing pending actor operations"); int tstart = Util.EnvironmentTickCount(); - SafeNativeMethods.AllocateODEDataForThread(0); + OdeNative.AllocateODEDataForThread(0); lock (_taintedPrims) { @@ -2329,7 +2329,7 @@ namespace OpenSim.Region.PhysicsModule.ODE lock (OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(~0U); + OdeNative.AllocateODEDataForThread(~0U); while (step_time > HalfOdeStep) { @@ -2478,12 +2478,12 @@ namespace OpenSim.Region.PhysicsModule.ODE } lock(SimulationLock) - SafeNativeMethods.WorldQuickStep(world, ODE_STEPSIZE); + OdeNative.WorldQuickStep(world, ODE_STEPSIZE); if (CollectStats) m_stats[ODENativeStepFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick); - SafeNativeMethods.JointGroupEmpty(contactgroup); + OdeNative.JointGroupEmpty(contactgroup); } catch (Exception e) { @@ -2531,7 +2531,7 @@ namespace OpenSim.Region.PhysicsModule.ODE foreach (OdePrim prim in _activeprims) { - if (prim.IsPhysical && (SafeNativeMethods.BodyIsEnabled(prim.Body) || !prim._zeroFlag)) + if (prim.IsPhysical && (OdeNative.BodyIsEnabled(prim.Body) || !prim._zeroFlag)) { prim.UpdatePositionAndVelocity(); } @@ -2558,7 +2558,7 @@ namespace OpenSim.Region.PhysicsModule.ODE fwriter.Close(); } - SafeNativeMethods.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); + OdeNative.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); } latertickcount = Util.EnvironmentTickCountSubtract(tickCountFrameRun); @@ -2670,7 +2670,7 @@ namespace OpenSim.Region.PhysicsModule.ODE lock (OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(~0U); + OdeNative.AllocateODEDataForThread(~0U); IntPtr GroundGeom = IntPtr.Zero; if (RegionTerrain.TryGetValue(pOffset, out GroundGeom)) @@ -2682,29 +2682,29 @@ namespace OpenSim.Region.PhysicsModule.ODE { TerrainHeightFieldHeights.Remove(GroundGeom); } - SafeNativeMethods.SpaceRemove(space, GroundGeom); - SafeNativeMethods.GeomDestroy(GroundGeom); + OdeNative.SpaceRemove(space, GroundGeom); + OdeNative.GeomDestroy(GroundGeom); } } - IntPtr HeightmapData = SafeNativeMethods.GeomHeightfieldDataCreate(); - SafeNativeMethods.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, + IntPtr HeightmapData = OdeNative.GeomHeightfieldDataCreate(); + OdeNative.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, offset, thickness, wrap); - SafeNativeMethods.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); - GroundGeom = SafeNativeMethods.CreateHeightfield(space, HeightmapData, 1); + OdeNative.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); + GroundGeom = OdeNative.CreateHeightfield(space, HeightmapData, 1); if (GroundGeom != IntPtr.Zero) { - SafeNativeMethods.GeomSetCategoryBits(GroundGeom, (int)(CollisionCategories.Land)); - SafeNativeMethods.GeomSetCollideBits(GroundGeom, (int)(CollisionCategories.Space)); + OdeNative.GeomSetCategoryBits(GroundGeom, (int)(CollisionCategories.Land)); + OdeNative.GeomSetCollideBits(GroundGeom, (int)(CollisionCategories.Space)); } geom_name_map[GroundGeom] = "Terrain"; - SafeNativeMethods.Matrix3 R = new SafeNativeMethods.Matrix3(); + OdeNative.Matrix3 R = new OdeNative.Matrix3(); Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); @@ -2714,9 +2714,9 @@ namespace OpenSim.Region.PhysicsModule.ODE float angle; q1.GetAxisAngle(out v3, out angle); - SafeNativeMethods.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); - SafeNativeMethods.GeomSetRotation(GroundGeom, ref R); - SafeNativeMethods.GeomSetPosition(GroundGeom, pOffset.X + regionsizeX * 0.5f, pOffset.Y + regionsizeY * 0.5f, 0.0f); + OdeNative.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); + OdeNative.GeomSetRotation(GroundGeom, ref R); + OdeNative.GeomSetPosition(GroundGeom, pOffset.X + regionsizeX * 0.5f, pOffset.Y + regionsizeY * 0.5f, 0.0f); IntPtr testGround = IntPtr.Zero; if (RegionTerrain.TryGetValue(pOffset, out testGround)) { @@ -2755,7 +2755,7 @@ namespace OpenSim.Region.PhysicsModule.ODE _worldInitialized = false; - SafeNativeMethods.AllocateODEDataForThread(~0U); + OdeNative.AllocateODEDataForThread(~0U); if (m_rayCastManager != null) { @@ -2783,13 +2783,13 @@ namespace OpenSim.Region.PhysicsModule.ODE { if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) TerrainHeightFieldHeights.Remove(GroundGeom); - SafeNativeMethods.GeomDestroy(GroundGeom); + OdeNative.GeomDestroy(GroundGeom); } } try { - SafeNativeMethods.WorldDestroy(world); + OdeNative.WorldDestroy(world); world = IntPtr.Zero; } catch (AccessViolationException e) diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEApi.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEApi.cs index 554b251eae..7c12af9d13 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEApi.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEApi.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //#endif [SuppressUnmanagedCodeSecurityAttribute] - internal static class SafeNativeMethods + internal static class UBOdeNative { internal static dReal Infinity = dReal.MaxValue; internal static int NTotalBodies = 0; @@ -250,7 +250,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde //needed for Contact only, rest should use the class internal struct ContactGeom { - internal Vector3 pos; internal Vector3 normal; internal dReal depth; @@ -261,18 +260,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde internal static readonly int unmanagedSizeOf = Marshal.SizeOf(typeof(ContactGeom)); } - /* - [StructLayout(LayoutKind.Sequential)] - internal struct GeomClass - { - internal int bytes; - internal GetColliderFnFn collider; - internal GetAABBFn aabb; - internal AABBTestFn aabb_test; - internal GeomDtorFn dtor; - } - */ - [StructLayout(LayoutKind.Sequential)] internal struct JointFeedback { @@ -282,7 +269,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde internal Vector3 t2; } - [StructLayout(LayoutKind.Sequential)] internal struct Mass { diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index e556e5a758..19ecce9727 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde private Vector3 m_lastFallVel; private Quaternion m_orientation; private Quaternion m_orientation2D; - private SafeNativeMethods.Quaternion m_NativeOrientation2D; + private UBOdeNative.Quaternion m_NativeOrientation2D; private float m_mass = 80f; private float m_massInvTimeScaled = 1600f; public readonly float m_density = 60f; @@ -151,7 +151,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde public IntPtr Amotor = IntPtr.Zero; - internal SafeNativeMethods.Mass ShellMass; + internal UBOdeNative.Mass ShellMass; public int m_eventsubscription = 0; private int m_cureventsubscription = 0; @@ -837,7 +837,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_pidControllerActive = true; _acceleration = accel; if (Body != IntPtr.Zero) - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodyEnable(Body); } /// @@ -911,19 +911,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde CapsuleRadius *= 0.5f; CapsuleSizeZ = 0.5f * sz; - collider = SafeNativeMethods.CreateCapsule(m_parent_scene.TopSpace, CapsuleRadius, l); - SafeNativeMethods.GeomSetCategoryBits(collider, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(collider, (uint)m_collisionFlags); + collider = UBOdeNative.CreateCapsule(m_parent_scene.TopSpace, CapsuleRadius, l); + UBOdeNative.GeomSetCategoryBits(collider, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(collider, (uint)m_collisionFlags); // update mass m_mass = m_density * sx * sy * sz; - SafeNativeMethods.MassSetBoxTotal(out ShellMass, m_mass, sx, sy, sz); + UBOdeNative.MassSetBoxTotal(out ShellMass, m_mass, sx, sy, sz); m_massInvTimeScaled = m_mass * m_sceneInverseTimeStep; PID_D = basePID_D * m_massInvTimeScaled; PID_P = basePID_P * m_massInvTimeScaled; m_scenegravityForceZ = m_sceneGravityZ * m_mass; - Body = SafeNativeMethods.BodyCreate(m_parent_scene.world); + Body = UBOdeNative.BodyCreate(m_parent_scene.world); _zeroFlag = false; m_pidControllerActive = true; @@ -932,52 +932,52 @@ namespace OpenSim.Region.PhysicsModule.ubOde _velocity = Vector3.Zero; // SafeNativeMethods.BodySetAutoDisableFlag(Body,false); - SafeNativeMethods.BodySetAutoDisableFlag(Body, true); + UBOdeNative.BodySetAutoDisableFlag(Body, true); m_bodydisablecontrol = 0; - SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + UBOdeNative.BodySetPosition(Body, _position.X, _position.Y, _position.Z); - SafeNativeMethods.BodySetMass(Body, ref ShellMass); + UBOdeNative.BodySetMass(Body, ref ShellMass); //SafeNativeMethods.GeomSetBody(capsule, Body); - SafeNativeMethods.GeomSetBody(collider, Body); + UBOdeNative.GeomSetBody(collider, Body); // The purpose of the AMotor here is to keep the avatar's physical // surrogate from rotating while moving - Amotor = SafeNativeMethods.JointCreateAMotor(m_parent_scene.world, IntPtr.Zero); - SafeNativeMethods.JointAttach(Amotor, Body, IntPtr.Zero); + Amotor = UBOdeNative.JointCreateAMotor(m_parent_scene.world, IntPtr.Zero); + UBOdeNative.JointAttach(Amotor, Body, IntPtr.Zero); - SafeNativeMethods.JointSetAMotorMode(Amotor, 0); - SafeNativeMethods.JointSetAMotorNumAxes(Amotor, 3); - SafeNativeMethods.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); - SafeNativeMethods.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); - SafeNativeMethods.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); + UBOdeNative.JointSetAMotorMode(Amotor, 0); + UBOdeNative.JointSetAMotorNumAxes(Amotor, 3); + UBOdeNative.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); + UBOdeNative.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); + UBOdeNative.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 0, 0); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 1, 0); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 2, 0); + UBOdeNative.JointSetAMotorAngle(Amotor, 0, 0); + UBOdeNative.JointSetAMotorAngle(Amotor, 1, 0); + UBOdeNative.JointSetAMotorAngle(Amotor, 2, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.StopCFM, 0f); // make it HARD - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.StopCFM2, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.StopCFM3, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.StopERP, 0.8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.StopERP2, 0.8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.StopERP3, 0.8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.StopCFM, 0f); // make it HARD + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.StopCFM2, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.StopCFM3, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.StopERP, 0.8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.StopERP2, 0.8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.StopERP3, 0.8f); // These lowstops and high stops are effectively (no wiggle room) - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -1e-5f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 1e-5f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -1e-5f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 1e-5f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -1e-5f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 1e-5f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -1e-5f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 1e-5f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -1e-5f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 1e-5f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -1e-5f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 1e-5f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Vel2, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Vel3, 0); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.Vel, 0); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.Vel2, 0); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.Vel3, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e8f); } /// @@ -989,14 +989,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde // Kill the Amotor if (Amotor != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(Amotor); + UBOdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } if (Body != IntPtr.Zero) { //kill the body - SafeNativeMethods.BodyDestroy(Body); + UBOdeNative.BodyDestroy(Body); Body = IntPtr.Zero; } @@ -1020,7 +1020,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { m_parent_scene.actor_name_map.Remove(collider); //m_parent_scene.waitForSpaceUnlock(m_parent_scene.CharsSpace); - SafeNativeMethods.GeomDestroy(collider); + UBOdeNative.GeomDestroy(collider); collider = IntPtr.Zero; } } @@ -1059,8 +1059,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde } [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal bool Collide(IntPtr me, IntPtr other, bool reverse, ref SafeNativeMethods.ContactGeom contact, - ref SafeNativeMethods.ContactGeom altContact, ref bool useAltcontact, ref bool feetcollision) + internal bool Collide(IntPtr me, IntPtr other, bool reverse, ref UBOdeNative.ContactGeom contact, + ref UBOdeNative.ContactGeom altContact, ref bool useAltcontact, ref bool feetcollision) { feetcollision = false; useAltcontact = false; @@ -1076,8 +1076,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde offset.X = contact.pos.X - _position.X; offset.Y = contact.pos.Y - _position.Y; - SafeNativeMethods.GeomClassID gtype = SafeNativeMethods.GeomGetClass(other); - if (gtype == SafeNativeMethods.GeomClassID.CapsuleClass) + UBOdeNative.GeomClassID gtype = UBOdeNative.GeomGetClass(other); + if (gtype == UBOdeNative.GeomClassID.CapsuleClass) { Vector3 roff = offset * Quaternion.Inverse(m_orientation2D); float r = roff.X * roff.X / AvaAvaSizeXsq; @@ -1105,9 +1105,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde return true; } - if (gtype == SafeNativeMethods.GeomClassID.SphereClass && SafeNativeMethods.GeomGetBody(other) != IntPtr.Zero) + if (gtype == UBOdeNative.GeomClassID.SphereClass && UBOdeNative.GeomGetBody(other) != IntPtr.Zero) { - if (SafeNativeMethods.GeomSphereGetRadius(other) < 0.5) + if (UBOdeNative.GeomSphereGetRadius(other) < 0.5) return true; } @@ -1194,25 +1194,25 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body == IntPtr.Zero) return; - if (!SafeNativeMethods.BodyIsEnabled(Body)) + if (!UBOdeNative.BodyIsEnabled(Body)) { if (++m_bodydisablecontrol < 50) return; // clear residuals - SafeNativeMethods.BodySetAngularVel(Body, 0f, 0f, 0f); - SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f); + UBOdeNative.BodySetAngularVel(Body, 0f, 0f, 0f); + UBOdeNative.BodySetLinearVel(Body, 0f, 0f, 0f); _zeroFlag = true; - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodyEnable(Body); } m_bodydisablecontrol = 0; // the Amotor still lets avatar rotation to drift during colisions // so force it back to identity - SafeNativeMethods.BodySetQuaternion(Body, ref m_NativeOrientation2D); + UBOdeNative.BodySetQuaternion(Body, ref m_NativeOrientation2D); - _position = SafeNativeMethods.BodyGetPositionOMV(Body); + _position = UBOdeNative.BodyGetPositionOMV(Body); // check outbounds forcing to be in world bool fixbody = false; if ((Single.IsNaN(_position.X) || Single.IsInfinity(_position.X))) @@ -1256,7 +1256,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (fixbody) { m_freemove = false; - SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + UBOdeNative.BodySetPosition(Body, _position.X, _position.Y, _position.Z); } if (m_pidControllerActive == false) @@ -1282,7 +1282,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde ctz.Y *= m_walkMultiplier; } - Vector3 vel = SafeNativeMethods.BodyGetLinearVelOMV(Body); + Vector3 vel = UBOdeNative.BodyGetLinearVelOMV(Body); //****************************************** // colide with land @@ -1620,7 +1620,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } if ((vec.Z != 0 || vec.X != 0 || vec.Y != 0)) - SafeNativeMethods.BodyAddForce(Body, vec.X, vec.Y, vec.Z); + UBOdeNative.BodyAddForce(Body, vec.X, vec.Y, vec.Z); if (_zeroFlag) { @@ -1635,7 +1635,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde a = (_velocity - a) * m_sceneInverseTimeStep; SetSmooth(ref _acceleration, ref a, 2); - m_rotationalVelocity = SafeNativeMethods.BodyGetAngularVelOMVforAvatar(Body); + m_rotationalVelocity = UBOdeNative.BodyGetAngularVelOMVforAvatar(Body); } } @@ -1820,7 +1820,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_cureventsubscription < m_eventsubscription) return; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) return; lock (CollisionEventsThisFrame) @@ -1938,19 +1938,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde CapsuleRadius *= 0.5f; CapsuleSizeZ= 0.5f * sz; //SafeNativeMethods.GeomCapsuleSetParams(capsule, r, l); - SafeNativeMethods.GeomCapsuleSetParams(collider, CapsuleRadius, l); + UBOdeNative.GeomCapsuleSetParams(collider, CapsuleRadius, l); m_mass = m_density * sx * sy * sz; // update mass m_massInvTimeScaled = m_mass * m_sceneInverseTimeStep; PID_D = basePID_D * m_massInvTimeScaled; PID_P = basePID_P * m_massInvTimeScaled; - SafeNativeMethods.MassSetBoxTotal(out ShellMass, m_mass, sx, sy, sz); - SafeNativeMethods.BodySetMass(Body, ref ShellMass); + UBOdeNative.MassSetBoxTotal(out ShellMass, m_mass, sx, sy, sz); + UBOdeNative.BodySetMass(Body, ref ShellMass); m_scenegravityForceZ = m_sceneGravityZ * m_mass; _position.Z += (sz - oldsz) * 0.5f; - SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + UBOdeNative.BodySetPosition(Body, _position.X, _position.Y, _position.Z); UpdateAABB2D(); @@ -1973,8 +1973,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z); + UBOdeNative.BodyEnable(Body); } _position = newPos; UpdateAABB2D(); @@ -2017,12 +2017,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetQuaternion(Body, ref m_NativeOrientation2D); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetQuaternion(Body, ref m_NativeOrientation2D); + UBOdeNative.BodyEnable(Body); } } else if (Body != IntPtr.Zero) - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodyEnable(Body); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -2033,8 +2033,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); + UBOdeNative.BodyEnable(Body); } } @@ -2045,7 +2045,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //m_freemove = false; m_targetVelocity = newVel; if (Body != IntPtr.Zero) - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodyEnable(Body); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -2119,8 +2119,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero) { if (newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0) - SafeNativeMethods.BodyAddForce(Body, newForce.X, newForce.Y, newForce.Z); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodyAddForce(Body, newForce.X, newForce.Y, newForce.Z); + UBOdeNative.BodyEnable(Body); } } @@ -2133,8 +2133,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); + UBOdeNative.BodyEnable(Body); } } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs index 00a695c2be..1a652b2457 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs @@ -336,9 +336,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_amEfect = 1.0f ; // turn it on m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; - if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body) + if (rootPrim.Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(rootPrim.Body) && !rootPrim.m_isSelected && !rootPrim.m_disabled) - SafeNativeMethods.BodyEnable(rootPrim.Body); + UBOdeNative.BodyEnable(rootPrim.Body); break; case Vehicle.LINEAR_FRICTION_TIMESCALE: @@ -355,9 +355,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_lmEfect = 1.0f; // turn it on m_ffactor = 0.0f; - if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body) + if (rootPrim.Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(rootPrim.Body) && !rootPrim.m_isSelected && !rootPrim.m_disabled) - SafeNativeMethods.BodyEnable(rootPrim.Body); + UBOdeNative.BodyEnable(rootPrim.Body); break; case Vehicle.LINEAR_MOTOR_OFFSET: m_linearMotorOffset = new Vector3(pValue, pValue, pValue); @@ -393,9 +393,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_amEfect = 1.0f; // turn it on m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; - if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body) + if (rootPrim.Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(rootPrim.Body) && !rootPrim.m_isSelected && !rootPrim.m_disabled) - SafeNativeMethods.BodyEnable(rootPrim.Body); + UBOdeNative.BodyEnable(rootPrim.Body); break; case Vehicle.LINEAR_FRICTION_TIMESCALE: if (pValue.X < m_timestep) pValue.X = m_timestep; @@ -413,9 +413,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; m_ffactor = 0.0f; - if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body) + if (rootPrim.Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(rootPrim.Body) && !rootPrim.m_isSelected && !rootPrim.m_disabled) - SafeNativeMethods.BodyEnable(rootPrim.Body); + UBOdeNative.BodyEnable(rootPrim.Body); break; case Vehicle.LINEAR_MOTOR_OFFSET: m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); @@ -766,30 +766,30 @@ namespace OpenSim.Region.PhysicsModule.ubOde { IntPtr Body = rootPrim.Body; - SafeNativeMethods.Mass dmass; - SafeNativeMethods.BodyGetMass(Body, out dmass); + UBOdeNative.Mass dmass; + UBOdeNative.BodyGetMass(Body, out dmass); - SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body); + UBOdeNative.Quaternion rot = UBOdeNative.BodyGetQuaternion(Body); Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object Quaternion rotq = objrotq; // rotq = rotation of object rotq *= m_referenceFrame; // rotq is now rotation in vehicle reference frame Quaternion irotq = Quaternion.Inverse(rotq); - SafeNativeMethods.Vector3 dvtmp; + UBOdeNative.Vector3 dvtmp; Vector3 tmpV; Vector3 curVel; // velocity in world Vector3 curAngVel; // angular velocity in world Vector3 force = Vector3.Zero; // actually linear aceleration until mult by mass in world frame Vector3 torque = Vector3.Zero;// actually angular aceleration until mult by Inertia in vehicle frame - SafeNativeMethods.Vector3 dtorque = new SafeNativeMethods.Vector3(); + UBOdeNative.Vector3 dtorque = new UBOdeNative.Vector3(); - dvtmp = SafeNativeMethods.BodyGetLinearVel(Body); + dvtmp = UBOdeNative.BodyGetLinearVel(Body); curVel.X = dvtmp.X; curVel.Y = dvtmp.Y; curVel.Z = dvtmp.Z; Vector3 curLocalVel = curVel * irotq; // current velocity in local - dvtmp = SafeNativeMethods.BodyGetAngularVel(Body); + dvtmp = UBOdeNative.BodyGetAngularVel(Body); curAngVel.X = dvtmp.X; curAngVel.Y = dvtmp.Y; curAngVel.Z = dvtmp.Z; @@ -833,7 +833,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { // have offset, do it now tmpV *= dmass.mass; - SafeNativeMethods.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z); + UBOdeNative.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z); } else { @@ -856,7 +856,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_VhoverTimescale < 300 && rootPrim.m_prim_geom != IntPtr.Zero) { // d.Vector3 pos = d.BodyGetPosition(Body); - SafeNativeMethods.Vector3 pos = SafeNativeMethods.GeomGetPosition(rootPrim.m_prim_geom); + UBOdeNative.Vector3 pos = UBOdeNative.GeomGetPosition(rootPrim.m_prim_geom); pos.Z -= 0.21f; // minor offset that seems to be always there in sl float t = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); @@ -1174,7 +1174,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (force.X != 0 || force.Y != 0 || force.Z != 0) { - SafeNativeMethods.BodyAddForce(Body, force.X, force.Y, force.Z); + UBOdeNative.BodyAddForce(Body, force.X, force.Y, force.Z); } if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) @@ -1184,15 +1184,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde dtorque.Y = torque.Y; dtorque.Z = torque.Z; - SafeNativeMethods.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque); - SafeNativeMethods.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame + UBOdeNative.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque); + UBOdeNative.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame } torque = rootPrim.m_torque; torque += rootPrim.m_angularForceacc; rootPrim.m_angularForceacc = Vector3.Zero; if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) - SafeNativeMethods.BodyAddTorque(Body,torque.X, torque.Y, torque.Z); + UBOdeNative.BodyAddTorque(Body,torque.X, torque.Y, torque.Z); } } } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs index 1735a4dfb9..4508f47519 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs @@ -58,9 +58,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Util.IsWindows()) Util.LoadArchSpecificWindowsDll("ubode.dll"); - SafeNativeMethods.InitODE(); + UBOdeNative.InitODE(); - string ode_config = SafeNativeMethods.GetConfiguration(); + string ode_config = UBOdeNative.GetConfiguration(); if (string.IsNullOrEmpty(ode_config)) { m_log.Error("[ubODE] Native ode library version not supported"); diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index ec4a7a8300..314c9571b1 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -160,7 +160,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde private float m_physCost; private float m_streamCost; - internal SafeNativeMethods.Mass primdMass; // prim inertia information on it's own referencial + internal UBOdeNative.Mass primdMass; // prim inertia information on it's own referencial private PhysicsInertiaData m_InertiaOverride; float primMass; // prim own mass float primVolume; // prim own volume; @@ -489,7 +489,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // double buffering if(m_fakeInertiaOverride != null) { - SafeNativeMethods.Mass objdmass = new SafeNativeMethods.Mass(); + UBOdeNative.Mass objdmass = new UBOdeNative.Mass(); objdmass.I.M00 = m_fakeInertiaOverride.Inertia.X; objdmass.I.M11 = m_fakeInertiaOverride.Inertia.Y; objdmass.I.M22 = m_fakeInertiaOverride.Inertia.Z; @@ -498,9 +498,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde if(Math.Abs(m_fakeInertiaOverride.InertiaRotation.W) < 0.999) { - SafeNativeMethods.Matrix3 inertiarotmat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.RfromQ(ref inertiarotmat, ref m_fakeInertiaOverride.InertiaRotation); - SafeNativeMethods.MassRotate(ref objdmass, ref inertiarotmat); + UBOdeNative.Matrix3 inertiarotmat = new UBOdeNative.Matrix3(); + UBOdeNative.RfromQ(ref inertiarotmat, ref m_fakeInertiaOverride.InertiaRotation); + UBOdeNative.MassRotate(ref objdmass, ref inertiarotmat); } inertia.TotalMass = m_fakeInertiaOverride.TotalMass; @@ -524,13 +524,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde return inertia; } - SafeNativeMethods.Vector3 dtmp; - SafeNativeMethods.Mass m = new SafeNativeMethods.Mass(); + UBOdeNative.Vector3 dtmp; + UBOdeNative.Mass m = new UBOdeNative.Mass(); lock(m_parentScene.OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(0); - dtmp = SafeNativeMethods.GeomGetOffsetPosition(m_prim_geom); - SafeNativeMethods.BodyGetMass(Body, out m); + UBOdeNative.AllocateODEDataForThread(0); + dtmp = UBOdeNative.GeomGetOffsetPosition(m_prim_geom); + UBOdeNative.BodyGetMass(Body, out m); } Vector3 cm = new Vector3(-dtmp.X, -dtmp.Y, -dtmp.Z); @@ -566,16 +566,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde { lock (m_parentScene.OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(0); + UBOdeNative.AllocateODEDataForThread(0); if (!childPrim && Body != IntPtr.Zero) { - return SafeNativeMethods.BodyGetPositionOMV(Body); + return UBOdeNative.BodyGetPositionOMV(Body); } else if (m_prim_geom != IntPtr.Zero) { - Vector3 Ptot = SafeNativeMethods.GeomGetPositionOMV(m_prim_geom); - Quaternion q = SafeNativeMethods.GeomGetQuaternionOMV(m_prim_geom); + Vector3 Ptot = UBOdeNative.GeomGetPositionOMV(m_prim_geom); + Quaternion q = UBOdeNative.GeomGetQuaternionOMV(m_prim_geom); Ptot = Ptot + m_OBBOffset * q; return Ptot; /* @@ -994,16 +994,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_lastposition = m_position; _velocity = Vector3.Zero; - SafeNativeMethods.AllocateODEDataForThread(0); + UBOdeNative.AllocateODEDataForThread(0); m_lastVelocity = _velocity; if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Stop(); if(Body != IntPtr.Zero) - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); // stop it + UBOdeNative.BodySetLinearVel(Body, 0, 0, 0); // stop it if (m_prim_geom != IntPtr.Zero) - SafeNativeMethods.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); + UBOdeNative.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); m_outbounds = false; changeDisable(false); @@ -1024,24 +1024,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_lastposition = m_position; m_lastorientation = m_orientation; - SafeNativeMethods.AllocateODEDataForThread(0); + UBOdeNative.AllocateODEDataForThread(0); if(Body != IntPtr.Zero) { - SafeNativeMethods.Vector3 dtmp = SafeNativeMethods.BodyGetAngularVel(Body); + UBOdeNative.Vector3 dtmp = UBOdeNative.BodyGetAngularVel(Body); m_rotationalVelocity.X = dtmp.X; m_rotationalVelocity.Y = dtmp.Y; m_rotationalVelocity.Z = dtmp.Z; - dtmp = SafeNativeMethods.BodyGetLinearVel(Body); + dtmp = UBOdeNative.BodyGetLinearVel(Body); _velocity.X = dtmp.X; _velocity.Y = dtmp.Y; _velocity.Z = dtmp.Z; - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); // stop it - SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0); + UBOdeNative.BodySetLinearVel(Body, 0, 0, 0); // stop it + UBOdeNative.BodySetAngularVel(Body, 0, 0, 0); } if(m_prim_geom != IntPtr.Zero) - SafeNativeMethods.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); + UBOdeNative.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); disableBodySoft(); // stop collisions UnSubscribeEvents(); } @@ -1256,7 +1256,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde SentEmptyCollisionsEvent = true; //_parent_scene.RemoveCollisionEventReporting(this); } - else if(Body == IntPtr.Zero || (SafeNativeMethods.BodyIsEnabled(Body) && m_bodydisablecontrol >= 0 )) + else if(Body == IntPtr.Zero || (UBOdeNative.BodyIsEnabled(Body) && m_bodydisablecontrol >= 0 )) { SentEmptyCollisionsEvent = false; CollisionEvents.Clear(); @@ -1458,16 +1458,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (prm.m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(prm.m_prim_geom, 0); + UBOdeNative.GeomSetCategoryBits(prm.m_prim_geom, 0); if (m_isphysical) - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, (int)CollisionCategories.Land); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, (int)CollisionCategories.Land); else - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, 0); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(prm.m_prim_geom, (uint)prm.m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, (uint)prm.m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(prm.m_prim_geom, (uint)prm.m_collisionCategories); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, (uint)prm.m_collisionFlags); } } } @@ -1475,22 +1475,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, (uint)CollisionCategories.Land); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, 0); + UBOdeNative.GeomSetCollideBits(m_prim_geom, (uint)CollisionCategories.Land); if (m_collide_geom != m_prim_geom && m_collide_geom != IntPtr.Zero) { - SafeNativeMethods.GeomSetCategoryBits(m_collide_geom, 0); - SafeNativeMethods.GeomSetCollideBits(m_collide_geom, (uint)CollisionCategories.Land); + UBOdeNative.GeomSetCategoryBits(m_collide_geom, 0); + UBOdeNative.GeomSetCollideBits(m_collide_geom, (uint)CollisionCategories.Land); } } else { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); if (m_collide_geom != m_prim_geom && m_collide_geom != IntPtr.Zero) { - SafeNativeMethods.GeomSetCategoryBits(m_collide_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(m_collide_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(m_collide_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(m_collide_geom, (uint)m_collisionFlags); } } } @@ -1503,7 +1503,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Amotor != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(Amotor); + UBOdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } @@ -1530,19 +1530,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde if(axisnum == 0) return; // stop it - SafeNativeMethods.BodySetTorque(Body, 0, 0, 0); - SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0); + UBOdeNative.BodySetTorque(Body, 0, 0, 0); + UBOdeNative.BodySetAngularVel(Body, 0, 0, 0); - Amotor = SafeNativeMethods.JointCreateAMotor(m_parentScene.world, IntPtr.Zero); - SafeNativeMethods.JointAttach(Amotor, Body, IntPtr.Zero); + Amotor = UBOdeNative.JointCreateAMotor(m_parentScene.world, IntPtr.Zero); + UBOdeNative.JointAttach(Amotor, Body, IntPtr.Zero); - SafeNativeMethods.JointSetAMotorMode(Amotor, 0); + UBOdeNative.JointSetAMotorMode(Amotor, 0); - SafeNativeMethods.JointSetAMotorNumAxes(Amotor, axisnum); + UBOdeNative.JointSetAMotorNumAxes(Amotor, axisnum); // get current orientation to lock - Quaternion curr= SafeNativeMethods.BodyGetQuaternionOMV(Body); + Quaternion curr= UBOdeNative.BodyGetQuaternionOMV(Body); Vector3 ax; int i = 0; @@ -1550,17 +1550,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (axisX) { ax = (new Vector3(1, 0, 0)) * curr; // rotate world X to current local X - SafeNativeMethods.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); - SafeNativeMethods.JointSetAMotorAngle(Amotor, 0, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.LoStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.HiStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Bounce, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.CFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.StopCFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.StopERP, 0.8f); + UBOdeNative.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); + UBOdeNative.JointSetAMotorAngle(Amotor, 0, 0); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.LoStop, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.HiStop, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.Vel, 0); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.FudgeFactor, 0.0001f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.Bounce, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.CFM, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.FMax, 5e8f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.StopCFM, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, (int)UBOdeNative.JointParam.StopERP, 0.8f); i++; j = 256; // move to next axis set } @@ -1568,17 +1568,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (axisY) { ax = (new Vector3(0, 1, 0)) * curr; - SafeNativeMethods.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); - SafeNativeMethods.JointSetAMotorAngle(Amotor, i, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.LoStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.HiStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Bounce, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.CFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopCFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopERP, 0.8f); + UBOdeNative.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); + UBOdeNative.JointSetAMotorAngle(Amotor, i, 0); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.LoStop, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.HiStop, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.Vel, 0); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.FudgeFactor, 0.0001f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.Bounce, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.CFM, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.FMax, 5e8f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.StopCFM, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.StopERP, 0.8f); i++; j += 256; } @@ -1586,17 +1586,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (axisZ) { ax = (new Vector3(0, 0, 1)) * curr; - SafeNativeMethods.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); - SafeNativeMethods.JointSetAMotorAngle(Amotor, i, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.LoStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.HiStop, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Vel, 0); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Bounce, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.CFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FMax, 5e8f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopCFM, 0f); - SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopERP, 0.8f); + UBOdeNative.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); + UBOdeNative.JointSetAMotorAngle(Amotor, i, 0); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.LoStop, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.HiStop, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.Vel, 0); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.FudgeFactor, 0.0001f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.Bounce, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.CFM, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.FMax, 5e8f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.StopCFM, 0f); + UBOdeNative.JointSetAMotorParam(Amotor, j + (int)UBOdeNative.JointParam.StopERP, 0.8f); } } @@ -1610,21 +1610,21 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, 0); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, 0); if (m_isphysical) { - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, (uint)CollisionCategories.Land); + UBOdeNative.GeomSetCollideBits(m_prim_geom, (uint)CollisionCategories.Land); } else { - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, 0); - SafeNativeMethods.GeomDisable(m_prim_geom); + UBOdeNative.GeomSetCollideBits(m_prim_geom, 0); + UBOdeNative.GeomDisable(m_prim_geom); } } else { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); } UpdatePrimBodyData(); @@ -1692,12 +1692,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde try { - _triMeshData = SafeNativeMethods.GeomTriMeshDataCreate(); + _triMeshData = UBOdeNative.GeomTriMeshDataCreate(); - SafeNativeMethods.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); - SafeNativeMethods.GeomTriMeshDataPreprocess(_triMeshData); + UBOdeNative.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); + UBOdeNative.GeomTriMeshDataPreprocess(_triMeshData); - geo = SafeNativeMethods.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null); + geo = UBOdeNative.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null); } catch (Exception e) @@ -1707,7 +1707,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { try { - SafeNativeMethods.GeomTriMeshDataDestroy(_triMeshData); + UBOdeNative.GeomTriMeshDataDestroy(_triMeshData); } catch { @@ -1763,7 +1763,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { // it's a sphere try { - geo = SafeNativeMethods.CreateSphere(m_targetSpace, m_size.X * 0.5f); + geo = UBOdeNative.CreateSphere(m_targetSpace, m_size.X * 0.5f); } catch (Exception e) { @@ -1775,7 +1775,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde {// do it as a box try { - geo = SafeNativeMethods.CreateBox(m_targetSpace, m_size.X, m_size.Y, m_size.Z); + geo = UBOdeNative.CreateBox(m_targetSpace, m_size.X, m_size.Y, m_size.Z); } catch (Exception e) { @@ -1797,10 +1797,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde try { - SafeNativeMethods.GeomDestroy(m_prim_geom); + UBOdeNative.GeomDestroy(m_prim_geom); if (_triMeshData != IntPtr.Zero) { - SafeNativeMethods.GeomTriMeshDataDestroy(_triMeshData); + UBOdeNative.GeomTriMeshDataDestroy(_triMeshData); _triMeshData = IntPtr.Zero; } } @@ -1852,8 +1852,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde ApplyCollisionCatFlags(); _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } resetCollisionAccounting(); @@ -1872,7 +1872,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_collisionCategories = 0; m_collisionFlags = 0; ApplyCollisionCatFlags(); - SafeNativeMethods.BodyDisable(Body); + UBOdeNative.BodyDisable(Body); } } } @@ -1900,35 +1900,35 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_log.Warn("[PHYSICS]: MakeBody called having a body"); } - if (SafeNativeMethods.GeomGetBody(m_prim_geom) != IntPtr.Zero) + if (UBOdeNative.GeomGetBody(m_prim_geom) != IntPtr.Zero) { - SafeNativeMethods.GeomSetBody(m_prim_geom, IntPtr.Zero); + UBOdeNative.GeomSetBody(m_prim_geom, IntPtr.Zero); m_log.Warn("[PHYSICS]: MakeBody root geom already had a body"); } bool noInertiaOverride = (m_InertiaOverride == null); - Body = SafeNativeMethods.BodyCreate(m_parentScene.world); + Body = UBOdeNative.BodyCreate(m_parentScene.world); // set the body rotation - SafeNativeMethods.Matrix3 mymat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.RfromQ(ref mymat, ref m_orientation); - SafeNativeMethods.BodySetRotation(Body, ref mymat); + UBOdeNative.Matrix3 mymat = new UBOdeNative.Matrix3(); + UBOdeNative.RfromQ(ref mymat, ref m_orientation); + UBOdeNative.BodySetRotation(Body, ref mymat); - SafeNativeMethods.Mass objdmass = new SafeNativeMethods.Mass { }; + UBOdeNative.Mass objdmass = new UBOdeNative.Mass { }; if (noInertiaOverride) { objdmass = primdMass; - SafeNativeMethods.MassRotate(ref objdmass, ref mymat); + UBOdeNative.MassRotate(ref objdmass, ref mymat); } // recompute full object inertia if needed if (childrenPrim.Count > 0) { - SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.Mass tmpdmass = new SafeNativeMethods.Mass { }; + UBOdeNative.Matrix3 mat = new UBOdeNative.Matrix3(); + UBOdeNative.Mass tmpdmass = new UBOdeNative.Mass { }; Vector3 rcm; rcm = m_position; @@ -1943,66 +1943,66 @@ namespace OpenSim.Region.PhysicsModule.ubOde continue; } - SafeNativeMethods.RfromQ(ref mat, ref prm.m_orientation); + UBOdeNative.RfromQ(ref mat, ref prm.m_orientation); // fix prim colision cats - if (SafeNativeMethods.GeomGetBody(prm.m_prim_geom) != IntPtr.Zero) + if (UBOdeNative.GeomGetBody(prm.m_prim_geom) != IntPtr.Zero) { - SafeNativeMethods.GeomSetBody(prm.m_prim_geom, IntPtr.Zero); + UBOdeNative.GeomSetBody(prm.m_prim_geom, IntPtr.Zero); m_log.Warn("[PHYSICS]: MakeBody child geom already had a body"); } - SafeNativeMethods.GeomClearOffset(prm.m_prim_geom); - SafeNativeMethods.GeomSetBody(prm.m_prim_geom, Body); + UBOdeNative.GeomClearOffset(prm.m_prim_geom); + UBOdeNative.GeomSetBody(prm.m_prim_geom, Body); prm.Body = Body; - SafeNativeMethods.GeomSetOffsetWorldRotation(prm.m_prim_geom, ref mat); // set relative rotation + UBOdeNative.GeomSetOffsetWorldRotation(prm.m_prim_geom, ref mat); // set relative rotation if(noInertiaOverride) { tmpdmass = prm.primdMass; - SafeNativeMethods.MassRotate(ref tmpdmass, ref mat); + UBOdeNative.MassRotate(ref tmpdmass, ref mat); Vector3 ppos = prm.m_position; ppos -= rcm; // refer inertia to root prim center of mass position - SafeNativeMethods.MassTranslate(ref tmpdmass, + UBOdeNative.MassTranslate(ref tmpdmass, ppos.X, ppos.Y, ppos.Z); - SafeNativeMethods.MassAdd(ref objdmass, ref tmpdmass); // add to total object inertia + UBOdeNative.MassAdd(ref objdmass, ref tmpdmass); // add to total object inertia } } } } - SafeNativeMethods.GeomClearOffset(m_prim_geom); // make sure we don't have a hidden offset + UBOdeNative.GeomClearOffset(m_prim_geom); // make sure we don't have a hidden offset // associate root geom with body - SafeNativeMethods.GeomSetBody(m_prim_geom, Body); + UBOdeNative.GeomSetBody(m_prim_geom, Body); if(noInertiaOverride) - SafeNativeMethods.BodySetPosition(Body, m_position.X + objdmass.c.X, m_position.Y + objdmass.c.Y, m_position.Z + objdmass.c.Z); + UBOdeNative.BodySetPosition(Body, m_position.X + objdmass.c.X, m_position.Y + objdmass.c.Y, m_position.Z + objdmass.c.Z); else { Vector3 ncm = m_InertiaOverride.CenterOfMass * m_orientation; - SafeNativeMethods.BodySetPosition(Body, + UBOdeNative.BodySetPosition(Body, m_position.X + ncm.X, m_position.Y + ncm.Y, m_position.Z + ncm.Z); } - SafeNativeMethods.GeomSetOffsetWorldPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); + UBOdeNative.GeomSetOffsetWorldPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); if(noInertiaOverride) { - SafeNativeMethods.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body + UBOdeNative.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body Quaternion mr = Quaternion.Conjugate(m_orientation); - SafeNativeMethods.RfromQ(ref mymat, ref mr); - SafeNativeMethods.MassRotate(ref objdmass, ref mymat); + UBOdeNative.RfromQ(ref mymat, ref mr); + UBOdeNative.MassRotate(ref objdmass, ref mymat); - SafeNativeMethods.BodySetMass(Body, ref objdmass); + UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } else @@ -2019,29 +2019,29 @@ namespace OpenSim.Region.PhysicsModule.ubOde if(Math.Abs(m_InertiaOverride.InertiaRotation.W) < 0.999) { - SafeNativeMethods.Matrix3 inertiarotmat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.RfromQ(ref inertiarotmat, ref m_InertiaOverride.InertiaRotation); - SafeNativeMethods.MassRotate(ref objdmass, ref inertiarotmat); + UBOdeNative.Matrix3 inertiarotmat = new UBOdeNative.Matrix3(); + UBOdeNative.RfromQ(ref inertiarotmat, ref m_InertiaOverride.InertiaRotation); + UBOdeNative.MassRotate(ref objdmass, ref inertiarotmat); } - SafeNativeMethods.BodySetMass(Body, ref objdmass); + UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } // disconnect from world gravity so we can apply buoyancy - SafeNativeMethods.BodySetGravityMode(Body, false); + UBOdeNative.BodySetGravityMode(Body, false); - SafeNativeMethods.BodySetAutoDisableFlag(Body, true); - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodySetAutoDisableAngularThreshold(Body, 0.001f); - SafeNativeMethods.BodySetAutoDisableLinearThreshold(Body, 0.01f); - SafeNativeMethods.BodySetDamping(Body, .002f, .0005f); + UBOdeNative.BodySetAutoDisableFlag(Body, true); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodySetAutoDisableAngularThreshold(Body, 0.001f); + UBOdeNative.BodySetAutoDisableLinearThreshold(Body, 0.01f); + UBOdeNative.BodySetDamping(Body, .002f, .0005f); if (m_targetSpace != IntPtr.Zero) { //m_parentScene.waitForSpaceUnlock(m_targetSpace); - if (SafeNativeMethods.SpaceQuery(m_targetSpace, m_prim_geom)) - SafeNativeMethods.SpaceRemove(m_targetSpace, m_prim_geom); + if (UBOdeNative.SpaceQuery(m_targetSpace, m_prim_geom)) + UBOdeNative.SpaceRemove(m_targetSpace, m_prim_geom); } if (childrenPrim.Count == 0) @@ -2051,23 +2051,23 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else { - m_targetSpace = SafeNativeMethods.SimpleSpaceCreate(m_parentScene.ActiveSpace); - SafeNativeMethods.SpaceSetSublevel(m_targetSpace, 0); - SafeNativeMethods.SpaceSetCleanup(m_targetSpace, false); + m_targetSpace = UBOdeNative.SimpleSpaceCreate(m_parentScene.ActiveSpace); + UBOdeNative.SpaceSetSublevel(m_targetSpace, 0); + UBOdeNative.SpaceSetCleanup(m_targetSpace, false); - SafeNativeMethods.GeomSetCategoryBits(m_targetSpace, (uint)(CollisionCategories.Space | + UBOdeNative.GeomSetCategoryBits(m_targetSpace, (uint)(CollisionCategories.Space | CollisionCategories.Geom | CollisionCategories.Phantom | CollisionCategories.VolumeDtc )); - SafeNativeMethods.GeomSetCollideBits(m_targetSpace, 0); + UBOdeNative.GeomSetCollideBits(m_targetSpace, 0); m_collide_geom = m_targetSpace; } - if (SafeNativeMethods.SpaceQuery(m_targetSpace, m_prim_geom)) + if (UBOdeNative.SpaceQuery(m_targetSpace, m_prim_geom)) m_log.Debug("[PRIM]: parent already in target space"); else - SafeNativeMethods.SpaceAdd(m_targetSpace, m_prim_geom); + UBOdeNative.SpaceAdd(m_targetSpace, m_prim_geom); if (m_delaySelect) { @@ -2091,7 +2091,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde continue; Vector3 ppos = prm.m_position; - SafeNativeMethods.GeomSetOffsetWorldPosition(prm.m_prim_geom, ppos.X, ppos.Y, ppos.Z); // set relative position + UBOdeNative.GeomSetOffsetWorldPosition(prm.m_prim_geom, ppos.X, ppos.Y, ppos.Z); // set relative position IntPtr prmspace = prm.m_targetSpace; if (prmspace != m_targetSpace) @@ -2099,14 +2099,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (prmspace != IntPtr.Zero) { //m_parentScene.waitForSpaceUnlock(prmspace); - if (SafeNativeMethods.SpaceQuery(prmspace, prmgeom)) - SafeNativeMethods.SpaceRemove(prmspace, prmgeom); + if (UBOdeNative.SpaceQuery(prmspace, prmgeom)) + UBOdeNative.SpaceRemove(prmspace, prmgeom); } prm.m_targetSpace = m_targetSpace; - if (SafeNativeMethods.SpaceQuery(m_targetSpace, prmgeom)) + if (UBOdeNative.SpaceQuery(m_targetSpace, prmgeom)) m_log.Debug("[PRIM]: child already in target space"); else - SafeNativeMethods.SpaceAdd(m_targetSpace, prmgeom); + UBOdeNative.SpaceAdd(m_targetSpace, prmgeom); } prm.m_collisionscore = 0; @@ -2126,13 +2126,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_isSelected || m_disabled) { - SafeNativeMethods.BodyDisable(Body); + UBOdeNative.BodyDisable(Body); _zeroFlag = true; } else { - SafeNativeMethods.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); - SafeNativeMethods.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); + UBOdeNative.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); + UBOdeNative.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); _zeroFlag = false; m_bodydisablecontrol = 0; @@ -2165,16 +2165,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, 0); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, 0); + UBOdeNative.GeomSetCollideBits(m_prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); } UpdateDataFromGeom(); - SafeNativeMethods.GeomSetBody(m_prim_geom, IntPtr.Zero); + UBOdeNative.GeomSetBody(m_prim_geom, IntPtr.Zero); SetInStaticSpace(this); } @@ -2201,13 +2201,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (prm.m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(prm.m_prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, 0); + UBOdeNative.GeomSetCategoryBits(prm.m_prim_geom, 0); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(prm.m_prim_geom, (uint)prm.m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, (uint)prm.m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(prm.m_prim_geom, (uint)prm.m_collisionCategories); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, (uint)prm.m_collisionFlags); } prm.UpdateDataFromGeom(); SetInStaticSpace(prm); @@ -2219,11 +2219,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde } if (Amotor != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(Amotor); + UBOdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } m_parentScene.remActiveGroup(this); - SafeNativeMethods.BodyDestroy(Body); + UBOdeNative.BodyDestroy(Body); } Body = IntPtr.Zero; } @@ -2233,30 +2233,30 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void FixInertia(Vector3 NewPos,Quaternion newrot) { - SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.Quaternion quat = new SafeNativeMethods.Quaternion(); + UBOdeNative.Matrix3 mat = new UBOdeNative.Matrix3(); + UBOdeNative.Quaternion quat = new UBOdeNative.Quaternion(); - SafeNativeMethods.Mass tmpdmass = new SafeNativeMethods.Mass { }; - SafeNativeMethods.Mass objdmass = new SafeNativeMethods.Mass { }; + UBOdeNative.Mass tmpdmass = new UBOdeNative.Mass { }; + UBOdeNative.Mass objdmass = new UBOdeNative.Mass { }; - SafeNativeMethods.BodyGetMass(Body, out tmpdmass); + UBOdeNative.BodyGetMass(Body, out tmpdmass); objdmass = tmpdmass; - SafeNativeMethods.Vector3 dobjpos; - SafeNativeMethods.Vector3 thispos; + UBOdeNative.Vector3 dobjpos; + UBOdeNative.Vector3 thispos; // get current object position and rotation - dobjpos = SafeNativeMethods.BodyGetPosition(Body); + dobjpos = UBOdeNative.BodyGetPosition(Body); // get prim own inertia in its local frame tmpdmass = primdMass; // transform to object frame - mat = SafeNativeMethods.GeomGetOffsetRotation(m_prim_geom); - SafeNativeMethods.MassRotate(ref tmpdmass, ref mat); + mat = UBOdeNative.GeomGetOffsetRotation(m_prim_geom); + UBOdeNative.MassRotate(ref tmpdmass, ref mat); - thispos = SafeNativeMethods.GeomGetOffsetPosition(m_prim_geom); - SafeNativeMethods.MassTranslate(ref tmpdmass, + thispos = UBOdeNative.GeomGetOffsetPosition(m_prim_geom); + UBOdeNative.MassTranslate(ref tmpdmass, thispos.X, thispos.Y, thispos.Z); @@ -2269,66 +2269,66 @@ namespace OpenSim.Region.PhysicsModule.ubOde // update to new position and orientation m_position = NewPos; - SafeNativeMethods.GeomSetOffsetWorldPosition(m_prim_geom, NewPos.X, NewPos.Y, NewPos.Z); + UBOdeNative.GeomSetOffsetWorldPosition(m_prim_geom, NewPos.X, NewPos.Y, NewPos.Z); m_orientation = newrot; quat.X = newrot.X; quat.Y = newrot.Y; quat.Z = newrot.Z; quat.W = newrot.W; - SafeNativeMethods.GeomSetOffsetWorldQuaternion(m_prim_geom, ref quat); + UBOdeNative.GeomSetOffsetWorldQuaternion(m_prim_geom, ref quat); - mat = SafeNativeMethods.GeomGetOffsetRotation(m_prim_geom); - SafeNativeMethods.MassRotate(ref tmpdmass, ref mat); + mat = UBOdeNative.GeomGetOffsetRotation(m_prim_geom); + UBOdeNative.MassRotate(ref tmpdmass, ref mat); - thispos = SafeNativeMethods.GeomGetOffsetPosition(m_prim_geom); - SafeNativeMethods.MassTranslate(ref tmpdmass, + thispos = UBOdeNative.GeomGetOffsetPosition(m_prim_geom); + UBOdeNative.MassTranslate(ref tmpdmass, thispos.X, thispos.Y, thispos.Z); - SafeNativeMethods.MassAdd(ref objdmass, ref tmpdmass); + UBOdeNative.MassAdd(ref objdmass, ref tmpdmass); // fix all positions - IntPtr g = SafeNativeMethods.BodyGetFirstGeom(Body); + IntPtr g = UBOdeNative.BodyGetFirstGeom(Body); while (g != IntPtr.Zero) { - thispos = SafeNativeMethods.GeomGetOffsetPosition(g); + thispos = UBOdeNative.GeomGetOffsetPosition(g); thispos.X -= objdmass.c.X; thispos.Y -= objdmass.c.Y; thispos.Z -= objdmass.c.Z; - SafeNativeMethods.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z); - g = SafeNativeMethods.dBodyGetNextGeom(g); + UBOdeNative.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z); + g = UBOdeNative.dBodyGetNextGeom(g); } - SafeNativeMethods.BodyVectorToWorld(Body,objdmass.c.X, objdmass.c.Y, objdmass.c.Z,out thispos); + UBOdeNative.BodyVectorToWorld(Body,objdmass.c.X, objdmass.c.Y, objdmass.c.Z,out thispos); - SafeNativeMethods.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); - SafeNativeMethods.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body - SafeNativeMethods.BodySetMass(Body, ref objdmass); + UBOdeNative.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); + UBOdeNative.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body + UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } private void FixInertia(Vector3 NewPos) { - SafeNativeMethods.Matrix3 primmat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.Mass tmpdmass = new SafeNativeMethods.Mass { }; - SafeNativeMethods.Mass objdmass = new SafeNativeMethods.Mass { }; - SafeNativeMethods.Mass primmass = new SafeNativeMethods.Mass { }; + UBOdeNative.Matrix3 primmat = new UBOdeNative.Matrix3(); + UBOdeNative.Mass tmpdmass = new UBOdeNative.Mass { }; + UBOdeNative.Mass objdmass = new UBOdeNative.Mass { }; + UBOdeNative.Mass primmass = new UBOdeNative.Mass { }; - SafeNativeMethods.Vector3 dobjpos; - SafeNativeMethods.Vector3 thispos; + UBOdeNative.Vector3 dobjpos; + UBOdeNative.Vector3 thispos; - SafeNativeMethods.BodyGetMass(Body, out objdmass); + UBOdeNative.BodyGetMass(Body, out objdmass); // get prim own inertia in its local frame primmass = primdMass; // transform to object frame - primmat = SafeNativeMethods.GeomGetOffsetRotation(m_prim_geom); - SafeNativeMethods.MassRotate(ref primmass, ref primmat); + primmat = UBOdeNative.GeomGetOffsetRotation(m_prim_geom); + UBOdeNative.MassRotate(ref primmass, ref primmat); tmpdmass = primmass; - thispos = SafeNativeMethods.GeomGetOffsetPosition(m_prim_geom); - SafeNativeMethods.MassTranslate(ref tmpdmass, + thispos = UBOdeNative.GeomGetOffsetPosition(m_prim_geom); + UBOdeNative.MassTranslate(ref tmpdmass, thispos.X, thispos.Y, thispos.Z); @@ -2338,58 +2338,58 @@ namespace OpenSim.Region.PhysicsModule.ubOde // update to new position m_position = NewPos; - SafeNativeMethods.GeomSetOffsetWorldPosition(m_prim_geom, NewPos.X, NewPos.Y, NewPos.Z); + UBOdeNative.GeomSetOffsetWorldPosition(m_prim_geom, NewPos.X, NewPos.Y, NewPos.Z); - thispos = SafeNativeMethods.GeomGetOffsetPosition(m_prim_geom); - SafeNativeMethods.MassTranslate(ref primmass, + thispos = UBOdeNative.GeomGetOffsetPosition(m_prim_geom); + UBOdeNative.MassTranslate(ref primmass, thispos.X, thispos.Y, thispos.Z); - SafeNativeMethods.MassAdd(ref objdmass, ref primmass); + UBOdeNative.MassAdd(ref objdmass, ref primmass); // fix all positions - IntPtr g = SafeNativeMethods.BodyGetFirstGeom(Body); + IntPtr g = UBOdeNative.BodyGetFirstGeom(Body); while (g != IntPtr.Zero) { - thispos = SafeNativeMethods.GeomGetOffsetPosition(g); + thispos = UBOdeNative.GeomGetOffsetPosition(g); thispos.X -= objdmass.c.X; thispos.Y -= objdmass.c.Y; thispos.Z -= objdmass.c.Z; - SafeNativeMethods.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z); - g = SafeNativeMethods.dBodyGetNextGeom(g); + UBOdeNative.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z); + g = UBOdeNative.dBodyGetNextGeom(g); } - SafeNativeMethods.BodyVectorToWorld(Body, objdmass.c.X, objdmass.c.Y, objdmass.c.Z, out thispos); + UBOdeNative.BodyVectorToWorld(Body, objdmass.c.X, objdmass.c.Y, objdmass.c.Z, out thispos); // get current object position and rotation - dobjpos = SafeNativeMethods.BodyGetPosition(Body); + dobjpos = UBOdeNative.BodyGetPosition(Body); - SafeNativeMethods.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); - SafeNativeMethods.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body - SafeNativeMethods.BodySetMass(Body, ref objdmass); + UBOdeNative.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); + UBOdeNative.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body + UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } private void FixInertia(Quaternion newrot) { - SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3(); - SafeNativeMethods.Quaternion quat = new SafeNativeMethods.Quaternion(); + UBOdeNative.Matrix3 mat = new UBOdeNative.Matrix3(); + UBOdeNative.Quaternion quat = new UBOdeNative.Quaternion(); - SafeNativeMethods.Mass tmpdmass = new SafeNativeMethods.Mass { }; - SafeNativeMethods.Mass objdmass = new SafeNativeMethods.Mass { }; - SafeNativeMethods.Vector3 dobjpos; - SafeNativeMethods.Vector3 thispos; + UBOdeNative.Mass tmpdmass = new UBOdeNative.Mass { }; + UBOdeNative.Mass objdmass = new UBOdeNative.Mass { }; + UBOdeNative.Vector3 dobjpos; + UBOdeNative.Vector3 thispos; - SafeNativeMethods.BodyGetMass(Body, out objdmass); + UBOdeNative.BodyGetMass(Body, out objdmass); // get prim own inertia in its local frame tmpdmass = primdMass; - mat = SafeNativeMethods.GeomGetOffsetRotation(m_prim_geom); - SafeNativeMethods.MassRotate(ref tmpdmass, ref mat); + mat = UBOdeNative.GeomGetOffsetRotation(m_prim_geom); + UBOdeNative.MassRotate(ref tmpdmass, ref mat); // transform to object frame - thispos = SafeNativeMethods.GeomGetOffsetPosition(m_prim_geom); - SafeNativeMethods.MassTranslate(ref tmpdmass, + thispos = UBOdeNative.GeomGetOffsetPosition(m_prim_geom); + UBOdeNative.MassTranslate(ref tmpdmass, thispos.X, thispos.Y, thispos.Z); @@ -2403,37 +2403,37 @@ namespace OpenSim.Region.PhysicsModule.ubOde quat.Y = newrot.Y; quat.Z = newrot.Z; quat.W = newrot.W; - SafeNativeMethods.GeomSetOffsetWorldQuaternion(m_prim_geom, ref quat); + UBOdeNative.GeomSetOffsetWorldQuaternion(m_prim_geom, ref quat); tmpdmass = primdMass; - mat = SafeNativeMethods.GeomGetOffsetRotation(m_prim_geom); - SafeNativeMethods.MassRotate(ref tmpdmass, ref mat); - SafeNativeMethods.MassTranslate(ref tmpdmass, + mat = UBOdeNative.GeomGetOffsetRotation(m_prim_geom); + UBOdeNative.MassRotate(ref tmpdmass, ref mat); + UBOdeNative.MassTranslate(ref tmpdmass, thispos.X, thispos.Y, thispos.Z); - SafeNativeMethods.MassAdd(ref objdmass, ref tmpdmass); + UBOdeNative.MassAdd(ref objdmass, ref tmpdmass); // fix all positions - IntPtr g = SafeNativeMethods.BodyGetFirstGeom(Body); + IntPtr g = UBOdeNative.BodyGetFirstGeom(Body); while (g != IntPtr.Zero) { - thispos = SafeNativeMethods.GeomGetOffsetPosition(g); + thispos = UBOdeNative.GeomGetOffsetPosition(g); thispos.X -= objdmass.c.X; thispos.Y -= objdmass.c.Y; thispos.Z -= objdmass.c.Z; - SafeNativeMethods.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z); - g = SafeNativeMethods.dBodyGetNextGeom(g); + UBOdeNative.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z); + g = UBOdeNative.dBodyGetNextGeom(g); } - SafeNativeMethods.BodyVectorToWorld(Body, objdmass.c.X, objdmass.c.Y, objdmass.c.Z, out thispos); + UBOdeNative.BodyVectorToWorld(Body, objdmass.c.X, objdmass.c.Y, objdmass.c.Z, out thispos); // get current object position and rotation - dobjpos = SafeNativeMethods.BodyGetPosition(Body); + dobjpos = UBOdeNative.BodyGetPosition(Body); - SafeNativeMethods.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); - SafeNativeMethods.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body - SafeNativeMethods.BodySetMass(Body, ref objdmass); + UBOdeNative.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z); + UBOdeNative.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body + UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } @@ -2451,9 +2451,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_mass = primMass; // just in case - SafeNativeMethods.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z); + UBOdeNative.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z); - SafeNativeMethods.MassTranslate(ref primdMass, + UBOdeNative.MassTranslate(ref primdMass, m_OBBOffset.X, m_OBBOffset.Y, m_OBBOffset.Z); @@ -2508,7 +2508,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (prm.Body != IntPtr.Zero) { if (prm.m_prim_geom != IntPtr.Zero) - SafeNativeMethods.GeomSetBody(prm.m_prim_geom, IntPtr.Zero); + UBOdeNative.GeomSetBody(prm.m_prim_geom, IntPtr.Zero); if (prm.Body != prim.Body) prm.DestroyBody(); // don't loose bodies around prm.Body = IntPtr.Zero; @@ -2525,7 +2525,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (prim.Body != IntPtr.Zero) { if (prim.m_prim_geom != IntPtr.Zero) - SafeNativeMethods.GeomSetBody(prim.m_prim_geom, IntPtr.Zero); + UBOdeNative.GeomSetBody(prim.m_prim_geom, IntPtr.Zero); prim.DestroyBody(); // don't loose bodies around prim.Body = IntPtr.Zero; } @@ -2550,7 +2550,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_prim_geom != IntPtr.Zero) { - m_orientation = SafeNativeMethods.GeomGetQuaternionOMV(m_prim_geom); + m_orientation = UBOdeNative.GeomGetQuaternionOMV(m_prim_geom); /* // Debug float qlen = _orientation.Length(); @@ -2558,7 +2558,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_log.WarnFormat("[PHYSICS]: Got nonnorm quaternion from geom in Object {0} norm {1}", Name, qlen); */ m_orientation.Normalize(); - m_position = SafeNativeMethods.GeomGetPositionOMV(m_prim_geom); + m_position = UBOdeNative.GeomGetPositionOMV(m_prim_geom); } } @@ -2686,7 +2686,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (Amotor != IntPtr.Zero) { - SafeNativeMethods.JointDestroy(Amotor); + UBOdeNative.JointDestroy(Amotor); Amotor = IntPtr.Zero; } } @@ -2745,10 +2745,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero) { - SafeNativeMethods.BodySetForce(Body, 0f, 0f, 0f); - SafeNativeMethods.BodySetTorque(Body, 0f, 0f, 0f); - SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f); - SafeNativeMethods.BodySetAngularVel(Body, 0f, 0f, 0f); + UBOdeNative.BodySetForce(Body, 0f, 0f, 0f); + UBOdeNative.BodySetTorque(Body, 0f, 0f, 0f); + UBOdeNative.BodySetLinearVel(Body, 0f, 0f, 0f); + UBOdeNative.BodySetAngularVel(Body, 0f, 0f, 0f); } } @@ -2789,7 +2789,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (newval) { if (!childPrim && Body != IntPtr.Zero) - SafeNativeMethods.BodyDisable(Body); + UBOdeNative.BodyDisable(Body); if (m_delaySelect || m_isphysical) { @@ -2808,13 +2808,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (prm.m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(prm.m_prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, 0); + UBOdeNative.GeomSetCategoryBits(prm.m_prim_geom, 0); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, 0); } else { - SafeNativeMethods.GeomSetCategoryBits(prm.m_prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(prm.m_prim_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(prm.m_prim_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(prm.m_prim_geom, (uint)m_collisionFlags); } } prm.m_delaySelect = false; @@ -2825,22 +2825,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_NoColide) { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, 0); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, 0); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, 0); + UBOdeNative.GeomSetCollideBits(m_prim_geom, 0); if (m_collide_geom != m_prim_geom && m_collide_geom != IntPtr.Zero) { - SafeNativeMethods.GeomSetCategoryBits(m_collide_geom, 0); - SafeNativeMethods.GeomSetCollideBits(m_collide_geom, 0); + UBOdeNative.GeomSetCategoryBits(m_collide_geom, 0); + UBOdeNative.GeomSetCollideBits(m_collide_geom, 0); } } else { - SafeNativeMethods.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(m_prim_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(m_prim_geom, (uint)m_collisionFlags); if (m_collide_geom != m_prim_geom && m_collide_geom != IntPtr.Zero) { - SafeNativeMethods.GeomSetCategoryBits(m_collide_geom, (uint)m_collisionCategories); - SafeNativeMethods.GeomSetCollideBits(m_collide_geom, (uint)m_collisionFlags); + UBOdeNative.GeomSetCategoryBits(m_collide_geom, (uint)m_collisionCategories); + UBOdeNative.GeomSetCollideBits(m_collide_geom, (uint)m_collisionFlags); } } } @@ -2859,8 +2859,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero && !m_disabled) { _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -2889,11 +2889,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde else if (m_forcePosOrRotation && Body != IntPtr.Zero && m_position.NotEqual(newPos)) { FixInertia(newPos); - if (!SafeNativeMethods.BodyIsEnabled(Body)) + if (!UBOdeNative.BodyIsEnabled(Body)) { _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } } @@ -2901,14 +2901,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_position.NotEqual(newPos)) { - SafeNativeMethods.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); + UBOdeNative.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); m_position = newPos; } - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } } @@ -2918,7 +2918,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_position.NotEqual(newPos)) { - SafeNativeMethods.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); + UBOdeNative.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); m_position = newPos; m_targetSpace = m_parentScene.MoveGeomToStaticSpace(m_prim_geom, m_targetSpace); @@ -2957,14 +2957,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (newOri.NotEqual(m_orientation)) { - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion() + UBOdeNative.Quaternion myrot = new UBOdeNative.Quaternion() { X = newOri.X, Y = newOri.Y, Z = newOri.Z, W = newOri.W }; - SafeNativeMethods.GeomSetQuaternion(m_prim_geom, ref myrot); + UBOdeNative.GeomSetQuaternion(m_prim_geom, ref myrot); m_orientation = newOri; if (Body != IntPtr.Zero) @@ -2973,11 +2973,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde createAMotor(m_angularlocks); } } - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } } @@ -2987,14 +2987,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (newOri.NotEqual(m_orientation)) { - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion() + UBOdeNative.Quaternion myrot = new UBOdeNative.Quaternion() { X = newOri.X, Y = newOri.Y, Z = newOri.Z, W = newOri.W }; - SafeNativeMethods.GeomSetQuaternion(m_prim_geom, ref myrot); + UBOdeNative.GeomSetQuaternion(m_prim_geom, ref myrot); m_orientation = newOri; } } @@ -3020,28 +3020,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (newOri.NotEqual(m_orientation)) { - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion() + UBOdeNative.Quaternion myrot = new UBOdeNative.Quaternion() { X = newOri.X, Y = newOri.Y, Z = newOri.Z, W = newOri.W }; - SafeNativeMethods.GeomSetQuaternion(m_prim_geom, ref myrot); + UBOdeNative.GeomSetQuaternion(m_prim_geom, ref myrot); m_orientation = newOri; if (Body != IntPtr.Zero && m_angularlocks != 0) createAMotor(m_angularlocks); } if (m_position.NotEqual(newPos)) { - SafeNativeMethods.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); + UBOdeNative.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); m_position = newPos; } - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } } @@ -3054,20 +3054,20 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (newOri.NotEqual(m_orientation)) { - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion() + UBOdeNative.Quaternion myrot = new UBOdeNative.Quaternion() { X = newOri.X, Y = newOri.Y, Z = newOri.Z, W = newOri.W }; - SafeNativeMethods.GeomSetQuaternion(m_prim_geom, ref myrot); + UBOdeNative.GeomSetQuaternion(m_prim_geom, ref myrot); m_orientation = newOri; } if (newPos.NotEqual(m_position)) { - SafeNativeMethods.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); + UBOdeNative.GeomSetPosition(m_prim_geom, newPos.X, newPos.Y, newPos.Z); m_position = newPos; m_targetSpace = m_parentScene.MoveGeomToStaticSpace(m_prim_geom, m_targetSpace); @@ -3156,13 +3156,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_prim_geom != IntPtr.Zero) { - SafeNativeMethods.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + UBOdeNative.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); + UBOdeNative.Quaternion myrot = new UBOdeNative.Quaternion(); myrot.X = m_orientation.X; myrot.Y = m_orientation.Y; myrot.Z = m_orientation.Z; myrot.W = m_orientation.W; - SafeNativeMethods.GeomSetQuaternion(m_prim_geom, ref myrot); + UBOdeNative.GeomSetQuaternion(m_prim_geom, ref myrot); } if (!m_isphysical) @@ -3233,13 +3233,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_prim_geom != IntPtr.Zero) { - SafeNativeMethods.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); - SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); + UBOdeNative.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); + UBOdeNative.Quaternion myrot = new UBOdeNative.Quaternion(); myrot.X = m_orientation.X; myrot.Y = m_orientation.Y; myrot.Z = m_orientation.Z; myrot.W = m_orientation.W; - SafeNativeMethods.GeomSetQuaternion(m_prim_geom, ref myrot); + UBOdeNative.GeomSetQuaternion(m_prim_geom, ref myrot); } if (m_isphysical) @@ -3292,10 +3292,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_disabled) enableBodySoft(); - else if (!SafeNativeMethods.BodyIsEnabled(Body)) + else if (!UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } m_torque = newtorque; @@ -3306,10 +3306,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changeForce(Vector3 force) { m_force = force; - if (!m_isSelected && !m_outbounds && Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (!m_isSelected && !m_outbounds && Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3326,10 +3326,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_disabled) enableBodySoft(); - else if (!SafeNativeMethods.BodyIsEnabled(Body)) + else if (!UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } } @@ -3350,10 +3350,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_disabled) enableBodySoft(); - else if (!SafeNativeMethods.BodyIsEnabled(Body)) + else if (!UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } } @@ -3377,12 +3377,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_disabled) enableBodySoft(); - else if (!SafeNativeMethods.BodyIsEnabled(Body)) + else if (!UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } - SafeNativeMethods.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); + UBOdeNative.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); } //resetCollisionAccounting(); } @@ -3405,12 +3405,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (m_disabled) enableBodySoft(); - else if (!SafeNativeMethods.BodyIsEnabled(Body)) + else if (!UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } - SafeNativeMethods.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z); + UBOdeNative.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z); } //resetCollisionAccounting(); } @@ -3485,10 +3485,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde return; m_vehicle.ProcessFloatVehicleParam((Vehicle)fp.param, fp.value); - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3498,10 +3498,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_vehicle == null) return; m_vehicle.ProcessVectorVehicleParam((Vehicle)vp.param, vp.value); - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3511,10 +3511,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_vehicle == null) return; m_vehicle.ProcessRotationVehicleParam((Vehicle)qp.param, qp.value); - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3524,10 +3524,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_vehicle == null) return; m_vehicle.ProcessVehicleFlags(bp.param, bp.value); - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3535,10 +3535,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changeBuoyancy(float b) { m_buoyancy = b; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3546,10 +3546,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changePIDTarget(Vector3 trg) { m_PIDTarget = trg; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3557,10 +3557,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changePIDTau(float tau) { m_PIDTau = tau; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3568,10 +3568,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changePIDActive(bool val) { m_usePID = val; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3581,10 +3581,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_PIDHoverHeight = val; if (val == 0) m_useHoverPID = false; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3592,10 +3592,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changePIDHoverType(PIDHoverType type) { m_PIDHoverType = type; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3603,10 +3603,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changePIDHoverTau(float tau) { m_PIDHoverTau = tau; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3614,10 +3614,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changePIDHoverActive(bool active) { m_useHoverPID = active; - if (Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body)) + if (Body != IntPtr.Zero && !UBOdeNative.BodyIsEnabled(Body)) { - SafeNativeMethods.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); + UBOdeNative.BodyEnable(Body); } } @@ -3638,7 +3638,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (!childPrim && m_isphysical && Body != IntPtr.Zero && !m_disabled && !m_isSelected && !m_building && !m_outbounds) { - if (!SafeNativeMethods.BodyIsEnabled(Body)) + if (!UBOdeNative.BodyIsEnabled(Body)) { // let vehicles sleep if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) @@ -3648,11 +3648,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde return; // clear residuals - SafeNativeMethods.BodySetAngularVel(Body,0f,0f,0f); - SafeNativeMethods.BodySetLinearVel(Body,0f,0f,0f); + UBOdeNative.BodySetAngularVel(Body,0f,0f,0f); + UBOdeNative.BodySetLinearVel(Body,0f,0f,0f); _zeroFlag = true; - SafeNativeMethods.BodySetAutoDisableSteps(Body, 1); - SafeNativeMethods.BodyEnable(Body); + UBOdeNative.BodySetAutoDisableSteps(Body, 1); + UBOdeNative.BodyEnable(Body); m_bodydisablecontrol = -3; } @@ -3670,7 +3670,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde float fy = 0; float fz = 0; - Vector3 lpos = SafeNativeMethods.GeomGetPositionOMV(m_prim_geom); // root position that is seem by rest of simulator + Vector3 lpos = UBOdeNative.GeomGetPositionOMV(m_prim_geom); // root position that is seem by rest of simulator if (m_usePID && m_PIDTau > 0) { @@ -3678,8 +3678,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde _target_velocity = m_PIDTarget - lpos; if (_target_velocity.ApproxZero(0.02f)) { - SafeNativeMethods.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); + UBOdeNative.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); + UBOdeNative.BodySetLinearVel(Body, 0, 0, 0); return; } else @@ -3702,7 +3702,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde _target_velocity *= tmp; } - SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body); + UBOdeNative.Vector3 vel = UBOdeNative.BodyGetLinearVel(Body); fx = (_target_velocity.X - vel.X) * m_sceneInverseTimeStep; fy = (_target_velocity.Y - vel.Y) * m_sceneInverseTimeStep; fz = (_target_velocity.Z - vel.Z) * m_sceneInverseTimeStep; @@ -3737,15 +3737,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_targetHoverHeight > groundHeight || m_isVolumeDetect) { - SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body); + UBOdeNative.Vector3 vel = UBOdeNative.BodyGetLinearVel(Body); fz = (m_targetHoverHeight - lpos.Z); // if error is zero, use position control; otherwise, velocity control if (Math.Abs(fz) < 0.01f) { - SafeNativeMethods.BodySetPosition(Body, lpos.X, lpos.Y, m_targetHoverHeight); - SafeNativeMethods.BodySetLinearVel(Body, vel.X, vel.Y, 0); + UBOdeNative.BodySetPosition(Body, lpos.X, lpos.Y, m_targetHoverHeight); + UBOdeNative.BodySetLinearVel(Body, vel.X, vel.Y, 0); } else { @@ -3789,7 +3789,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString()); if (fz != 0 || fx != 0 || fy != 0) { - SafeNativeMethods.BodyAddForce(Body, fx, fy, fz); + UBOdeNative.BodyAddForce(Body, fx, fy, fz); //Console.WriteLine("AddForce " + fx + "," + fy + "," + fz); } @@ -3797,7 +3797,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_angularForceacc = Vector3.Zero; if (trq.X != 0 || trq.Y != 0 || trq.Z != 0) { - SafeNativeMethods.BodyAddTorque(Body, trq.X, trq.Y, trq.Z); + UBOdeNative.BodyAddTorque(Body, trq.X, trq.Y, trq.Z); } } else @@ -3814,12 +3814,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde if(m_bodydisablecontrol < 0) return; - bool bodyenabled = SafeNativeMethods.BodyIsEnabled(Body); + bool bodyenabled = UBOdeNative.BodyIsEnabled(Body); if (bodyenabled || !_zeroFlag) { bool lastZeroFlag = _zeroFlag; - Vector3 lpos = SafeNativeMethods.GeomGetPositionOMV(m_prim_geom); + Vector3 lpos = UBOdeNative.GeomGetPositionOMV(m_prim_geom); // check outside region if (lpos.Z < -100 || lpos.Z > 100000f) @@ -3831,9 +3831,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde _velocity = Vector3.Zero; m_rotationalVelocity = Vector3.Zero; - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); // stop it - SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0); // stop it - SafeNativeMethods.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere + UBOdeNative.BodySetLinearVel(Body, 0, 0, 0); // stop it + UBOdeNative.BodySetAngularVel(Body, 0, 0, 0); // stop it + UBOdeNative.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere m_lastposition = m_position; m_lastorientation = m_orientation; @@ -3873,12 +3873,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_lastposition = m_position; m_lastorientation = m_orientation; - _velocity = SafeNativeMethods.BodyGetLinearVelOMV(Body); - m_rotationalVelocity = SafeNativeMethods.BodyGetAngularVelOMV(Body); + _velocity = UBOdeNative.BodyGetLinearVelOMV(Body); + m_rotationalVelocity = UBOdeNative.BodyGetAngularVelOMV(Body); - SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); // stop it - SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0); - SafeNativeMethods.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); + UBOdeNative.BodySetLinearVel(Body, 0, 0, 0); // stop it + UBOdeNative.BodySetAngularVel(Body, 0, 0, 0); + UBOdeNative.GeomSetPosition(m_prim_geom, m_position.X, m_position.Y, m_position.Z); disableBodySoft(); // stop collisions UnSubscribeEvents(); @@ -3886,7 +3886,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde return; } - Quaternion ori = SafeNativeMethods.GeomGetQuaternionOMV(m_prim_geom); + Quaternion ori = UBOdeNative.GeomGetQuaternionOMV(m_prim_geom); // decide if moving // use positions since this are integrated quantities @@ -3941,7 +3941,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else { - Vector3 vel = SafeNativeMethods.BodyGetLinearVelOMV(Body); + Vector3 vel = UBOdeNative.BodyGetLinearVelOMV(Body); m_acceleration = _velocity; if ((Math.Abs(vel.X) < 0.005f) && @@ -3965,7 +3965,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_acceleration = Vector3.Zero; } - vel = SafeNativeMethods.BodyGetAngularVelOMV(Body); + vel = UBOdeNative.BodyGetAngularVelOMV(Body); if ((Math.Abs(vel.X) < 0.0001) && (Math.Abs(vel.Y) < 0.0001) && (Math.Abs(vel.Z) < 0.0001) @@ -4010,7 +4010,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde return true; } - internal static void DMassSubPartFromObj(ref SafeNativeMethods.Mass part, ref SafeNativeMethods.Mass theobj) + internal static void DMassSubPartFromObj(ref UBOdeNative.Mass part, ref UBOdeNative.Mass theobj) { // assumes object center of mass is zero float smass = part.mass; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs index 0d55ebd9eb..6997d8b476 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// Scene that created this object. /// private readonly ODEScene m_scene; - private readonly SafeNativeMethods.ContactGeom[] m_contacts; + private readonly UBOdeNative.ContactGeom[] m_contacts; IntPtr ray; // the ray. we only need one for our lifetime @@ -64,7 +64,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// /// ODE near callback delegate /// - private readonly SafeNativeMethods.NearCallback nearCallback; + private readonly UBOdeNative.NearCallback nearCallback; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly List m_contactResults = new List(); private RayFilterFlags CurrentRayFilter; @@ -76,8 +76,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_scene = pScene; m_contacts = pScene.m_contacts; nearCallback = near; - ray = SafeNativeMethods.CreateRay(IntPtr.Zero, 1.0f); - SafeNativeMethods.GeomSetCategoryBits(ray, 0); + ray = UBOdeNative.CreateRay(IntPtr.Zero, 1.0f); + UBOdeNative.GeomSetCategoryBits(ray, 0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -132,22 +132,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde unchecked { CollisionContactGeomsPerTest = ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0) ? - CurrentMaxCount | (int)SafeNativeMethods.CONTACTS_UNIMPORTANT : CurrentMaxCount; + CurrentMaxCount | (int)UBOdeNative.CONTACTS_UNIMPORTANT : CurrentMaxCount; } int backfacecull = ((CurrentRayFilter & RayFilterFlags.BackFaceCull) == 0 ? 0 : 1); - SafeNativeMethods.GeomRaySetParams(ray, 0, backfacecull); + UBOdeNative.GeomRaySetParams(ray, 0, backfacecull); if (req.callbackMethod is RaycastCallback) { // if we only want one get only one per Collision pair saving memory CurrentRayFilter |= RayFilterFlags.ClosestHit; - SafeNativeMethods.GeomRaySetClosestHit(ray, 1); + UBOdeNative.GeomRaySetClosestHit(ray, 1); } else { int closestHit = ((CurrentRayFilter & RayFilterFlags.ClosestHit) == 0 ? 0 : 1); - SafeNativeMethods.GeomRaySetClosestHit(ray, closestHit); + UBOdeNative.GeomRaySetClosestHit(ray, closestHit); } if (geom == IntPtr.Zero) @@ -167,14 +167,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (catflags != 0) { - SafeNativeMethods.GeomSetCollideBits(ray, (uint)catflags); + UBOdeNative.GeomSetCollideBits(ray, (uint)catflags); doSpaceRay(req); } } else { // if we select a geom don't use filters - SafeNativeMethods.GeomSetCollideBits(ray, (uint)CollisionCategories.All); + UBOdeNative.GeomSetCollideBits(ray, (uint)CollisionCategories.All); doGeomRay(req,geom); } @@ -250,12 +250,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde } */ - SafeNativeMethods.GeomRaySetLength(ray, req.length); - SafeNativeMethods.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); + UBOdeNative.GeomRaySetLength(ray, req.length); + UBOdeNative.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide tests if ((CurrentRayFilter & FilterActiveSpace) != 0) - SafeNativeMethods.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); + UBOdeNative.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); if ((CurrentRayFilter & RayFilterFlags.agent) != 0) { @@ -268,7 +268,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) - SafeNativeMethods.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback); + UBOdeNative.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback); if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount)) { @@ -282,7 +282,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { float tmp2 = req.length * req.length - tmp + 2500; tmp2 = (float)Math.Sqrt(tmp2); - SafeNativeMethods.GeomRaySetLength(ray, tmp2); + UBOdeNative.GeomRaySetLength(ray, tmp2); } } @@ -337,11 +337,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde [MethodImpl(MethodImplOptions.AggressiveInlining)] private void doGeomRay(ODERayRequest req, IntPtr geom) { - SafeNativeMethods.GeomRaySetLength(ray, req.length); - SafeNativeMethods.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); + UBOdeNative.GeomRaySetLength(ray, req.length); + UBOdeNative.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test - SafeNativeMethods.SpaceCollide2(ray, geom, IntPtr.Zero, nearCallback); // still do this to have full AABB pre test + UBOdeNative.SpaceCollide2(ray, geom, IntPtr.Zero, nearCallback); // still do this to have full AABB pre test if (req.callbackMethod is RaycastCallback) { @@ -394,11 +394,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_contactResults.Count >= CurrentMaxCount) return; - if (SafeNativeMethods.GeomIsSpace(g2)) + if (UBOdeNative.GeomIsSpace(g2)) { try { - SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); + UBOdeNative.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); } catch (Exception e) { @@ -410,7 +410,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde int count = 0; try { - count = SafeNativeMethods.CollidePtr(g1, g2, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = UBOdeNative.CollidePtr(g1, g2, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, UBOdeNative.ContactGeom.unmanagedSizeOf); } catch (Exception e) { @@ -512,7 +512,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde int count = 0; try { - count = SafeNativeMethods.CollidePtr(ray, chr.collider, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = UBOdeNative.CollidePtr(ray, chr.collider, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, UBOdeNative.ContactGeom.unmanagedSizeOf); if (count == 0) return; } @@ -580,7 +580,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde int count = 0; try { - count = SafeNativeMethods.CollidePtr(ray, terrain, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = UBOdeNative.CollidePtr(ray, terrain, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, UBOdeNative.ContactGeom.unmanagedSizeOf); if (count == 0) return; } @@ -645,7 +645,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (ray != IntPtr.Zero) { - SafeNativeMethods.GeomDestroy(ray); + UBOdeNative.GeomDestroy(ray); ray = IntPtr.Zero; } } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 6dcc415f57..f4cf7f3945 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //private int threadid = 0; - const SafeNativeMethods.ContactFlags commomContactFlags = SafeNativeMethods.ContactFlags.Bounce | SafeNativeMethods.ContactFlags.Approx1; + const UBOdeNative.ContactFlags commomContactFlags = UBOdeNative.ContactFlags.Bounce | UBOdeNative.ContactFlags.Approx1; const float commomContactERP = 0.75f; const float commonContactCFM = 0.0001f; const float commomContactSLIP = 0f; @@ -221,7 +221,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde public int bodyFramesAutoDisable = 10; - private SafeNativeMethods.NearCallback NearCallback; + private UBOdeNative.NearCallback NearCallback; private readonly Dictionary _prims = new Dictionary(); private readonly HashSet _characters = new HashSet(); @@ -244,12 +244,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde private int contactsPerCollision = 80; internal IntPtr ContactgeomsArray = IntPtr.Zero; - internal SafeNativeMethods.ContactGeom[] m_contacts; + internal UBOdeNative.ContactGeom[] m_contacts; internal GCHandle m_contactsHandler; private IntPtr GlobalContactsArray; - private SafeNativeMethods.Contact contactSharedForJoints = new SafeNativeMethods.Contact(); + private UBOdeNative.Contact contactSharedForJoints = new UBOdeNative.Contact(); const int maxContactJoints = 6000; private volatile int ContactJointCount = 0; @@ -341,7 +341,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// private void Initialization() { - SafeNativeMethods.AllocateODEDataForThread(~0U); + UBOdeNative.AllocateODEDataForThread(~0U); NearCallback = DefaultNearCallback; @@ -357,12 +357,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde // Create the world and the first space try { - world = SafeNativeMethods.WorldCreate(); - TopSpace = SafeNativeMethods.SimpleSpaceCreate(IntPtr.Zero); - ActiveSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace); + world = UBOdeNative.WorldCreate(); + TopSpace = UBOdeNative.SimpleSpaceCreate(IntPtr.Zero); + ActiveSpace = UBOdeNative.SimpleSpaceCreate(TopSpace); float sx = m_regionWidth + 16; float sy = m_regionHeight + 16; - SafeNativeMethods.Vector3 px = new SafeNativeMethods.Vector3(sx * 0.5f, sy * 0.5f, 0); + UBOdeNative.Vector3 px = new UBOdeNative.Vector3(sx * 0.5f, sy * 0.5f, 0); if (sx < sy) sx = sy; int dp = Util.intLog2((uint)sx); @@ -370,42 +370,42 @@ namespace OpenSim.Region.PhysicsModule.ubOde dp = 8; else if(dp < 4) dp = 4; - StaticSpace = SafeNativeMethods.QuadTreeSpaceCreate(TopSpace, ref px, ref px, dp); + StaticSpace = UBOdeNative.QuadTreeSpaceCreate(TopSpace, ref px, ref px, dp); } catch { } // move to high level - SafeNativeMethods.SpaceSetSublevel(ActiveSpace, 1); - SafeNativeMethods.SpaceSetSublevel(StaticSpace, 1); + UBOdeNative.SpaceSetSublevel(ActiveSpace, 1); + UBOdeNative.SpaceSetSublevel(StaticSpace, 1); - SafeNativeMethods.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space | + UBOdeNative.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space | CollisionCategories.Geom | CollisionCategories.Character | CollisionCategories.Phantom | CollisionCategories.VolumeDtc )); - SafeNativeMethods.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space | + UBOdeNative.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space | CollisionCategories.Geom | CollisionCategories.Character | CollisionCategories.Phantom | CollisionCategories.VolumeDtc )); - SafeNativeMethods.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | + UBOdeNative.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | CollisionCategories.Geom | //CollisionCategories.Land | //CollisionCategories.Water | CollisionCategories.Phantom | CollisionCategories.VolumeDtc )); - SafeNativeMethods.GeomSetCollideBits(StaticSpace, 0); + UBOdeNative.GeomSetCollideBits(StaticSpace, 0); - JointContactGroup = SafeNativeMethods.JointGroupCreate(maxContactJoints + 1); + JointContactGroup = UBOdeNative.JointGroupCreate(maxContactJoints + 1); //contactgroup - SafeNativeMethods.WorldSetAutoDisableFlag(world, false); + UBOdeNative.WorldSetAutoDisableFlag(world, false); } @@ -451,30 +451,30 @@ namespace OpenSim.Region.PhysicsModule.ubOde maximumAngularVelocity = 0.49f * heartbeat *(float)Math.PI; maxAngVelocitySQ = maximumAngularVelocity * maximumAngularVelocity; - SafeNativeMethods.WorldSetCFM(world, commonContactCFM); - SafeNativeMethods.WorldSetERP(world, commomContactERP); + UBOdeNative.WorldSetCFM(world, commonContactCFM); + UBOdeNative.WorldSetERP(world, commomContactERP); - SafeNativeMethods.WorldSetGravity(world, gravityx, gravityy, gravityz); + UBOdeNative.WorldSetGravity(world, gravityx, gravityy, gravityz); - SafeNativeMethods.WorldSetLinearDamping(world, 0.001f); - SafeNativeMethods.WorldSetAngularDamping(world, 0.002f); - SafeNativeMethods.WorldSetAngularDampingThreshold(world, 0f); - SafeNativeMethods.WorldSetLinearDampingThreshold(world, 0f); - SafeNativeMethods.WorldSetMaxAngularSpeed(world, maximumAngularVelocity); + UBOdeNative.WorldSetLinearDamping(world, 0.001f); + UBOdeNative.WorldSetAngularDamping(world, 0.002f); + UBOdeNative.WorldSetAngularDampingThreshold(world, 0f); + UBOdeNative.WorldSetLinearDampingThreshold(world, 0f); + UBOdeNative.WorldSetMaxAngularSpeed(world, maximumAngularVelocity); - SafeNativeMethods.WorldSetQuickStepNumIterations(world, m_physicsiterations); + UBOdeNative.WorldSetQuickStepNumIterations(world, m_physicsiterations); - SafeNativeMethods.WorldSetContactSurfaceLayer(world, contactsurfacelayer); - SafeNativeMethods.WorldSetContactMaxCorrectingVel(world, 60.0f); + UBOdeNative.WorldSetContactSurfaceLayer(world, contactsurfacelayer); + UBOdeNative.WorldSetContactMaxCorrectingVel(world, 60.0f); HalfOdeStep = ODE_STEPSIZE * 0.5f; odetimestepMS = (int)(1000.0f * ODE_STEPSIZE + 0.5f); - m_contacts = new SafeNativeMethods.ContactGeom[contactsPerCollision]; + m_contacts = new UBOdeNative.ContactGeom[contactsPerCollision]; m_contactsHandler = GCHandle.Alloc(m_contacts, GCHandleType.Pinned); ContactgeomsArray = m_contactsHandler.AddrOfPinnedObject(); - GlobalContactsArray = Marshal.AllocHGlobal((maxContactJoints + 100) * SafeNativeMethods.Contact.unmanagedSizeOf); + GlobalContactsArray = Marshal.AllocHGlobal((maxContactJoints + 100) * UBOdeNative.Contact.unmanagedSizeOf); contactSharedForJoints.geom.g1 = IntPtr.Zero; contactSharedForJoints.geom.g2 = IntPtr.Zero; @@ -536,7 +536,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde #region Collision Detection [MethodImpl(MethodImplOptions.AggressiveInlining)] - private IntPtr CreateContacJoint(ref SafeNativeMethods.ContactGeom contactGeom, bool smooth) + private IntPtr CreateContacJoint(ref UBOdeNative.ContactGeom contactGeom, bool smooth) { if (ContactJointCount >= maxContactJoints) return IntPtr.Zero; @@ -546,12 +546,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde contactSharedForJoints.geom.pos = contactGeom.pos; contactSharedForJoints.geom.normal = contactGeom.normal; - IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(ContactJointCount * SafeNativeMethods.Contact.unmanagedSizeOf)); + IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(ContactJointCount * UBOdeNative.Contact.unmanagedSizeOf)); Marshal.StructureToPtr(contactSharedForJoints, contact, false); - return SafeNativeMethods.JointCreateContactPtr(world, JointContactGroup, contact); + return UBOdeNative.JointCreateContactPtr(world, JointContactGroup, contact); } - SafeNativeMethods.ContactGeom altWorkContact = new SafeNativeMethods.ContactGeom(); + UBOdeNative.ContactGeom altWorkContact = new UBOdeNative.ContactGeom(); /// /// This is our near callback. A geometry is near a body @@ -571,14 +571,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) return; - if (SafeNativeMethods.GeomIsSpace(g1) || SafeNativeMethods.GeomIsSpace(g2)) + if (UBOdeNative.GeomIsSpace(g1) || UBOdeNative.GeomIsSpace(g2)) { // We'll be calling near recursivly if one // of them is a space to find all of the // contact points in the space try { - SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(g1, g2, IntPtr.Zero, NearCallback); } catch (AccessViolationException) { @@ -594,14 +594,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde int count = 0; try { - if (SafeNativeMethods.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || - SafeNativeMethods.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc) + if (UBOdeNative.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || + UBOdeNative.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc) { - int cflags = unchecked((int)(1 | SafeNativeMethods.CONTACTS_UNIMPORTANT)); - count = SafeNativeMethods.CollidePtr(g1, g2, cflags, ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + int cflags = unchecked((int)(1 | UBOdeNative.CONTACTS_UNIMPORTANT)); + count = UBOdeNative.CollidePtr(g1, g2, cflags, ContactgeomsArray, UBOdeNative.ContactGeom.unmanagedSizeOf); } else - count = SafeNativeMethods.CollidePtr(g1, g2, contactsPerCollision, ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = UBOdeNative.CollidePtr(g1, g2, contactsPerCollision, ContactgeomsArray, UBOdeNative.ContactGeom.unmanagedSizeOf); } catch (SEHException) { @@ -700,8 +700,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde //if (relVlenSQ > 0.01f) // mu *= frictionMovementMult; - if (SafeNativeMethods.GeomGetClass(g2) == SafeNativeMethods.GeomClassID.TriMeshClass && - SafeNativeMethods.GeomGetClass(g1) == SafeNativeMethods.GeomClassID.TriMeshClass) + if (UBOdeNative.GeomGetClass(g2) == UBOdeNative.GeomClassID.TriMeshClass && + UBOdeNative.GeomGetClass(g1) == UBOdeNative.GeomClassID.TriMeshClass) smoothMesh = true; break; @@ -715,7 +715,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // mu *= frictionMovementMult; p1.CollidingGround = true; - if (SafeNativeMethods.GeomGetClass(g1) == SafeNativeMethods.GeomClassID.TriMeshClass) + if (UBOdeNative.GeomGetClass(g1) == UBOdeNative.GeomClassID.TriMeshClass) smoothMesh = true; break; @@ -741,7 +741,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //if (Math.Abs(v2.X) > 0.1f || Math.Abs(v2.Y) > 0.1f) // mu *= frictionMovementMult; - if (SafeNativeMethods.GeomGetClass(g2) == SafeNativeMethods.GeomClassID.TriMeshClass) + if (UBOdeNative.GeomGetClass(g2) == UBOdeNative.GeomClassID.TriMeshClass) smoothMesh = true; } else @@ -774,8 +774,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (dop1ava || dop2ava) smoothMesh = false; - IntPtr b1 = SafeNativeMethods.GeomGetBody(g1); - IntPtr b2 = SafeNativeMethods.GeomGetBody(g2); + IntPtr b1 = UBOdeNative.GeomGetBody(g1); + IntPtr b2 = UBOdeNative.GeomGetBody(g2); for (int i = 0; i < count; ++i) { @@ -821,7 +821,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Joint == IntPtr.Zero) break; - SafeNativeMethods.JointAttach(Joint, b1, b2); + UBOdeNative.JointAttach(Joint, b1, b2); ncontacts++; @@ -861,7 +861,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde int count = 0; try { - count = SafeNativeMethods.CollidePtr(p1.collider, p2.collider, contactsPerCollision, ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf); + count = UBOdeNative.CollidePtr(p1.collider, p2.collider, contactsPerCollision, ContactgeomsArray, UBOdeNative.ContactGeom.unmanagedSizeOf); } catch (SEHException) { @@ -914,7 +914,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Joint == IntPtr.Zero) break; - SafeNativeMethods.JointAttach(Joint, p1.Body, p2.Body); + UBOdeNative.JointAttach(Joint, p1.Body, p2.Body); ncontacts++; @@ -1054,8 +1054,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (chr.Body != IntPtr.Zero && chr.collider != IntPtr.Zero) { - SafeNativeMethods.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, NearCallback); - SafeNativeMethods.SpaceCollide2(chr.collider, ActiveSpace, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(chr.collider, ActiveSpace, IntPtr.Zero, NearCallback); } } } @@ -1073,8 +1073,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde chr.CollidingObj = false; // do colisions with static space - SafeNativeMethods.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, NearCallback); - SafeNativeMethods.SpaceCollide2(chr.collider, ActiveSpace, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(chr.collider, ActiveSpace, IntPtr.Zero, NearCallback); float mx = chr._AABB2D.minx; float Mx = chr._AABB2D.maxx; @@ -1131,7 +1131,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { aprim.CollisionScore = 0; aprim.IsColliding = false; - if(!aprim.m_outbounds && SafeNativeMethods.BodyIsEnabled(aprim.Body)) + if(!aprim.m_outbounds && UBOdeNative.BodyIsEnabled(aprim.Body)) aprim.clearSleeperCollisions(); } } @@ -1142,11 +1142,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde { foreach (OdePrim aprim in _activegroups) { - if(!aprim.m_outbounds && SafeNativeMethods.BodyIsEnabled(aprim.Body) && + if(!aprim.m_outbounds && UBOdeNative.BodyIsEnabled(aprim.Body) && aprim.m_collide_geom != IntPtr.Zero) { - SafeNativeMethods.SpaceCollide2(StaticSpace, aprim.m_collide_geom, IntPtr.Zero, NearCallback); - SafeNativeMethods.SpaceCollide2(TerrainGeom, aprim.m_collide_geom, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(StaticSpace, aprim.m_collide_geom, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide2(TerrainGeom, aprim.m_collide_geom, IntPtr.Zero, NearCallback); } } } @@ -1158,7 +1158,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // colide active amoung them try { - SafeNativeMethods.SpaceCollide(ActiveSpace, IntPtr.Zero, NearCallback); + UBOdeNative.SpaceCollide(ActiveSpace, IntPtr.Zero, NearCallback); } catch (Exception e) { @@ -1439,16 +1439,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde return StaticSpace; // else remove it from its current space - if (currentspace != IntPtr.Zero && SafeNativeMethods.SpaceQuery(currentspace, geom)) + if (currentspace != IntPtr.Zero && UBOdeNative.SpaceQuery(currentspace, geom)) { - if (SafeNativeMethods.GeomIsSpace(currentspace)) + if (UBOdeNative.GeomIsSpace(currentspace)) { //waitForSpaceUnlock(currentspace); - SafeNativeMethods.SpaceRemove(currentspace, geom); + UBOdeNative.SpaceRemove(currentspace, geom); - if (SafeNativeMethods.SpaceGetSublevel(currentspace) == 0 && SafeNativeMethods.SpaceGetNumGeoms(currentspace) == 0) + if (UBOdeNative.SpaceGetSublevel(currentspace) == 0 && UBOdeNative.SpaceGetNumGeoms(currentspace) == 0) { - SafeNativeMethods.SpaceDestroy(currentspace); + UBOdeNative.SpaceDestroy(currentspace); } } else @@ -1459,17 +1459,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else { - currentspace = SafeNativeMethods.GeomGetSpace(geom); + currentspace = UBOdeNative.GeomGetSpace(geom); if (currentspace != IntPtr.Zero) { - if (SafeNativeMethods.GeomIsSpace(currentspace)) + if (UBOdeNative.GeomIsSpace(currentspace)) { //waitForSpaceUnlock(currentspace); - SafeNativeMethods.SpaceRemove(currentspace, geom); + UBOdeNative.SpaceRemove(currentspace, geom); - if (SafeNativeMethods.SpaceGetSublevel(currentspace) == 0 && SafeNativeMethods.SpaceGetNumGeoms(currentspace) == 0) + if (UBOdeNative.SpaceGetSublevel(currentspace) == 0 && UBOdeNative.SpaceGetNumGeoms(currentspace) == 0) { - SafeNativeMethods.SpaceDestroy(currentspace); + UBOdeNative.SpaceDestroy(currentspace); } } } @@ -1477,10 +1477,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde // put the geom in the newspace //waitForSpaceUnlock(StaticSpace); - if(SafeNativeMethods.SpaceQuery(StaticSpace, geom)) + if(UBOdeNative.SpaceQuery(StaticSpace, geom)) m_log.Info("[Physics]: 'MoveGeomToStaticSpace' geom already in static space:" + geom); else - SafeNativeMethods.SpaceAdd(StaticSpace, geom); + UBOdeNative.SpaceAdd(StaticSpace, geom); return StaticSpace; } @@ -1529,7 +1529,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_log.InfoFormat("[ubOde] start processing pending actor operations"); int tstart = Util.EnvironmentTickCount(); - SafeNativeMethods.AllocateODEDataForThread(~0U); + UBOdeNative.AllocateODEDataForThread(~0U); while (ChangesQueue.TryDequeue(out ODEchangeitem item)) { @@ -1615,7 +1615,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //double rayTime = 0; - SafeNativeMethods.AllocateODEDataForThread(~0U); + UBOdeNative.AllocateODEDataForThread(~0U); while (ChangesQueue.TryDequeue(out ODEchangeitem item)) { @@ -1709,7 +1709,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if(pobj.Body != IntPtr.Zero && !pobj.m_isSelected && !pobj.m_disabled && !pobj.m_building && - !SafeNativeMethods.BodyIsEnabled(pobj.Body)) + !UBOdeNative.BodyIsEnabled(pobj.Body)) sleepers.Add(pobj); } } @@ -1727,8 +1727,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde // do a ode simulation step lock (SimulationLock) { - SafeNativeMethods.WorldQuickStep(world, ODE_STEPSIZE); - SafeNativeMethods.JointGroupEmpty(JointContactGroup); + UBOdeNative.WorldQuickStep(world, ODE_STEPSIZE); + UBOdeNative.JointGroupEmpty(JointContactGroup); } //qstepTIme += Util.GetTimeStampMS() - tmpTime; @@ -2042,12 +2042,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde lock(SimulationLock) lock (OdeLock) { - SafeNativeMethods.AllocateODEDataForThread(~0U); + UBOdeNative.AllocateODEDataForThread(~0U); if (TerrainGeom != IntPtr.Zero) { actor_name_map.Remove(TerrainGeom); - SafeNativeMethods.GeomDestroy(TerrainGeom); + UBOdeNative.GeomDestroy(TerrainGeom); } if (m_terrainHeightsHandler.IsAllocated) @@ -2063,16 +2063,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_lastRegionWidth = m_regionWidth; m_lastRegionHeight = m_regionHeight; - HeightmapData = SafeNativeMethods.GeomOSTerrainDataCreate(); - SafeNativeMethods.GeomOSTerrainDataBuild(HeightmapData, m_terrainHeightsHandler.AddrOfPinnedObject(), 0, 1.0f, + HeightmapData = UBOdeNative.GeomOSTerrainDataCreate(); + UBOdeNative.GeomOSTerrainDataBuild(HeightmapData, m_terrainHeightsHandler.AddrOfPinnedObject(), 0, 1.0f, m_heightmapWidthSamples, m_heightmapHeightSamples, 1, 0); - TerrainGeom = SafeNativeMethods.CreateOSTerrain(TopSpace, HeightmapData, 1); + TerrainGeom = UBOdeNative.CreateOSTerrain(TopSpace, HeightmapData, 1); if (TerrainGeom != IntPtr.Zero) { - SafeNativeMethods.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land)); - SafeNativeMethods.GeomSetCollideBits(TerrainGeom, 0); + UBOdeNative.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land)); + UBOdeNative.GeomSetCollideBits(TerrainGeom, 0); PhysicsActor pa = new NullPhysicsActor(); pa.Name = "Terrain"; @@ -2081,7 +2081,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde //geom_name_map[GroundGeom] = "Terrain"; - SafeNativeMethods.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f); + UBOdeNative.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f); } else m_terrainHeightsHandler.Free(); @@ -2147,8 +2147,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde lock(SimulationLock) lock (OdeLock) { - SafeNativeMethods.GeomOSTerrainDataSetBounds(HeightmapData, minH, maxH); - SafeNativeMethods.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f); + UBOdeNative.GeomOSTerrainDataSetBounds(HeightmapData, minH, maxH); + UBOdeNative.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f); } } @@ -2169,7 +2169,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (world == IntPtr.Zero) return; - SafeNativeMethods.AllocateODEDataForThread(~0U); + UBOdeNative.AllocateODEDataForThread(~0U); if (m_meshWorker != null) m_meshWorker.Stop(); @@ -2202,7 +2202,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (TerrainGeom != IntPtr.Zero) { - SafeNativeMethods.GeomDestroy(TerrainGeom); + UBOdeNative.GeomDestroy(TerrainGeom); TerrainGeom = IntPtr.Zero; } @@ -2222,7 +2222,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde GlobalContactsArray = IntPtr.Zero; } - SafeNativeMethods.WorldDestroy(world); + UBOdeNative.WorldDestroy(world); world = IntPtr.Zero; //d.CloseODE(); } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODESitAvatar.cs b/OpenSim/Region/PhysicsModules/ubOde/ODESitAvatar.cs index 374b74ddd3..2eadc7a29a 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODESitAvatar.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODESitAvatar.cs @@ -72,8 +72,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde IntPtr geom = ((OdePrim)actor).m_prim_geom; - Vector3 geopos = SafeNativeMethods.GeomGetPositionOMV(geom); - Quaternion geomOri = SafeNativeMethods.GeomGetQuaternionOMV(geom); + Vector3 geopos = UBOdeNative.GeomGetPositionOMV(geom); + Quaternion geomOri = UBOdeNative.GeomGetQuaternionOMV(geom); //Vector3 geopos = actor.Position; //Quaternion geomOri = actor.Orientation; @@ -116,11 +116,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde offset = rayResults[0].Pos - geopos; - SafeNativeMethods.GeomClassID geoclass = SafeNativeMethods.GeomGetClass(geom); + UBOdeNative.GeomClassID geoclass = UBOdeNative.GeomGetClass(geom); - if (geoclass == SafeNativeMethods.GeomClassID.SphereClass) + if (geoclass == UBOdeNative.GeomClassID.SphereClass) { - float r = SafeNativeMethods.GeomSphereGetRadius(geom); + float r = UBOdeNative.GeomSphereGetRadius(geom); offset.Normalize(); offset *= r;