From 65c5efe43b68700bad94076d4cd421160203c5de Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Fri, 16 May 2008 01:22:11 +0000
Subject: Formatting cleanup.
---
OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 62 +++----
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 226 +++++++++++------------
OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 208 +++++++--------------
3 files changed, 212 insertions(+), 284 deletions(-)
(limited to 'OpenSim/Region/Physics/OdePlugin')
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 4165484..5024b5d 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.Physics.OdePlugin
///
/// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
///
-
+
public enum dParam : int
{
LowStop = 0,
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private CollisionCategories m_collisionFlags = (CollisionCategories.Geom
| CollisionCategories.Space
| CollisionCategories.Body
- | CollisionCategories.Character
+ | CollisionCategories.Character
| CollisionCategories.Land);
public IntPtr Body;
private OdeScene _parent_scene;
@@ -145,7 +145,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_colliderarr[i] = false;
}
- CAPSULE_LENGTH = (size.Z - ((size.Z * height_fudge_factor)));
+ CAPSULE_LENGTH = (size.Z - ((size.Z * height_fudge_factor)));
lock (OdeScene.OdeLock)
{
@@ -338,7 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
///
- /// turn the PID controller on or off.
+ /// turn the PID controller on or off.
/// The PID Controller will turn on all by itself in many situations
///
///
@@ -354,7 +354,7 @@ namespace OpenSim.Region.Physics.OdePlugin
///
/// This 'puts' an avatar somewhere in the physics space.
- /// Not really a good choice unless you 'know' it's a good
+ /// Not really a good choice unless you 'know' it's a good
/// spot otherwise you're likely to orbit the avatar.
///
public override PhysicsVector Position
@@ -389,7 +389,7 @@ namespace OpenSim.Region.Physics.OdePlugin
lock (OdeScene.OdeLock)
{
d.JointDestroy(Amotor);
-
+
PhysicsVector SetSize = value;
float prevCapsule = CAPSULE_LENGTH;
float capsuleradius = CAPSULE_RADIUS;
@@ -405,7 +405,7 @@ namespace OpenSim.Region.Physics.OdePlugin
AvatarGeomAndBodyCreation(_position.X, _position.Y,
_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
Velocity = new PhysicsVector(0f, 0f, 0f);
-
+
}
_parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor) this;
@@ -423,7 +423,7 @@ namespace OpenSim.Region.Physics.OdePlugin
int dAMotorEuler = 1;
_parent_scene.waitForSpaceUnlock(_parent_scene.space);
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
-
+
d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
@@ -442,8 +442,8 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetBody(Shell, Body);
-
- // The purpose of the AMotor here is to keep the avatar's physical
+
+ // The purpose of the AMotor here is to keep the avatar's physical
// surrogate from rotating while moving
Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
d.JointAttach(Amotor, Body, IntPtr.Zero);
@@ -455,7 +455,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointSetAMotorAngle(Amotor, 0, 0);
d.JointSetAMotorAngle(Amotor, 1, 0);
d.JointSetAMotorAngle(Amotor, 2, 0);
-
+
// These lowstops and high stops are effectively (no wiggle room)
d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
@@ -464,23 +464,23 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
- // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
+ // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
// capped cyllinder will fall over
d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
-
+
//d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
//d.QfromR(
//d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
- //
+ //
//m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
//standupStraight();
-
-
-
+
+
+
}
- //
+ //
///
/// Uses the capped cyllinder volume formula to calculate the avatar's mass.
/// This may be used in calculations in the scene/scenepresence
@@ -508,13 +508,13 @@ namespace OpenSim.Region.Physics.OdePlugin
}
-// This code is very useful. Written by DanX0r. We're just not using it right now.
+// This code is very useful. Written by DanX0r. We're just not using it right now.
// Commented out to prevent a warning.
//
// private void standupStraight()
// {
// // The purpose of this routine here is to quickly stabilize the Body while it's popped up in the air.
-// // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you
+// // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you
// // change appearance and when you enter the simulator
// // After this routine is done, the amotor stabilizes much quicker
// d.Vector3 feet;
@@ -558,7 +558,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (_zeroFlag)
return new PhysicsVector(0f, 0f, 0f);
m_lastUpdateSent = false;
- return _velocity;
+ return _velocity;
}
set
{
@@ -601,7 +601,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
///
- /// Adds the force supplied to the Target Velocity
+ /// Adds the force supplied to the Target Velocity
/// The PID controller takes this target velocity and tries to make it a reality
///
///
@@ -616,7 +616,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// _target_velocity.Y += force.Y;
//_target_velocity.Z += force.Z;
}
- else
+ else
{
m_pidControllerActive = true;
_target_velocity.X += force.X;
@@ -637,7 +637,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodyAddForce(Body, force.X, force.Y, force.Z);
//d.BodySetRotation(Body, ref m_StandUpRotation);
//standupStraight();
-
+
}
}
@@ -655,16 +655,16 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// no lock; for now it's only called from within Simulate()
- // If the PID Controller isn't active then we set our force
+ // If the PID Controller isn't active then we set our force
// calculating base velocity to the current position
-
+
if (m_pidControllerActive == false)
{
_zeroPosition = d.BodyGetPosition(Body);
}
//PidStatus = true;
-
+
PhysicsVector vec = new PhysicsVector();
d.Vector3 vel = d.BodyGetLinearVel(Body);
float movementdivisor = 1f;
@@ -798,13 +798,13 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.X = 0.0f;
_velocity.Y = 0.0f;
_velocity.Z = 0.0f;
-
+
// Did we send out the 'stopped' message?
if (!m_lastUpdateSent)
{
m_lastUpdateSent = true;
//base.RequestPhysicsterseUpdate();
-
+
}
}
else
@@ -815,7 +815,7 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.Y = (vec.Y);
_velocity.Z = (vec.Z);
-
+
if (_velocity.Z < -6 && !m_hackSentFall)
{
m_hackSentFall = true;
@@ -849,7 +849,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomDestroy(Shell);
_parent_scene.geom_name_map.Remove(Shell);
-
+
//kill the body
d.BodyDestroy(Body);
}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 37a8b77..f1886e4 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -111,7 +111,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private IntPtr _linkJointGroup = (IntPtr)0;
private PhysicsActor _parent = null;
private PhysicsActor m_taintparent = null;
-
+
private bool iscolliding = false;
private bool m_isphysical = false;
private bool m_isSelected = false;
@@ -202,7 +202,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintadd = true;
_parent_scene.AddPhysicsActorTaint(this);
// don't do .add() here; old geoms get recycled with the same hash
-
+
}
public override int PhysicsActorType
@@ -232,9 +232,9 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool Selected
{
set {
- // This only makes the object not collidable if the object
+ // This only makes the object not collidable if the object
// is physical or the object is modified somehow *IN THE FUTURE*
- // without this, if an avatar selects prim, they can walk right
+ // without this, if an avatar selects prim, they can walk right
// through it while it's selected
if ((m_isphysical && !_zeroFlag) || !value)
@@ -262,7 +262,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
//m_log.Warn("Setting Geom to: " + prim_geom);
-
+
}
public void enableBodySoft()
@@ -277,7 +277,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void disableBodySoft()
{
m_disabled = true;
-
+
if (m_isphysical)
if (Body != (IntPtr)0)
d.BodyDisable(Body);
@@ -307,7 +307,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAutoDisableFlag(Body, true);
d.BodySetAutoDisableSteps(Body, 20);
-
+
m_interpenetrationcount = 0;
m_collisionscore = 0;
m_disabled = false;
@@ -327,7 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
float volume = 0;
- // No material is passed to the physics engines yet.. soo..
+ // No material is passed to the physics engines yet.. soo..
// we're using the m_density constant in the class definition
@@ -340,7 +340,7 @@ namespace OpenSim.Region.Physics.OdePlugin
volume = _size.X*_size.Y*_size.Z;
- // If the user has 'hollowed out'
+ // If the user has 'hollowed out'
// ProfileHollow is one of those 0 to 50000 values :P
// we like percentages better.. so turning into a percentage
@@ -415,7 +415,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// We don't know what the shape is yet, so use default
volume = _size.X * _size.Y * _size.Z;
}
- // If the user has 'hollowed out'
+ // If the user has 'hollowed out'
// ProfileHollow is one of those 0 to 50000 values :P
// we like percentages better.. so turning into a percentage
@@ -427,8 +427,8 @@ namespace OpenSim.Region.Physics.OdePlugin
float hollowVolume = 0;
switch (_pbs.HollowShape)
{
-
- case HollowShape.Same:
+
+ case HollowShape.Same:
case HollowShape.Circle:
// Hollow shape is a perfect cyllinder in respect to the cube's scale
// Cyllinder hollow volume calculation
@@ -447,7 +447,7 @@ namespace OpenSim.Region.Physics.OdePlugin
hollowVolume = hollowsizex * hollowsizey * hollowsizez;
break;
-
+
case HollowShape.Triangle:
// Equilateral Triangular Prism volume hollow calculation
@@ -465,7 +465,7 @@ namespace OpenSim.Region.Physics.OdePlugin
volume = volume - hollowVolume;
}
break;
-
+
case ProfileShape.HalfCircle:
if (_pbs.PathCurve == (byte)Extrusion.Curve1)
{
@@ -490,13 +490,13 @@ namespace OpenSim.Region.Physics.OdePlugin
}
break;
case ProfileShape.EquilateralTriangle:
- /*
+ /*
v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h
-
+
// seed mesh
Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f);
Vertex PM = new Vertex(+0.5f, 0f, 0.0f);
- Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f);
+ Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f);
*/
float xA = -0.25f * _size.X;
float yA = -0.45f * _size.Y;
@@ -509,7 +509,7 @@ namespace OpenSim.Region.Physics.OdePlugin
volume = (float)((Math.Abs((xB * yA - xA * yB) + (xC * yB - xB * yC) + (xA * yC - xC * yA)) / 2) * _size.Z);
- // If the user has 'hollowed out'
+ // If the user has 'hollowed out'
// ProfileHollow is one of those 0 to 50000 values :P
// we like percentages better.. so turning into a percentage
float fhollowFactor = ((float)_pbs.ProfileHollow / 1.9f);
@@ -521,7 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float hollowVolume = 0;
switch (_pbs.HollowShape)
{
-
+
case HollowShape.Same:
case HollowShape.Triangle:
// Equilateral Triangular Prism volume hollow calculation
@@ -550,7 +550,7 @@ namespace OpenSim.Region.Physics.OdePlugin
hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount);
break;
-
+
default:
hollowVolume = 0;
break;
@@ -560,7 +560,7 @@ namespace OpenSim.Region.Physics.OdePlugin
break;
default:
- // we don't have all of the volume formulas yet so
+ // we don't have all of the volume formulas yet so
// use the common volume formula for all
volume = _size.X*_size.Y*_size.Z;
break;
@@ -568,7 +568,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Calculate Path cut effect on volume
// Not exact, in the triangle hollow example
- // They should never be zero or less then zero..
+ // They should never be zero or less then zero..
// we'll ignore it if it's less then zero
// ProfileEnd and ProfileBegin are values
@@ -672,11 +672,11 @@ namespace OpenSim.Region.Physics.OdePlugin
public void setMesh(OdeScene parent_scene, IMesh mesh)
{
- // This sleeper is there to moderate how long it takes between
+ // This sleeper is there to moderate how long it takes between
// setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
-
+
Thread.Sleep(10);
-
+
//Kill Body so that mesh can re-make the geom
if (IsPhysical && Body != (IntPtr) 0)
{
@@ -694,9 +694,9 @@ namespace OpenSim.Region.Physics.OdePlugin
3*sizeof (int));
d.GeomTriMeshDataPreprocess(_triMeshData);
-
+
_parent_scene.waitForSpaceUnlock(m_targetSpace);
-
+
try
{
if (prim_geom == (IntPtr)0)
@@ -706,7 +706,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
catch (AccessViolationException)
{
-
+
m_log.Error("[PHYSICS]: MESH LOCKED");
return;
}
@@ -715,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Recreate the body
m_interpenetrationcount = 0;
m_collisionscore = 0;
-
+
enableBody();
}
@@ -724,7 +724,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void ProcessTaints(float timestep)
{
-
+
if (m_taintadd)
{
changeadd(timestep);
@@ -779,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
private void changeAngularLock(float timestep)
- {
+ {
// do we have a Physical object?
if (Body != IntPtr.Zero)
{
@@ -809,7 +809,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changelink(float timestep)
{
-
+
if (_parent == null && m_taintparent != null)
{
if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
@@ -834,14 +834,14 @@ namespace OpenSim.Region.Physics.OdePlugin
m_linkJoint = (IntPtr)0;
}
-
+
_parent = m_taintparent;
}
private void changeSelectedStatus(float timestep)
{
-
+
if (m_taintselected)
{
@@ -849,9 +849,9 @@ namespace OpenSim.Region.Physics.OdePlugin
m_collisionCategories = CollisionCategories.Selected;
m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
- // We do the body disable soft twice because 'in theory' a collision could have happened
+ // We do the body disable soft twice because 'in theory' a collision could have happened
// in between the disabling and the collision properties setting
- // which would wake the physical body up from a soft disabling and potentially cause it to fall
+ // which would wake the physical body up from a soft disabling and potentially cause it to fall
// through the ground.
if (m_isphysical)
@@ -873,9 +873,9 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
-
+
m_collisionCategories = CollisionCategories.Geom;
-
+
if (m_isphysical)
m_collisionCategories |= CollisionCategories.Body;
@@ -898,10 +898,10 @@ namespace OpenSim.Region.Physics.OdePlugin
enableBodySoft();
}
-
+
}
-
+
resetCollisionAccounting();
m_isSelected = m_taintselected;
}
@@ -918,21 +918,21 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintselected = m_isSelected;
m_taintsize = _size;
-
+
m_taintshape = false;
m_taintforce = false;
-
+
m_taintdisable = false;
m_taintVelocity = PhysicsVector.Zero;
}
public void changeadd(float timestep)
{
-
-
-
+
+
+
int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position);
@@ -941,7 +941,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_targetSpace = targetspace;
-
+
if (_mesh != null)
{
@@ -1010,7 +1010,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
ode.dunlock(_parent_scene.world);
- return;
+ return;
}
}
}
@@ -1060,7 +1060,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
-
+
_parent_scene.geom_name_map[prim_geom] = this.m_primName;
_parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
@@ -1072,7 +1072,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
public void changemove(float timestep)
{
-
+
if (m_isphysical)
@@ -1080,7 +1080,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// This is a fallback.. May no longer be necessary.
if (Body == (IntPtr) 0)
enableBody();
- //Prim auto disable after 20 frames,
+ //Prim auto disable after 20 frames,
//if you move it, re-enable the prim manually.
if (_parent != null)
{
@@ -1102,7 +1102,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
d.BodyEnable(Body);
-
+
}
else
{
@@ -1122,10 +1122,10 @@ namespace OpenSim.Region.Physics.OdePlugin
d.SpaceAdd(m_targetSpace, prim_geom);
}
}
-
+
changeSelectedStatus(timestep);
-
+
resetCollisionAccounting();
m_taintposition = _position;
}
@@ -1140,42 +1140,42 @@ namespace OpenSim.Region.Physics.OdePlugin
{
float PID_D = 2200.0f;
//float PID_P = 900.0f;
-
-
+
+
float m_mass = CalculateMass();
-
+
fz = 0f;
//m_log.Info(m_collisionFlags.ToString());
-
+
if (m_buoyancy != 0)
{
-
+
if (m_buoyancy > 0)
{
fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass);
-
+
//d.Vector3 l_velocity = d.BodyGetLinearVel(Body);
//m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString());
}
- else
+ else
{
fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass));
}
-
+
}
if (m_usePID)
{
- // If we're using the PID controller, then we have no gravity
+ // If we're using the PID controller, then we have no gravity
fz = (-1 * _parent_scene.gravityz) * this.Mass;
// no lock; for now it's only called from within Simulate()
- // If the PID Controller isn't active then we set our force
+ // If the PID Controller isn't active then we set our force
// calculating base velocity to the current position
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
@@ -1189,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
PID_D = 35f;
-
+
//PID_P = 1.0f;
float PID_G = 25;
@@ -1197,7 +1197,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
PID_G = PID_G / m_PIDTau;
}
-
+
if ((PID_G - m_PIDTau) <= 0)
{
@@ -1205,15 +1205,15 @@ namespace OpenSim.Region.Physics.OdePlugin
}
//PidStatus = true;
-
+
PhysicsVector vec = new PhysicsVector();
d.Vector3 vel = d.BodyGetLinearVel(Body);
-
+
d.Vector3 pos = d.BodyGetPosition(Body);
- _target_velocity =
+ _target_velocity =
new PhysicsVector(
(m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
(m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
@@ -1222,18 +1222,18 @@ namespace OpenSim.Region.Physics.OdePlugin
// if velocity is zero, use position control; otherwise, velocity control
-
+
if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
{
// keep track of where we stopped. No more slippin' & slidin'
-
-
+
+
// We only want to deactivate the PID Controller if we think we want to have our surrogate
// react to the physics scene by moving it's position.
// Avatar to Avatar collisions
// Prim to avatar collisions
-
+
//fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
//fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
//fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
@@ -1245,27 +1245,27 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
-
+
_zeroFlag = false;
-
+
// We're flying and colliding with something
fx = ((_target_velocity.X) - vel.X) * (PID_D);
fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
-
-
-
+
+
+
// vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
}
- }
+ }
fx *= m_mass;
fy *= m_mass;
//fz *= m_mass;
-
+
//m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
if (fx != 0 || fy != 0 || fz != 0)
{
@@ -1285,7 +1285,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void rotate(float timestep)
{
-
+
d.Quaternion myrot = new d.Quaternion();
myrot.W = _orientation.w;
@@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0))
createAMotor(m_angularlock);
}
-
+
resetCollisionAccounting();
m_taintrot = _orientation;
}
@@ -1313,21 +1313,21 @@ namespace OpenSim.Region.Physics.OdePlugin
public void changedisable(float timestep)
{
-
+
m_disabled = true;
if (Body != (IntPtr)0)
{
d.BodyDisable(Body);
Body = (IntPtr)0;
}
-
+
m_taintdisable = false;
}
public void changePhysicsStatus(float timestep)
{
-
+
if (m_isphysical == true)
{
@@ -1352,7 +1352,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void changesize(float timestamp)
{
-
+
//if (!_parent_scene.geom_name_map.ContainsKey(prim_geom))
//{
// m_taintsize = _size;
@@ -1369,7 +1369,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// Cleanup meshing here
}
- //kill body to rebuild
+ //kill body to rebuild
if (IsPhysical && Body != (IntPtr) 0)
{
disableBody();
@@ -1531,7 +1531,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_collisionFlags |= CollisionCategories.Water;
}
- else
+ else
{
m_collisionFlags &= ~CollisionCategories.Water;
}
@@ -1541,7 +1541,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void changeshape(float timestamp)
{
-
+
string oldname = _parent_scene.geom_name_map[prim_geom];
// Cleanup of old prim geometry and Bodies
@@ -1579,7 +1579,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Re creates body on size.
// EnableBody also does setMass()
enableBody();
-
+
}
}
else
@@ -1684,7 +1684,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodyEnable(Body);
}
}
-
+
_parent_scene.geom_name_map[prim_geom] = oldname;
@@ -1698,7 +1698,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (!m_isSelected)
{
-
+
lock (m_forcelist)
@@ -1728,7 +1728,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (!m_isSelected)
{
-
+
Thread.Sleep(20);
if (IsPhysical)
@@ -1737,8 +1737,8 @@ namespace OpenSim.Region.Physics.OdePlugin
{
d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
}
- }
-
+ }
+
//resetCollisionAccounting();
}
m_taintVelocity = PhysicsVector.Zero;
@@ -1794,7 +1794,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get { return _position; }
- set { _position = value;
+ set { _position = value;
//m_log.Info("[PHYSICS]: " + _position.ToString());
}
}
@@ -1838,7 +1838,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get
{
- // Averate previous velocity with the new one so
+ // Averate previous velocity with the new one so
// client object interpolation works a 'little' better
PhysicsVector returnVelocity = new PhysicsVector();
returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
@@ -1849,7 +1849,7 @@ namespace OpenSim.Region.Physics.OdePlugin
set
{
_velocity = value;
-
+
m_taintVelocity = value;
_parent_scene.AddPhysicsActorTaint(this);
}
@@ -1898,11 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
if (_zeroFlag)
return pv;
m_lastUpdateSent = false;
-
+
if (m_rotationalVelocity.IsIdentical(pv, 0.2f))
return pv;
- return m_rotationalVelocity;
+ return m_rotationalVelocity;
}
set { m_rotationalVelocity = value; }
}
@@ -1948,7 +1948,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
public void UpdatePositionAndVelocity()
- {
+ {
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
if (_parent != null)
{
@@ -1963,7 +1963,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.Quaternion ori = d.BodyGetQuaternion(Body);
d.Vector3 vel = d.BodyGetLinearVel(Body);
d.Vector3 rotvel = d.BodyGetAngularVel(Body);
-
+
PhysicsVector l_position = new PhysicsVector();
// kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
@@ -2000,16 +2000,16 @@ namespace OpenSim.Region.Physics.OdePlugin
if (l_position.Z < 0)
{
- // This is so prim that get lost underground don't fall forever and suck up
- //
+ // This is so prim that get lost underground don't fall forever and suck up
+ //
// Sim resources and memory.
- // Disables the prim's movement physics....
+ // Disables the prim's movement physics....
// It's a hack and will generate a console message if it fails.
//IsPhysical = false;
if (_parent == null)
base.RaiseOutOfBounds(_position);
-
+
_acceleration.X = 0;
_acceleration.Y = 0;
_acceleration.Z = 0;
@@ -2020,10 +2020,10 @@ namespace OpenSim.Region.Physics.OdePlugin
m_rotationalVelocity.X = 0;
m_rotationalVelocity.Y = 0;
m_rotationalVelocity.Z = 0;
-
+
if (_parent == null)
base.RequestPhysicsterseUpdate();
-
+
m_throttleUpdates = false;
throttleCounter = 0;
_zeroFlag = true;
@@ -2065,10 +2065,10 @@ namespace OpenSim.Region.Physics.OdePlugin
m_throttleUpdates = false;
throttleCounter = 0;
m_rotationalVelocity = pv;
-
+
if (_parent == null)
base.RequestPhysicsterseUpdate();
-
+
m_lastUpdateSent = true;
}
}
@@ -2087,11 +2087,11 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.X = vel.X;
_velocity.Y = vel.Y;
_velocity.Z = vel.Z;
-
+
_acceleration = ((_velocity - m_lastVelocity) / 0.1f);
_acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
//m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
-
+
if (_velocity.IsIdentical(pv, 0.5f))
{
m_rotationalVelocity = pv;
@@ -2173,7 +2173,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_tensor = 5f;
}
-
+
float axisnum = 3;
axisnum = (axisnum - (axis.X + axis.Y + axis.Z));
@@ -2222,7 +2222,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
-
+
d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor);
}
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index d795e45..c663fb0 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -42,7 +42,7 @@ using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Physics.OdePlugin
{
///
- /// ODE plugin
+ /// ODE plugin
///
public class OdePlugin : IPhysicsPlugin
{
@@ -51,7 +51,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private CollisionLocker ode;
private OdeScene _mScene;
-
public OdePlugin()
{
ode = new CollisionLocker();
@@ -81,15 +80,13 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
-
- public enum StatusIndicators : int
+ public enum StatusIndicators : int
{
Generic = 0,
Start = 1,
End = 2
}
-
public struct sCollisionData
{
public uint ColliderLocalId;
@@ -165,7 +162,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private float mAvatarObjectContactFriction = 75f;
private float mAvatarObjectContactBounce = 0.1f;
-
private float avPIDD = 3200f;
private float avPIDP = 1400f;
private float avCapRadius = 0.37f;
@@ -175,13 +171,12 @@ namespace OpenSim.Region.Physics.OdePlugin
private float avMovementDivisorWalk = 1.3f;
private float avMovementDivisorRun = 0.8f;
-
private float[] _heightmap;
private float[] _watermap;
private float[] _origheightmap;
-
+
private d.NearCallback nearCallback;
public d.TriCallback triCallback;
public d.TriArrayCallback triArrayCallback;
@@ -200,7 +195,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private d.Contact AvatarMovementTerrainContact;
private d.Contact WaterContact;
-
//Ckrinke: Comment out until used. We declare it, initialize it, but do not use it
//Ckrinke private int m_randomizeWater = 200;
private int m_physicsiterations = 10;
@@ -233,7 +227,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private IConfigSource m_config;
-
///
/// Initiailizes the scene
/// Sets many properties that ODE requires to be stable
@@ -245,44 +238,34 @@ namespace OpenSim.Region.Physics.OdePlugin
nearCallback = near;
triCallback = TriCallback;
triArrayCallback = TriArrayCallback;
-
-
-
lock (OdeLock)
{
-
- // Creat the world and the first space
+ // Create the world and the first space
world = d.WorldCreate();
space = d.HashSpaceCreate(IntPtr.Zero);
-
+
contactgroup = d.JointGroupCreate(0);
//contactgroup
-
-
-
d.WorldSetAutoDisableFlag(world, false);
-
}
// zero out a heightmap array float array (single dimention [flattened]))
_heightmap = new float[514*514];
_watermap = new float[258 * 258];
- // Zero out the prim spaces array (we split our space into smaller spaces so
+ // Zero out the prim spaces array (we split our space into smaller spaces so
// we can hit test less.
-
}
-
// Initialize the mesh plugin
public override void Initialise(IMesher meshmerizer, IConfigSource config)
{
mesher = meshmerizer;
m_config = config;
// Defaults
-
+
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
avPIDD = 3200.0f;
@@ -349,10 +332,7 @@ namespace OpenSim.Region.Physics.OdePlugin
avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f);
avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f);
}
-
-
}
-
}
staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)];
@@ -361,8 +341,8 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.surface.mu = nmAvatarObjectContactFriction;
contact.surface.bounce = nmAvatarObjectContactBounce;
- // Terrain contact friction and Bounce
- // This is the *non* moving version. Use this when an avatar
+ // Terrain contact friction and Bounce
+ // This is the *non* moving version. Use this when an avatar
// isn't moving to keep it in place better
TerrainContact.surface.mode |= d.ContactFlags.SoftERP;
TerrainContact.surface.mu = nmTerrainContactFriction;
@@ -376,7 +356,7 @@ namespace OpenSim.Region.Physics.OdePlugin
WaterContact.surface.soft_erp = 0.010f;
// Prim contact friction and bounce
- // THis is the *non* moving version of friction and bounce
+ // THis is the *non* moving version of friction and bounce
// Use this when an avatar comes in contact with a prim
// and is moving
AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction;
@@ -409,7 +389,6 @@ namespace OpenSim.Region.Physics.OdePlugin
staticPrimspace[i, j] = IntPtr.Zero;
}
}
-
}
internal void waitForSpaceUnlock(IntPtr space)
@@ -439,17 +418,17 @@ namespace OpenSim.Region.Physics.OdePlugin
private void near(IntPtr space, IntPtr g1, IntPtr g2)
{
// no lock here! It's invoked from within Simulate(), which is thread-locked
-
- // Test if we're collidng a geom with a space.
+
+ // Test if we're colliding a geom with a space.
// If so we have to drill down into the space recursively
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
{
if (g1 == (IntPtr)0 || g2 == (IntPtr)0)
return;
- // Separating static prim geometry spaces.
- // We'll be calling near recursivly if one
- // of them is a space to find all of the
+ // Separating static prim geometry spaces.
+ // We'll be calling near recursivly if one
+ // of them is a space to find all of the
// contact points in the space
try
{
@@ -462,13 +441,12 @@ namespace OpenSim.Region.Physics.OdePlugin
}
//Colliding a space or a geom with a space or a geom. so drill down
- //Collide all geoms in each space..
+ //Collide all geoms in each space..
//if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback);
//if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback);
return;
}
-
if (g1 == (IntPtr)0 || g2 == (IntPtr)0)
return;
@@ -499,23 +477,17 @@ namespace OpenSim.Region.Physics.OdePlugin
int count = 0;
try
{
-
// Colliding Geom To Geom
// This portion of the function 'was' blatantly ripped off from BoxStack.cs
-
-
-
if (g1 == g2)
return; // Can't collide with yourself
if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
return;
-
+
lock (contacts)
{
-
-
count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
}
}
@@ -527,7 +499,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
catch (AccessViolationException)
{
-
+
m_log.Warn("[PHYSICS]: Unable to collide test an object");
return;
}
@@ -539,6 +511,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
p1 = PANull;
}
+
if (!actor_name_map.TryGetValue(g2, out p2))
{
p2 = PANull;
@@ -554,14 +527,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// If we're colliding with terrain, use 'TerrainContact' instead of contact.
// allows us to have different settings
-
-
// We only need to test p2 for 'jump crouch purposes'
p2.IsColliding = true;
//if ((framecount % m_returncollisions) == 0)
-
-
switch (p1.PhysicsActorType)
{
@@ -588,41 +557,39 @@ namespace OpenSim.Region.Physics.OdePlugin
{
//This is disabled at the moment only because it needs more tweaking
//It will eventually be uncommented
-
+
if (contacts[i].depth >= 1.00f)
{
//m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString());
}
-
+
//If you interpenetrate a prim with an agent
if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
p1.PhysicsActorType == (int) ActorTypes.Prim) ||
(p1.PhysicsActorType == (int) ActorTypes.Agent &&
p2.PhysicsActorType == (int) ActorTypes.Prim))
{
-
-
# region disabled code1
//contacts[i].depth = contacts[i].depth * 4.15f;
/*
if (p2.PhysicsActorType == (int) ActorTypes.Agent)
- {
+ {
p2.CollidingObj = true;
contacts[i].depth = 0.003f;
p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
OdeCharacter character = (OdeCharacter) p2;
character.SetPidStatus(true);
contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2));
-
+
}
else
{
-
+
//contacts[i].depth = 0.0000000f;
}
if (p1.PhysicsActorType == (int) ActorTypes.Agent)
{
-
+
p1.CollidingObj = true;
contacts[i].depth = 0.003f;
p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);
@@ -632,14 +599,12 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
-
+
//contacts[i].depth = 0.0000000f;
}
*/
#endregion
-
}
-
// If you interpenetrate a prim with another prim
if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim)
@@ -649,7 +614,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//OdePrim op2 = (OdePrim)p2;
//op1.m_collisionscore++;
//op2.m_collisionscore++;
-
//if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000)
//{
@@ -658,11 +622,10 @@ namespace OpenSim.Region.Physics.OdePlugin
//op2.m_taintdisable = true;
//AddPhysicsActorTaint(p2);
//}
-
+
//if (contacts[i].depth >= 0.25f)
//{
// Don't collide, one or both prim will expld.
-
//op1.m_interpenetrationcount++;
//op2.m_interpenetrationcount++;
@@ -678,17 +641,17 @@ namespace OpenSim.Region.Physics.OdePlugin
//AddPhysicsActorTaint(p2);
//}
-
//contacts[i].depth = contacts[i].depth / 8f;
//contacts[i].normal = new d.Vector3(0, 0, 1);
//}
//if (op1.m_disabled || op2.m_disabled)
//{
- //Manually disabled objects stay disabled
+ //Manually disabled objects stay disabled
//contacts[i].depth = 0f;
//}
#endregion
}
+
if (contacts[i].depth >= 1.00f)
{
//m_log.Info("[P]: " + contacts[i].depth.ToString());
@@ -713,6 +676,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
}
+
if (p1.PhysicsActorType == (int) ActorTypes.Agent)
{
OdeCharacter character = (OdeCharacter)p1;
@@ -738,7 +702,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (contacts[i].depth >= 0f)
{
- // If we're collidng against terrain
+ // If we're colliding against terrain
if (name1 == "Terrain" || name2 == "Terrain")
{
// If we're moving
@@ -760,12 +724,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if ((p2.PhysicsActorType == (int)ActorTypes.Prim))
{
-
}
else
{
-
}
+
//WaterContact.surface.soft_cfm = 0.0000f;
//WaterContact.surface.soft_erp = 0.00000f;
if (contacts[i].depth > 0.1f)
@@ -775,7 +738,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f);
}
WaterContact.geom = contacts[i];
-
+
joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
//m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth);
@@ -806,7 +769,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// If there are more then 3 contact points, it's likely
// that we've got a pile of objects
- //
+ //
// We don't want to send out hundreds of terse updates over and over again
// so lets throttle them and send them again after it's somewhat sorted out.
p2.ThrottleUpdates = true;
@@ -814,7 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//System.Console.WriteLine(count.ToString());
//System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2);
}
-
}
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth)
@@ -831,7 +793,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
case ActorTypes.Agent:
cc2 = (OdeCharacter)p2;
-
+
obj1LocalID = cc2.m_localID;
switch ((ActorTypes)p1.PhysicsActorType)
{
@@ -840,7 +802,7 @@ namespace OpenSim.Region.Physics.OdePlugin
obj2LocalID = cc1.m_localID;
cc1.AddCollisionEvent(cc2.m_localID, collisiondepth);
//ctype = (int)CollisionCategories.Character;
-
+
//if (cc1.CollidingObj)
//cStartStop = (int)StatusIndicators.Generic;
//else
@@ -858,7 +820,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//cStartStop = (int)StatusIndicators.Generic;
//else
//cStartStop = (int)StatusIndicators.Start;
-
+
//returncollisions = true;
break;
@@ -869,14 +831,12 @@ namespace OpenSim.Region.Physics.OdePlugin
//returncollisions = true;
break;
}
-
-
cc2.AddCollisionEvent(obj2LocalID, collisiondepth);
break;
case ActorTypes.Prim:
cp2 = (OdePrim)p2;
-
+
obj1LocalID = cp2.m_localID;
switch ((ActorTypes)p1.PhysicsActorType)
{
@@ -891,7 +851,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//else
//cStartStop = (int)StatusIndicators.Start;
//returncollisions = true;
-
+
break;
case ActorTypes.Prim:
cp1 = (OdePrim)p1;
@@ -903,7 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//cStartStop = (int)StatusIndicators.Generic;
//else
//cStartStop = (int)StatusIndicators.Start;
-
+
//returncollisions = true;
break;
@@ -911,11 +871,11 @@ namespace OpenSim.Region.Physics.OdePlugin
case ActorTypes.Unknown:
obj2LocalID = 0;
//ctype = (int)CollisionCategories.Land;
-
+
//returncollisions = true;
break;
}
-
+
cp2.AddCollisionEvent(obj2LocalID, collisiondepth);
break;
}
@@ -999,7 +959,7 @@ namespace OpenSim.Region.Physics.OdePlugin
///
private void collision_optimized(float timeStep)
{
-
+
foreach (OdeCharacter chr in _characters)
{
// Reset the collision values to false
@@ -1008,7 +968,7 @@ namespace OpenSim.Region.Physics.OdePlugin
chr.IsColliding = false;
chr.CollidingGround = false;
chr.CollidingObj = false;
-
+
// test the avatar's geometry for collision with the space
// This will return near and the space that they are the closest to
// And we'll run this again against the avatar and the space segment
@@ -1029,15 +989,11 @@ namespace OpenSim.Region.Physics.OdePlugin
//forcedZ = true;
//}
}
-
-
lock (_activeprims)
{
-
foreach (OdePrim chr in _activeprims)
{
-
if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
{
try
@@ -1049,18 +1005,14 @@ namespace OpenSim.Region.Physics.OdePlugin
else
m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed");
}
-
}
catch (AccessViolationException)
{
m_log.Warn("[PHYSICS]: Unable to space collide");
}
-
}
-
}
}
-
}
#endregion
@@ -1077,7 +1029,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (!_collisionEventPrim.Contains(obj))
_collisionEventPrim.Add(obj);
-
}
}
@@ -1090,7 +1041,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
-
#region Add/Remove Entities
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size)
@@ -1131,8 +1081,6 @@ namespace OpenSim.Region.Physics.OdePlugin
rot.y = rotation.y;
rot.z = rotation.z;
-
-
OdePrim newPrim;
lock (OdeLock)
{
@@ -1141,7 +1089,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_prims.Add(newPrim);
}
-
return newPrim;
}
@@ -1178,11 +1125,9 @@ namespace OpenSim.Region.Physics.OdePlugin
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical);
-
return result;
}
-
public void remActivePrim(OdePrim deactivatePrim)
{
lock (_activeprims)
@@ -1210,8 +1155,8 @@ namespace OpenSim.Region.Physics.OdePlugin
/// This is called from within simulate but outside the locked portion
/// We need to do our own locking here
/// Essentially, we need to remove the prim from our space segment, whatever segment it's in.
- ///
- /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory
+ ///
+ /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory
/// that the space was using.
///
///
@@ -1226,7 +1171,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
prim.ResetTaints();
-
if (prim.IsPhysical)
{
prim.disableBody();
@@ -1267,7 +1211,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
}
-
}
catch (AccessViolationException)
{
@@ -1297,8 +1240,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//}
//}
}
-
-
}
}
}
@@ -1337,12 +1278,11 @@ namespace OpenSim.Region.Physics.OdePlugin
/// a pointer to the new space it's in
public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace)
{
-
- // Called from setting the Position and Size of an ODEPrim so
+ // Called from setting the Position and Size of an ODEPrim so
// it's already in locked space.
// we don't want to remove the main space
- // we don't need to test physical here because this function should
+ // we don't need to test physical here because this function should
// never be called if the prim is physical(active)
// All physical prim end up in the root space
@@ -1399,7 +1339,7 @@ namespace OpenSim.Region.Physics.OdePlugin
waitForSpaceUnlock(space);
d.SpaceRemove(space, currentspace);
// free up memory used by the space.
-
+
//d.SpaceDestroy(currentspace);
resetSpaceArrayItemToZero(currentspace);
}
@@ -1418,7 +1358,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (d.SpaceQuery(currentspace, geom))
{
-
if (d.GeomIsSpace(currentspace))
{
waitForSpaceUnlock(currentspace);
@@ -1453,8 +1392,8 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
- // The routines in the Position and Size sections do the 'inserting' into the space,
- // so all we have to do is make sure that the space that we're putting the prim into
+ // The routines in the Position and Size sections do the 'inserting' into the space,
+ // so all we have to do is make sure that the space that we're putting the prim into
// is in the 'main' space.
int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
IntPtr newspace = calculateSpaceForGeom(pos);
@@ -1492,11 +1431,11 @@ namespace OpenSim.Region.Physics.OdePlugin
public IntPtr calculateSpaceForGeom(PhysicsVector pos)
{
IntPtr locationbasedspace =IntPtr.Zero;
-
+
int[] xyspace = calculateSpaceArrayItemFromPos(pos);
//m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]];
-
+
//locationbasedspace = space;
return locationbasedspace;
}
@@ -1523,13 +1462,10 @@ namespace OpenSim.Region.Physics.OdePlugin
if (returnint[1] < 0)
returnint[1] = 0;
-
return returnint;
}
- #endregion
-
-
+ #endregion
///
/// Routine to figure out if we need to mesh this prim with our mesher
@@ -1564,7 +1500,6 @@ namespace OpenSim.Region.Physics.OdePlugin
return false;
}
-
///
/// Called after our prim properties are set Scale, position etc.
/// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex
@@ -1586,7 +1521,7 @@ namespace OpenSim.Region.Physics.OdePlugin
///
/// This is our main simulate loop
- /// It's thread locked by a Mutex in the scene.
+ /// It's thread locked by a Mutex in the scene.
/// It holds Collisions, it instructs ODE to step through the physical reactions
/// It moves the objects around in memory
/// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup)
@@ -1597,7 +1532,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (framecount >= int.MaxValue)
framecount = 0;
-
+
framecount++;
float fps = 0;
@@ -1605,12 +1540,11 @@ namespace OpenSim.Region.Physics.OdePlugin
step_time += timeStep;
- // If We're loaded down by something else,
+ // If We're loaded down by something else,
// or debugging with the Visual Studio project on pause
// skip a few frames to catch up gracefully.
// without shooting the physicsactors all over the place
-
if (step_time >= m_SkipFramesAtms)
{
// Instead of trying to catch up, it'll do 5 physics frames only
@@ -1623,7 +1557,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
lock (OdeLock)
{
- // Process 10 frames if the sim is running normal..
+ // Process 10 frames if the sim is running normal..
// process 5 frames if the sim is running slow
//try
//{
@@ -1642,13 +1576,13 @@ namespace OpenSim.Region.Physics.OdePlugin
//(step_time == 0.004f, there's 250 of those per second. Times the step time/step size
step_time = 0.09375f;
fps = (step_time/ODE_STEPSIZE) * 1000;
-
+
while (step_time > 0.0f)
{
//lock (ode)
//{
//if (!ode.lockquery())
- //{
+ //{
// ode.dlock(world);
try
{
@@ -1661,9 +1595,8 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
-
bool processedtaints = false;
-
+
lock (_taintedPrim)
{
foreach (OdePrim prim in _taintedPrim)
@@ -1679,10 +1612,9 @@ namespace OpenSim.Region.Physics.OdePlugin
processedtaints = true;
prim.m_collisionscore = 0;
}
-
+
if (processedtaints)
_taintedPrim = new List();
-
}
lock (_activeprims)
@@ -1696,7 +1628,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//if ((framecount % m_randomizeWater) == 0)
// randomizeWater(waterlevel);
-
collision_optimized(timeStep);
@@ -1718,7 +1649,6 @@ namespace OpenSim.Region.Physics.OdePlugin
pobj.SendCollisions();
break;
}
-
}
}
@@ -1726,13 +1656,13 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointGroupEmpty(contactgroup);
//ode.dunlock(world);
- }
+ }
catch (Exception e)
{
m_log.Error("[PHYSICS]: " + e.Message.ToString() + e.TargetSite.ToString());
ode.dunlock(world);
}
-
+
step_time -= ODE_STEPSIZE;
i++;
//}
@@ -1765,7 +1695,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
}
-
}
return fps;
}
@@ -1780,7 +1709,7 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return (false); }
}
- #region ODE Specific Terrain Fixes
+ #region ODE Specific Terrain Fixes
public float[] ResizeTerrain512NearestNeighbour(float[] heightMap)
{
float[] returnarr = new float[262144];
@@ -1800,7 +1729,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// This particular way is quick but it only works on a multiple of the original
// The idea behind this method can be described with the following diagrams
- // second pass and third pass happen in the same loop really.. just separated
+ // second pass and third pass happen in the same loop really.. just separated
// them to show what this does.
// First Pass
@@ -1893,6 +1822,7 @@ namespace OpenSim.Region.Physics.OdePlugin
return returnarr;
}
+
public float[] ResizeTerrain512Interpolation(float[] heightMap)
{
float[] returnarr = new float[262144];
@@ -1912,7 +1842,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// This particular way is quick but it only works on a multiple of the original
// The idea behind this method can be described with the following diagrams
- // second pass and third pass happen in the same loop really.. just separated
+ // second pass and third pass happen in the same loop really.. just separated
// them to show what this does.
// First Pass
@@ -2139,7 +2069,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f));
}
-
lock (OdeLock)
{
if (!(WaterGeom == (IntPtr)0))
@@ -2183,7 +2112,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
lock (OdeLock)
{
-
foreach (OdePrim prm in _prims)
{
RemovePrim(prm);
--
cgit v1.1