Formatting cleanup.
parent
aa5197304e
commit
a5f08b430d
|
@ -70,8 +70,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private float m_tensor = 5f;
|
private float m_tensor = 5f;
|
||||||
private int body_autodisable_frames = 20;
|
private int body_autodisable_frames = 20;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private bool m_usePID = false;
|
private bool m_usePID = false;
|
||||||
|
|
||||||
private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
|
private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
|
||||||
|
@ -98,7 +96,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
public bool m_taintselected = false;
|
public bool m_taintselected = false;
|
||||||
public bool m_taintCollidesWater = false;
|
public bool m_taintCollidesWater = false;
|
||||||
|
|
||||||
|
|
||||||
public uint m_localID = 0;
|
public uint m_localID = 0;
|
||||||
|
|
||||||
//public GCHandle gc;
|
//public GCHandle gc;
|
||||||
|
@ -148,11 +145,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
private IntPtr m_linkJoint = (IntPtr)0;
|
private IntPtr m_linkJoint = (IntPtr)0;
|
||||||
|
|
||||||
|
|
||||||
public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
|
public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
|
||||||
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
|
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
|
||||||
{
|
{
|
||||||
|
|
||||||
_target_velocity = new PhysicsVector(0, 0, 0);
|
_target_velocity = new PhysicsVector(0, 0, 0);
|
||||||
//gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
|
//gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
|
||||||
ode = dode;
|
ode = dode;
|
||||||
|
@ -214,7 +209,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_taintadd = true;
|
m_taintadd = true;
|
||||||
_parent_scene.AddPhysicsActorTaint(this);
|
_parent_scene.AddPhysicsActorTaint(this);
|
||||||
// don't do .add() here; old geoms get recycled with the same hash
|
// don't do .add() here; old geoms get recycled with the same hash
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int PhysicsActorType
|
public override int PhysicsActorType
|
||||||
|
@ -256,11 +250,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
m_taintselected = value;
|
m_taintselected = value;
|
||||||
m_isSelected = value;
|
m_isSelected = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,13 +266,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
|
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
|
||||||
}
|
}
|
||||||
//m_log.Warn("Setting Geom to: " + prim_geom);
|
//m_log.Warn("Setting Geom to: " + prim_geom);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableBodySoft()
|
public void enableBodySoft()
|
||||||
{
|
{
|
||||||
if (m_isphysical)
|
if (m_isphysical && Body != (IntPtr)0)
|
||||||
if (Body != (IntPtr)0)
|
|
||||||
d.BodyEnable(Body);
|
d.BodyEnable(Body);
|
||||||
|
|
||||||
m_disabled = false;
|
m_disabled = false;
|
||||||
|
@ -290,12 +280,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
m_disabled = true;
|
m_disabled = true;
|
||||||
|
|
||||||
if (m_isphysical)
|
if (m_isphysical && Body != (IntPtr)0)
|
||||||
if (Body != (IntPtr)0)
|
|
||||||
d.BodyDisable(Body);
|
d.BodyDisable(Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void enableBody()
|
public void enableBody()
|
||||||
{
|
{
|
||||||
// Sets the geom to a body
|
// Sets the geom to a body
|
||||||
|
@ -316,7 +304,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
|
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
|
||||||
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
|
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
|
||||||
|
|
||||||
|
|
||||||
d.BodySetAutoDisableFlag(Body, true);
|
d.BodySetAutoDisableFlag(Body, true);
|
||||||
d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
|
d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
|
||||||
|
|
||||||
|
@ -342,7 +329,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// 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
|
// we're using the m_density constant in the class definition
|
||||||
|
|
||||||
|
|
||||||
float returnMass = 0;
|
float returnMass = 0;
|
||||||
|
|
||||||
switch (_pbs.ProfileShape)
|
switch (_pbs.ProfileShape)
|
||||||
|
@ -439,7 +425,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
float hollowVolume = 0;
|
float hollowVolume = 0;
|
||||||
switch (_pbs.HollowShape)
|
switch (_pbs.HollowShape)
|
||||||
{
|
{
|
||||||
|
|
||||||
case HollowShape.Same:
|
case HollowShape.Same:
|
||||||
case HollowShape.Circle:
|
case HollowShape.Circle:
|
||||||
// Hollow shape is a perfect cyllinder in respect to the cube's scale
|
// Hollow shape is a perfect cyllinder in respect to the cube's scale
|
||||||
|
@ -459,8 +444,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
hollowVolume = hollowsizex * hollowsizey * hollowsizez;
|
hollowVolume = hollowsizex * hollowsizey * hollowsizez;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case HollowShape.Triangle:
|
case HollowShape.Triangle:
|
||||||
// Equilateral Triangular Prism volume hollow calculation
|
// Equilateral Triangular Prism volume hollow calculation
|
||||||
// Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
|
// Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
|
||||||
|
@ -493,7 +476,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// we treat this as a box currently
|
// we treat this as a box currently
|
||||||
volume = _size.X * _size.Y * _size.Z;
|
volume = _size.X * _size.Y * _size.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -501,6 +483,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
volume = _size.X * _size.Y * _size.Z;
|
volume = _size.X * _size.Y * _size.Z;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProfileShape.EquilateralTriangle:
|
case ProfileShape.EquilateralTriangle:
|
||||||
/*
|
/*
|
||||||
v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h
|
v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h
|
||||||
|
@ -533,7 +516,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
float hollowVolume = 0;
|
float hollowVolume = 0;
|
||||||
switch (_pbs.HollowShape)
|
switch (_pbs.HollowShape)
|
||||||
{
|
{
|
||||||
|
|
||||||
case HollowShape.Same:
|
case HollowShape.Same:
|
||||||
case HollowShape.Triangle:
|
case HollowShape.Triangle:
|
||||||
// Equilateral Triangular Prism volume hollow calculation
|
// Equilateral Triangular Prism volume hollow calculation
|
||||||
|
@ -562,7 +544,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount);
|
hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
hollowVolume = 0;
|
hollowVolume = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -642,7 +623,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
public void setMass()
|
public void setMass()
|
||||||
{
|
{
|
||||||
if (Body != (IntPtr) 0)
|
if (Body != (IntPtr) 0)
|
||||||
|
@ -656,7 +636,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void disableBody()
|
public void disableBody()
|
||||||
{
|
{
|
||||||
//this kills the body so things like 'mesh' can re-create it.
|
//this kills the body so things like 'mesh' can re-create it.
|
||||||
|
@ -689,7 +668,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
|
|
||||||
|
|
||||||
//Kill Body so that mesh can re-make the geom
|
//Kill Body so that mesh can re-make the geom
|
||||||
if (IsPhysical && Body != (IntPtr) 0)
|
if (IsPhysical && Body != (IntPtr) 0)
|
||||||
{
|
{
|
||||||
|
@ -707,7 +685,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
3*sizeof (int));
|
3*sizeof (int));
|
||||||
d.GeomTriMeshDataPreprocess(_triMeshData);
|
d.GeomTriMeshDataPreprocess(_triMeshData);
|
||||||
|
|
||||||
|
|
||||||
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -719,7 +696,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
catch (AccessViolationException)
|
catch (AccessViolationException)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_log.Error("[PHYSICS]: MESH LOCKED");
|
m_log.Error("[PHYSICS]: MESH LOCKED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -730,14 +706,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_collisionscore = 0;
|
m_collisionscore = 0;
|
||||||
|
|
||||||
enableBody();
|
enableBody();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessTaints(float timestep)
|
public void ProcessTaints(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (m_taintadd)
|
if (m_taintadd)
|
||||||
{
|
{
|
||||||
changeadd(timestep);
|
changeadd(timestep);
|
||||||
|
@ -783,7 +756,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (!m_angularlock.IsIdentical(m_taintAngularLock,0))
|
if (!m_angularlock.IsIdentical(m_taintAngularLock,0))
|
||||||
changeAngularLock(timestep);
|
changeAngularLock(timestep);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -822,7 +794,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
private void changelink(float timestep)
|
private void changelink(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_parent == null && m_taintparent != null)
|
if (_parent == null && m_taintparent != null)
|
||||||
{
|
{
|
||||||
if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
|
if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
|
||||||
|
@ -836,7 +807,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.JointSetFixed(m_linkJoint);
|
d.JointSetFixed(m_linkJoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (_parent != null && m_taintparent == null)
|
else if (_parent != null && m_taintparent == null)
|
||||||
{
|
{
|
||||||
|
@ -845,20 +815,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
_linkJointGroup = (IntPtr)0;
|
_linkJointGroup = (IntPtr)0;
|
||||||
m_linkJoint = (IntPtr)0;
|
m_linkJoint = (IntPtr)0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_parent = m_taintparent;
|
_parent = m_taintparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeSelectedStatus(float timestep)
|
private void changeSelectedStatus(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_taintselected)
|
if (m_taintselected)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
m_collisionCategories = CollisionCategories.Selected;
|
m_collisionCategories = CollisionCategories.Selected;
|
||||||
m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
|
m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
|
||||||
|
|
||||||
|
@ -882,17 +847,14 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
disableBodySoft();
|
disableBodySoft();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
m_collisionCategories = CollisionCategories.Geom;
|
m_collisionCategories = CollisionCategories.Geom;
|
||||||
|
|
||||||
if (m_isphysical)
|
if (m_isphysical)
|
||||||
m_collisionCategories |= CollisionCategories.Body;
|
m_collisionCategories |= CollisionCategories.Body;
|
||||||
|
|
||||||
|
|
||||||
m_collisionFlags = m_default_collisionFlags;
|
m_collisionFlags = m_default_collisionFlags;
|
||||||
|
|
||||||
if (m_collidesLand)
|
if (m_collidesLand)
|
||||||
|
@ -910,42 +872,27 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.BodySetLinearVel(Body, 0f, 0f, 0f);
|
d.BodySetLinearVel(Body, 0f, 0f, 0f);
|
||||||
enableBodySoft();
|
enableBodySoft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resetCollisionAccounting();
|
resetCollisionAccounting();
|
||||||
m_isSelected = m_taintselected;
|
m_isSelected = m_taintselected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetTaints()
|
public void ResetTaints()
|
||||||
{
|
{
|
||||||
|
|
||||||
m_taintposition = _position;
|
m_taintposition = _position;
|
||||||
|
|
||||||
m_taintrot = _orientation;
|
m_taintrot = _orientation;
|
||||||
|
|
||||||
m_taintPhysics = m_isphysical;
|
m_taintPhysics = m_isphysical;
|
||||||
|
|
||||||
m_taintselected = m_isSelected;
|
m_taintselected = m_isSelected;
|
||||||
|
|
||||||
m_taintsize = _size;
|
m_taintsize = _size;
|
||||||
|
|
||||||
|
|
||||||
m_taintshape = false;
|
m_taintshape = false;
|
||||||
|
|
||||||
m_taintforce = false;
|
m_taintforce = false;
|
||||||
|
|
||||||
m_taintdisable = false;
|
m_taintdisable = false;
|
||||||
|
|
||||||
m_taintVelocity = PhysicsVector.Zero;
|
m_taintVelocity = PhysicsVector.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeadd(float timestep)
|
public void changeadd(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
|
int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
|
||||||
IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position);
|
IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position);
|
||||||
|
|
||||||
|
@ -954,12 +901,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
m_targetSpace = targetspace;
|
m_targetSpace = targetspace;
|
||||||
|
|
||||||
|
if (_mesh == null)
|
||||||
|
|
||||||
if (_mesh != null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (_parent_scene.needsMeshing(_pbs))
|
if (_parent_scene.needsMeshing(_pbs))
|
||||||
{
|
{
|
||||||
|
@ -983,8 +925,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
if (((_size.X / 2f) > 0f))
|
if (((_size.X / 2f) > 0f))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1065,13 +1005,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_isphysical && Body == (IntPtr)0)
|
if (m_isphysical && Body == (IntPtr)0)
|
||||||
{
|
{
|
||||||
enableBody();
|
enableBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_parent_scene.geom_name_map[prim_geom] = this.m_primName;
|
_parent_scene.geom_name_map[prim_geom] = this.m_primName;
|
||||||
|
@ -1080,14 +1017,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
changeSelectedStatus(timestep);
|
changeSelectedStatus(timestep);
|
||||||
|
|
||||||
m_taintadd = false;
|
m_taintadd = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changemove(float timestep)
|
public void changemove(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_isphysical)
|
if (m_isphysical)
|
||||||
{
|
{
|
||||||
// This is a fallback.. May no longer be necessary.
|
// This is a fallback.. May no longer be necessary.
|
||||||
|
@ -1115,7 +1048,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.BodyEnable(Body);
|
d.BodyEnable(Body);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1136,7 +1068,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
changeSelectedStatus(timestep);
|
changeSelectedStatus(timestep);
|
||||||
|
|
||||||
resetCollisionAccounting();
|
resetCollisionAccounting();
|
||||||
|
@ -1151,21 +1082,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (IsPhysical && Body != (IntPtr)0 && !m_isSelected)
|
if (IsPhysical && Body != (IntPtr)0 && !m_isSelected)
|
||||||
{
|
{
|
||||||
|
|
||||||
//float PID_P = 900.0f;
|
//float PID_P = 900.0f;
|
||||||
|
|
||||||
|
|
||||||
float m_mass = CalculateMass();
|
float m_mass = CalculateMass();
|
||||||
|
|
||||||
fz = 0f;
|
fz = 0f;
|
||||||
//m_log.Info(m_collisionFlags.ToString());
|
//m_log.Info(m_collisionFlags.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_buoyancy != 0)
|
if (m_buoyancy != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_buoyancy > 0)
|
if (m_buoyancy > 0)
|
||||||
{
|
{
|
||||||
fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass);
|
fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass);
|
||||||
|
@ -1177,8 +1102,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass));
|
fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_usePID)
|
if (m_usePID)
|
||||||
|
@ -1191,27 +1114,20 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// 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
|
// calculating base velocity to the current position
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((m_PIDTau < 1))
|
if ((m_PIDTau < 1))
|
||||||
{
|
{
|
||||||
PID_G = PID_G / m_PIDTau;
|
PID_G = PID_G / m_PIDTau;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((PID_G - m_PIDTau) <= 0)
|
if ((PID_G - m_PIDTau) <= 0)
|
||||||
{
|
{
|
||||||
PID_G = m_PIDTau + 1;
|
PID_G = m_PIDTau + 1;
|
||||||
}
|
}
|
||||||
//PidStatus = true;
|
//PidStatus = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PhysicsVector vec = new PhysicsVector();
|
PhysicsVector vec = new PhysicsVector();
|
||||||
d.Vector3 vel = d.BodyGetLinearVel(Body);
|
d.Vector3 vel = d.BodyGetLinearVel(Body);
|
||||||
|
|
||||||
|
|
||||||
d.Vector3 pos = d.BodyGetPosition(Body);
|
d.Vector3 pos = d.BodyGetPosition(Body);
|
||||||
_target_velocity =
|
_target_velocity =
|
||||||
new PhysicsVector(
|
new PhysicsVector(
|
||||||
|
@ -1220,20 +1136,17 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
(m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
|
(m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// if velocity is zero, use position control; otherwise, velocity control
|
// if velocity is zero, use position control; otherwise, velocity control
|
||||||
|
|
||||||
if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
|
if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
|
||||||
{
|
{
|
||||||
// keep track of where we stopped. No more slippin' & slidin'
|
// 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
|
// 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.
|
// react to the physics scene by moving it's position.
|
||||||
// Avatar to Avatar collisions
|
// Avatar to Avatar collisions
|
||||||
// Prim to avatar collisions
|
// Prim to avatar collisions
|
||||||
|
|
||||||
|
|
||||||
//fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
|
//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);
|
//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;
|
//fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
|
||||||
|
@ -1241,25 +1154,19 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.BodySetLinearVel(Body, 0, 0, 0);
|
d.BodySetLinearVel(Body, 0, 0, 0);
|
||||||
d.BodyAddForce(Body, 0, 0, fz);
|
d.BodyAddForce(Body, 0, 0, fz);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
_zeroFlag = false;
|
_zeroFlag = false;
|
||||||
|
|
||||||
// We're flying and colliding with something
|
// We're flying and colliding with something
|
||||||
fx = ((_target_velocity.X) - vel.X) * (PID_D);
|
fx = ((_target_velocity.X) - vel.X) * (PID_D);
|
||||||
fy = ((_target_velocity.Y) - vel.Y) * (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;
|
// 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);
|
fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fx *= m_mass;
|
fx *= m_mass;
|
||||||
|
@ -1285,8 +1192,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public void rotate(float timestep)
|
public void rotate(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
d.Quaternion myrot = new d.Quaternion();
|
d.Quaternion myrot = new d.Quaternion();
|
||||||
myrot.W = _orientation.w;
|
myrot.W = _orientation.w;
|
||||||
myrot.X = _orientation.x;
|
myrot.X = _orientation.x;
|
||||||
|
@ -1313,7 +1218,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public void changedisable(float timestep)
|
public void changedisable(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_disabled = true;
|
m_disabled = true;
|
||||||
if (Body != (IntPtr)0)
|
if (Body != (IntPtr)0)
|
||||||
{
|
{
|
||||||
|
@ -1321,14 +1225,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
Body = (IntPtr)0;
|
Body = (IntPtr)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_taintdisable = false;
|
m_taintdisable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePhysicsStatus(float timestep)
|
public void changePhysicsStatus(float timestep)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (m_isphysical == true)
|
if (m_isphysical == true)
|
||||||
{
|
{
|
||||||
if (Body == (IntPtr)0)
|
if (Body == (IntPtr)0)
|
||||||
|
@ -1366,7 +1267,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public void changesize(float timestamp)
|
public void changesize(float timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
//if (!_parent_scene.geom_name_map.ContainsKey(prim_geom))
|
//if (!_parent_scene.geom_name_map.ContainsKey(prim_geom))
|
||||||
//{
|
//{
|
||||||
// m_taintsize = _size;
|
// m_taintsize = _size;
|
||||||
|
@ -1418,7 +1318,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
myrot.Z = _orientation.z;
|
myrot.Z = _orientation.z;
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
|
|
||||||
|
|
||||||
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
||||||
if (IsPhysical && Body == (IntPtr)0)
|
if (IsPhysical && Body == (IntPtr)0)
|
||||||
{
|
{
|
||||||
|
@ -1520,7 +1419,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
myrot.Z = _orientation.z;
|
myrot.Z = _orientation.z;
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
|
|
||||||
|
|
||||||
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
||||||
if (IsPhysical && Body == (IntPtr) 0)
|
if (IsPhysical && Body == (IntPtr) 0)
|
||||||
{
|
{
|
||||||
|
@ -1559,7 +1457,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public void changeshape(float timestamp)
|
public void changeshape(float timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
string oldname = _parent_scene.geom_name_map[prim_geom];
|
string oldname = _parent_scene.geom_name_map[prim_geom];
|
||||||
|
|
||||||
// Cleanup of old prim geometry and Bodies
|
// Cleanup of old prim geometry and Bodies
|
||||||
|
@ -1596,14 +1493,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
myrot.Z = _orientation.z;
|
myrot.Z = _orientation.z;
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
|
|
||||||
|
|
||||||
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
||||||
if (IsPhysical && Body == (IntPtr)0)
|
if (IsPhysical && Body == (IntPtr)0)
|
||||||
{
|
{
|
||||||
// Re creates body on size.
|
// Re creates body on size.
|
||||||
// EnableBody also does setMass()
|
// EnableBody also does setMass()
|
||||||
enableBody();
|
enableBody();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1623,7 +1518,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
||||||
SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
|
SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1698,7 +1592,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
myrot.Z = _orientation.z;
|
myrot.Z = _orientation.z;
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
|
|
||||||
|
|
||||||
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
//d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
||||||
if (IsPhysical && Body == (IntPtr)0)
|
if (IsPhysical && Body == (IntPtr)0)
|
||||||
{
|
{
|
||||||
|
@ -1709,7 +1602,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_parent_scene.geom_name_map[prim_geom] = oldname;
|
_parent_scene.geom_name_map[prim_geom] = oldname;
|
||||||
|
|
||||||
changeSelectedStatus(timestamp);
|
changeSelectedStatus(timestamp);
|
||||||
|
@ -1722,9 +1614,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
if (!m_isSelected)
|
if (!m_isSelected)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lock (m_forcelist)
|
lock (m_forcelist)
|
||||||
{
|
{
|
||||||
//m_log.Info("[PHYSICS]: dequeing forcelist");
|
//m_log.Info("[PHYSICS]: dequeing forcelist");
|
||||||
|
@ -1741,19 +1630,17 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_forcelist.Clear();
|
m_forcelist.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_collisionscore = 0;
|
m_collisionscore = 0;
|
||||||
m_interpenetrationcount = 0;
|
m_interpenetrationcount = 0;
|
||||||
}
|
}
|
||||||
m_taintforce = false;
|
m_taintforce = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changevelocity(float timestep)
|
private void changevelocity(float timestep)
|
||||||
{
|
{
|
||||||
if (!m_isSelected)
|
if (!m_isSelected)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Thread.Sleep(20);
|
Thread.Sleep(20);
|
||||||
if (IsPhysical)
|
if (IsPhysical)
|
||||||
{
|
{
|
||||||
|
@ -1767,6 +1654,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
m_taintVelocity = PhysicsVector.Zero;
|
m_taintVelocity = PhysicsVector.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsPhysical
|
public override bool IsPhysical
|
||||||
{
|
{
|
||||||
get { return m_isphysical; }
|
get { return m_isphysical; }
|
||||||
|
@ -1974,10 +1862,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
public void UpdatePositionAndVelocity()
|
public void UpdatePositionAndVelocity()
|
||||||
{
|
{
|
||||||
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
|
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
|
||||||
if (_parent != null)
|
if (_parent == null)
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
PhysicsVector pv = new PhysicsVector(0, 0, 0);
|
PhysicsVector pv = new PhysicsVector(0, 0, 0);
|
||||||
bool lastZeroFlag = _zeroFlag;
|
bool lastZeroFlag = _zeroFlag;
|
||||||
|
@ -2173,6 +2058,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
public override void SetMomentum(PhysicsVector momentum)
|
public override void SetMomentum(PhysicsVector momentum)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } }
|
public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } }
|
||||||
public override bool PIDActive { set { m_usePID = value; } }
|
public override bool PIDActive { set { m_usePID = value; } }
|
||||||
public override float PIDTau { set { m_PIDTau = value; } }
|
public override float PIDTau { set { m_PIDTau = value; } }
|
||||||
|
@ -2188,8 +2074,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
Amotor = IntPtr.Zero;
|
Amotor = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float axisnum = 3;
|
float axisnum = 3;
|
||||||
|
|
||||||
axisnum = (axisnum - (axis.X + axis.Y + axis.Z));
|
axisnum = (axisnum - (axis.X + axis.Y + axis.Z));
|
||||||
|
@ -2217,17 +2101,17 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (axis.Z == 0)
|
if (axis.Z == 0)
|
||||||
{
|
{
|
||||||
d.JointSetAMotorAxis(Amotor, i, 0, 0, 0, 1);
|
d.JointSetAMotorAxis(Amotor, i, 0, 0, 0, 1);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < (int)axisnum; j++)
|
for (int j = 0; j < (int)axisnum; j++)
|
||||||
{
|
{
|
||||||
//d.JointSetAMotorAngle(Amotor, j, 0);
|
//d.JointSetAMotorAngle(Amotor, j, 0);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//d.JointSetAMotorAngle(Amotor, 1, 0);
|
//d.JointSetAMotorAngle(Amotor, 1, 0);
|
||||||
//d.JointSetAMotorAngle(Amotor, 2, 0);
|
//d.JointSetAMotorAngle(Amotor, 2, 0);
|
||||||
|
|
||||||
|
@ -2242,16 +2126,19 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
|
d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
|
||||||
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor);
|
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SubscribeEvents(int ms)
|
public override void SubscribeEvents(int ms)
|
||||||
{
|
{
|
||||||
m_eventsubscription = ms;
|
m_eventsubscription = ms;
|
||||||
_parent_scene.addCollisionEventReporting(this);
|
_parent_scene.addCollisionEventReporting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UnSubscribeEvents()
|
public override void UnSubscribeEvents()
|
||||||
{
|
{
|
||||||
_parent_scene.remCollisionEventReporting(this);
|
_parent_scene.remCollisionEventReporting(this);
|
||||||
m_eventsubscription = 0;
|
m_eventsubscription = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddCollisionEvent(uint CollidedWith, float depth)
|
public void AddCollisionEvent(uint CollidedWith, float depth)
|
||||||
{
|
{
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEventsThisFrame == null)
|
||||||
|
@ -2273,6 +2160,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
CollisionEventsThisFrame = new CollisionEventUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool SubscribedEvents()
|
public override bool SubscribedEvents()
|
||||||
{
|
{
|
||||||
if (m_eventsubscription > 0)
|
if (m_eventsubscription > 0)
|
||||||
|
|
Loading…
Reference in New Issue