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())
{
AddChange(changes.Velocity, value);
// _velocity = value;
}
else
{
@ -676,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (value.IsFinite())
{
m_rotationalVelocity = value;
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
AddChange(changes.AngVelocity, value);
}
else
{
@ -687,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
public override float Buoyancy
{
get { return m_buoyancy; }
@ -1737,17 +1732,14 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAutoDisableFlag(Body, true);
d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
// d.BodySetLinearDampingThreshold(Body, 0.01f);
// d.BodySetAngularDampingThreshold(Body, 0.001f);
d.BodySetDamping(Body, .002f, .002f);
if (m_targetSpace != IntPtr.Zero)
{
_parent_scene.waitForSpaceUnlock(m_targetSpace);
if (d.SpaceQuery(m_targetSpace, prim_geom))
d.SpaceRemove(m_targetSpace, prim_geom);
}
d.BodySetDamping(Body, .005f, .005f);
if (m_targetSpace != IntPtr.Zero)
{
_parent_scene.waitForSpaceUnlock(m_targetSpace);
if (d.SpaceQuery(m_targetSpace, prim_geom))
d.SpaceRemove(m_targetSpace, prim_geom);
}
if (childrenPrim.Count == 0)
{
@ -3296,6 +3288,13 @@ namespace OpenSim.Region.Physics.OdePlugin
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 (Body != IntPtr.Zero)
@ -3312,6 +3311,33 @@ namespace OpenSim.Region.Physics.OdePlugin
_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)
{
m_isVolumeDetect = newVolDtc;
@ -3948,9 +3974,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// case changes.Acceleration:
// changeacceleration((Vector3)arg);
// break;
// case changes.AngVelocity:
// changeangvelocity((Vector3)arg);
// break;
case changes.AngVelocity:
changeangvelocity((Vector3)arg);
break;
case changes.Force:
changeForce((Vector3)arg);