* Tweak the character controller some more
* Add cursory integration with script engine. * LLMoveToTarget, LLSetBouyancy, LLSetStatus (Physical only), LLApplyImpulse, LLApplyTorque, LLPushObject.. etc. * Still missing linked physical active and LLSetStatus with an axis lock.0.6.5-rc1
parent
b664566b8f
commit
10f5615573
|
@ -963,7 +963,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
if (m_flying)
|
if (m_flying)
|
||||||
{
|
{
|
||||||
// Slight PID correction
|
// Slight PID correction
|
||||||
vec.Z += (((-1 * m_parent_scene.gravityz) * m_mass) * 0.035f);
|
vec.Z += (((-1 * m_parent_scene.gravityz) * m_mass) * 0.06f);
|
||||||
|
|
||||||
|
|
||||||
//auto fly height. Kitto Flora
|
//auto fly height. Kitto Flora
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private PhysicsVector _position;
|
private PhysicsVector _position;
|
||||||
|
private PhysicsVector m_zeroPosition;
|
||||||
private PhysicsVector _velocity;
|
private PhysicsVector _velocity;
|
||||||
private PhysicsVector _torque = new PhysicsVector(0, 0, 0);
|
private PhysicsVector _torque = new PhysicsVector(0, 0, 0);
|
||||||
private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f);
|
private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -168,6 +169,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
private btVector3 tempAngularVelocity2;
|
private btVector3 tempAngularVelocity2;
|
||||||
private btVector3 tempInertia1;
|
private btVector3 tempInertia1;
|
||||||
private btVector3 tempInertia2;
|
private btVector3 tempInertia2;
|
||||||
|
private btVector3 tempAddForce;
|
||||||
private btQuaternion tempOrientation1;
|
private btQuaternion tempOrientation1;
|
||||||
private btQuaternion tempOrientation2;
|
private btQuaternion tempOrientation2;
|
||||||
private btMotionState tempMotionState1;
|
private btMotionState tempMotionState1;
|
||||||
|
@ -870,6 +872,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
m_log.Debug("[PHYSICS]: _________ChangeMove");
|
m_log.Debug("[PHYSICS]: _________ChangeMove");
|
||||||
|
if (!m_isphysical)
|
||||||
|
{
|
||||||
tempTransform2 = Body.getWorldTransform();
|
tempTransform2 = Body.getWorldTransform();
|
||||||
btQuaternion quat = tempTransform2.getRotation();
|
btQuaternion quat = tempTransform2.getRotation();
|
||||||
tempPosition2.setValue(_position.X, _position.Y, _position.Z);
|
tempPosition2.setValue(_position.X, _position.Y, _position.Z);
|
||||||
|
@ -880,6 +884,47 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
changeSelectedStatus(timestep);
|
changeSelectedStatus(timestep);
|
||||||
|
|
||||||
resetCollisionAccounting();
|
resetCollisionAccounting();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Body != null)
|
||||||
|
{
|
||||||
|
if (Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
_parent_scene.removeFromWorld(this, Body);
|
||||||
|
//Body.Dispose();
|
||||||
|
}
|
||||||
|
//Body = null;
|
||||||
|
// TODO: dispose parts that make up body
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (_parent_scene.needsMeshing(_pbs))
|
||||||
|
{
|
||||||
|
// Don't need to re-enable body.. it's done in SetMesh
|
||||||
|
float meshlod = _parent_scene.meshSculptLOD;
|
||||||
|
|
||||||
|
if (IsPhysical)
|
||||||
|
meshlod = _parent_scene.MeshSculptphysicalLOD;
|
||||||
|
|
||||||
|
IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
|
||||||
|
// createmesh returns null when it doesn't mesh.
|
||||||
|
CreateGeom(IntPtr.Zero, mesh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mesh = null;
|
||||||
|
CreateGeom(IntPtr.Zero, null);
|
||||||
|
}
|
||||||
|
SetCollisionShape(prim_geom);
|
||||||
|
*/
|
||||||
|
if (m_isphysical)
|
||||||
|
SetBody(Mass);
|
||||||
|
else
|
||||||
|
SetBody(0);
|
||||||
|
changeSelectedStatus(timestep);
|
||||||
|
|
||||||
|
resetCollisionAccounting();
|
||||||
|
}
|
||||||
m_taintposition = _position;
|
m_taintposition = _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,17 +1135,88 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
|
|
||||||
private void changeAddForce(float timestep)
|
private void changeAddForce(float timestep)
|
||||||
{
|
{
|
||||||
// TODO: throw new NotImplementedException();
|
if (!m_isSelected)
|
||||||
|
{
|
||||||
|
lock (m_forcelist)
|
||||||
|
{
|
||||||
|
//m_log.Info("[PHYSICS]: dequeing forcelist");
|
||||||
|
if (IsPhysical)
|
||||||
|
{
|
||||||
|
PhysicsVector iforce = new PhysicsVector();
|
||||||
|
for (int i = 0; i < m_forcelist.Count; i++)
|
||||||
|
{
|
||||||
|
iforce = iforce + m_forcelist[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Body != null && Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
if (tempAddForce != null && tempAddForce.Handle != IntPtr.Zero)
|
||||||
|
tempAddForce.Dispose();
|
||||||
|
enableBodySoft();
|
||||||
|
tempAddForce = new btVector3(iforce.X, iforce.Y, iforce.Z);
|
||||||
|
Body.applyCentralImpulse(tempAddForce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_forcelist.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_collisionscore = 0;
|
||||||
|
m_interpenetrationcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_taintforce = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeAddAngularForce(float timestep)
|
private void changeAddAngularForce(float timestep)
|
||||||
{
|
{
|
||||||
// TODO: throw new NotImplementedException();
|
if (!m_isSelected)
|
||||||
|
{
|
||||||
|
lock (m_angularforcelist)
|
||||||
|
{
|
||||||
|
//m_log.Info("[PHYSICS]: dequeing forcelist");
|
||||||
|
if (IsPhysical)
|
||||||
|
{
|
||||||
|
PhysicsVector iforce = new PhysicsVector();
|
||||||
|
for (int i = 0; i < m_angularforcelist.Count; i++)
|
||||||
|
{
|
||||||
|
iforce = iforce + m_angularforcelist[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Body != null && Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
if (tempAddForce != null && tempAddForce.Handle != IntPtr.Zero)
|
||||||
|
tempAddForce.Dispose();
|
||||||
|
enableBodySoft();
|
||||||
|
tempAddForce = new btVector3(iforce.X, iforce.Y, iforce.Z);
|
||||||
|
Body.applyTorqueImpulse(tempAddForce);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
m_angularforcelist.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_collisionscore = 0;
|
||||||
|
m_interpenetrationcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_taintaddangularforce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeSetTorque(float timestep)
|
private void changeSetTorque(float timestep)
|
||||||
{
|
{
|
||||||
// TODO: throw new NotImplementedException();
|
if (!m_isSelected)
|
||||||
|
{
|
||||||
|
if (IsPhysical)
|
||||||
|
{
|
||||||
|
if (Body != null && Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
tempAngularVelocity2.setValue(m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
|
||||||
|
Body.applyTorque(tempAngularVelocity2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_taintTorque = new PhysicsVector(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changedisable(float timestep)
|
private void changedisable(float timestep)
|
||||||
|
@ -1113,10 +1229,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
// TODO: throw new NotImplementedException();
|
// TODO: throw new NotImplementedException();
|
||||||
if (m_taintselected)
|
if (m_taintselected)
|
||||||
{
|
{
|
||||||
|
Body.setCollisionFlags((int)ContactFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
disableBodySoft();
|
disableBodySoft();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Body.setCollisionFlags(0);
|
||||||
enableBodySoft();
|
enableBodySoft();
|
||||||
}
|
}
|
||||||
m_isSelected = m_taintselected;
|
m_isSelected = m_taintselected;
|
||||||
|
@ -1125,7 +1244,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
|
|
||||||
private void changevelocity(float timestep)
|
private void changevelocity(float timestep)
|
||||||
{
|
{
|
||||||
// TODO: throw new NotImplementedException();
|
if (!m_isSelected)
|
||||||
|
{
|
||||||
|
if (IsPhysical)
|
||||||
|
{
|
||||||
|
if (Body != null && Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
tempLinearVelocity2.setValue(m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
|
||||||
|
Body.setLinearVelocity(tempLinearVelocity2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//resetCollisionAccounting();
|
||||||
|
}
|
||||||
|
m_taintVelocity = PhysicsVector.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changelink(float timestep)
|
private void changelink(float timestep)
|
||||||
|
@ -1165,23 +1297,25 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
{
|
{
|
||||||
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) * 0.035f;
|
||||||
|
|
||||||
//d.Vector3 l_velocity = d.BodyGetLinearVel(Body);
|
//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());
|
//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));
|
fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass) * 0.035f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_usePID)
|
if (m_usePID)
|
||||||
{
|
{
|
||||||
|
PID_D = 61f;
|
||||||
|
PID_G = 65f;
|
||||||
//if (!d.BodyIsEnabled(Body))
|
//if (!d.BodyIsEnabled(Body))
|
||||||
//d.BodySetForce(Body, 0f, 0f, 0f);
|
//d.BodySetForce(Body, 0f, 0f, 0f);
|
||||||
// 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) * m_mass;
|
fz = ((-1 * _parent_scene.gravityz) * m_mass) * 1.025f;
|
||||||
|
|
||||||
// no lock; for now it's only called from within Simulate()
|
// no lock; for now it's only called from within Simulate()
|
||||||
|
|
||||||
|
@ -1202,8 +1336,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
// TODO: NEED btVector3 for Linear Velocity
|
// TODO: NEED btVector3 for Linear Velocity
|
||||||
// NEED btVector3 for Position
|
// NEED btVector3 for Position
|
||||||
|
|
||||||
PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet
|
PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet
|
||||||
PhysicsVector vel = new PhysicsVector(0, 0, 0);
|
PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z);
|
||||||
|
|
||||||
_target_velocity =
|
_target_velocity =
|
||||||
new PhysicsVector(
|
new PhysicsVector(
|
||||||
|
@ -1301,6 +1435,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
|
d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
|
||||||
d.BodyAddForce(Body, 0, 0, fz);
|
d.BodyAddForce(Body, 0, 0, fz);
|
||||||
*/
|
*/
|
||||||
|
if (Body != null && Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Body.setLinearVelocity(_parent_scene.VectorZero);
|
||||||
|
Body.clearForces();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1349,11 +1488,22 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
|
|
||||||
// TODO: Do Bullet Equiv
|
// TODO: Do Bullet Equiv
|
||||||
// d.BodyAddForce(Body, fx, fy, fz);
|
// d.BodyAddForce(Body, fx, fy, fz);
|
||||||
|
if (Body != null && Body.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Body.activate(true);
|
||||||
|
if (tempAddForce != null && tempAddForce.Handle != IntPtr.Zero)
|
||||||
|
tempAddForce.Dispose();
|
||||||
|
|
||||||
|
tempAddForce = new btVector3(fx * 0.01f, fy * 0.01f, fz * 0.01f);
|
||||||
|
Body.applyCentralImpulse(tempAddForce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// _zeroPosition = d.BodyGetPosition(Body);
|
if (m_zeroPosition == null)
|
||||||
|
m_zeroPosition = new PhysicsVector(0, 0, 0);
|
||||||
|
m_zeroPosition.setValues(_position.X,_position.Y,_position.Z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2065,6 +2215,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePositionAndVelocity()
|
public void UpdatePositionAndVelocity()
|
||||||
|
{
|
||||||
|
if (!m_isSelected)
|
||||||
{
|
{
|
||||||
if (_parent == null)
|
if (_parent == null)
|
||||||
{
|
{
|
||||||
|
@ -2092,7 +2244,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
|
tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
|
||||||
tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
|
tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
|
||||||
|
|
||||||
_torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), tempAngularVelocity1.getZ());
|
_torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(),
|
||||||
|
tempAngularVelocity1.getZ());
|
||||||
PhysicsVector l_position = new PhysicsVector();
|
PhysicsVector l_position = new PhysicsVector();
|
||||||
Quaternion l_orientation = new Quaternion();
|
Quaternion l_orientation = new Quaternion();
|
||||||
m_lastposition = _position;
|
m_lastposition = _position;
|
||||||
|
@ -2218,7 +2371,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
_velocity.Z = tempLinearVelocity1.getZ();
|
_velocity.Z = tempLinearVelocity1.getZ();
|
||||||
|
|
||||||
_acceleration = ((_velocity - m_lastVelocity)/0.1f);
|
_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);
|
_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());
|
//m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
|
||||||
|
|
||||||
if (_velocity.IsIdentical(pv, 0.5f))
|
if (_velocity.IsIdentical(pv, 0.5f))
|
||||||
|
@ -2228,7 +2383,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ());
|
m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(),
|
||||||
|
tempAngularVelocity1.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
//m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
|
//m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
|
||||||
|
@ -2274,6 +2430,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
|
||||||
_zeroFlag = true;
|
_zeroFlag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void setPrimForRemoval()
|
internal void setPrimForRemoval()
|
||||||
|
|
Loading…
Reference in New Issue