aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorUbitUmarov2017-07-10 19:31:35 +0100
committerUbitUmarov2017-07-10 19:31:35 +0100
commit9dbcb4e5f687f576ec23794cdf85b41130fea0b0 (patch)
treea44af36ec32b633fc83d434ce93325facbd8901e /OpenSim/Region/Framework
parentfix the name of a funtion on last commit (diff)
downloadopensim-SC_OLD-9dbcb4e5f687f576ec23794cdf85b41130fea0b0.zip
opensim-SC_OLD-9dbcb4e5f687f576ec23794cdf85b41130fea0b0.tar.gz
opensim-SC_OLD-9dbcb4e5f687f576ec23794cdf85b41130fea0b0.tar.bz2
opensim-SC_OLD-9dbcb4e5f687f576ec23794cdf85b41130fea0b0.tar.xz
on entities updates throttles vectors needed to be compared as vectors, not just their norms
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs133
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs15
2 files changed, 116 insertions, 32 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f9699b1..576a013 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -369,9 +369,9 @@ namespace OpenSim.Region.Framework.Scenes
369 protected Vector3 m_lastPosition; 369 protected Vector3 m_lastPosition;
370 protected Quaternion m_lastRotation; 370 protected Quaternion m_lastRotation;
371 protected Vector3 m_lastVelocity; 371 protected Vector3 m_lastVelocity;
372 protected Vector3 m_lastAcceleration; 372 protected Vector3 m_lastAcceleration; // acceleration is a derived var with high noise
373 protected Vector3 m_lastAngularVelocity; 373 protected Vector3 m_lastAngularVelocity;
374 protected int m_lastUpdateSentTime; 374 protected double m_lastUpdateSentTime;
375 protected float m_buoyancy = 0.0f; 375 protected float m_buoyancy = 0.0f;
376 protected Vector3 m_force; 376 protected Vector3 m_force;
377 protected Vector3 m_torque; 377 protected Vector3 m_torque;
@@ -2875,7 +2875,7 @@ namespace OpenSim.Region.Framework.Scenes
2875 2875
2876 public void PhysicsCollision(EventArgs e) 2876 public void PhysicsCollision(EventArgs e)
2877 { 2877 {
2878 if (ParentGroup.Scene == null || ParentGroup.IsDeleted) 2878 if (ParentGroup.Scene == null || ParentGroup.IsDeleted || ParentGroup.inTransit)
2879 return; 2879 return;
2880 2880
2881 // this a thread from physics ( heartbeat ) 2881 // this a thread from physics ( heartbeat )
@@ -3331,7 +3331,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3331 m_lastVelocity = Velocity; 3331 m_lastVelocity = Velocity;
3332 m_lastAcceleration = Acceleration; 3332 m_lastAcceleration = Acceleration;
3333 m_lastAngularVelocity = AngularVelocity; 3333 m_lastAngularVelocity = AngularVelocity;
3334 m_lastUpdateSentTime = Environment.TickCount; 3334 m_lastUpdateSentTime = Util.GetTimeStampMS();
3335 3335
3336 ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) 3336 ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
3337 { 3337 {
@@ -3350,7 +3350,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3350 m_lastVelocity = Velocity; 3350 m_lastVelocity = Velocity;
3351 m_lastAcceleration = Acceleration; 3351 m_lastAcceleration = Acceleration;
3352 m_lastAngularVelocity = AngularVelocity; 3352 m_lastAngularVelocity = AngularVelocity;
3353 m_lastUpdateSentTime = Environment.TickCount; 3353 m_lastUpdateSentTime = Util.GetTimeStampMS();
3354 3354
3355 if (ParentGroup.IsAttachment) 3355 if (ParentGroup.IsAttachment)
3356 { 3356 {
@@ -3396,31 +3396,122 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3396 ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); 3396 ParentGroup.Scene.StatsReporter.AddObjectUpdates(1);
3397 } 3397 }
3398 3398
3399
3399 /// <summary> 3400 /// <summary>
3400 /// Tell all the prims which have had updates scheduled 3401 /// Tell all the prims which have had updates scheduled
3401 /// </summary> 3402 /// </summary>
3402 public void SendScheduledUpdates() 3403 public void SendScheduledUpdates()
3403 { 3404 {
3404 const float ROTATION_TOLERANCE = 0.01f; 3405 const float ROTATION_TOLERANCE = 0.01f;
3405 const float VELOCITY_TOLERANCE = 0.001f; 3406 const float VELOCITY_TOLERANCE = 0.1f; // terse update vel has low resolution
3406 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary 3407 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
3407 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. 3408 const double TIME_MS_TOLERANCE = 200f; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
3408 3409
3409 switch (UpdateFlag) 3410 switch (UpdateFlag)
3410 { 3411 {
3412 // this is wrong we need to get back to this
3411 case UpdateRequired.TERSE: 3413 case UpdateRequired.TERSE:
3412 { 3414 {
3413 ClearUpdateSchedule(); 3415 ClearUpdateSchedule();
3414 // Throw away duplicate or insignificant updates 3416
3415 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || 3417 bool needupdate = true;
3416 !Acceleration.Equals(m_lastAcceleration) || 3418 double now = Util.GetTimeStampMS();
3417 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 3419 Vector3 curvel = Velocity;
3418 Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || 3420 Vector3 curacc = Acceleration;
3419 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || 3421 Vector3 angvel = AngularVelocity;
3420 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 3422
3421 Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) 3423 while(true) // just to avoid ugly goto
3422 { 3424 {
3423 SendTerseUpdateToAllClientsInternal(); 3425 double elapsed = now - m_lastUpdateSentTime;
3426
3427 // minimal rate also for the other things on terse updates
3428 if (elapsed > TIME_MS_TOLERANCE)
3429 break;
3430
3431 if( Math.Abs(curacc.X - m_lastAcceleration.X) > VELOCITY_TOLERANCE ||
3432 Math.Abs(curacc.Y - m_lastAcceleration.Y) > VELOCITY_TOLERANCE ||
3433 Math.Abs(curacc.Z - m_lastAcceleration.Z) > VELOCITY_TOLERANCE)
3434 break;
3435
3436 // velocity change is also direction not only norm)
3437 if( Math.Abs(curvel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE ||
3438 Math.Abs(curvel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE ||
3439 Math.Abs(curvel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE)
3440 break;
3441
3442 float vx = Math.Abs(curvel.X);
3443 if(vx > 128.0)
3444 break;
3445 float vy = Math.Abs(curvel.Y);
3446 if(vy > 128.0)
3447 break;
3448 float vz = Math.Abs(curvel.Z);
3449 if(vz > 128.0)
3450 break;
3451
3452 if (
3453 vx < VELOCITY_TOLERANCE &&
3454 vy < VELOCITY_TOLERANCE &&
3455 vz < VELOCITY_TOLERANCE
3456 )
3457 {
3458 if(!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
3459 break;
3460
3461 if (vx < 1e-4 &&
3462 vy < 1e-4 &&
3463 vz < 1e-4 &&
3464 (
3465 Math.Abs(m_lastVelocity.X) > 1e-4 ||
3466 Math.Abs(m_lastVelocity.Y) > 1e-4 ||
3467 Math.Abs(m_lastVelocity.Z) > 1e-4
3468 ))
3469 break;
3470 }
3471
3472 if( Math.Abs(angvel.X - m_lastAngularVelocity.X) > VELOCITY_TOLERANCE ||
3473 Math.Abs(angvel.Y - m_lastAngularVelocity.Y) > VELOCITY_TOLERANCE ||
3474 Math.Abs(angvel.Z - m_lastAngularVelocity.Z) > VELOCITY_TOLERANCE)
3475 break;
3476
3477 // viewer interpolators have a limit of 128m/s
3478 float ax = Math.Abs(angvel.X);
3479 if(ax > 64.0)
3480 break;
3481 float ay = Math.Abs(angvel.Y);
3482 if(ay > 64.0)
3483 break;
3484 float az = Math.Abs(angvel.Z);
3485 if(az > 64.0)
3486 break;
3487
3488 if (
3489 ax < VELOCITY_TOLERANCE &&
3490 ay < VELOCITY_TOLERANCE &&
3491 az < VELOCITY_TOLERANCE &&
3492 !RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)
3493 )
3494 break;
3495
3496 needupdate = false;
3497 break;
3498 }
3499
3500 if(needupdate)
3501 {
3502
3503 // Update the "last" values
3504 m_lastPosition = OffsetPosition;
3505 m_lastRotation = RotationOffset;
3506 m_lastVelocity = curvel;
3507 m_lastAcceleration = curacc;
3508 m_lastAngularVelocity = angvel;
3509 m_lastUpdateSentTime = now;
3510
3511 ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
3512 {
3513 SendTerseUpdateToClient(client);
3514 });
3424 } 3515 }
3425 break; 3516 break;
3426 } 3517 }
@@ -3442,13 +3533,15 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3442 if (ParentGroup == null || ParentGroup.Scene == null) 3533 if (ParentGroup == null || ParentGroup.Scene == null)
3443 return; 3534 return;
3444 3535
3536 ClearUpdateSchedule();
3537
3445 // Update the "last" values 3538 // Update the "last" values
3446 m_lastPosition = OffsetPosition; 3539 m_lastPosition = OffsetPosition;
3447 m_lastRotation = RotationOffset; 3540 m_lastRotation = RotationOffset;
3448 m_lastVelocity = Velocity; 3541 m_lastVelocity = Velocity;
3449 m_lastAcceleration = Acceleration; 3542 m_lastAcceleration = Acceleration;
3450 m_lastAngularVelocity = AngularVelocity; 3543 m_lastAngularVelocity = AngularVelocity;
3451 m_lastUpdateSentTime = Environment.TickCount; 3544 m_lastUpdateSentTime = Util.GetTimeStampMS();
3452 3545
3453 ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) 3546 ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
3454 { 3547 {
@@ -3461,13 +3554,15 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
3461 if (ParentGroup == null || ParentGroup.Scene == null) 3554 if (ParentGroup == null || ParentGroup.Scene == null)
3462 return; 3555 return;
3463 3556
3557 ClearUpdateSchedule();
3558
3464 // Update the "last" values 3559 // Update the "last" values
3465 m_lastPosition = OffsetPosition; 3560 m_lastPosition = OffsetPosition;
3466 m_lastRotation = RotationOffset; 3561 m_lastRotation = RotationOffset;
3467 m_lastVelocity = Velocity; 3562 m_lastVelocity = Velocity;
3468 m_lastAcceleration = Acceleration; 3563 m_lastAcceleration = Acceleration;
3469 m_lastAngularVelocity = AngularVelocity; 3564 m_lastAngularVelocity = AngularVelocity;
3470 m_lastUpdateSentTime = Environment.TickCount; 3565 m_lastUpdateSentTime = Util.GetTimeStampMS();
3471 3566
3472 if (ParentGroup.IsAttachment) 3567 if (ParentGroup.IsAttachment)
3473 { 3568 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7e3adb9..c1b62af 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3789,17 +3789,6 @@ namespace OpenSim.Region.Framework.Scenes
3789 3789
3790 // Send terse position update if not sitting and position, velocity, or rotation 3790 // Send terse position update if not sitting and position, velocity, or rotation
3791 // has changed significantly from last sent update 3791 // has changed significantly from last sent update
3792 if (!IsSatOnObject && (
3793 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)
3794 || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE)
3795 || !m_pos.ApproxEquals(m_lastPosition, POSITION_LARGETOLERANCE)
3796 // if velocity is zero and it wasn't zero last time, send the update
3797 || (Velocity == Vector3.Zero && m_lastVelocity != Vector3.Zero)
3798 // if position has moved just a little and velocity is very low, send the update
3799 || (!m_pos.ApproxEquals(m_lastPosition, POSITION_SMALLTOLERANCE) && Velocity.LengthSquared() < LOWVELOCITYSQ )
3800 ) )
3801 {
3802/*
3803 if (!IsSatOnObject) 3792 if (!IsSatOnObject)
3804 { 3793 {
3805 // this does need to be more complex later 3794 // this does need to be more complex later
@@ -3813,6 +3802,7 @@ namespace OpenSim.Region.Framework.Scenes
3813 Math.Abs(m_bodyRot.Y - m_lastRotation.Y) > ROTATION_TOLERANCE || 3802 Math.Abs(m_bodyRot.Y - m_lastRotation.Y) > ROTATION_TOLERANCE ||
3814 Math.Abs(m_bodyRot.Z - m_lastRotation.Z) > ROTATION_TOLERANCE || 3803 Math.Abs(m_bodyRot.Z - m_lastRotation.Z) > ROTATION_TOLERANCE ||
3815 3804
3805 (vel == Vector3.Zero && m_lastVelocity != Vector3.Zero) ||
3816 Math.Abs(dpos.X) > POSITION_LARGETOLERANCE || 3806 Math.Abs(dpos.X) > POSITION_LARGETOLERANCE ||
3817 Math.Abs(dpos.Y) > POSITION_LARGETOLERANCE || 3807 Math.Abs(dpos.Y) > POSITION_LARGETOLERANCE ||
3818 Math.Abs(dpos.Z) > POSITION_LARGETOLERANCE || 3808 Math.Abs(dpos.Z) > POSITION_LARGETOLERANCE ||
@@ -3823,9 +3813,8 @@ namespace OpenSim.Region.Framework.Scenes
3823 && vel.LengthSquared() < LOWVELOCITYSQ 3813 && vel.LengthSquared() < LOWVELOCITYSQ
3824 )) 3814 ))
3825 { 3815 {
3826*/
3827 SendTerseUpdateToAllClients(); 3816 SendTerseUpdateToAllClients();
3828// } 3817 }
3829 } 3818 }
3830 CheckForSignificantMovement(); 3819 CheckForSignificantMovement();
3831 } 3820 }