aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2012-04-17 16:49:08 +0100
committerUbitUmarov2012-04-17 16:49:08 +0100
commit9464fcebcd9f0a9b1846113e8aff56ea3f49ace2 (patch)
treebef6efbc0bb8db3af312f0dbbda2eba40155dfc8 /OpenSim/Region
parentubitODE: - character managed ode was only getting position etc from unmanaged... (diff)
downloadopensim-SC-9464fcebcd9f0a9b1846113e8aff56ea3f49ace2.zip
opensim-SC-9464fcebcd9f0a9b1846113e8aff56ea3f49ace2.tar.gz
opensim-SC-9464fcebcd9f0a9b1846113e8aff56ea3f49ace2.tar.bz2
opensim-SC-9464fcebcd9f0a9b1846113e8aff56ea3f49ace2.tar.xz
ubitODE: prims - update managed dinamic parameters from unmanaged at ODE rate and not heartbeat.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs124
1 files changed, 46 insertions, 78 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 32c4722..5467b9f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -3228,17 +3228,13 @@ namespace OpenSim.Region.Physics.OdePlugin
3228 { 3228 {
3229 if (!childPrim && m_isphysical && Body != IntPtr.Zero && 3229 if (!childPrim && m_isphysical && Body != IntPtr.Zero &&
3230 !m_disabled && !m_isSelected && !m_building && !m_outbounds) 3230 !m_disabled && !m_isSelected && !m_building && !m_outbounds)
3231 // !m_disabled && !m_isSelected && !m_building && !m_outbounds)
3232 { 3231 {
3233 // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009
3234
3235 if (d.BodyIsEnabled(Body)) 3232 if (d.BodyIsEnabled(Body))
3236 { 3233 {
3237 float timestep = _parent_scene.ODE_STEPSIZE; 3234 float timestep = _parent_scene.ODE_STEPSIZE;
3238 3235
3239 // check outside region 3236 // check outside region
3240 d.Vector3 lpos; 3237 d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator
3241 d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator
3242 3238
3243 if (lpos.Z < -100 || lpos.Z > 100000f) 3239 if (lpos.Z < -100 || lpos.Z > 100000f)
3244 { 3240 {
@@ -3321,12 +3317,9 @@ namespace OpenSim.Region.Physics.OdePlugin
3321 { 3317 {
3322 // 'VEHICLES' are dealt with in ODEDynamics.cs 3318 // 'VEHICLES' are dealt with in ODEDynamics.cs
3323 m_vehicle.Step(); 3319 m_vehicle.Step();
3324 return;
3325 } 3320 }
3326
3327 else 3321 else
3328 { 3322 {
3329
3330 float fx = 0; 3323 float fx = 0;
3331 float fy = 0; 3324 float fy = 0;
3332 float fz = 0; 3325 float fz = 0;
@@ -3512,10 +3505,39 @@ namespace OpenSim.Region.Physics.OdePlugin
3512 { 3505 {
3513 d.BodyAddTorque(Body, trq.X, trq.Y, trq.Z); 3506 d.BodyAddTorque(Body, trq.X, trq.Y, trq.Z);
3514 } 3507 }
3515
3516 } 3508 }
3509
3510 // update our ideia of velocities and acelerations
3511 d.Quaternion ori;
3512 d.Vector3 dtmpu;
3513
3514 _position.X = lpos.X;
3515 _position.Y = lpos.Y;
3516 _position.Z = lpos.Z;
3517
3518 d.GeomCopyQuaternion(prim_geom, out ori);
3519 _orientation.X = ori.X;
3520 _orientation.Y = ori.Y;
3521 _orientation.Z = ori.Z;
3522 _orientation.W = ori.W;
3523
3524 _acceleration = _velocity;
3525
3526 dtmpu = d.BodyGetLinearVel(Body);
3527 _velocity.X = dtmpu.X;
3528 _velocity.Y = dtmpu.Y;
3529 _velocity.Z = dtmpu.Z;
3530
3531 float invts = 1 / timestep;
3532 _acceleration = (_velocity - _acceleration) * invts;
3533
3534 dtmpu = d.BodyGetAngularVel(Body);
3535 m_rotationalVelocity.X = dtmpu.X;
3536 m_rotationalVelocity.Y = dtmpu.Y;
3537 m_rotationalVelocity.Z = dtmpu.Z;
3517 } 3538 }
3518 else // body disabled 3539
3540 else // body disabled/sleeping
3519 { 3541 {
3520 // let vehicles sleep 3542 // let vehicles sleep
3521 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 3543 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
@@ -3546,36 +3568,23 @@ namespace OpenSim.Region.Physics.OdePlugin
3546 { 3568 {
3547 if (Body != IntPtr.Zero) 3569 if (Body != IntPtr.Zero)
3548 { 3570 {
3549 Vector3 pv = Vector3.Zero;
3550 bool lastZeroFlag = _zeroFlag; 3571 bool lastZeroFlag = _zeroFlag;
3551 3572
3552 d.Vector3 lpos; 3573 if ((Math.Abs(m_lastposition.X - _position.X) < 0.01)
3553 d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator 3574 && (Math.Abs(m_lastposition.Y - _position.Y) < 0.01)
3554 3575 && (Math.Abs(m_lastposition.Z - _position.Z) < 0.01)
3555 3576 && (Math.Abs(m_lastorientation.X - _orientation.X) < 0.0001)
3556 d.Quaternion ori; 3577 && (Math.Abs(m_lastorientation.Y - _orientation.Y) < 0.0001)
3557 d.GeomCopyQuaternion(prim_geom, out ori); 3578 && (Math.Abs(m_lastorientation.Z - _orientation.Z) < 0.0001)
3558 d.Vector3 vel = d.BodyGetLinearVel(Body);
3559 d.Vector3 rotvel = d.BodyGetAngularVel(Body);
3560
3561 if ((Math.Abs(m_lastposition.X - lpos.X) < 0.01)
3562 && (Math.Abs(m_lastposition.Y - lpos.Y) < 0.01)
3563 && (Math.Abs(m_lastposition.Z - lpos.Z) < 0.01)
3564 && (Math.Abs(m_lastorientation.X - ori.X) < 0.0001)
3565 && (Math.Abs(m_lastorientation.Y - ori.Y) < 0.0001)
3566 && (Math.Abs(m_lastorientation.Z - ori.Z) < 0.0001)
3567 ) 3579 )
3568 { 3580 {
3569 _zeroFlag = true; 3581 _zeroFlag = true;
3570 //Console.WriteLine("ZFT 2");
3571 m_throttleUpdates = false; 3582 m_throttleUpdates = false;
3572 } 3583 }
3573 else 3584 else
3574 { 3585 {
3575 //m_log.Debug(Math.Abs(m_lastposition.X - l_position.X).ToString());
3576 _zeroFlag = false; 3586 _zeroFlag = false;
3577 m_lastUpdateSent = false; 3587 m_lastUpdateSent = false;
3578 //m_throttleUpdates = false;
3579 } 3588 }
3580 3589
3581 if (_zeroFlag) 3590 if (_zeroFlag)
@@ -3583,22 +3592,14 @@ namespace OpenSim.Region.Physics.OdePlugin
3583 m_lastposition = _position; 3592 m_lastposition = _position;
3584 m_lastorientation = _orientation; 3593 m_lastorientation = _orientation;
3585 3594
3586 _velocity.X = 0.0f; 3595 _velocity = Vector3.Zero;
3587 _velocity.Y = 0.0f; 3596 _acceleration = Vector3.Zero;
3588 _velocity.Z = 0.0f; 3597 m_rotationalVelocity = Vector3.Zero;
3589 3598
3590 _acceleration.X = 0;
3591 _acceleration.Y = 0;
3592 _acceleration.Z = 0;
3593
3594 m_rotationalVelocity.X = 0;
3595 m_rotationalVelocity.Y = 0;
3596 m_rotationalVelocity.Z = 0;
3597 if (!m_lastUpdateSent) 3599 if (!m_lastUpdateSent)
3598 { 3600 {
3599 m_throttleUpdates = false; 3601 m_throttleUpdates = false;
3600 throttleCounter = 0; 3602 throttleCounter = 0;
3601 m_rotationalVelocity = pv;
3602 3603
3603 base.RequestPhysicsterseUpdate(); 3604 base.RequestPhysicsterseUpdate();
3604 3605
@@ -3612,39 +3613,12 @@ namespace OpenSim.Region.Physics.OdePlugin
3612 base.RequestPhysicsterseUpdate(); 3613 base.RequestPhysicsterseUpdate();
3613 } 3614 }
3614 3615
3615 m_lastVelocity = _velocity;
3616
3617 _position.X = lpos.X;
3618 _position.Y = lpos.Y;
3619 _position.Z = lpos.Z;
3620
3621 _velocity.X = vel.X;
3622 _velocity.Y = vel.Y;
3623 _velocity.Z = vel.Z;
3624
3625 _orientation.X = ori.X;
3626 _orientation.Y = ori.Y;
3627 _orientation.Z = ori.Z;
3628 _orientation.W = ori.W;
3629
3630 _acceleration = ((_velocity - m_lastVelocity) / simulatedtime);
3631
3632 if (m_rotationalVelocity.ApproxEquals(pv, 0.0001f))
3633 {
3634 m_rotationalVelocity = pv;
3635 }
3636 else
3637 {
3638 m_rotationalVelocity.X = rotvel.X;
3639 m_rotationalVelocity.Y = rotvel.Y;
3640 m_rotationalVelocity.Z = rotvel.Z;
3641 }
3642
3643 m_lastUpdateSent = false; 3616 m_lastUpdateSent = false;
3644 if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate) 3617 if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate)
3645 { 3618 {
3646 m_lastposition = _position; 3619 m_lastposition = _position;
3647 m_lastorientation = _orientation; 3620 m_lastorientation = _orientation;
3621 m_lastVelocity = _velocity;
3648 base.RequestPhysicsterseUpdate(); 3622 base.RequestPhysicsterseUpdate();
3649 } 3623 }
3650 else 3624 else
@@ -3656,17 +3630,11 @@ namespace OpenSim.Region.Physics.OdePlugin
3656 else if (!m_lastUpdateSent || !_zeroFlag) 3630 else if (!m_lastUpdateSent || !_zeroFlag)
3657 { 3631 {
3658 // Not a body.. so Make sure the client isn't interpolating 3632 // Not a body.. so Make sure the client isn't interpolating
3659 _velocity.X = 0; 3633 _velocity = Vector3.Zero;
3660 _velocity.Y = 0; 3634 _acceleration = Vector3.Zero;
3661 _velocity.Z = 0; 3635 m_rotationalVelocity = Vector3.Zero;
3662 3636 m_lastVelocity = Vector3.Zero;
3663 _acceleration.X = 0;
3664 _acceleration.Y = 0;
3665 _acceleration.Z = 0;
3666 3637
3667 m_rotationalVelocity.X = 0;
3668 m_rotationalVelocity.Y = 0;
3669 m_rotationalVelocity.Z = 0;
3670 _zeroFlag = true; 3638 _zeroFlag = true;
3671 3639
3672 if (!m_lastUpdateSent) 3640 if (!m_lastUpdateSent)