From d199767e6991d6f368661fce9c5a072e564b8a4b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 23:16:12 -0700 Subject: Experimental change of PhysicsVector to Vector3. Untested --- .../BulletDotNETPlugin/BulletDotNETCharacter.cs | 96 ++++---- .../Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | 257 ++++++++++----------- .../BulletDotNETPlugin/BulletDotNETScene.cs | 12 +- 3 files changed, 178 insertions(+), 187 deletions(-) (limited to 'OpenSim/Region/Physics/BulletDotNETPlugin') diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs index 8da9687..5ed3b14 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs @@ -60,15 +60,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin private btQuaternion m_bodyOrientation; private btDefaultMotionState m_bodyMotionState; private btGeneric6DofConstraint m_aMotor; - // private PhysicsVector m_movementComparision; - private PhysicsVector m_position; - private PhysicsVector m_zeroPosition; + // private Vector3 m_movementComparision; + private Vector3 m_position; + private Vector3 m_zeroPosition; private bool m_zeroFlag = false; private bool m_lastUpdateSent = false; - private PhysicsVector m_velocity; - private PhysicsVector m_target_velocity; - private PhysicsVector m_acceleration; - private PhysicsVector m_rotationalVelocity; + private Vector3 m_velocity; + private Vector3 m_target_velocity; + private Vector3 m_acceleration; + private Vector3 m_rotationalVelocity; private bool m_pidControllerActive = true; public float PID_D = 80.0f; public float PID_P = 90.0f; @@ -96,8 +96,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. private bool m_taintRemove = false; // private bool m_taintedPosition = false; - // private PhysicsVector m_taintedPosition_value; - private PhysicsVector m_taintedForce; + // private Vector3 m_taintedPosition_value; + private Vector3 m_taintedForce; private float m_buoyancy = 0f; @@ -115,14 +115,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin public int m_eventsubscription = 0; // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); - public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) + public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) { - m_taintedForce = new PhysicsVector(); - m_velocity = new PhysicsVector(); - m_target_velocity = new PhysicsVector(); m_position = pos; - m_zeroPosition = new PhysicsVector(pos.X, pos.Y, pos.Z); // this is a class, not a struct. Must make new, or m_zeroPosition will == position regardless - m_acceleration = new PhysicsVector(); + m_zeroPosition = pos; m_parent_scene = parent_scene; PID_D = pid_d; PID_P = pid_p; @@ -161,9 +157,6 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempTrans1 = new btTransform(tempQuat1, tempVector1); // m_movementComparision = new PhysicsVector(0, 0, 0); m_CapsuleOrientationAxis = new btVector3(1, 0, 1); - - - } /// @@ -254,18 +247,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin get { return m_zeroFlag; } } - public override PhysicsVector Size + public override Vector3 Size { - get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } + get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } set { m_pidControllerActive = true; - - PhysicsVector SetSize = value; + + Vector3 SetSize = value; m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); - Velocity = new PhysicsVector(0f, 0f, 0f); + Velocity = Vector3.Zero; m_parent_scene.AddPhysicsActorTaint(this); } @@ -317,12 +310,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } - public override void LockAngularMotion(PhysicsVector axis) + public override void LockAngularMotion(Vector3 axis) { } - public override PhysicsVector Position + public override Vector3 Position { get { return m_position; } set @@ -342,9 +335,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - public override PhysicsVector Force + public override Vector3 Force { - get { return new PhysicsVector(m_target_velocity.X, m_target_velocity.Y, m_target_velocity.Z); } + get { return m_target_velocity; } set { return; } } @@ -359,7 +352,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } - public override void VehicleVectorParam(int param, PhysicsVector value) + public override void VehicleVectorParam(int param, Vector3 value) { } @@ -374,23 +367,22 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } - public override PhysicsVector GeometricCenter + public override Vector3 GeometricCenter { - get { return PhysicsVector.Zero; } + get { return Vector3.Zero; } } - public override PhysicsVector CenterOfMass + public override Vector3 CenterOfMass { - get { return PhysicsVector.Zero; } + get { return Vector3.Zero; } } - public override PhysicsVector Velocity + public override Vector3 Velocity { get { - // There's a problem with PhysicsVector.Zero! Don't Use it Here! if (m_zeroFlag) - return new PhysicsVector(0f, 0f, 0f); + return Vector3.Zero; m_lastUpdateSent = false; return m_velocity; } @@ -401,9 +393,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - public override PhysicsVector Torque + public override Vector3 Torque { - get { return PhysicsVector.Zero; } + get { return Vector3.Zero; } set { return; } } @@ -413,7 +405,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin set { } } - public override PhysicsVector Acceleration + public override Vector3 Acceleration { get { return m_acceleration; } } @@ -586,7 +578,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin set { return; } } - public override PhysicsVector RotationalVelocity + public override Vector3 RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } @@ -604,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin set { m_buoyancy = value; } } - public override PhysicsVector PIDTarget { set { return; } } + public override Vector3 PIDTarget { set { return; } } public override bool PIDActive { set { return; } } public override float PIDTau { set { return; } } @@ -634,7 +626,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin /// /// /// Is this a push by a script? - public override void AddForce(PhysicsVector force, bool pushforce) + public override void AddForce(Vector3 force, bool pushforce) { if (pushforce) { @@ -656,7 +648,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //m_lastUpdateSent = false; } - public void doForce(PhysicsVector force, bool now) + public void doForce(Vector3 force, bool now) { tempVector3.setValue(force.X, force.Y, force.Z); @@ -671,7 +663,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - public void doImpulse(PhysicsVector force, bool now) + public void doImpulse(Vector3 force, bool now) { tempVector3.setValue(force.X, force.Y, force.Z); @@ -686,12 +678,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - public override void AddAngularForce(PhysicsVector force, bool pushforce) + public override void AddAngularForce(Vector3 force, bool pushforce) { } - public override void SetMomentum(PhysicsVector momentum) + public override void SetMomentum(Vector3 momentum) { } @@ -808,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin AvatarGeomAndBodyCreation(m_position.X, m_position.Y, m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); - Velocity = new PhysicsVector(0f, 0f, 0f); + Velocity = Vector3.Zero; } else @@ -852,9 +844,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } //PidStatus = true; - PhysicsVector vec = new PhysicsVector(); + Vector3 vec = Vector3.Zero; - PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); + Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); float movementdivisor = 1f; @@ -885,7 +877,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin // Avatar to Avatar collisions // Prim to avatar collisions - PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); + Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); if (m_flying) @@ -927,7 +919,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { // We're colliding with something and we're not flying but we're moving // This means we're walking or running. - PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); + Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; if (m_target_velocity.X > 0) { @@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempVector2 = Body.getInterpolationLinearVelocity(); // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); + Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) if (vec.X < -10.0f) vec.X = 0.0f; @@ -1048,7 +1040,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin else { m_lastUpdateSent = false; - vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); + vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); m_velocity.X = (vec.X); m_velocity.Y = (vec.Y); diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs index f22ea71..5b542db 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs @@ -43,44 +43,43 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private PhysicsVector _position; - private PhysicsVector m_zeroPosition; - private PhysicsVector _velocity; - private PhysicsVector _torque = new PhysicsVector(0, 0, 0); - private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); - private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); - private Quaternion m_lastorientation = new Quaternion(); - private PhysicsVector m_rotationalVelocity; - private PhysicsVector _size; - private PhysicsVector _acceleration; + private Vector3 _position; + private Vector3 m_zeroPosition; + private Vector3 _velocity; + private Vector3 _torque; + private Vector3 m_lastVelocity; + private Vector3 m_lastposition; + private Quaternion m_lastorientation = Quaternion.Identity; + private Vector3 m_rotationalVelocity; + private Vector3 _size; + private Vector3 _acceleration; // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); private Quaternion _orientation; - private PhysicsVector m_taintposition; - private PhysicsVector m_taintsize; - private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); - private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); + private Vector3 m_taintposition; + private Vector3 m_taintsize; + private Vector3 m_taintVelocity; + private Vector3 m_taintTorque; private Quaternion m_taintrot; - private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); - private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); + private Vector3 m_angularlock = Vector3.One; + private Vector3 m_taintAngularLock = Vector3.One; // private btGeneric6DofConstraint Amotor; - private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); - private float m_PIDTau = 0f; - private float m_PIDHoverHeight = 0f; - private float m_PIDHoverTau = 0f; - private bool m_useHoverPID = false; + private Vector3 m_PIDTarget; + private float m_PIDTau; + private float m_PIDHoverHeight; + private float m_PIDHoverTau; + private bool m_useHoverPID; private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; - private float m_targetHoverHeight = 0f; - private float m_groundHeight = 0f; - private float m_waterHeight = 0f; + private float m_targetHoverHeight; + private float m_groundHeight; + private float m_waterHeight; private float PID_D = 35f; private float PID_G = 25f; // private float m_tensor = 5f; // private int body_autodisable_frames = 20; - private IMesh primMesh = null; - - private bool m_usePID = false; + private IMesh primMesh; + private bool m_usePID; private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom | CollisionCategories.Space @@ -88,11 +87,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin | CollisionCategories.Character ); - private bool m_taintshape = false; - private bool m_taintPhysics = false; + private bool m_taintshape; + private bool m_taintPhysics; // private bool m_collidesLand = true; - private bool m_collidesWater = false; - public bool m_returnCollisions = false; + private bool m_collidesWater; + public bool m_returnCollisions; // Default we're a Geometry // private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); @@ -100,23 +99,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin // Default, Collide with Other Geometries, spaces and Bodies // private CollisionCategories m_collisionFlags = m_default_collisionFlags; - public bool m_taintremove = false; - public bool m_taintdisable = false; - public bool m_disabled = false; - public bool m_taintadd = false; - public bool m_taintselected = false; - public bool m_taintCollidesWater = false; + public bool m_taintremove; + public bool m_taintdisable; + public bool m_disabled; + public bool m_taintadd; + public bool m_taintselected; + public bool m_taintCollidesWater; - public uint m_localID = 0; + public uint m_localID; //public GCHandle gc; // private CollisionLocker ode; - private bool m_taintforce = false; - private bool m_taintaddangularforce = false; - private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); - private List m_forcelist = new List(); - private List m_angularforcelist = new List(); + private bool m_taintforce; + private bool m_taintaddangularforce; + private Vector3 m_force; + private List m_forcelist = new List(); + private List m_angularforcelist = new List(); private IMesh _mesh; private PrimitiveBaseShape _pbs; @@ -124,40 +123,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin public btCollisionShape prim_geom; public IntPtr _triMeshData; - private PhysicsActor _parent = null; - private PhysicsActor m_taintparent = null; + private PhysicsActor _parent; + private PhysicsActor m_taintparent; private List childrenPrim = new List(); - private bool iscolliding = false; - private bool m_isphysical = false; - private bool m_isSelected = false; + private bool iscolliding; + private bool m_isphysical; + private bool m_isSelected; - internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively + internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively - private bool m_throttleUpdates = false; - // private int throttleCounter = 0; - public int m_interpenetrationcount = 0; - public float m_collisionscore = 0; - public int m_roundsUnderMotionThreshold = 0; - private int m_crossingfailures = 0; + private bool m_throttleUpdates; + // private int throttleCounter; + public int m_interpenetrationcount; + public float m_collisionscore; + public int m_roundsUnderMotionThreshold; + private int m_crossingfailures; - public float m_buoyancy = 0f; + public float m_buoyancy; - public bool outofBounds = false; + public bool outofBounds; private float m_density = 10.000006836f; // Aluminum g/cm3; - public bool _zeroFlag = false; - private bool m_lastUpdateSent = false; + public bool _zeroFlag; + private bool m_lastUpdateSent; private String m_primName; - private PhysicsVector _target_velocity; + private Vector3 _target_velocity; - public int m_eventsubscription = 0; + public int m_eventsubscription; // private CollisionEventUpdate CollisionEventsThisFrame = null; - public volatile bool childPrim = false; + public volatile bool childPrim; private btVector3 tempPosition1; private btVector3 tempPosition2; @@ -190,7 +189,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin public btRigidBody Body; - public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, + public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical) { tempPosition1 = new btVector3(0, 0, 0); @@ -225,8 +224,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize); - _target_velocity = new PhysicsVector(0, 0, 0); - _velocity = new PhysicsVector(); + _target_velocity = Vector3.Zero; + _velocity = Vector3.Zero; _position = pos; m_taintposition = pos; PID_D = parent_scene.bodyPIDD; @@ -244,8 +243,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin _size = size; m_taintsize = _size; - _acceleration = new PhysicsVector(); - m_rotationalVelocity = PhysicsVector.Zero; + _acceleration = Vector3.Zero; + m_rotationalVelocity = Vector3.Zero; _orientation = rotation; m_taintrot = _orientation; _mesh = mesh; @@ -274,7 +273,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin get { return _zeroFlag; } } - public override PhysicsVector Size + public override Vector3 Size { get { return _size; } set { _size = value; } @@ -348,13 +347,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin m_taintparent = null; } - public override void LockAngularMotion(PhysicsVector axis) + public override void LockAngularMotion(Vector3 axis) { m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); - m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); + m_taintAngularLock = axis; } - public override PhysicsVector Position + public override Vector3 Position { get { return _position; } @@ -370,9 +369,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin get { return CalculateMass(); } } - public override PhysicsVector Force + public override Vector3 Force { - //get { return PhysicsVector.Zero; } + //get { return Vector3.Zero; } get { return m_force; } set { m_force = value; } } @@ -388,7 +387,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //TODO: } - public override void VehicleVectorParam(int param, PhysicsVector value) + public override void VehicleVectorParam(int param, Vector3 value) { //TODO: } @@ -405,23 +404,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } - public override PhysicsVector GeometricCenter + public override Vector3 GeometricCenter { - get { return PhysicsVector.Zero; } + get { return Vector3.Zero; } } - public override PhysicsVector CenterOfMass + public override Vector3 CenterOfMass { - get { return PhysicsVector.Zero; } + get { return Vector3.Zero; } } - public override PhysicsVector Velocity + public override Vector3 Velocity { get { // Averate previous velocity with the new one so // client object interpolation works a 'little' better - PhysicsVector returnVelocity = new PhysicsVector(); + Vector3 returnVelocity; returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; @@ -436,12 +435,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - public override PhysicsVector Torque + public override Vector3 Torque { get { if (!m_isphysical || Body.Handle == IntPtr.Zero) - return new PhysicsVector(0, 0, 0); + return Vector3.Zero; return _torque; } @@ -459,7 +458,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin set { m_collisionscore = value; } } - public override PhysicsVector Acceleration + public override Vector3 Acceleration { get { return _acceleration; } } @@ -528,16 +527,16 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - public override PhysicsVector RotationalVelocity + public override Vector3 RotationalVelocity { get { - PhysicsVector pv = new PhysicsVector(0, 0, 0); + Vector3 pv = Vector3.Zero; if (_zeroFlag) return pv; m_lastUpdateSent = false; - if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) + if (m_rotationalVelocity.ApproxEquals(pv, 0.2f)) return pv; return m_rotationalVelocity; @@ -557,7 +556,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin set { m_buoyancy = value; } } - public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } } + public override Vector3 PIDTarget { set { m_PIDTarget = value; ; } } public override bool PIDActive { set { m_usePID = value; } } public override float PIDTau { set { m_PIDTau = value; } } @@ -567,20 +566,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin public override float PIDHoverTau { set { m_PIDHoverTau = value; } } - public override void AddForce(PhysicsVector force, bool pushforce) + public override void AddForce(Vector3 force, bool pushforce) { m_forcelist.Add(force); m_taintforce = true; //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); } - public override void AddAngularForce(PhysicsVector force, bool pushforce) + public override void AddAngularForce(Vector3 force, bool pushforce) { m_angularforcelist.Add(force); m_taintaddangularforce = true; } - public override void SetMomentum(PhysicsVector momentum) + public override void SetMomentum(Vector3 momentum) { } @@ -778,7 +777,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } - if (!_position.IsIdentical(m_taintposition, 0f)) + if (!_position.ApproxEquals(m_taintposition, 0f)) { m_log.Debug("[PHYSICS]: TaintMove"); changemove(timestep); @@ -796,7 +795,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } // - if (!_size.IsIdentical(m_taintsize, 0)) + if (!_size.ApproxEquals(m_taintsize, 0f)) { m_log.Debug("[PHYSICS]: TaintSize"); changesize(timestep); @@ -820,7 +819,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin m_log.Debug("[PHYSICS]: TaintAngularForce"); changeAddAngularForce(timestep); } - if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) + if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f)) { m_log.Debug("[PHYSICS]: TaintTorque"); changeSetTorque(timestep); @@ -835,7 +834,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin m_log.Debug("[PHYSICS]: TaintSelected"); changeSelectedStatus(timestep); } - if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) + if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) { m_log.Debug("[PHYSICS]: TaintVelocity"); changevelocity(timestep); @@ -849,7 +848,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { changefloatonwater(timestep); } - if (!m_angularlock.IsIdentical(m_taintAngularLock, 0)) + if (!m_angularlock.ApproxEquals(m_taintAngularLock, 0)) { m_log.Debug("[PHYSICS]: TaintAngularLock"); changeAngularLock(timestep); @@ -1012,7 +1011,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (_parent_scene.needsMeshing(_pbs)) { - ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); + ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity); // createmesh returns null when it doesn't mesh. CreateGeom(IntPtr.Zero, _mesh); } @@ -1029,7 +1028,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin return _parent_scene.needsMeshing(_pbs); } - internal void ProcessGeomCreationAsTriMesh(PhysicsVector positionOffset, Quaternion orientation) + internal void ProcessGeomCreationAsTriMesh(Vector3 positionOffset, Quaternion orientation) { // Don't need to re-enable body.. it's done in SetMesh float meshlod = _parent_scene.meshSculptLOD; @@ -1038,7 +1037,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin meshlod = _parent_scene.MeshSculptphysicalLOD; IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); - if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) + if (!positionOffset.ApproxEquals(Vector3.Zero, 0.001f) || orientation != Quaternion.Identity) { float[] xyz = new float[3]; @@ -1202,7 +1201,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //m_log.Info("[PHYSICS]: dequeing forcelist"); if (IsPhysical) { - PhysicsVector iforce = new PhysicsVector(); + Vector3 iforce = Vector3.Zero; for (int i = 0; i < m_forcelist.Count; i++) { iforce = iforce + m_forcelist[i]; @@ -1237,7 +1236,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //m_log.Info("[PHYSICS]: dequeing forcelist"); if (IsPhysical) { - PhysicsVector iforce = new PhysicsVector(); + Vector3 iforce = Vector3.Zero; for (int i = 0; i < m_angularforcelist.Count; i++) { iforce = iforce + m_angularforcelist[i]; @@ -1276,7 +1275,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } } - m_taintTorque = new PhysicsVector(0, 0, 0); + m_taintTorque = Vector3.Zero; } private void changedisable(float timestep) @@ -1317,7 +1316,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //resetCollisionAccounting(); } - m_taintVelocity = PhysicsVector.Zero; + m_taintVelocity = Vector3.Zero; } private void changelink(float timestep) @@ -1361,7 +1360,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin if (m_taintparent != null) { - m_taintparent.Position.Z = m_taintparent.Position.Z + 0.02f; + Vector3 taintparentPosition = m_taintparent.Position; + taintparentPosition.Z = m_taintparent.Position.Z + 0.02f; + m_taintparent.Position = taintparentPosition; _parent_scene.AddPhysicsActorTaint(m_taintparent); } } @@ -1382,7 +1383,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (_parent == null) { - if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0)) + if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f)) { //d.BodySetFiniteRotationMode(Body, 0); //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); @@ -1395,7 +1396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); + m_angularlock = m_taintAngularLock; } #endregion @@ -1460,17 +1461,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin // TODO: NEED btVector3 for Linear Velocity // NEED btVector3 for Position - PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet - PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z); + Vector3 pos = _position; //TODO: Insert values gotten from bullet + Vector3 vel = _velocity; _target_velocity = - new PhysicsVector( + new Vector3( (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) ); - if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) + if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f)) { /* TODO: Do Bullet equiv @@ -1512,8 +1513,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { PID_G = m_PIDTau + 1; } - PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet - PhysicsVector vel = new PhysicsVector(0, 0, 0); + Vector3 pos = Vector3.Zero; //TODO: Insert values gotten from bullet + Vector3 vel = Vector3.Zero; // determine what our target height really is based on HoverType switch (m_PIDHoverType) @@ -1545,13 +1546,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin _target_velocity = - new PhysicsVector(0.0f, 0.0f, + new Vector3(0.0f, 0.0f, (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) ); // if velocity is zero, use position control; otherwise, velocity control - if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) + if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f)) { /* TODO: Do Bullet Equiv @@ -1626,8 +1627,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin else { if (m_zeroPosition == null) - m_zeroPosition = new PhysicsVector(0, 0, 0); - m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); + m_zeroPosition = Vector3.Zero; + m_zeroPosition = _position; return; } } @@ -2177,7 +2178,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //if (hasTrimesh) //{ - ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); + ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity); // createmesh returns null when it doesn't mesh. /* @@ -2197,11 +2198,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (chld == null) continue; - PhysicsVector offset = chld.Position - Position; + Vector3 offset = chld.Position - Position; Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); pos *= Quaternion.Inverse(Orientation); //pos *= Orientation; - offset.setValues(pos.X, pos.Y, pos.Z); + offset = pos; chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); _mesh.Append(chld._mesh); @@ -2433,7 +2434,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin m_collisionscore = 0; m_disabled = false; // The body doesn't already have a finite rotation mode set here - if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) + if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) { // TODO: Create Angular Motor on Axis Lock! } @@ -2447,7 +2448,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (_parent == null) { - PhysicsVector pv = new PhysicsVector(0, 0, 0); + Vector3 pv = Vector3.Zero; bool lastZeroFlag = _zeroFlag; if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero) tempPosition3.Dispose(); @@ -2471,10 +2472,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel - _torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), + _torque = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), tempAngularVelocity1.getZ()); - PhysicsVector l_position = new PhysicsVector(); - Quaternion l_orientation = new Quaternion(); + Vector3 l_position = Vector3.Zero; + Quaternion l_orientation = Quaternion.Identity; m_lastposition = _position; m_lastorientation = _orientation; @@ -2598,20 +2599,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin _velocity.Z = tempLinearVelocity1.getZ(); _acceleration = ((_velocity - m_lastVelocity) / 0.1f); - _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, + _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); - if (_velocity.IsIdentical(pv, 0.5f)) + if (_velocity.ApproxEquals(pv, 0.5f)) { m_rotationalVelocity = pv; } else { - - m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), - tempAngularVelocity1.getZ()); + m_rotationalVelocity = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ()); } //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); @@ -2665,7 +2664,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin m_taintremove = true; } - internal void EnableAxisMotor(PhysicsVector axislock) + internal void EnableAxisMotor(Vector3 axislock) { if (m_aMotor != null) DisableAxisMotor(); diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs index 18d4bab..9e048ab 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs @@ -139,7 +139,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } - public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) + public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) { BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, @@ -177,14 +177,14 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, + private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) { - PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); + Vector3 pos = position; //pos.X = position.X; //pos.Y = position.Y; //pos.Z = position.Z; - PhysicsVector siz = new PhysicsVector(); + Vector3 siz = Vector3.Zero; siz.X = size.X; siz.Y = size.Y; siz.Z = size.Z; @@ -201,12 +201,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin return newPrim; } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation) { return AddPrimShape(primName, pbs, position, size, rotation, false); } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical) { PhysicsActor result; IMesh mesh = null; -- cgit v1.1