let rotationVelocity or AngularVelocity be setted on prims. Limited to

12rad/s
avinationmerge
UbitUmarov 2012-07-10 05:11:06 +01:00
parent 0d60568564
commit ca41ec9eb4
1 changed files with 46 additions and 19 deletions

View File

@ -583,8 +583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (value.IsFinite()) if (value.IsFinite())
{ {
AddChange(changes.Velocity, value); AddChange(changes.Velocity, value);
// _velocity = value;
} }
else else
{ {
@ -676,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (value.IsFinite()) if (value.IsFinite())
{ {
m_rotationalVelocity = value; AddChange(changes.AngVelocity, value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
} }
else else
{ {
@ -687,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override float Buoyancy public override float Buoyancy
{ {
get { return m_buoyancy; } get { return m_buoyancy; }
@ -1737,9 +1732,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAutoDisableFlag(Body, true); d.BodySetAutoDisableFlag(Body, true);
d.BodySetAutoDisableSteps(Body, body_autodisable_frames); d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
// d.BodySetLinearDampingThreshold(Body, 0.01f); d.BodySetDamping(Body, .005f, .005f);
// d.BodySetAngularDampingThreshold(Body, 0.001f);
d.BodySetDamping(Body, .002f, .002f);
if (m_targetSpace != IntPtr.Zero) if (m_targetSpace != IntPtr.Zero)
{ {
@ -1748,7 +1741,6 @@ namespace OpenSim.Region.Physics.OdePlugin
d.SpaceRemove(m_targetSpace, prim_geom); d.SpaceRemove(m_targetSpace, prim_geom);
} }
if (childrenPrim.Count == 0) if (childrenPrim.Count == 0)
{ {
collide_geom = prim_geom; collide_geom = prim_geom;
@ -3296,6 +3288,13 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changevelocity(Vector3 newVel) private void changevelocity(Vector3 newVel)
{ {
float len = newVel.LengthSquared();
if (len > 100000.0f) // limit to 100m/s
{
len = 100.0f / (float)Math.Sqrt(len);
newVel *= len;
}
if (!m_isSelected) if (!m_isSelected)
{ {
if (Body != IntPtr.Zero) if (Body != IntPtr.Zero)
@ -3312,6 +3311,33 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity = newVel; _velocity = newVel;
} }
private void changeangvelocity(Vector3 newAngVel)
{
float len = newAngVel.LengthSquared();
if (len > 144.0f) // limit to 12rad/s
{
len = 12.0f / (float)Math.Sqrt(len);
newAngVel *= len;
}
if (!m_isSelected)
{
if (Body != IntPtr.Zero)
{
if (m_disabled)
enableBodySoft();
else if (!d.BodyIsEnabled(Body))
d.BodyEnable(Body);
d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
}
//resetCollisionAccounting();
}
m_rotationalVelocity = newAngVel;
}
private void changeVolumedetetion(bool newVolDtc) private void changeVolumedetetion(bool newVolDtc)
{ {
m_isVolumeDetect = newVolDtc; m_isVolumeDetect = newVolDtc;
@ -3948,9 +3974,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// case changes.Acceleration: // case changes.Acceleration:
// changeacceleration((Vector3)arg); // changeacceleration((Vector3)arg);
// break; // break;
// case changes.AngVelocity:
// changeangvelocity((Vector3)arg); case changes.AngVelocity:
// break; changeangvelocity((Vector3)arg);
break;
case changes.Force: case changes.Force:
changeForce((Vector3)arg); changeForce((Vector3)arg);