From 8428b25939d39711e732eeb3928e8a8e64aad8a9 Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Mon, 26 Oct 2009 00:10:23 +0100 Subject: Add llRotLookat pt1. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 39 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 +++++++ 2 files changed, 51 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 69b3ded..fff807a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1727,6 +1727,45 @@ namespace OpenSim.Region.Framework.Scenes } } + public void rotLookAt(Quaternion target, float strength, float damping) + { + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) + { + if (IsAttachment) + { + /* + ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + if (avatar != null) + { + Rotate the Av? + } */ + } + else + { + if (rootpart.PhysActor != null) + { + rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); + rootpart.PhysActor.APIDStrength = strength; + rootpart.PhysActor.APIDDamping = damping; + rootpart.PhysActor.APIDActive = true; + } + } + } + } + public void stopLookAt() + { + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) + { + if (rootpart.PhysActor != null) + { + rootpart.PhysActor.APIDActive = false; + } + } + + } + /// /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 32171a0..5f46f6f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2187,6 +2187,11 @@ if (m_shape != null) { ParentGroup.HasGroupChanged = true; ScheduleFullUpdate(); } + + public void RotLookAt(Quaternion target, float strength, float damping) + { + m_parentGroup.rotLookAt(target, strength, damping); + } /// /// Schedules this prim for a full update @@ -2662,6 +2667,13 @@ if (m_shape != null) { SetText(text); } + public void StopLookAt() + { + m_parentGroup.stopLookAt(); + + m_parentGroup.ScheduleGroupForTerseUpdate(); + } + public void StopMoveToTarget() { m_parentGroup.stopMoveToTarget(); -- cgit v1.1 From 28aa8010b2b47b73c6b867ff8f6284f98f12f37a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Nov 2009 21:38:38 +0100 Subject: - Lower TIME_MS_TOLERANCE to 200ms - Allow m_updateFlag to be reset to 0 in the event of a terse update being rejected - Re-add a synchronous SendTo for certain types of packets --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 73d0984..c0fd437 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1064,14 +1064,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Clear all pending updates of parts to clients - /// - private void ClearUpdateSchedule() - { - m_updateFlag = 0; - } - private void SendObjectPropertiesToClient(UUID AgentID) { ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); @@ -2387,8 +2379,8 @@ namespace OpenSim.Region.Framework.Scenes { const float ROTATION_TOLERANCE = 0.01f; const float VELOCITY_TOLERANCE = 0.001f; - const float POSITION_TOLERANCE = 0.05f; - const int TIME_MS_TOLERANCE = 3000; + const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary + const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. if (m_updateFlag == 1) { @@ -2401,7 +2393,7 @@ namespace OpenSim.Region.Framework.Scenes Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { AddTerseUpdateToAllAvatars(); - ClearUpdateSchedule(); + // This causes the Scene to 'poll' physical objects every couple of frames // bad, so it's been replaced by an event driven method. @@ -2419,13 +2411,15 @@ namespace OpenSim.Region.Framework.Scenes m_lastAngularVelocity = AngularVelocity; m_lastTerseSent = Environment.TickCount; } + //Moved this outside of the if clause so updates don't get blocked.. *sigh* + m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* } else { if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes { AddFullUpdateToAllAvatars(); - ClearUpdateSchedule(); + m_updateFlag = 0; //Same here } } } -- cgit v1.1 From 0149265ee83581cf2fb150dcd5d8734c02926261 Mon Sep 17 00:00:00 2001 From: CasperW Date: Sat, 21 Nov 2009 15:36:38 +0100 Subject: Improved avatar responsiveness. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 4 +- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 80 ++++++++++++++++++---- 3 files changed, 72 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index cbe4118..2230fba 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -156,8 +156,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); // Check control flags - bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; - bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; + bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); + bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a430b1e..5058457 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1164,16 +1164,16 @@ namespace OpenSim.Region.Framework.Scenes // Check if any objects have reached their targets CheckAtTargets(); - // Update SceneObjectGroups that have scheduled themselves for updates - // Objects queue their updates onto all scene presences - if (m_frame % m_update_objects == 0) - m_sceneGraph.UpdateObjectGroups(); - // Run through all ScenePresences looking for updates // Presence updates and queued object updates for each presence are sent to clients if (m_frame % m_update_presences == 0) m_sceneGraph.UpdatePresences(); + // Update SceneObjectGroups that have scheduled themselves for updates + // Objects queue their updates onto all scene presences + if (m_frame % m_update_objects == 0) + m_sceneGraph.UpdateObjectGroups(); + int TempPhysicsMS2 = Environment.TickCount; if ((m_frame % m_update_physics == 0) && m_physics_enabled) m_sceneGraph.UpdatePreparePhysics(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 424c25b..99f3141 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes // { // m_log.Debug("[ScenePresence] Destructor called"); // } - + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; @@ -144,7 +144,6 @@ namespace OpenSim.Region.Framework.Scenes private int m_perfMonMS; private bool m_setAlwaysRun; - private bool m_forceFly; private bool m_flyDisabled; @@ -166,7 +165,8 @@ namespace OpenSim.Region.Framework.Scenes protected RegionInfo m_regionInfo; protected ulong crossingFromRegion; - private readonly Vector3[] Dir_Vectors = new Vector3[6]; + private readonly Vector3[] Dir_Vectors = new Vector3[9]; + private bool m_isNudging = false; // Position of agent's camera in world (region cordinates) protected Vector3 m_CameraCenter; @@ -230,6 +230,8 @@ namespace OpenSim.Region.Framework.Scenes DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, + DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, + DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG } @@ -714,21 +716,41 @@ namespace OpenSim.Region.Framework.Scenes Dir_Vectors[3] = -Vector3.UnitY; //RIGHT Dir_Vectors[4] = Vector3.UnitZ; //UP Dir_Vectors[5] = -Vector3.UnitZ; //DOWN - Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge + Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE + Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE + Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge } private Vector3[] GetWalkDirectionVectors() { - Vector3[] vector = new Vector3[6]; + Vector3[] vector = new Vector3[9]; vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK vector[2] = Vector3.UnitY; //LEFT vector[3] = -Vector3.UnitY; //RIGHT vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN - vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge + vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE + vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE + vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge return vector; } + + private bool[] GetDirectionIsNudge() + { + bool[] isNudge = new bool[9]; + isNudge[0] = false; //FORWARD + isNudge[1] = false; //BACK + isNudge[2] = false; //LEFT + isNudge[3] = false; //RIGHT + isNudge[4] = false; //UP + isNudge[5] = false; //DOWN + isNudge[6] = true; //FORWARD_NUDGE + isNudge[7] = true; //BACK_NUDGE + isNudge[8] = true; //DOWN_Nudge + return isNudge; + } + #endregion @@ -1147,7 +1169,6 @@ namespace OpenSim.Region.Framework.Scenes // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); // return; //} - m_perfMonMS = Environment.TickCount; ++m_movementUpdateCount; @@ -1229,7 +1250,6 @@ namespace OpenSim.Region.Framework.Scenes m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); } } - lock (scriptedcontrols) { if (scriptedcontrols.Count > 0) @@ -1261,7 +1281,6 @@ namespace OpenSim.Region.Framework.Scenes { return; } - if (m_allowMovement) { int i = 0; @@ -1289,6 +1308,11 @@ namespace OpenSim.Region.Framework.Scenes update_rotation = true; } + //guilty until proven innocent.. + bool Nudging = true; + //Basically, if there is at least one non-nudge control then we don't need + //to worry about stopping the avatar + if (m_parentID == 0) { bool bAllowUpdateMoveToPosition = false; @@ -1303,6 +1327,12 @@ namespace OpenSim.Region.Framework.Scenes else dirVectors = Dir_Vectors; + bool[] isNudge = GetDirectionIsNudge(); + + + + + foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) { if (((uint)flags & (uint)DCF) != 0) @@ -1312,6 +1342,10 @@ namespace OpenSim.Region.Framework.Scenes try { agent_control_v3 += dirVectors[i]; + if (isNudge[i] == false) + { + Nudging = false; + } } catch (IndexOutOfRangeException) { @@ -1373,6 +1407,9 @@ namespace OpenSim.Region.Framework.Scenes // Ignore z component of vector Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); LocalVectorToTarget2D.Normalize(); + + //We're not nudging + Nudging = false; agent_control_v3 += LocalVectorToTarget2D; // update avatar movement flags. the avatar coordinate system is as follows: @@ -1450,7 +1487,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); - AddNewMovement(agent_control_v3, q); + AddNewMovement(agent_control_v3, q, Nudging); if (update_movementflag) Animator.UpdateMovementAnimations(); @@ -1886,7 +1923,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// The vector in which to move. This is relative to the rotation argument /// The direction in which this avatar should now face. - public void AddNewMovement(Vector3 vec, Quaternion rotation) + public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) { if (m_isChildAgent) { @@ -1960,7 +1997,7 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Add the force instead of only setting it to support multiple forces per frame? m_forceToApply = direc; - + m_isNudging = Nudging; m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); } @@ -1975,7 +2012,7 @@ namespace OpenSim.Region.Framework.Scenes const float POSITION_TOLERANCE = 0.05f; //const int TIME_MS_TOLERANCE = 3000; - SendPrimUpdates(); + if (m_newCoarseLocations) { @@ -2011,6 +2048,9 @@ namespace OpenSim.Region.Framework.Scenes CheckForBorderCrossing(); CheckForSignificantMovement(); // sends update to the modules. } + + //Sending prim updates AFTER the avatar terse updates are sent + SendPrimUpdates(); } #endregion @@ -2864,14 +2904,24 @@ namespace OpenSim.Region.Framework.Scenes { if (m_forceToApply.HasValue) { - Vector3 force = m_forceToApply.Value; + Vector3 force = m_forceToApply.Value; m_updateflag = true; -// movementvector = force; Velocity = force; m_forceToApply = null; } + else + { + if (m_isNudging) + { + Vector3 force = Vector3.Zero; + + m_updateflag = true; + Velocity = force; + m_isNudging = false; + } + } } public override void SetText(string text, Vector3 color, double alpha) -- cgit v1.1 From f1522e62042d11604ad70a39b26dc94953e9db7d Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Sun, 22 Nov 2009 08:31:35 +0100 Subject: Add non-scripted sit, fix scripted sit. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 99 +++++++++++++++++------- 1 file changed, 69 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1dedcf1..aa538dc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -89,7 +89,8 @@ namespace OpenSim.Region.Framework.Scenes /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis /// issue #1716 /// - private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); +// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); + private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); public UUID currentParcelUUID = UUID.Zero; @@ -113,7 +114,8 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; public Vector4 CollisionPlane = Vector4.UnitW; - + + private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -1531,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; SendFullUpdateToAllClients(); - //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); + HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? } //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); m_requestedSitTargetUUID = UUID.Zero; @@ -1644,7 +1646,7 @@ namespace OpenSim.Region.Framework.Scenes bool SitTargetisSet = (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); - + // this test is probably failing if (SitTargetisSet && SitTargetUnOccupied) { //switch the target to this prim @@ -1671,26 +1673,37 @@ namespace OpenSim.Region.Framework.Scenes { // TODO: determine position to sit at based on scene geometry; don't trust offset from client // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - + + // part is the prim to sit on + // offset is the vector distance from that prim center to the click-spot + // UUID is the UUID of the Avatar doing the clicking + + m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation + // Is a sit target available? Vector3 avSitOffSet = part.SitTargetPosition; Quaternion avSitOrientation = part.SitTargetOrientation; UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); - bool SitTargetisSet = - (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && - avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); +// bool SitTargetisSet = +// (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && +// avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); + bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); + +//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + +// " TargSet=" + SitTargetisSet); + if (SitTargetisSet && SitTargetUnOccupied) { part.SetAvatarOnSitTarget(UUID); offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); sitOrientation = avSitOrientation; - autopilot = false; + autopilot = false; // Jump direct to scripted llSitPos() } - pos = part.AbsolutePosition + offset; + pos = part.AbsolutePosition + offset; // Region position where clicked //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) //{ // offset = pos; @@ -1703,17 +1716,17 @@ namespace OpenSim.Region.Framework.Scenes m_sitAvatarHeight = m_physicsActor.Size.Z; if (autopilot) - { + { // its not a scripted sit if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) { - autopilot = false; + autopilot = false; // close enough RemoveFromPhysicalScene(); - AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); - } + AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim + } // else the autopilot will get us close } else - { + { // its a scripted sit RemoveFromPhysicalScene(); } } @@ -1816,26 +1829,41 @@ namespace OpenSim.Region.Framework.Scenes { if (part.GetAvatarOnSitTarget() == UUID) { + // Scripted sit Vector3 sitTargetPos = part.SitTargetPosition; Quaternion sitTargetOrient = part.SitTargetOrientation; - - //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); - //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); - - //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); m_pos += SIT_TARGET_ADJUSTMENT; m_bodyRot = sitTargetOrient; - //Rotation = sitTargetOrient; m_parentPosition = part.AbsolutePosition; - - //SendTerseUpdateToAllClients(); } else { - m_pos -= part.AbsolutePosition; + // Non-scripted sit by Kitto Flora 21Nov09 + // Calculate angle of line from prim to Av + float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); + float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); + if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 + if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 + float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); + Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. + // Av sits at world euler <0,0, z>, translated by part rotation + m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click + m_pos = new Vector3(0f, 0f, 0.05f) + + (new Vector3(0.0f, 0f, 0.625f) * partIRot) + + (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim m_parentPosition = part.AbsolutePosition; + //Set up raytrace to find top surface of prim + Vector3 size = part.Scale; + float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); + Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); + Vector3 down = new Vector3(0f, 0f, -1f); + m_scene.PhysicsScene.RaycastWorld( + start, // Vector3 position, + down, // Vector3 direction, + mag, // float length, + SitAltitudeCallback); // retMethod } } else @@ -1850,11 +1878,22 @@ namespace OpenSim.Region.Framework.Scenes Animator.TrySetMovementAnimation(sitAnimation); SendFullUpdateToAllClients(); - // This may seem stupid, but Our Full updates don't send avatar rotation :P - // So we're also sending a terse update (which has avatar rotation) - // [Update] We do now. - //SendTerseUpdateToAllClients(); } + + public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) + { +// Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance); + if(hitYN) + { + // m_pos = Av offset from prim center to make look like on center + // m_parentPosition = Actual center pos of prim + // collisionPoint = spot on prim where we want to sit + SceneObjectPart part = m_scene.GetSceneObjectPart(localid); + Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); + m_pos += offset; +// Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); + } + } /// /// Event handler for the 'Always run' setting on the client @@ -3578,4 +3617,4 @@ namespace OpenSim.Region.Framework.Scenes } } } -} \ No newline at end of file +} -- cgit v1.1 From 73c2162ff60850d96761aa07a1950dbbb2ec3e80 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 23 Nov 2009 19:51:40 +0100 Subject: Fixed nullrefs --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 66fb918..83208e9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -840,8 +840,12 @@ namespace OpenSim.Region.Framework.Scenes public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) { SceneObjectPart part = GetSceneObjectPart(localID); - SceneObjectGroup group = part.ParentGroup; - if (group != null) + SceneObjectGroup group = null; + if (part != null) + { + group = part.ParentGroup; + } + if (part != null && group != null) { TaskInventoryItem item = group.GetInventoryItem(localID, itemID); if (item == null) -- cgit v1.1 From d1147136946daf14724183b3191119be44ff8b16 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 18:02:12 +0100 Subject: Drop all locking of part.TaskInventory in favour of a ReaderWriterLockSlim lock handler. This gives us: - Faster prim inventory actions. Multiple threads can read at once. - Fixes the known prim inventory thread locks - In the event of a thread lock occurring, it will usually self heal after sixty seconds with an error message in the console --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 38 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 390 +++++++++++---------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +- 3 files changed, 235 insertions(+), 209 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cdec135..bbece2f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -389,12 +389,16 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes + /// Get the inventory list /// public TaskInventoryDictionary TaskInventory { - get { return m_inventory.Items; } - set { m_inventory.Items = value; } + get { + return m_inventory.Items; + } + set { + m_inventory.Items = value; + } } public uint ObjectFlags @@ -2101,17 +2105,18 @@ namespace OpenSim.Region.Framework.Scenes //Trys to fetch sound id from prim's inventory. //Prim's inventory doesn't support non script items yet - lock (TaskInventory) + TaskInventory.LockItemsForRead(true); + + foreach (KeyValuePair item in TaskInventory) { - foreach (KeyValuePair item in TaskInventory) + if (item.Value.Name == sound) { - if (item.Value.Name == sound) - { - soundID = item.Value.ItemID; - break; - } + soundID = item.Value.ItemID; + break; } } + + TaskInventory.LockItemsForRead(false); } List avatarts = m_parentGroup.Scene.GetAvatars(); @@ -2457,17 +2462,16 @@ namespace OpenSim.Region.Framework.Scenes if (!UUID.TryParse(sound, out soundID)) { // search sound file from inventory - lock (TaskInventory) + TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair item in TaskInventory) { - foreach (KeyValuePair item in TaskInventory) + if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) { - if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) - { - soundID = item.Value.ItemID; - break; - } + soundID = item.Value.ItemID; + break; } } + TaskInventory.LockItemsForRead(false); } if (soundID == UUID.Zero) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f4ca877..4dc709e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal TaskInventoryDictionary Items { - get { return m_items; } + get { + return m_items; + } set { m_items = value; @@ -116,22 +118,25 @@ namespace OpenSim.Region.Framework.Scenes /// Link number for the part public void ResetInventoryIDs() { - lock (Items) + m_items.LockItemsForWrite(true); + + if (0 == Items.Count) { - if (0 == Items.Count) - return; + m_items.LockItemsForWrite(false); + return; + } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; - IList items = new List(Items.Values); - Items.Clear(); + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + IList items = new List(Items.Values); + Items.Clear(); - foreach (TaskInventoryItem item in items) - { - item.ResetIDs(m_part.UUID); - Items.Add(item.ItemID, item); - } + foreach (TaskInventoryItem item in items) + { + item.ResetIDs(m_part.UUID); + Items.Add(item.ItemID, item); } + m_items.LockItemsForWrite(false); } /// @@ -140,25 +145,25 @@ namespace OpenSim.Region.Framework.Scenes /// public void ChangeInventoryOwner(UUID ownerId) { - lock (Items) + m_items.LockItemsForWrite(true); + if (0 == Items.Count) { - if (0 == Items.Count) - { - return; - } + m_items.LockItemsForWrite(false); + return; + } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; - IList items = new List(Items.Values); - foreach (TaskInventoryItem item in items) + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + IList items = new List(Items.Values); + foreach (TaskInventoryItem item in items) + { + if (ownerId != item.OwnerID) { - if (ownerId != item.OwnerID) - { - item.LastOwnerID = item.OwnerID; - item.OwnerID = ownerId; - } + item.LastOwnerID = item.OwnerID; + item.OwnerID = ownerId; } } + m_items.LockItemsForWrite(false); } /// @@ -167,24 +172,24 @@ namespace OpenSim.Region.Framework.Scenes /// public void ChangeInventoryGroup(UUID groupID) { - lock (Items) + m_items.LockItemsForWrite(true); + if (0 == Items.Count) { - if (0 == Items.Count) - { - return; - } + m_items.LockItemsForWrite(false); + return; + } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; - IList items = new List(Items.Values); - foreach (TaskInventoryItem item in items) + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + IList items = new List(Items.Values); + foreach (TaskInventoryItem item in items) + { + if (groupID != item.GroupID) { - if (groupID != item.GroupID) - { - item.GroupID = groupID; - } + item.GroupID = groupID; } } + m_items.LockItemsForWrite(false); } /// @@ -192,14 +197,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) { - lock (m_items) + Items.LockItemsForRead(true); + IList items = new List(Items.Values); + Items.LockItemsForRead(false); + foreach (TaskInventoryItem item in items) { - foreach (TaskInventoryItem item in Items.Values) + if ((int)InventoryType.LSL == item.InvType) { - if ((int)InventoryType.LSL == item.InvType) - { - CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); - } + CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); } } } @@ -209,17 +214,20 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveScriptInstances() { - lock (Items) + Items.LockItemsForRead(true); + IList items = new List(Items.Values); + Items.LockItemsForRead(false); + + foreach (TaskInventoryItem item in items) { - foreach (TaskInventoryItem item in Items.Values) + if ((int)InventoryType.LSL == item.InvType) { - if ((int)InventoryType.LSL == item.InvType) - { - RemoveScriptInstance(item.ItemID); - m_part.RemoveScriptEvents(item.ItemID); - } + RemoveScriptInstance(item.ItemID); + m_part.RemoveScriptEvents(item.ItemID); } } + + } /// @@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes if (stateSource == 1 && // Prim crossing m_part.ParentGroup.Scene.m_trustBinaries) { + m_items.LockItemsForWrite(true); m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; + m_items.LockItemsForWrite(false); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); m_part.ParentGroup.AddActiveScriptCount(1); @@ -266,8 +276,10 @@ namespace OpenSim.Region.Framework.Scenes { if (m_part.ParentGroup.m_savedScriptState != null) RestoreSavedScriptState(item.OldItemID, item.ItemID); + m_items.LockItemsForWrite(true); m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; + m_items.LockItemsForWrite(false); string script = Utils.BytesToString(asset.Data); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); @@ -302,20 +314,22 @@ namespace OpenSim.Region.Framework.Scenes /// public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) { - lock (m_items) + m_items.LockItemsForRead(true); + if (m_items.ContainsKey(itemId)) { - if (m_items.ContainsKey(itemId)) - { - CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", - itemId, m_part.Name, m_part.UUID); - } + TaskInventoryItem item = m_items[itemId]; + m_items.LockItemsForRead(false); + CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); } + else + { + m_items.LockItemsForRead(false); + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", + itemId, m_part.Name, m_part.UUID); + } + } /// @@ -346,11 +360,16 @@ namespace OpenSim.Region.Framework.Scenes /// private bool InventoryContainsName(string name) { - foreach (TaskInventoryItem item in Items.Values) + m_items.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_items.Values) { if (item.Name == name) + { + m_items.LockItemsForRead(false); return true; + } } + m_items.LockItemsForRead(false); return false; } @@ -392,7 +411,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) { + m_items.LockItemsForRead(true); List il = new List(m_items.Values); + m_items.LockItemsForRead(false); foreach (TaskInventoryItem i in il) { if (i.Name == item.Name) @@ -429,15 +450,14 @@ namespace OpenSim.Region.Framework.Scenes item.ParentPartID = m_part.UUID; item.Name = name; - lock (m_items) - { - m_items.Add(item.ItemID, item); - + m_items.LockItemsForWrite(true); + m_items.Add(item.ItemID, item); + m_items.LockItemsForWrite(false); if (allowedDrop) m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); else m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - } + m_inventorySerial++; //m_inventorySerial += 2; @@ -454,14 +474,13 @@ namespace OpenSim.Region.Framework.Scenes /// public void RestoreInventoryItems(ICollection items) { - lock (m_items) + m_items.LockItemsForWrite(true); + foreach (TaskInventoryItem item in items) { - foreach (TaskInventoryItem item in items) - { - m_items.Add(item.ItemID, item); - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - } + m_items.Add(item.ItemID, item); + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); } + m_items.LockItemsForWrite(false); m_inventorySerial++; } @@ -474,8 +493,9 @@ namespace OpenSim.Region.Framework.Scenes public TaskInventoryItem GetInventoryItem(UUID itemId) { TaskInventoryItem item; + m_items.LockItemsForRead(true); m_items.TryGetValue(itemId, out item); - + m_items.LockItemsForRead(false); return item; } @@ -487,45 +507,45 @@ namespace OpenSim.Region.Framework.Scenes /// false if the item did not exist, true if the update occurred successfully public bool UpdateInventoryItem(TaskInventoryItem item) { - lock (m_items) + m_items.LockItemsForWrite(true); + + if (m_items.ContainsKey(item.ItemID)) { - if (m_items.ContainsKey(item.ItemID)) + item.ParentID = m_part.UUID; + item.ParentPartID = m_part.UUID; + item.Flags = m_items[item.ItemID].Flags; + if (item.AssetID == UUID.Zero) { - item.ParentID = m_part.UUID; - item.ParentPartID = m_part.UUID; - item.Flags = m_items[item.ItemID].Flags; - if (item.AssetID == UUID.Zero) - { - item.AssetID = m_items[item.ItemID].AssetID; - } - else if ((InventoryType)item.Type == InventoryType.Notecard) - { - ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); + item.AssetID = m_items[item.ItemID].AssetID; + } + else if ((InventoryType)item.Type == InventoryType.Notecard) + { + ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); - if (presence != null) - { - presence.ControllingClient.SendAgentAlertMessage( - "Notecard saved", false); - } + if (presence != null) + { + presence.ControllingClient.SendAgentAlertMessage( + "Notecard saved", false); } + } - m_items[item.ItemID] = item; - m_inventorySerial++; - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + m_items[item.ItemID] = item; + m_inventorySerial++; + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - return true; - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", - item.ItemID, m_part.Name, m_part.UUID); - } + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + m_items.LockItemsForWrite(false); + return true; + } + else + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", + item.ItemID, m_part.Name, m_part.UUID); } + m_items.LockItemsForWrite(false); return false; } @@ -538,51 +558,54 @@ namespace OpenSim.Region.Framework.Scenes /// in this prim's inventory. public int RemoveInventoryItem(UUID itemID) { - lock (m_items) + m_items.LockItemsForRead(true); + + if (m_items.ContainsKey(itemID)) { - if (m_items.ContainsKey(itemID)) + int type = m_items[itemID].InvType; + m_items.LockItemsForRead(false); + if (type == 10) // Script { - int type = m_items[itemID].InvType; - if (type == 10) // Script - { - m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); - } - m_items.Remove(itemID); - m_inventorySerial++; - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); + } + m_items.LockItemsForWrite(true); + m_items.Remove(itemID); + m_items.LockItemsForWrite(false); + m_inventorySerial++; + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - int scriptcount = 0; - lock (m_items) - { - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.Type == 10) - { - scriptcount++; - } - } - } + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; - if (scriptcount <= 0) + int scriptcount = 0; + m_items.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_items.Values) + { + if (item.Type == 10) { - m_part.RemFlag(PrimFlags.Scripted); + scriptcount++; } - - m_part.ScheduleFullUpdate(); - - return type; } - else + m_items.LockItemsForRead(false); + + + if (scriptcount <= 0) { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", - itemID, m_part.Name, m_part.UUID); + m_part.RemFlag(PrimFlags.Scripted); } + + m_part.ScheduleFullUpdate(); + + return type; + } + else + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", + itemID, m_part.Name, m_part.UUID); } + m_items.LockItemsForWrite(false); return -1; } @@ -635,52 +658,53 @@ namespace OpenSim.Region.Framework.Scenes // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); - lock (m_items) + m_items.LockItemsForRead(true); + + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) - { - UUID ownerID = item.OwnerID; - uint everyoneMask = 0; - uint baseMask = item.BasePermissions; - uint ownerMask = item.CurrentPermissions; + UUID ownerID = item.OwnerID; + uint everyoneMask = 0; + uint baseMask = item.BasePermissions; + uint ownerMask = item.CurrentPermissions; - invString.AddItemStart(); - invString.AddNameValueLine("item_id", item.ItemID.ToString()); - invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); + invString.AddItemStart(); + invString.AddNameValueLine("item_id", item.ItemID.ToString()); + invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); - invString.AddPermissionsStart(); + invString.AddPermissionsStart(); - invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); - invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); - invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); - invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); - invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); + invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); + invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); + invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); + invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); + invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); - invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); - invString.AddNameValueLine("owner_id", ownerID.ToString()); + invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); + invString.AddNameValueLine("owner_id", ownerID.ToString()); - invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); + invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); - invString.AddNameValueLine("group_id", item.GroupID.ToString()); - invString.AddSectionEnd(); + invString.AddNameValueLine("group_id", item.GroupID.ToString()); + invString.AddSectionEnd(); - invString.AddNameValueLine("asset_id", item.AssetID.ToString()); - invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); - invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); - invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); + invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); + invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); + invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); - invString.AddSaleStart(); - invString.AddNameValueLine("sale_type", "not"); - invString.AddNameValueLine("sale_price", "0"); - invString.AddSectionEnd(); + invString.AddSaleStart(); + invString.AddNameValueLine("sale_type", "not"); + invString.AddNameValueLine("sale_price", "0"); + invString.AddSectionEnd(); - invString.AddNameValueLine("name", item.Name + "|"); - invString.AddNameValueLine("desc", item.Description + "|"); + invString.AddNameValueLine("name", item.Name + "|"); + invString.AddNameValueLine("desc", item.Description + "|"); - invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); - invString.AddSectionEnd(); - } + invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); + invString.AddSectionEnd(); } + int count = m_items.Count; + m_items.LockItemsForRead(false); fileData = Utils.StringToBytes(invString.BuildString); @@ -689,6 +713,7 @@ namespace OpenSim.Region.Framework.Scenes if (fileData.Length > 2) { + m_log.Debug("Sending task inventory list of " + count.ToString() + " items to client " + client.AgentId.ToString()); xferManager.AddNewFile(m_inventoryFileName, fileData); } } @@ -701,10 +726,9 @@ namespace OpenSim.Region.Framework.Scenes { if (HasInventoryChanged) { - lock (Items) - { - datastore.StorePrimInventory(m_part.UUID, Items.Values); - } + Items.LockItemsForRead(true); + datastore.StorePrimInventory(m_part.UUID, Items.Values); + Items.LockItemsForRead(false); HasInventoryChanged = false; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4e5fee1..4c8c94f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1615,21 +1615,19 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) { + part.TaskInventory.LockItemsForRead(true); TaskInventoryDictionary taskIDict = part.TaskInventory; if (taskIDict != null) { - lock (taskIDict) + foreach (UUID taskID in taskIDict.Keys) { - foreach (UUID taskID in taskIDict.Keys) - { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS - } + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS } - } + part.TaskInventory.LockItemsForRead(false); // Reset sit target. if (part.GetAvatarOnSitTarget() == UUID) part.SetAvatarOnSitTarget(UUID.Zero); -- cgit v1.1 From 8383bde76880fc94a6644422d45baa28252b0231 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 18:18:19 +0100 Subject: Removed some extra debug chatter --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4dc709e..abb04cd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -713,7 +713,6 @@ namespace OpenSim.Region.Framework.Scenes if (fileData.Length > 2) { - m_log.Debug("Sending task inventory list of " + count.ToString() + " items to client " + client.AgentId.ToString()); xferManager.AddNewFile(m_inventoryFileName, fileData); } } -- cgit v1.1 From 32c464ad1f43cbee9492108c1bec7f874a20cd47 Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Wed, 25 Nov 2009 08:03:09 +0100 Subject: Fixed animation sequencing: SitHere, Falling, Stand/Walk etc. Login Init Av Animation at Stand. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 15 ++++++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 +++++++++++++++------- 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 30a95ce..2d41342 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -53,8 +53,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation { get { return m_movementAnimation; } } - protected string m_movementAnimation = "DEFAULT"; - + // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist! + protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init. private int m_animTickFall; private int m_animTickJump; @@ -123,17 +123,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void TrySetMovementAnimation(string anim) { - //m_log.DebugFormat("Updating movement animation to {0}", anim); +//Console.WriteLine("Updating movement animation to {0}", anim); if (!m_scenePresence.IsChildAgent) { if (m_animations.TrySetDefaultAnimation( anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero)) { +//Console.WriteLine("TSMA {0} success.", anim); // 16384 is CHANGED_ANIMATION m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); SendAnimPack(); } + else + { +//Console.WriteLine("TSMA {0} fail.", anim); + } } } @@ -313,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void UpdateMovementAnimations() { m_movementAnimation = GetMovementAnimation(); - +//Console.WriteLine("UMA got {0}", m_movementAnimation); if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) { // This was the previous behavior before PREJUMP @@ -445,4 +450,4 @@ namespace OpenSim.Region.Framework.Scenes.Animation SendAnimPack(animIDs, sequenceNums, objectIDs); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4e5fee1..a65b84b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -90,6 +90,7 @@ namespace OpenSim.Region.Framework.Scenes /// issue #1716 /// // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); + // Value revised by KF 091121 by comparison with SL. private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); public UUID currentParcelUUID = UUID.Zero; @@ -205,6 +206,9 @@ namespace OpenSim.Region.Framework.Scenes private bool m_followCamAuto; private int m_movementUpdateCount; + private int m_lastColCount = -1; //KF: Look for Collision chnages + private int m_updateCount = 0; //KF: Update Anims for a while + private static readonly int UPDATE_COUNT = 10; // how many frames to update for private const int NumMovementsBetweenRayCast = 5; @@ -662,9 +666,7 @@ namespace OpenSim.Region.Framework.Scenes AdjustKnownSeeds(); - // TODO: I think, this won't send anything, as we are still a child here... - Animator.TrySetMovementAnimation("STAND"); - + Animator.TrySetMovementAnimation("STAND"); // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) @@ -1018,7 +1020,9 @@ namespace OpenSim.Region.Framework.Scenes { AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); } - + + m_updateCount = UPDATE_COUNT; //KF: Trigger Anim updates to catch falling anim. + ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient))); } @@ -1266,9 +1270,7 @@ namespace OpenSim.Region.Framework.Scenes if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { - // TODO: This doesn't prevent the user from walking yet. - // Setting parent ID would fix this, if we knew what value - // to use. Or we could add a m_isSitting variable. + m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); } @@ -1926,7 +1928,6 @@ namespace OpenSim.Region.Framework.Scenes public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) { -// Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance); if(hitYN) { // m_pos = Av offset from prim center to make look like on center @@ -2964,6 +2965,7 @@ namespace OpenSim.Region.Framework.Scenes m_updateflag = true; Velocity = force; m_isNudging = false; + m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" } } } @@ -3015,19 +3017,29 @@ namespace OpenSim.Region.Framework.Scenes // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { + if (m_updateCount > 0) //KF: Update Anims for a short period. Many Anim + { // changes are very asynchronous. + Animator.UpdateMovementAnimations(); + m_updateCount--; + } + if (e == null) return; - //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene - Animator.UpdateMovementAnimations(); - + CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; CollisionPlane = Vector4.UnitW; + if (m_lastColCount != coldata.Count) + { + m_updateCount = 10; + m_lastColCount = coldata.Count; + } + if (coldata.Count != 0) { switch (Animator.CurrentMovementAnimation) -- cgit v1.1 From b9d22aa8213b62eb0c368b345ccfc105367c1aba Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 01:59:08 +0100 Subject: Add nudge right and left to avatar movement (faster reaction times when stepping left or right.) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4c8c94f..9b04422 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes protected RegionInfo m_regionInfo; protected ulong crossingFromRegion; - private readonly Vector3[] Dir_Vectors = new Vector3[9]; + private readonly Vector3[] Dir_Vectors = new Vector3[11]; private bool m_isNudging = false; // Position of agent's camera in world (region cordinates) @@ -236,6 +236,8 @@ namespace OpenSim.Region.Framework.Scenes DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, + DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG } @@ -722,12 +724,14 @@ namespace OpenSim.Region.Framework.Scenes Dir_Vectors[5] = -Vector3.UnitZ; //DOWN Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE - Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge + Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE + Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE + Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge } private Vector3[] GetWalkDirectionVectors() { - Vector3[] vector = new Vector3[9]; + Vector3[] vector = new Vector3[11]; vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK vector[2] = Vector3.UnitY; //LEFT @@ -736,13 +740,15 @@ namespace OpenSim.Region.Framework.Scenes vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE - vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge + vector[8] = Vector3.UnitY; //LEFT_NUDGE + vector[9] = -Vector3.UnitY; //RIGHT_NUDGE + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge return vector; } private bool[] GetDirectionIsNudge() { - bool[] isNudge = new bool[9]; + bool[] isNudge = new bool[11]; isNudge[0] = false; //FORWARD isNudge[1] = false; //BACK isNudge[2] = false; //LEFT @@ -751,7 +757,9 @@ namespace OpenSim.Region.Framework.Scenes isNudge[5] = false; //DOWN isNudge[6] = true; //FORWARD_NUDGE isNudge[7] = true; //BACK_NUDGE - isNudge[8] = true; //DOWN_Nudge + isNudge[8] = true; //LEFT_NUDGE + isNudge[9] = true; //RIGHT_NUDGE + isNudge[10] = true; //DOWN_Nudge return isNudge; } -- cgit v1.1 From 63b6b9cdce6382e2285b1a9d76e68a0ac10602ef Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 02:35:27 +0100 Subject: Added animation support for my last commit --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 4 ++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 30a95ce..2c4a4b0 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -158,8 +158,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Check control flags bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); - bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; - bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; + bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); + bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9b04422..a1bb244 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -742,7 +742,7 @@ namespace OpenSim.Region.Framework.Scenes vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE vector[8] = Vector3.UnitY; //LEFT_NUDGE vector[9] = -Vector3.UnitY; //RIGHT_NUDGE - vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE return vector; } -- cgit v1.1 From ac2fcbe224d4877dccc4d73e9c58771e40a4ae1c Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 15:17:44 +0100 Subject: Improvements to rAdmin admin_shutdown and admin_restart. Both methods can now accept a parameter of noticetype = dialog in order to display a blue persistant dropdown instead of a short notice. Added an optional and configurable delay to the restart method, defaulting at 30 seconds as before. Both methods can also accept a noticetype = none dialog in order to act silently. --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4ffa1a2..be1d4bf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -873,6 +873,15 @@ namespace OpenSim.Region.Framework.Scenes /// float indicating duration before restart. public virtual void Restart(float seconds) { + Restart(seconds, true); + } + + /// + /// Given float seconds, this will restart the region. showDialog will optionally alert the users. + /// + /// float indicating duration before restart. + public virtual void Restart(float seconds, bool showDialog) + { // notifications are done in 15 second increments // so .. if the number of seconds is less then 15 seconds, it's not really a restart request // It's a 'Cancel restart' request. @@ -893,8 +902,11 @@ namespace OpenSim.Region.Framework.Scenes m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); m_restartTimer.Start(); - m_dialogModule.SendNotificationToUsersInRegion( - UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); + if (showDialog) + { + m_dialogModule.SendNotificationToUsersInRegion( + UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes"); + } } } -- cgit v1.1 From 22c325aa5ae06b897e5eb10404c0aa3727f8237b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:08:20 +0000 Subject: Remove GetAssemblyName and friends from the SE interface. It's now handled internally --- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 93 ++-------------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 30 ------- 2 files changed, 5 insertions(+), 118 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 3cec77f..9a6f2b8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes public string GetStateSnapshot() { - //m_log.Debug(" >>> GetStateSnapshot <<<"); - - List assemblies = new List(); Dictionary states = new Dictionary(); foreach (SceneObjectPart part in m_parts.Values) { - foreach (string a in part.Inventory.GetScriptAssemblies()) - { - if (a != "" && !assemblies.Contains(a)) - assemblies.Add(a); - } - foreach (KeyValuePair s in part.Inventory.GetScriptStates()) - { states[s.Key] = s.Value; - } } - if (states.Count < 1 || assemblies.Count < 1) + if (states.Count < 1) return ""; XmlDocument xmldoc = new XmlDocument(); @@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes xmldoc.AppendChild(rootElement); - XmlElement wrapper = xmldoc.CreateElement("", "Assemblies", - ""); - rootElement.AppendChild(wrapper); - - foreach (string assembly in assemblies) - { - string fn = Path.GetFileName(assembly); - if (fn == String.Empty) - continue; - - String filedata = String.Empty; - - if (File.Exists(assembly+".text")) - { - FileInfo tfi = new FileInfo(assembly+".text"); - - if (tfi == null) - continue; - - Byte[] tdata = new Byte[tfi.Length]; - - try - { - FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); - } - - filedata = new System.Text.ASCIIEncoding().GetString(tdata); - } - else - { - FileInfo fi = new FileInfo(assembly); - - if (fi == null) - continue; - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); - } - - filedata = System.Convert.ToBase64String(data); - } - XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); - XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); - assemblyName.Value = fn; - assemblyData.Attributes.Append(assemblyName); - - assemblyData.InnerText = filedata; - - wrapper.AppendChild(assemblyData); - } - - wrapper = xmldoc.CreateElement("", "ScriptStates", + XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", ""); rootElement.AppendChild(wrapper); foreach (KeyValuePair state in states) { - XmlElement stateData = xmldoc.CreateElement("", "State", ""); - - XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", ""); - stateID.Value = state.Key.ToString(); - stateData.Attributes.Append(stateID); - XmlDocument sdoc = new XmlDocument(); sdoc.LoadXml(state.Value); - XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNodeList rootL = sdoc.GetElementsByTagName("State"); XmlNode rootNode = rootL[0]; XmlNode newNode = xmldoc.ImportNode(rootNode, true); - stateData.AppendChild(newNode); - wrapper.AppendChild(stateData); + wrapper.AppendChild(newNode); } return xmldoc.InnerXml; @@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(string objXMLData, UUID RegionID) { +m_log.Debug("SetState called with " + objXMLData); if (objXMLData == String.Empty) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index abb04cd..2ef8258 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -880,36 +880,6 @@ namespace OpenSim.Region.Framework.Scenes return ret; } - public string[] GetScriptAssemblies() - { - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - List ret = new List(); - if (engines == null) // No engine at all - return new string[0]; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (e != null) - { - string n = e.GetAssemblyName(item.ItemID); - if (n != String.Empty) - { - if (!ret.Contains(n)) - ret.Add(n); - break; - } - } - } - } - } - return ret.ToArray(); - } - public Dictionary GetScriptStates() { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); -- cgit v1.1 From a27d33cb634c78425eaa34cb5efd113e131baa51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:16:42 +0000 Subject: Remove the old remoting-type interregion code for prim/script crossing --- OpenSim/Region/Framework/Scenes/Scene.cs | 99 ---------------------- .../Framework/Scenes/SceneCommunicationService.cs | 72 ---------------- 2 files changed, 171 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index be1d4bf..f932659 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2393,103 +2393,6 @@ namespace OpenSim.Region.Framework.Scenes return successYN; } - /// - /// Handle a scene object that is crossing into this region from another. - /// NOTE: Unused as of 2009-02-09. Soon to be deleted. - /// - /// - /// - /// - /// - /// - public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod) - { - if (XMLMethod == 0) - { - m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); - SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); - if (sceneObject.IsAttachment) - sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; - - return AddSceneObject(sceneObject); - } - else if ((XMLMethod == 100) && m_allowScriptCrossings) - { - m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor"); - - XmlDocument doc = new XmlDocument(); - doc.LoadXml(objXMLData); - - XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); - if (rootL.Count == 1) - { - XmlNode rootNode = rootL[0]; - if (rootNode != null) - { - XmlNodeList partL = rootNode.ChildNodes; - - foreach (XmlNode part in partL) - { - XmlNodeList nodeL = part.ChildNodes; - - switch (part.Name) - { - case "Assemblies": - foreach (XmlNode asm in nodeL) - { - string fn = asm.Attributes.GetNamedItem("Filename").Value; - - Byte[] filedata = Convert.FromBase64String(asm.InnerText); - string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - } - } - break; - case "ScriptStates": - foreach (XmlNode st in nodeL) - { - string id = st.Attributes.GetNamedItem("UUID").Value; - UUID uuid = new UUID(id); - XmlNode state = st.ChildNodes[0]; - - XmlDocument sdoc = new XmlDocument(); - XmlNode sxmlnode = sdoc.CreateNode( - XmlNodeType.XmlDeclaration, - "", ""); - sdoc.AppendChild(sxmlnode); - - XmlNode newnode = sdoc.ImportNode(state, true); - sdoc.AppendChild(newnode); - - string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - spath = Path.Combine(spath, uuid.ToString()); - FileStream sfs = File.Create(spath + ".state"); - ASCIIEncoding enc = new ASCIIEncoding(); - Byte[] buf = enc.GetBytes(sdoc.InnerXml); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - } - break; - } - } - } - } - - SceneObjectPart RootPrim = GetSceneObjectPart(primID); - RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); - - return true; - } - - return true; - } - public bool IncomingCreateObject(ISceneObject sog) { //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); @@ -3362,7 +3265,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; //m_eventManager.OnRegionUp += OtherRegionUp; //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; m_sceneGridService.KiPrimitive += SendKillObject; @@ -3386,7 +3288,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.KiPrimitive -= SendKillObject; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; - m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; //m_eventManager.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= HandleNewUserConnection; diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 76c6cab..3892769 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// A Prim will arrive shortly /// - public event ExpectPrimDelegate OnExpectPrim; public event CloseAgentConnection OnCloseAgentConnection; /// @@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; - private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; //private RegionUp handlerRegionUp = null; // OnRegionUp; @@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes /// Thrown if region registration fails. public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) { - //m_interregionCommsOut = comms_out; - - //m_regionInfo = regionInfos; - //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; - //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); - - //if (regionCommsHost != null) - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); - - // regionCommsHost.debugRegionName = regionInfos.RegionName; - // regionCommsHost.OnExpectPrim += IncomingPrimCrossing; - // regionCommsHost.OnExpectUser += NewUserConnection; - // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; - // regionCommsHost.OnCloseAgentConnection += CloseConnection; - // regionCommsHost.OnRegionUp += newRegionUp; - // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - // regionCommsHost.OnLogOffUser += GridLogOffUser; - // regionCommsHost.OnGetLandData += FetchLandData; - //} - //else - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); - //} } /// @@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void Close() { - - //if (regionCommsHost != null) - //{ - // regionCommsHost.OnLogOffUser -= GridLogOffUser; - // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; - // regionCommsHost.OnRegionUp -= newRegionUp; - // regionCommsHost.OnExpectUser -= NewUserConnection; - // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; - // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; - // regionCommsHost.OnCloseAgentConnection -= CloseConnection; - // regionCommsHost.OnGetLandData -= FetchLandData; - - // try - // { - // m_commsProvider.GridService.DeregisterRegion(m_regionInfo); - // } - // catch (Exception e) - // { - // m_log.ErrorFormat( - // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", - // m_regionInfo.RegionName, e); - // } - - // regionCommsHost = null; - //} } #region CommsManager Event handlers @@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// We have a new prim from a neighbor - /// - /// unique ID for the primative - /// XML2 encoded data of the primative - /// An Int that represents the version of the XMLMethod - /// True if the prim was accepted, false if it was not - protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod) - { - handlerExpectPrim = OnExpectPrim; - if (handlerExpectPrim != null) - { - return handlerExpectPrim(primID, objXMLData, XMLMethod); - } - else - { - return false; - } - - } - protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) { handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; -- cgit v1.1 From 5dedacca3c9692948f29f5198dd444efe7c8526d Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Thu, 26 Nov 2009 20:37:08 +0100 Subject: First attempt at mult-sit on large single prims. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 91 +++++++++++++++--------- 1 file changed, 58 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a65b84b..e677cfd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -117,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes public Vector4 CollisionPlane = Vector4.UnitW; private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation + private Vector3 m_avUnscriptedSitPos; // for non-scripted prims private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -1644,9 +1645,9 @@ namespace OpenSim.Region.Framework.Scenes { AddToPhysicalScene(false); } - m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); m_parentPosition = Vector3.Zero; +//Console.WriteLine("Stand Pos {0}", m_pos); m_parentID = 0; SendFullUpdateToAllClients(); @@ -1740,21 +1741,37 @@ namespace OpenSim.Region.Framework.Scenes //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + // " TargSet=" + SitTargetisSet); - - if (SitTargetisSet && SitTargetUnOccupied) - { - part.SetAvatarOnSitTarget(UUID); - offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); - sitOrientation = avSitOrientation; - autopilot = false; // Jump direct to scripted llSitPos() - } + // Sit analysis rewritten by KF 091125 + if (SitTargetisSet) // scipted sit + { + if (SitTargetUnOccupied) + { + part.SetAvatarOnSitTarget(UUID); // set that Av will be on it + offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one + sitOrientation = avSitOrientation; // Change rotatione to the scripted one + autopilot = false; // Jump direct to scripted llSitPos() + } + else return; + } + else // Not Scripted + { + if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim + { + Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + m_avUnscriptedSitPos = offset * partIRot; // sit where clicked + pos = part.AbsolutePosition + (offset * partIRot); + } + else // small prim + { + if (SitTargetUnOccupied) + { + m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center + pos = part.AbsolutePosition; + } + else return; // occupied small + } // end large/small + } // end Scripted/not - pos = part.AbsolutePosition + offset; // Region position where clicked - //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) - //{ - // offset = pos; - //autopilot = false; - //} if (m_physicsActor != null) { // If we're not using the client autopilot, we're immediately warping the avatar to the location @@ -1887,8 +1904,9 @@ namespace OpenSim.Region.Framework.Scenes { // Non-scripted sit by Kitto Flora 21Nov09 // Calculate angle of line from prim to Av - float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); - float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); + Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; + float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); + float x_diff = ( m_avInitialPos.X - sitTargetPos.X); if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); @@ -1896,23 +1914,30 @@ namespace OpenSim.Region.Framework.Scenes // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. // Av sits at world euler <0,0, z>, translated by part rotation m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click - m_pos = new Vector3(0f, 0f, 0.05f) + - (new Vector3(0.0f, 0f, 0.625f) * partIRot) + - (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim m_parentPosition = part.AbsolutePosition; - //Set up raytrace to find top surface of prim - Vector3 size = part.Scale; - float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); - Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); - Vector3 down = new Vector3(0f, 0f, -1f); - m_scene.PhysicsScene.RaycastWorld( - start, // Vector3 position, - down, // Vector3 direction, - mag, // float length, - SitAltitudeCallback); // retMethod - } - } - else + if(m_avUnscriptedSitPos != Vector3.Zero) + { // sit where clicked on big prim + m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot); + } + else + { // sit at center of small prim + m_pos = new Vector3(0f, 0f, 0.05f) + + (new Vector3(0.0f, 0f, 0.625f) * partIRot) + + (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); + //Set up raytrace to find top surface of prim + Vector3 size = part.Scale; + float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); + Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); + Vector3 down = new Vector3(0f, 0f, -1f); + m_scene.PhysicsScene.RaycastWorld( + start, // Vector3 position, + down, // Vector3 direction, + mag, // float length, + SitAltitudeCallback); // retMethod + } // end small/big + } // end scripted/not + } + else // no Av { return; } -- cgit v1.1 From aa695e92f7d3b56e6e3371be021d9e6acf91077c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 27 Nov 2009 08:58:26 +0000 Subject: Reset update flag when a SOG is deleted. This fixes llDie(); --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f36ff1d..26a843e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1199,6 +1199,7 @@ namespace OpenSim.Region.Framework.Scenes if (!silent) { + part.UpdateFlag = 0; if (part == m_rootPart) avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); } -- cgit v1.1 From 9888f95068373f1bfdb289e85560a7d873d22696 Mon Sep 17 00:00:00 2001 From: CasperW Date: Fri, 27 Nov 2009 18:29:03 +0100 Subject: Convert multiple lock()s which directly hinder script performance in linksets to ReaderWriterLockSlim. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 400 ++++++++++++++------- 1 file changed, 277 insertions(+), 123 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 26a843e..fb34ddc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -98,6 +98,66 @@ namespace OpenSim.Region.Framework.Scenes private bool m_hasGroupChanged = false; private long timeFirstChanged; private long timeLastChanged; + private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); + + public void lockPartsForRead(bool locked) + { + if (locked) + { + if (m_partsLock.RecursiveReadCount > 0) + { + m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); + m_partsLock.ExitReadLock(); + } + if (m_partsLock.RecursiveWriteCount > 0) + { + m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed."); + m_partsLock.ExitWriteLock(); + } + + while (!m_partsLock.TryEnterReadLock(60000)) + { + m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire READ lock of m_parts in SceneObjectGroup. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); + if (m_partsLock.IsWriteLockHeld) + { + m_partsLock = new System.Threading.ReaderWriterLockSlim(); + } + } + } + else + { + m_partsLock.ExitReadLock(); + } + } + public void lockPartsForWrite(bool locked) + { + if (locked) + { + if (m_partsLock.RecursiveReadCount > 0) + { + m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); + m_partsLock.ExitReadLock(); + } + if (m_partsLock.RecursiveWriteCount > 0) + { + m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed."); + m_partsLock.ExitWriteLock(); + } + + while (!m_partsLock.TryEnterWriteLock(60000)) + { + m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); + if (m_partsLock.IsWriteLockHeld) + { + m_partsLock = new System.Threading.ReaderWriterLockSlim(); + } + } + } + else + { + m_partsLock.ExitWriteLock(); + } + } public bool HasGroupChanged { @@ -243,13 +303,16 @@ namespace OpenSim.Region.Framework.Scenes set { m_regionHandle = value; - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.RegionHandle = m_regionHandle; + } } + lockPartsForRead(false); } } @@ -275,13 +338,16 @@ namespace OpenSim.Region.Framework.Scenes m_scene.CrossPrimGroupIntoNewRegion(val, this, true); } - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.GroupPosition = val; + } } + lockPartsForRead(false); //if (m_rootPart.PhysActor != null) //{ @@ -432,13 +498,16 @@ namespace OpenSim.Region.Framework.Scenes public void SetFromItemID(UUID AssetId) { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.FromItemID = AssetId; + } } + lockPartsForRead(false); } public UUID GetFromItemID() @@ -505,10 +574,11 @@ namespace OpenSim.Region.Framework.Scenes Vector3 maxScale = Vector3.Zero; Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + Vector3 partscale = part.Scale; Vector3 partoffset = part.OffsetPosition; @@ -519,8 +589,11 @@ namespace OpenSim.Region.Framework.Scenes maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; + } } + lockPartsForRead(false); + finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; @@ -536,10 +609,11 @@ namespace OpenSim.Region.Framework.Scenes EntityIntersection result = new EntityIntersection(); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + // Temporary commented to stop compiler warning //Vector3 partPosition = // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); @@ -567,8 +641,10 @@ namespace OpenSim.Region.Framework.Scenes result.distance = inter.distance; } } + } } + lockPartsForRead(false); return result; } @@ -581,10 +657,11 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) { float maxX = -256f, maxY = -256f, maxZ = -256f, minX = 256f, minY = 256f, minZ = 256f; - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + Vector3 worldPos = part.GetWorldPosition(); Vector3 offset = worldPos - AbsolutePosition; Quaternion worldRot; @@ -643,6 +720,8 @@ namespace OpenSim.Region.Framework.Scenes backBottomRight.Y = orig.Y + (part.Scale.Y / 2); backBottomRight.Z = orig.Z - (part.Scale.Z / 2); + + //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); @@ -814,6 +893,7 @@ namespace OpenSim.Region.Framework.Scenes minZ = backBottomLeft.Z; } } + lockPartsForRead(false); Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ); @@ -842,17 +922,20 @@ namespace OpenSim.Region.Framework.Scenes Dictionary states = new Dictionary(); // Capture script state while holding the lock - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + Dictionary pstates = part.Inventory.GetScriptStates(); foreach (UUID itemid in pstates.Keys) { states.Add(itemid, pstates[itemid]); } + } } + lockPartsForRead(false); if (states.Count > 0) { @@ -1014,13 +1097,16 @@ namespace OpenSim.Region.Framework.Scenes public override void UpdateMovement() { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.UpdateMovement(); + } } + lockPartsForRead(false); } public ushort GetTimeDilation() @@ -1064,7 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void AddPart(SceneObjectPart part) { - lock (m_parts) + lockPartsForWrite(true); { part.SetParent(this); m_parts.Add(part.UUID, part); @@ -1074,6 +1160,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.LinkNum == 2 && RootPart != null) RootPart.LinkNum = 1; } + lockPartsForWrite(false); } /// @@ -1081,28 +1168,33 @@ namespace OpenSim.Region.Framework.Scenes /// private void UpdateParentIDs() { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + if (part.UUID != m_rootPart.UUID) { part.ParentID = m_rootPart.LocalId; } + } } + lockPartsForRead(false); } public void RegenerateFullIDs() { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.UUID = UUID.Random(); - + } } + lockPartsForRead(false); } // helper provided for parts. @@ -1183,29 +1275,33 @@ namespace OpenSim.Region.Framework.Scenes DetachFromBackup(); - lock (m_parts) + lockPartsForRead(true); + List values = new List(m_parts.Values); + lockPartsForRead(false); + + foreach (SceneObjectPart part in values) { - foreach (SceneObjectPart part in m_parts.Values) - { // part.Inventory.RemoveScriptInstances(); - - ScenePresence[] avatars = Scene.GetScenePresences(); - for (int i = 0; i < avatars.Length; i++) + + ScenePresence[] avatars = Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) + { + if (avatars[i].ParentID == LocalId) { - if (avatars[i].ParentID == LocalId) - { - avatars[i].StandUp(); - } + avatars[i].StandUp(); + } - if (!silent) - { - part.UpdateFlag = 0; - if (part == m_rootPart) - avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); - } + if (!silent) + { + part.UpdateFlag = 0; + if (part == m_rootPart) + avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); } } + } + + } public void AddScriptLPS(int count) @@ -1230,17 +1326,20 @@ namespace OpenSim.Region.Framework.Scenes scriptEvents aggregateScriptEvents=0; - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + if (part == null) continue; if (part != RootPart) part.ObjectFlags = objectflagupdate; aggregateScriptEvents |= part.AggregateScriptEvents; + } } + lockPartsForRead(false); m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0); m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0); @@ -1273,42 +1372,52 @@ namespace OpenSim.Region.Framework.Scenes /// public void ApplyPhysics(bool m_physicalPrim) { - lock (m_parts) + lockPartsForRead(true); + + if (m_parts.Count > 1) { - if (m_parts.Count > 1) + List values = new List(m_parts.Values); + lockPartsForRead(false); + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); + foreach (SceneObjectPart part in values) { - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); - foreach (SceneObjectPart part in m_parts.Values) + + if (part.LocalId != m_rootPart.LocalId) { - if (part.LocalId != m_rootPart.LocalId) - { - part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim); - } + part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim); } - // Hack to get the physics scene geometries in the right spot - ResetChildPrimPhysicsPositions(); - } - else - { - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); } + // Hack to get the physics scene geometries in the right spot + ResetChildPrimPhysicsPositions(); + } + else + { + lockPartsForRead(false); + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); } } public void SetOwnerId(UUID userId) { - ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); + ForEachPart(delegate(SceneObjectPart part) + { + + part.OwnerID = userId; + + }); } public void ForEachPart(Action whatToDo) { - lock (m_parts) + lockPartsForRead(true); + List values = new List(m_parts.Values); + lockPartsForRead(false); + foreach (SceneObjectPart part in values) { - foreach (SceneObjectPart part in m_parts.Values) - { - whatToDo(part); - } + + whatToDo(part); + } } @@ -1407,14 +1516,17 @@ namespace OpenSim.Region.Framework.Scenes { SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + if (part != RootPart) SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); + } } + lockPartsForRead(false); } /// @@ -1509,10 +1621,11 @@ namespace OpenSim.Region.Framework.Scenes List partList; - lock (m_parts) - { - partList = new List(m_parts.Values); - } + lockPartsForRead(true); + + partList = new List(m_parts.Values); + + lockPartsForRead(false); partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) { @@ -1835,10 +1948,11 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); newPart.SetParent(this); - lock (m_parts) + lockPartsForWrite(true); { m_parts.Add(newPart.UUID, newPart); } + lockPartsForWrite(false); SetPartAsNonRoot(newPart); @@ -1901,7 +2015,7 @@ namespace OpenSim.Region.Framework.Scenes //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) // return; - lock (m_parts) + lockPartsForRead(true); { bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); @@ -1919,34 +2033,43 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in m_parts.Values) { + part.SendScheduledUpdates(); + } } + lockPartsForRead(false); } public void ScheduleFullUpdateToAvatar(ScenePresence presence) { RootPart.AddFullUpdateToAvatar(presence); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + if (part != RootPart) part.AddFullUpdateToAvatar(presence); + } } + lockPartsForRead(false); } public void ScheduleTerseUpdateToAvatar(ScenePresence presence) { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.AddTerseUpdateToAvatar(presence); + } } + lockPartsForRead(false); } /// @@ -1957,14 +2080,17 @@ namespace OpenSim.Region.Framework.Scenes checkAtTargets(); RootPart.ScheduleFullUpdate(); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + if (part != RootPart) part.ScheduleFullUpdate(); + } } + lockPartsForRead(false); } /// @@ -1972,13 +2098,16 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForTerseUpdate() { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + part.ScheduleTerseUpdate(); + } } + lockPartsForRead(false); } /// @@ -1991,14 +2120,17 @@ namespace OpenSim.Region.Framework.Scenes RootPart.SendFullUpdateToAllClients(); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { + if (part != RootPart) part.SendFullUpdateToAllClients(); + } } + lockPartsForRead(false); } /// @@ -2029,14 +2161,15 @@ namespace OpenSim.Region.Framework.Scenes { if (IsDeleted) return; - - lock (m_parts) + + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { part.SendTerseUpdateToAllClients(); } } + lockPartsForRead(false); } #endregion @@ -2050,16 +2183,18 @@ namespace OpenSim.Region.Framework.Scenes /// null if no child part with that linknum or child part public SceneObjectPart GetLinkNumPart(int linknum) { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { if (part.LinkNum == linknum) { + lockPartsForRead(false); return part; } } } + lockPartsForRead(false); return null; } @@ -2087,17 +2222,19 @@ namespace OpenSim.Region.Framework.Scenes public SceneObjectPart GetChildPart(uint localID) { //m_log.DebugFormat("Entered looking for {0}", localID); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { //m_log.DebugFormat("Found {0}", part.LocalId); if (part.LocalId == localID) { + lockPartsForRead(false); return part; } } } + lockPartsForRead(false); return null; } @@ -2127,17 +2264,19 @@ namespace OpenSim.Region.Framework.Scenes public bool HasChildPrim(uint localID) { //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { //m_log.DebugFormat("Found {0}", part.LocalId); if (part.LocalId == localID) { + lockPartsForRead(false); return true; } } } + lockPartsForRead(false); return false; } @@ -2187,53 +2326,57 @@ namespace OpenSim.Region.Framework.Scenes if (m_rootPart.LinkNum == 0) m_rootPart.LinkNum = 1; - lock (m_parts) - { - m_parts.Add(linkPart.UUID, linkPart); + lockPartsForWrite(true); + + m_parts.Add(linkPart.UUID, linkPart); + + lockPartsForWrite(false); - // Insert in terms of link numbers, the new links - // before the current ones (with the exception of - // the root prim. Shuffle the old ones up - foreach (KeyValuePair kvp in m_parts) + // Insert in terms of link numbers, the new links + // before the current ones (with the exception of + // the root prim. Shuffle the old ones up + lockPartsForRead(true); + foreach (KeyValuePair kvp in m_parts) + { + if (kvp.Value.LinkNum != 1) { - if (kvp.Value.LinkNum != 1) - { - // Don't update root prim link number - kvp.Value.LinkNum += objectGroup.PrimCount; - } + // Don't update root prim link number + kvp.Value.LinkNum += objectGroup.PrimCount; } + } + lockPartsForRead(false); - linkPart.LinkNum = 2; + linkPart.LinkNum = 2; - linkPart.SetParent(this); - linkPart.AddFlag(PrimFlags.CreateSelected); + linkPart.SetParent(this); + linkPart.AddFlag(PrimFlags.CreateSelected); - //if (linkPart.PhysActor != null) - //{ - // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); - - //linkPart.PhysActor = null; - //} + //if (linkPart.PhysActor != null) + //{ + // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); + + //linkPart.PhysActor = null; + //} - //TODO: rest of parts - int linkNum = 3; - foreach (SceneObjectPart part in objectGroup.Children.Values) + //TODO: rest of parts + int linkNum = 3; + foreach (SceneObjectPart part in objectGroup.Children.Values) + { + if (part.UUID != objectGroup.m_rootPart.UUID) { - if (part.UUID != objectGroup.m_rootPart.UUID) - { - LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); - } - part.ClearUndoState(); + LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); } + part.ClearUndoState(); } m_scene.UnlinkSceneObject(objectGroup.UUID, true); objectGroup.m_isDeleted = true; + + objectGroup.lockPartsForWrite(true); - lock (objectGroup.m_parts) - { - objectGroup.m_parts.Clear(); - } + objectGroup.m_parts.Clear(); + + objectGroup.lockPartsForWrite(false); // Can't do this yet since backup still makes use of the root part without any synchronization // objectGroup.m_rootPart = null; @@ -2292,11 +2435,12 @@ namespace OpenSim.Region.Framework.Scenes Quaternion worldRot = linkPart.GetWorldRotation(); // Remove the part from this object - lock (m_parts) + lockPartsForWrite(true); { m_parts.Remove(linkPart.UUID); } - + lockPartsForWrite(false); + lockPartsForRead(true); if (m_parts.Count == 1 && RootPart != null) //Single prim is left RootPart.LinkNum = 0; else @@ -2307,6 +2451,7 @@ namespace OpenSim.Region.Framework.Scenes p.LinkNum--; } } + lockPartsForRead(false); linkPart.ParentID = 0; linkPart.LinkNum = 0; @@ -2624,22 +2769,23 @@ namespace OpenSim.Region.Framework.Scenes if (selectionPart != null) { - lock (m_parts) + lockPartsForRead(true); + List parts = new List(m_parts.Values); + lockPartsForRead(false); + foreach (SceneObjectPart part in parts) { - foreach (SceneObjectPart part in m_parts.Values) + if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) { - if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) - { - UsePhysics = false; // Reset physics - break; - } + UsePhysics = false; // Reset physics + break; } + } - foreach (SceneObjectPart part in m_parts.Values) - { - part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); - } + foreach (SceneObjectPart part in parts) + { + part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } + } } @@ -2863,7 +3009,7 @@ namespace OpenSim.Region.Framework.Scenes prevScale.Z *= z; part.Resize(prevScale); - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart obPart in m_parts.Values) { @@ -2882,6 +3028,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + lockPartsForRead(false); if (part.PhysActor != null) { @@ -2962,7 +3109,7 @@ namespace OpenSim.Region.Framework.Scenes axDiff *= Quaternion.Inverse(partRotation); diff = axDiff; - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart obPart in m_parts.Values) { @@ -2972,6 +3119,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + lockPartsForRead(false); AbsolutePosition = newPos; @@ -3089,7 +3237,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); } - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart prim in m_parts.Values) { @@ -3107,6 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + lockPartsForRead(false); m_rootPart.ScheduleTerseUpdate(); } @@ -3205,7 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes if (atTargets.Count > 0) { uint[] localids = new uint[0]; - lock (m_parts) + lockPartsForRead(true); { localids = new uint[m_parts.Count]; int cntr = 0; @@ -3215,6 +3364,7 @@ namespace OpenSim.Region.Framework.Scenes cntr++; } } + lockPartsForRead(false); for (int ctr = 0; ctr < localids.Length; ctr++) { @@ -3233,7 +3383,7 @@ namespace OpenSim.Region.Framework.Scenes { //trigger not_at_target uint[] localids = new uint[0]; - lock (m_parts) + lockPartsForRead(true); { localids = new uint[m_parts.Count]; int cntr = 0; @@ -3243,7 +3393,8 @@ namespace OpenSim.Region.Framework.Scenes cntr++; } } - + lockPartsForRead(false); + for (int ctr = 0; ctr < localids.Length; ctr++) { m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); @@ -3256,19 +3407,20 @@ namespace OpenSim.Region.Framework.Scenes public float GetMass() { float retmass = 0f; - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { retmass += part.GetMass(); } } + lockPartsForRead(false); return retmass; } public void CheckSculptAndLoad() { - lock (m_parts) + lockPartsForRead(true); { if (!IsDeleted) { @@ -3293,6 +3445,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + lockPartsForRead(false); } protected void AssetReceived(string id, Object sender, AssetBase asset) @@ -3313,7 +3466,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SetGroup(UUID GroupID, IClientAPI client) { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) { @@ -3323,7 +3476,7 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; } - + lockPartsForRead(false); ScheduleGroupForFullUpdate(); } @@ -3342,11 +3495,12 @@ namespace OpenSim.Region.Framework.Scenes public void SetAttachmentPoint(byte point) { - lock (m_parts) + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) part.SetAttachmentPoint(point); } + lockPartsForRead(false); } #region ISceneObject -- cgit v1.1 From 2e6dce434f1fd20664a60e464e589798287dcfe3 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 30 Nov 2009 21:52:55 +0100 Subject: Enforce physical prim max size on single prims. Also convert a lock() to ReaderWriterLockSlim that i missed in the last commit --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 119 ++++++++++----------- 1 file changed, 58 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fb34ddc..42481ff 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2871,11 +2871,9 @@ namespace OpenSim.Region.Framework.Scenes scale.Y = m_scene.m_maxNonphys; if (scale.Z > m_scene.m_maxNonphys) scale.Z = m_scene.m_maxNonphys; - SceneObjectPart part = GetChildPart(localID); if (part != null) { - part.Resize(scale); if (part.PhysActor != null) { if (part.PhysActor.IsPhysical) @@ -2890,7 +2888,7 @@ namespace OpenSim.Region.Framework.Scenes part.PhysActor.Size = scale; m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); } - //if (part.UUID != m_rootPart.UUID) + part.Resize(scale); HasGroupChanged = true; ScheduleGroupForFullUpdate(); @@ -2931,77 +2929,76 @@ namespace OpenSim.Region.Framework.Scenes float y = (scale.Y / part.Scale.Y); float z = (scale.Z / part.Scale.Z); - lock (m_parts) + lockPartsForRead(true); + if (x > 1.0f || y > 1.0f || z > 1.0f) { - if (x > 1.0f || y > 1.0f || z > 1.0f) + foreach (SceneObjectPart obPart in m_parts.Values) { - foreach (SceneObjectPart obPart in m_parts.Values) + if (obPart.UUID != m_rootPart.UUID) { - if (obPart.UUID != m_rootPart.UUID) - { - Vector3 oldSize = new Vector3(obPart.Scale); + Vector3 oldSize = new Vector3(obPart.Scale); - float f = 1.0f; - float a = 1.0f; + float f = 1.0f; + float a = 1.0f; - if (part.PhysActor != null && part.PhysActor.IsPhysical) + if (part.PhysActor != null && part.PhysActor.IsPhysical) + { + if (oldSize.X*x > m_scene.m_maxPhys) { - if (oldSize.X*x > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Y*y > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Z*z > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } + f = m_scene.m_maxPhys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; } - else + if (oldSize.Y*y > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Z*z > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } + } + else + { + if (oldSize.X*x > m_scene.m_maxNonphys) { - if (oldSize.X*x > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Y*y > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Z*z > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } + f = m_scene.m_maxNonphys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Y*y > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Z*z > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; } } } } } + lockPartsForRead(false); Vector3 prevScale = part.Scale; prevScale.X *= x; -- cgit v1.1 From cc8246206d5044aff0b306a4bcaf4b321fb826c9 Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Sat, 5 Dec 2009 09:03:02 +0100 Subject: Secnond revision of Sit and Stand for unscripted prims; Comment out spammy debug messages in Interregion.... --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 253 ++++++++++++--------- 2 files changed, 148 insertions(+), 113 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 19e3023..9f2c3db 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -212,6 +212,7 @@ namespace OpenSim.Region.Framework.Scenes private Quaternion m_sitTargetOrientation = Quaternion.Identity; private Vector3 m_sitTargetPosition; private string m_sitAnimation = "SIT"; + private bool m_occupied; // KF if any av is sitting on this prim private string m_text = String.Empty; private string m_touchName = String.Empty; private readonly UndoStack m_undo = new UndoStack(5); @@ -993,6 +994,13 @@ namespace OpenSim.Region.Framework.Scenes get { return _flags; } set { _flags = value; } } + + [XmlIgnore] + public bool IsOccupied // KF If an av is sittingon this prim + { + get { return m_occupied; } + set { m_occupied = value; } + } [XmlIgnore] public UUID SitTargetAvatar diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cebd108..817b9df 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -197,6 +197,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_autopilotMoving; private Vector3 m_autoPilotTarget; private bool m_sitAtAutoTarget; + private Vector3 m_initialSitTarget; //KF: First estimate of where to sit private string m_nextSitAnimation = String.Empty; @@ -1524,7 +1525,6 @@ namespace OpenSim.Region.Framework.Scenes m_sitAtAutoTarget = false; PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; //proxy.PCode = (byte)PCode.ParticleSystem; - proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); proxyObjectGroup.AttachToScene(m_scene); @@ -1566,7 +1566,7 @@ namespace OpenSim.Region.Framework.Scenes } m_moveToPositionInProgress = true; m_moveToPositionTarget = new Vector3(locx, locy, locz); - } + } catch (Exception ex) { //Why did I get this error? @@ -1646,16 +1646,22 @@ namespace OpenSim.Region.Framework.Scenes m_parentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); } + // part.GetWorldRotation() is the rotation of the object being sat on + // Rotation is the sittiing Av's rotation + + Quaternion wr = Quaternion.Inverse(Quaternion.Inverse(Rotation) * Quaternion.Inverse(part.GetWorldRotation())); // world or. of the av + Vector3 so = new Vector3(1.0f, 0f, 0f) * wr; // 1M infront of av + Vector3 wso = so + part.GetWorldPosition() + ( m_pos * part.GetWorldRotation()); // + av sit offset! if (m_physicsActor == null) { AddToPhysicalScene(false); } - m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); + AbsolutePosition = wso; //KF: Fix stand up. m_parentPosition = Vector3.Zero; -//Console.WriteLine("Stand Pos {0}", m_pos); - - m_parentID = 0; + + m_parentID = 0; + part.IsOccupied = false; SendFullUpdateToAllClients(); m_requestedSitTargetID = 0; if ((m_physicsActor != null) && (m_avHeight > 0)) @@ -1694,13 +1700,9 @@ namespace OpenSim.Region.Framework.Scenes Vector3 avSitOffSet = part.SitTargetPosition; Quaternion avSitOrientation = part.SitTargetOrientation; UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); - - bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); - bool SitTargetisSet = - (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && - avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); - // this test is probably failing - if (SitTargetisSet && SitTargetUnOccupied) + bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); + bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. + if (SitTargetisSet && !SitTargetOccupied) { //switch the target to this prim return part; @@ -1714,7 +1716,7 @@ namespace OpenSim.Region.Framework.Scenes private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset) { bool autopilot = true; - Vector3 pos = new Vector3(); + Vector3 autopilotTarget = new Vector3(); Quaternion sitOrientation = Quaternion.Identity; Vector3 cameraEyeOffset = Vector3.Zero; Vector3 cameraAtOffset = Vector3.Zero; @@ -1722,98 +1724,104 @@ namespace OpenSim.Region.Framework.Scenes //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); SceneObjectPart part = FindNextAvailableSitTarget(targetID); - if (part != null) - { - // TODO: determine position to sit at based on scene geometry; don't trust offset from client - // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it + if (part == null) return; + + // TODO: determine position to sit at based on scene geometry; don't trust offset from client + // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - // part is the prim to sit on - // offset is the vector distance from that prim center to the click-spot - // UUID is the UUID of the Avatar doing the clicking - - m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation + // part is the prim to sit on + // offset is the world-ref vector distance from that prim center to the click-spot + // UUID is the UUID of the Avatar doing the clicking - // Is a sit target available? - Vector3 avSitOffSet = part.SitTargetPosition; - Quaternion avSitOrientation = part.SitTargetOrientation; - UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); - - bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); -// bool SitTargetisSet = -// (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && -// avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); - - bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); - -//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + -// " TargSet=" + SitTargetisSet); - // Sit analysis rewritten by KF 091125 - if (SitTargetisSet) // scipted sit - { - if (SitTargetUnOccupied) - { - part.SetAvatarOnSitTarget(UUID); // set that Av will be on it - offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one - sitOrientation = avSitOrientation; // Change rotatione to the scripted one - autopilot = false; // Jump direct to scripted llSitPos() - } - else return; + m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation + + // Is a sit target available? + Vector3 avSitOffSet = part.SitTargetPosition; + Quaternion avSitOrientation = part.SitTargetOrientation; + + bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. + Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + +//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); + // Sit analysis rewritten by KF 091125 + if (SitTargetisSet) // scipted sit + { + if (!part.IsOccupied) + { +//Console.WriteLine("Scripted, unoccupied"); + part.SetAvatarOnSitTarget(UUID); // set that Av will be on it + offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one + sitOrientation = avSitOrientation; // Change rotatione to the scripted one + autopilot = false; // Jump direct to scripted llSitPos() } - else // Not Scripted - { - if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim - { - Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); - m_avUnscriptedSitPos = offset * partIRot; // sit where clicked - pos = part.AbsolutePosition + (offset * partIRot); - } - else // small prim - { - if (SitTargetUnOccupied) - { - m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center - pos = part.AbsolutePosition; - } - else return; // occupied small - } // end large/small - } // end Scripted/not - - if (m_physicsActor != null) - { - // If we're not using the client autopilot, we're immediately warping the avatar to the location - // We can remove the physicsActor until they stand up. - m_sitAvatarHeight = m_physicsActor.Size.Z; - - if (autopilot) - { // its not a scripted sit - if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) - { - autopilot = false; // close enough + else + { +//Console.WriteLine("Scripted, occupied"); + return; + } + } + else // Not Scripted + { + if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) + { + // large prim & offset, ignore if other Avs sitting +// offset.Z -= 0.05f; + m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked + autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point + +//Console.WriteLine(" offset ={0}", offset); +//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); +//Console.WriteLine(" autopilotTarget={0}", autopilotTarget); + + } + else // small offset + { +//Console.WriteLine("Small offset"); + if (!part.IsOccupied) + { + m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center + autopilotTarget = part.AbsolutePosition; + } + else return; // occupied small + } // end large/small + } // end Scripted/not + cameraAtOffset = part.GetCameraAtOffset(); + cameraEyeOffset = part.GetCameraEyeOffset(); + forceMouselook = part.GetForceMouselook(); - RemoveFromPhysicalScene(); - AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim - } // else the autopilot will get us close - } - else - { // its a scripted sit + if (m_physicsActor != null) + { + // If we're not using the client autopilot, we're immediately warping the avatar to the location + // We can remove the physicsActor until they stand up. + m_sitAvatarHeight = m_physicsActor.Size.Z; + if (autopilot) + { // its not a scripted sit +// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) + if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) + { + autopilot = false; // close enough RemoveFromPhysicalScene(); - } + AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target + } // else the autopilot will get us close + } + else + { // its a scripted sit + RemoveFromPhysicalScene(); } - - cameraAtOffset = part.GetCameraAtOffset(); - cameraEyeOffset = part.GetCameraEyeOffset(); - forceMouselook = part.GetForceMouselook(); } + else return; // physactor is null! - ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); - m_requestedSitTargetUUID = targetID; + Vector3 offsetr = offset * partIRot; + ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though // which happens in HandleAgentSit :P m_autopilotMoving = autopilot; - m_autoPilotTarget = pos; + m_autoPilotTarget = autopilotTarget; m_sitAtAutoTarget = autopilot; + m_initialSitTarget = autopilotTarget; if (!autopilot) HandleAgentSit(remoteClient, UUID); } @@ -1898,6 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes { if (part.GetAvatarOnSitTarget() == UUID) { +//Console.WriteLine("Scripted Sit"); // Scripted sit Vector3 sitTargetPos = part.SitTargetPosition; Quaternion sitTargetOrient = part.SitTargetOrientation; @@ -1905,42 +1914,44 @@ namespace OpenSim.Region.Framework.Scenes m_pos += SIT_TARGET_ADJUSTMENT; m_bodyRot = sitTargetOrient; m_parentPosition = part.AbsolutePosition; + part.IsOccupied = true; } else { +//Console.WriteLine("NON Scripted Sit"); + // if m_avUnscriptedSitPos is zero then Av sits above center + // Else Av sits at m_avUnscriptedSitPos + // Non-scripted sit by Kitto Flora 21Nov09 // Calculate angle of line from prim to Av + Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); float x_diff = ( m_avInitialPos.X - sitTargetPos.X); if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); - Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. // Av sits at world euler <0,0, z>, translated by part rotation m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click + m_parentPosition = part.AbsolutePosition; - if(m_avUnscriptedSitPos != Vector3.Zero) - { // sit where clicked on big prim - m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot); - } - else - { // sit at center of small prim - m_pos = new Vector3(0f, 0f, 0.05f) + - (new Vector3(0.0f, 0f, 0.625f) * partIRot) + - (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); - //Set up raytrace to find top surface of prim - Vector3 size = part.Scale; - float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); - Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); - Vector3 down = new Vector3(0f, 0f, -1f); - m_scene.PhysicsScene.RaycastWorld( + part.IsOccupied = true; + m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation + (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center + (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + + m_avUnscriptedSitPos; // adds click offset, if any + //Set up raytrace to find top surface of prim + Vector3 size = part.Scale; + float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); + Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); + Vector3 down = new Vector3(0f, 0f, -1f); +//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); + m_scene.PhysicsScene.RaycastWorld( start, // Vector3 position, down, // Vector3 direction, mag, // float length, SitAltitudeCallback); // retMethod - } // end small/big } // end scripted/not } else // no Av @@ -1957,19 +1968,24 @@ namespace OpenSim.Region.Framework.Scenes SendFullUpdateToAllClients(); } - public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) + public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) // KF: Nov 2009 { + // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer + // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. if(hitYN) { // m_pos = Av offset from prim center to make look like on center // m_parentPosition = Actual center pos of prim // collisionPoint = spot on prim where we want to sit + // collisionPoint.Z = global sit surface height SceneObjectPart part = m_scene.GetSceneObjectPart(localid); - Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); + Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + float offZ = collisionPoint.Z - m_initialSitTarget.Z; + Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction +//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); m_pos += offset; -// Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); } - } + } // End SitAltitudeCallback KF. /// /// Event handler for the 'Always run' setting on the client @@ -3716,5 +3732,16 @@ namespace OpenSim.Region.Framework.Scenes m_reprioritization_called = false; } } + + private Vector3 Quat2Euler(Quaternion rot){ + float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , + (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); + float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); + float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , + (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); + return(new Vector3(x,y,z)); + } + + } } -- cgit v1.1 From ceccfe02d0e25c234560b6ef25306b8db4cd9875 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 00:02:24 +0000 Subject: Eliminate multiple updates on link/unlink --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 ++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 2fdb48d..d87e814 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1593,6 +1593,8 @@ namespace OpenSim.Region.Framework.Scenes // occur on link to invoke this elsewhere (such as object selection) parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); parentGroup.TriggerScriptChangedEvent(Changed.LINK); + parentGroup.HasGroupChanged = true; + parentGroup.ScheduleGroupForFullUpdate(); if (client != null) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ecda80c..fa2e3ce 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2389,8 +2389,8 @@ namespace OpenSim.Region.Framework.Scenes // unmoved prims! ResetChildPrimPhysicsPositions(); - HasGroupChanged = true; - ScheduleGroupForFullUpdate(); + //HasGroupChanged = true; + //ScheduleGroupForFullUpdate(); } /// @@ -2483,8 +2483,8 @@ namespace OpenSim.Region.Framework.Scenes linkPart.Rezzed = RootPart.Rezzed; - HasGroupChanged = true; - ScheduleGroupForFullUpdate(); + //HasGroupChanged = true; + //ScheduleGroupForFullUpdate(); } /// -- cgit v1.1 From fbefa8273be70d90404b37230c168fd031288e31 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 00:25:04 +0000 Subject: Lock updates out while linking and unlinking --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 255 ++++++++++++++------------ 1 file changed, 134 insertions(+), 121 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d87e814..5efe188 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -26,6 +26,7 @@ */ using System; +using System.Threading; using System.Collections.Generic; using System.Reflection; using OpenMetaverse; @@ -96,6 +97,8 @@ namespace OpenSim.Region.Framework.Scenes protected internal Dictionary SceneObjectGroupsByFullID = new Dictionary(); private readonly Object m_dictionary_lock = new Object(); + private Object m_updateLock = new Object(); + #endregion protected internal SceneGraph(Scene parent, RegionInfo regInfo) @@ -369,6 +372,9 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void UpdateObjectGroups() { + if (!Monitor.TryEnter(m_updateLock)) + return; + List updates; // Some updates add more updates to the updateList. @@ -395,6 +401,7 @@ namespace OpenSim.Region.Framework.Scenes "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); } } + Monitor.Exit(m_updateLock); } protected internal void AddPhysicalPrim(int number) @@ -1555,56 +1562,59 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds) { - SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId); - - List childGroups = new List(); - if (parentGroup != null) + lock (m_updateLock) { - // We do this in reverse to get the link order of the prims correct - for (int i = childPrimIds.Count - 1; i >= 0; i--) + SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId); + + List childGroups = new List(); + if (parentGroup != null) { - SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]); - if (child != null) + // We do this in reverse to get the link order of the prims correct + for (int i = childPrimIds.Count - 1; i >= 0; i--) { - // Make sure no child prim is set for sale - // So that, on delink, no prims are unwittingly - // left for sale and sold off - child.RootPart.ObjectSaleType = 0; - child.RootPart.SalePrice = 10; - childGroups.Add(child); + SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]); + if (child != null) + { + // Make sure no child prim is set for sale + // So that, on delink, no prims are unwittingly + // left for sale and sold off + child.RootPart.ObjectSaleType = 0; + child.RootPart.SalePrice = 10; + childGroups.Add(child); + } } } - } - else - { - return; // parent is null so not in this region - } + else + { + return; // parent is null so not in this region + } - foreach (SceneObjectGroup child in childGroups) - { - parentGroup.LinkToGroup(child); + foreach (SceneObjectGroup child in childGroups) + { + parentGroup.LinkToGroup(child); - // this is here so physics gets updated! - // Don't remove! Bad juju! Stay away! or fix physics! - child.AbsolutePosition = child.AbsolutePosition; - } + // this is here so physics gets updated! + // Don't remove! Bad juju! Stay away! or fix physics! + child.AbsolutePosition = child.AbsolutePosition; + } - // We need to explicitly resend the newly link prim's object properties since no other actions - // occur on link to invoke this elsewhere (such as object selection) - parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); - parentGroup.TriggerScriptChangedEvent(Changed.LINK); - parentGroup.HasGroupChanged = true; - parentGroup.ScheduleGroupForFullUpdate(); - - if (client != null) - { - parentGroup.GetProperties(client); - } - else - { - foreach (ScenePresence p in GetScenePresences()) + // We need to explicitly resend the newly link prim's object properties since no other actions + // occur on link to invoke this elsewhere (such as object selection) + parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); + parentGroup.TriggerScriptChangedEvent(Changed.LINK); + parentGroup.HasGroupChanged = true; + parentGroup.ScheduleGroupForFullUpdate(); + + if (client != null) { - parentGroup.GetProperties(p.ControllingClient); + parentGroup.GetProperties(client); + } + else + { + foreach (ScenePresence p in GetScenePresences()) + { + parentGroup.GetProperties(p.ControllingClient); + } } } } @@ -1620,109 +1630,112 @@ namespace OpenSim.Region.Framework.Scenes protected internal void DelinkObjects(List primIds, bool sendEvents) { - List childParts = new List(); - List rootParts = new List(); - List affectedGroups = new List(); - // Look them all up in one go, since that is comparatively expensive - // - foreach (uint primID in primIds) + lock (m_updateLock) { - SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID); - if (part != null) + List childParts = new List(); + List rootParts = new List(); + List affectedGroups = new List(); + // Look them all up in one go, since that is comparatively expensive + // + foreach (uint primID in primIds) { - if (part.LinkNum < 2) // Root or single - rootParts.Add(part); + SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID); + if (part != null) + { + if (part.LinkNum < 2) // Root or single + rootParts.Add(part); + else + childParts.Add(part); + + SceneObjectGroup group = part.ParentGroup; + if (!affectedGroups.Contains(group)) + affectedGroups.Add(group); + } else - childParts.Add(part); - - SceneObjectGroup group = part.ParentGroup; - if (!affectedGroups.Contains(group)) - affectedGroups.Add(group); + { + m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID); + } } - else + + foreach (SceneObjectPart child in childParts) { - m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID); + // Unlink all child parts from their groups + // + child.ParentGroup.DelinkFromGroup(child, sendEvents); } - } - foreach (SceneObjectPart child in childParts) - { - // Unlink all child parts from their groups - // - child.ParentGroup.DelinkFromGroup(child, sendEvents); - } - - foreach (SceneObjectPart root in rootParts) - { - // In most cases, this will run only one time, and the prim - // will be a solo prim - // However, editing linked parts and unlinking may be different - // - SceneObjectGroup group = root.ParentGroup; - List newSet = new List(group.Children.Values); - int numChildren = group.Children.Count; - - // If there are prims left in a link set, but the root is - // slated for unlink, we need to do this - // - if (numChildren != 1) + foreach (SceneObjectPart root in rootParts) { - // Unlink the remaining set + // In most cases, this will run only one time, and the prim + // will be a solo prim + // However, editing linked parts and unlinking may be different // - bool sendEventsToRemainder = true; - if (numChildren > 1) - sendEventsToRemainder = false; - - foreach (SceneObjectPart p in newSet) - { - if (p != group.RootPart) - group.DelinkFromGroup(p, sendEventsToRemainder); - } + SceneObjectGroup group = root.ParentGroup; + List newSet = new List(group.Children.Values); + int numChildren = group.Children.Count; - // If there is more than one prim remaining, we - // need to re-link + // If there are prims left in a link set, but the root is + // slated for unlink, we need to do this // - if (numChildren > 2) + if (numChildren != 1) { - // Remove old root + // Unlink the remaining set // - if (newSet.Contains(root)) - newSet.Remove(root); + bool sendEventsToRemainder = true; + if (numChildren > 1) + sendEventsToRemainder = false; - // Preserve link ordering - // - newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) + foreach (SceneObjectPart p in newSet) { - return a.LinkNum.CompareTo(b.LinkNum); - }); + if (p != group.RootPart) + group.DelinkFromGroup(p, sendEventsToRemainder); + } - // Determine new root + // If there is more than one prim remaining, we + // need to re-link // - SceneObjectPart newRoot = newSet[0]; - newSet.RemoveAt(0); + if (numChildren > 2) + { + // Remove old root + // + if (newSet.Contains(root)) + newSet.Remove(root); + + // Preserve link ordering + // + newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) + { + return a.LinkNum.CompareTo(b.LinkNum); + }); - List linkIDs = new List(); + // Determine new root + // + SceneObjectPart newRoot = newSet[0]; + newSet.RemoveAt(0); - foreach (SceneObjectPart newChild in newSet) - { - newChild.UpdateFlag = 0; - linkIDs.Add(newChild.LocalId); - } + List linkIDs = new List(); + + foreach (SceneObjectPart newChild in newSet) + { + newChild.UpdateFlag = 0; + linkIDs.Add(newChild.LocalId); + } - LinkObjects(null, newRoot.LocalId, linkIDs); - if (!affectedGroups.Contains(newRoot.ParentGroup)) - affectedGroups.Add(newRoot.ParentGroup); + LinkObjects(null, newRoot.LocalId, linkIDs); + if (!affectedGroups.Contains(newRoot.ParentGroup)) + affectedGroups.Add(newRoot.ParentGroup); + } } } - } - // Finally, trigger events in the roots - // - foreach (SceneObjectGroup g in affectedGroups) - { - g.TriggerScriptChangedEvent(Changed.LINK); - g.HasGroupChanged = true; // Persist - g.ScheduleGroupForFullUpdate(); + // Finally, trigger events in the roots + // + foreach (SceneObjectGroup g in affectedGroups) + { + g.TriggerScriptChangedEvent(Changed.LINK); + g.HasGroupChanged = true; // Persist + g.ScheduleGroupForFullUpdate(); + } } } -- cgit v1.1 From f2891e77383f70d807f4ef1ceefbf9a0f2bf6a84 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 00:50:28 +0000 Subject: Remove extra forced updates. They're not needed for each prim. Really. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fa2e3ce..93888f1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2292,14 +2292,14 @@ namespace OpenSim.Region.Framework.Scenes public void LinkToGroup(SceneObjectGroup objectGroup) { // Make sure we have sent any pending unlinks or stuff. - if (objectGroup.RootPart.UpdateFlag > 0) - { - m_log.WarnFormat( - "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.", - objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); + //if (objectGroup.RootPart.UpdateFlag > 0) + //{ + // m_log.WarnFormat( + // "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.", + // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); - objectGroup.RootPart.SendScheduledUpdates(); - } + // objectGroup.RootPart.SendScheduledUpdates(); + //} // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", -- cgit v1.1 From da414fd509a6adfa0499b71172e1c789b3cf7ca4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 01:20:39 +0000 Subject: Change locking to not mix explicit Monitor.* calls with lock() --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5efe188..4bdc52c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1562,7 +1562,8 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds) { - lock (m_updateLock) + Monitor.Enter(m_updateLock); + try { SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId); @@ -1617,6 +1618,10 @@ namespace OpenSim.Region.Framework.Scenes } } } + finally + { + Monitor.Exit(m_updateLock); + } } /// @@ -1630,7 +1635,8 @@ namespace OpenSim.Region.Framework.Scenes protected internal void DelinkObjects(List primIds, bool sendEvents) { - lock (m_updateLock) + Monitor.Enter(m_updateLock); + try { List childParts = new List(); List rootParts = new List(); @@ -1737,6 +1743,10 @@ namespace OpenSim.Region.Framework.Scenes g.ScheduleGroupForFullUpdate(); } } + finally + { + Monitor.Exit(m_updateLock); + } } protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID) -- cgit v1.1 From 2fe75a62bec2f06155bf5f05b6f558d028f6b12c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 02:00:32 +0000 Subject: Skip single prims in unlink selections --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 4bdc52c..18e7b79 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1648,14 +1648,17 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID); if (part != null) { - if (part.LinkNum < 2) // Root or single - rootParts.Add(part); - else - childParts.Add(part); - - SceneObjectGroup group = part.ParentGroup; - if (!affectedGroups.Contains(group)) - affectedGroups.Add(group); + if (part.ParentGroup.Children.Count != 1) // Skip single + { + if (part.LinkNum < 2) // Root + rootParts.Add(part); + else + childParts.Add(part); + + SceneObjectGroup group = part.ParentGroup; + if (!affectedGroups.Contains(group)) + affectedGroups.Add(group); + } } else { -- cgit v1.1 From 79511ecce240a864dc02575acd3399fb244a8d82 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 02:15:52 +0000 Subject: Experimental: Remove explicit property sends --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 18e7b79..f74fd5d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1606,17 +1606,17 @@ namespace OpenSim.Region.Framework.Scenes parentGroup.HasGroupChanged = true; parentGroup.ScheduleGroupForFullUpdate(); - if (client != null) - { - parentGroup.GetProperties(client); - } - else - { - foreach (ScenePresence p in GetScenePresences()) - { - parentGroup.GetProperties(p.ControllingClient); - } - } +// if (client != null) +// { +// parentGroup.GetProperties(client); +// } +// else +// { +// foreach (ScenePresence p in GetScenePresences()) +// { +// parentGroup.GetProperties(p.ControllingClient); +// } +// } } finally { -- cgit v1.1 From f9ae9afaacc82ee0284b1f7dc88ad880aabe23af Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 03:10:34 +0000 Subject: Fix build break from conflicted merge --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3d4490a..f6bcb59 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1972,7 +1972,7 @@ namespace OpenSim.Region.Framework.Scenes SendFullUpdateToAllClients(); } - public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) + public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) { if(hitYN) { -- cgit v1.1 From 1e222d52e6219db4ad32338b952a94eebb0f7799 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Dec 2009 03:56:15 +0000 Subject: Change EntityManager to use RWlocks --- OpenSim/Region/Framework/Scenes/EntityManager.cs | 79 ++++++++++++++++++++---- 1 file changed, 67 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs index 099fcce..c246e32 100644 --- a/OpenSim/Region/Framework/Scenes/EntityManager.cs +++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes private readonly Dictionary m_eb_uuid = new Dictionary(); private readonly Dictionary m_eb_localID = new Dictionary(); //private readonly Dictionary m_pres_uuid = new Dictionary(); - private readonly Object m_lock = new Object(); + private System.Threading.ReaderWriterLockSlim m_lock = new System.Threading.ReaderWriterLockSlim(); [Obsolete("Use Add() instead.")] public void Add(UUID id, EntityBase eb) @@ -50,7 +50,8 @@ namespace OpenSim.Region.Framework.Scenes public void Add(EntityBase entity) { - lock (m_lock) + m_lock.EnterWriteLock(); + try { try { @@ -62,11 +63,16 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("Add Entity failed: {0}", e.Message); } } + finally + { + m_lock.ExitWriteLock(); + } } public void InsertOrReplace(EntityBase entity) { - lock (m_lock) + m_lock.EnterWriteLock(); + try { try { @@ -78,15 +84,24 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message); } } + finally + { + m_lock.ExitWriteLock(); + } } public void Clear() { - lock (m_lock) + m_lock.EnterWriteLock(); + try { m_eb_uuid.Clear(); m_eb_localID.Clear(); } + finally + { + m_lock.ExitWriteLock(); + } } public int Count @@ -123,7 +138,8 @@ namespace OpenSim.Region.Framework.Scenes public bool Remove(uint localID) { - lock (m_lock) + m_lock.EnterWriteLock(); + try { try { @@ -141,11 +157,16 @@ namespace OpenSim.Region.Framework.Scenes return false; } } + finally + { + m_lock.ExitWriteLock(); + } } public bool Remove(UUID id) { - lock (m_lock) + m_lock.EnterWriteLock(); + try { try { @@ -163,13 +184,18 @@ namespace OpenSim.Region.Framework.Scenes return false; } } + finally + { + m_lock.ExitWriteLock(); + } } public List GetAllByType() { List tmp = new List(); - lock (m_lock) + m_lock.EnterReadLock(); + try { try { @@ -187,23 +213,33 @@ namespace OpenSim.Region.Framework.Scenes tmp = null; } } + finally + { + m_lock.ExitReadLock(); + } return tmp; } public List GetEntities() { - lock (m_lock) + m_lock.EnterReadLock(); + try { return new List(m_eb_uuid.Values); } + finally + { + m_lock.ExitReadLock(); + } } public EntityBase this[UUID id] { get { - lock (m_lock) + m_lock.EnterReadLock(); + try { EntityBase entity; if (m_eb_uuid.TryGetValue(id, out entity)) @@ -211,6 +247,10 @@ namespace OpenSim.Region.Framework.Scenes else return null; } + finally + { + m_lock.ExitReadLock(); + } } set { @@ -222,7 +262,8 @@ namespace OpenSim.Region.Framework.Scenes { get { - lock (m_lock) + m_lock.EnterReadLock(); + try { EntityBase entity; if (m_eb_localID.TryGetValue(localID, out entity)) @@ -230,6 +271,10 @@ namespace OpenSim.Region.Framework.Scenes else return null; } + finally + { + m_lock.ExitReadLock(); + } } set { @@ -239,18 +284,28 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetValue(UUID key, out EntityBase obj) { - lock (m_lock) + m_lock.EnterReadLock(); + try { return m_eb_uuid.TryGetValue(key, out obj); } + finally + { + m_lock.ExitReadLock(); + } } public bool TryGetValue(uint key, out EntityBase obj) { - lock (m_lock) + m_lock.EnterReadLock(); + try { return m_eb_localID.TryGetValue(key, out obj); } + finally + { + m_lock.ExitReadLock(); + } } /// -- cgit v1.1 From 172e2f4e7609c278d02ad83ca207fd79624db587 Mon Sep 17 00:00:00 2001 From: CasperW Date: Sun, 6 Dec 2009 17:23:07 +0100 Subject: Fix to existing ReaderWriterLockSlim implementations --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++++-- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 93888f1..eacd219 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -126,7 +126,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_partsLock.ExitReadLock(); + if (m_partsLock.RecursiveReadCount > 0) + { + m_partsLock.ExitReadLock(); + } } } public void lockPartsForWrite(bool locked) @@ -155,7 +158,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_partsLock.ExitWriteLock(); + if (m_partsLock.RecursiveWriteCount > 0) + { + m_partsLock.ExitWriteLock(); + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4780ff2..b57d912 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -320,17 +320,18 @@ namespace OpenSim.Region.Framework.Scenes { if (m_items.ContainsKey(itemId)) { + m_items.LockItemsForRead(false); CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); } else { + m_items.LockItemsForRead(false); m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", itemId, m_part.Name, m_part.UUID, m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); } - m_items.LockItemsForRead(false); } else { -- cgit v1.1 From 0d1d437bd3bf608448d71ea7de8e4f7cfb0371f0 Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Sun, 6 Dec 2009 21:11:59 +0100 Subject: Fix linked physical daughter prim position update. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 ++++++++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 -- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9f2c3db..a6382ee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -513,9 +513,16 @@ namespace OpenSim.Region.Framework.Scenes { // If this is a linkset, we don't want the physics engine mucking up our group position here. PhysicsActor actor = PhysActor; - if (actor != null && _parentID == 0) + if (actor != null) { - m_groupPosition = actor.Position; + if (_parentID == 0) + { + m_groupPosition = actor.Position; + } + else + { + m_groupPosition = ParentGroup.AbsolutePosition; // KF+Casper Update Child prims too! + } } if (IsAttachment) @@ -1743,9 +1750,13 @@ namespace OpenSim.Region.Framework.Scenes Quaternion parentRot = ParentGroup.RootPart.RotationOffset; Vector3 axPos = OffsetPosition; - axPos *= parentRot; Vector3 translationOffsetPosition = axPos; + + int tx = (int)GroupPosition.X; + int ty = (int)GroupPosition.Y; + int tz = (int)GroupPosition.Z; + return GroupPosition + translationOffsetPosition; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 817b9df..5d0218f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1642,7 +1642,6 @@ namespace OpenSim.Region.Framework.Scenes // Reset sit target. if (part.GetAvatarOnSitTarget() == UUID) part.SetAvatarOnSitTarget(UUID.Zero); - m_parentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); } @@ -1659,7 +1658,6 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = wso; //KF: Fix stand up. m_parentPosition = Vector3.Zero; - m_parentID = 0; part.IsOccupied = false; SendFullUpdateToAllClients(); -- cgit v1.1 From 29a740ec8c78bfc3c1ab5b41b302ae2205c6e9aa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Dec 2009 18:03:53 +0100 Subject: Initial windlight codebase commit --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f5a1e74..f70af27 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -539,6 +539,8 @@ namespace OpenSim.Region.Framework.Scenes // Load region settings m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); + m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(m_regInfo.RegionID); + if (m_storageManager.EstateDataStore != null) { m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 8a27b7b..e8cda60 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs @@ -101,7 +101,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests { throw new NotImplementedException(); } - + public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID) + { + //This connector doesn't support the windlight module yet + //Return default LL windlight settings + return new RegionMeta7WindlightData(); + } public RegionSettings LoadRegionSettings(UUID regionUUID) { return null; -- cgit v1.1 From ee9d46c8255840473ed62c3b37270b35af1a9027 Mon Sep 17 00:00:00 2001 From: KittoFlora Date: Tue, 8 Dec 2009 05:49:05 +0100 Subject: Correct AbsolutePosition calculation --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a6382ee..a23c11e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -849,7 +849,8 @@ namespace OpenSim.Region.Framework.Scenes if (IsAttachment) return GroupPosition; - return m_offsetPosition + m_groupPosition; } +// return m_offsetPosition + m_groupPosition; } + return m_groupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset) ; } //KF: Rotation was ignored! } public SceneObjectGroup ParentGroup -- cgit v1.1 From e3f229225c5a1506090bfcffcce6d423a566f1fe Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Dec 2009 01:34:26 +0100 Subject: Enable scripting interface for windlight --- OpenSim/Region/Framework/Scenes/EventManager.cs | 12 ++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 4 ++++ 3 files changed, 23 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 753344d..a86e263 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -193,7 +193,9 @@ namespace OpenSim.Region.Framework.Scenes public event OnMakeChildAgentDelegate OnMakeChildAgent; public delegate void OnMakeRootAgentDelegate(ScenePresence presence); + public delegate void OnSaveNewWindlightProfileDelegate(); public event OnMakeRootAgentDelegate OnMakeRootAgent; + public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); @@ -411,6 +413,7 @@ namespace OpenSim.Region.Framework.Scenes private IncomingInstantMessage handlerUnhandledInstantMessage = null; //OnUnhandledInstantMessage; private ClientClosed handlerClientClosed = null; //OnClientClosed; private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; + private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile; private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent; private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; @@ -772,6 +775,15 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerOnSaveNewWindlightProfile() + { + handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile; + if (handlerSaveNewWindlightProfile != null) + { + handlerSaveNewWindlightProfile(); + } + } + public void TriggerOnMakeRootAgent(ScenePresence presence) { handlerMakeRootAgent = OnMakeRootAgent; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8d91d65..475d775 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1505,6 +1505,13 @@ namespace OpenSim.Region.Framework.Scenes m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); } + public void StoreWindlightProfile(RegionMeta7WindlightData wl) + { + m_regInfo.WindlightSettings = wl; + m_storageManager.DataStore.StoreRegionWindlightSettings(wl); + m_eventManager.TriggerOnSaveNewWindlightProfile(); + } + /// /// Loads the World heightmap /// diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index e8cda60..5abbb82 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs @@ -107,6 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests //Return default LL windlight settings return new RegionMeta7WindlightData(); } + public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl) + { + //This connector doesn't support the windlight module yet + } public RegionSettings LoadRegionSettings(UUID regionUUID) { return null; -- cgit v1.1 From 2a6dbd068ef48c7605f44153dcfea6b215749bed Mon Sep 17 00:00:00 2001 From: CasperW Date: Wed, 9 Dec 2009 03:58:56 +0100 Subject: Last bits and bobs to clean up the Meta7WindlightModule --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 475d775..1b275b0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1504,7 +1504,7 @@ namespace OpenSim.Region.Framework.Scenes { m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); } - + public void StoreWindlightProfile(RegionMeta7WindlightData wl) { m_regInfo.WindlightSettings = wl; @@ -1512,6 +1512,12 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager.TriggerOnSaveNewWindlightProfile(); } + public void LoadWindlightProfile() + { + m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(RegionInfo.RegionID); + m_eventManager.TriggerOnSaveNewWindlightProfile(); + } + /// /// Loads the World heightmap /// -- cgit v1.1 From b056c243e46daa3370f8d330b70a37b5f856e9ec Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Sat, 12 Dec 2009 10:12:59 -0500 Subject: Commit partial work because of repo change --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 83 ++++++++++++++++++++---- 1 file changed, 72 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c553ca0..d0c20ff 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1660,16 +1660,27 @@ namespace OpenSim.Region.Framework.Scenes } // part.GetWorldRotation() is the rotation of the object being sat on // Rotation is the sittiing Av's rotation - - Quaternion wr = Quaternion.Inverse(Quaternion.Inverse(Rotation) * Quaternion.Inverse(part.GetWorldRotation())); // world or. of the av - Vector3 so = new Vector3(1.0f, 0f, 0f) * wr; // 1M infront of av - Vector3 wso = so + part.GetWorldPosition() + ( m_pos * part.GetWorldRotation()); // + av sit offset! + + Quaternion partRot; + if (part.LinkNum == 1) + { // Root prim of linkset + partRot = part.ParentGroup.RootPart.RotationOffset; + } + else + { // single or child prim + partRot = part.GetWorldRotation(); + } + Quaternion partIRot = Quaternion.Inverse(partRot); + + Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av + Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ( m_pos * partRot); // + av sit offset! if (m_physicsActor == null) { AddToPhysicalScene(false); } - AbsolutePosition = wso; //KF: Fix stand up. + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. m_parentPosition = Vector3.Zero; m_parentID = 0; part.IsOccupied = false; @@ -1752,8 +1763,17 @@ namespace OpenSim.Region.Framework.Scenes Quaternion avSitOrientation = part.SitTargetOrientation; bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. - Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); - + // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + Quaternion partRot; + if (part.LinkNum == 1) + { // Root prim of linkset + partRot = part.ParentGroup.RootPart.RotationOffset; + } + else + { // single or child prim + partRot = part.GetWorldRotation(); + } + Quaternion partIRot = Quaternion.Inverse(partRot); //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); // Sit analysis rewritten by KF 091125 if (SitTargetisSet) // scipted sit @@ -1800,6 +1820,8 @@ namespace OpenSim.Region.Framework.Scenes cameraAtOffset = part.GetCameraAtOffset(); cameraEyeOffset = part.GetCameraEyeOffset(); forceMouselook = part.GetForceMouselook(); + if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // + if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // if (m_physicsActor != null) { @@ -1823,7 +1845,29 @@ namespace OpenSim.Region.Framework.Scenes } else return; // physactor is null! - Vector3 offsetr = offset * partIRot; + Vector3 offsetr; // = offset * partIRot; + // KF: In a linkset, offsetr needs to be relative to the group root! 091208 + // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); + if (part.LinkNum < 2) + { // Single, or Root prim of linkset, target is ClickOffset * RootRot + offsetr = offset * partIRot; + } + else + { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) + offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + + (offset * partRot); + } + +Console.WriteLine(" "); +Console.WriteLine("link number ={0}", part.LinkNum); +Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); +Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); +Console.WriteLine("Click offst ={0}", offset); +Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); +Console.WriteLine("offsetr ={0}", offsetr); +Console.WriteLine("Camera At ={0}", cameraAtOffset); +Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); + ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target // This calls HandleAgentSit twice, once from here, and the client calls @@ -2142,13 +2186,20 @@ namespace OpenSim.Region.Framework.Scenes } else { -//Console.WriteLine("NON Scripted Sit"); // if m_avUnscriptedSitPos is zero then Av sits above center // Else Av sits at m_avUnscriptedSitPos // Non-scripted sit by Kitto Flora 21Nov09 // Calculate angle of line from prim to Av - Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + Quaternion partIRot; + if (part.LinkNum == 1) + { // Root prim of linkset + partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); + } + else + { // single or child prim + partIRot = Quaternion.Inverse(part.GetWorldRotation()); + } Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); float x_diff = ( m_avInitialPos.X - sitTargetPos.X); @@ -2203,11 +2254,21 @@ namespace OpenSim.Region.Framework.Scenes // collisionPoint = spot on prim where we want to sit // collisionPoint.Z = global sit surface height SceneObjectPart part = m_scene.GetSceneObjectPart(localid); - Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + Quaternion partIRot; + if (part.LinkNum == 1) + { // Root prim of linkset + partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); + } + else + { // single or child prim + partIRot = Quaternion.Inverse(part.GetWorldRotation()); + } float offZ = collisionPoint.Z - m_initialSitTarget.Z; Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); m_pos += offset; + ControllingClient.SendClearFollowCamProperties(part.UUID); + } } // End SitAltitudeCallback KF. -- cgit v1.1 From b8b4517211d332f76c022075f81cfefd41877d14 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Tue, 15 Dec 2009 01:49:23 -0500 Subject: Removed excessive call to UpdateMovementAnimations which prevented GroundSit; Corrected cause of 'sit on roof'. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 48 ++++++++++++------------ 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d0c20ff..c67463a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -670,8 +670,7 @@ namespace OpenSim.Region.Framework.Scenes AdjustKnownSeeds(); - - Animator.TrySetMovementAnimation("STAND"); + Animator.TrySetMovementAnimation("STAND"); // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) @@ -1691,7 +1690,6 @@ namespace OpenSim.Region.Framework.Scenes SetHeight(m_avHeight); } } - Animator.TrySetMovementAnimation("STAND"); } @@ -1858,15 +1856,15 @@ namespace OpenSim.Region.Framework.Scenes (offset * partRot); } -Console.WriteLine(" "); -Console.WriteLine("link number ={0}", part.LinkNum); -Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); -Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); -Console.WriteLine("Click offst ={0}", offset); -Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); -Console.WriteLine("offsetr ={0}", offsetr); -Console.WriteLine("Camera At ={0}", cameraAtOffset); -Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); +//Console.WriteLine(" "); +//Console.WriteLine("link number ={0}", part.LinkNum); +//Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); +//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); +//Console.WriteLine("Click offst ={0}", offset); +//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); +//Console.WriteLine("offsetr ={0}", offsetr); +//Console.WriteLine("Camera At ={0}", cameraAtOffset); +//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target @@ -2218,7 +2216,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); m_avUnscriptedSitPos; // adds click offset, if any //Set up raytrace to find top surface of prim Vector3 size = part.Scale; - float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); + float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); Vector3 down = new Vector3(0f, 0f, -1f); //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); @@ -2267,7 +2265,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); m_pos += offset; - ControllingClient.SendClearFollowCamProperties(part.UUID); +// ControllingClient.SendClearFollowCamProperties(part.UUID); } } // End SitAltitudeCallback KF. @@ -3297,7 +3295,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); m_updateflag = true; Velocity = force; m_isNudging = false; - m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" + m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" } } } @@ -3349,19 +3347,19 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { - if (m_updateCount > 0) //KF: Update Anims for a short period. Many Anim - { // changes are very asynchronous. - Animator.UpdateMovementAnimations(); - m_updateCount--; - } - if (e == null) return; - - // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( + + // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene if (Animator!=null) - Animator.UpdateMovementAnimations(); + { + if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, + { // else its will lock out other animation changes, like ground sit. + Animator.UpdateMovementAnimations(); + m_updateCount--; + } + } CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; @@ -3370,7 +3368,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); if (m_lastColCount != coldata.Count) { - m_updateCount = 10; + m_updateCount = UPDATE_COUNT; m_lastColCount = coldata.Count; } -- cgit v1.1 From 7cd44c1a818615ca0e267f64c74593ad0361350b Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Tue, 15 Dec 2009 20:04:53 -0500 Subject: Fix prim linking bug, Manis #14 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a23c11e..778e384 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -513,18 +513,24 @@ namespace OpenSim.Region.Framework.Scenes { // If this is a linkset, we don't want the physics engine mucking up our group position here. PhysicsActor actor = PhysActor; + + if (actor != null && _parentID == 0) + { + m_groupPosition = actor.Position; + } +/* if (actor != null) { if (_parentID == 0) { - m_groupPosition = actor.Position; + m_groupPosition = actor.Position; } else { m_groupPosition = ParentGroup.AbsolutePosition; // KF+Casper Update Child prims too! } } - +*/ if (IsAttachment) { ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); -- cgit v1.1 From 6483470ec5e9000fb6a85bbdfe5b79be6f336a74 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 17 Dec 2009 02:54:02 -0500 Subject: Fix GetWorldRotation(), and a host of related Sit fixes. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 73 +++++++++++----------- 2 files changed, 38 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 778e384..4495eda 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1775,7 +1775,7 @@ namespace OpenSim.Region.Framework.Scenes { Quaternion newRot; - if (this.LinkNum == 0) + if (this.LinkNum < 2) //KF Single or root prim { newRot = RotationOffset; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c67463a..865f649 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1661,14 +1661,14 @@ namespace OpenSim.Region.Framework.Scenes // Rotation is the sittiing Av's rotation Quaternion partRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partRot = part.ParentGroup.RootPart.RotationOffset; - } - else - { // single or child prim +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim partRot = part.GetWorldRotation(); - } +// } Quaternion partIRot = Quaternion.Inverse(partRot); Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av @@ -1763,14 +1763,14 @@ namespace OpenSim.Region.Framework.Scenes bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); Quaternion partRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partRot = part.ParentGroup.RootPart.RotationOffset; - } - else - { // single or child prim +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim partRot = part.GetWorldRotation(); - } +// } Quaternion partIRot = Quaternion.Inverse(partRot); //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); // Sit analysis rewritten by KF 091125 @@ -1846,15 +1846,15 @@ namespace OpenSim.Region.Framework.Scenes Vector3 offsetr; // = offset * partIRot; // KF: In a linkset, offsetr needs to be relative to the group root! 091208 // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); - if (part.LinkNum < 2) - { // Single, or Root prim of linkset, target is ClickOffset * RootRot + // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. + // { // Single, or Root prim of linkset, target is ClickOffset * RootRot offsetr = offset * partIRot; - } - else - { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) - offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + - (offset * partRot); - } +// + // else + // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) + // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + + // (offset * partRot); + // } //Console.WriteLine(" "); //Console.WriteLine("link number ={0}", part.LinkNum); @@ -2170,6 +2170,7 @@ namespace OpenSim.Region.Framework.Scenes { if (part != null) { +//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); if (part.GetAvatarOnSitTarget() == UUID) { //Console.WriteLine("Scripted Sit"); @@ -2190,14 +2191,14 @@ namespace OpenSim.Region.Framework.Scenes // Non-scripted sit by Kitto Flora 21Nov09 // Calculate angle of line from prim to Av Quaternion partIRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); - } - else - { // single or child prim +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim partIRot = Quaternion.Inverse(part.GetWorldRotation()); - } +// } Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); float x_diff = ( m_avInitialPos.X - sitTargetPos.X); @@ -2253,14 +2254,14 @@ namespace OpenSim.Region.Framework.Scenes // collisionPoint.Z = global sit surface height SceneObjectPart part = m_scene.GetSceneObjectPart(localid); Quaternion partIRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); - } - else - { // single or child prim +// if (part.LinkNum == 1) +/// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim partIRot = Quaternion.Inverse(part.GetWorldRotation()); - } +// } float offZ = collisionPoint.Z - m_initialSitTarget.Z; Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); -- cgit v1.1 From 6dbe25360ec3dc3c998378da8b422751d3e032a9 Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 17 Dec 2009 18:40:34 +0100 Subject: Add cmSetWindlightSceneTargeted. Add restrictions on windlight script use. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 12 ++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index a86e263..68e73b1 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -194,7 +194,9 @@ namespace OpenSim.Region.Framework.Scenes public delegate void OnMakeRootAgentDelegate(ScenePresence presence); public delegate void OnSaveNewWindlightProfileDelegate(); + public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user); public event OnMakeRootAgentDelegate OnMakeRootAgent; + public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); @@ -414,6 +416,7 @@ namespace OpenSim.Region.Framework.Scenes private ClientClosed handlerClientClosed = null; //OnClientClosed; private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile; + private OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = null; //OnSendNewWindlightProfileTargeted; private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent; private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; @@ -775,6 +778,15 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user) + { + handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted; + if (handlerSendNewWindlightProfileTargeted != null) + { + handlerSendNewWindlightProfileTargeted(wl, user); + } + } + public void TriggerOnSaveNewWindlightProfile() { handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 104d22b..20cae5d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1519,8 +1519,8 @@ namespace OpenSim.Region.Framework.Scenes public void SaveTerrain() { m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); - } - + } + public void StoreWindlightProfile(RegionMeta7WindlightData wl) { m_regInfo.WindlightSettings = wl; -- cgit v1.1 From e38e8ae98759e403175016260edd27772b5c9e4c Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Sat, 19 Dec 2009 19:54:44 -0500 Subject: Fix mantis #10 & #14 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 33 +++++++--------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 778e384..0eddbfd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -513,24 +513,11 @@ namespace OpenSim.Region.Framework.Scenes { // If this is a linkset, we don't want the physics engine mucking up our group position here. PhysicsActor actor = PhysActor; - if (actor != null && _parentID == 0) { m_groupPosition = actor.Position; - } -/* - if (actor != null) - { - if (_parentID == 0) - { - m_groupPosition = actor.Position; - } - else - { - m_groupPosition = ParentGroup.AbsolutePosition; // KF+Casper Update Child prims too! - } } -*/ + if (IsAttachment) { ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); @@ -545,7 +532,6 @@ namespace OpenSim.Region.Framework.Scenes StoreUndoState(); m_groupPosition = value; - PhysicsActor actor = PhysActor; if (actor != null) { @@ -1755,16 +1741,17 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetWorldPosition() { Quaternion parentRot = ParentGroup.RootPart.RotationOffset; - Vector3 axPos = OffsetPosition; axPos *= parentRot; Vector3 translationOffsetPosition = axPos; - - int tx = (int)GroupPosition.X; - int ty = (int)GroupPosition.Y; - int tz = (int)GroupPosition.Z; - - return GroupPosition + translationOffsetPosition; + if(_parentID == 0) + { + return GroupPosition; + } + else + { + return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position + } } /// @@ -1775,7 +1762,7 @@ namespace OpenSim.Region.Framework.Scenes { Quaternion newRot; - if (this.LinkNum == 0) + if (this.LinkNum < 2) //KF Single or root prim { newRot = RotationOffset; } -- cgit v1.1 From e3c14660478bdd3af8c792b4b6b48ffffbbe19f9 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 21 Dec 2009 13:22:52 +0100 Subject: Fixed a nasty crash in StandUp() that occurred when the part got killed with an avatar sitting on it. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 54 ++++++++++++++++++------ 1 file changed, 41 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 865f649..abdd1a0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -118,7 +118,8 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; + private Vector3 m_lastPosition; + private Vector3 m_lastWorldPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; //private int m_lastTerseSent; @@ -1667,24 +1668,45 @@ namespace OpenSim.Region.Framework.Scenes // } // else // { // single or child prim - partRot = part.GetWorldRotation(); -// } + +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); + } + Quaternion partIRot = Quaternion.Inverse(partRot); Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ( m_pos * partRot); // + av sit offset! - if (m_physicsActor == null) - { - AddToPhysicalScene(false); + + if (m_physicsActor == null) + { + AddToPhysicalScene(false); + } + //CW: If the part isn't null then we can set the current position + if (part != null) + { + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. + part.IsOccupied = false; + } + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; } - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - m_parentPosition = Vector3.Zero; + + m_parentPosition = Vector3.Zero; m_parentID = 0; - part.IsOccupied = false; SendFullUpdateToAllClients(); m_requestedSitTargetID = 0; + if ((m_physicsActor != null) && (m_avHeight > 0)) { SetHeight(m_avHeight); @@ -1778,7 +1800,7 @@ namespace OpenSim.Region.Framework.Scenes { if (!part.IsOccupied) { -//Console.WriteLine("Scripted, unoccupied"); +//Console.WriteLine("Scripted, unoccupied"); part.SetAvatarOnSitTarget(UUID); // set that Av will be on it offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one sitOrientation = avSitOrientation; // Change rotatione to the scripted one @@ -1831,13 +1853,19 @@ namespace OpenSim.Region.Framework.Scenes // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) { - autopilot = false; // close enough + autopilot = false; // close enough + m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. + Not using the part's position because returning the AV to the last known standing + position is likely to be more friendly, isn't it? */ RemoveFromPhysicalScene(); AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target } // else the autopilot will get us close } else - { // its a scripted sit + { // its a scripted sit + m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. + I *am* using the part's position this time because we have no real idea how far away + the avatar is from the sit target. */ RemoveFromPhysicalScene(); } } -- cgit v1.1 From 69b551c51686bca58c478f517f6ccfa561ad9730 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Dec 2009 03:22:33 +0100 Subject: Allow 100ms for scripts to run attach(NULL_KEY) on detach --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f74fd5d..e875525 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -542,6 +542,18 @@ namespace OpenSim.Region.Framework.Scenes if (group.GetFromItemID() == itemID) { m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero); + bool hasScripts = false; + foreach (SceneObjectPart part in group.Children) + { + if (part..Inventory.ContainsScripts()) + { + hasScripts = true; + break; + } + } + + if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event + System.Threading.Thread.Sleep(100); group.DetachToInventoryPrep(); m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); -- cgit v1.1 From 46fea747265574bb056b8d1ffa189ec3725a7abc Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Dec 2009 03:25:09 +0100 Subject: Jumped the gun... --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e875525..fadeaf4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -545,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes bool hasScripts = false; foreach (SceneObjectPart part in group.Children) { - if (part..Inventory.ContainsScripts()) + if (part.Inventory.ContainsScripts()) { hasScripts = true; break; -- cgit v1.1 From 49fbe0ddb429b8625682255bf0cafa9ea93d274a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Dec 2009 03:26:47 +0100 Subject: Should not commit without compiling --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fadeaf4..b0fb8b3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -543,7 +543,7 @@ namespace OpenSim.Region.Framework.Scenes { m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero); bool hasScripts = false; - foreach (SceneObjectPart part in group.Children) + foreach (SceneObjectPart part in group.Children.Values) { if (part.Inventory.ContainsScripts()) { -- cgit v1.1 From b53b87166940ca0fca4ae2190649e18102c886ec Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Dec 2009 06:25:32 +0100 Subject: Add a data path for error messages --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 18 ++++++++++++------ .../Framework/Scenes/SceneObjectPartInventory.cs | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7ca779a..bce7d32 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Collections; using System.Reflection; using System.Text; using System.Timers; @@ -215,13 +216,13 @@ namespace OpenSim.Region.Framework.Scenes /// The prim which contains the item to update /// Indicates whether the script to update is currently running /// - public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId, + public ArrayList CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId, UUID primId, bool isScriptRunning, byte[] data) { if (!Permissions.CanEditScript(itemId, primId, remoteClient.AgentId)) { remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); - return; + return new ArrayList(); } // Retrieve group @@ -234,7 +235,7 @@ namespace OpenSim.Region.Framework.Scenes "Prim inventory update requested for item ID {0} in prim ID {1} but this prim does not exist", itemId, primId); - return; + return new ArrayList(); } // Retrieve item @@ -247,7 +248,7 @@ namespace OpenSim.Region.Framework.Scenes + " but the item does not exist in this inventory", itemId, part.Name, part.UUID); - return; + return new ArrayList(); } AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); @@ -264,29 +265,33 @@ namespace OpenSim.Region.Framework.Scenes part.GetProperties(remoteClient); // Trigger rerunning of script (use TriggerRezScript event, see RezScript) + ArrayList errors = new ArrayList(); + if (isScriptRunning) { // Needs to determine which engine was running it and use that // part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); + errors = part.Inventory.GetScriptErrors(item.ItemID); } else { remoteClient.SendAgentAlertMessage("Script saved", false); } + return errors; } /// /// CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[]) /// - public void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId, + public ArrayList CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId, UUID primId, bool isScriptRunning, byte[] data) { ScenePresence avatar; if (TryGetAvatar(avatarId, out avatar)) { - CapsUpdateTaskInventoryScriptAsset( + return CapsUpdateTaskInventoryScriptAsset( avatar.ControllingClient, itemId, primId, isScriptRunning, data); } else @@ -295,6 +300,7 @@ namespace OpenSim.Region.Framework.Scenes "[PRIM INVENTORY]: " + "Avatar {0} cannot be found to update its prim item asset", avatarId); + return new ArrayList(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index cdd23bd..c3c6342 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -29,6 +29,7 @@ using System; using System.Xml; using System.IO; using System.Collections.Generic; +using System.Collections; using System.Reflection; using OpenMetaverse; using log4net; @@ -210,6 +211,27 @@ namespace OpenSim.Region.Framework.Scenes } } + public ArrayList GetScriptErrors(UUID itemID) + { + ArrayList ret = new ArrayList(); + + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); + if (engines == null) // No engine at all + return ret; + + foreach (IScriptModule e in engines) + { + if (e != null) + { + ArrayList errors = e.GetScriptErrors(itemID); + foreach (Object line in errors) + ret.Add(line); + } + } + + return ret; + } + /// /// Stop all the scripts in this prim. /// -- cgit v1.1 From e7439efc74a1cc0daedc51eb25ae66cd03db70b5 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 24 Dec 2009 19:19:44 -0500 Subject: Recover out-of-region objects during db load. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b0fb8b3..998d598 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -222,6 +222,30 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) { + // KF: Check for out-of-region, move inside and make static. + Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, + sceneObject.RootPart.GroupPosition.Y, + sceneObject.RootPart.GroupPosition.Z); + if (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || + npos.X > Constants.RegionSize || + npos.Y > Constants.RegionSize) + { + if (npos.X < 0.0) npos.X = 1.0f; + if (npos.Y < 0.0) npos.Y = 1.0f; + if (npos.Z < 0.0) npos.Z = 0.0f; + if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; + if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; + + foreach (SceneObjectPart part in sceneObject.Children.Values) + { + part.GroupPosition = npos; + } + sceneObject.RootPart.Velocity = Vector3.Zero; + sceneObject.RootPart.AngularVelocity = Vector3.Zero; + sceneObject.RootPart.Acceleration = Vector3.Zero; + sceneObject.RootPart.Velocity = Vector3.Zero; + } + if (!alreadyPersisted) { sceneObject.ForceInventoryPersistence(); -- cgit v1.1 From 7371c7662a05d2c1dae1c110905817bb873cf934 Mon Sep 17 00:00:00 2001 From: CasperW Date: Sat, 26 Dec 2009 18:14:12 +0100 Subject: Fix for landing points. Only one scenario is not fully covered by this change, and that is people who teleport from neighbouring regions, who won't get affected by the landing point. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 + .../Framework/Scenes/SceneCommunicationService.cs | 47 +++++++++++++++++----- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 25 ++++++++++-- 3 files changed, 59 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 265129c..37734f4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3460,6 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes } } // Honor parcel landing type and position. + /* ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); if (land != null) { @@ -3468,6 +3469,7 @@ namespace OpenSim.Region.Framework.Scenes agent.startpos = land.LandData.UserLocation; } } + */// This is now handled properly in ScenePresence.MakeRootAgent } m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index e649139..0a02d39 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -706,17 +706,42 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat( "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}", - position, m_regionInfo.RegionName); - - // Teleport within the same region - if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) - { - Vector3 emergencyPos = new Vector3(128, 128, 128); - - m_log.WarnFormat( - "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", - position, avatar.Name, avatar.UUID, emergencyPos); - position = emergencyPos; + position, m_regionInfo.RegionName); + + // Teleport within the same region + if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) + { + Vector3 emergencyPos = new Vector3(128, 128, 128); + + m_log.WarnFormat( + "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + position, avatar.Name, avatar.UUID, emergencyPos); + position = emergencyPos; + } + + Vector3 currentPos = avatar.AbsolutePosition; + ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y); + ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y); + if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0) + { + if (srcLand.LandData.LocalID == destLand.LandData.LocalID) + { + //TPing within the same parcel. If the landing point is restricted, block the TP. + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) + { + avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false); + position = currentPos; + } + } + else + { + //Tping to a different parcel. Respect the landing point on the destination parcel. + if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) + { + position = destLand.LandData.UserLocation; + } + } } // TODO: Get proper AVG Height diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a3ad7ca..c3bc96a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -836,9 +836,24 @@ namespace OpenSim.Region.Framework.Scenes { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); pos.Y = crossedBorder.BorderLine.Z - 1; + } + + //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. + //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, + //they'll bypass the landing point. But I can't think of any decent way of fixing this. + if (KnownChildRegionHandles.Count == 0) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + { + pos = land.LandData.UserLocation; + } + } } - if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) { Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); @@ -973,9 +988,10 @@ namespace OpenSim.Region.Framework.Scenes public void Teleport(Vector3 pos) { bool isFlying = false; - if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; + if (m_physicsActor != null) + isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); Velocity = Vector3.Zero; AbsolutePosition = pos; @@ -986,7 +1002,8 @@ namespace OpenSim.Region.Framework.Scenes SetHeight(m_appearance.AvatarHeight); } - SendTerseUpdateToAllClients(); + SendTerseUpdateToAllClients(); + } public void TeleportWithMomentum(Vector3 pos) -- cgit v1.1 From a6c93ce875c9e563de791002b309a3285266d597 Mon Sep 17 00:00:00 2001 From: CasperW Date: Sat, 26 Dec 2009 22:55:18 +0100 Subject: Make sure that we're not bounds checking attachments. 'Cos otherwise your hair will end up on your bum. Seen that before? --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 998d598..34a92fe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -226,9 +226,9 @@ namespace OpenSim.Region.Framework.Scenes Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, sceneObject.RootPart.GroupPosition.Y, sceneObject.RootPart.GroupPosition.Z); - if (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || + if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || npos.X > Constants.RegionSize || - npos.Y > Constants.RegionSize) + npos.Y > Constants.RegionSize)) { if (npos.X < 0.0) npos.X = 1.0f; if (npos.Y < 0.0) npos.Y = 1.0f; -- cgit v1.1 From 19a5e606b38372e882c13e27d6459ee703e07570 Mon Sep 17 00:00:00 2001 From: CasperW Date: Sun, 27 Dec 2009 07:08:16 +0100 Subject: Convert some remaining legacy lock()s for m_parts in SceneObjectGroup to ReaderWriteLockSlim, hopefully fixes a native crash --- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 5a06bdb..65ce13a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -46,12 +46,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void ForceInventoryPersistence() { - lock (m_parts) + lockPartsForRead(true); + List values = new List(m_parts.Values); + lockPartsForRead(false); + foreach (SceneObjectPart part in values) { - foreach (SceneObjectPart part in m_parts.Values) - { - part.Inventory.ForceInventoryPersistence(); - } + part.Inventory.ForceInventoryPersistence(); } } @@ -75,14 +75,16 @@ namespace OpenSim.Region.Framework.Scenes /// Stop the scripts contained in all the prims in this group /// public void RemoveScriptInstances() - { - lock (m_parts) + { + lockPartsForRead(true); + List values = new List(m_parts.Values); + lockPartsForRead(false); + + foreach (SceneObjectPart part in values) { - foreach (SceneObjectPart part in m_parts.Values) - { - part.Inventory.RemoveScriptInstances(); - } + part.Inventory.RemoveScriptInstances(); } + } /// -- cgit v1.1 From 9602227eb6d26cf76d8c88ac86558218ca11e918 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 06:19:22 +0100 Subject: Add a small delay in NewAgentConnection to fix an issue with Hippo (and possibly other cleints) getting their data mixed up. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2091bf0..2e34d1c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3414,6 +3414,9 @@ namespace OpenSim.Region.Framework.Scenes CapsModule.AddCapsHandler(agent.AgentID); + if ((teleportFlags & ((uint)TeleportFlags.ViaLandmark | (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.ViaLandmark | (uint)TeleportFlags.Default)) != 0) + System.Threading.Thread.Sleep(2000); + if (!agent.child) { if (TestBorderCross(agent.startpos,Cardinals.E)) -- cgit v1.1 From 1121919b57e1495d0357d59e010a865b91757bfb Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 3 Jan 2010 22:02:36 +0000 Subject: Solve conflict --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index eda3d60..a14e3ad 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2910,13 +2910,6 @@ namespace OpenSim.Region.Framework.Scenes SetText(text); } - public void StopLookAt() - { - m_parentGroup.stopLookAt(); - - m_parentGroup.ScheduleGroupForTerseUpdate(); - } - public void StopMoveToTarget() { m_parentGroup.stopMoveToTarget(); -- cgit v1.1 From 884410501e50f0abb09ef1339ac74e22c2dfd39f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 20:19:06 +0000 Subject: Allow renaming of items that contain no-mod items --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 18ec25f..dd4c14b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1803,8 +1803,13 @@ namespace OpenSim.Region.Framework.Scenes } else { - item.BasePermissions = objectGroup.GetEffectivePermissions(); - item.CurrentPermissions = objectGroup.GetEffectivePermissions(); + uint ownerPerms = objectGroup.GetEffectivePermissions(); + if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0) + ownerPerms |= (uint)PermissionMask.Modify; + + item.BasePermissions = ownerPerms; + item.CurrentPermissions = ownerPerms; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; item.GroupPermissions = objectGroup.RootPart.GroupMask; -- cgit v1.1 From 496a8a4f7ca5422daa30913595b6b1a03fa8a59a Mon Sep 17 00:00:00 2001 From: CasperW Date: Wed, 20 Jan 2010 22:14:43 +0100 Subject: Fixed an issue with PayPrice sometimes being shared between multiple objects --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a7c14cf..4c97467 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes // TODO: This needs to be persisted in next XML version update! [XmlIgnore] - public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; + public int[] PayPrice = {-2,-2,-2,-2,-2}; [XmlIgnore] public PhysicsActor PhysActor; -- cgit v1.1 From 1abb70cc73c997c08a416fecf689b83453f853d0 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 21 Jan 2010 19:31:02 -0500 Subject: Add glue for llSetVehicleFlags(), llRemoveVehicleFlags(). ChODE: Add associated methods. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4c97467..04be9fc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2963,7 +2963,23 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.VehicleRotationParam(param, rotation); } } - + + public void SetVehicleFlags(int flags) + { + if (PhysActor != null) + { + PhysActor.VehicleFlagsSet(flags); + } + } + + public void RemoveVehicleFlags(int flags) + { + if (PhysActor != null) + { + PhysActor.VehicleFlagsRemove(flags); + } + } + public void SetGroup(UUID groupID, IClientAPI client) { _groupID = groupID; -- cgit v1.1 From e9c9a74e0ade505ee8d8d8e7790141f758a65f61 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 26 Jan 2010 15:12:41 +0000 Subject: Some merge fixups --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index aea005e..8b58b3e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -74,7 +74,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Stop the scripts contained in all the prims in this group /// - public void RemoveScriptInstances() + public void RemoveScriptInstances(bool sceneObjectBeingDeleted) { lockPartsForRead(true); List values = new List(m_parts.Values); @@ -82,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in values) { - part.Inventory.RemoveScriptInstances(); + part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 1de0092..9661775 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -249,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes { if ((int)InventoryType.LSL == item.InvType) { - RemoveScriptInstance(item.ItemID); + RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); m_part.RemoveScriptEvents(item.ItemID); } } -- cgit v1.1 From 0c5850237ec68158743117933d2ddd6e7df62c28 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jan 2010 16:50:00 +0000 Subject: Small fix for a spurious exception --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index e4296ef..1cff0eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (EntityBase e in m_presence.Scene.Entities) { - if (e is SceneObjectGroup) + if (e != null && e is SceneObjectGroup) m_pendingObjects.Enqueue((SceneObjectGroup)e); } } -- cgit v1.1 From 6478617c932e87bf091266dba2db4d73fcdd046f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 2 Feb 2010 03:49:00 +0000 Subject: Revert "improve locking of m_items in SceneObjectPartInventory" This reverts commit 968b9e160d70568fbdea5b190d1386e9431316e3. --- .../Framework/Scenes/SceneObjectPartInventory.cs | 218 ++++++++------------- 1 file changed, 85 insertions(+), 133 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 87c1a95..b37e1a2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -44,8 +44,6 @@ namespace OpenSim.Region.Framework.Scenes { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); - private string m_inventoryFileName = String.Empty; private int m_inventoryFileNameSerial = 0; @@ -272,12 +270,8 @@ namespace OpenSim.Region.Framework.Scenes if (stateSource == 1 && // Prim crossing m_part.ParentGroup.Scene.m_trustBinaries) { - lock (m_items) - { - m_items[item.ItemID].PermsMask = 0; - m_items[item.ItemID].PermsGranter = UUID.Zero; - } - + m_items[item.ItemID].PermsMask = 0; + m_items[item.ItemID].PermsGranter = UUID.Zero; m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); m_part.ParentGroup.AddActiveScriptCount(1); @@ -285,38 +279,33 @@ namespace OpenSim.Region.Framework.Scenes return; } - m_part.ParentGroup.Scene.AssetService.Get( - item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) - { - if (null == asset) - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", - item.Name, item.ItemID, m_part.AbsolutePosition, - m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); - } - else - { - if (m_part.ParentGroup.m_savedScriptState != null) - RestoreSavedScriptState(item.OldItemID, item.ItemID); - - lock (m_items) - { - m_items[item.ItemID].PermsMask = 0; - m_items[item.ItemID].PermsGranter = UUID.Zero; - } - - string script = Utils.BytesToString(asset.Data); - m_part.ParentGroup.Scene.EventManager.TriggerRezScript( - m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); - m_part.ParentGroup.AddActiveScriptCount(1); - m_part.ScheduleFullUpdate(); - } - } - ); + m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) + { + if (null == asset) + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", + item.Name, item.ItemID, m_part.AbsolutePosition, + m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); + } + else + { + if (m_part.ParentGroup.m_savedScriptState != null) + RestoreSavedScriptState(item.OldItemID, item.ItemID); + m_items[item.ItemID].PermsMask = 0; + m_items[item.ItemID].PermsGranter = UUID.Zero; + string script = Utils.BytesToString(asset.Data); + m_part.ParentGroup.Scene.EventManager.TriggerRezScript( + m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); + m_part.ParentGroup.AddActiveScriptCount(1); + m_part.ScheduleFullUpdate(); + } + }); } - } + } + + static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); private void RestoreSavedScriptState(UUID oldID, UUID newID) { @@ -408,15 +397,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) { - bool scriptPresent = false; - - lock (m_items) - { - if (m_items.ContainsKey(itemId)) - scriptPresent = true; - } - - if (scriptPresent) + if (m_items.ContainsKey(itemId)) { if (!sceneObjectBeingDeleted) m_part.RemoveScriptEvents(itemId); @@ -488,13 +469,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) { - List il; - - lock (m_items) - { - il = new List(m_items.Values); - } - + List il = new List(m_items.Values); foreach (TaskInventoryItem i in il) { if (i.Name == item.Name) @@ -576,9 +551,7 @@ namespace OpenSim.Region.Framework.Scenes public TaskInventoryItem GetInventoryItem(UUID itemId) { TaskInventoryItem item; - - lock (m_items) - m_items.TryGetValue(itemId, out item); + m_items.TryGetValue(itemId, out item); return item; } @@ -904,61 +877,54 @@ namespace OpenSim.Region.Framework.Scenes { uint mask=0x7fffffff; - lock (m_items) + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) + if (item.InvType != (int)InventoryType.Object) { - if (item.InvType != (int)InventoryType.Object) - { - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) - mask &= ~((uint)PermissionMask.Copy >> 13); - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) - mask &= ~((uint)PermissionMask.Transfer >> 13); - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) - mask &= ~((uint)PermissionMask.Modify >> 13); - } - else - { - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) - mask &= ~((uint)PermissionMask.Copy >> 13); - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) - mask &= ~((uint)PermissionMask.Transfer >> 13); - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) - mask &= ~((uint)PermissionMask.Modify >> 13); - } - - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - mask &= ~(uint)PermissionMask.Copy; - if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) - mask &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) - mask &= ~(uint)PermissionMask.Modify; + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) + mask &= ~((uint)PermissionMask.Copy >> 13); + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) + mask &= ~((uint)PermissionMask.Transfer >> 13); + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) + mask &= ~((uint)PermissionMask.Modify >> 13); + } + else + { + if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) + mask &= ~((uint)PermissionMask.Copy >> 13); + if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) + mask &= ~((uint)PermissionMask.Transfer >> 13); + if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) + mask &= ~((uint)PermissionMask.Modify >> 13); } + + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + mask &= ~(uint)PermissionMask.Copy; + if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) + mask &= ~(uint)PermissionMask.Transfer; + if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) + mask &= ~(uint)PermissionMask.Modify; } - return mask; } public void ApplyNextOwnerPermissions() { - lock (m_items) + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) + if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) { - if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) - { - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Copy; - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Modify; - item.CurrentPermissions |= 8; - } - item.CurrentPermissions &= item.NextPermissions; - item.BasePermissions &= item.NextPermissions; - item.EveryonePermissions &= item.NextPermissions; + if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Copy; + if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; + if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Modify; + item.CurrentPermissions |= 8; } + item.CurrentPermissions &= item.NextPermissions; + item.BasePermissions &= item.NextPermissions; + item.EveryonePermissions &= item.NextPermissions; } m_part.TriggerScriptChangedEvent(Changed.OWNER); @@ -966,29 +932,22 @@ namespace OpenSim.Region.Framework.Scenes public void ApplyGodPermissions(uint perms) { - lock (m_items) + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) - { - item.CurrentPermissions = perms; - item.BasePermissions = perms; - } + item.CurrentPermissions = perms; + item.BasePermissions = perms; } } public bool ContainsScripts() { - lock (m_items) + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) + if (item.InvType == (int)InventoryType.LSL) { - if (item.InvType == (int)InventoryType.LSL) - { - return true; - } + return true; } } - return false; } @@ -996,11 +955,8 @@ namespace OpenSim.Region.Framework.Scenes { List ret = new List(); - lock (m_items) - { - foreach (TaskInventoryItem item in m_items.Values) - ret.Add(item.ItemID); - } + foreach (TaskInventoryItem item in m_items.Values) + ret.Add(item.ItemID); return ret; } @@ -1013,30 +969,26 @@ namespace OpenSim.Region.Framework.Scenes if (engines == null) // No engine at all return ret; - lock (m_items) + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) + if (item.InvType == (int)InventoryType.LSL) { - if (item.InvType == (int)InventoryType.LSL) + foreach (IScriptModule e in engines) { - foreach (IScriptModule e in engines) + if (e != null) { - if (e != null) + string n = e.GetXMLState(item.ItemID); + if (n != String.Empty) { - string n = e.GetXMLState(item.ItemID); - if (n != String.Empty) - { - if (!ret.ContainsKey(item.ItemID)) - ret[item.ItemID] = n; - break; - } + if (!ret.ContainsKey(item.ItemID)) + ret[item.ItemID] = n; + break; } } } } } - return ret; } } -} \ No newline at end of file +} -- cgit v1.1 From ae9362636e1a95c32f7bcf1225e939b44c37a4a0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Feb 2010 17:00:16 +0000 Subject: Line endings cleanup --- .../Framework/Scenes/SceneCommunicationService.cs | 72 +++++++++++----------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 6a3c386..545183b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -699,42 +699,42 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat( "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}", - position, m_regionInfo.RegionName); - - // Teleport within the same region - if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) - { - Vector3 emergencyPos = new Vector3(128, 128, 128); - - m_log.WarnFormat( - "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", - position, avatar.Name, avatar.UUID, emergencyPos); - position = emergencyPos; - } - - Vector3 currentPos = avatar.AbsolutePosition; - ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y); - ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y); - if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0) - { - if (srcLand.LandData.LocalID == destLand.LandData.LocalID) - { - //TPing within the same parcel. If the landing point is restricted, block the TP. - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) - { - avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false); - position = currentPos; - } - } - else - { - //Tping to a different parcel. Respect the landing point on the destination parcel. - if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) - { - position = destLand.LandData.UserLocation; - } - } + position, m_regionInfo.RegionName); + + // Teleport within the same region + if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) + { + Vector3 emergencyPos = new Vector3(128, 128, 128); + + m_log.WarnFormat( + "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + position, avatar.Name, avatar.UUID, emergencyPos); + position = emergencyPos; + } + + Vector3 currentPos = avatar.AbsolutePosition; + ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y); + ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y); + if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0) + { + if (srcLand.LandData.LocalID == destLand.LandData.LocalID) + { + //TPing within the same parcel. If the landing point is restricted, block the TP. + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) + { + avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false); + position = currentPos; + } + } + else + { + //Tping to a different parcel. Respect the landing point on the destination parcel. + if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) + { + position = destLand.LandData.UserLocation; + } + } } // TODO: Get proper AVG Height -- cgit v1.1 From ce3e2655752fb56d9f18bf7cc0686e97c06f16da Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 14 Feb 2010 23:58:54 +0000 Subject: Plug a small hole --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7b852a2..b2b061e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -585,6 +585,9 @@ namespace OpenSim.Region.Framework.Scenes m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); return; } + + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + return; } AssetBase asset = AssetService.Get(item.AssetID.ToString()); -- cgit v1.1 From efd481085135f60d8f6d3e4615591a26ec3f05f6 Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 25 Feb 2010 12:04:51 +0100 Subject: Disable blocking teleports within the same parcel for now; it's not implemented correctly. Will review soon. --- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 9ceab19..5f84252 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -722,8 +722,10 @@ namespace OpenSim.Region.Framework.Scenes //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) { - avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false); - position = currentPos; + //Disabling this behaviour for now pending review. ~CasperW + + //avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false); + //position = currentPos; } } else -- cgit v1.1 From 7f61de8f57d9f01e532dc37a5ef81153ba40fc24 Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 25 Feb 2010 14:14:53 +0100 Subject: Allow particles and texture anims to be persisted to XML. This behaviour is expected. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 11682d9..0d19589 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -518,14 +518,12 @@ namespace OpenSim.Region.Framework.Scenes set { m_scriptAccessPin = (int)value; } } - [XmlIgnore] public Byte[] TextureAnimation { get { return m_TextureAnimation; } set { m_TextureAnimation = value; } } - [XmlIgnore] public Byte[] ParticleSystem { get { return m_particleSystem; } -- cgit v1.1 From 83929c69e35d156d99be46a6ee50b0d3fe5c9f25 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Mar 2010 00:56:55 -0600 Subject: - implementing server 1.38 functions Signed-off-by: Melanie --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5c283bc..a85a4b3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4680,5 +4680,10 @@ namespace OpenSim.Region.Framework.Scenes m_log.Error("[Physics] " + ex); } } + + public Color4 GetTextColor() + { + return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A)); + } } } -- cgit v1.1 From 5caae0293ab0f69cced21923c36db230698c7970 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Mar 2010 22:14:06 +0000 Subject: Fix bug where approximately half the time, attachments would rez only their root prim until right clicked (or otherwise updated). The root cause of this problem was that multiple ObjectUpdates were being sent on attachment which differed enough to confuse the client. Sometimes these would eliminate each other and sometimes not, depending on whether the scheduler looked at the queued updates. The solution here is to only schedule the ObjectUpdate once the attachment code has done all it needs to do. Backport from head. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 44 ++++++++++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 40 +++++++++++--- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 62 ++++++++++++++-------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 35 +++++++++--- 4 files changed, 138 insertions(+), 43 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index c6cee75..5b21332 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2339,9 +2339,18 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnAttach(localID, itemID, avatarID); } - public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, - uint AttachmentPt) + /// + /// Called when the client receives a request to rez a single attachment on to the avatar from inventory + /// (RezSingleAttachmentFromInv packet). + /// + /// + /// + /// + /// + public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { + m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name); + SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt); if (att == null) @@ -2353,9 +2362,20 @@ namespace OpenSim.Region.Framework.Scenes return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt); } - public UUID RezSingleAttachment(SceneObjectGroup att, - IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + /// + /// Update the user inventory to reflect an attachment + /// + /// + /// + /// + /// + /// + public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { + m_log.DebugFormat( + "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})", + remoteClient.Name, att.Name, itemID); + if (!att.IsDeleted) AttachmentPt = att.RootPart.AttachmentPoint; @@ -2394,8 +2414,19 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); } + /// + /// This registers the item as attached in a user's inventory + /// + /// + /// + /// + /// public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) { +// m_log.DebugFormat( +// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", +// att.Name, remoteClient.Name, AttachmentPt, itemID); + if (UUID.Zero == itemID) { m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); @@ -2423,10 +2454,7 @@ namespace OpenSim.Region.Framework.Scenes presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); if (m_AvatarFactory != null) - { m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); - } - } } @@ -2509,6 +2537,7 @@ namespace OpenSim.Region.Framework.Scenes { sog.SetOwnerId(ownerID); sog.SetGroup(groupID, remoteClient); + sog.ScheduleGroupForFullUpdate(); foreach (SceneObjectPart child in sog.Children.Values) child.Inventory.ChangeInventoryOwner(ownerID); @@ -2530,6 +2559,7 @@ namespace OpenSim.Region.Framework.Scenes sog.SetOwnerId(groupID); sog.ApplyNextOwnerPermissions(); } + } foreach (uint localID in localIDs) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 41fd1e1..7796b8d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1813,14 +1813,22 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat( // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName); + SceneObjectGroup sceneObject = null; + // If an entity creator has been registered for this prim type then use that if (m_entityCreators.ContainsKey((PCode)shape.PCode)) - return m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape); + { + sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape); + } + else + { + // Otherwise, use this default creation code; + sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); + AddNewSceneObject(sceneObject, true); + sceneObject.SetGroup(groupID, null); + } - // Otherwise, use this default creation code; - SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); - AddNewSceneObject(sceneObject, true); - sceneObject.SetGroup(groupID, null); + sceneObject.ScheduleGroupForFullUpdate(); return sceneObject; } @@ -1848,7 +1856,7 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Add a newly created object to the scene + /// Add a newly created object to the scene. Updates are also sent to viewers. /// /// /// @@ -1857,8 +1865,25 @@ namespace OpenSim.Region.Framework.Scenes /// public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) { - return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup); + return AddNewSceneObject(sceneObject, attachToBackup, true); } + + /// + /// Add a newly created object to the scene + /// + /// + /// + /// If true, the object is made persistent into the scene. + /// If false, the object will not persist over server restarts + /// + /// + /// If true, updates for the new scene object are sent to all viewers in range. + /// If false, it is left to the caller to schedule the update + /// + public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) + { + return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); + } /// /// Delete every object from the scene @@ -3322,7 +3347,6 @@ namespace OpenSim.Region.Framework.Scenes } else m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn"); - } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 321cc45..d31b45e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -228,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.HasGroupChanged = true; } - return AddSceneObject(sceneObject, attachToBackup); + return AddSceneObject(sceneObject, attachToBackup, true); } /// @@ -243,12 +243,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// true if the object was added, false if an object with the same uuid was already in the scene /// - protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) + protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { // Ensure that we persist this new scene object sceneObject.HasGroupChanged = true; - return AddSceneObject(sceneObject, attachToBackup); + return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); } /// @@ -260,12 +260,19 @@ namespace OpenSim.Region.Framework.Scenes /// If true, the object is made persistent into the scene. /// If false, the object will not persist over server restarts /// - /// true if the object was added, false if an object with the same uuid was already in the scene + /// + /// If true, updates for the new scene object are sent to all viewers in range. + /// If false, it is left to the caller to schedule the update + /// + /// + /// true if the object was added, false if an object with the same uuid was already in the scene /// - protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) + protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) return false; + + bool alreadyExisted = false; if (m_parentScene.m_clampPrimSize) { @@ -286,6 +293,9 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.AttachToScene(m_parentScene); + if (sendClientUpdates) + sceneObject.ScheduleGroupForFullUpdate(); + lock (sceneObject) { if (!Entities.ContainsKey(sceneObject.UUID)) @@ -309,12 +319,14 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; } } - - return true; + } + else + { + alreadyExisted = true; } } - return false; + return alreadyExisted; } /// @@ -521,26 +533,34 @@ namespace OpenSim.Region.Framework.Scenes itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, false, false, remoteClient.AgentId, true); +// m_log.DebugFormat( +// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}", +// objatt.Name, remoteClient.Name, AttachmentPt); + if (objatt != null) { bool tainted = false; if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) tainted = true; - if (AttachObject( - remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false)) - { - objatt.ScheduleGroupForFullUpdate(); - if (tainted) - objatt.HasGroupChanged = true; - - // Fire after attach, so we don't get messy perms dialogs - // 3 == AttachedRez - objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); + //objatt.ScheduleGroupForFullUpdate(); - // Do this last so that event listeners have access to all the effects of the attachment - m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); - } + if (tainted) + objatt.HasGroupChanged = true; + + // Fire after attach, so we don't get messy perms dialogs + // 3 == AttachedRez + objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + + // Do this last so that event listeners have access to all the effects of the attachment + m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); + } + else + { + m_log.WarnFormat( + "[SCENE GRAPH]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", + itemID, remoteClient.Name, AttachmentPt); } return objatt; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c5a6171..c14b39a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -567,8 +567,10 @@ namespace OpenSim.Region.Framework.Scenes } ApplyPhysics(m_scene.m_physicalPrim); - - ScheduleGroupForFullUpdate(); + + // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled + // for the same object with very different properties. The caller must schedule the update. + //ScheduleGroupForFullUpdate(); } public Vector3 GroupScale() @@ -956,10 +958,11 @@ namespace OpenSim.Region.Framework.Scenes // don't attach attachments to child agents if (avatar.IsChildAgent) return; +// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name); + DetachFromBackup(); // Remove from database and parcel prim count - // m_scene.DeleteFromStorage(UUID); m_scene.EventManager.TriggerParcelPrimCountTainted(); @@ -985,7 +988,6 @@ namespace OpenSim.Region.Framework.Scenes SetAttachmentPoint(Convert.ToByte(attachmentpoint)); avatar.AddAttachment(this); - m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID); if (!silent) { @@ -1002,6 +1004,12 @@ namespace OpenSim.Region.Framework.Scenes ScheduleGroupForFullUpdate(); } } + else + { + m_log.WarnFormat( + "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", + UUID, agentID, Scene.RegionInfo.RegionName); + } } public byte GetAttachmentPoint() @@ -1986,6 +1994,8 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleFullUpdateToAvatar(ScenePresence presence) { +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); + RootPart.AddFullUpdateToAvatar(presence); lock (m_parts) @@ -2000,6 +2010,8 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleTerseUpdateToAvatar(ScenePresence presence) { +// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); + lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) @@ -2014,6 +2026,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForFullUpdate() { +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); + checkAtTargets(); RootPart.ScheduleFullUpdate(); @@ -2032,6 +2046,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForTerseUpdate() { +// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); + lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) @@ -2045,9 +2061,11 @@ namespace OpenSim.Region.Framework.Scenes /// Immediately send a full update for this scene object. /// public void SendGroupFullUpdate() - { + { if (IsDeleted) return; + +// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); RootPart.SendFullUpdateToAllClients(); @@ -2064,7 +2082,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Immediately send an update for this scene object's root prim only. /// This is for updates regarding the object as a whole, and none of its parts in particular. - /// Note: this may not be cused by opensim (it probably should) but it's used by + /// Note: this may not be used by opensim (it probably should) but it's used by /// external modules. /// public void SendGroupRootTerseUpdate() @@ -2079,6 +2097,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_scene == null) // Need to check here as it's null during object creation return; + m_scene.SceneGraph.AddToUpdateList(this); } @@ -3557,7 +3576,9 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; } - ScheduleGroupForFullUpdate(); + // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled + // for the same object with very different properties. The caller must schedule the update. + //ScheduleGroupForFullUpdate(); } public void TriggerScriptChangedEvent(Changed val) -- cgit v1.1 From fce9e499e4682edf6db7b4f9c5546524b4a25197 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 8 Mar 2010 01:19:45 -0600 Subject: - parcel blocking, region crossing blocking, teleport blocking --- OpenSim/Region/Framework/Scenes/Scene.cs | 229 +++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 388bc99..884f13a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -3251,6 +3252,7 @@ namespace OpenSim.Region.Framework.Scenes /// also return a reason. public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) { + TeleportFlags tp = (TeleportFlags)teleportFlags; //Teleport flags: // // TeleportFlags.ViaGodlikeLure - Border Crossing @@ -3284,6 +3286,17 @@ namespace OpenSim.Region.Framework.Scenes CapsModule.NewUserConnection(agent); + ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); + + //On login or border crossing test land permisions + if (tp != TeleportFlags.Default) + { + if (land != null && !TestLandRestrictions(agent, land, out reason)) + { + return false; + } + } + ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); if (sp != null) { @@ -3377,6 +3390,40 @@ namespace OpenSim.Region.Framework.Scenes return true; } + private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) + { + + bool banned = land.IsBannedFromLand(agent.AgentID); + bool restricted = land.IsRestrictedFromLand(agent.AgentID); + + if (banned || restricted) + { + ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); + if (nearestParcel != null) + { + //Move agent to nearest allowed + Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); + agent.startpos.X = newPosition.X; + agent.startpos.Y = newPosition.Y; + } + else + { + if (banned) + { + reason = "Cannot regioncross into banned parcel."; + } + else + { + reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", + RegionInfo.RegionName); + } + return false; + } + } + reason = ""; + return true; + } + /// /// Verifies that the user has a presence on the Grid /// @@ -3508,6 +3555,18 @@ namespace OpenSim.Region.Framework.Scenes return true; } + private ILandObject GetParcelAtPoint(float x, float y) + { + foreach (var parcel in AllParcels()) + { + if( parcel.ContainsPoint((int)x,(int)y)) + { + return parcel; + } + } + return null; + } + /// /// Update an AgentCircuitData object with new information /// @@ -4780,5 +4839,175 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_allowScriptCrossings; } } + + public Vector3? GetNearestAllowedPosition(ScenePresence avatar) + { + //simulate to make sure we have pretty up to date positions + PhysicsScene.Simulate(0); + + ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + + if (nearestParcel != null) + { + Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1)); + //Try to get a location that feels like where they came from + Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); + if (nearestPoint != null) + { + Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); + return nearestPoint.Value; + } + + //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel + Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition); + dir = Vector3.Normalize(directionToParcelCenter); + nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); + if (nearestPoint != null) + { + Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); + return nearestPoint.Value; + } + + //Ultimate backup if we have no idea where they are + Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); + return avatar.lastKnownAllowedPosition; + + } + + //Go to the edge, this happens in teleporting to a region with no available parcels + Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); + //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); + return nearestRegionEdgePoint; + return null; + } + + private Vector3 GetParcelCenterAtGround(ILandObject parcel) + { + Vector2 center = GetParcelCenter(parcel); + return GetPositionAtGround(center.X, center.Y); + } + + private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel) + { + Vector3 unitDirection = Vector3.Normalize(direction); + //Making distance to search go through some sane limit of distance + for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) + { + Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); + if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) + { + return testPos; + } + } + return null; + } + + public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) + { + List all = AllParcels(); + float minParcelDistance = float.MaxValue; + ILandObject nearestParcel = null; + + foreach (var parcel in all) + { + if (!parcel.IsEitherBannedOrRestricted(avatarId)) + { + float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); + if (parcelDistance < minParcelDistance) + { + minParcelDistance = parcelDistance; + nearestParcel = parcel; + } + } + } + + return nearestParcel; + } + + private List AllParcels() + { + return LandChannel.AllParcels(); + } + + private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y) + { + return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel)); + } + + //calculate the average center point of a parcel + private Vector2 GetParcelCenter(ILandObject parcel) + { + int count = 0; + int avgx = 0; + int avgy = 0; + for (int x = 0; x < Constants.RegionSize; x++) + { + for (int y = 0; y < Constants.RegionSize; y++) + { + //Just keep a running average as we check if all the points are inside or not + if (parcel.ContainsPoint(x, y)) + { + if (count == 0) + { + avgx = x; + avgy = y; + } + else + { + avgx = (avgx * count + x) / (count + 1); + avgy = (avgy * count + y) / (count + 1); + } + count += 1; + } + } + } + return new Vector2(avgx, avgy); + } + + private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) + { + float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; + float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y; + + //find out what vertical edge to go to + if (xdistance < ydistance) + { + if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) + { + return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); + } + else + { + return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); + } + } + //find out what horizontal edge to go to + else + { + if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) + { + return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); + } + else + { + return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); + } + } + } + + private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y) + { + Vector3 ground = GetPositionAtGround(x, y); + if( avatar.AbsolutePosition.Z > ground.Z) + { + ground.Z = avatar.AbsolutePosition.Z; + } + return ground; + } + + private Vector3 GetPositionAtGround(float x, float y) + { + return new Vector3(x, y, GetGroundHeight(x, y)); + } } } -- cgit v1.1 From 689514a40a52d71f9cfaaedbb295a57b1d7c728a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 9 Mar 2010 23:10:14 +0000 Subject: Cache UserLevel in ScenePresence on SP creation. Change IsAdministrator to use that stored value. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 93e66e0..f1be4d8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -150,7 +150,8 @@ namespace OpenSim.Region.Framework.Scenes private float m_sitAvatarHeight = 2.0f; - private float m_godlevel; + private int m_godLevel; + private int m_userLevel; private bool m_invulnerable = true; @@ -304,9 +305,14 @@ namespace OpenSim.Region.Framework.Scenes get { return m_invulnerable; } } - public float GodLevel + public int UserLevel { - get { return m_godlevel; } + get { return m_userLevel; } + } + + public int GodLevel + { + get { return m_godLevel; } } public ulong RegionHandle @@ -678,6 +684,10 @@ namespace OpenSim.Region.Framework.Scenes m_regionInfo = reginfo; m_localId = m_scene.AllocateLocalId(); + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); + + m_userLevel = account.UserLevel; + IGroupsModule gm = m_scene.RequestModuleInterface(); if (gm != null) m_grouptitle = gm.GetGroupTitle(m_uuid); @@ -3164,17 +3174,17 @@ namespace OpenSim.Region.Framework.Scenes if (account != null) { if (account.UserLevel > 0) - m_godlevel = account.UserLevel; + m_godLevel = account.UserLevel; else - m_godlevel = 200; + m_godLevel = 200; } } else { - m_godlevel = 0; + m_godLevel = 0; } - ControllingClient.SendAdminResponse(token, (uint)m_godlevel); + ControllingClient.SendAdminResponse(token, (uint)m_godLevel); } #region Child Agent Updates @@ -3265,7 +3275,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.ControlFlags = (uint)m_AgentControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) - cAgent.GodLevel = (byte)m_godlevel; + cAgent.GodLevel = (byte)m_godLevel; else cAgent.GodLevel = (byte) 0; @@ -3354,7 +3364,7 @@ namespace OpenSim.Region.Framework.Scenes m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) - m_godlevel = cAgent.GodLevel; + m_godLevel = cAgent.GodLevel; m_setAlwaysRun = cAgent.AlwaysRun; uint i = 0; -- cgit v1.1 From f6f6ef1532517972b973d8a500818dcd50873352 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 11 Mar 2010 19:12:38 -0500 Subject: Dynamics Integration Part 1 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0d19589..1353518 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -747,7 +747,16 @@ namespace OpenSim.Region.Framework.Scenes /// public Vector3 Acceleration { - get { return m_acceleration; } + get + { + PhysicsActor actor = PhysActor; + if (actor != null) + { + m_acceleration = actor.Acceleration; + } + return m_acceleration; + } + set { m_acceleration = value; } } -- cgit v1.1 From 819806261026cccd68dee649f11938ae5bf10029 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Sun, 14 Mar 2010 16:22:13 -0400 Subject: RotLookAt repaired; debug msg cleanup. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 +-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 35 ++-------------------- 2 files changed, 4 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f35a7c5..5443c28 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1955,7 +1955,7 @@ namespace OpenSim.Region.Framework.Scenes else { if (rootpart.PhysActor != null) - { + { // APID must be implemented in your physics system for this to function. rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); rootpart.PhysActor.APIDStrength = strength; rootpart.PhysActor.APIDDamping = damping; @@ -1971,7 +1971,7 @@ namespace OpenSim.Region.Framework.Scenes if (rootpart != null) { if (rootpart.PhysActor != null) - { + { // APID must be implemented in your physics system for this to function. rootpart.PhysActor.APIDActive = false; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 31ea502..548a64f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2705,38 +2705,7 @@ namespace OpenSim.Region.Framework.Scenes public void RotLookAt(Quaternion target, float strength, float damping) { - rotLookAt(target, strength, damping); - } - - public void rotLookAt(Quaternion target, float strength, float damping) - { - if (IsAttachment) - { - /* - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) - { - Rotate the Av? - } */ - } - else - { - APIDDamp = damping; - APIDStrength = strength; - APIDTarget = target; - } - } - - public void startLookAt(Quaternion rot, float damp, float strength) - { - APIDDamp = damp; - APIDStrength = strength; - APIDTarget = rot; - } - - public void stopLookAt() - { - APIDTarget = Quaternion.Identity; + m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup. } /// @@ -3460,7 +3429,7 @@ namespace OpenSim.Region.Framework.Scenes public void StopLookAt() { - m_parentGroup.stopLookAt(); + m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup. m_parentGroup.ScheduleGroupForTerseUpdate(); } -- cgit v1.1 From a1cd3b5b88cc2cc3fcd552085dc9ab46f9d9b10f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 15 Mar 2010 17:54:39 +0000 Subject: Change GodLevel to UserLevel so gods can teleport freely without having to enter god mode first --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 24179a9..2661dc3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -879,7 +879,7 @@ namespace OpenSim.Region.Framework.Scenes if (land != null) { //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) { pos = land.LandData.UserLocation; } -- cgit v1.1 From 6df969894c1943dceeefd3765951daaf0a2eb94c Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Wed, 17 Mar 2010 13:30:48 -0400 Subject: Fix AbsolutePosition for autopilot/sit. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 24179a9..608e84c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -463,7 +463,8 @@ namespace OpenSim.Region.Framework.Scenes get { PhysicsActor actor = m_physicsActor; - if (actor != null) +// if (actor != null) + if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! m_pos = actor.Position; return m_parentPosition + m_pos; @@ -484,7 +485,8 @@ namespace OpenSim.Region.Framework.Scenes } } - m_pos = value; + if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! + m_pos = value; m_parentPosition = Vector3.Zero; } } @@ -1267,6 +1269,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); m_pos = m_LastFinitePos; + if (!m_pos.IsFinite()) { m_pos.X = 127f; @@ -1904,6 +1907,7 @@ namespace OpenSim.Region.Framework.Scenes { m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center autopilotTarget = part.AbsolutePosition; +//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); } else return; // occupied small } // end large/small @@ -2280,7 +2284,8 @@ namespace OpenSim.Region.Framework.Scenes m_pos += SIT_TARGET_ADJUSTMENT; m_bodyRot = sitTargetOrient; m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; + part.IsOccupied = true; +Console.WriteLine("Scripted Sit ofset {0}", m_pos); } else { @@ -3348,6 +3353,7 @@ namespace OpenSim.Region.Framework.Scenes m_callbackURI = cAgent.CallbackURI; m_pos = cAgent.Position; + m_velocity = cAgent.Velocity; m_CameraCenter = cAgent.Center; //m_avHeight = cAgent.Size.Z; -- cgit v1.1 From f35eb8819c6a872e7c4727940ffc560f7d5d68bd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Mar 2010 18:57:29 +0000 Subject: Unify a previous refactor of object return with the older solution. We really don't need two methods doing the same thing, but differently. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 +++--- .../Region/Framework/Scenes/Scene.Permissions.cs | 29 +++++----------------- 2 files changed, 10 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b2b061e..ffbf745 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1581,9 +1581,10 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient != null) { permissionToTake = - Permissions.CanReturnObject( - grp.UUID, - remoteClient.AgentId); + Permissions.CanReturnObjects( + null, + remoteClient.AgentId, + new List() {grp}); permissionToDelete = permissionToTake; if (permissionToDelete) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d1d6b6a..7dab04f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); - public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene); + public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool TeleportHandler(UUID userID, Scene scene); - public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List retlist, Scene scene); #endregion public class ScenePermissions @@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes public event EditObjectInventoryHandler OnEditObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; - public event ReturnObjectHandler OnReturnObject; + public event ReturnObjectsHandler OnReturnObjects; public event InstantMessageHandler OnInstantMessage; public event InventoryTransferHandler OnInventoryTransfer; public event ViewScriptHandler OnViewScript; @@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes public event CopyUserInventoryHandler OnCopyUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory; public event TeleportHandler OnTeleport; - public event UseObjectReturnHandler OnUseObjectReturn; #endregion #region Object Permission Checks @@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region RETURN OBJECT - public bool CanReturnObject(UUID objectID, UUID returnerID) + public bool CanReturnObjects(ILandObject land, UUID user, List objects) { - ReturnObjectHandler handler = OnReturnObject; + ReturnObjectsHandler handler = OnReturnObjects; if (handler != null) { Delegate[] list = handler.GetInvocationList(); - foreach (ReturnObjectHandler h in list) + foreach (ReturnObjectsHandler h in list) { - if (h(objectID, returnerID, m_scene) == false) + if (h(land, user, objects, m_scene) == false) return false; } } @@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes } return true; } - - public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List retlist) - { - UseObjectReturnHandler handler = OnUseObjectReturn; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (UseObjectReturnHandler h in list) - { - if (h(landData, type, client, retlist, m_scene) == false) - return false; - } - } - return true; - } } } -- cgit v1.1 From 69b5ddceda1fd418712fb7ada0443555dc82b231 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Mar 2010 18:57:29 +0000 Subject: Unify a previous refactor of object return with the older solution. We really don't need two methods doing the same thing, but differently. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 +++--- .../Region/Framework/Scenes/Scene.Permissions.cs | 29 +++++----------------- 2 files changed, 10 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 6ebd048..cadb858 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1522,9 +1522,10 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient != null) { permissionToTake = - Permissions.CanReturnObject( - grp.UUID, - remoteClient.AgentId); + Permissions.CanReturnObjects( + null, + remoteClient.AgentId, + new List() {grp}); permissionToDelete = permissionToTake; if (permissionToDelete) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d1d6b6a..7dab04f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); - public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene); + public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool TeleportHandler(UUID userID, Scene scene); - public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List retlist, Scene scene); #endregion public class ScenePermissions @@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes public event EditObjectInventoryHandler OnEditObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; - public event ReturnObjectHandler OnReturnObject; + public event ReturnObjectsHandler OnReturnObjects; public event InstantMessageHandler OnInstantMessage; public event InventoryTransferHandler OnInventoryTransfer; public event ViewScriptHandler OnViewScript; @@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes public event CopyUserInventoryHandler OnCopyUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory; public event TeleportHandler OnTeleport; - public event UseObjectReturnHandler OnUseObjectReturn; #endregion #region Object Permission Checks @@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region RETURN OBJECT - public bool CanReturnObject(UUID objectID, UUID returnerID) + public bool CanReturnObjects(ILandObject land, UUID user, List objects) { - ReturnObjectHandler handler = OnReturnObject; + ReturnObjectsHandler handler = OnReturnObjects; if (handler != null) { Delegate[] list = handler.GetInvocationList(); - foreach (ReturnObjectHandler h in list) + foreach (ReturnObjectsHandler h in list) { - if (h(objectID, returnerID, m_scene) == false) + if (h(land, user, objects, m_scene) == false) return false; } } @@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes } return true; } - - public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List retlist) - { - UseObjectReturnHandler handler = OnUseObjectReturn; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (UseObjectReturnHandler h in list) - { - if (h(landData, type, client, retlist, m_scene) == false) - return false; - } - } - return true; - } } } -- cgit v1.1 From 3ea72eeabb12cff4f71523f501450a7df38a17b1 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Fri, 19 Mar 2010 13:26:34 -0400 Subject: Fix sit with autopilot. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 123d6f3..2603fe1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -455,8 +455,9 @@ namespace OpenSim.Region.Framework.Scenes get { PhysicsActor actor = m_physicsActor; - if (actor != null) - m_pos = actor.Position; +// if (actor != null) + if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! + m_pos = actor.Position; return m_parentPosition + m_pos; } @@ -476,7 +477,8 @@ namespace OpenSim.Region.Framework.Scenes } } - m_pos = value; + if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! + m_pos = value; m_parentPosition = Vector3.Zero; } } -- cgit v1.1 From 7d917e7c5c599549d2a87451fe3d6ca2bf6e62a4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Mar 2010 23:29:03 +0100 Subject: Rename Meta7Windlight to LightShare --- OpenSim/Region/Framework/Scenes/EventManager.cs | 4 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 11 +++++------ OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 37a51d9..ef125cd 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -207,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate void OnMakeRootAgentDelegate(ScenePresence presence); public delegate void OnSaveNewWindlightProfileDelegate(); - public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user); + public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user); public event OnMakeRootAgentDelegate OnMakeRootAgent; public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; @@ -1220,7 +1220,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user) + public void TriggerOnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID user) { OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted; if (handlerSendNewWindlightProfileTargeted != null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2b6f80b..1f604c5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1729,7 +1729,7 @@ namespace OpenSim.Region.Framework.Scenes m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); } - public void StoreWindlightProfile(RegionMeta7WindlightData wl) + public void StoreWindlightProfile(RegionLightShareData wl) { m_regInfo.WindlightSettings = wl; m_storageManager.DataStore.StoreRegionWindlightSettings(wl); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3895d93..7ed29a5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1370,21 +1370,20 @@ namespace OpenSim.Region.Framework.Scenes { // part.Inventory.RemoveScriptInstances(); - List avatars = Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + Scene.ForEachScenePresence(delegate (ScenePresence sp) { - if (avatars[i].ParentID == LocalId) + if (sp.ParentID == LocalId) { - avatars[i].StandUp(); + sp.StandUp(); } if (!silent) { part.UpdateFlag = 0; if (part == m_rootPart) - avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); + sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); } - } + }); } diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 68035ca..8b2d387 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs @@ -101,13 +101,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests { throw new NotImplementedException(); } - public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID) + public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) { //This connector doesn't support the windlight module yet //Return default LL windlight settings - return new RegionMeta7WindlightData(); + return new RegionLightShareData(); } - public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl) + public void StoreRegionWindlightSettings(RegionLightShareData wl) { //This connector doesn't support the windlight module yet } -- cgit v1.1 From 2fbbc13c71052e66269035031e894b736e2ead5d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Apr 2010 19:42:15 +0100 Subject: Fix some overlooked merge conflicts that got committed --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5951a92..0785f7f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2203,13 +2203,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForTerseUpdate() { -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs lockPartsForRead(true); -======= -// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); - - lock (m_parts) ->>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs { foreach (SceneObjectPart part in m_parts.Values) { @@ -3765,15 +3759,11 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; } -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs lockPartsForRead(false); - ScheduleGroupForFullUpdate(); -======= // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled // for the same object with very different properties. The caller must schedule the update. //ScheduleGroupForFullUpdate(); ->>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs } public void TriggerScriptChangedEvent(Changed val) -- cgit v1.1 From f34cc6b46949033803c79235b9d82da9bf9634dd Mon Sep 17 00:00:00 2001 From: Thomas Grimshaw Date: Mon, 5 Apr 2010 22:08:34 +0200 Subject: Add a much cheaper agent count retrieval method. This is obsoleted by 0.7 so it can be reverted then. --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ab0d397..e5e6fc9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1523,7 +1523,7 @@ namespace OpenSim.Region.Framework.Scenes public void SaveTerrain() { m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); - } + } public void StoreWindlightProfile(RegionMeta7WindlightData wl) { @@ -4339,6 +4339,14 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Cheaply return the number of avatars in a region (without fetching a list object) + /// + public int GetRootAgentCount() + { + return m_sceneGraph.GetRootAgentCount(); + } + + /// /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. /// This list is a new object, so it can be iterated over without locking. /// -- cgit v1.1 From 7a3bb266ebc057a1af589fc642bfeca08de72c98 Mon Sep 17 00:00:00 2001 From: Thomas Grimshaw Date: Mon, 5 Apr 2010 22:11:05 +0200 Subject: This commit adds some randomness to object persistence. It's a Work In Progress, I am working on improving this to a tiered approach. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 46 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5443c28..9a205e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes /// since the group's last persistent backup /// private bool m_hasGroupChanged = false; - private long timeFirstChanged; - private long timeLastChanged; + private long timeFirstChanged = 0; + private long timeLastChanged = 0; + long m_maxPersistTime = 0; + long m_minPersistTime = 0; + Random m_rand; + private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); public void lockPartsForRead(bool locked) @@ -182,6 +186,28 @@ namespace OpenSim.Region.Framework.Scenes timeLastChanged = DateTime.Now.Ticks; if (!m_hasGroupChanged) timeFirstChanged = DateTime.Now.Ticks; + if (m_rand == null) + { + byte[] val = new byte[16]; + m_rootPart.UUID.ToBytes(val, 0); + m_rand = new Random(BitConverter.ToInt32(val, 0)); + } + if (Scene.GetRootAgentCount() == 0) + { + //If the region is empty, this change has been made by an automated process + //and thus we delay the persist time by a random amount between 1.5 and 2.5. + + float factor = 1.5f + (float)(m_rand.NextDouble()); + m_maxPersistTime = (long)((float)Scene.m_persistAfter * factor); + m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * factor); + } + else + { + //If the region is not empty, we want to obey the minimum and maximum persist times + //but add a random factor so we stagger the object persistance a little + m_maxPersistTime = (long)((float)Scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 + m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 + } } m_hasGroupChanged = value; } @@ -197,8 +223,19 @@ namespace OpenSim.Region.Framework.Scenes return false; if (m_scene.ShuttingDown) return true; + + if (m_minPersistTime == 0 || m_maxPersistTime == 0) + { + m_maxPersistTime = m_scene.m_persistAfter; + m_minPersistTime = m_scene.m_dontPersistBefore; + } + long currentTime = DateTime.Now.Ticks; - if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) + + if (timeLastChanged == 0) timeLastChanged = currentTime; + if (timeFirstChanged == 0) timeFirstChanged = currentTime; + + if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) return true; return false; } @@ -529,6 +566,7 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup() { + } /// @@ -545,7 +583,7 @@ namespace OpenSim.Region.Framework.Scenes /// Constructor. This object is added to the scene later via AttachToScene() /// public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) - { + { SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); } -- cgit v1.1 From 2f454843d82ce0253af393817cf6f0ebb9046112 Mon Sep 17 00:00:00 2001 From: Thomas Grimshaw Date: Mon, 5 Apr 2010 23:17:06 +0200 Subject: Fix up my own shoddy code! Fixes prim rez break. Whups! --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0277ed8..13d1d4e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -106,9 +106,9 @@ namespace OpenSim.Region.Framework.Scenes private bool m_hasGroupChanged = false; private long timeFirstChanged = 0; private long timeLastChanged = 0; - long m_maxPersistTime = 0; - long m_minPersistTime = 0; - Random m_rand; + private long m_maxPersistTime = 0; + private long m_minPersistTime = 0; + private Random m_rand; private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); @@ -186,27 +186,31 @@ namespace OpenSim.Region.Framework.Scenes timeLastChanged = DateTime.Now.Ticks; if (!m_hasGroupChanged) timeFirstChanged = DateTime.Now.Ticks; - if (m_rand == null) + if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) { - byte[] val = new byte[16]; - m_rootPart.UUID.ToBytes(val, 0); - m_rand = new Random(BitConverter.ToInt32(val, 0)); - } - if (Scene.GetRootAgentCount() == 0) - { - //If the region is empty, this change has been made by an automated process - //and thus we delay the persist time by a random amount between 1.5 and 2.5. + if (m_rand == null) + { + byte[] val = new byte[16]; + m_rootPart.UUID.ToBytes(val, 0); + m_rand = new Random(BitConverter.ToInt32(val, 0)); + } + + if (m_scene.GetRootAgentCount() == 0) + { + //If the region is empty, this change has been made by an automated process + //and thus we delay the persist time by a random amount between 1.5 and 2.5. - float factor = 1.5f + (float)(m_rand.NextDouble()); - m_maxPersistTime = (long)((float)Scene.m_persistAfter * factor); - m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * factor); - } - else - { - //If the region is not empty, we want to obey the minimum and maximum persist times - //but add a random factor so we stagger the object persistance a little - m_maxPersistTime = (long)((float)Scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 - m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 + float factor = 1.5f + (float)(m_rand.NextDouble()); + m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); + m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); + } + else + { + //If the region is not empty, we want to obey the minimum and maximum persist times + //but add a random factor so we stagger the object persistance a little + m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 + m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 + } } } m_hasGroupChanged = value; -- cgit v1.1 From e80e04c5fd3892cf3c988baaa00aa8ccfa330256 Mon Sep 17 00:00:00 2001 From: Thomas Grimshaw Date: Wed, 7 Apr 2010 22:59:13 +0200 Subject: Increase the amount of time we wait for a teleport to complete. This allows teleportation to a remote region without a local connection to the asset server without timing out. --- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 5f84252..04626d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -1032,7 +1032,7 @@ namespace OpenSim.Region.Framework.Scenes public bool WaitForCallback(UUID id) { - int count = 200; + int count = 400; while (m_agentsInTransit.Contains(id) && count-- > 0) { //m_log.Debug(" >>> Waiting... " + count); -- cgit v1.1 From 7701ea27983be851a3c9d3954346018e07680ae6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 9 Apr 2010 06:49:14 +0100 Subject: Add Scene.SnmpService, which is of type ISnmpModule and, if nun-null, can be used to send snmp alerts --- OpenSim/Region/Framework/Scenes/Scene.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55f4550..db073e8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -158,6 +158,20 @@ namespace OpenSim.Region.Framework.Scenes public IXfer XferManager; + protected ISnmpModule m_snmpService = null; + public ISnmpModule SnmpService + { + get + { + if (m_snmpService == null) + { + m_snmpService = RequestModuleInterface(); + } + + return m_snmpService; + } + } + protected IAssetService m_AssetService; protected IAuthorizationService m_AuthorizationService; -- cgit v1.1 From 0b2b2daf23dbf7a51f3d568903548cd964334ce2 Mon Sep 17 00:00:00 2001 From: Mike Rieker Date: Sat, 10 Apr 2010 14:43:26 -0400 Subject: guarantee that a script engine's GetScriptErrors() will not be called until after its OnRezScript() returns so that script compile error messages can be retrieved --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 76 +++++++++++++++++++--- 2 files changed, 69 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b04871e..6c57d18 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -271,8 +271,7 @@ namespace OpenSim.Region.Framework.Scenes { // Needs to determine which engine was running it and use that // - part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); - errors = part.Inventory.GetScriptErrors(item.ItemID); + errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5d00917..d03b464 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -46,6 +46,8 @@ namespace OpenSim.Region.Framework.Scenes private string m_inventoryFileName = String.Empty; private int m_inventoryFileNameSerial = 0; + + private Dictionary m_scriptErrors = new Dictionary(); /// /// The part to which the inventory belongs. @@ -211,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public ArrayList GetScriptErrors(UUID itemID) + private ArrayList GetScriptErrors(UUID itemID) { ArrayList ret = new ArrayList(); @@ -270,7 +272,10 @@ namespace OpenSim.Region.Framework.Scenes // item.Name, item.ItemID, Name, UUID); if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) + { + StoreScriptError(item.ItemID, "no permission"); return; + } m_part.AddFlag(PrimFlags.Scripted); @@ -285,6 +290,7 @@ namespace OpenSim.Region.Framework.Scenes m_items.LockItemsForWrite(false); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); + StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID)); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); return; @@ -294,11 +300,13 @@ namespace OpenSim.Region.Framework.Scenes { if (null == asset) { + string msg = String.Format("asset ID {0} could not be found", item.AssetID); + StoreScriptError(item.ItemID, msg); m_log.ErrorFormat( "[PRIM INVENTORY]: " + - "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", + "Couldn't start script {0}, {1} at {2} in {3} since {4}", item.Name, item.ItemID, m_part.AbsolutePosition, - m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); + m_part.ParentGroup.Scene.RegionInfo.RegionName, msg); } else { @@ -311,11 +319,16 @@ namespace OpenSim.Region.Framework.Scenes string script = Utils.BytesToString(asset.Data); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); + StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID)); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); } }); } + else + { + StoreScriptError(item.ItemID, "scripts disabled"); + } } private void RestoreSavedScriptState(UUID oldID, UUID newID) @@ -392,24 +405,71 @@ namespace OpenSim.Region.Framework.Scenes else { m_items.LockItemsForRead(false); + string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, + m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); + StoreScriptError(itemId, msg); m_log.ErrorFormat( "[PRIM INVENTORY]: " + - "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", - itemId, m_part.Name, m_part.UUID, - m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); + "Couldn't start script with ID {0} since it {1}", itemId, msg); } } else { m_items.LockItemsForRead(false); + string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); + StoreScriptError(itemId, msg); m_log.ErrorFormat( "[PRIM INVENTORY]: " + - "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", - itemId, m_part.Name, m_part.UUID); + "Couldn't start script with ID {0} since it {1}", itemId, msg); } } + public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) + { + ArrayList errors; + + lock (m_scriptErrors) + { + m_scriptErrors.Remove(itemId); + } + CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource); + lock (m_scriptErrors) + { + while (!m_scriptErrors.TryGetValue(itemId, out errors)) + { + if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "timedout waiting for script {0} errors", itemId); + if (!m_scriptErrors.TryGetValue(itemId, out errors)) + { + errors = new ArrayList(1); + errors.Add("timedout waiting for errors"); + } + break; + } + } + m_scriptErrors.Remove(itemId); + } + return errors; + } + private void StoreScriptErrors(UUID itemId, ArrayList errors) + { + lock (m_scriptErrors) + { + m_scriptErrors[itemId] = errors; + System.Threading.Monitor.PulseAll(m_scriptErrors); + } + } + private void StoreScriptError(UUID itemId, string message) + { + ArrayList errors = new ArrayList(1); + errors.Add(message); + StoreScriptErrors(itemId, errors); + } + /// /// Stop a script which is in this prim's inventory. /// -- cgit v1.1 From 68a4f897b4f39e46c291d180db5062725130392d Mon Sep 17 00:00:00 2001 From: Mike Rieker Date: Sun, 18 Apr 2010 19:19:16 -0400 Subject: This GetScriptErrors() change allows initial XEngine to run in background thread. It should block only for the case of being called by CapsUpdateTaskInventoryScriptAsset(). --- .../Framework/Scenes/SceneObjectPartInventory.cs | 71 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index d03b464..a2fceb7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -290,7 +290,7 @@ namespace OpenSim.Region.Framework.Scenes m_items.LockItemsForWrite(false); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); - StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID)); + StoreScriptErrors(item.ItemID, null); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); return; @@ -319,7 +319,7 @@ namespace OpenSim.Region.Framework.Scenes string script = Utils.BytesToString(asset.Data); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); - StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID)); + StoreScriptErrors(item.ItemID, null); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); } @@ -388,12 +388,23 @@ namespace OpenSim.Region.Framework.Scenes /// /// Start a script which is in this prim's inventory. + /// Some processing may occur in the background, but this routine returns asap. /// /// /// A /// public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) { + lock (m_scriptErrors) + { + // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion + m_scriptErrors.Remove(itemId); + } + CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); + } + + private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) + { m_items.LockItemsForRead(true); if (m_items.ContainsKey(itemId)) { @@ -425,25 +436,38 @@ namespace OpenSim.Region.Framework.Scenes } + /// + /// Start a script which is in this prim's inventory and return any compilation error messages. + /// + /// + /// A + /// public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) { ArrayList errors; + // Indicate to CreateScriptInstanceInternal() we want it to + // post any compilation/loading error messages lock (m_scriptErrors) { - m_scriptErrors.Remove(itemId); + m_scriptErrors[itemId] = null; } - CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource); + + // Perform compilation/loading + CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); + + // Wait for and retrieve any errors lock (m_scriptErrors) { - while (!m_scriptErrors.TryGetValue(itemId, out errors)) + while ((errors = m_scriptErrors[itemId]) == null) { if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "timedout waiting for script {0} errors", itemId); - if (!m_scriptErrors.TryGetValue(itemId, out errors)) + errors = m_scriptErrors[itemId]; + if (errors == null) { errors = new ArrayList(1); errors.Add("timedout waiting for errors"); @@ -455,14 +479,49 @@ namespace OpenSim.Region.Framework.Scenes } return errors; } + + // Signal to CreateScriptInstanceEr() that compilation/loading is complete private void StoreScriptErrors(UUID itemId, ArrayList errors) { lock (m_scriptErrors) { + // If compilation/loading initiated via CreateScriptInstance(), + // it does not want the errors, so just get out + if (!m_scriptErrors.ContainsKey(itemId)) + { + return; + } + + // Initiated via CreateScriptInstanceEr(), if we know what the + // errors are, save them and wake CreateScriptInstanceEr(). + if (errors != null) + { + m_scriptErrors[itemId] = errors; + System.Threading.Monitor.PulseAll(m_scriptErrors); + return; + } + } + + // Initiated via CreateScriptInstanceEr() but we don't know what + // the errors are yet, so retrieve them from the script engine. + // This may involve some waiting internal to GetScriptErrors(). + errors = GetScriptErrors(itemId); + + // Get a default non-null value to indicate success. + if (errors == null) + { + errors = new ArrayList(); + } + + // Post to CreateScriptInstanceEr() and wake it up + lock (m_scriptErrors) + { m_scriptErrors[itemId] = errors; System.Threading.Monitor.PulseAll(m_scriptErrors); } } + + // Like StoreScriptErrors(), but just posts a single string message private void StoreScriptError(UUID itemId, string message) { ArrayList errors = new ArrayList(1); -- cgit v1.1 From 1667a29c88905e6734c1402a51a9365209114e1d Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 19 Apr 2010 12:54:33 +0200 Subject: And some more rez modes that weren't covered before --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 66ed64b..2f1a189 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1281,6 +1281,7 @@ namespace OpenSim.Region.Framework.Scenes // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); part.GetProperties(remoteClient); + part.ParentGroup.ResumeScripts(); } else { @@ -1350,6 +1351,7 @@ namespace OpenSim.Region.Framework.Scenes part.GetProperties(remoteClient); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); + part.ParentGroup.ResumeScripts(); } } -- cgit v1.1 From 780630d7c05f7306ffceb52db0eda1401112f426 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 23 Apr 2010 14:41:20 +0200 Subject: Fix a nullref in attachment handling. Add some debug to find the attachment state issue --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 6 ++++++ 3 files changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e6e414f..44fd2e1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1628,6 +1628,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient.AgentId); AssetService.Store(asset); + m_log.DebugFormat("[ScriptState]: Saved attachment as asset {0}", asset.FullID); item.AssetID = asset.FullID; item.Description = asset.Description; item.Name = asset.Name; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 84c3719..1f8c732 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -612,6 +612,7 @@ namespace OpenSim.Region.Framework.Scenes { UUID itemid = new UUID(node.Attributes["UUID"].Value); m_savedScriptState.Add(itemid, node.InnerXml); + m_log.DebugFormat("[ScriptState]: Retrieved state for script item ID {0}", itemid.ToString()); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 04df35a..ce4802d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -333,8 +333,10 @@ namespace OpenSim.Region.Framework.Scenes if (engines == null) // No engine at all return; + m_log.DebugFormat("[ScriptState]: Item ID changed: {0} to {1}", oldID, newID); if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) { + m_log.DebugFormat("[ScriptState]: Found script state for {0}, applying to new script item {1}", oldID, newID); XmlDocument doc = new XmlDocument(); doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); @@ -380,6 +382,10 @@ namespace OpenSim.Region.Framework.Scenes } m_part.ParentGroup.m_savedScriptState.Remove(oldID); } + else + { + m_log.DebugFormat("[ScriptState]: No state for old ID {0}", oldID); + } } /// -- cgit v1.1 From 31e0704c8d7f6100153ddedd64be7f2ab1ad9311 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 23 Apr 2010 17:48:50 +0200 Subject: Remove debug output, the culprit has been identified --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 - OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 - OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 6 ------ 3 files changed, 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 44fd2e1..e6e414f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1628,7 +1628,6 @@ namespace OpenSim.Region.Framework.Scenes remoteClient.AgentId); AssetService.Store(asset); - m_log.DebugFormat("[ScriptState]: Saved attachment as asset {0}", asset.FullID); item.AssetID = asset.FullID; item.Description = asset.Description; item.Name = asset.Name; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1f8c732..84c3719 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -612,7 +612,6 @@ namespace OpenSim.Region.Framework.Scenes { UUID itemid = new UUID(node.Attributes["UUID"].Value); m_savedScriptState.Add(itemid, node.InnerXml); - m_log.DebugFormat("[ScriptState]: Retrieved state for script item ID {0}", itemid.ToString()); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index ce4802d..04df35a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -333,10 +333,8 @@ namespace OpenSim.Region.Framework.Scenes if (engines == null) // No engine at all return; - m_log.DebugFormat("[ScriptState]: Item ID changed: {0} to {1}", oldID, newID); if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) { - m_log.DebugFormat("[ScriptState]: Found script state for {0}, applying to new script item {1}", oldID, newID); XmlDocument doc = new XmlDocument(); doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); @@ -382,10 +380,6 @@ namespace OpenSim.Region.Framework.Scenes } m_part.ParentGroup.m_savedScriptState.Remove(oldID); } - else - { - m_log.DebugFormat("[ScriptState]: No state for old ID {0}", oldID); - } } /// -- cgit v1.1 From 71f42f185a48ef96391b39fa0197c1a8b793e969 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 24 Apr 2010 16:45:25 +0200 Subject: Plumb a data path to initialize an attachment from an alternate source --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c220bf0..a5c0b0d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3984,7 +3984,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); { // Rez from inventory UUID asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); m_log.InfoFormat( "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", -- cgit v1.1 From 899d521ab41910e09e66849a5c086d7ae32d01a4 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 24 Apr 2010 18:59:34 +0200 Subject: Use the saved script states --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a5c0b0d..ceb4395 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -26,6 +26,7 @@ */ using System; +using System.Xml; using System.Collections.Generic; using System.Reflection; using System.Timers; @@ -3963,6 +3964,32 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); return; } + XmlDocument doc = new XmlDocument(); + string stateData = String.Empty; + + IAttachmentsService attServ = m_scene.RequestModuleInterface(); + if (attServ != null) + { + m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); + stateData = attServ.Get(ControllingClient.AgentId.ToString()); + doc.LoadXml(stateData); + } + + Dictionary itemData = new Dictionary(); + + XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); + if (nodes.Count > 0) + { + foreach (XmlNode n in nodes) + { + XmlElement elem = (XmlElement)n; + string itemID = elem.GetAttribute("ItemID"); + string xml = elem.InnerXml; + + itemData[new UUID(itemID)] = xml; + } + } + List attPoints = m_appearance.GetAttachedPoints(); foreach (int p in attPoints) { @@ -3982,9 +4009,17 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); try { + string xmlData; + XmlDocument d = new XmlDocument(); + if (itemData.TryGetValue(itemID, out xmlData)) + { + d.LoadXml(xmlData); + m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); + } + // Rez from inventory UUID asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); m_log.InfoFormat( "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", -- cgit v1.1 From 81ff5eaba09e7569ef5359874ffcfc7f8855f0b4 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 25 Apr 2010 22:03:35 +0200 Subject: Make scripted attachment states work. Finally. Also replace two monitor locks with RWLocks, hunting the 10^3 bug. Not successful, but needed to be done anyway --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 7 +++- .../Framework/Scenes/SceneObjectPartInventory.cs | 41 +++++++++++++++------- 2 files changed, 34 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 84c3719..1c6f2d1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1041,6 +1041,11 @@ namespace OpenSim.Region.Framework.Scenes public void SaveScriptedState(XmlTextWriter writer) { + SaveScriptedState(writer, false); + } + + public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) + { XmlDocument doc = new XmlDocument(); Dictionary states = new Dictionary(); @@ -1050,7 +1055,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in m_parts.Values) { - Dictionary pstates = part.Inventory.GetScriptStates(); + Dictionary pstates = part.Inventory.GetScriptStates(oldIDs); foreach (UUID itemid in pstates.Keys) { states.Add(itemid, pstates[itemid]); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 04df35a..f875224 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -311,11 +311,12 @@ namespace OpenSim.Region.Framework.Scenes if (m_part.ParentGroup.m_savedScriptState != null) RestoreSavedScriptState(item.OldItemID, item.ItemID); - lock (m_items) - { - m_items[item.ItemID].PermsMask = 0; - m_items[item.ItemID].PermsGranter = UUID.Zero; - } + m_items.LockItemsForWrite(true); + + m_items[item.ItemID].PermsMask = 0; + m_items[item.ItemID].PermsGranter = UUID.Zero; + + m_items.LockItemsForWrite(false); string script = Utils.BytesToString(asset.Data); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( @@ -713,15 +714,16 @@ namespace OpenSim.Region.Framework.Scenes { IList items = new List(); - lock (m_items) + m_items.LockItemsForRead(true); + + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.Name == name) - items.Add(item); - } + if (item.Name == name) + items.Add(item); } + m_items.LockItemsForRead(false); + return items; } @@ -1115,6 +1117,11 @@ namespace OpenSim.Region.Framework.Scenes public Dictionary GetScriptStates() { + return GetScriptStates(false); + } + + public Dictionary GetScriptStates(bool oldIDs) + { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); Dictionary ret = new Dictionary(); @@ -1132,8 +1139,16 @@ namespace OpenSim.Region.Framework.Scenes string n = e.GetXMLState(item.ItemID); if (n != String.Empty) { - if (!ret.ContainsKey(item.ItemID)) - ret[item.ItemID] = n; + if (oldIDs) + { + if (!ret.ContainsKey(item.OldItemID)) + ret[item.OldItemID] = n; + } + else + { + if (!ret.ContainsKey(item.ItemID)) + ret[item.ItemID] = n; + } break; } } -- cgit v1.1 From 06661708b4b2ed33116839ced93d43ca0f0909a0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 27 Apr 2010 02:40:30 +0200 Subject: Add a parameter to prim inventory update to prevent event firing --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f875224..bc3225a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -735,6 +735,11 @@ namespace OpenSim.Region.Framework.Scenes /// false if the item did not exist, true if the update occurred successfully public bool UpdateInventoryItem(TaskInventoryItem item) { + return UpdateInventoryItem(item, true); + } + + public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) + { m_items.LockItemsForWrite(true); if (m_items.ContainsKey(item.ItemID)) @@ -765,7 +770,8 @@ namespace OpenSim.Region.Framework.Scenes m_items[item.ItemID] = item; m_inventorySerial++; - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); + if (fireScriptEvents) + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; m_items.LockItemsForWrite(false); -- cgit v1.1 From 04845c1898fee6a8b8563a8103b73cbe38525416 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 30 Apr 2010 11:46:50 +0100 Subject: Fix link security issue --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 50 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 41 ++++-------------- 3 files changed, 63 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5b21332..8716e0a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2568,5 +2568,55 @@ namespace OpenSim.Region.Framework.Scenes part.GetProperties(remoteClient); } } + + public void DelinkObjects(List primIds, IClientAPI client) + { + List parts = new List(); + + foreach (uint localID in primIds) + { + SceneObjectPart part = GetSceneObjectPart(localID); + + if (part == null) + continue; + + if (Permissions.CanDelinkObject(client.AgentId, part.ParentGroup.RootPart.UUID)) + parts.Add(part); + } + + m_sceneGraph.DelinkObjects(parts); + } + + public void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds) + { + List owners = new List(); + + List children = new List(); + SceneObjectPart root = GetSceneObjectPart(parentPrimId); + + if (Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID)) + return; + + foreach (uint localID in childPrimIds) + { + SceneObjectPart part = GetSceneObjectPart(localID); + + if (part == null) + continue; + + if (!owners.Contains(part.OwnerID)) + owners.Add(part.OwnerID); + + if (Permissions.CanLinkObject(client.AgentId, part.ParentGroup.RootPart.UUID)) + children.Add(part); + } + + // Must be all one owner + // + if (owners.Count > 1) + return; + + m_sceneGraph.LinkObjects(root, children); + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7796b8d..637ebff 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2721,8 +2721,8 @@ namespace OpenSim.Region.Framework.Scenes client.OnObjectName += m_sceneGraph.PrimName; client.OnObjectClickAction += m_sceneGraph.PrimClickAction; client.OnObjectMaterial += m_sceneGraph.PrimMaterial; - client.OnLinkObjects += m_sceneGraph.LinkObjects; - client.OnDelinkObjects += m_sceneGraph.DelinkObjects; + client.OnLinkObjects += LinkObjects; + client.OnDelinkObjects += DelinkObjects; client.OnObjectDuplicate += m_sceneGraph.DuplicateObject; client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; client.OnUpdatePrimFlags += m_sceneGraph.UpdatePrimFlags; @@ -2877,8 +2877,8 @@ namespace OpenSim.Region.Framework.Scenes client.OnObjectName -= m_sceneGraph.PrimName; client.OnObjectClickAction -= m_sceneGraph.PrimClickAction; client.OnObjectMaterial -= m_sceneGraph.PrimMaterial; - client.OnLinkObjects -= m_sceneGraph.LinkObjects; - client.OnDelinkObjects -= m_sceneGraph.DelinkObjects; + client.OnLinkObjects -= LinkObjects; + client.OnDelinkObjects -= DelinkObjects; client.OnObjectDuplicate -= m_sceneGraph.DuplicateObject; client.OnObjectDuplicateOnRay -= doObjectDuplicateOnRay; client.OnUpdatePrimFlags -= m_sceneGraph.UpdatePrimFlags; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d31b45e..ad24160 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1619,20 +1619,21 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds) + protected internal void LinkObjects(SceneObjectPart root, List children) { Monitor.Enter(m_updateLock); try { - SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId); + SceneObjectGroup parentGroup = root.ParentGroup; List childGroups = new List(); if (parentGroup != null) { // We do this in reverse to get the link order of the prims correct - for (int i = childPrimIds.Count - 1; i >= 0; i--) + for (int i = children.Count - 1; i >= 0; i--) { - SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]); + SceneObjectGroup child = children[i].ParentGroup; + if (child != null) { // Make sure no child prim is set for sale @@ -1665,17 +1666,6 @@ namespace OpenSim.Region.Framework.Scenes parentGroup.HasGroupChanged = true; parentGroup.ScheduleGroupForFullUpdate(); -// if (client != null) -// { -// parentGroup.GetProperties(client); -// } -// else -// { -// foreach (ScenePresence p in GetScenePresences()) -// { -// parentGroup.GetProperties(p.ControllingClient); -// } -// } } finally { @@ -1687,12 +1677,7 @@ namespace OpenSim.Region.Framework.Scenes /// Delink a linkset /// /// - protected internal void DelinkObjects(List primIds) - { - DelinkObjects(primIds, true); - } - - protected internal void DelinkObjects(List primIds, bool sendEvents) + protected internal void DelinkObjects(List prims) { Monitor.Enter(m_updateLock); try @@ -1702,9 +1687,8 @@ namespace OpenSim.Region.Framework.Scenes List affectedGroups = new List(); // Look them all up in one go, since that is comparatively expensive // - foreach (uint primID in primIds) + foreach (SceneObjectPart part in prims) { - SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID); if (part != null) { if (part.ParentGroup.Children.Count != 1) // Skip single @@ -1719,17 +1703,13 @@ namespace OpenSim.Region.Framework.Scenes affectedGroups.Add(group); } } - else - { - m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID); - } } foreach (SceneObjectPart child in childParts) { // Unlink all child parts from their groups // - child.ParentGroup.DelinkFromGroup(child, sendEvents); + child.ParentGroup.DelinkFromGroup(child, true); } foreach (SceneObjectPart root in rootParts) @@ -1784,12 +1764,9 @@ namespace OpenSim.Region.Framework.Scenes List linkIDs = new List(); foreach (SceneObjectPart newChild in newSet) - { newChild.UpdateFlag = 0; - linkIDs.Add(newChild.LocalId); - } - LinkObjects(null, newRoot.LocalId, linkIDs); + LinkObjects(newRoot, newSet); if (!affectedGroups.Contains(newRoot.ParentGroup)) affectedGroups.Add(newRoot.ParentGroup); } -- cgit v1.1 From 3e30de7430bff6f2eede395140e45207a15c23a5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 30 Apr 2010 22:35:07 +0200 Subject: Fix linking issue introduced in my earlier commit --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 90bce39..cfcd544 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1970,8 +1970,17 @@ namespace OpenSim.Region.Framework.Scenes List children = new List(); SceneObjectPart root = GetSceneObjectPart(parentPrimId); - if (Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID)) + if (root == null) + { + m_log.DebugFormat("[LINK]: Can't find linkset root prim {0{", parentPrimId); + return; + } + + if (!Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID)) + { + m_log.DebugFormat("[LINK]: Refusing link. No permissions on root prim"); return; + } foreach (uint localID in childPrimIds) { @@ -1990,7 +1999,16 @@ namespace OpenSim.Region.Framework.Scenes // Must be all one owner // if (owners.Count > 1) + { + m_log.DebugFormat("[LINK]: Refusing link. Too many owners"); + return; + } + + if (children.Count == 0) + { + m_log.DebugFormat("[LINK]: Refusing link. No permissions to link any of the children"); return; + } m_sceneGraph.LinkObjects(root, children); } -- cgit v1.1 From 7ae55f624883b711e5a9d4d5f040ba884fc8bd5e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 30 Apr 2010 22:35:07 +0200 Subject: Fix linking issue introduced in my earlier commit --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a430bc4..e031ebc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2603,8 +2603,17 @@ namespace OpenSim.Region.Framework.Scenes List children = new List(); SceneObjectPart root = GetSceneObjectPart(parentPrimId); - if (Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID)) + if (root == null) + { + m_log.DebugFormat("[LINK]: Can't find linkset root prim {0{", parentPrimId); + return; + } + + if (!Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID)) + { + m_log.DebugFormat("[LINK]: Refusing link. No permissions on root prim"); return; + } foreach (uint localID in childPrimIds) { @@ -2623,7 +2632,16 @@ namespace OpenSim.Region.Framework.Scenes // Must be all one owner // if (owners.Count > 1) + { + m_log.DebugFormat("[LINK]: Refusing link. Too many owners"); + return; + } + + if (children.Count == 0) + { + m_log.DebugFormat("[LINK]: Refusing link. No permissions to link any of the children"); return; + } m_sceneGraph.LinkObjects(root, children); } -- cgit v1.1 From 87664017773227d07b39382efa2aa94f22bbe6c6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 3 May 2010 04:28:30 +0200 Subject: Adapt CM to the new CHANGED_OWNER handling --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 ++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++++++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1c6f2d1..ff471e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3931,5 +3931,13 @@ namespace OpenSim.Region.Framework.Scenes return priority; } + + public void ResetOwnerChangeFlag() + { + ForEachPart(delegate(SceneObjectPart part) + { + part.ResetOwnerChangeFlag(); + }); + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4b2641c..48e65a5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4683,5 +4683,17 @@ namespace OpenSim.Region.Framework.Scenes { return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A)); } + + public void ResetOwnerChangeFlag() + { + List inv = Inventory.GetInventoryList(); + + foreach (UUID itemID in inv) + { + TaskInventoryItem item = Inventory.GetInventoryItem(itemID); + item.OwnerChanged = false; + Inventory.UpdateInventoryItem(item); + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ceb4395..562232c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4011,15 +4011,24 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); { string xmlData; XmlDocument d = new XmlDocument(); + UUID asset; if (itemData.TryGetValue(itemID, out xmlData)) { d.LoadXml(xmlData); m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); - } - // Rez from inventory - UUID asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); + // Rez from inventory + asset + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); + + } + else + { + // Rez from inventory (with a null doc to let + // CHANGED_OWNER happen) + asset + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); + } m_log.InfoFormat( "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", -- cgit v1.1 From 9c8d7d34b39c6351459989f02473b6f5200d14ee Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 3 May 2010 04:55:41 +0200 Subject: Fix a bug in owner change notification --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 64282d1..62b44bd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1180,7 +1180,9 @@ namespace OpenSim.Region.Framework.Scenes { if (engine != null) { - engine.PostScriptEvent(item.ItemID, "changed", new Object[] { Changed.OWNER }); + if (item.OwnerChanged) + engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); + item.OwnerChanged = false; engine.ResumeScript(item.ItemID); } } -- cgit v1.1 From 4df87631ede57316fe41ea6c5edcd4996deac625 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 3 May 2010 23:44:23 +0200 Subject: Store given items in correct parent folder. Fixes items given to offline avatars not getting lost. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cfcd544..9b838ab 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -414,6 +414,25 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.BasePermissions = item.BasePermissions; } + if (itemCopy.Folder == UUID.Zero) + { + InventoryFolderBase folder = InventoryService.GetFolderForType(recipient, (AssetType)itemCopy.AssetType); + + if (folder != null) + { + itemCopy.Folder = folder.ID; + } + else + { + InventoryFolderBase root = InventoryService.GetRootFolder(recipient); + + if (root != null) + itemCopy.Folder = root.ID; + else + return null; // No destination + } + } + itemCopy.GroupID = UUID.Zero; itemCopy.GroupOwned = false; itemCopy.Flags = item.Flags; -- cgit v1.1 From c86259c6710c8ce5c97a7a64bbb96dac35440aec Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 4 May 2010 00:44:05 +0200 Subject: Fix scripted give and interactive give to offline avatars. Both folder and single items are now supported. Magic Boxes, yeah! --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9b838ab..c105560 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -94,6 +94,22 @@ namespace OpenSim.Region.Framework.Scenes public void AddInventoryItem(UUID AgentID, InventoryItemBase item) { + InventoryFolderBase folder; + + if (item.Folder == UUID.Zero) + { + folder = InventoryService.GetFolderForType(AgentID, (AssetType)item.AssetType); + if (folder == null) + { + folder = InventoryService.GetRootFolder(AgentID); + + if (folder == null) + return; + } + + item.Folder = folder.ID; + } + if (InventoryService.AddItem(item)) { int userlevel = 0; -- cgit v1.1 From 4f93d30790c8392c6f91cb1818d1c16f89169ab7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 4 May 2010 18:10:13 +0200 Subject: Allow reloading of estate settings into a running region. Move sun update helper into Scene, since that is less evil than exposing m_storageManager to the public. --- OpenSim/Region/Framework/Scenes/Scene.cs | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3e78a08..f17e464 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5109,5 +5109,51 @@ namespace OpenSim.Region.Framework.Scenes { return new Vector3(x, y, GetGroundHeight(x, y)); } + + public List GetEstateRegions(int estateID) + { + if (m_storageManager.EstateDataStore == null) + return new List(); + + return m_storageManager.EstateDataStore.GetRegions(estateID); + } + + public void ReloadEstateData() + { + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); + + TriggerEstateSunUpdate(); + } + + public void TriggerEstateSunUpdate() + { + float sun; + if (RegionInfo.RegionSettings.UseEstateSun) + { + sun = (float)RegionInfo.EstateSettings.SunPosition; + if (RegionInfo.EstateSettings.UseGlobalTime) + { + sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f; + } + + // + EventManager.TriggerEstateToolsSunUpdate( + RegionInfo.RegionHandle, + RegionInfo.EstateSettings.FixedSun, + RegionInfo.RegionSettings.UseEstateSun, + sun); + } + else + { + // Use the Sun Position from the Region Settings + sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f; + + EventManager.TriggerEstateToolsSunUpdate( + RegionInfo.RegionHandle, + RegionInfo.RegionSettings.FixedSun, + RegionInfo.RegionSettings.UseEstateSun, + sun); + } + } } } -- cgit v1.1 From ce86d39c70882a4beb04a23565121b05a4325a46 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 4 May 2010 18:31:52 +0200 Subject: Add "reload estate" command to sims --- OpenSim/Region/Framework/Scenes/Scene.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f17e464..0ca5948 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -662,6 +662,10 @@ namespace OpenSim.Region.Framework.Scenes } } + MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", + "reload estate", + "Reload the estate data", HandleReloadEstate); + //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); @@ -5155,5 +5159,15 @@ namespace OpenSim.Region.Framework.Scenes sun); } } + + private void HandleReloadEstate(string module, string[] cmd) + { + if (MainConsole.Instance.ConsoleScene == null || + (MainConsole.Instance.ConsoleScene is Scene && + (Scene)MainConsole.Instance.ConsoleScene == this)) + { + ReloadEstateData(); + } + } } } -- cgit v1.1 From 733a07e061cdcb6095677758a264ba976bb94b93 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 6 May 2010 00:34:49 +0200 Subject: Plumb the viewer version string through into AgentCircuitData. Now all that is left os to figure out what black magic turns AgentCircuitData into AgentData and then copy that into the ScenePresence, where m_Viewer is already added with this commit and waits for the data. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 562232c..987180b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -227,6 +227,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_lastColCount = -1; //KF: Look for Collision chnages private int m_updateCount = 0; //KF: Update Anims for a while private static readonly int UPDATE_COUNT = 10; // how many frames to update for + private string m_Viewer = String.Empty; private const int NumMovementsBetweenRayCast = 5; @@ -664,6 +665,11 @@ namespace OpenSim.Region.Framework.Scenes set { m_flyDisabled = value; } } + public string Viewer + { + get { return m_Viewer; } + } + #endregion #region Constructor(s) -- cgit v1.1 From 2d9a20529d6818093747eb764d86efa11f3874d5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 6 May 2010 00:54:21 +0200 Subject: Plumb Viewer version into ScenePresence for initial login. It's still not carried along --- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0ca5948..bebd463 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2680,6 +2680,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = CreateAndAddScenePresence(client); if (aCircuit != null) sp.Appearance = aCircuit.Appearance; + sp.Viewer = aCircuit.Viewer; // HERE!!! Do the initial attachments right here // first agent upon login is a root agent by design. diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 987180b..f649dfe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -668,6 +668,7 @@ namespace OpenSim.Region.Framework.Scenes public string Viewer { get { return m_Viewer; } + set { m_Viewer = value; } } #endregion -- cgit v1.1 From 02dea4ce580a08a9a4119ed063ed36704bb44825 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 6 May 2010 02:02:12 +0200 Subject: Remove the m_Viewer variable and make the property a shortcut to the proper field in AgentCircuitData instead --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 897fda6..0ca5948 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2679,10 +2679,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = CreateAndAddScenePresence(client); if (aCircuit != null) - { sp.Appearance = aCircuit.Appearance; - sp.Viewer = aCircuit.Viewer; - } // HERE!!! Do the initial attachments right here // first agent upon login is a root agent by design. diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f649dfe..cb24784 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -227,8 +227,6 @@ namespace OpenSim.Region.Framework.Scenes private int m_lastColCount = -1; //KF: Look for Collision chnages private int m_updateCount = 0; //KF: Update Anims for a while private static readonly int UPDATE_COUNT = 10; // how many frames to update for - private string m_Viewer = String.Empty; - private const int NumMovementsBetweenRayCast = 5; private bool CameraConstraintActive; @@ -667,8 +665,7 @@ namespace OpenSim.Region.Framework.Scenes public string Viewer { - get { return m_Viewer; } - set { m_Viewer = value; } + get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } } #endregion -- cgit v1.1 From add7abc1de2fce8db4c6d01cc4b5305bafa4bd87 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Fri, 7 May 2010 14:12:07 -0400 Subject: Fix Mouse+WASD makes Av rise; Fix PREJUMP. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 13 +++--------- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 ++++++++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index be0e985..b43caf2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -56,7 +56,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist! protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init. private int m_animTickFall; - private int m_animTickJump; +// private int m_animTickJump; + public int m_animTickJump; // ScenePresence has to see this to control +Z force /// /// The scene presence that this animator applies to @@ -123,22 +124,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void TrySetMovementAnimation(string anim) { -//Console.WriteLine("Updating movement animation to {0}", anim); - if (!m_scenePresence.IsChildAgent) { if (m_animations.TrySetDefaultAnimation( anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) { -//Console.WriteLine("TSMA {0} success.", anim); // 16384 is CHANGED_ANIMATION m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); SendAnimPack(); } - else - { -//Console.WriteLine("TSMA {0} fail.", anim); - } } } @@ -267,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animTickJump = Environment.TickCount; return "PREJUMP"; } - else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) + else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 800.0f) { // Start actual jump if (m_animTickJump == -1) @@ -317,7 +311,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void UpdateMovementAnimations() { m_movementAnimation = GetMovementAnimation(); -//Console.WriteLine("UMA got {0}", m_movementAnimation); if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) { // This was the previous behavior before PREJUMP diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index db073e8..665fb4c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -613,7 +613,7 @@ namespace OpenSim.Region.Framework.Scenes m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", false); - + m_usePreJump = true; // Above line fails!? m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2603fe1..565438d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -665,7 +665,7 @@ namespace OpenSim.Region.Framework.Scenes CreateSceneViewer(); m_animator = new ScenePresenceAnimator(this); } - + private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() { m_rootRegionHandle = reginfo.RegionHandle; @@ -1459,7 +1459,6 @@ namespace OpenSim.Region.Framework.Scenes } i++; } - //Paupaw:Do Proper PID for Autopilot here if (bResetMoveToPosition) { @@ -2433,10 +2432,11 @@ namespace OpenSim.Region.Framework.Scenes Rotation = rotation; Vector3 direc = vec * rotation; direc.Normalize(); + PhysicsActor actor = m_physicsActor; + if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. direc *= 0.03f * 128f * m_speedModifier; - PhysicsActor actor = m_physicsActor; if (actor != null) { if (actor.Flying) @@ -2458,11 +2458,18 @@ namespace OpenSim.Region.Framework.Scenes { if (direc.Z > 2.0f) { - direc.Z *= 3.0f; - - // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. - Animator.TrySetMovementAnimation("PREJUMP"); - Animator.TrySetMovementAnimation("JUMP"); + if(m_animator.m_animTickJump == -1) + { + direc.Z *= 3.0f; // jump + } + else + { + direc.Z *= 0.1f; // prejump + } + /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs + Animator.TrySetMovementAnimation("PREJUMP"); + Animator.TrySetMovementAnimation("JUMP"); + */ } } } -- cgit v1.1 From 3cda854ef312a71f3ceab6cb8339a0d2d2fce803 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 10 May 2010 08:47:41 -0700 Subject: Fix overlooked readLock which was left open --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ff471e0..35134d6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -123,7 +123,7 @@ namespace OpenSim.Region.Framework.Scenes } if (m_partsLock.RecursiveWriteCount > 0) { - m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed."); + m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested (write lock exists on this thread). This should not happen and means something needs to be fixed."); m_partsLock.ExitWriteLock(); } @@ -1667,6 +1667,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); } } + lockPartsForRead(false); } #region Copying -- cgit v1.1 From 14a86de115934e981e5c3e413821861434ccf5e8 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 10 May 2010 12:45:33 -0700 Subject: Fix another ReaderWriterLockSlim issue --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 62b44bd..c4cff12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -840,12 +840,12 @@ namespace OpenSim.Region.Framework.Scenes } else { + m_items.LockItemsForRead(false); m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", itemID, m_part.Name, m_part.UUID); } - m_items.LockItemsForWrite(false); return -1; } -- cgit v1.1 From 7705012ee7b016f8e163c5e9586fef724b233932 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Wed, 12 May 2010 08:25:40 -0700 Subject: Optimise the heavily used GetScenePresences; eliminate the array->list conversion on every call and transition from hard locks to ReaderWriter locks. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 56 +++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f43de20..c16ba12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -70,6 +70,9 @@ namespace OpenSim.Region.Framework.Scenes protected Dictionary m_scenePresences = new Dictionary(); protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0]; + protected List m_scenePresenceList = new List(); + + protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); // SceneObjects is not currently populated or used. //public Dictionary SceneObjects; @@ -132,10 +135,16 @@ namespace OpenSim.Region.Framework.Scenes protected internal void Close() { - lock (m_scenePresences) + m_scenePresencesLock.EnterWriteLock(); + try { m_scenePresences.Clear(); m_scenePresenceArray = new ScenePresence[0]; + m_scenePresenceList = new List(); + } + finally + { + m_scenePresencesLock.ExitWriteLock(); } lock (m_dictionary_lock) @@ -542,7 +551,8 @@ namespace OpenSim.Region.Framework.Scenes Entities[presence.UUID] = presence; - lock (m_scenePresences) + m_scenePresencesLock.EnterWriteLock(); + try { if (!m_scenePresences.ContainsKey(presence.UUID)) { @@ -554,11 +564,12 @@ namespace OpenSim.Region.Framework.Scenes Array.Copy(m_scenePresenceArray, newArray, oldLength); newArray[oldLength] = presence; m_scenePresenceArray = newArray; + m_scenePresenceList = new List(m_scenePresenceArray); } else { m_scenePresences[presence.UUID] = presence; - + // Do a linear search through the array of ScenePresence references // and update the modified entry for (int i = 0; i < m_scenePresenceArray.Length; i++) @@ -569,8 +580,13 @@ namespace OpenSim.Region.Framework.Scenes break; } } + m_scenePresenceList = new List(m_scenePresenceArray); } } + finally + { + m_scenePresencesLock.ExitWriteLock(); + } } /// @@ -585,7 +601,8 @@ namespace OpenSim.Region.Framework.Scenes agentID); } - lock (m_scenePresences) + m_scenePresencesLock.EnterWriteLock(); + try { if (m_scenePresences.Remove(agentID)) { @@ -604,12 +621,17 @@ namespace OpenSim.Region.Framework.Scenes } } m_scenePresenceArray = newArray; + m_scenePresenceList = new List(m_scenePresenceArray); } else { m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); } } + finally + { + m_scenePresencesLock.ExitWriteLock(); + } } protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) @@ -730,8 +752,15 @@ namespace OpenSim.Region.Framework.Scenes /// private List GetScenePresences() { - lock (m_scenePresences) - return new List(m_scenePresenceArray); + m_scenePresencesLock.EnterReadLock(); + try + { + return m_scenePresenceList; + } + finally + { + m_scenePresencesLock.ExitReadLock(); + } } /// @@ -742,10 +771,15 @@ namespace OpenSim.Region.Framework.Scenes protected internal ScenePresence GetScenePresence(UUID agentID) { ScenePresence sp; - lock (m_scenePresences) + m_scenePresencesLock.EnterReadLock(); + try { m_scenePresences.TryGetValue(agentID, out sp); } + finally + { + m_scenePresencesLock.ExitReadLock(); + } return sp; } @@ -780,10 +814,15 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) { - lock (m_scenePresences) + m_scenePresencesLock.EnterReadLock(); + try { m_scenePresences.TryGetValue(agentID, out avatar); } + finally + { + m_scenePresencesLock.ExitReadLock(); + } return (avatar != null); } @@ -1061,6 +1100,7 @@ namespace OpenSim.Region.Framework.Scenes Parallel.ForEach(GetScenePresences(), protectedAction); */ // For now, perform actiona serially + foreach (ScenePresence sp in GetScenePresences()) { try -- cgit v1.1 From fd37a21b59836143f50fdf994c691d65bd641d52 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Wed, 12 May 2010 08:34:47 -0700 Subject: Kill some locks that have crept into SOG --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 35134d6..a4b8944 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3651,7 +3651,8 @@ namespace OpenSim.Region.Framework.Scenes if (atRotTargets.Count > 0) { uint[] localids = new uint[0]; - lock (m_parts) + lockPartsForRead(true); + try { localids = new uint[m_parts.Count]; int cntr = 0; @@ -3661,6 +3662,10 @@ namespace OpenSim.Region.Framework.Scenes cntr++; } } + finally + { + lockPartsForRead(false); + } for (int ctr = 0; ctr < localids.Length; ctr++) { @@ -3679,7 +3684,8 @@ namespace OpenSim.Region.Framework.Scenes { //trigger not_at_target uint[] localids = new uint[0]; - lock (m_parts) + lockPartsForRead(true); + try { localids = new uint[m_parts.Count]; int cntr = 0; @@ -3689,6 +3695,10 @@ namespace OpenSim.Region.Framework.Scenes cntr++; } } + finally + { + lockPartsForRead(false); + } for (int ctr = 0; ctr < localids.Length; ctr++) { -- cgit v1.1 From 8f838c722da978da646fcef59a5af767840832bb Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 17 May 2010 14:14:19 -0700 Subject: When killing a zombie session, don't send the stop packet since it often has the effect of killing a newly connected client. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3d59615..1b08c50 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3489,7 +3489,7 @@ namespace OpenSim.Region.Framework.Scenes { // We have a zombie from a crashed session. Kill it. m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); - sp.ControllingClient.Close(); + sp.ControllingClient.Close(false); } } -- cgit v1.1 From 91b1d17e5bd3ff6ed006744bc529b53a67af1a64 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Tue, 18 May 2010 01:09:47 -0700 Subject: Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 102 ++++++++++++----------- 1 file changed, 53 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d76f029..0b644b9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; + private Vector3 m_lastPosition; private Vector3 m_lastWorldPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -715,8 +715,11 @@ namespace OpenSim.Region.Framework.Scenes // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) SendInitialFullUpdateToAllClients(); - RegisterToEvents(); + if (m_controllingClient != null) + { + m_controllingClient.ProcessPendingPackets(); + } SetDirectionVectors(); } @@ -858,7 +861,6 @@ namespace OpenSim.Region.Framework.Scenes m_grouptitle = gm.GetGroupTitle(m_uuid); m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; - m_scene.SetRootAgentScene(m_uuid); // Moved this from SendInitialData to ensure that m_appearance is initialized @@ -875,22 +877,22 @@ namespace OpenSim.Region.Framework.Scenes { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); pos.Y = crossedBorder.BorderLine.Z - 1; - } - - //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. - //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, - //they'll bypass the landing point. But I can't think of any decent way of fixing this. - if (KnownChildRegionHandles.Count == 0) - { - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) - { - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) - { - pos = land.LandData.UserLocation; - } - } + } + + //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. + //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, + //they'll bypass the landing point. But I can't think of any decent way of fixing this. + if (KnownChildRegionHandles.Count == 0) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + { + pos = land.LandData.UserLocation; + } + } } if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) @@ -1027,8 +1029,8 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = false; if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - + isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); Velocity = Vector3.Zero; AbsolutePosition = pos; @@ -1039,7 +1041,7 @@ namespace OpenSim.Region.Framework.Scenes SetHeight(m_appearance.AvatarHeight); } - SendTerseUpdateToAllClients(); + SendTerseUpdateToAllClients(); } @@ -1173,7 +1175,6 @@ namespace OpenSim.Region.Framework.Scenes pos.Z = ground + 1.5f; AbsolutePosition = pos; } - m_isChildAgent = false; bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); MakeRootAgent(AbsolutePosition, m_flying); @@ -1745,14 +1746,14 @@ namespace OpenSim.Region.Framework.Scenes // else // { // single or child prim -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); } Quaternion partIRot = Quaternion.Inverse(partRot); @@ -1760,22 +1761,22 @@ namespace OpenSim.Region.Framework.Scenes Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av - - if (m_physicsActor == null) - { - AddToPhysicalScene(false); + + if (m_physicsActor == null) + { + AddToPhysicalScene(false); + } + //CW: If the part isn't null then we can set the current position + if (part != null) + { + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. + part.IsOccupied = false; } - //CW: If the part isn't null then we can set the current position - if (part != null) - { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - part.IsOccupied = false; - } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; } m_parentPosition = Vector3.Zero; @@ -1930,7 +1931,7 @@ namespace OpenSim.Region.Framework.Scenes // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) { - autopilot = false; // close enough + autopilot = false; // close enough m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. Not using the part's position because returning the AV to the last known standing position is likely to be more friendly, isn't it? */ @@ -1939,7 +1940,7 @@ namespace OpenSim.Region.Framework.Scenes } // else the autopilot will get us close } else - { // its a scripted sit + { // its a scripted sit m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. I *am* using the part's position this time because we have no real idea how far away the avatar is from the sit target. */ @@ -3744,7 +3745,10 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); m_scene = scene; RegisterToEvents(); - + if (m_controllingClient != null) + { + m_controllingClient.ProcessPendingPackets(); + } /* AbsolutePosition = client.StartPos; -- cgit v1.1 From 1c040d8c1ed5ee1ba1e80aa1d248a9b06d1790a5 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Tue, 18 May 2010 03:24:43 -0700 Subject: Fix to the scenario where we send an agent to a neighbouring sim (via teleport), then tell our neighbours to close the agents.. thereby disconnecting the user. Added a new CloseChildAgent method in lieu of CloseAgent. This has been a long standing problem - with any luck this will cure it. --- OpenSim/Region/Framework/Scenes/Scene.cs | 23 +++++++++++++++++----- .../Framework/Scenes/SceneCommunicationService.cs | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1b08c50..f331984 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3914,12 +3914,22 @@ namespace OpenSim.Region.Framework.Scenes return false; } + public bool IncomingCloseAgent(UUID agentID) + { + return IncomingCloseAgent(agentID, false); + } + + public bool IncomingCloseChildAgent(UUID agentID) + { + return IncomingCloseAgent(agentID, true); + } + /// /// Tell a single agent to disconnect from the region. /// - /// /// - public bool IncomingCloseAgent(UUID agentID) + /// + public bool IncomingCloseAgent(UUID agentID, bool childOnly) { //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); @@ -3931,7 +3941,7 @@ namespace OpenSim.Region.Framework.Scenes { m_sceneGraph.removeUserCount(false); } - else + else if (!childOnly) { m_sceneGraph.removeUserCount(true); } @@ -3947,9 +3957,12 @@ namespace OpenSim.Region.Framework.Scenes } else presence.ControllingClient.SendShutdownConnectionNotice(); + presence.ControllingClient.Close(); + } + else if (!childOnly) + { + presence.ControllingClient.Close(); } - - presence.ControllingClient.Close(); return true; } diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 9d0e6f4..6309cd9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.Framework.Scenes uint x = 0, y = 0; Utils.LongToUInts(regionHandle, out x, out y); GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - m_scene.SimulationService.CloseAgent(destination, agentID); + m_scene.SimulationService.CloseChildAgent(destination, agentID); } private void SendCloseChildAgentCompleted(IAsyncResult iar) -- cgit v1.1 From bb0806c61e545b6509843ed0258475e47d4bb273 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Tue, 18 May 2010 03:44:09 -0700 Subject: Don't send kill packets to child agents as we close them --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f331984..377abe3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3957,11 +3957,11 @@ namespace OpenSim.Region.Framework.Scenes } else presence.ControllingClient.SendShutdownConnectionNotice(); - presence.ControllingClient.Close(); + presence.ControllingClient.Close(false); } else if (!childOnly) { - presence.ControllingClient.Close(); + presence.ControllingClient.Close(true); } return true; } -- cgit v1.1 From f77f9ecd8f3f94ccc6d69c7625fd1eacfa9250d7 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Wed, 19 May 2010 13:44:59 -0700 Subject: Fix a nullref issue in SitAltitudeCallback --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 103 ++++++++++++----------- 1 file changed, 53 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 565438d..68acabe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -128,7 +128,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; + private Vector3 m_lastPosition; private Vector3 m_lastWorldPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -857,22 +857,22 @@ namespace OpenSim.Region.Framework.Scenes { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); pos.Y = crossedBorder.BorderLine.Z - 1; - } - - //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. - //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, - //they'll bypass the landing point. But I can't think of any decent way of fixing this. - if (KnownChildRegionHandles.Count == 0) - { - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) - { - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) - { - pos = land.LandData.UserLocation; - } - } + } + + //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. + //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, + //they'll bypass the landing point. But I can't think of any decent way of fixing this. + if (KnownChildRegionHandles.Count == 0) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + { + pos = land.LandData.UserLocation; + } + } } if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) @@ -1036,8 +1036,8 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = false; if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - + isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); Velocity = Vector3.Zero; AbsolutePosition = pos; @@ -1048,7 +1048,7 @@ namespace OpenSim.Region.Framework.Scenes SetHeight(m_appearance.AvatarHeight); } - SendTerseUpdateToAllClients(); + SendTerseUpdateToAllClients(); } @@ -1736,14 +1736,14 @@ namespace OpenSim.Region.Framework.Scenes // else // { // single or child prim -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); } Quaternion partIRot = Quaternion.Inverse(partRot); @@ -1751,22 +1751,22 @@ namespace OpenSim.Region.Framework.Scenes Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av - - if (m_physicsActor == null) - { - AddToPhysicalScene(false); + + if (m_physicsActor == null) + { + AddToPhysicalScene(false); } - //CW: If the part isn't null then we can set the current position - if (part != null) - { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - part.IsOccupied = false; - } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; + //CW: If the part isn't null then we can set the current position + if (part != null) + { + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. + part.IsOccupied = false; + } + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; } m_parentPosition = Vector3.Zero; @@ -1920,7 +1920,7 @@ namespace OpenSim.Region.Framework.Scenes // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) { - autopilot = false; // close enough + autopilot = false; // close enough m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. Not using the part's position because returning the AV to the last known standing position is likely to be more friendly, isn't it? */ @@ -1929,7 +1929,7 @@ namespace OpenSim.Region.Framework.Scenes } // else the autopilot will get us close } else - { // its a scripted sit + { // its a scripted sit m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. I *am* using the part's position this time because we have no real idea how far away the avatar is from the sit target. */ @@ -2357,11 +2357,14 @@ namespace OpenSim.Region.Framework.Scenes // { // single or child prim partIRot = Quaternion.Inverse(part.GetWorldRotation()); // } - float offZ = collisionPoint.Z - m_initialSitTarget.Z; - Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction -//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); - m_pos += offset; -// ControllingClient.SendClearFollowCamProperties(part.UUID); + if (m_initialSitTarget != null) + { + float offZ = collisionPoint.Z - m_initialSitTarget.Z; + Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction + //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); + m_pos += offset; + // ControllingClient.SendClearFollowCamProperties(part.UUID); + } } } // End SitAltitudeCallback KF. -- cgit v1.1 From 6933b48a7e94511f1de969b28a61d834888fd2f5 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Wed, 19 May 2010 13:49:34 -0700 Subject: Fix a nullref issue in SitAltitudeCallback --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0b644b9..b6081de 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2368,12 +2368,15 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); // else // { // single or child prim partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - float offZ = collisionPoint.Z - m_initialSitTarget.Z; - Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction -//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); - m_pos += offset; -// ControllingClient.SendClearFollowCamProperties(part.UUID); +// } + if (m_initialSitTarget != null) + { + float offZ = collisionPoint.Z - m_initialSitTarget.Z; + Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction + //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); + m_pos += offset; + // ControllingClient.SendClearFollowCamProperties(part.UUID); + } } } // End SitAltitudeCallback KF. -- cgit v1.1 From 5532341bf9e477a007e81bdbcc6477923703e2a2 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Wed, 19 May 2010 14:04:44 -0700 Subject: Initialise m_initialSitTarget to ZERO_VACTOR for safety's sake as per convo with kitto --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b6081de..c89f656 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -213,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_autopilotMoving; private Vector3 m_autoPilotTarget; private bool m_sitAtAutoTarget; - private Vector3 m_initialSitTarget; //KF: First estimate of where to sit + private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit private string m_nextSitAnimation = String.Empty; -- cgit v1.1 From 147c2d6f80c6b911839e890cb42cb63020269afc Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 21 May 2010 02:31:14 +0100 Subject: Change the way the object perms are propagated to attempt to salvage some older content --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 44 +++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e031ebc..ba70ae5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -437,29 +437,31 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.InvType = item.InvType; itemCopy.Folder = recipientFolderId; - if (Permissions.PropagatePermissions()) + if (Permissions.PropagatePermissions() && recipient != senderId) { + // First, make sore base is limited to the next perms + itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions; + // By default, current equals base + itemCopy.CurrentPermissions = itemCopy.BasePermissions; + + // If this is an object, replace current perms + // with folded perms if (item.InvType == (int)InventoryType.Object) { - itemCopy.BasePermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - itemCopy.BasePermissions |= (item.CurrentPermissions & 7) << 13; - } - else - { - itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions; + itemCopy.CurrentPermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + itemCopy.CurrentPermissions |= (item.CurrentPermissions & 7) << 13; } - itemCopy.CurrentPermissions = itemCopy.BasePermissions; - if ((item.CurrentPermissions & 8) != 0) // Propagate slam bit - { - itemCopy.BasePermissions &= item.NextPermissions; - itemCopy.CurrentPermissions = itemCopy.BasePermissions; - itemCopy.CurrentPermissions |= 8; - } + // Ensure there is no escalation + itemCopy.CurrentPermissions &= item.NextPermissions; + + // Need slam bit on xfer + itemCopy.CurrentPermissions |= 8; itemCopy.NextPermissions = item.NextPermissions; - itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; - itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; + + itemCopy.EveryOnePermissions = 0; + itemCopy.GroupPermissions = 0; } else { @@ -913,12 +915,12 @@ namespace OpenSim.Region.Framework.Scenes if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions()) { + agentItem.BasePermissions = taskItem.BasePermissions & taskItem.NextPermissions; if (taskItem.InvType == (int)InventoryType.Object) - agentItem.BasePermissions = taskItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13); - else - agentItem.BasePermissions = taskItem.BasePermissions; - agentItem.BasePermissions &= taskItem.NextPermissions; - agentItem.CurrentPermissions = agentItem.BasePermissions | 8; + agentItem.CurrentPermissions = agentItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13); + agentItem.CurrentPermissions = agentItem.BasePermissions ; + + agentItem.CurrentPermissions |= 8; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions; agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; -- cgit v1.1 From d28da5e5ce4e36c7a0b052fb5d2f04105d95176b Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 21 May 2010 03:41:32 +0100 Subject: Refactor scene presence list for lockless iteration. Lock contention will now only be for simultaneous add/removes of scene presences from the scene. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 131 ++++++++++---------------- 1 file changed, 49 insertions(+), 82 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index c16ba12..3c2203c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -68,11 +68,9 @@ namespace OpenSim.Region.Framework.Scenes #region Fields - protected Dictionary m_scenePresences = new Dictionary(); - protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0]; - protected List m_scenePresenceList = new List(); - protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); + protected Dictionary m_scenePresenceMap = new Dictionary(); + protected List m_scenePresenceArray = new List(); // SceneObjects is not currently populated or used. //public Dictionary SceneObjects; @@ -138,9 +136,10 @@ namespace OpenSim.Region.Framework.Scenes m_scenePresencesLock.EnterWriteLock(); try { - m_scenePresences.Clear(); - m_scenePresenceArray = new ScenePresence[0]; - m_scenePresenceList = new List(); + Dictionary newmap = new Dictionary(); + List newlist = new List(); + m_scenePresenceMap = newmap; + m_scenePresenceArray = newlist; } finally { @@ -554,34 +553,27 @@ namespace OpenSim.Region.Framework.Scenes m_scenePresencesLock.EnterWriteLock(); try { - if (!m_scenePresences.ContainsKey(presence.UUID)) + Dictionary newmap = new Dictionary(m_scenePresenceMap); + List newlist = new List(m_scenePresenceArray); + + if (!newmap.ContainsKey(presence.UUID)) { - m_scenePresences.Add(presence.UUID, presence); - - // Create a new array of ScenePresence references - int oldLength = m_scenePresenceArray.Length; - ScenePresence[] newArray = new ScenePresence[oldLength + 1]; - Array.Copy(m_scenePresenceArray, newArray, oldLength); - newArray[oldLength] = presence; - m_scenePresenceArray = newArray; - m_scenePresenceList = new List(m_scenePresenceArray); + newmap.Add(presence.UUID, presence); + newlist.Add(presence); } else { - m_scenePresences[presence.UUID] = presence; - - // Do a linear search through the array of ScenePresence references - // and update the modified entry - for (int i = 0; i < m_scenePresenceArray.Length; i++) - { - if (m_scenePresenceArray[i].UUID == presence.UUID) - { - m_scenePresenceArray[i] = presence; - break; - } - } - m_scenePresenceList = new List(m_scenePresenceArray); + // Remember the old presene reference from the dictionary + ScenePresence oldref = newmap[presence.UUID]; + // Replace the presence reference in the dictionary with the new value + newmap[presence.UUID] = presence; + // Find the index in the list where the old ref was stored and update the reference + newlist[newlist.IndexOf(oldref)] = presence; } + + // Swap out the dictionary and list with new references + m_scenePresenceMap = newmap; + m_scenePresenceArray = newlist; } finally { @@ -604,24 +596,19 @@ namespace OpenSim.Region.Framework.Scenes m_scenePresencesLock.EnterWriteLock(); try { - if (m_scenePresences.Remove(agentID)) + Dictionary newmap = new Dictionary(m_scenePresenceMap); + List newlist = new List(m_scenePresenceArray); + + // Remember the old presene reference from the dictionary + ScenePresence oldref = newmap[agentID]; + // Remove the presence reference from the dictionary + if (newmap.Remove(agentID)) { - // Copy all of the elements from the previous array - // into the new array except the removed element - int oldLength = m_scenePresenceArray.Length; - ScenePresence[] newArray = new ScenePresence[oldLength - 1]; - int j = 0; - for (int i = 0; i < m_scenePresenceArray.Length; i++) - { - ScenePresence presence = m_scenePresenceArray[i]; - if (presence.UUID != agentID) - { - newArray[j] = presence; - ++j; - } - } - m_scenePresenceArray = newArray; - m_scenePresenceList = new List(m_scenePresenceArray); + // Find the index in the list where the old ref was stored and remove the reference + newlist.RemoveAt(newlist.IndexOf(oldref)); + // Swap out the dictionary and list with new references + m_scenePresenceMap = newmap; + m_scenePresenceArray = newlist; } else { @@ -744,7 +731,7 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Request a copy of m_scenePresences in this World + /// Get a reference to the scene presence list. Changes to the list will be done in a copy /// There is no guarantee that presences will remain in the scene after the list is returned. /// This list should remain private to SceneGraph. Callers wishing to iterate should instead /// pass a delegate to ForEachScenePresence. @@ -752,15 +739,7 @@ namespace OpenSim.Region.Framework.Scenes /// private List GetScenePresences() { - m_scenePresencesLock.EnterReadLock(); - try - { - return m_scenePresenceList; - } - finally - { - m_scenePresencesLock.ExitReadLock(); - } + return m_scenePresenceArray; } /// @@ -770,17 +749,10 @@ namespace OpenSim.Region.Framework.Scenes /// null if the presence was not found protected internal ScenePresence GetScenePresence(UUID agentID) { - ScenePresence sp; - m_scenePresencesLock.EnterReadLock(); - try - { - m_scenePresences.TryGetValue(agentID, out sp); - } - finally - { - m_scenePresencesLock.ExitReadLock(); - } - return sp; + Dictionary presences = m_scenePresenceMap; + ScenePresence presence; + presences.TryGetValue(agentID, out presence); + return presence; } /// @@ -791,7 +763,8 @@ namespace OpenSim.Region.Framework.Scenes /// null if the presence was not found protected internal ScenePresence GetScenePresence(string firstName, string lastName) { - foreach (ScenePresence presence in GetScenePresences()) + List presences = GetScenePresences(); + foreach (ScenePresence presence in presences) { if (presence.Firstname == firstName && presence.Lastname == lastName) return presence; @@ -806,7 +779,8 @@ namespace OpenSim.Region.Framework.Scenes /// null if the presence was not found protected internal ScenePresence GetScenePresence(uint localID) { - foreach (ScenePresence presence in GetScenePresences()) + List presences = GetScenePresences(); + foreach (ScenePresence presence in presences) if (presence.LocalId == localID) return presence; return null; @@ -814,15 +788,8 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) { - m_scenePresencesLock.EnterReadLock(); - try - { - m_scenePresences.TryGetValue(agentID, out avatar); - } - finally - { - m_scenePresencesLock.ExitReadLock(); - } + Dictionary presences = m_scenePresenceMap; + presences.TryGetValue(agentID, out avatar); return (avatar != null); } @@ -1099,9 +1066,9 @@ namespace OpenSim.Region.Framework.Scenes }); Parallel.ForEach(GetScenePresences(), protectedAction); */ - // For now, perform actiona serially - - foreach (ScenePresence sp in GetScenePresences()) + // For now, perform actions serially + List presences = GetScenePresences(); + foreach (ScenePresence sp in presences) { try { -- cgit v1.1 From 72b96e81213c0dd3d586f552bd2cbd9221c5341d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 May 2010 06:12:11 +0100 Subject: Add the SitGround flag back in --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 49a7766..d7660fd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,6 +140,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3? m_forceToApply; private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID; + public bool SitGround = false; private SendCourseLocationsMethod m_sendCourseLocationsMethod; @@ -1643,7 +1644,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (update_movementflag) + if (update_movementflag && !SitGround) Animator.UpdateMovementAnimations(); m_scene.EventManager.TriggerOnClientMovement(this); @@ -1754,6 +1755,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void StandUp() { + SitGround = false; + if (m_parentID != 0) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); -- cgit v1.1 From ba49319c077bc5e7b998674aaac62497e757706c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 27 May 2010 20:08:48 +0200 Subject: Prevent a null ref --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 4ba4fab..2fc98e5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -84,6 +84,9 @@ namespace OpenSim.Region.Framework.Scenes while (m_pendingObjects != null && m_pendingObjects.Count > 0) { SceneObjectGroup g = m_pendingObjects.Dequeue(); + // Yes, this can really happen + if (g == null) + continue; // This is where we should check for draw distance // do culling and stuff. Problem with that is that until -- cgit v1.1 From e3dac1292ef000daadda3e264354d8df0fc77c22 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 29 May 2010 02:10:34 -0700 Subject: Implement suspended updates - When an operation is occurring on lots of prims in a single group, don't schedule any updates until the operation has completed. This makes things like llSetAlpha(LINK_SET,0.0,ALL_SIDES); a *lot* faster, more efficient and less buggy, and also makes unlinking a lot better. Linking is still treacherous.. this needs to be analysed. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 47 +++++++++++++++++----- .../Region/Framework/Scenes/SceneObjectGroup.cs | 17 ++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 +++- 3 files changed, 59 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d4658ec..445c2c8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1499,10 +1499,13 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void LinkObjects(SceneObjectPart root, List children) { + SceneObjectGroup parentGroup = root.ParentGroup; + if (parentGroup == null) return; Monitor.Enter(m_updateLock); + try { - SceneObjectGroup parentGroup = root.ParentGroup; + parentGroup.areUpdatesSuspended = true; List childGroups = new List(); if (parentGroup != null) @@ -1541,12 +1544,12 @@ namespace OpenSim.Region.Framework.Scenes // occur on link to invoke this elsewhere (such as object selection) parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); parentGroup.TriggerScriptChangedEvent(Changed.LINK); - parentGroup.HasGroupChanged = true; - parentGroup.ScheduleGroupForFullUpdate(); - } finally { + parentGroup.areUpdatesSuspended = false; + parentGroup.HasGroupChanged = true; + parentGroup.ScheduleGroupForFullUpdate(); Monitor.Exit(m_updateLock); } } @@ -1583,11 +1586,22 @@ namespace OpenSim.Region.Framework.Scenes } } - foreach (SceneObjectPart child in childParts) + if (childParts.Count > 0) { - // Unlink all child parts from their groups - // - child.ParentGroup.DelinkFromGroup(child, true); + try + { + childParts[0].ParentGroup.areUpdatesSuspended = true; + foreach (SceneObjectPart child in childParts) + { + // Unlink all child parts from their groups + // + child.ParentGroup.DelinkFromGroup(child, true); + } + } + finally + { + childParts[0].ParentGroup.areUpdatesSuspended = false; + } } foreach (SceneObjectPart root in rootParts) @@ -1611,10 +1625,21 @@ namespace OpenSim.Region.Framework.Scenes if (numChildren > 1) sendEventsToRemainder = false; - foreach (SceneObjectPart p in newSet) + if (newSet.Count > 0) { - if (p != group.RootPart) - group.DelinkFromGroup(p, sendEventsToRemainder); + try + { + newSet[0].ParentGroup.areUpdatesSuspended = true; + foreach (SceneObjectPart p in newSet) + { + if (p != group.RootPart) + group.DelinkFromGroup(p, sendEventsToRemainder); + } + } + finally + { + newSet[0].ParentGroup.areUpdatesSuspended = false; + } } // If there is more than one prim remaining, we diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cee2be3..9ebb168 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -109,9 +109,26 @@ namespace OpenSim.Region.Framework.Scenes private long m_maxPersistTime = 0; private long m_minPersistTime = 0; private Random m_rand; + private bool m_suspendUpdates; private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); + public bool areUpdatesSuspended + { + get + { + return m_suspendUpdates; + } + set + { + m_suspendUpdates = value; + if (!value) + { + QueueForUpdateCheck(); + } + } + } + public void lockPartsForRead(bool locked) { if (locked) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c84596b..6e73b65 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2724,7 +2724,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentGroup != null) { - m_parentGroup.QueueForUpdateCheck(); + if (!m_parentGroup.areUpdatesSuspended) + { + m_parentGroup.QueueForUpdateCheck(); + } } int timeNow = Util.UnixTimeSinceEpoch(); @@ -4450,8 +4453,9 @@ namespace OpenSim.Region.Framework.Scenes { m_shape.TextureEntry = textureEntry; TriggerScriptChangedEvent(Changed.TEXTURE); - + m_updateFlag = 1; ParentGroup.HasGroupChanged = true; + //This is madness.. //ParentGroup.ScheduleGroupForFullUpdate(); //This is sparta -- cgit v1.1 From d4b4cbf5a5fead727b5e2e48f69d2016eb942cff Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 31 May 2010 19:00:02 +0200 Subject: Fix create selection getting overwritten by multiple updates for the same prim. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 445c2c8..5fbc658 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1542,7 +1542,7 @@ namespace OpenSim.Region.Framework.Scenes // We need to explicitly resend the newly link prim's object properties since no other actions // occur on link to invoke this elsewhere (such as object selection) - parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); + parentGroup.RootPart.CreateSelected = true; parentGroup.TriggerScriptChangedEvent(Changed.LINK); } finally diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9ebb168..509ec01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2486,7 +2486,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.LinkNum = 2; linkPart.SetParent(this); - linkPart.AddFlag(PrimFlags.CreateSelected); + linkPart.CreateSelected = true; //if (linkPart.PhysActor != null) //{ diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6e73b65..2f4191d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -388,7 +388,6 @@ namespace OpenSim.Region.Framework.Scenes // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log _flags = 0; - _flags |= PrimFlags.CreateSelected; TrimPermissions(); //m_undo = new UndoStack(ParentGroup.GetSceneMaxUndo()); @@ -418,6 +417,7 @@ namespace OpenSim.Region.Framework.Scenes private PrimFlags _flags = 0; private DateTime m_expires; private DateTime m_rezzed; + private bool m_createSelected = true; public UUID CreatorID { @@ -978,6 +978,13 @@ namespace OpenSim.Region.Framework.Scenes set { m_updateFlag = value; } } + [XmlIgnore] + public bool CreateSelected + { + get { return m_createSelected; } + set { m_createSelected = value; } + } + #endregion //--------------- -- cgit v1.1 From 70f779041334e7cf3642c334e9800362afde7895 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 01:07:46 +0200 Subject: Split GetAxisAlignedBoundingBox into two methods to allow calculation of combined bounding boxes and offsets --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 509ec01..4203ba9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -794,9 +794,15 @@ namespace OpenSim.Region.Framework.Scenes /// offsetHeight is the offset in the Z axis from the centre of the bounding box to the centre of the root prim /// /// - public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) + public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) { - float maxX = -256f, maxY = -256f, maxZ = -256f, minX = 256f, minY = 256f, minZ = 256f; + maxX = -256f; + maxY = -256f; + maxZ = -256f; + minX = 256f; + minY = 256f; + minZ = 256f; + lockPartsForRead(true); { foreach (SceneObjectPart part in m_parts.Values) @@ -1034,7 +1040,18 @@ namespace OpenSim.Region.Framework.Scenes } } lockPartsForRead(false); + } + + public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) + { + float minX; + float maxX; + float minY; + float maxY; + float minZ; + float maxZ; + GetAxisAlignedBoundingBoxRaw(out minX, out maxX, out minY, out maxY, out minZ, out maxZ); Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ); offsetHeight = 0; -- cgit v1.1 From f57f2370f1737e997e8871d5b05a426e9ac19ba7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 01:25:24 +0200 Subject: Add a method to get the bounding box and root prim offsets within it for a group of prims. --- OpenSim/Region/Framework/Scenes/Scene.cs | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 933999e..22248af 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5236,5 +5236,49 @@ namespace OpenSim.Region.Framework.Scenes ReloadEstateData(); } } + + public Vector3[] GetCombinedBoundingBox(List objects, out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) + { + minX = 256; + maxX = -256; + minY = 256; + maxY = -256; + minZ = 8192; + maxZ = -256; + + List offsets = new List(); + + foreach (SceneObjectGroup g in objects) + { + float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; + + g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); + + if (minX > ominX) + minX = ominX; + if (minY > ominY) + minY = ominY; + if (minZ > ominZ) + minZ = ominZ; + if (maxX < omaxX) + maxX = omaxX; + if (maxY < omaxY) + maxY = omaxY; + if (maxZ < omaxZ) + maxZ = omaxZ; + } + + foreach (SceneObjectGroup g in objects) + { + Vector3 vec = g.AbsolutePosition; + vec.X -= minX; + vec.Y -= minY; + vec.Z -= minZ; + + offsets.Add(vec); + } + + return offsets.ToArray(); + } } } -- cgit v1.1 From bf233ea0dc564dbae3896d8b5ac355fb2f247a00 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 02:27:30 +0200 Subject: Continuing refactor. Refactor DeRezObject to deal with multiple objects --- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 18 ++- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 138 ++++++++++++--------- 2 files changed, 88 insertions(+), 68 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index c08b961..241cac0 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes { public DeRezAction action; public IClientAPI remoteClient; - public SceneObjectGroup objectGroup; + public List objectGroups; public UUID folderID; public bool permissionToDelete; } @@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes /// Delete the given object from the scene /// public void DeleteToInventory(DeRezAction action, UUID folderID, - SceneObjectGroup objectGroup, IClientAPI remoteClient, + List objectGroups, IClientAPI remoteClient, bool permissionToDelete) { if (Enabled) @@ -87,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes DeleteToInventoryHolder dtis = new DeleteToInventoryHolder(); dtis.action = action; dtis.folderID = folderID; - dtis.objectGroup = objectGroup; + dtis.objectGroups = objectGroups; dtis.remoteClient = remoteClient; dtis.permissionToDelete = permissionToDelete; @@ -103,7 +103,10 @@ namespace OpenSim.Region.Framework.Scenes // This is not ideal since the object will still be available for manipulation when it should be, but it's // better than losing the object for now. if (permissionToDelete) - objectGroup.DeleteGroup(false); + { + foreach (SceneObjectGroup g in objectGroups) + g.DeleteGroup(false); + } } private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) @@ -140,9 +143,12 @@ namespace OpenSim.Region.Framework.Scenes { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) - invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); + invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient); if (x.permissionToDelete) - m_scene.DeleteSceneObject(x.objectGroup, false); + { + foreach (SceneObjectGroup g in x.objectGroups) + m_scene.DeleteSceneObject(g, false); + } } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cbe3456..e1128a6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1550,79 +1550,98 @@ namespace OpenSim.Region.Framework.Scenes public virtual void DeRezObject(IClientAPI remoteClient, uint localID, UUID groupID, DeRezAction action, UUID destinationID) { - SceneObjectPart part = GetSceneObjectPart(localID); - if (part == null) - return; + DeRezObjects(remoteClient, new List() { localID} , groupID, action, destinationID); + } - if (part.ParentGroup == null || part.ParentGroup.IsDeleted) - return; + public virtual void DeRezObjects(IClientAPI remoteClient, List localIDs, + UUID groupID, DeRezAction action, UUID destinationID) + { + // First, see of we can perform the requested action and + // build a list of eligible objects + List deleteIDs = new List(); + List deleteGroups = new List(); - // Can't delete child prims - if (part != part.ParentGroup.RootPart) - return; + // Start with true for both, then remove the flags if objects + // that we can't derez are part of the selection + bool permissionToTake = true; + bool permissionToTakeCopy = true; + bool permissionToDelete = true; - SceneObjectGroup grp = part.ParentGroup; + foreach (uint localID in localIDs) + { + // Invalid id + SceneObjectPart part = GetSceneObjectPart(localID); + if (part == null) + continue; - //force a database backup/update on this SceneObjectGroup - //So that we know the database is upto date, for when deleting the object from it - ForceSceneObjectBackup(grp); + // Already deleted by someone else + if (part.ParentGroup == null || part.ParentGroup.IsDeleted) + continue; - bool permissionToTake = false; - bool permissionToDelete = false; + // Can't delete child prims + if (part != part.ParentGroup.RootPart) + continue; - if (action == DeRezAction.SaveToExistingUserInventoryItem) - { - if (grp.OwnerID == remoteClient.AgentId && grp.RootPart.FromUserInventoryItemID != UUID.Zero) - { - permissionToTake = true; + SceneObjectGroup grp = part.ParentGroup; + + deleteIDs.Add(localID); + deleteGroups.Add(grp); + + // Force a database backup/update on this SceneObjectGroup + // So that we know the database is upto date, + // for when deleting the object from it + ForceSceneObjectBackup(grp); + + if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) + permissionToTakeCopy = false; + if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) + permissionToTake = false; + + if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) permissionToDelete = false; - } + } - else if (action == DeRezAction.TakeCopy) + + // Handle god perms + if (Permissions.IsGod(remoteClient.AgentId)) { - permissionToTake = - Permissions.CanTakeCopyObject( - grp.UUID, - remoteClient.AgentId); + permissionToTake = true; + permissionToTakeCopy = true; + permissionToDelete = true; } - else if (action == DeRezAction.GodTakeCopy) - { - permissionToTake = - Permissions.IsGod( - remoteClient.AgentId); - } - else if (action == DeRezAction.Take) - { - permissionToTake = - Permissions.CanTakeObject( - grp.UUID, - remoteClient.AgentId); - //If they can take, they can delete! - permissionToDelete = permissionToTake; - } - else if (action == DeRezAction.Delete) + // If we're re-saving, we don't even want to delete + if (action == DeRezAction.SaveToExistingUserInventoryItem) + permissionToDelete = false; + + // if we want to take a copy,, we also don't want to delete + // Note: after this point, the permissionToTakeCopy flag + // becomes irrelevant. It already includes the permissionToTake + // permission and after excluding no copy items here, we can + // just use that. + if (action == DeRezAction.TakeCopy) { - permissionToTake = - Permissions.CanDeleteObject( - grp.UUID, - remoteClient.AgentId); - permissionToDelete = permissionToTake; + // If we don't have permission, stop right here + if (!permissionToTakeCopy) + return; + + // Don't delete + permissionToDelete = false; } - else if (action == DeRezAction.Return) + + if (action == DeRezAction.Return) { if (remoteClient != null) { - permissionToTake = - Permissions.CanReturnObjects( + if (Permissions.CanReturnObjects( null, remoteClient.AgentId, - new List() {grp}); - permissionToDelete = permissionToTake; - - if (permissionToDelete) + deleteGroups)) + foreach (SceneObjectGroup g in deleteGroups) { - AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); + AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); + DeleteSceneObject(g, false); + return; } } else // Auto return passes through here with null agent @@ -1631,22 +1650,17 @@ namespace OpenSim.Region.Framework.Scenes permissionToDelete = true; } } - else - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Ignoring unexpected derez action {0} for {1}", action, remoteClient.Name); - return; - } if (permissionToTake) { m_asyncSceneObjectDeleter.DeleteToInventory( - action, destinationID, grp, remoteClient, + action, destinationID, deleteGroups, remoteClient, permissionToDelete); } else if (permissionToDelete) { - DeleteSceneObject(grp, false); + foreach (SceneObjectGroup g in deleteGroups) + DeleteSceneObject(g, false); } } -- cgit v1.1 From eca15cfbf25134ddc8bb752abbe3a6ba01bf07a9 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 02:45:14 +0200 Subject: Change the handling of CreateSelected. Only send it on real creation, not for each prim coming into view. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2f4191d..e4a36ef 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -388,6 +388,7 @@ namespace OpenSim.Region.Framework.Scenes // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log _flags = 0; + CreateSelected = true; TrimPermissions(); //m_undo = new UndoStack(ParentGroup.GetSceneMaxUndo()); @@ -417,7 +418,7 @@ namespace OpenSim.Region.Framework.Scenes private PrimFlags _flags = 0; private DateTime m_expires; private DateTime m_rezzed; - private bool m_createSelected = true; + private bool m_createSelected = false; public UUID CreatorID { -- cgit v1.1 From 16d8602d3cad613a830a4903bb0d2beb1fa6b7e2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 03:04:49 +0200 Subject: Fix prim returns I broke earlier --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 11 +++++++---- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e1128a6..e111867 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1637,11 +1637,14 @@ namespace OpenSim.Region.Framework.Scenes null, remoteClient.AgentId, deleteGroups)) - foreach (SceneObjectGroup g in deleteGroups) { - AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); - DeleteSceneObject(g, false); - return; + permissionToTake = true; + permissionToDelete = true; + + foreach (SceneObjectGroup g in deleteGroups) + { + AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); + } } } else // Auto return passes through here with null agent diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4203ba9..7e73f91 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -801,7 +801,7 @@ namespace OpenSim.Region.Framework.Scenes maxZ = -256f; minX = 256f; minY = 256f; - minZ = 256f; + minZ = 8192f; lockPartsForRead(true); { -- cgit v1.1 From c900134f911b7f11c4fa25c67d55c112b1f56033 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 16:03:53 +0200 Subject: Lock the object queue when dequeueing --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 159 +++++++++++++------------ 1 file changed, 81 insertions(+), 78 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 2fc98e5..5cbd8d9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -67,105 +67,108 @@ namespace OpenSim.Region.Framework.Scenes public void SendPrimUpdates() { - if (m_pendingObjects == null) + lock(m_pendingObjects) { - if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) + if (m_pendingObjects == null) { - m_pendingObjects = new Queue(); - - foreach (EntityBase e in m_presence.Scene.Entities) + if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) { - if (e != null && e is SceneObjectGroup) - m_pendingObjects.Enqueue((SceneObjectGroup)e); + m_pendingObjects = new Queue(); + + foreach (EntityBase e in m_presence.Scene.Entities) + { + if (e != null && e is SceneObjectGroup) + m_pendingObjects.Enqueue((SceneObjectGroup)e); + } } } - } - - while (m_pendingObjects != null && m_pendingObjects.Count > 0) - { - SceneObjectGroup g = m_pendingObjects.Dequeue(); - // Yes, this can really happen - if (g == null) - continue; - - // This is where we should check for draw distance - // do culling and stuff. Problem with that is that until - // we recheck in movement, that won't work right. - // So it's not implemented now. - // - - // Don't even queue if we have sent this one - // - if (!m_updateTimes.ContainsKey(g.UUID)) - g.ScheduleFullUpdateToAvatar(m_presence); - } - while (m_partsUpdateQueue.Count > 0) - { - SceneObjectPart part = m_partsUpdateQueue.Dequeue(); - - if (part.ParentGroup == null || part.ParentGroup.IsDeleted) - continue; - - if (m_updateTimes.ContainsKey(part.UUID)) + while (m_pendingObjects != null && m_pendingObjects.Count > 0) { - ScenePartUpdate update = m_updateTimes[part.UUID]; + SceneObjectGroup g = m_pendingObjects.Dequeue(); + // Yes, this can really happen + if (g == null) + continue; - // We deal with the possibility that two updates occur at - // the same unix time at the update point itself. + // This is where we should check for draw distance + // do culling and stuff. Problem with that is that until + // we recheck in movement, that won't work right. + // So it's not implemented now. + // + + // Don't even queue if we have sent this one + // + if (!m_updateTimes.ContainsKey(g.UUID)) + g.ScheduleFullUpdateToAvatar(m_presence); + } - if ((update.LastFullUpdateTime < part.TimeStampFull) || - part.IsAttachment) + while (m_partsUpdateQueue.Count > 0) + { + SceneObjectPart part = m_partsUpdateQueue.Dequeue(); + + if (part.ParentGroup == null || part.ParentGroup.IsDeleted) + continue; + + if (m_updateTimes.ContainsKey(part.UUID)) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", -// part.Name, part.UUID, part.TimeStampFull); + ScenePartUpdate update = m_updateTimes[part.UUID]; - part.SendFullUpdate(m_presence.ControllingClient, - m_presence.GenerateClientFlags(part.UUID)); + // We deal with the possibility that two updates occur at + // the same unix time at the update point itself. - // We'll update to the part's timestamp rather than - // the current time to avoid the race condition - // whereby the next tick occurs while we are doing - // this update. If this happened, then subsequent - // updates which occurred on the same tick or the - // next tick of the last update would be ignored. + if ((update.LastFullUpdateTime < part.TimeStampFull) || + part.IsAttachment) + { + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", + // part.Name, part.UUID, part.TimeStampFull); - update.LastFullUpdateTime = part.TimeStampFull; + part.SendFullUpdate(m_presence.ControllingClient, + m_presence.GenerateClientFlags(part.UUID)); - } - else if (update.LastTerseUpdateTime <= part.TimeStampTerse) - { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", -// part.Name, part.UUID, part.TimeStampTerse); + // We'll update to the part's timestamp rather than + // the current time to avoid the race condition + // whereby the next tick occurs while we are doing + // this update. If this happened, then subsequent + // updates which occurred on the same tick or the + // next tick of the last update would be ignored. - part.SendTerseUpdateToClient(m_presence.ControllingClient); + update.LastFullUpdateTime = part.TimeStampFull; - update.LastTerseUpdateTime = part.TimeStampTerse; - } - } - else - { - //never been sent to client before so do full update - ScenePartUpdate update = new ScenePartUpdate(); - update.FullID = part.UUID; - update.LastFullUpdateTime = part.TimeStampFull; - m_updateTimes.Add(part.UUID, update); + } + else if (update.LastTerseUpdateTime <= part.TimeStampTerse) + { + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", + // part.Name, part.UUID, part.TimeStampTerse); - // Attachment handling - // - if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0) + part.SendTerseUpdateToClient(m_presence.ControllingClient); + + update.LastTerseUpdateTime = part.TimeStampTerse; + } + } + else { - if (part != part.ParentGroup.RootPart) + //never been sent to client before so do full update + ScenePartUpdate update = new ScenePartUpdate(); + update.FullID = part.UUID; + update.LastFullUpdateTime = part.TimeStampFull; + m_updateTimes.Add(part.UUID, update); + + // Attachment handling + // + if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0) + { + if (part != part.ParentGroup.RootPart) + continue; + + part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient); continue; + } - part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient); - continue; + part.SendFullUpdate(m_presence.ControllingClient, + m_presence.GenerateClientFlags(part.UUID)); } - - part.SendFullUpdate(m_presence.ControllingClient, - m_presence.GenerateClientFlags(part.UUID)); } } } -- cgit v1.1 From 6668c789d34bf9b068df5821973fdb75cf129b75 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 19:01:21 +0200 Subject: One should not lock null objects. --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 5cbd8d9..f478a4a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -67,14 +67,14 @@ namespace OpenSim.Region.Framework.Scenes public void SendPrimUpdates() { - lock(m_pendingObjects) + if (m_pendingObjects == null) { - if (m_pendingObjects == null) + if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) { - if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) - { - m_pendingObjects = new Queue(); + m_pendingObjects = new Queue(); + lock(m_pendingObjects) + { foreach (EntityBase e in m_presence.Scene.Entities) { if (e != null && e is SceneObjectGroup) @@ -82,7 +82,10 @@ namespace OpenSim.Region.Framework.Scenes } } } + } + lock(m_pendingObjects) + { while (m_pendingObjects != null && m_pendingObjects.Count > 0) { SceneObjectGroup g = m_pendingObjects.Dequeue(); -- cgit v1.1 From fad5158ab4ab01a179eac80c92df301157fb8319 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 7 Jun 2010 00:09:22 +0200 Subject: Add a call to SOG.ResumeScripts() after region crossing / teleport --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 22248af..19329a8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2495,6 +2495,8 @@ namespace OpenSim.Region.Framework.Scenes newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); + newObject.ResumeScripts(); + // Do this as late as possible so that listeners have full access to the incoming object EventManager.TriggerOnIncomingSceneObject(newObject); -- cgit v1.1 From 30d3ea3d4be1bed3001e2bda5890cce183c4f388 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jun 2010 17:00:24 +0100 Subject: Give attachments the same priority as other avatars in BestAvatarResponsiveness policy --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 4780cdd..7b7677b 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -210,7 +210,10 @@ namespace OpenSim.Region.Framework.Scenes { PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; if (physActor == null || !physActor.IsPhysical) - priority+=100; + priority += 100; + + if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + priority = 1.0; } return priority; } -- cgit v1.1 From 57a60282f5746a3aa73c0cac34059fbdbd319c0c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 12 Jun 2010 06:57:10 +0100 Subject: Don't filre CHANGED_INVENTORY if a prim comes in from storage --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index c4cff12..c3cdca8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -681,7 +681,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (TaskInventoryItem item in items) { m_items.Add(item.ItemID, item); - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); +// m_part.TriggerScriptChangedEvent(Changed.INVENTORY); } m_items.LockItemsForWrite(false); -- cgit v1.1 From 03a48f87e418e79ca780b29a696e5e878213e7ef Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 12 Jun 2010 08:29:20 +0200 Subject: Preserving the link numbers is a serializer's highest duty. Prevent region crossings from screwing up complex attachments by preserving link numbers. --- .../Framework/Scenes/Serialization/SceneObjectSerializer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index f7544ac..5bdaa17 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -221,7 +221,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization sr = new StringReader(parts[i].OuterXml); reader = new XmlTextReader(sr); SceneObjectPart part = SceneObjectPart.FromXml(reader); + + int originalLinkNum = part.LinkNum; + sceneObject.AddPart(part); + + // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. + // We override that here + if (originalLinkNum != 0) + part.LinkNum = originalLinkNum; + part.StoreUndoState(); reader.Close(); sr.Close(); -- cgit v1.1 From 3ea11fe2e6593fe0455a7c5bf842deca307f373e Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 12 Jun 2010 04:35:51 -0700 Subject: Get rid of spamming SOG debug message --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 66ad14f..c7d21bb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2230,8 +2230,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForFullUpdate() { - if (IsAttachment) - m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); + //if (IsAttachment) + // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); checkAtTargets(); RootPart.ScheduleFullUpdate(); -- cgit v1.1 From f59e272643a92b20e7f7eb97f54a30c8b045725d Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 13 Jun 2010 22:21:05 +0200 Subject: Introduce SOP.UpdateSitters() to update sitting avatars' chat position if needed --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 +++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++++++ 2 files changed, 17 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c7d21bb..6f68029 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2174,6 +2174,7 @@ namespace OpenSim.Region.Framework.Scenes { m_rootPart.UpdateFlag = 1; lastPhysGroupPos = AbsolutePosition; + UpdateSitters(); } if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) @@ -3832,6 +3833,14 @@ namespace OpenSim.Region.Framework.Scenes } } + private void UpdateSitters() + { + foreach (SceneObjectPart part in Children.Values) + { + part.UpdateSitter(); + } + } + public override string ToString() { return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e4a36ef..705e0a3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4720,5 +4720,13 @@ namespace OpenSim.Region.Framework.Scenes Inventory.UpdateInventoryItem(item); } } + + public void UpdateSitter() + { + if (m_sitTargetAvatar != UUID.Zero) + return; + + // Update sitting avatar chat position + } } } -- cgit v1.1 From 3d319d6c3ff2bded0f4b6c730f227a490dd2fb2e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 13 Jun 2010 22:23:07 +0200 Subject: Actually update the SP. EXPERIMENTAL --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 705e0a3..a83119e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4726,7 +4726,13 @@ namespace OpenSim.Region.Framework.Scenes if (m_sitTargetAvatar != UUID.Zero) return; + ScenePresence p = m_parentGroup.Scene.GetScenePresence(m_sitTargetAvatar); + if (p == null) + return; + // Update sitting avatar chat position + + p.AbsolutePosition = AbsolutePosition; } } } -- cgit v1.1 From 520b0e131c43e97d4a08c8ed93a32228ab61a99e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 13 Jun 2010 22:37:11 +0200 Subject: Try to make prims stop moving. Reset velocity, etc, unconditionally. Although the phys actor may be new, the prim fields could still be set and the slimupdates system would continue sending that data out. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a83119e..be2bbc5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1738,7 +1738,7 @@ namespace OpenSim.Region.Framework.Scenes // which stops client-side interpolation of deactivated joint proxy objects. } - if (!UsePhysics && !isNew) + if (!UsePhysics) { // reset velocity to 0 on physics switch-off. Without that, the client thinks the // prim still has velocity and continues to interpolate its position along the old -- cgit v1.1 From 305876180690e5c236d6bda60a6173a16ad5edc8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 13 Jun 2010 22:43:14 +0200 Subject: D.U.H. un-reverse a reversed condition --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index be2bbc5..c3e87b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4723,7 +4723,7 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateSitter() { - if (m_sitTargetAvatar != UUID.Zero) + if (m_sitTargetAvatar == UUID.Zero) return; ScenePresence p = m_parentGroup.Scene.GetScenePresence(m_sitTargetAvatar); -- cgit v1.1 From d520360cb83bb3f7733228ff74cf083b0855b261 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 13 Jun 2010 23:01:15 +0200 Subject: Try it witht he root prim --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c3e87b7..68681c9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4732,7 +4732,7 @@ namespace OpenSim.Region.Framework.Scenes // Update sitting avatar chat position - p.AbsolutePosition = AbsolutePosition; + p.AbsolutePosition = GroupPosition; } } } -- cgit v1.1 From 62763cc0fb80caae199ea03d2cb8d031924c111e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jun 2010 00:02:17 +0200 Subject: Report current position instead of position at the time we sat down --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 68681c9..91b7d35 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4732,7 +4732,7 @@ namespace OpenSim.Region.Framework.Scenes // Update sitting avatar chat position - p.AbsolutePosition = GroupPosition; + p.AbsolutePosition = GroupPosition + OffsetPosition + m_sitTargetPosition; } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b6f67f7..7a7816a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -466,6 +466,13 @@ namespace OpenSim.Region.Framework.Scenes if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! m_pos = actor.Position; + // If we're sitting, we need to update our position + if (m_parentID == 0) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); + m_parentPosition = part.AbsolutePosition; + } + return m_parentPosition + m_pos; } set -- cgit v1.1 From 093cc047cd42f4cc3d59f365aa70cc196855e83f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jun 2010 00:03:43 +0200 Subject: Revert "Try it witht he root prim" This reverts commit d520360cb83bb3f7733228ff74cf083b0855b261. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 91b7d35..c3e87b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4732,7 +4732,7 @@ namespace OpenSim.Region.Framework.Scenes // Update sitting avatar chat position - p.AbsolutePosition = GroupPosition + OffsetPosition + m_sitTargetPosition; + p.AbsolutePosition = AbsolutePosition; } } } -- cgit v1.1 From 5fda89fdb5ca6569239412b7b2d38163b8b3b5ab Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jun 2010 00:04:02 +0200 Subject: Revert "D.U.H." This reverts commit 305876180690e5c236d6bda60a6173a16ad5edc8. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c3e87b7..be2bbc5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4723,7 +4723,7 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateSitter() { - if (m_sitTargetAvatar == UUID.Zero) + if (m_sitTargetAvatar != UUID.Zero) return; ScenePresence p = m_parentGroup.Scene.GetScenePresence(m_sitTargetAvatar); -- cgit v1.1 From f9b4f5f594caf609d255c585c4224f0455403908 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jun 2010 00:05:01 +0200 Subject: Revert "Introduce SOP.UpdateSitters() to update sitting avatars' chat position if" This reverts commit f59e272643a92b20e7f7eb97f54a30c8b045725d. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 --------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 -------------- 2 files changed, 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6f68029..c7d21bb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2174,7 +2174,6 @@ namespace OpenSim.Region.Framework.Scenes { m_rootPart.UpdateFlag = 1; lastPhysGroupPos = AbsolutePosition; - UpdateSitters(); } if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) @@ -3833,14 +3832,6 @@ namespace OpenSim.Region.Framework.Scenes } } - private void UpdateSitters() - { - foreach (SceneObjectPart part in Children.Values) - { - part.UpdateSitter(); - } - } - public override string ToString() { return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index be2bbc5..b80a557 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4720,19 +4720,5 @@ namespace OpenSim.Region.Framework.Scenes Inventory.UpdateInventoryItem(item); } } - - public void UpdateSitter() - { - if (m_sitTargetAvatar != UUID.Zero) - return; - - ScenePresence p = m_parentGroup.Scene.GetScenePresence(m_sitTargetAvatar); - if (p == null) - return; - - // Update sitting avatar chat position - - p.AbsolutePosition = AbsolutePosition; - } } } -- cgit v1.1 From 1532dbca0ae54ee6427153d7beec95b8cb52e1e3 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jun 2010 00:12:39 +0200 Subject: Guard against a potential nullref --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a7816a..9c507c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -470,7 +470,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentID == 0) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); - m_parentPosition = part.AbsolutePosition; + if (part != null) + m_parentPosition = part.AbsolutePosition; } return m_parentPosition + m_pos; -- cgit v1.1 From 9b30f446729e16c165551ecf0756dedb85d8b269 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jun 2010 02:28:31 +0200 Subject: D.U.H. #2. Inverted test. Again. Argh! --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9c507c2..6d2cd88 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -467,7 +467,7 @@ namespace OpenSim.Region.Framework.Scenes m_pos = actor.Position; // If we're sitting, we need to update our position - if (m_parentID == 0) + if (m_parentID != 0) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) -- cgit v1.1 From 958c6c6fde45e41433452f44bf8e2e925153a24d Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 17 Jun 2010 13:04:18 -0400 Subject: Add rez on water surface. --- OpenSim/Region/Framework/Scenes/Scene.cs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b58bfb8..a88b87f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1967,14 +1967,24 @@ namespace OpenSim.Region.Framework.Scenes /// public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) { + + float wheight = (float)RegionInfo.RegionSettings.WaterHeight; + Vector3 wpos = Vector3.Zero; + // Check for water surface intersection from above + if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) + { + float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); + wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); + wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); + wpos.Z = wheight; + } + Vector3 pos = Vector3.Zero; if (RayEndIsIntersection == (byte)1) { pos = RayEnd; - return pos; } - - if (RayTargetID != UUID.Zero) + else if (RayTargetID != UUID.Zero) { SceneObjectPart target = GetSceneObjectPart(RayTargetID); @@ -1996,7 +2006,7 @@ namespace OpenSim.Region.Framework.Scenes EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); // Un-comment out the following line to Get Raytrace results printed to the console. - // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); + // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); float ScaleOffset = 0.5f; // If we hit something @@ -2019,13 +2029,10 @@ namespace OpenSim.Region.Framework.Scenes //pos.Z -= 0.25F; } - - return pos; } else { // We don't have a target here, so we're going to raytrace all the objects in the scene. - EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); // Un-comment the following line to print the raytrace results to the console. @@ -2034,13 +2041,12 @@ namespace OpenSim.Region.Framework.Scenes if (ei.HitTF) { pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); - } else + } + else { // fall back to our stupid functionality pos = RayEnd; } - - return pos; } } else @@ -2051,8 +2057,12 @@ namespace OpenSim.Region.Framework.Scenes //increase height so its above the ground. //should be getting the normal of the ground at the rez point and using that? pos.Z += scale.Z / 2f; - return pos; +// return pos; } + + // check against posible water intercept + if (wpos.Z > pos.Z) pos = wpos; + return pos; } -- cgit v1.1 From 6d8da699b275cf9a52214de3b22256533b7bb784 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 19 Jun 2010 07:00:01 -0700 Subject: Add "AvatarHeight/2" to the Home Position when set to avoid having the avatar fall through the ground when they TP home. --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 97de147..dc58d84 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3235,6 +3235,16 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) { + //Add half the avatar's height so that the user doesn't fall through prims + ScenePresence presence; + if (TryGetScenePresence(remoteClient.AgentId, out presence)) + { + if (presence.Appearance != null) + { + position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); + } + } + if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); -- cgit v1.1 From 49d7d8534ccd037f4690c5ac6aecd66a460960df Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 19 Jun 2010 10:06:09 -0700 Subject: Allow moving an avatar as part of a linkset using llSetLinkPrimitiveParams. This unlocks an awful lot of poseball-free content, and is a step towards resolving mantis #59. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 56 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 39 ++++++++++++++- 2 files changed, 91 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c7d21bb..3e92954 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -110,8 +110,8 @@ namespace OpenSim.Region.Framework.Scenes private long m_minPersistTime = 0; private Random m_rand; private bool m_suspendUpdates; - - private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); + private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); + private List m_linkedAvatars = new List(); public bool areUpdatesSuspended { @@ -1116,6 +1116,47 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Add the avatar to this linkset (avatar is sat). + /// + /// + public void AddAvatar(UUID agentID) + { + ScenePresence presence; + if (m_scene.TryGetScenePresence(agentID, out presence)) + { + if (!m_linkedAvatars.Contains(presence)) + { + m_linkedAvatars.Add(presence); + } + } + } + + /// + /// Delete the avatar from this linkset (avatar is unsat). + /// + /// + public void DeleteAvatar(UUID agentID) + { + ScenePresence presence; + if (m_scene.TryGetScenePresence(agentID, out presence)) + { + if (m_linkedAvatars.Contains(presence)) + { + m_linkedAvatars.Remove(presence); + } + } + } + + /// + /// Returns the list of linked presences (avatars sat on this group) + /// + /// + public List GetLinkedAvatars() + { + return m_linkedAvatars; + } + + /// /// Attach this scene object to the given avatar. /// /// @@ -2974,6 +3015,17 @@ namespace OpenSim.Region.Framework.Scenes } } + + + /// + /// Gets the number of parts + /// + /// + public int GetPartCount() + { + return Children.Count; + } + /// /// Get the parts of this scene object /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d4fc6cd..76267ab 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -219,6 +219,7 @@ namespace OpenSim.Region.Framework.Scenes //PauPaw:Proper PID Controler for autopilot************ private bool m_moveToPositionInProgress; private Vector3 m_moveToPositionTarget; + private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); private bool m_followCamAuto; @@ -537,10 +538,39 @@ namespace OpenSim.Region.Framework.Scenes } } + public Quaternion OffsetRotation + { + get { return m_offsetRotation; } + set { m_offsetRotation = value; } + } + public Quaternion Rotation { - get { return m_bodyRot; } - set { m_bodyRot = value; } + get { + if (m_parentID != 0) + { + if (m_offsetRotation != null) + { + return m_offsetRotation; + } + else + { + return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + + } + else + { + return m_bodyRot; + } + } + set { + m_bodyRot = value; + if (m_parentID != 0) + { + m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + } } public Quaternion PreviousRotation @@ -1795,6 +1825,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! AbsolutePosition = avWorldStandUp; //KF: Fix stand up. part.IsOccupied = false; + part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); } else { @@ -1804,6 +1835,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentPosition = Vector3.Zero; m_parentID = 0; + m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); SendFullUpdateToAllClients(); m_requestedSitTargetID = 0; @@ -1904,6 +1936,7 @@ namespace OpenSim.Region.Framework.Scenes part.SetAvatarOnSitTarget(UUID); // set that Av will be on it offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one sitOrientation = avSitOrientation; // Change rotatione to the scripted one + OffsetRotation = avSitOrientation; autopilot = false; // Jump direct to scripted llSitPos() } else @@ -2311,6 +2344,7 @@ namespace OpenSim.Region.Framework.Scenes m_bodyRot = sitTargetOrient; m_parentPosition = part.AbsolutePosition; part.IsOccupied = true; + part.ParentGroup.AddAvatar(agentID); Console.WriteLine("Scripted Sit ofset {0}", m_pos); } else @@ -2341,6 +2375,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); m_parentPosition = part.AbsolutePosition; part.IsOccupied = true; + part.ParentGroup.AddAvatar(agentID); m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + -- cgit v1.1 From 13a0b65a804349e41b8e692727068ac6580c0d35 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 20 Jun 2010 21:38:06 +0200 Subject: Modify avatar responsiveness policy to send roots before children --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 7b7677b..b95b5f2 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -208,12 +208,19 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { - PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; - if (physActor == null || !physActor.IsPhysical) - priority += 100; - if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + { priority = 1.0; + } + else + { + PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; + if (physActor == null || !physActor.IsPhysical) + priority += 100; + } + + if (((SceneObjectPart)entity).ParentGroup.RootPart != (SceneObjectPart)entity) + priority +=1; } return priority; } -- cgit v1.1 From a1416612a9f9e0d5cbe1c1f02d313e9be020226d Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 20 Jun 2010 14:45:04 -0700 Subject: Update all clients sitting on a linkset if a child prim is moved. This prevents avatars being "lost in the void" until they stand up when a child prim is moved that they're sitting on. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b80a557..78faa01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -711,6 +711,12 @@ namespace OpenSim.Region.Framework.Scenes // Tell the physics engines that this prim changed. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } + + List avs = ParentGroup.GetLinkedAvatars(); + foreach (ScenePresence av in avs) + { + av.SendFullUpdateToAllClients(); + } } } } -- cgit v1.1 From fc715a092c9b48ddfbf75eb35e1a052885aecbff Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 20 Jun 2010 15:38:48 -0700 Subject: Fix the sit code to ensure that we use the root prim of a linkset as a reference in the case of an avatar sitting on a child prim. This fixes various camera issues and fixes mantis #0000059. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 76267ab..472c389 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1766,7 +1766,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); if (part != null) { part.TaskInventory.LockItemsForRead(true); @@ -2028,7 +2028,9 @@ namespace OpenSim.Region.Framework.Scenes //Console.WriteLine("Camera At ={0}", cameraAtOffset); //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); - ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child + ControllingClient.SendSitResponse(part.ParentGroup.UUID, offsetr + part.OffsetPosition, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location @@ -2398,7 +2400,17 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); return; } } - m_parentID = m_requestedSitTargetID; + + //We want our offsets to reference the root prim, not the child we may have sat on + if (!part.IsRoot) + { + m_parentID = part.ParentGroup.RootPart.LocalId; + m_pos += part.OffsetPosition; + } + else + { + m_parentID = m_requestedSitTargetID; + } Velocity = Vector3.Zero; RemoveFromPhysicalScene(); -- cgit v1.1 From 9d251b1dc518522979b73fdadc0329067b669149 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 20 Jun 2010 15:57:01 -0700 Subject: Fix the StandUp position to calculate as if we're still using the child prim id. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 472c389..a376ab1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1822,7 +1822,7 @@ namespace OpenSim.Region.Framework.Scenes //CW: If the part isn't null then we can set the current position if (part != null) { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! AbsolutePosition = avWorldStandUp; //KF: Fix stand up. part.IsOccupied = false; part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); -- cgit v1.1 From 3428196631bb13f04d04208af9fd28a432805ccf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 22 Jun 2010 02:33:20 +0200 Subject: Guard prioritizer agains null values as those produced by a bullet dying before it can be updated --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index b95b5f2..8cd0160 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -52,6 +52,9 @@ namespace OpenSim.Region.Framework.Scenes public double GetUpdatePriority(IClientAPI client, ISceneEntity entity) { double priority = 0; + + if (entity == null) + return 100000; switch (m_scene.UpdatePrioritizationScheme) { -- cgit v1.1 From 962dade15596d0aeff3baba0b0b85c17524766c6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 22 Jun 2010 04:04:59 +0200 Subject: Cause collisions with the avatar to be sent to attachments. Currently ignores collision filter. Physics collisions are still dodgy, so we don't get the events we should be getting. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 140 +++++++++++++++++++++++ 1 file changed, 140 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a376ab1..654e9ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -228,6 +228,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_updateCount = 0; //KF: Update Anims for a while private static readonly int UPDATE_COUNT = 10; // how many frames to update for private const int NumMovementsBetweenRayCast = 5; + private List m_lastColliders = new List(); private bool CameraConstraintActive; //private int m_moveToPositionStateStatus; @@ -3595,6 +3596,145 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); } } + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); + + foreach (uint localid in coldata.Keys) + { + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + { + startedColliders.Add(localid); + } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } + + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) + { + endedColliders.Add(localID); + } + } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } + + // do event notification + if (startedColliders.Count > 0) + { + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } + } + + if (endedColliders.Count > 0) + { + ColliderArgs EndCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in endedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + EndCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); + } + } + + if (thisHitColliders.Count > 0) + { + ColliderArgs CollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in thisHitColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + CollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + } + } + if (m_invulnerable) return; -- cgit v1.1 From e94cf3d9b71206384d33b4cc02fb252dfc93aed7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 24 Jun 2010 03:35:42 +0100 Subject: And another conflict --- .../Region/Framework/Scenes/SceneObjectPartInventory.cs | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5be71df..2cde8f3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -310,7 +310,6 @@ namespace OpenSim.Region.Framework.Scenes } else { -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs if (m_part.ParentGroup.m_savedScriptState != null) RestoreSavedScriptState(item.OldItemID, item.ItemID); @@ -327,22 +326,6 @@ namespace OpenSim.Region.Framework.Scenes StoreScriptErrors(item.ItemID, null); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); -======= - lock (m_items) - { - if (m_part.ParentGroup.m_savedScriptState != null) - RestoreSavedScriptState(item.OldItemID, item.ItemID); - - m_items[item.ItemID].PermsMask = 0; - m_items[item.ItemID].PermsGranter = UUID.Zero; - - string script = Utils.BytesToString(asset.Data); - m_part.ParentGroup.Scene.EventManager.TriggerRezScript( - m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); - m_part.ParentGroup.AddActiveScriptCount(1); - m_part.ScheduleFullUpdate(); - } ->>>>>>> master:OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs } } } -- cgit v1.1 From 96e649189f24b6261d0bcdd6aa7f5a078b8d3f7f Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Fri, 25 Jun 2010 14:25:39 -0700 Subject: Add two events: OnAttachToBackup and OnDetachFromBackup. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 26 ++++++++++++++++++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++++ 2 files changed, 30 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 80f9114..904e38a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -43,6 +43,10 @@ namespace OpenSim.Region.Framework.Scenes public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone); + public delegate void AttachToBackupDelegate(SceneObjectGroup sog); + + public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); + public delegate void ObjectCreateDelegate(EntityBase obj); public delegate void ObjectDeleteDelegate(EntityBase obj); @@ -61,6 +65,8 @@ namespace OpenSim.Region.Framework.Scenes private PhysicsCrash handlerPhysicsCrash = null; public event ObjectDuplicateDelegate OnObjectDuplicate; + public event AttachToBackupDelegate OnAttachToBackup; + public event DetachFromBackupDelegate OnDetachFromBackup; public event ObjectCreateDelegate OnObjectCreate; public event ObjectDeleteDelegate OnObjectRemove; @@ -388,10 +394,14 @@ namespace OpenSim.Region.Framework.Scenes m_numPrim += sceneObject.Children.Count; if (attachToBackup) + { sceneObject.AttachToBackup(); + } if (OnObjectCreate != null) + { OnObjectCreate(sceneObject); + } lock (m_dictionary_lock) { @@ -458,6 +468,22 @@ namespace OpenSim.Region.Framework.Scenes } } + public void FireAttachToBackup(SceneObjectGroup obj) + { + if (OnAttachToBackup != null) + { + OnAttachToBackup(obj); + } + } + + public void FireDetachFromBackup(SceneObjectGroup obj) + { + if (OnDetachFromBackup != null) + { + OnDetachFromBackup(obj); + } + } + /// /// Process all pending updates /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3e92954..e18dfd2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -658,6 +658,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void AttachToBackup() { + m_scene.SceneGraph.FireAttachToBackup(this); + if (InSceneBackup) { //m_log.DebugFormat( @@ -2703,6 +2705,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void DetachFromBackup() { + m_scene.SceneGraph.FireDetachFromBackup(this); + if (m_isBackedUp) m_scene.EventManager.OnBackup -= ProcessBackup; -- cgit v1.1 From f64d1cb3967b5352921b296348f618a62fdfa622 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Fri, 25 Jun 2010 14:39:15 -0700 Subject: Add new event: OnChangedBackup --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 +++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index ce7b0eb..81ef54f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -47,6 +47,8 @@ namespace OpenSim.Region.Framework.Scenes public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); + public delegate void ChangedBackupDelegate(SceneObjectGroup sog); + public delegate void ObjectCreateDelegate(EntityBase obj); public delegate void ObjectDeleteDelegate(EntityBase obj); @@ -67,6 +69,7 @@ namespace OpenSim.Region.Framework.Scenes public event ObjectDuplicateDelegate OnObjectDuplicate; public event AttachToBackupDelegate OnAttachToBackup; public event DetachFromBackupDelegate OnDetachFromBackup; + public event ChangedBackupDelegate OnChangeBackup; public event ObjectCreateDelegate OnObjectCreate; public event ObjectDeleteDelegate OnObjectRemove; @@ -484,6 +487,14 @@ namespace OpenSim.Region.Framework.Scenes } } + public void FireChangeBackup(SceneObjectGroup obj) + { + if (OnChangeBackup != null) + { + OnChangeBackup(obj); + } + } + /// /// Process all pending updates /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e18dfd2..7081ced 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -200,6 +200,10 @@ namespace OpenSim.Region.Framework.Scenes { if (value) { + if (m_isBackedUp) + { + m_scene.SceneGraph.FireChangeBackup(this); + } timeLastChanged = DateTime.Now.Ticks; if (!m_hasGroupChanged) timeFirstChanged = DateTime.Now.Ticks; -- cgit v1.1 From 6274317e63e18785a2c3d96514ca371e0a04cf71 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 26 Jun 2010 06:16:24 +0200 Subject: Fix loading of attachments on login --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 654e9ce..4a4cac9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4151,7 +4151,14 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); { m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); stateData = attServ.Get(ControllingClient.AgentId.ToString()); - doc.LoadXml(stateData); + if (stateData != String.Empty) + { + try + { + doc.LoadXml(stateData); + } + catch { } + } } Dictionary itemData = new Dictionary(); -- cgit v1.1 From 70d3b9aecaf5bf2447b43a1359c631eb60ca66aa Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 11:14:58 -0700 Subject: Add a DeleteAllSceneObjects(bool exceptNoCopy) method to allow NoCopy objects to be retained when the scene is cleared. --- OpenSim/Region/Framework/Scenes/Scene.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dc58d84..c596baa 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2183,6 +2183,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void DeleteAllSceneObjects() { + DeleteAllSceneObjects(false); + } + + /// + /// Delete every object from the scene. This does not include attachments worn by avatars. + /// + public void DeleteAllSceneObjects(bool exceptNoCopy) + { lock (Entities) { ICollection entities = new List(Entities); @@ -2192,8 +2200,13 @@ namespace OpenSim.Region.Framework.Scenes if (e is SceneObjectGroup) { SceneObjectGroup sog = (SceneObjectGroup)e; - if (!sog.IsAttachment) - DeleteSceneObject((SceneObjectGroup)e, false); + if (sog != null && !sog.IsAttachment) + { + if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) + { + DeleteSceneObject((SceneObjectGroup)e, false); + } + } } } } -- cgit v1.1 From acab2a159d150072aa9952100aa6722cbd51c1ea Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 11:24:36 -0700 Subject: Return objects which are NoCopy instead of just leaving them when cleaning the scene, if exceptNoCopy = true. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c596baa..abc7377 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2206,6 +2206,10 @@ namespace OpenSim.Region.Framework.Scenes { DeleteSceneObject((SceneObjectGroup)e, false); } + else + { + DeRezObject(null, sog.RootPart.LocalId, sog.RootPart.GroupID, DeRezAction.Return, UUID.Zero); + } } } } -- cgit v1.1 From bd19cf739a03e255b0bf46021d3fab6ea0148afb Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 12:38:08 -0700 Subject: Fix a bug with DeRezObjects (check for a null remoteClient) --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5e1798b..83fd349 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1591,15 +1591,17 @@ namespace OpenSim.Region.Framework.Scenes // So that we know the database is upto date, // for when deleting the object from it ForceSceneObjectBackup(grp); + if (remoteClient != null) + { + if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) + permissionToTakeCopy = false; + if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) + permissionToTake = false; - if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) - permissionToTakeCopy = false; - if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) - permissionToTake = false; - - if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) - permissionToDelete = false; + if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) + permissionToDelete = false; + } } // Handle god perms -- cgit v1.1 From ed5dac7e82adfe639a2057ed5d531418277869d7 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 13:06:47 -0700 Subject: Fix another nullref issue in DeRezSceneObject --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 83fd349..0380199 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1605,7 +1605,7 @@ namespace OpenSim.Region.Framework.Scenes } // Handle god perms - if (Permissions.IsGod(remoteClient.AgentId)) + if (remoteClient != null && Permissions.IsGod(remoteClient.AgentId)) { permissionToTake = true; permissionToTakeCopy = true; -- cgit v1.1 From d188ed8ed86661a79b68f5c43ce0a94dc51308f0 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 13:07:17 -0700 Subject: Return everything at once, it's more efficient that way --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index abc7377..bbac919 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2191,6 +2191,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void DeleteAllSceneObjects(bool exceptNoCopy) { + List toReturn = new List(); lock (Entities) { ICollection entities = new List(Entities); @@ -2208,12 +2209,16 @@ namespace OpenSim.Region.Framework.Scenes } else { - DeRezObject(null, sog.RootPart.LocalId, sog.RootPart.GroupID, DeRezAction.Return, UUID.Zero); + toReturn.Add((SceneObjectGroup)e); } } } } } + if (toReturn.Count > 0) + { + returnObjects(toReturn.ToArray(), UUID.Zero); + } } /// -- cgit v1.1 From 8f0adfbfb264532d55c0f0bab5bc508d36ad365e Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 15:15:19 -0700 Subject: Trigger the RegionLightShareData OnSave event properly when the profile is saved --- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bbac919..c5fb198 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1770,6 +1770,7 @@ namespace OpenSim.Region.Framework.Scenes public void StoreWindlightProfile(RegionLightShareData wl) { m_regInfo.WindlightSettings = wl; + wl.Save(); m_storageManager.DataStore.StoreRegionWindlightSettings(wl); m_eventManager.TriggerOnSaveNewWindlightProfile(); } -- cgit v1.1 From 592ff1288dd1fccc1d2efde90e94ca0ab4a57652 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 26 Jun 2010 18:51:19 -0700 Subject: Add a new global event : OnTerrainUpdate --- OpenSim/Region/Framework/Scenes/EventManager.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index ef125cd..0c9759d 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -55,8 +55,12 @@ namespace OpenSim.Region.Framework.Scenes public delegate void OnTerrainTickDelegate(); + public delegate void OnTerrainUpdateDelegate(); + public event OnTerrainTickDelegate OnTerrainTick; + public event OnTerrainUpdateDelegate OnTerrainUpdate; + public delegate void OnBackupDelegate(IRegionDataStore datastore, bool forceBackup); public event OnBackupDelegate OnBackup; @@ -716,6 +720,26 @@ namespace OpenSim.Region.Framework.Scenes } } } + public void TriggerTerrainUpdate() + { + OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; + if (handlerTerrainUpdate != null) + { + foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) + { + try + { + d(); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } public void TriggerTerrainTick() { -- cgit v1.1 From 19f18c8a1b6377fec44ebd358bb4d810d36bd586 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 27 Jun 2010 21:04:30 +0200 Subject: Make drag copy and copy-on-ray handle friends list perms properly --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 81ef54f..dfcbc4c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1851,6 +1851,28 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup copy = original.Copy(AgentID, GroupID, true); copy.AbsolutePosition = copy.AbsolutePosition + offset; + if (copy.OwnerID != AgentID) + { + copy.SetOwnerId(AgentID); + copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); + + List partList = + new List(copy.Children.Values); + + if (m_parentScene.Permissions.PropagatePermissions()) + { + foreach (SceneObjectPart child in partList) + { + child.Inventory.ChangeInventoryOwner(AgentID); + child.TriggerScriptChangedEvent(Changed.OWNER); + child.ApplyNextOwnerPermissions(); + } + } + + copy.RootPart.ObjectSaleType = 0; + copy.RootPart.SalePrice = 10; + } + Entities.Add(copy); // Since we copy from a source group that is in selected -- cgit v1.1 From 9c553cd254b5b27f3ddcffddee9684aeb4a6298b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Jun 2010 20:20:08 +0100 Subject: Fix more perms weirdness. Preserve "Locked" status across gives and rez/take. Preserve "Anyone can move" flag in most cases. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 55c1575..6532537 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -402,7 +402,7 @@ namespace OpenSim.Region.Framework.Scenes // First, make sore base is limited to the next perms itemCopy.BasePermissions = item.BasePermissions & (item.NextPermissions | (uint)PermissionMask.Move); // By default, current equals base - itemCopy.CurrentPermissions = itemCopy.BasePermissions; + itemCopy.CurrentPermissions = itemCopy.BasePermissions & item.CurrentPermissions; // If this is an object, replace current perms // with folded perms @@ -413,7 +413,7 @@ namespace OpenSim.Region.Framework.Scenes } // Ensure there is no escalation - itemCopy.CurrentPermissions &= item.NextPermissions; + itemCopy.CurrentPermissions &= (item.NextPermissions | (uint)PermissionMask.Move); // Need slam bit on xfer itemCopy.CurrentPermissions |= 8; @@ -918,12 +918,13 @@ namespace OpenSim.Region.Framework.Scenes { agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); if (taskItem.InvType == (int)InventoryType.Object) - agentItem.CurrentPermissions = agentItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13); - agentItem.CurrentPermissions = agentItem.BasePermissions ; + agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move)); + else + agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; agentItem.CurrentPermissions |= 8; agentItem.NextPermissions = taskItem.NextPermissions; - agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions; + agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; } else @@ -1105,11 +1106,11 @@ namespace OpenSim.Region.Framework.Scenes if (Permissions.PropagatePermissions()) { destTaskItem.CurrentPermissions = srcTaskItem.CurrentPermissions & - srcTaskItem.NextPermissions; + (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.GroupPermissions = srcTaskItem.GroupPermissions & - srcTaskItem.NextPermissions; + (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.EveryonePermissions = srcTaskItem.EveryonePermissions & - srcTaskItem.NextPermissions; + (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.BasePermissions = srcTaskItem.BasePermissions & (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.CurrentPermissions |= 8; // Slam! -- cgit v1.1 From d570cffa39e9ca6417ebd1c05cbdfea1d3beabd2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 28 Jun 2010 01:29:30 +0200 Subject: Fix Copy on Ray, Drag Copy and other little things. Removed the wrong and nonworking ownership assignment in SOG, which messed things up before. No longer trust the client to send the ID of the person something is copied as, since it allows to run a script with someone else's permissions. Properly adjust inventory ownership and perms. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index dfcbc4c..69a909b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1851,7 +1851,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup copy = original.Copy(AgentID, GroupID, true); copy.AbsolutePosition = copy.AbsolutePosition + offset; - if (copy.OwnerID != AgentID) + if (original.OwnerID != AgentID) { copy.SetOwnerId(AgentID); copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7081ced..241295f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1781,7 +1781,9 @@ namespace OpenSim.Region.Framework.Scenes dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); if (!userExposed) + { dupe.RootPart.IsAttachment = previousAttachmentStatus; + } dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; @@ -1806,16 +1808,6 @@ namespace OpenSim.Region.Framework.Scenes dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); } - // Now we've made a copy that replaces this one, we need to - // switch the owner to the person who did the copying - // Second Life copies an object and duplicates the first one in it's place - // So, we have to make a copy of this one, set it in it's place then set the owner on this one - if (userExposed) - { - SetRootPartOwner(m_rootPart, cAgentID, cGroupID); - m_rootPart.ScheduleFullUpdate(); - } - List partList; lockPartsForRead(true); @@ -1837,12 +1829,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); newPart.LinkNum = part.LinkNum; - - if (userExposed) - { - SetPartOwner(newPart, cAgentID, cGroupID); - newPart.ScheduleFullUpdate(); - } } } -- cgit v1.1 From a817f6b48c27fe5e950846d687edcd4d375a3c6c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 28 Jun 2010 01:48:24 +0200 Subject: Remove AgentID and GroupOD from the signature of SOG.Copy(). They were never used, but made for a very mispleading read of the code in the callers. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 69a909b..a36800b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1848,7 +1848,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanDuplicateObject(original.Children.Count, original.UUID, AgentID, original.AbsolutePosition)) { - SceneObjectGroup copy = original.Copy(AgentID, GroupID, true); + SceneObjectGroup copy = original.Copy(true); copy.AbsolutePosition = copy.AbsolutePosition + offset; if (original.OwnerID != AgentID) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 241295f..c48ce3b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1700,7 +1700,7 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE]: Storing {0}, {1} in {2}", Name, UUID, m_scene.RegionInfo.RegionName); - SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false); + SceneObjectGroup backup_group = Copy(false); backup_group.RootPart.Velocity = RootPart.Velocity; backup_group.RootPart.Acceleration = RootPart.Acceleration; backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; @@ -1758,7 +1758,7 @@ namespace OpenSim.Region.Framework.Scenes /// Duplicates this object, including operations such as physics set up and attaching to the backup event. /// /// - public SceneObjectGroup Copy(UUID cAgentID, UUID cGroupID, bool userExposed) + public SceneObjectGroup Copy(bool userExposed) { SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); dupe.m_isBackedUp = false; @@ -3897,7 +3897,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual ISceneObject CloneForNewScene() { - SceneObjectGroup sog = Copy(this.OwnerID, this.GroupID, false); + SceneObjectGroup sog = Copy(false); sog.m_isDeleted = false; return sog; } -- cgit v1.1 From 6f4d4543b94f28160d697489e591da6614f0c8fc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 29 Jun 2010 03:51:16 +0200 Subject: Make newly created prims be named "Object" and make newly created scripts have a default touch handler. Compatibility patch --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 6532537..a2a8882 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1378,7 +1378,7 @@ namespace OpenSim.Region.Framework.Scenes return; AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, - Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), + Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), remoteClient.AgentId); AssetService.Store(asset); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 09c945b..5b007e6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -358,7 +358,7 @@ namespace OpenSim.Region.Framework.Scenes UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, Quaternion rotationOffset, Vector3 offsetPosition) { - m_name = "Primitive"; + m_name = "Object"; Rezzed = DateTime.UtcNow; _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); @@ -1625,7 +1625,7 @@ namespace OpenSim.Region.Framework.Scenes PrimitiveBaseShape shape = PrimitiveBaseShape.Create(); part.Shape = shape; - part.Name = "Primitive"; + part.Name = "Object"; part._ownerID = UUID.Random(); return part; -- cgit v1.1 From 3cd717d929d641b8e34d2212165af8d32fc8978e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 29 Jun 2010 04:09:14 +0200 Subject: Comment the "Notecard saved" notification that pops up when a notecard is saved into a prim. Sl doesn't have it, and for good reason: It also happens on scripts in our version. Which is wrong. Better no message than a wrong one. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a2a8882..e61132e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1285,7 +1285,7 @@ namespace OpenSim.Region.Framework.Scenes } if (part.Inventory.UpdateInventoryItem(itemInfo)) { - remoteClient.SendAgentAlertMessage("Notecard saved", false); + // remoteClient.SendAgentAlertMessage("Notecard saved", false); part.GetProperties(remoteClient); } } -- cgit v1.1 From 3940a4dbc7ffb4eab319ea9c2f1f787ddeee65e8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 1 Jul 2010 16:11:10 +0200 Subject: Avoid a spurious error message when taking a friend's no copy item --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0ac427f..167e166 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1604,8 +1604,15 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) + if (action == DeRezAction.TakeCopy) + { + if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) + permissionToTakeCopy = false; + } + else + { permissionToTakeCopy = false; + } if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) permissionToTake = false; -- cgit v1.1 From c87e6a289c5ab93025bf03f486629fd5aa00aaaa Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 2 Jul 2010 06:20:36 +0200 Subject: Clean up IMoneyModule and adjust the other modules to the changes --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 167e166..489b8ca 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes IMoneyModule money=RequestModuleInterface(); if (money != null) { - money.ApplyUploadCharge(agentID); + money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); } AddInventoryItem(agentID, item); -- cgit v1.1 From fe2b044d38f3bd3aa669334d34567fd991a67b3e Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 3 Jul 2010 06:10:55 -0700 Subject: Fix Undo! Made a lot of changes to Undo state saving; it now considers that groups of objects can be moved and not just individual prims.. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 39 ++++++++++----- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 16 ++++++- OpenSim/Region/Framework/Scenes/UndoState.cs | 55 ++++++++++++++++++---- 3 files changed, 87 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c48ce3b..da664da 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -349,7 +349,21 @@ namespace OpenSim.Region.Framework.Scenes public virtual Quaternion Rotation { get { return m_rotation; } - set { m_rotation = value; } + set { + lockPartsForRead(true); + try + { + foreach(SceneObjectPart p in m_parts.Values) + { + p.StoreUndoState(true); + } + } + finally + { + lockPartsForRead(false); + } + m_rotation = value; + } } public Quaternion GroupRotation @@ -421,6 +435,7 @@ namespace OpenSim.Region.Framework.Scenes get { return m_rootPart.GroupPosition; } set { + Vector3 val = value; if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) @@ -431,7 +446,10 @@ namespace OpenSim.Region.Framework.Scenes } lockPartsForRead(true); - + foreach (SceneObjectPart part in m_parts.Values) + { + part.IgnoreUndoUpdate = true; + } if (RootPart.GetStatusSandbox()) { if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) @@ -443,12 +461,12 @@ namespace OpenSim.Region.Framework.Scenes return; } } - foreach (SceneObjectPart part in m_parts.Values) { + part.IgnoreUndoUpdate = false; + part.StoreUndoState(true); part.GroupPosition = val; } - lockPartsForRead(false); //if (m_rootPart.PhysActor != null) @@ -724,7 +742,6 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart part in m_parts.Values) { - Vector3 partscale = part.Scale; Vector3 partoffset = part.OffsetPosition; @@ -3132,7 +3149,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { - part.IgnoreUndoUpdate = true; if (scale.X > m_scene.m_maxNonphys) scale.X = m_scene.m_maxNonphys; if (scale.Y > m_scene.m_maxNonphys) @@ -3218,8 +3234,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - obPart.IgnoreUndoUpdate = false; - obPart.StoreUndoState(); + } } } @@ -3229,13 +3244,17 @@ namespace OpenSim.Region.Framework.Scenes Vector3 prevScale = part.Scale; prevScale.X *= x; prevScale.Y *= y; - prevScale.Z *= z; + prevScale.Z *= z;; + part.IgnoreUndoUpdate = true; part.Resize(prevScale); + part.IgnoreUndoUpdate = false; lockPartsForRead(true); { foreach (SceneObjectPart obPart in m_parts.Values) { + obPart.IgnoreUndoUpdate = false; + obPart.StoreUndoState(true); obPart.IgnoreUndoUpdate = true; if (obPart.UUID != m_rootPart.UUID) { @@ -3251,7 +3270,6 @@ namespace OpenSim.Region.Framework.Scenes obPart.UpdateOffSet(currentpos); } obPart.IgnoreUndoUpdate = false; - obPart.StoreUndoState(); } } lockPartsForRead(false); @@ -3263,7 +3281,6 @@ namespace OpenSim.Region.Framework.Scenes } part.IgnoreUndoUpdate = false; - part.StoreUndoState(); HasGroupChanged = true; ScheduleGroupForTerseUpdate(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5b007e6..72ad281 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3504,9 +3504,12 @@ namespace OpenSim.Region.Framework.Scenes m_parentGroup.ScheduleGroupForTerseUpdate(); //m_parentGroup.ScheduleGroupForFullUpdate(); } - public void StoreUndoState() { + StoreUndoState(false); + } + public void StoreUndoState(bool group) + { if (!Undoing) { if (!IgnoreUndoUpdate) @@ -3528,7 +3531,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentGroup.GetSceneMaxUndo() > 0) { UndoState nUndo = new UndoState(this); - + nUndo.GroupChange = group; m_undo.Push(nUndo); } @@ -4010,6 +4013,15 @@ namespace OpenSim.Region.Framework.Scenes nUndo = new UndoState(this); } UndoState goback = m_undo.Pop(); + m_log.Debug("Got goback"); + if (goback == null) + { + m_log.Debug("it's null"); + } + else + { + m_log.Debug(goback.GroupPosition.ToString()); + } if (goback != null) { goback.PlaybackState(this); diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 55e407e..77381ab 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -35,6 +35,10 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 Position = Vector3.Zero; public Vector3 Scale = Vector3.Zero; public Quaternion Rotation = Quaternion.Identity; + public bool GroupChange = false; + public Vector3 GroupPosition = Vector3.Zero; + public Quaternion GroupRotation = Quaternion.Identity; + public Vector3 GroupScale = Vector3.Zero; public UndoState(SceneObjectPart part) { @@ -42,12 +46,24 @@ namespace OpenSim.Region.Framework.Scenes { if (part.ParentID == 0) { - Position = part.ParentGroup.AbsolutePosition; + GroupScale = part.Shape.Scale; + + //FUBAR WARNING: Do NOT get the group's absoluteposition here + //or you'll experience a loop and/or a stack issue + GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; + GroupRotation = part.ParentGroup.Rotation; + Position = part.ParentGroup.RootPart.AbsolutePosition; Rotation = part.RotationOffset; Scale = part.Shape.Scale; } else { + GroupScale = part.Shape.Scale; + + //FUBAR WARNING: Do NOT get the group's absoluteposition here + //or you'll experience a loop and/or a stack issue + GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; + GroupRotation = part.ParentGroup.Rotation; Position = part.OffsetPosition; Rotation = part.RotationOffset; Scale = part.Shape.Scale; @@ -61,14 +77,14 @@ namespace OpenSim.Region.Framework.Scenes { if (part.ParentID == 0) { - if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation) + if (Position == part.ParentGroup.RootPart.AbsolutePosition && Rotation == part.ParentGroup.Rotation && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale) return true; else return false; } else { - if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale) + if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale) return true; else return false; @@ -84,10 +100,10 @@ namespace OpenSim.Region.Framework.Scenes { part.Undoing = true; - if (part.ParentID == 0) + if (part.ParentID == 0 && GroupChange == false) { if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; + part.ParentGroup.AbsolutePosition = Position; part.RotationOffset = Rotation; if (Scale != Vector3.Zero) part.Resize(Scale); @@ -95,11 +111,30 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (Position != Vector3.Zero) - part.OffsetPosition = Position; - part.UpdateRotation(Rotation); - if (Scale != Vector3.Zero) - part.Resize(Scale); part.ScheduleTerseUpdate(); + if (GroupChange) + { + if (Position != Vector3.Zero) + { + //Calculate the scale... + Vector3 gs = part.Shape.Scale; + float scale = GroupScale.Z / gs.Z; + + //Scale first since it can affect our position + part.ParentGroup.GroupResize(gs * scale, part.LocalId); + part.ParentGroup.AbsolutePosition = GroupPosition; + part.ParentGroup.Rotation = GroupRotation; + + } + } + else + { + if (Position != Vector3.Zero) //We can use this for all the updates since all are set + { + part.OffsetPosition = Position; + part.UpdateRotation(Rotation); + part.Resize(Scale); part.ScheduleTerseUpdate(); + } + } } part.Undoing = false; -- cgit v1.1 From edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 3 Jul 2010 20:27:00 +0200 Subject: Fix IMs the right way. This sets it up so that timestamps are actually in PST (to match viewer time), does correct storage and retrieval of IMs, corrects the session ID and makes sure IMs don't get marked "saved" if they're live. Removes the group IM save option, which our group IM module never had in the first place, as saving group chatter makes no sense at all. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4a4cac9..e51d9ee 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3730,8 +3730,11 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); { CollidingMessage.Colliders = colliding; - foreach (SceneObjectGroup att in Attachments) - Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + lock (m_attachments) + { + foreach (SceneObjectGroup att in m_attachments) + Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + } } } -- cgit v1.1 From 5b68343361cbd000a2f024b37797ec235abb7207 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 4 Jul 2010 19:28:39 -0700 Subject: The majority of the Undo fix. There is still an issue with Rotation which i'll address next; however position undo and scale undo should be working just fine now. Also removed some residual debug logging. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 38 +++++----- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 61 ++++++++--------- .../Scenes/Serialization/SceneObjectSerializer.cs | 4 +- OpenSim/Region/Framework/Scenes/UndoState.cs | 80 ++++++++++++++++++++-- 4 files changed, 127 insertions(+), 56 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index da664da..34712b8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -355,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach(SceneObjectPart p in m_parts.Values) { - p.StoreUndoState(true); + p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); } } finally @@ -435,7 +435,6 @@ namespace OpenSim.Region.Framework.Scenes get { return m_rootPart.GroupPosition; } set { - Vector3 val = value; if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) @@ -464,7 +463,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in m_parts.Values) { part.IgnoreUndoUpdate = false; - part.StoreUndoState(true); + part.StoreUndoState(UndoType.STATE_GROUP_POSITION); part.GroupPosition = val; } lockPartsForRead(false); @@ -1488,7 +1487,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) { - part.StoreUndoState(); + part.StoreUndoState(UndoType.STATE_PRIM_ALL); part.OnGrab(offsetPos, remoteClient); } @@ -3245,6 +3244,9 @@ namespace OpenSim.Region.Framework.Scenes prevScale.X *= x; prevScale.Y *= y; prevScale.Z *= z;; + + part.IgnoreUndoUpdate = false; + part.StoreUndoState(UndoType.STATE_GROUP_SCALE); part.IgnoreUndoUpdate = true; part.Resize(prevScale); part.IgnoreUndoUpdate = false; @@ -3253,11 +3255,12 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart obPart in m_parts.Values) { - obPart.IgnoreUndoUpdate = false; - obPart.StoreUndoState(true); - obPart.IgnoreUndoUpdate = true; if (obPart.UUID != m_rootPart.UUID) { + obPart.IgnoreUndoUpdate = false; + obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); + obPart.IgnoreUndoUpdate = true; + Vector3 currentpos = new Vector3(obPart.OffsetPosition); currentpos.X *= x; currentpos.Y *= y; @@ -3296,14 +3299,11 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupPosition(Vector3 pos) { - foreach (SceneObjectPart part in Children.Values) - { - part.StoreUndoState(); - } if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { if (IsAttachment) { + m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); m_rootPart.AttachedPos = pos; } if (RootPart.GetStatusSandbox()) @@ -3336,7 +3336,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); foreach (SceneObjectPart parts in Children.Values) { - parts.StoreUndoState(); + parts.StoreUndoState(UndoType.STATE_PRIM_POSITION); } if (part != null) { @@ -3361,7 +3361,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart part in Children.Values) { - part.StoreUndoState(); + part.StoreUndoState(UndoType.STATE_PRIM_POSITION); } Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); Vector3 oldPos = @@ -3409,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart parts in Children.Values) { - parts.StoreUndoState(); + parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); } m_rootPart.UpdateRotation(rot); @@ -3433,7 +3433,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart parts in Children.Values) { - parts.StoreUndoState(); + parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); } m_rootPart.UpdateRotation(rot); @@ -3460,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); foreach (SceneObjectPart parts in Children.Values) { - parts.StoreUndoState(); + parts.StoreUndoState(UndoType.STATE_PRIM_ROTATION); } if (part != null) { @@ -3496,7 +3496,7 @@ namespace OpenSim.Region.Framework.Scenes part.UpdateRotation(rot); part.OffsetPosition = pos; part.IgnoreUndoUpdate = false; - part.StoreUndoState(); + part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); } } } @@ -3510,7 +3510,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; - m_rootPart.StoreUndoState(); + m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { @@ -3542,7 +3542,7 @@ namespace OpenSim.Region.Framework.Scenes if (childpart != m_rootPart) { childpart.IgnoreUndoUpdate = false; - childpart.StoreUndoState(); + childpart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 72ad281..93a23ca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -697,7 +697,7 @@ namespace OpenSim.Region.Framework.Scenes get { return m_offsetPosition; } set { - StoreUndoState(); + StoreUndoState(UndoType.STATE_PRIM_POSITION); m_offsetPosition = value; if (ParentGroup != null && !ParentGroup.IsDeleted) @@ -759,7 +759,7 @@ namespace OpenSim.Region.Framework.Scenes set { - StoreUndoState(); + StoreUndoState(UndoType.STATE_PRIM_ROTATION); m_rotationOffset = value; PhysicsActor actor = PhysActor; @@ -958,7 +958,7 @@ namespace OpenSim.Region.Framework.Scenes get { return m_shape.Scale; } set { - StoreUndoState(); + StoreUndoState(UndoType.STATE_PRIM_SCALE); if (m_shape != null) { m_shape.Scale = value; @@ -1522,7 +1522,7 @@ namespace OpenSim.Region.Framework.Scenes { m_redo.Clear(); } - StoreUndoState(); + StoreUndoState(UndoType.STATE_ALL); } public byte ConvertScriptUintToByte(uint indata) @@ -2721,7 +2721,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void Resize(Vector3 scale) { - StoreUndoState(); + StoreUndoState(UndoType.STATE_PRIM_SCALE); m_shape.Scale = scale; ParentGroup.HasGroupChanged = true; @@ -3504,13 +3504,11 @@ namespace OpenSim.Region.Framework.Scenes m_parentGroup.ScheduleGroupForTerseUpdate(); //m_parentGroup.ScheduleGroupForFullUpdate(); } - public void StoreUndoState() + public void StoreUndoState(UndoType type) { - StoreUndoState(false); - } - public void StoreUndoState(bool group) - { - if (!Undoing) + + + if (!Undoing && (m_parentGroup == null || m_parentGroup.RootPart == null || !m_parentGroup.RootPart.Undoing)) { if (!IgnoreUndoUpdate) { @@ -3521,17 +3519,25 @@ namespace OpenSim.Region.Framework.Scenes if (m_undo.Count > 0) { UndoState last = m_undo.Peek(); - if (last != null) - { - if (last.Compare(this)) - return; - } + } if (m_parentGroup.GetSceneMaxUndo() > 0) { - UndoState nUndo = new UndoState(this); - nUndo.GroupChange = group; + UndoState lastUndo = m_undo.Peek(); + + UndoState nUndo = new UndoState(this, type); + + if (lastUndo != null) + { + TimeSpan ts = DateTime.Now.Subtract(lastUndo.LastUpdated); + if (ts.TotalMilliseconds < 500) + { + //Delete the last entry since it was less than 500 milliseconds ago + nUndo.Merge(lastUndo); + m_undo.Pop(); + } + } m_undo.Push(nUndo); } @@ -4008,20 +4014,13 @@ namespace OpenSim.Region.Framework.Scenes if (m_undo.Count > 0) { UndoState nUndo = null; - if (m_parentGroup.GetSceneMaxUndo() > 0) - { - nUndo = new UndoState(this); - } UndoState goback = m_undo.Pop(); - m_log.Debug("Got goback"); - if (goback == null) - { - m_log.Debug("it's null"); - } - else + if (m_parentGroup.GetSceneMaxUndo() > 0) { - m_log.Debug(goback.GroupPosition.ToString()); + nUndo = new UndoState(this, goback.Type); } + + if (goback != null) { goback.PlaybackState(this); @@ -4036,13 +4035,13 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_redo) { + UndoState gofwd = m_redo.Pop(); if (m_parentGroup.GetSceneMaxUndo() > 0) { - UndoState nUndo = new UndoState(this); + UndoState nUndo = new UndoState(this, gofwd.Type); m_undo.Push(nUndo); } - UndoState gofwd = m_redo.Pop(); if (gofwd != null) gofwd.PlayfwdState(this); } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 5bdaa17..77e477f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization sceneObject.AddPart(part); part.LinkNum = linkNum; part.TrimPermissions(); - part.StoreUndoState(); + part.StoreUndoState(UndoType.STATE_ALL); reader.Close(); sr.Close(); } @@ -231,7 +231,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (originalLinkNum != 0) part.LinkNum = originalLinkNum; - part.StoreUndoState(); + part.StoreUndoState(UndoType.STATE_ALL); reader.Close(); sr.Close(); } diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 77381ab..ad05351 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -27,26 +27,43 @@ using OpenMetaverse; using OpenSim.Region.Framework.Interfaces; +using System; namespace OpenSim.Region.Framework.Scenes { + [Flags] + public enum UndoType + { + STATE_PRIM_POSITION = 1, + STATE_PRIM_ROTATION = 2, + STATE_PRIM_SCALE = 4, + STATE_PRIM_ALL = 7, + STATE_GROUP_POSITION = 8, + STATE_GROUP_ROTATION = 16, + STATE_GROUP_SCALE = 32, + STATE_GROUP_ALL = 56, + STATE_ALL = 63 + } + public class UndoState { public Vector3 Position = Vector3.Zero; public Vector3 Scale = Vector3.Zero; public Quaternion Rotation = Quaternion.Identity; - public bool GroupChange = false; public Vector3 GroupPosition = Vector3.Zero; public Quaternion GroupRotation = Quaternion.Identity; public Vector3 GroupScale = Vector3.Zero; + public DateTime LastUpdated = DateTime.Now; + public UndoType Type; - public UndoState(SceneObjectPart part) + public UndoState(SceneObjectPart part, UndoType type) { + Type = type; if (part != null) { if (part.ParentID == 0) { - GroupScale = part.Shape.Scale; + GroupScale = part.ParentGroup.RootPart.Shape.Scale; //FUBAR WARNING: Do NOT get the group's absoluteposition here //or you'll experience a loop and/or a stack issue @@ -55,6 +72,7 @@ namespace OpenSim.Region.Framework.Scenes Position = part.ParentGroup.RootPart.AbsolutePosition; Rotation = part.RotationOffset; Scale = part.Shape.Scale; + LastUpdated = DateTime.Now; } else { @@ -67,10 +85,54 @@ namespace OpenSim.Region.Framework.Scenes Position = part.OffsetPosition; Rotation = part.RotationOffset; Scale = part.Shape.Scale; + LastUpdated = DateTime.Now; } } } - + public void Merge(UndoState last) + { + if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION))) + { + GroupPosition = last.GroupPosition; + Position = last.Position; + } + if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) + { + Console.WriteLine("Setting groupscale to " + last.GroupScale.ToString()); + GroupScale = last.GroupScale; + Scale = last.Scale; + } + if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION))) + { + GroupRotation = last.GroupRotation; + Rotation = last.Rotation; + } + if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION))) + { + Position = last.Position; + } + if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE))) + { + Scale = last.Scale; + } + if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION))) + { + Rotation = last.Rotation; + } + Type = Type | last.Type; + } + public bool Compare(UndoState undo) + { + if (undo == null || Position == null) return false; + if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) + { + return true; + } + else + { + return false; + } + } public bool Compare(SceneObjectPart part) { if (part != null) @@ -96,6 +158,14 @@ namespace OpenSim.Region.Framework.Scenes public void PlaybackState(SceneObjectPart part) { + bool GroupChange = false; + if ((Type & UndoType.STATE_GROUP_POSITION) != 0 + || (Type & UndoType.STATE_GROUP_ROTATION) != 0 + || (Type & UndoType.STATE_GROUP_SCALE) != 0) + { + GroupChange = true; + } + if (part != null) { part.Undoing = true; @@ -113,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes { if (GroupChange) { + part.ParentGroup.RootPart.Undoing = true; if (Position != Vector3.Zero) { //Calculate the scale... @@ -125,6 +196,7 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.Rotation = GroupRotation; } + part.ParentGroup.RootPart.Undoing = false; } else { -- cgit v1.1 From c616335019dc9419460407930af4e40e84663efa Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 4 Jul 2010 19:58:52 -0700 Subject: Rotation undo fix and remove a debug chatter i missed. Still not working: Individual child prim rotational undo and special cases where the root prim was moved or rotated (all the children then need to restore their offsets). Coming shortly. --- OpenSim/Region/Framework/Scenes/UndoState.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index ad05351..f9601e6 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.Framework.Scenes //FUBAR WARNING: Do NOT get the group's absoluteposition here //or you'll experience a loop and/or a stack issue GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; - GroupRotation = part.ParentGroup.Rotation; + GroupRotation = part.ParentGroup.GroupRotation; Position = part.ParentGroup.RootPart.AbsolutePosition; Rotation = part.RotationOffset; Scale = part.Shape.Scale; @@ -98,7 +98,6 @@ namespace OpenSim.Region.Framework.Scenes } if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) { - Console.WriteLine("Setting groupscale to " + last.GroupScale.ToString()); GroupScale = last.GroupScale; Scale = last.Scale; } @@ -184,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes if (GroupChange) { part.ParentGroup.RootPart.Undoing = true; - if (Position != Vector3.Zero) + if (GroupPosition != Vector3.Zero) { //Calculate the scale... Vector3 gs = part.Shape.Scale; @@ -193,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes //Scale first since it can affect our position part.ParentGroup.GroupResize(gs * scale, part.LocalId); part.ParentGroup.AbsolutePosition = GroupPosition; - part.ParentGroup.Rotation = GroupRotation; + part.ParentGroup.UpdateGroupRotationR(GroupRotation); } part.ParentGroup.RootPart.Undoing = false; -- cgit v1.1 From 8849b9af8bd3260152dede0ccf61fd98137ef6c5 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 4 Jul 2010 20:45:11 -0700 Subject: Fix single prim rotation undo. All UNDO functions are now working correctly except for when the root prim is moved or rotated as a single prim (coming soon). --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 34712b8..7492601 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3492,11 +3492,11 @@ namespace OpenSim.Region.Framework.Scenes } else { + part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); part.IgnoreUndoUpdate = true; part.UpdateRotation(rot); part.OffsetPosition = pos; part.IgnoreUndoUpdate = false; - part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); } } } -- cgit v1.1 From be5dd04150bae69745de3cf5efde3d5be288dd71 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 5 Jul 2010 03:58:18 -0700 Subject: Bring "Redo" up to date with "Undo" so it works too --- OpenSim/Region/Framework/Scenes/UndoState.cs | 41 +++++++--------------------- 1 file changed, 10 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index f9601e6..2af3316 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -123,7 +123,7 @@ namespace OpenSim.Region.Framework.Scenes public bool Compare(UndoState undo) { if (undo == null || Position == null) return false; - if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) + if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) { return true; } @@ -155,7 +155,7 @@ namespace OpenSim.Region.Framework.Scenes return false; } - public void PlaybackState(SceneObjectPart part) + private void RestoreState(SceneObjectPart part) { bool GroupChange = false; if ((Type & UndoType.STATE_GROUP_POSITION) != 0 @@ -172,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentID == 0 && GroupChange == false) { if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; + part.ParentGroup.AbsolutePosition = Position; part.RotationOffset = Rotation; if (Scale != Vector3.Zero) part.Resize(Scale); @@ -193,7 +193,7 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.GroupResize(gs * scale, part.LocalId); part.ParentGroup.AbsolutePosition = GroupPosition; part.ParentGroup.UpdateGroupRotationR(GroupRotation); - + } part.ParentGroup.RootPart.Undoing = false; } @@ -211,35 +211,13 @@ namespace OpenSim.Region.Framework.Scenes } } + public void PlaybackState(SceneObjectPart part) + { + RestoreState(part); + } public void PlayfwdState(SceneObjectPart part) { - if (part != null) - { - part.Undoing = true; - - if (part.ParentID == 0) - { - if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; - if (Rotation != Quaternion.Identity) - part.UpdateRotation(Rotation); - if (Scale != Vector3.Zero) - part.Resize(Scale); - part.ParentGroup.ScheduleGroupForTerseUpdate(); - } - else - { - if (Position != Vector3.Zero) - part.OffsetPosition = Position; - if (Rotation != Quaternion.Identity) - part.UpdateRotation(Rotation); - if (Scale != Vector3.Zero) - part.Resize(Scale); - part.ScheduleTerseUpdate(); - } - part.Undoing = false; - - } + RestoreState(part); } } public class LandUndoState @@ -267,3 +245,4 @@ namespace OpenSim.Region.Framework.Scenes } } } + -- cgit v1.1 From e947d04038f7b42929368d9f7b6d440be139e675 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 5 Jul 2010 05:44:35 -0700 Subject: Undo fix is now complete. This commit repairs the special case of the root prim moving or rotating independently of the rest of the group. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 49 +++++++++++++++++----- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 - OpenSim/Region/Framework/Scenes/UndoState.cs | 5 ++- 3 files changed, 41 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7492601..f85d3d9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3386,10 +3386,27 @@ namespace OpenSim.Region.Framework.Scenes } lockPartsForRead(false); - AbsolutePosition = newPos; + //We have to set undoing here because otherwise an undo state will be saved + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + AbsolutePosition = newPos; + m_rootPart.Undoing = false; + } + else + { + AbsolutePosition = newPos; + } HasGroupChanged = true; - ScheduleGroupForTerseUpdate(); + if (m_rootPart.Undoing) + { + ScheduleGroupForFullUpdate(); + } + else + { + ScheduleGroupForTerseUpdate(); + } } public void OffsetForNewRegion(Vector3 offset) @@ -3488,7 +3505,16 @@ namespace OpenSim.Region.Framework.Scenes if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); - AbsolutePosition = pos; + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + AbsolutePosition = pos; + m_rootPart.Undoing = false; + } + else + { + AbsolutePosition = pos; + } } else { @@ -3511,6 +3537,12 @@ namespace OpenSim.Region.Framework.Scenes Quaternion oldParentRot = m_rootPart.RotationOffset; m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); + bool cancelUndo = false; + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + cancelUndo = true; + } m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { @@ -3534,18 +3566,13 @@ namespace OpenSim.Region.Framework.Scenes newRot *= Quaternion.Inverse(axRot); prim.RotationOffset = newRot; prim.ScheduleTerseUpdate(); + prim.IgnoreUndoUpdate = false; } } - - foreach (SceneObjectPart childpart in Children.Values) + if (cancelUndo == true) { - if (childpart != m_rootPart) - { - childpart.IgnoreUndoUpdate = false; - childpart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); - } + m_rootPart.Undoing = false; } - lockPartsForRead(false); m_rootPart.ScheduleTerseUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 93a23ca..3327b1e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3506,8 +3506,6 @@ namespace OpenSim.Region.Framework.Scenes } public void StoreUndoState(UndoType type) { - - if (!Undoing && (m_parentGroup == null || m_parentGroup.RootPart == null || !m_parentGroup.RootPart.Undoing)) { if (!IgnoreUndoUpdate) diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 2af3316..f71b507 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -172,8 +172,9 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentID == 0 && GroupChange == false) { if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; - part.RotationOffset = Rotation; + + part.ParentGroup.UpdateSinglePosition(Position, part.LocalId); + part.ParentGroup.UpdateSingleRotation(Rotation, part.LocalId); if (Scale != Vector3.Zero) part.Resize(Scale); part.ParentGroup.ScheduleGroupForTerseUpdate(); -- cgit v1.1 From 8aa5f30082f667fc23ccfdb839e04ba8b72f872c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 10 Jul 2010 10:51:49 +0200 Subject: Make taken items go back to the folder they came from --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3327b1e..b552cdc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -180,6 +180,9 @@ namespace OpenSim.Region.Framework.Scenes public UUID FromItemID; [XmlIgnore] + public UUID FromFolderID; + + [XmlIgnore] public int STATUS_ROTATE_X; [XmlIgnore] -- cgit v1.1 From 7f0f11304f0979355d75538ab7326b687b62e76e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 11 Jul 2010 14:26:57 +0200 Subject: Add scripted controllers into agent intersim messaging --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 33 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b552cdc..e87766e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4145,6 +4145,10 @@ namespace OpenSim.Region.Framework.Scenes case 16: _nextOwnerMask = ApplyMask(_nextOwnerMask, set, mask) & baseMask; + // Prevent the client from creating no mod, no copy + // objects + if ((_nextOwnerMask & (uint)PermissionMask.Copy) == 0) + _nextOwnerMask |= (uint)PermissionMask.Transfer; break; } SendFullUpdateToAllClients(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5ac7755..efe3365 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3365,6 +3365,18 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); cAgent.Attachments = attachs; } + lock (scriptedcontrols) + { + ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; + int i = 0; + + foreach (ScriptControllers c in scriptedcontrols.Values) + { + controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); + } + cAgent.Controllers = controls; + } + // Animations try { @@ -3446,6 +3458,27 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); } catch { } + try + { + lock (scriptedcontrols) + { + if (cAgent.Controllers != null) + { + scriptedcontrols.Clear(); + + foreach (ControllerData c in cAgent.Controllers) + { + ScriptControllers sc = new ScriptControllers(); + sc.itemID = c.ItemID; + sc.ignoreControls = (ScriptControlled)c.IgnoreControls; + sc.eventControls = (ScriptControlled)c.EventControls; + + scriptedcontrols[sc.itemID] = sc; + } + } + } + } + catch { } // Animations try { -- cgit v1.1 From 5f4105d48c9776423a730e6480a2587bd64550a5 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 12 Jul 2010 13:55:56 -0700 Subject: Removed the CHANGED_COLOR event post from the Color accessor in SOP. This is not the correct usage of this changed event - it's only supposed to be posted when the /textures/ change colour or alpha transparency, not the floating text. This fixes several race conditions in scripts ported from SL. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e87766e..f8ae321 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -882,7 +882,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_color = value; - TriggerScriptChangedEvent(Changed.COLOR); /* ScheduleFullUpdate() need not be called b/c after * setting the color, the text will be set, so then -- cgit v1.1 From 89c1c5c35a7665315e66e46276d1b6066f3cf2b8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 13 Jul 2010 20:40:23 +0200 Subject: Revamp the permissions propagation. This MAY mess up. Please test. Change the slam bit from 3 to 4. Assume the old slam bit is always set. The new slam bit is a "changed owner" bit, correcting a bug where an item passed from the creator to another with less than full perms, then back (sale test) would arrive back full perm. Lots of in-code docs. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 134 +++++++++++++++------ OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 5 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 1 - 4 files changed, 103 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 38a5456..5796194 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -280,6 +280,10 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, UUID itemID, InventoryItemBase itemUpd) { + // This one will let people set next perms on items in agent + // inventory. Rut-Roh. Whatever. Make this secure. Yeah. + // + // Passing something to another avatar or a an object will already InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = InventoryService.GetItem(item); @@ -289,11 +293,9 @@ namespace OpenSim.Region.Framework.Scenes { item.Name = itemUpd.Name; item.Description = itemUpd.Description; - item.NextPermissions = itemUpd.NextPermissions; - item.CurrentPermissions |= 8; // Slam! - item.EveryOnePermissions = itemUpd.EveryOnePermissions; - item.GroupPermissions = itemUpd.GroupPermissions; - + item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; + item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions; + item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions; item.GroupID = itemUpd.GroupID; item.GroupOwned = itemUpd.GroupOwned; item.CreationDate = itemUpd.CreationDate; @@ -399,28 +401,96 @@ namespace OpenSim.Region.Framework.Scenes if (Permissions.PropagatePermissions() && recipient != senderId) { - // First, make sore base is limited to the next perms - itemCopy.BasePermissions = item.BasePermissions & (item.NextPermissions | (uint)PermissionMask.Move); - // By default, current equals base - itemCopy.CurrentPermissions = itemCopy.BasePermissions & item.CurrentPermissions; - - // If this is an object, replace current perms - // with folded perms + // Trying to do this right this time. This is evil. If + // you believe in Good, go elsewhere. Vampires and other + // evil creatores only beyond this point. You have been + // warned. + + // We're going to mask a lot of things by the next perms + // Tweak the next perms to be nicer to our data + // + // In this mask, all the bits we do NOT want to mess + // with are set. These are: + // + // Transfer + // Copy + // Modufy + uint permsMask = ~ ((uint)PermissionMask.Copy | + (uint)PermissionMask.Transfer | + (uint)PermissionMask.Modify); + + // Now, reduce the next perms to the mask bits + // relevant to the operation + uint nextPerms = permsMask | (item.NextPermissions & + ((uint)PermissionMask.Copy | + (uint)PermissionMask.Transfer | + (uint)PermissionMask.Modify)); + + // nextPerms now has all bits set, except for the actual + // next permission bits. + + // This checks for no mod, no copy, no trans. + // This indicates an error or messed up item. Do it like + // SL and assume trans + if (nextPerms == permsMask) + nextPerms |= (uint)PermissionMask.Transfer; + + // Inventory owner perms are the logical AND of the + // folded perms and the root prim perms, however, if + // the root prim is mod, the inventory perms will be + // mod. This happens on "take" and is of little concern + // here, save for preventing escalation + + // This hack ensures that items previously permalocked + // get unlocked when they're passed or rezzed + uint basePerms = item.BasePermissions | + (uint)PermissionMask.Move; + uint ownerPerms = item.CurrentPermissions; + + // Mask the base permissions. This is a conservative + // approach altering only the three main perms + basePerms &= nextPerms; + + // If this is an object, root prim perms may be more + // permissive than folded perms. Use folded perms as + // a mask if (item.InvType == (int)InventoryType.Object) { - itemCopy.CurrentPermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - itemCopy.CurrentPermissions |= (item.CurrentPermissions & 7) << 13; + // Create a safe mask for the current perms + uint foldedPerms = (item.CurrentPermissions & 7) << 13; + foldedPerms |= permsMask; + + bool isRootMod = (item.CurrentPermissions & + (uint)PermissionMask.Modify) != 0 ? + true : false; + + // Mask the owner perms to the folded perms + ownerPerms &= foldedPerms; + + // If the root was mod, let the mask reflect that + if (isRootMod) + ownerPerms |= (uint)PermissionMask.Modify; } - // Ensure there is no escalation - itemCopy.CurrentPermissions &= (item.NextPermissions | (uint)PermissionMask.Move); + // These will be applied to the root prim at next rez. + // The slam bit (bit 3) and folded permission (bits 0-2) + // are preserved due to the above mangling + ownerPerms &= nextPerms; - // Need slam bit on xfer - itemCopy.CurrentPermissions |= 8; + // Assign to the actual item. Make sure the slam bit is + // set, if it wasn't set before. + itemCopy.BasePermissions = basePerms; + itemCopy.CurrentPermissions = ownerPerms | 16; // Slam itemCopy.NextPermissions = item.NextPermissions; - itemCopy.EveryOnePermissions = 0; + // This preserves "everyone can move" + itemCopy.EveryOnePermissions = item.EveryOnePermissions & + nextPerms; + + // Intentionally killing "share with group" here, as + // the recipient will not have the group this is + // set to itemCopy.GroupPermissions = 0; } else @@ -922,7 +992,7 @@ namespace OpenSim.Region.Framework.Scenes else agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; - agentItem.CurrentPermissions |= 8; + agentItem.CurrentPermissions |= 16; // Slam agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; @@ -1113,7 +1183,7 @@ namespace OpenSim.Region.Framework.Scenes (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.BasePermissions = srcTaskItem.BasePermissions & (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); - destTaskItem.CurrentPermissions |= 8; // Slam! + destTaskItem.CurrentPermissions |= 16; // Slam! } } @@ -1497,7 +1567,7 @@ namespace OpenSim.Region.Framework.Scenes srcTaskItem.NextPermissions; destTaskItem.BasePermissions = srcTaskItem.BasePermissions & srcTaskItem.NextPermissions; - destTaskItem.CurrentPermissions |= 8; // Slam! + destTaskItem.CurrentPermissions |= 16; // Slam! } } @@ -1889,17 +1959,14 @@ namespace OpenSim.Region.Framework.Scenes group.SetGroup(sourcePart.GroupID, null); - if (rootPart.OwnerID != item.OwnerID) + if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) { if (Permissions.PropagatePermissions()) { - if ((item.CurrentPermissions & 8) != 0) + foreach (SceneObjectPart part in partList) { - foreach (SceneObjectPart part in partList) - { - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; - } + part.EveryoneMask = item.EveryonePermissions; + part.NextOwnerMask = item.NextPermissions; } group.ApplyNextOwnerPermissions(); } @@ -1907,17 +1974,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in partList) { - if (part.OwnerID != item.OwnerID) + if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; part.Inventory.ChangeInventoryOwner(item.OwnerID); } - else if ((item.CurrentPermissions & 8) != 0) // Slam! - { - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; - } + part.EveryoneMask = item.EveryonePermissions; + part.NextOwnerMask = item.NextPermissions; } rootPart.TrimPermissions(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c5fb198..d323e19 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4818,7 +4818,7 @@ namespace OpenSim.Region.Framework.Scenes part.NextOwnerMask; item.GroupPermissions = part.GroupMask & part.NextOwnerMask; - item.CurrentPermissions |= 8; // Slam! + item.CurrentPermissions |= 16; // Slam! item.CreationDate = Util.UnixTimeSinceEpoch(); if (InventoryService.AddItem(item)) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 1149a20..70b37fb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -170,13 +170,14 @@ namespace OpenSim.Region.Framework.Scenes taskItem.GroupPermissions = item.GroupPermissions & item.NextPermissions; taskItem.NextPermissions = item.NextPermissions; - taskItem.CurrentPermissions |= 8; + // We're adding this to a prim we don't own. Force + // owner change + taskItem.CurrentPermissions |= 16; // Slam } else { taskItem.BasePermissions = item.BasePermissions; taskItem.CurrentPermissions = item.CurrentPermissions; - taskItem.CurrentPermissions |= 8; taskItem.EveryonePermissions = item.EveryOnePermissions; taskItem.GroupPermissions = item.GroupPermissions; taskItem.NextPermissions = item.NextPermissions; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2cde8f3..0066158 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1082,7 +1082,6 @@ namespace OpenSim.Region.Framework.Scenes item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) item.CurrentPermissions &= ~(uint)PermissionMask.Modify; - item.CurrentPermissions |= 8; } item.OwnerChanged = true; item.CurrentPermissions &= item.NextPermissions; -- cgit v1.1 From c5891c14c7547dc0cbbf1bd5bf3a0d2923616f25 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Tue, 13 Jul 2010 15:32:35 -0700 Subject: Bail out in AttachToBackup if the group is an attachment --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f85d3d9..7053c02 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -679,6 +679,7 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void AttachToBackup() { + if (IsAttachment) return; m_scene.SceneGraph.FireAttachToBackup(this); if (InSceneBackup) -- cgit v1.1 From af13c80d6835d7440994e6ad50ff40a8e3aeb99e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 14 Jul 2010 03:59:26 +0200 Subject: Remove getting the object capacity from the money module. It is now set directly from the Region Info (and the region ini file) --- OpenSim/Region/Framework/Scenes/Scene.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d323e19..7c25e87 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -492,8 +492,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_sceneGraph.RestorePresences = value; } } - public int objectCapacity = 45000; - #endregion #region BinaryStats @@ -703,7 +701,7 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; - StatsReporter.SetObjectCapacity(objectCapacity); + StatsReporter.SetObjectCapacity(RegionInfo.ObjectCapacity); // Old /* @@ -4206,20 +4204,6 @@ namespace OpenSim.Region.Framework.Scenes #region Other Methods - public void SetObjectCapacity(int objects) - { - // Region specific config overrides global - // - if (RegionInfo.ObjectCapacity != 0) - objects = RegionInfo.ObjectCapacity; - - if (StatsReporter != null) - { - StatsReporter.SetObjectCapacity(objects); - } - objectCapacity = objects; - } - #endregion public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) -- cgit v1.1 From cbb3a8ab94f8df6963f8045a3ca3795bcbcfe0b5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 14 Jul 2010 16:21:55 +0200 Subject: Fix a permissions issue --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 15 +++++++++++---- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 18 +++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5796194..e972382 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -447,10 +447,6 @@ namespace OpenSim.Region.Framework.Scenes (uint)PermissionMask.Move; uint ownerPerms = item.CurrentPermissions; - // Mask the base permissions. This is a conservative - // approach altering only the three main perms - basePerms &= nextPerms; - // If this is an object, root prim perms may be more // permissive than folded perms. Use folded perms as // a mask @@ -466,10 +462,17 @@ namespace OpenSim.Region.Framework.Scenes // Mask the owner perms to the folded perms ownerPerms &= foldedPerms; + basePerms &= foldedPerms; // If the root was mod, let the mask reflect that + // We also need to adjust the base here, because + // we should be able to edit in-inventory perms + // for the root prim, if it's mod. if (isRootMod) + { ownerPerms |= (uint)PermissionMask.Modify; + basePerms |= (uint)PermissionMask.Modify; + } } // These will be applied to the root prim at next rez. @@ -477,6 +480,10 @@ namespace OpenSim.Region.Framework.Scenes // are preserved due to the above mangling ownerPerms &= nextPerms; + // Mask the base permissions. This is a conservative + // approach altering only the three main perms + basePerms &= nextPerms; + // Assign to the actual item. Make sure the slam bit is // set, if it wasn't set before. itemCopy.BasePermissions = basePerms; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 70b37fb..abb4de6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -280,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes PermissionMask.Move | PermissionMask.Transfer) | 7; - uint ownerMask = 0x7ffffff; + uint ownerMask = 0x7fffffff; foreach (SceneObjectPart part in m_parts.Values) { ownerMask &= part.OwnerMask; @@ -294,12 +294,16 @@ namespace OpenSim.Region.Framework.Scenes if ((ownerMask & (uint)PermissionMask.Transfer) == 0) perms &= ~(uint)PermissionMask.Transfer; - if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0) - perms &= ~((uint)PermissionMask.Modify >> 13); - if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0) - perms &= ~((uint)PermissionMask.Copy >> 13); - if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0) - perms &= ~((uint)PermissionMask.Transfer >> 13); + // If root prim permissions are applied here, this would screw + // with in-inventory manipulation of the next owner perms + // in a major way. So, let's move this to the give itself. + // Yes. I know. Evil. +// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0) +// perms &= ~((uint)PermissionMask.Modify >> 13); +// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0) +// perms &= ~((uint)PermissionMask.Copy >> 13); +// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0) +// perms &= ~((uint)PermissionMask.Transfer >> 13); return perms; } -- cgit v1.1 From 0c445239a68688311d6fa7405ef13ceb3e773930 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 14 Jul 2010 19:21:01 +0200 Subject: Remove useless quaternion parameter from AttachObject sig --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c25e87..873a11d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2633,7 +2633,7 @@ namespace OpenSim.Region.Framework.Scenes if (AttachmentsModule != null) AttachmentsModule.AttachObject( - sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); + sp.ControllingClient, grp.LocalId, (uint)0, grp.AbsolutePosition, false); } else -- cgit v1.1 From bebbe407ee166a0aa22f0ec8d14ada780924f9af Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 14 Jul 2010 19:58:23 +0200 Subject: Major attachments cleanup. Remove unused AttachObject ClientView method Clean up use of AttachObject throughout, reduce number of overloads and number of parameters --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 873a11d..daad3d2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2632,8 +2632,7 @@ namespace OpenSim.Region.Framework.Scenes RootPrim.RemFlag(PrimFlags.TemporaryOnRez); if (AttachmentsModule != null) - AttachmentsModule.AttachObject( - sp.ControllingClient, grp.LocalId, (uint)0, grp.AbsolutePosition, false); + AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); } else -- cgit v1.1 From ddfff55cc76144607086fbca03c86df57a271ed0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 14 Jul 2010 21:06:49 +0200 Subject: Preserve attachment data while a prim is in world. Allows attachment editing on the ground without losing attachpoint and position --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f8ae321..87b2d74 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -182,6 +182,14 @@ namespace OpenSim.Region.Framework.Scenes [XmlIgnore] public UUID FromFolderID; + // The following two are to hold the attachment data + // while an object is inworld + [XmlIgnore] + public byte AttachPoint = 0; + + [XmlIgnore] + public Vector3 AttachOffset = Vector3.Zero; + [XmlIgnore] public int STATUS_ROTATE_X; -- cgit v1.1 From 8d2b4b7b487f7a35b610d894c03619e638866473 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 15 Jul 2010 20:03:08 +0200 Subject: Fix a few permissions vulnerability. Owners could cause permissions escalation on items contained in prims using a hacked viewer --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 35 ++++++++++++++++++++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++ .../Framework/Scenes/SceneObjectPartInventory.cs | 6 ---- 3 files changed, 35 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index c77efc7..e1674be 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1359,16 +1359,45 @@ namespace OpenSim.Region.Framework.Scenes { agentTransactions.HandleTaskItemUpdateFromTransaction( remoteClient, part, transactionID, currentItem); - } - if (part.Inventory.UpdateInventoryItem(itemInfo)) - { + if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) remoteClient.SendAgentAlertMessage("Notecard saved", false); else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) remoteClient.SendAgentAlertMessage("Script saved", false); else remoteClient.SendAgentAlertMessage("Item saved", false); + } + // Check if we're allowed to mess with permissions + if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god + { + if (remoteClient.AgentId != part.OwnerID) // Not owner + { + // Friends and group members can't change any perms + itemInfo.BasePermissions = currentItem.BasePermissions; + itemInfo.EveryonePermissions = currentItem.EveryonePermissions; + itemInfo.GroupPermissions = currentItem.GroupPermissions; + itemInfo.NextPermissions = currentItem.NextPermissions; + itemInfo.CurrentPermissions = currentItem.CurrentPermissions; + } + else + { + // Owner can't change base, and can change other + // only up to base + // Base ALWAYS has move + currentItem.BasePermissions |= (uint)PermissionMask.Move; + itemInfo.BasePermissions = currentItem.BasePermissions; + itemInfo.EveryonePermissions &= currentItem.BasePermissions; + itemInfo.GroupPermissions &= currentItem.BasePermissions; + itemInfo.CurrentPermissions &= currentItem.BasePermissions; + itemInfo.NextPermissions &= currentItem.BasePermissions; + // Next ALWAYS has move + itemInfo.NextPermissions |= (uint)PermissionMask.Move; + } + + } + if (part.Inventory.UpdateInventoryItem(itemInfo)) + { part.GetProperties(remoteClient); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 87b2d74..b19c443 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4156,6 +4156,9 @@ namespace OpenSim.Region.Framework.Scenes // objects if ((_nextOwnerMask & (uint)PermissionMask.Copy) == 0) _nextOwnerMask |= (uint)PermissionMask.Transfer; + + _nextOwnerMask |= (uint)PermissionMask.Move; + break; } SendFullUpdateToAllClients(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 0066158..2a3727a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -762,12 +762,6 @@ namespace OpenSim.Region.Framework.Scenes else if ((InventoryType)item.Type == InventoryType.Notecard) { ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); - - if (presence != null) - { - presence.ControllingClient.SendAgentAlertMessage( - "Notecard saved", false); - } } m_items[item.ItemID] = item; -- cgit v1.1 From 3f91805afbff1b69ebebcee4ed2593671cf12e12 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 15 Jul 2010 20:28:18 +0200 Subject: prevent hacked viewers from being able to delete arbitrary items from any prim. Allow friends with perms and shared group members to move or copy things out of prims --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e1674be..4575068 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -935,6 +935,9 @@ namespace OpenSim.Region.Framework.Scenes } if (part != null && group != null) { + if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) + return; + TaskInventoryItem item = group.GetInventoryItem(localID, itemID); if (item == null) return; @@ -1074,9 +1077,21 @@ namespace OpenSim.Region.Framework.Scenes return; } - // Only owner can copy - if (remoteClient.AgentId != taskItem.OwnerID) - return; + TaskInventoryItem item = part.Inventory.GetInventoryItem(itemId); + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + // If the item to be moved is no copy, we need to be able to + // edit the prim. + if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) + return; + } + else + { + // If the item is copiable, then we just need to have perms + // on it. The delete check is a pure rights check + if (!Permissions.CanDeleteObject(part.UUID, remoteClient.AgentId)) + return; + } MoveTaskInventoryItem(remoteClient, folderId, part, itemId); } -- cgit v1.1 From c088397ec72916dfb2914b44f2be8df827fd89d9 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sun, 18 Jul 2010 06:01:26 -0700 Subject: If the client requests that an object be deleted, and the SOG/SOP is null and/or is marked as deleted, just send the KillObject --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4575068..989ec37 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1700,11 +1700,19 @@ namespace OpenSim.Region.Framework.Scenes // Invalid id SceneObjectPart part = GetSceneObjectPart(localID); if (part == null) + { + //Client still thinks the object exists, kill it + SendKillObject(localID); continue; + } // Already deleted by someone else if (part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + //Client still thinks the object exists, kill it + SendKillObject(localID); continue; + } // Can't delete child prims if (part != part.ParentGroup.RootPart) -- cgit v1.1 From fd66ee57f3b091e6e4b6c619645595b300c94fbb Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 20 Jul 2010 14:45:46 +0200 Subject: When a god uses mass permission setting, the V bit is cleared from next perms, rendering the item unmoveable for the next owenr. Make god mods conform to the rules, too. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 989ec37..59731f7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1383,6 +1383,9 @@ namespace OpenSim.Region.Framework.Scenes remoteClient.SendAgentAlertMessage("Item saved", false); } + // Base ALWAYS has move + currentItem.BasePermissions |= (uint)PermissionMask.Move; + // Check if we're allowed to mess with permissions if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god { @@ -1399,18 +1402,18 @@ namespace OpenSim.Region.Framework.Scenes { // Owner can't change base, and can change other // only up to base - // Base ALWAYS has move - currentItem.BasePermissions |= (uint)PermissionMask.Move; itemInfo.BasePermissions = currentItem.BasePermissions; itemInfo.EveryonePermissions &= currentItem.BasePermissions; itemInfo.GroupPermissions &= currentItem.BasePermissions; itemInfo.CurrentPermissions &= currentItem.BasePermissions; itemInfo.NextPermissions &= currentItem.BasePermissions; - // Next ALWAYS has move - itemInfo.NextPermissions |= (uint)PermissionMask.Move; } } + + // Next ALWAYS has move + itemInfo.NextPermissions |= (uint)PermissionMask.Move; + if (part.Inventory.UpdateInventoryItem(itemInfo)) { part.GetProperties(remoteClient); -- cgit v1.1 From 4ccc141764083ae6dfc0b5b8e303a4395e66b684 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 20 Jul 2010 21:49:31 +0100 Subject: Resync with master --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 44b76b7..8b4f0ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -749,13 +749,7 @@ namespace OpenSim.Region.Framework.Scenes item.GroupID = m_part.GroupID; if (item.AssetID == UUID.Zero) - item.AssetID = it.AssetID; - - lock (m_items) - { - m_items[item.ItemID] = item; - m_inventorySerial++; - } + item.AssetID = m_items[item.ItemID].AssetID; m_items[item.ItemID] = item; m_inventorySerial++; -- cgit v1.1 From c72c84b4559ea164bcb77c2d64a046729662bf04 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 21 Jul 2010 12:16:17 +0200 Subject: Refine autoreturn a bit --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7053c02..e738dd2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1681,7 +1681,10 @@ namespace OpenSim.Region.Framework.Scenes try { - if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart + if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart + m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things + m_scene.LoadingPrims) // Land may not be valid yet + { ILandObject parcel = m_scene.LandChannel.GetLandObject( m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); -- cgit v1.1 From fb89d0ff4eb4636a6a70fd45c85b935e0a6b388a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 21 Jul 2010 12:31:59 +0200 Subject: Allow megaregions to be used in M7, should we so decide --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 47 ++++++++++++++------------- 2 files changed, 27 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f79bd23..2a498cc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -137,6 +137,7 @@ namespace OpenSim.Region.Framework.Scenes protected SceneCommunicationService m_sceneGridService; public bool LoginsDisabled = true; public bool LoadingPrims = false; + public bool CombineRegions = false; public new float TimeDilation { @@ -768,6 +769,7 @@ namespace OpenSim.Region.Framework.Scenes } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); + CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); #region BinaryStats diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a36800b..12c1c20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -283,30 +283,33 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) { - // KF: Check for out-of-region, move inside and make static. - Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, - sceneObject.RootPart.GroupPosition.Y, - sceneObject.RootPart.GroupPosition.Z); - if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || - npos.X > Constants.RegionSize || - npos.Y > Constants.RegionSize)) - { - if (npos.X < 0.0) npos.X = 1.0f; - if (npos.Y < 0.0) npos.Y = 1.0f; - if (npos.Z < 0.0) npos.Z = 0.0f; - if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; - if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; - - foreach (SceneObjectPart part in sceneObject.Children.Values) + if (!m_parentScene.CombineRegions) + { + // KF: Check for out-of-region, move inside and make static. + Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, + sceneObject.RootPart.GroupPosition.Y, + sceneObject.RootPart.GroupPosition.Z); + if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || + npos.X > Constants.RegionSize || + npos.Y > Constants.RegionSize)) { - part.GroupPosition = npos; + if (npos.X < 0.0) npos.X = 1.0f; + if (npos.Y < 0.0) npos.Y = 1.0f; + if (npos.Z < 0.0) npos.Z = 0.0f; + if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; + if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; + + foreach (SceneObjectPart part in sceneObject.Children.Values) + { + part.GroupPosition = npos; + } + sceneObject.RootPart.Velocity = Vector3.Zero; + sceneObject.RootPart.AngularVelocity = Vector3.Zero; + sceneObject.RootPart.Acceleration = Vector3.Zero; + sceneObject.RootPart.Velocity = Vector3.Zero; } - sceneObject.RootPart.Velocity = Vector3.Zero; - sceneObject.RootPart.AngularVelocity = Vector3.Zero; - sceneObject.RootPart.Acceleration = Vector3.Zero; - sceneObject.RootPart.Velocity = Vector3.Zero; - } - + } + if (!alreadyPersisted) { sceneObject.ForceInventoryPersistence(); -- cgit v1.1 From 516ec4acd01d70276329d251155775cedf7b8941 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 25 Jul 2010 08:11:39 +0200 Subject: Eat a lockign exception that kills scripts. May bear more investigation in the long run. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 24d260e..dbf493c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -136,12 +136,21 @@ namespace OpenSim.Region.Framework.Scenes if (m_partsLock.RecursiveReadCount > 0) { m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); - m_partsLock.ExitReadLock(); + try + { + m_partsLock.ExitReadLock(); + } + catch { } // Ignore errors, to allow resync } if (m_partsLock.RecursiveWriteCount > 0) { m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested (write lock exists on this thread). This should not happen and means something needs to be fixed."); - m_partsLock.ExitWriteLock(); + try + { + m_partsLock.ExitWriteLock(); + } + catch { } + } while (!m_partsLock.TryEnterReadLock(60000)) -- cgit v1.1 From 7871dd606eb8c827101ee4ee3c64d00139e1a0b4 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 29 Jul 2010 16:33:20 +0200 Subject: Allow gods and estate managers/owners to be unaffected by parcel bans --- OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 7dab04f..a523351 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -64,6 +64,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); public delegate bool IsGodHandler(UUID user, Scene requestFromScene); + public delegate bool IsAdministratorHandler(UUID user); public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); @@ -122,6 +123,7 @@ namespace OpenSim.Region.Framework.Scenes public event RunConsoleCommandHandler OnRunConsoleCommand; public event IssueEstateCommandHandler OnIssueEstateCommand; public event IsGodHandler OnIsGod; + public event IsAdministratorHandler OnIsAdministrator; public event EditParcelHandler OnEditParcel; public event SellParcelHandler OnSellParcel; public event AbandonParcelHandler OnAbandonParcel; @@ -652,6 +654,21 @@ namespace OpenSim.Region.Framework.Scenes } return true; } + + public bool IsAdministrator(UUID user) + { + IsAdministratorHandler handler = OnIsAdministrator; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (IsAdministratorHandler h in list) + { + if (h(user) == false) + return false; + } + } + return true; + } #endregion #region EDIT PARCEL -- cgit v1.1 From e3184753a6956078a2e34c449d5e30843b5d7f94 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 3 Aug 2010 05:25:23 +0200 Subject: Log the UUID of a prim that fails meshing and set the prim to phantom during region startup --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b19c443..032fbe8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1497,14 +1497,21 @@ namespace OpenSim.Region.Framework.Scenes // or flexible if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) { - PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( - Name, - Shape, - AbsolutePosition, - Scale, - RotationOffset, - RigidBody); - + try + { + PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( + Name, + Shape, + AbsolutePosition, + Scale, + RotationOffset, + RigidBody); + } + catch + { + m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); + PhysActor = null; + } // Basic Physics returns null.. joy joy joy. if (PhysActor != null) { -- cgit v1.1 From ae99c1393d4555d4cd26249b149078e4cd3d439f Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 3 Aug 2010 15:31:04 -0700 Subject: Fix scripted sit offset in child prims --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index efe3365..1fc4a81 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1935,8 +1935,14 @@ namespace OpenSim.Region.Framework.Scenes //Console.WriteLine("Scripted, unoccupied"); part.SetAvatarOnSitTarget(UUID); // set that Av will be on it offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one - sitOrientation = avSitOrientation; // Change rotatione to the scripted one - OffsetRotation = avSitOrientation; + + Quaternion nrot = avSitOrientation; + if (!part.IsRoot) + { + nrot = nrot * part.RotationOffset; + } + sitOrientation = nrot; // Change rotatione to the scripted one + OffsetRotation = nrot; autopilot = false; // Jump direct to scripted llSitPos() } else @@ -2010,7 +2016,7 @@ namespace OpenSim.Region.Framework.Scenes // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. // { // Single, or Root prim of linkset, target is ClickOffset * RootRot - offsetr = offset * partIRot; + //offsetr = offset * partIRot; // // else // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) @@ -2029,7 +2035,7 @@ namespace OpenSim.Region.Framework.Scenes //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child - ControllingClient.SendSitResponse(part.ParentGroup.UUID, offsetr + part.OffsetPosition, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target // This calls HandleAgentSit twice, once from here, and the client calls @@ -2343,6 +2349,10 @@ namespace OpenSim.Region.Framework.Scenes Quaternion sitTargetOrient = part.SitTargetOrientation; m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); m_pos += SIT_TARGET_ADJUSTMENT; + if (!part.IsRoot) + { + m_pos *= part.RotationOffset; + } m_bodyRot = sitTargetOrient; m_parentPosition = part.AbsolutePosition; part.IsOccupied = true; -- cgit v1.1 From f1c51c8bb4c634cedf9eb57a1bb339d3e8052b10 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 3 Aug 2010 19:51:32 -0700 Subject: Scripted sit target fixes --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1fc4a81..d857a1c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1939,7 +1939,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion nrot = avSitOrientation; if (!part.IsRoot) { - nrot = nrot * part.RotationOffset; + nrot = part.RotationOffset * avSitOrientation; } sitOrientation = nrot; // Change rotatione to the scripted one OffsetRotation = nrot; -- cgit v1.1 From 8bdbcda2b70ede033c38a604af573554dd2776ad Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 5 Aug 2010 18:50:17 +0200 Subject: We already have a record of killed prims. It just wasn't used by the new JHurlicane code anymore. Use it to prevent sending updates after kills. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 032fbe8..67cb7cc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3043,6 +3043,15 @@ namespace OpenSim.Region.Framework.Scenes UUID ownerID = _ownerID; UUID objectID = UUID; UUID parentID = GetRootPartUUID(); + + if (ParentGroup.IsAttachment && ParentGroup.RootPart.Shape.State > 30) + { + // Use the avatar as the parent for HUDs, since the prims + // are not sent to other avatars + objectID = _ownerID; + parentID = _ownerID; + } + UUID soundID = UUID.Zero; Vector3 position = AbsolutePosition; // region local ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle; -- cgit v1.1 From c5c6627adb79644b93c5871243a9eeeff553829c Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 6 Aug 2010 02:39:42 -0700 Subject: Implement CHANGED_REGION_(RE)START and also fix various CHANGED_* constants which had the wrong values (checked using LSL in SL). This addresses mantis #217 and mantis #53. --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 ++++--- .../Region/Framework/Scenes/SceneObjectPartInventory.cs | 16 ++++++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 702a1e2..b847d87 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) { // 16384 is CHANGED_ANIMATION - m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); + m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); SendAnimPack(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 032fbe8..a0fabff 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -56,9 +56,10 @@ namespace OpenSim.Region.Framework.Scenes LINK = 32, ALLOWED_DROP = 64, OWNER = 128, - REGION_RESTART = 256, - REGION = 512, - TELEPORT = 1024 + REGION = 256, + TELEPORT = 512, + REGION_RESTART = 1024, + ANIMATION = 16384 } // I don't really know where to put this except here. diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8b4f0ed..4f80a7e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -321,6 +321,22 @@ namespace OpenSim.Region.Framework.Scenes StoreScriptErrors(item.ItemID, null); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); + + //This should play nice with XEngine since XEngine loads scripts /after/ the region starts + if (stateSource == 0 && m_part.ParentGroup.Scene.LoginsDisabled == true) + { + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); + if (engines != null) + { + foreach (IScriptModule xengine in engines) + { + if (xengine != null) + { + xengine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.REGION_RESTART }); + } + } + } + } } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d857a1c..5fcd1c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3939,7 +3939,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); if (m == null) // No script engine loaded continue; - m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { 16384 }); + m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); } } } -- cgit v1.1 From a636af13e77aae588f425b7bc9504854a7ed1261 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 6 Aug 2010 06:37:40 -0700 Subject: Make sure the avatar position gets moved along with a prim it is sitting on. This fixes mantis #208 and (maybe) issues with chat and sound coming from the wrong place when sat on a vehicle. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 13 +++++++++++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 22 ++++++++-------------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 +++++++++++++ 3 files changed, 32 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index dbf493c..5a3dc20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -469,13 +469,22 @@ namespace OpenSim.Region.Framework.Scenes return; } } - foreach (SceneObjectPart part in m_parts.Values) + List parts = new List(m_parts.Values); + lockPartsForRead(false); + foreach (SceneObjectPart part in parts) { part.IgnoreUndoUpdate = false; part.StoreUndoState(UndoType.STATE_GROUP_POSITION); part.GroupPosition = val; } - lockPartsForRead(false); + + foreach (ScenePresence av in m_linkedAvatars) + { + Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; + av.AbsolutePosition += offset; + av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition + av.SendFullUpdateToAllClients(); + } //if (m_rootPart.PhysActor != null) //{ diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ba84b88..badd357 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -682,25 +682,13 @@ namespace OpenSim.Region.Framework.Scenes // Tell the physics engines that this prim changed. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); + } catch (Exception e) { m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); } } - - // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too - if (m_sitTargetAvatar != UUID.Zero) - { - if (m_parentGroup != null) // TODO can there be a SOP without a SOG? - { - ScenePresence avatar; - if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar)) - { - avatar.ParentPosition = GetWorldPosition(); - } - } - } } } @@ -709,6 +697,7 @@ namespace OpenSim.Region.Framework.Scenes get { return m_offsetPosition; } set { + Vector3 oldpos = m_offsetPosition; StoreUndoState(UndoType.STATE_PRIM_POSITION); m_offsetPosition = value; @@ -727,7 +716,12 @@ namespace OpenSim.Region.Framework.Scenes List avs = ParentGroup.GetLinkedAvatars(); foreach (ScenePresence av in avs) { - av.SendFullUpdateToAllClients(); + if (av.LinkedPrim == m_uuid) + { + Vector3 offset = (m_offsetPosition - oldpos); + av.OffsetPosition += offset; + av.SendFullUpdateToAllClients(); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5fcd1c2..44c3d12 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -595,11 +595,21 @@ namespace OpenSim.Region.Framework.Scenes private uint m_parentID; + + private UUID m_linkedPrim; + public uint ParentID { get { return m_parentID; } set { m_parentID = value; } } + + public UUID LinkedPrim + { + get { return m_linkedPrim; } + set { m_linkedPrim = value; } + } + public float Health { get { return m_health; } @@ -1835,6 +1845,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentPosition = Vector3.Zero; m_parentID = 0; + m_linkedPrim = UUID.Zero; m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); SendFullUpdateToAllClients(); m_requestedSitTargetID = 0; @@ -2422,6 +2433,8 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); m_parentID = m_requestedSitTargetID; } + m_linkedPrim = part.UUID; + Velocity = Vector3.Zero; RemoveFromPhysicalScene(); -- cgit v1.1 From c48be64d9ab82676a2c1894193db42f0a849ae4d Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Aug 2010 16:08:50 +0200 Subject: Remove posting region restart event from SOP, as it's now in XMRe --- .../Region/Framework/Scenes/SceneObjectPartInventory.cs | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4f80a7e..8b4f0ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -321,22 +321,6 @@ namespace OpenSim.Region.Framework.Scenes StoreScriptErrors(item.ItemID, null); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); - - //This should play nice with XEngine since XEngine loads scripts /after/ the region starts - if (stateSource == 0 && m_part.ParentGroup.Scene.LoginsDisabled == true) - { - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - if (engines != null) - { - foreach (IScriptModule xengine in engines) - { - if (xengine != null) - { - xengine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.REGION_RESTART }); - } - } - } - } } } } -- cgit v1.1 From 330343505ca2d6d109e89b4767f4351ab9bec91d Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 6 Aug 2010 11:39:10 -0700 Subject: Implement CreateNewOutfitAttachments. This addresses mantis #199. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 20 ++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 1 + 2 files changed, 21 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 59731f7..17159b4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -648,6 +648,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + if (newName == null) newName = item.Name; + AssetBase asset = AssetService.Get(item.AssetID.ToString()); if (asset != null) @@ -695,6 +697,24 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) + /// + public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List items, UUID destfolder) + { + List moveitems = new List(); + foreach (InventoryItemBase b in items) + { + CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); + InventoryItemBase n = InventoryService.GetItem(b); + n.Folder = destfolder; + moveitems.Add(n); + remoteClient.SendInventoryItemCreateUpdate(n, 0); + } + + MoveInventoryItem(remoteClient, moveitems); + } + + /// /// Move an item within the agent's inventory. /// /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 644fbb0..ea52ffb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2922,6 +2922,7 @@ namespace OpenSim.Region.Framework.Scenes client.OnFetchInventory += HandleFetchInventory; client.OnUpdateInventoryItem += UpdateInventoryItemAsset; client.OnCopyInventoryItem += CopyInventoryItem; + client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; client.OnMoveInventoryItem += MoveInventoryItem; client.OnRemoveInventoryItem += RemoveInventoryItem; client.OnRemoveInventoryFolder += RemoveInventoryFolder; -- cgit v1.1 From 4f80d75bf3fa6de226203c6752e7a8e53fda8108 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 7 Aug 2010 06:28:04 -0700 Subject: Add a CHANGED_POSITION event so scripts don't have to run expensive loops to check for position changes --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8ce79a2..cac3df6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -476,6 +476,7 @@ namespace OpenSim.Region.Framework.Scenes part.IgnoreUndoUpdate = false; part.StoreUndoState(UndoType.STATE_GROUP_POSITION); part.GroupPosition = val; + part.TriggerScriptChangedEvent(Changed.POSITION); } foreach (ScenePresence av in m_linkedAvatars) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index efdc19c..d544619 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -60,7 +60,8 @@ namespace OpenSim.Region.Framework.Scenes TELEPORT = 512, REGION_RESTART = 1024, MEDIA = 2048, - ANIMATION = 16384 + ANIMATION = 16384, + POSITION = 32768 } // I don't really know where to put this except here. @@ -730,6 +731,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + TriggerScriptChangedEvent(Changed.POSITION); } } -- cgit v1.1 From 00cc42a607c59add54af3c1113162576e6109e41 Mon Sep 17 00:00:00 2001 From: sacha Date: Sat, 7 Aug 2010 13:40:38 +0000 Subject: and another endless debug cleaning --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8ce79a2..0dc63ef 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1734,9 +1734,9 @@ namespace OpenSim.Region.Framework.Scenes // don't backup while it's selected or you're asking for changes mid stream. if ((isTimeToPersist()) || (forcedBackup)) { - m_log.DebugFormat( - "[SCENE]: Storing {0}, {1} in {2}", - Name, UUID, m_scene.RegionInfo.RegionName); + // m_log.DebugFormat( + // "[SCENE]: Storing {0}, {1} in {2}", + // Name, UUID, m_scene.RegionInfo.RegionName); SceneObjectGroup backup_group = Copy(false); backup_group.RootPart.Velocity = RootPart.Velocity; -- cgit v1.1 From 413b0525db81ebc39a3a79cc2763553058056a5c Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 11:06:07 -0700 Subject: It seems hippo disregards velocities in full updates, so also send a terse update when an agent sits to avoid drifting off --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8656 +++++++++++----------- 1 file changed, 4328 insertions(+), 4328 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b3fa2f4..882f4a7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1,4328 +1,4328 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Xml; -using System.Collections.Generic; -using System.Reflection; -using System.Timers; -using OpenMetaverse; -using log4net; -using OpenSim.Framework; -using OpenSim.Framework.Client; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes.Animation; -using OpenSim.Region.Framework.Scenes.Types; -using OpenSim.Region.Physics.Manager; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.Framework.Scenes -{ - enum ScriptControlled : uint - { - CONTROL_ZERO = 0, - CONTROL_FWD = 1, - CONTROL_BACK = 2, - CONTROL_LEFT = 4, - CONTROL_RIGHT = 8, - CONTROL_UP = 16, - CONTROL_DOWN = 32, - CONTROL_ROT_LEFT = 256, - CONTROL_ROT_RIGHT = 512, - CONTROL_LBUTTON = 268435456, - CONTROL_ML_LBUTTON = 1073741824 - } - - struct ScriptControllers - { - public UUID itemID; - public ScriptControlled ignoreControls; - public ScriptControlled eventControls; - } - - public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs); - - public class ScenePresence : EntityBase, ISceneEntity - { -// ~ScenePresence() -// { -// m_log.Debug("[ScenePresence] Destructor called"); -// } - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; -// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); - private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); - private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); - - /// - /// Experimentally determined "fudge factor" to make sit-target positions - /// the same as in SecondLife. Fudge factor was tested for 36 different - /// test cases including prims of type box, sphere, cylinder, and torus, - /// with varying parameters for sit target location, prim size, prim - /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis - /// issue #1716 - /// -// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); - // Value revised by KF 091121 by comparison with SL. - private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); - - public UUID currentParcelUUID = UUID.Zero; - - private ISceneViewer m_sceneViewer; - - /// - /// The animator for this avatar - /// - public ScenePresenceAnimator Animator - { - get { return m_animator; } - } - protected ScenePresenceAnimator m_animator; - - /// - /// The scene objects attached to this avatar. Do not change this list directly - use methods such as - /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. - /// - public List Attachments - { - get { return m_attachments; } - } - protected List m_attachments = new List(); - - private Dictionary scriptedcontrols = new Dictionary(); - private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; - private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; - private bool MouseDown = false; - private SceneObjectGroup proxyObjectGroup; - //private SceneObjectPart proxyObjectPart = null; - public Vector3 lastKnownAllowedPosition; - public bool sentMessageAboutRestrictedParcelFlyingDown; - public Vector4 CollisionPlane = Vector4.UnitW; - - private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation - private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; - private Vector3 m_lastWorldPosition; - private Quaternion m_lastRotation; - private Vector3 m_lastVelocity; - //private int m_lastTerseSent; - - private bool m_updateflag; - private byte m_movementflag; - private Vector3? m_forceToApply; - private uint m_requestedSitTargetID; - private UUID m_requestedSitTargetUUID; - public bool SitGround = false; - - private SendCourseLocationsMethod m_sendCourseLocationsMethod; - - private bool m_startAnimationSet; - - //private Vector3 m_requestedSitOffset = new Vector3(); - - private Vector3 m_LastFinitePos; - - private float m_sitAvatarHeight = 2.0f; - - private int m_godLevel; - private int m_userLevel; - - private bool m_invulnerable = true; - - private Vector3 m_lastChildAgentUpdatePosition; - private Vector3 m_lastChildAgentUpdateCamPosition; - - private int m_perfMonMS; - - private bool m_setAlwaysRun; - private bool m_forceFly; - private bool m_flyDisabled; - - private float m_speedModifier = 1.0f; - - private Quaternion m_bodyRot= Quaternion.Identity; - - private Quaternion m_bodyRotPrevious = Quaternion.Identity; - - private const int LAND_VELOCITYMAG_MAX = 12; - - public bool IsRestrictedToRegion; - - public string JID = String.Empty; - - private float m_health = 100f; - - // Default AV Height - private float m_avHeight = 127.0f; - - protected RegionInfo m_regionInfo; - protected ulong crossingFromRegion; - - private readonly Vector3[] Dir_Vectors = new Vector3[11]; - private bool m_isNudging = false; - - // Position of agent's camera in world (region cordinates) - protected Vector3 m_CameraCenter; - protected Vector3 m_lastCameraCenter; - - protected Timer m_reprioritization_timer; - protected bool m_reprioritizing; - protected bool m_reprioritization_called; - - // Use these three vectors to figure out what the agent is looking at - // Convert it to a Matrix and/or Quaternion - protected Vector3 m_CameraAtAxis; - protected Vector3 m_CameraLeftAxis; - protected Vector3 m_CameraUpAxis; - private AgentManager.ControlFlags m_AgentControlFlags; - private Quaternion m_headrotation = Quaternion.Identity; - private byte m_state; - - //Reuse the Vector3 instead of creating a new one on the UpdateMovement method -// private Vector3 movementvector; - - private bool m_autopilotMoving; - private Vector3 m_autoPilotTarget; - private bool m_sitAtAutoTarget; - private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit - - private string m_nextSitAnimation = String.Empty; - - //PauPaw:Proper PID Controler for autopilot************ - private bool m_moveToPositionInProgress; - private Vector3 m_moveToPositionTarget; - private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - - private bool m_followCamAuto; - - private int m_movementUpdateCount; - private int m_lastColCount = -1; //KF: Look for Collision chnages - private int m_updateCount = 0; //KF: Update Anims for a while - private static readonly int UPDATE_COUNT = 10; // how many frames to update for - private const int NumMovementsBetweenRayCast = 5; - private List m_lastColliders = new List(); - - private bool CameraConstraintActive; - //private int m_moveToPositionStateStatus; - //***************************************************** - - // Agent's Draw distance. - protected float m_DrawDistance; - - protected AvatarAppearance m_appearance; - - // neighbouring regions we have enabled a child agent in - // holds the seed cap for the child agent in that region - private Dictionary m_knownChildRegions = new Dictionary(); - - /// - /// Implemented Control Flags - /// - private enum Dir_ControlFlags - { - DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, - DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, - DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, - DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, - DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, - DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, - DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, - DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, - DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, - DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, - DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG - } - - /// - /// Position at which a significant movement was made - /// - private Vector3 posLastSignificantMove; - - // For teleports and crossings callbacks - string m_callbackURI; - UUID m_originRegionID; - - ulong m_rootRegionHandle; - - /// - /// Script engines present in the scene - /// - private IScriptModule[] m_scriptEngines; - - #region Properties - - /// - /// Physical scene representation of this Avatar. - /// - public PhysicsActor PhysicsActor - { - set { m_physicsActor = value; } - get { return m_physicsActor; } - } - - public byte MovementFlag - { - set { m_movementflag = value; } - get { return m_movementflag; } - } - - public bool Updated - { - set { m_updateflag = value; } - get { return m_updateflag; } - } - - public bool Invulnerable - { - set { m_invulnerable = value; } - get { return m_invulnerable; } - } - - public int UserLevel - { - get { return m_userLevel; } - } - - public int GodLevel - { - get { return m_godLevel; } - } - - public ulong RegionHandle - { - get { return m_rootRegionHandle; } - } - - public Vector3 CameraPosition - { - get { return m_CameraCenter; } - } - - public Quaternion CameraRotation - { - get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } - } - - public Vector3 CameraAtAxis - { - get { return m_CameraAtAxis; } - } - - public Vector3 CameraLeftAxis - { - get { return m_CameraLeftAxis; } - } - - public Vector3 CameraUpAxis - { - get { return m_CameraUpAxis; } - } - - public Vector3 Lookat - { - get - { - Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); - - if (a == Vector3.Zero) - return a; - - return Util.GetNormalizedVector(a); - } - } - - private readonly string m_firstname; - - public string Firstname - { - get { return m_firstname; } - } - - private readonly string m_lastname; - - public string Lastname - { - get { return m_lastname; } - } - - private string m_grouptitle; - - public string Grouptitle - { - get { return m_grouptitle; } - set { m_grouptitle = value; } - } - - public float DrawDistance - { - get { return m_DrawDistance; } - } - - protected bool m_allowMovement = true; - - public bool AllowMovement - { - get { return m_allowMovement; } - set { m_allowMovement = value; } - } - - public bool SetAlwaysRun - { - get - { - if (PhysicsActor != null) - { - return PhysicsActor.SetAlwaysRun; - } - else - { - return m_setAlwaysRun; - } - } - set - { - m_setAlwaysRun = value; - if (PhysicsActor != null) - { - PhysicsActor.SetAlwaysRun = value; - } - } - } - - public byte State - { - get { return m_state; } - set { m_state = value; } - } - - public uint AgentControlFlags - { - get { return (uint)m_AgentControlFlags; } - set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } - } - - /// - /// This works out to be the ClientView object associated with this avatar, or it's client connection manager - /// - private IClientAPI m_controllingClient; - - protected PhysicsActor m_physicsActor; - - /// - /// The client controlling this presence - /// - public IClientAPI ControllingClient - { - get { return m_controllingClient; } - } - - public IClientCore ClientView - { - get { return (IClientCore) m_controllingClient; } - } - - protected Vector3 m_parentPosition; - public Vector3 ParentPosition - { - get { return m_parentPosition; } - set { m_parentPosition = value; } - } - - /// - /// Position of this avatar relative to the region the avatar is in - /// - public override Vector3 AbsolutePosition - { - get - { - PhysicsActor actor = m_physicsActor; -// if (actor != null) - if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! - m_pos = actor.Position; - - // If we're sitting, we need to update our position - if (m_parentID != 0) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); - if (part != null) - m_parentPosition = part.AbsolutePosition; - } - - return m_parentPosition + m_pos; - } - set - { - PhysicsActor actor = m_physicsActor; - if (actor != null) - { - try - { - lock (m_scene.SyncRoot) - m_physicsActor.Position = value; - } - catch (Exception e) - { - m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); - } - } - - if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! - m_pos = value; - m_parentPosition = Vector3.Zero; - } - } - - public Vector3 OffsetPosition - { - get { return m_pos; } - set { m_pos = value; } - } - - /// - /// Current velocity of the avatar. - /// - public override Vector3 Velocity - { - get - { - PhysicsActor actor = m_physicsActor; - if (actor != null) - m_velocity = actor.Velocity; - - return m_velocity; - } - set - { - PhysicsActor actor = m_physicsActor; - if (actor != null) - { - try - { - lock (m_scene.SyncRoot) - actor.Velocity = value; - } - catch (Exception e) - { - m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); - } - } - - m_velocity = value; - } - } - - public Quaternion OffsetRotation - { - get { return m_offsetRotation; } - set { m_offsetRotation = value; } - } - - public Quaternion Rotation - { - get { - if (m_parentID != 0) - { - if (m_offsetRotation != null) - { - return m_offsetRotation; - } - else - { - return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - - } - else - { - return m_bodyRot; - } - } - set { - m_bodyRot = value; - if (m_parentID != 0) - { - m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - } - } - - public Quaternion PreviousRotation - { - get { return m_bodyRotPrevious; } - set { m_bodyRotPrevious = value; } - } - - /// - /// If this is true, agent doesn't have a representation in this scene. - /// this is an agent 'looking into' this scene from a nearby scene(region) - /// - /// if False, this agent has a representation in this scene - /// - private bool m_isChildAgent = true; - - public bool IsChildAgent - { - get { return m_isChildAgent; } - set { m_isChildAgent = value; } - } - - private uint m_parentID; - - - private UUID m_linkedPrim; - - public uint ParentID - { - get { return m_parentID; } - set { m_parentID = value; } - } - - public UUID LinkedPrim - { - get { return m_linkedPrim; } - set { m_linkedPrim = value; } - } - - public float Health - { - get { return m_health; } - set { m_health = value; } - } - - /// - /// These are the region handles known by the avatar. - /// - public List KnownChildRegionHandles - { - get - { - if (m_knownChildRegions.Count == 0) - return new List(); - else - return new List(m_knownChildRegions.Keys); - } - } - - public Dictionary KnownRegions - { - get { return m_knownChildRegions; } - set - { - m_knownChildRegions = value; - } - } - - public ISceneViewer SceneViewer - { - get { return m_sceneViewer; } - } - - public void AdjustKnownSeeds() - { - Dictionary seeds; - - if (Scene.CapsModule != null) - seeds = Scene.CapsModule.GetChildrenSeeds(UUID); - else - seeds = new Dictionary(); - - List old = new List(); - foreach (ulong handle in seeds.Keys) - { - uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) - { - old.Add(handle); - } - } - DropOldNeighbours(old); - - if (Scene.CapsModule != null) - Scene.CapsModule.SetChildrenSeed(UUID, seeds); - - KnownRegions = seeds; - //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); - //DumpKnownRegions(); - } - - public void DumpKnownRegions() - { - m_log.Info("================ KnownRegions "+Scene.RegionInfo.RegionName+" ================"); - foreach (KeyValuePair kvp in KnownRegions) - { - uint x, y; - Utils.LongToUInts(kvp.Key, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - m_log.Info(" >> "+x+", "+y+": "+kvp.Value); - } - } - - private bool m_inTransit; - private bool m_mouseLook; - private bool m_leftButtonDown; - - public bool IsInTransit - { - get { return m_inTransit; } - set { m_inTransit = value; } - } - - public float SpeedModifier - { - get { return m_speedModifier; } - set { m_speedModifier = value; } - } - - public bool ForceFly - { - get { return m_forceFly; } - set { m_forceFly = value; } - } - - public bool FlyDisabled - { - get { return m_flyDisabled; } - set { m_flyDisabled = value; } - } - - public string Viewer - { - get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } - } - - #endregion - - #region Constructor(s) - - public ScenePresence() - { - m_sendCourseLocationsMethod = SendCoarseLocationsDefault; - CreateSceneViewer(); - m_animator = new ScenePresenceAnimator(this); - } - - private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() - { - m_rootRegionHandle = reginfo.RegionHandle; - m_controllingClient = client; - m_firstname = m_controllingClient.FirstName; - m_lastname = m_controllingClient.LastName; - m_name = String.Format("{0} {1}", m_firstname, m_lastname); - m_scene = world; - m_uuid = client.AgentId; - m_regionInfo = reginfo; - m_localId = m_scene.AllocateLocalId(); - - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); - - if (account != null) - m_userLevel = account.UserLevel; - - IGroupsModule gm = m_scene.RequestModuleInterface(); - if (gm != null) - m_grouptitle = gm.GetGroupTitle(m_uuid); - - m_scriptEngines = m_scene.RequestModuleInterfaces(); - - AbsolutePosition = posLastSignificantMove = m_CameraCenter = - m_lastCameraCenter = m_controllingClient.StartPos; - - m_reprioritization_timer = new Timer(world.ReprioritizationInterval); - m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); - m_reprioritization_timer.AutoReset = false; - - AdjustKnownSeeds(); - Animator.TrySetMovementAnimation("STAND"); - // we created a new ScenePresence (a new child agent) in a fresh region. - // Request info about all the (root) agents in this region - // Note: This won't send data *to* other clients in that region (children don't send) - SendInitialFullUpdateToAllClients(); - RegisterToEvents(); - if (m_controllingClient != null) - { - m_controllingClient.ProcessPendingPackets(); - } - SetDirectionVectors(); - } - - public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, - AvatarWearable[] wearables) - : this(client, world, reginfo) - { - m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); - } - - public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) - : this(client, world, reginfo) - { - m_appearance = appearance; - } - - private void CreateSceneViewer() - { - m_sceneViewer = new SceneViewer(this); - } - - public void RegisterToEvents() - { - m_controllingClient.OnRequestWearables += SendWearables; - m_controllingClient.OnSetAppearance += SetAppearance; - m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; - //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; - m_controllingClient.OnAgentUpdate += HandleAgentUpdate; - m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; - m_controllingClient.OnAgentSit += HandleAgentSit; - m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; - m_controllingClient.OnStartAnim += HandleStartAnim; - m_controllingClient.OnStopAnim += HandleStopAnim; - m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; - m_controllingClient.OnAutoPilotGo += DoAutoPilot; - m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); - - // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); - // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - } - - private void SetDirectionVectors() - { - Dir_Vectors[0] = Vector3.UnitX; //FORWARD - Dir_Vectors[1] = -Vector3.UnitX; //BACK - Dir_Vectors[2] = Vector3.UnitY; //LEFT - Dir_Vectors[3] = -Vector3.UnitY; //RIGHT - Dir_Vectors[4] = Vector3.UnitZ; //UP - Dir_Vectors[5] = -Vector3.UnitZ; //DOWN - Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE - Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE - Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE - Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE - Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge - } - - private Vector3[] GetWalkDirectionVectors() - { - Vector3[] vector = new Vector3[11]; - vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD - vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK - vector[2] = Vector3.UnitY; //LEFT - vector[3] = -Vector3.UnitY; //RIGHT - vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP - vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN - vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE - vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE - vector[8] = Vector3.UnitY; //LEFT_NUDGE - vector[9] = -Vector3.UnitY; //RIGHT_NUDGE - vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE - return vector; - } - - private bool[] GetDirectionIsNudge() - { - bool[] isNudge = new bool[11]; - isNudge[0] = false; //FORWARD - isNudge[1] = false; //BACK - isNudge[2] = false; //LEFT - isNudge[3] = false; //RIGHT - isNudge[4] = false; //UP - isNudge[5] = false; //DOWN - isNudge[6] = true; //FORWARD_NUDGE - isNudge[7] = true; //BACK_NUDGE - isNudge[8] = true; //LEFT_NUDGE - isNudge[9] = true; //RIGHT_NUDGE - isNudge[10] = true; //DOWN_Nudge - return isNudge; - } - - - #endregion - - public uint GenerateClientFlags(UUID ObjectID) - { - return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); - } - - /// - /// Send updates to the client about prims which have been placed on the update queue. We don't - /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent - /// timestamp has already been sent. - /// - public void SendPrimUpdates() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_sceneViewer.SendPrimUpdates(); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - #region Status Methods - - /// - /// This turns a child agent, into a root agent - /// This is called when an agent teleports into a region, or if an - /// agent crosses into this region from a neighbor over the border - /// - public void MakeRootAgent(Vector3 pos, bool isFlying) - { - m_log.DebugFormat( - "[SCENE]: Upgrading child to root agent for {0} in {1}", - Name, m_scene.RegionInfo.RegionName); - - //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); - - IGroupsModule gm = m_scene.RequestModuleInterface(); - if (gm != null) - m_grouptitle = gm.GetGroupTitle(m_uuid); - - m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; - m_scene.SetRootAgentScene(m_uuid); - - // Moved this from SendInitialData to ensure that m_appearance is initialized - // before the inventory is processed in MakeRootAgent. This fixes a race condition - // related to the handling of attachments - //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - if (m_scene.TestBorderCross(pos, Cardinals.E)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); - pos.X = crossedBorder.BorderLine.Z - 1; - } - - if (m_scene.TestBorderCross(pos, Cardinals.N)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); - pos.Y = crossedBorder.BorderLine.Z - 1; - } - - //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. - //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, - //they'll bypass the landing point. But I can't think of any decent way of fixing this. - if (KnownChildRegionHandles.Count == 0) - { - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) - { - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) - { - pos = land.LandData.UserLocation; - } - } - } - - if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) - { - Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); - - if (pos.X < 0) - { - emergencyPos.X = (int)Constants.RegionSize + pos.X; - if (!(pos.Y < 0)) - emergencyPos.Y = pos.Y; - if (!(pos.Z < 0)) - emergencyPos.Z = pos.Z; - } - if (pos.Y < 0) - { - emergencyPos.Y = (int)Constants.RegionSize + pos.Y; - if (!(pos.X < 0)) - emergencyPos.X = pos.X; - if (!(pos.Z < 0)) - emergencyPos.Z = pos.Z; - } - if (pos.Z < 0) - { - emergencyPos.Z = 128; - if (!(pos.Y < 0)) - emergencyPos.Y = pos.Y; - if (!(pos.X < 0)) - emergencyPos.X = pos.X; - } - } - - if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) - { - m_log.WarnFormat( - "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", - pos, Name, UUID); - - if (pos.X < 0f) pos.X = 0f; - if (pos.Y < 0f) pos.Y = 0f; - if (pos.Z < 0f) pos.Z = 0f; - } - - float localAVHeight = 1.56f; - if (m_avHeight != 127.0f) - { - localAVHeight = m_avHeight; - } - - float posZLimit = 0; - - if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) - posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; - - float newPosZ = posZLimit + localAVHeight / 2; - if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - pos.Z = newPosZ; - } - AbsolutePosition = pos; - - AddToPhysicalScene(isFlying); - - if (m_forceFly) - { - m_physicsActor.Flying = true; - } - else if (m_flyDisabled) - { - m_physicsActor.Flying = false; - } - - if (m_appearance != null) - { - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - } - else - { - m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); - // emergency; this really shouldn't happen - m_appearance = new AvatarAppearance(UUID); - } - - // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying - // avatar to return to the standing position in mid-air. On login it looks like this is being sent - // elsewhere anyway - // Animator.SendAnimPack(); - - m_scene.SwapRootAgentCount(false); - - //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); - //if (userInfo != null) - // userInfo.FetchInventory(); - //else - // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); - - // On the next prim update, all objects will be sent - // - m_sceneViewer.Reset(); - - m_isChildAgent = false; - - // send the animations of the other presences to me - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - if (presence != this) - presence.Animator.SendAnimPackToClient(ControllingClient); - }); - - m_scene.EventManager.TriggerOnMakeRootAgent(this); - } - - /// - /// This turns a root agent into a child agent - /// when an agent departs this region for a neighbor, this gets called. - /// - /// It doesn't get called for a teleport. Reason being, an agent that - /// teleports out may not end up anywhere near this region - /// - public void MakeChildAgent() - { - // It looks like m_animator is set to null somewhere, and MakeChild - // is called after that. Probably in aborted teleports. - if (m_animator == null) - m_animator = new ScenePresenceAnimator(this); - else - Animator.ResetAnimations(); - -// m_log.DebugFormat( -// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", -// Name, UUID, m_scene.RegionInfo.RegionName); - - // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, - // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. - //Velocity = new Vector3(0, 0, 0); - - m_isChildAgent = true; - m_scene.SwapRootAgentCount(true); - RemoveFromPhysicalScene(); - - // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into - - m_scene.EventManager.TriggerOnMakeChildAgent(this); - } - - /// - /// Removes physics plugin scene representation of this agent if it exists. - /// - private void RemoveFromPhysicalScene() - { - if (PhysicsActor != null) - { - m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; - m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - m_physicsActor.UnSubscribeEvents(); - m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; - PhysicsActor = null; - } - } - - /// - /// - /// - /// - public void Teleport(Vector3 pos) - { - bool isFlying = false; - - if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - - RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - AbsolutePosition = pos; - AddToPhysicalScene(isFlying); - if (m_appearance != null) - { - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - } - - SendTerseUpdateToAllClients(); - - } - - public void TeleportWithMomentum(Vector3 pos) - { - bool isFlying = false; - if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - - RemoveFromPhysicalScene(); - AbsolutePosition = pos; - AddToPhysicalScene(isFlying); - if (m_appearance != null) - { - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - } - - SendTerseUpdateToAllClients(); - } - - /// - /// - /// - public void StopMovement() - { - } - - public void StopFlying() - { - ControllingClient.StopFlying(this); - } - - public void AddNeighbourRegion(ulong regionHandle, string cap) - { - lock (m_knownChildRegions) - { - if (!m_knownChildRegions.ContainsKey(regionHandle)) - { - uint x, y; - Utils.LongToUInts(regionHandle, out x, out y); - m_knownChildRegions.Add(regionHandle, cap); - } - } - } - - public void RemoveNeighbourRegion(ulong regionHandle) - { - lock (m_knownChildRegions) - { - if (m_knownChildRegions.ContainsKey(regionHandle)) - { - m_knownChildRegions.Remove(regionHandle); - //m_log.Debug(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); - } - } - } - - public void DropOldNeighbours(List oldRegions) - { - foreach (ulong handle in oldRegions) - { - RemoveNeighbourRegion(handle); - Scene.CapsModule.DropChildSeed(UUID, handle); - } - } - - public List GetKnownRegionList() - { - return new List(m_knownChildRegions.Keys); - } - - #endregion - - #region Event Handlers - - /// - /// Sets avatar height in the phyiscs plugin - /// - internal void SetHeight(float height) - { - m_avHeight = height; - if (PhysicsActor != null && !IsChildAgent) - { - Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); - PhysicsActor.Size = SetSize; - } - } - - /// - /// Complete Avatar's movement into the region. - /// This is called upon a very important packet sent from the client, - /// so it's client-controlled. Never call this method directly. - /// - public void CompleteMovement(IClientAPI client) - { - //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); - - Vector3 look = Velocity; - if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) - { - look = new Vector3(0.99f, 0.042f, 0); - } - - // Prevent teleporting to an underground location - // (may crash client otherwise) - // - Vector3 pos = AbsolutePosition; - float ground = m_scene.GetGroundHeight(pos.X, pos.Y); - if (pos.Z < ground + 1.5f) - { - pos.Z = ground + 1.5f; - AbsolutePosition = pos; - } - m_isChildAgent = false; - bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); - MakeRootAgent(AbsolutePosition, m_flying); - - if ((m_callbackURI != null) && !m_callbackURI.Equals("")) - { - m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); - Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); - m_callbackURI = null; - } - - //m_log.DebugFormat("Completed movement"); - - m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); - SendInitialData(); - - // Create child agents in neighbouring regions - if (!m_isChildAgent) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); - else - m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); - - IFriendsModule friendsModule = m_scene.RequestModuleInterface(); - if (friendsModule != null) - friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); - } - - } - - /// - /// Callback for the Camera view block check. Gets called with the results of the camera view block test - /// hitYN is true when there's something in the way. - /// - /// - /// - /// - /// - public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) - { - const float POSITION_TOLERANCE = 0.02f; - const float VELOCITY_TOLERANCE = 0.02f; - const float ROTATION_TOLERANCE = 0.02f; - - if (m_followCamAuto) - { - if (hitYN) - { - CameraConstraintActive = true; - //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); - - Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); - ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); - } - else - { - if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) - { - if (CameraConstraintActive) - { - ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); - CameraConstraintActive = false; - } - } - } - } - } - - /// - /// This is the event handler for client movement. If a client is moving, this event is triggering. - /// - public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) - { - //if (m_isChildAgent) - //{ - // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); - // return; - //} - - m_perfMonMS = Util.EnvironmentTickCount(); - - ++m_movementUpdateCount; - if (m_movementUpdateCount < 1) - m_movementUpdateCount = 1; - - #region Sanity Checking - - // This is irritating. Really. - if (!AbsolutePosition.IsFinite()) - { - RemoveFromPhysicalScene(); - m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); - - m_pos = m_LastFinitePos; - - if (!m_pos.IsFinite()) - { - m_pos.X = 127f; - m_pos.Y = 127f; - m_pos.Z = 127f; - m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); - } - - AddToPhysicalScene(false); - } - else - { - m_LastFinitePos = m_pos; - } - - #endregion Sanity Checking - - #region Inputs - - AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; - Quaternion bodyRotation = agentData.BodyRotation; - - // Camera location in world. We'll need to raytrace - // from this location from time to time. - m_CameraCenter = agentData.CameraCenter; - if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) - { - ReprioritizeUpdates(); - m_lastCameraCenter = m_CameraCenter; - } - - // Use these three vectors to figure out what the agent is looking at - // Convert it to a Matrix and/or Quaternion - m_CameraAtAxis = agentData.CameraAtAxis; - m_CameraLeftAxis = agentData.CameraLeftAxis; - m_CameraUpAxis = agentData.CameraUpAxis; - - // The Agent's Draw distance setting - m_DrawDistance = agentData.Far; - - // Check if Client has camera in 'follow cam' or 'build' mode. - Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); - - m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) - && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; - - m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; - m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; - - #endregion Inputs - - if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) - { - StandUp(); - } - - //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); - // Raycast from the avatar's head to the camera to see if there's anything blocking the view - if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) - { - if (m_followCamAuto) - { - Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; - m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); - } - } - lock (scriptedcontrols) - { - if (scriptedcontrols.Count > 0) - { - SendControlToScripts((uint)flags); - flags = RemoveIgnoredControls(flags, IgnoredControls); - } - } - - if (m_autopilotMoving) - CheckAtSitTarget(); - - if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) - { - m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. - Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); - - // TODO: This doesn't prevent the user from walking yet. - // Setting parent ID would fix this, if we knew what value - // to use. Or we could add a m_isSitting variable. - //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); - SitGround = true; - } - - // In the future, these values might need to go global. - // Here's where you get them. - m_AgentControlFlags = flags; - m_headrotation = agentData.HeadRotation; - m_state = agentData.State; - - PhysicsActor actor = PhysicsActor; - if (actor == null) - { - return; - } - - bool update_movementflag = false; - - if (m_allowMovement && !SitGround) - { - if (agentData.UseClientAgentPosition) - { - m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; - m_moveToPositionTarget = agentData.ClientAgentPosition; - } - - int i = 0; - - bool update_rotation = false; - bool DCFlagKeyPressed = false; - Vector3 agent_control_v3 = Vector3.Zero; - Quaternion q = bodyRotation; - - bool oldflying = PhysicsActor.Flying; - - if (m_forceFly) - actor.Flying = true; - else if (m_flyDisabled) - actor.Flying = false; - else - actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); - - if (actor.Flying != oldflying) - update_movementflag = true; - - if (q != m_bodyRot) - { - m_bodyRot = q; - update_rotation = true; - } - - //guilty until proven innocent.. - bool Nudging = true; - //Basically, if there is at least one non-nudge control then we don't need - //to worry about stopping the avatar - - if (m_parentID == 0) - { - bool bAllowUpdateMoveToPosition = false; - bool bResetMoveToPosition = false; - - Vector3[] dirVectors; - - // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying - // this prevents 'jumping' in inappropriate situations. - if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) - dirVectors = GetWalkDirectionVectors(); - else - dirVectors = Dir_Vectors; - - bool[] isNudge = GetDirectionIsNudge(); - - - - - - foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) - { - if (((uint)flags & (uint)DCF) != 0) - { - bResetMoveToPosition = true; - DCFlagKeyPressed = true; - try - { - agent_control_v3 += dirVectors[i]; - if (isNudge[i] == false) - { - Nudging = false; - } - } - catch (IndexOutOfRangeException) - { - // Why did I get this? - } - - if ((m_movementflag & (uint)DCF) == 0) - { - m_movementflag += (byte)(uint)DCF; - update_movementflag = true; - } - } - else - { - if ((m_movementflag & (uint)DCF) != 0) - { - m_movementflag -= (byte)(uint)DCF; - update_movementflag = true; - } - else - { - bAllowUpdateMoveToPosition = true; - } - } - i++; - } - //Paupaw:Do Proper PID for Autopilot here - if (bResetMoveToPosition) - { - m_moveToPositionTarget = Vector3.Zero; - m_moveToPositionInProgress = false; - update_movementflag = true; - bAllowUpdateMoveToPosition = false; - } - - if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) - { - //Check the error term of the current position in relation to the target position - if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) - { - // we are close enough to the target - m_moveToPositionTarget = Vector3.Zero; - m_moveToPositionInProgress = false; - update_movementflag = true; - } - else - { - try - { - // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. - // This movement vector gets added to the velocity through AddNewMovement(). - // Theoretically we might need a more complex PID approach here if other - // unknown forces are acting on the avatar and we need to adaptively respond - // to such forces, but the following simple approach seems to works fine. - Vector3 LocalVectorToTarget3D = - (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords - * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords - // Ignore z component of vector - Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); - LocalVectorToTarget2D.Normalize(); - - //We're not nudging - Nudging = false; - agent_control_v3 += LocalVectorToTarget2D; - - // update avatar movement flags. the avatar coordinate system is as follows: - // - // +X (forward) - // - // ^ - // | - // | - // | - // | - // (left) +Y <--------o--------> -Y - // avatar - // | - // | - // | - // | - // v - // -X - // - - // based on the above avatar coordinate system, classify the movement into - // one of left/right/back/forward. - if (LocalVectorToTarget2D.Y > 0)//MoveLeft - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; - //AgentControlFlags - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; - update_movementflag = true; - } - else if (LocalVectorToTarget2D.Y < 0) //MoveRight - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; - update_movementflag = true; - } - if (LocalVectorToTarget2D.X < 0) //MoveBack - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; - update_movementflag = true; - } - else if (LocalVectorToTarget2D.X > 0) //Move Forward - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; - update_movementflag = true; - } - } - catch (Exception e) - { - //Avoid system crash, can be slower but... - m_log.DebugFormat("Crash! {0}", e.ToString()); - } - } - } - } - - // Cause the avatar to stop flying if it's colliding - // with something with the down arrow pressed. - - // Only do this if we're flying - if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) - { - // Landing detection code - - // Are the landing controls requirements filled? - bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || - ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - - // Are the collision requirements fulfilled? - bool colliding = (m_physicsActor.IsColliding == true); - - if (m_physicsActor.Flying && colliding && controlland) - { - // nesting this check because LengthSquared() is expensive and we don't - // want to do it every step when flying. - if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) - StopFlying(); - } - } - - if (update_movementflag || (update_rotation && DCFlagKeyPressed)) - { - // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); - // m_log.DebugFormat( - // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); - - AddNewMovement(agent_control_v3, q, Nudging); - - - } - } - - if (update_movementflag && !SitGround) - Animator.UpdateMovementAnimations(); - - m_scene.EventManager.TriggerOnClientMovement(this); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) - { - m_autopilotMoving = true; - m_autoPilotTarget = Pos; - m_sitAtAutoTarget = false; - PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; - //proxy.PCode = (byte)PCode.ParticleSystem; - proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); - proxyObjectGroup.AttachToScene(m_scene); - - // Commented out this code since it could never have executed, but might still be informative. -// if (proxyObjectGroup != null) -// { - proxyObjectGroup.SendGroupFullUpdate(); - remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); - m_scene.DeleteSceneObject(proxyObjectGroup, false); -// } -// else -// { -// m_autopilotMoving = false; -// m_autoPilotTarget = Vector3.Zero; -// ControllingClient.SendAlertMessage("Autopilot cancelled"); -// } - } - - public void DoMoveToPosition(Object sender, string method, List args) - { - try - { - float locx = 0f; - float locy = 0f; - float locz = 0f; - uint regionX = 0; - uint regionY = 0; - try - { - Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); - locx = Convert.ToSingle(args[0]) - (float)regionX; - locy = Convert.ToSingle(args[1]) - (float)regionY; - locz = Convert.ToSingle(args[2]); - } - catch (InvalidCastException) - { - m_log.Error("[CLIENT]: Invalid autopilot request"); - return; - } - m_moveToPositionInProgress = true; - m_moveToPositionTarget = new Vector3(locx, locy, locz); - } - catch (Exception ex) - { - //Why did I get this error? - m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); - } - } - - private void CheckAtSitTarget() - { - //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); - if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) - { - if (m_sitAtAutoTarget) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); - if (part != null) - { - AbsolutePosition = part.AbsolutePosition; - Velocity = Vector3.Zero; - SendFullUpdateToAllClients(); - - HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? - } - //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); - m_requestedSitTargetUUID = UUID.Zero; - } - /* - else - { - //ControllingClient.SendAlertMessage("Autopilot cancelled"); - //SendTerseUpdateToAllClients(); - //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; - //proxy.PCode = (byte)PCode.ParticleSystem; - ////uint nextUUID = m_scene.NextLocalId; - - //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); - //if (proxyObjectGroup != null) - //{ - //proxyObjectGroup.SendGroupFullUpdate(); - //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); - //m_scene.DeleteSceneObject(proxyObjectGroup); - //} - } - */ - m_autoPilotTarget = Vector3.Zero; - m_autopilotMoving = false; - } - } - /// - /// Perform the logic necessary to stand the avatar up. This method also executes - /// the stand animation. - /// - public void StandUp() - { - SitGround = false; - - if (m_parentID != 0) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); - if (part != null) - { - part.TaskInventory.LockItemsForRead(true); - TaskInventoryDictionary taskIDict = part.TaskInventory; - if (taskIDict != null) - { - foreach (UUID taskID in taskIDict.Keys) - { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS - } - } - part.TaskInventory.LockItemsForRead(false); - // Reset sit target. - if (part.GetAvatarOnSitTarget() == UUID) - part.SetAvatarOnSitTarget(UUID.Zero); - m_parentPosition = part.GetWorldPosition(); - ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - } - // part.GetWorldRotation() is the rotation of the object being sat on - // Rotation is the sittiing Av's rotation - - Quaternion partRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partRot = part.ParentGroup.RootPart.RotationOffset; -// } -// else -// { // single or child prim - -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); - } - - Quaternion partIRot = Quaternion.Inverse(partRot); - - Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av - Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av - - - if (m_physicsActor == null) - { - AddToPhysicalScene(false); - } - //CW: If the part isn't null then we can set the current position - if (part != null) - { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - part.IsOccupied = false; - part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); - } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; - } - - m_parentPosition = Vector3.Zero; - m_parentID = 0; - m_linkedPrim = UUID.Zero; - m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - SendFullUpdateToAllClients(); - m_requestedSitTargetID = 0; - - if ((m_physicsActor != null) && (m_avHeight > 0)) - { - SetHeight(m_avHeight); - } - } - Animator.TrySetMovementAnimation("STAND"); - } - - private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) - { - SceneObjectPart targetPart = m_scene.GetSceneObjectPart(targetID); - if (targetPart == null) - return null; - - // If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used. - // If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used. - - // Get our own copy of the part array, and sort into the order we want to test - SceneObjectPart[] partArray = targetPart.ParentGroup.GetParts(); - Array.Sort(partArray, delegate(SceneObjectPart p1, SceneObjectPart p2) - { - // we want the originally selected part first, then the rest in link order -- so make the selected part link num (-1) - int linkNum1 = p1==targetPart ? -1 : p1.LinkNum; - int linkNum2 = p2==targetPart ? -1 : p2.LinkNum; - return linkNum1 - linkNum2; - } - ); - - //look for prims with explicit sit targets that are available - foreach (SceneObjectPart part in partArray) - { - // Is a sit target available? - Vector3 avSitOffSet = part.SitTargetPosition; - Quaternion avSitOrientation = part.SitTargetOrientation; - UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); - bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); - bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. - if (SitTargetisSet && !SitTargetOccupied) - { - //switch the target to this prim - return part; - } - } - - // no explicit sit target found - use original target - return targetPart; - } - - private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) - { - bool autopilot = true; - Vector3 autopilotTarget = new Vector3(); - Quaternion sitOrientation = Quaternion.Identity; - Vector3 pos = new Vector3(); - Vector3 cameraEyeOffset = Vector3.Zero; - Vector3 cameraAtOffset = Vector3.Zero; - bool forceMouselook = false; - - //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); - if (part == null) return; - - // TODO: determine position to sit at based on scene geometry; don't trust offset from client - // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - - // part is the prim to sit on - // offset is the world-ref vector distance from that prim center to the click-spot - // UUID is the UUID of the Avatar doing the clicking - - m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation - - // Is a sit target available? - Vector3 avSitOffSet = part.SitTargetPosition; - Quaternion avSitOrientation = part.SitTargetOrientation; - - bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. - // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); - Quaternion partRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partRot = part.ParentGroup.RootPart.RotationOffset; -// } -// else -// { // single or child prim - partRot = part.GetWorldRotation(); -// } - Quaternion partIRot = Quaternion.Inverse(partRot); -//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); - // Sit analysis rewritten by KF 091125 - if (SitTargetisSet) // scipted sit - { - if (!part.IsOccupied) - { -//Console.WriteLine("Scripted, unoccupied"); - part.SetAvatarOnSitTarget(UUID); // set that Av will be on it - offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one - - Quaternion nrot = avSitOrientation; - if (!part.IsRoot) - { - nrot = part.RotationOffset * avSitOrientation; - } - sitOrientation = nrot; // Change rotatione to the scripted one - OffsetRotation = nrot; - autopilot = false; // Jump direct to scripted llSitPos() - } - else - { -//Console.WriteLine("Scripted, occupied"); - return; - } - } - else // Not Scripted - { - if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) - { - // large prim & offset, ignore if other Avs sitting -// offset.Z -= 0.05f; - m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked - autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point - -//Console.WriteLine(" offset ={0}", offset); -//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); -//Console.WriteLine(" autopilotTarget={0}", autopilotTarget); - - } - else // small offset - { -//Console.WriteLine("Small offset"); - if (!part.IsOccupied) - { - m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center - autopilotTarget = part.AbsolutePosition; -//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); - } - else return; // occupied small - } // end large/small - } // end Scripted/not - cameraAtOffset = part.GetCameraAtOffset(); - cameraEyeOffset = part.GetCameraEyeOffset(); - forceMouselook = part.GetForceMouselook(); - if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // - if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // - - if (m_physicsActor != null) - { - // If we're not using the client autopilot, we're immediately warping the avatar to the location - // We can remove the physicsActor until they stand up. - m_sitAvatarHeight = m_physicsActor.Size.Z; - if (autopilot) - { // its not a scripted sit -// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) - if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) - { - autopilot = false; // close enough - m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. - Not using the part's position because returning the AV to the last known standing - position is likely to be more friendly, isn't it? */ - RemoveFromPhysicalScene(); - AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target - } // else the autopilot will get us close - } - else - { // its a scripted sit - m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. - I *am* using the part's position this time because we have no real idea how far away - the avatar is from the sit target. */ - RemoveFromPhysicalScene(); - } - } - else return; // physactor is null! - - Vector3 offsetr; // = offset * partIRot; - // KF: In a linkset, offsetr needs to be relative to the group root! 091208 - // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); - // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. - // { // Single, or Root prim of linkset, target is ClickOffset * RootRot - //offsetr = offset * partIRot; -// - // else - // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) - // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + - // (offset * partRot); - // } - -//Console.WriteLine(" "); -//Console.WriteLine("link number ={0}", part.LinkNum); -//Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); -//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); -//Console.WriteLine("Click offst ={0}", offset); -//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); -//Console.WriteLine("offsetr ={0}", offsetr); -//Console.WriteLine("Camera At ={0}", cameraAtOffset); -//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); - - //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child - ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); - - m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target - // This calls HandleAgentSit twice, once from here, and the client calls - // HandleAgentSit itself after it gets to the location - // It doesn't get to the location until we've moved them there though - // which happens in HandleAgentSit :P - m_autopilotMoving = autopilot; - m_autoPilotTarget = autopilotTarget; - m_sitAtAutoTarget = autopilot; - m_initialSitTarget = autopilotTarget; - if (!autopilot) - HandleAgentSit(remoteClient, UUID); - } - - public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) - { - if (m_parentID != 0) - { - StandUp(); - } - m_nextSitAnimation = "SIT"; - - //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); - - if (part != null) - { - if (!String.IsNullOrEmpty(part.SitAnimation)) - { - m_nextSitAnimation = part.SitAnimation; - } - m_requestedSitTargetID = part.LocalId; - //m_requestedSitOffset = offset; - m_requestedSitTargetUUID = targetID; - - m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - - if (m_scene.PhysicsScene.SupportsRayCast()) - { - //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); - //SitRayCastAvatarPosition(part); - //return; - } - } - else - { - - m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); - } - - - - SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); - } - /* - public void SitRayCastAvatarPosition(SceneObjectPart part) - { - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); - } - - public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) - { - // Next, try to raycast from the camera Z position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); - } - - public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayCastCameraPosition(SceneObjectPart part) - { - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); - } - - public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayHorizontal(part); - } - } - else - { - SitRayHorizontal(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayHorizontal(SceneObjectPart part) - { - // Next, try to raycast from the avatar position to fwd - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); - } - - public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) - { - int i = 0; - //throw new NotImplementedException(); - //m_requestedSitTargetUUID = UUID.Zero; - //m_requestedSitTargetID = 0; - //m_requestedSitOffset = Vector3.Zero; - - SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); - } - */ - public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) - { - if (m_parentID != 0) - { - StandUp(); - } - if (!String.IsNullOrEmpty(sitAnimation)) - { - m_nextSitAnimation = sitAnimation; - } - else - { - m_nextSitAnimation = "SIT"; - } - - //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); - if (part != null) - { - m_requestedSitTargetID = part.LocalId; - //m_requestedSitOffset = offset; - m_requestedSitTargetUUID = targetID; - - m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - - if (m_scene.PhysicsScene.SupportsRayCast()) - { - //SitRayCastAvatarPosition(part); - //return; - } - } - else - { - m_log.Warn("Sit requested on unknown object: " + targetID); - } - - SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); - } - - public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) - { - if (!String.IsNullOrEmpty(m_nextSitAnimation)) - { - HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); - } - else - { - HandleAgentSit(remoteClient, agentID, "SIT"); - } - } - - public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); - - if (m_sitAtAutoTarget || !m_autopilotMoving) - { - if (part != null) - { -//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); - if (part.GetAvatarOnSitTarget() == UUID) - { -//Console.WriteLine("Scripted Sit"); - // Scripted sit - Vector3 sitTargetPos = part.SitTargetPosition; - Quaternion sitTargetOrient = part.SitTargetOrientation; - m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); - m_pos += SIT_TARGET_ADJUSTMENT; - if (!part.IsRoot) - { - m_pos *= part.RotationOffset; - } - m_bodyRot = sitTargetOrient; - m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); -Console.WriteLine("Scripted Sit ofset {0}", m_pos); - } - else - { - // if m_avUnscriptedSitPos is zero then Av sits above center - // Else Av sits at m_avUnscriptedSitPos - - // Non-scripted sit by Kitto Flora 21Nov09 - // Calculate angle of line from prim to Av - Quaternion partIRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); -// } -// else -// { // single or child prim - partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; - float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); - float x_diff = ( m_avInitialPos.X - sitTargetPos.X); - if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 - if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 - float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); - // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. - // Av sits at world euler <0,0, z>, translated by part rotation - m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click - - m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); - m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation - (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center - (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + - m_avUnscriptedSitPos; // adds click offset, if any - //Set up raytrace to find top surface of prim - Vector3 size = part.Scale; - float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); - Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); - Vector3 down = new Vector3(0f, 0f, -1f); -//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); - m_scene.PhysicsScene.RaycastWorld( - start, // Vector3 position, - down, // Vector3 direction, - mag, // float length, - SitAltitudeCallback); // retMethod - } // end scripted/not - } - else // no Av - { - return; - } - } - - //We want our offsets to reference the root prim, not the child we may have sat on - if (!part.IsRoot) - { - m_parentID = part.ParentGroup.RootPart.LocalId; - m_pos += part.OffsetPosition; - } - else - { - m_parentID = m_requestedSitTargetID; - } - - m_linkedPrim = part.UUID; - - Velocity = Vector3.Zero; - RemoveFromPhysicalScene(); - - Animator.TrySetMovementAnimation(sitAnimation); - SendFullUpdateToAllClients(); - } - - public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) - { - // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer - // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. - if(hitYN) - { - // m_pos = Av offset from prim center to make look like on center - // m_parentPosition = Actual center pos of prim - // collisionPoint = spot on prim where we want to sit - // collisionPoint.Z = global sit surface height - SceneObjectPart part = m_scene.GetSceneObjectPart(localid); - Quaternion partIRot; -// if (part.LinkNum == 1) -/// { // Root prim of linkset -// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); -// } -// else -// { // single or child prim - partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - if (m_initialSitTarget != null) - { - float offZ = collisionPoint.Z - m_initialSitTarget.Z; - Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction - //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); - m_pos += offset; - // ControllingClient.SendClearFollowCamProperties(part.UUID); - } - - } - } // End SitAltitudeCallback KF. - - /// - /// Event handler for the 'Always run' setting on the client - /// Tells the physics plugin to increase speed of movement. - /// - public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) - { - m_setAlwaysRun = pSetAlwaysRun; - if (PhysicsActor != null) - { - PhysicsActor.SetAlwaysRun = pSetAlwaysRun; - } - } - - public void HandleStartAnim(IClientAPI remoteClient, UUID animID) - { - Animator.AddAnimation(animID, UUID.Zero); - } - - public void HandleStopAnim(IClientAPI remoteClient, UUID animID) - { - Animator.RemoveAnimation(animID); - } - - /// - /// Rotate the avatar to the given rotation and apply a movement in the given relative vector - /// - /// The vector in which to move. This is relative to the rotation argument - /// The direction in which this avatar should now face. - public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) - { - if (m_isChildAgent) - { - // WHAT??? - m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); - - // we have to reset the user's child agent connections. - // Likely, here they've lost the eventqueue for other regions so border - // crossings will fail at this point unless we reset them. - - List regions = new List(KnownChildRegionHandles); - regions.Remove(m_scene.RegionInfo.RegionHandle); - - MakeRootAgent(new Vector3(127f, 127f, 127f), true); - - // Async command - if (m_scene.SceneGridService != null) - { - m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); - - // Give the above command some time to try and close the connections. - // this is really an emergency.. so sleep, or we'll get all discombobulated. - System.Threading.Thread.Sleep(500); - } - - if (m_scene.SceneGridService != null) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); - } - - return; - } - - m_perfMonMS = Util.EnvironmentTickCount(); - - Rotation = rotation; - Vector3 direc = vec * rotation; - direc.Normalize(); - PhysicsActor actor = m_physicsActor; - if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. - - direc *= 0.03f * 128f * m_speedModifier; - - if (actor != null) - { - if (actor.Flying) - { - direc *= 4.0f; - //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - //bool colliding = (m_physicsActor.IsColliding==true); - //if (controlland) - // m_log.Info("[AGENT]: landCommand"); - //if (colliding) - // m_log.Info("[AGENT]: colliding"); - //if (m_physicsActor.Flying && colliding && controlland) - //{ - // StopFlying(); - // m_log.Info("[AGENT]: Stop FLying"); - //} - } - else if (!actor.Flying && actor.IsColliding) - { - if (direc.Z > 2.0f) - { - if(m_animator.m_animTickJump == -1) - { - direc.Z *= 3.0f; // jump - } - else - { - direc.Z *= 0.1f; // prejump - } - /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs - Animator.TrySetMovementAnimation("PREJUMP"); - Animator.TrySetMovementAnimation("JUMP"); - */ - } - } - } - - // TODO: Add the force instead of only setting it to support multiple forces per frame? - m_forceToApply = direc; - m_isNudging = Nudging; - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - #endregion - - #region Overridden Methods - - public override void Update() - { - const float ROTATION_TOLERANCE = 0.01f; - const float VELOCITY_TOLERANCE = 0.001f; - const float POSITION_TOLERANCE = 0.05f; - //const int TIME_MS_TOLERANCE = 3000; - - - - if (m_isChildAgent == false) - { -// PhysicsActor actor = m_physicsActor; - - // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to - // grab the latest PhysicsActor velocity, whereas m_velocity is often - // storing a requested force instead of an actual traveling velocity - - // Throw away duplicate or insignificant updates - if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || - !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) - //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) - { - SendTerseUpdateToAllClients(); - - // Update the "last" values - m_lastPosition = m_pos; - m_lastRotation = m_bodyRot; - m_lastVelocity = Velocity; - //m_lastTerseSent = Environment.TickCount; - } - - // followed suggestion from mic bowman. reversed the two lines below. - if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something - CheckForBorderCrossing(); - CheckForSignificantMovement(); // sends update to the modules. - } - - //Sending prim updates AFTER the avatar terse updates are sent - SendPrimUpdates(); - } - - #endregion - - #region Update Client(s) - - /// - /// Sends a location update to the client connected to this scenePresence - /// - /// - public void SendTerseUpdateToClient(IClientAPI remoteClient) - { - // If the client is inactive, it's getting its updates from another - // server. - if (remoteClient.IsActive) - { - m_perfMonMS = Util.EnvironmentTickCount(); - - PhysicsActor actor = m_physicsActor; - Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); - - remoteClient.SendPrimUpdate(this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - m_scene.StatsReporter.AddAgentUpdates(1); - } - } - - /// - /// Send a location/velocity/accelleration update to all agents in scene - /// - public void SendTerseUpdateToAllClients() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_scene.ForEachClient(SendTerseUpdateToClient); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - public void SendCoarseLocations(List coarseLocations, List avatarUUIDs) - { - SendCourseLocationsMethod d = m_sendCourseLocationsMethod; - if (d != null) - { - d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); - } - } - - public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) - { - if (d != null) - m_sendCourseLocationsMethod = d; - } - - public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List coarseLocations, List avatarUUIDs) - { - m_perfMonMS = Util.EnvironmentTickCount(); - m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - /// - /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) - /// - /// - public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) - { - // 2 stage check is needed. - if (remoteAvatar == null) - return; - IClientAPI cl=remoteAvatar.ControllingClient; - if (cl == null) - return; - if (m_appearance.Texture == null) - return; - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); - m_scene.StatsReporter.AddAgentUpdates(1); - } - - /// - /// Tell *ALL* agents about this agent - /// - public void SendInitialFullUpdateToAllClients() - { - m_perfMonMS = Util.EnvironmentTickCount(); - int avUpdates = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - ++avUpdates; - // only send if this is the root (children are only "listening posts" in a foreign region) - if (!IsChildAgent) - { - SendFullUpdateToOtherClient(avatar); - } - - if (avatar.LocalId != LocalId) - { - if (!avatar.IsChildAgent) - { - avatar.SendFullUpdateToOtherClient(this); - avatar.SendAppearanceToOtherAgent(this); - avatar.Animator.SendAnimPackToClient(ControllingClient); - } - } - }); - - m_scene.StatsReporter.AddAgentUpdates(avUpdates); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - - //Animator.SendAnimPack(); - } - - public void SendFullUpdateToAllClients() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - // only send update from root agents to other clients; children are only "listening posts" - int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence sp) - { - if (sp.IsChildAgent) - return; - SendFullUpdateToOtherClient(sp); - ++count; - }); - m_scene.StatsReporter.AddAgentUpdates(count); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - - Animator.SendAnimPack(); - } - - /// - /// Do everything required once a client completes its movement into a region - /// - public void SendInitialData() - { - // Moved this into CompleteMovement to ensure that m_appearance is initialized before - // the inventory arrives - // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - m_controllingClient.SendAvatarDataImmediate(this); - - SendInitialFullUpdateToAllClients(); - SendAppearanceToAllOtherAgents(); - } - - /// - /// Tell the client for this scene presence what items it should be wearing now - /// - public void SendWearables() - { - m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name); - - ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); - } - - /// - /// - /// - public void SendAppearanceToAllOtherAgents() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - if (scenePresence.UUID != UUID) - { - SendAppearanceToOtherAgent(scenePresence); - } - }); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - /// - /// Send appearance data to an agent that isn't this one. - /// - /// - public void SendAppearanceToOtherAgent(ScenePresence avatar) - { - avatar.ControllingClient.SendAppearance( - m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); - } - - /// - /// Set appearance data (textureentry and slider settings) received from the client - /// - /// - /// - public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) - { - if (m_physicsActor != null) - { - if (!IsChildAgent) - { - // This may seem like it's redundant, remove the avatar from the physics scene - // just to add it back again, but it saves us from having to update - // 3 variables 10 times a second. - bool flyingTemp = m_physicsActor.Flying; - RemoveFromPhysicalScene(); - //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); - - //PhysicsActor = null; - - AddToPhysicalScene(flyingTemp); - } - } - - #region Bake Cache Check - - if (textureEntry != null) - { - for (int i = 0; i < BAKE_INDICES.Length; i++) - { - int j = BAKE_INDICES[i]; - Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; - - if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) - { - if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) - { - m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); - this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); - } - } - } - - } - - - #endregion Bake Cache Check - - m_appearance.SetAppearance(textureEntry, visualParams); - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - - // This is not needed, because only the transient data changed - //AvatarData adata = new AvatarData(m_appearance); - //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); - - SendAppearanceToAllOtherAgents(); - if (!m_startAnimationSet) - { - Animator.UpdateMovementAnimations(); - m_startAnimationSet = true; - } - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - m_controllingClient.SendAvatarDataImmediate(this); - } - - public void SetWearable(int wearableId, AvatarWearable wearable) - { - m_appearance.SetWearable(wearableId, wearable); - AvatarData adata = new AvatarData(m_appearance); - m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); - m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); - } - - // Because appearance setting is in a module, we actually need - // to give it access to our appearance directly, otherwise we - // get a synchronization issue. - public AvatarAppearance Appearance - { - get { return m_appearance; } - set { m_appearance = value; } - } - - #endregion - - #region Significant Movement Method - - /// - /// This checks for a significant movement and sends a courselocationchange update - /// - protected void CheckForSignificantMovement() - { - // Movement updates for agents in neighboring regions are sent directly to clients. - // This value only affects how often agent positions are sent to neighbor regions - // for things such as distance-based update prioritization - const float SIGNIFICANT_MOVEMENT = 2.0f; - - if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) - { - posLastSignificantMove = AbsolutePosition; - m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); - } - - // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m - if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || - Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) - { - m_lastChildAgentUpdatePosition = AbsolutePosition; - m_lastChildAgentUpdateCamPosition = CameraPosition; - - ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); - cadu.ActiveGroupID = UUID.Zero.Guid; - cadu.AgentID = UUID.Guid; - cadu.alwaysrun = m_setAlwaysRun; - cadu.AVHeight = m_avHeight; - Vector3 tempCameraCenter = m_CameraCenter; - cadu.cameraPosition = tempCameraCenter; - cadu.drawdistance = m_DrawDistance; - cadu.GroupAccess = 0; - cadu.Position = AbsolutePosition; - cadu.regionHandle = m_rootRegionHandle; - float multiplier = 1; - int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); - if (innacurateNeighbors != 0) - { - multiplier = 1f / (float)innacurateNeighbors; - } - if (multiplier <= 0f) - { - multiplier = 0.25f; - } - - //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); - cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); - cadu.Velocity = Velocity; - - AgentPosition agentpos = new AgentPosition(); - agentpos.CopyFrom(cadu); - - m_scene.SendOutChildAgentUpdates(agentpos, this); - } - } - - #endregion - - #region Border Crossing Methods - - /// - /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion - /// - protected void CheckForBorderCrossing() - { - if (IsChildAgent) - return; - - Vector3 pos2 = AbsolutePosition; - Vector3 vel = Velocity; - int neighbor = 0; - int[] fix = new int[2]; - - float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X*timeStep); - pos2.Y = pos2.Y + (vel.Y*timeStep); - pos2.Z = pos2.Z + (vel.Z*timeStep); - - if (!IsInTransit) - { - // Checks if where it's headed exists a region - - bool needsTransit = false; - if (m_scene.TestBorderCross(pos2, Cardinals.W)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.SW, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.NW, ref fix); - } - else - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.W, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.E)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.SE, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.NE, ref fix); - } - else - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.E, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.S, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.N, ref fix); - } - - - // Makes sure avatar does not end up outside region - if (neighbor <= 0) - { - if (!needsTransit) - { - if (m_requestedSitTargetUUID == UUID.Zero) - { - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y; - AbsolutePosition = pos; - } - } - } - else if (neighbor > 0) - CrossToNewRegion(); - } - else - { - RemoveFromPhysicalScene(); - // This constant has been inferred from experimentation - // I'm not sure what this value should be, so I tried a few values. - timeStep = 0.04f; - pos2 = AbsolutePosition; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); - m_pos = pos2; - } - } - - protected int HaveNeighbor(Cardinals car, ref int[] fix) - { - uint neighbourx = m_regionInfo.RegionLocX; - uint neighboury = m_regionInfo.RegionLocY; - - int dir = (int)car; - - if (dir > 1 && dir < 5) //Heading East - neighbourx++; - else if (dir > 5) // Heading West - neighbourx--; - - if (dir < 3 || dir == 8) // Heading North - neighboury++; - else if (dir > 3 && dir < 7) // Heading Sout - neighboury--; - - int x = (int)(neighbourx * Constants.RegionSize); - int y = (int)(neighboury * Constants.RegionSize); - GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); - - if (neighbourRegion == null) - { - fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); - fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); - return dir * (-1); - } - else - return dir; - } - - /// - /// Moves the agent outside the region bounds - /// Tells neighbor region that we're crossing to it - /// If the neighbor accepts, remove the agent's viewable avatar from this scene - /// set them to a child agent. - /// - protected void CrossToNewRegion() - { - InTransit(); - try - { - m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); - } - catch - { - m_scene.CrossAgentToNewRegion(this, false); - } - } - - public void InTransit() - { - m_inTransit = true; - - if ((m_physicsActor != null) && m_physicsActor.Flying) - m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; - else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) - m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; - } - - public void NotInTransit() - { - m_inTransit = false; - } - - public void RestoreInCurrentScene() - { - AddToPhysicalScene(false); // not exactly false - } - - public void Reset() - { - // Put the child agent back at the center - AbsolutePosition - = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); - Animator.ResetAnimations(); - } - - /// - /// Computes which child agents to close when the scene presence moves to another region. - /// Removes those regions from m_knownRegions. - /// - /// The new region's x on the map - /// The new region's y on the map - /// - public void CloseChildAgents(uint newRegionX, uint newRegionY) - { - List byebyeRegions = new List(); - m_log.DebugFormat( - "[SCENE PRESENCE]: Closing child agents. Checking {0} regions in {1}", - m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName); - //DumpKnownRegions(); - - lock (m_knownChildRegions) - { - foreach (ulong handle in m_knownChildRegions.Keys) - { - // Don't close the agent on this region yet - if (handle != Scene.RegionInfo.RegionHandle) - { - uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - - //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); - //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); - if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) - { - byebyeRegions.Add(handle); - } - } - } - } - - if (byebyeRegions.Count > 0) - { - m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); - m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); - } - - foreach (ulong handle in byebyeRegions) - { - RemoveNeighbourRegion(handle); - } - } - - #endregion - - /// - /// This allows the Sim owner the abiility to kick users from their sim currently. - /// It tells the client that the agent has permission to do so. - /// - public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) - { - if (godStatus) - { - // For now, assign god level 200 to anyone - // who is granted god powers, but has no god level set. - // - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); - if (account != null) - { - if (account.UserLevel > 0) - m_godLevel = account.UserLevel; - else - m_godLevel = 200; - } - } - else - { - m_godLevel = 0; - } - - ControllingClient.SendAdminResponse(token, (uint)m_godLevel); - } - - #region Child Agent Updates - - public void ChildAgentDataUpdate(AgentData cAgentData) - { - //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); - if (!IsChildAgent) - return; - - CopyFrom(cAgentData); - } - - /// - /// This updates important decision making data about a child agent - /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region - /// - public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) - { - if (!IsChildAgent) - return; - - //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); - int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; - int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; - - Vector3 offset = new Vector3(shiftx, shifty, 0f); - - m_DrawDistance = cAgentData.Far; - if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! - m_pos = cAgentData.Position + offset; - - if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) - { - posLastSignificantMove = AbsolutePosition; - ReprioritizeUpdates(); - } - - m_CameraCenter = cAgentData.Center + offset; - - m_avHeight = cAgentData.Size.Z; - //SetHeight(cAgentData.AVHeight); - - if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); - - // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. - if (m_scene.m_seeIntoRegionFromNeighbor) - m_sceneViewer.Reset(); - - //cAgentData.AVHeight; - m_rootRegionHandle = cAgentData.RegionHandle; - //m_velocity = cAgentData.Velocity; - } - - public void CopyTo(AgentData cAgent) - { - cAgent.AgentID = UUID; - cAgent.RegionID = Scene.RegionInfo.RegionID; - - cAgent.Position = AbsolutePosition; - cAgent.Velocity = m_velocity; - cAgent.Center = m_CameraCenter; - // Don't copy the size; it is inferred from apearance parameters - //cAgent.Size = new Vector3(0, 0, m_avHeight); - cAgent.AtAxis = m_CameraAtAxis; - cAgent.LeftAxis = m_CameraLeftAxis; - cAgent.UpAxis = m_CameraUpAxis; - - cAgent.Far = m_DrawDistance; - - // Throttles - float multiplier = 1; - int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); - if (innacurateNeighbors != 0) - { - multiplier = 1f / innacurateNeighbors; - } - if (multiplier <= 0f) - { - multiplier = 0.25f; - } - //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); - cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); - - cAgent.HeadRotation = m_headrotation; - cAgent.BodyRotation = m_bodyRot; - cAgent.ControlFlags = (uint)m_AgentControlFlags; - - if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) - cAgent.GodLevel = (byte)m_godLevel; - else - cAgent.GodLevel = (byte) 0; - - cAgent.AlwaysRun = m_setAlwaysRun; - - try - { - // We might not pass the Wearables in all cases... - // They're only needed so that persistent changes to the appearance - // are preserved in the new region where the user is moving to. - // But in Hypergrid we might not let this happen. - int i = 0; - UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; - foreach (AvatarWearable aw in m_appearance.Wearables) - { - if (aw != null) - { - wears[i++] = aw.ItemID; - wears[i++] = aw.AssetID; - } - else - { - wears[i++] = UUID.Zero; - wears[i++] = UUID.Zero; - } - } - cAgent.Wearables = wears; - - cAgent.VisualParams = m_appearance.VisualParams; - - if (m_appearance.Texture != null) - cAgent.AgentTextures = m_appearance.Texture.GetBytes(); - } - catch (Exception e) - { - m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); - } - - //Attachments - List attPoints = m_appearance.GetAttachedPoints(); - if (attPoints != null) - { - //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); - int i = 0; - AttachmentData[] attachs = new AttachmentData[attPoints.Count]; - foreach (int point in attPoints) - { - attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); - } - cAgent.Attachments = attachs; - } - - lock (scriptedcontrols) - { - ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; - int i = 0; - - foreach (ScriptControllers c in scriptedcontrols.Values) - { - controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); - } - cAgent.Controllers = controls; - } - - // Animations - try - { - cAgent.Anims = Animator.Animations.ToArray(); - } - catch { } - - // cAgent.GroupID = ?? - // Groups??? - - } - - public void CopyFrom(AgentData cAgent) - { - m_originRegionID = cAgent.RegionID; - - m_callbackURI = cAgent.CallbackURI; - - m_pos = cAgent.Position; - - m_velocity = cAgent.Velocity; - m_CameraCenter = cAgent.Center; - //m_avHeight = cAgent.Size.Z; - m_CameraAtAxis = cAgent.AtAxis; - m_CameraLeftAxis = cAgent.LeftAxis; - m_CameraUpAxis = cAgent.UpAxis; - - m_DrawDistance = cAgent.Far; - - if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgent.Throttles); - - m_headrotation = cAgent.HeadRotation; - m_bodyRot = cAgent.BodyRotation; - m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; - - if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) - m_godLevel = cAgent.GodLevel; - m_setAlwaysRun = cAgent.AlwaysRun; - - uint i = 0; - try - { - if (cAgent.Wearables == null) - cAgent.Wearables = new UUID[0]; - AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; - for (uint n = 0; n < cAgent.Wearables.Length; n += 2) - { - UUID itemId = cAgent.Wearables[n]; - UUID assetId = cAgent.Wearables[n + 1]; - wears[i++] = new AvatarWearable(itemId, assetId); - } - m_appearance.Wearables = wears; - Primitive.TextureEntry te; - if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) - te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); - else - te = AvatarAppearance.GetDefaultTexture(); - if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) - cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); - m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); - } - catch (Exception e) - { - m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); - } - - // Attachments - try - { - if (cAgent.Attachments != null) - { - m_appearance.ClearAttachments(); - foreach (AttachmentData att in cAgent.Attachments) - { - m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); - } - } - } - catch { } - - try - { - lock (scriptedcontrols) - { - if (cAgent.Controllers != null) - { - scriptedcontrols.Clear(); - - foreach (ControllerData c in cAgent.Controllers) - { - ScriptControllers sc = new ScriptControllers(); - sc.itemID = c.ItemID; - sc.ignoreControls = (ScriptControlled)c.IgnoreControls; - sc.eventControls = (ScriptControlled)c.EventControls; - - scriptedcontrols[sc.itemID] = sc; - } - } - } - } - catch { } - // Animations - try - { - Animator.ResetAnimations(); - Animator.Animations.FromArray(cAgent.Anims); - } - catch { } - - //cAgent.GroupID = ?? - //Groups??? - } - - public bool CopyAgent(out IAgentData agent) - { - agent = new CompleteAgentData(); - CopyTo((AgentData)agent); - return true; - } - - #endregion Child Agent Updates - - /// - /// Handles part of the PID controller function for moving an avatar. - /// - public override void UpdateMovement() - { - if (m_forceToApply.HasValue) - { - - Vector3 force = m_forceToApply.Value; - m_updateflag = true; - Velocity = force; - - m_forceToApply = null; - } - else - { - if (m_isNudging) - { - Vector3 force = Vector3.Zero; - - m_updateflag = true; - Velocity = force; - m_isNudging = false; - m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" - } - } - } - - public override void SetText(string text, Vector3 color, double alpha) - { - throw new Exception("Can't set Text on avatar."); - } - - /// - /// Adds a physical representation of the avatar to the Physics plugin - /// - public void AddToPhysicalScene(bool isFlying) - { - PhysicsScene scene = m_scene.PhysicsScene; - - Vector3 pVec = AbsolutePosition; - - // Old bug where the height was in centimeters instead of meters - if (m_avHeight == 127.0f) - { - m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), - isFlying); - } - else - { - m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, - new Vector3(0f, 0f, m_avHeight), isFlying); - } - scene.AddPhysicsActorTaint(m_physicsActor); - //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; - m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; - m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong - m_physicsActor.SubscribeEvents(500); - m_physicsActor.LocalID = LocalId; - } - - private void OutOfBoundsCall(Vector3 pos) - { - //bool flying = m_physicsActor.Flying; - //RemoveFromPhysicalScene(); - - //AddToPhysicalScene(flying); - if (ControllingClient != null) - ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); - } - - // Event called by the physics plugin to tell the avatar about a collision. - private void PhysicsCollisionUpdate(EventArgs e) - { - if (e == null) - return; - - // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( - // as of this comment the interval is set in AddToPhysicalScene - if (Animator!=null) - { - if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, - { // else its will lock out other animation changes, like ground sit. - Animator.UpdateMovementAnimations(); - m_updateCount--; - } - } - - CollisionEventUpdate collisionData = (CollisionEventUpdate)e; - Dictionary coldata = collisionData.m_objCollisionList; - - CollisionPlane = Vector4.UnitW; - - if (m_lastColCount != coldata.Count) - { - m_updateCount = UPDATE_COUNT; - m_lastColCount = coldata.Count; - } - - if (coldata.Count != 0 && Animator != null) - { - switch (Animator.CurrentMovementAnimation) - { - case "STAND": - case "WALK": - case "RUN": - case "CROUCH": - case "CROUCHWALK": - { - ContactPoint lowest; - lowest.SurfaceNormal = Vector3.Zero; - lowest.Position = Vector3.Zero; - lowest.Position.Z = Single.NaN; - - foreach (ContactPoint contact in coldata.Values) - { - if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) - { - lowest = contact; - } - } - - CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); - } - break; - } - } - - List thisHitColliders = new List(); - List endedColliders = new List(); - List startedColliders = new List(); - - foreach (uint localid in coldata.Keys) - { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) - { - endedColliders.Add(localID); - } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); - } - - // do event notification - if (startedColliders.Count > 0) - { - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - StartCollidingMessage.Colliders = colliding; - - foreach (SceneObjectGroup att in Attachments) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); - } - } - - if (endedColliders.Count > 0) - { - ColliderArgs EndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in endedColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - EndCollidingMessage.Colliders = colliding; - - foreach (SceneObjectGroup att in Attachments) - Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); - } - } - - if (thisHitColliders.Count > 0) - { - ColliderArgs CollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in thisHitColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - CollidingMessage.Colliders = colliding; - - lock (m_attachments) - { - foreach (SceneObjectGroup att in m_attachments) - Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); - } - } - } - - if (m_invulnerable) - return; - - float starthealth = Health; - uint killerObj = 0; - foreach (uint localid in coldata.Keys) - { - SceneObjectPart part = Scene.GetSceneObjectPart(localid); - - if (part != null && part.ParentGroup.Damage != -1.0f) - Health -= part.ParentGroup.Damage; - else - { - if (coldata[localid].PenetrationDepth >= 0.10f) - Health -= coldata[localid].PenetrationDepth * 5.0f; - } - - if (Health <= 0.0f) - { - if (localid != 0) - killerObj = localid; - } - //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); - } - //Health = 100; - if (!m_invulnerable) - { - if (starthealth != Health) - { - ControllingClient.SendHealth(Health); - } - if (m_health <= 0) - m_scene.EventManager.TriggerAvatarKill(killerObj, this); - } - } - - public void setHealthWithUpdate(float health) - { - Health = health; - ControllingClient.SendHealth(Health); - } - - public void Close() - { - lock (m_attachments) - { - // Delete attachments from scene - // Don't try to save, as this thread won't live long - // enough to complete the save. This would cause no copy - // attachments to poof! - // - foreach (SceneObjectGroup grp in m_attachments) - { - m_scene.DeleteSceneObject(grp, false); - } - m_attachments.Clear(); - } - - lock (m_knownChildRegions) - { - m_knownChildRegions.Clear(); - } - - lock (m_reprioritization_timer) - { - m_reprioritization_timer.Enabled = false; - m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); - } - - // I don't get it but mono crashes when you try to dispose of this timer, - // unsetting the elapsed callback should be enough to allow for cleanup however. - // m_reprioritizationTimer.Dispose(); - - m_sceneViewer.Close(); - - RemoveFromPhysicalScene(); - m_animator.Close(); - m_animator = null; - } - - public void AddAttachment(SceneObjectGroup gobj) - { - lock (m_attachments) - { - m_attachments.Add(gobj); - } - } - - public bool HasAttachments() - { - return m_attachments.Count > 0; - } - - public bool HasScriptedAttachments() - { - lock (m_attachments) - { - foreach (SceneObjectGroup gobj in m_attachments) - { - if (gobj != null) - { - if (gobj.RootPart.Inventory.ContainsScripts()) - return true; - } - } - } - return false; - } - - public void RemoveAttachment(SceneObjectGroup gobj) - { - lock (m_attachments) - { - if (m_attachments.Contains(gobj)) - { - m_attachments.Remove(gobj); - } - } - } - - public bool ValidateAttachments() - { - lock (m_attachments) - { - // Validate - foreach (SceneObjectGroup gobj in m_attachments) - { - if (gobj == null) - return false; - - if (gobj.IsDeleted) - return false; - } - } - return true; - } - - /// - /// Send a script event to this scene presence's attachments - /// - /// The name of the event - /// The arguments for the event - public void SendScriptEventToAttachments(string eventName, Object[] args) - { - if (m_scriptEngines != null) - { - lock (m_attachments) - { - foreach (SceneObjectGroup grp in m_attachments) - { - // 16384 is CHANGED_ANIMATION - // - // Send this to all attachment root prims - // - foreach (IScriptModule m in m_scriptEngines) - { - if (m == null) // No script engine loaded - continue; - - m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); - } - } - } - } - } - - - public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) - { - m_controllingClient = client; - m_regionInfo = region; - m_scene = scene; - - RegisterToEvents(); - if (m_controllingClient != null) - { - m_controllingClient.ProcessPendingPackets(); - } - /* - AbsolutePosition = client.StartPos; - - Animations = new AvatarAnimations(); - Animations.LoadAnims(); - - m_animations = new List(); - m_animations.Add(Animations.AnimsUUID["STAND"]); - m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); - - SetDirectionVectors(); - */ - } - - internal void PushForce(Vector3 impulse) - { - if (PhysicsActor != null) - { - PhysicsActor.AddForce(impulse,true); - } - } - - public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) - { - ScriptControllers obj = new ScriptControllers(); - obj.ignoreControls = ScriptControlled.CONTROL_ZERO; - obj.eventControls = ScriptControlled.CONTROL_ZERO; - - obj.itemID = Script_item_UUID; - if (pass_on == 0 && accept == 0) - { - IgnoredControls |= (ScriptControlled)controls; - obj.ignoreControls = (ScriptControlled)controls; - } - - if (pass_on == 0 && accept == 1) - { - IgnoredControls |= (ScriptControlled)controls; - obj.ignoreControls = (ScriptControlled)controls; - obj.eventControls = (ScriptControlled)controls; - } - if (pass_on == 1 && accept == 1) - { - IgnoredControls = ScriptControlled.CONTROL_ZERO; - obj.eventControls = (ScriptControlled)controls; - obj.ignoreControls = ScriptControlled.CONTROL_ZERO; - } - - lock (scriptedcontrols) - { - if (pass_on == 1 && accept == 0) - { - IgnoredControls &= ~(ScriptControlled)controls; - if (scriptedcontrols.ContainsKey(Script_item_UUID)) - scriptedcontrols.Remove(Script_item_UUID); - } - else - { - scriptedcontrols[Script_item_UUID] = obj; - } - } - ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); - } - - public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) - { - IgnoredControls = ScriptControlled.CONTROL_ZERO; - lock (scriptedcontrols) - { - scriptedcontrols.Clear(); - } - ControllingClient.SendTakeControls(int.MaxValue, false, false); - } - - public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) - { - ScriptControllers takecontrols; - - lock (scriptedcontrols) - { - if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) - { - ScriptControlled sctc = takecontrols.eventControls; - - ControllingClient.SendTakeControls((int)sctc, false, false); - ControllingClient.SendTakeControls((int)sctc, true, false); - - scriptedcontrols.Remove(Script_item_UUID); - IgnoredControls = ScriptControlled.CONTROL_ZERO; - foreach (ScriptControllers scData in scriptedcontrols.Values) - { - IgnoredControls |= scData.ignoreControls; - } - } - } - } - - internal void SendControlToScripts(uint flags) - { - ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; - - if (MouseDown) - { - allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) - { - allflags = ScriptControlled.CONTROL_ZERO; - MouseDown = true; - } - } - - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_ML_LBUTTON; - MouseDown = true; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_LBUTTON; - MouseDown = true; - } - - // find all activated controls, whether the scripts are interested in them or not - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_FWD; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_BACK; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_UP; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_DOWN; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_LEFT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_RIGHT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_ROT_RIGHT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_ROT_LEFT; - } - // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that - if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) - { - lock (scriptedcontrols) - { - foreach (KeyValuePair kvp in scriptedcontrols) - { - UUID scriptUUID = kvp.Key; - ScriptControllers scriptControlData = kvp.Value; - - ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us - ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle - ScriptControlled localChange = localHeld ^ localLast; // the changed bits - if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) - { - // only send if still pressed or just changed - m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); - } - } - } - } - - LastCommands = allflags; - } - - internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) - { - if (ignored == ScriptControlled.CONTROL_ZERO) - return flags; - - if ((ignored & ScriptControlled.CONTROL_BACK) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); - if ((ignored & ScriptControlled.CONTROL_FWD) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); - if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); - if ((ignored & ScriptControlled.CONTROL_UP) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); - if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); - if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); - if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); - if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); - if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); - if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); - - //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, - //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, - //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, - //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, - //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, - //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, - //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG - - return flags; - } - - /// - /// RezAttachments. This should only be called upon login on the first region. - /// Attachment rezzings on crossings and TPs are done in a different way. - /// - public void RezAttachments() - { - if (null == m_appearance) - { - m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); - return; - } - - XmlDocument doc = new XmlDocument(); - string stateData = String.Empty; - - IAttachmentsService attServ = m_scene.RequestModuleInterface(); - if (attServ != null) - { - m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); - stateData = attServ.Get(ControllingClient.AgentId.ToString()); - if (stateData != String.Empty) - { - try - { - doc.LoadXml(stateData); - } - catch { } - } - } - - Dictionary itemData = new Dictionary(); - - XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); - if (nodes.Count > 0) - { - foreach (XmlNode n in nodes) - { - XmlElement elem = (XmlElement)n; - string itemID = elem.GetAttribute("ItemID"); - string xml = elem.InnerXml; - - itemData[new UUID(itemID)] = xml; - } - } - - List attPoints = m_appearance.GetAttachedPoints(); - foreach (int p in attPoints) - { - if (m_isDeleted) - return; - - UUID itemID = m_appearance.GetAttachedItem(p); - UUID assetID = m_appearance.GetAttachedAsset(p); - - // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down - // But they're not used anyway, the item is being looked up for now, so let's proceed. - //if (UUID.Zero == assetID) - //{ - // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); - // continue; - //} - - try - { - string xmlData; - XmlDocument d = new XmlDocument(); - UUID asset; - if (itemData.TryGetValue(itemID, out xmlData)) - { - d.LoadXml(xmlData); - m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); - - // Rez from inventory - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); - - } - else - { - // Rez from inventory (with a null doc to let - // CHANGED_OWNER happen) - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); - } - - m_log.InfoFormat( - "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", - p, itemID, assetID, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e.ToString()); - } - } - } - - private void ReprioritizeUpdates() - { - if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) - { - lock (m_reprioritization_timer) - { - if (!m_reprioritizing) - m_reprioritization_timer.Enabled = m_reprioritizing = true; - else - m_reprioritization_called = true; - } - } - } - - private void Reprioritize(object sender, ElapsedEventArgs e) - { - m_controllingClient.ReprioritizeUpdates(); - - lock (m_reprioritization_timer) - { - m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; - m_reprioritization_called = false; - } - } - - private Vector3 Quat2Euler(Quaternion rot){ - float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , - (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); - float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); - float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , - (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); - return(new Vector3(x,y,z)); - } - - - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Collections.Generic; +using System.Reflection; +using System.Timers; +using OpenMetaverse; +using log4net; +using OpenSim.Framework; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes.Animation; +using OpenSim.Region.Framework.Scenes.Types; +using OpenSim.Region.Physics.Manager; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.Framework.Scenes +{ + enum ScriptControlled : uint + { + CONTROL_ZERO = 0, + CONTROL_FWD = 1, + CONTROL_BACK = 2, + CONTROL_LEFT = 4, + CONTROL_RIGHT = 8, + CONTROL_UP = 16, + CONTROL_DOWN = 32, + CONTROL_ROT_LEFT = 256, + CONTROL_ROT_RIGHT = 512, + CONTROL_LBUTTON = 268435456, + CONTROL_ML_LBUTTON = 1073741824 + } + + struct ScriptControllers + { + public UUID itemID; + public ScriptControlled ignoreControls; + public ScriptControlled eventControls; + } + + public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs); + + public class ScenePresence : EntityBase, ISceneEntity + { +// ~ScenePresence() +// { +// m_log.Debug("[ScenePresence] Destructor called"); +// } + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; +// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); + private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); + private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); + + /// + /// Experimentally determined "fudge factor" to make sit-target positions + /// the same as in SecondLife. Fudge factor was tested for 36 different + /// test cases including prims of type box, sphere, cylinder, and torus, + /// with varying parameters for sit target location, prim size, prim + /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis + /// issue #1716 + /// +// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); + // Value revised by KF 091121 by comparison with SL. + private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); + + public UUID currentParcelUUID = UUID.Zero; + + private ISceneViewer m_sceneViewer; + + /// + /// The animator for this avatar + /// + public ScenePresenceAnimator Animator + { + get { return m_animator; } + } + protected ScenePresenceAnimator m_animator; + + /// + /// The scene objects attached to this avatar. Do not change this list directly - use methods such as + /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. + /// + public List Attachments + { + get { return m_attachments; } + } + protected List m_attachments = new List(); + + private Dictionary scriptedcontrols = new Dictionary(); + private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; + private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; + private bool MouseDown = false; + private SceneObjectGroup proxyObjectGroup; + //private SceneObjectPart proxyObjectPart = null; + public Vector3 lastKnownAllowedPosition; + public bool sentMessageAboutRestrictedParcelFlyingDown; + public Vector4 CollisionPlane = Vector4.UnitW; + + private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation + private Vector3 m_avUnscriptedSitPos; // for non-scripted prims + private Vector3 m_lastPosition; + private Vector3 m_lastWorldPosition; + private Quaternion m_lastRotation; + private Vector3 m_lastVelocity; + //private int m_lastTerseSent; + + private bool m_updateflag; + private byte m_movementflag; + private Vector3? m_forceToApply; + private uint m_requestedSitTargetID; + private UUID m_requestedSitTargetUUID; + public bool SitGround = false; + + private SendCourseLocationsMethod m_sendCourseLocationsMethod; + + private bool m_startAnimationSet; + + //private Vector3 m_requestedSitOffset = new Vector3(); + + private Vector3 m_LastFinitePos; + + private float m_sitAvatarHeight = 2.0f; + + private int m_godLevel; + private int m_userLevel; + + private bool m_invulnerable = true; + + private Vector3 m_lastChildAgentUpdatePosition; + private Vector3 m_lastChildAgentUpdateCamPosition; + + private int m_perfMonMS; + + private bool m_setAlwaysRun; + private bool m_forceFly; + private bool m_flyDisabled; + + private float m_speedModifier = 1.0f; + + private Quaternion m_bodyRot= Quaternion.Identity; + + private Quaternion m_bodyRotPrevious = Quaternion.Identity; + + private const int LAND_VELOCITYMAG_MAX = 12; + + public bool IsRestrictedToRegion; + + public string JID = String.Empty; + + private float m_health = 100f; + + // Default AV Height + private float m_avHeight = 127.0f; + + protected RegionInfo m_regionInfo; + protected ulong crossingFromRegion; + + private readonly Vector3[] Dir_Vectors = new Vector3[11]; + private bool m_isNudging = false; + + // Position of agent's camera in world (region cordinates) + protected Vector3 m_CameraCenter; + protected Vector3 m_lastCameraCenter; + + protected Timer m_reprioritization_timer; + protected bool m_reprioritizing; + protected bool m_reprioritization_called; + + // Use these three vectors to figure out what the agent is looking at + // Convert it to a Matrix and/or Quaternion + protected Vector3 m_CameraAtAxis; + protected Vector3 m_CameraLeftAxis; + protected Vector3 m_CameraUpAxis; + private AgentManager.ControlFlags m_AgentControlFlags; + private Quaternion m_headrotation = Quaternion.Identity; + private byte m_state; + + //Reuse the Vector3 instead of creating a new one on the UpdateMovement method +// private Vector3 movementvector; + + private bool m_autopilotMoving; + private Vector3 m_autoPilotTarget; + private bool m_sitAtAutoTarget; + private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit + + private string m_nextSitAnimation = String.Empty; + + //PauPaw:Proper PID Controler for autopilot************ + private bool m_moveToPositionInProgress; + private Vector3 m_moveToPositionTarget; + private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + + private bool m_followCamAuto; + + private int m_movementUpdateCount; + private int m_lastColCount = -1; //KF: Look for Collision chnages + private int m_updateCount = 0; //KF: Update Anims for a while + private static readonly int UPDATE_COUNT = 10; // how many frames to update for + private const int NumMovementsBetweenRayCast = 5; + private List m_lastColliders = new List(); + + private bool CameraConstraintActive; + //private int m_moveToPositionStateStatus; + //***************************************************** + + // Agent's Draw distance. + protected float m_DrawDistance; + + protected AvatarAppearance m_appearance; + + // neighbouring regions we have enabled a child agent in + // holds the seed cap for the child agent in that region + private Dictionary m_knownChildRegions = new Dictionary(); + + /// + /// Implemented Control Flags + /// + private enum Dir_ControlFlags + { + DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, + DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, + DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, + DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, + DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, + DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, + DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, + DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, + DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG + } + + /// + /// Position at which a significant movement was made + /// + private Vector3 posLastSignificantMove; + + // For teleports and crossings callbacks + string m_callbackURI; + UUID m_originRegionID; + + ulong m_rootRegionHandle; + + /// + /// Script engines present in the scene + /// + private IScriptModule[] m_scriptEngines; + + #region Properties + + /// + /// Physical scene representation of this Avatar. + /// + public PhysicsActor PhysicsActor + { + set { m_physicsActor = value; } + get { return m_physicsActor; } + } + + public byte MovementFlag + { + set { m_movementflag = value; } + get { return m_movementflag; } + } + + public bool Updated + { + set { m_updateflag = value; } + get { return m_updateflag; } + } + + public bool Invulnerable + { + set { m_invulnerable = value; } + get { return m_invulnerable; } + } + + public int UserLevel + { + get { return m_userLevel; } + } + + public int GodLevel + { + get { return m_godLevel; } + } + + public ulong RegionHandle + { + get { return m_rootRegionHandle; } + } + + public Vector3 CameraPosition + { + get { return m_CameraCenter; } + } + + public Quaternion CameraRotation + { + get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } + } + + public Vector3 CameraAtAxis + { + get { return m_CameraAtAxis; } + } + + public Vector3 CameraLeftAxis + { + get { return m_CameraLeftAxis; } + } + + public Vector3 CameraUpAxis + { + get { return m_CameraUpAxis; } + } + + public Vector3 Lookat + { + get + { + Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); + + if (a == Vector3.Zero) + return a; + + return Util.GetNormalizedVector(a); + } + } + + private readonly string m_firstname; + + public string Firstname + { + get { return m_firstname; } + } + + private readonly string m_lastname; + + public string Lastname + { + get { return m_lastname; } + } + + private string m_grouptitle; + + public string Grouptitle + { + get { return m_grouptitle; } + set { m_grouptitle = value; } + } + + public float DrawDistance + { + get { return m_DrawDistance; } + } + + protected bool m_allowMovement = true; + + public bool AllowMovement + { + get { return m_allowMovement; } + set { m_allowMovement = value; } + } + + public bool SetAlwaysRun + { + get + { + if (PhysicsActor != null) + { + return PhysicsActor.SetAlwaysRun; + } + else + { + return m_setAlwaysRun; + } + } + set + { + m_setAlwaysRun = value; + if (PhysicsActor != null) + { + PhysicsActor.SetAlwaysRun = value; + } + } + } + + public byte State + { + get { return m_state; } + set { m_state = value; } + } + + public uint AgentControlFlags + { + get { return (uint)m_AgentControlFlags; } + set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } + } + + /// + /// This works out to be the ClientView object associated with this avatar, or it's client connection manager + /// + private IClientAPI m_controllingClient; + + protected PhysicsActor m_physicsActor; + + /// + /// The client controlling this presence + /// + public IClientAPI ControllingClient + { + get { return m_controllingClient; } + } + + public IClientCore ClientView + { + get { return (IClientCore) m_controllingClient; } + } + + protected Vector3 m_parentPosition; + public Vector3 ParentPosition + { + get { return m_parentPosition; } + set { m_parentPosition = value; } + } + + /// + /// Position of this avatar relative to the region the avatar is in + /// + public override Vector3 AbsolutePosition + { + get + { + PhysicsActor actor = m_physicsActor; +// if (actor != null) + if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! + m_pos = actor.Position; + + // If we're sitting, we need to update our position + if (m_parentID != 0) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); + if (part != null) + m_parentPosition = part.AbsolutePosition; + } + + return m_parentPosition + m_pos; + } + set + { + PhysicsActor actor = m_physicsActor; + if (actor != null) + { + try + { + lock (m_scene.SyncRoot) + m_physicsActor.Position = value; + } + catch (Exception e) + { + m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); + } + } + + if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! + m_pos = value; + m_parentPosition = Vector3.Zero; + } + } + + public Vector3 OffsetPosition + { + get { return m_pos; } + set { m_pos = value; } + } + + /// + /// Current velocity of the avatar. + /// + public override Vector3 Velocity + { + get + { + PhysicsActor actor = m_physicsActor; + if (actor != null) + m_velocity = actor.Velocity; + + return m_velocity; + } + set + { + PhysicsActor actor = m_physicsActor; + if (actor != null) + { + try + { + lock (m_scene.SyncRoot) + actor.Velocity = value; + } + catch (Exception e) + { + m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); + } + } + + m_velocity = value; + } + } + + public Quaternion OffsetRotation + { + get { return m_offsetRotation; } + set { m_offsetRotation = value; } + } + + public Quaternion Rotation + { + get { + if (m_parentID != 0) + { + if (m_offsetRotation != null) + { + return m_offsetRotation; + } + else + { + return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + + } + else + { + return m_bodyRot; + } + } + set { + m_bodyRot = value; + if (m_parentID != 0) + { + m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + } + } + + public Quaternion PreviousRotation + { + get { return m_bodyRotPrevious; } + set { m_bodyRotPrevious = value; } + } + + /// + /// If this is true, agent doesn't have a representation in this scene. + /// this is an agent 'looking into' this scene from a nearby scene(region) + /// + /// if False, this agent has a representation in this scene + /// + private bool m_isChildAgent = true; + + public bool IsChildAgent + { + get { return m_isChildAgent; } + set { m_isChildAgent = value; } + } + + private uint m_parentID; + + + private UUID m_linkedPrim; + + public uint ParentID + { + get { return m_parentID; } + set { m_parentID = value; } + } + + public UUID LinkedPrim + { + get { return m_linkedPrim; } + set { m_linkedPrim = value; } + } + + public float Health + { + get { return m_health; } + set { m_health = value; } + } + + /// + /// These are the region handles known by the avatar. + /// + public List KnownChildRegionHandles + { + get + { + if (m_knownChildRegions.Count == 0) + return new List(); + else + return new List(m_knownChildRegions.Keys); + } + } + + public Dictionary KnownRegions + { + get { return m_knownChildRegions; } + set + { + m_knownChildRegions = value; + } + } + + public ISceneViewer SceneViewer + { + get { return m_sceneViewer; } + } + + public void AdjustKnownSeeds() + { + Dictionary seeds; + + if (Scene.CapsModule != null) + seeds = Scene.CapsModule.GetChildrenSeeds(UUID); + else + seeds = new Dictionary(); + + List old = new List(); + foreach (ulong handle in seeds.Keys) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) + { + old.Add(handle); + } + } + DropOldNeighbours(old); + + if (Scene.CapsModule != null) + Scene.CapsModule.SetChildrenSeed(UUID, seeds); + + KnownRegions = seeds; + //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); + //DumpKnownRegions(); + } + + public void DumpKnownRegions() + { + m_log.Info("================ KnownRegions "+Scene.RegionInfo.RegionName+" ================"); + foreach (KeyValuePair kvp in KnownRegions) + { + uint x, y; + Utils.LongToUInts(kvp.Key, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + m_log.Info(" >> "+x+", "+y+": "+kvp.Value); + } + } + + private bool m_inTransit; + private bool m_mouseLook; + private bool m_leftButtonDown; + + public bool IsInTransit + { + get { return m_inTransit; } + set { m_inTransit = value; } + } + + public float SpeedModifier + { + get { return m_speedModifier; } + set { m_speedModifier = value; } + } + + public bool ForceFly + { + get { return m_forceFly; } + set { m_forceFly = value; } + } + + public bool FlyDisabled + { + get { return m_flyDisabled; } + set { m_flyDisabled = value; } + } + + public string Viewer + { + get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } + } + + #endregion + + #region Constructor(s) + + public ScenePresence() + { + m_sendCourseLocationsMethod = SendCoarseLocationsDefault; + CreateSceneViewer(); + m_animator = new ScenePresenceAnimator(this); + } + + private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() + { + m_rootRegionHandle = reginfo.RegionHandle; + m_controllingClient = client; + m_firstname = m_controllingClient.FirstName; + m_lastname = m_controllingClient.LastName; + m_name = String.Format("{0} {1}", m_firstname, m_lastname); + m_scene = world; + m_uuid = client.AgentId; + m_regionInfo = reginfo; + m_localId = m_scene.AllocateLocalId(); + + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); + + if (account != null) + m_userLevel = account.UserLevel; + + IGroupsModule gm = m_scene.RequestModuleInterface(); + if (gm != null) + m_grouptitle = gm.GetGroupTitle(m_uuid); + + m_scriptEngines = m_scene.RequestModuleInterfaces(); + + AbsolutePosition = posLastSignificantMove = m_CameraCenter = + m_lastCameraCenter = m_controllingClient.StartPos; + + m_reprioritization_timer = new Timer(world.ReprioritizationInterval); + m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); + m_reprioritization_timer.AutoReset = false; + + AdjustKnownSeeds(); + Animator.TrySetMovementAnimation("STAND"); + // we created a new ScenePresence (a new child agent) in a fresh region. + // Request info about all the (root) agents in this region + // Note: This won't send data *to* other clients in that region (children don't send) + SendInitialFullUpdateToAllClients(); + RegisterToEvents(); + if (m_controllingClient != null) + { + m_controllingClient.ProcessPendingPackets(); + } + SetDirectionVectors(); + } + + public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, + AvatarWearable[] wearables) + : this(client, world, reginfo) + { + m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); + } + + public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) + : this(client, world, reginfo) + { + m_appearance = appearance; + } + + private void CreateSceneViewer() + { + m_sceneViewer = new SceneViewer(this); + } + + public void RegisterToEvents() + { + m_controllingClient.OnRequestWearables += SendWearables; + m_controllingClient.OnSetAppearance += SetAppearance; + m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; + //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; + m_controllingClient.OnAgentUpdate += HandleAgentUpdate; + m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; + m_controllingClient.OnAgentSit += HandleAgentSit; + m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; + m_controllingClient.OnStartAnim += HandleStartAnim; + m_controllingClient.OnStopAnim += HandleStopAnim; + m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; + m_controllingClient.OnAutoPilotGo += DoAutoPilot; + m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); + + // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); + // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); + } + + private void SetDirectionVectors() + { + Dir_Vectors[0] = Vector3.UnitX; //FORWARD + Dir_Vectors[1] = -Vector3.UnitX; //BACK + Dir_Vectors[2] = Vector3.UnitY; //LEFT + Dir_Vectors[3] = -Vector3.UnitY; //RIGHT + Dir_Vectors[4] = Vector3.UnitZ; //UP + Dir_Vectors[5] = -Vector3.UnitZ; //DOWN + Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE + Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE + Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE + Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE + Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge + } + + private Vector3[] GetWalkDirectionVectors() + { + Vector3[] vector = new Vector3[11]; + vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD + vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK + vector[2] = Vector3.UnitY; //LEFT + vector[3] = -Vector3.UnitY; //RIGHT + vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP + vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN + vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE + vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE + vector[8] = Vector3.UnitY; //LEFT_NUDGE + vector[9] = -Vector3.UnitY; //RIGHT_NUDGE + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE + return vector; + } + + private bool[] GetDirectionIsNudge() + { + bool[] isNudge = new bool[11]; + isNudge[0] = false; //FORWARD + isNudge[1] = false; //BACK + isNudge[2] = false; //LEFT + isNudge[3] = false; //RIGHT + isNudge[4] = false; //UP + isNudge[5] = false; //DOWN + isNudge[6] = true; //FORWARD_NUDGE + isNudge[7] = true; //BACK_NUDGE + isNudge[8] = true; //LEFT_NUDGE + isNudge[9] = true; //RIGHT_NUDGE + isNudge[10] = true; //DOWN_Nudge + return isNudge; + } + + + #endregion + + public uint GenerateClientFlags(UUID ObjectID) + { + return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); + } + + /// + /// Send updates to the client about prims which have been placed on the update queue. We don't + /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent + /// timestamp has already been sent. + /// + public void SendPrimUpdates() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + m_sceneViewer.SendPrimUpdates(); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + #region Status Methods + + /// + /// This turns a child agent, into a root agent + /// This is called when an agent teleports into a region, or if an + /// agent crosses into this region from a neighbor over the border + /// + public void MakeRootAgent(Vector3 pos, bool isFlying) + { + m_log.DebugFormat( + "[SCENE]: Upgrading child to root agent for {0} in {1}", + Name, m_scene.RegionInfo.RegionName); + + //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); + + IGroupsModule gm = m_scene.RequestModuleInterface(); + if (gm != null) + m_grouptitle = gm.GetGroupTitle(m_uuid); + + m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; + m_scene.SetRootAgentScene(m_uuid); + + // Moved this from SendInitialData to ensure that m_appearance is initialized + // before the inventory is processed in MakeRootAgent. This fixes a race condition + // related to the handling of attachments + //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); + if (m_scene.TestBorderCross(pos, Cardinals.E)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); + pos.X = crossedBorder.BorderLine.Z - 1; + } + + if (m_scene.TestBorderCross(pos, Cardinals.N)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); + pos.Y = crossedBorder.BorderLine.Z - 1; + } + + //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. + //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, + //they'll bypass the landing point. But I can't think of any decent way of fixing this. + if (KnownChildRegionHandles.Count == 0) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + { + pos = land.LandData.UserLocation; + } + } + } + + if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) + { + Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); + + if (pos.X < 0) + { + emergencyPos.X = (int)Constants.RegionSize + pos.X; + if (!(pos.Y < 0)) + emergencyPos.Y = pos.Y; + if (!(pos.Z < 0)) + emergencyPos.Z = pos.Z; + } + if (pos.Y < 0) + { + emergencyPos.Y = (int)Constants.RegionSize + pos.Y; + if (!(pos.X < 0)) + emergencyPos.X = pos.X; + if (!(pos.Z < 0)) + emergencyPos.Z = pos.Z; + } + if (pos.Z < 0) + { + emergencyPos.Z = 128; + if (!(pos.Y < 0)) + emergencyPos.Y = pos.Y; + if (!(pos.X < 0)) + emergencyPos.X = pos.X; + } + } + + if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", + pos, Name, UUID); + + if (pos.X < 0f) pos.X = 0f; + if (pos.Y < 0f) pos.Y = 0f; + if (pos.Z < 0f) pos.Z = 0f; + } + + float localAVHeight = 1.56f; + if (m_avHeight != 127.0f) + { + localAVHeight = m_avHeight; + } + + float posZLimit = 0; + + if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) + posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; + + float newPosZ = posZLimit + localAVHeight / 2; + if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + pos.Z = newPosZ; + } + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + + if (m_forceFly) + { + m_physicsActor.Flying = true; + } + else if (m_flyDisabled) + { + m_physicsActor.Flying = false; + } + + if (m_appearance != null) + { + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + } + else + { + m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); + // emergency; this really shouldn't happen + m_appearance = new AvatarAppearance(UUID); + } + + // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying + // avatar to return to the standing position in mid-air. On login it looks like this is being sent + // elsewhere anyway + // Animator.SendAnimPack(); + + m_scene.SwapRootAgentCount(false); + + //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); + //if (userInfo != null) + // userInfo.FetchInventory(); + //else + // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); + + // On the next prim update, all objects will be sent + // + m_sceneViewer.Reset(); + + m_isChildAgent = false; + + // send the animations of the other presences to me + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + if (presence != this) + presence.Animator.SendAnimPackToClient(ControllingClient); + }); + + m_scene.EventManager.TriggerOnMakeRootAgent(this); + } + + /// + /// This turns a root agent into a child agent + /// when an agent departs this region for a neighbor, this gets called. + /// + /// It doesn't get called for a teleport. Reason being, an agent that + /// teleports out may not end up anywhere near this region + /// + public void MakeChildAgent() + { + // It looks like m_animator is set to null somewhere, and MakeChild + // is called after that. Probably in aborted teleports. + if (m_animator == null) + m_animator = new ScenePresenceAnimator(this); + else + Animator.ResetAnimations(); + +// m_log.DebugFormat( +// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", +// Name, UUID, m_scene.RegionInfo.RegionName); + + // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, + // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. + //Velocity = new Vector3(0, 0, 0); + + m_isChildAgent = true; + m_scene.SwapRootAgentCount(true); + RemoveFromPhysicalScene(); + + // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into + + m_scene.EventManager.TriggerOnMakeChildAgent(this); + } + + /// + /// Removes physics plugin scene representation of this agent if it exists. + /// + private void RemoveFromPhysicalScene() + { + if (PhysicsActor != null) + { + m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; + m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); + m_physicsActor.UnSubscribeEvents(); + m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor = null; + } + } + + /// + /// + /// + /// + public void Teleport(Vector3 pos) + { + bool isFlying = false; + + if (m_physicsActor != null) + isFlying = m_physicsActor.Flying; + + RemoveFromPhysicalScene(); + Velocity = Vector3.Zero; + AbsolutePosition = pos; + AddToPhysicalScene(isFlying); + if (m_appearance != null) + { + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + } + + SendTerseUpdateToAllClients(); + + } + + public void TeleportWithMomentum(Vector3 pos) + { + bool isFlying = false; + if (m_physicsActor != null) + isFlying = m_physicsActor.Flying; + + RemoveFromPhysicalScene(); + AbsolutePosition = pos; + AddToPhysicalScene(isFlying); + if (m_appearance != null) + { + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + } + + SendTerseUpdateToAllClients(); + } + + /// + /// + /// + public void StopMovement() + { + } + + public void StopFlying() + { + ControllingClient.StopFlying(this); + } + + public void AddNeighbourRegion(ulong regionHandle, string cap) + { + lock (m_knownChildRegions) + { + if (!m_knownChildRegions.ContainsKey(regionHandle)) + { + uint x, y; + Utils.LongToUInts(regionHandle, out x, out y); + m_knownChildRegions.Add(regionHandle, cap); + } + } + } + + public void RemoveNeighbourRegion(ulong regionHandle) + { + lock (m_knownChildRegions) + { + if (m_knownChildRegions.ContainsKey(regionHandle)) + { + m_knownChildRegions.Remove(regionHandle); + //m_log.Debug(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); + } + } + } + + public void DropOldNeighbours(List oldRegions) + { + foreach (ulong handle in oldRegions) + { + RemoveNeighbourRegion(handle); + Scene.CapsModule.DropChildSeed(UUID, handle); + } + } + + public List GetKnownRegionList() + { + return new List(m_knownChildRegions.Keys); + } + + #endregion + + #region Event Handlers + + /// + /// Sets avatar height in the phyiscs plugin + /// + internal void SetHeight(float height) + { + m_avHeight = height; + if (PhysicsActor != null && !IsChildAgent) + { + Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); + PhysicsActor.Size = SetSize; + } + } + + /// + /// Complete Avatar's movement into the region. + /// This is called upon a very important packet sent from the client, + /// so it's client-controlled. Never call this method directly. + /// + public void CompleteMovement(IClientAPI client) + { + //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); + + Vector3 look = Velocity; + if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) + { + look = new Vector3(0.99f, 0.042f, 0); + } + + // Prevent teleporting to an underground location + // (may crash client otherwise) + // + Vector3 pos = AbsolutePosition; + float ground = m_scene.GetGroundHeight(pos.X, pos.Y); + if (pos.Z < ground + 1.5f) + { + pos.Z = ground + 1.5f; + AbsolutePosition = pos; + } + m_isChildAgent = false; + bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + MakeRootAgent(AbsolutePosition, m_flying); + + if ((m_callbackURI != null) && !m_callbackURI.Equals("")) + { + m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); + Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); + m_callbackURI = null; + } + + //m_log.DebugFormat("Completed movement"); + + m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); + SendInitialData(); + + // Create child agents in neighbouring regions + if (!m_isChildAgent) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); + else + m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); + + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + } + + } + + /// + /// Callback for the Camera view block check. Gets called with the results of the camera view block test + /// hitYN is true when there's something in the way. + /// + /// + /// + /// + /// + public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) + { + const float POSITION_TOLERANCE = 0.02f; + const float VELOCITY_TOLERANCE = 0.02f; + const float ROTATION_TOLERANCE = 0.02f; + + if (m_followCamAuto) + { + if (hitYN) + { + CameraConstraintActive = true; + //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); + + Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); + ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); + } + else + { + if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) + { + if (CameraConstraintActive) + { + ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); + CameraConstraintActive = false; + } + } + } + } + } + + /// + /// This is the event handler for client movement. If a client is moving, this event is triggering. + /// + public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) + { + //if (m_isChildAgent) + //{ + // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); + // return; + //} + + m_perfMonMS = Util.EnvironmentTickCount(); + + ++m_movementUpdateCount; + if (m_movementUpdateCount < 1) + m_movementUpdateCount = 1; + + #region Sanity Checking + + // This is irritating. Really. + if (!AbsolutePosition.IsFinite()) + { + RemoveFromPhysicalScene(); + m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); + + m_pos = m_LastFinitePos; + + if (!m_pos.IsFinite()) + { + m_pos.X = 127f; + m_pos.Y = 127f; + m_pos.Z = 127f; + m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); + } + + AddToPhysicalScene(false); + } + else + { + m_LastFinitePos = m_pos; + } + + #endregion Sanity Checking + + #region Inputs + + AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; + Quaternion bodyRotation = agentData.BodyRotation; + + // Camera location in world. We'll need to raytrace + // from this location from time to time. + m_CameraCenter = agentData.CameraCenter; + if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) + { + ReprioritizeUpdates(); + m_lastCameraCenter = m_CameraCenter; + } + + // Use these three vectors to figure out what the agent is looking at + // Convert it to a Matrix and/or Quaternion + m_CameraAtAxis = agentData.CameraAtAxis; + m_CameraLeftAxis = agentData.CameraLeftAxis; + m_CameraUpAxis = agentData.CameraUpAxis; + + // The Agent's Draw distance setting + m_DrawDistance = agentData.Far; + + // Check if Client has camera in 'follow cam' or 'build' mode. + Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); + + m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) + && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; + + m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; + m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; + + #endregion Inputs + + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + { + StandUp(); + } + + //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); + // Raycast from the avatar's head to the camera to see if there's anything blocking the view + if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) + { + if (m_followCamAuto) + { + Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; + m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); + } + } + lock (scriptedcontrols) + { + if (scriptedcontrols.Count > 0) + { + SendControlToScripts((uint)flags); + flags = RemoveIgnoredControls(flags, IgnoredControls); + } + } + + if (m_autopilotMoving) + CheckAtSitTarget(); + + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) + { + m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. + Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); + + // TODO: This doesn't prevent the user from walking yet. + // Setting parent ID would fix this, if we knew what value + // to use. Or we could add a m_isSitting variable. + //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); + SitGround = true; + } + + // In the future, these values might need to go global. + // Here's where you get them. + m_AgentControlFlags = flags; + m_headrotation = agentData.HeadRotation; + m_state = agentData.State; + + PhysicsActor actor = PhysicsActor; + if (actor == null) + { + return; + } + + bool update_movementflag = false; + + if (m_allowMovement && !SitGround) + { + if (agentData.UseClientAgentPosition) + { + m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; + m_moveToPositionTarget = agentData.ClientAgentPosition; + } + + int i = 0; + + bool update_rotation = false; + bool DCFlagKeyPressed = false; + Vector3 agent_control_v3 = Vector3.Zero; + Quaternion q = bodyRotation; + + bool oldflying = PhysicsActor.Flying; + + if (m_forceFly) + actor.Flying = true; + else if (m_flyDisabled) + actor.Flying = false; + else + actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + + if (actor.Flying != oldflying) + update_movementflag = true; + + if (q != m_bodyRot) + { + m_bodyRot = q; + update_rotation = true; + } + + //guilty until proven innocent.. + bool Nudging = true; + //Basically, if there is at least one non-nudge control then we don't need + //to worry about stopping the avatar + + if (m_parentID == 0) + { + bool bAllowUpdateMoveToPosition = false; + bool bResetMoveToPosition = false; + + Vector3[] dirVectors; + + // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying + // this prevents 'jumping' in inappropriate situations. + if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) + dirVectors = GetWalkDirectionVectors(); + else + dirVectors = Dir_Vectors; + + bool[] isNudge = GetDirectionIsNudge(); + + + + + + foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) + { + if (((uint)flags & (uint)DCF) != 0) + { + bResetMoveToPosition = true; + DCFlagKeyPressed = true; + try + { + agent_control_v3 += dirVectors[i]; + if (isNudge[i] == false) + { + Nudging = false; + } + } + catch (IndexOutOfRangeException) + { + // Why did I get this? + } + + if ((m_movementflag & (uint)DCF) == 0) + { + m_movementflag += (byte)(uint)DCF; + update_movementflag = true; + } + } + else + { + if ((m_movementflag & (uint)DCF) != 0) + { + m_movementflag -= (byte)(uint)DCF; + update_movementflag = true; + } + else + { + bAllowUpdateMoveToPosition = true; + } + } + i++; + } + //Paupaw:Do Proper PID for Autopilot here + if (bResetMoveToPosition) + { + m_moveToPositionTarget = Vector3.Zero; + m_moveToPositionInProgress = false; + update_movementflag = true; + bAllowUpdateMoveToPosition = false; + } + + if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) + { + //Check the error term of the current position in relation to the target position + if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) + { + // we are close enough to the target + m_moveToPositionTarget = Vector3.Zero; + m_moveToPositionInProgress = false; + update_movementflag = true; + } + else + { + try + { + // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. + // This movement vector gets added to the velocity through AddNewMovement(). + // Theoretically we might need a more complex PID approach here if other + // unknown forces are acting on the avatar and we need to adaptively respond + // to such forces, but the following simple approach seems to works fine. + Vector3 LocalVectorToTarget3D = + (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords + * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords + // Ignore z component of vector + Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); + LocalVectorToTarget2D.Normalize(); + + //We're not nudging + Nudging = false; + agent_control_v3 += LocalVectorToTarget2D; + + // update avatar movement flags. the avatar coordinate system is as follows: + // + // +X (forward) + // + // ^ + // | + // | + // | + // | + // (left) +Y <--------o--------> -Y + // avatar + // | + // | + // | + // | + // v + // -X + // + + // based on the above avatar coordinate system, classify the movement into + // one of left/right/back/forward. + if (LocalVectorToTarget2D.Y > 0)//MoveLeft + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; + //AgentControlFlags + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; + update_movementflag = true; + } + else if (LocalVectorToTarget2D.Y < 0) //MoveRight + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; + update_movementflag = true; + } + if (LocalVectorToTarget2D.X < 0) //MoveBack + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; + update_movementflag = true; + } + else if (LocalVectorToTarget2D.X > 0) //Move Forward + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; + update_movementflag = true; + } + } + catch (Exception e) + { + //Avoid system crash, can be slower but... + m_log.DebugFormat("Crash! {0}", e.ToString()); + } + } + } + } + + // Cause the avatar to stop flying if it's colliding + // with something with the down arrow pressed. + + // Only do this if we're flying + if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) + { + // Landing detection code + + // Are the landing controls requirements filled? + bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + + // Are the collision requirements fulfilled? + bool colliding = (m_physicsActor.IsColliding == true); + + if (m_physicsActor.Flying && colliding && controlland) + { + // nesting this check because LengthSquared() is expensive and we don't + // want to do it every step when flying. + if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) + StopFlying(); + } + } + + if (update_movementflag || (update_rotation && DCFlagKeyPressed)) + { + // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); + // m_log.DebugFormat( + // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); + + AddNewMovement(agent_control_v3, q, Nudging); + + + } + } + + if (update_movementflag && !SitGround) + Animator.UpdateMovementAnimations(); + + m_scene.EventManager.TriggerOnClientMovement(this); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) + { + m_autopilotMoving = true; + m_autoPilotTarget = Pos; + m_sitAtAutoTarget = false; + PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; + //proxy.PCode = (byte)PCode.ParticleSystem; + proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); + proxyObjectGroup.AttachToScene(m_scene); + + // Commented out this code since it could never have executed, but might still be informative. +// if (proxyObjectGroup != null) +// { + proxyObjectGroup.SendGroupFullUpdate(); + remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); + m_scene.DeleteSceneObject(proxyObjectGroup, false); +// } +// else +// { +// m_autopilotMoving = false; +// m_autoPilotTarget = Vector3.Zero; +// ControllingClient.SendAlertMessage("Autopilot cancelled"); +// } + } + + public void DoMoveToPosition(Object sender, string method, List args) + { + try + { + float locx = 0f; + float locy = 0f; + float locz = 0f; + uint regionX = 0; + uint regionY = 0; + try + { + Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); + locx = Convert.ToSingle(args[0]) - (float)regionX; + locy = Convert.ToSingle(args[1]) - (float)regionY; + locz = Convert.ToSingle(args[2]); + } + catch (InvalidCastException) + { + m_log.Error("[CLIENT]: Invalid autopilot request"); + return; + } + m_moveToPositionInProgress = true; + m_moveToPositionTarget = new Vector3(locx, locy, locz); + } + catch (Exception ex) + { + //Why did I get this error? + m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); + } + } + + private void CheckAtSitTarget() + { + //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); + if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) + { + if (m_sitAtAutoTarget) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); + if (part != null) + { + AbsolutePosition = part.AbsolutePosition; + Velocity = Vector3.Zero; + SendFullUpdateToAllClients(); + + HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? + } + //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); + m_requestedSitTargetUUID = UUID.Zero; + } + /* + else + { + //ControllingClient.SendAlertMessage("Autopilot cancelled"); + //SendTerseUpdateToAllClients(); + //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; + //proxy.PCode = (byte)PCode.ParticleSystem; + ////uint nextUUID = m_scene.NextLocalId; + + //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); + //if (proxyObjectGroup != null) + //{ + //proxyObjectGroup.SendGroupFullUpdate(); + //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); + //m_scene.DeleteSceneObject(proxyObjectGroup); + //} + } + */ + m_autoPilotTarget = Vector3.Zero; + m_autopilotMoving = false; + } + } + /// + /// Perform the logic necessary to stand the avatar up. This method also executes + /// the stand animation. + /// + public void StandUp() + { + SitGround = false; + + if (m_parentID != 0) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + if (part != null) + { + part.TaskInventory.LockItemsForRead(true); + TaskInventoryDictionary taskIDict = part.TaskInventory; + if (taskIDict != null) + { + foreach (UUID taskID in taskIDict.Keys) + { + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS + } + } + part.TaskInventory.LockItemsForRead(false); + // Reset sit target. + if (part.GetAvatarOnSitTarget() == UUID) + part.SetAvatarOnSitTarget(UUID.Zero); + m_parentPosition = part.GetWorldPosition(); + ControllingClient.SendClearFollowCamProperties(part.ParentUUID); + } + // part.GetWorldRotation() is the rotation of the object being sat on + // Rotation is the sittiing Av's rotation + + Quaternion partRot; +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim + +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); + } + + Quaternion partIRot = Quaternion.Inverse(partRot); + + Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av + Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av + + + if (m_physicsActor == null) + { + AddToPhysicalScene(false); + } + //CW: If the part isn't null then we can set the current position + if (part != null) + { + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. + part.IsOccupied = false; + part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); + } + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; + } + + m_parentPosition = Vector3.Zero; + m_parentID = 0; + m_linkedPrim = UUID.Zero; + m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + SendFullUpdateToAllClients(); + m_requestedSitTargetID = 0; + + if ((m_physicsActor != null) && (m_avHeight > 0)) + { + SetHeight(m_avHeight); + } + } + Animator.TrySetMovementAnimation("STAND"); + } + + private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) + { + SceneObjectPart targetPart = m_scene.GetSceneObjectPart(targetID); + if (targetPart == null) + return null; + + // If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used. + // If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used. + + // Get our own copy of the part array, and sort into the order we want to test + SceneObjectPart[] partArray = targetPart.ParentGroup.GetParts(); + Array.Sort(partArray, delegate(SceneObjectPart p1, SceneObjectPart p2) + { + // we want the originally selected part first, then the rest in link order -- so make the selected part link num (-1) + int linkNum1 = p1==targetPart ? -1 : p1.LinkNum; + int linkNum2 = p2==targetPart ? -1 : p2.LinkNum; + return linkNum1 - linkNum2; + } + ); + + //look for prims with explicit sit targets that are available + foreach (SceneObjectPart part in partArray) + { + // Is a sit target available? + Vector3 avSitOffSet = part.SitTargetPosition; + Quaternion avSitOrientation = part.SitTargetOrientation; + UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); + bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); + bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. + if (SitTargetisSet && !SitTargetOccupied) + { + //switch the target to this prim + return part; + } + } + + // no explicit sit target found - use original target + return targetPart; + } + + private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) + { + bool autopilot = true; + Vector3 autopilotTarget = new Vector3(); + Quaternion sitOrientation = Quaternion.Identity; + Vector3 pos = new Vector3(); + Vector3 cameraEyeOffset = Vector3.Zero; + Vector3 cameraAtOffset = Vector3.Zero; + bool forceMouselook = false; + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + if (part == null) return; + + // TODO: determine position to sit at based on scene geometry; don't trust offset from client + // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it + + // part is the prim to sit on + // offset is the world-ref vector distance from that prim center to the click-spot + // UUID is the UUID of the Avatar doing the clicking + + m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation + + // Is a sit target available? + Vector3 avSitOffSet = part.SitTargetPosition; + Quaternion avSitOrientation = part.SitTargetOrientation; + + bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. + // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + Quaternion partRot; +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim + partRot = part.GetWorldRotation(); +// } + Quaternion partIRot = Quaternion.Inverse(partRot); +//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); + // Sit analysis rewritten by KF 091125 + if (SitTargetisSet) // scipted sit + { + if (!part.IsOccupied) + { +//Console.WriteLine("Scripted, unoccupied"); + part.SetAvatarOnSitTarget(UUID); // set that Av will be on it + offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one + + Quaternion nrot = avSitOrientation; + if (!part.IsRoot) + { + nrot = part.RotationOffset * avSitOrientation; + } + sitOrientation = nrot; // Change rotatione to the scripted one + OffsetRotation = nrot; + autopilot = false; // Jump direct to scripted llSitPos() + } + else + { +//Console.WriteLine("Scripted, occupied"); + return; + } + } + else // Not Scripted + { + if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) + { + // large prim & offset, ignore if other Avs sitting +// offset.Z -= 0.05f; + m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked + autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point + +//Console.WriteLine(" offset ={0}", offset); +//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); +//Console.WriteLine(" autopilotTarget={0}", autopilotTarget); + + } + else // small offset + { +//Console.WriteLine("Small offset"); + if (!part.IsOccupied) + { + m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center + autopilotTarget = part.AbsolutePosition; +//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); + } + else return; // occupied small + } // end large/small + } // end Scripted/not + cameraAtOffset = part.GetCameraAtOffset(); + cameraEyeOffset = part.GetCameraEyeOffset(); + forceMouselook = part.GetForceMouselook(); + if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // + if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // + + if (m_physicsActor != null) + { + // If we're not using the client autopilot, we're immediately warping the avatar to the location + // We can remove the physicsActor until they stand up. + m_sitAvatarHeight = m_physicsActor.Size.Z; + if (autopilot) + { // its not a scripted sit +// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) + if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) + { + autopilot = false; // close enough + m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. + Not using the part's position because returning the AV to the last known standing + position is likely to be more friendly, isn't it? */ + RemoveFromPhysicalScene(); + AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target + } // else the autopilot will get us close + } + else + { // its a scripted sit + m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. + I *am* using the part's position this time because we have no real idea how far away + the avatar is from the sit target. */ + RemoveFromPhysicalScene(); + } + } + else return; // physactor is null! + + Vector3 offsetr; // = offset * partIRot; + // KF: In a linkset, offsetr needs to be relative to the group root! 091208 + // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); + // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. + // { // Single, or Root prim of linkset, target is ClickOffset * RootRot + //offsetr = offset * partIRot; +// + // else + // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) + // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + + // (offset * partRot); + // } + +//Console.WriteLine(" "); +//Console.WriteLine("link number ={0}", part.LinkNum); +//Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); +//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); +//Console.WriteLine("Click offst ={0}", offset); +//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); +//Console.WriteLine("offsetr ={0}", offsetr); +//Console.WriteLine("Camera At ={0}", cameraAtOffset); +//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); + + //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child + ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + + m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target + // This calls HandleAgentSit twice, once from here, and the client calls + // HandleAgentSit itself after it gets to the location + // It doesn't get to the location until we've moved them there though + // which happens in HandleAgentSit :P + m_autopilotMoving = autopilot; + m_autoPilotTarget = autopilotTarget; + m_sitAtAutoTarget = autopilot; + m_initialSitTarget = autopilotTarget; + if (!autopilot) + HandleAgentSit(remoteClient, UUID); + } + + public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) + { + if (m_parentID != 0) + { + StandUp(); + } + m_nextSitAnimation = "SIT"; + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + + if (part != null) + { + if (!String.IsNullOrEmpty(part.SitAnimation)) + { + m_nextSitAnimation = part.SitAnimation; + } + m_requestedSitTargetID = part.LocalId; + //m_requestedSitOffset = offset; + m_requestedSitTargetUUID = targetID; + + m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); + + if (m_scene.PhysicsScene.SupportsRayCast()) + { + //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); + //SitRayCastAvatarPosition(part); + //return; + } + } + else + { + + m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); + } + + + + SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); + } + /* + public void SitRayCastAvatarPosition(SceneObjectPart part) + { + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = AbsolutePosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); + } + + public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); + } + else + { + SitRayCastAvatarPositionCameraZ(part); + } + } + else + { + SitRayCastAvatarPositionCameraZ(part); + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) + { + // Next, try to raycast from the camera Z position + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); + } + + public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); + } + else + { + SitRayCastCameraPosition(part); + } + } + else + { + SitRayCastCameraPosition(part); + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + public void SitRayCastCameraPosition(SceneObjectPart part) + { + // Next, try to raycast from the camera position + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = CameraPosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); + } + + public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); + } + else + { + SitRayHorizontal(part); + } + } + else + { + SitRayHorizontal(part); + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + public void SitRayHorizontal(SceneObjectPart part) + { + // Next, try to raycast from the avatar position to fwd + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = CameraPosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); + } + + public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); + // Next, try to raycast from the camera position + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = CameraPosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); + } + else + { + ControllingClient.SendAlertMessage("Sit position not accessable."); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + } + else + { + ControllingClient.SendAlertMessage("Sit position not accessable."); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) + { + int i = 0; + //throw new NotImplementedException(); + //m_requestedSitTargetUUID = UUID.Zero; + //m_requestedSitTargetID = 0; + //m_requestedSitOffset = Vector3.Zero; + + SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); + } + */ + public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) + { + if (m_parentID != 0) + { + StandUp(); + } + if (!String.IsNullOrEmpty(sitAnimation)) + { + m_nextSitAnimation = sitAnimation; + } + else + { + m_nextSitAnimation = "SIT"; + } + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + if (part != null) + { + m_requestedSitTargetID = part.LocalId; + //m_requestedSitOffset = offset; + m_requestedSitTargetUUID = targetID; + + m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); + + if (m_scene.PhysicsScene.SupportsRayCast()) + { + //SitRayCastAvatarPosition(part); + //return; + } + } + else + { + m_log.Warn("Sit requested on unknown object: " + targetID); + } + + SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); + } + + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) + { + if (!String.IsNullOrEmpty(m_nextSitAnimation)) + { + HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); + } + else + { + HandleAgentSit(remoteClient, agentID, "SIT"); + } + } + + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + + if (m_sitAtAutoTarget || !m_autopilotMoving) + { + if (part != null) + { +//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); + if (part.GetAvatarOnSitTarget() == UUID) + { +//Console.WriteLine("Scripted Sit"); + // Scripted sit + Vector3 sitTargetPos = part.SitTargetPosition; + Quaternion sitTargetOrient = part.SitTargetOrientation; + m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); + m_pos += SIT_TARGET_ADJUSTMENT; + if (!part.IsRoot) + { + m_pos *= part.RotationOffset; + } + m_bodyRot = sitTargetOrient; + m_parentPosition = part.AbsolutePosition; + part.IsOccupied = true; + part.ParentGroup.AddAvatar(agentID); +Console.WriteLine("Scripted Sit ofset {0}", m_pos); + } + else + { + // if m_avUnscriptedSitPos is zero then Av sits above center + // Else Av sits at m_avUnscriptedSitPos + + // Non-scripted sit by Kitto Flora 21Nov09 + // Calculate angle of line from prim to Av + Quaternion partIRot; +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim + partIRot = Quaternion.Inverse(part.GetWorldRotation()); +// } + Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; + float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); + float x_diff = ( m_avInitialPos.X - sitTargetPos.X); + if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 + if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 + float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); + // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. + // Av sits at world euler <0,0, z>, translated by part rotation + m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click + + m_parentPosition = part.AbsolutePosition; + part.IsOccupied = true; + part.ParentGroup.AddAvatar(agentID); + m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation + (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center + (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + + m_avUnscriptedSitPos; // adds click offset, if any + //Set up raytrace to find top surface of prim + Vector3 size = part.Scale; + float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); + Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); + Vector3 down = new Vector3(0f, 0f, -1f); +//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); + m_scene.PhysicsScene.RaycastWorld( + start, // Vector3 position, + down, // Vector3 direction, + mag, // float length, + SitAltitudeCallback); // retMethod + } // end scripted/not + } + else // no Av + { + return; + } + } + + //We want our offsets to reference the root prim, not the child we may have sat on + if (!part.IsRoot) + { + m_parentID = part.ParentGroup.RootPart.LocalId; + m_pos += part.OffsetPosition; + } + else + { + m_parentID = m_requestedSitTargetID; + } + + m_linkedPrim = part.UUID; + + Velocity = Vector3.Zero; + RemoveFromPhysicalScene(); + Animator.TrySetMovementAnimation(sitAnimation); + SendFullUpdateToAllClients(); + SendTerseUpdateToAllClients(); + } + + public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) + { + // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer + // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. + if(hitYN) + { + // m_pos = Av offset from prim center to make look like on center + // m_parentPosition = Actual center pos of prim + // collisionPoint = spot on prim where we want to sit + // collisionPoint.Z = global sit surface height + SceneObjectPart part = m_scene.GetSceneObjectPart(localid); + Quaternion partIRot; +// if (part.LinkNum == 1) +/// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim + partIRot = Quaternion.Inverse(part.GetWorldRotation()); +// } + if (m_initialSitTarget != null) + { + float offZ = collisionPoint.Z - m_initialSitTarget.Z; + Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction + //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); + m_pos += offset; + // ControllingClient.SendClearFollowCamProperties(part.UUID); + } + + } + } // End SitAltitudeCallback KF. + + /// + /// Event handler for the 'Always run' setting on the client + /// Tells the physics plugin to increase speed of movement. + /// + public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) + { + m_setAlwaysRun = pSetAlwaysRun; + if (PhysicsActor != null) + { + PhysicsActor.SetAlwaysRun = pSetAlwaysRun; + } + } + + public void HandleStartAnim(IClientAPI remoteClient, UUID animID) + { + Animator.AddAnimation(animID, UUID.Zero); + } + + public void HandleStopAnim(IClientAPI remoteClient, UUID animID) + { + Animator.RemoveAnimation(animID); + } + + /// + /// Rotate the avatar to the given rotation and apply a movement in the given relative vector + /// + /// The vector in which to move. This is relative to the rotation argument + /// The direction in which this avatar should now face. + public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) + { + if (m_isChildAgent) + { + // WHAT??? + m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); + + // we have to reset the user's child agent connections. + // Likely, here they've lost the eventqueue for other regions so border + // crossings will fail at this point unless we reset them. + + List regions = new List(KnownChildRegionHandles); + regions.Remove(m_scene.RegionInfo.RegionHandle); + + MakeRootAgent(new Vector3(127f, 127f, 127f), true); + + // Async command + if (m_scene.SceneGridService != null) + { + m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); + + // Give the above command some time to try and close the connections. + // this is really an emergency.. so sleep, or we'll get all discombobulated. + System.Threading.Thread.Sleep(500); + } + + if (m_scene.SceneGridService != null) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); + } + + return; + } + + m_perfMonMS = Util.EnvironmentTickCount(); + + Rotation = rotation; + Vector3 direc = vec * rotation; + direc.Normalize(); + PhysicsActor actor = m_physicsActor; + if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. + + direc *= 0.03f * 128f * m_speedModifier; + + if (actor != null) + { + if (actor.Flying) + { + direc *= 4.0f; + //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + //bool colliding = (m_physicsActor.IsColliding==true); + //if (controlland) + // m_log.Info("[AGENT]: landCommand"); + //if (colliding) + // m_log.Info("[AGENT]: colliding"); + //if (m_physicsActor.Flying && colliding && controlland) + //{ + // StopFlying(); + // m_log.Info("[AGENT]: Stop FLying"); + //} + } + else if (!actor.Flying && actor.IsColliding) + { + if (direc.Z > 2.0f) + { + if(m_animator.m_animTickJump == -1) + { + direc.Z *= 3.0f; // jump + } + else + { + direc.Z *= 0.1f; // prejump + } + /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs + Animator.TrySetMovementAnimation("PREJUMP"); + Animator.TrySetMovementAnimation("JUMP"); + */ + } + } + } + + // TODO: Add the force instead of only setting it to support multiple forces per frame? + m_forceToApply = direc; + m_isNudging = Nudging; + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + #endregion + + #region Overridden Methods + + public override void Update() + { + const float ROTATION_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.001f; + const float POSITION_TOLERANCE = 0.05f; + //const int TIME_MS_TOLERANCE = 3000; + + + + if (m_isChildAgent == false) + { +// PhysicsActor actor = m_physicsActor; + + // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to + // grab the latest PhysicsActor velocity, whereas m_velocity is often + // storing a requested force instead of an actual traveling velocity + + // Throw away duplicate or insignificant updates + if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) + //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) + { + SendTerseUpdateToAllClients(); + + // Update the "last" values + m_lastPosition = m_pos; + m_lastRotation = m_bodyRot; + m_lastVelocity = Velocity; + //m_lastTerseSent = Environment.TickCount; + } + + // followed suggestion from mic bowman. reversed the two lines below. + if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something + CheckForBorderCrossing(); + CheckForSignificantMovement(); // sends update to the modules. + } + + //Sending prim updates AFTER the avatar terse updates are sent + SendPrimUpdates(); + } + + #endregion + + #region Update Client(s) + + /// + /// Sends a location update to the client connected to this scenePresence + /// + /// + public void SendTerseUpdateToClient(IClientAPI remoteClient) + { + // If the client is inactive, it's getting its updates from another + // server. + if (remoteClient.IsActive) + { + m_perfMonMS = Util.EnvironmentTickCount(); + + PhysicsActor actor = m_physicsActor; + Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); + + remoteClient.SendPrimUpdate(this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + m_scene.StatsReporter.AddAgentUpdates(1); + } + } + + /// + /// Send a location/velocity/accelleration update to all agents in scene + /// + public void SendTerseUpdateToAllClients() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + m_scene.ForEachClient(SendTerseUpdateToClient); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + public void SendCoarseLocations(List coarseLocations, List avatarUUIDs) + { + SendCourseLocationsMethod d = m_sendCourseLocationsMethod; + if (d != null) + { + d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); + } + } + + public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) + { + if (d != null) + m_sendCourseLocationsMethod = d; + } + + public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List coarseLocations, List avatarUUIDs) + { + m_perfMonMS = Util.EnvironmentTickCount(); + m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + /// + /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) + /// + /// + public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) + { + // 2 stage check is needed. + if (remoteAvatar == null) + return; + IClientAPI cl=remoteAvatar.ControllingClient; + if (cl == null) + return; + if (m_appearance.Texture == null) + return; + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); + m_scene.StatsReporter.AddAgentUpdates(1); + } + + /// + /// Tell *ALL* agents about this agent + /// + public void SendInitialFullUpdateToAllClients() + { + m_perfMonMS = Util.EnvironmentTickCount(); + int avUpdates = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence avatar) + { + ++avUpdates; + // only send if this is the root (children are only "listening posts" in a foreign region) + if (!IsChildAgent) + { + SendFullUpdateToOtherClient(avatar); + } + + if (avatar.LocalId != LocalId) + { + if (!avatar.IsChildAgent) + { + avatar.SendFullUpdateToOtherClient(this); + avatar.SendAppearanceToOtherAgent(this); + avatar.Animator.SendAnimPackToClient(ControllingClient); + } + } + }); + + m_scene.StatsReporter.AddAgentUpdates(avUpdates); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + + //Animator.SendAnimPack(); + } + + public void SendFullUpdateToAllClients() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + // only send update from root agents to other clients; children are only "listening posts" + int count = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence sp) + { + if (sp.IsChildAgent) + return; + SendFullUpdateToOtherClient(sp); + ++count; + }); + m_scene.StatsReporter.AddAgentUpdates(count); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + + Animator.SendAnimPack(); + } + + /// + /// Do everything required once a client completes its movement into a region + /// + public void SendInitialData() + { + // Moved this into CompleteMovement to ensure that m_appearance is initialized before + // the inventory arrives + // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + m_controllingClient.SendAvatarDataImmediate(this); + + SendInitialFullUpdateToAllClients(); + SendAppearanceToAllOtherAgents(); + } + + /// + /// Tell the client for this scene presence what items it should be wearing now + /// + public void SendWearables() + { + m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name); + + ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); + } + + /// + /// + /// + public void SendAppearanceToAllOtherAgents() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + { + if (scenePresence.UUID != UUID) + { + SendAppearanceToOtherAgent(scenePresence); + } + }); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + /// + /// Send appearance data to an agent that isn't this one. + /// + /// + public void SendAppearanceToOtherAgent(ScenePresence avatar) + { + avatar.ControllingClient.SendAppearance( + m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); + } + + /// + /// Set appearance data (textureentry and slider settings) received from the client + /// + /// + /// + public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) + { + if (m_physicsActor != null) + { + if (!IsChildAgent) + { + // This may seem like it's redundant, remove the avatar from the physics scene + // just to add it back again, but it saves us from having to update + // 3 variables 10 times a second. + bool flyingTemp = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); + + //PhysicsActor = null; + + AddToPhysicalScene(flyingTemp); + } + } + + #region Bake Cache Check + + if (textureEntry != null) + { + for (int i = 0; i < BAKE_INDICES.Length; i++) + { + int j = BAKE_INDICES[i]; + Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; + + if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + { + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + { + m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); + this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } + } + } + + } + + + #endregion Bake Cache Check + + m_appearance.SetAppearance(textureEntry, visualParams); + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + + // This is not needed, because only the transient data changed + //AvatarData adata = new AvatarData(m_appearance); + //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); + + SendAppearanceToAllOtherAgents(); + if (!m_startAnimationSet) + { + Animator.UpdateMovementAnimations(); + m_startAnimationSet = true; + } + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + m_controllingClient.SendAvatarDataImmediate(this); + } + + public void SetWearable(int wearableId, AvatarWearable wearable) + { + m_appearance.SetWearable(wearableId, wearable); + AvatarData adata = new AvatarData(m_appearance); + m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); + m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); + } + + // Because appearance setting is in a module, we actually need + // to give it access to our appearance directly, otherwise we + // get a synchronization issue. + public AvatarAppearance Appearance + { + get { return m_appearance; } + set { m_appearance = value; } + } + + #endregion + + #region Significant Movement Method + + /// + /// This checks for a significant movement and sends a courselocationchange update + /// + protected void CheckForSignificantMovement() + { + // Movement updates for agents in neighboring regions are sent directly to clients. + // This value only affects how often agent positions are sent to neighbor regions + // for things such as distance-based update prioritization + const float SIGNIFICANT_MOVEMENT = 2.0f; + + if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) + { + posLastSignificantMove = AbsolutePosition; + m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); + } + + // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m + if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || + Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) + { + m_lastChildAgentUpdatePosition = AbsolutePosition; + m_lastChildAgentUpdateCamPosition = CameraPosition; + + ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); + cadu.ActiveGroupID = UUID.Zero.Guid; + cadu.AgentID = UUID.Guid; + cadu.alwaysrun = m_setAlwaysRun; + cadu.AVHeight = m_avHeight; + Vector3 tempCameraCenter = m_CameraCenter; + cadu.cameraPosition = tempCameraCenter; + cadu.drawdistance = m_DrawDistance; + cadu.GroupAccess = 0; + cadu.Position = AbsolutePosition; + cadu.regionHandle = m_rootRegionHandle; + float multiplier = 1; + int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); + if (innacurateNeighbors != 0) + { + multiplier = 1f / (float)innacurateNeighbors; + } + if (multiplier <= 0f) + { + multiplier = 0.25f; + } + + //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); + cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); + cadu.Velocity = Velocity; + + AgentPosition agentpos = new AgentPosition(); + agentpos.CopyFrom(cadu); + + m_scene.SendOutChildAgentUpdates(agentpos, this); + } + } + + #endregion + + #region Border Crossing Methods + + /// + /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion + /// + protected void CheckForBorderCrossing() + { + if (IsChildAgent) + return; + + Vector3 pos2 = AbsolutePosition; + Vector3 vel = Velocity; + int neighbor = 0; + int[] fix = new int[2]; + + float timeStep = 0.1f; + pos2.X = pos2.X + (vel.X*timeStep); + pos2.Y = pos2.Y + (vel.Y*timeStep); + pos2.Z = pos2.Z + (vel.Z*timeStep); + + if (!IsInTransit) + { + // Checks if where it's headed exists a region + + bool needsTransit = false; + if (m_scene.TestBorderCross(pos2, Cardinals.W)) + { + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.SW, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.NW, ref fix); + } + else + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.W, ref fix); + } + } + else if (m_scene.TestBorderCross(pos2, Cardinals.E)) + { + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.SE, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.NE, ref fix); + } + else + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.E, ref fix); + } + } + else if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.S, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.N, ref fix); + } + + + // Makes sure avatar does not end up outside region + if (neighbor <= 0) + { + if (!needsTransit) + { + if (m_requestedSitTargetUUID == UUID.Zero) + { + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y; + AbsolutePosition = pos; + } + } + } + else if (neighbor > 0) + CrossToNewRegion(); + } + else + { + RemoveFromPhysicalScene(); + // This constant has been inferred from experimentation + // I'm not sure what this value should be, so I tried a few values. + timeStep = 0.04f; + pos2 = AbsolutePosition; + pos2.X = pos2.X + (vel.X * timeStep); + pos2.Y = pos2.Y + (vel.Y * timeStep); + pos2.Z = pos2.Z + (vel.Z * timeStep); + m_pos = pos2; + } + } + + protected int HaveNeighbor(Cardinals car, ref int[] fix) + { + uint neighbourx = m_regionInfo.RegionLocX; + uint neighboury = m_regionInfo.RegionLocY; + + int dir = (int)car; + + if (dir > 1 && dir < 5) //Heading East + neighbourx++; + else if (dir > 5) // Heading West + neighbourx--; + + if (dir < 3 || dir == 8) // Heading North + neighboury++; + else if (dir > 3 && dir < 7) // Heading Sout + neighboury--; + + int x = (int)(neighbourx * Constants.RegionSize); + int y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); + + if (neighbourRegion == null) + { + fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); + fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); + return dir * (-1); + } + else + return dir; + } + + /// + /// Moves the agent outside the region bounds + /// Tells neighbor region that we're crossing to it + /// If the neighbor accepts, remove the agent's viewable avatar from this scene + /// set them to a child agent. + /// + protected void CrossToNewRegion() + { + InTransit(); + try + { + m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); + } + catch + { + m_scene.CrossAgentToNewRegion(this, false); + } + } + + public void InTransit() + { + m_inTransit = true; + + if ((m_physicsActor != null) && m_physicsActor.Flying) + m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; + else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) + m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; + } + + public void NotInTransit() + { + m_inTransit = false; + } + + public void RestoreInCurrentScene() + { + AddToPhysicalScene(false); // not exactly false + } + + public void Reset() + { + // Put the child agent back at the center + AbsolutePosition + = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); + Animator.ResetAnimations(); + } + + /// + /// Computes which child agents to close when the scene presence moves to another region. + /// Removes those regions from m_knownRegions. + /// + /// The new region's x on the map + /// The new region's y on the map + /// + public void CloseChildAgents(uint newRegionX, uint newRegionY) + { + List byebyeRegions = new List(); + m_log.DebugFormat( + "[SCENE PRESENCE]: Closing child agents. Checking {0} regions in {1}", + m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName); + //DumpKnownRegions(); + + lock (m_knownChildRegions) + { + foreach (ulong handle in m_knownChildRegions.Keys) + { + // Don't close the agent on this region yet + if (handle != Scene.RegionInfo.RegionHandle) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + + //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); + //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); + if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) + { + byebyeRegions.Add(handle); + } + } + } + } + + if (byebyeRegions.Count > 0) + { + m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); + m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); + } + + foreach (ulong handle in byebyeRegions) + { + RemoveNeighbourRegion(handle); + } + } + + #endregion + + /// + /// This allows the Sim owner the abiility to kick users from their sim currently. + /// It tells the client that the agent has permission to do so. + /// + public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) + { + if (godStatus) + { + // For now, assign god level 200 to anyone + // who is granted god powers, but has no god level set. + // + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); + if (account != null) + { + if (account.UserLevel > 0) + m_godLevel = account.UserLevel; + else + m_godLevel = 200; + } + } + else + { + m_godLevel = 0; + } + + ControllingClient.SendAdminResponse(token, (uint)m_godLevel); + } + + #region Child Agent Updates + + public void ChildAgentDataUpdate(AgentData cAgentData) + { + //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); + if (!IsChildAgent) + return; + + CopyFrom(cAgentData); + } + + /// + /// This updates important decision making data about a child agent + /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region + /// + public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) + { + if (!IsChildAgent) + return; + + //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); + int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; + int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; + + Vector3 offset = new Vector3(shiftx, shifty, 0f); + + m_DrawDistance = cAgentData.Far; + if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! + m_pos = cAgentData.Position + offset; + + if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) + { + posLastSignificantMove = AbsolutePosition; + ReprioritizeUpdates(); + } + + m_CameraCenter = cAgentData.Center + offset; + + m_avHeight = cAgentData.Size.Z; + //SetHeight(cAgentData.AVHeight); + + if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) + ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); + + // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. + if (m_scene.m_seeIntoRegionFromNeighbor) + m_sceneViewer.Reset(); + + //cAgentData.AVHeight; + m_rootRegionHandle = cAgentData.RegionHandle; + //m_velocity = cAgentData.Velocity; + } + + public void CopyTo(AgentData cAgent) + { + cAgent.AgentID = UUID; + cAgent.RegionID = Scene.RegionInfo.RegionID; + + cAgent.Position = AbsolutePosition; + cAgent.Velocity = m_velocity; + cAgent.Center = m_CameraCenter; + // Don't copy the size; it is inferred from apearance parameters + //cAgent.Size = new Vector3(0, 0, m_avHeight); + cAgent.AtAxis = m_CameraAtAxis; + cAgent.LeftAxis = m_CameraLeftAxis; + cAgent.UpAxis = m_CameraUpAxis; + + cAgent.Far = m_DrawDistance; + + // Throttles + float multiplier = 1; + int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); + if (innacurateNeighbors != 0) + { + multiplier = 1f / innacurateNeighbors; + } + if (multiplier <= 0f) + { + multiplier = 0.25f; + } + //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); + cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); + + cAgent.HeadRotation = m_headrotation; + cAgent.BodyRotation = m_bodyRot; + cAgent.ControlFlags = (uint)m_AgentControlFlags; + + if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) + cAgent.GodLevel = (byte)m_godLevel; + else + cAgent.GodLevel = (byte) 0; + + cAgent.AlwaysRun = m_setAlwaysRun; + + try + { + // We might not pass the Wearables in all cases... + // They're only needed so that persistent changes to the appearance + // are preserved in the new region where the user is moving to. + // But in Hypergrid we might not let this happen. + int i = 0; + UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; + foreach (AvatarWearable aw in m_appearance.Wearables) + { + if (aw != null) + { + wears[i++] = aw.ItemID; + wears[i++] = aw.AssetID; + } + else + { + wears[i++] = UUID.Zero; + wears[i++] = UUID.Zero; + } + } + cAgent.Wearables = wears; + + cAgent.VisualParams = m_appearance.VisualParams; + + if (m_appearance.Texture != null) + cAgent.AgentTextures = m_appearance.Texture.GetBytes(); + } + catch (Exception e) + { + m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); + } + + //Attachments + List attPoints = m_appearance.GetAttachedPoints(); + if (attPoints != null) + { + //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); + int i = 0; + AttachmentData[] attachs = new AttachmentData[attPoints.Count]; + foreach (int point in attPoints) + { + attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); + } + cAgent.Attachments = attachs; + } + + lock (scriptedcontrols) + { + ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; + int i = 0; + + foreach (ScriptControllers c in scriptedcontrols.Values) + { + controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); + } + cAgent.Controllers = controls; + } + + // Animations + try + { + cAgent.Anims = Animator.Animations.ToArray(); + } + catch { } + + // cAgent.GroupID = ?? + // Groups??? + + } + + public void CopyFrom(AgentData cAgent) + { + m_originRegionID = cAgent.RegionID; + + m_callbackURI = cAgent.CallbackURI; + + m_pos = cAgent.Position; + + m_velocity = cAgent.Velocity; + m_CameraCenter = cAgent.Center; + //m_avHeight = cAgent.Size.Z; + m_CameraAtAxis = cAgent.AtAxis; + m_CameraLeftAxis = cAgent.LeftAxis; + m_CameraUpAxis = cAgent.UpAxis; + + m_DrawDistance = cAgent.Far; + + if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) + ControllingClient.SetChildAgentThrottle(cAgent.Throttles); + + m_headrotation = cAgent.HeadRotation; + m_bodyRot = cAgent.BodyRotation; + m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; + + if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) + m_godLevel = cAgent.GodLevel; + m_setAlwaysRun = cAgent.AlwaysRun; + + uint i = 0; + try + { + if (cAgent.Wearables == null) + cAgent.Wearables = new UUID[0]; + AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; + for (uint n = 0; n < cAgent.Wearables.Length; n += 2) + { + UUID itemId = cAgent.Wearables[n]; + UUID assetId = cAgent.Wearables[n + 1]; + wears[i++] = new AvatarWearable(itemId, assetId); + } + m_appearance.Wearables = wears; + Primitive.TextureEntry te; + if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) + te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); + else + te = AvatarAppearance.GetDefaultTexture(); + if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) + cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); + m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); + } + catch (Exception e) + { + m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); + } + + // Attachments + try + { + if (cAgent.Attachments != null) + { + m_appearance.ClearAttachments(); + foreach (AttachmentData att in cAgent.Attachments) + { + m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); + } + } + } + catch { } + + try + { + lock (scriptedcontrols) + { + if (cAgent.Controllers != null) + { + scriptedcontrols.Clear(); + + foreach (ControllerData c in cAgent.Controllers) + { + ScriptControllers sc = new ScriptControllers(); + sc.itemID = c.ItemID; + sc.ignoreControls = (ScriptControlled)c.IgnoreControls; + sc.eventControls = (ScriptControlled)c.EventControls; + + scriptedcontrols[sc.itemID] = sc; + } + } + } + } + catch { } + // Animations + try + { + Animator.ResetAnimations(); + Animator.Animations.FromArray(cAgent.Anims); + } + catch { } + + //cAgent.GroupID = ?? + //Groups??? + } + + public bool CopyAgent(out IAgentData agent) + { + agent = new CompleteAgentData(); + CopyTo((AgentData)agent); + return true; + } + + #endregion Child Agent Updates + + /// + /// Handles part of the PID controller function for moving an avatar. + /// + public override void UpdateMovement() + { + if (m_forceToApply.HasValue) + { + + Vector3 force = m_forceToApply.Value; + m_updateflag = true; + Velocity = force; + + m_forceToApply = null; + } + else + { + if (m_isNudging) + { + Vector3 force = Vector3.Zero; + + m_updateflag = true; + Velocity = force; + m_isNudging = false; + m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" + } + } + } + + public override void SetText(string text, Vector3 color, double alpha) + { + throw new Exception("Can't set Text on avatar."); + } + + /// + /// Adds a physical representation of the avatar to the Physics plugin + /// + public void AddToPhysicalScene(bool isFlying) + { + PhysicsScene scene = m_scene.PhysicsScene; + + Vector3 pVec = AbsolutePosition; + + // Old bug where the height was in centimeters instead of meters + if (m_avHeight == 127.0f) + { + m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), + isFlying); + } + else + { + m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, + new Vector3(0f, 0f, m_avHeight), isFlying); + } + scene.AddPhysicsActorTaint(m_physicsActor); + //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; + m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; + m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong + m_physicsActor.SubscribeEvents(500); + m_physicsActor.LocalID = LocalId; + } + + private void OutOfBoundsCall(Vector3 pos) + { + //bool flying = m_physicsActor.Flying; + //RemoveFromPhysicalScene(); + + //AddToPhysicalScene(flying); + if (ControllingClient != null) + ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); + } + + // Event called by the physics plugin to tell the avatar about a collision. + private void PhysicsCollisionUpdate(EventArgs e) + { + if (e == null) + return; + + // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( + // as of this comment the interval is set in AddToPhysicalScene + if (Animator!=null) + { + if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, + { // else its will lock out other animation changes, like ground sit. + Animator.UpdateMovementAnimations(); + m_updateCount--; + } + } + + CollisionEventUpdate collisionData = (CollisionEventUpdate)e; + Dictionary coldata = collisionData.m_objCollisionList; + + CollisionPlane = Vector4.UnitW; + + if (m_lastColCount != coldata.Count) + { + m_updateCount = UPDATE_COUNT; + m_lastColCount = coldata.Count; + } + + if (coldata.Count != 0 && Animator != null) + { + switch (Animator.CurrentMovementAnimation) + { + case "STAND": + case "WALK": + case "RUN": + case "CROUCH": + case "CROUCHWALK": + { + ContactPoint lowest; + lowest.SurfaceNormal = Vector3.Zero; + lowest.Position = Vector3.Zero; + lowest.Position.Z = Single.NaN; + + foreach (ContactPoint contact in coldata.Values) + { + if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) + { + lowest = contact; + } + } + + CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + } + break; + } + } + + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); + + foreach (uint localid in coldata.Keys) + { + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + { + startedColliders.Add(localid); + } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } + + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) + { + endedColliders.Add(localID); + } + } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } + + // do event notification + if (startedColliders.Count > 0) + { + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } + } + + if (endedColliders.Count > 0) + { + ColliderArgs EndCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in endedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + EndCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); + } + } + + if (thisHitColliders.Count > 0) + { + ColliderArgs CollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in thisHitColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + CollidingMessage.Colliders = colliding; + + lock (m_attachments) + { + foreach (SceneObjectGroup att in m_attachments) + Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + } + } + } + + if (m_invulnerable) + return; + + float starthealth = Health; + uint killerObj = 0; + foreach (uint localid in coldata.Keys) + { + SceneObjectPart part = Scene.GetSceneObjectPart(localid); + + if (part != null && part.ParentGroup.Damage != -1.0f) + Health -= part.ParentGroup.Damage; + else + { + if (coldata[localid].PenetrationDepth >= 0.10f) + Health -= coldata[localid].PenetrationDepth * 5.0f; + } + + if (Health <= 0.0f) + { + if (localid != 0) + killerObj = localid; + } + //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); + } + //Health = 100; + if (!m_invulnerable) + { + if (starthealth != Health) + { + ControllingClient.SendHealth(Health); + } + if (m_health <= 0) + m_scene.EventManager.TriggerAvatarKill(killerObj, this); + } + } + + public void setHealthWithUpdate(float health) + { + Health = health; + ControllingClient.SendHealth(Health); + } + + public void Close() + { + lock (m_attachments) + { + // Delete attachments from scene + // Don't try to save, as this thread won't live long + // enough to complete the save. This would cause no copy + // attachments to poof! + // + foreach (SceneObjectGroup grp in m_attachments) + { + m_scene.DeleteSceneObject(grp, false); + } + m_attachments.Clear(); + } + + lock (m_knownChildRegions) + { + m_knownChildRegions.Clear(); + } + + lock (m_reprioritization_timer) + { + m_reprioritization_timer.Enabled = false; + m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); + } + + // I don't get it but mono crashes when you try to dispose of this timer, + // unsetting the elapsed callback should be enough to allow for cleanup however. + // m_reprioritizationTimer.Dispose(); + + m_sceneViewer.Close(); + + RemoveFromPhysicalScene(); + m_animator.Close(); + m_animator = null; + } + + public void AddAttachment(SceneObjectGroup gobj) + { + lock (m_attachments) + { + m_attachments.Add(gobj); + } + } + + public bool HasAttachments() + { + return m_attachments.Count > 0; + } + + public bool HasScriptedAttachments() + { + lock (m_attachments) + { + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj != null) + { + if (gobj.RootPart.Inventory.ContainsScripts()) + return true; + } + } + } + return false; + } + + public void RemoveAttachment(SceneObjectGroup gobj) + { + lock (m_attachments) + { + if (m_attachments.Contains(gobj)) + { + m_attachments.Remove(gobj); + } + } + } + + public bool ValidateAttachments() + { + lock (m_attachments) + { + // Validate + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj == null) + return false; + + if (gobj.IsDeleted) + return false; + } + } + return true; + } + + /// + /// Send a script event to this scene presence's attachments + /// + /// The name of the event + /// The arguments for the event + public void SendScriptEventToAttachments(string eventName, Object[] args) + { + if (m_scriptEngines != null) + { + lock (m_attachments) + { + foreach (SceneObjectGroup grp in m_attachments) + { + // 16384 is CHANGED_ANIMATION + // + // Send this to all attachment root prims + // + foreach (IScriptModule m in m_scriptEngines) + { + if (m == null) // No script engine loaded + continue; + + m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); + } + } + } + } + } + + + public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) + { + m_controllingClient = client; + m_regionInfo = region; + m_scene = scene; + + RegisterToEvents(); + if (m_controllingClient != null) + { + m_controllingClient.ProcessPendingPackets(); + } + /* + AbsolutePosition = client.StartPos; + + Animations = new AvatarAnimations(); + Animations.LoadAnims(); + + m_animations = new List(); + m_animations.Add(Animations.AnimsUUID["STAND"]); + m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); + + SetDirectionVectors(); + */ + } + + internal void PushForce(Vector3 impulse) + { + if (PhysicsActor != null) + { + PhysicsActor.AddForce(impulse,true); + } + } + + public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) + { + ScriptControllers obj = new ScriptControllers(); + obj.ignoreControls = ScriptControlled.CONTROL_ZERO; + obj.eventControls = ScriptControlled.CONTROL_ZERO; + + obj.itemID = Script_item_UUID; + if (pass_on == 0 && accept == 0) + { + IgnoredControls |= (ScriptControlled)controls; + obj.ignoreControls = (ScriptControlled)controls; + } + + if (pass_on == 0 && accept == 1) + { + IgnoredControls |= (ScriptControlled)controls; + obj.ignoreControls = (ScriptControlled)controls; + obj.eventControls = (ScriptControlled)controls; + } + if (pass_on == 1 && accept == 1) + { + IgnoredControls = ScriptControlled.CONTROL_ZERO; + obj.eventControls = (ScriptControlled)controls; + obj.ignoreControls = ScriptControlled.CONTROL_ZERO; + } + + lock (scriptedcontrols) + { + if (pass_on == 1 && accept == 0) + { + IgnoredControls &= ~(ScriptControlled)controls; + if (scriptedcontrols.ContainsKey(Script_item_UUID)) + scriptedcontrols.Remove(Script_item_UUID); + } + else + { + scriptedcontrols[Script_item_UUID] = obj; + } + } + ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); + } + + public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) + { + IgnoredControls = ScriptControlled.CONTROL_ZERO; + lock (scriptedcontrols) + { + scriptedcontrols.Clear(); + } + ControllingClient.SendTakeControls(int.MaxValue, false, false); + } + + public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) + { + ScriptControllers takecontrols; + + lock (scriptedcontrols) + { + if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) + { + ScriptControlled sctc = takecontrols.eventControls; + + ControllingClient.SendTakeControls((int)sctc, false, false); + ControllingClient.SendTakeControls((int)sctc, true, false); + + scriptedcontrols.Remove(Script_item_UUID); + IgnoredControls = ScriptControlled.CONTROL_ZERO; + foreach (ScriptControllers scData in scriptedcontrols.Values) + { + IgnoredControls |= scData.ignoreControls; + } + } + } + } + + internal void SendControlToScripts(uint flags) + { + ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; + + if (MouseDown) + { + allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) + { + allflags = ScriptControlled.CONTROL_ZERO; + MouseDown = true; + } + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) + { + allflags |= ScriptControlled.CONTROL_ML_LBUTTON; + MouseDown = true; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) + { + allflags |= ScriptControlled.CONTROL_LBUTTON; + MouseDown = true; + } + + // find all activated controls, whether the scripts are interested in them or not + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_FWD; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_BACK; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_UP; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_DOWN; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_LEFT; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_RIGHT; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_ROT_RIGHT; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_ROT_LEFT; + } + // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that + if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) + { + lock (scriptedcontrols) + { + foreach (KeyValuePair kvp in scriptedcontrols) + { + UUID scriptUUID = kvp.Key; + ScriptControllers scriptControlData = kvp.Value; + + ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us + ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle + ScriptControlled localChange = localHeld ^ localLast; // the changed bits + if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) + { + // only send if still pressed or just changed + m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); + } + } + } + } + + LastCommands = allflags; + } + + internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) + { + if (ignored == ScriptControlled.CONTROL_ZERO) + return flags; + + if ((ignored & ScriptControlled.CONTROL_BACK) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); + if ((ignored & ScriptControlled.CONTROL_FWD) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); + if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); + if ((ignored & ScriptControlled.CONTROL_UP) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); + if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); + if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); + if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); + if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); + if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); + if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); + + //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, + //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, + //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, + //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, + //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, + //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, + //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG + + return flags; + } + + /// + /// RezAttachments. This should only be called upon login on the first region. + /// Attachment rezzings on crossings and TPs are done in a different way. + /// + public void RezAttachments() + { + if (null == m_appearance) + { + m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); + return; + } + + XmlDocument doc = new XmlDocument(); + string stateData = String.Empty; + + IAttachmentsService attServ = m_scene.RequestModuleInterface(); + if (attServ != null) + { + m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); + stateData = attServ.Get(ControllingClient.AgentId.ToString()); + if (stateData != String.Empty) + { + try + { + doc.LoadXml(stateData); + } + catch { } + } + } + + Dictionary itemData = new Dictionary(); + + XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); + if (nodes.Count > 0) + { + foreach (XmlNode n in nodes) + { + XmlElement elem = (XmlElement)n; + string itemID = elem.GetAttribute("ItemID"); + string xml = elem.InnerXml; + + itemData[new UUID(itemID)] = xml; + } + } + + List attPoints = m_appearance.GetAttachedPoints(); + foreach (int p in attPoints) + { + if (m_isDeleted) + return; + + UUID itemID = m_appearance.GetAttachedItem(p); + UUID assetID = m_appearance.GetAttachedAsset(p); + + // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down + // But they're not used anyway, the item is being looked up for now, so let's proceed. + //if (UUID.Zero == assetID) + //{ + // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); + // continue; + //} + + try + { + string xmlData; + XmlDocument d = new XmlDocument(); + UUID asset; + if (itemData.TryGetValue(itemID, out xmlData)) + { + d.LoadXml(xmlData); + m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); + + // Rez from inventory + asset + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); + + } + else + { + // Rez from inventory (with a null doc to let + // CHANGED_OWNER happen) + asset + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); + } + + m_log.InfoFormat( + "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", + p, itemID, assetID, asset); + } + catch (Exception e) + { + m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e.ToString()); + } + } + } + + private void ReprioritizeUpdates() + { + if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) + { + lock (m_reprioritization_timer) + { + if (!m_reprioritizing) + m_reprioritization_timer.Enabled = m_reprioritizing = true; + else + m_reprioritization_called = true; + } + } + } + + private void Reprioritize(object sender, ElapsedEventArgs e) + { + m_controllingClient.ReprioritizeUpdates(); + + lock (m_reprioritization_timer) + { + m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; + m_reprioritization_called = false; + } + } + + private Vector3 Quat2Euler(Quaternion rot){ + float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , + (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); + float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); + float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , + (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); + return(new Vector3(x,y,z)); + } + + + } +} -- cgit v1.1 From cabbd187e7945329c2f0700180f400b11096d33c Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 11:13:05 -0700 Subject: Fix the distance from which autopilot is negated when sitting on an unscripted prim - and also add some more Velocity code to ensure it gets set to zero in all cases --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 882f4a7..56e7e93 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2007,13 +2007,14 @@ namespace OpenSim.Region.Framework.Scenes if (autopilot) { // its not a scripted sit // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) - if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) + if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 10.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 10.0f) ) { autopilot = false; // close enough m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. Not using the part's position because returning the AV to the last known standing position is likely to be more friendly, isn't it? */ RemoveFromPhysicalScene(); + Velocity = Vector3.Zero; AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target } // else the autopilot will get us close } @@ -2023,6 +2024,7 @@ namespace OpenSim.Region.Framework.Scenes I *am* using the part's position this time because we have no real idea how far away the avatar is from the sit target. */ RemoveFromPhysicalScene(); + Velocity = Vector3.Zero; } } else return; // physactor is null! -- cgit v1.1 From 478d83539244157992b1849648e5e4cf758543e0 Mon Sep 17 00:00:00 2001 From: sacha Date: Sat, 7 Aug 2010 21:04:16 +0000 Subject: removing more stains ... --- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index a9ecde8..59e4037 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -168,7 +168,7 @@ namespace OpenSim.Region.Framework.Scenes if (neighbour != null) { - m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); + // m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); m_scene.EventManager.TriggerOnRegionUp(neighbour); } else @@ -183,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); List neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); - m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); + //m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); foreach (GridRegion n in neighbours) { InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; @@ -267,7 +267,7 @@ namespace OpenSim.Region.Framework.Scenes protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) { - m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle); + //m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle); // let's do our best, but there's not much we can do if the neighbour doesn't accept. //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); -- cgit v1.1 From 19ab4c950880beb3ac88a172b775c3973782ec3d Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 16:52:03 -0700 Subject: Fix a rather nasty issue where the Backup() process causes objects and avatars sitting on them to be pushed to the corner of the sim. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 199 +++++++++++---------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 25 +-- 2 files changed, 120 insertions(+), 104 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a828127..0d15cb4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -317,8 +317,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scriptListens_notAtTarget = false; private bool m_scriptListens_atRotTarget = false; - private bool m_scriptListens_notAtRotTarget = false; - + private bool m_scriptListens_notAtRotTarget = false; + public bool m_dupeInProgress = false; internal Dictionary m_savedScriptState = null; #region Properties @@ -475,16 +475,21 @@ namespace OpenSim.Region.Framework.Scenes { part.IgnoreUndoUpdate = false; part.StoreUndoState(UndoType.STATE_GROUP_POSITION); - part.GroupPosition = val; - part.TriggerScriptChangedEvent(Changed.POSITION); - } - - foreach (ScenePresence av in m_linkedAvatars) - { - Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; - av.AbsolutePosition += offset; - av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition - av.SendFullUpdateToAllClients(); + part.GroupPosition = val; + if (!m_dupeInProgress) + { + part.TriggerScriptChangedEvent(Changed.POSITION); + } + } + if (!m_dupeInProgress) + { + foreach (ScenePresence av in m_linkedAvatars) + { + Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; + av.AbsolutePosition += offset; + av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition + av.SendFullUpdateToAllClients(); + } } //if (m_rootPart.PhysActor != null) @@ -1800,88 +1805,96 @@ namespace OpenSim.Region.Framework.Scenes /// True if the duplicate will immediately be in the scene, false otherwise /// public SceneObjectGroup Copy(bool userExposed) - { - SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new Dictionary(); - - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state - - // This is only necessary when userExposed is false! - - bool previousAttachmentStatus = dupe.RootPart.IsAttachment; - - if (!userExposed) - dupe.RootPart.IsAttachment = true; - - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - - if (!userExposed) - { - dupe.RootPart.IsAttachment = previousAttachmentStatus; - } - - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - - if (userExposed) - dupe.m_rootPart.TrimPermissions(); - - /// may need to create a new Physics actor. - if (dupe.RootPart.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = dupe.RootPart.Shape; - - dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( - dupe.RootPart.Name, - pbs, - dupe.RootPart.AbsolutePosition, - dupe.RootPart.Scale, - dupe.RootPart.RotationOffset, - dupe.RootPart.PhysActor.IsPhysical); - - dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; - dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); + { + SceneObjectGroup dupe; + try + { + m_dupeInProgress = true; + dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new Dictionary(); + + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state + + // This is only necessary when userExposed is false! + + bool previousAttachmentStatus = dupe.RootPart.IsAttachment; + + if (!userExposed) + dupe.RootPart.IsAttachment = true; + + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + + if (!userExposed) + { + dupe.RootPart.IsAttachment = previousAttachmentStatus; + } + + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + + if (userExposed) + dupe.m_rootPart.TrimPermissions(); + + /// may need to create a new Physics actor. + if (dupe.RootPart.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = dupe.RootPart.Shape; + + dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( + dupe.RootPart.Name, + pbs, + dupe.RootPart.AbsolutePosition, + dupe.RootPart.Scale, + dupe.RootPart.RotationOffset, + dupe.RootPart.PhysActor.IsPhysical); + + dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; + dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); + } + + List partList; + + lockPartsForRead(true); + + partList = new List(m_parts.Values); + + lockPartsForRead(false); + + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); + + foreach (SceneObjectPart part in partList) + { + if (part.UUID != m_rootPart.UUID) + { + SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); + + newPart.LinkNum = part.LinkNum; + } + } + + if (userExposed) + { + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); + } + } + finally + { + m_dupeInProgress = false; } - - List partList; - - lockPartsForRead(true); - - partList = new List(m_parts.Values); - - lockPartsForRead(false); - - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); - - foreach (SceneObjectPart part in partList) - { - if (part.UUID != m_rootPart.UUID) - { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - - newPart.LinkNum = part.LinkNum; - } - } - - if (userExposed) - { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); - - ScheduleGroupForFullUpdate(); - } - return dupe; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b0ce450..77581af 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -718,17 +718,20 @@ namespace OpenSim.Region.Framework.Scenes // Tell the physics engines that this prim changed. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); - } - - List avs = ParentGroup.GetLinkedAvatars(); - foreach (ScenePresence av in avs) - { - if (av.LinkedPrim == m_uuid) - { - Vector3 offset = (m_offsetPosition - oldpos); - av.OffsetPosition += offset; - av.SendFullUpdateToAllClients(); - } + } + + if (!m_parentGroup.m_dupeInProgress) + { + List avs = ParentGroup.GetLinkedAvatars(); + foreach (ScenePresence av in avs) + { + if (av.LinkedPrim == m_uuid) + { + Vector3 offset = (m_offsetPosition - oldpos); + av.OffsetPosition += offset; + av.SendFullUpdateToAllClients(); + } + } } } TriggerScriptChangedEvent(Changed.POSITION); -- cgit v1.1 From acb1590cf063769802f35c99dd5fb6398172296f Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 17:32:36 -0700 Subject: Fix the unscripted sit rotation being incorrect (relative to the prim). Note that unscripted sit offset is still really poor but this is not something i'm prepared to spend time on fixing. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 56e7e93..5191236 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2053,9 +2053,13 @@ namespace OpenSim.Region.Framework.Scenes //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child - ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + Quaternion roffset = Quaternion.Identity; + if (SitTargetisSet) + { + roffset = part.RotationOffset; + } + ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * roffset) + part.OffsetPosition), sitOrientation / part.RotationOffset, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); - m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though @@ -2441,7 +2445,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); } m_linkedPrim = part.UUID; - + m_offsetRotation = m_offsetRotation / part.RotationOffset; Velocity = Vector3.Zero; RemoveFromPhysicalScene(); Animator.TrySetMovementAnimation(sitAnimation); -- cgit v1.1 From b771965f287af0cb5d46e4f652e9912dfaa40682 Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 17:33:27 -0700 Subject: Get rid of some debug chatter that someone who can't spell left behind. ;) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5191236..6f92a41 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2378,8 +2378,7 @@ namespace OpenSim.Region.Framework.Scenes m_bodyRot = sitTargetOrient; m_parentPosition = part.AbsolutePosition; part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); -Console.WriteLine("Scripted Sit ofset {0}", m_pos); + part.ParentGroup.AddAvatar(agentID); } else { -- cgit v1.1 From aa54e8d95eb920869da5c885fc536cfb1ffca90b Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 17:35:16 -0700 Subject: Increase sit distance to 256 meters, but leave the initial autopilot process in the picture so sit position can still be raycast by the existing code. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6f92a41..cca296e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2007,7 +2007,7 @@ namespace OpenSim.Region.Framework.Scenes if (autopilot) { // its not a scripted sit // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) - if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 10.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 10.0f) ) + if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) { autopilot = false; // close enough m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. -- cgit v1.1 From f9b5f23383675abe0ae1c2ed83dd5ccce738d940 Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 22:19:26 -0700 Subject: Reverted: * Fix the unscripted sit rotation being incorrect .. will commit a proper fix now. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cca296e..87cf135 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2053,13 +2053,9 @@ namespace OpenSim.Region.Framework.Scenes //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child - Quaternion roffset = Quaternion.Identity; - if (SitTargetisSet) - { - roffset = part.RotationOffset; - } - ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * roffset) + part.OffsetPosition), sitOrientation / part.RotationOffset, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though @@ -2444,7 +2440,7 @@ namespace OpenSim.Region.Framework.Scenes } m_linkedPrim = part.UUID; - m_offsetRotation = m_offsetRotation / part.RotationOffset; + Velocity = Vector3.Zero; RemoveFromPhysicalScene(); Animator.TrySetMovementAnimation(sitAnimation); -- cgit v1.1 From a1f2be5e69ef04a8520229e161bdd0527badb844 Mon Sep 17 00:00:00 2001 From: meta7 Date: Sat, 7 Aug 2010 22:25:37 -0700 Subject: The real fix for unscripted sit positions. This one doesn't fuck everything else up. Promise. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 87cf135..fc8e0d7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2440,7 +2440,10 @@ namespace OpenSim.Region.Framework.Scenes } m_linkedPrim = part.UUID; - + if (part.GetAvatarOnSitTarget() != UUID) + { + m_offsetRotation = m_offsetRotation / part.RotationOffset; + } Velocity = Vector3.Zero; RemoveFromPhysicalScene(); Animator.TrySetMovementAnimation(sitAnimation); -- cgit v1.1 From ca2a4bbded8c33125c5b96bb3b715e3f3925ddad Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 8 Aug 2010 19:35:20 +0200 Subject: Add debug messages to attachment receiving and cowardly refuse to create them if the owner can't be determined. --- OpenSim/Region/Framework/Scenes/Scene.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6c17be8..8a8dabc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2592,6 +2592,12 @@ namespace OpenSim.Region.Framework.Scenes /// True if the SceneObjectGroup was added, False if it was not public bool AddSceneObject(SceneObjectGroup sceneObject) { + if (sceneObject.OwnerID == UUID.Zero) + { + m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); + return false; + } + // If the user is banned, we won't let any of their objects // enter. Period. // @@ -2641,15 +2647,27 @@ namespace OpenSim.Region.Framework.Scenes if (AttachmentsModule != null) AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); + m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); } else { + m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); RootPrim.RemFlag(PrimFlags.TemporaryOnRez); RootPrim.AddFlag(PrimFlags.TemporaryOnRez); } + if (sceneObject.OwnerID == UUID.Zero) + { + m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); + return false; + } } else { + if (sceneObject.OwnerID == UUID.Zero) + { + m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); + return false; + } AddRestoredSceneObject(sceneObject, true, false); if (!Permissions.CanObjectEntry(sceneObject.UUID, @@ -5333,4 +5351,4 @@ namespace OpenSim.Region.Framework.Scenes return offsets.ToArray(); } } -} \ No newline at end of file +} -- cgit v1.1 From 603b3a1606396e355416eae838f6bdaa5051bf1f Mon Sep 17 00:00:00 2001 From: meta7 Date: Sun, 8 Aug 2010 17:31:29 -0700 Subject: Fix minimap issues. This addresses mantis #228. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5acc227..94ec534 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -228,27 +228,8 @@ namespace OpenSim.Region.Framework.Scenes if (sp.IsChildAgent) return; - if (sp.ParentID != 0) - { - // sitting avatar - SceneObjectPart sop = m_parentScene.GetSceneObjectPart(sp.ParentID); - if (sop != null) - { - coarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition); - avatarUUIDs.Add(sp.UUID); - } - else - { - // we can't find the parent.. ! arg! - coarseLocations.Add(sp.AbsolutePosition); - avatarUUIDs.Add(sp.UUID); - } - } - else - { - coarseLocations.Add(sp.AbsolutePosition); - avatarUUIDs.Add(sp.UUID); - } + coarseLocations.Add(sp.AbsolutePosition); + avatarUUIDs.Add(sp.UUID); } } -- cgit v1.1 From 680e801bf229d54dc57dbca24e841f7f2e8f43d4 Mon Sep 17 00:00:00 2001 From: meta7 Date: Sun, 8 Aug 2010 17:32:20 -0700 Subject: Print a console message when we deny access because of no valid parcel found. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8a8dabc..779f898 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3513,7 +3513,8 @@ namespace OpenSim.Region.Framework.Scenes if (tp == TeleportFlags.ViaLogin) { if (land != null && !TestLandRestrictions(agent, land, out reason)) - { + { + m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); return false; } } -- cgit v1.1 From f20dc512e87983b9ba6b86f806489380d3cfef5a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 9 Aug 2010 02:46:09 +0200 Subject: Whitespace conflict --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 779f898..06bbe32 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3513,7 +3513,7 @@ namespace OpenSim.Region.Framework.Scenes if (tp == TeleportFlags.ViaLogin) { if (land != null && !TestLandRestrictions(agent, land, out reason)) - { + { m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); return false; } -- cgit v1.1 From 0f9eebdfb1e948bc1ffb148322e668b5a2f560a6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 10 Aug 2010 03:52:00 +0200 Subject: Change prejump from hardcoded true to default true so it can be disabled. It completely destroys roleplay jumping --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 06bbe32..05036f1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -726,8 +726,7 @@ namespace OpenSim.Region.Framework.Scenes //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported - m_usePreJump = startupConfig.GetBoolean("enableprejump", false); - m_usePreJump = true; // Above line fails!? + m_usePreJump = startupConfig.GetBoolean("enableprejump", true); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { -- cgit v1.1 From 1ead2ed5eea379c500d2657e7bed8908b376e336 Mon Sep 17 00:00:00 2001 From: meta7 Date: Tue, 10 Aug 2010 09:07:17 -0700 Subject: Add a stack trace to the error output on the recursive read lock warning on my RWlocks. Whilst recursive locks are safe, coupled with other issues we're experiencing with the TaskInventoryDictionary it implies that somewhere the lock is not being freed possibly due to a merge error somewhere, and thus it needs to be looked into. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 218 +++++++++++---------- 1 file changed, 114 insertions(+), 104 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3c3f4b7..4f6bc52 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Diagnostics; using System.Threading; using System.Xml; using System.Xml.Serialization; @@ -138,6 +139,15 @@ namespace OpenSim.Region.Framework.Scenes m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); try { + StackTrace stackTrace = new StackTrace(); // get call stack + StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) + + // write call stack method names + foreach (StackFrame stackFrame in stackFrames) + { + m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name); // write method name + } + m_partsLock.ExitReadLock(); } catch { } // Ignore errors, to allow resync @@ -317,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scriptListens_notAtTarget = false; private bool m_scriptListens_atRotTarget = false; - private bool m_scriptListens_notAtRotTarget = false; + private bool m_scriptListens_notAtRotTarget = false; public bool m_dupeInProgress = false; internal Dictionary m_savedScriptState = null; @@ -475,21 +485,21 @@ namespace OpenSim.Region.Framework.Scenes { part.IgnoreUndoUpdate = false; part.StoreUndoState(UndoType.STATE_GROUP_POSITION); - part.GroupPosition = val; - if (!m_dupeInProgress) - { - part.TriggerScriptChangedEvent(Changed.POSITION); + part.GroupPosition = val; + if (!m_dupeInProgress) + { + part.TriggerScriptChangedEvent(Changed.POSITION); + } + } + if (!m_dupeInProgress) + { + foreach (ScenePresence av in m_linkedAvatars) + { + Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; + av.AbsolutePosition += offset; + av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition + av.SendFullUpdateToAllClients(); } - } - if (!m_dupeInProgress) - { - foreach (ScenePresence av in m_linkedAvatars) - { - Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; - av.AbsolutePosition += offset; - av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition - av.SendFullUpdateToAllClients(); - } } //if (m_rootPart.PhysActor != null) @@ -1805,95 +1815,95 @@ namespace OpenSim.Region.Framework.Scenes /// True if the duplicate will immediately be in the scene, false otherwise /// public SceneObjectGroup Copy(bool userExposed) - { - SceneObjectGroup dupe; - try - { - m_dupeInProgress = true; - dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new Dictionary(); - - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state - - // This is only necessary when userExposed is false! - - bool previousAttachmentStatus = dupe.RootPart.IsAttachment; - - if (!userExposed) - dupe.RootPart.IsAttachment = true; - - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - - if (!userExposed) - { - dupe.RootPart.IsAttachment = previousAttachmentStatus; - } - - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - - if (userExposed) - dupe.m_rootPart.TrimPermissions(); - - /// may need to create a new Physics actor. - if (dupe.RootPart.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = dupe.RootPart.Shape; - - dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( - dupe.RootPart.Name, - pbs, - dupe.RootPart.AbsolutePosition, - dupe.RootPart.Scale, - dupe.RootPart.RotationOffset, - dupe.RootPart.PhysActor.IsPhysical); - - dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; - dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); - } - - List partList; - - lockPartsForRead(true); - - partList = new List(m_parts.Values); - - lockPartsForRead(false); - - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); - - foreach (SceneObjectPart part in partList) - { - if (part.UUID != m_rootPart.UUID) - { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - - newPart.LinkNum = part.LinkNum; - } - } - - if (userExposed) - { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); - - ScheduleGroupForFullUpdate(); - } - } - finally - { - m_dupeInProgress = false; + { + SceneObjectGroup dupe; + try + { + m_dupeInProgress = true; + dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new Dictionary(); + + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state + + // This is only necessary when userExposed is false! + + bool previousAttachmentStatus = dupe.RootPart.IsAttachment; + + if (!userExposed) + dupe.RootPart.IsAttachment = true; + + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + + if (!userExposed) + { + dupe.RootPart.IsAttachment = previousAttachmentStatus; + } + + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + + if (userExposed) + dupe.m_rootPart.TrimPermissions(); + + /// may need to create a new Physics actor. + if (dupe.RootPart.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = dupe.RootPart.Shape; + + dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( + dupe.RootPart.Name, + pbs, + dupe.RootPart.AbsolutePosition, + dupe.RootPart.Scale, + dupe.RootPart.RotationOffset, + dupe.RootPart.PhysActor.IsPhysical); + + dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; + dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); + } + + List partList; + + lockPartsForRead(true); + + partList = new List(m_parts.Values); + + lockPartsForRead(false); + + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); + + foreach (SceneObjectPart part in partList) + { + if (part.UUID != m_rootPart.UUID) + { + SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); + + newPart.LinkNum = part.LinkNum; + } + } + + if (userExposed) + { + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); + } + } + finally + { + m_dupeInProgress = false; } return dupe; } -- cgit v1.1 From d98d5ee6be233cf644be5ee1011c4a7f4b86ae46 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 10 Aug 2010 19:42:18 +0100 Subject: Remove windows line endinge --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 208 ++++++++++----------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 28 +-- 2 files changed, 118 insertions(+), 118 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3c3f4b7..a862fa2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -317,7 +317,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scriptListens_notAtTarget = false; private bool m_scriptListens_atRotTarget = false; - private bool m_scriptListens_notAtRotTarget = false; + private bool m_scriptListens_notAtRotTarget = false; public bool m_dupeInProgress = false; internal Dictionary m_savedScriptState = null; @@ -475,21 +475,21 @@ namespace OpenSim.Region.Framework.Scenes { part.IgnoreUndoUpdate = false; part.StoreUndoState(UndoType.STATE_GROUP_POSITION); - part.GroupPosition = val; - if (!m_dupeInProgress) - { - part.TriggerScriptChangedEvent(Changed.POSITION); + part.GroupPosition = val; + if (!m_dupeInProgress) + { + part.TriggerScriptChangedEvent(Changed.POSITION); + } + } + if (!m_dupeInProgress) + { + foreach (ScenePresence av in m_linkedAvatars) + { + Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; + av.AbsolutePosition += offset; + av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition + av.SendFullUpdateToAllClients(); } - } - if (!m_dupeInProgress) - { - foreach (ScenePresence av in m_linkedAvatars) - { - Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; - av.AbsolutePosition += offset; - av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition - av.SendFullUpdateToAllClients(); - } } //if (m_rootPart.PhysActor != null) @@ -1805,95 +1805,95 @@ namespace OpenSim.Region.Framework.Scenes /// True if the duplicate will immediately be in the scene, false otherwise /// public SceneObjectGroup Copy(bool userExposed) - { - SceneObjectGroup dupe; - try - { - m_dupeInProgress = true; - dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new Dictionary(); - - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state - - // This is only necessary when userExposed is false! - - bool previousAttachmentStatus = dupe.RootPart.IsAttachment; - - if (!userExposed) - dupe.RootPart.IsAttachment = true; - - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - - if (!userExposed) - { - dupe.RootPart.IsAttachment = previousAttachmentStatus; - } - - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - - if (userExposed) - dupe.m_rootPart.TrimPermissions(); - - /// may need to create a new Physics actor. - if (dupe.RootPart.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = dupe.RootPart.Shape; - - dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( - dupe.RootPart.Name, - pbs, - dupe.RootPart.AbsolutePosition, - dupe.RootPart.Scale, - dupe.RootPart.RotationOffset, - dupe.RootPart.PhysActor.IsPhysical); - - dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; - dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); - } - - List partList; - - lockPartsForRead(true); - - partList = new List(m_parts.Values); - - lockPartsForRead(false); - - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); - - foreach (SceneObjectPart part in partList) - { - if (part.UUID != m_rootPart.UUID) - { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - - newPart.LinkNum = part.LinkNum; - } - } - - if (userExposed) - { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); - - ScheduleGroupForFullUpdate(); - } - } - finally - { - m_dupeInProgress = false; + { + SceneObjectGroup dupe; + try + { + m_dupeInProgress = true; + dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new Dictionary(); + + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state + + // This is only necessary when userExposed is false! + + bool previousAttachmentStatus = dupe.RootPart.IsAttachment; + + if (!userExposed) + dupe.RootPart.IsAttachment = true; + + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + + if (!userExposed) + { + dupe.RootPart.IsAttachment = previousAttachmentStatus; + } + + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + + if (userExposed) + dupe.m_rootPart.TrimPermissions(); + + /// may need to create a new Physics actor. + if (dupe.RootPart.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = dupe.RootPart.Shape; + + dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( + dupe.RootPart.Name, + pbs, + dupe.RootPart.AbsolutePosition, + dupe.RootPart.Scale, + dupe.RootPart.RotationOffset, + dupe.RootPart.PhysActor.IsPhysical); + + dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; + dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); + } + + List partList; + + lockPartsForRead(true); + + partList = new List(m_parts.Values); + + lockPartsForRead(false); + + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); + + foreach (SceneObjectPart part in partList) + { + if (part.UUID != m_rootPart.UUID) + { + SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); + + newPart.LinkNum = part.LinkNum; + } + } + + if (userExposed) + { + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); + } + } + finally + { + m_dupeInProgress = false; } return dupe; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 77581af..277384e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -718,20 +718,20 @@ namespace OpenSim.Region.Framework.Scenes // Tell the physics engines that this prim changed. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); - } - - if (!m_parentGroup.m_dupeInProgress) - { - List avs = ParentGroup.GetLinkedAvatars(); - foreach (ScenePresence av in avs) - { - if (av.LinkedPrim == m_uuid) - { - Vector3 offset = (m_offsetPosition - oldpos); - av.OffsetPosition += offset; - av.SendFullUpdateToAllClients(); - } - } + } + + if (!m_parentGroup.m_dupeInProgress) + { + List avs = ParentGroup.GetLinkedAvatars(); + foreach (ScenePresence av in avs) + { + if (av.LinkedPrim == m_uuid) + { + Vector3 offset = (m_offsetPosition - oldpos); + av.OffsetPosition += offset; + av.SendFullUpdateToAllClients(); + } + } } } TriggerScriptChangedEvent(Changed.POSITION); -- cgit v1.1 From 383ee0d647df245dcb933e71f2b4bcdfbc026a15 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 10 Aug 2010 19:48:45 +0100 Subject: Remove 4000+ DOS line endings. Grrr! --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8664 +++++++++++----------- 1 file changed, 4332 insertions(+), 4332 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fc8e0d7..9d95324 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1,4332 +1,4332 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Xml; -using System.Collections.Generic; -using System.Reflection; -using System.Timers; -using OpenMetaverse; -using log4net; -using OpenSim.Framework; -using OpenSim.Framework.Client; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes.Animation; -using OpenSim.Region.Framework.Scenes.Types; -using OpenSim.Region.Physics.Manager; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.Framework.Scenes -{ - enum ScriptControlled : uint - { - CONTROL_ZERO = 0, - CONTROL_FWD = 1, - CONTROL_BACK = 2, - CONTROL_LEFT = 4, - CONTROL_RIGHT = 8, - CONTROL_UP = 16, - CONTROL_DOWN = 32, - CONTROL_ROT_LEFT = 256, - CONTROL_ROT_RIGHT = 512, - CONTROL_LBUTTON = 268435456, - CONTROL_ML_LBUTTON = 1073741824 - } - - struct ScriptControllers - { - public UUID itemID; - public ScriptControlled ignoreControls; - public ScriptControlled eventControls; - } - - public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs); - - public class ScenePresence : EntityBase, ISceneEntity - { -// ~ScenePresence() -// { -// m_log.Debug("[ScenePresence] Destructor called"); -// } - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; -// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); - private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); - private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); - - /// - /// Experimentally determined "fudge factor" to make sit-target positions - /// the same as in SecondLife. Fudge factor was tested for 36 different - /// test cases including prims of type box, sphere, cylinder, and torus, - /// with varying parameters for sit target location, prim size, prim - /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis - /// issue #1716 - /// -// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); - // Value revised by KF 091121 by comparison with SL. - private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); - - public UUID currentParcelUUID = UUID.Zero; - - private ISceneViewer m_sceneViewer; - - /// - /// The animator for this avatar - /// - public ScenePresenceAnimator Animator - { - get { return m_animator; } - } - protected ScenePresenceAnimator m_animator; - - /// - /// The scene objects attached to this avatar. Do not change this list directly - use methods such as - /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. - /// - public List Attachments - { - get { return m_attachments; } - } - protected List m_attachments = new List(); - - private Dictionary scriptedcontrols = new Dictionary(); - private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; - private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; - private bool MouseDown = false; - private SceneObjectGroup proxyObjectGroup; - //private SceneObjectPart proxyObjectPart = null; - public Vector3 lastKnownAllowedPosition; - public bool sentMessageAboutRestrictedParcelFlyingDown; - public Vector4 CollisionPlane = Vector4.UnitW; - - private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation - private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; - private Vector3 m_lastWorldPosition; - private Quaternion m_lastRotation; - private Vector3 m_lastVelocity; - //private int m_lastTerseSent; - - private bool m_updateflag; - private byte m_movementflag; - private Vector3? m_forceToApply; - private uint m_requestedSitTargetID; - private UUID m_requestedSitTargetUUID; - public bool SitGround = false; - - private SendCourseLocationsMethod m_sendCourseLocationsMethod; - - private bool m_startAnimationSet; - - //private Vector3 m_requestedSitOffset = new Vector3(); - - private Vector3 m_LastFinitePos; - - private float m_sitAvatarHeight = 2.0f; - - private int m_godLevel; - private int m_userLevel; - - private bool m_invulnerable = true; - - private Vector3 m_lastChildAgentUpdatePosition; - private Vector3 m_lastChildAgentUpdateCamPosition; - - private int m_perfMonMS; - - private bool m_setAlwaysRun; - private bool m_forceFly; - private bool m_flyDisabled; - - private float m_speedModifier = 1.0f; - - private Quaternion m_bodyRot= Quaternion.Identity; - - private Quaternion m_bodyRotPrevious = Quaternion.Identity; - - private const int LAND_VELOCITYMAG_MAX = 12; - - public bool IsRestrictedToRegion; - - public string JID = String.Empty; - - private float m_health = 100f; - - // Default AV Height - private float m_avHeight = 127.0f; - - protected RegionInfo m_regionInfo; - protected ulong crossingFromRegion; - - private readonly Vector3[] Dir_Vectors = new Vector3[11]; - private bool m_isNudging = false; - - // Position of agent's camera in world (region cordinates) - protected Vector3 m_CameraCenter; - protected Vector3 m_lastCameraCenter; - - protected Timer m_reprioritization_timer; - protected bool m_reprioritizing; - protected bool m_reprioritization_called; - - // Use these three vectors to figure out what the agent is looking at - // Convert it to a Matrix and/or Quaternion - protected Vector3 m_CameraAtAxis; - protected Vector3 m_CameraLeftAxis; - protected Vector3 m_CameraUpAxis; - private AgentManager.ControlFlags m_AgentControlFlags; - private Quaternion m_headrotation = Quaternion.Identity; - private byte m_state; - - //Reuse the Vector3 instead of creating a new one on the UpdateMovement method -// private Vector3 movementvector; - - private bool m_autopilotMoving; - private Vector3 m_autoPilotTarget; - private bool m_sitAtAutoTarget; - private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit - - private string m_nextSitAnimation = String.Empty; - - //PauPaw:Proper PID Controler for autopilot************ - private bool m_moveToPositionInProgress; - private Vector3 m_moveToPositionTarget; - private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - - private bool m_followCamAuto; - - private int m_movementUpdateCount; - private int m_lastColCount = -1; //KF: Look for Collision chnages - private int m_updateCount = 0; //KF: Update Anims for a while - private static readonly int UPDATE_COUNT = 10; // how many frames to update for - private const int NumMovementsBetweenRayCast = 5; - private List m_lastColliders = new List(); - - private bool CameraConstraintActive; - //private int m_moveToPositionStateStatus; - //***************************************************** - - // Agent's Draw distance. - protected float m_DrawDistance; - - protected AvatarAppearance m_appearance; - - // neighbouring regions we have enabled a child agent in - // holds the seed cap for the child agent in that region - private Dictionary m_knownChildRegions = new Dictionary(); - - /// - /// Implemented Control Flags - /// - private enum Dir_ControlFlags - { - DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, - DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, - DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, - DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, - DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, - DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, - DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, - DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, - DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, - DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, - DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG - } - - /// - /// Position at which a significant movement was made - /// - private Vector3 posLastSignificantMove; - - // For teleports and crossings callbacks - string m_callbackURI; - UUID m_originRegionID; - - ulong m_rootRegionHandle; - - /// - /// Script engines present in the scene - /// - private IScriptModule[] m_scriptEngines; - - #region Properties - - /// - /// Physical scene representation of this Avatar. - /// - public PhysicsActor PhysicsActor - { - set { m_physicsActor = value; } - get { return m_physicsActor; } - } - - public byte MovementFlag - { - set { m_movementflag = value; } - get { return m_movementflag; } - } - - public bool Updated - { - set { m_updateflag = value; } - get { return m_updateflag; } - } - - public bool Invulnerable - { - set { m_invulnerable = value; } - get { return m_invulnerable; } - } - - public int UserLevel - { - get { return m_userLevel; } - } - - public int GodLevel - { - get { return m_godLevel; } - } - - public ulong RegionHandle - { - get { return m_rootRegionHandle; } - } - - public Vector3 CameraPosition - { - get { return m_CameraCenter; } - } - - public Quaternion CameraRotation - { - get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } - } - - public Vector3 CameraAtAxis - { - get { return m_CameraAtAxis; } - } - - public Vector3 CameraLeftAxis - { - get { return m_CameraLeftAxis; } - } - - public Vector3 CameraUpAxis - { - get { return m_CameraUpAxis; } - } - - public Vector3 Lookat - { - get - { - Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); - - if (a == Vector3.Zero) - return a; - - return Util.GetNormalizedVector(a); - } - } - - private readonly string m_firstname; - - public string Firstname - { - get { return m_firstname; } - } - - private readonly string m_lastname; - - public string Lastname - { - get { return m_lastname; } - } - - private string m_grouptitle; - - public string Grouptitle - { - get { return m_grouptitle; } - set { m_grouptitle = value; } - } - - public float DrawDistance - { - get { return m_DrawDistance; } - } - - protected bool m_allowMovement = true; - - public bool AllowMovement - { - get { return m_allowMovement; } - set { m_allowMovement = value; } - } - - public bool SetAlwaysRun - { - get - { - if (PhysicsActor != null) - { - return PhysicsActor.SetAlwaysRun; - } - else - { - return m_setAlwaysRun; - } - } - set - { - m_setAlwaysRun = value; - if (PhysicsActor != null) - { - PhysicsActor.SetAlwaysRun = value; - } - } - } - - public byte State - { - get { return m_state; } - set { m_state = value; } - } - - public uint AgentControlFlags - { - get { return (uint)m_AgentControlFlags; } - set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } - } - - /// - /// This works out to be the ClientView object associated with this avatar, or it's client connection manager - /// - private IClientAPI m_controllingClient; - - protected PhysicsActor m_physicsActor; - - /// - /// The client controlling this presence - /// - public IClientAPI ControllingClient - { - get { return m_controllingClient; } - } - - public IClientCore ClientView - { - get { return (IClientCore) m_controllingClient; } - } - - protected Vector3 m_parentPosition; - public Vector3 ParentPosition - { - get { return m_parentPosition; } - set { m_parentPosition = value; } - } - - /// - /// Position of this avatar relative to the region the avatar is in - /// - public override Vector3 AbsolutePosition - { - get - { - PhysicsActor actor = m_physicsActor; -// if (actor != null) - if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! - m_pos = actor.Position; - - // If we're sitting, we need to update our position - if (m_parentID != 0) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); - if (part != null) - m_parentPosition = part.AbsolutePosition; - } - - return m_parentPosition + m_pos; - } - set - { - PhysicsActor actor = m_physicsActor; - if (actor != null) - { - try - { - lock (m_scene.SyncRoot) - m_physicsActor.Position = value; - } - catch (Exception e) - { - m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); - } - } - - if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! - m_pos = value; - m_parentPosition = Vector3.Zero; - } - } - - public Vector3 OffsetPosition - { - get { return m_pos; } - set { m_pos = value; } - } - - /// - /// Current velocity of the avatar. - /// - public override Vector3 Velocity - { - get - { - PhysicsActor actor = m_physicsActor; - if (actor != null) - m_velocity = actor.Velocity; - - return m_velocity; - } - set - { - PhysicsActor actor = m_physicsActor; - if (actor != null) - { - try - { - lock (m_scene.SyncRoot) - actor.Velocity = value; - } - catch (Exception e) - { - m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); - } - } - - m_velocity = value; - } - } - - public Quaternion OffsetRotation - { - get { return m_offsetRotation; } - set { m_offsetRotation = value; } - } - - public Quaternion Rotation - { - get { - if (m_parentID != 0) - { - if (m_offsetRotation != null) - { - return m_offsetRotation; - } - else - { - return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - - } - else - { - return m_bodyRot; - } - } - set { - m_bodyRot = value; - if (m_parentID != 0) - { - m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - } - } - - public Quaternion PreviousRotation - { - get { return m_bodyRotPrevious; } - set { m_bodyRotPrevious = value; } - } - - /// - /// If this is true, agent doesn't have a representation in this scene. - /// this is an agent 'looking into' this scene from a nearby scene(region) - /// - /// if False, this agent has a representation in this scene - /// - private bool m_isChildAgent = true; - - public bool IsChildAgent - { - get { return m_isChildAgent; } - set { m_isChildAgent = value; } - } - - private uint m_parentID; - - - private UUID m_linkedPrim; - - public uint ParentID - { - get { return m_parentID; } - set { m_parentID = value; } - } - - public UUID LinkedPrim - { - get { return m_linkedPrim; } - set { m_linkedPrim = value; } - } - - public float Health - { - get { return m_health; } - set { m_health = value; } - } - - /// - /// These are the region handles known by the avatar. - /// - public List KnownChildRegionHandles - { - get - { - if (m_knownChildRegions.Count == 0) - return new List(); - else - return new List(m_knownChildRegions.Keys); - } - } - - public Dictionary KnownRegions - { - get { return m_knownChildRegions; } - set - { - m_knownChildRegions = value; - } - } - - public ISceneViewer SceneViewer - { - get { return m_sceneViewer; } - } - - public void AdjustKnownSeeds() - { - Dictionary seeds; - - if (Scene.CapsModule != null) - seeds = Scene.CapsModule.GetChildrenSeeds(UUID); - else - seeds = new Dictionary(); - - List old = new List(); - foreach (ulong handle in seeds.Keys) - { - uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) - { - old.Add(handle); - } - } - DropOldNeighbours(old); - - if (Scene.CapsModule != null) - Scene.CapsModule.SetChildrenSeed(UUID, seeds); - - KnownRegions = seeds; - //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); - //DumpKnownRegions(); - } - - public void DumpKnownRegions() - { - m_log.Info("================ KnownRegions "+Scene.RegionInfo.RegionName+" ================"); - foreach (KeyValuePair kvp in KnownRegions) - { - uint x, y; - Utils.LongToUInts(kvp.Key, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - m_log.Info(" >> "+x+", "+y+": "+kvp.Value); - } - } - - private bool m_inTransit; - private bool m_mouseLook; - private bool m_leftButtonDown; - - public bool IsInTransit - { - get { return m_inTransit; } - set { m_inTransit = value; } - } - - public float SpeedModifier - { - get { return m_speedModifier; } - set { m_speedModifier = value; } - } - - public bool ForceFly - { - get { return m_forceFly; } - set { m_forceFly = value; } - } - - public bool FlyDisabled - { - get { return m_flyDisabled; } - set { m_flyDisabled = value; } - } - - public string Viewer - { - get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } - } - - #endregion - - #region Constructor(s) - - public ScenePresence() - { - m_sendCourseLocationsMethod = SendCoarseLocationsDefault; - CreateSceneViewer(); - m_animator = new ScenePresenceAnimator(this); - } - - private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() - { - m_rootRegionHandle = reginfo.RegionHandle; - m_controllingClient = client; - m_firstname = m_controllingClient.FirstName; - m_lastname = m_controllingClient.LastName; - m_name = String.Format("{0} {1}", m_firstname, m_lastname); - m_scene = world; - m_uuid = client.AgentId; - m_regionInfo = reginfo; - m_localId = m_scene.AllocateLocalId(); - - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); - - if (account != null) - m_userLevel = account.UserLevel; - - IGroupsModule gm = m_scene.RequestModuleInterface(); - if (gm != null) - m_grouptitle = gm.GetGroupTitle(m_uuid); - - m_scriptEngines = m_scene.RequestModuleInterfaces(); - - AbsolutePosition = posLastSignificantMove = m_CameraCenter = - m_lastCameraCenter = m_controllingClient.StartPos; - - m_reprioritization_timer = new Timer(world.ReprioritizationInterval); - m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); - m_reprioritization_timer.AutoReset = false; - - AdjustKnownSeeds(); - Animator.TrySetMovementAnimation("STAND"); - // we created a new ScenePresence (a new child agent) in a fresh region. - // Request info about all the (root) agents in this region - // Note: This won't send data *to* other clients in that region (children don't send) - SendInitialFullUpdateToAllClients(); - RegisterToEvents(); - if (m_controllingClient != null) - { - m_controllingClient.ProcessPendingPackets(); - } - SetDirectionVectors(); - } - - public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, - AvatarWearable[] wearables) - : this(client, world, reginfo) - { - m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); - } - - public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) - : this(client, world, reginfo) - { - m_appearance = appearance; - } - - private void CreateSceneViewer() - { - m_sceneViewer = new SceneViewer(this); - } - - public void RegisterToEvents() - { - m_controllingClient.OnRequestWearables += SendWearables; - m_controllingClient.OnSetAppearance += SetAppearance; - m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; - //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; - m_controllingClient.OnAgentUpdate += HandleAgentUpdate; - m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; - m_controllingClient.OnAgentSit += HandleAgentSit; - m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; - m_controllingClient.OnStartAnim += HandleStartAnim; - m_controllingClient.OnStopAnim += HandleStopAnim; - m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; - m_controllingClient.OnAutoPilotGo += DoAutoPilot; - m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); - - // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); - // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - } - - private void SetDirectionVectors() - { - Dir_Vectors[0] = Vector3.UnitX; //FORWARD - Dir_Vectors[1] = -Vector3.UnitX; //BACK - Dir_Vectors[2] = Vector3.UnitY; //LEFT - Dir_Vectors[3] = -Vector3.UnitY; //RIGHT - Dir_Vectors[4] = Vector3.UnitZ; //UP - Dir_Vectors[5] = -Vector3.UnitZ; //DOWN - Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE - Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE - Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE - Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE - Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge - } - - private Vector3[] GetWalkDirectionVectors() - { - Vector3[] vector = new Vector3[11]; - vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD - vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK - vector[2] = Vector3.UnitY; //LEFT - vector[3] = -Vector3.UnitY; //RIGHT - vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP - vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN - vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE - vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE - vector[8] = Vector3.UnitY; //LEFT_NUDGE - vector[9] = -Vector3.UnitY; //RIGHT_NUDGE - vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE - return vector; - } - - private bool[] GetDirectionIsNudge() - { - bool[] isNudge = new bool[11]; - isNudge[0] = false; //FORWARD - isNudge[1] = false; //BACK - isNudge[2] = false; //LEFT - isNudge[3] = false; //RIGHT - isNudge[4] = false; //UP - isNudge[5] = false; //DOWN - isNudge[6] = true; //FORWARD_NUDGE - isNudge[7] = true; //BACK_NUDGE - isNudge[8] = true; //LEFT_NUDGE - isNudge[9] = true; //RIGHT_NUDGE - isNudge[10] = true; //DOWN_Nudge - return isNudge; - } - - - #endregion - - public uint GenerateClientFlags(UUID ObjectID) - { - return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); - } - - /// - /// Send updates to the client about prims which have been placed on the update queue. We don't - /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent - /// timestamp has already been sent. - /// - public void SendPrimUpdates() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_sceneViewer.SendPrimUpdates(); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - #region Status Methods - - /// - /// This turns a child agent, into a root agent - /// This is called when an agent teleports into a region, or if an - /// agent crosses into this region from a neighbor over the border - /// - public void MakeRootAgent(Vector3 pos, bool isFlying) - { - m_log.DebugFormat( - "[SCENE]: Upgrading child to root agent for {0} in {1}", - Name, m_scene.RegionInfo.RegionName); - - //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); - - IGroupsModule gm = m_scene.RequestModuleInterface(); - if (gm != null) - m_grouptitle = gm.GetGroupTitle(m_uuid); - - m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; - m_scene.SetRootAgentScene(m_uuid); - - // Moved this from SendInitialData to ensure that m_appearance is initialized - // before the inventory is processed in MakeRootAgent. This fixes a race condition - // related to the handling of attachments - //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - if (m_scene.TestBorderCross(pos, Cardinals.E)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); - pos.X = crossedBorder.BorderLine.Z - 1; - } - - if (m_scene.TestBorderCross(pos, Cardinals.N)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); - pos.Y = crossedBorder.BorderLine.Z - 1; - } - - //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. - //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, - //they'll bypass the landing point. But I can't think of any decent way of fixing this. - if (KnownChildRegionHandles.Count == 0) - { - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) - { - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) - { - pos = land.LandData.UserLocation; - } - } - } - - if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) - { - Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); - - if (pos.X < 0) - { - emergencyPos.X = (int)Constants.RegionSize + pos.X; - if (!(pos.Y < 0)) - emergencyPos.Y = pos.Y; - if (!(pos.Z < 0)) - emergencyPos.Z = pos.Z; - } - if (pos.Y < 0) - { - emergencyPos.Y = (int)Constants.RegionSize + pos.Y; - if (!(pos.X < 0)) - emergencyPos.X = pos.X; - if (!(pos.Z < 0)) - emergencyPos.Z = pos.Z; - } - if (pos.Z < 0) - { - emergencyPos.Z = 128; - if (!(pos.Y < 0)) - emergencyPos.Y = pos.Y; - if (!(pos.X < 0)) - emergencyPos.X = pos.X; - } - } - - if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) - { - m_log.WarnFormat( - "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", - pos, Name, UUID); - - if (pos.X < 0f) pos.X = 0f; - if (pos.Y < 0f) pos.Y = 0f; - if (pos.Z < 0f) pos.Z = 0f; - } - - float localAVHeight = 1.56f; - if (m_avHeight != 127.0f) - { - localAVHeight = m_avHeight; - } - - float posZLimit = 0; - - if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) - posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; - - float newPosZ = posZLimit + localAVHeight / 2; - if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - pos.Z = newPosZ; - } - AbsolutePosition = pos; - - AddToPhysicalScene(isFlying); - - if (m_forceFly) - { - m_physicsActor.Flying = true; - } - else if (m_flyDisabled) - { - m_physicsActor.Flying = false; - } - - if (m_appearance != null) - { - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - } - else - { - m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); - // emergency; this really shouldn't happen - m_appearance = new AvatarAppearance(UUID); - } - - // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying - // avatar to return to the standing position in mid-air. On login it looks like this is being sent - // elsewhere anyway - // Animator.SendAnimPack(); - - m_scene.SwapRootAgentCount(false); - - //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); - //if (userInfo != null) - // userInfo.FetchInventory(); - //else - // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); - - // On the next prim update, all objects will be sent - // - m_sceneViewer.Reset(); - - m_isChildAgent = false; - - // send the animations of the other presences to me - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - if (presence != this) - presence.Animator.SendAnimPackToClient(ControllingClient); - }); - - m_scene.EventManager.TriggerOnMakeRootAgent(this); - } - - /// - /// This turns a root agent into a child agent - /// when an agent departs this region for a neighbor, this gets called. - /// - /// It doesn't get called for a teleport. Reason being, an agent that - /// teleports out may not end up anywhere near this region - /// - public void MakeChildAgent() - { - // It looks like m_animator is set to null somewhere, and MakeChild - // is called after that. Probably in aborted teleports. - if (m_animator == null) - m_animator = new ScenePresenceAnimator(this); - else - Animator.ResetAnimations(); - -// m_log.DebugFormat( -// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", -// Name, UUID, m_scene.RegionInfo.RegionName); - - // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, - // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. - //Velocity = new Vector3(0, 0, 0); - - m_isChildAgent = true; - m_scene.SwapRootAgentCount(true); - RemoveFromPhysicalScene(); - - // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into - - m_scene.EventManager.TriggerOnMakeChildAgent(this); - } - - /// - /// Removes physics plugin scene representation of this agent if it exists. - /// - private void RemoveFromPhysicalScene() - { - if (PhysicsActor != null) - { - m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; - m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - m_physicsActor.UnSubscribeEvents(); - m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; - PhysicsActor = null; - } - } - - /// - /// - /// - /// - public void Teleport(Vector3 pos) - { - bool isFlying = false; - - if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - - RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - AbsolutePosition = pos; - AddToPhysicalScene(isFlying); - if (m_appearance != null) - { - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - } - - SendTerseUpdateToAllClients(); - - } - - public void TeleportWithMomentum(Vector3 pos) - { - bool isFlying = false; - if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - - RemoveFromPhysicalScene(); - AbsolutePosition = pos; - AddToPhysicalScene(isFlying); - if (m_appearance != null) - { - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - } - - SendTerseUpdateToAllClients(); - } - - /// - /// - /// - public void StopMovement() - { - } - - public void StopFlying() - { - ControllingClient.StopFlying(this); - } - - public void AddNeighbourRegion(ulong regionHandle, string cap) - { - lock (m_knownChildRegions) - { - if (!m_knownChildRegions.ContainsKey(regionHandle)) - { - uint x, y; - Utils.LongToUInts(regionHandle, out x, out y); - m_knownChildRegions.Add(regionHandle, cap); - } - } - } - - public void RemoveNeighbourRegion(ulong regionHandle) - { - lock (m_knownChildRegions) - { - if (m_knownChildRegions.ContainsKey(regionHandle)) - { - m_knownChildRegions.Remove(regionHandle); - //m_log.Debug(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); - } - } - } - - public void DropOldNeighbours(List oldRegions) - { - foreach (ulong handle in oldRegions) - { - RemoveNeighbourRegion(handle); - Scene.CapsModule.DropChildSeed(UUID, handle); - } - } - - public List GetKnownRegionList() - { - return new List(m_knownChildRegions.Keys); - } - - #endregion - - #region Event Handlers - - /// - /// Sets avatar height in the phyiscs plugin - /// - internal void SetHeight(float height) - { - m_avHeight = height; - if (PhysicsActor != null && !IsChildAgent) - { - Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); - PhysicsActor.Size = SetSize; - } - } - - /// - /// Complete Avatar's movement into the region. - /// This is called upon a very important packet sent from the client, - /// so it's client-controlled. Never call this method directly. - /// - public void CompleteMovement(IClientAPI client) - { - //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); - - Vector3 look = Velocity; - if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) - { - look = new Vector3(0.99f, 0.042f, 0); - } - - // Prevent teleporting to an underground location - // (may crash client otherwise) - // - Vector3 pos = AbsolutePosition; - float ground = m_scene.GetGroundHeight(pos.X, pos.Y); - if (pos.Z < ground + 1.5f) - { - pos.Z = ground + 1.5f; - AbsolutePosition = pos; - } - m_isChildAgent = false; - bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); - MakeRootAgent(AbsolutePosition, m_flying); - - if ((m_callbackURI != null) && !m_callbackURI.Equals("")) - { - m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); - Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); - m_callbackURI = null; - } - - //m_log.DebugFormat("Completed movement"); - - m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); - SendInitialData(); - - // Create child agents in neighbouring regions - if (!m_isChildAgent) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); - else - m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); - - IFriendsModule friendsModule = m_scene.RequestModuleInterface(); - if (friendsModule != null) - friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); - } - - } - - /// - /// Callback for the Camera view block check. Gets called with the results of the camera view block test - /// hitYN is true when there's something in the way. - /// - /// - /// - /// - /// - public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) - { - const float POSITION_TOLERANCE = 0.02f; - const float VELOCITY_TOLERANCE = 0.02f; - const float ROTATION_TOLERANCE = 0.02f; - - if (m_followCamAuto) - { - if (hitYN) - { - CameraConstraintActive = true; - //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); - - Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); - ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); - } - else - { - if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) - { - if (CameraConstraintActive) - { - ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); - CameraConstraintActive = false; - } - } - } - } - } - - /// - /// This is the event handler for client movement. If a client is moving, this event is triggering. - /// - public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) - { - //if (m_isChildAgent) - //{ - // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); - // return; - //} - - m_perfMonMS = Util.EnvironmentTickCount(); - - ++m_movementUpdateCount; - if (m_movementUpdateCount < 1) - m_movementUpdateCount = 1; - - #region Sanity Checking - - // This is irritating. Really. - if (!AbsolutePosition.IsFinite()) - { - RemoveFromPhysicalScene(); - m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); - - m_pos = m_LastFinitePos; - - if (!m_pos.IsFinite()) - { - m_pos.X = 127f; - m_pos.Y = 127f; - m_pos.Z = 127f; - m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); - } - - AddToPhysicalScene(false); - } - else - { - m_LastFinitePos = m_pos; - } - - #endregion Sanity Checking - - #region Inputs - - AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; - Quaternion bodyRotation = agentData.BodyRotation; - - // Camera location in world. We'll need to raytrace - // from this location from time to time. - m_CameraCenter = agentData.CameraCenter; - if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) - { - ReprioritizeUpdates(); - m_lastCameraCenter = m_CameraCenter; - } - - // Use these three vectors to figure out what the agent is looking at - // Convert it to a Matrix and/or Quaternion - m_CameraAtAxis = agentData.CameraAtAxis; - m_CameraLeftAxis = agentData.CameraLeftAxis; - m_CameraUpAxis = agentData.CameraUpAxis; - - // The Agent's Draw distance setting - m_DrawDistance = agentData.Far; - - // Check if Client has camera in 'follow cam' or 'build' mode. - Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); - - m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) - && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; - - m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; - m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; - - #endregion Inputs - - if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) - { - StandUp(); - } - - //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); - // Raycast from the avatar's head to the camera to see if there's anything blocking the view - if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) - { - if (m_followCamAuto) - { - Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; - m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); - } - } - lock (scriptedcontrols) - { - if (scriptedcontrols.Count > 0) - { - SendControlToScripts((uint)flags); - flags = RemoveIgnoredControls(flags, IgnoredControls); - } - } - - if (m_autopilotMoving) - CheckAtSitTarget(); - - if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) - { - m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. - Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); - - // TODO: This doesn't prevent the user from walking yet. - // Setting parent ID would fix this, if we knew what value - // to use. Or we could add a m_isSitting variable. - //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); - SitGround = true; - } - - // In the future, these values might need to go global. - // Here's where you get them. - m_AgentControlFlags = flags; - m_headrotation = agentData.HeadRotation; - m_state = agentData.State; - - PhysicsActor actor = PhysicsActor; - if (actor == null) - { - return; - } - - bool update_movementflag = false; - - if (m_allowMovement && !SitGround) - { - if (agentData.UseClientAgentPosition) - { - m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; - m_moveToPositionTarget = agentData.ClientAgentPosition; - } - - int i = 0; - - bool update_rotation = false; - bool DCFlagKeyPressed = false; - Vector3 agent_control_v3 = Vector3.Zero; - Quaternion q = bodyRotation; - - bool oldflying = PhysicsActor.Flying; - - if (m_forceFly) - actor.Flying = true; - else if (m_flyDisabled) - actor.Flying = false; - else - actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); - - if (actor.Flying != oldflying) - update_movementflag = true; - - if (q != m_bodyRot) - { - m_bodyRot = q; - update_rotation = true; - } - - //guilty until proven innocent.. - bool Nudging = true; - //Basically, if there is at least one non-nudge control then we don't need - //to worry about stopping the avatar - - if (m_parentID == 0) - { - bool bAllowUpdateMoveToPosition = false; - bool bResetMoveToPosition = false; - - Vector3[] dirVectors; - - // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying - // this prevents 'jumping' in inappropriate situations. - if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) - dirVectors = GetWalkDirectionVectors(); - else - dirVectors = Dir_Vectors; - - bool[] isNudge = GetDirectionIsNudge(); - - - - - - foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) - { - if (((uint)flags & (uint)DCF) != 0) - { - bResetMoveToPosition = true; - DCFlagKeyPressed = true; - try - { - agent_control_v3 += dirVectors[i]; - if (isNudge[i] == false) - { - Nudging = false; - } - } - catch (IndexOutOfRangeException) - { - // Why did I get this? - } - - if ((m_movementflag & (uint)DCF) == 0) - { - m_movementflag += (byte)(uint)DCF; - update_movementflag = true; - } - } - else - { - if ((m_movementflag & (uint)DCF) != 0) - { - m_movementflag -= (byte)(uint)DCF; - update_movementflag = true; - } - else - { - bAllowUpdateMoveToPosition = true; - } - } - i++; - } - //Paupaw:Do Proper PID for Autopilot here - if (bResetMoveToPosition) - { - m_moveToPositionTarget = Vector3.Zero; - m_moveToPositionInProgress = false; - update_movementflag = true; - bAllowUpdateMoveToPosition = false; - } - - if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) - { - //Check the error term of the current position in relation to the target position - if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) - { - // we are close enough to the target - m_moveToPositionTarget = Vector3.Zero; - m_moveToPositionInProgress = false; - update_movementflag = true; - } - else - { - try - { - // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. - // This movement vector gets added to the velocity through AddNewMovement(). - // Theoretically we might need a more complex PID approach here if other - // unknown forces are acting on the avatar and we need to adaptively respond - // to such forces, but the following simple approach seems to works fine. - Vector3 LocalVectorToTarget3D = - (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords - * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords - // Ignore z component of vector - Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); - LocalVectorToTarget2D.Normalize(); - - //We're not nudging - Nudging = false; - agent_control_v3 += LocalVectorToTarget2D; - - // update avatar movement flags. the avatar coordinate system is as follows: - // - // +X (forward) - // - // ^ - // | - // | - // | - // | - // (left) +Y <--------o--------> -Y - // avatar - // | - // | - // | - // | - // v - // -X - // - - // based on the above avatar coordinate system, classify the movement into - // one of left/right/back/forward. - if (LocalVectorToTarget2D.Y > 0)//MoveLeft - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; - //AgentControlFlags - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; - update_movementflag = true; - } - else if (LocalVectorToTarget2D.Y < 0) //MoveRight - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; - update_movementflag = true; - } - if (LocalVectorToTarget2D.X < 0) //MoveBack - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; - update_movementflag = true; - } - else if (LocalVectorToTarget2D.X > 0) //Move Forward - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; - update_movementflag = true; - } - } - catch (Exception e) - { - //Avoid system crash, can be slower but... - m_log.DebugFormat("Crash! {0}", e.ToString()); - } - } - } - } - - // Cause the avatar to stop flying if it's colliding - // with something with the down arrow pressed. - - // Only do this if we're flying - if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) - { - // Landing detection code - - // Are the landing controls requirements filled? - bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || - ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - - // Are the collision requirements fulfilled? - bool colliding = (m_physicsActor.IsColliding == true); - - if (m_physicsActor.Flying && colliding && controlland) - { - // nesting this check because LengthSquared() is expensive and we don't - // want to do it every step when flying. - if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) - StopFlying(); - } - } - - if (update_movementflag || (update_rotation && DCFlagKeyPressed)) - { - // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); - // m_log.DebugFormat( - // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); - - AddNewMovement(agent_control_v3, q, Nudging); - - - } - } - - if (update_movementflag && !SitGround) - Animator.UpdateMovementAnimations(); - - m_scene.EventManager.TriggerOnClientMovement(this); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) - { - m_autopilotMoving = true; - m_autoPilotTarget = Pos; - m_sitAtAutoTarget = false; - PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; - //proxy.PCode = (byte)PCode.ParticleSystem; - proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); - proxyObjectGroup.AttachToScene(m_scene); - - // Commented out this code since it could never have executed, but might still be informative. -// if (proxyObjectGroup != null) -// { - proxyObjectGroup.SendGroupFullUpdate(); - remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); - m_scene.DeleteSceneObject(proxyObjectGroup, false); -// } -// else -// { -// m_autopilotMoving = false; -// m_autoPilotTarget = Vector3.Zero; -// ControllingClient.SendAlertMessage("Autopilot cancelled"); -// } - } - - public void DoMoveToPosition(Object sender, string method, List args) - { - try - { - float locx = 0f; - float locy = 0f; - float locz = 0f; - uint regionX = 0; - uint regionY = 0; - try - { - Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); - locx = Convert.ToSingle(args[0]) - (float)regionX; - locy = Convert.ToSingle(args[1]) - (float)regionY; - locz = Convert.ToSingle(args[2]); - } - catch (InvalidCastException) - { - m_log.Error("[CLIENT]: Invalid autopilot request"); - return; - } - m_moveToPositionInProgress = true; - m_moveToPositionTarget = new Vector3(locx, locy, locz); - } - catch (Exception ex) - { - //Why did I get this error? - m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); - } - } - - private void CheckAtSitTarget() - { - //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); - if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) - { - if (m_sitAtAutoTarget) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); - if (part != null) - { - AbsolutePosition = part.AbsolutePosition; - Velocity = Vector3.Zero; - SendFullUpdateToAllClients(); - - HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? - } - //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); - m_requestedSitTargetUUID = UUID.Zero; - } - /* - else - { - //ControllingClient.SendAlertMessage("Autopilot cancelled"); - //SendTerseUpdateToAllClients(); - //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; - //proxy.PCode = (byte)PCode.ParticleSystem; - ////uint nextUUID = m_scene.NextLocalId; - - //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); - //if (proxyObjectGroup != null) - //{ - //proxyObjectGroup.SendGroupFullUpdate(); - //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); - //m_scene.DeleteSceneObject(proxyObjectGroup); - //} - } - */ - m_autoPilotTarget = Vector3.Zero; - m_autopilotMoving = false; - } - } - /// - /// Perform the logic necessary to stand the avatar up. This method also executes - /// the stand animation. - /// - public void StandUp() - { - SitGround = false; - - if (m_parentID != 0) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); - if (part != null) - { - part.TaskInventory.LockItemsForRead(true); - TaskInventoryDictionary taskIDict = part.TaskInventory; - if (taskIDict != null) - { - foreach (UUID taskID in taskIDict.Keys) - { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS - } - } - part.TaskInventory.LockItemsForRead(false); - // Reset sit target. - if (part.GetAvatarOnSitTarget() == UUID) - part.SetAvatarOnSitTarget(UUID.Zero); - m_parentPosition = part.GetWorldPosition(); - ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - } - // part.GetWorldRotation() is the rotation of the object being sat on - // Rotation is the sittiing Av's rotation - - Quaternion partRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partRot = part.ParentGroup.RootPart.RotationOffset; -// } -// else -// { // single or child prim - -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); - } - - Quaternion partIRot = Quaternion.Inverse(partRot); - - Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av - Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av - - - if (m_physicsActor == null) - { - AddToPhysicalScene(false); - } - //CW: If the part isn't null then we can set the current position - if (part != null) - { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - part.IsOccupied = false; - part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); - } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; - } - - m_parentPosition = Vector3.Zero; - m_parentID = 0; - m_linkedPrim = UUID.Zero; - m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - SendFullUpdateToAllClients(); - m_requestedSitTargetID = 0; - - if ((m_physicsActor != null) && (m_avHeight > 0)) - { - SetHeight(m_avHeight); - } - } - Animator.TrySetMovementAnimation("STAND"); - } - - private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) - { - SceneObjectPart targetPart = m_scene.GetSceneObjectPart(targetID); - if (targetPart == null) - return null; - - // If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used. - // If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used. - - // Get our own copy of the part array, and sort into the order we want to test - SceneObjectPart[] partArray = targetPart.ParentGroup.GetParts(); - Array.Sort(partArray, delegate(SceneObjectPart p1, SceneObjectPart p2) - { - // we want the originally selected part first, then the rest in link order -- so make the selected part link num (-1) - int linkNum1 = p1==targetPart ? -1 : p1.LinkNum; - int linkNum2 = p2==targetPart ? -1 : p2.LinkNum; - return linkNum1 - linkNum2; - } - ); - - //look for prims with explicit sit targets that are available - foreach (SceneObjectPart part in partArray) - { - // Is a sit target available? - Vector3 avSitOffSet = part.SitTargetPosition; - Quaternion avSitOrientation = part.SitTargetOrientation; - UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); - bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); - bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. - if (SitTargetisSet && !SitTargetOccupied) - { - //switch the target to this prim - return part; - } - } - - // no explicit sit target found - use original target - return targetPart; - } - - private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) - { - bool autopilot = true; - Vector3 autopilotTarget = new Vector3(); - Quaternion sitOrientation = Quaternion.Identity; - Vector3 pos = new Vector3(); - Vector3 cameraEyeOffset = Vector3.Zero; - Vector3 cameraAtOffset = Vector3.Zero; - bool forceMouselook = false; - - //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); - if (part == null) return; - - // TODO: determine position to sit at based on scene geometry; don't trust offset from client - // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - - // part is the prim to sit on - // offset is the world-ref vector distance from that prim center to the click-spot - // UUID is the UUID of the Avatar doing the clicking - - m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation - - // Is a sit target available? - Vector3 avSitOffSet = part.SitTargetPosition; - Quaternion avSitOrientation = part.SitTargetOrientation; - - bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. - // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); - Quaternion partRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partRot = part.ParentGroup.RootPart.RotationOffset; -// } -// else -// { // single or child prim - partRot = part.GetWorldRotation(); -// } - Quaternion partIRot = Quaternion.Inverse(partRot); -//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); - // Sit analysis rewritten by KF 091125 - if (SitTargetisSet) // scipted sit - { - if (!part.IsOccupied) - { -//Console.WriteLine("Scripted, unoccupied"); - part.SetAvatarOnSitTarget(UUID); // set that Av will be on it - offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one - - Quaternion nrot = avSitOrientation; - if (!part.IsRoot) - { - nrot = part.RotationOffset * avSitOrientation; - } - sitOrientation = nrot; // Change rotatione to the scripted one - OffsetRotation = nrot; - autopilot = false; // Jump direct to scripted llSitPos() - } - else - { -//Console.WriteLine("Scripted, occupied"); - return; - } - } - else // Not Scripted - { - if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) - { - // large prim & offset, ignore if other Avs sitting -// offset.Z -= 0.05f; - m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked - autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point - -//Console.WriteLine(" offset ={0}", offset); -//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); -//Console.WriteLine(" autopilotTarget={0}", autopilotTarget); - - } - else // small offset - { -//Console.WriteLine("Small offset"); - if (!part.IsOccupied) - { - m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center - autopilotTarget = part.AbsolutePosition; -//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); - } - else return; // occupied small - } // end large/small - } // end Scripted/not - cameraAtOffset = part.GetCameraAtOffset(); - cameraEyeOffset = part.GetCameraEyeOffset(); - forceMouselook = part.GetForceMouselook(); - if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // - if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // - - if (m_physicsActor != null) - { - // If we're not using the client autopilot, we're immediately warping the avatar to the location - // We can remove the physicsActor until they stand up. - m_sitAvatarHeight = m_physicsActor.Size.Z; - if (autopilot) - { // its not a scripted sit -// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) - if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) - { - autopilot = false; // close enough - m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. - Not using the part's position because returning the AV to the last known standing - position is likely to be more friendly, isn't it? */ - RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target - } // else the autopilot will get us close - } - else - { // its a scripted sit - m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. - I *am* using the part's position this time because we have no real idea how far away - the avatar is from the sit target. */ - RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - } - } - else return; // physactor is null! - - Vector3 offsetr; // = offset * partIRot; - // KF: In a linkset, offsetr needs to be relative to the group root! 091208 - // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); - // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. - // { // Single, or Root prim of linkset, target is ClickOffset * RootRot - //offsetr = offset * partIRot; -// - // else - // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) - // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + - // (offset * partRot); - // } - -//Console.WriteLine(" "); -//Console.WriteLine("link number ={0}", part.LinkNum); -//Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); -//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); -//Console.WriteLine("Click offst ={0}", offset); -//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); -//Console.WriteLine("offsetr ={0}", offsetr); -//Console.WriteLine("Camera At ={0}", cameraAtOffset); -//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); - - //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child - ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); - - m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target - // This calls HandleAgentSit twice, once from here, and the client calls - // HandleAgentSit itself after it gets to the location - // It doesn't get to the location until we've moved them there though - // which happens in HandleAgentSit :P - m_autopilotMoving = autopilot; - m_autoPilotTarget = autopilotTarget; - m_sitAtAutoTarget = autopilot; - m_initialSitTarget = autopilotTarget; - if (!autopilot) - HandleAgentSit(remoteClient, UUID); - } - - public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) - { - if (m_parentID != 0) - { - StandUp(); - } - m_nextSitAnimation = "SIT"; - - //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); - - if (part != null) - { - if (!String.IsNullOrEmpty(part.SitAnimation)) - { - m_nextSitAnimation = part.SitAnimation; - } - m_requestedSitTargetID = part.LocalId; - //m_requestedSitOffset = offset; - m_requestedSitTargetUUID = targetID; - - m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - - if (m_scene.PhysicsScene.SupportsRayCast()) - { - //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); - //SitRayCastAvatarPosition(part); - //return; - } - } - else - { - - m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); - } - - - - SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); - } - /* - public void SitRayCastAvatarPosition(SceneObjectPart part) - { - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); - } - - public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) - { - // Next, try to raycast from the camera Z position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); - } - - public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayCastCameraPosition(SceneObjectPart part) - { - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); - } - - public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayHorizontal(part); - } - } - else - { - SitRayHorizontal(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayHorizontal(SceneObjectPart part) - { - // Next, try to raycast from the avatar position to fwd - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); - } - - public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) - { - int i = 0; - //throw new NotImplementedException(); - //m_requestedSitTargetUUID = UUID.Zero; - //m_requestedSitTargetID = 0; - //m_requestedSitOffset = Vector3.Zero; - - SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); - } - */ - public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) - { - if (m_parentID != 0) - { - StandUp(); - } - if (!String.IsNullOrEmpty(sitAnimation)) - { - m_nextSitAnimation = sitAnimation; - } - else - { - m_nextSitAnimation = "SIT"; - } - - //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); - if (part != null) - { - m_requestedSitTargetID = part.LocalId; - //m_requestedSitOffset = offset; - m_requestedSitTargetUUID = targetID; - - m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - - if (m_scene.PhysicsScene.SupportsRayCast()) - { - //SitRayCastAvatarPosition(part); - //return; - } - } - else - { - m_log.Warn("Sit requested on unknown object: " + targetID); - } - - SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); - } - - public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) - { - if (!String.IsNullOrEmpty(m_nextSitAnimation)) - { - HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); - } - else - { - HandleAgentSit(remoteClient, agentID, "SIT"); - } - } - - public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) - { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); - - if (m_sitAtAutoTarget || !m_autopilotMoving) - { - if (part != null) - { -//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); - if (part.GetAvatarOnSitTarget() == UUID) - { -//Console.WriteLine("Scripted Sit"); - // Scripted sit - Vector3 sitTargetPos = part.SitTargetPosition; - Quaternion sitTargetOrient = part.SitTargetOrientation; - m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); - m_pos += SIT_TARGET_ADJUSTMENT; - if (!part.IsRoot) - { - m_pos *= part.RotationOffset; - } - m_bodyRot = sitTargetOrient; - m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); - } - else - { - // if m_avUnscriptedSitPos is zero then Av sits above center - // Else Av sits at m_avUnscriptedSitPos - - // Non-scripted sit by Kitto Flora 21Nov09 - // Calculate angle of line from prim to Av - Quaternion partIRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); -// } -// else -// { // single or child prim - partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; - float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); - float x_diff = ( m_avInitialPos.X - sitTargetPos.X); - if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 - if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 - float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); - // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. - // Av sits at world euler <0,0, z>, translated by part rotation - m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click - - m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); - m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation - (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center - (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + - m_avUnscriptedSitPos; // adds click offset, if any - //Set up raytrace to find top surface of prim - Vector3 size = part.Scale; - float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); - Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); - Vector3 down = new Vector3(0f, 0f, -1f); -//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); - m_scene.PhysicsScene.RaycastWorld( - start, // Vector3 position, - down, // Vector3 direction, - mag, // float length, - SitAltitudeCallback); // retMethod - } // end scripted/not - } - else // no Av - { - return; - } - } - - //We want our offsets to reference the root prim, not the child we may have sat on - if (!part.IsRoot) - { - m_parentID = part.ParentGroup.RootPart.LocalId; - m_pos += part.OffsetPosition; - } - else - { - m_parentID = m_requestedSitTargetID; - } - - m_linkedPrim = part.UUID; - if (part.GetAvatarOnSitTarget() != UUID) - { - m_offsetRotation = m_offsetRotation / part.RotationOffset; - } - Velocity = Vector3.Zero; - RemoveFromPhysicalScene(); - Animator.TrySetMovementAnimation(sitAnimation); - SendFullUpdateToAllClients(); - SendTerseUpdateToAllClients(); - } - - public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) - { - // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer - // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. - if(hitYN) - { - // m_pos = Av offset from prim center to make look like on center - // m_parentPosition = Actual center pos of prim - // collisionPoint = spot on prim where we want to sit - // collisionPoint.Z = global sit surface height - SceneObjectPart part = m_scene.GetSceneObjectPart(localid); - Quaternion partIRot; -// if (part.LinkNum == 1) -/// { // Root prim of linkset -// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); -// } -// else -// { // single or child prim - partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - if (m_initialSitTarget != null) - { - float offZ = collisionPoint.Z - m_initialSitTarget.Z; - Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction - //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); - m_pos += offset; - // ControllingClient.SendClearFollowCamProperties(part.UUID); - } - - } - } // End SitAltitudeCallback KF. - - /// - /// Event handler for the 'Always run' setting on the client - /// Tells the physics plugin to increase speed of movement. - /// - public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) - { - m_setAlwaysRun = pSetAlwaysRun; - if (PhysicsActor != null) - { - PhysicsActor.SetAlwaysRun = pSetAlwaysRun; - } - } - - public void HandleStartAnim(IClientAPI remoteClient, UUID animID) - { - Animator.AddAnimation(animID, UUID.Zero); - } - - public void HandleStopAnim(IClientAPI remoteClient, UUID animID) - { - Animator.RemoveAnimation(animID); - } - - /// - /// Rotate the avatar to the given rotation and apply a movement in the given relative vector - /// - /// The vector in which to move. This is relative to the rotation argument - /// The direction in which this avatar should now face. - public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) - { - if (m_isChildAgent) - { - // WHAT??? - m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); - - // we have to reset the user's child agent connections. - // Likely, here they've lost the eventqueue for other regions so border - // crossings will fail at this point unless we reset them. - - List regions = new List(KnownChildRegionHandles); - regions.Remove(m_scene.RegionInfo.RegionHandle); - - MakeRootAgent(new Vector3(127f, 127f, 127f), true); - - // Async command - if (m_scene.SceneGridService != null) - { - m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); - - // Give the above command some time to try and close the connections. - // this is really an emergency.. so sleep, or we'll get all discombobulated. - System.Threading.Thread.Sleep(500); - } - - if (m_scene.SceneGridService != null) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); - } - - return; - } - - m_perfMonMS = Util.EnvironmentTickCount(); - - Rotation = rotation; - Vector3 direc = vec * rotation; - direc.Normalize(); - PhysicsActor actor = m_physicsActor; - if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. - - direc *= 0.03f * 128f * m_speedModifier; - - if (actor != null) - { - if (actor.Flying) - { - direc *= 4.0f; - //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - //bool colliding = (m_physicsActor.IsColliding==true); - //if (controlland) - // m_log.Info("[AGENT]: landCommand"); - //if (colliding) - // m_log.Info("[AGENT]: colliding"); - //if (m_physicsActor.Flying && colliding && controlland) - //{ - // StopFlying(); - // m_log.Info("[AGENT]: Stop FLying"); - //} - } - else if (!actor.Flying && actor.IsColliding) - { - if (direc.Z > 2.0f) - { - if(m_animator.m_animTickJump == -1) - { - direc.Z *= 3.0f; // jump - } - else - { - direc.Z *= 0.1f; // prejump - } - /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs - Animator.TrySetMovementAnimation("PREJUMP"); - Animator.TrySetMovementAnimation("JUMP"); - */ - } - } - } - - // TODO: Add the force instead of only setting it to support multiple forces per frame? - m_forceToApply = direc; - m_isNudging = Nudging; - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - #endregion - - #region Overridden Methods - - public override void Update() - { - const float ROTATION_TOLERANCE = 0.01f; - const float VELOCITY_TOLERANCE = 0.001f; - const float POSITION_TOLERANCE = 0.05f; - //const int TIME_MS_TOLERANCE = 3000; - - - - if (m_isChildAgent == false) - { -// PhysicsActor actor = m_physicsActor; - - // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to - // grab the latest PhysicsActor velocity, whereas m_velocity is often - // storing a requested force instead of an actual traveling velocity - - // Throw away duplicate or insignificant updates - if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || - !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) - //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) - { - SendTerseUpdateToAllClients(); - - // Update the "last" values - m_lastPosition = m_pos; - m_lastRotation = m_bodyRot; - m_lastVelocity = Velocity; - //m_lastTerseSent = Environment.TickCount; - } - - // followed suggestion from mic bowman. reversed the two lines below. - if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something - CheckForBorderCrossing(); - CheckForSignificantMovement(); // sends update to the modules. - } - - //Sending prim updates AFTER the avatar terse updates are sent - SendPrimUpdates(); - } - - #endregion - - #region Update Client(s) - - /// - /// Sends a location update to the client connected to this scenePresence - /// - /// - public void SendTerseUpdateToClient(IClientAPI remoteClient) - { - // If the client is inactive, it's getting its updates from another - // server. - if (remoteClient.IsActive) - { - m_perfMonMS = Util.EnvironmentTickCount(); - - PhysicsActor actor = m_physicsActor; - Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); - - remoteClient.SendPrimUpdate(this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - m_scene.StatsReporter.AddAgentUpdates(1); - } - } - - /// - /// Send a location/velocity/accelleration update to all agents in scene - /// - public void SendTerseUpdateToAllClients() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_scene.ForEachClient(SendTerseUpdateToClient); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - public void SendCoarseLocations(List coarseLocations, List avatarUUIDs) - { - SendCourseLocationsMethod d = m_sendCourseLocationsMethod; - if (d != null) - { - d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); - } - } - - public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) - { - if (d != null) - m_sendCourseLocationsMethod = d; - } - - public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List coarseLocations, List avatarUUIDs) - { - m_perfMonMS = Util.EnvironmentTickCount(); - m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - /// - /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) - /// - /// - public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) - { - // 2 stage check is needed. - if (remoteAvatar == null) - return; - IClientAPI cl=remoteAvatar.ControllingClient; - if (cl == null) - return; - if (m_appearance.Texture == null) - return; - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); - m_scene.StatsReporter.AddAgentUpdates(1); - } - - /// - /// Tell *ALL* agents about this agent - /// - public void SendInitialFullUpdateToAllClients() - { - m_perfMonMS = Util.EnvironmentTickCount(); - int avUpdates = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - ++avUpdates; - // only send if this is the root (children are only "listening posts" in a foreign region) - if (!IsChildAgent) - { - SendFullUpdateToOtherClient(avatar); - } - - if (avatar.LocalId != LocalId) - { - if (!avatar.IsChildAgent) - { - avatar.SendFullUpdateToOtherClient(this); - avatar.SendAppearanceToOtherAgent(this); - avatar.Animator.SendAnimPackToClient(ControllingClient); - } - } - }); - - m_scene.StatsReporter.AddAgentUpdates(avUpdates); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - - //Animator.SendAnimPack(); - } - - public void SendFullUpdateToAllClients() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - // only send update from root agents to other clients; children are only "listening posts" - int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence sp) - { - if (sp.IsChildAgent) - return; - SendFullUpdateToOtherClient(sp); - ++count; - }); - m_scene.StatsReporter.AddAgentUpdates(count); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - - Animator.SendAnimPack(); - } - - /// - /// Do everything required once a client completes its movement into a region - /// - public void SendInitialData() - { - // Moved this into CompleteMovement to ensure that m_appearance is initialized before - // the inventory arrives - // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - m_controllingClient.SendAvatarDataImmediate(this); - - SendInitialFullUpdateToAllClients(); - SendAppearanceToAllOtherAgents(); - } - - /// - /// Tell the client for this scene presence what items it should be wearing now - /// - public void SendWearables() - { - m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name); - - ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); - } - - /// - /// - /// - public void SendAppearanceToAllOtherAgents() - { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - if (scenePresence.UUID != UUID) - { - SendAppearanceToOtherAgent(scenePresence); - } - }); - - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - } - - /// - /// Send appearance data to an agent that isn't this one. - /// - /// - public void SendAppearanceToOtherAgent(ScenePresence avatar) - { - avatar.ControllingClient.SendAppearance( - m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); - } - - /// - /// Set appearance data (textureentry and slider settings) received from the client - /// - /// - /// - public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) - { - if (m_physicsActor != null) - { - if (!IsChildAgent) - { - // This may seem like it's redundant, remove the avatar from the physics scene - // just to add it back again, but it saves us from having to update - // 3 variables 10 times a second. - bool flyingTemp = m_physicsActor.Flying; - RemoveFromPhysicalScene(); - //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); - - //PhysicsActor = null; - - AddToPhysicalScene(flyingTemp); - } - } - - #region Bake Cache Check - - if (textureEntry != null) - { - for (int i = 0; i < BAKE_INDICES.Length; i++) - { - int j = BAKE_INDICES[i]; - Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; - - if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) - { - if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) - { - m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); - this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); - } - } - } - - } - - - #endregion Bake Cache Check - - m_appearance.SetAppearance(textureEntry, visualParams); - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); - - // This is not needed, because only the transient data changed - //AvatarData adata = new AvatarData(m_appearance); - //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); - - SendAppearanceToAllOtherAgents(); - if (!m_startAnimationSet) - { - Animator.UpdateMovementAnimations(); - m_startAnimationSet = true; - } - - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; - - m_controllingClient.SendAvatarDataImmediate(this); - } - - public void SetWearable(int wearableId, AvatarWearable wearable) - { - m_appearance.SetWearable(wearableId, wearable); - AvatarData adata = new AvatarData(m_appearance); - m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); - m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); - } - - // Because appearance setting is in a module, we actually need - // to give it access to our appearance directly, otherwise we - // get a synchronization issue. - public AvatarAppearance Appearance - { - get { return m_appearance; } - set { m_appearance = value; } - } - - #endregion - - #region Significant Movement Method - - /// - /// This checks for a significant movement and sends a courselocationchange update - /// - protected void CheckForSignificantMovement() - { - // Movement updates for agents in neighboring regions are sent directly to clients. - // This value only affects how often agent positions are sent to neighbor regions - // for things such as distance-based update prioritization - const float SIGNIFICANT_MOVEMENT = 2.0f; - - if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) - { - posLastSignificantMove = AbsolutePosition; - m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); - } - - // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m - if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || - Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) - { - m_lastChildAgentUpdatePosition = AbsolutePosition; - m_lastChildAgentUpdateCamPosition = CameraPosition; - - ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); - cadu.ActiveGroupID = UUID.Zero.Guid; - cadu.AgentID = UUID.Guid; - cadu.alwaysrun = m_setAlwaysRun; - cadu.AVHeight = m_avHeight; - Vector3 tempCameraCenter = m_CameraCenter; - cadu.cameraPosition = tempCameraCenter; - cadu.drawdistance = m_DrawDistance; - cadu.GroupAccess = 0; - cadu.Position = AbsolutePosition; - cadu.regionHandle = m_rootRegionHandle; - float multiplier = 1; - int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); - if (innacurateNeighbors != 0) - { - multiplier = 1f / (float)innacurateNeighbors; - } - if (multiplier <= 0f) - { - multiplier = 0.25f; - } - - //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); - cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); - cadu.Velocity = Velocity; - - AgentPosition agentpos = new AgentPosition(); - agentpos.CopyFrom(cadu); - - m_scene.SendOutChildAgentUpdates(agentpos, this); - } - } - - #endregion - - #region Border Crossing Methods - - /// - /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion - /// - protected void CheckForBorderCrossing() - { - if (IsChildAgent) - return; - - Vector3 pos2 = AbsolutePosition; - Vector3 vel = Velocity; - int neighbor = 0; - int[] fix = new int[2]; - - float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X*timeStep); - pos2.Y = pos2.Y + (vel.Y*timeStep); - pos2.Z = pos2.Z + (vel.Z*timeStep); - - if (!IsInTransit) - { - // Checks if where it's headed exists a region - - bool needsTransit = false; - if (m_scene.TestBorderCross(pos2, Cardinals.W)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.SW, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.NW, ref fix); - } - else - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.W, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.E)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.SE, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.NE, ref fix); - } - else - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.E, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.S, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = HaveNeighbor(Cardinals.N, ref fix); - } - - - // Makes sure avatar does not end up outside region - if (neighbor <= 0) - { - if (!needsTransit) - { - if (m_requestedSitTargetUUID == UUID.Zero) - { - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y; - AbsolutePosition = pos; - } - } - } - else if (neighbor > 0) - CrossToNewRegion(); - } - else - { - RemoveFromPhysicalScene(); - // This constant has been inferred from experimentation - // I'm not sure what this value should be, so I tried a few values. - timeStep = 0.04f; - pos2 = AbsolutePosition; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); - m_pos = pos2; - } - } - - protected int HaveNeighbor(Cardinals car, ref int[] fix) - { - uint neighbourx = m_regionInfo.RegionLocX; - uint neighboury = m_regionInfo.RegionLocY; - - int dir = (int)car; - - if (dir > 1 && dir < 5) //Heading East - neighbourx++; - else if (dir > 5) // Heading West - neighbourx--; - - if (dir < 3 || dir == 8) // Heading North - neighboury++; - else if (dir > 3 && dir < 7) // Heading Sout - neighboury--; - - int x = (int)(neighbourx * Constants.RegionSize); - int y = (int)(neighboury * Constants.RegionSize); - GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); - - if (neighbourRegion == null) - { - fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); - fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); - return dir * (-1); - } - else - return dir; - } - - /// - /// Moves the agent outside the region bounds - /// Tells neighbor region that we're crossing to it - /// If the neighbor accepts, remove the agent's viewable avatar from this scene - /// set them to a child agent. - /// - protected void CrossToNewRegion() - { - InTransit(); - try - { - m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); - } - catch - { - m_scene.CrossAgentToNewRegion(this, false); - } - } - - public void InTransit() - { - m_inTransit = true; - - if ((m_physicsActor != null) && m_physicsActor.Flying) - m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; - else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) - m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; - } - - public void NotInTransit() - { - m_inTransit = false; - } - - public void RestoreInCurrentScene() - { - AddToPhysicalScene(false); // not exactly false - } - - public void Reset() - { - // Put the child agent back at the center - AbsolutePosition - = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); - Animator.ResetAnimations(); - } - - /// - /// Computes which child agents to close when the scene presence moves to another region. - /// Removes those regions from m_knownRegions. - /// - /// The new region's x on the map - /// The new region's y on the map - /// - public void CloseChildAgents(uint newRegionX, uint newRegionY) - { - List byebyeRegions = new List(); - m_log.DebugFormat( - "[SCENE PRESENCE]: Closing child agents. Checking {0} regions in {1}", - m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName); - //DumpKnownRegions(); - - lock (m_knownChildRegions) - { - foreach (ulong handle in m_knownChildRegions.Keys) - { - // Don't close the agent on this region yet - if (handle != Scene.RegionInfo.RegionHandle) - { - uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - - //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); - //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); - if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) - { - byebyeRegions.Add(handle); - } - } - } - } - - if (byebyeRegions.Count > 0) - { - m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); - m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); - } - - foreach (ulong handle in byebyeRegions) - { - RemoveNeighbourRegion(handle); - } - } - - #endregion - - /// - /// This allows the Sim owner the abiility to kick users from their sim currently. - /// It tells the client that the agent has permission to do so. - /// - public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) - { - if (godStatus) - { - // For now, assign god level 200 to anyone - // who is granted god powers, but has no god level set. - // - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); - if (account != null) - { - if (account.UserLevel > 0) - m_godLevel = account.UserLevel; - else - m_godLevel = 200; - } - } - else - { - m_godLevel = 0; - } - - ControllingClient.SendAdminResponse(token, (uint)m_godLevel); - } - - #region Child Agent Updates - - public void ChildAgentDataUpdate(AgentData cAgentData) - { - //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); - if (!IsChildAgent) - return; - - CopyFrom(cAgentData); - } - - /// - /// This updates important decision making data about a child agent - /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region - /// - public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) - { - if (!IsChildAgent) - return; - - //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); - int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; - int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; - - Vector3 offset = new Vector3(shiftx, shifty, 0f); - - m_DrawDistance = cAgentData.Far; - if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! - m_pos = cAgentData.Position + offset; - - if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) - { - posLastSignificantMove = AbsolutePosition; - ReprioritizeUpdates(); - } - - m_CameraCenter = cAgentData.Center + offset; - - m_avHeight = cAgentData.Size.Z; - //SetHeight(cAgentData.AVHeight); - - if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); - - // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. - if (m_scene.m_seeIntoRegionFromNeighbor) - m_sceneViewer.Reset(); - - //cAgentData.AVHeight; - m_rootRegionHandle = cAgentData.RegionHandle; - //m_velocity = cAgentData.Velocity; - } - - public void CopyTo(AgentData cAgent) - { - cAgent.AgentID = UUID; - cAgent.RegionID = Scene.RegionInfo.RegionID; - - cAgent.Position = AbsolutePosition; - cAgent.Velocity = m_velocity; - cAgent.Center = m_CameraCenter; - // Don't copy the size; it is inferred from apearance parameters - //cAgent.Size = new Vector3(0, 0, m_avHeight); - cAgent.AtAxis = m_CameraAtAxis; - cAgent.LeftAxis = m_CameraLeftAxis; - cAgent.UpAxis = m_CameraUpAxis; - - cAgent.Far = m_DrawDistance; - - // Throttles - float multiplier = 1; - int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); - if (innacurateNeighbors != 0) - { - multiplier = 1f / innacurateNeighbors; - } - if (multiplier <= 0f) - { - multiplier = 0.25f; - } - //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); - cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); - - cAgent.HeadRotation = m_headrotation; - cAgent.BodyRotation = m_bodyRot; - cAgent.ControlFlags = (uint)m_AgentControlFlags; - - if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) - cAgent.GodLevel = (byte)m_godLevel; - else - cAgent.GodLevel = (byte) 0; - - cAgent.AlwaysRun = m_setAlwaysRun; - - try - { - // We might not pass the Wearables in all cases... - // They're only needed so that persistent changes to the appearance - // are preserved in the new region where the user is moving to. - // But in Hypergrid we might not let this happen. - int i = 0; - UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; - foreach (AvatarWearable aw in m_appearance.Wearables) - { - if (aw != null) - { - wears[i++] = aw.ItemID; - wears[i++] = aw.AssetID; - } - else - { - wears[i++] = UUID.Zero; - wears[i++] = UUID.Zero; - } - } - cAgent.Wearables = wears; - - cAgent.VisualParams = m_appearance.VisualParams; - - if (m_appearance.Texture != null) - cAgent.AgentTextures = m_appearance.Texture.GetBytes(); - } - catch (Exception e) - { - m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); - } - - //Attachments - List attPoints = m_appearance.GetAttachedPoints(); - if (attPoints != null) - { - //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); - int i = 0; - AttachmentData[] attachs = new AttachmentData[attPoints.Count]; - foreach (int point in attPoints) - { - attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); - } - cAgent.Attachments = attachs; - } - - lock (scriptedcontrols) - { - ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; - int i = 0; - - foreach (ScriptControllers c in scriptedcontrols.Values) - { - controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); - } - cAgent.Controllers = controls; - } - - // Animations - try - { - cAgent.Anims = Animator.Animations.ToArray(); - } - catch { } - - // cAgent.GroupID = ?? - // Groups??? - - } - - public void CopyFrom(AgentData cAgent) - { - m_originRegionID = cAgent.RegionID; - - m_callbackURI = cAgent.CallbackURI; - - m_pos = cAgent.Position; - - m_velocity = cAgent.Velocity; - m_CameraCenter = cAgent.Center; - //m_avHeight = cAgent.Size.Z; - m_CameraAtAxis = cAgent.AtAxis; - m_CameraLeftAxis = cAgent.LeftAxis; - m_CameraUpAxis = cAgent.UpAxis; - - m_DrawDistance = cAgent.Far; - - if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgent.Throttles); - - m_headrotation = cAgent.HeadRotation; - m_bodyRot = cAgent.BodyRotation; - m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; - - if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) - m_godLevel = cAgent.GodLevel; - m_setAlwaysRun = cAgent.AlwaysRun; - - uint i = 0; - try - { - if (cAgent.Wearables == null) - cAgent.Wearables = new UUID[0]; - AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; - for (uint n = 0; n < cAgent.Wearables.Length; n += 2) - { - UUID itemId = cAgent.Wearables[n]; - UUID assetId = cAgent.Wearables[n + 1]; - wears[i++] = new AvatarWearable(itemId, assetId); - } - m_appearance.Wearables = wears; - Primitive.TextureEntry te; - if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) - te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); - else - te = AvatarAppearance.GetDefaultTexture(); - if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) - cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); - m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); - } - catch (Exception e) - { - m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); - } - - // Attachments - try - { - if (cAgent.Attachments != null) - { - m_appearance.ClearAttachments(); - foreach (AttachmentData att in cAgent.Attachments) - { - m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); - } - } - } - catch { } - - try - { - lock (scriptedcontrols) - { - if (cAgent.Controllers != null) - { - scriptedcontrols.Clear(); - - foreach (ControllerData c in cAgent.Controllers) - { - ScriptControllers sc = new ScriptControllers(); - sc.itemID = c.ItemID; - sc.ignoreControls = (ScriptControlled)c.IgnoreControls; - sc.eventControls = (ScriptControlled)c.EventControls; - - scriptedcontrols[sc.itemID] = sc; - } - } - } - } - catch { } - // Animations - try - { - Animator.ResetAnimations(); - Animator.Animations.FromArray(cAgent.Anims); - } - catch { } - - //cAgent.GroupID = ?? - //Groups??? - } - - public bool CopyAgent(out IAgentData agent) - { - agent = new CompleteAgentData(); - CopyTo((AgentData)agent); - return true; - } - - #endregion Child Agent Updates - - /// - /// Handles part of the PID controller function for moving an avatar. - /// - public override void UpdateMovement() - { - if (m_forceToApply.HasValue) - { - - Vector3 force = m_forceToApply.Value; - m_updateflag = true; - Velocity = force; - - m_forceToApply = null; - } - else - { - if (m_isNudging) - { - Vector3 force = Vector3.Zero; - - m_updateflag = true; - Velocity = force; - m_isNudging = false; - m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" - } - } - } - - public override void SetText(string text, Vector3 color, double alpha) - { - throw new Exception("Can't set Text on avatar."); - } - - /// - /// Adds a physical representation of the avatar to the Physics plugin - /// - public void AddToPhysicalScene(bool isFlying) - { - PhysicsScene scene = m_scene.PhysicsScene; - - Vector3 pVec = AbsolutePosition; - - // Old bug where the height was in centimeters instead of meters - if (m_avHeight == 127.0f) - { - m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), - isFlying); - } - else - { - m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, - new Vector3(0f, 0f, m_avHeight), isFlying); - } - scene.AddPhysicsActorTaint(m_physicsActor); - //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; - m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; - m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong - m_physicsActor.SubscribeEvents(500); - m_physicsActor.LocalID = LocalId; - } - - private void OutOfBoundsCall(Vector3 pos) - { - //bool flying = m_physicsActor.Flying; - //RemoveFromPhysicalScene(); - - //AddToPhysicalScene(flying); - if (ControllingClient != null) - ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); - } - - // Event called by the physics plugin to tell the avatar about a collision. - private void PhysicsCollisionUpdate(EventArgs e) - { - if (e == null) - return; - - // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( - // as of this comment the interval is set in AddToPhysicalScene - if (Animator!=null) - { - if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, - { // else its will lock out other animation changes, like ground sit. - Animator.UpdateMovementAnimations(); - m_updateCount--; - } - } - - CollisionEventUpdate collisionData = (CollisionEventUpdate)e; - Dictionary coldata = collisionData.m_objCollisionList; - - CollisionPlane = Vector4.UnitW; - - if (m_lastColCount != coldata.Count) - { - m_updateCount = UPDATE_COUNT; - m_lastColCount = coldata.Count; - } - - if (coldata.Count != 0 && Animator != null) - { - switch (Animator.CurrentMovementAnimation) - { - case "STAND": - case "WALK": - case "RUN": - case "CROUCH": - case "CROUCHWALK": - { - ContactPoint lowest; - lowest.SurfaceNormal = Vector3.Zero; - lowest.Position = Vector3.Zero; - lowest.Position.Z = Single.NaN; - - foreach (ContactPoint contact in coldata.Values) - { - if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) - { - lowest = contact; - } - } - - CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); - } - break; - } - } - - List thisHitColliders = new List(); - List endedColliders = new List(); - List startedColliders = new List(); - - foreach (uint localid in coldata.Keys) - { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) - { - endedColliders.Add(localID); - } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); - } - - // do event notification - if (startedColliders.Count > 0) - { - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - StartCollidingMessage.Colliders = colliding; - - foreach (SceneObjectGroup att in Attachments) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); - } - } - - if (endedColliders.Count > 0) - { - ColliderArgs EndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in endedColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - EndCollidingMessage.Colliders = colliding; - - foreach (SceneObjectGroup att in Attachments) - Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); - } - } - - if (thisHitColliders.Count > 0) - { - ColliderArgs CollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in thisHitColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - CollidingMessage.Colliders = colliding; - - lock (m_attachments) - { - foreach (SceneObjectGroup att in m_attachments) - Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); - } - } - } - - if (m_invulnerable) - return; - - float starthealth = Health; - uint killerObj = 0; - foreach (uint localid in coldata.Keys) - { - SceneObjectPart part = Scene.GetSceneObjectPart(localid); - - if (part != null && part.ParentGroup.Damage != -1.0f) - Health -= part.ParentGroup.Damage; - else - { - if (coldata[localid].PenetrationDepth >= 0.10f) - Health -= coldata[localid].PenetrationDepth * 5.0f; - } - - if (Health <= 0.0f) - { - if (localid != 0) - killerObj = localid; - } - //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); - } - //Health = 100; - if (!m_invulnerable) - { - if (starthealth != Health) - { - ControllingClient.SendHealth(Health); - } - if (m_health <= 0) - m_scene.EventManager.TriggerAvatarKill(killerObj, this); - } - } - - public void setHealthWithUpdate(float health) - { - Health = health; - ControllingClient.SendHealth(Health); - } - - public void Close() - { - lock (m_attachments) - { - // Delete attachments from scene - // Don't try to save, as this thread won't live long - // enough to complete the save. This would cause no copy - // attachments to poof! - // - foreach (SceneObjectGroup grp in m_attachments) - { - m_scene.DeleteSceneObject(grp, false); - } - m_attachments.Clear(); - } - - lock (m_knownChildRegions) - { - m_knownChildRegions.Clear(); - } - - lock (m_reprioritization_timer) - { - m_reprioritization_timer.Enabled = false; - m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); - } - - // I don't get it but mono crashes when you try to dispose of this timer, - // unsetting the elapsed callback should be enough to allow for cleanup however. - // m_reprioritizationTimer.Dispose(); - - m_sceneViewer.Close(); - - RemoveFromPhysicalScene(); - m_animator.Close(); - m_animator = null; - } - - public void AddAttachment(SceneObjectGroup gobj) - { - lock (m_attachments) - { - m_attachments.Add(gobj); - } - } - - public bool HasAttachments() - { - return m_attachments.Count > 0; - } - - public bool HasScriptedAttachments() - { - lock (m_attachments) - { - foreach (SceneObjectGroup gobj in m_attachments) - { - if (gobj != null) - { - if (gobj.RootPart.Inventory.ContainsScripts()) - return true; - } - } - } - return false; - } - - public void RemoveAttachment(SceneObjectGroup gobj) - { - lock (m_attachments) - { - if (m_attachments.Contains(gobj)) - { - m_attachments.Remove(gobj); - } - } - } - - public bool ValidateAttachments() - { - lock (m_attachments) - { - // Validate - foreach (SceneObjectGroup gobj in m_attachments) - { - if (gobj == null) - return false; - - if (gobj.IsDeleted) - return false; - } - } - return true; - } - - /// - /// Send a script event to this scene presence's attachments - /// - /// The name of the event - /// The arguments for the event - public void SendScriptEventToAttachments(string eventName, Object[] args) - { - if (m_scriptEngines != null) - { - lock (m_attachments) - { - foreach (SceneObjectGroup grp in m_attachments) - { - // 16384 is CHANGED_ANIMATION - // - // Send this to all attachment root prims - // - foreach (IScriptModule m in m_scriptEngines) - { - if (m == null) // No script engine loaded - continue; - - m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); - } - } - } - } - } - - - public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) - { - m_controllingClient = client; - m_regionInfo = region; - m_scene = scene; - - RegisterToEvents(); - if (m_controllingClient != null) - { - m_controllingClient.ProcessPendingPackets(); - } - /* - AbsolutePosition = client.StartPos; - - Animations = new AvatarAnimations(); - Animations.LoadAnims(); - - m_animations = new List(); - m_animations.Add(Animations.AnimsUUID["STAND"]); - m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); - - SetDirectionVectors(); - */ - } - - internal void PushForce(Vector3 impulse) - { - if (PhysicsActor != null) - { - PhysicsActor.AddForce(impulse,true); - } - } - - public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) - { - ScriptControllers obj = new ScriptControllers(); - obj.ignoreControls = ScriptControlled.CONTROL_ZERO; - obj.eventControls = ScriptControlled.CONTROL_ZERO; - - obj.itemID = Script_item_UUID; - if (pass_on == 0 && accept == 0) - { - IgnoredControls |= (ScriptControlled)controls; - obj.ignoreControls = (ScriptControlled)controls; - } - - if (pass_on == 0 && accept == 1) - { - IgnoredControls |= (ScriptControlled)controls; - obj.ignoreControls = (ScriptControlled)controls; - obj.eventControls = (ScriptControlled)controls; - } - if (pass_on == 1 && accept == 1) - { - IgnoredControls = ScriptControlled.CONTROL_ZERO; - obj.eventControls = (ScriptControlled)controls; - obj.ignoreControls = ScriptControlled.CONTROL_ZERO; - } - - lock (scriptedcontrols) - { - if (pass_on == 1 && accept == 0) - { - IgnoredControls &= ~(ScriptControlled)controls; - if (scriptedcontrols.ContainsKey(Script_item_UUID)) - scriptedcontrols.Remove(Script_item_UUID); - } - else - { - scriptedcontrols[Script_item_UUID] = obj; - } - } - ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); - } - - public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) - { - IgnoredControls = ScriptControlled.CONTROL_ZERO; - lock (scriptedcontrols) - { - scriptedcontrols.Clear(); - } - ControllingClient.SendTakeControls(int.MaxValue, false, false); - } - - public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) - { - ScriptControllers takecontrols; - - lock (scriptedcontrols) - { - if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) - { - ScriptControlled sctc = takecontrols.eventControls; - - ControllingClient.SendTakeControls((int)sctc, false, false); - ControllingClient.SendTakeControls((int)sctc, true, false); - - scriptedcontrols.Remove(Script_item_UUID); - IgnoredControls = ScriptControlled.CONTROL_ZERO; - foreach (ScriptControllers scData in scriptedcontrols.Values) - { - IgnoredControls |= scData.ignoreControls; - } - } - } - } - - internal void SendControlToScripts(uint flags) - { - ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; - - if (MouseDown) - { - allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) - { - allflags = ScriptControlled.CONTROL_ZERO; - MouseDown = true; - } - } - - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_ML_LBUTTON; - MouseDown = true; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_LBUTTON; - MouseDown = true; - } - - // find all activated controls, whether the scripts are interested in them or not - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_FWD; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_BACK; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_UP; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_DOWN; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_LEFT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_RIGHT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_ROT_RIGHT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_ROT_LEFT; - } - // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that - if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) - { - lock (scriptedcontrols) - { - foreach (KeyValuePair kvp in scriptedcontrols) - { - UUID scriptUUID = kvp.Key; - ScriptControllers scriptControlData = kvp.Value; - - ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us - ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle - ScriptControlled localChange = localHeld ^ localLast; // the changed bits - if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) - { - // only send if still pressed or just changed - m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); - } - } - } - } - - LastCommands = allflags; - } - - internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) - { - if (ignored == ScriptControlled.CONTROL_ZERO) - return flags; - - if ((ignored & ScriptControlled.CONTROL_BACK) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); - if ((ignored & ScriptControlled.CONTROL_FWD) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); - if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); - if ((ignored & ScriptControlled.CONTROL_UP) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); - if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); - if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); - if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); - if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); - if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); - if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) - flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); - - //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, - //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, - //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, - //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, - //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, - //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, - //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG - - return flags; - } - - /// - /// RezAttachments. This should only be called upon login on the first region. - /// Attachment rezzings on crossings and TPs are done in a different way. - /// - public void RezAttachments() - { - if (null == m_appearance) - { - m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); - return; - } - - XmlDocument doc = new XmlDocument(); - string stateData = String.Empty; - - IAttachmentsService attServ = m_scene.RequestModuleInterface(); - if (attServ != null) - { - m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); - stateData = attServ.Get(ControllingClient.AgentId.ToString()); - if (stateData != String.Empty) - { - try - { - doc.LoadXml(stateData); - } - catch { } - } - } - - Dictionary itemData = new Dictionary(); - - XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); - if (nodes.Count > 0) - { - foreach (XmlNode n in nodes) - { - XmlElement elem = (XmlElement)n; - string itemID = elem.GetAttribute("ItemID"); - string xml = elem.InnerXml; - - itemData[new UUID(itemID)] = xml; - } - } - - List attPoints = m_appearance.GetAttachedPoints(); - foreach (int p in attPoints) - { - if (m_isDeleted) - return; - - UUID itemID = m_appearance.GetAttachedItem(p); - UUID assetID = m_appearance.GetAttachedAsset(p); - - // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down - // But they're not used anyway, the item is being looked up for now, so let's proceed. - //if (UUID.Zero == assetID) - //{ - // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); - // continue; - //} - - try - { - string xmlData; - XmlDocument d = new XmlDocument(); - UUID asset; - if (itemData.TryGetValue(itemID, out xmlData)) - { - d.LoadXml(xmlData); - m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); - - // Rez from inventory - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); - - } - else - { - // Rez from inventory (with a null doc to let - // CHANGED_OWNER happen) - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); - } - - m_log.InfoFormat( - "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", - p, itemID, assetID, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e.ToString()); - } - } - } - - private void ReprioritizeUpdates() - { - if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) - { - lock (m_reprioritization_timer) - { - if (!m_reprioritizing) - m_reprioritization_timer.Enabled = m_reprioritizing = true; - else - m_reprioritization_called = true; - } - } - } - - private void Reprioritize(object sender, ElapsedEventArgs e) - { - m_controllingClient.ReprioritizeUpdates(); - - lock (m_reprioritization_timer) - { - m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; - m_reprioritization_called = false; - } - } - - private Vector3 Quat2Euler(Quaternion rot){ - float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , - (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); - float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); - float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , - (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); - return(new Vector3(x,y,z)); - } - - - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Collections.Generic; +using System.Reflection; +using System.Timers; +using OpenMetaverse; +using log4net; +using OpenSim.Framework; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes.Animation; +using OpenSim.Region.Framework.Scenes.Types; +using OpenSim.Region.Physics.Manager; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.Framework.Scenes +{ + enum ScriptControlled : uint + { + CONTROL_ZERO = 0, + CONTROL_FWD = 1, + CONTROL_BACK = 2, + CONTROL_LEFT = 4, + CONTROL_RIGHT = 8, + CONTROL_UP = 16, + CONTROL_DOWN = 32, + CONTROL_ROT_LEFT = 256, + CONTROL_ROT_RIGHT = 512, + CONTROL_LBUTTON = 268435456, + CONTROL_ML_LBUTTON = 1073741824 + } + + struct ScriptControllers + { + public UUID itemID; + public ScriptControlled ignoreControls; + public ScriptControlled eventControls; + } + + public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs); + + public class ScenePresence : EntityBase, ISceneEntity + { +// ~ScenePresence() +// { +// m_log.Debug("[ScenePresence] Destructor called"); +// } + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; +// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); + private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); + private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); + + /// + /// Experimentally determined "fudge factor" to make sit-target positions + /// the same as in SecondLife. Fudge factor was tested for 36 different + /// test cases including prims of type box, sphere, cylinder, and torus, + /// with varying parameters for sit target location, prim size, prim + /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis + /// issue #1716 + /// +// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); + // Value revised by KF 091121 by comparison with SL. + private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); + + public UUID currentParcelUUID = UUID.Zero; + + private ISceneViewer m_sceneViewer; + + /// + /// The animator for this avatar + /// + public ScenePresenceAnimator Animator + { + get { return m_animator; } + } + protected ScenePresenceAnimator m_animator; + + /// + /// The scene objects attached to this avatar. Do not change this list directly - use methods such as + /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. + /// + public List Attachments + { + get { return m_attachments; } + } + protected List m_attachments = new List(); + + private Dictionary scriptedcontrols = new Dictionary(); + private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; + private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; + private bool MouseDown = false; + private SceneObjectGroup proxyObjectGroup; + //private SceneObjectPart proxyObjectPart = null; + public Vector3 lastKnownAllowedPosition; + public bool sentMessageAboutRestrictedParcelFlyingDown; + public Vector4 CollisionPlane = Vector4.UnitW; + + private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation + private Vector3 m_avUnscriptedSitPos; // for non-scripted prims + private Vector3 m_lastPosition; + private Vector3 m_lastWorldPosition; + private Quaternion m_lastRotation; + private Vector3 m_lastVelocity; + //private int m_lastTerseSent; + + private bool m_updateflag; + private byte m_movementflag; + private Vector3? m_forceToApply; + private uint m_requestedSitTargetID; + private UUID m_requestedSitTargetUUID; + public bool SitGround = false; + + private SendCourseLocationsMethod m_sendCourseLocationsMethod; + + private bool m_startAnimationSet; + + //private Vector3 m_requestedSitOffset = new Vector3(); + + private Vector3 m_LastFinitePos; + + private float m_sitAvatarHeight = 2.0f; + + private int m_godLevel; + private int m_userLevel; + + private bool m_invulnerable = true; + + private Vector3 m_lastChildAgentUpdatePosition; + private Vector3 m_lastChildAgentUpdateCamPosition; + + private int m_perfMonMS; + + private bool m_setAlwaysRun; + private bool m_forceFly; + private bool m_flyDisabled; + + private float m_speedModifier = 1.0f; + + private Quaternion m_bodyRot= Quaternion.Identity; + + private Quaternion m_bodyRotPrevious = Quaternion.Identity; + + private const int LAND_VELOCITYMAG_MAX = 12; + + public bool IsRestrictedToRegion; + + public string JID = String.Empty; + + private float m_health = 100f; + + // Default AV Height + private float m_avHeight = 127.0f; + + protected RegionInfo m_regionInfo; + protected ulong crossingFromRegion; + + private readonly Vector3[] Dir_Vectors = new Vector3[11]; + private bool m_isNudging = false; + + // Position of agent's camera in world (region cordinates) + protected Vector3 m_CameraCenter; + protected Vector3 m_lastCameraCenter; + + protected Timer m_reprioritization_timer; + protected bool m_reprioritizing; + protected bool m_reprioritization_called; + + // Use these three vectors to figure out what the agent is looking at + // Convert it to a Matrix and/or Quaternion + protected Vector3 m_CameraAtAxis; + protected Vector3 m_CameraLeftAxis; + protected Vector3 m_CameraUpAxis; + private AgentManager.ControlFlags m_AgentControlFlags; + private Quaternion m_headrotation = Quaternion.Identity; + private byte m_state; + + //Reuse the Vector3 instead of creating a new one on the UpdateMovement method +// private Vector3 movementvector; + + private bool m_autopilotMoving; + private Vector3 m_autoPilotTarget; + private bool m_sitAtAutoTarget; + private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit + + private string m_nextSitAnimation = String.Empty; + + //PauPaw:Proper PID Controler for autopilot************ + private bool m_moveToPositionInProgress; + private Vector3 m_moveToPositionTarget; + private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + + private bool m_followCamAuto; + + private int m_movementUpdateCount; + private int m_lastColCount = -1; //KF: Look for Collision chnages + private int m_updateCount = 0; //KF: Update Anims for a while + private static readonly int UPDATE_COUNT = 10; // how many frames to update for + private const int NumMovementsBetweenRayCast = 5; + private List m_lastColliders = new List(); + + private bool CameraConstraintActive; + //private int m_moveToPositionStateStatus; + //***************************************************** + + // Agent's Draw distance. + protected float m_DrawDistance; + + protected AvatarAppearance m_appearance; + + // neighbouring regions we have enabled a child agent in + // holds the seed cap for the child agent in that region + private Dictionary m_knownChildRegions = new Dictionary(); + + /// + /// Implemented Control Flags + /// + private enum Dir_ControlFlags + { + DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, + DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, + DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, + DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, + DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, + DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, + DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, + DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, + DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG + } + + /// + /// Position at which a significant movement was made + /// + private Vector3 posLastSignificantMove; + + // For teleports and crossings callbacks + string m_callbackURI; + UUID m_originRegionID; + + ulong m_rootRegionHandle; + + /// + /// Script engines present in the scene + /// + private IScriptModule[] m_scriptEngines; + + #region Properties + + /// + /// Physical scene representation of this Avatar. + /// + public PhysicsActor PhysicsActor + { + set { m_physicsActor = value; } + get { return m_physicsActor; } + } + + public byte MovementFlag + { + set { m_movementflag = value; } + get { return m_movementflag; } + } + + public bool Updated + { + set { m_updateflag = value; } + get { return m_updateflag; } + } + + public bool Invulnerable + { + set { m_invulnerable = value; } + get { return m_invulnerable; } + } + + public int UserLevel + { + get { return m_userLevel; } + } + + public int GodLevel + { + get { return m_godLevel; } + } + + public ulong RegionHandle + { + get { return m_rootRegionHandle; } + } + + public Vector3 CameraPosition + { + get { return m_CameraCenter; } + } + + public Quaternion CameraRotation + { + get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } + } + + public Vector3 CameraAtAxis + { + get { return m_CameraAtAxis; } + } + + public Vector3 CameraLeftAxis + { + get { return m_CameraLeftAxis; } + } + + public Vector3 CameraUpAxis + { + get { return m_CameraUpAxis; } + } + + public Vector3 Lookat + { + get + { + Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); + + if (a == Vector3.Zero) + return a; + + return Util.GetNormalizedVector(a); + } + } + + private readonly string m_firstname; + + public string Firstname + { + get { return m_firstname; } + } + + private readonly string m_lastname; + + public string Lastname + { + get { return m_lastname; } + } + + private string m_grouptitle; + + public string Grouptitle + { + get { return m_grouptitle; } + set { m_grouptitle = value; } + } + + public float DrawDistance + { + get { return m_DrawDistance; } + } + + protected bool m_allowMovement = true; + + public bool AllowMovement + { + get { return m_allowMovement; } + set { m_allowMovement = value; } + } + + public bool SetAlwaysRun + { + get + { + if (PhysicsActor != null) + { + return PhysicsActor.SetAlwaysRun; + } + else + { + return m_setAlwaysRun; + } + } + set + { + m_setAlwaysRun = value; + if (PhysicsActor != null) + { + PhysicsActor.SetAlwaysRun = value; + } + } + } + + public byte State + { + get { return m_state; } + set { m_state = value; } + } + + public uint AgentControlFlags + { + get { return (uint)m_AgentControlFlags; } + set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } + } + + /// + /// This works out to be the ClientView object associated with this avatar, or it's client connection manager + /// + private IClientAPI m_controllingClient; + + protected PhysicsActor m_physicsActor; + + /// + /// The client controlling this presence + /// + public IClientAPI ControllingClient + { + get { return m_controllingClient; } + } + + public IClientCore ClientView + { + get { return (IClientCore) m_controllingClient; } + } + + protected Vector3 m_parentPosition; + public Vector3 ParentPosition + { + get { return m_parentPosition; } + set { m_parentPosition = value; } + } + + /// + /// Position of this avatar relative to the region the avatar is in + /// + public override Vector3 AbsolutePosition + { + get + { + PhysicsActor actor = m_physicsActor; +// if (actor != null) + if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! + m_pos = actor.Position; + + // If we're sitting, we need to update our position + if (m_parentID != 0) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); + if (part != null) + m_parentPosition = part.AbsolutePosition; + } + + return m_parentPosition + m_pos; + } + set + { + PhysicsActor actor = m_physicsActor; + if (actor != null) + { + try + { + lock (m_scene.SyncRoot) + m_physicsActor.Position = value; + } + catch (Exception e) + { + m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); + } + } + + if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! + m_pos = value; + m_parentPosition = Vector3.Zero; + } + } + + public Vector3 OffsetPosition + { + get { return m_pos; } + set { m_pos = value; } + } + + /// + /// Current velocity of the avatar. + /// + public override Vector3 Velocity + { + get + { + PhysicsActor actor = m_physicsActor; + if (actor != null) + m_velocity = actor.Velocity; + + return m_velocity; + } + set + { + PhysicsActor actor = m_physicsActor; + if (actor != null) + { + try + { + lock (m_scene.SyncRoot) + actor.Velocity = value; + } + catch (Exception e) + { + m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); + } + } + + m_velocity = value; + } + } + + public Quaternion OffsetRotation + { + get { return m_offsetRotation; } + set { m_offsetRotation = value; } + } + + public Quaternion Rotation + { + get { + if (m_parentID != 0) + { + if (m_offsetRotation != null) + { + return m_offsetRotation; + } + else + { + return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + + } + else + { + return m_bodyRot; + } + } + set { + m_bodyRot = value; + if (m_parentID != 0) + { + m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + } + } + + public Quaternion PreviousRotation + { + get { return m_bodyRotPrevious; } + set { m_bodyRotPrevious = value; } + } + + /// + /// If this is true, agent doesn't have a representation in this scene. + /// this is an agent 'looking into' this scene from a nearby scene(region) + /// + /// if False, this agent has a representation in this scene + /// + private bool m_isChildAgent = true; + + public bool IsChildAgent + { + get { return m_isChildAgent; } + set { m_isChildAgent = value; } + } + + private uint m_parentID; + + + private UUID m_linkedPrim; + + public uint ParentID + { + get { return m_parentID; } + set { m_parentID = value; } + } + + public UUID LinkedPrim + { + get { return m_linkedPrim; } + set { m_linkedPrim = value; } + } + + public float Health + { + get { return m_health; } + set { m_health = value; } + } + + /// + /// These are the region handles known by the avatar. + /// + public List KnownChildRegionHandles + { + get + { + if (m_knownChildRegions.Count == 0) + return new List(); + else + return new List(m_knownChildRegions.Keys); + } + } + + public Dictionary KnownRegions + { + get { return m_knownChildRegions; } + set + { + m_knownChildRegions = value; + } + } + + public ISceneViewer SceneViewer + { + get { return m_sceneViewer; } + } + + public void AdjustKnownSeeds() + { + Dictionary seeds; + + if (Scene.CapsModule != null) + seeds = Scene.CapsModule.GetChildrenSeeds(UUID); + else + seeds = new Dictionary(); + + List old = new List(); + foreach (ulong handle in seeds.Keys) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) + { + old.Add(handle); + } + } + DropOldNeighbours(old); + + if (Scene.CapsModule != null) + Scene.CapsModule.SetChildrenSeed(UUID, seeds); + + KnownRegions = seeds; + //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); + //DumpKnownRegions(); + } + + public void DumpKnownRegions() + { + m_log.Info("================ KnownRegions "+Scene.RegionInfo.RegionName+" ================"); + foreach (KeyValuePair kvp in KnownRegions) + { + uint x, y; + Utils.LongToUInts(kvp.Key, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + m_log.Info(" >> "+x+", "+y+": "+kvp.Value); + } + } + + private bool m_inTransit; + private bool m_mouseLook; + private bool m_leftButtonDown; + + public bool IsInTransit + { + get { return m_inTransit; } + set { m_inTransit = value; } + } + + public float SpeedModifier + { + get { return m_speedModifier; } + set { m_speedModifier = value; } + } + + public bool ForceFly + { + get { return m_forceFly; } + set { m_forceFly = value; } + } + + public bool FlyDisabled + { + get { return m_flyDisabled; } + set { m_flyDisabled = value; } + } + + public string Viewer + { + get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } + } + + #endregion + + #region Constructor(s) + + public ScenePresence() + { + m_sendCourseLocationsMethod = SendCoarseLocationsDefault; + CreateSceneViewer(); + m_animator = new ScenePresenceAnimator(this); + } + + private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() + { + m_rootRegionHandle = reginfo.RegionHandle; + m_controllingClient = client; + m_firstname = m_controllingClient.FirstName; + m_lastname = m_controllingClient.LastName; + m_name = String.Format("{0} {1}", m_firstname, m_lastname); + m_scene = world; + m_uuid = client.AgentId; + m_regionInfo = reginfo; + m_localId = m_scene.AllocateLocalId(); + + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); + + if (account != null) + m_userLevel = account.UserLevel; + + IGroupsModule gm = m_scene.RequestModuleInterface(); + if (gm != null) + m_grouptitle = gm.GetGroupTitle(m_uuid); + + m_scriptEngines = m_scene.RequestModuleInterfaces(); + + AbsolutePosition = posLastSignificantMove = m_CameraCenter = + m_lastCameraCenter = m_controllingClient.StartPos; + + m_reprioritization_timer = new Timer(world.ReprioritizationInterval); + m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); + m_reprioritization_timer.AutoReset = false; + + AdjustKnownSeeds(); + Animator.TrySetMovementAnimation("STAND"); + // we created a new ScenePresence (a new child agent) in a fresh region. + // Request info about all the (root) agents in this region + // Note: This won't send data *to* other clients in that region (children don't send) + SendInitialFullUpdateToAllClients(); + RegisterToEvents(); + if (m_controllingClient != null) + { + m_controllingClient.ProcessPendingPackets(); + } + SetDirectionVectors(); + } + + public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, + AvatarWearable[] wearables) + : this(client, world, reginfo) + { + m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); + } + + public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) + : this(client, world, reginfo) + { + m_appearance = appearance; + } + + private void CreateSceneViewer() + { + m_sceneViewer = new SceneViewer(this); + } + + public void RegisterToEvents() + { + m_controllingClient.OnRequestWearables += SendWearables; + m_controllingClient.OnSetAppearance += SetAppearance; + m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; + //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; + m_controllingClient.OnAgentUpdate += HandleAgentUpdate; + m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; + m_controllingClient.OnAgentSit += HandleAgentSit; + m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; + m_controllingClient.OnStartAnim += HandleStartAnim; + m_controllingClient.OnStopAnim += HandleStopAnim; + m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; + m_controllingClient.OnAutoPilotGo += DoAutoPilot; + m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); + + // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); + // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); + } + + private void SetDirectionVectors() + { + Dir_Vectors[0] = Vector3.UnitX; //FORWARD + Dir_Vectors[1] = -Vector3.UnitX; //BACK + Dir_Vectors[2] = Vector3.UnitY; //LEFT + Dir_Vectors[3] = -Vector3.UnitY; //RIGHT + Dir_Vectors[4] = Vector3.UnitZ; //UP + Dir_Vectors[5] = -Vector3.UnitZ; //DOWN + Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE + Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE + Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE + Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE + Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge + } + + private Vector3[] GetWalkDirectionVectors() + { + Vector3[] vector = new Vector3[11]; + vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD + vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK + vector[2] = Vector3.UnitY; //LEFT + vector[3] = -Vector3.UnitY; //RIGHT + vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP + vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN + vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE + vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE + vector[8] = Vector3.UnitY; //LEFT_NUDGE + vector[9] = -Vector3.UnitY; //RIGHT_NUDGE + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE + return vector; + } + + private bool[] GetDirectionIsNudge() + { + bool[] isNudge = new bool[11]; + isNudge[0] = false; //FORWARD + isNudge[1] = false; //BACK + isNudge[2] = false; //LEFT + isNudge[3] = false; //RIGHT + isNudge[4] = false; //UP + isNudge[5] = false; //DOWN + isNudge[6] = true; //FORWARD_NUDGE + isNudge[7] = true; //BACK_NUDGE + isNudge[8] = true; //LEFT_NUDGE + isNudge[9] = true; //RIGHT_NUDGE + isNudge[10] = true; //DOWN_Nudge + return isNudge; + } + + + #endregion + + public uint GenerateClientFlags(UUID ObjectID) + { + return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); + } + + /// + /// Send updates to the client about prims which have been placed on the update queue. We don't + /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent + /// timestamp has already been sent. + /// + public void SendPrimUpdates() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + m_sceneViewer.SendPrimUpdates(); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + #region Status Methods + + /// + /// This turns a child agent, into a root agent + /// This is called when an agent teleports into a region, or if an + /// agent crosses into this region from a neighbor over the border + /// + public void MakeRootAgent(Vector3 pos, bool isFlying) + { + m_log.DebugFormat( + "[SCENE]: Upgrading child to root agent for {0} in {1}", + Name, m_scene.RegionInfo.RegionName); + + //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); + + IGroupsModule gm = m_scene.RequestModuleInterface(); + if (gm != null) + m_grouptitle = gm.GetGroupTitle(m_uuid); + + m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; + m_scene.SetRootAgentScene(m_uuid); + + // Moved this from SendInitialData to ensure that m_appearance is initialized + // before the inventory is processed in MakeRootAgent. This fixes a race condition + // related to the handling of attachments + //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); + if (m_scene.TestBorderCross(pos, Cardinals.E)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); + pos.X = crossedBorder.BorderLine.Z - 1; + } + + if (m_scene.TestBorderCross(pos, Cardinals.N)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); + pos.Y = crossedBorder.BorderLine.Z - 1; + } + + //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. + //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, + //they'll bypass the landing point. But I can't think of any decent way of fixing this. + if (KnownChildRegionHandles.Count == 0) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + { + pos = land.LandData.UserLocation; + } + } + } + + if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) + { + Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); + + if (pos.X < 0) + { + emergencyPos.X = (int)Constants.RegionSize + pos.X; + if (!(pos.Y < 0)) + emergencyPos.Y = pos.Y; + if (!(pos.Z < 0)) + emergencyPos.Z = pos.Z; + } + if (pos.Y < 0) + { + emergencyPos.Y = (int)Constants.RegionSize + pos.Y; + if (!(pos.X < 0)) + emergencyPos.X = pos.X; + if (!(pos.Z < 0)) + emergencyPos.Z = pos.Z; + } + if (pos.Z < 0) + { + emergencyPos.Z = 128; + if (!(pos.Y < 0)) + emergencyPos.Y = pos.Y; + if (!(pos.X < 0)) + emergencyPos.X = pos.X; + } + } + + if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", + pos, Name, UUID); + + if (pos.X < 0f) pos.X = 0f; + if (pos.Y < 0f) pos.Y = 0f; + if (pos.Z < 0f) pos.Z = 0f; + } + + float localAVHeight = 1.56f; + if (m_avHeight != 127.0f) + { + localAVHeight = m_avHeight; + } + + float posZLimit = 0; + + if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) + posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; + + float newPosZ = posZLimit + localAVHeight / 2; + if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + pos.Z = newPosZ; + } + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + + if (m_forceFly) + { + m_physicsActor.Flying = true; + } + else if (m_flyDisabled) + { + m_physicsActor.Flying = false; + } + + if (m_appearance != null) + { + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + } + else + { + m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); + // emergency; this really shouldn't happen + m_appearance = new AvatarAppearance(UUID); + } + + // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying + // avatar to return to the standing position in mid-air. On login it looks like this is being sent + // elsewhere anyway + // Animator.SendAnimPack(); + + m_scene.SwapRootAgentCount(false); + + //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); + //if (userInfo != null) + // userInfo.FetchInventory(); + //else + // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); + + // On the next prim update, all objects will be sent + // + m_sceneViewer.Reset(); + + m_isChildAgent = false; + + // send the animations of the other presences to me + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + if (presence != this) + presence.Animator.SendAnimPackToClient(ControllingClient); + }); + + m_scene.EventManager.TriggerOnMakeRootAgent(this); + } + + /// + /// This turns a root agent into a child agent + /// when an agent departs this region for a neighbor, this gets called. + /// + /// It doesn't get called for a teleport. Reason being, an agent that + /// teleports out may not end up anywhere near this region + /// + public void MakeChildAgent() + { + // It looks like m_animator is set to null somewhere, and MakeChild + // is called after that. Probably in aborted teleports. + if (m_animator == null) + m_animator = new ScenePresenceAnimator(this); + else + Animator.ResetAnimations(); + +// m_log.DebugFormat( +// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", +// Name, UUID, m_scene.RegionInfo.RegionName); + + // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, + // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. + //Velocity = new Vector3(0, 0, 0); + + m_isChildAgent = true; + m_scene.SwapRootAgentCount(true); + RemoveFromPhysicalScene(); + + // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into + + m_scene.EventManager.TriggerOnMakeChildAgent(this); + } + + /// + /// Removes physics plugin scene representation of this agent if it exists. + /// + private void RemoveFromPhysicalScene() + { + if (PhysicsActor != null) + { + m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; + m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); + m_physicsActor.UnSubscribeEvents(); + m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor = null; + } + } + + /// + /// + /// + /// + public void Teleport(Vector3 pos) + { + bool isFlying = false; + + if (m_physicsActor != null) + isFlying = m_physicsActor.Flying; + + RemoveFromPhysicalScene(); + Velocity = Vector3.Zero; + AbsolutePosition = pos; + AddToPhysicalScene(isFlying); + if (m_appearance != null) + { + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + } + + SendTerseUpdateToAllClients(); + + } + + public void TeleportWithMomentum(Vector3 pos) + { + bool isFlying = false; + if (m_physicsActor != null) + isFlying = m_physicsActor.Flying; + + RemoveFromPhysicalScene(); + AbsolutePosition = pos; + AddToPhysicalScene(isFlying); + if (m_appearance != null) + { + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + } + + SendTerseUpdateToAllClients(); + } + + /// + /// + /// + public void StopMovement() + { + } + + public void StopFlying() + { + ControllingClient.StopFlying(this); + } + + public void AddNeighbourRegion(ulong regionHandle, string cap) + { + lock (m_knownChildRegions) + { + if (!m_knownChildRegions.ContainsKey(regionHandle)) + { + uint x, y; + Utils.LongToUInts(regionHandle, out x, out y); + m_knownChildRegions.Add(regionHandle, cap); + } + } + } + + public void RemoveNeighbourRegion(ulong regionHandle) + { + lock (m_knownChildRegions) + { + if (m_knownChildRegions.ContainsKey(regionHandle)) + { + m_knownChildRegions.Remove(regionHandle); + //m_log.Debug(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); + } + } + } + + public void DropOldNeighbours(List oldRegions) + { + foreach (ulong handle in oldRegions) + { + RemoveNeighbourRegion(handle); + Scene.CapsModule.DropChildSeed(UUID, handle); + } + } + + public List GetKnownRegionList() + { + return new List(m_knownChildRegions.Keys); + } + + #endregion + + #region Event Handlers + + /// + /// Sets avatar height in the phyiscs plugin + /// + internal void SetHeight(float height) + { + m_avHeight = height; + if (PhysicsActor != null && !IsChildAgent) + { + Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); + PhysicsActor.Size = SetSize; + } + } + + /// + /// Complete Avatar's movement into the region. + /// This is called upon a very important packet sent from the client, + /// so it's client-controlled. Never call this method directly. + /// + public void CompleteMovement(IClientAPI client) + { + //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); + + Vector3 look = Velocity; + if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) + { + look = new Vector3(0.99f, 0.042f, 0); + } + + // Prevent teleporting to an underground location + // (may crash client otherwise) + // + Vector3 pos = AbsolutePosition; + float ground = m_scene.GetGroundHeight(pos.X, pos.Y); + if (pos.Z < ground + 1.5f) + { + pos.Z = ground + 1.5f; + AbsolutePosition = pos; + } + m_isChildAgent = false; + bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + MakeRootAgent(AbsolutePosition, m_flying); + + if ((m_callbackURI != null) && !m_callbackURI.Equals("")) + { + m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); + Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); + m_callbackURI = null; + } + + //m_log.DebugFormat("Completed movement"); + + m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); + SendInitialData(); + + // Create child agents in neighbouring regions + if (!m_isChildAgent) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); + else + m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); + + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + } + + } + + /// + /// Callback for the Camera view block check. Gets called with the results of the camera view block test + /// hitYN is true when there's something in the way. + /// + /// + /// + /// + /// + public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) + { + const float POSITION_TOLERANCE = 0.02f; + const float VELOCITY_TOLERANCE = 0.02f; + const float ROTATION_TOLERANCE = 0.02f; + + if (m_followCamAuto) + { + if (hitYN) + { + CameraConstraintActive = true; + //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); + + Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); + ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); + } + else + { + if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) + { + if (CameraConstraintActive) + { + ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); + CameraConstraintActive = false; + } + } + } + } + } + + /// + /// This is the event handler for client movement. If a client is moving, this event is triggering. + /// + public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) + { + //if (m_isChildAgent) + //{ + // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); + // return; + //} + + m_perfMonMS = Util.EnvironmentTickCount(); + + ++m_movementUpdateCount; + if (m_movementUpdateCount < 1) + m_movementUpdateCount = 1; + + #region Sanity Checking + + // This is irritating. Really. + if (!AbsolutePosition.IsFinite()) + { + RemoveFromPhysicalScene(); + m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); + + m_pos = m_LastFinitePos; + + if (!m_pos.IsFinite()) + { + m_pos.X = 127f; + m_pos.Y = 127f; + m_pos.Z = 127f; + m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); + } + + AddToPhysicalScene(false); + } + else + { + m_LastFinitePos = m_pos; + } + + #endregion Sanity Checking + + #region Inputs + + AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; + Quaternion bodyRotation = agentData.BodyRotation; + + // Camera location in world. We'll need to raytrace + // from this location from time to time. + m_CameraCenter = agentData.CameraCenter; + if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) + { + ReprioritizeUpdates(); + m_lastCameraCenter = m_CameraCenter; + } + + // Use these three vectors to figure out what the agent is looking at + // Convert it to a Matrix and/or Quaternion + m_CameraAtAxis = agentData.CameraAtAxis; + m_CameraLeftAxis = agentData.CameraLeftAxis; + m_CameraUpAxis = agentData.CameraUpAxis; + + // The Agent's Draw distance setting + m_DrawDistance = agentData.Far; + + // Check if Client has camera in 'follow cam' or 'build' mode. + Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); + + m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) + && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; + + m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; + m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; + + #endregion Inputs + + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + { + StandUp(); + } + + //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); + // Raycast from the avatar's head to the camera to see if there's anything blocking the view + if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) + { + if (m_followCamAuto) + { + Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; + m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); + } + } + lock (scriptedcontrols) + { + if (scriptedcontrols.Count > 0) + { + SendControlToScripts((uint)flags); + flags = RemoveIgnoredControls(flags, IgnoredControls); + } + } + + if (m_autopilotMoving) + CheckAtSitTarget(); + + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) + { + m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. + Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); + + // TODO: This doesn't prevent the user from walking yet. + // Setting parent ID would fix this, if we knew what value + // to use. Or we could add a m_isSitting variable. + //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); + SitGround = true; + } + + // In the future, these values might need to go global. + // Here's where you get them. + m_AgentControlFlags = flags; + m_headrotation = agentData.HeadRotation; + m_state = agentData.State; + + PhysicsActor actor = PhysicsActor; + if (actor == null) + { + return; + } + + bool update_movementflag = false; + + if (m_allowMovement && !SitGround) + { + if (agentData.UseClientAgentPosition) + { + m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; + m_moveToPositionTarget = agentData.ClientAgentPosition; + } + + int i = 0; + + bool update_rotation = false; + bool DCFlagKeyPressed = false; + Vector3 agent_control_v3 = Vector3.Zero; + Quaternion q = bodyRotation; + + bool oldflying = PhysicsActor.Flying; + + if (m_forceFly) + actor.Flying = true; + else if (m_flyDisabled) + actor.Flying = false; + else + actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + + if (actor.Flying != oldflying) + update_movementflag = true; + + if (q != m_bodyRot) + { + m_bodyRot = q; + update_rotation = true; + } + + //guilty until proven innocent.. + bool Nudging = true; + //Basically, if there is at least one non-nudge control then we don't need + //to worry about stopping the avatar + + if (m_parentID == 0) + { + bool bAllowUpdateMoveToPosition = false; + bool bResetMoveToPosition = false; + + Vector3[] dirVectors; + + // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying + // this prevents 'jumping' in inappropriate situations. + if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) + dirVectors = GetWalkDirectionVectors(); + else + dirVectors = Dir_Vectors; + + bool[] isNudge = GetDirectionIsNudge(); + + + + + + foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) + { + if (((uint)flags & (uint)DCF) != 0) + { + bResetMoveToPosition = true; + DCFlagKeyPressed = true; + try + { + agent_control_v3 += dirVectors[i]; + if (isNudge[i] == false) + { + Nudging = false; + } + } + catch (IndexOutOfRangeException) + { + // Why did I get this? + } + + if ((m_movementflag & (uint)DCF) == 0) + { + m_movementflag += (byte)(uint)DCF; + update_movementflag = true; + } + } + else + { + if ((m_movementflag & (uint)DCF) != 0) + { + m_movementflag -= (byte)(uint)DCF; + update_movementflag = true; + } + else + { + bAllowUpdateMoveToPosition = true; + } + } + i++; + } + //Paupaw:Do Proper PID for Autopilot here + if (bResetMoveToPosition) + { + m_moveToPositionTarget = Vector3.Zero; + m_moveToPositionInProgress = false; + update_movementflag = true; + bAllowUpdateMoveToPosition = false; + } + + if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) + { + //Check the error term of the current position in relation to the target position + if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) + { + // we are close enough to the target + m_moveToPositionTarget = Vector3.Zero; + m_moveToPositionInProgress = false; + update_movementflag = true; + } + else + { + try + { + // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. + // This movement vector gets added to the velocity through AddNewMovement(). + // Theoretically we might need a more complex PID approach here if other + // unknown forces are acting on the avatar and we need to adaptively respond + // to such forces, but the following simple approach seems to works fine. + Vector3 LocalVectorToTarget3D = + (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords + * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords + // Ignore z component of vector + Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); + LocalVectorToTarget2D.Normalize(); + + //We're not nudging + Nudging = false; + agent_control_v3 += LocalVectorToTarget2D; + + // update avatar movement flags. the avatar coordinate system is as follows: + // + // +X (forward) + // + // ^ + // | + // | + // | + // | + // (left) +Y <--------o--------> -Y + // avatar + // | + // | + // | + // | + // v + // -X + // + + // based on the above avatar coordinate system, classify the movement into + // one of left/right/back/forward. + if (LocalVectorToTarget2D.Y > 0)//MoveLeft + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; + //AgentControlFlags + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; + update_movementflag = true; + } + else if (LocalVectorToTarget2D.Y < 0) //MoveRight + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; + update_movementflag = true; + } + if (LocalVectorToTarget2D.X < 0) //MoveBack + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; + update_movementflag = true; + } + else if (LocalVectorToTarget2D.X > 0) //Move Forward + { + m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; + AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; + update_movementflag = true; + } + } + catch (Exception e) + { + //Avoid system crash, can be slower but... + m_log.DebugFormat("Crash! {0}", e.ToString()); + } + } + } + } + + // Cause the avatar to stop flying if it's colliding + // with something with the down arrow pressed. + + // Only do this if we're flying + if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) + { + // Landing detection code + + // Are the landing controls requirements filled? + bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + + // Are the collision requirements fulfilled? + bool colliding = (m_physicsActor.IsColliding == true); + + if (m_physicsActor.Flying && colliding && controlland) + { + // nesting this check because LengthSquared() is expensive and we don't + // want to do it every step when flying. + if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) + StopFlying(); + } + } + + if (update_movementflag || (update_rotation && DCFlagKeyPressed)) + { + // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); + // m_log.DebugFormat( + // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); + + AddNewMovement(agent_control_v3, q, Nudging); + + + } + } + + if (update_movementflag && !SitGround) + Animator.UpdateMovementAnimations(); + + m_scene.EventManager.TriggerOnClientMovement(this); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) + { + m_autopilotMoving = true; + m_autoPilotTarget = Pos; + m_sitAtAutoTarget = false; + PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; + //proxy.PCode = (byte)PCode.ParticleSystem; + proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); + proxyObjectGroup.AttachToScene(m_scene); + + // Commented out this code since it could never have executed, but might still be informative. +// if (proxyObjectGroup != null) +// { + proxyObjectGroup.SendGroupFullUpdate(); + remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); + m_scene.DeleteSceneObject(proxyObjectGroup, false); +// } +// else +// { +// m_autopilotMoving = false; +// m_autoPilotTarget = Vector3.Zero; +// ControllingClient.SendAlertMessage("Autopilot cancelled"); +// } + } + + public void DoMoveToPosition(Object sender, string method, List args) + { + try + { + float locx = 0f; + float locy = 0f; + float locz = 0f; + uint regionX = 0; + uint regionY = 0; + try + { + Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); + locx = Convert.ToSingle(args[0]) - (float)regionX; + locy = Convert.ToSingle(args[1]) - (float)regionY; + locz = Convert.ToSingle(args[2]); + } + catch (InvalidCastException) + { + m_log.Error("[CLIENT]: Invalid autopilot request"); + return; + } + m_moveToPositionInProgress = true; + m_moveToPositionTarget = new Vector3(locx, locy, locz); + } + catch (Exception ex) + { + //Why did I get this error? + m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); + } + } + + private void CheckAtSitTarget() + { + //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); + if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) + { + if (m_sitAtAutoTarget) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); + if (part != null) + { + AbsolutePosition = part.AbsolutePosition; + Velocity = Vector3.Zero; + SendFullUpdateToAllClients(); + + HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? + } + //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); + m_requestedSitTargetUUID = UUID.Zero; + } + /* + else + { + //ControllingClient.SendAlertMessage("Autopilot cancelled"); + //SendTerseUpdateToAllClients(); + //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; + //proxy.PCode = (byte)PCode.ParticleSystem; + ////uint nextUUID = m_scene.NextLocalId; + + //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); + //if (proxyObjectGroup != null) + //{ + //proxyObjectGroup.SendGroupFullUpdate(); + //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); + //m_scene.DeleteSceneObject(proxyObjectGroup); + //} + } + */ + m_autoPilotTarget = Vector3.Zero; + m_autopilotMoving = false; + } + } + /// + /// Perform the logic necessary to stand the avatar up. This method also executes + /// the stand animation. + /// + public void StandUp() + { + SitGround = false; + + if (m_parentID != 0) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + if (part != null) + { + part.TaskInventory.LockItemsForRead(true); + TaskInventoryDictionary taskIDict = part.TaskInventory; + if (taskIDict != null) + { + foreach (UUID taskID in taskIDict.Keys) + { + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS + } + } + part.TaskInventory.LockItemsForRead(false); + // Reset sit target. + if (part.GetAvatarOnSitTarget() == UUID) + part.SetAvatarOnSitTarget(UUID.Zero); + m_parentPosition = part.GetWorldPosition(); + ControllingClient.SendClearFollowCamProperties(part.ParentUUID); + } + // part.GetWorldRotation() is the rotation of the object being sat on + // Rotation is the sittiing Av's rotation + + Quaternion partRot; +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim + +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); + } + + Quaternion partIRot = Quaternion.Inverse(partRot); + + Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av + Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av + + + if (m_physicsActor == null) + { + AddToPhysicalScene(false); + } + //CW: If the part isn't null then we can set the current position + if (part != null) + { + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. + part.IsOccupied = false; + part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); + } + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; + } + + m_parentPosition = Vector3.Zero; + m_parentID = 0; + m_linkedPrim = UUID.Zero; + m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + SendFullUpdateToAllClients(); + m_requestedSitTargetID = 0; + + if ((m_physicsActor != null) && (m_avHeight > 0)) + { + SetHeight(m_avHeight); + } + } + Animator.TrySetMovementAnimation("STAND"); + } + + private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) + { + SceneObjectPart targetPart = m_scene.GetSceneObjectPart(targetID); + if (targetPart == null) + return null; + + // If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used. + // If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used. + + // Get our own copy of the part array, and sort into the order we want to test + SceneObjectPart[] partArray = targetPart.ParentGroup.GetParts(); + Array.Sort(partArray, delegate(SceneObjectPart p1, SceneObjectPart p2) + { + // we want the originally selected part first, then the rest in link order -- so make the selected part link num (-1) + int linkNum1 = p1==targetPart ? -1 : p1.LinkNum; + int linkNum2 = p2==targetPart ? -1 : p2.LinkNum; + return linkNum1 - linkNum2; + } + ); + + //look for prims with explicit sit targets that are available + foreach (SceneObjectPart part in partArray) + { + // Is a sit target available? + Vector3 avSitOffSet = part.SitTargetPosition; + Quaternion avSitOrientation = part.SitTargetOrientation; + UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); + bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); + bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. + if (SitTargetisSet && !SitTargetOccupied) + { + //switch the target to this prim + return part; + } + } + + // no explicit sit target found - use original target + return targetPart; + } + + private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) + { + bool autopilot = true; + Vector3 autopilotTarget = new Vector3(); + Quaternion sitOrientation = Quaternion.Identity; + Vector3 pos = new Vector3(); + Vector3 cameraEyeOffset = Vector3.Zero; + Vector3 cameraAtOffset = Vector3.Zero; + bool forceMouselook = false; + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + if (part == null) return; + + // TODO: determine position to sit at based on scene geometry; don't trust offset from client + // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it + + // part is the prim to sit on + // offset is the world-ref vector distance from that prim center to the click-spot + // UUID is the UUID of the Avatar doing the clicking + + m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation + + // Is a sit target available? + Vector3 avSitOffSet = part.SitTargetPosition; + Quaternion avSitOrientation = part.SitTargetOrientation; + + bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. + // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); + Quaternion partRot; +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim + partRot = part.GetWorldRotation(); +// } + Quaternion partIRot = Quaternion.Inverse(partRot); +//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); + // Sit analysis rewritten by KF 091125 + if (SitTargetisSet) // scipted sit + { + if (!part.IsOccupied) + { +//Console.WriteLine("Scripted, unoccupied"); + part.SetAvatarOnSitTarget(UUID); // set that Av will be on it + offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one + + Quaternion nrot = avSitOrientation; + if (!part.IsRoot) + { + nrot = part.RotationOffset * avSitOrientation; + } + sitOrientation = nrot; // Change rotatione to the scripted one + OffsetRotation = nrot; + autopilot = false; // Jump direct to scripted llSitPos() + } + else + { +//Console.WriteLine("Scripted, occupied"); + return; + } + } + else // Not Scripted + { + if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) + { + // large prim & offset, ignore if other Avs sitting +// offset.Z -= 0.05f; + m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked + autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point + +//Console.WriteLine(" offset ={0}", offset); +//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); +//Console.WriteLine(" autopilotTarget={0}", autopilotTarget); + + } + else // small offset + { +//Console.WriteLine("Small offset"); + if (!part.IsOccupied) + { + m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center + autopilotTarget = part.AbsolutePosition; +//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); + } + else return; // occupied small + } // end large/small + } // end Scripted/not + cameraAtOffset = part.GetCameraAtOffset(); + cameraEyeOffset = part.GetCameraEyeOffset(); + forceMouselook = part.GetForceMouselook(); + if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // + if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // + + if (m_physicsActor != null) + { + // If we're not using the client autopilot, we're immediately warping the avatar to the location + // We can remove the physicsActor until they stand up. + m_sitAvatarHeight = m_physicsActor.Size.Z; + if (autopilot) + { // its not a scripted sit +// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) + if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) + { + autopilot = false; // close enough + m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. + Not using the part's position because returning the AV to the last known standing + position is likely to be more friendly, isn't it? */ + RemoveFromPhysicalScene(); + Velocity = Vector3.Zero; + AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target + } // else the autopilot will get us close + } + else + { // its a scripted sit + m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. + I *am* using the part's position this time because we have no real idea how far away + the avatar is from the sit target. */ + RemoveFromPhysicalScene(); + Velocity = Vector3.Zero; + } + } + else return; // physactor is null! + + Vector3 offsetr; // = offset * partIRot; + // KF: In a linkset, offsetr needs to be relative to the group root! 091208 + // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); + // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. + // { // Single, or Root prim of linkset, target is ClickOffset * RootRot + //offsetr = offset * partIRot; +// + // else + // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) + // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + + // (offset * partRot); + // } + +//Console.WriteLine(" "); +//Console.WriteLine("link number ={0}", part.LinkNum); +//Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); +//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); +//Console.WriteLine("Click offst ={0}", offset); +//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); +//Console.WriteLine("offsetr ={0}", offsetr); +//Console.WriteLine("Camera At ={0}", cameraAtOffset); +//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); + + //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child + ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + + m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target + // This calls HandleAgentSit twice, once from here, and the client calls + // HandleAgentSit itself after it gets to the location + // It doesn't get to the location until we've moved them there though + // which happens in HandleAgentSit :P + m_autopilotMoving = autopilot; + m_autoPilotTarget = autopilotTarget; + m_sitAtAutoTarget = autopilot; + m_initialSitTarget = autopilotTarget; + if (!autopilot) + HandleAgentSit(remoteClient, UUID); + } + + public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) + { + if (m_parentID != 0) + { + StandUp(); + } + m_nextSitAnimation = "SIT"; + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + + if (part != null) + { + if (!String.IsNullOrEmpty(part.SitAnimation)) + { + m_nextSitAnimation = part.SitAnimation; + } + m_requestedSitTargetID = part.LocalId; + //m_requestedSitOffset = offset; + m_requestedSitTargetUUID = targetID; + + m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); + + if (m_scene.PhysicsScene.SupportsRayCast()) + { + //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); + //SitRayCastAvatarPosition(part); + //return; + } + } + else + { + + m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); + } + + + + SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); + } + /* + public void SitRayCastAvatarPosition(SceneObjectPart part) + { + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = AbsolutePosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); + } + + public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); + } + else + { + SitRayCastAvatarPositionCameraZ(part); + } + } + else + { + SitRayCastAvatarPositionCameraZ(part); + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) + { + // Next, try to raycast from the camera Z position + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); + } + + public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); + } + else + { + SitRayCastCameraPosition(part); + } + } + else + { + SitRayCastCameraPosition(part); + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + public void SitRayCastCameraPosition(SceneObjectPart part) + { + // Next, try to raycast from the camera position + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = CameraPosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); + } + + public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); + } + else + { + SitRayHorizontal(part); + } + } + else + { + SitRayHorizontal(part); + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + public void SitRayHorizontal(SceneObjectPart part) + { + // Next, try to raycast from the avatar position to fwd + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = CameraPosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); + } + + public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) + { + SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); + if (part != null) + { + if (hitYN) + { + if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) + { + SitRaycastFindEdge(collisionPoint, normal); + m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); + // Next, try to raycast from the camera position + Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; + Vector3 StartRayCastPosition = CameraPosition; + Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); + float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); + //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); + } + else + { + ControllingClient.SendAlertMessage("Sit position not accessable."); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + } + else + { + ControllingClient.SendAlertMessage("Sit position not accessable."); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + } + else + { + ControllingClient.SendAlertMessage("Sit position no longer exists"); + m_requestedSitTargetUUID = UUID.Zero; + m_requestedSitTargetID = 0; + m_requestedSitOffset = Vector3.Zero; + } + + } + + private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) + { + int i = 0; + //throw new NotImplementedException(); + //m_requestedSitTargetUUID = UUID.Zero; + //m_requestedSitTargetID = 0; + //m_requestedSitOffset = Vector3.Zero; + + SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); + } + */ + public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) + { + if (m_parentID != 0) + { + StandUp(); + } + if (!String.IsNullOrEmpty(sitAnimation)) + { + m_nextSitAnimation = sitAnimation; + } + else + { + m_nextSitAnimation = "SIT"; + } + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + if (part != null) + { + m_requestedSitTargetID = part.LocalId; + //m_requestedSitOffset = offset; + m_requestedSitTargetUUID = targetID; + + m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); + + if (m_scene.PhysicsScene.SupportsRayCast()) + { + //SitRayCastAvatarPosition(part); + //return; + } + } + else + { + m_log.Warn("Sit requested on unknown object: " + targetID); + } + + SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); + } + + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) + { + if (!String.IsNullOrEmpty(m_nextSitAnimation)) + { + HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); + } + else + { + HandleAgentSit(remoteClient, agentID, "SIT"); + } + } + + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + + if (m_sitAtAutoTarget || !m_autopilotMoving) + { + if (part != null) + { +//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); + if (part.GetAvatarOnSitTarget() == UUID) + { +//Console.WriteLine("Scripted Sit"); + // Scripted sit + Vector3 sitTargetPos = part.SitTargetPosition; + Quaternion sitTargetOrient = part.SitTargetOrientation; + m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); + m_pos += SIT_TARGET_ADJUSTMENT; + if (!part.IsRoot) + { + m_pos *= part.RotationOffset; + } + m_bodyRot = sitTargetOrient; + m_parentPosition = part.AbsolutePosition; + part.IsOccupied = true; + part.ParentGroup.AddAvatar(agentID); + } + else + { + // if m_avUnscriptedSitPos is zero then Av sits above center + // Else Av sits at m_avUnscriptedSitPos + + // Non-scripted sit by Kitto Flora 21Nov09 + // Calculate angle of line from prim to Av + Quaternion partIRot; +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim + partIRot = Quaternion.Inverse(part.GetWorldRotation()); +// } + Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; + float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); + float x_diff = ( m_avInitialPos.X - sitTargetPos.X); + if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 + if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 + float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); + // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. + // Av sits at world euler <0,0, z>, translated by part rotation + m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click + + m_parentPosition = part.AbsolutePosition; + part.IsOccupied = true; + part.ParentGroup.AddAvatar(agentID); + m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation + (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center + (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + + m_avUnscriptedSitPos; // adds click offset, if any + //Set up raytrace to find top surface of prim + Vector3 size = part.Scale; + float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); + Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); + Vector3 down = new Vector3(0f, 0f, -1f); +//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); + m_scene.PhysicsScene.RaycastWorld( + start, // Vector3 position, + down, // Vector3 direction, + mag, // float length, + SitAltitudeCallback); // retMethod + } // end scripted/not + } + else // no Av + { + return; + } + } + + //We want our offsets to reference the root prim, not the child we may have sat on + if (!part.IsRoot) + { + m_parentID = part.ParentGroup.RootPart.LocalId; + m_pos += part.OffsetPosition; + } + else + { + m_parentID = m_requestedSitTargetID; + } + + m_linkedPrim = part.UUID; + if (part.GetAvatarOnSitTarget() != UUID) + { + m_offsetRotation = m_offsetRotation / part.RotationOffset; + } + Velocity = Vector3.Zero; + RemoveFromPhysicalScene(); + Animator.TrySetMovementAnimation(sitAnimation); + SendFullUpdateToAllClients(); + SendTerseUpdateToAllClients(); + } + + public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) + { + // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer + // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. + if(hitYN) + { + // m_pos = Av offset from prim center to make look like on center + // m_parentPosition = Actual center pos of prim + // collisionPoint = spot on prim where we want to sit + // collisionPoint.Z = global sit surface height + SceneObjectPart part = m_scene.GetSceneObjectPart(localid); + Quaternion partIRot; +// if (part.LinkNum == 1) +/// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim + partIRot = Quaternion.Inverse(part.GetWorldRotation()); +// } + if (m_initialSitTarget != null) + { + float offZ = collisionPoint.Z - m_initialSitTarget.Z; + Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction + //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); + m_pos += offset; + // ControllingClient.SendClearFollowCamProperties(part.UUID); + } + + } + } // End SitAltitudeCallback KF. + + /// + /// Event handler for the 'Always run' setting on the client + /// Tells the physics plugin to increase speed of movement. + /// + public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) + { + m_setAlwaysRun = pSetAlwaysRun; + if (PhysicsActor != null) + { + PhysicsActor.SetAlwaysRun = pSetAlwaysRun; + } + } + + public void HandleStartAnim(IClientAPI remoteClient, UUID animID) + { + Animator.AddAnimation(animID, UUID.Zero); + } + + public void HandleStopAnim(IClientAPI remoteClient, UUID animID) + { + Animator.RemoveAnimation(animID); + } + + /// + /// Rotate the avatar to the given rotation and apply a movement in the given relative vector + /// + /// The vector in which to move. This is relative to the rotation argument + /// The direction in which this avatar should now face. + public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) + { + if (m_isChildAgent) + { + // WHAT??? + m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); + + // we have to reset the user's child agent connections. + // Likely, here they've lost the eventqueue for other regions so border + // crossings will fail at this point unless we reset them. + + List regions = new List(KnownChildRegionHandles); + regions.Remove(m_scene.RegionInfo.RegionHandle); + + MakeRootAgent(new Vector3(127f, 127f, 127f), true); + + // Async command + if (m_scene.SceneGridService != null) + { + m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); + + // Give the above command some time to try and close the connections. + // this is really an emergency.. so sleep, or we'll get all discombobulated. + System.Threading.Thread.Sleep(500); + } + + if (m_scene.SceneGridService != null) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); + } + + return; + } + + m_perfMonMS = Util.EnvironmentTickCount(); + + Rotation = rotation; + Vector3 direc = vec * rotation; + direc.Normalize(); + PhysicsActor actor = m_physicsActor; + if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. + + direc *= 0.03f * 128f * m_speedModifier; + + if (actor != null) + { + if (actor.Flying) + { + direc *= 4.0f; + //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + //bool colliding = (m_physicsActor.IsColliding==true); + //if (controlland) + // m_log.Info("[AGENT]: landCommand"); + //if (colliding) + // m_log.Info("[AGENT]: colliding"); + //if (m_physicsActor.Flying && colliding && controlland) + //{ + // StopFlying(); + // m_log.Info("[AGENT]: Stop FLying"); + //} + } + else if (!actor.Flying && actor.IsColliding) + { + if (direc.Z > 2.0f) + { + if(m_animator.m_animTickJump == -1) + { + direc.Z *= 3.0f; // jump + } + else + { + direc.Z *= 0.1f; // prejump + } + /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs + Animator.TrySetMovementAnimation("PREJUMP"); + Animator.TrySetMovementAnimation("JUMP"); + */ + } + } + } + + // TODO: Add the force instead of only setting it to support multiple forces per frame? + m_forceToApply = direc; + m_isNudging = Nudging; + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + #endregion + + #region Overridden Methods + + public override void Update() + { + const float ROTATION_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.001f; + const float POSITION_TOLERANCE = 0.05f; + //const int TIME_MS_TOLERANCE = 3000; + + + + if (m_isChildAgent == false) + { +// PhysicsActor actor = m_physicsActor; + + // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to + // grab the latest PhysicsActor velocity, whereas m_velocity is often + // storing a requested force instead of an actual traveling velocity + + // Throw away duplicate or insignificant updates + if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) + //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) + { + SendTerseUpdateToAllClients(); + + // Update the "last" values + m_lastPosition = m_pos; + m_lastRotation = m_bodyRot; + m_lastVelocity = Velocity; + //m_lastTerseSent = Environment.TickCount; + } + + // followed suggestion from mic bowman. reversed the two lines below. + if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something + CheckForBorderCrossing(); + CheckForSignificantMovement(); // sends update to the modules. + } + + //Sending prim updates AFTER the avatar terse updates are sent + SendPrimUpdates(); + } + + #endregion + + #region Update Client(s) + + /// + /// Sends a location update to the client connected to this scenePresence + /// + /// + public void SendTerseUpdateToClient(IClientAPI remoteClient) + { + // If the client is inactive, it's getting its updates from another + // server. + if (remoteClient.IsActive) + { + m_perfMonMS = Util.EnvironmentTickCount(); + + PhysicsActor actor = m_physicsActor; + Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); + + remoteClient.SendPrimUpdate(this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + m_scene.StatsReporter.AddAgentUpdates(1); + } + } + + /// + /// Send a location/velocity/accelleration update to all agents in scene + /// + public void SendTerseUpdateToAllClients() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + m_scene.ForEachClient(SendTerseUpdateToClient); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + public void SendCoarseLocations(List coarseLocations, List avatarUUIDs) + { + SendCourseLocationsMethod d = m_sendCourseLocationsMethod; + if (d != null) + { + d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); + } + } + + public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) + { + if (d != null) + m_sendCourseLocationsMethod = d; + } + + public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List coarseLocations, List avatarUUIDs) + { + m_perfMonMS = Util.EnvironmentTickCount(); + m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + /// + /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) + /// + /// + public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) + { + // 2 stage check is needed. + if (remoteAvatar == null) + return; + IClientAPI cl=remoteAvatar.ControllingClient; + if (cl == null) + return; + if (m_appearance.Texture == null) + return; + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); + m_scene.StatsReporter.AddAgentUpdates(1); + } + + /// + /// Tell *ALL* agents about this agent + /// + public void SendInitialFullUpdateToAllClients() + { + m_perfMonMS = Util.EnvironmentTickCount(); + int avUpdates = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence avatar) + { + ++avUpdates; + // only send if this is the root (children are only "listening posts" in a foreign region) + if (!IsChildAgent) + { + SendFullUpdateToOtherClient(avatar); + } + + if (avatar.LocalId != LocalId) + { + if (!avatar.IsChildAgent) + { + avatar.SendFullUpdateToOtherClient(this); + avatar.SendAppearanceToOtherAgent(this); + avatar.Animator.SendAnimPackToClient(ControllingClient); + } + } + }); + + m_scene.StatsReporter.AddAgentUpdates(avUpdates); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + + //Animator.SendAnimPack(); + } + + public void SendFullUpdateToAllClients() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + // only send update from root agents to other clients; children are only "listening posts" + int count = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence sp) + { + if (sp.IsChildAgent) + return; + SendFullUpdateToOtherClient(sp); + ++count; + }); + m_scene.StatsReporter.AddAgentUpdates(count); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + + Animator.SendAnimPack(); + } + + /// + /// Do everything required once a client completes its movement into a region + /// + public void SendInitialData() + { + // Moved this into CompleteMovement to ensure that m_appearance is initialized before + // the inventory arrives + // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + m_controllingClient.SendAvatarDataImmediate(this); + + SendInitialFullUpdateToAllClients(); + SendAppearanceToAllOtherAgents(); + } + + /// + /// Tell the client for this scene presence what items it should be wearing now + /// + public void SendWearables() + { + m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name); + + ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); + } + + /// + /// + /// + public void SendAppearanceToAllOtherAgents() + { + m_perfMonMS = Util.EnvironmentTickCount(); + + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + { + if (scenePresence.UUID != UUID) + { + SendAppearanceToOtherAgent(scenePresence); + } + }); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } + + /// + /// Send appearance data to an agent that isn't this one. + /// + /// + public void SendAppearanceToOtherAgent(ScenePresence avatar) + { + avatar.ControllingClient.SendAppearance( + m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); + } + + /// + /// Set appearance data (textureentry and slider settings) received from the client + /// + /// + /// + public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) + { + if (m_physicsActor != null) + { + if (!IsChildAgent) + { + // This may seem like it's redundant, remove the avatar from the physics scene + // just to add it back again, but it saves us from having to update + // 3 variables 10 times a second. + bool flyingTemp = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); + + //PhysicsActor = null; + + AddToPhysicalScene(flyingTemp); + } + } + + #region Bake Cache Check + + if (textureEntry != null) + { + for (int i = 0; i < BAKE_INDICES.Length; i++) + { + int j = BAKE_INDICES[i]; + Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; + + if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + { + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + { + m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); + this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } + } + } + + } + + + #endregion Bake Cache Check + + m_appearance.SetAppearance(textureEntry, visualParams); + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); + + // This is not needed, because only the transient data changed + //AvatarData adata = new AvatarData(m_appearance); + //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); + + SendAppearanceToAllOtherAgents(); + if (!m_startAnimationSet) + { + Animator.UpdateMovementAnimations(); + m_startAnimationSet = true; + } + + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; + + m_controllingClient.SendAvatarDataImmediate(this); + } + + public void SetWearable(int wearableId, AvatarWearable wearable) + { + m_appearance.SetWearable(wearableId, wearable); + AvatarData adata = new AvatarData(m_appearance); + m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); + m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); + } + + // Because appearance setting is in a module, we actually need + // to give it access to our appearance directly, otherwise we + // get a synchronization issue. + public AvatarAppearance Appearance + { + get { return m_appearance; } + set { m_appearance = value; } + } + + #endregion + + #region Significant Movement Method + + /// + /// This checks for a significant movement and sends a courselocationchange update + /// + protected void CheckForSignificantMovement() + { + // Movement updates for agents in neighboring regions are sent directly to clients. + // This value only affects how often agent positions are sent to neighbor regions + // for things such as distance-based update prioritization + const float SIGNIFICANT_MOVEMENT = 2.0f; + + if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) + { + posLastSignificantMove = AbsolutePosition; + m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); + } + + // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m + if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || + Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) + { + m_lastChildAgentUpdatePosition = AbsolutePosition; + m_lastChildAgentUpdateCamPosition = CameraPosition; + + ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); + cadu.ActiveGroupID = UUID.Zero.Guid; + cadu.AgentID = UUID.Guid; + cadu.alwaysrun = m_setAlwaysRun; + cadu.AVHeight = m_avHeight; + Vector3 tempCameraCenter = m_CameraCenter; + cadu.cameraPosition = tempCameraCenter; + cadu.drawdistance = m_DrawDistance; + cadu.GroupAccess = 0; + cadu.Position = AbsolutePosition; + cadu.regionHandle = m_rootRegionHandle; + float multiplier = 1; + int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); + if (innacurateNeighbors != 0) + { + multiplier = 1f / (float)innacurateNeighbors; + } + if (multiplier <= 0f) + { + multiplier = 0.25f; + } + + //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); + cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); + cadu.Velocity = Velocity; + + AgentPosition agentpos = new AgentPosition(); + agentpos.CopyFrom(cadu); + + m_scene.SendOutChildAgentUpdates(agentpos, this); + } + } + + #endregion + + #region Border Crossing Methods + + /// + /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion + /// + protected void CheckForBorderCrossing() + { + if (IsChildAgent) + return; + + Vector3 pos2 = AbsolutePosition; + Vector3 vel = Velocity; + int neighbor = 0; + int[] fix = new int[2]; + + float timeStep = 0.1f; + pos2.X = pos2.X + (vel.X*timeStep); + pos2.Y = pos2.Y + (vel.Y*timeStep); + pos2.Z = pos2.Z + (vel.Z*timeStep); + + if (!IsInTransit) + { + // Checks if where it's headed exists a region + + bool needsTransit = false; + if (m_scene.TestBorderCross(pos2, Cardinals.W)) + { + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.SW, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.NW, ref fix); + } + else + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.W, ref fix); + } + } + else if (m_scene.TestBorderCross(pos2, Cardinals.E)) + { + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.SE, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.NE, ref fix); + } + else + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.E, ref fix); + } + } + else if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.S, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = HaveNeighbor(Cardinals.N, ref fix); + } + + + // Makes sure avatar does not end up outside region + if (neighbor <= 0) + { + if (!needsTransit) + { + if (m_requestedSitTargetUUID == UUID.Zero) + { + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y; + AbsolutePosition = pos; + } + } + } + else if (neighbor > 0) + CrossToNewRegion(); + } + else + { + RemoveFromPhysicalScene(); + // This constant has been inferred from experimentation + // I'm not sure what this value should be, so I tried a few values. + timeStep = 0.04f; + pos2 = AbsolutePosition; + pos2.X = pos2.X + (vel.X * timeStep); + pos2.Y = pos2.Y + (vel.Y * timeStep); + pos2.Z = pos2.Z + (vel.Z * timeStep); + m_pos = pos2; + } + } + + protected int HaveNeighbor(Cardinals car, ref int[] fix) + { + uint neighbourx = m_regionInfo.RegionLocX; + uint neighboury = m_regionInfo.RegionLocY; + + int dir = (int)car; + + if (dir > 1 && dir < 5) //Heading East + neighbourx++; + else if (dir > 5) // Heading West + neighbourx--; + + if (dir < 3 || dir == 8) // Heading North + neighboury++; + else if (dir > 3 && dir < 7) // Heading Sout + neighboury--; + + int x = (int)(neighbourx * Constants.RegionSize); + int y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); + + if (neighbourRegion == null) + { + fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); + fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); + return dir * (-1); + } + else + return dir; + } + + /// + /// Moves the agent outside the region bounds + /// Tells neighbor region that we're crossing to it + /// If the neighbor accepts, remove the agent's viewable avatar from this scene + /// set them to a child agent. + /// + protected void CrossToNewRegion() + { + InTransit(); + try + { + m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); + } + catch + { + m_scene.CrossAgentToNewRegion(this, false); + } + } + + public void InTransit() + { + m_inTransit = true; + + if ((m_physicsActor != null) && m_physicsActor.Flying) + m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; + else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) + m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; + } + + public void NotInTransit() + { + m_inTransit = false; + } + + public void RestoreInCurrentScene() + { + AddToPhysicalScene(false); // not exactly false + } + + public void Reset() + { + // Put the child agent back at the center + AbsolutePosition + = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); + Animator.ResetAnimations(); + } + + /// + /// Computes which child agents to close when the scene presence moves to another region. + /// Removes those regions from m_knownRegions. + /// + /// The new region's x on the map + /// The new region's y on the map + /// + public void CloseChildAgents(uint newRegionX, uint newRegionY) + { + List byebyeRegions = new List(); + m_log.DebugFormat( + "[SCENE PRESENCE]: Closing child agents. Checking {0} regions in {1}", + m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName); + //DumpKnownRegions(); + + lock (m_knownChildRegions) + { + foreach (ulong handle in m_knownChildRegions.Keys) + { + // Don't close the agent on this region yet + if (handle != Scene.RegionInfo.RegionHandle) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + + //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); + //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); + if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) + { + byebyeRegions.Add(handle); + } + } + } + } + + if (byebyeRegions.Count > 0) + { + m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); + m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); + } + + foreach (ulong handle in byebyeRegions) + { + RemoveNeighbourRegion(handle); + } + } + + #endregion + + /// + /// This allows the Sim owner the abiility to kick users from their sim currently. + /// It tells the client that the agent has permission to do so. + /// + public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) + { + if (godStatus) + { + // For now, assign god level 200 to anyone + // who is granted god powers, but has no god level set. + // + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); + if (account != null) + { + if (account.UserLevel > 0) + m_godLevel = account.UserLevel; + else + m_godLevel = 200; + } + } + else + { + m_godLevel = 0; + } + + ControllingClient.SendAdminResponse(token, (uint)m_godLevel); + } + + #region Child Agent Updates + + public void ChildAgentDataUpdate(AgentData cAgentData) + { + //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); + if (!IsChildAgent) + return; + + CopyFrom(cAgentData); + } + + /// + /// This updates important decision making data about a child agent + /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region + /// + public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) + { + if (!IsChildAgent) + return; + + //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); + int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; + int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; + + Vector3 offset = new Vector3(shiftx, shifty, 0f); + + m_DrawDistance = cAgentData.Far; + if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! + m_pos = cAgentData.Position + offset; + + if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) + { + posLastSignificantMove = AbsolutePosition; + ReprioritizeUpdates(); + } + + m_CameraCenter = cAgentData.Center + offset; + + m_avHeight = cAgentData.Size.Z; + //SetHeight(cAgentData.AVHeight); + + if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) + ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); + + // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. + if (m_scene.m_seeIntoRegionFromNeighbor) + m_sceneViewer.Reset(); + + //cAgentData.AVHeight; + m_rootRegionHandle = cAgentData.RegionHandle; + //m_velocity = cAgentData.Velocity; + } + + public void CopyTo(AgentData cAgent) + { + cAgent.AgentID = UUID; + cAgent.RegionID = Scene.RegionInfo.RegionID; + + cAgent.Position = AbsolutePosition; + cAgent.Velocity = m_velocity; + cAgent.Center = m_CameraCenter; + // Don't copy the size; it is inferred from apearance parameters + //cAgent.Size = new Vector3(0, 0, m_avHeight); + cAgent.AtAxis = m_CameraAtAxis; + cAgent.LeftAxis = m_CameraLeftAxis; + cAgent.UpAxis = m_CameraUpAxis; + + cAgent.Far = m_DrawDistance; + + // Throttles + float multiplier = 1; + int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); + if (innacurateNeighbors != 0) + { + multiplier = 1f / innacurateNeighbors; + } + if (multiplier <= 0f) + { + multiplier = 0.25f; + } + //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); + cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); + + cAgent.HeadRotation = m_headrotation; + cAgent.BodyRotation = m_bodyRot; + cAgent.ControlFlags = (uint)m_AgentControlFlags; + + if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) + cAgent.GodLevel = (byte)m_godLevel; + else + cAgent.GodLevel = (byte) 0; + + cAgent.AlwaysRun = m_setAlwaysRun; + + try + { + // We might not pass the Wearables in all cases... + // They're only needed so that persistent changes to the appearance + // are preserved in the new region where the user is moving to. + // But in Hypergrid we might not let this happen. + int i = 0; + UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; + foreach (AvatarWearable aw in m_appearance.Wearables) + { + if (aw != null) + { + wears[i++] = aw.ItemID; + wears[i++] = aw.AssetID; + } + else + { + wears[i++] = UUID.Zero; + wears[i++] = UUID.Zero; + } + } + cAgent.Wearables = wears; + + cAgent.VisualParams = m_appearance.VisualParams; + + if (m_appearance.Texture != null) + cAgent.AgentTextures = m_appearance.Texture.GetBytes(); + } + catch (Exception e) + { + m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); + } + + //Attachments + List attPoints = m_appearance.GetAttachedPoints(); + if (attPoints != null) + { + //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); + int i = 0; + AttachmentData[] attachs = new AttachmentData[attPoints.Count]; + foreach (int point in attPoints) + { + attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); + } + cAgent.Attachments = attachs; + } + + lock (scriptedcontrols) + { + ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; + int i = 0; + + foreach (ScriptControllers c in scriptedcontrols.Values) + { + controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); + } + cAgent.Controllers = controls; + } + + // Animations + try + { + cAgent.Anims = Animator.Animations.ToArray(); + } + catch { } + + // cAgent.GroupID = ?? + // Groups??? + + } + + public void CopyFrom(AgentData cAgent) + { + m_originRegionID = cAgent.RegionID; + + m_callbackURI = cAgent.CallbackURI; + + m_pos = cAgent.Position; + + m_velocity = cAgent.Velocity; + m_CameraCenter = cAgent.Center; + //m_avHeight = cAgent.Size.Z; + m_CameraAtAxis = cAgent.AtAxis; + m_CameraLeftAxis = cAgent.LeftAxis; + m_CameraUpAxis = cAgent.UpAxis; + + m_DrawDistance = cAgent.Far; + + if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) + ControllingClient.SetChildAgentThrottle(cAgent.Throttles); + + m_headrotation = cAgent.HeadRotation; + m_bodyRot = cAgent.BodyRotation; + m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; + + if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) + m_godLevel = cAgent.GodLevel; + m_setAlwaysRun = cAgent.AlwaysRun; + + uint i = 0; + try + { + if (cAgent.Wearables == null) + cAgent.Wearables = new UUID[0]; + AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; + for (uint n = 0; n < cAgent.Wearables.Length; n += 2) + { + UUID itemId = cAgent.Wearables[n]; + UUID assetId = cAgent.Wearables[n + 1]; + wears[i++] = new AvatarWearable(itemId, assetId); + } + m_appearance.Wearables = wears; + Primitive.TextureEntry te; + if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) + te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); + else + te = AvatarAppearance.GetDefaultTexture(); + if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) + cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); + m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); + } + catch (Exception e) + { + m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); + } + + // Attachments + try + { + if (cAgent.Attachments != null) + { + m_appearance.ClearAttachments(); + foreach (AttachmentData att in cAgent.Attachments) + { + m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); + } + } + } + catch { } + + try + { + lock (scriptedcontrols) + { + if (cAgent.Controllers != null) + { + scriptedcontrols.Clear(); + + foreach (ControllerData c in cAgent.Controllers) + { + ScriptControllers sc = new ScriptControllers(); + sc.itemID = c.ItemID; + sc.ignoreControls = (ScriptControlled)c.IgnoreControls; + sc.eventControls = (ScriptControlled)c.EventControls; + + scriptedcontrols[sc.itemID] = sc; + } + } + } + } + catch { } + // Animations + try + { + Animator.ResetAnimations(); + Animator.Animations.FromArray(cAgent.Anims); + } + catch { } + + //cAgent.GroupID = ?? + //Groups??? + } + + public bool CopyAgent(out IAgentData agent) + { + agent = new CompleteAgentData(); + CopyTo((AgentData)agent); + return true; + } + + #endregion Child Agent Updates + + /// + /// Handles part of the PID controller function for moving an avatar. + /// + public override void UpdateMovement() + { + if (m_forceToApply.HasValue) + { + + Vector3 force = m_forceToApply.Value; + m_updateflag = true; + Velocity = force; + + m_forceToApply = null; + } + else + { + if (m_isNudging) + { + Vector3 force = Vector3.Zero; + + m_updateflag = true; + Velocity = force; + m_isNudging = false; + m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" + } + } + } + + public override void SetText(string text, Vector3 color, double alpha) + { + throw new Exception("Can't set Text on avatar."); + } + + /// + /// Adds a physical representation of the avatar to the Physics plugin + /// + public void AddToPhysicalScene(bool isFlying) + { + PhysicsScene scene = m_scene.PhysicsScene; + + Vector3 pVec = AbsolutePosition; + + // Old bug where the height was in centimeters instead of meters + if (m_avHeight == 127.0f) + { + m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), + isFlying); + } + else + { + m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, + new Vector3(0f, 0f, m_avHeight), isFlying); + } + scene.AddPhysicsActorTaint(m_physicsActor); + //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; + m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; + m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong + m_physicsActor.SubscribeEvents(500); + m_physicsActor.LocalID = LocalId; + } + + private void OutOfBoundsCall(Vector3 pos) + { + //bool flying = m_physicsActor.Flying; + //RemoveFromPhysicalScene(); + + //AddToPhysicalScene(flying); + if (ControllingClient != null) + ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); + } + + // Event called by the physics plugin to tell the avatar about a collision. + private void PhysicsCollisionUpdate(EventArgs e) + { + if (e == null) + return; + + // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( + // as of this comment the interval is set in AddToPhysicalScene + if (Animator!=null) + { + if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, + { // else its will lock out other animation changes, like ground sit. + Animator.UpdateMovementAnimations(); + m_updateCount--; + } + } + + CollisionEventUpdate collisionData = (CollisionEventUpdate)e; + Dictionary coldata = collisionData.m_objCollisionList; + + CollisionPlane = Vector4.UnitW; + + if (m_lastColCount != coldata.Count) + { + m_updateCount = UPDATE_COUNT; + m_lastColCount = coldata.Count; + } + + if (coldata.Count != 0 && Animator != null) + { + switch (Animator.CurrentMovementAnimation) + { + case "STAND": + case "WALK": + case "RUN": + case "CROUCH": + case "CROUCHWALK": + { + ContactPoint lowest; + lowest.SurfaceNormal = Vector3.Zero; + lowest.Position = Vector3.Zero; + lowest.Position.Z = Single.NaN; + + foreach (ContactPoint contact in coldata.Values) + { + if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) + { + lowest = contact; + } + } + + CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + } + break; + } + } + + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); + + foreach (uint localid in coldata.Keys) + { + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + { + startedColliders.Add(localid); + } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } + + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) + { + endedColliders.Add(localID); + } + } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } + + // do event notification + if (startedColliders.Count > 0) + { + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } + } + + if (endedColliders.Count > 0) + { + ColliderArgs EndCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in endedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + EndCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in Attachments) + Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); + } + } + + if (thisHitColliders.Count > 0) + { + ColliderArgs CollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in thisHitColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + CollidingMessage.Colliders = colliding; + + lock (m_attachments) + { + foreach (SceneObjectGroup att in m_attachments) + Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + } + } + } + + if (m_invulnerable) + return; + + float starthealth = Health; + uint killerObj = 0; + foreach (uint localid in coldata.Keys) + { + SceneObjectPart part = Scene.GetSceneObjectPart(localid); + + if (part != null && part.ParentGroup.Damage != -1.0f) + Health -= part.ParentGroup.Damage; + else + { + if (coldata[localid].PenetrationDepth >= 0.10f) + Health -= coldata[localid].PenetrationDepth * 5.0f; + } + + if (Health <= 0.0f) + { + if (localid != 0) + killerObj = localid; + } + //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); + } + //Health = 100; + if (!m_invulnerable) + { + if (starthealth != Health) + { + ControllingClient.SendHealth(Health); + } + if (m_health <= 0) + m_scene.EventManager.TriggerAvatarKill(killerObj, this); + } + } + + public void setHealthWithUpdate(float health) + { + Health = health; + ControllingClient.SendHealth(Health); + } + + public void Close() + { + lock (m_attachments) + { + // Delete attachments from scene + // Don't try to save, as this thread won't live long + // enough to complete the save. This would cause no copy + // attachments to poof! + // + foreach (SceneObjectGroup grp in m_attachments) + { + m_scene.DeleteSceneObject(grp, false); + } + m_attachments.Clear(); + } + + lock (m_knownChildRegions) + { + m_knownChildRegions.Clear(); + } + + lock (m_reprioritization_timer) + { + m_reprioritization_timer.Enabled = false; + m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); + } + + // I don't get it but mono crashes when you try to dispose of this timer, + // unsetting the elapsed callback should be enough to allow for cleanup however. + // m_reprioritizationTimer.Dispose(); + + m_sceneViewer.Close(); + + RemoveFromPhysicalScene(); + m_animator.Close(); + m_animator = null; + } + + public void AddAttachment(SceneObjectGroup gobj) + { + lock (m_attachments) + { + m_attachments.Add(gobj); + } + } + + public bool HasAttachments() + { + return m_attachments.Count > 0; + } + + public bool HasScriptedAttachments() + { + lock (m_attachments) + { + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj != null) + { + if (gobj.RootPart.Inventory.ContainsScripts()) + return true; + } + } + } + return false; + } + + public void RemoveAttachment(SceneObjectGroup gobj) + { + lock (m_attachments) + { + if (m_attachments.Contains(gobj)) + { + m_attachments.Remove(gobj); + } + } + } + + public bool ValidateAttachments() + { + lock (m_attachments) + { + // Validate + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj == null) + return false; + + if (gobj.IsDeleted) + return false; + } + } + return true; + } + + /// + /// Send a script event to this scene presence's attachments + /// + /// The name of the event + /// The arguments for the event + public void SendScriptEventToAttachments(string eventName, Object[] args) + { + if (m_scriptEngines != null) + { + lock (m_attachments) + { + foreach (SceneObjectGroup grp in m_attachments) + { + // 16384 is CHANGED_ANIMATION + // + // Send this to all attachment root prims + // + foreach (IScriptModule m in m_scriptEngines) + { + if (m == null) // No script engine loaded + continue; + + m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); + } + } + } + } + } + + + public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) + { + m_controllingClient = client; + m_regionInfo = region; + m_scene = scene; + + RegisterToEvents(); + if (m_controllingClient != null) + { + m_controllingClient.ProcessPendingPackets(); + } + /* + AbsolutePosition = client.StartPos; + + Animations = new AvatarAnimations(); + Animations.LoadAnims(); + + m_animations = new List(); + m_animations.Add(Animations.AnimsUUID["STAND"]); + m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); + + SetDirectionVectors(); + */ + } + + internal void PushForce(Vector3 impulse) + { + if (PhysicsActor != null) + { + PhysicsActor.AddForce(impulse,true); + } + } + + public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) + { + ScriptControllers obj = new ScriptControllers(); + obj.ignoreControls = ScriptControlled.CONTROL_ZERO; + obj.eventControls = ScriptControlled.CONTROL_ZERO; + + obj.itemID = Script_item_UUID; + if (pass_on == 0 && accept == 0) + { + IgnoredControls |= (ScriptControlled)controls; + obj.ignoreControls = (ScriptControlled)controls; + } + + if (pass_on == 0 && accept == 1) + { + IgnoredControls |= (ScriptControlled)controls; + obj.ignoreControls = (ScriptControlled)controls; + obj.eventControls = (ScriptControlled)controls; + } + if (pass_on == 1 && accept == 1) + { + IgnoredControls = ScriptControlled.CONTROL_ZERO; + obj.eventControls = (ScriptControlled)controls; + obj.ignoreControls = ScriptControlled.CONTROL_ZERO; + } + + lock (scriptedcontrols) + { + if (pass_on == 1 && accept == 0) + { + IgnoredControls &= ~(ScriptControlled)controls; + if (scriptedcontrols.ContainsKey(Script_item_UUID)) + scriptedcontrols.Remove(Script_item_UUID); + } + else + { + scriptedcontrols[Script_item_UUID] = obj; + } + } + ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); + } + + public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) + { + IgnoredControls = ScriptControlled.CONTROL_ZERO; + lock (scriptedcontrols) + { + scriptedcontrols.Clear(); + } + ControllingClient.SendTakeControls(int.MaxValue, false, false); + } + + public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) + { + ScriptControllers takecontrols; + + lock (scriptedcontrols) + { + if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) + { + ScriptControlled sctc = takecontrols.eventControls; + + ControllingClient.SendTakeControls((int)sctc, false, false); + ControllingClient.SendTakeControls((int)sctc, true, false); + + scriptedcontrols.Remove(Script_item_UUID); + IgnoredControls = ScriptControlled.CONTROL_ZERO; + foreach (ScriptControllers scData in scriptedcontrols.Values) + { + IgnoredControls |= scData.ignoreControls; + } + } + } + } + + internal void SendControlToScripts(uint flags) + { + ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; + + if (MouseDown) + { + allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) + { + allflags = ScriptControlled.CONTROL_ZERO; + MouseDown = true; + } + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) + { + allflags |= ScriptControlled.CONTROL_ML_LBUTTON; + MouseDown = true; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) + { + allflags |= ScriptControlled.CONTROL_LBUTTON; + MouseDown = true; + } + + // find all activated controls, whether the scripts are interested in them or not + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_FWD; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_BACK; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_UP; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_DOWN; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_LEFT; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_RIGHT; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_ROT_RIGHT; + } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_ROT_LEFT; + } + // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that + if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) + { + lock (scriptedcontrols) + { + foreach (KeyValuePair kvp in scriptedcontrols) + { + UUID scriptUUID = kvp.Key; + ScriptControllers scriptControlData = kvp.Value; + + ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us + ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle + ScriptControlled localChange = localHeld ^ localLast; // the changed bits + if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) + { + // only send if still pressed or just changed + m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); + } + } + } + } + + LastCommands = allflags; + } + + internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) + { + if (ignored == ScriptControlled.CONTROL_ZERO) + return flags; + + if ((ignored & ScriptControlled.CONTROL_BACK) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); + if ((ignored & ScriptControlled.CONTROL_FWD) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); + if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); + if ((ignored & ScriptControlled.CONTROL_UP) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); + if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); + if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); + if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); + if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); + if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); + if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); + + //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, + //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, + //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, + //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, + //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, + //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, + //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG + + return flags; + } + + /// + /// RezAttachments. This should only be called upon login on the first region. + /// Attachment rezzings on crossings and TPs are done in a different way. + /// + public void RezAttachments() + { + if (null == m_appearance) + { + m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); + return; + } + + XmlDocument doc = new XmlDocument(); + string stateData = String.Empty; + + IAttachmentsService attServ = m_scene.RequestModuleInterface(); + if (attServ != null) + { + m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); + stateData = attServ.Get(ControllingClient.AgentId.ToString()); + if (stateData != String.Empty) + { + try + { + doc.LoadXml(stateData); + } + catch { } + } + } + + Dictionary itemData = new Dictionary(); + + XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); + if (nodes.Count > 0) + { + foreach (XmlNode n in nodes) + { + XmlElement elem = (XmlElement)n; + string itemID = elem.GetAttribute("ItemID"); + string xml = elem.InnerXml; + + itemData[new UUID(itemID)] = xml; + } + } + + List attPoints = m_appearance.GetAttachedPoints(); + foreach (int p in attPoints) + { + if (m_isDeleted) + return; + + UUID itemID = m_appearance.GetAttachedItem(p); + UUID assetID = m_appearance.GetAttachedAsset(p); + + // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down + // But they're not used anyway, the item is being looked up for now, so let's proceed. + //if (UUID.Zero == assetID) + //{ + // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); + // continue; + //} + + try + { + string xmlData; + XmlDocument d = new XmlDocument(); + UUID asset; + if (itemData.TryGetValue(itemID, out xmlData)) + { + d.LoadXml(xmlData); + m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); + + // Rez from inventory + asset + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); + + } + else + { + // Rez from inventory (with a null doc to let + // CHANGED_OWNER happen) + asset + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); + } + + m_log.InfoFormat( + "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", + p, itemID, assetID, asset); + } + catch (Exception e) + { + m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e.ToString()); + } + } + } + + private void ReprioritizeUpdates() + { + if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) + { + lock (m_reprioritization_timer) + { + if (!m_reprioritizing) + m_reprioritization_timer.Enabled = m_reprioritizing = true; + else + m_reprioritization_called = true; + } + } + } + + private void Reprioritize(object sender, ElapsedEventArgs e) + { + m_controllingClient.ReprioritizeUpdates(); + + lock (m_reprioritization_timer) + { + m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; + m_reprioritization_called = false; + } + } + + private Vector3 Quat2Euler(Quaternion rot){ + float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , + (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); + float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); + float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , + (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); + return(new Vector3(x,y,z)); + } + + + } +} -- cgit v1.1 From 24b9a2885f1204d32cd032aa8ea9905fa9ce19b1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 10 Aug 2010 20:11:55 +0100 Subject: Resolve merge issues --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 68 +++++++++++++++------- 1 file changed, 46 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a0f267c..b179646 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1838,6 +1838,26 @@ namespace OpenSim.Region.Framework.Scenes dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + if (userExposed) + dupe.m_rootPart.TrimPermissions(); + + /// may need to create a new Physics actor. + if (dupe.RootPart.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = dupe.RootPart.Shape; + + dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( + dupe.RootPart.Name, + pbs, + dupe.RootPart.AbsolutePosition, + dupe.RootPart.Scale, + dupe.RootPart.RotationOffset, + dupe.RootPart.PhysActor.IsPhysical); + + dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; + dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); + } + lockPartsForRead(true); List partList; @@ -1860,34 +1880,37 @@ namespace OpenSim.Region.Framework.Scenes newPart.LinkNum = part.LinkNum; } - } + // Need to duplicate the physics actor as well + if (part.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = part.Shape; + + part.PhysActor + = m_scene.PhysicsScene.AddPrimShape( + part.Name, + pbs, + part.AbsolutePosition, + part.Scale, + part.RotationOffset, + part.PhysActor.IsPhysical); + + part.PhysActor.LocalID = part.LocalId; + part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); + } + + } if (userExposed) { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - newPart.LinkNum = part.LinkNum; + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); } - // Need to duplicate the physics actor as well - if (part.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = part.Shape; - - part.PhysActor - = m_scene.PhysicsScene.AddPrimShape( - part.Name, - pbs, - part.AbsolutePosition, - part.Scale, - part.RotationOffset, - part.PhysActor.IsPhysical); - - part.PhysActor.LocalID = part.LocalId; - part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); - } } - - if (userExposed) + finally { m_dupeInProgress = false; } @@ -1905,6 +1928,7 @@ namespace OpenSim.Region.Framework.Scenes SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed)); } + public void ScriptSetPhysicsStatus(bool UsePhysics) { bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); -- cgit v1.1 From fb14390fb0446e225bca08ec2dc25960d1441728 Mon Sep 17 00:00:00 2001 From: meta7 Date: Tue, 10 Aug 2010 09:17:30 -0700 Subject: Note to self: don't break the build --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ffe2094..20a2abc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -145,7 +145,7 @@ namespace OpenSim.Region.Framework.Scenes // write call stack method names foreach (StackFrame stackFrame in stackFrames) { - m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name); // write method name + m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name } m_partsLock.ExitReadLock(); -- cgit v1.1 From 1582e05ac78ac46708de84f5d35f79c935febd5b Mon Sep 17 00:00:00 2001 From: meta7 Date: Tue, 10 Aug 2010 09:55:40 -0700 Subject: Fix a nullref issue in the AgentSetAppearance packet handler when removing the physactor from the scene --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3154872..4064339 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1090,12 +1090,17 @@ namespace OpenSim.Region.Framework.Scenes { if (PhysicsActor != null) { - m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; - m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - m_physicsActor.UnSubscribeEvents(); - m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; - PhysicsActor = null; + try + { + m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; + m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; + m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); + m_physicsActor.UnSubscribeEvents(); + PhysicsActor = null; + } + catch + { } } } -- cgit v1.1 From d00a954d35c21581dfb7d06122ae329891bc7103 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 11 Aug 2010 03:09:56 +0200 Subject: Log the state of the prejump flag --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7e83634..7a97669 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -728,6 +728,8 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", true); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); + + m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; -- cgit v1.1 From fa393cb13a6008ed82c13d9f2bcec96dd8e21cae Mon Sep 17 00:00:00 2001 From: meta7 Date: Wed, 11 Aug 2010 13:39:36 -0700 Subject: Fix Omega getting overwritten on startup. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fbe1da9..dd780b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1827,7 +1827,7 @@ namespace OpenSim.Region.Framework.Scenes // which stops client-side interpolation of deactivated joint proxy objects. } - if (!UsePhysics) + if (!UsePhysics && !isNew) { // reset velocity to 0 on physics switch-off. Without that, the client thinks the // prim still has velocity and continues to interpolate its position along the old -- cgit v1.1 From 24577876be9affa844f0361058bd9f93e244bdc0 Mon Sep 17 00:00:00 2001 From: meta7 Date: Wed, 11 Aug 2010 14:10:47 -0700 Subject: Add some console debug to help fix a threadlock issue. --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7a97669..7c89e65 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3335,7 +3335,9 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); } + m_log.Debug("[Scene] Beginning ClientClosed"); m_eventManager.TriggerClientClosed(agentID, this); + m_log.Debug("[Scene] Finished ClientClosed"); } catch (NullReferenceException) { @@ -3343,7 +3345,9 @@ namespace OpenSim.Region.Framework.Scenes // Avatar is already disposed :/ } + m_log.Debug("[Scene] Beginning OnRemovePresence"); m_eventManager.TriggerOnRemovePresence(agentID); + m_log.Debug("[Scene] Finished OnRemovePresence"); ForEachClient( delegate(IClientAPI client) { @@ -3359,8 +3363,11 @@ namespace OpenSim.Region.Framework.Scenes } // Remove the avatar from the scene + m_log.Debug("[Scene] Begin RemoveScenePresence"); m_sceneGraph.RemoveScenePresence(agentID); + m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); m_clientManager.Remove(agentID); + m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); try { @@ -3374,9 +3381,9 @@ namespace OpenSim.Region.Framework.Scenes { m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); } - + m_log.Debug("[Scene] Done. Firing RemoveCircuit"); m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); - + m_log.Debug("[Scene] The avatar has left the building"); //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); } -- cgit v1.1 From b43a731beb24dccf273aefc0e601841ea59b6fd4 Mon Sep 17 00:00:00 2001 From: meta7 Date: Thu, 12 Aug 2010 05:40:41 -0700 Subject: Fix a nullref exception in the prioritizer --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 8cd0160..c6db7af 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -134,6 +134,7 @@ namespace OpenSim.Region.Framework.Scenes private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) { + if (entity == null) return double.NaN; ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { @@ -144,7 +145,17 @@ namespace OpenSim.Region.Framework.Scenes // Use group position for child prims Vector3 entityPos = entity.AbsolutePosition; if (entity is SceneObjectPart) - entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; + { + SceneObjectGroup group = m_scene.GetGroupByPrim(entity.LocalId); + if (group == null) + { + entityPos = entity.AbsolutePosition; + } + else + { + entityPos = group.AbsolutePosition; + } + } else entityPos = entity.AbsolutePosition; -- cgit v1.1 From a32b0ce0ae28ff42d30e25530dc286401188b89c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 14 Aug 2010 13:59:36 +0200 Subject: Fix a possible nullref in BestAvatarResponsiveness policy --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 8cd0160..7c3746b 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -186,9 +186,9 @@ namespace OpenSim.Region.Framework.Scenes return 0.0; // Use group position for child prims - Vector3 entityPos = entity.AbsolutePosition; + Vector3 entityPos; if (entity is SceneObjectPart) - entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; + entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition; else entityPos = entity.AbsolutePosition; -- cgit v1.1 From 47838e5fb39596effd4d0f7e1021ab68e69cd9d8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 20 Aug 2010 08:46:46 +0200 Subject: Add some maptile options, change maptile generation from OpenSimBase to Scene to make it more configurable. --- OpenSim/Region/Framework/Scenes/Scene.cs | 61 +++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 73472a9..98c46bd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -411,6 +411,9 @@ namespace OpenSim.Region.Framework.Scenes private double m_rootReprioritizationDistance = 10.0; private double m_childReprioritizationDistance = 20.0; + private Timer m_mapGenerationTimer = new Timer(); + bool m_generateMaptiles = false; + #endregion #region Properties @@ -665,6 +668,29 @@ namespace OpenSim.Region.Framework.Scenes m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); + + m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); + if (m_generateMaptiles) + { + int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); + if (maptileRefresh != 0) + { + m_mapGenerationTimer.Interval = maptileRefresh * 1000; + m_mapGenerationTimer.Elapsed += RegenerateMaptile; + m_mapGenerationTimer.AutoReset = true; + m_mapGenerationTimer.Start(); + } + } + else + { + string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); + UUID tileID; + + if (UUID.TryParse(tile, out tileID)) + { + RegionInfo.RegionSettings.TerrainImageID = tileID; + } + } } catch { @@ -1694,16 +1720,21 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.SetScene(this); - // These two 'commands' *must be* next to each other or sim rebooting fails. - //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); - - GridRegion region = new GridRegion(RegionInfo); - string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); - if (error != String.Empty) + // If we generate maptiles internally at all, the maptile generator + // will register the region. If not, do it here + if (m_generateMaptiles) { - throw new Exception(error); + RegenerateMaptile(null, null); + } + else + { + GridRegion region = new GridRegion(RegionInfo); + string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); + if (error != String.Empty) + { + throw new Exception(error); + } } - } #endregion @@ -4995,5 +5026,19 @@ namespace OpenSim.Region.Framework.Scenes return offsets.ToArray(); } + + public void RegenerateMaptile(object sender, ElapsedEventArgs e) + { + IWorldMapModule mapModule = RequestModuleInterface(); + if (mapModule != null) + { + mapModule.GenerateMaptile(); + + string error = GridService.RegisterRegion(RegionInfo.ScopeID, new GridRegion(RegionInfo)); + + if (error != String.Empty) + throw new Exception(error); + } + } } } -- cgit v1.1 From 071edaff491c318ba4164b4c4783e425222dc570 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 22 Aug 2010 13:51:15 +0200 Subject: Suppress error messages about scripts not foind if they're in fact disabled --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index abb4de6..a7003c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -422,6 +422,9 @@ namespace OpenSim.Region.Framework.Scenes public void ResumeScripts() { + if (m_scene.RegionInfo.RegionSettings.DisableScripts) + return; + foreach (SceneObjectPart part in m_parts.Values) { part.Inventory.ResumeScripts(); -- cgit v1.1 From 32ddeab5e37b6ba11eaa8322ad6473b52f21d55b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 22 Aug 2010 14:26:58 +0200 Subject: Add printing the default script engine name. Report real exceptions when there is an issue with the config file, as a typo could cause configuration to silently fail. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 32211c4..957c4e8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -658,6 +658,7 @@ namespace OpenSim.Region.Framework.Scenes m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); + m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) @@ -692,9 +693,9 @@ namespace OpenSim.Region.Framework.Scenes } } } - catch + catch (Exception e) { - m_log.Warn("[SCENE]: Failed to load StartupConfig"); + m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); } #endregion Region Config -- cgit v1.1 From b9e12ed3b7e6f33a824129ce6e79519140a34aa2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 24 Aug 2010 18:20:24 +0200 Subject: Add a method to delete left over / dropped attachments --- OpenSim/Region/Framework/Scenes/Scene.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 957c4e8..d0619d7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5040,5 +5040,37 @@ namespace OpenSim.Region.Framework.Scenes throw new Exception(error); } } + + public void CleanDroppedAttachments() + { + List objectsToDelete = + new List(); + + ForEachSOG(delegate (SceneObjectGroup grp) + { + if (grp.RootPart.Shape.State != 0) + { + UUID agentID = grp.OwnerID; + if (agentID == UUID.Zero) + { + objectsToDelete.Add(grp); + return; + } + + ScenePresence sp = GetScenePresence(agentID); + if (sp == null) + { + objectsToDelete.Add(grp); + return; + } + } + }); + + foreach (SceneObjectGroup grp in objectsToDelete) + { + m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); + DeleteSceneObject(grp, true); + } + } } } -- cgit v1.1 From 512a13dbe7a8dfa36a662f64caf573f467173b95 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 24 Aug 2010 18:52:00 +0200 Subject: Call the Cleanup when an agent logs out, when an agent leaves and just before an agent logs in directly. Intentionally not calling this from MakeRoot as that would mess up attachment transfer in teleport --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d0619d7..6452dfe 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3199,6 +3199,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[Scene] Beginning ClientClosed"); m_eventManager.TriggerClientClosed(agentID, this); m_log.Debug("[Scene] Finished ClientClosed"); + CleanDroppedAttachments(); } catch (NullReferenceException) { @@ -3442,6 +3443,8 @@ namespace OpenSim.Region.Framework.Scenes if (vialogin) { + CleanDroppedAttachments(); + if (TestBorderCross(agent.startpos, Cardinals.E)) { Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); -- cgit v1.1 From 4e324ae3cbf5c4ce16900bd5e57d8671c1de0cfc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 24 Aug 2010 19:07:42 +0200 Subject: Call the cleanup after saving attachment states, so that the attachments don't get killed before they can be saved --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6452dfe..37d797e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3199,7 +3199,6 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[Scene] Beginning ClientClosed"); m_eventManager.TriggerClientClosed(agentID, this); m_log.Debug("[Scene] Finished ClientClosed"); - CleanDroppedAttachments(); } catch (NullReferenceException) { @@ -3210,6 +3209,9 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[Scene] Beginning OnRemovePresence"); m_eventManager.TriggerOnRemovePresence(agentID); m_log.Debug("[Scene] Finished OnRemovePresence"); + + CleanDroppedAttachments(); + ForEachClient( delegate(IClientAPI client) { -- cgit v1.1 From 314d1171efd6d45686ad54944e9bf53ec8cd0b7f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 25 Aug 2010 16:06:06 +0200 Subject: Lock the attachment cleanup so it doesn't go into an endless deletion frenzy --- OpenSim/Region/Framework/Scenes/Scene.cs | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 37d797e..2324f7a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -399,6 +399,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_firstHeartbeat = true; private object m_deleting_scene_object = new object(); + private object m_cleaningAttachments = new object(); // the minimum time that must elapse before a changed object will be considered for persisted public long m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE * 10000000L; @@ -5051,26 +5052,29 @@ namespace OpenSim.Region.Framework.Scenes List objectsToDelete = new List(); - ForEachSOG(delegate (SceneObjectGroup grp) - { - if (grp.RootPart.Shape.State != 0) + lock (m_cleaningAttachments) + { + ForEachSOG(delegate (SceneObjectGroup grp) { - UUID agentID = grp.OwnerID; - if (agentID == UUID.Zero) + if (grp.RootPart.Shape.State != 0 || objectsToDelete.Contains(grp)) { - objectsToDelete.Add(grp); - return; + UUID agentID = grp.OwnerID; + if (agentID == UUID.Zero) + { + objectsToDelete.Add(grp); + return; + } + + ScenePresence sp = GetScenePresence(agentID); + if (sp == null) + { + objectsToDelete.Add(grp); + return; + } } + }); + } - ScenePresence sp = GetScenePresence(agentID); - if (sp == null) - { - objectsToDelete.Add(grp); - return; - } - } - }); - foreach (SceneObjectGroup grp in objectsToDelete) { m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); -- cgit v1.1 From c13045b25e6424c90642613d400ab6ebf2744064 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 25 Aug 2010 20:11:47 +0200 Subject: Correct a logic error in attachment cleanup --- OpenSim/Region/Framework/Scenes/Scene.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2324f7a..c7b38a1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5056,7 +5056,7 @@ namespace OpenSim.Region.Framework.Scenes { ForEachSOG(delegate (SceneObjectGroup grp) { - if (grp.RootPart.Shape.State != 0 || objectsToDelete.Contains(grp)) + if (grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) { UUID agentID = grp.OwnerID; if (agentID == UUID.Zero) @@ -5075,10 +5075,15 @@ namespace OpenSim.Region.Framework.Scenes }); } - foreach (SceneObjectGroup grp in objectsToDelete) + if (objectsToDelete.Count > 0) { - m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); - DeleteSceneObject(grp, true); + m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); + foreach (SceneObjectGroup grp in objectsToDelete) + { + m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); + DeleteSceneObject(grp, true); + } + m_log.Debug("[SCENE]: Finished dropped attachment deletion"); } } } -- cgit v1.1 From dc1baf802545329fc78d5fa36174e27025629527 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 25 Aug 2010 23:11:00 +0200 Subject: Change object cleanup again. Make scene object directories more robust and prevent deleted SOP's from sticking around --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 46 +++++++++++++++++---------- 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c7b38a1..eb5c3cb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3211,8 +3211,6 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager.TriggerOnRemovePresence(agentID); m_log.Debug("[Scene] Finished OnRemovePresence"); - CleanDroppedAttachments(); - ForEachClient( delegate(IClientAPI client) { @@ -3248,6 +3246,7 @@ namespace OpenSim.Region.Framework.Scenes } m_log.Debug("[Scene] Done. Firing RemoveCircuit"); m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); + CleanDroppedAttachments(); m_log.Debug("[Scene] The avatar has left the building"); //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 94ec534..1268259 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -104,7 +104,6 @@ namespace OpenSim.Region.Framework.Scenes protected internal Dictionary SceneObjectGroupsByLocalID = new Dictionary(); protected internal Dictionary SceneObjectGroupsByFullID = new Dictionary(); - private readonly Object m_dictionary_lock = new Object(); private Object m_updateLock = new Object(); @@ -150,11 +149,10 @@ namespace OpenSim.Region.Framework.Scenes m_scenePresencesLock.ExitWriteLock(); } - lock (m_dictionary_lock) - { + lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID.Clear(); + lock (SceneObjectGroupsByLocalID) SceneObjectGroupsByLocalID.Clear(); - } Entities.Clear(); } @@ -385,15 +383,17 @@ namespace OpenSim.Region.Framework.Scenes OnObjectCreate(sceneObject); } - lock (m_dictionary_lock) + lock (SceneObjectGroupsByFullID) { SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; - SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; foreach (SceneObjectPart part in sceneObject.Children.Values) - { SceneObjectGroupsByFullID[part.UUID] = sceneObject; + } + lock (SceneObjectGroupsByLocalID) + { + SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; + foreach (SceneObjectPart part in sceneObject.Children.Values) SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; - } } } @@ -408,24 +408,32 @@ namespace OpenSim.Region.Framework.Scenes { if (Entities.ContainsKey(uuid)) { + SceneObjectGroup grp = (SceneObjectGroup)Entities[uuid]; + if (!resultOfObjectLinked) { m_numPrim -= ((SceneObjectGroup) Entities[uuid]).Children.Count; - if ((((SceneObjectGroup)Entities[uuid]).RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) - { - RemovePhysicalPrim(((SceneObjectGroup)Entities[uuid]).Children.Count); - } + if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) + RemovePhysicalPrim(grp.Children.Count); } if (OnObjectRemove != null) OnObjectRemove(Entities[uuid]); - lock (m_dictionary_lock) + lock (SceneObjectGroupsByFullID) { - SceneObjectGroupsByFullID.Remove(uuid); - SceneObjectGroupsByLocalID.Remove(((SceneObjectGroup)Entities[uuid]).LocalId); + foreach (SceneObjectPart part in grp.Children.Values) + SceneObjectGroupsByFullID.Remove(part.UUID); + SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID); } + lock (SceneObjectGroupsByLocalID) + { + foreach (SceneObjectPart part in grp.Children.Values) + SceneObjectGroupsByLocalID.Remove(part.LocalId); + SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId); + } + Entities.Remove(uuid); //SceneObjectGroup part; //((part.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) @@ -884,7 +892,9 @@ namespace OpenSim.Region.Framework.Scenes { if (SceneObjectGroupsByLocalID.TryGetValue(localID, out sog)) { - return sog; + if (sog.HasChildPrim(localID)) + return sog; + SceneObjectGroupsByLocalID.Remove(localID); } } @@ -920,7 +930,9 @@ namespace OpenSim.Region.Framework.Scenes { if (SceneObjectGroupsByFullID.TryGetValue(fullID, out sog)) { - return sog; + if (sog.Children.ContainsKey(fullID)) + return sog; + SceneObjectGroupsByFullID.Remove(fullID); } } -- cgit v1.1 From 47818a2db303eefaf59f7c98d03112bfb1371379 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 26 Aug 2010 01:06:50 +0200 Subject: Fix a horrible bug in SG, where iteration of scene objects is carried out in a fashion that causes the delegate to be invoked once per child prim for a given group. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 9c5ee60..1d952c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1140,9 +1140,11 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void ForEachSOG(Action action) { - List objlist = new List(SceneObjectGroupsByFullID.Values); - foreach (SceneObjectGroup obj in objlist) + List objlist = Entities.GetAllByType(); + foreach (EntityBase ent in objlist) { + SceneObjectGroup obj = (SceneObjectGroup)ent; + try { action(obj); -- cgit v1.1 From 4cf5ef3cd4c6712f74615385a03217f5d4cecb80 Mon Sep 17 00:00:00 2001 From: meta7 Date: Mon, 30 Aug 2010 11:41:20 -0700 Subject: Kick the user from the region in the circumstance that the TP home failed - ONLY if it was triggered by an estate ban. This makes baby jesus cry, and should be fixed to search for alternative regions if the home region is unavailable. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 957c4e8..736b696 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2985,15 +2985,16 @@ namespace OpenSim.Region.Framework.Scenes /// /// The avatar's Unique ID /// The IClientAPI for the client - public virtual void TeleportClientHome(UUID agentId, IClientAPI client) + public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) { if (m_teleportModule != null) - m_teleportModule.TeleportHome(agentId, client); + return m_teleportModule.TeleportHome(agentId, client); else { m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); client.SendTeleportFailed("Unable to perform teleports on this simulator."); } + return false; } /// -- cgit v1.1 From b973fe52976c909197c360d6afdd62952e3d37ae Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 31 Aug 2010 22:24:11 +0200 Subject: Adjust the "Magic numbers" we use because we can't reference the actual script state enum to reflect recent changes. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 8760c84..ffbf7bf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1993,7 +1993,7 @@ namespace OpenSim.Region.Framework.Scenes // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. - group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); + group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); group.ScheduleGroupForFullUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6a742c1..767d370 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2442,7 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes return false; } - newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); + newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2); newObject.ResumeScripts(); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b86a564..8823df1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1928,7 +1928,7 @@ namespace OpenSim.Region.Framework.Scenes copy.UpdateGroupRotationR(rot); } - copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); + copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); copy.HasGroupChanged = true; copy.ScheduleGroupForFullUpdate(); copy.ResumeScripts(); -- cgit v1.1 From 2232e6f27300032188a7a1eeb77c56e84cd51d66 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 1 Sep 2010 14:08:52 +0200 Subject: Improve sim health reporting. Output error message if heartbeat thread is restarted by scene. This may help to find out why this recovery mechanism isn't working. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b950dbd..a9e6647 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1160,6 +1160,7 @@ namespace OpenSim.Region.Framework.Scenes //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); if (HeartbeatThread != null) { + m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); HeartbeatThread.Abort(); HeartbeatThread = null; } @@ -4555,7 +4556,7 @@ namespace OpenSim.Region.Framework.Scenes // int health=1; // Start at 1, means we're up - if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) + if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000)) health+=1; else return health; -- cgit v1.1 From 09fba1609493b5ad60ab95fb6db4b368a1833fc3 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 1 Sep 2010 20:10:44 +0200 Subject: Prevent Meta7 plants from being treated like dropped attachments and removed from the sim. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a9e6647..400f4c0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5068,7 +5068,7 @@ namespace OpenSim.Region.Framework.Scenes { ForEachSOG(delegate (SceneObjectGroup grp) { - if (grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) + if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) { UUID agentID = grp.OwnerID; if (agentID == UUID.Zero) -- cgit v1.1 From db015963a9905b1af5d4d1d42a6384b5644a3617 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 2 Sep 2010 14:17:33 +0200 Subject: Remove the annoying "Script saved" popups when saving scripts in task inventory. They cause spam when using recompile scripts in selection and are redundant because that message is also shown in the script window message pane. These popups were a legacy from when we couldn't drive the message pane and their finest hour has now come. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ffbf7bf..0d9682e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -218,8 +218,7 @@ namespace OpenSim.Region.Framework.Scenes // Update item with new asset item.AssetID = asset.FullID; - if (group.UpdateInventoryItem(item)) - remoteClient.SendAgentAlertMessage("Script saved", false); + group.UpdateInventoryItem(item); part.GetProperties(remoteClient); @@ -232,10 +231,6 @@ namespace OpenSim.Region.Framework.Scenes // errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); } - else - { - remoteClient.SendAgentAlertMessage("Script saved", false); - } part.ParentGroup.ResumeScripts(); return errors; } @@ -1401,13 +1396,6 @@ namespace OpenSim.Region.Framework.Scenes { agentTransactions.HandleTaskItemUpdateFromTransaction( remoteClient, part, transactionID, currentItem); - - if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) - remoteClient.SendAgentAlertMessage("Notecard saved", false); - else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) - remoteClient.SendAgentAlertMessage("Script saved", false); - else - remoteClient.SendAgentAlertMessage("Item saved", false); } // Base ALWAYS has move -- cgit v1.1 From eea5d8368acb9a7934e55b6e4b6ccddb40bc5611 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 2 Sep 2010 20:08:39 +0200 Subject: Experimentally comment the sending of unbaked avatars --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd80eb0..2acf8ff 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2806,7 +2806,9 @@ namespace OpenSim.Region.Framework.Scenes m_controllingClient.SendAvatarDataImmediate(this); SendInitialFullUpdateToAllClients(); - SendAppearanceToAllOtherAgents(); + // Experimentally commenting this. We don't have bakes at this time + // and 1.23 will not display an avatar without bakes. + //SendAppearanceToAllOtherAgents(); } /// -- cgit v1.1 From 5ea979d51517b11895a4c5431e3c3c02767a23ac Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 2 Sep 2010 20:51:27 +0200 Subject: Remove commented code and the comment, as the change has proven out --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2acf8ff..604ffad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2806,9 +2806,6 @@ namespace OpenSim.Region.Framework.Scenes m_controllingClient.SendAvatarDataImmediate(this); SendInitialFullUpdateToAllClients(); - // Experimentally commenting this. We don't have bakes at this time - // and 1.23 will not display an avatar without bakes. - //SendAppearanceToAllOtherAgents(); } /// -- cgit v1.1 From 16814dd8f18b51f5dd8841ae341847e117bb83b3 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 2 Sep 2010 21:51:19 +0000 Subject: Fixes to JUMP system. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 151 ++++++++++++++++----- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 66 ++++++--- 2 files changed, 163 insertions(+), 54 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index b847d87..99d9564 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -58,7 +58,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation private int m_animTickFall; // private int m_animTickJump; public int m_animTickJump; // ScenePresence has to see this to control +Z force - + public bool m_jumping = false; // Add for jumping + public float m_jumpVelocity = 0f; // Add for jumping + private int m_landing = 0; // Add for jumping + /// /// The scene presence that this animator applies to /// @@ -141,9 +144,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public string GetMovementAnimation() { +//Console.WriteLine("GMA-------"); //## const float FALL_DELAY = 0.33f; - const float PREJUMP_DELAY = 0.25f; - +//rm for jumping const float PREJUMP_DELAY = 0.25f; + const float PREJUMP_DELAY = 200f; // mS add for jumping + const float JUMP_PERIOD = 800f; // mS add for jumping #region Inputs AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; @@ -177,8 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Is the avatar trying to move? // bool moving = (move != Vector3.Zero); - bool jumping = m_animTickJump != 0; - +// rm for jumping bool jumping = m_animTickJump != 0; #endregion Inputs #region Flying @@ -187,6 +191,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation { m_animTickFall = 0; m_animTickJump = 0; + m_jumping = false; //add for jumping flag + m_jumpVelocity = 0f; //add for jumping flag + actor.Selected = false; //add for jumping flag if (move.X != 0f || move.Y != 0f) { @@ -213,8 +220,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Falling/Floating/Landing - if (actor == null || !actor.IsColliding) +// rm for jumping if (actor == null || !actor.IsColliding) + if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping { +//Console.WriteLine("FFL"); //## float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; @@ -223,7 +232,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Just started falling m_animTickFall = Environment.TickCount; } - else if (!jumping && fallElapsed > FALL_DELAY) +// else if (!jumping && fallElapsed > FALL_DELAY) + else if (!m_jumping && fallElapsed > FALL_DELAY) // add for jumping { // Falling long enough to trigger the animation return "FALLDOWN"; @@ -234,6 +244,67 @@ namespace OpenSim.Region.Framework.Scenes.Animation #endregion Falling/Floating/Landing + + #region Jumping // section added for jumping... + + Vector3 vj = Vector3.Zero; + int jumptime; + jumptime = Environment.TickCount - m_animTickJump; + + + if ((move.Z > 0f) && (!m_jumping)) + { +//Console.WriteLine("PJ {0}", jumptime); //## + // Start jumping, prejump + m_animTickFall = 0; + m_jumping = true; + actor.Selected = true; // borrowed for jmping flag + m_animTickJump = Environment.TickCount; + vj.Z = 0.35f; +m_jumpVelocity = 0.35f; + vj += actor.Velocity; +// #@ actor.Velocity = vj; + return "PREJUMP"; + } + + if(m_jumping) + { + if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) + { +//Console.WriteLine("LA {0}", jumptime); //## + // end jumping + m_jumping = false; + actor.Selected = false; // borrowed for jumping flag +m_jumpVelocity = 0f; + m_animTickFall = Environment.TickCount; + return "LAND"; + } + else if (jumptime > JUMP_PERIOD) + { +//Console.WriteLine("JD {0}", jumptime); //## + // jump down + vj = actor.Velocity; + vj.Z = 0f; +m_jumpVelocity = 0f; +// #@ actor.Velocity = vj; + return "JUMP"; + } + else if (jumptime > PREJUMP_DELAY) + { +//Console.WriteLine("JU {0}", jumptime); //## + // jump up + m_jumping = true; + vj.Z = 10f; +m_jumpVelocity = 10f; + vj.X = actor.Velocity.X; + vj.Y = actor.Velocity.Y; +// #@ actor.Velocity = vj; + return "JUMP"; + } + } + + #endregion Jumping // end added section + #region Ground Movement if (m_movementAnimation == "FALLDOWN") @@ -245,11 +316,26 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (m_movementAnimation == "LAND") { - float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) +// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping +// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) +/* Try change ## + if ((m_animTickFall != 0) && (landElapsed <= 500)) // add for jumping + return "LAND"; + */ + // NB if this is set too long a weird anim reset from some place prevents STAND from being sent to client + if ((m_animTickFall != 0) && (landElapsed <= 300)) // add for jumping + { +//Console.WriteLine("LAND"); //## return "LAND"; + } + else + { +//Console.WriteLine("STAND"); //## + return "STAND"; + } } - +/* This section removed, replaced by jumping section m_animTickFall = 0; if (move.Z > 0f) @@ -279,27 +365,28 @@ namespace OpenSim.Region.Framework.Scenes.Animation { // Not jumping m_animTickJump = 0; - - if (move.X != 0f || move.Y != 0f) - { - // Walking / crouchwalking / running - if (move.Z < 0f) - return "CROUCHWALK"; - else if (m_scenePresence.SetAlwaysRun) - return "RUN"; - else - return "WALK"; - } + */ + // next section moved outside paren. and realigned for jumping + if (move.X != 0f || move.Y != 0f) + { + // Walking / crouchwalking / running + if (move.Z < 0f) + return "CROUCHWALK"; + else if (m_scenePresence.SetAlwaysRun) + return "RUN"; else - { - // Not walking - if (move.Z < 0f) - return "CROUCH"; - else - return "STAND"; - } + return "WALK"; } - +// rm for jumping else + else if (!m_jumping) // add for jumping + { + // Not walking + if (move.Z < 0f) + return "CROUCH"; + else + return "STAND"; + } + // end section realign for jumping #endregion Ground Movement return m_movementAnimation; @@ -311,15 +398,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void UpdateMovementAnimations() { m_movementAnimation = GetMovementAnimation(); - if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) +/* if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) { // This was the previous behavior before PREJUMP TrySetMovementAnimation("JUMP"); } else - { + { removed for jumping */ TrySetMovementAnimation(m_movementAnimation); - } +// rm for jumping } } public UUID[] GetAnimationArray() diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd80eb0..f682ee5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1471,6 +1471,9 @@ namespace OpenSim.Region.Framework.Scenes if (actor.Flying != oldflying) update_movementflag = true; + if (m_animator.m_jumping) // add for jumping + update_movementflag = true; + if (q != m_bodyRot) { m_bodyRot = q; @@ -2580,6 +2583,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop FLying"); //} } + /* This jumping section removed to SPA else if (!actor.Flying && actor.IsColliding) { if (direc.Z > 2.0f) @@ -2592,12 +2596,12 @@ namespace OpenSim.Region.Framework.Scenes { direc.Z *= 0.1f; // prejump } - /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs + / * Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs Animator.TrySetMovementAnimation("PREJUMP"); Animator.TrySetMovementAnimation("JUMP"); - */ + * / } - } + } */ } // TODO: Add the force instead of only setting it to support multiple forces per frame? @@ -3543,28 +3547,46 @@ namespace OpenSim.Region.Framework.Scenes /// public override void UpdateMovement() { - if (m_forceToApply.HasValue) - { + if (Animator!=null) // add for jumping + { // add for jumping + // if (!m_animator.m_jumping) // add for jumping + // { // add for jumping - Vector3 force = m_forceToApply.Value; - m_updateflag = true; - Velocity = force; + if (m_forceToApply.HasValue) // this section realigned + { - m_forceToApply = null; - } - else - { - if (m_isNudging) - { - Vector3 force = Vector3.Zero; + Vector3 force = m_forceToApply.Value; + m_updateflag = true; +if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping + Velocity = force; +//Console.WriteLine("UM1 {0}", Velocity); + m_forceToApply = null; + } + else + { + if (m_isNudging) + { + Vector3 force = Vector3.Zero; + + m_updateflag = true; +if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping + Velocity = force; +//Console.WriteLine("UM2 {0}", Velocity); + m_isNudging = false; + m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" + } + else // add for jumping + { // add for jumping + Vector3 force = Vector3.Zero; // add for jumping +if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping +//Console.WriteLine("UM3 {0}", Velocity); + Velocity = force; // add for jumping + } - m_updateflag = true; - Velocity = force; - m_isNudging = false; - m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" - } - } - } + } + // } // end realign + } // add for jumping + } // add for jumping /// /// Adds a physical representation of the avatar to the Physics plugin -- cgit v1.1 From 457160afc3cc0878b068486a7cbb8a41a5f18520 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 3 Sep 2010 03:16:08 +0200 Subject: Fix an issue with rezzing scripted objects. --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index c5994b2..1959427 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) { - if (stateSource == 1 && // Prim crossing + if (stateSource == 2 && // Prim crossing m_part.ParentGroup.Scene.m_trustBinaries) { m_items.LockItemsForWrite(true); @@ -1263,4 +1263,4 @@ namespace OpenSim.Region.Framework.Scenes Items.LockItemsForRead(false); } } -} \ No newline at end of file +} -- cgit v1.1 From 00a23eea0ec5d3607cf9cd021a3a182da258686e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 6 Sep 2010 03:59:48 +0200 Subject: Reflect the ParcelPropertiesUpdateRequest into Scene.EventManager, because modules need to see it (Search!) even if it comes in via CAPS --- OpenSim/Region/Framework/Scenes/EventManager.cs | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 52e6e92..d4e2736 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -113,6 +113,8 @@ namespace OpenSim.Region.Framework.Scenes public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; + public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; + /// /// Fired when an object is touched/grabbed. /// @@ -2128,5 +2130,27 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args, + int local_id, IClientAPI remote_client) + { + ParcelPropertiesUpdateRequest handler = OnParcelPropertiesUpdateRequest; + if (handler != null) + { + foreach (ParcelPropertiesUpdateRequest d in handler.GetInvocationList()) + { + try + { + d(args, local_id, remote_client); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerOnSceneObjectPartCopy failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } } -} \ No newline at end of file +} -- cgit v1.1 From f4f9a2cb4590fe56e672242b4c5697078785e793 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 6 Sep 2010 18:14:24 +0200 Subject: Don't turn off the sale settings on child prims when linking, and on copy of prims anymore. The behavior now matches SL and can be used to link vendor prims for transport --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 8823df1..86842b3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1619,11 +1619,6 @@ namespace OpenSim.Region.Framework.Scenes if (child != null) { - // Make sure no child prim is set for sale - // So that, on delink, no prims are unwittingly - // left for sale and sold off - child.RootPart.ObjectSaleType = 0; - child.RootPart.SalePrice = 10; childGroups.Add(child); } } @@ -1907,9 +1902,6 @@ namespace OpenSim.Region.Framework.Scenes child.ApplyNextOwnerPermissions(); } } - - copy.RootPart.ObjectSaleType = 0; - copy.RootPart.SalePrice = 10; } Entities.Add(copy); -- cgit v1.1 From c719e016ed9bfbb56fd8c571b9b7b9622bcef566 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Mon, 6 Sep 2010 21:45:07 +0000 Subject: Falling animation fix, comment out instrumentation. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 95 +++++++++++++--------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- 2 files changed, 61 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 99d9564..9658e11 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -61,6 +61,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public bool m_jumping = false; // Add for jumping public float m_jumpVelocity = 0f; // Add for jumping private int m_landing = 0; // Add for jumping + public bool m_falling = false; // Add for falling + private float m_fallHeight; // Add for falling /// /// The scene presence that this animator applies to @@ -118,7 +120,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void ResetAnimations() { +Console.WriteLine("ResetA............."); m_animations.Clear(); +TrySetMovementAnimation("STAND"); } /// @@ -145,7 +149,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public string GetMovementAnimation() { //Console.WriteLine("GMA-------"); //## - const float FALL_DELAY = 0.33f; +//#@ const float FALL_DELAY = 0.33f; + const float FALL_DELAY = 800f; //## mS //rm for jumping const float PREJUMP_DELAY = 0.25f; const float PREJUMP_DELAY = 200f; // mS add for jumping const float JUMP_PERIOD = 800f; // mS add for jumping @@ -191,9 +196,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation { m_animTickFall = 0; m_animTickJump = 0; - m_jumping = false; //add for jumping flag - m_jumpVelocity = 0f; //add for jumping flag + m_jumping = false; //add for jumping + m_falling = true; //add for falling + m_jumpVelocity = 0f; //add for jumping actor.Selected = false; //add for jumping flag + m_fallHeight = actor.Position.Z; // save latest flying height if (move.X != 0f || move.Y != 0f) { @@ -205,8 +212,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (move.Z < 0f) { - if (actor != null && actor.IsColliding) + if (actor != null && actor.IsColliding) + { //## +//Console.WriteLine("LAND FLYING"); // ## return "LAND"; + } //# else return "HOVER_DOWN"; } @@ -223,19 +233,25 @@ namespace OpenSim.Region.Framework.Scenes.Animation // rm for jumping if (actor == null || !actor.IsColliding) if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping { -//Console.WriteLine("FFL"); //## - float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; +// rm float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + float fallElapsed = (float)(Environment.TickCount - m_animTickFall); // add, in mS float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; +//Console.WriteLine("falling t={0} v={1}", fallElapsed, fallVelocity); //## - if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) +// rm for fall if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) + if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; // add for falling and jumping + + if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) // add for jumping + // not falling yet or going up { - // Just started falling + // reset start of fall time m_animTickFall = Environment.TickCount; } // else if (!jumping && fallElapsed > FALL_DELAY) - else if (!m_jumping && fallElapsed > FALL_DELAY) // add for jumping + else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) ) // add for falling and jumping { // Falling long enough to trigger the animation +//Console.WriteLine("FALLDOWN"); //## return "FALLDOWN"; } @@ -247,7 +263,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Jumping // section added for jumping... - Vector3 vj = Vector3.Zero; int jumptime; jumptime = Environment.TickCount - m_animTickJump; @@ -258,12 +273,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Start jumping, prejump m_animTickFall = 0; m_jumping = true; + m_falling = false; actor.Selected = true; // borrowed for jmping flag m_animTickJump = Environment.TickCount; - vj.Z = 0.35f; -m_jumpVelocity = 0.35f; - vj += actor.Velocity; -// #@ actor.Velocity = vj; + m_jumpVelocity = 0.35f; return "PREJUMP"; } @@ -274,8 +287,9 @@ m_jumpVelocity = 0.35f; //Console.WriteLine("LA {0}", jumptime); //## // end jumping m_jumping = false; + m_falling = false; actor.Selected = false; // borrowed for jumping flag -m_jumpVelocity = 0f; + m_jumpVelocity = 0f; m_animTickFall = Environment.TickCount; return "LAND"; } @@ -283,10 +297,7 @@ m_jumpVelocity = 0f; { //Console.WriteLine("JD {0}", jumptime); //## // jump down - vj = actor.Velocity; - vj.Z = 0f; -m_jumpVelocity = 0f; -// #@ actor.Velocity = vj; + m_jumpVelocity = 0f; return "JUMP"; } else if (jumptime > PREJUMP_DELAY) @@ -294,11 +305,7 @@ m_jumpVelocity = 0f; //Console.WriteLine("JU {0}", jumptime); //## // jump up m_jumping = true; - vj.Z = 10f; -m_jumpVelocity = 10f; - vj.X = actor.Velocity.X; - vj.Y = actor.Velocity.Y; -// #@ actor.Velocity = vj; + m_jumpVelocity = 10f; return "JUMP"; } } @@ -309,29 +316,37 @@ m_jumpVelocity = 10f; if (m_movementAnimation == "FALLDOWN") { + m_falling = false; m_animTickFall = Environment.TickCount; - // TODO: SOFT_LAND support - return "LAND"; + float fallHeight = m_fallHeight - actor.Position.Z; +//Console.WriteLine("Hit from {0}", fallHeight); //## + if (fallHeight > 15.0f) // add for falling + return "STANDUP"; + else if (fallHeight > 8.0f) // add for falling + return "SOFT_LAND"; // add for falling + else // add for falling + return "LAND"; // add for falling } - else if (m_movementAnimation == "LAND") - { // rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping // rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) -/* Try change ## - if ((m_animTickFall != 0) && (landElapsed <= 500)) // add for jumping - return "LAND"; - */ - // NB if this is set too long a weird anim reset from some place prevents STAND from being sent to client - if ((m_animTickFall != 0) && (landElapsed <= 300)) // add for jumping +// rm for landing return "LAND"; + else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) + { + int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping + int limit = 1000; // add for jumping + if(m_movementAnimation == "LAND") limit = 350; // add for jumping + // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client + + if ((m_animTickFall != 0) && (landElapsed <= limit)) // add for jumping { -//Console.WriteLine("LAND"); //## - return "LAND"; +//Console.WriteLine("Lelapse {0}", m_movementAnimation); //## + return m_movementAnimation; } else { -//Console.WriteLine("STAND"); //## +//Console.WriteLine("end/STAND"); //## + m_fallHeight = actor.Position.Z; // save latest flying height return "STAND"; } } @@ -369,6 +384,8 @@ m_jumpVelocity = 10f; // next section moved outside paren. and realigned for jumping if (move.X != 0f || move.Y != 0f) { + m_fallHeight = actor.Position.Z; // save latest flying height + m_falling = false; // Add for falling // Walking / crouchwalking / running if (move.Z < 0f) return "CROUCHWALK"; @@ -380,6 +397,7 @@ m_jumpVelocity = 10f; // rm for jumping else else if (!m_jumping) // add for jumping { + m_falling = false; // Add for falling // Not walking if (move.Z < 0f) return "CROUCH"; @@ -389,6 +407,7 @@ m_jumpVelocity = 10f; // end section realign for jumping #endregion Ground Movement + m_falling = false; // Add for falling return m_movementAnimation; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2ed00a0..faf6354 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2568,9 +2568,11 @@ namespace OpenSim.Region.Framework.Scenes if (actor != null) { - if (actor.Flying) +// rm falling if (actor.Flying) + if ((actor.Flying) || Animator.m_falling) // add for falling lateral speed { - direc *= 4.0f; +// rm speed mod direc *= 4.0f; + direc *= 5.2f; // for speed mod //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); //bool colliding = (m_physicsActor.IsColliding==true); //if (controlland) -- cgit v1.1 From 8ab4b277c1e1d5470a0322ec49dde665f3cceadc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 7 Sep 2010 17:12:28 +0200 Subject: Fix some issues with unlinking --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 109 +++++++++++++------------- 1 file changed, 53 insertions(+), 56 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 905c683..a39f27a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1678,28 +1678,23 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) + { + group.areUpdatesSuspended = true; affectedGroups.Add(group); + } } } } if (childParts.Count > 0) { - try + foreach (SceneObjectPart child in childParts) { - childParts[0].ParentGroup.areUpdatesSuspended = true; - foreach (SceneObjectPart child in childParts) - { - // Unlink all child parts from their groups - // - child.ParentGroup.DelinkFromGroup(child, true); - child.ParentGroup.HasGroupChanged = true; - child.ParentGroup.ScheduleGroupForFullUpdate(); - } - } - finally - { - childParts[0].ParentGroup.areUpdatesSuspended = false; + // Unlink all child parts from their groups + // + child.ParentGroup.DelinkFromGroup(child, true); + child.ParentGroup.HasGroupChanged = true; + child.ParentGroup.ScheduleGroupForFullUpdate(); } } @@ -1710,9 +1705,10 @@ namespace OpenSim.Region.Framework.Scenes // However, editing linked parts and unlinking may be different // SceneObjectGroup group = root.ParentGroup; + group.areUpdatesSuspended = true; List newSet = null; - int numChildren = -1; + int numChildren; lock (group.Children) { @@ -1720,63 +1716,63 @@ namespace OpenSim.Region.Framework.Scenes numChildren = group.PrimCount; } + if (numChildren == 1) + break; + // If there are prims left in a link set, but the root is // slated for unlink, we need to do this + // Unlink the remaining set // - if (numChildren != 1) - { - // Unlink the remaining set - // - bool sendEventsToRemainder = true; - if (numChildren > 1) - sendEventsToRemainder = false; + bool sendEventsToRemainder = true; + if (numChildren > 1) + sendEventsToRemainder = false; - if (newSet.Count > 0) + foreach (SceneObjectPart p in newSet) + { + if (p != group.RootPart) { - try + group.DelinkFromGroup(p, sendEventsToRemainder); + if (numChildren > 2) { - newSet[0].ParentGroup.areUpdatesSuspended = true; - foreach (SceneObjectPart p in newSet) - { - if (p != group.RootPart) - group.DelinkFromGroup(p, sendEventsToRemainder); - } + p.ParentGroup.areUpdatesSuspended = true; } - finally + else { - newSet[0].ParentGroup.areUpdatesSuspended = false; + p.ParentGroup.HasGroupChanged = true; + p.ParentGroup.ScheduleGroupForFullUpdate(); } } + } + + // If there is more than one prim remaining, we + // need to re-link + // + if (numChildren > 2) + { + // Remove old root + // + if (newSet.Contains(root)) + newSet.Remove(root); - // If there is more than one prim remaining, we - // need to re-link + // Preserve link ordering // - if (numChildren > 2) + newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) { - // Remove old root - // - if (newSet.Contains(root)) - newSet.Remove(root); - - // Preserve link ordering - // - newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) - { - return a.LinkNum.CompareTo(b.LinkNum); - }); + return a.LinkNum.CompareTo(b.LinkNum); + }); - // Determine new root - // - SceneObjectPart newRoot = newSet[0]; - newSet.RemoveAt(0); + // Determine new root + // + SceneObjectPart newRoot = newSet[0]; + newSet.RemoveAt(0); - foreach (SceneObjectPart newChild in newSet) - newChild.UpdateFlag = 0; + foreach (SceneObjectPart newChild in newSet) + newChild.UpdateFlag = 0; - LinkObjects(newRoot, newSet); - if (!affectedGroups.Contains(newRoot.ParentGroup)) - affectedGroups.Add(newRoot.ParentGroup); - } + newRoot.ParentGroup.areUpdatesSuspended = true; + LinkObjects(newRoot, newSet); + if (!affectedGroups.Contains(newRoot.ParentGroup)) + affectedGroups.Add(newRoot.ParentGroup); } } @@ -1786,6 +1782,7 @@ namespace OpenSim.Region.Framework.Scenes { g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist + g.areUpdatesSuspended = false; g.ScheduleGroupForFullUpdate(); } } -- cgit v1.1 From 7a1b1dd419d458cbf46ecdf48872497186e67355 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 8 Sep 2010 00:49:32 +0200 Subject: Make AddRestoredSceneObject reset the IsDeleted flag so we can take an object out of the scene and then put it back in. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6b71426..be342ab 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2003,7 +2003,10 @@ namespace OpenSim.Region.Framework.Scenes public bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) { - return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); + bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); + if (result) + sceneObject.IsDeleted = false; + return result; } /// -- cgit v1.1 From d299f8b55cb0e3848dbcbb941a5789d52459bc44 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 14 Sep 2010 19:41:53 +0200 Subject: Fix a small left over buglet and also add checking of the physics actor position on backup. This way, ant object that has been moved will be checked for ghost prims as soon as it is persisted. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a952508..37630e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1786,6 +1786,16 @@ namespace OpenSim.Region.Framework.Scenes // don't backup while it's selected or you're asking for changes mid stream. if (isTimeToPersist() || forcedBackup) { + if (m_rootPart.PhysActor != null && + (!m_rootPart.PhysActor.IsPhysical)) + { + if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) + { + m_rootPart.PhysActor.Position = m_rootPart.GroupPosition; + m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; + m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + } + } // m_log.DebugFormat( // "[SCENE]: Storing {0}, {1} in {2}", // Name, UUID, m_scene.RegionInfo.RegionName); -- cgit v1.1 From cc290abf7a2bd651205e8978a095cb83ffeddcf7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 14 Sep 2010 22:13:44 +0200 Subject: Adjust the code for ghost prim removal to new information from Kitto --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 37630e0..e933e77 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1789,11 +1789,15 @@ namespace OpenSim.Region.Framework.Scenes if (m_rootPart.PhysActor != null && (!m_rootPart.PhysActor.IsPhysical)) { + // Possible ghost prim if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) { - m_rootPart.PhysActor.Position = m_rootPart.GroupPosition; - m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; - m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + foreach (SceneObjectPart part in Children.Values) + { + // Re-set physics actor positions and + // orientations + part.GroupPosition = m_rootPart.GroupPosition; + } } } // m_log.DebugFormat( -- cgit v1.1 From 2f41bc4ca738cd27730639c8cd49a154404c6a82 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Sep 2010 22:14:08 +0100 Subject: Fix merge issues --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index abec699..12c7fea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1348,15 +1348,12 @@ namespace OpenSim.Region.Framework.Scenes if (m_frame % m_update_presences == 0) m_sceneGraph.UpdatePresences(); -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/Scene.cs // Update SceneObjectGroups that have scheduled themselves for updates // Objects queue their updates onto all scene presences if (m_frame % m_update_objects == 0) m_sceneGraph.UpdateObjectGroups(); -======= // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) ->>>>>>> master:OpenSim/Region/Framework/Scenes/Scene.cs if (m_frame % m_update_coarse_locations == 0) { List coarseLocations; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index caf376b..ed92d86 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4330,8 +4330,8 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju } m_log.InfoFormat( - "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", - p, itemID, assetID, asset); + "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {3}", + p, itemID, asset); } catch (Exception e) { -- cgit v1.1 From e27f59cf422e4afef1b76af29d49f2c2770e3281 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Sep 2010 22:15:16 +0100 Subject: reorder some code to avoid merge issues in the future --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 12c7fea..ac2246c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1343,16 +1343,16 @@ namespace OpenSim.Region.Framework.Scenes // Check if any objects have reached their targets CheckAtTargets(); - // Run through all ScenePresences looking for updates - // Presence updates and queued object updates for each presence are sent to clients - if (m_frame % m_update_presences == 0) - m_sceneGraph.UpdatePresences(); - // Update SceneObjectGroups that have scheduled themselves for updates // Objects queue their updates onto all scene presences if (m_frame % m_update_objects == 0) m_sceneGraph.UpdateObjectGroups(); + // Run through all ScenePresences looking for updates + // Presence updates and queued object updates for each presence are sent to clients + if (m_frame % m_update_presences == 0) + m_sceneGraph.UpdatePresences(); + // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) if (m_frame % m_update_coarse_locations == 0) { -- cgit v1.1 From 1f74f013b23a8bbcc94d79aa57d35e1929b662d6 Mon Sep 17 00:00:00 2001 From: meta7 Date: Wed, 15 Sep 2010 07:59:28 -0700 Subject: Don't fart when deserializing a prim with no ParentGroup set yet --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2de439b..a9a5c8a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -132,7 +132,11 @@ namespace OpenSim.Region.Framework.Scenes } HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + if (m_part.ParentGroup != null) + { + m_part.ParentGroup.HasGroupChanged = true; + } + IList items = new List(Items.Values); Items.Clear(); -- cgit v1.1 From ec89dc99b705f86fb4ed2f984125c2196d8c6288 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Sep 2010 18:58:25 +0200 Subject: Some small bug fixes --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3411d18..142f5d8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Xml; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ed92d86..8da9bdc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4330,7 +4330,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju } m_log.InfoFormat( - "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {3}", + "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2}", p, itemID, asset); } catch (Exception e) -- cgit v1.1 From a0c87b5af6bba104fe50de3006b5dd515a8eb833 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Sep 2010 23:12:32 +0200 Subject: JustinCC is evil. f7b28dd3 broke script persistence. This fixes it. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++- .../Framework/Scenes/SceneObjectPartInventory.cs | 28 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 142f5d8..ab9cbd7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -696,6 +696,7 @@ namespace OpenSim.Region.Framework.Scenes if (node.Attributes["UUID"] != null) { UUID itemid = new UUID(node.Attributes["UUID"].Value); + m_log.DebugFormat("[SCRIPT STATE]: Adding state for oldID {0}", itemid); m_savedScriptState.Add(itemid, node.InnerXml); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5c4a2a3..40112c9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -514,7 +514,7 @@ namespace OpenSim.Region.Framework.Scenes // This is necessary so that TaskInventoryItem parent ids correctly reference the new uuid of this part if (Inventory != null) - Inventory.ResetInventoryIDs(); + Inventory.ResetObjectID(); } } @@ -2800,6 +2800,7 @@ namespace OpenSim.Region.Framework.Scenes UUID = UUID.Random(); LinkNum = linkNum; LocalId = 0; + Inventory.ResetInventoryIDs(); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a9a5c8a..b205503 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -148,6 +148,34 @@ namespace OpenSim.Region.Framework.Scenes m_items.LockItemsForWrite(false); } + public void ResetObjectID() + { + m_items.LockItemsForWrite(true); + + if (Items.Count == 0) + { + m_items.LockItemsForWrite(false); + return; + } + + HasInventoryChanged = true; + if (m_part.ParentGroup != null) + { + m_part.ParentGroup.HasGroupChanged = true; + } + + IList items = new List(Items.Values); + Items.Clear(); + + foreach (TaskInventoryItem item in items) + { + item.ParentPartID = m_part.UUID; + item.ParentID = m_part.UUID; + Items.Add(item.ItemID, item); + } + m_items.LockItemsForWrite(false); + } + /// /// Change every item in this inventory to a new owner. /// -- cgit v1.1 From 1e4e978f7ff798292211c58ef07eee37cd76ef8e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Sep 2010 23:26:53 +0200 Subject: Removing debug --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ab9cbd7..142f5d8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -696,7 +696,6 @@ namespace OpenSim.Region.Framework.Scenes if (node.Attributes["UUID"] != null) { UUID itemid = new UUID(node.Attributes["UUID"].Value); - m_log.DebugFormat("[SCRIPT STATE]: Adding state for oldID {0}", itemid); m_savedScriptState.Add(itemid, node.InnerXml); } } -- cgit v1.1 From 87a1e00f058f737628d50732ffbe46d5d6638779 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Sep 2010 04:00:00 +0200 Subject: Remove the now unused partslock --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3bc7834..f9bfffd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -112,7 +112,6 @@ namespace OpenSim.Region.Framework.Scenes private long m_minPersistTime = 0; private Random m_rand; private bool m_suspendUpdates; - private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); private List m_linkedAvatars = new List(); public bool areUpdatesSuspended -- cgit v1.1 From 9cf8795ecf1a2f34f803babf318d9c1f394ee18b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 19 Sep 2010 22:53:05 +0200 Subject: Fix a merge artefact that broke script state persistence in XAttachments --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f9bfffd..41b0a42 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1029,7 +1029,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { - Dictionary pstates = parts[i].Inventory.GetScriptStates(); + Dictionary pstates = parts[i].Inventory.GetScriptStates(oldIDs); foreach (KeyValuePair kvp in pstates) states.Add(kvp.Key, kvp.Value); } -- cgit v1.1 From 7229bc4fbda804d41525356027269ca9a665b0bf Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Sep 2010 02:08:55 +0200 Subject: Refactor script create permission into the perms module --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ac82fda..18cfcbc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1532,16 +1532,6 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; - if (part.OwnerID != remoteClient.AgentId) - { - // Group permissions - if ((part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0)) - return; - } else { - if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) - return; - } - if (!Permissions.CanCreateObjectInventory( itemBase.InvType, part.UUID, remoteClient.AgentId)) return; -- cgit v1.1 From 1c1f3080526ed3e4845b4e98488d1d0c327dabb3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 24 Sep 2010 23:48:52 +0200 Subject: if you can't edit a prim's inventory, you don't need to see the asset ids. Prevents stealing IDs of animations, sounds and textures from prim inventories. Prevents copybot from gathering the wearable UUIDs needed for pirating things from vendors. --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8aa17a1..9359aea 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -975,6 +975,10 @@ namespace OpenSim.Region.Framework.Scenes // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); + bool includeAssets = false; + if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) + includeAssets = true; + m_items.LockItemsForRead(true); foreach (TaskInventoryItem item in m_items.Values) @@ -1005,7 +1009,10 @@ namespace OpenSim.Region.Framework.Scenes invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); - invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + if (includeAssets) + invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + else + invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); -- cgit v1.1 From 34e8bf45b6f44c7e9c1e8fb824215214f6e9244c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 27 Sep 2010 00:29:27 +0100 Subject: Restrict inventory items added in a transaction to folder belonging to the connected client. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 18cfcbc..9a33993 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -834,6 +834,12 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) return; + InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId); + InventoryFolderBase folder = InventoryService.GetFolder(f); + + if (folder == null || folder.Owner != remoteClient.AgentId) + return; + if (transactionID == UUID.Zero) { ScenePresence presence; -- cgit v1.1 From 41051b3cc68f1b7cf92538bd2affbf4c838f1a1d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 27 Sep 2010 02:11:55 +0100 Subject: Prevent setting arbitrary groups on your objects. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5ef14bf..b61aed5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -590,6 +590,9 @@ namespace OpenSim.Region.Framework.Scenes protected internal void HandleObjectGroupUpdate( IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage) { + if (!remoteClient.IsGroupMember(GroupID)) + return; + SceneObjectGroup group = GetGroupByPrim(objectLocalID); if (group != null) { -- cgit v1.1 From 841c84831fedcfa40e0b0fa9c99990f6754591fa Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 27 Sep 2010 19:34:16 +0200 Subject: Try to prevent threading issues in SP.SetAppearance by locking it --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 85 +++++++++++++----------- 1 file changed, 45 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b3df1ea..ec3f004 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -229,6 +229,8 @@ namespace OpenSim.Region.Framework.Scenes private const int NumMovementsBetweenRayCast = 5; private List m_lastColliders = new List(); + private object m_syncRoot = new Object(); + private bool CameraConstraintActive; //private int m_moveToPositionStateStatus; //***************************************************** @@ -2861,66 +2863,69 @@ namespace OpenSim.Region.Framework.Scenes /// public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) { - if (m_physicsActor != null) + lock (m_syncRoot) { - if (!IsChildAgent) + if (m_physicsActor != null) { - // This may seem like it's redundant, remove the avatar from the physics scene - // just to add it back again, but it saves us from having to update - // 3 variables 10 times a second. - bool flyingTemp = m_physicsActor.Flying; - RemoveFromPhysicalScene(); - //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); + if (!IsChildAgent) + { + // This may seem like it's redundant, remove the avatar from the physics scene + // just to add it back again, but it saves us from having to update + // 3 variables 10 times a second. + bool flyingTemp = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); - //PhysicsActor = null; + //PhysicsActor = null; - AddToPhysicalScene(flyingTemp); + AddToPhysicalScene(flyingTemp); + } } - } - #region Bake Cache Check + #region Bake Cache Check - if (textureEntry != null) - { - for (int i = 0; i < BAKE_INDICES.Length; i++) + if (textureEntry != null) { - int j = BAKE_INDICES[i]; - Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; - - if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + for (int i = 0; i < BAKE_INDICES.Length; i++) { - if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + int j = BAKE_INDICES[i]; + Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; + + if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) { - m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); - this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + { + m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); + this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } } } - } - } + } - #endregion Bake Cache Check + #endregion Bake Cache Check - m_appearance.SetAppearance(textureEntry, visualParams); - if (m_appearance.AvatarHeight > 0) - SetHeight(m_appearance.AvatarHeight); + m_appearance.SetAppearance(textureEntry, visualParams); + if (m_appearance.AvatarHeight > 0) + SetHeight(m_appearance.AvatarHeight); - // This is not needed, because only the transient data changed - //AvatarData adata = new AvatarData(m_appearance); - //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); + // This is not needed, because only the transient data changed + //AvatarData adata = new AvatarData(m_appearance); + //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); - SendAppearanceToAllOtherAgents(); - if (!m_startAnimationSet) - { - Animator.UpdateMovementAnimations(); - m_startAnimationSet = true; - } + SendAppearanceToAllOtherAgents(); + if (!m_startAnimationSet) + { + Animator.UpdateMovementAnimations(); + m_startAnimationSet = true; + } - Vector3 pos = m_pos; - pos.Z += m_appearance.HipOffset; + Vector3 pos = m_pos; + pos.Z += m_appearance.HipOffset; - m_controllingClient.SendAvatarDataImmediate(this); + m_controllingClient.SendAvatarDataImmediate(this); + } } public void SetWearable(int wearableId, AvatarWearable wearable) -- cgit v1.1 From 3d75e9addd50b9416a221282d7e24fc44ebda3a8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 28 Sep 2010 02:22:32 +0200 Subject: Lock the iteration over the inventory items when saving script states --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index c88dda6..522f75e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1241,6 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes if (engines == null) // No engine at all return ret; + Items.LockItemsForRead(true); foreach (TaskInventoryItem item in m_items.Values) { if (item.InvType == (int)InventoryType.LSL) @@ -1268,6 +1269,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + Items.LockItemsForRead(false); return ret; } -- cgit v1.1 From 9522881404e9496cb68d97fae537d60bbfa5233b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 30 Sep 2010 02:46:47 +0200 Subject: Fix a potential key collision --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a9502ed..a00a7c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1035,7 +1035,7 @@ namespace OpenSim.Region.Framework.Scenes { Dictionary pstates = parts[i].Inventory.GetScriptStates(oldIDs); foreach (KeyValuePair kvp in pstates) - states.Add(kvp.Key, kvp.Value); + states[kvp.Key] = kvp.Value; } if (states.Count > 0) -- cgit v1.1 From ac7a4a7d38454c9c2263b54f847b28a5a7567b83 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 30 Sep 2010 02:47:07 +0200 Subject: Fix an inventory fetch issue --- OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 4d97db7..21c36d3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -515,6 +515,9 @@ namespace OpenSim.Region.Framework.Scenes public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { + if (folderID == UUID.Zero) + return; + // FIXME MAYBE: We're not handling sortOrder! // TODO: This code for looking in the folder for the library should be folded somewhere else -- cgit v1.1 From 7ad1b60ecaa64ae693be48df9a32cb93bb22e76f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 30 Sep 2010 20:01:55 +0200 Subject: Enforce region agent limit as set in estate tools --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 5 +++++ 2 files changed, 13 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 240d33c..e835281 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3856,6 +3856,14 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence + int num = m_sceneGraph.GetNumberOfScenePresences(); + + if (num >= RegionInfo.RegionSettings.AgentLimit) + { + if (!Permissions.IsAdministrator(cAgentData.AgentID)) + return false; + } + ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); if (childAgentUpdate != null) { diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b61aed5..1163ebf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -826,6 +826,11 @@ namespace OpenSim.Region.Framework.Scenes return m_scenePresenceArray; } + public int GetNumberOfScenePresences() + { + return m_scenePresenceArray.Count; + } + /// /// Request a scene presence by UUID. Fast, indexed lookup. /// -- cgit v1.1 From 42f76773a15d83fd31f249cc4a21985184b0cdbf Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Oct 2010 19:59:30 +0200 Subject: Plumb the path for multiple object deletes --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 44 +++++----------------- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 8 +++- .../Scenes/Tests/SceneObjectBasicTests.cs | 2 +- 4 files changed, 18 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9a33993..8b5316a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1688,37 +1688,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Called when one or more objects are removed from the environment into inventory. - /// - /// - /// - /// - /// - /// - public virtual void DeRezObject(IClientAPI remoteClient, List localIDs, - UUID groupID, DeRezAction action, UUID destinationID) - { - foreach (uint localID in localIDs) - { - DeRezObject(remoteClient, localID, groupID, action, destinationID); - } - } - - /// - /// Called when an object is removed from the environment into inventory. - /// - /// - /// - /// - /// - /// - public virtual void DeRezObject(IClientAPI remoteClient, uint localID, - UUID groupID, DeRezAction action, UUID destinationID) - { - DeRezObjects(remoteClient, new List() { localID }, groupID, action, destinationID); - } - public virtual void DeRezObjects(IClientAPI remoteClient, List localIDs, UUID groupID, DeRezAction action, UUID destinationID) { @@ -2003,14 +1972,19 @@ namespace OpenSim.Region.Framework.Scenes return group; } - public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) + public virtual bool returnObjects(SceneObjectGroup[] returnobjects, + UUID AgentId) { + List localIDs = new List(); + foreach (SceneObjectGroup grp in returnobjects) { - AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); - DeRezObject(null, grp.RootPart.LocalId, - grp.RootPart.GroupID, DeRezAction.Return, UUID.Zero); + AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, + "parcel owner return"); + localIDs.Add(grp.RootPart.LocalId); } + DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, + UUID.Zero); return true; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e835281..bcc439c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2823,7 +2823,7 @@ namespace OpenSim.Region.Framework.Scenes client.OnGrabUpdate += m_sceneGraph.MoveObject; client.OnSpinStart += m_sceneGraph.SpinStart; client.OnSpinUpdate += m_sceneGraph.SpinObject; - client.OnDeRezObject += DeRezObject; + client.OnDeRezObject += DeRezObjects; client.OnObjectName += m_sceneGraph.PrimName; client.OnObjectClickAction += m_sceneGraph.PrimClickAction; @@ -2953,7 +2953,7 @@ namespace OpenSim.Region.Framework.Scenes client.OnGrabUpdate -= m_sceneGraph.MoveObject; client.OnSpinStart -= m_sceneGraph.SpinStart; client.OnSpinUpdate -= m_sceneGraph.SpinObject; - client.OnDeRezObject -= DeRezObject; + client.OnDeRezObject -= DeRezObjects; client.OnObjectName -= m_sceneGraph.PrimName; client.OnObjectClickAction -= m_sceneGraph.PrimClickAction; client.OnObjectMaterial -= m_sceneGraph.PrimMaterial; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a00a7c4..a6d89cf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1569,6 +1569,8 @@ namespace OpenSim.Region.Framework.Scenes ILandObject parcel = m_scene.LandChannel.GetLandObject( m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); + List returns = new List(); + if (parcel != null && parcel.LandData != null && parcel.LandData.OtherCleanTime != 0) { @@ -1582,13 +1584,15 @@ namespace OpenSim.Region.Framework.Scenes DetachFromBackup(); m_log.InfoFormat("[SCENE]: Returning object {0} due to parcel auto return", RootPart.UUID.ToString()); m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return"); - m_scene.DeRezObject(null, RootPart.LocalId, - RootPart.GroupID, DeRezAction.Return, UUID.Zero); + returns.Add(RootPart.LocalId); return; } } } + + m_scene.DeRezObjects(null, returns, UUID.Zero, + DeRezAction.Return, UUID.Zero); } if (HasGroupChanged) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 5616a4e..4969b09 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -142,7 +142,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); - scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); + scene.DeRezObjects(client, new System.Collections.Generic.List() { part.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); -- cgit v1.1 From 2db0ac74c72f18d1bceb15b8a368777e42b366c0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Oct 2010 01:13:17 +0200 Subject: Implement taking of coalesced objects. WARNING!!!!! You can TAKE them, but you can't REZ them again. Only the first of the contained objects will rez, the rest is inaccessible until rezzing them is implemented. Also, rotations are not explicitly stored. This MAY work. Or not. --- OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs | 4 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++++++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++----- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 64567db..8feb022 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -137,7 +137,7 @@ namespace OpenSim.Region.Framework.Scenes x = m_inventoryDeletes.Dequeue(); m_log.DebugFormat( - "[ASYNC DELETER]: Sending object to user's inventory, {0} item(s) remaining.", left); + "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", left, x.action, x.objectGroups.Count); try { @@ -177,4 +177,4 @@ namespace OpenSim.Region.Framework.Scenes return false; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bcc439c..76e160d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5063,8 +5063,17 @@ namespace OpenSim.Region.Framework.Scenes { float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; + Vector3 vec = g.AbsolutePosition; + g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); + ominX += vec.X; + omaxX += vec.X; + ominY += vec.Y; + omaxY += vec.Y; + ominZ += vec.Z; + omaxZ += vec.Z; + if (minX > ominX) minX = ominX; if (minY > ominY) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a6d89cf..9a7d560 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1569,8 +1569,6 @@ namespace OpenSim.Region.Framework.Scenes ILandObject parcel = m_scene.LandChannel.GetLandObject( m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); - List returns = new List(); - if (parcel != null && parcel.LandData != null && parcel.LandData.OtherCleanTime != 0) { @@ -1584,15 +1582,14 @@ namespace OpenSim.Region.Framework.Scenes DetachFromBackup(); m_log.InfoFormat("[SCENE]: Returning object {0} due to parcel auto return", RootPart.UUID.ToString()); m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return"); - returns.Add(RootPart.LocalId); + m_scene.DeRezObjects(null, new List() { RootPart.LocalId }, UUID.Zero, + DeRezAction.Return, UUID.Zero); return; } } } - m_scene.DeRezObjects(null, returns, UUID.Zero, - DeRezAction.Return, UUID.Zero); } if (HasGroupChanged) -- cgit v1.1 From 52dd547863c0cdd22f53f0efcaef11ae096855a0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Oct 2010 11:31:52 +0200 Subject: Make SendKillObject send multiple localIDs in one packet. This avoids the halting visual behavior of large group deletes and eliminates the packet flood --- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 7 ++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 ++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 26 +++++++++++++--------- .../Framework/Scenes/SceneCommunicationService.cs | 4 ---- .../Region/Framework/Scenes/SceneObjectGroup.cs | 6 +---- 5 files changed, 29 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 8feb022..a8d24fd 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -104,8 +104,15 @@ namespace OpenSim.Region.Framework.Scenes // better than losing the object for now. if (permissionToDelete) { + List killIDs = new List(); + foreach (SceneObjectGroup g in objectGroups) + { + killIDs.Add(g.LocalId); g.DeleteGroupFromScene(false); + } + + m_scene.SendKillObject(killIDs); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 8b5316a..6d7f984 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1709,7 +1709,7 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) { //Client still thinks the object exists, kill it - SendKillObject(localID); + deleteIDs.Add(localID); continue; } @@ -1717,7 +1717,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentGroup == null || part.ParentGroup.IsDeleted) { //Client still thinks the object exists, kill it - SendKillObject(localID); + deleteIDs.Add(localID); continue; } @@ -1727,8 +1727,8 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup grp = part.ParentGroup; - deleteIDs.Add(localID); deleteGroups.Add(grp); + deleteIDs.Add(grp.LocalId); if (remoteClient == null) { @@ -1811,6 +1811,8 @@ namespace OpenSim.Region.Framework.Scenes } } + SendKillObject(deleteIDs); + if (permissionToTake) { m_asyncSceneObjectDeleter.DeleteToInventory( diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 76e160d..48ae4ca 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2188,6 +2188,8 @@ namespace OpenSim.Region.Framework.Scenes } group.DeleteGroupFromScene(silent); + if (!silent) + SendKillObject(new List() { group.LocalId }); // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); } @@ -3273,7 +3275,7 @@ namespace OpenSim.Region.Framework.Scenes delegate(IClientAPI client) { //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway - try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } + try { client.SendKillObject(avatar.RegionHandle, new List() { avatar.LocalId}); } catch (NullReferenceException) { } }); @@ -3336,18 +3338,24 @@ namespace OpenSim.Region.Framework.Scenes #region Entities - public void SendKillObject(uint localID) + public void SendKillObject(List localIDs) { - SceneObjectPart part = GetSceneObjectPart(localID); - if (part != null) // It is a prim + List deleteIDs = new List(); + + foreach (uint localID in localIDs) { - if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid + SceneObjectPart part = GetSceneObjectPart(localID); + if (part != null) // It is a prim { - if (part.ParentGroup.RootPart != part) // Child part - return; + if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid + { + if (part.ParentGroup.RootPart != part) // Child part + continue; + } } + deleteIDs.Add(localID); } - ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); + ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); } #endregion @@ -3365,7 +3373,6 @@ namespace OpenSim.Region.Framework.Scenes //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; - m_sceneGridService.KiPrimitive += SendKillObject; m_sceneGridService.OnGetLandData += GetLandData; } @@ -3374,7 +3381,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void UnRegisterRegionWithComms() { - m_sceneGridService.KiPrimitive -= SendKillObject; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 1293d5d..632646d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -44,8 +44,6 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes { - public delegate void KiPrimitiveDelegate(uint localID); - public delegate void RemoveKnownRegionsFromAvatarList(UUID avatarID, List regionlst); /// @@ -113,8 +111,6 @@ namespace OpenSim.Region.Framework.Scenes // private LogOffUser handlerLogOffUser = null; // private GetLandData handlerGetLandData = null; // OnGetLandData - public KiPrimitiveDelegate KiPrimitive; - public SceneCommunicationService() { } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9a7d560..c870797 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1151,7 +1151,7 @@ namespace OpenSim.Region.Framework.Scenes // if (IsSelected) { - m_scene.SendKillObject(m_rootPart.LocalId); + m_scene.SendKillObject(new List { m_rootPart.LocalId }); } IsSelected = false; // fudge.... @@ -1415,11 +1415,7 @@ namespace OpenSim.Region.Framework.Scenes avatar.StandUp(); if (!silent) - { part.UpdateFlag = 0; - if (part == m_rootPart) - avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); - } }); } -- cgit v1.1 From ff49a21eca5b084bf0df71f69bce98db0b2f0094 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 9 Oct 2010 01:02:57 +0200 Subject: Fix a security relevant issue with take / take copy --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 110 ++++++++++++--------- 1 file changed, 62 insertions(+), 48 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 6d7f984..9b5459d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1695,6 +1695,7 @@ namespace OpenSim.Region.Framework.Scenes // build a list of eligible objects List deleteIDs = new List(); List deleteGroups = new List(); + List takeGroups = new List(); // Start with true for both, then remove the flags if objects // that we can't derez are part of the selection @@ -1727,9 +1728,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup grp = part.ParentGroup; - deleteGroups.Add(grp); - deleteIDs.Add(grp.LocalId); - if (remoteClient == null) { // Autoreturn has a null client. Nothing else does. So @@ -1756,73 +1754,89 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) permissionToDelete = false; } - } - // Handle god perms - if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) - { - permissionToTake = true; - permissionToTakeCopy = true; - permissionToDelete = true; - } + // Handle god perms + if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) + { + permissionToTake = true; + permissionToTakeCopy = true; + permissionToDelete = true; + } - // If we're re-saving, we don't even want to delete - if (action == DeRezAction.SaveToExistingUserInventoryItem) - permissionToDelete = false; + // If we're re-saving, we don't even want to delete + if (action == DeRezAction.SaveToExistingUserInventoryItem) + permissionToDelete = false; - // if we want to take a copy, we also don't want to delete - // Note: after this point, the permissionToTakeCopy flag - // becomes irrelevant. It already includes the permissionToTake - // permission and after excluding no copy items here, we can - // just use that. - if (action == DeRezAction.TakeCopy) - { - // If we don't have permission, stop right here - if (!permissionToTakeCopy) - return; + // if we want to take a copy, we also don't want to delete + // Note: after this point, the permissionToTakeCopy flag + // becomes irrelevant. It already includes the permissionToTake + // permission and after excluding no copy items here, we can + // just use that. + if (action == DeRezAction.TakeCopy) + { + // If we don't have permission, stop right here + if (!permissionToTakeCopy) + return; - permissionToTake = true; - // Don't delete - permissionToDelete = false; - } + permissionToTake = true; + // Don't delete + permissionToDelete = false; + } - if (action == DeRezAction.Return) - { - if (remoteClient != null) + if (action == DeRezAction.Return) { - if (Permissions.CanReturnObjects( - null, - remoteClient.AgentId, - deleteGroups)) + if (remoteClient != null) + { + if (Permissions.CanReturnObjects( + null, + remoteClient.AgentId, + deleteGroups)) + { + permissionToTake = true; + permissionToDelete = true; + + AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); + } + } + else // Auto return passes through here with null agent { permissionToTake = true; permissionToDelete = true; + } - foreach (SceneObjectGroup g in deleteGroups) - { - AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); - } + if (permissionToTake && (!permissionToDelete)) + takeGroups.Add(grp); + + if (permissionToDelete) + { + if (permissionToTake) + deleteGroups.Add(grp); + deleteIDs.Add(grp.LocalId); } } - else // Auto return passes through here with null agent - { - permissionToTake = true; - permissionToDelete = true; - } } SendKillObject(deleteIDs); - if (permissionToTake) + if (deleteGroups.Count > 0) { + foreach (SceneObjectGroup g in deleteGroups) + deleteIDs.Remove(g.LocalId); + m_asyncSceneObjectDeleter.DeleteToInventory( action, destinationID, deleteGroups, remoteClient, - permissionToDelete); + true); + } + if (takeGroups.Count > 0) + { + m_asyncSceneObjectDeleter.DeleteToInventory( + action, destinationID, takeGroups, remoteClient, + false); } - else if (permissionToDelete) + if (deleteIDs.Count > 0) { foreach (SceneObjectGroup g in deleteGroups) - DeleteSceneObject(g, false); + DeleteSceneObject(g, true); } } -- cgit v1.1 From c2971a6398f21cb3eb6c9cad46348a035eb2a0f5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Oct 2010 20:15:02 +0200 Subject: Add group invites to the list of messages that get offlined --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9b5459d..1d8b988 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1697,14 +1697,14 @@ namespace OpenSim.Region.Framework.Scenes List deleteGroups = new List(); List takeGroups = new List(); - // Start with true for both, then remove the flags if objects - // that we can't derez are part of the selection - bool permissionToTake = true; - bool permissionToTakeCopy = true; - bool permissionToDelete = true; - foreach (uint localID in localIDs) { + // Start with true for both, then remove the flags if objects + // that we can't derez are part of the selection + bool permissionToTake = true; + bool permissionToTakeCopy = true; + bool permissionToDelete = true; + // Invalid id SceneObjectPart part = GetSceneObjectPart(localID); if (part == null) @@ -1803,16 +1803,16 @@ namespace OpenSim.Region.Framework.Scenes permissionToTake = true; permissionToDelete = true; } + } - if (permissionToTake && (!permissionToDelete)) - takeGroups.Add(grp); + if (permissionToTake && (!permissionToDelete)) + takeGroups.Add(grp); - if (permissionToDelete) - { - if (permissionToTake) - deleteGroups.Add(grp); - deleteIDs.Add(grp.LocalId); - } + if (permissionToDelete) + { + if (permissionToTake) + deleteGroups.Add(grp); + deleteIDs.Add(grp.LocalId); } } -- cgit v1.1 From 2804c97a39ece1352bc8ce8cf3672307798417df Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Oct 2010 22:06:47 +0100 Subject: Change the part for sound playback to be the root part / object UUID instead of the child prim because using the child prim plain doesn't work. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index efdb94c..726bda1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2730,7 +2730,7 @@ namespace OpenSim.Region.Framework.Scenes public void PreloadSound(string sound) { // UUID ownerID = OwnerID; - UUID objectID = UUID; + UUID objectID = ParentGroup.RootPart.UUID; UUID soundID = UUID.Zero; if (!UUID.TryParse(sound, out soundID)) @@ -3112,7 +3112,7 @@ namespace OpenSim.Region.Framework.Scenes volume = 0; UUID ownerID = _ownerID; - UUID objectID = UUID; + UUID objectID = ParentGroup.RootPart.UUID; UUID parentID = GetRootPartUUID(); if (ParentGroup.IsAttachment && ParentGroup.RootPart.Shape.State > 30) @@ -3157,11 +3157,11 @@ namespace OpenSim.Region.Framework.Scenes else soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); ParentGroup.PlaySoundMasterPrim = this; - ownerID = this._ownerID; - objectID = this.UUID; - parentID = this.GetRootPartUUID(); - position = this.AbsolutePosition; // region local - regionHandle = this.ParentGroup.Scene.RegionInfo.RegionHandle; + ownerID = _ownerID; + objectID = ParentGroup.RootPart.UUID; + parentID = GetRootPartUUID(); + position = AbsolutePosition; // region local + regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; if (triggered) soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); else @@ -3169,7 +3169,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) { ownerID = prim._ownerID; - objectID = prim.UUID; + objectID = prim.ParentGroup.RootPart.UUID; parentID = prim.GetRootPartUUID(); position = prim.AbsolutePosition; // region local regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle; -- cgit v1.1 From 3eb68c319e1211bf0d4e251931f23d44ac88e63e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 13 Oct 2010 08:24:18 +0200 Subject: change default next owner persm to mod/trans to match SL. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 726bda1..f0740f8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -443,7 +443,7 @@ namespace OpenSim.Region.Framework.Scenes private uint _ownerMask = (uint)PermissionMask.All; private uint _groupMask = (uint)PermissionMask.None; private uint _everyoneMask = (uint)PermissionMask.None; - private uint _nextOwnerMask = (uint)PermissionMask.All; + private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); private PrimFlags _flags = PrimFlags.None; private DateTime m_expires; private DateTime m_rezzed; @@ -1668,6 +1668,9 @@ namespace OpenSim.Region.Framework.Scenes // Move afterwards ResetIDs as it clears the localID dupe.LocalId = localID; + if(dupe.PhysActor != null) + dupe.PhysActor.LocalID = localID; + // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. dupe._lastOwnerID = OwnerID; -- cgit v1.1 From 78a6e5489beccbd4de7385219d0d214323a3d9a1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 18 Oct 2010 20:50:16 +0200 Subject: Fix merge issues --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7ec3697..0321515 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -191,7 +191,6 @@ namespace OpenSim.Region.Framework.Scenes public UUID FromFolderID; -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectPart.cs // The following two are to hold the attachment data // while an object is inworld [XmlIgnore] @@ -201,9 +200,6 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 AttachOffset = Vector3.Zero; [XmlIgnore] -======= - ->>>>>>> master:OpenSim/Region/Framework/Scenes/SceneObjectPart.cs public int STATUS_ROTATE_X; @@ -633,20 +629,12 @@ namespace OpenSim.Region.Framework.Scenes set { m_LoopSoundSlavePrims = value; } } -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectPart.cs -======= - ->>>>>>> master:OpenSim/Region/Framework/Scenes/SceneObjectPart.cs public Byte[] TextureAnimation { get { return m_TextureAnimation; } set { m_TextureAnimation = value; } } -<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectPart.cs -======= - ->>>>>>> master:OpenSim/Region/Framework/Scenes/SceneObjectPart.cs public Byte[] ParticleSystem { get { return m_particleSystem; } -- cgit v1.1 From 8853c21763790389f4bcc3b21993221630fdfd2e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 19 Oct 2010 01:22:31 +0100 Subject: COmmented the wrong line instead, now I commented them all to be on the safe side --- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 49ebe81..e33ad4a 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1363,7 +1363,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } else { - m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); +// m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); reader.ReadOuterXml(); // ignore } @@ -1467,7 +1467,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization p(shape, reader); else { - m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name); +// m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name); reader.ReadOuterXml(); } } -- cgit v1.1 From 301a926015f0bdc1c99c814f18b7a0505bd59869 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 22 Oct 2010 13:29:59 +0100 Subject: Change some exception to use ToString(). e.Message is not sufficient to fix errors. Please don't use e.Message, devs NEED to see the dumps! --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4b24ba2..5428e5d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2466,7 +2466,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.WarnFormat("[SCENE]: Problem casting object: {0}", e.Message); + m_log.WarnFormat("[SCENE]: Problem casting object: " + e.ToString()); return false; } @@ -3464,7 +3464,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.DebugFormat("[CONNECTION BEGIN]: Exception verifying presence {0}", e.Message); + m_log.ErrorFormat("[CONNECTION BEGIN]: Exception verifying presence " + e.ToString()); return false; } @@ -3475,7 +3475,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.DebugFormat("[CONNECTION BEGIN]: Exception authorizing user {0}", e.Message); + m_log.ErrorFormat("[CONNECTION BEGIN]: Exception authorizing user " + e.ToString()); return false; } -- cgit v1.1 From 5f266fd57131193a9ff37b03f214aa0476e2e3aa Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 24 Oct 2010 17:18:21 +0200 Subject: Change the results from llGetPrimitiveParams to be the same as SL for the prim position. This will make attached resizer scripts work like SL. Existing resizers may be affected adversely. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0321515..5521326 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1060,7 +1060,7 @@ namespace OpenSim.Region.Framework.Scenes { get { if (IsAttachment) - return GroupPosition; + return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); // return m_offsetPosition + m_groupPosition; } return m_groupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset) ; } //KF: Rotation was ignored! -- cgit v1.1 From cf78f3fae311be4aa4c0ab37d2a7c8b6679fb22d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 25 Oct 2010 00:53:38 +0200 Subject: Comment repeated add and remove of avatars from the physical scene. It's no longer needed. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 38 ++++++++++++++---------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 618f425..7bf0a99 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2865,22 +2865,28 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_syncRoot) { - if (m_physicsActor != null) - { - if (!IsChildAgent) - { - // This may seem like it's redundant, remove the avatar from the physics scene - // just to add it back again, but it saves us from having to update - // 3 variables 10 times a second. - bool flyingTemp = m_physicsActor.Flying; - RemoveFromPhysicalScene(); - //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); - - //PhysicsActor = null; - - AddToPhysicalScene(flyingTemp); - } - } +// MT: Commented this because it's no longer needed. +// It used to be that the avatar height was calculated from the visual +// params, so any call to this method could change the physical actor's +// height. Now the height is supplied in the agent circuit data and never +// changes here. So, we can leave physics alone. +// +// if (m_physicsActor != null) +// { +// if (!IsChildAgent) +// { +// // This may seem like it's redundant, remove the avatar from the physics scene +// // just to add it back again, but it saves us from having to update +// // 3 variables 10 times a second. +// bool flyingTemp = m_physicsActor.Flying; +// RemoveFromPhysicalScene(); +// //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); +// +// //PhysicsActor = null; +// +// AddToPhysicalScene(flyingTemp); +// } +// } #region Bake Cache Check -- cgit v1.1 From c2bd6ccdb8f9a5063450f684c31d75df537ff5e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 3 Nov 2010 23:20:30 +0100 Subject: Fix playing sound from HUDs --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5521326..be3e87f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3115,14 +3115,6 @@ namespace OpenSim.Region.Framework.Scenes UUID objectID = ParentGroup.RootPart.UUID; UUID parentID = GetRootPartUUID(); - if (ParentGroup.IsAttachment && ParentGroup.RootPart.Shape.State > 30) - { - // Use the avatar as the parent for HUDs, since the prims - // are not sent to other avatars - objectID = _ownerID; - parentID = _ownerID; - } - UUID soundID = UUID.Zero; Vector3 position = AbsolutePosition; // region local ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle; -- cgit v1.1 From b8924167e004cba5e9b426cbb0b2619816ee6858 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Nov 2010 10:37:39 +0100 Subject: Fix creation of a duplicate physics actor on chained drag-copy operations, the main cause for "ghost prims" --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c870797..93d223e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1704,23 +1704,6 @@ namespace OpenSim.Region.Framework.Scenes if (userExposed) dupe.m_rootPart.TrimPermissions(); - /// may need to create a new Physics actor. - if (dupe.RootPart.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = dupe.RootPart.Shape; - - dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( - dupe.RootPart.Name, - pbs, - dupe.RootPart.AbsolutePosition, - dupe.RootPart.Scale, - dupe.RootPart.RotationOffset, - dupe.RootPart.PhysActor.IsPhysical); - - dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; - dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); - } - List partList = new List(m_parts.GetArray()); partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) -- cgit v1.1 From 893915ce0b88348bc7e2053e8942f76ad7ef830b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Nov 2010 21:09:59 +0100 Subject: Fix child prims returning after being unlinked and deleted where the root is not deleted --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b016065..a462133 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1760,6 +1760,11 @@ namespace OpenSim.Region.Framework.Scenes // foreach (SceneObjectGroup g in affectedGroups) { + // Child prims that have been unlinked and deleted will + // return unless the root is deleted. This will remove them + // from the database. They will be rewritten immediately, + // minus the rows for the unlinked child prims. + m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist g.areUpdatesSuspended = false; -- cgit v1.1 From f985775962ae8da0010cc5ef5f903a53b550f5d2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 5 Nov 2010 14:27:14 +0100 Subject: Revert "Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready." This reverts commit 91b1d17e5bd3ff6ed006744bc529b53a67af1a64. Conflicts: OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 84 ++++++++++++++++-------- 1 file changed, 58 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3866647..ec39df8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -127,7 +127,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; + private Vector3 m_lastPosition; private Vector3 m_lastWorldPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -766,11 +766,8 @@ namespace OpenSim.Region.Framework.Scenes // MIC: This gets called again in CompleteMovement SendInitialFullUpdateToAllClients(); + RegisterToEvents(); - if (m_controllingClient != null) - { - m_controllingClient.ProcessPendingPackets(); - } SetDirectionVectors(); } @@ -895,7 +892,11 @@ namespace OpenSim.Region.Framework.Scenes m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; +<<<<<<< HEAD m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); +======= + m_scene.SetRootAgentScene(m_uuid); +>>>>>>> 91b1d17... Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. // Moved this from SendInitialData to ensure that m_appearance is initialized // before the inventory is processed in MakeRootAgent. This fixes a race condition @@ -911,6 +912,7 @@ namespace OpenSim.Region.Framework.Scenes { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); pos.Y = crossedBorder.BorderLine.Z - 1; +<<<<<<< HEAD } //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. @@ -927,6 +929,24 @@ namespace OpenSim.Region.Framework.Scenes pos = land.LandData.UserLocation; } } +======= + } + + //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. + //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, + //they'll bypass the landing point. But I can't think of any decent way of fixing this. + if (KnownChildRegionHandles.Count == 0) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + { + pos = land.LandData.UserLocation; + } + } +>>>>>>> 91b1d17... Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. } if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) @@ -1110,8 +1130,8 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = false; if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - + isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); Velocity = Vector3.Zero; AbsolutePosition = pos; @@ -1122,7 +1142,7 @@ namespace OpenSim.Region.Framework.Scenes SetHeight(m_appearance.AvatarHeight); } - SendTerseUpdateToAllClients(); + SendTerseUpdateToAllClients(); } @@ -1240,6 +1260,7 @@ namespace OpenSim.Region.Framework.Scenes pos.Z = ground + 1.5f; AbsolutePosition = pos; } + m_isChildAgent = false; bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); MakeRootAgent(AbsolutePosition, m_flying); @@ -1827,14 +1848,14 @@ namespace OpenSim.Region.Framework.Scenes // else // { // single or child prim -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); } Quaternion partIRot = Quaternion.Inverse(partRot); @@ -1842,6 +1863,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av +<<<<<<< HEAD if (m_physicsActor == null) { @@ -1854,11 +1876,24 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = avWorldStandUp; //KF: Fix stand up. part.IsOccupied = false; part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); +======= + + if (m_physicsActor == null) + { + AddToPhysicalScene(false); +>>>>>>> 91b1d17... Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; + //CW: If the part isn't null then we can set the current position + if (part != null) + { + Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! + AbsolutePosition = avWorldStandUp; //KF: Fix stand up. + part.IsOccupied = false; + } + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; } m_parentPosition = Vector3.Zero; @@ -2022,7 +2057,7 @@ namespace OpenSim.Region.Framework.Scenes // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) { - autopilot = false; // close enough + autopilot = false; // close enough m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. Not using the part's position because returning the AV to the last known standing position is likely to be more friendly, isn't it? */ @@ -2032,7 +2067,7 @@ namespace OpenSim.Region.Framework.Scenes } // else the autopilot will get us close } else - { // its a scripted sit + { // its a scripted sit m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. I *am* using the part's position this time because we have no real idea how far away the avatar is from the sit target. */ @@ -3993,10 +4028,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju m_scene = scene; RegisterToEvents(); - if (m_controllingClient != null) - { - m_controllingClient.ProcessPendingPackets(); - } + /* AbsolutePosition = client.StartPos; -- cgit v1.1 From 78448720671e364862ae5c17464ccf112bbf7034 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 5 Nov 2010 14:46:13 +0100 Subject: Fix merge artefacts --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 73 ++++++------------------ 1 file changed, 18 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ec39df8..b637317 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -127,7 +127,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation private Vector3 m_avUnscriptedSitPos; // for non-scripted prims - private Vector3 m_lastPosition; + private Vector3 m_lastPosition; private Vector3 m_lastWorldPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -892,11 +892,7 @@ namespace OpenSim.Region.Framework.Scenes m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; -<<<<<<< HEAD m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); -======= - m_scene.SetRootAgentScene(m_uuid); ->>>>>>> 91b1d17... Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. // Moved this from SendInitialData to ensure that m_appearance is initialized // before the inventory is processed in MakeRootAgent. This fixes a race condition @@ -912,7 +908,6 @@ namespace OpenSim.Region.Framework.Scenes { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); pos.Y = crossedBorder.BorderLine.Z - 1; -<<<<<<< HEAD } //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. @@ -929,24 +924,6 @@ namespace OpenSim.Region.Framework.Scenes pos = land.LandData.UserLocation; } } -======= - } - - //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. - //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, - //they'll bypass the landing point. But I can't think of any decent way of fixing this. - if (KnownChildRegionHandles.Count == 0) - { - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) - { - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) - { - pos = land.LandData.UserLocation; - } - } ->>>>>>> 91b1d17... Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. } if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) @@ -1130,8 +1107,8 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = false; if (m_physicsActor != null) - isFlying = m_physicsActor.Flying; - + isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); Velocity = Vector3.Zero; AbsolutePosition = pos; @@ -1142,7 +1119,7 @@ namespace OpenSim.Region.Framework.Scenes SetHeight(m_appearance.AvatarHeight); } - SendTerseUpdateToAllClients(); + SendTerseUpdateToAllClients(); } @@ -1848,14 +1825,14 @@ namespace OpenSim.Region.Framework.Scenes // else // { // single or child prim -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); +// } + if (part == null) //CW: Part may be gone. llDie() for example. + { + partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + } + else + { + partRot = part.GetWorldRotation(); } Quaternion partIRot = Quaternion.Inverse(partRot); @@ -1863,7 +1840,6 @@ namespace OpenSim.Region.Framework.Scenes Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av -<<<<<<< HEAD if (m_physicsActor == null) { @@ -1876,24 +1852,11 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = avWorldStandUp; //KF: Fix stand up. part.IsOccupied = false; part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); -======= - - if (m_physicsActor == null) - { - AddToPhysicalScene(false); ->>>>>>> 91b1d17... Fix for hanging on "Connecting to region".. caused by packets being processed before the presence has bound to receive events. Fixed this by adding packets to a queue and then processing them when the presence is ready. } - //CW: If the part isn't null then we can set the current position - if (part != null) - { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - part.IsOccupied = false; - } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; + else + { + //CW: Since the part doesn't exist, a coarse standup position isn't an issue + AbsolutePosition = m_lastWorldPosition; } m_parentPosition = Vector3.Zero; @@ -2057,7 +2020,7 @@ namespace OpenSim.Region.Framework.Scenes // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) { - autopilot = false; // close enough + autopilot = false; // close enough m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. Not using the part's position because returning the AV to the last known standing position is likely to be more friendly, isn't it? */ @@ -2067,7 +2030,7 @@ namespace OpenSim.Region.Framework.Scenes } // else the autopilot will get us close } else - { // its a scripted sit + { // its a scripted sit m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. I *am* using the part's position this time because we have no real idea how far away the avatar is from the sit target. */ -- cgit v1.1 From 15da52d73aab37ba32447d317bab89baaceb38ba Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 8 Nov 2010 19:00:03 +0100 Subject: Prevent temp-on-rez prims from being persisted --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 93d223e..79f7162 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1553,6 +1553,9 @@ namespace OpenSim.Region.Framework.Scenes return; } + if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) + return; + // Since this is the top of the section of call stack for backing up a particular scene object, don't let // any exception propogate upwards. try -- cgit v1.1 From dfe11566f43a60aaf0dda466a9425d8a1cc1d2e4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 9 Nov 2010 20:18:36 +0100 Subject: Fix parcel bans to work only on the avatars they're supposed to work on instead of pushing all avatars, even the ones that are allowed. --- OpenSim/Region/Framework/Scenes/Scene.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ae48c02..b6d9a02 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4878,7 +4878,6 @@ namespace OpenSim.Region.Framework.Scenes Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); return nearestRegionEdgePoint; - return null; } private Vector3 GetParcelCenterAtGround(ILandObject parcel) -- cgit v1.1 From d206721e2f8833f6c95fa9fda350f0187c24d34f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 9 Nov 2010 22:41:40 +0100 Subject: Add option SeeIntoBannedRegion to allow band to act like SL, where you can see in but not enter. Defaults to false, so no change. --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b6d9a02..a449cca 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -84,6 +84,7 @@ namespace OpenSim.Region.Framework.Scenes // TODO: need to figure out how allow client agents but deny // root agents when ACL denies access to root agent public bool m_strictAccessControl = true; + public bool m_seeIntoBannedRegion = false; public int MaxUndoCount = 5; public bool LoginsDisabled = true; public bool LoadingPrims; @@ -683,6 +684,7 @@ namespace OpenSim.Region.Framework.Scenes } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); + m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); @@ -3688,7 +3690,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) + if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID)) { m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); @@ -3878,6 +3880,12 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence + if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID)) + { + m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); + return false; + } + int num = m_sceneGraph.GetNumberOfScenePresences(); if (num >= RegionInfo.RegionSettings.AgentLimit) -- cgit v1.1 From aace455249b2ea8c033871f39f23409119760932 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 10 Nov 2010 16:22:55 +0100 Subject: Prevent teleporting to a region when the egent is banned in all parcels --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a449cca..dd06be2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3886,6 +3886,13 @@ namespace OpenSim.Region.Framework.Scenes return false; } + ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); + if (nearestParcel == null) + { + m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); + return false; + } + int num = m_sceneGraph.GetNumberOfScenePresences(); if (num >= RegionInfo.RegionSettings.AgentLimit) -- cgit v1.1 From 9462a1861b3a10467370380d11cf2e82a91c4ab7 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 11 Nov 2010 04:49:47 +0000 Subject: Fix excessive forward motion and flailing while descending a slope, prevent adding motion while falling from flying. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 9658e11..9c103cb 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -248,7 +248,7 @@ TrySetMovementAnimation("STAND"); m_animTickFall = Environment.TickCount; } // else if (!jumping && fallElapsed > FALL_DELAY) - else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) ) // add for falling and jumping + else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.m_wasFlying)) // add for falling and jumping { // Falling long enough to trigger the animation //Console.WriteLine("FALLDOWN"); //## diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b637317..f20eb33 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -161,6 +161,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_setAlwaysRun; private bool m_forceFly; private bool m_flyDisabled; + private bool m_flyingOld; // add for fly velocity control + public bool m_wasFlying; // add for fly velocity control private float m_speedModifier = 1.0f; @@ -2564,14 +2566,22 @@ namespace OpenSim.Region.Framework.Scenes Vector3 direc = vec * rotation; direc.Normalize(); PhysicsActor actor = m_physicsActor; + + if (actor.Flying != m_flyingOld) // add for fly velocity control + { + m_flyingOld = actor.Flying; // add for fly velocity control + if (!actor.Flying) m_wasFlying = true; // add for fly velocity control + } + + if (m_physicsActor.IsColliding == true) m_wasFlying = false; // add for fly velocity control + if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. direc *= 0.03f * 128f * m_speedModifier; if (actor != null) { -// rm falling if (actor.Flying) - if ((actor.Flying) || Animator.m_falling) // add for falling lateral speed + if (actor.Flying) { // rm speed mod direc *= 4.0f; direc *= 5.2f; // for speed mod @@ -2587,6 +2597,10 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop FLying"); //} } + if (Animator.m_falling && m_wasFlying) // if falling from flying, disable motion add + { + direc *= 0.0f; + } /* This jumping section removed to SPA else if (!actor.Flying && actor.IsColliding) { -- cgit v1.1 From 0f152bfe8c6e9723da3abec3eeef83d0f2d18796 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 16 Nov 2010 01:33:24 +0100 Subject: Diva needs a spanking! Serializing OldItemID breaks script state persistence in agent inventory. --- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index a398dfd..dfc69d8 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -735,7 +735,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) { - item.OldItemID = ReadUUID(reader, "OldItemID"); + ReadUUID(reader, "OldItemID"); + // On deserialization, the old item id MUST BE UUID.Zero!!!!! + // Setting this to the saved value will BREAK script persistence! + // item.OldItemID = ReadUUID(reader, "OldItemID"); } private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) -- cgit v1.1 From 4f15b8d4e6be1e1fe88ad32aa43595861d1005ad Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 16 Nov 2010 20:44:39 +0100 Subject: Change the way attachments are persisted. Editing a worn attachment will now save properly, as will the results of a resizer script working. Attachment positions are no longer saved on each move, but instead are saved once on logout. Attachment script states are saved as part of the attachment now when detaching. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 17 +++++++--- .../Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 37 ++++++++++++---------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 +++++++++++ 6 files changed, 58 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dd06be2..c4639c3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3255,7 +3255,6 @@ namespace OpenSim.Region.Framework.Scenes List regions = new List(avatar.KnownChildRegionHandles); regions.Remove(RegionInfo.RegionHandle); m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); - } m_log.Debug("[Scene] Beginning ClientClosed"); m_eventManager.TriggerClientClosed(agentID, this); @@ -3271,6 +3270,9 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager.TriggerOnRemovePresence(agentID); m_log.Debug("[Scene] Finished OnRemovePresence"); + if (avatar != null && (!avatar.IsChildAgent)) + avatar.SaveChangedAttachments(); + ForEachClient( delegate(IClientAPI client) { diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a462133..b2d9358 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (!alreadyPersisted) + if (attachToBackup && (!alreadyPersisted)) { sceneObject.ForceInventoryPersistence(); sceneObject.HasGroupChanged = true; @@ -304,8 +304,10 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - // Ensure that we persist this new scene object - sceneObject.HasGroupChanged = true; + // Ensure that we persist this new scene object if it's not an + // attachment + if (attachToBackup) + sceneObject.HasGroupChanged = true; return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); } @@ -1342,8 +1344,13 @@ namespace OpenSim.Region.Framework.Scenes { if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) { - if (m_parentScene.AttachmentsModule != null) - m_parentScene.AttachmentsModule.UpdateAttachmentPosition(remoteClient, group, pos); + // Set the new attachment point data in the object + byte attachmentPoint = group.GetAttachmentPoint(); + group.UpdateGroupPosition(pos); + group.RootPart.IsAttachment = false; + group.AbsolutePosition = group.RootPart.AttachedPos; + group.SetAttachmentPoint(attachmentPoint); + group.HasGroupChanged = true; } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 79f7162..ee08072 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -586,13 +586,15 @@ namespace OpenSim.Region.Framework.Scenes XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState"); if (nodes.Count > 0) { - m_savedScriptState = new Dictionary(); + if (m_savedScriptState == null) + m_savedScriptState = new Dictionary(); foreach (XmlNode node in nodes) { if (node.Attributes["UUID"] != null) { UUID itemid = new UUID(node.Attributes["UUID"].Value); - m_savedScriptState.Add(itemid, node.InnerXml); + if (itemid != UUID.Zero) + m_savedScriptState[itemid] = node.InnerXml; } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index be3e87f..b615d42 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4822,7 +4822,7 @@ namespace OpenSim.Region.Framework.Scenes { TaskInventoryItem item = Inventory.GetInventoryItem(itemID); item.OwnerChanged = false; - Inventory.UpdateInventoryItem(item); + Inventory.UpdateInventoryItem(item, false, false); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 522f75e..8fcfcc5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -131,12 +131,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - HasInventoryChanged = true; - if (m_part.ParentGroup != null) - { - m_part.ParentGroup.HasGroupChanged = true; - } - IList items = new List(Items.Values); Items.Clear(); @@ -158,12 +152,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - HasInventoryChanged = true; - if (m_part.ParentGroup != null) - { - m_part.ParentGroup.HasGroupChanged = true; - } - IList items = new List(Items.Values); Items.Clear(); @@ -216,8 +204,15 @@ namespace OpenSim.Region.Framework.Scenes return; } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + // Don't let this set the HasGroupChanged flag for attachments + // as this happens during rez and we don't want a new asset + // for each attachment each time + if (!m_part.ParentGroup.RootPart.IsAttachment) + { + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + } + IList items = new List(Items.Values); foreach (TaskInventoryItem item in items) { @@ -824,11 +819,16 @@ namespace OpenSim.Region.Framework.Scenes /// false if the item did not exist, true if the update occurred successfully public bool UpdateInventoryItem(TaskInventoryItem item) { - return UpdateInventoryItem(item, true); + return UpdateInventoryItem(item, true, true); } public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) { + return UpdateInventoryItem(item, fireScriptEvents, true); + } + + public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) + { m_items.LockItemsForWrite(true); if (m_items.ContainsKey(item.ItemID)) @@ -849,8 +849,11 @@ namespace OpenSim.Region.Framework.Scenes m_inventorySerial++; if (fireScriptEvents) m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + if (considerChanged) + { + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + } m_items.LockItemsForWrite(false); return true; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cc9c445..dfaf06d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4340,6 +4340,24 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju return(new Vector3(x,y,z)); } + public void SaveChangedAttachments() + { + // Need to copy this list because DetachToInventoryPrep mods it + List attachments = new List(Attachments.ToArray()); + IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule; + if (attachmentsModule != null) + { + foreach (SceneObjectGroup grp in attachments) + { + if (grp.HasGroupChanged) // Resizer scripts? + { + grp.DetachToInventoryPrep(); + attachmentsModule.UpdateKnownItem(ControllingClient, + grp, grp.GetFromItemID(), grp.OwnerID); + } + } + } + } } } -- cgit v1.1 From 0049ec16f56eab51c812eef5e2e4396f23d91507 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 16 Nov 2010 22:26:07 +0100 Subject: Prevent leftover attachments from clogging up the pipes --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b340bda..d2c6a29 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4366,9 +4366,12 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju { if (grp.HasGroupChanged) // Resizer scripts? { - grp.DetachToInventoryPrep(); + grp.RootPart.IsAttachment = false; + grp.AbsolutePosition = grp.RootPart.AttachedPos; +// grp.DetachToInventoryPrep(); attachmentsModule.UpdateKnownItem(ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); + grp.RootPart.IsAttachment = true; } } } -- cgit v1.1 From 47f04689953b9a84a9e718a5e7a75fe9fc9028aa Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Nov 2010 04:18:43 +0100 Subject: Send parcel data upon becoming root. This will make streams play and build flags be set properly --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d2c6a29..c35df08 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -915,10 +915,10 @@ namespace OpenSim.Region.Framework.Scenes //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, //they'll bypass the landing point. But I can't think of any decent way of fixing this. - if (KnownChildRegionHandles.Count == 0) + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) { - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) + if (KnownChildRegionHandles.Count == 0) { //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) @@ -926,6 +926,8 @@ namespace OpenSim.Region.Framework.Scenes pos = land.LandData.UserLocation; } } + + land.SendLandUpdateToClient(ControllingClient); } if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) -- cgit v1.1 From f3e4000a552e5dcb7d3f3612badb622e1d412055 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Nov 2010 13:26:35 +0100 Subject: Send media and other parcel data to client on login. Makes streams visible right away and starts media. --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3ae8a38..a0ae82f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2706,12 +2706,19 @@ namespace OpenSim.Region.Framework.Scenes } } - if (GetScenePresence(client.AgentId) != null) + if (TryGetScenePresence(client.AgentId, out presence)) { m_LastLogin = Util.EnvironmentTickCount(); EventManager.TriggerOnNewClient(client); if (vialogin) + { EventManager.TriggerOnClientLogin(client); + + // Send initial parcel data + Vector3 pos = presence.AbsolutePosition; + ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); + land.SendLandUpdateToClient(presence.ControllingClient); + } } } -- cgit v1.1 From b3a71c6df1538c61247f7d4711aba4c840508db8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 24 Nov 2010 18:56:25 +0100 Subject: Prevent an overlength button label from producing a debug dump and aborting the script. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 233 +++++++++++---------- 3 files changed, 120 insertions(+), 117 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f3964c2..bcb715b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -398,7 +398,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3 offset = p.GetWorldPosition() - av.ParentPosition; av.AbsolutePosition += offset; av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition - av.SendFullUpdateToAllClients(); + av.SendAvatarDataToAllAgents(); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index bdd42fc..8cc2be1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -803,7 +803,7 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 offset = (m_offsetPosition - oldpos); av.OffsetPosition += offset; - av.SendFullUpdateToAllClients(); + av.SendAvatarDataToAllAgents(); } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c35df08..98a3b29 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -767,7 +767,9 @@ namespace OpenSim.Region.Framework.Scenes // Note: This won't send data *to* other clients in that region (children don't send) // MIC: This gets called again in CompleteMovement - SendInitialFullUpdateToAllClients(); + // SendInitialFullUpdateToAllClients(); + SendOtherAgentsAvatarDataToMe(); + SendOtherAgentsAppearanceToMe(); RegisterToEvents(); SetDirectionVectors(); @@ -1757,7 +1759,7 @@ namespace OpenSim.Region.Framework.Scenes { AbsolutePosition = part.AbsolutePosition; Velocity = Vector3.Zero; - SendFullUpdateToAllClients(); + SendAvatarDataToAllAgents(); HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? } @@ -1867,7 +1869,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentID = 0; m_linkedPrim = UUID.Zero; m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - SendFullUpdateToAllClients(); + SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; if (m_physicsActor != null && m_appearance != null) { @@ -2462,8 +2464,8 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; RemoveFromPhysicalScene(); Animator.TrySetMovementAnimation(sitAnimation); - SendFullUpdateToAllClients(); - SendTerseUpdateToAllClients(); + SendAvatarDataToAllAgents(); + //SendTerseUpdateToAllClients(); } public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) @@ -2742,165 +2744,169 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) + /// Do everything required once a client completes its movement into a region and becomes + /// a root agent. /// - /// - public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) + private void SendInitialData() { - // 2 stage check is needed. - if (remoteAvatar == null) - return; + // Moved this into CompleteMovement to ensure that m_appearance is initialized before + // the inventory arrives + // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - IClientAPI cl = remoteAvatar.ControllingClient; - if (cl == null) - return; + // This agent just became root. We are going to tell everyone about it. The process of + // getting other avatars information was initiated in the constructor... don't do it + // again here... + SendAvatarDataToAllAgents(); - if (m_appearance.Texture == null) - return; - -// MT: This is needed for sit. It's legal to send it to oneself, and the name -// of the method is a misnomer -// -// if (LocalId == remoteAvatar.LocalId) -// { -// m_log.WarnFormat("[SCENEPRESENCE]: An agent is attempting to send avatar data to itself; {0}", UUID); -// return; -// } + // We have an appearance but we may not have the baked textures. Check the asset cache + // to see if all the baked textures are already here. + if (m_scene.AvatarFactory != null) + { + if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) + { +// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); + SendAppearanceToAgent(this); - if (IsChildAgent) + // If the avatars baked textures are all in the cache, then we have a + // complete appearance... send it out, if not, then we'll send it when + // the avatar finishes updating its appearance + SendAppearanceToAllOtherAgents(); + } + } + else { - m_log.WarnFormat("[SCENEPRESENCE]: A child agent is attempting to send out avatar data; {0}", UUID); - return; + m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); } - - remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); - m_scene.StatsReporter.AddAgentUpdates(1); } /// - /// Tell *ALL* agents about this agent + /// Send this agent's avatar data to all other root and child agents in the scene + /// This agent must be root. This avatar will receive its own update. /// - public void SendInitialFullUpdateToAllClients() + public void SendAvatarDataToAllAgents() { - m_perfMonMS = Util.EnvironmentTickCount(); - int avUpdates = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence avatar) + // only send update from root agents to other clients; children are only "listening posts" + if (IsChildAgent) { - ++avUpdates; - - // Don't update ourselves - if (avatar.LocalId == LocalId) - return; - - // If this is a root agent, then get info about the avatar - if (!IsChildAgent) - { - SendFullUpdateToOtherClient(avatar); - } + m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); + return; + } + + m_perfMonMS = Util.EnvironmentTickCount(); - // If the other avatar is a root - if (!avatar.IsChildAgent) - { - avatar.SendFullUpdateToOtherClient(this); - avatar.SendAppearanceToOtherAgent(this); - avatar.Animator.SendAnimPackToClient(ControllingClient); - } - }); + int count = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + { + SendAvatarDataToAgent(scenePresence); + count++; + }); - m_scene.StatsReporter.AddAgentUpdates(avUpdates); + m_scene.StatsReporter.AddAgentUpdates(count); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - - //Animator.SendAnimPack(); } - public void SendFullUpdateToAllClients() + /// + /// Send avatar data for all other root agents to this agent, this agent + /// can be either a child or root + /// + public void SendOtherAgentsAvatarDataToMe() { m_perfMonMS = Util.EnvironmentTickCount(); - // only send update from root agents to other clients; children are only "listening posts" - if (IsChildAgent) - { - m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent"); - return; - } - int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence sp) - { - if (sp.IsChildAgent) - return; - SendFullUpdateToOtherClient(sp); - ++count; - }); + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + { + // only send information about root agents + if (scenePresence.IsChildAgent) + return; + + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; + + scenePresence.SendAvatarDataToAgent(this); + count++; + }); + m_scene.StatsReporter.AddAgentUpdates(count); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); - - Animator.SendAnimPack(); } /// - /// Do everything required once a client completes its movement into a region + /// Send avatar data to an agent. /// - public void SendInitialData() + /// + private void SendAvatarDataToAgent(ScenePresence avatar) { - // Moved this into CompleteMovement to ensure that m_appearance is initialized before - // the inventory arrives - // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); +// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); - m_controllingClient.SendAvatarDataImmediate(this); - if (m_scene.AvatarFactory != null) - { - if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) - { -// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); - m_controllingClient.SendAppearance( - m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes()); - } - } - else + avatar.ControllingClient.SendAvatarDataImmediate(this); + Animator.SendAnimPackToClient(avatar.ControllingClient); + } + + /// + /// Send this agent's appearance to all other root and child agents in the scene + /// This agent must be root. + /// + public void SendAppearanceToAllOtherAgents() + { + // only send update from root agents to other clients; children are only "listening posts" + if (IsChildAgent) { - m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); + m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); + return; } + + m_perfMonMS = Util.EnvironmentTickCount(); + + int count = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + { + if (scenePresence.UUID == UUID) + return; - SendInitialFullUpdateToAllClients(); + SendAppearanceToAgent(scenePresence); + count++; + }); + + m_scene.StatsReporter.AddAgentUpdates(count); + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); } /// - /// + /// Send appearance from all other root agents to this agent. this agent + /// can be either root or child /// - public void SendAppearanceToAllOtherAgents() + public void SendOtherAgentsAppearanceToMe() { -// DEBUG ON -// m_log.WarnFormat("[SCENEPRESENCE]: Send appearance from {0} to all other agents", m_uuid); -// DEBUG OFF m_perfMonMS = Util.EnvironmentTickCount(); + int count = 0; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { - if (scenePresence.UUID != UUID) - { - SendAppearanceToOtherAgent(scenePresence); - } + // only send information about root agents + if (scenePresence.IsChildAgent) + return; + + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; + + scenePresence.SendAppearanceToAgent(this); + count++; }); + m_scene.StatsReporter.AddAgentUpdates(count); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); } /// - /// Send appearance data to an agent that isn't this one. + /// Send appearance data to an agent. /// /// - public void SendAppearanceToOtherAgent(ScenePresence avatar) + private void SendAppearanceToAgent(ScenePresence avatar) { - if (LocalId == avatar.LocalId) - { - m_log.WarnFormat("[SCENE PRESENCE]: An agent is attempting to send appearance data to itself; {0}", UUID); - return; - } - -// DEBUG ON // m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); -// DEBUG OFF avatar.ControllingClient.SendAppearance( m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); @@ -3413,9 +3419,6 @@ namespace OpenSim.Region.Framework.Scenes public void CopyFrom(AgentData cAgent) { -// DEBUG ON - m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM"); -// DEBUG OFF m_originRegionID = cAgent.RegionID; m_callbackURI = cAgent.CallbackURI; -- cgit v1.1 From 2bee150aac6d4996140ddf1f9bd09ba444901033 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Nov 2010 20:45:03 +0100 Subject: Implement health monitoring of the packet receiving and sending threads --- OpenSim/Region/Framework/Scenes/Scene.cs | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 216eb51..83887b4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -174,6 +174,8 @@ namespace OpenSim.Region.Framework.Scenes private volatile bool shuttingdown; private int m_lastUpdate; + private int m_lastIncoming; + private int m_lastOutgoing; private bool m_firstHeartbeat = true; private object m_deleting_scene_object = new object(); @@ -567,6 +569,8 @@ namespace OpenSim.Region.Framework.Scenes m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); + m_lastIncoming = Util.EnvironmentTickCount(); + m_lastOutgoing = Util.EnvironmentTickCount(); m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; @@ -4543,11 +4547,17 @@ namespace OpenSim.Region.Framework.Scenes // 1 = sim is up and accepting http requests. The heartbeat has // stopped and the sim is probably locked up, but a remote // admin restart may succeed - // + // // 2 = Sim is up and the heartbeat is running. The sim is likely - // usable for people within and logins _may_ work + // usable for people within + // + // 3 = Sim is up and one packet thread is running. Sim is + // unstable and will not accept new logins + // + // 4 = Sim is up and both packet threads are running. Sim is + // likely usable // - // 3 = We have seen a new user enter within the past 4 minutes + // 5 = We have seen a new user enter within the past 4 minutes // which can be seen as positive confirmation of sim health // int health=1; // Start at 1, means we're up @@ -4557,6 +4567,16 @@ namespace OpenSim.Region.Framework.Scenes else return health; + if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastIncoming)) < 1000)) + health+=1; + else + return health; + + if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastOutgoing)) < 1000)) + health+=1; + else + return health; + // A login in the last 4 mins? We can't be doing too badly // if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) @@ -5106,5 +5126,18 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[SCENE]: Finished dropped attachment deletion"); } } + + public void ThreadAlive(int threadCode) + { + switch(threadCode) + { + case 1: // Incoming + m_lastIncoming = Util.EnvironmentTickCount(); + break; + case 2: // Incoming + m_lastOutgoing = Util.EnvironmentTickCount(); + break; + } + } } } -- cgit v1.1 From ab2adaf3418e5a64c7d94305d45489310eaa2ab0 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 29 Nov 2010 16:24:16 -0800 Subject: Various bug fixes for appearance handling --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 +++++++++++++++--------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 24c809b..5a842d8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2773,30 +2773,44 @@ namespace OpenSim.Region.Framework.Scenes // the inventory arrives // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - // This agent just became root. We are going to tell everyone about it. The process of - // getting other avatars information was initiated in the constructor... don't do it - // again here... - SendAvatarDataToAllAgents(); + bool cachedappearance = false; // We have an appearance but we may not have the baked textures. Check the asset cache // to see if all the baked textures are already here. if (m_scene.AvatarFactory != null) { - if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) - { -// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); - SendAppearanceToAgent(this); - - // If the avatars baked textures are all in the cache, then we have a - // complete appearance... send it out, if not, then we'll send it when - // the avatar finishes updating its appearance - SendAppearanceToAllOtherAgents(); - } + cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient); } else { m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); } + + // If we aren't using a cached appearance, then clear out the baked textures + if (! cachedappearance) + { + m_appearance.ResetBakedTextures(); + if (m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(UUID); + } + + // This agent just became root. We are going to tell everyone about it. The process of + // getting other avatars information was initiated in the constructor... don't do it + // again here... this comes after the cached appearance check because the avatars + // appearance goes into the avatar update packet + SendAvatarDataToAllAgents(); + + // If we are using the the cached appearance then send it out to everyone + if (cachedappearance) + { + m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); + SendAppearanceToAgent(this); + + // If the avatars baked textures are all in the cache, then we have a + // complete appearance... send it out, if not, then we'll send it when + // the avatar finishes updating its appearance + SendAppearanceToAllOtherAgents(); + } } /// @@ -2856,7 +2870,7 @@ namespace OpenSim.Region.Framework.Scenes /// Send avatar data to an agent. /// /// - private void SendAvatarDataToAgent(ScenePresence avatar) + public void SendAvatarDataToAgent(ScenePresence avatar) { // m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); @@ -2924,7 +2938,7 @@ namespace OpenSim.Region.Framework.Scenes /// Send appearance data to an agent. /// /// - private void SendAppearanceToAgent(ScenePresence avatar) + public void SendAppearanceToAgent(ScenePresence avatar) { // m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); -- cgit v1.1 From ec01936d38f6a082ec7f9d5ba4a07d8150d73ea3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 02:37:08 +0100 Subject: Change the way sim health reporting reports sim startup --- OpenSim/Region/Framework/Scenes/Scene.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 83887b4..3c2cd9b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -569,8 +569,8 @@ namespace OpenSim.Region.Framework.Scenes m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); - m_lastIncoming = Util.EnvironmentTickCount(); - m_lastOutgoing = Util.EnvironmentTickCount(); + m_lastIncoming = 0; + m_lastOutgoing = 0; m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; @@ -4560,26 +4560,34 @@ namespace OpenSim.Region.Framework.Scenes // 5 = We have seen a new user enter within the past 4 minutes // which can be seen as positive confirmation of sim health // + if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) + { + // We're still starting + // 0 means "in startup", it can't happen another way, since + // to get here, we must be able to accept http connections + return 0; + } + int health=1; // Start at 1, means we're up - if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000)) + if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) health+=1; else return health; - if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastIncoming)) < 1000)) + if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) health+=1; else return health; - if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastOutgoing)) < 1000)) + if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) health+=1; else return health; // A login in the last 4 mins? We can't be doing too badly // - if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) + if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) health++; else return health; -- cgit v1.1 From 6c01ebb87541ecf66d678606bb97d996bee51953 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 04:39:51 +0100 Subject: Revert "Trigger changed event with CHANGED_TELEPORT when teleporting to another region." This reverts commit 2827deffe822378b6cb35dac6c90a21c3fbc0de7. Pulling out a bad core commit that broke attachment teleporting for us --- OpenSim/Region/Framework/Scenes/Scene.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0c7b2e8..ae85605 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2391,14 +2391,16 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); return false; } - - newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); + + newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2); newObject.ResumeScripts(); // Do this as late as possible so that listeners have full access to the incoming object EventManager.TriggerOnIncomingSceneObject(newObject); + TriggerChangedTeleport(newObject); + return true; } @@ -2525,7 +2527,7 @@ namespace OpenSim.Region.Framework.Scenes return true; } - private int GetStateSource(SceneObjectGroup sog) + private void TriggerChangedTeleport(SceneObjectGroup sog) { ScenePresence sp = GetScenePresence(sog.OwnerID); @@ -2536,12 +2538,13 @@ namespace OpenSim.Region.Framework.Scenes if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default)) { // This will get your attention - //m_log.Error("[XXX] Triggering CHANGED_TELEPORT"); + //m_log.Error("[XXX] Triggering "); - return 5; // StateSource.Teleporting + // Trigger CHANGED_TELEPORT + sp.Scene.EventManager.TriggerOnScriptChangedEvent(sog.LocalId, (uint)Changed.TELEPORT); } + } - return 2; // StateSource.PrimCrossing } #endregion -- cgit v1.1 From e913e1690e0e4a8da26103e1159d5ec6aedfb43b Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 07:16:06 +0100 Subject: Fix health reporting. This will now actually monitor the threads properly and not just the http server. It will also restart a dead heartbeat. --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ae85605..ec1eda0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1213,9 +1213,6 @@ namespace OpenSim.Region.Framework.Scenes try { Update(); - - m_lastUpdate = Util.EnvironmentTickCount(); - m_firstHeartbeat = false; } catch (ThreadAbortException) { @@ -1405,6 +1402,9 @@ namespace OpenSim.Region.Framework.Scenes // Tell the watchdog that this thread is still alive Watchdog.UpdateThread(); + + m_lastUpdate = Util.EnvironmentTickCount(); + m_firstHeartbeat = false; } } -- cgit v1.1 From b94092517365fd557ca85142d315e746056dcfeb Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 07:27:29 +0100 Subject: Improve health reporting --- OpenSim/Region/Framework/Scenes/Scene.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ec1eda0..d17814d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4548,7 +4548,7 @@ namespace OpenSim.Region.Framework.Scenes SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); } - public int GetHealth() + public int GetHealth(out int flags, out string message) { // Returns: // 1 = sim is up and accepting http requests. The heartbeat has @@ -4567,6 +4567,12 @@ namespace OpenSim.Region.Framework.Scenes // 5 = We have seen a new user enter within the past 4 minutes // which can be seen as positive confirmation of sim health // + + flags = 0; + message = String.Empty; + + CheckHeartbeat(); + if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) { // We're still starting @@ -4578,28 +4584,30 @@ namespace OpenSim.Region.Framework.Scenes int health=1; // Start at 1, means we're up if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) + { health+=1; - else - return health; + flags |= 1; + } if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) + { health+=1; - else - return health; + flags |= 2; + } if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) + { health+=1; - else + flags |= 4; + } + + if (flags != 7) return health; // A login in the last 4 mins? We can't be doing too badly // if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) health++; - else - return health; - - CheckHeartbeat(); return health; } -- cgit v1.1 From 8741676bc3681e2045084e17f86196693d9156d3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 18:32:03 +0100 Subject: Revert "Revert "Trigger changed event with CHANGED_TELEPORT when teleporting to another region."" This reverts commit 6c01ebb87541ecf66d678606bb97d996bee51953. --- OpenSim/Region/Framework/Scenes/Scene.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d17814d..792115a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2391,16 +2391,14 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); return false; } - - newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2); + + newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); newObject.ResumeScripts(); // Do this as late as possible so that listeners have full access to the incoming object EventManager.TriggerOnIncomingSceneObject(newObject); - TriggerChangedTeleport(newObject); - return true; } @@ -2527,7 +2525,7 @@ namespace OpenSim.Region.Framework.Scenes return true; } - private void TriggerChangedTeleport(SceneObjectGroup sog) + private int GetStateSource(SceneObjectGroup sog) { ScenePresence sp = GetScenePresence(sog.OwnerID); @@ -2538,13 +2536,12 @@ namespace OpenSim.Region.Framework.Scenes if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default)) { // This will get your attention - //m_log.Error("[XXX] Triggering "); + //m_log.Error("[XXX] Triggering CHANGED_TELEPORT"); - // Trigger CHANGED_TELEPORT - sp.Scene.EventManager.TriggerOnScriptChangedEvent(sog.LocalId, (uint)Changed.TELEPORT); + return 5; // StateSource.Teleporting } - } + return 2; // StateSource.PrimCrossing } #endregion -- cgit v1.1 From 8e3bacc691926340c049e2082b46e4d22a72b6ff Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 23:06:44 +0100 Subject: When linking something, immediately persist the linked set. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b2d9358..ecc7f40 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1639,6 +1639,7 @@ namespace OpenSim.Region.Framework.Scenes { parentGroup.areUpdatesSuspended = false; parentGroup.HasGroupChanged = true; + parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); Monitor.Exit(m_updateLock); } -- cgit v1.1 From f28dc77ab4f0abeac942b25d3547f43184d5cf2e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 9 Dec 2010 02:01:41 +0100 Subject: Plumb a code path for the entity transfer module to ask a destination scene whether or not an agent is allowed there as a root agent. --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e48b92b..383d95f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5160,5 +5160,16 @@ namespace OpenSim.Region.Framework.Scenes break; } } + + // This method is called across the simulation connector to + // determine if a given agent is allowed in this region + // AS A ROOT AGENT. Returning false here will prevent them + // from logging into the region, teleporting into the region + // or corssing the broder walking, but will NOT prevent + // child agent creation, thereby emulating the SL behavior. + public bool QueryAccess(UUID agentID) + { + return true; + } } } -- cgit v1.1 From 663a626a6f1b7b7960f086ac4b3401ae9a100c11 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 12 Dec 2010 08:57:26 +0000 Subject: Apply the useful part of diva's patch that was skipped --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 10 +++++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 28 +----------------------- 2 files changed, 7 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index c75f8ba..cde8d3f 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -219,13 +219,15 @@ namespace OpenSim.Region.Framework.Scenes private double GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) { + // If this is an update for our own avatar give it the highest priority + if (client.AgentId == entity.UUID) + return 0.0; + if (entity == null) + return double.NaN; + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { - // If this is an update for our own avatar give it the highest priority - if (presence == entity) - return 0.0; - // Use group position for child prims Vector3 entityPos; if (entity is SceneObjectPart) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7ce94d4..961fe29 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2553,34 +2553,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent) { // WHAT??? - m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); + m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent"); - // we have to reset the user's child agent connections. - // Likely, here they've lost the eventqueue for other regions so border - // crossings will fail at this point unless we reset them. - - List regions = new List(KnownChildRegionHandles); - regions.Remove(m_scene.RegionInfo.RegionHandle); - - MakeRootAgent(new Vector3(127f, 127f, 127f), true); - - // Async command - if (m_scene.SceneGridService != null) - { - m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); - - // Give the above command some time to try and close the connections. - // this is really an emergency.. so sleep, or we'll get all discombobulated. - System.Threading.Thread.Sleep(500); - } - - if (m_scene.SceneGridService != null) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); - } - return; } -- cgit v1.1 From 63353a0687ddb8e530d95ae197e99c1408f057e6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 12 Dec 2010 21:24:00 +0100 Subject: Fix a perms issue when wearing an object from inworld --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 52e2e83..a1f1ea5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1902,21 +1902,29 @@ namespace OpenSim.Region.Framework.Scenes else // oopsies item.Folder = UUID.Zero; + // Set up base perms properly + uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); + permsBase &= grp.RootPart.BaseMask; + permsBase |= (uint)PermissionMask.Move; + + // Make sure we don't lock it + grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; + if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) { - item.BasePermissions = grp.RootPart.NextOwnerMask; - item.CurrentPermissions = grp.RootPart.NextOwnerMask; - item.NextPermissions = grp.RootPart.NextOwnerMask; - item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; - item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; + item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; + item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; + item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; + item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; } else { - item.BasePermissions = grp.RootPart.BaseMask; - item.CurrentPermissions = grp.RootPart.OwnerMask; - item.NextPermissions = grp.RootPart.NextOwnerMask; - item.EveryOnePermissions = grp.RootPart.EveryoneMask; - item.GroupPermissions = grp.RootPart.GroupMask; + item.BasePermissions = permsBase; + item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; + item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; + item.GroupPermissions = permsBase & grp.RootPart.GroupMask; } item.CreationDate = Util.UnixTimeSinceEpoch(); -- cgit v1.1 From d36b880022b5efcd1c6d98d94a868575d2f6f184 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 13 Dec 2010 11:13:34 +0100 Subject: Change some lookups in he Land Management module to make group permissions work better. Add a generic group permissions hoot to the scene permissions system. --- OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d67638a..ab0eed8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -68,6 +68,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool IsGodHandler(UUID user, Scene requestFromScene); public delegate bool IsAdministratorHandler(UUID user); public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); + public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); @@ -131,6 +132,7 @@ namespace OpenSim.Region.Framework.Scenes public event IsGodHandler OnIsGod; public event IsAdministratorHandler OnIsAdministrator; public event EditParcelHandler OnEditParcel; + public event EditParcelPropertiesHandler OnEditParcelProperties; public event SellParcelHandler OnSellParcel; public event AbandonParcelHandler OnAbandonParcel; public event ReclaimParcelHandler OnReclaimParcel; @@ -734,6 +736,21 @@ namespace OpenSim.Region.Framework.Scenes } return true; } + + public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p) + { + EditParcelPropertiesHandler handler = OnEditParcelProperties; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (EditParcelPropertiesHandler h in list) + { + if (h(user, parcel, p, m_scene) == false) + return false; + } + } + return true; + } #endregion #region SELL PARCEL @@ -1043,4 +1060,4 @@ namespace OpenSim.Region.Framework.Scenes return true; } } -} \ No newline at end of file +} -- cgit v1.1 From 6b374fa54767a22c1d236470c8a19ee59b44d937 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 13 Dec 2010 20:19:52 +0100 Subject: Revamp the viewer -> banlist packet processing so fix a number of bugs. Remove the too coarse CanEditParcel method in favor of a CanEditParcelProperties method that takes a GroupPowers argument to specify what action is to be taken. Also, make the method to set parcel data much more granular. Permissions in a deeded setting should now work. --- OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index ab0eed8..1295e58 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -722,20 +722,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region EDIT PARCEL - public bool CanEditParcel(UUID user, ILandObject parcel) - { - EditParcelHandler handler = OnEditParcel; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (EditParcelHandler h in list) - { - if (h(user, parcel, m_scene) == false) - return false; - } - } - return true; - } public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p) { -- cgit v1.1 From 62e66b17bcc6e9dd856a0d46b3097f452d865a3b Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Dec 2010 17:54:57 +0100 Subject: Make sure the material is set on physical prims --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ 2 files changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 896300f..72443b9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1749,6 +1749,7 @@ namespace OpenSim.Region.Framework.Scenes part.Scale, part.RotationOffset, part.PhysActor.IsPhysical); + part.PhysActor.SetMaterial((int)part.Material); part.PhysActor.LocalID = part.LocalId; part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a109d68..0297a39 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1608,6 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes Scale, RotationOffset, RigidBody); + PhysActor.SetMaterial(Material); } catch { @@ -4432,6 +4433,7 @@ namespace OpenSim.Region.Framework.Scenes Scale, RotationOffset, UsePhysics); + PhysActor.SetMaterial(Material); pa = PhysActor; if (pa != null) -- cgit v1.1 From 2f84f2171fb7e17f6c336a4e6db9a04ad822704a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Dec 2010 20:47:00 +0000 Subject: Make prim inventories a bit more sane --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 23 ++----- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 43 ------------ .../Framework/Scenes/SceneObjectPartInventory.cs | 76 ++++++++++------------ 3 files changed, 39 insertions(+), 103 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a1f1ea5..47c574a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -951,23 +951,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) { - SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) - { - bool fileChange = group.GetPartInventoryFileName(remoteClient, primLocalID); - if (fileChange) - { - if (XferManager != null) - { - group.RequestInventoryFile(remoteClient, primLocalID, XferManager); - } - } - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: Inventory requested of prim {0} which doesn't exist", primLocalID); - } + SceneObjectPart part = GetSceneObjectPart(primLocalID); + if (part == null) + return; + + if (XferManager != null) + part.Inventory.RequestInventoryFile(remoteClient, XferManager); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 6cc7231..50521c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -77,49 +77,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// - /// - /// - /// - public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID) - { - SceneObjectPart part = GetChildPart(localID); - if (part != null) - { - return part.Inventory.GetInventoryFileName(remoteClient, localID); - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory", - localID, Name, UUID); - } - return false; - } - - /// - /// Return serialized inventory metadata for the given constituent prim - /// - /// - /// - public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager) - { - SceneObjectPart part = GetChildPart(localID); - if (part != null) - { - part.Inventory.RequestInventoryFile(client, xferManager); - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't find part {0} in object group {1}, {2} to request inventory data", - localID, Name, UUID); - } - } - - /// /// Add an inventory item to a prim in this group. /// /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8fcfcc5..74b4e54 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -46,6 +46,7 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_inventoryFileName = String.Empty; + private byte[] m_inventoryFileData = new byte[0]; private int m_inventoryFileNameSerial = 0; private Dictionary m_scriptErrors = new Dictionary(); @@ -930,39 +931,16 @@ namespace OpenSim.Region.Framework.Scenes return -1; } - public string GetInventoryFileName() + private bool CreateInventoryFileName() { - if (m_inventoryFileName == String.Empty) - m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; - if (m_inventoryFileNameSerial < m_inventorySerial) + if (m_inventoryFileName == String.Empty || + m_inventoryFileNameSerial < m_inventorySerial) { m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; - } - return m_inventoryFileName; - } - - /// - /// Return the name with which a client can request a xfer of this prim's inventory metadata - /// - /// - /// - public bool GetInventoryFileName(IClientAPI client, uint localID) - { -// m_log.DebugFormat( -// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", -// client.AgentId, Name, UUID); - - if (m_inventorySerial > 0) - { - client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, - Utils.StringToBytes(GetInventoryFileName())); return true; } - else - { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); - return false; - } + + return false; } /// @@ -971,19 +949,34 @@ namespace OpenSim.Region.Framework.Scenes /// public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { - byte[] fileData = new byte[0]; + bool changed = CreateInventoryFileName(); - // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches - // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality - // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); - bool includeAssets = false; - if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) - includeAssets = true; - lock (m_items) { + if (m_inventorySerial == 0) // No inventory + { + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + return; + } + + client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, + Util.StringToBytes256(m_inventoryFileName)); + + if (!changed) + { + if (m_inventoryFileData.Length > 2) + { + xferManager.AddNewFile(m_inventoryFileName, + m_inventoryFileData); + } + } + + bool includeAssets = false; + if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) + includeAssets = true; + foreach (TaskInventoryItem item in m_items.Values) { UUID ownerID = item.OwnerID; @@ -1032,17 +1025,14 @@ namespace OpenSim.Region.Framework.Scenes invString.AddSectionEnd(); } } - int count = m_items.Count; - m_items.LockItemsForRead(false); - fileData = Utils.StringToBytes(invString.BuildString); + int count = m_items.Count; - //m_log.Debug(Utils.BytesToString(fileData)); - //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData)); + m_inventoryFileData = Utils.StringToBytes(invString.BuildString); - if (fileData.Length > 2) + if (m_inventoryFileData.Length > 2) { - xferManager.AddNewFile(m_inventoryFileName, fileData); + xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); } } -- cgit v1.1 From c9aa420c2d87da6285007ca52f0defbe60239c91 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Dec 2010 20:48:58 +0000 Subject: Restore CM loking after core extract --- .../Framework/Scenes/SceneObjectPartInventory.cs | 129 ++++++++++----------- 1 file changed, 64 insertions(+), 65 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 74b4e54..8ec9d55 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -953,80 +953,79 @@ namespace OpenSim.Region.Framework.Scenes InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); - lock (m_items) + Items.LockItemsForRead(true); + + if (m_inventorySerial == 0) // No inventory { - if (m_inventorySerial == 0) // No inventory - { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); - return; - } + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + return; + } - client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, - Util.StringToBytes256(m_inventoryFileName)); + client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, + Util.StringToBytes256(m_inventoryFileName)); - if (!changed) + if (!changed) + { + if (m_inventoryFileData.Length > 2) { - if (m_inventoryFileData.Length > 2) - { - xferManager.AddNewFile(m_inventoryFileName, - m_inventoryFileData); - } + xferManager.AddNewFile(m_inventoryFileName, + m_inventoryFileData); } + } - bool includeAssets = false; - if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) - includeAssets = true; + bool includeAssets = false; + if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) + includeAssets = true; - foreach (TaskInventoryItem item in m_items.Values) - { - UUID ownerID = item.OwnerID; - uint everyoneMask = 0; - uint baseMask = item.BasePermissions; - uint ownerMask = item.CurrentPermissions; - uint groupMask = item.GroupPermissions; - - invString.AddItemStart(); - invString.AddNameValueLine("item_id", item.ItemID.ToString()); - invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); - - invString.AddPermissionsStart(); - - invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); - invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); - invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); - invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); - invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); - - invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); - invString.AddNameValueLine("owner_id", ownerID.ToString()); - - invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); - - invString.AddNameValueLine("group_id", item.GroupID.ToString()); - invString.AddSectionEnd(); - - if (includeAssets) - invString.AddNameValueLine("asset_id", item.AssetID.ToString()); - else - invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); - invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); - invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); - invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); - - invString.AddSaleStart(); - invString.AddNameValueLine("sale_type", "not"); - invString.AddNameValueLine("sale_price", "0"); - invString.AddSectionEnd(); - - invString.AddNameValueLine("name", item.Name + "|"); - invString.AddNameValueLine("desc", item.Description + "|"); - - invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); - invString.AddSectionEnd(); - } + foreach (TaskInventoryItem item in m_items.Values) + { + UUID ownerID = item.OwnerID; + uint everyoneMask = 0; + uint baseMask = item.BasePermissions; + uint ownerMask = item.CurrentPermissions; + uint groupMask = item.GroupPermissions; + + invString.AddItemStart(); + invString.AddNameValueLine("item_id", item.ItemID.ToString()); + invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); + + invString.AddPermissionsStart(); + + invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); + invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); + invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); + invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); + invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); + + invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); + invString.AddNameValueLine("owner_id", ownerID.ToString()); + + invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); + + invString.AddNameValueLine("group_id", item.GroupID.ToString()); + invString.AddSectionEnd(); + + if (includeAssets) + invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + else + invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); + invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); + invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); + invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); + + invString.AddSaleStart(); + invString.AddNameValueLine("sale_type", "not"); + invString.AddNameValueLine("sale_price", "0"); + invString.AddSectionEnd(); + + invString.AddNameValueLine("name", item.Name + "|"); + invString.AddNameValueLine("desc", item.Description + "|"); + + invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); + invString.AddSectionEnd(); } - int count = m_items.Count; + Items.LockItemsForRead(false); m_inventoryFileData = Utils.StringToBytes(invString.BuildString); -- cgit v1.1 From cf37b3b9434ca940fa635c0e951fa9ac7c07175a Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 22 Dec 2010 03:25:30 +0100 Subject: Prevent a null ref when an avatar login doesn't go as planned --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 ++- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d915807..deeb817 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1093,6 +1093,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); HeartbeatThread.Abort(); + Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); HeartbeatThread = null; } m_lastUpdate = Util.EnvironmentTickCount(); @@ -4801,7 +4802,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_firstHeartbeat) return; - if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) + if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) StartTimer(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index b44a010..40a73a9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes g.ScheduleFullUpdateToAvatar(m_presence); } - while (m_partsUpdateQueue.Count > 0) + while (m_partsUpdateQueue.Count != null && m_partsUpdateQueue.Count > 0) { SceneObjectPart part = m_partsUpdateQueue.Dequeue(); -- cgit v1.1 From 32cc569b008e4d847530577081528c7baf51d8bb Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 22 Dec 2010 13:45:21 +0100 Subject: Fix up some locking issues in task inventory. Don't use any prior versions in production! --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index da1b983..9412e09 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -959,6 +959,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_inventorySerial == 0) // No inventory { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + Items.LockItemsForRead(false); return; } @@ -971,6 +972,7 @@ namespace OpenSim.Region.Framework.Scenes { xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); + Items.LockItemsForRead(false); return; } } -- cgit v1.1 From b16f4024dbf89e2a9a30232fe0be452c0e722b90 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 24 Dec 2010 21:04:10 +0100 Subject: Update child prim group positions in moving vehicles --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0297a39..faa6f37 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -730,9 +730,10 @@ namespace OpenSim.Region.Framework.Scenes { // If this is a linkset, we don't want the physics engine mucking up our group position here. PhysicsActor actor = PhysActor; - if (actor != null && _parentID == 0) + if (_parentID == 0) { - m_groupPosition = actor.Position; + if (actor != null) + m_groupPosition = actor.Position; } if (IsAttachment) @@ -742,6 +743,8 @@ namespace OpenSim.Region.Framework.Scenes return sp.AbsolutePosition; } + // use root prim's group position. Physics may have updated it + m_groupPosition = ParentGroup.RootPart.GroupPosition; return m_groupPosition; } set -- cgit v1.1 From 0aeafc9919b9f6b78adba231a03d75db16977398 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 Dec 2010 07:25:56 +0100 Subject: Fix the recent stack overflow --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index faa6f37..fe9201b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -734,6 +734,7 @@ namespace OpenSim.Region.Framework.Scenes { if (actor != null) m_groupPosition = actor.Position; + return m_groupPosition; } if (IsAttachment) @@ -741,6 +742,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); if (sp != null) return sp.AbsolutePosition; + return m_groupPosition; } // use root prim's group position. Physics may have updated it -- cgit v1.1 From b17150c3e8db0058fd1c29cb8ef991932730d31b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 Dec 2010 08:05:42 +0100 Subject: Fix the corner casse of stack overflow when logging out with attachments --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fe9201b..3e3f032 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -742,11 +742,11 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); if (sp != null) return sp.AbsolutePosition; - return m_groupPosition; } // use root prim's group position. Physics may have updated it - m_groupPosition = ParentGroup.RootPart.GroupPosition; + if (ParentGroup.RootPart != this) + m_groupPosition = ParentGroup.RootPart.GroupPosition; return m_groupPosition; } set -- cgit v1.1 From f2dd324bc8fd7ef4be7426a660d7548e53c54962 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Dec 2010 20:42:47 +0100 Subject: Fix linking link sets to rotated prims. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 72443b9..304de67 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2584,7 +2584,8 @@ namespace OpenSim.Region.Framework.Scenes axPos *= parentRot; part.OffsetPosition = axPos; - part.GroupPosition = oldGroupPosition + part.OffsetPosition; + Vector3 newPos = oldGroupPosition + part.OffsetPosition; + part.GroupPosition = newPos; part.OffsetPosition = Vector3.Zero; part.RotationOffset = worldRot; @@ -2595,7 +2596,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = linkNum; - part.OffsetPosition = part.GroupPosition - AbsolutePosition; + part.OffsetPosition = newPos - AbsolutePosition; Quaternion rootRotation = m_rootPart.RotationOffset; @@ -2605,7 +2606,7 @@ namespace OpenSim.Region.Framework.Scenes parentRot = m_rootPart.RotationOffset; oldRot = part.RotationOffset; - Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; + Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; part.RotationOffset = newRot; } -- cgit v1.1 From 61b7ec5fb552d045343590c773565968d1cdb6c1 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Sun, 26 Dec 2010 22:52:03 +0000 Subject: Fixing AbsolutePosition to correct llSensor in vehicles --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3e3f032..6496a25 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1108,12 +1108,10 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 AbsolutePosition { - get { - if (IsAttachment) - return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); - -// return m_offsetPosition + m_groupPosition; } - return m_groupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset) ; } //KF: Rotation was ignored! + get + { + return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); + } } public SceneObjectGroup ParentGroup -- cgit v1.1 From dbaaccf92af588eaa07be7e97057decf79f0668e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 29 Dec 2010 21:02:45 +0100 Subject: Copying a ref type under lock doesn't dissociate it from the source. Use a new list to do that. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index deeb817..a90caa9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1428,9 +1428,9 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAtTargets() { - Dictionary.ValueCollection objs; + List objs = new List(); lock (m_groupsWithTargets) - objs = m_groupsWithTargets.Values; + objs = new List(m_groupsWithTargets.Values); foreach (SceneObjectGroup entry in objs) entry.checkAtTargets(); -- cgit v1.1 From 04e450e2bc065bd6049939129d0eacc851e014ba Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 31 Dec 2010 16:05:59 +0100 Subject: Fix child agent scoping --- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 632646d..c8af4c3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -189,7 +189,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); + public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, UUID scopeID, ulong regionHandle); /// /// This informs all neighboring regions about the settings of it's child agent. @@ -198,7 +198,7 @@ namespace OpenSim.Region.Framework.Scenes /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc. /// /// - private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, ulong regionHandle) + private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, UUID scopeID, ulong regionHandle) { //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName); try @@ -241,7 +241,7 @@ namespace OpenSim.Region.Framework.Scenes if (regionHandle != m_regionInfo.RegionHandle) { SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; - d.BeginInvoke(cAgentData, regionHandle, + d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, regionHandle, SendChildAgentDataUpdateCompleted, d); } @@ -269,7 +269,7 @@ namespace OpenSim.Region.Framework.Scenes //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); uint x = 0, y = 0; Utils.LongToUInts(regionHandle, out x, out y); - GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); m_scene.SimulationService.CloseChildAgent(destination, agentID); } -- cgit v1.1 From e15ab75d620a3d90c22bcb1c33679feb0666922a Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 3 Jan 2011 19:56:56 +0100 Subject: Add permissions hooks for object transfers --- .../Region/Framework/Scenes/Scene.Permissions.cs | 61 ++++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 66439ab..e1fedf4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -43,6 +43,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool PropagatePermissionsHandler(); public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene); public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene); + public delegate bool TransferObjectHandler(UUID objectID, UUID recipient, Scene scene); public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene); public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene); public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); @@ -80,10 +81,12 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID); public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); + public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); public delegate bool CreateUserInventoryHandler(int invType, UUID userID); public delegate bool EditUserInventoryHandler(UUID itemID, UUID userID); public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); + public delegate bool TransferUserInventoryHandler(UUID itemID, UUID userID, UUID recipientID); public delegate bool TeleportHandler(UUID userID, Scene scene); public delegate bool ControlPrimMediaHandler(UUID userID, UUID primID, int face); public delegate bool InteractWithPrimMediaHandler(UUID userID, UUID primID, int face); @@ -107,6 +110,7 @@ namespace OpenSim.Region.Framework.Scenes public event PropagatePermissionsHandler OnPropagatePermissions; public event RezObjectHandler OnRezObject; public event DeleteObjectHandler OnDeleteObject; + public event TransferObjectHandler OnTransferObject; public event TakeObjectHandler OnTakeObject; public event TakeCopyObjectHandler OnTakeCopyObject; public event DuplicateObjectHandler OnDuplicateObject; @@ -144,10 +148,12 @@ namespace OpenSim.Region.Framework.Scenes public event CreateObjectInventoryHandler OnCreateObjectInventory; public event CopyObjectInventoryHandler OnCopyObjectInventory; public event DeleteObjectInventoryHandler OnDeleteObjectInventory; + public event TransferObjectInventoryHandler OnTransferObjectInventory; public event CreateUserInventoryHandler OnCreateUserInventory; public event EditUserInventoryHandler OnEditUserInventory; public event CopyUserInventoryHandler OnCopyUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory; + public event TransferUserInventoryHandler OnTransferUserInventory; public event TeleportHandler OnTeleport; public event ControlPrimMediaHandler OnControlPrimMedia; public event InteractWithPrimMediaHandler OnInteractWithPrimMedia; @@ -264,10 +270,27 @@ namespace OpenSim.Region.Framework.Scenes } } -// m_log.DebugFormat( -// "[SCENE PERMISSIONS]: CanDeleteObject() fired for object {0}, deleter {1}, result {2}", -// objectID, deleter, result); - + return result; + } + + public bool CanTransferObject(UUID objectID, UUID recipient) + { + bool result = true; + + TransferObjectHandler handler = OnTransferObject; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (TransferObjectHandler h in list) + { + if (h(objectID, recipient, m_scene) == false) + { + result = false; + break; + } + } + } + return result; } @@ -917,6 +940,21 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public bool CanTransferObjectInventory(UUID itemID, UUID objectID, UUID userID) + { + TransferObjectInventoryHandler handler = OnTransferObjectInventory; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (TransferObjectInventoryHandler h in list) + { + if (h(itemID, objectID, userID) == false) + return false; + } + } + return true; + } + /// /// Check whether the specified user is allowed to create the given inventory type in their inventory. /// @@ -1001,6 +1039,21 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public bool CanTransferUserInventory(UUID itemID, UUID userID, UUID recipientID) + { + TransferUserInventoryHandler handler = OnTransferUserInventory; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (TransferUserInventoryHandler h in list) + { + if (h(itemID, userID, recipientID) == false) + return false; + } + } + return true; + } + public bool CanTeleport(UUID userID) { TeleportHandler handler = OnTeleport; -- cgit v1.1 From ba7a2277633804eb2d5e449efa0895e9f43a4ece Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Tue, 4 Jan 2011 21:36:09 +0000 Subject: Revise Materials properties; Fix Double-Click Autopilot; Allow non-script sit positions >= 0.1M; Add llLookAt(); Comment out spammy bad adjacent sim message. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 557fc42..208c2a6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1758,7 +1758,7 @@ namespace OpenSim.Region.Framework.Scenes return; } m_moveToPositionInProgress = true; - m_moveToPositionTarget = new Vector3(locx, locy, locz); + m_moveToPositionTarget = new Vector3(locx, locy, locz + (m_appearance.AvatarHeight / 2.0f)); } catch (Exception ex) { @@ -2008,7 +2008,7 @@ namespace OpenSim.Region.Framework.Scenes } else // Not Scripted { - if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) + if ( (Math.Abs(offset.X) > 0.1f) || (Math.Abs(offset.Y) > 0.1f) ) // Changed 0.5M to 0.1M as they want to be able to sit close together { // large prim & offset, ignore if other Avs sitting // offset.Z -= 0.05f; -- cgit v1.1 From d1b6b4d28893b890ad9766aebd52a3227162cdaa Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 6 Jan 2011 19:12:25 +0100 Subject: Fix god mode perms adjustment --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3cfca4b..970003a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1179,6 +1179,8 @@ namespace OpenSim.Region.Framework.Scenes item.CurrentPermissions = perms; item.BasePermissions = perms; } + m_inventorySerial++; + HasInventoryChanged = true; } public bool ContainsScripts() -- cgit v1.1 From 1ab9cd0997b30eae24b0fc609d7d8598e5a549fc Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 8 Jan 2011 13:51:34 +0100 Subject: Fix a couple of security issues --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 +++ OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 682c36d..5658f90 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2025,6 +2025,9 @@ namespace OpenSim.Region.Framework.Scenes public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) { + if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) + return; + SceneObjectPart part = GetSceneObjectPart(objectID); if (part == null) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 970003a..5a39941 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -48,6 +48,7 @@ namespace OpenSim.Region.Framework.Scenes private string m_inventoryFileName = String.Empty; private byte[] m_inventoryFileData = new byte[0]; private uint m_inventoryFileNameSerial = 0; + private bool m_inventoryPrivileged = false; private Dictionary m_scriptErrors = new Dictionary(); @@ -952,6 +953,13 @@ namespace OpenSim.Region.Framework.Scenes { bool changed = CreateInventoryFileName(); + bool includeAssets = false; + if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) + includeAssets = true; + + if (m_inventoryPrivileged != includeAssets) + changed = true; + InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); Items.LockItemsForRead(true); @@ -977,9 +985,7 @@ namespace OpenSim.Region.Framework.Scenes } } - bool includeAssets = false; - if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) - includeAssets = true; + m_inventoryPrivileged = includeAssets; foreach (TaskInventoryItem item in m_items.Values) { -- cgit v1.1 From c271bbcc8af1549666f6a5299a4b9ab9cf1c86d9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 8 Jan 2011 16:44:28 +0100 Subject: Preserve the script running flag when copying an object. --- .../Framework/Scenes/SceneObjectPartInventory.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5a39941..6c56dc3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -94,6 +94,7 @@ namespace OpenSim.Region.Framework.Scenes { m_items = value; m_inventorySerial++; + QueryScriptStates(); } } @@ -226,6 +227,36 @@ namespace OpenSim.Region.Framework.Scenes m_items.LockItemsForWrite(false); } + private void QueryScriptStates() + { + if (m_part == null || m_part.ParentGroup == null) + return; + + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); + if (engines == null) // No engine at all + return; + + Items.LockItemsForRead(true); + foreach (TaskInventoryItem item in Items.Values) + { + if (item.InvType == (int)InventoryType.LSL) + { + foreach (IScriptModule e in engines) + { + bool running; + + if (e.HasScript(item.ItemID, out running)) + { + item.ScriptRunning = running; + break; + } + } + } + } + + Items.LockItemsForRead(false); + } + /// /// Start all the scripts contained in this prim's inventory /// @@ -349,6 +380,9 @@ namespace OpenSim.Region.Framework.Scenes m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); StoreScriptErrors(item.ItemID, null); + if (!item.ScriptRunning) + m_part.ParentGroup.Scene.EventManager.TriggerStopScript( + m_part.LocalId, item.ItemID); m_part.ParentGroup.AddActiveScriptCount(1); m_part.ScheduleFullUpdate(); } -- cgit v1.1 From 72048169c0f8aea6806f987f8ef932798f73a8aa Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 Jan 2011 22:02:09 +0100 Subject: Taint SOGs the right way --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 304de67..6e0fc43 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2857,8 +2857,12 @@ namespace OpenSim.Region.Framework.Scenes } } + RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); for (int i = 0; i < parts.Length; i++) - parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + { + if (parts[i] != RootPart) + parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + } } } -- cgit v1.1 From 2c6a410e903767a9c4f18777ec0d9fd862fe531e Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 Jan 2011 22:02:22 +0100 Subject: Partial permissions fix for boxed items. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 10 ++++++++++ .../Framework/Scenes/SceneObjectPartInventory.cs | 18 ++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5658f90..1f32362 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2171,5 +2171,15 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.LinkObjects(root, children); } + + private string PermissionString(uint permissions) + { + PermissionMask perms = (PermissionMask)permissions & + (PermissionMask.Move | + PermissionMask.Copy | + PermissionMask.Transfer | + PermissionMask.Modify); + return perms.ToString(); + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 6c56dc3..3b1ab01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1163,16 +1163,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (TaskInventoryItem item in m_items.Values) { - if (item.InvType != (int)InventoryType.Object) - { - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) - mask &= ~((uint)PermissionMask.Copy >> 13); - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) - mask &= ~((uint)PermissionMask.Transfer >> 13); - if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) - mask &= ~((uint)PermissionMask.Modify >> 13); - } - else + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) + mask &= ~((uint)PermissionMask.Copy >> 13); + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) + mask &= ~((uint)PermissionMask.Transfer >> 13); + if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) + mask &= ~((uint)PermissionMask.Modify >> 13); + + if (item.InvType == (int)InventoryType.Object) { if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) mask &= ~((uint)PermissionMask.Copy >> 13); -- cgit v1.1 From 7f99a8c900251c59bc7cb7d8309a14ad5360de42 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Jan 2011 16:20:38 +0100 Subject: Fix direct item give permissions --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 44 +++++++++++++++++++--- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 2 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 22 ++++++++--- 3 files changed, 56 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1f32362..7216b39 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -308,10 +308,17 @@ namespace OpenSim.Region.Framework.Scenes { if (UUID.Zero == transactionID) { + item.Flags = itemUpd.Flags; item.Name = itemUpd.Name; item.Description = itemUpd.Description; + if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) + item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; + if (item.EveryOnePermissions != (itemUpd.EveryOnePermissions & item.BasePermissions)) + item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions; + if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions)) + item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions; item.GroupID = itemUpd.GroupID; item.GroupOwned = itemUpd.GroupOwned; @@ -326,9 +333,12 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Check if folder changed and move item //item.NextPermissions = itemUpd.Folder; item.InvType = itemUpd.InvType; + + if (item.SalePrice != itemUpd.SalePrice || + item.SaleType != itemUpd.SaleType) + item.Flags |= (uint)InventoryItemFlags.ObjectSlamSale; item.SalePrice = itemUpd.SalePrice; item.SaleType = itemUpd.SaleType; - item.Flags = itemUpd.Flags; InventoryService.UpdateItem(item); } @@ -509,7 +519,8 @@ namespace OpenSim.Region.Framework.Scenes // Assign to the actual item. Make sure the slam bit is // set, if it wasn't set before. itemCopy.BasePermissions = basePerms; - itemCopy.CurrentPermissions = ownerPerms | 16; // Slam + itemCopy.CurrentPermissions = ownerPerms; + itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; itemCopy.NextPermissions = item.NextPermissions; @@ -1049,7 +1060,7 @@ namespace OpenSim.Region.Framework.Scenes else agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; - agentItem.CurrentPermissions |= 16; // Slam + agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; @@ -1260,7 +1271,7 @@ namespace OpenSim.Region.Framework.Scenes (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); destTaskItem.BasePermissions = srcTaskItem.BasePermissions & (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); - destTaskItem.CurrentPermissions |= 16; // Slam! + destTaskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; } } @@ -1434,6 +1445,8 @@ namespace OpenSim.Region.Framework.Scenes // Base ALWAYS has move currentItem.BasePermissions |= (uint)PermissionMask.Move; + itemInfo.Flags = currentItem.Flags; + // Check if we're allowed to mess with permissions if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god { @@ -1451,6 +1464,14 @@ namespace OpenSim.Region.Framework.Scenes // Owner can't change base, and can change other // only up to base itemInfo.BasePermissions = currentItem.BasePermissions; + if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; + if (itemInfo.GroupPermissions != currentItem.GroupPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; + if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; + if (itemInfo.NextPermissions != currentItem.NextPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; itemInfo.EveryonePermissions &= currentItem.BasePermissions; itemInfo.GroupPermissions &= currentItem.BasePermissions; itemInfo.CurrentPermissions &= currentItem.BasePermissions; @@ -1458,6 +1479,19 @@ namespace OpenSim.Region.Framework.Scenes } } + else + { + if (itemInfo.BasePermissions != currentItem.BasePermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase; + if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; + if (itemInfo.GroupPermissions != currentItem.GroupPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; + if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; + if (itemInfo.NextPermissions != currentItem.NextPermissions) + itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; + } // Next ALWAYS has move itemInfo.NextPermissions |= (uint)PermissionMask.Move; @@ -1666,7 +1700,7 @@ namespace OpenSim.Region.Framework.Scenes srcTaskItem.NextPermissions; destTaskItem.BasePermissions = srcTaskItem.BasePermissions & srcTaskItem.NextPermissions; - destTaskItem.CurrentPermissions |= 16; // Slam! + destTaskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 50521c4..0b545c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes taskItem.NextPermissions = item.NextPermissions; // We're adding this to a prim we don't own. Force // owner change - taskItem.CurrentPermissions |= 16; // Slam + taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3b1ab01..8761284 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -815,14 +815,19 @@ namespace OpenSim.Region.Framework.Scenes group.SetGroup(m_part.GroupID, null); - if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) + // TODO: Remove magic number badness + if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number { if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) { foreach (SceneObjectPart part in partList) { - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + part.EveryoneMask = item.EveryonePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + part.GroupMask = item.GroupPermissions; } group.ApplyNextOwnerPermissions(); @@ -831,15 +836,20 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in partList) { - if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) + // TODO: Remove magic number badness + if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; part.Inventory.ChangeInventoryOwner(item.OwnerID); } - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + part.EveryoneMask = item.EveryonePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + part.GroupMask = item.GroupPermissions; } rootPart.TrimPermissions(); -- cgit v1.1 From f59b55d930b4a715d2ea5b99d2b3f5494073b1ae Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Jan 2011 17:40:21 +0100 Subject: Dont' trust the viewer! Fix a permission slam error caused by trusting the viewer too much. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7216b39..7fa5509 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -308,7 +308,6 @@ namespace OpenSim.Region.Framework.Scenes { if (UUID.Zero == transactionID) { - item.Flags = itemUpd.Flags; item.Name = itemUpd.Name; item.Description = itemUpd.Description; if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) -- cgit v1.1 From d92069fb8b0a4f1ca51a24599ae308458c424e19 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 13 Jan 2011 04:44:04 +0000 Subject: Add llLookAt() kinetic. Reduce StandUp +x offset to 0.3M. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b8ad3ca..927f78d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1866,7 +1866,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion partIRot = Quaternion.Inverse(partRot); Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av - Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av + Vector3 avStandUp = new Vector3(0.3f, 0f, 0f) * avatarRot; // 0.3M infront of av if (m_physicsActor == null) -- cgit v1.1 From 139e84c0b2033462bdfa91b186fb77432474afc5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Jan 2011 01:01:02 +0100 Subject: Fix slam bits being lost when editing perms in prim inventory --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8761284..2ee8c07 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -881,7 +881,6 @@ namespace OpenSim.Region.Framework.Scenes { item.ParentID = m_part.UUID; item.ParentPartID = m_part.UUID; - item.Flags = m_items[item.ItemID].Flags; // If group permissions have been set on, check that the groupID is up to date in case it has // changed since permissions were last set. -- cgit v1.1 From a30bbcbb64e9b985b0db4c4b795ad369d7f4cda7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Jan 2011 04:09:02 +0100 Subject: Temporarily reinstate prim counting in the update loop to make the production systems run --- OpenSim/Region/Framework/Scenes/Scene.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 066e504..a4f630a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -151,7 +151,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_update_events = 1; private int m_update_backup = 200; private int m_update_terrain = 50; -// private int m_update_land = 1; + private int m_update_land = 10; private int m_update_coarse_locations = 50; private int frameMS; @@ -1330,12 +1330,12 @@ namespace OpenSim.Region.Framework.Scenes terrainMS = Util.EnvironmentTickCountSubtract(terMS); } - //if (m_frame % m_update_land == 0) - //{ - // int ldMS = Util.EnvironmentTickCount(); - // UpdateLand(); - // landMS = Util.EnvironmentTickCountSubtract(ldMS); - //} + if (m_frame % m_update_land == 0) + { + int ldMS = Util.EnvironmentTickCount(); + UpdateLand(); + landMS = Util.EnvironmentTickCountSubtract(ldMS); + } frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; -- cgit v1.1 From 76f39d326e88f0793daf5d1f0d19654d596d572c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Jan 2011 18:26:41 +0100 Subject: Add a new ViewObjectInventory permission to decouple viewing from +MOD status --- OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index e1fedf4..48beb9c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -49,6 +49,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); + public delegate bool ViewObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); @@ -116,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes public event DuplicateObjectHandler OnDuplicateObject; public event EditObjectHandler OnEditObject; public event EditObjectInventoryHandler OnEditObjectInventory; + public event ViewObjectInventoryHandler OnViewObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; public event ReturnObjectsHandler OnReturnObjects; @@ -401,6 +403,21 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public bool CanViewObjectInventory(UUID objectID, UUID editorID) + { + ViewObjectInventoryHandler handler = OnViewObjectInventory; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (ViewObjectInventoryHandler h in list) + { + if (h(objectID, editorID, m_scene) == false) + return false; + } + } + return true; + } + #endregion #region MOVE OBJECT -- cgit v1.1 From 17787e7c87c82f266c9b9d5f525cf3c5bead6ce8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 22 Jan 2011 19:00:46 +0100 Subject: Completely nixing flags from the client causes wearables to break. Fix it so we let the lowest byte through. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7fa5509..9a93a26 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -308,6 +308,7 @@ namespace OpenSim.Region.Framework.Scenes { if (UUID.Zero == transactionID) { + item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); item.Name = itemUpd.Name; item.Description = itemUpd.Description; if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) -- cgit v1.1 From 649d9ef93445439f6e222802757e1bc7d08d919c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 24 Jan 2011 02:20:54 +0100 Subject: Fix script data not being reset as it should be --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2ee8c07..7e59b10 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -189,6 +189,8 @@ namespace OpenSim.Region.Framework.Scenes { item.LastOwnerID = item.OwnerID; item.OwnerID = ownerId; + item.PermsMask = 0; + item.PermsGranter = UUID.Zero; } } m_items.LockItemsForWrite(false); @@ -1216,6 +1218,8 @@ namespace OpenSim.Region.Framework.Scenes item.CurrentPermissions &= item.NextPermissions; item.BasePermissions &= item.NextPermissions; item.EveryonePermissions &= item.NextPermissions; + item.PermsMask = 0; + item.PermsGranter = UUID.Zero; } } -- cgit v1.1 From 3ecf712e4dd5318442e7c853eb43299840594ce5 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 14:20:39 -0800 Subject: Add userFlags check to isBanned. This checks bans against DenyAnonymous and DenyMinors. Note that the ban doesn't actually work yet due to some stuff mel's working on . --- OpenSim/Region/Framework/Scenes/Scene.cs | 43 +++++++++++++++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 +++++ 2 files changed, 47 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a4f630a..2ca82ca 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2443,7 +2443,15 @@ namespace OpenSim.Region.Framework.Scenes // If the user is banned, we won't let any of their objects // enter. Period. // - if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) + int flags = 0; + ScenePresence sp; + if (TryGetScenePresence(sceneObject.OwnerID, out sp)) + { + flags = sp.UserFlags; + } + + + if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) { m_log.Info("[INTERREGION]: Denied prim crossing for " + "banned avatar"); @@ -2472,7 +2480,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart RootPrim = sceneObject.RootPart; // Fix up attachment Parent Local ID - ScenePresence sp = GetScenePresence(sceneObject.OwnerID); + sp = GetScenePresence(sceneObject.OwnerID); if (sp != null) { @@ -3617,8 +3625,29 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID)) + int flags = 0; + ScenePresence sp; + if (TryGetScenePresence(agent.AgentID, out sp)) { + flags = sp.UserFlags; + } + if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags)) + { + //Add some more info to help users + if (!m_regInfo.EstateSettings.IsBanned(agent.AgentID, 32)) + { + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the region requires age verification", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + reason = String.Format("Denied access to region (0): Region requires age verification"); + return false; + } + if (!m_regInfo.EstateSettings.IsBanned(agent.AgentID, 4)) + { + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the region requires payment info on file", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + reason = String.Format("Denied access to region (0): Region requires payment info on file"); + return false; + } m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: You have been banned from that region.", @@ -3807,7 +3836,13 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence - if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID)) + int flags = 0; + ScenePresence sp; + if (TryGetScenePresence(cAgentData.AgentID, out sp)) + { + flags = sp.UserFlags; + } + if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) { m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); return false; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6a3983f..c4ae0f0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -113,6 +113,7 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_attachments; } } + protected List m_attachments = new List(); private Dictionary scriptedcontrols = new Dictionary(); @@ -136,6 +137,12 @@ namespace OpenSim.Region.Framework.Scenes private bool m_updateflag; private byte m_movementflag; private Vector3? m_forceToApply; + private int m_userFlags; + public int UserFlags + { + get { return m_userFlags; } + } + private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID; public bool SitGround = false; @@ -763,6 +770,7 @@ namespace OpenSim.Region.Framework.Scenes m_localId = m_scene.AllocateLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); + m_userFlags = account.UserFlags; if (account != null) m_userLevel = account.UserLevel; -- cgit v1.1 From 6b27587bc7631d6fd083f3b4f752d9ddcfda4830 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 16:25:08 -0800 Subject: Add a "useCached" parameter to GetUserAccount. Add a function to Scene to get the user flags. It has to be here due to access restrictions :/ --- OpenSim/Region/Framework/Scenes/Scene.cs | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2ca82ca..99248c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2443,14 +2443,7 @@ namespace OpenSim.Region.Framework.Scenes // If the user is banned, we won't let any of their objects // enter. Period. // - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(sceneObject.OwnerID, out sp)) - { - flags = sp.UserFlags; - } - - + int flags = GetUserFlags(sceneObject.OwnerID); if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) { m_log.Info("[INTERREGION]: Denied prim crossing for " + @@ -2480,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart RootPrim = sceneObject.RootPart; // Fix up attachment Parent Local ID - sp = GetScenePresence(sceneObject.OwnerID); + ScenePresence sp = GetScenePresence(sceneObject.OwnerID); if (sp != null) { @@ -2554,7 +2547,22 @@ namespace OpenSim.Region.Framework.Scenes } return 2; // StateSource.PrimCrossing } - + public int GetUserFlags(UUID user) + { + //Unfortunately the SP approach means that the value is cached until region is restarted + /* + ScenePresence sp; + if (TryGetScenePresence(user, out sp)) + { + return sp.UserFlags; + } + else + { + */ + UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user, false); + return uac.UserFlags; + //} + } #endregion #region Add/Remove Avatar Methods @@ -3625,12 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(agent.AgentID, out sp)) - { - flags = sp.UserFlags; - } + int flags = GetUserFlags(agent.AgentID); if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags)) { //Add some more info to help users @@ -3836,12 +3839,7 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(cAgentData.AgentID, out sp)) - { - flags = sp.UserFlags; - } + int flags = GetUserFlags(cAgentData.AgentID); if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) { m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); -- cgit v1.1 From 31fb448cfc9c43532c38a58fff75fb6c0e67d632 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 17:06:17 -0800 Subject: Mostly revert the last commit with the aim of searching for a better solution --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 99248c1..236e9c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2559,7 +2559,7 @@ namespace OpenSim.Region.Framework.Scenes else { */ - UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user, false); + UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); return uac.UserFlags; //} } -- cgit v1.1 From 11c742a5a8b1edd97923cc445aa43e0ba92f1bce Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 02:16:41 +0100 Subject: Make bans work for teleport. Now teleport will complete block if the user is not allowed on the estate. If the user is allowed on no parcel, the teleport will also be blocked. If the user is allowed on a parcel, but not the desired one, the user will be shifted to the closest allowed location. --- OpenSim/Region/Framework/Scenes/Scene.cs | 99 ++++++++++++++++---------------- 1 file changed, 48 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a4f630a..fc4110b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3387,12 +3387,11 @@ namespace OpenSim.Region.Framework.Scenes sp = null; } - ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); //On login test land permisions if (vialogin) { - if (land != null && !TestLandRestrictions(agent, land, out reason)) + if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) { m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); return false; @@ -3417,8 +3416,13 @@ namespace OpenSim.Region.Framework.Scenes try { - if (!AuthorizeUser(agent, out reason)) - return false; + // Always check estate if this is a login. Always + // check if banned regions are to be blacked out. + if (vialogin || (!m_seeIntoBannedRegion)) + { + if (!AuthorizeUser(agent.AgentID, out reason)) + return false; + } } catch (Exception e) { @@ -3527,21 +3531,26 @@ namespace OpenSim.Region.Framework.Scenes return true; } - private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) + private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { - - bool banned = land.IsBannedFromLand(agent.AgentID); - bool restricted = land.IsRestrictedFromLand(agent.AgentID); + reason = String.Empty; + + ILandObject land = LandChannel.GetLandObject(posX, posY); + if (land == null) + return false; + + bool banned = land.IsBannedFromLand(agentID); + bool restricted = land.IsRestrictedFromLand(agentID); if (banned || restricted) { - ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); + ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); if (nearestParcel != null) { //Move agent to nearest allowed Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); - agent.startpos.X = newPosition.X; - agent.startpos.Y = newPosition.Y; + posX = newPosition.X; + posY = newPosition.Y; } else { @@ -3597,19 +3606,19 @@ namespace OpenSim.Region.Framework.Scenes /// outputs the reason to this string /// True if the region accepts this agent. False if it does not. False will /// also return a reason. - protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) + protected virtual bool AuthorizeUser(UUID agentID, out string reason) { reason = String.Empty; if (!m_strictAccessControl) return true; - if (Permissions.IsGod(agent.AgentID)) return true; + if (Permissions.IsGod(agentID)) return true; if (AuthorizationService != null) { - if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) + if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", - agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", + agentID, RegionInfo.RegionName); //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); return false; } @@ -3617,10 +3626,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID)) + if (m_regInfo.EstateSettings.IsBanned(agentID)) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", - agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the banlist", + agentID, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: You have been banned from that region.", RegionInfo.RegionName); return false; @@ -3637,7 +3646,7 @@ namespace OpenSim.Region.Framework.Scenes if (groupsModule != null) { GroupMembershipData[] GroupMembership = - groupsModule.GetMembershipData(agent.AgentID); + groupsModule.GetMembershipData(agentID); if (GroupMembership != null) { @@ -3666,44 +3675,16 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); if (!m_regInfo.EstateSettings.PublicAccess && - !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && + !m_regInfo.EstateSettings.HasAccess(agentID) && !groupAccess) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", - agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", + agentID, RegionInfo.RegionName); reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", RegionInfo.RegionName); return false; } - // TODO: estate/region settings are not properly hooked up - // to ILandObject.isRestrictedFromLand() - // if (null != LandChannel) - // { - // // region seems to have local Id of 1 - // ILandObject land = LandChannel.GetLandObject(1); - // if (null != land) - // { - // if (land.isBannedFromLand(agent.AgentID)) - // { - // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", - // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); - // reason = String.Format("Denied access to private region {0}: You are banned from that region.", - // RegionInfo.RegionName); - // return false; - // } - - // if (land.isRestrictedFromLand(agent.AgentID)) - // { - // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", - // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); - // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", - // RegionInfo.RegionName); - // return false; - // } - // } - // } - return true; } @@ -5173,6 +5154,22 @@ namespace OpenSim.Region.Framework.Scenes // child agent creation, thereby emulating the SL behavior. public bool QueryAccess(UUID agentID) { + string reason; + + if (!AuthorizeUser(agentID, out reason)) + { + m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); + return false; + } + + float posX = 128.0f; + float posY = 128.0f; + + if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) + { + m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); + return false; + } return true; } } -- cgit v1.1 From 307a2c61ef8106ae6aad3cd4a25c9067cdaf888a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 02:43:52 +0100 Subject: Fix merge artifacts --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6a5f84a..f85db84 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3643,7 +3643,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - int flags = GetUserFlags(agent.AgentID); + int flags = GetUserFlags(agentID); if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) { //Add some more info to help users @@ -3657,12 +3657,12 @@ namespace OpenSim.Region.Framework.Scenes if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) { m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", - agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + agentID, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); return false; } m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", - agent.AgentID, RegionInfo.RegionName); + agentID, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: You have been banned from that region.", RegionInfo.RegionName); return false; -- cgit v1.1 From 0e1d28a86277537ead2f35c8a5eefc7dbd596d8a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 03:05:33 +0100 Subject: Clear user account cache before checking flags on login. This will make AV and other bannable flags work in this case. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f85db84..d9850d6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3408,6 +3408,9 @@ namespace OpenSim.Region.Framework.Scenes //On login test land permisions if (vialogin) { + IUserAccountCacheModule cache = RequestModuleInterface(); + if (cache != null) + cache.Remove(agent.firstname + " " + agent.lastname); if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) { m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); -- cgit v1.1 From c43b892f3a644028391fd02a6c29cb88de5b356f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 04:14:41 +0100 Subject: Add a TeleportFlags member to SP so we can tell how we got there. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++++++++++ 2 files changed, 14 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d9850d6..9bad644 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3472,6 +3472,10 @@ namespace OpenSim.Region.Framework.Scenes } + // Let the SP know how we got here. This has a lot of interesting + // uses down the line. + sp.TeleportFlags = (TeleportFlags)teleportFlags; + // In all cases, add or update the circuit data with the new agent circuit data and teleport flags agent.teleportFlags = teleportFlags; m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c4ae0f0..c108129 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -142,6 +142,12 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_userFlags; } } + private TeleportFlags m_teleportFlags; + public TeleportFlags TeleportFlags + { + get { return m_teleportFlags; } + set { m_teleportFlags = value; } + } private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID; @@ -1083,6 +1089,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void MakeChildAgent() { + // Reset these so that teleporting in and walking out isn't seen + // as teleporting back + m_teleportFlags = TeleportFlags.Default; + // It looks like m_animator is set to null somewhere, and MakeChild // is called after that. Probably in aborted teleports. if (m_animator == null) -- cgit v1.1 From 4cc8d842813dc6cc6dffc9f6895bdc71eb456edc Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 05:30:39 +0000 Subject: Fix build break --- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 56eaf06..7f308da 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2578,6 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; CheckHeartbeat(); + ScenePresence presence; if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here { -- cgit v1.1 From d894007920744979296284e78cb42d504037abc3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 05:46:31 +0100 Subject: Make it work --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7f308da..bb9a748 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2590,6 +2590,8 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance); m_eventManager.TriggerOnNewPresence(sp); + sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; + // HERE!!! Do the initial attachments right here // first agent upon login is a root agent by design. // All other AddNewClient calls find aCircuit.child to be true @@ -3404,6 +3406,10 @@ namespace OpenSim.Region.Framework.Scenes } else { + // Let the SP know how we got here. This has a lot of interesting + // uses down the line. + sp.TeleportFlags = (TeleportFlags)teleportFlags; + if (sp.IsChildAgent) { m_log.DebugFormat( @@ -3416,10 +3422,6 @@ namespace OpenSim.Region.Framework.Scenes } - // Let the SP know how we got here. This has a lot of interesting - // uses down the line. - sp.TeleportFlags = (TeleportFlags)teleportFlags; - // In all cases, add or update the circuit data with the new agent circuit data and teleport flags agent.teleportFlags = teleportFlags; m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); -- cgit v1.1 From eca82d90c2116645a7f03bd0ebd37d41b6eda826 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 06:04:56 +0100 Subject: Change the way landing points are honored --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c108129..5440e6c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -948,16 +948,23 @@ namespace OpenSim.Region.Framework.Scenes pos.Y = crossedBorder.BorderLine.Z - 1; } - //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. - //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, - //they'll bypass the landing point. But I can't think of any decent way of fixing this. ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) { - if (KnownChildRegionHandles.Count == 0) + // If we come in via login, landmark or map, we want to + // honor landing points. If we come in via Lure, we want + // to ignore them. + if ((m_teleportFlags & (TeleportFlags.ViaLogin | + TeleportFlags.ViaLandmark | + TeleportFlags.ViaLocation)) != 0) { - //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) + // Don't restrict gods, estate managers, or land owners to + // the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)LandingType.LandingPoint && + land.LandData.UserLocation != Vector3.Zero && + land.LandData.OwnerID != m_uuid && + (!m_scene.Permissions.IsGod(m_uuid)) && + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) { pos = land.LandData.UserLocation; } -- cgit v1.1 From 1143e022b41c835bf0d587c2ddd6a70504d78d42 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 06:45:53 +0100 Subject: Make landing points work on local teleports. Constrain owners and gods to landing points when coming from off sim (matches agni) to prevent landing in floors or other prims. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 31 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5440e6c..7445f57 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -954,17 +954,17 @@ namespace OpenSim.Region.Framework.Scenes // If we come in via login, landmark or map, we want to // honor landing points. If we come in via Lure, we want // to ignore them. - if ((m_teleportFlags & (TeleportFlags.ViaLogin | - TeleportFlags.ViaLandmark | - TeleportFlags.ViaLocation)) != 0) + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || + (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0) { // Don't restrict gods, estate managers, or land owners to // the TP point. This behaviour mimics agni. if (land.LandData.LandingType == (byte)LandingType.LandingPoint && land.LandData.UserLocation != Vector3.Zero && - land.LandData.OwnerID != m_uuid && + ((land.LandData.OwnerID != m_uuid && (!m_scene.Permissions.IsGod(m_uuid)) && - (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) { pos = land.LandData.UserLocation; } @@ -1158,6 +1158,7 @@ namespace OpenSim.Region.Framework.Scenes RemoveFromPhysicalScene(); Velocity = Vector3.Zero; + CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); if (m_appearance != null) @@ -1177,6 +1178,7 @@ namespace OpenSim.Region.Framework.Scenes isFlying = m_physicsActor.Flying; RemoveFromPhysicalScene(); + CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); if (m_appearance != null) @@ -2099,6 +2101,7 @@ namespace OpenSim.Region.Framework.Scenes // { // Single, or Root prim of linkset, target is ClickOffset * RootRot //offsetr = offset * partIRot; // + // } // else // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + @@ -4415,5 +4418,23 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju } } } + + private void CheckLandingPoint(ref Vector3 pos) + { + // Never constrain lures + if ((TeleportFlags & TeleportFlags.ViaLure) != 0) + return; + + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + + if (land.LandData.LandingType == (byte)LandingType.LandingPoint && + land.LandData.UserLocation != Vector3.Zero && + land.LandData.OwnerID != m_uuid && + (!m_scene.Permissions.IsGod(m_uuid)) && + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) + { + pos = land.LandData.UserLocation; + } + } } } -- cgit v1.1 From 8568c6a7c038a8f49b926d44ca5324c741c80c98 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 06:57:54 +0100 Subject: Implement "Cannot teleport closer to destination" message --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7445f57..5810824 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4433,7 +4433,11 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju (!m_scene.Permissions.IsGod(m_uuid)) && (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) { - pos = land.LandData.UserLocation; + float curr = Vector3.Distance(AbsolutePosition, pos); + if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) + pos = land.LandData.UserLocation; + else + ControllingClient.SendAlertMessage("Can't teleport closer to destination"); } } } -- cgit v1.1 From 2a9e712cb4381c585505cbe5aa98092a41a617b5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 07:03:43 +0100 Subject: Let gods TP in wherever they like while in god mode --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5810824..1925daa 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -962,6 +962,7 @@ namespace OpenSim.Region.Framework.Scenes // the TP point. This behaviour mimics agni. if (land.LandData.LandingType == (byte)LandingType.LandingPoint && land.LandData.UserLocation != Vector3.Zero && + GodLevel < 200 && ((land.LandData.OwnerID != m_uuid && (!m_scene.Permissions.IsGod(m_uuid)) && (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) -- cgit v1.1 From b13eac99963bf4db480f13429895b0131ea07a29 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Jan 2011 07:07:33 +0100 Subject: Make the estate setting "Allow direct teleport" override the constraint of local tepeports to landing points like it is meant to --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1925daa..db9a95b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4426,6 +4426,9 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju if ((TeleportFlags & TeleportFlags.ViaLure) != 0) return; + if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) + return; + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land.LandData.LandingType == (byte)LandingType.LandingPoint && -- cgit v1.1 From 7492131bb60129f5ce875ee376fc10b477e3fc5f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Jan 2011 01:37:37 +0100 Subject: Fix bumping into sim borders and check estate bans for walking crossings --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 49 ++++++++++++++++++------ 2 files changed, 42 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bb9a748..5caf06c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4022,14 +4022,16 @@ namespace OpenSim.Region.Framework.Scenes RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); } - public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) + public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) { if (m_teleportModule != null) - m_teleportModule.Cross(agent, isFlying); + return m_teleportModule.Cross(agent, isFlying); else { m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); } + + return false; } public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index db9a95b..a1ca9c5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3102,29 +3102,57 @@ namespace OpenSim.Region.Framework.Scenes // Makes sure avatar does not end up outside region if (neighbor <= 0) { - if (!needsTransit) + if (needsTransit) { if (m_requestedSitTargetUUID == UUID.Zero) { + bool isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + Vector3 pos = AbsolutePosition; if (AbsolutePosition.X < 0) - pos.X += Velocity.X; + pos.X += Velocity.X * 2; else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X; + pos.X -= Velocity.X * 2; if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y; + pos.Y += Velocity.Y * 2; else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y; + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); } } } else if (neighbor > 0) - CrossToNewRegion(); + { + if (!CrossToNewRegion()) + { + if (m_requestedSitTargetUUID == UUID.Zero) + { + bool isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + } + } + } } else { - RemoveFromPhysicalScene(); // This constant has been inferred from experimentation // I'm not sure what this value should be, so I tried a few values. timeStep = 0.04f; @@ -3173,16 +3201,15 @@ namespace OpenSim.Region.Framework.Scenes /// If the neighbor accepts, remove the agent's viewable avatar from this scene /// set them to a child agent. /// - protected void CrossToNewRegion() + protected bool CrossToNewRegion() { - InTransit(); try { - m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); + return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); } catch { - m_scene.CrossAgentToNewRegion(this, false); + return m_scene.CrossAgentToNewRegion(this, false); } } -- cgit v1.1 From 657c14c5db8b0c882484926ba76aa64ec757ee07 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Jan 2011 03:07:25 +0100 Subject: Fix up QueryAccess to also check parcels --- OpenSim/Region/Framework/Scenes/Scene.cs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5caf06c..c65a82b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5141,23 +5141,38 @@ namespace OpenSim.Region.Framework.Scenes // from logging into the region, teleporting into the region // or corssing the broder walking, but will NOT prevent // child agent creation, thereby emulating the SL behavior. - public bool QueryAccess(UUID agentID) + public bool QueryAccess(UUID agentID, Vector3 position) { string reason; if (!AuthorizeUser(agentID, out reason)) { - m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); + // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); return false; } - float posX = 128.0f; - float posY = 128.0f; + if (position == Vector3.Zero) // Teleport + { + float posX = 128.0f; + float posY = 128.0f; - if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) + if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) + { + // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); + return false; + } + } + else // Walking { - m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); - return false; + ILandObject land = LandChannel.GetLandObject(position.X, position.Y); + if (land == null) + return false; + + bool banned = land.IsBannedFromLand(agentID); + bool restricted = land.IsRestrictedFromLand(agentID); + + if (banned || restricted) + return false; } return true; } -- cgit v1.1 From 3834000778b121a963ddbda8d5c2a9a2cd554569 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Jan 2011 03:35:59 +0100 Subject: Change the way ban lines work --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a1ca9c5..1d7bf4c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1128,7 +1128,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Removes physics plugin scene representation of this agent if it exists. /// - private void RemoveFromPhysicalScene() + public void RemoveFromPhysicalScene() { if (PhysicsActor != null) { -- cgit v1.1 From 9abaac4d60ed2ccb90d63c65517ab269000a7f06 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Fri, 28 Jan 2011 04:35:43 +0000 Subject: Correct chat source location for Av seated on daughter prim. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a1ca9c5..df7d7c8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -497,7 +497,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) { - return m_parentPosition + (m_pos * part.GetWorldRotation()); + return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); } else { -- cgit v1.1 From ba39d9f0e65bc43a891871fcddae997ff2e85b31 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Feb 2011 03:10:39 +0100 Subject: Squash a nullref --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c65a82b..2424194 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2555,6 +2555,8 @@ namespace OpenSim.Region.Framework.Scenes { */ UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); + if (uac == null) + return 0; return uac.UserFlags; //} } -- cgit v1.1 From b6dda231f2d6be6ac7684048a11f1f0516ed3067 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Fri, 4 Feb 2011 17:31:52 +0000 Subject: Corrections for Avatar Auto-pilot target; add llStopMoveToTarget() for Avatar-attached. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 13 +++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 47 ++++++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6e0fc43..4cbf3e1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1912,6 +1912,7 @@ namespace OpenSim.Region.Framework.Scenes return Vector3.Zero; } + // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object public void moveToTarget(Vector3 target, float tau) { SceneObjectPart rootpart = m_rootPart; @@ -1951,9 +1952,17 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart rootpart = m_rootPart; if (rootpart != null) { - if (rootpart.PhysActor != null) + if (IsAttachment) { - rootpart.PhysActor.PIDActive = false; + ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + if (avatar != null) avatar.StopMoveToPosition(); + } + else + { + if (rootpart.PhysActor != null) + { + rootpart.PhysActor.PIDActive = false; + } } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b54d1b8..b87275c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1605,8 +1605,41 @@ namespace OpenSim.Region.Framework.Scenes if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) { +/* + bool twoD = false; + bool there = false; + if (Animator != null) + { + switch (Animator.CurrentMovementAnimation) + { + case "STAND": + case "WALK": + case "RUN": + case "CROUCH": + case "CROUCHWALK": + { + twoD = true; + } + break; + } + } + + if (twoD) + { +*/ + Vector3 abspos = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, 0.0f); + Vector3 tgt = new Vector3(m_moveToPositionTarget.X, m_moveToPositionTarget.Y, 0.0f); +/* if (Util.GetDistanceTo(abspos, tgt) <= 0.5f) there = true; + } + else + { + if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) there = true; + } +*/ //Check the error term of the current position in relation to the target position - if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) +// if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) +// if (there) + if (Util.GetDistanceTo(abspos, tgt) <= 0.5f) { // we are close enough to the target m_moveToPositionTarget = Vector3.Zero; @@ -1623,7 +1656,8 @@ namespace OpenSim.Region.Framework.Scenes // unknown forces are acting on the avatar and we need to adaptively respond // to such forces, but the following simple approach seems to works fine. Vector3 LocalVectorToTarget3D = - (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords +// (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords + (tgt - abspos) * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords // Ignore z component of vector Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); @@ -1760,8 +1794,15 @@ namespace OpenSim.Region.Framework.Scenes // } } + public void StopMoveToPosition() + { + m_moveToPositionTarget = Vector3.Zero; + m_moveToPositionInProgress = false; + } + public void DoMoveToPosition(Object sender, string method, List args) { +//Console.WriteLine("SP:DoMoveToPosition"); try { float locx = 0f; @@ -1782,7 +1823,7 @@ namespace OpenSim.Region.Framework.Scenes return; } m_moveToPositionInProgress = true; - m_moveToPositionTarget = new Vector3(locx, locy, locz + (m_appearance.AvatarHeight / 2.0f)); + m_moveToPositionTarget = new Vector3(locx, locy, locz); } catch (Exception ex) { -- cgit v1.1 From cfce0aa4482c50e3046ae44fe76d71fb70c82201 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 16 Feb 2011 05:22:05 +0100 Subject: Change the QUERYACCESS method to eliminate spurious access denied messages --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 171d637..f38a6fc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5145,9 +5145,9 @@ namespace OpenSim.Region.Framework.Scenes // from logging into the region, teleporting into the region // or corssing the broder walking, but will NOT prevent // child agent creation, thereby emulating the SL behavior. - public bool QueryAccess(UUID agentID, Vector3 position) + public bool QueryAccess(UUID agentID, Vector3 position, out string reason) { - string reason; + reason = "You are banned from the region"; if (!AuthorizeUser(agentID, out reason)) { @@ -5178,6 +5178,8 @@ namespace OpenSim.Region.Framework.Scenes if (banned || restricted) return false; } + + reason = String.Empty; return true; } } -- cgit v1.1 From 3f93db83711956dbef8870d5b997e3bc12d16c46 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 16 Feb 2011 05:23:30 +0100 Subject: Streamline ban line processing. Remove remnants of old advisory messages. Centralize ban checking and prepare for adding a "ban and eject" function. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b54d1b8..af24ed3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -123,7 +123,6 @@ namespace OpenSim.Region.Framework.Scenes private SceneObjectGroup proxyObjectGroup; //private SceneObjectPart proxyObjectPart = null; public Vector3 lastKnownAllowedPosition; - public bool sentMessageAboutRestrictedParcelFlyingDown; public Vector4 CollisionPlane = Vector4.UnitW; private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation -- cgit v1.1 From 5a78161e74116050b063ec679e1c134ad4a2f16e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Feb 2011 01:32:20 +0100 Subject: Restore heartbeat thread --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d4bfd46..2815f29 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1220,10 +1220,8 @@ namespace OpenSim.Region.Framework.Scenes try { - Update(); - - m_lastUpdate = Util.EnvironmentTickCount(); - m_firstHeartbeat = false; + while (!shuttingdown) + Update(); } catch (ThreadAbortException) { @@ -1410,7 +1408,7 @@ namespace OpenSim.Region.Framework.Scenes // Tell the watchdog that this thread is still alive Watchdog.UpdateThread(); - } + } public void AddGroupTarget(SceneObjectGroup grp) { -- cgit v1.1 From 1a31f7b579753bdcb5f52adc16a41eef4b14a25f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Feb 2011 04:14:49 +0100 Subject: Allow modifying a no mod object through llGiveInventoryItem if the object sets allowed drop. This makes breedables feasible. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9a93a26..9150257 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1227,6 +1227,10 @@ namespace OpenSim.Region.Framework.Scenes if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) return; + bool overrideNoMod = false; + if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) + overrideNoMod = true; + if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) { // object cannot copy items to an object owned by a different owner @@ -1236,7 +1240,7 @@ namespace OpenSim.Region.Framework.Scenes } // must have both move and modify permission to put an item in an object - if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) + if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) { return; } -- cgit v1.1 From 11105d38bdd8eb3eb3eb29eac7f054a2bdc22baf Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Feb 2011 18:55:17 +0100 Subject: Fix a few little things --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9150257..bc892e0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -303,6 +303,8 @@ namespace OpenSim.Region.Framework.Scenes // Passing something to another avatar or a an object will already InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = InventoryService.GetItem(item); + if (item.Owner != remoteClient.AgentId) + return; if (item != null) { -- cgit v1.1 From 13aae75ad88b69c319f86911bac81096510975c1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 16 Mar 2011 22:43:49 +0100 Subject: Prevent god users from being stopped logging into a region --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fe111ff..e5c0f38 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3524,6 +3524,8 @@ namespace OpenSim.Region.Framework.Scenes private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { reason = String.Empty; + if (Permissions.IsGod(agentID)) + return true; ILandObject land = LandChannel.GetLandObject(posX, posY); if (land == null) @@ -5165,6 +5167,12 @@ namespace OpenSim.Region.Framework.Scenes { reason = "You are banned from the region"; + if (Permissions.IsGod(agentID)) + { + reason = String.Empty; + return true; + } + if (!AuthorizeUser(agentID, out reason)) { // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); -- cgit v1.1 From 8338b74d3f023c825cca8d59b90be44a52faec10 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 25 Mar 2011 02:39:17 +0100 Subject: Add giving lists of items to another prim --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index bc892e0..63fed6b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1301,6 +1301,14 @@ namespace OpenSim.Region.Framework.Scenes public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List items) { + SceneObjectPart destPart = GetSceneObjectPart(destID); + if (destPart != null) // Move into a prim + { + foreach(UUID itemID in items) + MoveTaskInventoryItem(destID, host, itemID); + return destID; // Prim folder ID == prim ID + } + InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); UUID newFolderID = UUID.Random(); -- cgit v1.1 From 553a195493db93f9718c1e48b408c1e6839bfde0 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 27 Mar 2011 13:09:19 -0700 Subject: Fix issues with UpdateRootRotation and also increase efficiency --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4cbf3e1..92a275e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3393,7 +3393,9 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.Undoing = true; cancelUndo = true; } - m_rootPart.UpdateRotation(rot); + + //Don't use UpdateRotation because it schedules an update prematurely + m_rootPart.RotationOffset = rot; if (m_rootPart.PhysActor != null) { m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; @@ -3408,14 +3410,13 @@ namespace OpenSim.Region.Framework.Scenes { prim.IgnoreUndoUpdate = true; Vector3 axPos = prim.OffsetPosition; + axPos *= oldParentRot; axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; - Quaternion primsRot = prim.RotationOffset; - Quaternion newRot = primsRot * oldParentRot; - newRot *= Quaternion.Inverse(axRot); - prim.RotationOffset = newRot; - prim.ScheduleTerseUpdate(); + + prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); + prim.IgnoreUndoUpdate = false; } } @@ -3424,7 +3425,7 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.Undoing = false; } - m_rootPart.ScheduleTerseUpdate(); + ScheduleGroupForTerseUpdate(); } #endregion -- cgit v1.1 From 2d2a1acfae712585f1f00ec8d26b5aa4c00482fc Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 27 Mar 2011 13:43:32 -0700 Subject: Upgrade terse to full update on root rotation change. Not entirely sure why, but it seems that the terse update causes the first prim to rotate improperly on occasion (only temporary, it's fixed by the full update on deselect, but this will prevent confusion.) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 92a275e..631a7a0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3425,7 +3425,7 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.Undoing = false; } - ScheduleGroupForTerseUpdate(); + ScheduleGroupForFullUpdate(); } #endregion -- cgit v1.1 From f7276dda027c6ac8d500f20e44a3a7a0218a70b7 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 27 Mar 2011 14:20:25 -0700 Subject: Flag root prim changes for persistence --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 631a7a0..776b3b3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3424,7 +3424,7 @@ namespace OpenSim.Region.Framework.Scenes { m_rootPart.Undoing = false; } - + HasGroupChanged = true; ScheduleGroupForFullUpdate(); } -- cgit v1.1 From 95e524dde100aa14d71a49ee5d5f0cc4b5fa45f7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 1 Apr 2011 18:49:53 +0200 Subject: A stab at making CHANGED_OWNER work --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 854f1dc..1992956 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -186,12 +186,12 @@ namespace OpenSim.Region.Framework.Scenes foreach (TaskInventoryItem item in items) { if (ownerId != item.OwnerID) - { item.LastOwnerID = item.OwnerID; - item.OwnerID = ownerId; - item.PermsMask = 0; - item.PermsGranter = UUID.Zero; - } + + item.OwnerID = ownerId; + item.PermsMask = 0; + item.PermsGranter = UUID.Zero; + item.OwnerChanged = true; } m_items.LockItemsForWrite(false); } -- cgit v1.1 From 4256693a9e05478e8fb5aae7063f4b024ff1d23b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 3 Apr 2011 13:50:19 +0200 Subject: Make CHANGED_OWNER work for deeding and god-mode in-world change --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 63fed6b..0748954 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2122,7 +2122,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] partList = sog.Parts; foreach (SceneObjectPart child in partList) + { child.Inventory.ChangeInventoryOwner(ownerID); + child.TriggerScriptChangedEvent(Changed.OWNER); + } } else { @@ -2138,6 +2141,7 @@ namespace OpenSim.Region.Framework.Scenes { child.LastOwnerID = child.OwnerID; child.Inventory.ChangeInventoryOwner(groupID); + child.TriggerScriptChangedEvent(Changed.OWNER); } sog.SetOwnerId(groupID); -- cgit v1.1 From 33dd74e410bcd95364d8029a3f2a21b522c9f9d2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Apr 2011 03:50:27 +0200 Subject: Add support for the new display name related functions in LSL. This does not implement the display names functionality as such, but it allows scripts that are display name aware to function as if the display name were implemented and set to the avatar name. --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2e82e1f..0e3cffb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1337,12 +1337,12 @@ namespace OpenSim.Region.Framework.Scenes terrainMS = Util.EnvironmentTickCountSubtract(terMS); } - if (Frame % m_update_land == 0) - { - int ldMS = Util.EnvironmentTickCount(); - UpdateLand(); - landMS = Util.EnvironmentTickCountSubtract(ldMS); - } + // if (Frame % m_update_land == 0) + // { + // int ldMS = Util.EnvironmentTickCount(); + // UpdateLand(); + // landMS = Util.EnvironmentTickCountSubtract(ldMS); + // } frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; -- cgit v1.1 From 282e116f948d431b570f7c17425cfc0a8ea767a2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 21 Apr 2011 22:34:49 +0200 Subject: Honor agent limit for region crossings and teleports --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eed5ebc..e29b51c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5191,6 +5191,17 @@ namespace OpenSim.Region.Framework.Scenes return true; } + int num = m_sceneGraph.GetNumberOfScenePresences(); + + if (num >= RegionInfo.RegionSettings.AgentLimit) + { + if (!Permissions.IsAdministrator(cAgentData.AgentID)) + { + reason = "The region is full"; + return false; + } + } + if (!AuthorizeUser(agentID, out reason)) { // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); -- cgit v1.1 From a1dce960d782559dd2967dbb8faefa4e2363fb66 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 21 Apr 2011 22:45:46 +0200 Subject: Add fix a minor bug --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e29b51c..4d619c3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5195,7 +5195,7 @@ namespace OpenSim.Region.Framework.Scenes if (num >= RegionInfo.RegionSettings.AgentLimit) { - if (!Permissions.IsAdministrator(cAgentData.AgentID)) + if (!Permissions.IsAdministrator(agentID)) { reason = "The region is full"; return false; -- cgit v1.1 From e713b7e3bbfdae81add08b2ef48ea7f79812f4e0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 26 Apr 2011 23:18:52 +0200 Subject: Try to repair attachments ion the fly if they are detached and reattached. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3a5b05d..9e48447 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4038,6 +4038,10 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju { lock (m_attachments) { + // This may be true when the attachment comes back + // from serialization after login. Clear it. + gobj.IsDeleted = false; + m_attachments.Add(gobj); } } -- cgit v1.1 From 98fe37051a6844851245d4cd5460326873eb9759 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 30 Apr 2011 14:22:46 +0200 Subject: Set the attachment data on scripted rez to allow toasters to work. --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 1992956..3e0241c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -803,6 +803,9 @@ namespace OpenSim.Region.Framework.Scenes string xmlData = Utils.BytesToString(rezAsset.Data); SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + group.RootPart.AttachPoint = group.RootPart.Shape.State; + group.RootPart.AttachOffset = group.AbsolutePosition; + group.ResetIDs(); SceneObjectPart rootPart = group.GetChildPart(group.UUID); -- cgit v1.1 From 8a398ef02d60b3f9007bc76fa404ddffa6c458d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 30 Apr 2011 16:01:54 +0200 Subject: When coming in from a legacy region without fatpacks, start scripts the usual way --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1d06889..bbf36f1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2409,6 +2409,22 @@ namespace OpenSim.Region.Framework.Scenes newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); newObject.ResumeScripts(); } + else + { + ScenePresence sp; + if (TryGetScenePresence(newObject.OwnerID, out sp)) + { + // If the scene presence is here and already a root + // agent, we came from a ;egacy region. Start the scripts + // here as they used to start. + // TODO: Remove in 0.7.3 + if (!sp.IsChildAgent) + { + newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); + newObject.ResumeScripts(); + } + } + } // Do this as late as possible so that listeners have full access to the incoming object EventManager.TriggerOnIncomingSceneObject(newObject); -- cgit v1.1 From aa73f99de6b305b2425746950db8bd562a63b4be Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 May 2011 16:44:45 +0100 Subject: Revert the CM prioritizer to the core version --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 0f35894..4595a29 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -158,8 +158,6 @@ namespace OpenSim.Region.Framework.Scenes private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) { - if (entity == null) return 0; - uint pqueue = ComputeDistancePriority(client,entity,true); ScenePresence presence = m_scene.GetScenePresence(client.AgentId); @@ -190,12 +188,6 @@ namespace OpenSim.Region.Framework.Scenes private uint ComputeDistancePriority(IClientAPI client, ISceneEntity entity, bool useFrontBack) { - // If this is an update for our own avatar give it the highest priority - if (client.AgentId == entity.UUID) - return 0; - if (entity == null) - return 0; - // Get this agent's position ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence == null) -- cgit v1.1 From 61263e2ce3534b0356af9b608c84bcd96015aa34 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 May 2011 16:58:39 +0200 Subject: Some private changes to the prioritizer: 30m steps instead of 10 and disable the broken frontback math. Much better user experience. --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 4595a29..657df15 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -158,7 +158,7 @@ namespace OpenSim.Region.Framework.Scenes private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) { - uint pqueue = ComputeDistancePriority(client,entity,true); + uint pqueue = ComputeDistancePriority(client,entity,false); ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) @@ -228,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < queues - 1; i++) { - if (distance < 10 * Math.Pow(2.0,i)) + if (distance < 30 * Math.Pow(2.0,i)) break; pqueue++; } -- cgit v1.1 From dbf623a3d29cc594b3e3a5188ce58189d5ce65d8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 9 May 2011 00:59:32 +0200 Subject: Add commands to delete objects by name, UUID, creator or owner --- OpenSim/Region/Framework/Scenes/Scene.cs | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0d7894f..bac66cb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -610,6 +610,19 @@ namespace OpenSim.Region.Framework.Scenes "reload estate", "Reload the estate data", HandleReloadEstate); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", + "delete object owner ", + "Delete object by owner", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", + "delete object creator ", + "Delete object by creator", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", + "delete object uuid ", + "Delete object by uuid", HandleDeleteObject); + MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", + "delete object name ", + "Delete object by name", HandleDeleteObject); + //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(simDataService.StoreLandObject); @@ -5042,6 +5055,60 @@ namespace OpenSim.Region.Framework.Scenes } } + private void HandleDeleteObject(string module, string[] cmd) + { + if (cmd.Length < 4) + return; + + string mode = cmd[2]; + string o = cmd[3]; + + List deletes = new List(); + + UUID match; + + switch (mode) + { + case "owner": + if (!UUID.TryParse(o, out match)) + return; + ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.OwnerID == match && !g.IsAttachment) + deletes.Add(g); + }); + break; + case "creator": + if (!UUID.TryParse(o, out match)) + return; + ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.RootPart.CreatorID == match && !g.IsAttachment) + deletes.Add(g); + }); + break; + case "uuid": + if (!UUID.TryParse(o, out match)) + return; + ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.UUID == match && !g.IsAttachment) + deletes.Add(g); + }); + break; + case "name": + ForEachSOG(delegate (SceneObjectGroup g) + { + if (g.RootPart.Name == o && !g.IsAttachment) + deletes.Add(g); + }); + break; + } + + foreach (SceneObjectGroup g in deletes) + DeleteSceneObject(g, false); + } + private void HandleReloadEstate(string module, string[] cmd) { if (MainConsole.Instance.ConsoleScene == null || -- cgit v1.1 From 8b42f824d3ccd487e1d0917b155faa75fd311927 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 May 2011 00:53:28 +0200 Subject: Add an event for an orderly region shutdown that fires once per region before the SceneGraph is torn down. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 25 +++++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 2 files changed, 27 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 4ce7a6c..d326141 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -115,6 +115,10 @@ namespace OpenSim.Region.Framework.Scenes public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; + public delegate void SceneShuttingDownDelegate(Scene scene); + + public event SceneShuttingDownDelegate OnSceneShuttingDown; + /// /// Fired when an object is touched/grabbed. /// @@ -2217,5 +2221,26 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void TriggerSceneShuttingDown(Scene s) + { + SceneShuttingDownDelegate handler = OnSceneShuttingDown; + if (handler != null) + { + foreach (SceneShuttingDownDelegate d in handler.GetInvocationList()) + { + try + { + d(s); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerSceneShuttingDown failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1d2092e..5085396 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1091,6 +1091,8 @@ namespace OpenSim.Region.Framework.Scenes shuttingdown = true; m_log.Debug("[SCENE]: Persisting changed objects"); + EventManager.TriggerSceneShuttingDown(this); + EntityBase[] entities = GetEntities(); foreach (EntityBase entity in entities) { -- cgit v1.1 From 62e0c960363e0949bbc41b072a0dfffb90d19762 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 May 2011 03:37:25 +0200 Subject: Allow disabling the legacy backup mechanism to avoid the object clone if backup is not used. --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++++++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5085396..254ad05 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -209,6 +209,7 @@ namespace OpenSim.Region.Framework.Scenes private Timer m_mapGenerationTimer = new Timer(); private bool m_generateMaptiles; + private bool m_useBackup = true; // private Dictionary m_UserNamesCache = new Dictionary(); @@ -477,6 +478,11 @@ namespace OpenSim.Region.Framework.Scenes get { return m_sceneGraph; } } + public bool UseBackup + { + get { return m_useBackup; } + } + // an instance to the physics plugin's Scene object. public PhysicsScene PhysicsScene { @@ -670,6 +676,9 @@ namespace OpenSim.Region.Framework.Scenes IConfig startupConfig = m_config.Configs["Startup"]; m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); + m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); + if (!m_useBackup) + m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b100b39..62277ff 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1613,7 +1613,7 @@ namespace OpenSim.Region.Framework.Scenes } - if (HasGroupChanged) + if (m_scene.UseBackup && HasGroupChanged) { // don't backup while it's selected or you're asking for changes mid stream. if (isTimeToPersist() || forcedBackup) -- cgit v1.1 From 932db1c3742415bd089620ca4eba9ed8ac857d85 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 May 2011 11:30:21 +0200 Subject: Add PayPrice to serialization format Xml2 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 - .../Scenes/Serialization/SceneObjectSerializer.cs | 37 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e7e3014..4e1d6b6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -145,7 +145,6 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 StatusSandboxPos; - // TODO: This needs to be persisted in next XML version update! [XmlIgnore] public int[] PayPrice = {-2,-2,-2,-2,-2}; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 769d8a5..c42302f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -341,6 +341,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl); m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation); m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); + m_SOPXmlProcessors.Add("PayPrice0", ProcessPayPrice0); + m_SOPXmlProcessors.Add("PayPrice1", ProcessPayPrice1); + m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); + m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); + m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); #endregion #region TaskInventoryXmlProcessors initialization @@ -698,6 +703,32 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { obj.ParticleSystem = Convert.FromBase64String(reader.ReadElementContentAsString("ParticleSystem", String.Empty)); } + + private static void ProcessPayPrice0(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[0] = (int)reader.ReadElementContentAsInt("PayPrice0", String.Empty); + } + + private static void ProcessPayPrice1(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[1] = (int)reader.ReadElementContentAsInt("PayPrice1", String.Empty); + } + + private static void ProcessPayPrice2(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[2] = (int)reader.ReadElementContentAsInt("PayPrice2", String.Empty); + } + + private static void ProcessPayPrice3(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[3] = (int)reader.ReadElementContentAsInt("PayPrice3", String.Empty); + } + + private static void ProcessPayPrice4(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); + } + #endregion #region TaskInventoryXmlProcessors @@ -1069,7 +1100,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization shp.Media = PrimitiveBaseShape.MediaList.FromXml(value); } - #endregion ////////// Write ///////// @@ -1175,6 +1205,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); WriteBytes(writer, "TextureAnimation", sop.TextureAnimation); WriteBytes(writer, "ParticleSystem", sop.ParticleSystem); + writer.WriteElementString("PayPrice0", sop.PayPrice[0].ToString()); + writer.WriteElementString("PayPrice1", sop.PayPrice[1].ToString()); + writer.WriteElementString("PayPrice2", sop.PayPrice[2].ToString()); + writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); + writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); writer.WriteEndElement(); } -- cgit v1.1 From 4d324f1b74deb1bc08b02ad1fe781d46cff43ccc Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 May 2011 16:29:00 +0200 Subject: Change setter on changed flags to public so modules can reset it --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 62277ff..d3d5d08 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -183,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. /// - public bool HasGroupChangedDueToDelink { get; private set; } + public bool HasGroupChangedDueToDelink { get; set; } private bool isTimeToPersist() { -- cgit v1.1 From 61bf2bf2ddce323255d7d009274d8da5a2da54c9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Jun 2011 18:32:25 +0200 Subject: Make Buoyancy a prim property --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 3 +++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d3d5d08..74d24a6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -680,6 +680,9 @@ namespace OpenSim.Region.Framework.Scenes ApplyPhysics(m_scene.m_physicalPrim); + if (RootPart.PhysActor != null) + RootPart.Buoyancy = RootPart.Buoyancy; + // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled // for the same object with very different properties. The caller must schedule the update. //ScheduleGroupForFullUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4e1d6b6..cb321aa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -338,6 +338,7 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastAcceleration; protected Vector3 m_lastAngularVelocity; protected int m_lastTerseSent; + protected float m_buoyancy = 0.0f; /// /// Stores media texture data @@ -1335,6 +1336,19 @@ namespace OpenSim.Region.Framework.Scenes set { m_collisionSoundVolume = value; } } + public float Buoyancy + { + get { return m_buoyancy; } + set + { + m_buoyancy = value; + if (PhysActor != null) + { + PhysActor.Buoyancy = value; + } + } + } + #endregion Public Properties with only Get #region Private Methods @@ -3275,14 +3289,6 @@ namespace OpenSim.Region.Framework.Scenes STATUS_ROTATE_Z = rotate; } - public void SetBuoyancy(float fvalue) - { - if (PhysActor != null) - { - PhysActor.Buoyancy = fvalue; - } - } - public void SetDieAtEdge(bool p) { if (m_parentGroup == null) -- cgit v1.1 From 458a8c6d0b1c54e3d395c28605a5b6bce45881fd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Jun 2011 18:44:51 +0200 Subject: Persist Buoyancy in inventory --- .../Framework/Scenes/Serialization/SceneObjectSerializer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index c42302f..95ded7f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -346,6 +346,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); + + m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); #endregion #region TaskInventoryXmlProcessors initialization @@ -729,6 +731,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); } + private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) + { + obj.Buoyancy = (int)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); + } + #endregion #region TaskInventoryXmlProcessors @@ -1211,6 +1218,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); + writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); + writer.WriteEndElement(); } -- cgit v1.1 From fedfa02b64deeaf78555b5767908e14bc27e4aa8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Jul 2011 21:20:11 +0200 Subject: Remove another core SNAFU. AbsolutePosition is NOT equal to group position in attachments! Breaks resizers!!! --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ff1d520..0746b06 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1118,9 +1118,6 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (IsAttachment) - return GroupPosition; - return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); } } -- cgit v1.1 From bb402d0d95c934fbcd8b1c03e228ec1d0a14f14d Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 15 Jul 2011 12:08:40 -0700 Subject: Add localid support to ch0de properly --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 482597d..aeb03a2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1767,7 +1767,8 @@ namespace OpenSim.Region.Framework.Scenes part.AbsolutePosition, part.Scale, part.RotationOffset, - part.PhysActor.IsPhysical); + part.PhysActor.IsPhysical, + m_localId); part.PhysActor.SetMaterial((int)part.Material); part.PhysActor.LocalID = part.LocalId; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 980f7a3..2214f2f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1633,7 +1633,8 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition, Scale, RotationOffset, - RigidBody); + RigidBody, + m_localId); PhysActor.SetMaterial(Material); } catch @@ -4442,7 +4443,8 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition, Scale, RotationOffset, - UsePhysics); + UsePhysics, + m_localId); PhysActor.SetMaterial(Material); pa = PhysActor; -- cgit v1.1 From 8dff9d564dfbf4841f03a919df44e8ae3d76de25 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jul 2011 19:35:49 +0200 Subject: Revert "Add localid support to ch0de properly" This reverts commit bb402d0d95c934fbcd8b1c03e228ec1d0a14f14d. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 +-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index aeb03a2..482597d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1767,8 +1767,7 @@ namespace OpenSim.Region.Framework.Scenes part.AbsolutePosition, part.Scale, part.RotationOffset, - part.PhysActor.IsPhysical, - m_localId); + part.PhysActor.IsPhysical); part.PhysActor.SetMaterial((int)part.Material); part.PhysActor.LocalID = part.LocalId; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2214f2f..980f7a3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1633,8 +1633,7 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition, Scale, RotationOffset, - RigidBody, - m_localId); + RigidBody); PhysActor.SetMaterial(Material); } catch @@ -4443,8 +4442,7 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition, Scale, RotationOffset, - UsePhysics, - m_localId); + UsePhysics); PhysActor.SetMaterial(Material); pa = PhysActor; -- cgit v1.1 From c7dbd7cbd035ccc412624cd221348479d43798d6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jul 2011 12:08:40 -0700 Subject: Fox some local id issues in physics glue --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 482597d..aeb03a2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1767,7 +1767,8 @@ namespace OpenSim.Region.Framework.Scenes part.AbsolutePosition, part.Scale, part.RotationOffset, - part.PhysActor.IsPhysical); + part.PhysActor.IsPhysical, + m_localId); part.PhysActor.SetMaterial((int)part.Material); part.PhysActor.LocalID = part.LocalId; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 980f7a3..2214f2f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1633,7 +1633,8 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition, Scale, RotationOffset, - RigidBody); + RigidBody, + m_localId); PhysActor.SetMaterial(Material); } catch @@ -4442,7 +4443,8 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition, Scale, RotationOffset, - UsePhysics); + UsePhysics, + m_localId); PhysActor.SetMaterial(Material); pa = PhysActor; -- cgit v1.1 From b5fcd2caba91fc4c524c5f58836e2d5a08573549 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 15 Jul 2011 20:11:12 +0100 Subject: Fix some local id issues in physics glue --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index aeb03a2..6c47645 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + using System; using System.Collections.Generic; using System.Drawing; -- cgit v1.1 From f5623b5c3903606606fedead8f365244c0eddbed Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 19 Jul 2011 10:15:34 -0700 Subject: Tidy up a superfluous AddPrimShape override in PhysicsScene --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2214f2f..037f384 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4437,7 +4437,6 @@ namespace OpenSim.Region.Framework.Scenes { // It's not phantom anymore. So make sure the physics engine get's knowledge of it PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( - LocalId, string.Format("{0}/{1}", Name, UUID), Shape, AbsolutePosition, -- cgit v1.1 From c768d18c92d145427eb1b1679894f082b0bed7a5 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Jul 2011 18:16:36 +0100 Subject: Revert "Tidy up a superfluous AddPrimShape override in PhysicsScene" This reverts commit f5623b5c3903606606fedead8f365244c0eddbed. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 037f384..2214f2f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4437,6 +4437,7 @@ namespace OpenSim.Region.Framework.Scenes { // It's not phantom anymore. So make sure the physics engine get's knowledge of it PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( + LocalId, string.Format("{0}/{1}", Name, UUID), Shape, AbsolutePosition, -- cgit v1.1 From cbaa4aa88fd45df70003176254579492f11e0d5a Mon Sep 17 00:00:00 2001 From: Careminster Team Date: Tue, 19 Jul 2011 10:15:34 -0700 Subject: Tidy up a superfluous AddPrimShape override in PhysicsScene --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2214f2f..037f384 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4437,7 +4437,6 @@ namespace OpenSim.Region.Framework.Scenes { // It's not phantom anymore. So make sure the physics engine get's knowledge of it PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( - LocalId, string.Format("{0}/{1}", Name, UUID), Shape, AbsolutePosition, -- cgit v1.1 From c2de0c930c526157b464ce7a7d17a37042a3676c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 23 Jul 2011 18:29:43 +0200 Subject: Fix failure to find avatars due to trainling spaces being sent by viewers. --- OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 44472b2..9bef443 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -378,7 +378,10 @@ namespace OpenSim.Region.Framework.Scenes List accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query); if (accounts == null) + { + m_log.DebugFormat("[LLCIENT]: ProcessAvatarPickerRequest: returned null result"); return; + } AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); // TODO: don't create new blocks if recycling an old packet -- cgit v1.1 From 5c012cac54f92f2881005a50fd3eb103f0f2ea07 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 25 Jul 2011 04:16:53 +0200 Subject: Add a timer to monitor the heartbeat. Restart it if it's been dead for 5 seconds. --- OpenSim/Region/Framework/Scenes/Scene.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e02a866..ec82cc3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -109,6 +109,7 @@ namespace OpenSim.Region.Framework.Scenes protected int m_splitRegionID; protected Timer m_restartWaitTimer = new Timer(); + protected Timer m_timerWatchdog = new Timer(); protected List m_regionRestartNotifyList = new List(); protected List m_neighbours = new List(); protected string m_simulatorVersion = "OpenSimulator Server"; @@ -191,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scripts_enabled = true; private string m_defaultScriptEngine; private int m_LastLogin; - private Thread HeartbeatThread; + private Thread HeartbeatThread = null; private volatile bool shuttingdown; private int m_lastUpdate; @@ -4886,7 +4887,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_firstHeartbeat) return; - if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) + if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) StartTimer(); } @@ -5380,5 +5381,18 @@ namespace OpenSim.Region.Framework.Scenes reason = String.Empty; return true; } + + public void StartTimerWatchdog() + { + m_timerWatchdog.Interval = 1000; + m_timerWatchdog.Elapsed += TimerWatchdog; + m_timerWatchdog.AutoReset = true; + m_timerWatchdog.Start(); + } + + public void TimerWatchdog(object sender, ElapsedEventArgs e) + { + CheckHeartbeat(); + } } } -- cgit v1.1 From 6ab5ca2bda9966d00470fc9f6967bce4eca663d2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 9 Aug 2011 22:11:27 +0200 Subject: Guard another nullref --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 1f4ec96..f04ed4d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes g.ScheduleFullUpdateToAvatar(m_presence); } - while (m_partsUpdateQueue.Count != null && m_partsUpdateQueue.Count > 0) + while (m_partsUpdateQueue != null && m_partsUpdateQueue.Count != null && m_partsUpdateQueue.Count > 0) { SceneObjectPart part = m_partsUpdateQueue.Dequeue(); -- cgit v1.1 From 9ab951a954ff85371dc3dd92563d7c8cdefb7c20 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 4 Sep 2011 07:38:25 -0700 Subject: I fucked up the merge for SOG, so reverting back to OpenSim Core's version... --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 1260 ++++---------------- 1 file changed, 255 insertions(+), 1005 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b1b76dd..5762717 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -24,12 +24,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + using System; using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Diagnostics; using System.Linq; using System.Threading; using System.Xml; @@ -106,29 +105,8 @@ namespace OpenSim.Region.Framework.Scenes /// since the group's last persistent backup /// private bool m_hasGroupChanged = false; - private long timeFirstChanged = 0; - private long timeLastChanged = 0; - private long m_maxPersistTime = 0; - private long m_minPersistTime = 0; - private Random m_rand; - private bool m_suspendUpdates; - private List m_linkedAvatars = new List(); - - public bool areUpdatesSuspended - { - get - { - return m_suspendUpdates; - } - set - { - m_suspendUpdates = value; - if (!value) - { - QueueForUpdateCheck(); - } - } - } + private long timeFirstChanged; + private long timeLastChanged; public bool HasGroupChanged { @@ -136,54 +114,24 @@ namespace OpenSim.Region.Framework.Scenes { if (value) { - if (m_isBackedUp) - { - m_scene.SceneGraph.FireChangeBackup(this); - } timeLastChanged = DateTime.Now.Ticks; if (!m_hasGroupChanged) timeFirstChanged = DateTime.Now.Ticks; - if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) - { - if (m_rand == null) - { - byte[] val = new byte[16]; - m_rootPart.UUID.ToBytes(val, 0); - m_rand = new Random(BitConverter.ToInt32(val, 0)); - } - - if (m_scene.GetRootAgentCount() == 0) - { - //If the region is empty, this change has been made by an automated process - //and thus we delay the persist time by a random amount between 1.5 and 2.5. - - float factor = 1.5f + (float)(m_rand.NextDouble()); - m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); - m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); - } - else - { - //If the region is not empty, we want to obey the minimum and maximum persist times - //but add a random factor so we stagger the object persistance a little - m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 - m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 - } - } } m_hasGroupChanged = value; - -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId); + + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId); } get { return m_hasGroupChanged; } } - + /// /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. /// - public bool HasGroupChangedDueToDelink { get; set; } + public bool HasGroupChangedDueToDelink { get; private set; } private bool isTimeToPersist() { @@ -193,19 +141,8 @@ namespace OpenSim.Region.Framework.Scenes return false; if (m_scene.ShuttingDown) return true; - - if (m_minPersistTime == 0 || m_maxPersistTime == 0) - { - m_maxPersistTime = m_scene.m_persistAfter; - m_minPersistTime = m_scene.m_dontPersistBefore; - } - long currentTime = DateTime.Now.Ticks; - - if (timeLastChanged == 0) timeLastChanged = currentTime; - if (timeFirstChanged == 0) timeFirstChanged = currentTime; - - if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) + if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) return true; return false; } @@ -310,10 +247,10 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scriptListens_atTarget; private bool m_scriptListens_notAtTarget; + private bool m_scriptListens_atRotTarget; private bool m_scriptListens_notAtRotTarget; - public bool m_dupeInProgress = false; internal Dictionary m_savedScriptState; #region Properties @@ -349,13 +286,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual Quaternion Rotation { get { return m_rotation; } - set { - foreach(SceneObjectPart p in m_parts.GetArray()) - { - p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); - } - m_rotation = value; - } + set { m_rotation = value; } } public Quaternion GroupRotation @@ -370,27 +301,27 @@ namespace OpenSim.Region.Framework.Scenes Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); Vector3 maxScale = Vector3.Zero; Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); - + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; Vector3 partscale = part.Scale; Vector3 partoffset = part.OffsetPosition; - + minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; - + maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; } - + finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; - + return finalScale; } } @@ -446,7 +377,7 @@ namespace OpenSim.Region.Framework.Scenes { return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); } - + /// /// The absolute position of this scene object in the scene /// @@ -460,55 +391,30 @@ namespace OpenSim.Region.Framework.Scenes if (Scene != null) { if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) - || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { m_scene.CrossPrimGroupIntoNewRegion(val, this, true); } } - foreach (SceneObjectPart part in m_parts.GetArray()) - { - part.IgnoreUndoUpdate = true; - } if (RootPart.GetStatusSandbox()) { if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) { RootPart.ScriptSetPhysicsStatus(false); - + if (Scene != null) Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); - + return; } } + SceneObjectPart[] parts = m_parts.GetArray(); - foreach (SceneObjectPart part in parts) - { - part.IgnoreUndoUpdate = false; - part.StoreUndoState(UndoType.STATE_GROUP_POSITION); - part.GroupPosition = val; - if (!m_dupeInProgress) - { - part.TriggerScriptChangedEvent(Changed.POSITION); - } - } - if (!m_dupeInProgress) - { - foreach (ScenePresence av in m_linkedAvatars) - { - SceneObjectPart p; - if (m_parts.TryGetValue(av.LinkedPrim, out p)) - { - Vector3 offset = p.GetWorldPosition() - av.ParentPosition; - av.AbsolutePosition += offset; - av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition - av.SendAvatarDataToAllAgents(); - } - } - } + for (int i = 0; i < parts.Length; i++) + parts[i].GroupPosition = val; //if (m_rootPart.PhysActor != null) //{ @@ -517,7 +423,7 @@ namespace OpenSim.Region.Framework.Scenes //m_rootPart.GroupPosition.Z); //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); //} - + if (Scene != null) Scene.EventManager.TriggerParcelPrimCountTainted(); } @@ -532,7 +438,7 @@ namespace OpenSim.Region.Framework.Scenes public override UUID UUID { get { return m_rootPart.UUID; } - set + set { lock (m_parts.SyncRoot) { @@ -563,9 +469,10 @@ namespace OpenSim.Region.Framework.Scenes public string Text { - get { + get + { string returnstr = m_rootPart.Text; - if (returnstr.Length > 255) + if (returnstr.Length > 255) { returnstr = returnstr.Substring(0, 255); } @@ -578,7 +485,7 @@ namespace OpenSim.Region.Framework.Scenes { get { return true; } } - + private bool m_passCollision; public bool PassCollision { @@ -655,10 +562,10 @@ namespace OpenSim.Region.Framework.Scenes #endregion -// ~SceneObjectGroup() -// { -// m_log.DebugFormat("[SCENE OBJECT GROUP]: Destructor called for {0}, local id {1}", Name, LocalId); -// } + // ~SceneObjectGroup() + // { + // m_log.DebugFormat("[SCENE OBJECT GROUP]: Destructor called for {0}, local id {1}", Name, LocalId); + // } #region Constructors @@ -667,7 +574,6 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup() { - } /// @@ -711,7 +617,7 @@ namespace OpenSim.Region.Framework.Scenes if (itemid != UUID.Zero) m_savedScriptState[itemid] = node.InnerXml; } - } + } } } @@ -732,9 +638,6 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void AttachToBackup() { - if (IsAttachment) return; - m_scene.SceneGraph.FireAttachToBackup(this); - if (InSceneBackup) { //m_log.DebugFormat( @@ -742,11 +645,11 @@ namespace OpenSim.Region.Framework.Scenes if (!m_isBackedUp) m_scene.EventManager.OnBackup += ProcessBackup; - + m_isBackedUp = true; } } - + /// /// Attach this object to a scene. It will also now appear to agents. /// @@ -777,9 +680,6 @@ namespace OpenSim.Region.Framework.Scenes ApplyPhysics(m_scene.m_physicalPrim); - if (RootPart.PhysActor != null) - RootPart.Buoyancy = RootPart.Buoyancy; - // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled // for the same object with very different properties. The caller must schedule the update. //ScheduleGroupForFullUpdate(); @@ -825,9 +725,9 @@ namespace OpenSim.Region.Framework.Scenes result.normal = inter.normal; result.distance = inter.distance; } - } } + return result; } @@ -847,19 +747,17 @@ namespace OpenSim.Region.Framework.Scenes minZ = 8192f; SceneObjectPart[] parts = m_parts.GetArray(); - foreach (SceneObjectPart part in parts) + for (int i = 0; i < parts.Length; i++) { + SceneObjectPart part = parts[i]; + Vector3 worldPos = part.GetWorldPosition(); Vector3 offset = worldPos - AbsolutePosition; Quaternion worldRot; if (part.ParentID == 0) - { worldRot = part.RotationOffset; - } else - { worldRot = part.GetWorldRotation(); - } Vector3 frontTopLeft; Vector3 frontTopRight; @@ -871,8 +769,6 @@ namespace OpenSim.Region.Framework.Scenes Vector3 backBottomLeft; Vector3 backBottomRight; - // Vector3[] corners = new Vector3[8]; - Vector3 orig = Vector3.Zero; frontTopLeft.X = orig.X - (part.Scale.X / 2); @@ -907,38 +803,6 @@ namespace OpenSim.Region.Framework.Scenes backBottomRight.Y = orig.Y + (part.Scale.Y / 2); backBottomRight.Z = orig.Z - (part.Scale.Z / 2); - - - //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); - //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); - //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); - //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); - //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); - //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); - //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); - //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); - - //for (int i = 0; i < 8; i++) - //{ - // corners[i] = corners[i] * worldRot; - // corners[i] += offset; - - // if (corners[i].X > maxX) - // maxX = corners[i].X; - // if (corners[i].X < minX) - // minX = corners[i].X; - - // if (corners[i].Y > maxY) - // maxY = corners[i].Y; - // if (corners[i].Y < minY) - // minY = corners[i].Y; - - // if (corners[i].Z > maxZ) - // maxZ = corners[i].Y; - // if (corners[i].Z < minZ) - // minZ = corners[i].Z; - //} - frontTopLeft = frontTopLeft * worldRot; frontTopRight = frontTopRight * worldRot; frontBottomLeft = frontBottomLeft * worldRot; @@ -960,15 +824,6 @@ namespace OpenSim.Region.Framework.Scenes backTopLeft += offset; backTopRight += offset; - //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); - //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); - //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); - //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); - //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); - //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); - //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); - //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); - if (frontTopRight.X > maxX) maxX = frontTopRight.X; if (frontTopLeft.X > maxX) @@ -1106,7 +961,7 @@ namespace OpenSim.Region.Framework.Scenes offsetHeight *= -1; } - // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); + // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); return boundingBox; } @@ -1114,20 +969,15 @@ namespace OpenSim.Region.Framework.Scenes public void SaveScriptedState(XmlTextWriter writer) { - SaveScriptedState(writer, false); - } - - public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) - { XmlDocument doc = new XmlDocument(); - Dictionary states = new Dictionary(); + Dictionary states = new Dictionary(); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { - Dictionary pstates = parts[i].Inventory.GetScriptStates(oldIDs); + Dictionary pstates = parts[i].Inventory.GetScriptStates(); foreach (KeyValuePair kvp in pstates) - states[kvp.Key] = kvp.Value; + states.Add(kvp.Key, kvp.Value); } if (states.Count > 0) @@ -1146,190 +996,6 @@ namespace OpenSim.Region.Framework.Scenes } } -<<<<<<< HEAD - /// - /// Add the avatar to this linkset (avatar is sat). - /// - /// - public void AddAvatar(UUID agentID) - { - ScenePresence presence; - if (m_scene.TryGetScenePresence(agentID, out presence)) - { - if (!m_linkedAvatars.Contains(presence)) - { - m_linkedAvatars.Add(presence); - } - } - } - - /// - /// Delete the avatar from this linkset (avatar is unsat). - /// - /// - public void DeleteAvatar(UUID agentID) - { - ScenePresence presence; - if (m_scene.TryGetScenePresence(agentID, out presence)) - { - if (m_linkedAvatars.Contains(presence)) - { - m_linkedAvatars.Remove(presence); - } - } - } - - /// - /// Returns the list of linked presences (avatars sat on this group) - /// - /// - public List GetLinkedAvatars() - { - return m_linkedAvatars; - } - - /// - /// Attach this scene object to the given avatar. - /// - /// - /// - /// - public void AttachToAgent(UUID agentID, uint attachmentpoint, Vector3 AttachOffset, bool silent) - { - ScenePresence avatar = m_scene.GetScenePresence(agentID); - if (avatar != null) - { - // don't attach attachments to child agents - if (avatar.IsChildAgent) return; - -// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name); - - DetachFromBackup(); - - // Remove from database and parcel prim count - m_scene.DeleteFromStorage(UUID); - m_scene.EventManager.TriggerParcelPrimCountTainted(); - - m_rootPart.AttachedAvatar = agentID; - - //Anakin Lohner bug #3839 - lock (m_parts) - { - foreach (SceneObjectPart p in m_parts.GetArray()) - { - p.AttachedAvatar = agentID; - } - } - - if (m_rootPart.PhysActor != null) - { - m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); - m_rootPart.PhysActor = null; - } - - AbsolutePosition = AttachOffset; - m_rootPart.AttachedPos = AttachOffset; - m_rootPart.IsAttachment = true; - - m_rootPart.SetParentLocalId(avatar.LocalId); - SetAttachmentPoint(Convert.ToByte(attachmentpoint)); - - avatar.AddAttachment(this); - - if (!silent) - { - // Killing it here will cause the client to deselect it - // It then reappears on the avatar, deselected - // through the full update below - // - if (IsSelected) - { - m_scene.SendKillObject(new List { m_rootPart.LocalId }); - } - - IsSelected = false; // fudge.... - ScheduleGroupForFullUpdate(); - } - } - else - { - m_log.WarnFormat( - "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", - UUID, agentID, Scene.RegionInfo.RegionName); - } - } - - public byte GetAttachmentPoint() - { - return m_rootPart.Shape.State; - } - - public void ClearPartAttachmentData() - { - SetAttachmentPoint((Byte)0); - } - - public void DetachToGround() - { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); - if (avatar == null) - return; - - avatar.RemoveAttachment(this); - - Vector3 detachedpos = new Vector3(127f,127f,127f); - if (avatar == null) - return; - - detachedpos = avatar.AbsolutePosition; - RootPart.FromItemID = UUID.Zero; - - AbsolutePosition = detachedpos; - m_rootPart.AttachedAvatar = UUID.Zero; - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; - - m_rootPart.SetParentLocalId(0); - SetAttachmentPoint((byte)0); - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); - HasGroupChanged = true; - RootPart.Rezzed = DateTime.Now; - RootPart.RemFlag(PrimFlags.TemporaryOnRez); - AttachToBackup(); - m_scene.EventManager.TriggerParcelPrimCountTainted(); - m_rootPart.ScheduleFullUpdate(); - m_rootPart.ClearUndoState(); - } - - public void DetachToInventoryPrep() - { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); - //Vector3 detachedpos = new Vector3(127f, 127f, 127f); - if (avatar != null) - { - //detachedpos = avatar.AbsolutePosition; - avatar.RemoveAttachment(this); - } - - m_rootPart.AttachedAvatar = UUID.Zero; - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; - - m_rootPart.SetParentLocalId(0); - //m_rootPart.SetAttachmentPoint((byte)0); - m_rootPart.IsAttachment = false; - AbsolutePosition = m_rootPart.AttachedPos; - //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); - //AttachToBackup(); - //m_rootPart.ScheduleFullUpdate(); - } - -======= ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 /// /// /// @@ -1361,7 +1027,7 @@ namespace OpenSim.Region.Framework.Scenes { m_scene = scene; } - + /// /// Set a part to act as the root part for this scene object /// @@ -1376,7 +1042,7 @@ namespace OpenSim.Region.Framework.Scenes if (!IsAttachment) part.ParentID = 0; part.LinkNum = 0; - + m_parts.Add(m_rootPart.UUID, m_rootPart); } @@ -1387,16 +1053,8 @@ namespace OpenSim.Region.Framework.Scenes public void AddPart(SceneObjectPart part) { part.SetParent(this); -<<<<<<< HEAD - m_parts.Add(part.UUID, part); - - part.LinkNum = m_parts.Count; - - if (part.LinkNum == 2 && RootPart != null) -======= part.LinkNum = m_parts.Add(part.UUID, part); if (part.LinkNum == 2) ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 RootPart.LinkNum = 1; } @@ -1432,19 +1090,19 @@ namespace OpenSim.Region.Framework.Scenes // justincc: I don't believe this hack is needed any longer, especially since the physics // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false // this method was preventing proper reload of scene objects. - + // dahlia: I had to uncomment it, without it meshing was failing on some prims and objects // at region startup - + // teravus: After this was removed from the linking algorithm, Linked prims no longer collided // properly when non-physical if they havn't been moved. This breaks ALL builds. // see: http://opensimulator.org/mantis/view.php?id=3108 - + // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and // unmoved prims! As soon as you move a Prim/group, it will collide properly because Absolute // Position has been set! - + public void ResetChildPrimPhysicsPositions() { AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? @@ -1479,15 +1137,11 @@ namespace OpenSim.Region.Framework.Scenes public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) { -<<<<<<< HEAD - part.StoreUndoState(UndoType.STATE_PRIM_ALL); -======= -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", -// remoteClient.Name, part.Name, part.LocalId, offsetPos); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", + // remoteClient.Name, part.Name, part.LocalId, offsetPos); part.StoreUndoState(); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 part.OnGrab(offsetPos, remoteClient); } @@ -1507,11 +1161,6 @@ namespace OpenSim.Region.Framework.Scenes /// If true then deletion is not broadcast to clients public void DeleteGroupFromScene(bool silent) { - // We need to keep track of this state in case this group is still queued for backup. - m_isDeleted = true; - - DetachFromBackup(); - SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { @@ -1523,11 +1172,13 @@ namespace OpenSim.Region.Framework.Scenes avatar.StandUp(); if (!silent) + { part.UpdateFlag = 0; + if (part == m_rootPart) + avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); + } }); } - - } public void AddScriptLPS(int count) @@ -1587,10 +1238,10 @@ namespace OpenSim.Region.Framework.Scenes public void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int) (alpha * 0xff), - (int) (color.X * 0xff), - (int) (color.Y * 0xff), - (int) (color.Z * 0xff)); + Color = Color.FromArgb(0xff - (int)(alpha * 0xff), + (int)(color.X * 0xff), + (int)(color.Y * 0xff), + (int)(color.Z * 0xff)); Text = text; HasGroupChanged = true; @@ -1605,7 +1256,7 @@ namespace OpenSim.Region.Framework.Scenes { // Apply physics to the root prim m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); - + // Apply physics to child prims SceneObjectPart[] parts = m_parts.GetArray(); if (parts.Length > 1) @@ -1624,12 +1275,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetOwnerId(UUID userId) { - ForEachPart(delegate(SceneObjectPart part) - { - - part.OwnerID = userId; - - }); + ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); } public void ForEachPart(Action whatToDo) @@ -1649,29 +1295,23 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_isBackedUp) { -// m_log.DebugFormat( -// "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID); + // m_log.DebugFormat( + // "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID); return; } if (IsDeleted || UUID == UUID.Zero) { -// m_log.DebugFormat( -// "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); + // m_log.DebugFormat( + // "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); return; } - if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) - return; - // Since this is the top of the section of call stack for backing up a particular scene object, don't let // any exception propogate upwards. try { - if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart - m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things - m_scene.LoadingPrims) // Land may not be valid yet - + if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart { ILandObject parcel = m_scene.LandChannel.GetLandObject( m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); @@ -1688,7 +1328,7 @@ namespace OpenSim.Region.Framework.Scenes { DetachFromBackup(); m_log.DebugFormat( - "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", + "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", RootPart.UUID); m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn"); m_scene.DeRezObjects(null, new List() { RootPart.LocalId }, UUID.Zero, @@ -1698,7 +1338,6 @@ namespace OpenSim.Region.Framework.Scenes } } } - } if (m_scene.UseBackup && HasGroupChanged) @@ -1706,23 +1345,9 @@ namespace OpenSim.Region.Framework.Scenes // don't backup while it's selected or you're asking for changes mid stream. if (isTimeToPersist() || forcedBackup) { - if (m_rootPart.PhysActor != null && - (!m_rootPart.PhysActor.IsPhysical)) - { - // Possible ghost prim - if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) - { - foreach (SceneObjectPart part in m_parts.GetArray()) - { - // Re-set physics actor positions and - // orientations - part.GroupPosition = m_rootPart.GroupPosition; - } - } - } -// m_log.DebugFormat( -// "[SCENE]: Storing {0}, {1} in {2}", -// Name, UUID, m_scene.RegionInfo.RegionName); + // m_log.DebugFormat( + // "[SCENE]: Storing {0}, {1} in {2}", + // Name, UUID, m_scene.RegionInfo.RegionName); SceneObjectGroup backup_group = Copy(false); backup_group.RootPart.Velocity = RootPart.Velocity; @@ -1735,25 +1360,25 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); - backup_group.ForEachPart(delegate(SceneObjectPart part) - { - part.Inventory.ProcessInventoryBackup(datastore); + backup_group.ForEachPart(delegate(SceneObjectPart part) + { + part.Inventory.ProcessInventoryBackup(datastore); }); backup_group = null; } -// else -// { -// m_log.DebugFormat( -// "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}", -// Name, UUID, IsSelected); -// } + // else + // { + // m_log.DebugFormat( + // "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}", + // Name, UUID, IsSelected); + // } } } catch (Exception e) { m_log.ErrorFormat( - "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", + "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", Name, UUID, m_scene.RegionInfo.RegionName, e.Message, e.StackTrace); } } @@ -1783,106 +1408,63 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup Copy(bool userExposed) { - SceneObjectGroup dupe; - try - { - m_dupeInProgress = true; - dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new MapAndArray(); - -<<<<<<< HEAD - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state -======= + SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new MapAndArray(); + + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state + + // This is only necessary when userExposed is false! + bool previousAttachmentStatus = dupe.IsAttachment; - + if (!userExposed) dupe.IsAttachment = true; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 - // This is only necessary when userExposed is false! + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); -<<<<<<< HEAD - bool previousAttachmentStatus = dupe.RootPart.IsAttachment; -======= if (!userExposed) { dupe.IsAttachment = previousAttachmentStatus; } ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 - - if (!userExposed) - dupe.RootPart.IsAttachment = true; - - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - - if (!userExposed) - { - dupe.RootPart.IsAttachment = previousAttachmentStatus; - } - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - if (userExposed) - dupe.m_rootPart.TrimPermissions(); + if (userExposed) + dupe.m_rootPart.TrimPermissions(); - List partList = new List(m_parts.GetArray()); + List partList = new List(m_parts.GetArray()); - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); - foreach (SceneObjectPart part in partList) + foreach (SceneObjectPart part in partList) + { + SceneObjectPart newPart; + if (part.UUID != m_rootPart.UUID) { - if (part.UUID != m_rootPart.UUID) - { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - - newPart.LinkNum = part.LinkNum; - } - - // Need to duplicate the physics actor as well - if (part.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = part.Shape; - - part.PhysActor - = m_scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", part.Name, part.UUID), - pbs, - part.AbsolutePosition, - part.Scale, - part.RotationOffset, - part.PhysActor.IsPhysical, - m_localId); - part.PhysActor.SetMaterial((int)part.Material); - - part.PhysActor.LocalID = part.LocalId; - part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); - } + newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); + newPart.LinkNum = part.LinkNum; } - if (userExposed) + else { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); + newPart = dupe.m_rootPart; + } -<<<<<<< HEAD - ScheduleGroupForFullUpdate(); -======= // Need to duplicate the physics actor as well if (part.PhysActor != null && userExposed) { PrimitiveBaseShape pbs = newPart.Shape; - + newPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( string.Format("{0}/{1}", newPart.Name, newPart.UUID), @@ -1892,15 +1474,20 @@ namespace OpenSim.Region.Framework.Scenes newPart.RotationOffset, part.PhysActor.IsPhysical, newPart.LocalId); - + newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 } } - finally + + if (userExposed) { - m_dupeInProgress = false; + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); } + return dupe; } @@ -2006,7 +1593,6 @@ namespace OpenSim.Region.Framework.Scenes return Vector3.Zero; } - // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object public void moveToTarget(Vector3 target, float tau) { if (IsAttachment) @@ -2030,72 +1616,14 @@ namespace OpenSim.Region.Framework.Scenes public void stopMoveToTarget() { -<<<<<<< HEAD - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) - { - if (IsAttachment) - { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) avatar.StopMoveToPosition(); - } - else - { - if (rootpart.PhysActor != null) - { - rootpart.PhysActor.PIDActive = false; - } - } - } -======= if (RootPart.PhysActor != null) RootPart.PhysActor.PIDActive = false; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 - } - - public void rotLookAt(Quaternion target, float strength, float damping) - { - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) - { - if (IsAttachment) - { - /* - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) - { - Rotate the Av? - } */ - } - else - { - if (rootpart.PhysActor != null) - { // APID must be implemented in your physics system for this to function. - rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); - rootpart.PhysActor.APIDStrength = strength; - rootpart.PhysActor.APIDDamping = damping; - rootpart.PhysActor.APIDActive = true; - } - } - } } public void stopLookAt() { -<<<<<<< HEAD - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) - { - if (rootpart.PhysActor != null) - { // APID must be implemented in your physics system for this to function. - rootpart.PhysActor.APIDActive = false; - } - } - -======= if (RootPart.PhysActor != null) RootPart.PhysActor.APIDActive = false; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 } /// @@ -2153,8 +1681,6 @@ namespace OpenSim.Region.Framework.Scenes public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); - newPart.SetParent(this); - AddPart(newPart); SetPartAsNonRoot(newPart); @@ -2188,11 +1714,11 @@ namespace OpenSim.Region.Framework.Scenes public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags) { remoteClient.SendObjectPropertiesFamilyData(RootPart, RequestFlags); - -// remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask, -// RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, -// RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, -// RootPart.CreatorID, RootPart.Name, RootPart.Description); + + // remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask, + // RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, + // RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, + // RootPart.CreatorID, RootPart.Name, RootPart.Description); } public void SetPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID) @@ -2245,8 +1771,8 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleFullUpdateToAvatar(ScenePresence presence) { -// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); - + // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); + RootPart.AddFullUpdateToAvatar(presence); SceneObjectPart[] parts = m_parts.GetArray(); @@ -2260,7 +1786,7 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleTerseUpdateToAvatar(ScenePresence presence) { -// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); + // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -2272,9 +1798,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForFullUpdate() { -// if (IsAttachment) -// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); - + // if (IsAttachment) + // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); + checkAtTargets(); RootPart.ScheduleFullUpdate(); @@ -2292,7 +1818,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForTerseUpdate() { -// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); + // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -2303,12 +1829,12 @@ namespace OpenSim.Region.Framework.Scenes /// Immediately send a full update for this scene object. /// public void SendGroupFullUpdate() - { + { if (IsDeleted) return; -// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); - + // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); + RootPart.SendFullUpdateToAllClients(); SceneObjectPart[] parts = m_parts.GetArray(); @@ -2338,7 +1864,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_scene == null) // Need to check here as it's null during object creation return; - + m_scene.SceneGraph.AddToUpdateList(this); } @@ -2454,9 +1980,9 @@ namespace OpenSim.Region.Framework.Scenes // objectGroup.RootPart.SendScheduledUpdates(); //} -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", -// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", + // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); SceneObjectPart linkPart = objectGroup.m_rootPart; @@ -2496,15 +2022,12 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum += objectGroup.PrimCount; } } - } - linkPart.LinkNum = 2; + linkPart.LinkNum = 2; - linkPart.SetParent(this); - linkPart.CreateSelected = true; + linkPart.SetParent(this); + linkPart.CreateSelected = true; - lock (m_parts.SyncRoot) - { //if (linkPart.PhysActor != null) //{ // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); @@ -2528,9 +2051,9 @@ namespace OpenSim.Region.Framework.Scenes objectGroup.IsDeleted = true; objectGroup.m_parts.Clear(); - + // Can't do this yet since backup still makes use of the root part without any synchronization -// objectGroup.m_rootPart = null; + // objectGroup.m_rootPart = null; AttachToBackup(); @@ -2588,10 +2111,10 @@ namespace OpenSim.Region.Framework.Scenes /// The object group of the newly delinked prim. public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", -// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); - + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", + // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); + linkPart.ClearUndoState(); Quaternion worldRot = linkPart.GetWorldRotation(); @@ -2662,15 +2185,9 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void DetachFromBackup() { -<<<<<<< HEAD - m_scene.SceneGraph.FireDetachFromBackup(this); - - if (m_isBackedUp) -======= if (m_isBackedUp && Scene != null) ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 m_scene.EventManager.OnBackup -= ProcessBackup; - + m_isBackedUp = false; } @@ -2686,8 +2203,7 @@ namespace OpenSim.Region.Framework.Scenes axPos *= parentRot; part.OffsetPosition = axPos; - Vector3 newPos = oldGroupPosition + part.OffsetPosition; - part.GroupPosition = newPos; + part.GroupPosition = oldGroupPosition + part.OffsetPosition; part.OffsetPosition = Vector3.Zero; part.RotationOffset = worldRot; @@ -2698,7 +2214,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = linkNum; - part.OffsetPosition = newPos - AbsolutePosition; + part.OffsetPosition = part.GroupPosition - AbsolutePosition; Quaternion rootRotation = m_rootPart.RotationOffset; @@ -2708,7 +2224,7 @@ namespace OpenSim.Region.Framework.Scenes parentRot = m_rootPart.RotationOffset; oldRot = part.RotationOffset; - Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; + Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; part.RotationOffset = newRot; } @@ -2806,7 +2322,7 @@ namespace OpenSim.Region.Framework.Scenes // but it will result in over-shoot or under-shoot of the target orientation. // For the end user, this means that ctrl+shift+drag can be used for relative, // but not absolute, adjustments of orientation for physical prims. - + if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) { if (m_rootPart.PhysActor != null) @@ -2821,25 +2337,25 @@ namespace OpenSim.Region.Framework.Scenes } else { - // save and update old orientation - Quaternion old = m_rootPart.SpinOldOrientation; - m_rootPart.SpinOldOrientation = newOrientation; - //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); - //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); - - // compute difference between previous old rotation and new incoming rotation - Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; - - float rotationAngle; - Vector3 rotationAxis; - minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); - rotationAxis.Normalize(); - - //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); - Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); - spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor - m_rootPart.PhysActor.AddAngularForce(spinforce,true); - m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + // save and update old orientation + Quaternion old = m_rootPart.SpinOldOrientation; + m_rootPart.SpinOldOrientation = newOrientation; + //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); + //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); + + // compute difference between previous old rotation and new incoming rotation + Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; + + float rotationAngle; + Vector3 rotationAxis; + minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); + rotationAxis.Normalize(); + + //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); + Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); + spinforce = (spinforce / 8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor + m_rootPart.PhysActor.AddAngularForce(spinforce, true); + m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); } } else @@ -2948,14 +2464,14 @@ namespace OpenSim.Region.Framework.Scenes if (selectionPart != null) { SceneObjectPart[] parts = m_parts.GetArray(); - + if (Scene != null) { for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; - if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || - part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || + if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || + part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || part.Scale.Z > m_scene.RegionInfo.PhysPrimMax) { UsePhysics = false; // Reset physics @@ -2964,16 +2480,8 @@ namespace OpenSim.Region.Framework.Scenes } } - RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); for (int i = 0; i < parts.Length; i++) -<<<<<<< HEAD - { - if (parts[i] != RootPart) - parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); - } -======= parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 } } @@ -2986,17 +2494,6 @@ namespace OpenSim.Region.Framework.Scenes } } - - - /// - /// Gets the number of parts - /// - /// - public int GetPartCount() - { - return Parts.Count(); - } - /// /// Update the texture entry for this part /// @@ -3051,37 +2548,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void GroupResize(Vector3 scale) { -<<<<<<< HEAD - if (scale.X > m_scene.m_maxNonphys) - scale.X = m_scene.m_maxNonphys; - if (scale.Y > m_scene.m_maxNonphys) - scale.Y = m_scene.m_maxNonphys; - if (scale.Z > m_scene.m_maxNonphys) - scale.Z = m_scene.m_maxNonphys; - SceneObjectPart part = GetChildPart(localID); - if (part != null) - { - if (part.PhysActor != null) - { - if (part.PhysActor.IsPhysical) - { - if (scale.X > m_scene.m_maxPhys) - scale.X = m_scene.m_maxPhys; - if (scale.Y > m_scene.m_maxPhys) - scale.Y = m_scene.m_maxPhys; - if (scale.Z > m_scene.m_maxPhys) - scale.Z = m_scene.m_maxPhys; - } - part.PhysActor.Size = scale; - m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); - } - part.Resize(scale); -======= -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); RootPart.StoreUndoState(true); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 scale.X = Math.Min(scale.X, Scene.m_maxNonphys); scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); @@ -3094,35 +2564,9 @@ namespace OpenSim.Region.Framework.Scenes scale.Z = Math.Min(scale.Z, Scene.m_maxPhys); } -<<<<<<< HEAD - public void GroupResize(Vector3 scale, uint localID) - { - SceneObjectPart part = GetChildPart(localID); - if (part != null) - { - if (scale.X > m_scene.m_maxNonphys) - scale.X = m_scene.m_maxNonphys; - if (scale.Y > m_scene.m_maxNonphys) - scale.Y = m_scene.m_maxNonphys; - if (scale.Z > m_scene.m_maxNonphys) - scale.Z = m_scene.m_maxNonphys; - if (part.PhysActor != null && part.PhysActor.IsPhysical) - { - if (scale.X > m_scene.m_maxPhys) - scale.X = m_scene.m_maxPhys; - if (scale.Y > m_scene.m_maxPhys) - scale.Y = m_scene.m_maxPhys; - if (scale.Z > m_scene.m_maxPhys) - scale.Z = m_scene.m_maxPhys; - } - float x = (scale.X / part.Scale.X); - float y = (scale.Y / part.Scale.Y); - float z = (scale.Z / part.Scale.Z); -======= float x = (scale.X / RootPart.Scale.X); float y = (scale.Y / RootPart.Scale.Y); float z = (scale.Z / RootPart.Scale.Z); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 SceneObjectPart[] parts; if (x > 1.0f || y > 1.0f || z > 1.0f) @@ -3133,7 +2577,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart obPart = parts[i]; if (obPart.UUID != m_rootPart.UUID) { -// obPart.IgnoreUndoUpdate = true; + // obPart.IgnoreUndoUpdate = true; Vector3 oldSize = new Vector3(obPart.Scale); float f = 1.0f; @@ -3161,72 +2605,17 @@ namespace OpenSim.Region.Framework.Scenes if (oldSize.Z * z > m_scene.m_maxPhys) { -<<<<<<< HEAD - if (oldSize.X*x > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Y*y > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Z*z > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } -======= f = m_scene.m_maxPhys / oldSize.Z; a = f / z; x *= a; y *= a; z *= a; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 } } else { if (oldSize.X * x > m_scene.m_maxNonphys) { -<<<<<<< HEAD - if (oldSize.X*x > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Y*y > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Z*z > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } - } - obPart.IgnoreUndoUpdate = false; -======= f = m_scene.m_maxNonphys / oldSize.X; a = f / x; x *= a; @@ -3251,35 +2640,21 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 } -// obPart.IgnoreUndoUpdate = false; + // obPart.IgnoreUndoUpdate = false; } } } -<<<<<<< HEAD - Vector3 prevScale = part.Scale; - prevScale.X *= x; - prevScale.Y *= y; - prevScale.Z *= z;; - - part.IgnoreUndoUpdate = false; - part.StoreUndoState(UndoType.STATE_GROUP_SCALE); - part.IgnoreUndoUpdate = true; - part.Resize(prevScale); - part.IgnoreUndoUpdate = false; -======= Vector3 prevScale = RootPart.Scale; prevScale.X *= x; prevScale.Y *= y; prevScale.Z *= z; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 -// RootPart.IgnoreUndoUpdate = true; + // RootPart.IgnoreUndoUpdate = true; RootPart.Resize(prevScale); -// RootPart.IgnoreUndoUpdate = false; + // RootPart.IgnoreUndoUpdate = false; parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -3289,32 +2664,6 @@ namespace OpenSim.Region.Framework.Scenes if (obPart.UUID != m_rootPart.UUID) { obPart.IgnoreUndoUpdate = true; -<<<<<<< HEAD - if (obPart.UUID != m_rootPart.UUID) - { - if (obPart.UUID != m_rootPart.UUID) - { - obPart.IgnoreUndoUpdate = false; - obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); - obPart.IgnoreUndoUpdate = true; - - Vector3 currentpos = new Vector3(obPart.OffsetPosition); - currentpos.X *= x; - currentpos.Y *= y; - currentpos.Z *= z; - Vector3 newSize = new Vector3(obPart.Scale); - newSize.X *= x; - newSize.Y *= y; - newSize.Z *= z; - obPart.Resize(newSize); - obPart.UpdateOffSet(currentpos); - } - obPart.IgnoreUndoUpdate = false; - } - obPart.IgnoreUndoUpdate = false; - } -======= ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 Vector3 currentpos = new Vector3(obPart.OffsetPosition); currentpos.X *= x; @@ -3329,22 +2678,15 @@ namespace OpenSim.Region.Framework.Scenes obPart.Resize(newSize); obPart.UpdateOffSet(currentpos); - obPart.IgnoreUndoUpdate = false; + obPart.IgnoreUndoUpdate = false; } -<<<<<<< HEAD - part.IgnoreUndoUpdate = false; - HasGroupChanged = true; - m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); - ScheduleGroupForTerseUpdate(); -======= -// obPart.IgnoreUndoUpdate = false; -// obPart.StoreUndoState(); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 + // obPart.IgnoreUndoUpdate = false; + // obPart.StoreUndoState(); } -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); } #endregion @@ -3357,22 +2699,18 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupPosition(Vector3 pos) { -<<<<<<< HEAD -======= -// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); + // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); RootPart.StoreUndoState(true); -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); + // SceneObjectPart[] parts = m_parts.GetArray(); + // for (int i = 0; i < parts.Length; i++) + // parts[i].StoreUndoState(); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { if (IsAttachment) { - m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); m_rootPart.AttachedPos = pos; } if (RootPart.GetStatusSandbox()) @@ -3404,20 +2742,14 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetChildPart(localID); -<<<<<<< HEAD - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); -======= -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 + // SceneObjectPart[] parts = m_parts.GetArray(); + // for (int i = 0; i < parts.Length; i++) + // parts[i].StoreUndoState(); if (part != null) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); part.StoreUndoState(false); part.IgnoreUndoUpdate = true; @@ -3442,18 +2774,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateRootPosition(Vector3 pos) { -<<<<<<< HEAD - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); -======= -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 + // SceneObjectPart[] parts = m_parts.GetArray(); + // for (int i = 0; i < parts.Length; i++) + // parts[i].StoreUndoState(); Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); Vector3 oldPos = @@ -3474,27 +2800,10 @@ namespace OpenSim.Region.Framework.Scenes obPart.OffsetPosition = obPart.OffsetPosition + diff; } - //We have to set undoing here because otherwise an undo state will be saved - if (!m_rootPart.Undoing) - { - m_rootPart.Undoing = true; - AbsolutePosition = newPos; - m_rootPart.Undoing = false; - } - else - { - AbsolutePosition = newPos; - } + AbsolutePosition = newPos; HasGroupChanged = true; - if (m_rootPart.Undoing) - { - ScheduleGroupForFullUpdate(); - } - else - { - ScheduleGroupForTerseUpdate(); - } + ScheduleGroupForTerseUpdate(); } public void OffsetForNewRegion(Vector3 offset) @@ -3512,20 +2821,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationR(Quaternion rot) { -<<<<<<< HEAD - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); -======= -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); + // SceneObjectPart[] parts = m_parts.GetArray(); + // for (int i = 0; i < parts.Length; i++) + // parts[i].StoreUndoState(); m_rootPart.StoreUndoState(true); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 m_rootPart.UpdateRotation(rot); @@ -3547,21 +2850,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) { -<<<<<<< HEAD - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); -======= -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); + // SceneObjectPart[] parts = m_parts.GetArray(); + // for (int i = 0; i < parts.Length; i++) + // parts[i].StoreUndoState(); RootPart.StoreUndoState(true); RootPart.IgnoreUndoUpdate = true; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 m_rootPart.UpdateRotation(rot); @@ -3588,14 +2885,15 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateSingleRotation(Quaternion rot, uint localID) { SceneObjectPart part = GetChildPart(localID); + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_PRIM_ROTATION); + parts[i].StoreUndoState(); if (part != null) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); if (part.UUID == m_rootPart.UUID) { @@ -3618,9 +2916,9 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", -// part.Name, part.LocalId, rot); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", + // part.Name, part.LocalId, rot); part.StoreUndoState(); part.IgnoreUndoUpdate = true; @@ -3628,29 +2926,12 @@ namespace OpenSim.Region.Framework.Scenes if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); - if (!m_rootPart.Undoing) - { - m_rootPart.Undoing = true; - AbsolutePosition = pos; - m_rootPart.Undoing = false; - } - else - { - AbsolutePosition = pos; - } + AbsolutePosition = pos; } else { -<<<<<<< HEAD - part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); - part.IgnoreUndoUpdate = true; - part.UpdateRotation(rot); - part.OffsetPosition = pos; - part.IgnoreUndoUpdate = false; -======= part.UpdateRotation(rot); part.OffsetPosition = pos; ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 } part.IgnoreUndoUpdate = false; @@ -3663,23 +2944,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateRootRotation(Quaternion rot) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", -// Name, LocalId, rot); + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", + // Name, LocalId, rot); Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; - m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); - bool cancelUndo = false; - if (!m_rootPart.Undoing) - { - m_rootPart.Undoing = true; - cancelUndo = true; - } - - //Don't use UpdateRotation because it schedules an update prematurely - m_rootPart.RotationOffset = rot; + m_rootPart.StoreUndoState(); + m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; @@ -3694,24 +2967,9 @@ namespace OpenSim.Region.Framework.Scenes { prim.IgnoreUndoUpdate = true; Vector3 axPos = prim.OffsetPosition; - axPos *= oldParentRot; axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; -<<<<<<< HEAD - - prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); - - prim.IgnoreUndoUpdate = false; - } - } - if (cancelUndo == true) - { - m_rootPart.Undoing = false; - } - HasGroupChanged = true; - ScheduleGroupForFullUpdate(); -======= Quaternion primsRot = prim.RotationOffset; Quaternion newRot = primsRot * oldParentRot; newRot *= Quaternion.Inverse(axRot); @@ -3721,22 +2979,21 @@ namespace OpenSim.Region.Framework.Scenes } } -// for (int i = 0; i < parts.Length; i++) -// { -// SceneObjectPart childpart = parts[i]; -// if (childpart != m_rootPart) -// { -//// childpart.IgnoreUndoUpdate = false; -//// childpart.StoreUndoState(); -// } -// } + // for (int i = 0; i < parts.Length; i++) + // { + // SceneObjectPart childpart = parts[i]; + // if (childpart != m_rootPart) + // { + //// childpart.IgnoreUndoUpdate = false; + //// childpart.StoreUndoState(); + // } + // } m_rootPart.ScheduleTerseUpdate(); -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", -// Name, LocalId, rot); ->>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8 + // m_log.DebugFormat( + // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", + // Name, LocalId, rot); } #endregion @@ -3807,7 +3064,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.AddGroupTarget(this); return (int)handle; } - + public void unregisterTargetWaypoint(int handle) { lock (m_targets) @@ -3848,14 +3105,14 @@ namespace OpenSim.Region.Framework.Scenes } } } - + if (atTargets.Count > 0) { SceneObjectPart[] parts = m_parts.GetArray(); uint[] localids = new uint[parts.Length]; for (int i = 0; i < parts.Length; i++) localids[i] = parts[i].LocalId; - + for (int ctr = 0; ctr < localids.Length; ctr++) { foreach (uint target in atTargets.Keys) @@ -3865,10 +3122,10 @@ namespace OpenSim.Region.Framework.Scenes localids[ctr], att.handle, att.targetPos, m_rootPart.GroupPosition); } } - + return; } - + if (m_scriptListens_notAtTarget && !at_target) { //trigger not_at_target @@ -3876,7 +3133,7 @@ namespace OpenSim.Region.Framework.Scenes uint[] localids = new uint[parts.Length]; for (int i = 0; i < parts.Length; i++) localids[i] = parts[i].LocalId; - + for (int ctr = 0; ctr < localids.Length; ctr++) { m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); @@ -3956,10 +3213,11 @@ namespace OpenSim.Region.Framework.Scenes } } } - + public float GetMass() { float retmass = 0f; + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) retmass += parts[i].GetMass(); @@ -3982,7 +3240,7 @@ namespace OpenSim.Region.Framework.Scenes if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) return; -// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); + // m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); SceneObjectPart[] parts = m_parts.GetArray(); @@ -4016,14 +3274,14 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) parts[i].TriggerScriptChangedEvent(val); } - + public override string ToString() { return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); } #region ISceneObject - + public virtual ISceneObject CloneForNewScene() { SceneObjectGroup sog = Copy(false); @@ -4053,14 +3311,6 @@ namespace OpenSim.Region.Framework.Scenes SetFromItemID(uuid); } - public void ResetOwnerChangeFlag() - { - ForEachPart(delegate(SceneObjectPart part) - { - part.ResetOwnerChangeFlag(); - }); - } - #endregion } -} +} \ No newline at end of file -- cgit v1.1 From af59352c4c6b1b49151c009058d867f5ccca3010 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 4 Sep 2011 07:54:17 -0700 Subject: Change of tactic. Reverting this to the careminster version, then i'll selectively merge the changes made to core. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 1752 +++++++++++++------- 1 file changed, 1117 insertions(+), 635 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5762717..6c47645 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -24,11 +24,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + using System; using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Xml; @@ -105,8 +106,29 @@ namespace OpenSim.Region.Framework.Scenes /// since the group's last persistent backup /// private bool m_hasGroupChanged = false; - private long timeFirstChanged; - private long timeLastChanged; + private long timeFirstChanged = 0; + private long timeLastChanged = 0; + private long m_maxPersistTime = 0; + private long m_minPersistTime = 0; + private Random m_rand; + private bool m_suspendUpdates; + private List m_linkedAvatars = new List(); + + public bool areUpdatesSuspended + { + get + { + return m_suspendUpdates; + } + set + { + m_suspendUpdates = value; + if (!value) + { + QueueForUpdateCheck(); + } + } + } public bool HasGroupChanged { @@ -114,24 +136,54 @@ namespace OpenSim.Region.Framework.Scenes { if (value) { + if (m_isBackedUp) + { + m_scene.SceneGraph.FireChangeBackup(this); + } timeLastChanged = DateTime.Now.Ticks; if (!m_hasGroupChanged) timeFirstChanged = DateTime.Now.Ticks; + if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) + { + if (m_rand == null) + { + byte[] val = new byte[16]; + m_rootPart.UUID.ToBytes(val, 0); + m_rand = new Random(BitConverter.ToInt32(val, 0)); + } + + if (m_scene.GetRootAgentCount() == 0) + { + //If the region is empty, this change has been made by an automated process + //and thus we delay the persist time by a random amount between 1.5 and 2.5. + + float factor = 1.5f + (float)(m_rand.NextDouble()); + m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); + m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); + } + else + { + //If the region is not empty, we want to obey the minimum and maximum persist times + //but add a random factor so we stagger the object persistance a little + m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 + m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 + } + } } m_hasGroupChanged = value; - - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId); + +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId); } get { return m_hasGroupChanged; } } - + /// /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. /// - public bool HasGroupChangedDueToDelink { get; private set; } + public bool HasGroupChangedDueToDelink { get; set; } private bool isTimeToPersist() { @@ -141,94 +193,43 @@ namespace OpenSim.Region.Framework.Scenes return false; if (m_scene.ShuttingDown) return true; + + if (m_minPersistTime == 0 || m_maxPersistTime == 0) + { + m_maxPersistTime = m_scene.m_persistAfter; + m_minPersistTime = m_scene.m_dontPersistBefore; + } + long currentTime = DateTime.Now.Ticks; - if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) + + if (timeLastChanged == 0) timeLastChanged = currentTime; + if (timeFirstChanged == 0) timeFirstChanged = currentTime; + + if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) return true; return false; } - - /// + + /// /// Is this scene object acting as an attachment? - /// - public bool IsAttachment { get; set; } - - /// - /// The avatar to which this scene object is attached. - /// - /// - /// If we're not attached to an avatar then this is UUID.Zero - /// - public UUID AttachedAvatar { get; set; } - - /// - /// Attachment point of this scene object to an avatar. - /// - /// - /// 0 if we're not attached to anything - /// - public uint AttachmentPoint + /// + /// We return false if the group has already been deleted. + /// + /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I + /// presume either all or no parts in a linkset can be part of an attachment (in which + /// case the value would get proprogated down into all the descendent parts). + /// + public bool IsAttachment { get { - return m_rootPart.Shape.State; - } - - set - { - IsAttachment = value != 0; - m_rootPart.Shape.State = (byte)value; + if (!IsDeleted) + return m_rootPart.IsAttachment; + + return false; } } - public void ClearPartAttachmentData() - { - AttachmentPoint = 0; - - // Even though we don't use child part state parameters for attachments any more, we still need to set - // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if - // we store them correctly, scene objects that we receive from elsewhere might not. - foreach (SceneObjectPart part in Parts) - part.Shape.State = 0; - } - - /// - /// Is this scene object phantom? - /// - /// - /// Updating must currently take place through UpdatePrimFlags() - /// - public bool IsPhantom - { - get { return (RootPart.Flags & PrimFlags.Phantom) != 0; } - } - - /// - /// Does this scene object use physics? - /// - /// - /// Updating must currently take place through UpdatePrimFlags() - /// - public bool UsesPhysics - { - get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; } - } - - /// - /// Is this scene object temporary? - /// - /// - /// Updating must currently take place through UpdatePrimFlags() - /// - public bool IsTemporary - { - get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; } - } - - public bool IsVolumeDetect - { - get { return RootPart.VolumeDetectActive; } - } - public float scriptScore; private Vector3 lastPhysGroupPos; @@ -247,10 +248,10 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scriptListens_atTarget; private bool m_scriptListens_notAtTarget; - private bool m_scriptListens_atRotTarget; private bool m_scriptListens_notAtRotTarget; + public bool m_dupeInProgress = false; internal Dictionary m_savedScriptState; #region Properties @@ -260,7 +261,11 @@ namespace OpenSim.Region.Framework.Scenes /// public override string Name { - get { return RootPart.Name; } + get { + if (RootPart == null) + return String.Empty; + return RootPart.Name; + } set { RootPart.Name = value; } } @@ -286,7 +291,13 @@ namespace OpenSim.Region.Framework.Scenes public virtual Quaternion Rotation { get { return m_rotation; } - set { m_rotation = value; } + set { + foreach(SceneObjectPart p in m_parts.GetArray()) + { + p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); + } + m_rotation = value; + } } public Quaternion GroupRotation @@ -294,38 +305,6 @@ namespace OpenSim.Region.Framework.Scenes get { return m_rootPart.RotationOffset; } } - public Vector3 GroupScale - { - get - { - Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); - Vector3 maxScale = Vector3.Zero; - Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - Vector3 partscale = part.Scale; - Vector3 partoffset = part.OffsetPosition; - - minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; - minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; - minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; - - maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; - maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; - maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; - } - - finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; - finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; - finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; - - return finalScale; - } - } - public UUID GroupID { get { return m_rootPart.GroupID; } @@ -365,19 +344,17 @@ namespace OpenSim.Region.Framework.Scenes /// /// Check both the attachment property and the relevant properties of the underlying root part. /// - /// /// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't /// have the IsAttachment property yet checked. /// /// FIXME: However, this should be fixed so that this property /// propertly reflects the underlying status. - /// /// public bool IsAttachmentCheckFull() { return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); } - + /// /// The absolute position of this scene object in the scene /// @@ -391,30 +368,55 @@ namespace OpenSim.Region.Framework.Scenes if (Scene != null) { if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) - || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { m_scene.CrossPrimGroupIntoNewRegion(val, this, true); } } + foreach (SceneObjectPart part in m_parts.GetArray()) + { + part.IgnoreUndoUpdate = true; + } if (RootPart.GetStatusSandbox()) { if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) { RootPart.ScriptSetPhysicsStatus(false); - + if (Scene != null) Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); - + return; } } - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].GroupPosition = val; + foreach (SceneObjectPart part in parts) + { + part.IgnoreUndoUpdate = false; + part.StoreUndoState(UndoType.STATE_GROUP_POSITION); + part.GroupPosition = val; + if (!m_dupeInProgress) + { + part.TriggerScriptChangedEvent(Changed.POSITION); + } + } + if (!m_dupeInProgress) + { + foreach (ScenePresence av in m_linkedAvatars) + { + SceneObjectPart p; + if (m_parts.TryGetValue(av.LinkedPrim, out p)) + { + Vector3 offset = p.GetWorldPosition() - av.ParentPosition; + av.AbsolutePosition += offset; + av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition + av.SendAvatarDataToAllAgents(); + } + } + } //if (m_rootPart.PhysActor != null) //{ @@ -423,7 +425,7 @@ namespace OpenSim.Region.Framework.Scenes //m_rootPart.GroupPosition.Z); //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); //} - + if (Scene != null) Scene.EventManager.TriggerParcelPrimCountTainted(); } @@ -438,7 +440,7 @@ namespace OpenSim.Region.Framework.Scenes public override UUID UUID { get { return m_rootPart.UUID; } - set + set { lock (m_parts.SyncRoot) { @@ -469,10 +471,9 @@ namespace OpenSim.Region.Framework.Scenes public string Text { - get - { + get { string returnstr = m_rootPart.Text; - if (returnstr.Length > 255) + if (returnstr.Length > 255) { returnstr = returnstr.Substring(0, 255); } @@ -485,7 +486,7 @@ namespace OpenSim.Region.Framework.Scenes { get { return true; } } - + private bool m_passCollision; public bool PassCollision { @@ -562,10 +563,10 @@ namespace OpenSim.Region.Framework.Scenes #endregion - // ~SceneObjectGroup() - // { - // m_log.DebugFormat("[SCENE OBJECT GROUP]: Destructor called for {0}, local id {1}", Name, LocalId); - // } +// ~SceneObjectGroup() +// { +// m_log.DebugFormat("[SCENE OBJECT GROUP]: Destructor called for {0}, local id {1}", Name, LocalId); +// } #region Constructors @@ -574,6 +575,7 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup() { + } /// @@ -617,7 +619,7 @@ namespace OpenSim.Region.Framework.Scenes if (itemid != UUID.Zero) m_savedScriptState[itemid] = node.InnerXml; } - } + } } } @@ -638,6 +640,9 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void AttachToBackup() { + if (IsAttachment) return; + m_scene.SceneGraph.FireAttachToBackup(this); + if (InSceneBackup) { //m_log.DebugFormat( @@ -645,11 +650,11 @@ namespace OpenSim.Region.Framework.Scenes if (!m_isBackedUp) m_scene.EventManager.OnBackup += ProcessBackup; - + m_isBackedUp = true; } } - + /// /// Attach this object to a scene. It will also now appear to agents. /// @@ -677,14 +682,45 @@ namespace OpenSim.Region.Framework.Scenes part.ParentID = m_rootPart.LocalId; //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID); } - + ApplyPhysics(m_scene.m_physicalPrim); + if (RootPart.PhysActor != null) + RootPart.Buoyancy = RootPart.Buoyancy; + // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled // for the same object with very different properties. The caller must schedule the update. //ScheduleGroupForFullUpdate(); } + public Vector3 GroupScale() + { + Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); + Vector3 maxScale = Vector3.Zero; + Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + Vector3 partscale = part.Scale; + Vector3 partoffset = part.OffsetPosition; + + minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; + minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; + minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; + + maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; + maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; + maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; + } + + finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; + finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; + finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; + return finalScale; + + } public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) { // We got a request from the inner_scene to raytrace along the Ray hRay @@ -725,9 +761,9 @@ namespace OpenSim.Region.Framework.Scenes result.normal = inter.normal; result.distance = inter.distance; } + } } - return result; } @@ -747,17 +783,19 @@ namespace OpenSim.Region.Framework.Scenes minZ = 8192f; SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) + foreach (SceneObjectPart part in parts) { - SceneObjectPart part = parts[i]; - Vector3 worldPos = part.GetWorldPosition(); Vector3 offset = worldPos - AbsolutePosition; Quaternion worldRot; if (part.ParentID == 0) + { worldRot = part.RotationOffset; + } else + { worldRot = part.GetWorldRotation(); + } Vector3 frontTopLeft; Vector3 frontTopRight; @@ -769,6 +807,8 @@ namespace OpenSim.Region.Framework.Scenes Vector3 backBottomLeft; Vector3 backBottomRight; + // Vector3[] corners = new Vector3[8]; + Vector3 orig = Vector3.Zero; frontTopLeft.X = orig.X - (part.Scale.X / 2); @@ -803,6 +843,38 @@ namespace OpenSim.Region.Framework.Scenes backBottomRight.Y = orig.Y + (part.Scale.Y / 2); backBottomRight.Z = orig.Z - (part.Scale.Z / 2); + + + //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); + //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); + //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); + //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); + //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); + //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); + //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); + //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); + + //for (int i = 0; i < 8; i++) + //{ + // corners[i] = corners[i] * worldRot; + // corners[i] += offset; + + // if (corners[i].X > maxX) + // maxX = corners[i].X; + // if (corners[i].X < minX) + // minX = corners[i].X; + + // if (corners[i].Y > maxY) + // maxY = corners[i].Y; + // if (corners[i].Y < minY) + // minY = corners[i].Y; + + // if (corners[i].Z > maxZ) + // maxZ = corners[i].Y; + // if (corners[i].Z < minZ) + // minZ = corners[i].Z; + //} + frontTopLeft = frontTopLeft * worldRot; frontTopRight = frontTopRight * worldRot; frontBottomLeft = frontBottomLeft * worldRot; @@ -824,6 +896,15 @@ namespace OpenSim.Region.Framework.Scenes backTopLeft += offset; backTopRight += offset; + //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); + //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); + //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); + //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); + //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); + //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); + //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); + //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); + if (frontTopRight.X > maxX) maxX = frontTopRight.X; if (frontTopLeft.X > maxX) @@ -961,7 +1042,7 @@ namespace OpenSim.Region.Framework.Scenes offsetHeight *= -1; } - // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); + // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); return boundingBox; } @@ -969,15 +1050,20 @@ namespace OpenSim.Region.Framework.Scenes public void SaveScriptedState(XmlTextWriter writer) { + SaveScriptedState(writer, false); + } + + public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) + { XmlDocument doc = new XmlDocument(); - Dictionary states = new Dictionary(); + Dictionary states = new Dictionary(); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { - Dictionary pstates = parts[i].Inventory.GetScriptStates(); + Dictionary pstates = parts[i].Inventory.GetScriptStates(oldIDs); foreach (KeyValuePair kvp in pstates) - states.Add(kvp.Key, kvp.Value); + states[kvp.Key] = kvp.Value; } if (states.Count > 0) @@ -997,6 +1083,187 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Add the avatar to this linkset (avatar is sat). + /// + /// + public void AddAvatar(UUID agentID) + { + ScenePresence presence; + if (m_scene.TryGetScenePresence(agentID, out presence)) + { + if (!m_linkedAvatars.Contains(presence)) + { + m_linkedAvatars.Add(presence); + } + } + } + + /// + /// Delete the avatar from this linkset (avatar is unsat). + /// + /// + public void DeleteAvatar(UUID agentID) + { + ScenePresence presence; + if (m_scene.TryGetScenePresence(agentID, out presence)) + { + if (m_linkedAvatars.Contains(presence)) + { + m_linkedAvatars.Remove(presence); + } + } + } + + /// + /// Returns the list of linked presences (avatars sat on this group) + /// + /// + public List GetLinkedAvatars() + { + return m_linkedAvatars; + } + + /// + /// Attach this scene object to the given avatar. + /// + /// + /// + /// + public void AttachToAgent(UUID agentID, uint attachmentpoint, Vector3 AttachOffset, bool silent) + { + ScenePresence avatar = m_scene.GetScenePresence(agentID); + if (avatar != null) + { + // don't attach attachments to child agents + if (avatar.IsChildAgent) return; + +// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name); + + DetachFromBackup(); + + // Remove from database and parcel prim count + m_scene.DeleteFromStorage(UUID); + m_scene.EventManager.TriggerParcelPrimCountTainted(); + + m_rootPart.AttachedAvatar = agentID; + + //Anakin Lohner bug #3839 + lock (m_parts) + { + foreach (SceneObjectPart p in m_parts.GetArray()) + { + p.AttachedAvatar = agentID; + } + } + + if (m_rootPart.PhysActor != null) + { + m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); + m_rootPart.PhysActor = null; + } + + AbsolutePosition = AttachOffset; + m_rootPart.AttachedPos = AttachOffset; + m_rootPart.IsAttachment = true; + + m_rootPart.SetParentLocalId(avatar.LocalId); + SetAttachmentPoint(Convert.ToByte(attachmentpoint)); + + avatar.AddAttachment(this); + + if (!silent) + { + // Killing it here will cause the client to deselect it + // It then reappears on the avatar, deselected + // through the full update below + // + if (IsSelected) + { + m_scene.SendKillObject(new List { m_rootPart.LocalId }); + } + + IsSelected = false; // fudge.... + ScheduleGroupForFullUpdate(); + } + } + else + { + m_log.WarnFormat( + "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", + UUID, agentID, Scene.RegionInfo.RegionName); + } + } + + public byte GetAttachmentPoint() + { + return m_rootPart.Shape.State; + } + + public void ClearPartAttachmentData() + { + SetAttachmentPoint((Byte)0); + } + + public void DetachToGround() + { + ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); + if (avatar == null) + return; + + avatar.RemoveAttachment(this); + + Vector3 detachedpos = new Vector3(127f,127f,127f); + if (avatar == null) + return; + + detachedpos = avatar.AbsolutePosition; + RootPart.FromItemID = UUID.Zero; + + AbsolutePosition = detachedpos; + m_rootPart.AttachedAvatar = UUID.Zero; + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].AttachedAvatar = UUID.Zero; + + m_rootPart.SetParentLocalId(0); + SetAttachmentPoint((byte)0); + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); + HasGroupChanged = true; + RootPart.Rezzed = DateTime.Now; + RootPart.RemFlag(PrimFlags.TemporaryOnRez); + AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); + m_rootPart.ScheduleFullUpdate(); + m_rootPart.ClearUndoState(); + } + + public void DetachToInventoryPrep() + { + ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); + //Vector3 detachedpos = new Vector3(127f, 127f, 127f); + if (avatar != null) + { + //detachedpos = avatar.AbsolutePosition; + avatar.RemoveAttachment(this); + } + + m_rootPart.AttachedAvatar = UUID.Zero; + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].AttachedAvatar = UUID.Zero; + + m_rootPart.SetParentLocalId(0); + //m_rootPart.SetAttachmentPoint((byte)0); + m_rootPart.IsAttachment = false; + AbsolutePosition = m_rootPart.AttachedPos; + //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); + //AttachToBackup(); + //m_rootPart.ScheduleFullUpdate(); + } + + /// /// /// /// @@ -1027,7 +1294,7 @@ namespace OpenSim.Region.Framework.Scenes { m_scene = scene; } - + /// /// Set a part to act as the root part for this scene object /// @@ -1042,7 +1309,7 @@ namespace OpenSim.Region.Framework.Scenes if (!IsAttachment) part.ParentID = 0; part.LinkNum = 0; - + m_parts.Add(m_rootPart.UUID, m_rootPart); } @@ -1053,8 +1320,11 @@ namespace OpenSim.Region.Framework.Scenes public void AddPart(SceneObjectPart part) { part.SetParent(this); - part.LinkNum = m_parts.Add(part.UUID, part); - if (part.LinkNum == 2) + m_parts.Add(part.UUID, part); + + part.LinkNum = m_parts.Count; + + if (part.LinkNum == 2 && RootPart != null) RootPart.LinkNum = 1; } @@ -1090,19 +1360,19 @@ namespace OpenSim.Region.Framework.Scenes // justincc: I don't believe this hack is needed any longer, especially since the physics // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false // this method was preventing proper reload of scene objects. - + // dahlia: I had to uncomment it, without it meshing was failing on some prims and objects // at region startup - + // teravus: After this was removed from the linking algorithm, Linked prims no longer collided // properly when non-physical if they havn't been moved. This breaks ALL builds. // see: http://opensimulator.org/mantis/view.php?id=3108 - + // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and // unmoved prims! As soon as you move a Prim/group, it will collide properly because Absolute // Position has been set! - + public void ResetChildPrimPhysicsPositions() { AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? @@ -1137,11 +1407,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", - // remoteClient.Name, part.Name, part.LocalId, offsetPos); - - part.StoreUndoState(); + part.StoreUndoState(UndoType.STATE_PRIM_ALL); part.OnGrab(offsetPos, remoteClient); } @@ -1161,6 +1427,11 @@ namespace OpenSim.Region.Framework.Scenes /// If true then deletion is not broadcast to clients public void DeleteGroupFromScene(bool silent) { + // We need to keep track of this state in case this group is still queued for backup. + m_isDeleted = true; + + DetachFromBackup(); + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { @@ -1172,13 +1443,11 @@ namespace OpenSim.Region.Framework.Scenes avatar.StandUp(); if (!silent) - { part.UpdateFlag = 0; - if (part == m_rootPart) - avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); - } }); } + + } public void AddScriptLPS(int count) @@ -1238,10 +1507,10 @@ namespace OpenSim.Region.Framework.Scenes public void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.X * 0xff), - (int)(color.Y * 0xff), - (int)(color.Z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha * 0xff), + (int) (color.X * 0xff), + (int) (color.Y * 0xff), + (int) (color.Z * 0xff)); Text = text; HasGroupChanged = true; @@ -1256,7 +1525,7 @@ namespace OpenSim.Region.Framework.Scenes { // Apply physics to the root prim m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); - + // Apply physics to child prims SceneObjectPart[] parts = m_parts.GetArray(); if (parts.Length > 1) @@ -1275,7 +1544,12 @@ namespace OpenSim.Region.Framework.Scenes public void SetOwnerId(UUID userId) { - ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); + ForEachPart(delegate(SceneObjectPart part) + { + + part.OwnerID = userId; + + }); } public void ForEachPart(Action whatToDo) @@ -1295,23 +1569,29 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_isBackedUp) { - // m_log.DebugFormat( - // "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID); +// m_log.DebugFormat( +// "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID); return; } if (IsDeleted || UUID == UUID.Zero) { - // m_log.DebugFormat( - // "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); +// m_log.DebugFormat( +// "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); return; } + if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) + return; + // Since this is the top of the section of call stack for backing up a particular scene object, don't let // any exception propogate upwards. try { - if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart + if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart + m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things + m_scene.LoadingPrims) // Land may not be valid yet + { ILandObject parcel = m_scene.LandChannel.GetLandObject( m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); @@ -1328,7 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes { DetachFromBackup(); m_log.DebugFormat( - "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", + "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", RootPart.UUID); m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn"); m_scene.DeRezObjects(null, new List() { RootPart.LocalId }, UUID.Zero, @@ -1338,6 +1618,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + } if (m_scene.UseBackup && HasGroupChanged) @@ -1345,9 +1626,23 @@ namespace OpenSim.Region.Framework.Scenes // don't backup while it's selected or you're asking for changes mid stream. if (isTimeToPersist() || forcedBackup) { - // m_log.DebugFormat( - // "[SCENE]: Storing {0}, {1} in {2}", - // Name, UUID, m_scene.RegionInfo.RegionName); + if (m_rootPart.PhysActor != null && + (!m_rootPart.PhysActor.IsPhysical)) + { + // Possible ghost prim + if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) + { + foreach (SceneObjectPart part in m_parts.GetArray()) + { + // Re-set physics actor positions and + // orientations + part.GroupPosition = m_rootPart.GroupPosition; + } + } + } +// m_log.DebugFormat( +// "[SCENE]: Storing {0}, {1} in {2}", +// Name, UUID, m_scene.RegionInfo.RegionName); SceneObjectGroup backup_group = Copy(false); backup_group.RootPart.Velocity = RootPart.Velocity; @@ -1360,25 +1655,25 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); - backup_group.ForEachPart(delegate(SceneObjectPart part) - { - part.Inventory.ProcessInventoryBackup(datastore); + backup_group.ForEachPart(delegate(SceneObjectPart part) + { + part.Inventory.ProcessInventoryBackup(datastore); }); backup_group = null; } - // else - // { - // m_log.DebugFormat( - // "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}", - // Name, UUID, IsSelected); - // } +// else +// { +// m_log.DebugFormat( +// "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}", +// Name, UUID, IsSelected); +// } } } catch (Exception e) { m_log.ErrorFormat( - "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", + "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", Name, UUID, m_scene.RegionInfo.RegionName, e.Message, e.StackTrace); } } @@ -1408,86 +1703,91 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup Copy(bool userExposed) { - SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new MapAndArray(); + SceneObjectGroup dupe; + try + { + m_dupeInProgress = true; + dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new MapAndArray(); - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state - // This is only necessary when userExposed is false! + // This is only necessary when userExposed is false! - bool previousAttachmentStatus = dupe.IsAttachment; + bool previousAttachmentStatus = dupe.RootPart.IsAttachment; - if (!userExposed) - dupe.IsAttachment = true; + if (!userExposed) + dupe.RootPart.IsAttachment = true; - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - if (!userExposed) - { - dupe.IsAttachment = previousAttachmentStatus; - } + if (!userExposed) + { + dupe.RootPart.IsAttachment = previousAttachmentStatus; + } - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - if (userExposed) - dupe.m_rootPart.TrimPermissions(); + if (userExposed) + dupe.m_rootPart.TrimPermissions(); - List partList = new List(m_parts.GetArray()); + List partList = new List(m_parts.GetArray()); - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); - foreach (SceneObjectPart part in partList) - { - SceneObjectPart newPart; - if (part.UUID != m_rootPart.UUID) + foreach (SceneObjectPart part in partList) { - newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - newPart.LinkNum = part.LinkNum; - } - else - { - newPart = dupe.m_rootPart; - } + if (part.UUID != m_rootPart.UUID) + { + SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - // Need to duplicate the physics actor as well - if (part.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = newPart.Shape; + newPart.LinkNum = part.LinkNum; + } - newPart.PhysActor - = m_scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", newPart.Name, newPart.UUID), - pbs, - newPart.AbsolutePosition, - newPart.Scale, - newPart.RotationOffset, - part.PhysActor.IsPhysical, - newPart.LocalId); + // Need to duplicate the physics actor as well + if (part.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = part.Shape; + + part.PhysActor + = m_scene.PhysicsScene.AddPrimShape( + string.Format("{0}/{1}", part.Name, part.UUID), + pbs, + part.AbsolutePosition, + part.Scale, + part.RotationOffset, + part.PhysActor.IsPhysical, + m_localId); + part.PhysActor.SetMaterial((int)part.Material); + + part.PhysActor.LocalID = part.LocalId; + part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); + } + } + if (userExposed) + { + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); - newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); + ScheduleGroupForFullUpdate(); } } - - if (userExposed) + finally { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); - - ScheduleGroupForFullUpdate(); + m_dupeInProgress = false; } - return dupe; } @@ -1502,24 +1802,36 @@ namespace OpenSim.Region.Framework.Scenes SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); } - public void ScriptSetPhysicsStatus(bool usePhysics) + public void ScriptSetPhysicsStatus(bool UsePhysics) { - UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); + bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); + bool IsVolumeDetect = RootPart.VolumeDetectActive; + UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } - public void ScriptSetTemporaryStatus(bool makeTemporary) + public void ScriptSetTemporaryStatus(bool TemporaryStatus) { - UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect); + bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); + bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); + bool IsVolumeDetect = RootPart.VolumeDetectActive; + UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect); } - public void ScriptSetPhantomStatus(bool makePhantom) + public void ScriptSetPhantomStatus(bool PhantomStatus) { - UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect); + bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); + bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); + bool IsVolumeDetect = RootPart.VolumeDetectActive; + UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect); } - public void ScriptSetVolumeDetect(bool makeVolumeDetect) + public void ScriptSetVolumeDetect(bool VDStatus) { - UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect); + bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); + bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); + bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); + UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus); /* ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore @@ -1537,93 +1849,182 @@ namespace OpenSim.Region.Framework.Scenes public void applyImpulse(Vector3 impulse) { - if (IsAttachment) + // We check if rootpart is null here because scripts don't delete if you delete the host. + // This means that unfortunately, we can pass a null physics actor to Simulate! + // Make sure we don't do that! + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) { - ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); - if (avatar != null) + if (IsAttachment) { - avatar.PushForce(impulse); + ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + if (avatar != null) + { + avatar.PushForce(impulse); + } } - } - else - { - if (RootPart.PhysActor != null) + else { - RootPart.PhysActor.AddForce(impulse, true); - m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); + if (rootpart.PhysActor != null) + { + rootpart.PhysActor.AddForce(impulse, true); + m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); + } } } } public void applyAngularImpulse(Vector3 impulse) { - if (RootPart.PhysActor != null) + // We check if rootpart is null here because scripts don't delete if you delete the host. + // This means that unfortunately, we can pass a null physics actor to Simulate! + // Make sure we don't do that! + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) { - if (!IsAttachment) + if (rootpart.PhysActor != null) { - RootPart.PhysActor.AddAngularForce(impulse, true); - m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); + if (!IsAttachment) + { + rootpart.PhysActor.AddAngularForce(impulse, true); + m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); + } } } } public void setAngularImpulse(Vector3 impulse) { - if (RootPart.PhysActor != null) + // We check if rootpart is null here because scripts don't delete if you delete the host. + // This means that unfortunately, we can pass a null physics actor to Simulate! + // Make sure we don't do that! + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) { - if (!IsAttachment) + if (rootpart.PhysActor != null) { - RootPart.PhysActor.Torque = impulse; - m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); + if (!IsAttachment) + { + rootpart.PhysActor.Torque = impulse; + m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); + } } } } public Vector3 GetTorque() { - if (RootPart.PhysActor != null) + // We check if rootpart is null here because scripts don't delete if you delete the host. + // This means that unfortunately, we can pass a null physics actor to Simulate! + // Make sure we don't do that! + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) { - if (!IsAttachment) + if (rootpart.PhysActor != null) { - Vector3 torque = RootPart.PhysActor.Torque; - return torque; + if (!IsAttachment) + { + Vector3 torque = rootpart.PhysActor.Torque; + return torque; + } } } - return Vector3.Zero; } + // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object public void moveToTarget(Vector3 target, float tau) { - if (IsAttachment) + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) { - ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); - if (avatar != null) + if (IsAttachment) { - avatar.MoveToTarget(target, false); + ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + if (avatar != null) + { + List coords = new List(); + uint regionX = 0; + uint regionY = 0; + Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); + target.X += regionX; + target.Y += regionY; + coords.Add(target.X.ToString()); + coords.Add(target.Y.ToString()); + coords.Add(target.Z.ToString()); + avatar.DoMoveToPosition(avatar, "", coords); + } } - } - else - { - if (RootPart.PhysActor != null) + else { - RootPart.PhysActor.PIDTarget = target; - RootPart.PhysActor.PIDTau = tau; - RootPart.PhysActor.PIDActive = true; + if (rootpart.PhysActor != null) + { + rootpart.PhysActor.PIDTarget = target; + rootpart.PhysActor.PIDTau = tau; + rootpart.PhysActor.PIDActive = true; + } } } } public void stopMoveToTarget() { - if (RootPart.PhysActor != null) - RootPart.PhysActor.PIDActive = false; + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) + { + if (IsAttachment) + { + ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + if (avatar != null) avatar.StopMoveToPosition(); + } + else + { + if (rootpart.PhysActor != null) + { + rootpart.PhysActor.PIDActive = false; + } + } + } + } + + public void rotLookAt(Quaternion target, float strength, float damping) + { + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) + { + if (IsAttachment) + { + /* + ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + if (avatar != null) + { + Rotate the Av? + } */ + } + else + { + if (rootpart.PhysActor != null) + { // APID must be implemented in your physics system for this to function. + rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); + rootpart.PhysActor.APIDStrength = strength; + rootpart.PhysActor.APIDDamping = damping; + rootpart.PhysActor.APIDActive = true; + } + } + } } public void stopLookAt() { - if (RootPart.PhysActor != null) - RootPart.PhysActor.APIDActive = false; + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) + { + if (rootpart.PhysActor != null) + { // APID must be implemented in your physics system for this to function. + rootpart.PhysActor.APIDActive = false; + } + } + } /// @@ -1634,18 +2035,22 @@ namespace OpenSim.Region.Framework.Scenes /// Number of seconds over which to reach target public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) { - if (RootPart.PhysActor != null) + SceneObjectPart rootpart = m_rootPart; + if (rootpart != null) { - if (height != 0f) - { - RootPart.PhysActor.PIDHoverHeight = height; - RootPart.PhysActor.PIDHoverType = hoverType; - RootPart.PhysActor.PIDTau = tau; - RootPart.PhysActor.PIDHoverActive = true; - } - else + if (rootpart.PhysActor != null) { - RootPart.PhysActor.PIDHoverActive = false; + if (height != 0f) + { + rootpart.PhysActor.PIDHoverHeight = height; + rootpart.PhysActor.PIDHoverType = hoverType; + rootpart.PhysActor.PIDTau = tau; + rootpart.PhysActor.PIDHoverActive = true; + } + else + { + rootpart.PhysActor.PIDHoverActive = false; + } } } } @@ -1681,6 +2086,8 @@ namespace OpenSim.Region.Framework.Scenes public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); + newPart.SetParent(this); + AddPart(newPart); SetPartAsNonRoot(newPart); @@ -1714,11 +2121,11 @@ namespace OpenSim.Region.Framework.Scenes public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags) { remoteClient.SendObjectPropertiesFamilyData(RootPart, RequestFlags); - - // remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask, - // RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, - // RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, - // RootPart.CreatorID, RootPart.Name, RootPart.Description); + +// remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask, +// RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, +// RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, +// RootPart.CreatorID, RootPart.Name, RootPart.Description); } public void SetPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID) @@ -1738,7 +2145,7 @@ namespace OpenSim.Region.Framework.Scenes // an object has been deleted from a scene before update was processed. // A more fundamental overhaul of the update mechanism is required to eliminate all // the race conditions. - if (IsDeleted) + if (m_isDeleted) return; // Even temporary objects take part in physics (e.g. temp-on-rez bullets) @@ -1771,8 +2178,8 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleFullUpdateToAvatar(ScenePresence presence) { - // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); - +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); + RootPart.AddFullUpdateToAvatar(presence); SceneObjectPart[] parts = m_parts.GetArray(); @@ -1786,7 +2193,7 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleTerseUpdateToAvatar(ScenePresence presence) { - // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); +// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -1798,9 +2205,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForFullUpdate() { - // if (IsAttachment) - // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); - +// if (IsAttachment) +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); + checkAtTargets(); RootPart.ScheduleFullUpdate(); @@ -1818,7 +2225,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForTerseUpdate() { - // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); +// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -1829,12 +2236,12 @@ namespace OpenSim.Region.Framework.Scenes /// Immediately send a full update for this scene object. /// public void SendGroupFullUpdate() - { + { if (IsDeleted) return; - // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); - +// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); + RootPart.SendFullUpdateToAllClients(); SceneObjectPart[] parts = m_parts.GetArray(); @@ -1864,7 +2271,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_scene == null) // Need to check here as it's null during object creation return; - + m_scene.SceneGraph.AddToUpdateList(this); } @@ -1980,9 +2387,9 @@ namespace OpenSim.Region.Framework.Scenes // objectGroup.RootPart.SendScheduledUpdates(); //} - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", - // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", +// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); SceneObjectPart linkPart = objectGroup.m_rootPart; @@ -2022,12 +2429,15 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum += objectGroup.PrimCount; } } + } - linkPart.LinkNum = 2; + linkPart.LinkNum = 2; - linkPart.SetParent(this); - linkPart.CreateSelected = true; + linkPart.SetParent(this); + linkPart.CreateSelected = true; + lock (m_parts.SyncRoot) + { //if (linkPart.PhysActor != null) //{ // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); @@ -2048,12 +2458,12 @@ namespace OpenSim.Region.Framework.Scenes } m_scene.UnlinkSceneObject(objectGroup, true); - objectGroup.IsDeleted = true; + objectGroup.m_isDeleted = true; objectGroup.m_parts.Clear(); - + // Can't do this yet since backup still makes use of the root part without any synchronization - // objectGroup.m_rootPart = null; +// objectGroup.m_rootPart = null; AttachToBackup(); @@ -2111,10 +2521,10 @@ namespace OpenSim.Region.Framework.Scenes /// The object group of the newly delinked prim. public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", - // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); - +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", +// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); + linkPart.ClearUndoState(); Quaternion worldRot = linkPart.GetWorldRotation(); @@ -2185,9 +2595,11 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void DetachFromBackup() { - if (m_isBackedUp && Scene != null) - m_scene.EventManager.OnBackup -= ProcessBackup; + m_scene.SceneGraph.FireDetachFromBackup(this); + if (m_isBackedUp) + m_scene.EventManager.OnBackup -= ProcessBackup; + m_isBackedUp = false; } @@ -2203,7 +2615,8 @@ namespace OpenSim.Region.Framework.Scenes axPos *= parentRot; part.OffsetPosition = axPos; - part.GroupPosition = oldGroupPosition + part.OffsetPosition; + Vector3 newPos = oldGroupPosition + part.OffsetPosition; + part.GroupPosition = newPos; part.OffsetPosition = Vector3.Zero; part.RotationOffset = worldRot; @@ -2214,7 +2627,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = linkNum; - part.OffsetPosition = part.GroupPosition - AbsolutePosition; + part.OffsetPosition = newPos - AbsolutePosition; Quaternion rootRotation = m_rootPart.RotationOffset; @@ -2224,7 +2637,7 @@ namespace OpenSim.Region.Framework.Scenes parentRot = m_rootPart.RotationOffset; oldRot = part.RotationOffset; - Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; + Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; part.RotationOffset = newRot; } @@ -2322,7 +2735,7 @@ namespace OpenSim.Region.Framework.Scenes // but it will result in over-shoot or under-shoot of the target orientation. // For the end user, this means that ctrl+shift+drag can be used for relative, // but not absolute, adjustments of orientation for physical prims. - + if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) { if (m_rootPart.PhysActor != null) @@ -2337,25 +2750,25 @@ namespace OpenSim.Region.Framework.Scenes } else { - // save and update old orientation - Quaternion old = m_rootPart.SpinOldOrientation; - m_rootPart.SpinOldOrientation = newOrientation; - //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); - //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); - - // compute difference between previous old rotation and new incoming rotation - Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; - - float rotationAngle; - Vector3 rotationAxis; - minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); - rotationAxis.Normalize(); - - //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); - Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); - spinforce = (spinforce / 8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor - m_rootPart.PhysActor.AddAngularForce(spinforce, true); - m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + // save and update old orientation + Quaternion old = m_rootPart.SpinOldOrientation; + m_rootPart.SpinOldOrientation = newOrientation; + //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); + //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); + + // compute difference between previous old rotation and new incoming rotation + Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; + + float rotationAngle; + Vector3 rotationAxis; + minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); + rotationAxis.Normalize(); + + //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); + Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); + spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor + m_rootPart.PhysActor.AddAngularForce(spinforce,true); + m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); } } else @@ -2444,15 +2857,14 @@ namespace OpenSim.Region.Framework.Scenes /// Update prim flags for this group. /// /// - /// - /// - /// - /// - public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) + /// + /// + /// + public void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVolumeDetect) { SceneObjectPart selectionPart = GetChildPart(localID); - if (SetTemporary && Scene != null) + if (IsTemporary) { DetachFromBackup(); // Remove from database and parcel prim count @@ -2464,24 +2876,24 @@ namespace OpenSim.Region.Framework.Scenes if (selectionPart != null) { SceneObjectPart[] parts = m_parts.GetArray(); - - if (Scene != null) + for (int i = 0; i < parts.Length; i++) { - for (int i = 0; i < parts.Length; i++) + SceneObjectPart part = parts[i]; + if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || + part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || + part.Scale.Z > m_scene.RegionInfo.PhysPrimMax) { - SceneObjectPart part = parts[i]; - if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || - part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || - part.Scale.Z > m_scene.RegionInfo.PhysPrimMax) - { - UsePhysics = false; // Reset physics - break; - } + UsePhysics = false; // Reset physics + break; } } + RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); for (int i = 0; i < parts.Length; i++) - parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); + { + if (parts[i] != RootPart) + parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + } } } @@ -2494,6 +2906,17 @@ namespace OpenSim.Region.Framework.Scenes } } + + + /// + /// Gets the number of parts + /// + /// + public int GetPartCount() + { + return Parts.Count(); + } + /// /// Update the texture entry for this part /// @@ -2543,150 +2966,202 @@ namespace OpenSim.Region.Framework.Scenes #region Resize /// - /// Resize the entire group of prims. + /// Resize the given part /// /// - public void GroupResize(Vector3 scale) - { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); - - RootPart.StoreUndoState(true); + /// + public void Resize(Vector3 scale, uint localID) + { + if (scale.X > m_scene.m_maxNonphys) + scale.X = m_scene.m_maxNonphys; + if (scale.Y > m_scene.m_maxNonphys) + scale.Y = m_scene.m_maxNonphys; + if (scale.Z > m_scene.m_maxNonphys) + scale.Z = m_scene.m_maxNonphys; + SceneObjectPart part = GetChildPart(localID); + if (part != null) + { + if (part.PhysActor != null) + { + if (part.PhysActor.IsPhysical) + { + if (scale.X > m_scene.m_maxPhys) + scale.X = m_scene.m_maxPhys; + if (scale.Y > m_scene.m_maxPhys) + scale.Y = m_scene.m_maxPhys; + if (scale.Z > m_scene.m_maxPhys) + scale.Z = m_scene.m_maxPhys; + } + part.PhysActor.Size = scale; + m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); + } + part.Resize(scale); - scale.X = Math.Min(scale.X, Scene.m_maxNonphys); - scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); - scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); + HasGroupChanged = true; + part.TriggerScriptChangedEvent(Changed.SCALE); + ScheduleGroupForFullUpdate(); - if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) - { - scale.X = Math.Min(scale.X, Scene.m_maxPhys); - scale.Y = Math.Min(scale.Y, Scene.m_maxPhys); - scale.Z = Math.Min(scale.Z, Scene.m_maxPhys); + //if (part.UUID == m_rootPart.UUID) + //{ + //if (m_rootPart.PhysActor != null) + //{ + //m_rootPart.PhysActor.Size = + //new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z); + //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + //} + //} } + } - float x = (scale.X / RootPart.Scale.X); - float y = (scale.Y / RootPart.Scale.Y); - float z = (scale.Z / RootPart.Scale.Z); - - SceneObjectPart[] parts; - if (x > 1.0f || y > 1.0f || z > 1.0f) + public void GroupResize(Vector3 scale, uint localID) + { + SceneObjectPart part = GetChildPart(localID); + if (part != null) { - parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) + if (scale.X > m_scene.m_maxNonphys) + scale.X = m_scene.m_maxNonphys; + if (scale.Y > m_scene.m_maxNonphys) + scale.Y = m_scene.m_maxNonphys; + if (scale.Z > m_scene.m_maxNonphys) + scale.Z = m_scene.m_maxNonphys; + if (part.PhysActor != null && part.PhysActor.IsPhysical) { - SceneObjectPart obPart = parts[i]; - if (obPart.UUID != m_rootPart.UUID) - { - // obPart.IgnoreUndoUpdate = true; - Vector3 oldSize = new Vector3(obPart.Scale); - - float f = 1.0f; - float a = 1.0f; + if (scale.X > m_scene.m_maxPhys) + scale.X = m_scene.m_maxPhys; + if (scale.Y > m_scene.m_maxPhys) + scale.Y = m_scene.m_maxPhys; + if (scale.Z > m_scene.m_maxPhys) + scale.Z = m_scene.m_maxPhys; + } + float x = (scale.X / part.Scale.X); + float y = (scale.Y / part.Scale.Y); + float z = (scale.Z / part.Scale.Z); - if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) + SceneObjectPart[] parts; + if (x > 1.0f || y > 1.0f || z > 1.0f) + { + parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + if (obPart.UUID != m_rootPart.UUID) { - if (oldSize.X * x > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - - if (oldSize.Y * y > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } + obPart.IgnoreUndoUpdate = true; + Vector3 oldSize = new Vector3(obPart.Scale); - if (oldSize.Z * z > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } - } - else - { - if (oldSize.X * x > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } + float f = 1.0f; + float a = 1.0f; - if (oldSize.Y * y > m_scene.m_maxNonphys) + if (part.PhysActor != null && part.PhysActor.IsPhysical) { - f = m_scene.m_maxNonphys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; + if (oldSize.X*x > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Y*y > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Z*z > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } } - - if (oldSize.Z * z > m_scene.m_maxNonphys) + else { - f = m_scene.m_maxNonphys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; + if (oldSize.X*x > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Y*y > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + if (oldSize.Z*z > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } } + obPart.IgnoreUndoUpdate = false; } - - // obPart.IgnoreUndoUpdate = false; } } - } - Vector3 prevScale = RootPart.Scale; - prevScale.X *= x; - prevScale.Y *= y; - prevScale.Z *= z; + Vector3 prevScale = part.Scale; + prevScale.X *= x; + prevScale.Y *= y; + prevScale.Z *= z;; - // RootPart.IgnoreUndoUpdate = true; - RootPart.Resize(prevScale); - // RootPart.IgnoreUndoUpdate = false; - - parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart obPart = parts[i]; + part.IgnoreUndoUpdate = false; + part.StoreUndoState(UndoType.STATE_GROUP_SCALE); + part.IgnoreUndoUpdate = true; + part.Resize(prevScale); + part.IgnoreUndoUpdate = false; - if (obPart.UUID != m_rootPart.UUID) + parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) { + SceneObjectPart obPart = parts[i]; obPart.IgnoreUndoUpdate = true; - - Vector3 currentpos = new Vector3(obPart.OffsetPosition); - currentpos.X *= x; - currentpos.Y *= y; - currentpos.Z *= z; - - Vector3 newSize = new Vector3(obPart.Scale); - newSize.X *= x; - newSize.Y *= y; - newSize.Z *= z; - - obPart.Resize(newSize); - obPart.UpdateOffSet(currentpos); - + if (obPart.UUID != m_rootPart.UUID) + { + if (obPart.UUID != m_rootPart.UUID) + { + obPart.IgnoreUndoUpdate = false; + obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); + obPart.IgnoreUndoUpdate = true; + + Vector3 currentpos = new Vector3(obPart.OffsetPosition); + currentpos.X *= x; + currentpos.Y *= y; + currentpos.Z *= z; + Vector3 newSize = new Vector3(obPart.Scale); + newSize.X *= x; + newSize.Y *= y; + newSize.Z *= z; + obPart.Resize(newSize); + obPart.UpdateOffSet(currentpos); + } + obPart.IgnoreUndoUpdate = false; + } obPart.IgnoreUndoUpdate = false; } - // obPart.IgnoreUndoUpdate = false; - // obPart.StoreUndoState(); - } + if (part.PhysActor != null) + { + part.PhysActor.Size = prevScale; + m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); + } - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); + part.IgnoreUndoUpdate = false; + HasGroupChanged = true; + m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); + ScheduleGroupForTerseUpdate(); + } } #endregion @@ -2699,18 +3174,11 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupPosition(Vector3 pos) { - // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); - - RootPart.StoreUndoState(true); - - // SceneObjectPart[] parts = m_parts.GetArray(); - // for (int i = 0; i < parts.Length; i++) - // parts[i].StoreUndoState(); - if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { if (IsAttachment) { + m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); m_rootPart.AttachedPos = pos; } if (RootPart.GetStatusSandbox()) @@ -2742,18 +3210,12 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetChildPart(localID); - // SceneObjectPart[] parts = m_parts.GetArray(); - // for (int i = 0; i < parts.Length; i++) - // parts[i].StoreUndoState(); + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); if (part != null) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); - - part.StoreUndoState(false); - part.IgnoreUndoUpdate = true; - if (part.UUID == m_rootPart.UUID) { UpdateRootPosition(pos); @@ -2764,22 +3226,18 @@ namespace OpenSim.Region.Framework.Scenes } HasGroupChanged = true; - part.IgnoreUndoUpdate = false; } } /// - /// Update just the root prim position in a linkset + /// /// /// - public void UpdateRootPosition(Vector3 pos) + private void UpdateRootPosition(Vector3 pos) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); - - // SceneObjectPart[] parts = m_parts.GetArray(); - // for (int i = 0; i < parts.Length; i++) - // parts[i].StoreUndoState(); + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); Vector3 oldPos = @@ -2792,7 +3250,7 @@ namespace OpenSim.Region.Framework.Scenes axDiff *= Quaternion.Inverse(partRotation); diff = axDiff; - SceneObjectPart[] parts = m_parts.GetArray(); + parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart obPart = parts[i]; @@ -2800,10 +3258,27 @@ namespace OpenSim.Region.Framework.Scenes obPart.OffsetPosition = obPart.OffsetPosition + diff; } - AbsolutePosition = newPos; + //We have to set undoing here because otherwise an undo state will be saved + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + AbsolutePosition = newPos; + m_rootPart.Undoing = false; + } + else + { + AbsolutePosition = newPos; + } HasGroupChanged = true; - ScheduleGroupForTerseUpdate(); + if (m_rootPart.Undoing) + { + ScheduleGroupForFullUpdate(); + } + else + { + ScheduleGroupForTerseUpdate(); + } } public void OffsetForNewRegion(Vector3 offset) @@ -2821,14 +3296,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationR(Quaternion rot) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); - - // SceneObjectPart[] parts = m_parts.GetArray(); - // for (int i = 0; i < parts.Length; i++) - // parts[i].StoreUndoState(); - - m_rootPart.StoreUndoState(true); + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); m_rootPart.UpdateRotation(rot); @@ -2850,15 +3320,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); - - // SceneObjectPart[] parts = m_parts.GetArray(); - // for (int i = 0; i < parts.Length; i++) - // parts[i].StoreUndoState(); - - RootPart.StoreUndoState(true); - RootPart.IgnoreUndoUpdate = true; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); m_rootPart.UpdateRotation(rot); @@ -2873,8 +3337,6 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; ScheduleGroupForTerseUpdate(); - - RootPart.IgnoreUndoUpdate = false; } /// @@ -2885,16 +3347,12 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateSingleRotation(Quaternion rot, uint localID) { SceneObjectPart part = GetChildPart(localID); - SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(); + parts[i].StoreUndoState(UndoType.STATE_PRIM_ROTATION); if (part != null) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); - if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); @@ -2916,25 +3374,28 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", - // part.Name, part.LocalId, rot); - - part.StoreUndoState(); - part.IgnoreUndoUpdate = true; - if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); - AbsolutePosition = pos; + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + AbsolutePosition = pos; + m_rootPart.Undoing = false; + } + else + { + AbsolutePosition = pos; + } } else { + part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); + part.IgnoreUndoUpdate = true; part.UpdateRotation(rot); part.OffsetPosition = pos; + part.IgnoreUndoUpdate = false; } - - part.IgnoreUndoUpdate = false; } } @@ -2942,17 +3403,21 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void UpdateRootRotation(Quaternion rot) + private void UpdateRootRotation(Quaternion rot) { - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", - // Name, LocalId, rot); - Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; - m_rootPart.StoreUndoState(); - m_rootPart.UpdateRotation(rot); + m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); + bool cancelUndo = false; + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + cancelUndo = true; + } + + //Don't use UpdateRotation because it schedules an update prematurely + m_rootPart.RotationOffset = rot; if (m_rootPart.PhysActor != null) { m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; @@ -2967,33 +3432,22 @@ namespace OpenSim.Region.Framework.Scenes { prim.IgnoreUndoUpdate = true; Vector3 axPos = prim.OffsetPosition; + axPos *= oldParentRot; axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; - Quaternion primsRot = prim.RotationOffset; - Quaternion newRot = primsRot * oldParentRot; - newRot *= Quaternion.Inverse(axRot); - prim.RotationOffset = newRot; - prim.ScheduleTerseUpdate(); + + prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); + prim.IgnoreUndoUpdate = false; } } - - // for (int i = 0; i < parts.Length; i++) - // { - // SceneObjectPart childpart = parts[i]; - // if (childpart != m_rootPart) - // { - //// childpart.IgnoreUndoUpdate = false; - //// childpart.StoreUndoState(); - // } - // } - - m_rootPart.ScheduleTerseUpdate(); - - // m_log.DebugFormat( - // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", - // Name, LocalId, rot); + if (cancelUndo == true) + { + m_rootPart.Undoing = false; + } + HasGroupChanged = true; + ScheduleGroupForFullUpdate(); } #endregion @@ -3008,23 +3462,28 @@ namespace OpenSim.Region.Framework.Scenes int yaxis = 4; int zaxis = 8; - setX = ((axis & xaxis) != 0) ? true : false; - setY = ((axis & yaxis) != 0) ? true : false; - setZ = ((axis & zaxis) != 0) ? true : false; + if (m_rootPart != null) + { + setX = ((axis & xaxis) != 0) ? true : false; + setY = ((axis & yaxis) != 0) ? true : false; + setZ = ((axis & zaxis) != 0) ? true : false; - float setval = (rotate10 > 0) ? 1f : 0f; + float setval = (rotate10 > 0) ? 1f : 0f; - if (setX) - RootPart.RotationAxis.X = setval; - if (setY) - RootPart.RotationAxis.Y = setval; - if (setZ) - RootPart.RotationAxis.Z = setval; + if (setX) + m_rootPart.RotationAxis.X = setval; + if (setY) + m_rootPart.RotationAxis.Y = setval; + if (setZ) + m_rootPart.RotationAxis.Z = setval; - if (setX || setY || setZ) - RootPart.SetPhysicsAxisRotation(); - } + if (setX || setY || setZ) + { + m_rootPart.SetPhysicsAxisRotation(); + } + } + } public int registerRotTargetWaypoint(Quaternion target, float tolerance) { scriptRotTarget waypoint = new scriptRotTarget(); @@ -3064,7 +3523,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.AddGroupTarget(this); return (int)handle; } - + public void unregisterTargetWaypoint(int handle) { lock (m_targets) @@ -3105,14 +3564,14 @@ namespace OpenSim.Region.Framework.Scenes } } } - + if (atTargets.Count > 0) { SceneObjectPart[] parts = m_parts.GetArray(); uint[] localids = new uint[parts.Length]; for (int i = 0; i < parts.Length; i++) localids[i] = parts[i].LocalId; - + for (int ctr = 0; ctr < localids.Length; ctr++) { foreach (uint target in atTargets.Keys) @@ -3122,10 +3581,10 @@ namespace OpenSim.Region.Framework.Scenes localids[ctr], att.handle, att.targetPos, m_rootPart.GroupPosition); } } - + return; } - + if (m_scriptListens_notAtTarget && !at_target) { //trigger not_at_target @@ -3133,7 +3592,7 @@ namespace OpenSim.Region.Framework.Scenes uint[] localids = new uint[parts.Length]; for (int i = 0; i < parts.Length; i++) localids[i] = parts[i].LocalId; - + for (int ctr = 0; ctr < localids.Length; ctr++) { m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); @@ -3152,13 +3611,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint idx in m_rotTargets.Keys) { scriptRotTarget target = m_rotTargets[idx]; - double angle - = Math.Acos( - target.targetRot.X * m_rootPart.RotationOffset.X - + target.targetRot.Y * m_rootPart.RotationOffset.Y - + target.targetRot.Z * m_rootPart.RotationOffset.Z - + target.targetRot.W * m_rootPart.RotationOffset.W) - * 2; + double angle = Math.Acos(target.targetRot.X * m_rootPart.RotationOffset.X + target.targetRot.Y * m_rootPart.RotationOffset.Y + target.targetRot.Z * m_rootPart.RotationOffset.Z + target.targetRot.W * m_rootPart.RotationOffset.W) * 2; if (angle < 0) angle = -angle; if (angle > Math.PI) angle = (Math.PI * 2 - angle); if (angle <= target.tolerance) @@ -3213,39 +3666,53 @@ namespace OpenSim.Region.Framework.Scenes } } } - + public float GetMass() { float retmass = 0f; - SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) retmass += parts[i].GetMass(); return retmass; } - - /// - /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that - /// the physics engine can use it. - /// - /// - /// When the physics engine has finished with it, the sculpt data is discarded to save memory. - /// + public void CheckSculptAndLoad() { if (IsDeleted) return; - if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) return; - // m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].CheckSculptAndLoad(); + { + SceneObjectPart part = parts[i]; + if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero) + { + // check if a previously decoded sculpt map has been cached + if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + part.Shape.SculptTexture.ToString()))) + { + part.SculptTextureCallback(part.Shape.SculptTexture, null); + } + else + { + m_scene.AssetService.Get( + part.Shape.SculptTexture.ToString(), part, AssetReceived); + } + } + } + } + + protected void AssetReceived(string id, Object sender, AssetBase asset) + { + SceneObjectPart sop = (SceneObjectPart)sender; + + if (sop != null) + { + if (asset != null) + sop.SculptTextureCallback(asset.FullID, asset); + } } /// @@ -3274,18 +3741,25 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) parts[i].TriggerScriptChangedEvent(val); } - + public override string ToString() { return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); } - #region ISceneObject + public void SetAttachmentPoint(byte point) + { + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].SetAttachmentPoint(point); + } + #region ISceneObject + public virtual ISceneObject CloneForNewScene() { SceneObjectGroup sog = Copy(false); - sog.IsDeleted = false; + sog.m_isDeleted = false; return sog; } @@ -3311,6 +3785,14 @@ namespace OpenSim.Region.Framework.Scenes SetFromItemID(uuid); } + public void ResetOwnerChangeFlag() + { + ForEachPart(delegate(SceneObjectPart part) + { + part.ResetOwnerChangeFlag(); + }); + } + #endregion } -} \ No newline at end of file +} -- cgit v1.1 From 9cc2d0b60ae3398cf0a2f2ea144c331fa73d3e76 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 4 Sep 2011 08:30:23 -0700 Subject: Now merging the core changes. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 865 +++++++++++---------- 1 file changed, 444 insertions(+), 421 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6c47645..88a6232 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -209,27 +209,89 @@ namespace OpenSim.Region.Framework.Scenes return true; return false; } - - /// + + /// /// Is this scene object acting as an attachment? - /// - /// We return false if the group has already been deleted. - /// - /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I - /// presume either all or no parts in a linkset can be part of an attachment (in which - /// case the value would get proprogated down into all the descendent parts). - /// - public bool IsAttachment + /// + public bool IsAttachment { get; set; } + + /// + /// The avatar to which this scene object is attached. + /// + /// + /// If we're not attached to an avatar then this is UUID.Zero + /// + public UUID AttachedAvatar { get; set; } + + /// + /// Attachment point of this scene object to an avatar. + /// + /// + /// 0 if we're not attached to anything + /// + public uint AttachmentPoint { get { - if (!IsDeleted) - return m_rootPart.IsAttachment; - - return false; + return m_rootPart.Shape.State; + } + + set + { + IsAttachment = value != 0; + m_rootPart.Shape.State = (byte)value; } } + public void ClearPartAttachmentData() + { + AttachmentPoint = 0; + + // Even though we don't use child part state parameters for attachments any more, we still need to set + // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if + // we store them correctly, scene objects that we receive from elsewhere might not. + foreach (SceneObjectPart part in Parts) + part.Shape.State = 0; + } + + /// + /// Is this scene object phantom? + /// + /// + /// Updating must currently take place through UpdatePrimFlags() + /// + public bool IsPhantom + { + get { return (RootPart.Flags & PrimFlags.Phantom) != 0; } + } + + /// + /// Does this scene object use physics? + /// + /// + /// Updating must currently take place through UpdatePrimFlags() + /// + public bool UsesPhysics + { + get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; } + } + + /// + /// Is this scene object temporary? + /// + /// + /// Updating must currently take place through UpdatePrimFlags() + /// + public bool IsTemporary + { + get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; } + } + + public bool IsVolumeDetect + { + get { return RootPart.VolumeDetectActive; } + } + public float scriptScore; private Vector3 lastPhysGroupPos; @@ -261,11 +323,7 @@ namespace OpenSim.Region.Framework.Scenes /// public override string Name { - get { - if (RootPart == null) - return String.Empty; - return RootPart.Name; - } + get { return RootPart.Name; } set { RootPart.Name = value; } } @@ -305,6 +363,38 @@ namespace OpenSim.Region.Framework.Scenes get { return m_rootPart.RotationOffset; } } + public Vector3 GroupScale + { + get + { + Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); + Vector3 maxScale = Vector3.Zero; + Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + Vector3 partscale = part.Scale; + Vector3 partoffset = part.OffsetPosition; + + minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; + minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; + minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; + + maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; + maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; + maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; + } + + finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; + finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; + finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; + + return finalScale; + } + } + public UUID GroupID { get { return m_rootPart.GroupID; } @@ -344,11 +434,13 @@ namespace OpenSim.Region.Framework.Scenes /// /// Check both the attachment property and the relevant properties of the underlying root part. /// + /// /// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't /// have the IsAttachment property yet checked. /// /// FIXME: However, this should be fixed so that this property /// propertly reflects the underlying status. + /// /// public bool IsAttachmentCheckFull() { @@ -682,7 +774,7 @@ namespace OpenSim.Region.Framework.Scenes part.ParentID = m_rootPart.LocalId; //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID); } - + ApplyPhysics(m_scene.m_physicalPrim); if (RootPart.PhysActor != null) @@ -693,34 +785,6 @@ namespace OpenSim.Region.Framework.Scenes //ScheduleGroupForFullUpdate(); } - public Vector3 GroupScale() - { - Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); - Vector3 maxScale = Vector3.Zero; - Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - Vector3 partscale = part.Scale; - Vector3 partoffset = part.OffsetPosition; - - minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; - minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; - minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; - - maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; - maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; - maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; - } - - finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; - finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; - finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; - return finalScale; - - } public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) { // We got a request from the inner_scene to raytrace along the Ray hRay @@ -1324,7 +1388,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = m_parts.Count; - if (part.LinkNum == 2 && RootPart != null) + if (part.LinkNum == 2) RootPart.LinkNum = 1; } @@ -1407,7 +1471,11 @@ namespace OpenSim.Region.Framework.Scenes public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) { - part.StoreUndoState(UndoType.STATE_PRIM_ALL); +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", +// remoteClient.Name, part.Name, part.LocalId, offsetPos); + + part.StoreUndoState(); part.OnGrab(offsetPos, remoteClient); } @@ -1720,12 +1788,19 @@ namespace OpenSim.Region.Framework.Scenes // This is only necessary when userExposed is false! - bool previousAttachmentStatus = dupe.RootPart.IsAttachment; + bool previousAttachmentStatus = dupe.IsAttachment; + + if (!userExposed) + dupe.IsAttachment = true; if (!userExposed) dupe.RootPart.IsAttachment = true; dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + if (!userExposed) + { + dupe.IsAttachment = previousAttachmentStatus; + } if (!userExposed) { @@ -1782,6 +1857,22 @@ namespace OpenSim.Region.Framework.Scenes dupe.AttachToBackup(); ScheduleGroupForFullUpdate(); + // Need to duplicate the physics actor as well + if (part.PhysActor != null && userExposed) + { + PrimitiveBaseShape pbs = newPart.Shape; + + newPart.PhysActor + = m_scene.PhysicsScene.AddPrimShape( + string.Format("{0}/{1}", newPart.Name, newPart.UUID), + pbs, + newPart.AbsolutePosition, + newPart.Scale, + newPart.RotationOffset, + part.PhysActor.IsPhysical, + newPart.LocalId); + + newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); } } finally @@ -1802,36 +1893,24 @@ namespace OpenSim.Region.Framework.Scenes SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); } - public void ScriptSetPhysicsStatus(bool UsePhysics) + public void ScriptSetPhysicsStatus(bool usePhysics) { - bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); - bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); - bool IsVolumeDetect = RootPart.VolumeDetectActive; - UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } - public void ScriptSetTemporaryStatus(bool TemporaryStatus) + public void ScriptSetTemporaryStatus(bool makeTemporary) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); - bool IsVolumeDetect = RootPart.VolumeDetectActive; - UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect); + UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect); } - public void ScriptSetPhantomStatus(bool PhantomStatus) + public void ScriptSetPhantomStatus(bool makePhantom) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); - bool IsVolumeDetect = RootPart.VolumeDetectActive; - UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect); + UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect); } - public void ScriptSetVolumeDetect(bool VDStatus) + public void ScriptSetVolumeDetect(bool makeVolumeDetect) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); - bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); - UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus); + UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect); /* ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore @@ -1849,120 +1928,80 @@ namespace OpenSim.Region.Framework.Scenes public void applyImpulse(Vector3 impulse) { - // We check if rootpart is null here because scripts don't delete if you delete the host. - // This means that unfortunately, we can pass a null physics actor to Simulate! - // Make sure we don't do that! - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) + if (IsAttachment) { - if (IsAttachment) + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); + if (avatar != null) { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) - { - avatar.PushForce(impulse); - } + avatar.PushForce(impulse); } - else + } + else + { + if (RootPart.PhysActor != null) { - if (rootpart.PhysActor != null) - { - rootpart.PhysActor.AddForce(impulse, true); - m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); - } + RootPart.PhysActor.AddForce(impulse, true); + m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); } } } public void applyAngularImpulse(Vector3 impulse) { - // We check if rootpart is null here because scripts don't delete if you delete the host. - // This means that unfortunately, we can pass a null physics actor to Simulate! - // Make sure we don't do that! - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) + if (RootPart.PhysActor != null) { - if (rootpart.PhysActor != null) + if (!IsAttachment) { - if (!IsAttachment) - { - rootpart.PhysActor.AddAngularForce(impulse, true); - m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); - } + RootPart.PhysActor.AddAngularForce(impulse, true); + m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); } } } public void setAngularImpulse(Vector3 impulse) { - // We check if rootpart is null here because scripts don't delete if you delete the host. - // This means that unfortunately, we can pass a null physics actor to Simulate! - // Make sure we don't do that! - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) + if (RootPart.PhysActor != null) { - if (rootpart.PhysActor != null) + if (!IsAttachment) { - if (!IsAttachment) - { - rootpart.PhysActor.Torque = impulse; - m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); - } + RootPart.PhysActor.Torque = impulse; + m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); } } } public Vector3 GetTorque() { - // We check if rootpart is null here because scripts don't delete if you delete the host. - // This means that unfortunately, we can pass a null physics actor to Simulate! - // Make sure we don't do that! - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) + if (RootPart.PhysActor != null) { - if (rootpart.PhysActor != null) + if (!IsAttachment) { - if (!IsAttachment) - { - Vector3 torque = rootpart.PhysActor.Torque; - return torque; - } + Vector3 torque = RootPart.PhysActor.Torque; + return torque; } } + return Vector3.Zero; } // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object public void moveToTarget(Vector3 target, float tau) { - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) + if (IsAttachment) { - if (IsAttachment) + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); + if (avatar != null) { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) - { - List coords = new List(); - uint regionX = 0; - uint regionY = 0; - Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); - target.X += regionX; - target.Y += regionY; - coords.Add(target.X.ToString()); - coords.Add(target.Y.ToString()); - coords.Add(target.Z.ToString()); - avatar.DoMoveToPosition(avatar, "", coords); - } + avatar.MoveToTarget(target, false); } - else + } + else + { + if (RootPart.PhysActor != null) { - if (rootpart.PhysActor != null) - { - rootpart.PhysActor.PIDTarget = target; - rootpart.PhysActor.PIDTau = tau; - rootpart.PhysActor.PIDActive = true; - } + RootPart.PhysActor.PIDTarget = target; + RootPart.PhysActor.PIDTau = tau; + RootPart.PhysActor.PIDActive = true; } } } @@ -2035,22 +2074,18 @@ namespace OpenSim.Region.Framework.Scenes /// Number of seconds over which to reach target public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) { - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) + if (RootPart.PhysActor != null) { - if (rootpart.PhysActor != null) + if (height != 0f) { - if (height != 0f) - { - rootpart.PhysActor.PIDHoverHeight = height; - rootpart.PhysActor.PIDHoverType = hoverType; - rootpart.PhysActor.PIDTau = tau; - rootpart.PhysActor.PIDHoverActive = true; - } - else - { - rootpart.PhysActor.PIDHoverActive = false; - } + RootPart.PhysActor.PIDHoverHeight = height; + RootPart.PhysActor.PIDHoverType = hoverType; + RootPart.PhysActor.PIDTau = tau; + RootPart.PhysActor.PIDHoverActive = true; + } + else + { + RootPart.PhysActor.PIDHoverActive = false; } } } @@ -2145,7 +2180,7 @@ namespace OpenSim.Region.Framework.Scenes // an object has been deleted from a scene before update was processed. // A more fundamental overhaul of the update mechanism is required to eliminate all // the race conditions. - if (m_isDeleted) + if (IsDeleted) return; // Even temporary objects take part in physics (e.g. temp-on-rez bullets) @@ -2458,7 +2493,7 @@ namespace OpenSim.Region.Framework.Scenes } m_scene.UnlinkSceneObject(objectGroup, true); - objectGroup.m_isDeleted = true; + objectGroup.IsDeleted = true; objectGroup.m_parts.Clear(); @@ -2596,8 +2631,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void DetachFromBackup() { m_scene.SceneGraph.FireDetachFromBackup(this); - - if (m_isBackedUp) + if (m_isBackedUp && Scene != null) m_scene.EventManager.OnBackup -= ProcessBackup; m_isBackedUp = false; @@ -2857,14 +2891,15 @@ namespace OpenSim.Region.Framework.Scenes /// Update prim flags for this group. /// /// - /// - /// - /// - public void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVolumeDetect) + /// + /// + /// + /// + public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) { SceneObjectPart selectionPart = GetChildPart(localID); - if (IsTemporary) + if (SetTemporary && Scene != null) { DetachFromBackup(); // Remove from database and parcel prim count @@ -2876,23 +2911,27 @@ namespace OpenSim.Region.Framework.Scenes if (selectionPart != null) { SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) + + if (Scene != null) { - SceneObjectPart part = parts[i]; - if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || - part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || - part.Scale.Z > m_scene.RegionInfo.PhysPrimMax) + for (int i = 0; i < parts.Length; i++) { - UsePhysics = false; // Reset physics - break; + SceneObjectPart part = parts[i]; + if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || + part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || + part.Scale.Z > m_scene.RegionInfo.PhysPrimMax) + { + UsePhysics = false; // Reset physics + break; + } } } - RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, SetVolumeDetect); for (int i = 0; i < parts.Length; i++) { if (parts[i] != RootPart) - parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, SetVolumeDetect); } } } @@ -2966,202 +3005,152 @@ namespace OpenSim.Region.Framework.Scenes #region Resize /// - /// Resize the given part + /// Resize the entire group of prims. /// /// - /// - public void Resize(Vector3 scale, uint localID) - { - if (scale.X > m_scene.m_maxNonphys) - scale.X = m_scene.m_maxNonphys; - if (scale.Y > m_scene.m_maxNonphys) - scale.Y = m_scene.m_maxNonphys; - if (scale.Z > m_scene.m_maxNonphys) - scale.Z = m_scene.m_maxNonphys; - SceneObjectPart part = GetChildPart(localID); - if (part != null) - { - if (part.PhysActor != null) - { - if (part.PhysActor.IsPhysical) - { - if (scale.X > m_scene.m_maxPhys) - scale.X = m_scene.m_maxPhys; - if (scale.Y > m_scene.m_maxPhys) - scale.Y = m_scene.m_maxPhys; - if (scale.Z > m_scene.m_maxPhys) - scale.Z = m_scene.m_maxPhys; - } - part.PhysActor.Size = scale; - m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); - } - part.Resize(scale); + public void GroupResize(Vector3 scale) + { +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); + RootPart.StoreUndoState(true); - HasGroupChanged = true; - part.TriggerScriptChangedEvent(Changed.SCALE); - ScheduleGroupForFullUpdate(); + scale.X = Math.Min(scale.X, Scene.m_maxNonphys); + scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); + scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); - //if (part.UUID == m_rootPart.UUID) - //{ - //if (m_rootPart.PhysActor != null) - //{ - //m_rootPart.PhysActor.Size = - //new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z); - //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); - //} - //} + if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) + { + scale.X = Math.Min(scale.X, Scene.m_maxPhys); + scale.Y = Math.Min(scale.Y, Scene.m_maxPhys); + scale.Z = Math.Min(scale.Z, Scene.m_maxPhys); } - } - public void GroupResize(Vector3 scale, uint localID) - { - SceneObjectPart part = GetChildPart(localID); - if (part != null) + float x = (scale.X / RootPart.Scale.X); + float y = (scale.Y / RootPart.Scale.Y); + float z = (scale.Z / RootPart.Scale.Z); + + SceneObjectPart[] parts; + if (x > 1.0f || y > 1.0f || z > 1.0f) { - if (scale.X > m_scene.m_maxNonphys) - scale.X = m_scene.m_maxNonphys; - if (scale.Y > m_scene.m_maxNonphys) - scale.Y = m_scene.m_maxNonphys; - if (scale.Z > m_scene.m_maxNonphys) - scale.Z = m_scene.m_maxNonphys; - if (part.PhysActor != null && part.PhysActor.IsPhysical) - { - if (scale.X > m_scene.m_maxPhys) - scale.X = m_scene.m_maxPhys; - if (scale.Y > m_scene.m_maxPhys) - scale.Y = m_scene.m_maxPhys; - if (scale.Z > m_scene.m_maxPhys) - scale.Z = m_scene.m_maxPhys; - } - float x = (scale.X / part.Scale.X); - float y = (scale.Y / part.Scale.Y); - float z = (scale.Z / part.Scale.Z); - - SceneObjectPart[] parts; - if (x > 1.0f || y > 1.0f || z > 1.0f) - { - parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) + parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + if (obPart.UUID != m_rootPart.UUID) { - SceneObjectPart obPart = parts[i]; - if (obPart.UUID != m_rootPart.UUID) +// obPart.IgnoreUndoUpdate = true; + Vector3 oldSize = new Vector3(obPart.Scale); + + float f = 1.0f; + float a = 1.0f; + + if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) { - obPart.IgnoreUndoUpdate = true; - Vector3 oldSize = new Vector3(obPart.Scale); + if (oldSize.X * x > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } - float f = 1.0f; - float a = 1.0f; + if (oldSize.Y * y > m_scene.m_maxPhys) + { + f = m_scene.m_maxPhys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } - if (part.PhysActor != null && part.PhysActor.IsPhysical) + if (oldSize.Z * z > m_scene.m_maxPhys) { - if (oldSize.X*x > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Y*y > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Z*z > m_scene.m_maxPhys) - { - f = m_scene.m_maxPhys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } + f = m_scene.m_maxPhys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; } - else + } + else + { + if (oldSize.X * x > m_scene.m_maxNonphys) { - if (oldSize.X*x > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.X; - a = f / x; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Y*y > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.Y; - a = f / y; - x *= a; - y *= a; - z *= a; - } - if (oldSize.Z*z > m_scene.m_maxNonphys) - { - f = m_scene.m_maxNonphys / oldSize.Z; - a = f / z; - x *= a; - y *= a; - z *= a; - } + f = m_scene.m_maxNonphys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } + + if (oldSize.Y * y > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + + if (oldSize.Z * z > m_scene.m_maxNonphys) + { + f = m_scene.m_maxNonphys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; } - obPart.IgnoreUndoUpdate = false; } + +// obPart.IgnoreUndoUpdate = false; } } + } - Vector3 prevScale = part.Scale; - prevScale.X *= x; - prevScale.Y *= y; - prevScale.Z *= z;; - - part.IgnoreUndoUpdate = false; - part.StoreUndoState(UndoType.STATE_GROUP_SCALE); - part.IgnoreUndoUpdate = true; - part.Resize(prevScale); + Vector3 prevScale = RootPart.Scale; + prevScale.X *= x; + prevScale.Y *= y; + prevScale.Z *= z; part.IgnoreUndoUpdate = false; - parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) +// RootPart.IgnoreUndoUpdate = true; + RootPart.Resize(prevScale); +// RootPart.IgnoreUndoUpdate = false; + + parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + + if (obPart.UUID != m_rootPart.UUID) { - SceneObjectPart obPart = parts[i]; obPart.IgnoreUndoUpdate = true; - if (obPart.UUID != m_rootPart.UUID) - { - if (obPart.UUID != m_rootPart.UUID) - { - obPart.IgnoreUndoUpdate = false; - obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); - obPart.IgnoreUndoUpdate = true; - - Vector3 currentpos = new Vector3(obPart.OffsetPosition); - currentpos.X *= x; - currentpos.Y *= y; - currentpos.Z *= z; - Vector3 newSize = new Vector3(obPart.Scale); - newSize.X *= x; - newSize.Y *= y; - newSize.Z *= z; - obPart.Resize(newSize); - obPart.UpdateOffSet(currentpos); - } - obPart.IgnoreUndoUpdate = false; - } - obPart.IgnoreUndoUpdate = false; - } - if (part.PhysActor != null) - { - part.PhysActor.Size = prevScale; - m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); + Vector3 currentpos = new Vector3(obPart.OffsetPosition); + currentpos.X *= x; + currentpos.Y *= y; + currentpos.Z *= z; + + Vector3 newSize = new Vector3(obPart.Scale); + newSize.X *= x; + newSize.Y *= y; + newSize.Z *= z; + + obPart.Resize(newSize); + obPart.UpdateOffSet(currentpos); + + obPart.IgnoreUndoUpdate = false; } - part.IgnoreUndoUpdate = false; +// obPart.IgnoreUndoUpdate = false; HasGroupChanged = true; m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); ScheduleGroupForTerseUpdate(); } + +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); } #endregion @@ -3174,6 +3163,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupPosition(Vector3 pos) { +// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); + + RootPart.StoreUndoState(true); + +// SceneObjectPart[] parts = m_parts.GetArray(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].StoreUndoState(); + if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { if (IsAttachment) @@ -3210,12 +3207,18 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetChildPart(localID); - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); +// SceneObjectPart[] parts = m_parts.GetArray(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].StoreUndoState(); if (part != null) { +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); + + part.StoreUndoState(false); + part.IgnoreUndoUpdate = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootPosition(pos); @@ -3226,18 +3229,22 @@ namespace OpenSim.Region.Framework.Scenes } HasGroupChanged = true; + part.IgnoreUndoUpdate = false; } } /// - /// + /// Update just the root prim position in a linkset /// /// - private void UpdateRootPosition(Vector3 pos) + public void UpdateRootPosition(Vector3 pos) { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); + +// SceneObjectPart[] parts = m_parts.GetArray(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].StoreUndoState(); Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); Vector3 oldPos = @@ -3250,7 +3257,7 @@ namespace OpenSim.Region.Framework.Scenes axDiff *= Quaternion.Inverse(partRotation); diff = axDiff; - parts = m_parts.GetArray(); + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart obPart = parts[i]; @@ -3296,9 +3303,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationR(Quaternion rot) { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); + +// SceneObjectPart[] parts = m_parts.GetArray(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].StoreUndoState(); + + m_rootPart.StoreUndoState(true); m_rootPart.UpdateRotation(rot); @@ -3320,9 +3332,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); + +// SceneObjectPart[] parts = m_parts.GetArray(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].StoreUndoState(); + + RootPart.StoreUndoState(true); + RootPart.IgnoreUndoUpdate = true; m_rootPart.UpdateRotation(rot); @@ -3337,6 +3355,8 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; ScheduleGroupForTerseUpdate(); + + RootPart.IgnoreUndoUpdate = false; } /// @@ -3353,6 +3373,9 @@ namespace OpenSim.Region.Framework.Scenes if (part != null) { +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); + if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); @@ -3374,6 +3397,13 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", +// part.Name, part.LocalId, rot); + + part.StoreUndoState(); + part.IgnoreUndoUpdate = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); @@ -3390,12 +3420,11 @@ namespace OpenSim.Region.Framework.Scenes } else { - part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); - part.IgnoreUndoUpdate = true; part.UpdateRotation(rot); part.OffsetPosition = pos; - part.IgnoreUndoUpdate = false; } + + part.IgnoreUndoUpdate = false; } } @@ -3403,8 +3432,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - private void UpdateRootRotation(Quaternion rot) + public void UpdateRootRotation(Quaternion rot) { +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", +// Name, LocalId, rot); + Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; @@ -3440,14 +3473,25 @@ namespace OpenSim.Region.Framework.Scenes prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); prim.IgnoreUndoUpdate = false; + prim.IgnoreUndoUpdate = false; } } - if (cancelUndo == true) - { - m_rootPart.Undoing = false; - } + +// for (int i = 0; i < parts.Length; i++) +// { +// SceneObjectPart childpart = parts[i]; +// if (childpart != m_rootPart) +// { +//// childpart.IgnoreUndoUpdate = false; +//// childpart.StoreUndoState(); +// } +// } HasGroupChanged = true; ScheduleGroupForFullUpdate(); + +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", +// Name, LocalId, rot); } #endregion @@ -3462,28 +3506,23 @@ namespace OpenSim.Region.Framework.Scenes int yaxis = 4; int zaxis = 8; - if (m_rootPart != null) - { - setX = ((axis & xaxis) != 0) ? true : false; - setY = ((axis & yaxis) != 0) ? true : false; - setZ = ((axis & zaxis) != 0) ? true : false; + setX = ((axis & xaxis) != 0) ? true : false; + setY = ((axis & yaxis) != 0) ? true : false; + setZ = ((axis & zaxis) != 0) ? true : false; - float setval = (rotate10 > 0) ? 1f : 0f; + float setval = (rotate10 > 0) ? 1f : 0f; - if (setX) - m_rootPart.RotationAxis.X = setval; - if (setY) - m_rootPart.RotationAxis.Y = setval; - if (setZ) - m_rootPart.RotationAxis.Z = setval; + if (setX) + RootPart.RotationAxis.X = setval; + if (setY) + RootPart.RotationAxis.Y = setval; + if (setZ) + RootPart.RotationAxis.Z = setval; - if (setX || setY || setZ) - { - m_rootPart.SetPhysicsAxisRotation(); - } - - } + if (setX || setY || setZ) + RootPart.SetPhysicsAxisRotation(); } + public int registerRotTargetWaypoint(Quaternion target, float tolerance) { scriptRotTarget waypoint = new scriptRotTarget(); @@ -3611,7 +3650,13 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint idx in m_rotTargets.Keys) { scriptRotTarget target = m_rotTargets[idx]; - double angle = Math.Acos(target.targetRot.X * m_rootPart.RotationOffset.X + target.targetRot.Y * m_rootPart.RotationOffset.Y + target.targetRot.Z * m_rootPart.RotationOffset.Z + target.targetRot.W * m_rootPart.RotationOffset.W) * 2; + double angle + = Math.Acos( + target.targetRot.X * m_rootPart.RotationOffset.X + + target.targetRot.Y * m_rootPart.RotationOffset.Y + + target.targetRot.Z * m_rootPart.RotationOffset.Z + + target.targetRot.W * m_rootPart.RotationOffset.W) + * 2; if (angle < 0) angle = -angle; if (angle > Math.PI) angle = (Math.PI * 2 - angle); if (angle <= target.tolerance) @@ -3676,43 +3721,28 @@ namespace OpenSim.Region.Framework.Scenes return retmass; } - + + /// + /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that + /// the physics engine can use it. + /// + /// + /// When the physics engine has finished with it, the sculpt data is discarded to save memory. + /// public void CheckSculptAndLoad() { if (IsDeleted) return; + if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) return; - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero) - { - // check if a previously decoded sculpt map has been cached - if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + part.Shape.SculptTexture.ToString()))) - { - part.SculptTextureCallback(part.Shape.SculptTexture, null); - } - else - { - m_scene.AssetService.Get( - part.Shape.SculptTexture.ToString(), part, AssetReceived); - } - } - } - } +// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); - protected void AssetReceived(string id, Object sender, AssetBase asset) - { - SceneObjectPart sop = (SceneObjectPart)sender; + SceneObjectPart[] parts = m_parts.GetArray(); - if (sop != null) - { - if (asset != null) - sop.SculptTextureCallback(asset.FullID, asset); - } + for (int i = 0; i < parts.Length; i++) + parts[i].CheckSculptAndLoad(); } /// @@ -3747,19 +3777,12 @@ namespace OpenSim.Region.Framework.Scenes return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); } - public void SetAttachmentPoint(byte point) - { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].SetAttachmentPoint(point); - } - #region ISceneObject public virtual ISceneObject CloneForNewScene() { SceneObjectGroup sog = Copy(false); - sog.m_isDeleted = false; + sog.IsDeleted = false; return sog; } -- cgit v1.1 From 03f6734f4367b08e2b181ed68bc80b885e76148f Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 7 Sep 2011 09:42:18 -0700 Subject: First set of merge fixes --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 19 +- OpenSim/Region/Framework/Scenes/Scene.cs | 35 --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 15 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 87 ++---- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 63 ++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 309 ++++++--------------- 6 files changed, 147 insertions(+), 381 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 89f3683..63dd550 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -968,24 +968,25 @@ namespace OpenSim.Region.Framework.Scenes if (part != null) { group = part.ParentGroup; - } + } if (part != null && group != null) { if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) return; - + TaskInventoryItem item = group.GetInventoryItem(localID, itemID); if (item == null) return; - if (item.Type == 10) - { - part.RemoveScriptEvents(itemID); - EventManager.TriggerRemoveScript(localID, itemID); + if (item.Type == 10) + { + part.RemoveScriptEvents(itemID); + EventManager.TriggerRemoveScript(localID, itemID); + } + + group.RemoveInventoryItem(localID, itemID); + part.GetProperties(remoteClient); } - - group.RemoveInventoryItem(localID, itemID); - part.GetProperties(remoteClient); } private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 26fe61d..345c2df 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5347,41 +5347,6 @@ namespace OpenSim.Region.Framework.Scenes // } // } - lock (m_cleaningAttachments) - { - ForEachSOG(delegate (SceneObjectGroup grp) - { - if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) - { - UUID agentID = grp.OwnerID; - if (agentID == UUID.Zero) - { - objectsToDelete.Add(grp); - return; - } - - ScenePresence sp = GetScenePresence(agentID); - if (sp == null) - { - objectsToDelete.Add(grp); - return; - } - } - }); - } - - if (objectsToDelete.Count > 0) - { - m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); - foreach (SceneObjectGroup grp in objectsToDelete) - { - m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); - DeleteSceneObject(grp, true); - } - m_log.Debug("[SCENE]: Finished dropped attachment deletion"); - } - } - public void ThreadAlive(int threadCode) { switch(threadCode) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 29edf13..42e2502 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1437,9 +1437,9 @@ namespace OpenSim.Region.Framework.Scenes // Set the new attachment point data in the object byte attachmentPoint = group.GetAttachmentPoint(); group.UpdateGroupPosition(pos); - group.RootPart.IsAttachment = false; + group.IsAttachment = false; group.AbsolutePosition = group.RootPart.AttachedPos; - group.SetAttachmentPoint(attachmentPoint); + group.AttachmentPoint = attachmentPoint; group.HasGroupChanged = true; } else @@ -1723,12 +1723,11 @@ namespace OpenSim.Region.Framework.Scenes // So that, on delink, no prims are unwittingly // left for sale and sold off - if (child != null) - { - child.RootPart.ObjectSaleType = 0; - child.RootPart.SalePrice = 10; - childGroups.Add(child); - } + if (child != null) + { + child.RootPart.ObjectSaleType = 0; + child.RootPart.SalePrice = 10; + childGroups.Add(child); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 88a6232..35684e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -350,10 +350,6 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_rotation; } set { - foreach(SceneObjectPart p in m_parts.GetArray()) - { - p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); - } m_rotation = value; } } @@ -487,8 +483,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = m_parts.GetArray(); foreach (SceneObjectPart part in parts) { - part.IgnoreUndoUpdate = false; - part.StoreUndoState(UndoType.STATE_GROUP_POSITION); part.GroupPosition = val; if (!m_dupeInProgress) { @@ -1193,45 +1187,31 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void AttachToAgent(UUID agentID, uint attachmentpoint, Vector3 AttachOffset, bool silent) + private void AttachToAgent( + ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { - ScenePresence avatar = m_scene.GetScenePresence(agentID); if (avatar != null) { // don't attach attachments to child agents if (avatar.IsChildAgent) return; -// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name); - - DetachFromBackup(); - // Remove from database and parcel prim count - m_scene.DeleteFromStorage(UUID); + m_scene.DeleteFromStorage(so.UUID); m_scene.EventManager.TriggerParcelPrimCountTainted(); - m_rootPart.AttachedAvatar = agentID; + so.AttachedAvatar = avatar.UUID; - //Anakin Lohner bug #3839 - lock (m_parts) + if (so.RootPart.PhysActor != null) { - foreach (SceneObjectPart p in m_parts.GetArray()) - { - p.AttachedAvatar = agentID; - } + m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); + so.RootPart.PhysActor = null; } - if (m_rootPart.PhysActor != null) - { - m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); - m_rootPart.PhysActor = null; - } - - AbsolutePosition = AttachOffset; - m_rootPart.AttachedPos = AttachOffset; - m_rootPart.IsAttachment = true; - - m_rootPart.SetParentLocalId(avatar.LocalId); - SetAttachmentPoint(Convert.ToByte(attachmentpoint)); + so.AbsolutePosition = attachOffset; + so.RootPart.AttachedPos = attachOffset; + so.IsAttachment = true; + so.RootPart.SetParentLocalId(avatar.LocalId); + so.AttachmentPoint = attachmentpoint; avatar.AddAttachment(this); @@ -1254,7 +1234,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.WarnFormat( "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", - UUID, agentID, Scene.RegionInfo.RegionName); + UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); } } @@ -1263,11 +1243,6 @@ namespace OpenSim.Region.Framework.Scenes return m_rootPart.Shape.State; } - public void ClearPartAttachmentData() - { - SetAttachmentPoint((Byte)0); - } - public void DetachToGround() { ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); @@ -1788,19 +1763,19 @@ namespace OpenSim.Region.Framework.Scenes // This is only necessary when userExposed is false! - bool previousAttachmentStatus = dupe.IsAttachment; + bool previousAttachmentStatus = dupe.IsAttachment; - if (!userExposed) - dupe.IsAttachment = true; + if (!userExposed) + dupe.IsAttachment = true; if (!userExposed) dupe.RootPart.IsAttachment = true; dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - if (!userExposed) - { - dupe.IsAttachment = previousAttachmentStatus; - } + if (!userExposed) + { + dupe.IsAttachment = previousAttachmentStatus; + } if (!userExposed) { @@ -1855,8 +1830,8 @@ namespace OpenSim.Region.Framework.Scenes dupe.UpdateParentIDs(); dupe.HasGroupChanged = true; dupe.AttachToBackup(); - - ScheduleGroupForFullUpdate(); + } + ScheduleGroupForFullUpdate(); // Need to duplicate the physics actor as well if (part.PhysActor != null && userExposed) { @@ -3175,7 +3150,6 @@ namespace OpenSim.Region.Framework.Scenes { if (IsAttachment) { - m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); m_rootPart.AttachedPos = pos; } if (RootPart.GetStatusSandbox()) @@ -3207,9 +3181,9 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetChildPart(localID); -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].StoreUndoState(); if (part != null) { @@ -3368,8 +3342,6 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetChildPart(localID); SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(UndoType.STATE_PRIM_ROTATION); if (part != null) { @@ -3440,14 +3412,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; - - m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); - bool cancelUndo = false; - if (!m_rootPart.Undoing) - { - m_rootPart.Undoing = true; - cancelUndo = true; - } + m_rootPart.StoreUndoState(); //Don't use UpdateRotation because it schedules an update prematurely m_rootPart.RotationOffset = rot; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 893faf8..6988718 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -852,7 +852,7 @@ namespace OpenSim.Region.Framework.Scenes set { - StoreUndoState(UndoType.STATE_PRIM_ROTATION); + StoreUndoState(); m_rotationOffset = value; PhysicsActor actor = PhysActor; @@ -3590,7 +3590,8 @@ namespace OpenSim.Region.Framework.Scenes m_parentGroup.ScheduleGroupForTerseUpdate(); //m_parentGroup.ScheduleGroupForFullUpdate(); } - public void StoreUndoState(UndoType type) + + public void StoreUndoState() { StoreUndoState(false); } @@ -3613,57 +3614,45 @@ namespace OpenSim.Region.Framework.Scenes // TODO: May need to fix for group comparison if (last.Compare(this)) { - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", - // Name, LocalId, m_undo.Count); - + // m_log.DebugFormat( + // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", + // Name, LocalId, m_undo.Count); + return; } } } - - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", - // Name, LocalId, forGroup, m_undo.Count); - + + // m_log.DebugFormat( + // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", + // Name, LocalId, forGroup, m_undo.Count); + if (m_parentGroup.GetSceneMaxUndo() > 0) { UndoState nUndo = new UndoState(this, forGroup); - - UndoState nUndo = new UndoState(this, type); - if (lastUndo != null) - { - TimeSpan ts = DateTime.Now.Subtract(lastUndo.LastUpdated); - if (ts.TotalMilliseconds < 500) - { - //Delete the last entry since it was less than 500 milliseconds ago - nUndo.Merge(lastUndo); - m_undo.Pop(); - } - } m_undo.Push(nUndo); - + if (m_redo.Count > 0) m_redo.Clear(); - - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", - // Name, LocalId, forGroup, m_undo.Count); + + // m_log.DebugFormat( + // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", + // Name, LocalId, forGroup, m_undo.Count); } } } } -// else -// { -// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); -// } + // else + // { + // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); + // } } -// else -// { -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); -// } + // else + // { + // m_log.DebugFormat( + // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); + // } } /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index de9b1f3..8ee7d89 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1364,9 +1364,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// This is the event handler for client movement. If a client is moving, this event is triggering. /// + /// + /// This is the event handler for client movement. If a client is moving, this event is triggering. + /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { -// m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); + // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); //if (m_isChildAgent) //{ @@ -1389,7 +1392,6 @@ namespace OpenSim.Region.Framework.Scenes m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); m_pos = m_LastFinitePos; - if (!m_pos.IsFinite()) { m_pos.X = 127f; @@ -1459,6 +1461,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); } } + lock (scriptedcontrols) { if (scriptedcontrols.Count > 0) @@ -1473,9 +1476,6 @@ namespace OpenSim.Region.Framework.Scenes if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { - m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. - Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); - // TODO: This doesn't prevent the user from walking yet. // Setting parent ID would fix this, if we knew what value // to use. Or we could add a m_isSitting variable. @@ -1530,20 +1530,6 @@ namespace OpenSim.Region.Framework.Scenes if (actor.Flying != oldflying) update_movementflag = true; - if (m_animator.m_jumping) // add for jumping - update_movementflag = true; - - if (q != m_bodyRot) - { - m_bodyRot = q; - update_rotation = true; - } - - //guilty until proven innocent.. - bool Nudging = true; - //Basically, if there is at least one non-nudge control then we don't need - //to worry about stopping the avatar - if (m_parentID == 0) { bool bAllowUpdateMoveToPosition = false; @@ -1557,12 +1543,10 @@ namespace OpenSim.Region.Framework.Scenes else dirVectors = Dir_Vectors; - bool[] isNudge = GetDirectionIsNudge(); - - - - - + // The fact that m_movementflag is a byte needs to be fixed + // it really should be a uint + // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. + uint nudgehack = 250; foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) { if (((uint)flags & (uint)DCF) != 0) @@ -1572,30 +1556,43 @@ namespace OpenSim.Region.Framework.Scenes try { agent_control_v3 += dirVectors[i]; - if (isNudge[i] == false) - { - Nudging = false; - } + //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); } catch (IndexOutOfRangeException) { // Why did I get this? } - if ((m_movementflag & (uint)DCF) == 0) + if ((m_movementflag & (byte)(uint)DCF) == 0) { + if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) + { + m_movementflag |= (byte)nudgehack; + } -// m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); + // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); m_movementflag += (byte)(uint)DCF; update_movementflag = true; } } else { - if ((m_movementflag & (uint)DCF) != 0) + if ((m_movementflag & (byte)(uint)DCF) != 0 || + ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) + && ((m_movementflag & (byte)nudgehack) == nudgehack)) + ) // This or is for Nudge forward { - m_movementflag -= (byte)(uint)DCF; + // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with lack of {1}", Name, DCF); + m_movementflag -= ((byte)(uint)DCF); update_movementflag = true; + + /* + if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) + && ((m_movementflag & (byte)nudgehack) == nudgehack)) + { + m_log.Debug("Removed Hack flag"); + } + */ } else { @@ -1605,128 +1602,19 @@ namespace OpenSim.Region.Framework.Scenes i++; } - if (MovingToTarget) - { - m_moveToPositionTarget = Vector3.Zero; - m_moveToPositionInProgress = false; - update_movementflag = true; - bAllowUpdateMoveToPosition = false; - } - if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) + if (MovingToTarget) { -/* - bool twoD = false; - bool there = false; - if (Animator != null) - { - switch (Animator.CurrentMovementAnimation) - { - case "STAND": - case "WALK": - case "RUN": - case "CROUCH": - case "CROUCHWALK": - { - twoD = true; - } - break; - } - } - - if (twoD) - { -*/ - Vector3 abspos = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, 0.0f); - Vector3 tgt = new Vector3(m_moveToPositionTarget.X, m_moveToPositionTarget.Y, 0.0f); -/* if (Util.GetDistanceTo(abspos, tgt) <= 0.5f) there = true; - } - else - { - if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) there = true; - } -*/ - //Check the error term of the current position in relation to the target position -// if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) -// if (there) - if (Util.GetDistanceTo(abspos, tgt) <= 0.5f) + // If the user has pressed a key then we want to cancel any move to target. + if (DCFlagKeyPressed) { ResetMoveToTarget(); update_movementflag = true; } else if (bAllowUpdateMoveToPosition) { - try - { - // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. - // This movement vector gets added to the velocity through AddNewMovement(). - // Theoretically we might need a more complex PID approach here if other - // unknown forces are acting on the avatar and we need to adaptively respond - // to such forces, but the following simple approach seems to works fine. - Vector3 LocalVectorToTarget3D = -// (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords - (tgt - abspos) - * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords - // Ignore z component of vector - Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); - LocalVectorToTarget2D.Normalize(); - - //We're not nudging - Nudging = false; - agent_control_v3 += LocalVectorToTarget2D; - - // update avatar movement flags. the avatar coordinate system is as follows: - // - // +X (forward) - // - // ^ - // | - // | - // | - // | - // (left) +Y <--------o--------> -Y - // avatar - // | - // | - // | - // | - // v - // -X - // - - // based on the above avatar coordinate system, classify the movement into - // one of left/right/back/forward. - if (LocalVectorToTarget2D.Y > 0)//MoveLeft - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; - //AgentControlFlags - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; - update_movementflag = true; - } - else if (LocalVectorToTarget2D.Y < 0) //MoveRight - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; - update_movementflag = true; - } - if (LocalVectorToTarget2D.X < 0) //MoveBack - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; - update_movementflag = true; - } - else if (LocalVectorToTarget2D.X > 0) //Move Forward - { - m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; - AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; - update_movementflag = true; - } - } - catch (Exception e) - { - //Avoid system crash, can be slower but... - m_log.DebugFormat("Crash! {0}", e.ToString()); - } + if (HandleMoveToTargetUpdate(ref agent_control_v3)) + update_movementflag = true; } } } @@ -1759,31 +1647,26 @@ namespace OpenSim.Region.Framework.Scenes // which occurs later in the main scene loop if (update_movementflag || (update_rotation && DCFlagKeyPressed)) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", -// m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); + // m_log.DebugFormat( + // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", + // m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); - AddNewMovement(agent_control_v3, q, Nudging); - - + AddNewMovement(agent_control_v3); } -// else -// { -// if (!update_movementflag) -// { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", -// m_scene.RegionInfo.RegionName, agent_control_v3, Name); -// } -// } + // else + // { + // if (!update_movementflag) + // { + // m_log.DebugFormat( + // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", + // m_scene.RegionInfo.RegionName, agent_control_v3, Name); + // } + // } if (update_movementflag && m_parentID == 0) Animator.UpdateMovementAnimations(); } - if (update_movementflag && !SitGround) - Animator.UpdateMovementAnimations(); - m_scene.EventManager.TriggerOnClientMovement(this); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); @@ -1799,24 +1682,20 @@ namespace OpenSim.Region.Framework.Scenes /// True if movement has been updated in some way. False otherwise. public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) { -// m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); + // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); + bool updated = false; - public void StopMoveToPosition() - { - m_moveToPositionTarget = Vector3.Zero; - m_moveToPositionInProgress = false; - } + // m_log.DebugFormat( + // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", + // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); - public void DoMoveToPosition(Object sender, string method, List args) - { -//Console.WriteLine("SP:DoMoveToPosition"); - try + if (!m_autopilotMoving) { double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", -// Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", + // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); // Check the error term of the current position in relation to the target position if (distanceToTarget <= 1) @@ -1839,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords // Ignore z component of vector -// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); + // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); LocalVectorToTarget3D.Normalize(); // update avatar movement flags. the avatar coordinate system is as follows: @@ -1905,9 +1784,9 @@ namespace OpenSim.Region.Framework.Scenes updated = true; } -// m_log.DebugFormat( -// "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", -// LocalVectorToTarget3D, agent_control_v3, Name); + // m_log.DebugFormat( + // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", + // LocalVectorToTarget3D, agent_control_v3, Name); agent_control_v3 += LocalVectorToTarget3D; } @@ -1917,7 +1796,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("Crash! {0}", e.ToString()); } } - } + } return updated; } @@ -2746,41 +2625,21 @@ namespace OpenSim.Region.Framework.Scenes /// Rotate the avatar to the given rotation and apply a movement in the given relative vector /// /// The vector in which to move. This is relative to the rotation argument - /// The direction in which this avatar should now face. - public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) + public void AddNewMovement(Vector3 vec) { - if (m_isChildAgent) - { - // WHAT??? - m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent"); - - return; - } - m_perfMonMS = Util.EnvironmentTickCount(); Vector3 direc = vec * Rotation; direc.Normalize(); - PhysicsActor actor = m_physicsActor; - - if (actor.Flying != m_flyingOld) // add for fly velocity control - { - m_flyingOld = actor.Flying; // add for fly velocity control - if (!actor.Flying) m_wasFlying = true; // add for fly velocity control - } - - if (m_physicsActor.IsColliding == true) m_wasFlying = false; // add for fly velocity control - - if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. direc *= 0.03f * 128f * m_speedModifier; + PhysicsActor actor = m_physicsActor; if (actor != null) { if (actor.Flying) { -// rm speed mod direc *= 4.0f; - direc *= 5.2f; // for speed mod + direc *= 4.0f; //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); //bool colliding = (m_physicsActor.IsColliding==true); //if (controlland) @@ -2793,34 +2652,22 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop FLying"); //} } - if (Animator.m_falling && m_wasFlying) // if falling from flying, disable motion add - { - direc *= 0.0f; - } - /* This jumping section removed to SPA else if (!actor.Flying && actor.IsColliding) { if (direc.Z > 2.0f) { - if(m_animator.m_animTickJump == -1) - { - direc.Z *= 3.0f; // jump - } - else - { - direc.Z *= 0.1f; // prejump - } - / * Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs - Animator.TrySetMovementAnimation("PREJUMP"); - Animator.TrySetMovementAnimation("JUMP"); - * / + direc.Z *= 3.0f; + + // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. + Animator.TrySetMovementAnimation("PREJUMP"); + Animator.TrySetMovementAnimation("JUMP"); } - } */ + } } // TODO: Add the force instead of only setting it to support multiple forces per frame? m_forceToApply = direc; - m_isNudging = Nudging; + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); } @@ -3961,7 +3808,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju { StartCollidingMessage.Colliders = colliding; - foreach (SceneObjectGroup att in Attachments) + foreach (SceneObjectGroup att in GetAttachments()) Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); } } @@ -3996,7 +3843,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju { EndCollidingMessage.Colliders = colliding; - foreach (SceneObjectGroup att in Attachments) + foreach (SceneObjectGroup att in GetAttachments()) Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); } } @@ -4517,7 +4364,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju List attachments = m_appearance.GetAttachments(); foreach (AvatarAttachment attach in attachments) { - if (m_isDeleted) + if (IsDeleted) return; int p = attach.AttachPoint; @@ -4603,7 +4450,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju public void SaveChangedAttachments() { // Need to copy this list because DetachToInventoryPrep mods it - List attachments = new List(Attachments.ToArray()); + List attachments = new List(GetAttachments().ToArray()); IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule; if (attachmentsModule != null) @@ -4612,12 +4459,12 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju { if (grp.HasGroupChanged) // Resizer scripts? { - grp.RootPart.IsAttachment = false; + grp.IsAttachment = false; grp.AbsolutePosition = grp.RootPart.AttachedPos; // grp.DetachToInventoryPrep(); attachmentsModule.UpdateKnownItem(ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); - grp.RootPart.IsAttachment = true; + grp.IsAttachment = true; } } } -- cgit v1.1 From cda4cd6b551156ed503a5f284ad6c5a9a0e1c5a5 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 14 Sep 2011 18:46:42 -0700 Subject: Merge fixes, and fix the build --- OpenSim/Region/Framework/Scenes/Scene.cs | 87 ++++++----- .../Region/Framework/Scenes/SceneObjectGroup.cs | 166 ++++++++------------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 98 +----------- OpenSim/Region/Framework/Scenes/UndoState.cs | 127 +++++----------- 5 files changed, 160 insertions(+), 326 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 345c2df..a661ab8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2695,9 +2695,9 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnClientLogin(client); // Send initial parcel data - Vector3 pos = presence.AbsolutePosition; + Vector3 pos = createdSp.AbsolutePosition; ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); - land.SendLandUpdateToClient(presence.ControllingClient); + land.SendLandUpdateToClient(client); } } } @@ -3500,7 +3500,7 @@ namespace OpenSim.Region.Framework.Scenes // check if banned regions are to be blacked out. if (vialogin || (!m_seeIntoBannedRegion)) { - if (!AuthorizeUser(agent.AgentID, out reason)) + if (!AuthorizeUser(agent, out reason)) return false; } } @@ -3696,47 +3696,31 @@ namespace OpenSim.Region.Framework.Scenes /// outputs the reason to this string /// True if the region accepts this agent. False if it does not. False will /// also return a reason. - protected virtual bool AuthorizeUser(UUID agentID, out string reason) + protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) { reason = String.Empty; if (!m_strictAccessControl) return true; - if (Permissions.IsGod(agentID)) return true; - + if (Permissions.IsGod(agent.AgentID)) return true; + if (AuthorizationService != null) { if (!AuthorizationService.IsAuthorizedForRegion( agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", - agentID, RegionInfo.RegionName); - + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + return false; } } if (m_regInfo.EstateSettings != null) { - int flags = GetUserFlags(agentID); - if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) + if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) { - //Add some more info to help users - if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) - { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", - agentID, RegionInfo.RegionName); - reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); - return false; - } - if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) - { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", - agentID, RegionInfo.RegionName); - reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); - return false; - } - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", - agentID, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: You have been banned from that region.", RegionInfo.RegionName); return false; @@ -3753,7 +3737,7 @@ namespace OpenSim.Region.Framework.Scenes if (groupsModule != null) { GroupMembershipData[] GroupMembership = - groupsModule.GetMembershipData(agentID); + groupsModule.GetMembershipData(agent.AgentID); if (GroupMembership != null) { @@ -3782,16 +3766,44 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); if (!m_regInfo.EstateSettings.PublicAccess && - !m_regInfo.EstateSettings.HasAccess(agentID) && + !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && !groupAccess) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", - agentID, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", RegionInfo.RegionName); return false; } + // TODO: estate/region settings are not properly hooked up + // to ILandObject.isRestrictedFromLand() + // if (null != LandChannel) + // { + // // region seems to have local Id of 1 + // ILandObject land = LandChannel.GetLandObject(1); + // if (null != land) + // { + // if (land.isBannedFromLand(agent.AgentID)) + // { + // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", + // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + // reason = String.Format("Denied access to private region {0}: You are banned from that region.", + // RegionInfo.RegionName); + // return false; + // } + + // if (land.isRestrictedFromLand(agent.AgentID)) + // { + // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", + // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", + // RegionInfo.RegionName); + // return false; + // } + // } + // } + return true; } @@ -5387,9 +5399,16 @@ namespace OpenSim.Region.Framework.Scenes } } - if (!AuthorizeUser(agentID, out reason)) + try + { + if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) + { + // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); + return false; + } + } + catch { - // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); return false; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 35684e0..ea6aab0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1245,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes public void DetachToGround() { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar == null) return; @@ -1259,14 +1259,14 @@ namespace OpenSim.Region.Framework.Scenes RootPart.FromItemID = UUID.Zero; AbsolutePosition = detachedpos; - m_rootPart.AttachedAvatar = UUID.Zero; + AttachedAvatar = UUID.Zero; - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; + //SceneObjectPart[] parts = m_parts.GetArray(); + //for (int i = 0; i < parts.Length; i++) + // parts[i].AttachedAvatar = UUID.Zero; m_rootPart.SetParentLocalId(0); - SetAttachmentPoint((byte)0); + AttachmentPoint = (byte)0; m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); HasGroupChanged = true; RootPart.Rezzed = DateTime.Now; @@ -1279,7 +1279,7 @@ namespace OpenSim.Region.Framework.Scenes public void DetachToInventoryPrep() { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); //Vector3 detachedpos = new Vector3(127f, 127f, 127f); if (avatar != null) { @@ -1287,15 +1287,15 @@ namespace OpenSim.Region.Framework.Scenes avatar.RemoveAttachment(this); } - m_rootPart.AttachedAvatar = UUID.Zero; + AttachedAvatar = UUID.Zero; - SceneObjectPart[] parts = m_parts.GetArray(); + /*SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; + parts[i].AttachedAvatar = UUID.Zero;*/ m_rootPart.SetParentLocalId(0); //m_rootPart.SetAttachmentPoint((byte)0); - m_rootPart.IsAttachment = false; + IsAttachment = false; AbsolutePosition = m_rootPart.AttachedPos; //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); //AttachToBackup(); @@ -1471,7 +1471,7 @@ namespace OpenSim.Region.Framework.Scenes public void DeleteGroupFromScene(bool silent) { // We need to keep track of this state in case this group is still queued for backup. - m_isDeleted = true; + IsDeleted = true; DetachFromBackup(); @@ -1746,97 +1746,63 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup Copy(bool userExposed) { - SceneObjectGroup dupe; - try - { - m_dupeInProgress = true; - dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new MapAndArray(); + SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new MapAndArray(); - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state - // This is only necessary when userExposed is false! + // This is only necessary when userExposed is false! - bool previousAttachmentStatus = dupe.IsAttachment; - - if (!userExposed) - dupe.IsAttachment = true; + bool previousAttachmentStatus = dupe.IsAttachment; - if (!userExposed) - dupe.RootPart.IsAttachment = true; + if (!userExposed) + dupe.IsAttachment = true; - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - if (!userExposed) - { - dupe.IsAttachment = previousAttachmentStatus; - } + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - if (!userExposed) - { - dupe.RootPart.IsAttachment = previousAttachmentStatus; - } + if (!userExposed) + { + dupe.IsAttachment = previousAttachmentStatus; + } - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - if (userExposed) - dupe.m_rootPart.TrimPermissions(); + if (userExposed) + dupe.m_rootPart.TrimPermissions(); - List partList = new List(m_parts.GetArray()); + List partList = new List(m_parts.GetArray()); - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); - foreach (SceneObjectPart part in partList) + foreach (SceneObjectPart part in partList) + { + SceneObjectPart newPart; + if (part.UUID != m_rootPart.UUID) { - if (part.UUID != m_rootPart.UUID) - { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - - newPart.LinkNum = part.LinkNum; - } - - // Need to duplicate the physics actor as well - if (part.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = part.Shape; - - part.PhysActor - = m_scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", part.Name, part.UUID), - pbs, - part.AbsolutePosition, - part.Scale, - part.RotationOffset, - part.PhysActor.IsPhysical, - m_localId); - part.PhysActor.SetMaterial((int)part.Material); - - part.PhysActor.LocalID = part.LocalId; - part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); - } + newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); + newPart.LinkNum = part.LinkNum; } - if (userExposed) + else { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); + newPart = dupe.m_rootPart; } - ScheduleGroupForFullUpdate(); + // Need to duplicate the physics actor as well if (part.PhysActor != null && userExposed) { PrimitiveBaseShape pbs = newPart.Shape; - + newPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( string.Format("{0}/{1}", newPart.Name, newPart.UUID), @@ -1846,14 +1812,20 @@ namespace OpenSim.Region.Framework.Scenes newPart.RotationOffset, part.PhysActor.IsPhysical, newPart.LocalId); - + newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); } } - finally + + if (userExposed) { - m_dupeInProgress = false; + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); } + return dupe; } @@ -1983,22 +1955,8 @@ namespace OpenSim.Region.Framework.Scenes public void stopMoveToTarget() { - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) - { - if (IsAttachment) - { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) avatar.StopMoveToPosition(); - } - else - { - if (rootpart.PhysActor != null) - { - rootpart.PhysActor.PIDActive = false; - } - } - } + if (RootPart.PhysActor != null) + RootPart.PhysActor.PIDActive = false; } public void rotLookAt(Quaternion target, float strength, float damping) @@ -3087,8 +3045,6 @@ namespace OpenSim.Region.Framework.Scenes prevScale.X *= x; prevScale.Y *= y; prevScale.Z *= z; - part.IgnoreUndoUpdate = false; - // RootPart.IgnoreUndoUpdate = true; RootPart.Resize(prevScale); // RootPart.IgnoreUndoUpdate = false; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6988718..0c3b404 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3243,6 +3243,14 @@ namespace OpenSim.Region.Framework.Scenes STATUS_ROTATE_Z = rotate; } + public void SetBuoyancy(float fvalue) + { + if (PhysActor != null) + { + PhysActor.Buoyancy = fvalue; + } + } + public void SetDieAtEdge(bool p) { if (m_parentGroup.IsDeleted) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8ee7d89..35a8df7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -131,6 +131,7 @@ namespace OpenSim.Region.Framework.Scenes // private SceneObjectGroup proxyObjectGroup; //private SceneObjectPart proxyObjectPart = null; public Vector3 lastKnownAllowedPosition; + public bool sentMessageAboutRestrictedParcelFlyingDown; public Vector4 CollisionPlane = Vector4.UnitW; private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation @@ -4316,103 +4317,6 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju return flags; } - /// - /// RezAttachments. This should only be called upon login on the first region. - /// Attachment rezzings on crossings and TPs are done in a different way. - /// - public void RezAttachments() - { - if (null == m_appearance) - { - m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); - return; - } - - XmlDocument doc = new XmlDocument(); - string stateData = String.Empty; - - IAttachmentsService attServ = m_scene.RequestModuleInterface(); - if (attServ != null) - { - m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); - stateData = attServ.Get(ControllingClient.AgentId.ToString()); - if (stateData != String.Empty) - { - try - { - doc.LoadXml(stateData); - } - catch { } - } - } - - Dictionary itemData = new Dictionary(); - - XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); - if (nodes.Count > 0) - { - foreach (XmlNode n in nodes) - { - XmlElement elem = (XmlElement)n; - string itemID = elem.GetAttribute("ItemID"); - string xml = elem.InnerXml; - - itemData[new UUID(itemID)] = xml; - } - } - - List attachments = m_appearance.GetAttachments(); - foreach (AvatarAttachment attach in attachments) - { - if (IsDeleted) - return; - - int p = attach.AttachPoint; - UUID itemID = attach.ItemID; - - //UUID assetID = attach.AssetID; - // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down - // But they're not used anyway, the item is being looked up for now, so let's proceed. - //if (UUID.Zero == assetID) - //{ - // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); - // continue; - //} - - try - { - string xmlData; - XmlDocument d = new XmlDocument(); - UUID asset; - if (itemData.TryGetValue(itemID, out xmlData)) - { - d.LoadXml(xmlData); - m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); - - // Rez from inventory - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); - - } - else - { - // Rez from inventory (with a null doc to let - // CHANGED_OWNER happen) - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); - } - - m_log.InfoFormat( - "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2}", - p, itemID, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); - } - } - } - private void ReprioritizeUpdates() { if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 81f41db..0a30f4b 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -50,16 +50,11 @@ namespace OpenSim.Region.Framework.Scenes public class UndoState { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public Vector3 Position = Vector3.Zero; public Vector3 Scale = Vector3.Zero; public Quaternion Rotation = Quaternion.Identity; - public Vector3 GroupPosition = Vector3.Zero; - public Quaternion GroupRotation = Quaternion.Identity; - public Vector3 GroupScale = Vector3.Zero; - public DateTime LastUpdated = DateTime.Now; - public UndoType Type; /// /// Is this undo state for an entire group? @@ -77,88 +72,40 @@ namespace OpenSim.Region.Framework.Scenes { ForGroup = forGroup; -// if (ForGroup) - GroupScale = part.ParentGroup.RootPart.Shape.Scale; + // if (ForGroup) + Position = part.ParentGroup.AbsolutePosition; + // else + // Position = part.OffsetPosition; - //FUBAR WARNING: Do NOT get the group's absoluteposition here - //or you'll experience a loop and/or a stack issue - GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; - GroupRotation = part.ParentGroup.GroupRotation; - Position = part.ParentGroup.RootPart.AbsolutePosition; -// else -// Position = part.OffsetPosition; - -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo position {0} for root part", Position); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo position {0} for root part", Position); Rotation = part.RotationOffset; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); Scale = part.Shape.Scale; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo scale {0} for root part", Scale); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); } else { Position = part.OffsetPosition; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo position {0} for child part", Position); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo position {0} for child part", Position); Rotation = part.RotationOffset; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); Scale = part.Shape.Scale; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo scale {0} for child part", Scale); - } - } - public void Merge(UndoState last) - { - if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION))) - { - GroupPosition = last.GroupPosition; - Position = last.Position; - } - if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) - { - GroupScale = last.GroupScale; - Scale = last.Scale; - } - if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION))) - { - GroupRotation = last.GroupRotation; - Rotation = last.Rotation; - } - if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION))) - { - Position = last.Position; - } - if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE))) - { - Scale = last.Scale; - } - if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION))) - { - Rotation = last.Rotation; - } - Type = Type | last.Type; - } - public bool Compare(UndoState undo) - { - if (undo == null || Position == null) return false; - if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) - { - return true; - } - else - { - return false; + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); } } + /// /// Compare the relevant state in the given part to this state. /// @@ -183,15 +130,15 @@ namespace OpenSim.Region.Framework.Scenes return false; } - private void RestoreState(SceneObjectPart part) + public void PlaybackState(SceneObjectPart part) { part.Undoing = true; if (part.ParentID == 0) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", -// Position, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", + // Position, part.Name, part.LocalId); if (Position != Vector3.Zero) { @@ -201,9 +148,9 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.UpdateRootPosition(Position); } -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", -// part.RotationOffset, Rotation, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", + // part.RotationOffset, Rotation, part.Name, part.LocalId); if (ForGroup) part.UpdateRotation(Rotation); @@ -212,9 +159,9 @@ namespace OpenSim.Region.Framework.Scenes if (Scale != Vector3.Zero) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", -// part.Shape.Scale, Scale, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", + // part.Shape.Scale, Scale, part.Name, part.LocalId); if (ForGroup) part.ParentGroup.GroupResize(Scale); @@ -228,24 +175,24 @@ namespace OpenSim.Region.Framework.Scenes { if (Position != Vector3.Zero) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", -// part.OffsetPosition, Position, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", + // part.OffsetPosition, Position, part.Name, part.LocalId); part.OffsetPosition = Position; } -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", -// part.RotationOffset, Rotation, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", + // part.RotationOffset, Rotation, part.Name, part.LocalId); part.UpdateRotation(Rotation); if (Scale != Vector3.Zero) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", -// part.Shape.Scale, Scale, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", + // part.Shape.Scale, Scale, part.Name, part.LocalId); part.Resize(Scale); } -- cgit v1.1 From e15917f4658789096902625dddf226dd218a23c2 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 14 Sep 2011 19:34:03 -0700 Subject: Fixed a movement regression - Kitto's jump code is no longer needed (plus it's an eyesore) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 +++++------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a86f98..fa6945c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3620,45 +3620,17 @@ namespace OpenSim.Region.Framework.Scenes /// public override void UpdateMovement() { - if (Animator!=null) // add for jumping - { // add for jumping - // if (!m_animator.m_jumping) // add for jumping - // { // add for jumping + if (m_forceToApply.HasValue) + { + Vector3 force = m_forceToApply.Value; - if (m_forceToApply.HasValue) // this section realigned - { + m_updateflag = true; - Vector3 force = m_forceToApply.Value; - m_updateflag = true; -if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping - Velocity = force; -//Console.WriteLine("UM1 {0}", Velocity); - m_forceToApply = null; - } - else - { - if (m_isNudging) - { - Vector3 force = Vector3.Zero; - - m_updateflag = true; -if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping - Velocity = force; -//Console.WriteLine("UM2 {0}", Velocity); - m_isNudging = false; - m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" - } - else // add for jumping - { // add for jumping - Vector3 force = Vector3.Zero; // add for jumping -if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping -//Console.WriteLine("UM3 {0}", Velocity); - Velocity = force; // add for jumping - } - } - // } // end realign - } // add for jumping - } // add for jumping + Velocity = force; + + m_forceToApply = null; + } + } /// /// Adds a physical representation of the avatar to the Physics plugin -- cgit v1.1 From 300d357573a272ef0042ebbe0912ab88de958f65 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 6 Oct 2011 17:55:20 +0200 Subject: Fix physics proxy position when linking and rotating the root prim only --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6c47645..58f2586 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2397,6 +2397,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion oldRootRotation = linkPart.RotationOffset; linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + linkPart.ParentID = m_rootPart.LocalId; linkPart.GroupPosition = AbsolutePosition; Vector3 axPos = linkPart.OffsetPosition; @@ -3431,14 +3432,17 @@ namespace OpenSim.Region.Framework.Scenes if (prim.UUID != m_rootPart.UUID) { prim.IgnoreUndoUpdate = true; + + Quaternion NewRot = oldParentRot * prim.RotationOffset; + NewRot = Quaternion.Inverse(axRot) * NewRot; + prim.RotationOffset = NewRot; + Vector3 axPos = prim.OffsetPosition; axPos *= oldParentRot; axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; - prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); - prim.IgnoreUndoUpdate = false; } } -- cgit v1.1 From 1d379a9c7b59f95ccca1149fad6e5e0107040f6e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Oct 2011 07:46:13 +0200 Subject: Make WALK animation state work again. TURNLEFT and TURNRIGHT are now rebroken --- .../Scenes/Animation/ScenePresenceAnimator.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 904a657..f54b071 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -404,25 +404,19 @@ TrySetMovementAnimation("STAND"); else if (m_scenePresence.SetAlwaysRun) return "RUN"; else - { - // Not walking - if (move.Z < 0) - return "CROUCH"; - else if (heldTurnLeft) - return "TURNLEFT"; - else if (heldTurnRight) - return "TURNRIGHT"; - else - return "WALK"; - } + return "WALK"; } // rm for jumping else else if (!m_jumping) // add for jumping { m_falling = false; // Add for falling // Not walking - if (move.Z < 0f) + if (move.Z < 0) return "CROUCH"; + else if (heldTurnLeft) + return "TURNLEFT"; + else if (heldTurnRight) + return "TURNRIGHT"; else return "STAND"; } -- cgit v1.1 From fd0e65b0b17c2985d4dd8199e16fbc84d9929dad Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 20 Oct 2011 23:11:53 +0200 Subject: Fix up the animator and ScenePresence to like each other again --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 14 +++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index f54b071..e4e5ab6 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public class ScenePresenceAnimator { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public AnimationSet Animations { @@ -181,8 +181,8 @@ TrySetMovementAnimation("STAND"); bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); - bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; - bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; + //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; + //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; @@ -413,10 +413,10 @@ TrySetMovementAnimation("STAND"); // Not walking if (move.Z < 0) return "CROUCH"; - else if (heldTurnLeft) - return "TURNLEFT"; - else if (heldTurnRight) - return "TURNRIGHT"; +// else if (heldTurnLeft) +// return "TURNLEFT"; +// else if (heldTurnRight) +// return "TURNRIGHT"; else return "STAND"; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 975d855..1f39c3f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2703,6 +2703,19 @@ namespace OpenSim.Region.Framework.Scenes Vector3 direc = vec * Rotation; direc.Normalize(); + if (PhysicsActor.Flying != m_flyingOld) // add for fly velocity control + { + m_flyingOld = PhysicsActor.Flying; // add for fly velocity control + if (!PhysicsActor.Flying) + m_wasFlying = true; // add for fly velocity control + } + + if (PhysicsActor.IsColliding == true) + m_wasFlying = false; // add for fly velocity control + + if ((vec.Z == 0f) && !PhysicsActor.Flying) + direc.Z = 0f; // Prevent camera WASD up. + direc *= 0.03f * 128f * SpeedModifier; if (PhysicsActor != null) @@ -2721,6 +2734,10 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop Flying"); //} } + if (Animator.m_falling && m_wasFlying) // if falling from flying, disable motion add + { + direc *= 0.0f; + } else if (!PhysicsActor.Flying && PhysicsActor.IsColliding) { if (direc.Z > 2.0f) -- cgit v1.1 From 8cca9fe23cd2b8d785e844d123e3c565efc23e97 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 21 Oct 2011 03:15:56 +0200 Subject: Allow updating the movement animation while flying. This fixes falling, splatting and ground sit. Walking to a ground sit still doesn't work. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 ++++++------------------ 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1f39c3f..9884acd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -187,7 +187,6 @@ namespace OpenSim.Region.Framework.Scenes protected ulong crossingFromRegion; private readonly Vector3[] Dir_Vectors = new Vector3[11]; - private bool m_isNudging = false; protected Timer m_reprioritization_timer; @@ -903,24 +902,6 @@ namespace OpenSim.Region.Framework.Scenes return vector; } - private bool[] GetDirectionIsNudge() - { - bool[] isNudge = new bool[11]; - isNudge[0] = false; //FORWARD - isNudge[1] = false; //BACK - isNudge[2] = false; //LEFT - isNudge[3] = false; //RIGHT - isNudge[4] = false; //UP - isNudge[5] = false; //DOWN - isNudge[6] = true; //FORWARD_NUDGE - isNudge[7] = true; //BACK_NUDGE - isNudge[8] = true; //LEFT_NUDGE - isNudge[9] = true; //RIGHT_NUDGE - isNudge[10] = true; //DOWN_Nudge - return isNudge; - } - - #endregion public uint GenerateClientFlags(UUID ObjectID) @@ -1535,6 +1516,9 @@ namespace OpenSim.Region.Framework.Scenes if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { + m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. + Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); + // TODO: This doesn't prevent the user from walking yet. // Setting parent ID would fix this, if we knew what value // to use. Or we could add a m_isSitting variable. @@ -3736,7 +3720,9 @@ namespace OpenSim.Region.Framework.Scenes CollisionPlane = Vector4.UnitW; - if (m_lastColCount != coldata.Count) + // No collisions at all means we may be flying. Update always + // to make falling work + if (m_lastColCount != coldata.Count || coldata.Count == 0) { m_updateCount = UPDATE_COUNT; m_lastColCount = coldata.Count; -- cgit v1.1 From 4a6160e7ad6284de8eef48892c6a6e133d4ddc2f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 24 Oct 2011 18:22:36 +0200 Subject: Fake an AgentCircuitData if none is available rather than crashing out --- OpenSim/Region/Framework/Scenes/Scene.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 80d7871..98bc44f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5360,16 +5360,38 @@ namespace OpenSim.Region.Framework.Scenes } } + ScenePresence presence = GetScenePresence(agentID); + IClientAPI client = null; + AgentCircuitData aCircuit = null; + + if (presence != null) + { + client = presence.ControllingClient; + if (client != null) + aCircuit = client.RequestClientInfo(); + } + + // We may be called before there is a presence or a client. + // Fake AgentCircuitData to keep IAuthorizationModule smiling + if (client == null) + { + aCircuit = new AgentCircuitData(); + aCircuit.AgentID = agentID; + aCircuit.firstname = String.Empty; + aCircuit.lastname = String.Empty; + } + try { - if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) + if (!AuthorizeUser(aCircuit, out reason)) { // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); return false; } } - catch + catch (Exception e) { + m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); return false; } -- cgit v1.1 From 5f025d20fe9aa8449f446f33d9147ddb27e2d5be Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 25 Oct 2011 00:53:39 +0200 Subject: Fix ground sit autopilot --- .../Scenes/Animation/ScenePresenceAnimator.cs | 4 +++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 24 ++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index e4e5ab6..175e8ed 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -26,6 +26,7 @@ */ using System; +using System.Threading; using System.Collections.Generic; using System.Reflection; using log4net; @@ -169,6 +170,7 @@ TrySetMovementAnimation("STAND"); #region Inputs AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; +// m_log.DebugFormat("[ANIM]: Control flags: {0}", controlFlags); PhysicsActor actor = m_scenePresence.PhysicsActor; // Create forward and left vectors from the current avatar rotation @@ -190,12 +192,12 @@ TrySetMovementAnimation("STAND"); // Direction in which the avatar is trying to move Vector3 move = Vector3.Zero; - if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } if (heldLeft) { move.X += left.X; move.Y += left.Y; } if (heldRight) { move.X -= left.X; move.Y -= left.Y; } if (heldUp) { move.Z += 1; } if (heldDown) { move.Z -= 1; } + if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } // Is the avatar trying to move? // bool moving = (move != Vector3.Zero); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9884acd..d43f67f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1486,6 +1486,10 @@ namespace OpenSim.Region.Framework.Scenes #endregion Inputs + // Make anims work for client side autopilot + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) + m_updateCount = UPDATE_COUNT; + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); @@ -1856,9 +1860,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget) { - m_log.DebugFormat( - "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", - Name, pos, m_scene.RegionInfo.RegionName); + if (SitGround) + StandUp(); + +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", +// Name, pos, m_scene.RegionInfo.RegionName); if (pos.X < 0 || pos.X >= Constants.RegionSize || pos.Y < 0 || pos.Y >= Constants.RegionSize @@ -1884,9 +1891,9 @@ namespace OpenSim.Region.Framework.Scenes if (pos.Z - terrainHeight < 0.2) pos.Z = terrainHeight; - m_log.DebugFormat( - "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", - Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", +// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); if (noFly) PhysicsActor.Flying = false; @@ -1922,7 +1929,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ResetMoveToTarget() { - m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); +// m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); MovingToTarget = false; MoveToPositionTarget = Vector3.Zero; @@ -2061,7 +2068,8 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; } - Animator.TrySetMovementAnimation("STAND"); + + Animator.UpdateMovementAnimations(); } private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) -- cgit v1.1 From 585f1b189fa6248c0620963d9c39d50a6a33e11e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 25 Oct 2011 02:08:43 +0100 Subject: Merge --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 -- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4d8a759..c76538f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -577,8 +577,6 @@ namespace OpenSim.Region.Framework.Scenes m_lastIncoming = 0; m_lastOutgoing = 0; - m_physicalPrim = physicalPrim; - m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2507c67..fae1618 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1267,7 +1267,7 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.SetParentLocalId(0); AttachmentPoint = (byte)0; - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); HasGroupChanged = true; RootPart.Rezzed = DateTime.Now; RootPart.RemFlag(PrimFlags.TemporaryOnRez); -- cgit v1.1 From f6ea36b4fa5f2517d71c13a9dda154397a0939d3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 25 Oct 2011 03:15:28 +0200 Subject: Fix a missing locking call --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4edc220..07e303f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1033,6 +1033,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_items.Count == 0) // No inventory { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + Items.LockItemsForRead(false); return; } -- cgit v1.1 From ce8419fdd0d3384a9df037d9df1b5d7d8960d1d8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Nov 2011 23:42:09 +0100 Subject: Fix link order when linking sets to sets --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 8 +++- .../Region/Framework/Scenes/SceneObjectGroup.cs | 50 +++++----------------- 2 files changed, 18 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a6178e7..0f5e99d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1752,7 +1752,7 @@ namespace OpenSim.Region.Framework.Scenes List childGroups = new List(); // We do this in reverse to get the link order of the prims correct - for (int i = children.Count - 1; i >= 0; i--) + for (int i = 0 ; i < children.Count ; i++) { SceneObjectGroup child = children[i].ParentGroup; @@ -1784,6 +1784,12 @@ namespace OpenSim.Region.Framework.Scenes } finally { + lock (SceneObjectGroupsByLocalPartID) + { + foreach (SceneObjectPart part in parentGroup.Parts) + SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; + } + parentGroup.areUpdatesSuspended = false; parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8b71f5b..3a863e7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2351,16 +2351,6 @@ namespace OpenSim.Region.Framework.Scenes /// The group of prims which should be linked to this group public void LinkToGroup(SceneObjectGroup objectGroup) { - // Make sure we have sent any pending unlinks or stuff. - //if (objectGroup.RootPart.UpdateFlag > 0) - //{ - // m_log.WarnFormat( - // "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.", - // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); - - // objectGroup.RootPart.SendScheduledUpdates(); - //} - // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); @@ -2384,45 +2374,27 @@ namespace OpenSim.Region.Framework.Scenes linkPart.RotationOffset = newRot; linkPart.ParentID = m_rootPart.LocalId; + if (m_rootPart.LinkNum == 0) m_rootPart.LinkNum = 1; lock (m_parts.SyncRoot) { - m_parts.Add(linkPart.UUID, linkPart); - - // Insert in terms of link numbers, the new links - // before the current ones (with the exception of - // the root prim. Shuffle the old ones up - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - if (part.LinkNum != 1) - { - // Don't update root prim link number - part.LinkNum += objectGroup.PrimCount; - } - } - } + int linkNum = PrimCount + 1; - linkPart.LinkNum = 2; + m_parts.Add(linkPart.UUID, linkPart); - linkPart.SetParent(this); - linkPart.CreateSelected = true; + linkPart.SetParent(this); + linkPart.CreateSelected = true; - lock (m_parts.SyncRoot) - { - //if (linkPart.PhysActor != null) - //{ - // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); + linkPart.LinkNum = linkNum++; - //linkPart.PhysActor = null; - //} - - //TODO: rest of parts - int linkNum = 3; SceneObjectPart[] ogParts = objectGroup.Parts; + Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) + { + return a.LinkNum - b.LinkNum; + }); + for (int i = 0; i < ogParts.Length; i++) { SceneObjectPart part = ogParts[i]; -- cgit v1.1 From bda7b3dffe320f358a2e34b738c23371bb7e302b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 19:28:16 +0100 Subject: Replace our patched up, broken an rebroken sit code with the code from core which has now matured beyond what we had. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 409 ++++++----------------- 1 file changed, 106 insertions(+), 303 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bd94902..64b2ddb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1942,7 +1942,7 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; SendAvatarDataToAllAgents(); - HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? + //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); } //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); m_requestedSitTargetUUID = UUID.Zero; @@ -1979,22 +1979,24 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + m_log.Debug("StandupCode Executed"); + SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); if (part != null) { - part.TaskInventory.LockItemsForRead(true); TaskInventoryDictionary taskIDict = part.TaskInventory; if (taskIDict != null) { - foreach (UUID taskID in taskIDict.Keys) + lock (taskIDict) { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS + foreach (UUID taskID in taskIDict.Keys) + { + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS + } } } - part.TaskInventory.LockItemsForRead(false); // Reset sit target. if (part.SitTargetAvatar == UUID) @@ -2003,54 +2005,16 @@ namespace OpenSim.Region.Framework.Scenes ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); } - // part.GetWorldRotation() is the rotation of the object being sat on - // Rotation is the sittiing Av's rotation - - Quaternion partRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partRot = part.ParentGroup.RootPart.RotationOffset; -// } -// else -// { // single or child prim - -// } - if (part == null) //CW: Part may be gone. llDie() for example. - { - partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - partRot = part.GetWorldRotation(); - } - - Quaternion partIRot = Quaternion.Inverse(partRot); - - Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av - Vector3 avStandUp = new Vector3(0.3f, 0f, 0f) * avatarRot; // 0.3M infront of av - - if (m_physicsActor == null) + if (PhysicsActor == null) { AddToPhysicalScene(false); } - //CW: If the part isn't null then we can set the current position - if (part != null) - { - Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! - AbsolutePosition = avWorldStandUp; //KF: Fix stand up. - part.IsOccupied = false; - part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); - } - else - { - //CW: Since the part doesn't exist, a coarse standup position isn't an issue - AbsolutePosition = m_lastWorldPosition; - } - - m_parentPosition = Vector3.Zero; - m_parentID = 0; - m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + + m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + ParentPosition = Vector3.Zero; + + ParentID = 0; SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; @@ -2058,7 +2022,7 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } - Animator.UpdateMovementAnimations(); + Animator.TrySetMovementAnimation("STAND"); } private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) @@ -2089,8 +2053,8 @@ namespace OpenSim.Region.Framework.Scenes Quaternion avSitOrientation = part.SitTargetOrientation; UUID avOnTargetAlready = part.SitTargetAvatar; - bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); - bool SitTargetisSet = (Vector3.Zero != avSitOffset); //NB Latest SL Spec shows Sit Rotation setting is ignored. + bool SitTargetUnOccupied = avOnTargetAlready == UUID.Zero; + bool SitTargetisSet = avSitOffset != Vector3.Zero || avSitOrientation != Quaternion.Identity; if (SitTargetisSet && SitTargetUnOccupied) { @@ -2106,167 +2070,87 @@ namespace OpenSim.Region.Framework.Scenes private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) { bool autopilot = true; - Vector3 autopilotTarget = new Vector3(); - Quaternion sitOrientation = Quaternion.Identity; Vector3 pos = new Vector3(); + Quaternion sitOrientation = pSitOrientation; Vector3 cameraEyeOffset = Vector3.Zero; Vector3 cameraAtOffset = Vector3.Zero; bool forceMouselook = false; SceneObjectPart part = FindNextAvailableSitTarget(targetID); - if (part == null) return; - - // TODO: determine position to sit at based on scene geometry; don't trust offset from client - // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - - // part is the prim to sit on - // offset is the world-ref vector distance from that prim center to the click-spot - // UUID is the UUID of the Avatar doing the clicking - - m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation - - // Is a sit target available? - Vector3 avSitOffSet = part.SitTargetPosition; - Quaternion avSitOrientation = part.SitTargetOrientation; - - bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. - // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); - Quaternion partRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partRot = part.ParentGroup.RootPart.RotationOffset; -// } -// else -// { // single or child prim - partRot = part.GetWorldRotation(); -// } - Quaternion partIRot = Quaternion.Inverse(partRot); -//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); - // Sit analysis rewritten by KF 091125 - if (SitTargetisSet) // scipted sit - { - if (!part.IsOccupied) - { -//Console.WriteLine("Scripted, unoccupied"); - part.SitTargetAvatar = UUID; // set that Av will be on it - offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one + if (part != null) + { + // TODO: determine position to sit at based on scene geometry; don't trust offset from client + // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it + + // Is a sit target available? + Vector3 avSitOffSet = part.SitTargetPosition; + Quaternion avSitOrientation = part.SitTargetOrientation; + UUID avOnTargetAlready = part.SitTargetAvatar; + + bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); + bool SitTargetisSet = + (!(avSitOffSet == Vector3.Zero && + ( + avSitOrientation == Quaternion.Identity // Valid Zero Rotation quaternion + || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point + || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion + ) + )); + +// m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); + + if (SitTargetisSet && SitTargetUnOccupied) + { + part.SitTargetAvatar = UUID; + offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); + sitOrientation = avSitOrientation; + autopilot = false; + } + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); + + pos = part.AbsolutePosition + offset; + //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) + //{ + // offset = pos; + //autopilot = false; + //} + if (PhysicsActor != null) + { + // If we're not using the client autopilot, we're immediately warping the avatar to the location + // We can remove the physicsActor until they stand up. + m_sitAvatarHeight = PhysicsActor.Size.Z; - Quaternion nrot = avSitOrientation; - if (!part.IsRoot) + if (autopilot) { - nrot = part.RotationOffset * avSitOrientation; + if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) + { + autopilot = false; + + RemoveFromPhysicalScene(); + AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); + } } - sitOrientation = nrot; // Change rotatione to the scripted one - OffsetRotation = nrot; - autopilot = false; // Jump direct to scripted llSitPos() - } - else - { -//Console.WriteLine("Scripted, occupied"); - return; - } - } - else // Not Scripted - { - if ( (Math.Abs(offset.X) > 0.1f) || (Math.Abs(offset.Y) > 0.1f) ) // Changed 0.5M to 0.1M as they want to be able to sit close together - { - // large prim & offset, ignore if other Avs sitting -// offset.Z -= 0.05f; - m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked - autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point - -//Console.WriteLine(" offset ={0}", offset); -//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); -//Console.WriteLine(" autopilotTarget={0}", autopilotTarget); - - } - else // small offset - { -//Console.WriteLine("Small offset"); - if (!part.IsOccupied) - { - m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center - autopilotTarget = part.AbsolutePosition; -//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); - } - else return; // occupied small - } // end large/small - } // end Scripted/not - - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - - cameraAtOffset = part.GetCameraAtOffset(); - cameraEyeOffset = part.GetCameraEyeOffset(); - forceMouselook = part.GetForceMouselook(); - if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // - if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // - - if (m_physicsActor != null) - { - // If we're not using the client autopilot, we're immediately warping the avatar to the location - // We can remove the physicsActor until they stand up. - m_sitAvatarHeight = m_physicsActor.Size.Z; - if (autopilot) - { // its not a scripted sit -// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) - if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) + else { - autopilot = false; // close enough - m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. - Not using the part's position because returning the AV to the last known standing - position is likely to be more friendly, isn't it? */ RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target - } // else the autopilot will get us close - } - else - { // its a scripted sit - m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. - I *am* using the part's position this time because we have no real idea how far away - the avatar is from the sit target. */ - RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; + } } + + cameraAtOffset = part.GetCameraAtOffset(); + cameraEyeOffset = part.GetCameraEyeOffset(); + forceMouselook = part.GetForceMouselook(); } - else return; // physactor is null! - Vector3 offsetr; // = offset * partIRot; - // KF: In a linkset, offsetr needs to be relative to the group root! 091208 - // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); - // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. - // { // Single, or Root prim of linkset, target is ClickOffset * RootRot - //offsetr = offset * partIRot; -// - // } - // else - // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) - // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + - // (offset * partRot); - // } - -//Console.WriteLine(" "); -//Console.WriteLine("link number ={0}", part.LinkNum); -//Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); -//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); -//Console.WriteLine("Click offst ={0}", offset); -//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); -//Console.WriteLine("offsetr ={0}", offsetr); -//Console.WriteLine("Camera At ={0}", cameraAtOffset); -//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); - - //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child - ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); - - m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target + ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); + m_requestedSitTargetUUID = targetID; + // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though // which happens in HandleAgentSit :P m_autopilotMoving = autopilot; - m_autoPilotTarget = autopilotTarget; + m_autoPilotTarget = pos; m_sitAtAutoTarget = autopilot; - m_initialSitTarget = autopilotTarget; if (!autopilot) HandleAgentSit(remoteClient, UUID); } @@ -2300,9 +2184,9 @@ namespace OpenSim.Region.Framework.Scenes m_requestedSitTargetID = part.LocalId; //m_requestedSitOffset = offset; m_requestedSitTargetUUID = targetID; - + m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - + if (m_scene.PhysicsScene.SupportsRayCast()) { //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); @@ -2521,7 +2405,7 @@ namespace OpenSim.Region.Framework.Scenes HandleAgentSit(remoteClient, agentID, "SIT"); } } - + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); @@ -2532,68 +2416,33 @@ namespace OpenSim.Region.Framework.Scenes { if (part.SitTargetAvatar == UUID) { -//Console.WriteLine("Scripted Sit"); - // Scripted sit Vector3 sitTargetPos = part.SitTargetPosition; Quaternion sitTargetOrient = part.SitTargetOrientation; - m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); - m_pos += SIT_TARGET_ADJUSTMENT; - if (!part.IsRoot) - { - m_pos *= part.RotationOffset; - } - m_bodyRot = sitTargetOrient; - m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); + +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Sitting {0} at sit target {1}, {2} on {3} {4}", +// Name, sitTargetPos, sitTargetOrient, part.Name, part.LocalId); + + //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); + //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); + + //Quaternion result = (sitTargetOrient * vq) * nq; + + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + Rotation = sitTargetOrient; + ParentPosition = part.AbsolutePosition; } else { - // if m_avUnscriptedSitPos is zero then Av sits above center - // Else Av sits at m_avUnscriptedSitPos - - // Non-scripted sit by Kitto Flora 21Nov09 - // Calculate angle of line from prim to Av - Quaternion partIRot; -// if (part.LinkNum == 1) -// { // Root prim of linkset -// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); -// } -// else -// { // single or child prim - partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; - float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); - float x_diff = ( m_avInitialPos.X - sitTargetPos.X); - if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 - if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 - float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); - // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. - // Av sits at world euler <0,0, z>, translated by part rotation - m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click - - m_parentPosition = part.AbsolutePosition; - part.IsOccupied = true; - part.ParentGroup.AddAvatar(agentID); - m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation - (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center - (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + - m_avUnscriptedSitPos; // adds click offset, if any - //Set up raytrace to find top surface of prim - Vector3 size = part.Scale; - float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); - Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); - Vector3 down = new Vector3(0f, 0f, -1f); -//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); - m_scene.PhysicsScene.RaycastWorld( - start, // Vector3 position, - down, // Vector3 direction, - mag, // float length, - SitAltitudeCallback); // retMethod - } // end scripted/not + m_pos -= part.AbsolutePosition; + ParentPosition = part.AbsolutePosition; + +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", +// Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); + } } - else // no Av + else { return; } @@ -2601,58 +2450,12 @@ namespace OpenSim.Region.Framework.Scenes ParentID = m_requestedSitTargetID; - //We want our offsets to reference the root prim, not the child we may have sat on - if (!part.IsRoot) - { - m_parentID = part.ParentGroup.RootPart.LocalId; - m_pos += part.OffsetPosition; - } - else - { - m_parentID = m_requestedSitTargetID; - } - - if (part.SitTargetAvatar != UUID) - { - m_offsetRotation = m_offsetRotation / part.RotationOffset; - } Velocity = Vector3.Zero; RemoveFromPhysicalScene(); + Animator.TrySetMovementAnimation(sitAnimation); SendAvatarDataToAllAgents(); } - - public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) - { - // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer - // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. - if(hitYN) - { - // m_pos = Av offset from prim center to make look like on center - // m_parentPosition = Actual center pos of prim - // collisionPoint = spot on prim where we want to sit - // collisionPoint.Z = global sit surface height - SceneObjectPart part = m_scene.GetSceneObjectPart(localid); - Quaternion partIRot; -// if (part.LinkNum == 1) -/// { // Root prim of linkset -// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); -// } -// else -// { // single or child prim - partIRot = Quaternion.Inverse(part.GetWorldRotation()); -// } - if (m_initialSitTarget != null) - { - float offZ = collisionPoint.Z - m_initialSitTarget.Z; - Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction - //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); - m_pos += offset; - // ControllingClient.SendClearFollowCamProperties(part.UUID); - } - - } - } // End SitAltitudeCallback KF. /// /// Event handler for the 'Always run' setting on the client -- cgit v1.1 From 1a6b2a6429639a411c86065379341f8e452ff10a Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 20:17:02 +0000 Subject: Change comment formatting to match core for a cleaner diff --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 64b2ddb..d730bbf 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1681,21 +1681,21 @@ namespace OpenSim.Region.Framework.Scenes // which occurs later in the main scene loop if (update_movementflag || (update_rotation && DCFlagKeyPressed)) { - // m_log.DebugFormat( - // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", - // m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", +// m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); AddNewMovement(agent_control_v3); } - // else - // { - // if (!update_movementflag) - // { - // m_log.DebugFormat( - // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", - // m_scene.RegionInfo.RegionName, agent_control_v3, Name); - // } - // } +// else +// { +// if (!update_movementflag) +// { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", +// m_scene.RegionInfo.RegionName, agent_control_v3, Name); +// } +// } if (update_movementflag && ParentID == 0) Animator.UpdateMovementAnimations(); @@ -1714,20 +1714,20 @@ namespace OpenSim.Region.Framework.Scenes /// True if movement has been updated in some way. False otherwise. public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) { - // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); +// m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); bool updated = false; - // m_log.DebugFormat( - // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", - // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", +// allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); if (!m_autopilotMoving) { double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); - // m_log.DebugFormat( - // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", - // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", +// Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); // Check the error term of the current position in relation to the target position if (distanceToTarget <= 1) @@ -1750,7 +1750,7 @@ namespace OpenSim.Region.Framework.Scenes (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords // Ignore z component of vector - // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); +// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); LocalVectorToTarget3D.Normalize(); // update avatar movement flags. the avatar coordinate system is as follows: @@ -1816,9 +1816,9 @@ namespace OpenSim.Region.Framework.Scenes updated = true; } - // m_log.DebugFormat( - // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", - // LocalVectorToTarget3D, agent_control_v3, Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", +// LocalVectorToTarget3D, agent_control_v3, Name); agent_control_v3 += LocalVectorToTarget3D; } -- cgit v1.1 From 506653ff0031cade99d496be9ce733a0460c8597 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 20:32:20 +0000 Subject: Some trivial changes to get closer to core --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d730bbf..86e557e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes // { // m_log.Debug("[SCENE PRESENCE] Destructor called"); // } - + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public PresenceType PresenceType { get; private set; } @@ -90,8 +90,6 @@ namespace OpenSim.Region.Framework.Scenes /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis /// issue #1716 /// -// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); - // Value revised by KF 091121 by comparison with SL. public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); /// @@ -120,7 +118,6 @@ namespace OpenSim.Region.Framework.Scenes /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is /// necessary. /// - protected List m_attachments = new List(); public Object AttachmentsSyncLock { get; private set; } @@ -134,11 +131,8 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; public Vector4 CollisionPlane = Vector4.UnitW; - - private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation - private Vector3 m_avUnscriptedSitPos; // for non-scripted prims + private Vector3 m_lastPosition; - private Vector3 m_lastWorldPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; //private int m_lastTerseSent; @@ -149,6 +143,9 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_userFlags; } } + private bool m_flyingOld; // add for fly velocity control + public bool m_wasFlying; // add for fly velocity control + private TeleportFlags m_teleportFlags; public TeleportFlags TeleportFlags { @@ -171,9 +168,6 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastChildAgentUpdatePosition; private Vector3 m_lastChildAgentUpdateCamPosition; - private bool m_flyingOld; // add for fly velocity control - public bool m_wasFlying; // add for fly velocity control - private const int LAND_VELOCITYMAG_MAX = 12; public bool IsRestrictedToRegion; @@ -199,7 +193,6 @@ namespace OpenSim.Region.Framework.Scenes private bool m_autopilotMoving; private Vector3 m_autoPilotTarget; private bool m_sitAtAutoTarget; - private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit private string m_nextSitAnimation = String.Empty; -- cgit v1.1 From cc8e693fb9c00b24ccdde586324bbcc30ac218e6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 20:39:43 +0000 Subject: Remove unused and broken OffsetRotation from ScenePresence --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 33 +++--------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 86e557e..19e6a20 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -199,7 +199,6 @@ namespace OpenSim.Region.Framework.Scenes //PauPaw:Proper PID Controler for autopilot************ public bool MovingToTarget { get; private set; } public Vector3 MoveToPositionTarget { get; private set; } - private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); /// /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying). @@ -612,39 +611,15 @@ namespace OpenSim.Region.Framework.Scenes } } - public Quaternion OffsetRotation - { - get { return m_offsetRotation; } - set { m_offsetRotation = value; } - } private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation { - get { - if (m_parentID != 0) - { - if (m_offsetRotation != null) - { - return m_offsetRotation; - } - else - { - return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } - - } - else - { - return m_bodyRot; - } - } - set { + get { return m_bodyRot; } + set + { m_bodyRot = value; - if (m_parentID != 0) - { - m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); - } +// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); } } -- cgit v1.1 From 0f279b1187e0c518f5feb08a2824d1f718154a67 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 21:23:25 +0000 Subject: Some more changes to catch up with core --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 120 +++++++++-------------- 1 file changed, 49 insertions(+), 71 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 19e6a20..a1fc1c0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -146,6 +146,11 @@ namespace OpenSim.Region.Framework.Scenes private bool m_flyingOld; // add for fly velocity control public bool m_wasFlying; // add for fly velocity control + private int m_lastColCount = -1; //KF: Look for Collision chnages + private int m_updateCount = 0; //KF: Update Anims for a while + private static readonly int UPDATE_COUNT = 10; // how many frames to update for + private List m_lastColliders = new List(); + private TeleportFlags m_teleportFlags; public TeleportFlags TeleportFlags { @@ -208,13 +213,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_followCamAuto; private int m_movementUpdateCount; - private int m_lastColCount = -1; //KF: Look for Collision chnages - private int m_updateCount = 0; //KF: Update Anims for a while - private static readonly int UPDATE_COUNT = 10; // how many frames to update for private const int NumMovementsBetweenRayCast = 5; - private List m_lastColliders = new List(); - - private object m_syncRoot = new Object(); private bool CameraConstraintActive; //private int m_moveToPositionStateStatus; @@ -255,7 +254,7 @@ namespace OpenSim.Region.Framework.Scenes DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, - DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, + DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG @@ -496,11 +495,9 @@ namespace OpenSim.Region.Framework.Scenes { get { - PhysicsActor actor = m_physicsActor; -// if (actor != null) - if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! - { - m_pos = actor.Position; + if (PhysicsActor != null && m_parentID == 0) + { + m_pos = PhysicsActor.Position; // m_log.DebugFormat( // "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!", @@ -551,10 +548,8 @@ namespace OpenSim.Region.Framework.Scenes } } -// Changed this to update unconditionally to make npose work -// if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! - m_pos = value; - m_parentPosition = Vector3.Zero; + m_pos = value; + ParentPosition = Vector3.Zero; // m_log.DebugFormat( // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", @@ -637,15 +632,12 @@ namespace OpenSim.Region.Framework.Scenes set { m_isChildAgent = value; } } - private uint m_parentID; - - public uint ParentID { get { return m_parentID; } set { m_parentID = value; } } - + private uint m_parentID; public float Health { @@ -797,7 +789,10 @@ namespace OpenSim.Region.Framework.Scenes m_reprioritization_timer.AutoReset = false; AdjustKnownSeeds(); + + // TODO: I think, this won't send anything, as we are still a child here... Animator.TrySetMovementAnimation("STAND"); + // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) @@ -861,7 +856,7 @@ namespace OpenSim.Region.Framework.Scenes vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE return vector; } - + #endregion public uint GenerateClientFlags(UUID ObjectID) @@ -876,8 +871,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendPrimUpdates() { - m_sceneViewer.SendPrimUpdates(); - SceneViewer.SendPrimUpdates(); } @@ -1117,11 +1110,11 @@ namespace OpenSim.Region.Framework.Scenes { try { - m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; - m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; + PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - m_physicsActor.UnSubscribeEvents(); + PhysicsActor.UnSubscribeEvents(); + PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; PhysicsActor = null; } catch @@ -1146,7 +1139,6 @@ namespace OpenSim.Region.Framework.Scenes AddToPhysicalScene(isFlying); SendTerseUpdateToAllClients(); - } public void TeleportWithMomentum(Vector3 pos) @@ -1364,12 +1356,11 @@ namespace OpenSim.Region.Framework.Scenes /// /// This is the event handler for client movement. If a client is moving, this event is triggering. /// - /// - /// This is the event handler for client movement. If a client is moving, this event is triggering. - /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { - // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} received agent update from {1}", +// Scene.RegionInfo.RegionName, remoteClient.Name); //if (IsChildAgent) //{ @@ -1570,7 +1561,7 @@ namespace OpenSim.Region.Framework.Scenes if ((MovementFlag & (byte)(uint)DCF) == 0) { - if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) + if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) { MovementFlag |= (byte)nudgehack; } @@ -1582,13 +1573,13 @@ namespace OpenSim.Region.Framework.Scenes } else { - if ((m_movementflag & (byte)(uint)DCF) != 0 || - ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) - && ((m_movementflag & (byte)nudgehack) == nudgehack)) + if ((MovementFlag & (byte)(uint)DCF) != 0 || + ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) + && ((MovementFlag & (byte)nudgehack) == nudgehack)) ) // This or is for Nudge forward { - // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with lack of {1}", Name, DCF); - m_movementflag -= ((byte)(uint)DCF); +// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); + MovementFlag -= ((byte)(uint)DCF); update_movementflag = true; /* @@ -1818,9 +1809,9 @@ namespace OpenSim.Region.Framework.Scenes if (SitGround) StandUp(); -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", -// Name, pos, m_scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", + Name, pos, m_scene.RegionInfo.RegionName); if (pos.X < 0 || pos.X >= Constants.RegionSize || pos.Y < 0 || pos.Y >= Constants.RegionSize @@ -1846,9 +1837,9 @@ namespace OpenSim.Region.Framework.Scenes if (pos.Z - terrainHeight < 0.2) pos.Z = terrainHeight; -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", -// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", + Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); if (noFly) PhysicsActor.Flying = false; @@ -1884,7 +1875,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ResetMoveToTarget() { -// m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); + m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); MovingToTarget = false; MoveToPositionTarget = Vector3.Zero; @@ -2548,9 +2539,6 @@ namespace OpenSim.Region.Framework.Scenes CheckForSignificantMovement(); // sends update to the modules. } - - //Sending prim updates AFTER the avatar terse updates are sent - SendPrimUpdates(); } #endregion @@ -3268,7 +3256,6 @@ namespace OpenSim.Region.Framework.Scenes m_callbackURI = cAgent.CallbackURI; m_pos = cAgent.Position; - m_velocity = cAgent.Velocity; CameraPosition = cAgent.Center; CameraAtAxis = cAgent.AtAxis; @@ -3415,14 +3402,14 @@ namespace OpenSim.Region.Framework.Scenes //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene - if (Animator!=null) + if (Animator != null) { - if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, - { // else its will lock out other animation changes, like ground sit. - Animator.UpdateMovementAnimations(); - m_updateCount--; - } - } + if (m_updateCount > 0) + { + Animator.UpdateMovementAnimations(); + m_updateCount--; + } + } CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; @@ -3431,12 +3418,12 @@ namespace OpenSim.Region.Framework.Scenes // No collisions at all means we may be flying. Update always // to make falling work - if (m_lastColCount != coldata.Count || coldata.Count == 0) - { - m_updateCount = UPDATE_COUNT; - m_lastColCount = coldata.Count; - } - + if (m_lastColCount != coldata.Count || coldata.Count == 0) + { + m_updateCount = UPDATE_COUNT; + m_lastColCount = coldata.Count; + } + if (coldata.Count != 0 && Animator != null) { switch (Animator.CurrentMovementAnimation) @@ -4047,15 +4034,6 @@ namespace OpenSim.Region.Framework.Scenes } } - private Vector3 Quat2Euler(Quaternion rot){ - float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , - (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); - float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); - float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , - (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); - return(new Vector3(x,y,z)); - } - private void CheckLandingPoint(ref Vector3 pos) { // Never constrain lures -- cgit v1.1 From 9c6025f928302b0242aa1887071e5e3f96bae90e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 21:53:05 +0000 Subject: Adapt to the core SP rework --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 175e8ed..cc96b24 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -262,7 +262,7 @@ TrySetMovementAnimation("STAND"); m_animTickFall = Environment.TickCount; } // else if (!jumping && fallElapsed > FALL_DELAY) - else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.m_wasFlying)) // add for falling and jumping + else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) // add for falling and jumping { // Falling long enough to trigger the animation //Console.WriteLine("FALLDOWN"); //## diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a1fc1c0..cca55be 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -144,7 +144,11 @@ namespace OpenSim.Region.Framework.Scenes get { return m_userFlags; } } private bool m_flyingOld; // add for fly velocity control - public bool m_wasFlying; // add for fly velocity control + public bool WasFlying + { + get { return m_wasFlying; } + } + private bool m_wasFlying; // add for fly velocity control private int m_lastColCount = -1; //KF: Look for Collision chnages private int m_updateCount = 0; //KF: Update Anims for a while -- cgit v1.1 From 8fb6ae379ae830da0b52b1825ec74fbcded5981b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:05:27 +0000 Subject: Change m_falling public to a getter property. --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 6 +++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index cc96b24..c39f34f 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -66,7 +66,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation public bool m_jumping = false; // Add for jumping public float m_jumpVelocity = 0f; // Add for jumping private int m_landing = 0; // Add for jumping - public bool m_falling = false; // Add for falling + public bool Falling + { + get { return m_falling; } + } + private bool m_falling = false; // Add for falling private float m_fallHeight; // Add for falling /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cca55be..1067b9d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2479,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop Flying"); //} } - if (Animator.m_falling && m_wasFlying) // if falling from flying, disable motion add + if (Animator.Falling && m_wasFlying) // if falling from flying, disable motion add { direc *= 0.0f; } -- cgit v1.1 From 534560df8c9f59eb416cb7415ac7055c459da339 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 23:31:20 +0100 Subject: Remove backup optimization that was causing prim contents to poof --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 07e303f..309f543 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1122,14 +1122,19 @@ namespace OpenSim.Region.Framework.Scenes /// public void ProcessInventoryBackup(ISimulationDataService datastore) { - if (HasInventoryChanged) - { +// Removed this because linking will cause an immediate delete of the new +// child prim from the database and the subsequent storing of the prim sees +// the inventory of it as unchanged and doesn't store it at all. The overhead +// of storing prim inventory needlessly is much less than the aggravation +// of prim inventory loss. +// if (HasInventoryChanged) +// { Items.LockItemsForRead(true); datastore.StorePrimInventory(m_part.UUID, Items.Values); Items.LockItemsForRead(false); HasInventoryChanged = false; - } +// } } public class InventoryStringBuilder -- cgit v1.1 From 5517e210682b329152e4face3a59945ff6d71c25 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:34:36 +0000 Subject: Harmonize with core and remove extraneous comments with no information in them --- .../Scenes/Animation/ScenePresenceAnimator.cs | 144 ++++++--------------- 1 file changed, 39 insertions(+), 105 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index c39f34f..68e405e 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -58,20 +58,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation { get { return m_movementAnimation; } } - // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist! - protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init. + protected string m_movementAnimation = "CROUCH"; private int m_animTickFall; -// private int m_animTickJump; public int m_animTickJump; // ScenePresence has to see this to control +Z force - public bool m_jumping = false; // Add for jumping - public float m_jumpVelocity = 0f; // Add for jumping - private int m_landing = 0; // Add for jumping + public bool m_jumping = false; + public float m_jumpVelocity = 0f; + private int m_landing = 0; public bool Falling { get { return m_falling; } } - private bool m_falling = false; // Add for falling - private float m_fallHeight; // Add for falling + private bool m_falling = false; + private float m_fallHeight; /// /// The scene presence that this animator applies to @@ -133,9 +131,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void ResetAnimations() { -Console.WriteLine("ResetA............."); m_animations.Clear(); -TrySetMovementAnimation("STAND"); + TrySetMovementAnimation("STAND"); } /// @@ -165,16 +162,11 @@ TrySetMovementAnimation("STAND"); /// public string GetMovementAnimation() { -//Console.WriteLine("GMA-------"); //## -//#@ const float FALL_DELAY = 0.33f; - const float FALL_DELAY = 800f; //## mS -//rm for jumping const float PREJUMP_DELAY = 0.25f; - const float PREJUMP_DELAY = 200f; // mS add for jumping - const float JUMP_PERIOD = 800f; // mS add for jumping + const float FALL_DELAY = 800f; + const float PREJUMP_DELAY = 200f; + const float JUMP_PERIOD = 800f; #region Inputs - AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; -// m_log.DebugFormat("[ANIM]: Control flags: {0}", controlFlags); PhysicsActor actor = m_scenePresence.PhysicsActor; // Create forward and left vectors from the current avatar rotation @@ -196,16 +188,15 @@ TrySetMovementAnimation("STAND"); // Direction in which the avatar is trying to move Vector3 move = Vector3.Zero; + if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } if (heldLeft) { move.X += left.X; move.Y += left.Y; } if (heldRight) { move.X -= left.X; move.Y -= left.Y; } if (heldUp) { move.Z += 1; } if (heldDown) { move.Z -= 1; } - if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } // Is the avatar trying to move? // bool moving = (move != Vector3.Zero); -// rm for jumping bool jumping = m_animTickJump != 0; #endregion Inputs #region Flying @@ -214,10 +205,10 @@ TrySetMovementAnimation("STAND"); { m_animTickFall = 0; m_animTickJump = 0; - m_jumping = false; //add for jumping - m_falling = true; //add for falling - m_jumpVelocity = 0f; //add for jumping - actor.Selected = false; //add for jumping flag + m_jumping = false; + m_falling = true; + m_jumpVelocity = 0f; + actor.Selected = false; m_fallHeight = actor.Position.Z; // save latest flying height if (move.X != 0f || move.Y != 0f) @@ -231,10 +222,9 @@ TrySetMovementAnimation("STAND"); else if (move.Z < 0f) { if (actor != null && actor.IsColliding) - { //## -//Console.WriteLine("LAND FLYING"); // ## + { return "LAND"; - } //# + } else return "HOVER_DOWN"; } @@ -248,28 +238,22 @@ TrySetMovementAnimation("STAND"); #region Falling/Floating/Landing -// rm for jumping if (actor == null || !actor.IsColliding) - if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping + if ((actor == null || !actor.IsColliding) && !m_jumping) { -// rm float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - float fallElapsed = (float)(Environment.TickCount - m_animTickFall); // add, in mS + float fallElapsed = (float)(Environment.TickCount - m_animTickFall); float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; -//Console.WriteLine("falling t={0} v={1}", fallElapsed, fallVelocity); //## -// rm for fall if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) - if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; // add for falling and jumping + if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; - if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) // add for jumping - // not falling yet or going up + if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) { + // not falling yet, or going up // reset start of fall time m_animTickFall = Environment.TickCount; } -// else if (!jumping && fallElapsed > FALL_DELAY) - else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) // add for falling and jumping + else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) { // Falling long enough to trigger the animation -//Console.WriteLine("FALLDOWN"); //## return "FALLDOWN"; } @@ -287,12 +271,11 @@ TrySetMovementAnimation("STAND"); if ((move.Z > 0f) && (!m_jumping)) { -//Console.WriteLine("PJ {0}", jumptime); //## // Start jumping, prejump m_animTickFall = 0; m_jumping = true; m_falling = false; - actor.Selected = true; // borrowed for jmping flag + actor.Selected = true; // borrowed for jumping flag m_animTickJump = Environment.TickCount; m_jumpVelocity = 0.35f; return "PREJUMP"; @@ -302,7 +285,6 @@ TrySetMovementAnimation("STAND"); { if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) { -//Console.WriteLine("LA {0}", jumptime); //## // end jumping m_jumping = false; m_falling = false; @@ -313,14 +295,12 @@ TrySetMovementAnimation("STAND"); } else if (jumptime > JUMP_PERIOD) { -//Console.WriteLine("JD {0}", jumptime); //## // jump down m_jumpVelocity = 0f; return "JUMP"; } else if (jumptime > PREJUMP_DELAY) { -//Console.WriteLine("JU {0}", jumptime); //## // jump up m_jumping = true; m_jumpVelocity = 10f; @@ -328,7 +308,7 @@ TrySetMovementAnimation("STAND"); } } - #endregion Jumping // end added section + #endregion Jumping #region Ground Movement @@ -338,72 +318,36 @@ TrySetMovementAnimation("STAND"); m_animTickFall = Environment.TickCount; // TODO: SOFT_LAND support float fallHeight = m_fallHeight - actor.Position.Z; -//Console.WriteLine("Hit from {0}", fallHeight); //## - if (fallHeight > 15.0f) // add for falling + if (fallHeight > 15.0f) return "STANDUP"; - else if (fallHeight > 8.0f) // add for falling - return "SOFT_LAND"; // add for falling - else // add for falling - return "LAND"; // add for falling + else if (fallHeight > 8.0f) + return "SOFT_LAND"; + else + return "LAND"; } -// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; -// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) -// rm for landing return "LAND"; else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) { - int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping - int limit = 1000; // add for jumping - if(m_movementAnimation == "LAND") limit = 350; // add for jumping + int landElapsed = Environment.TickCount - m_animTickFall; + int limit = 1000; + if(m_movementAnimation == "LAND") limit = 350; // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client - if ((m_animTickFall != 0) && (landElapsed <= limit)) // add for jumping + if ((m_animTickFall != 0) && (landElapsed <= limit)) { -//Console.WriteLine("Lelapse {0}", m_movementAnimation); //## return m_movementAnimation; } else { -//Console.WriteLine("end/STAND"); //## m_fallHeight = actor.Position.Z; // save latest flying height return "STAND"; } } -/* This section removed, replaced by jumping section - m_animTickFall = 0; - - if (move.Z > 0.2f) - { - // Jumping - if (!jumping) - { - // Begin prejump - m_animTickJump = Environment.TickCount; - return "PREJUMP"; - } - else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 800.0f) - { - // Start actual jump - if (m_animTickJump == -1) - { - // Already jumping! End the current jump - m_animTickJump = 0; - return "JUMP"; - } - m_animTickJump = -1; - return "JUMP"; - } - } - else - { - // Not jumping - m_animTickJump = 0; - */ // next section moved outside paren. and realigned for jumping if (move.X != 0f || move.Y != 0f) { m_fallHeight = actor.Position.Z; // save latest flying height - m_falling = false; // Add for falling + m_falling = false; // Walking / crouchwalking / running if (move.Z < 0f) return "CROUCHWALK"; @@ -412,10 +356,9 @@ TrySetMovementAnimation("STAND"); else return "WALK"; } -// rm for jumping else - else if (!m_jumping) // add for jumping + else if (!m_jumping) { - m_falling = false; // Add for falling + m_falling = false; // Not walking if (move.Z < 0) return "CROUCH"; @@ -426,10 +369,9 @@ TrySetMovementAnimation("STAND"); else return "STAND"; } - // end section realign for jumping #endregion Ground Movement - m_falling = false; // Add for falling + m_falling = false; return m_movementAnimation; } @@ -439,15 +381,7 @@ TrySetMovementAnimation("STAND"); public void UpdateMovementAnimations() { m_movementAnimation = GetMovementAnimation(); -/* if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) - { - // This was the previous behavior before PREJUMP - TrySetMovementAnimation("JUMP"); - } - else - { removed for jumping */ - TrySetMovementAnimation(m_movementAnimation); -// rm for jumping } + TrySetMovementAnimation(m_movementAnimation); } public UUID[] GetAnimationArray() -- cgit v1.1 From 9bded61ca46fb6e4aa8a55f28e4eb21600711b92 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:48:32 +0000 Subject: Whitespace fix from core --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 68e405e..05cdf61 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -166,6 +166,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation const float PREJUMP_DELAY = 200f; const float JUMP_PERIOD = 800f; #region Inputs + AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; PhysicsActor actor = m_scenePresence.PhysicsActor; -- cgit v1.1 From 57194facdc4aae3b9498041aad56d4f1942225fc Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 23:06:59 +0000 Subject: Fix up with core changes --- OpenSim/Region/Framework/Scenes/Scene.cs | 1 - OpenSim/Region/Framework/Scenes/ScenePresence.cs | 87 +++++++++--------------- 2 files changed, 31 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5d4ddea..42ce61e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -675,7 +675,6 @@ namespace OpenSim.Region.Framework.Scenes m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); - m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 76bc390..f3af808 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -920,61 +920,7 @@ namespace OpenSim.Region.Framework.Scenes pos.Y = crossedBorder.BorderLine.Z - 1; } - ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (land != null) - { - // If we come in via login, landmark or map, we want to - // honor landing points. If we come in via Lure, we want - // to ignore them. - if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || - (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || - (m_teleportFlags & TeleportFlags.ViaLocation) != 0) - { - // Don't restrict gods, estate managers, or land owners to - // the TP point. This behaviour mimics agni. - if (land.LandData.LandingType == (byte)LandingType.LandingPoint && - land.LandData.UserLocation != Vector3.Zero && - GodLevel < 200 && - ((land.LandData.OwnerID != m_uuid && - (!m_scene.Permissions.IsGod(m_uuid)) && - (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) - { - pos = land.LandData.UserLocation; - } - } - - land.SendLandUpdateToClient(ControllingClient); - } - - if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) - { - Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); - - if (pos.X < 0) - { - emergencyPos.X = (int)Constants.RegionSize + pos.X; - if (!(pos.Y < 0)) - emergencyPos.Y = pos.Y; - if (!(pos.Z < 0)) - emergencyPos.Z = pos.Z; - } - if (pos.Y < 0) - { - emergencyPos.Y = (int)Constants.RegionSize + pos.Y; - if (!(pos.X < 0)) - emergencyPos.X = pos.X; - if (!(pos.Z < 0)) - emergencyPos.Z = pos.Z; - } - if (pos.Z < 0) - { - emergencyPos.Z = 128; - if (!(pos.Y < 0)) - emergencyPos.Y = pos.Y; - if (!(pos.X < 0)) - emergencyPos.X = pos.X; - } - } + CheckAndAdjustLandingPoint(ref pos); if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) { @@ -1815,7 +1761,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", - Name, pos, m_scene.RegionInfo.RegionName); +// Name, pos, m_scene.RegionInfo.RegionName); if (pos.X < 0 || pos.X >= Constants.RegionSize || pos.Y < 0 || pos.Y >= Constants.RegionSize @@ -4062,5 +4008,34 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAlertMessage("Can't teleport closer to destination"); } } + + private void CheckAndAdjustLandingPoint(ref Vector3 pos) + { + ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + // If we come in via login, landmark or map, we want to + // honor landing points. If we come in via Lure, we want + // to ignore them. + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || + (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0) + { + // Don't restrict gods, estate managers, or land owners to + // the TP point. This behaviour mimics agni. + if (land.LandData.LandingType == (byte)LandingType.LandingPoint && + land.LandData.UserLocation != Vector3.Zero && + GodLevel < 200 && + ((land.LandData.OwnerID != m_uuid && + (!m_scene.Permissions.IsGod(m_uuid)) && + (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) + { + pos = land.LandData.UserLocation; + } + } + + land.SendLandUpdateToClient(ControllingClient); + } + } } } -- cgit v1.1 From 89a1d7c37c2097a4aede038feadab9dc945faa61 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 23:37:43 +0000 Subject: Break out the parts of ScenePresence that differ from core --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 287 ++++++++++++----------- 1 file changed, 146 insertions(+), 141 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f3af808..0e29b60 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3403,147 +3403,7 @@ namespace OpenSim.Region.Framework.Scenes } } - List thisHitColliders = new List(); - List endedColliders = new List(); - List startedColliders = new List(); - - foreach (uint localid in coldata.Keys) - { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) - { - endedColliders.Add(localID); - } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); - } - - // do event notification - if (startedColliders.Count > 0) - { - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - StartCollidingMessage.Colliders = colliding; - - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); - } - } - - if (endedColliders.Count > 0) - { - ColliderArgs EndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in endedColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - EndCollidingMessage.Colliders = colliding; - - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); - } - } - - if (thisHitColliders.Count > 0) - { - ColliderArgs CollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in thisHitColliders) - { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - CollidingMessage.Colliders = colliding; - - lock (m_attachments) - { - foreach (SceneObjectGroup att in m_attachments) - Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); - } - } - } + RaiseCollisionScriptEvents(coldata); if (Invulnerable) return; @@ -4037,5 +3897,150 @@ namespace OpenSim.Region.Framework.Scenes land.SendLandUpdateToClient(ControllingClient); } } + + private void RaiseCollisionScriptEvents(Dictionary coldata) + { + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); + + foreach (uint localid in coldata.Keys) + { + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + { + startedColliders.Add(localid); + } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } + + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) + { + endedColliders.Add(localID); + } + } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } + + // do event notification + if (startedColliders.Count > 0) + { + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in GetAttachments()) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } + } + + if (endedColliders.Count > 0) + { + ColliderArgs EndCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in endedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + EndCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in GetAttachments()) + Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); + } + } + + if (thisHitColliders.Count > 0) + { + ColliderArgs CollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in thisHitColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + CollidingMessage.Colliders = colliding; + + lock (m_attachments) + { + foreach (SceneObjectGroup att in m_attachments) + Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + } + } + } + } } } -- cgit v1.1 From c9179be1ed85528e5580685a07f67d3eb644be35 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Nov 2011 20:16:24 +0100 Subject: Small preformance tweak --- OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 12688bd..218f2c5 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectGroup g in objectGroups) { killIDs.Add(g.LocalId); - g.DeleteGroupFromScene(false); + g.DeleteGroupFromScene(true); } m_scene.SendKillObject(killIDs); -- cgit v1.1 From d40d0e45964444e0a95e400c5d14e0fc647058a6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Nov 2011 23:15:09 +0100 Subject: Fix the ability to move the seated avatar via LSL --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index eb3597d..e2c68fd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1914,6 +1914,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.SitTargetAvatar == UUID) part.SitTargetAvatar = UUID.Zero; + part.ParentGroup.DeleteAvatar(UUID); ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); } @@ -2343,11 +2344,13 @@ namespace OpenSim.Region.Framework.Scenes m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; + part.ParentGroup.AddAvatar(UUID); } else { m_pos -= part.AbsolutePosition; ParentPosition = part.AbsolutePosition; + part.ParentGroup.AddAvatar(UUID); // m_log.DebugFormat( // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", -- cgit v1.1 From 063920e0a2e746f73d5088889951fa45ac10ec38 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 10 Nov 2011 20:26:14 +0100 Subject: Fix misaligned sit animation on scripted sit caused by the default sit animation being run after the scripted one. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e2c68fd..bb19621 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2019,8 +2019,6 @@ namespace OpenSim.Region.Framework.Scenes sitOrientation = avSitOrientation; autopilot = false; } - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - pos = part.AbsolutePosition + offset; //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) //{ @@ -2066,6 +2064,12 @@ namespace OpenSim.Region.Framework.Scenes m_sitAtAutoTarget = autopilot; if (!autopilot) HandleAgentSit(remoteClient, UUID); + + // Moved here to avoid a race with default sit anim + // The script event needs to be raised after the default sit anim is set. + if (part != null) + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); + } // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) -- cgit v1.1 From 81fbe7ffb16cddd568a5d4969782a9b679f10d4d Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 10 Nov 2011 22:34:54 +0100 Subject: Implement nudging support for strafing motion --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bb19621..c4bd016 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1514,7 +1514,8 @@ namespace OpenSim.Region.Framework.Scenes if ((MovementFlag & (byte)(uint)DCF) == 0) { - if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) + if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE || + DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT_NUDGE) { MovementFlag |= (byte)nudgehack; } @@ -1527,7 +1528,8 @@ namespace OpenSim.Region.Framework.Scenes else { if ((MovementFlag & (byte)(uint)DCF) != 0 || - ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) + ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE || + DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT_NUDGE) && ((MovementFlag & (byte)nudgehack) == nudgehack)) ) // This or is for Nudge forward { -- cgit v1.1 From 008b213ec092aafa59fde39c3e150bfebdac23fe Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 10 Nov 2011 23:15:03 +0100 Subject: Fix turn left and turn right properly. Works for both built-ins and LSL AOs --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 17 +++++++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++++ 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 05cdf61..4cf854e 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -180,12 +180,17 @@ namespace OpenSim.Region.Framework.Scenes.Animation bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); - //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; - //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; + bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; + bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; + if (heldForward || heldBack || heldLeft || heldRight || heldUp || heldDown) + { + heldTurnLeft = false; + heldTurnRight = false; + } // Direction in which the avatar is trying to move Vector3 move = Vector3.Zero; @@ -363,10 +368,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Not walking if (move.Z < 0) return "CROUCH"; -// else if (heldTurnLeft) -// return "TURNLEFT"; -// else if (heldTurnRight) -// return "TURNRIGHT"; + else if (heldTurnLeft) + return "TURNLEFT"; + else if (heldTurnRight) + return "TURNRIGHT"; else return "STAND"; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c4bd016..fe2dfef 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1392,6 +1392,11 @@ namespace OpenSim.Region.Framework.Scenes if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) m_updateCount = UPDATE_COUNT; + // Make turning in place work + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0 || + (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) + m_updateCount = UPDATE_COUNT; + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); -- cgit v1.1 From a081df75e283cf3c7ae07b598d0fca868a0110a5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 10 Nov 2011 23:59:13 +0100 Subject: Prevent linking objects while they are deeded. On unlinking deeded objects, set LastOwnerID properly so the parts cannot be transferred, circumventing no trans perms --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d780fb3..c16038c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1743,6 +1743,11 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup parentGroup = root.ParentGroup; if (parentGroup == null) return; + + // Cowardly refuse to link to a group owned root + if (parentGroup.OwnerID == parentGroup.GroupID) + return; + Monitor.Enter(m_updateLock); try @@ -1770,11 +1775,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectGroup child in childGroups) { - parentGroup.LinkToGroup(child); + if (parentGroup.OwnerID == child.OwnerID) + { + parentGroup.LinkToGroup(child); - // this is here so physics gets updated! - // Don't remove! Bad juju! Stay away! or fix physics! - child.AbsolutePosition = child.AbsolutePosition; + // this is here so physics gets updated! + // Don't remove! Bad juju! Stay away! or fix physics! + child.AbsolutePosition = child.AbsolutePosition; + } } // We need to explicitly resend the newly link prim's object properties since no other actions @@ -1819,9 +1827,14 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentGroup.PrimCount != 1) // Skip single { if (part.LinkNum < 2) // Root + { rootParts.Add(part); + } else + { + part.LastOwnerID = part.ParentGroup.RootPart.LastOwnerID; childParts.Add(part); + } SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) -- cgit v1.1 From efc6c6db7ce3602660c566f4beaf529d5ea9ec71 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 12 Nov 2011 12:09:28 +0100 Subject: Fix taking or returning locked objects losing permissions for owner --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 6bd9183..c7da4f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -230,6 +230,11 @@ namespace OpenSim.Region.Framework.Scenes public uint GetEffectivePermissions() { + return GetEffectivePermissions(false); + } + + public uint GetEffectivePermissions(bool useBase) + { uint perms=(uint)(PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Move | @@ -241,7 +246,10 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; - ownerMask &= part.OwnerMask; + if (useBase) + ownerMask &= part.BaseMask; + else + ownerMask &= part.OwnerMask; perms &= part.Inventory.MaskEffectivePermissions(); } -- cgit v1.1 From e9c386f6a61124b14219496c9b1696b1819f93d5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 17 Nov 2011 19:15:11 +0100 Subject: Force a sim exit when hearbeat isn't restarting successfully --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 149d2d3..876dfb2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -215,6 +215,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_lastIncoming; private int m_lastOutgoing; private bool m_firstHeartbeat = true; + private int m_hbRestarts = 0; private object m_deleting_scene_object = new object(); @@ -1166,6 +1167,9 @@ namespace OpenSim.Region.Framework.Scenes //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); if (HeartbeatThread != null) { + m_hbRestarts++; + if(m_hbRestarts > 10) + Environment.Exit(1); m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); HeartbeatThread.Abort(); Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); -- cgit v1.1 From 797982ee11fd117e74ff3b09c7b74c1973062c8e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 1 Dec 2011 13:30:10 +0100 Subject: Implement llTransferLindenDollars --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2323335..df54ae2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1171,6 +1171,16 @@ namespace OpenSim.Region.Framework.Scenes if(m_hbRestarts > 10) Environment.Exit(1); m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); + int pid = System.Diagnostics.Process.GetCurrentProcess().Id; + +System.Diagnostics.Process proc = new System.Diagnostics.Process(); +proc.EnableRaisingEvents=false; +proc.StartInfo.FileName = "/bin/kill"; +proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); +proc.Start(); +proc.WaitForExit(); +Thread.Sleep(1000); +Environment.Exit(1); HeartbeatThread.Abort(); Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); HeartbeatThread = null; -- cgit v1.1 From 516c3dfbbbbc361c8cf52e9db15c2cd099d7913a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 1 Dec 2011 16:12:09 +0100 Subject: Remove some debug code that had snuck in --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index df54ae2..171443e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1173,14 +1173,14 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); int pid = System.Diagnostics.Process.GetCurrentProcess().Id; -System.Diagnostics.Process proc = new System.Diagnostics.Process(); -proc.EnableRaisingEvents=false; -proc.StartInfo.FileName = "/bin/kill"; -proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); -proc.Start(); -proc.WaitForExit(); -Thread.Sleep(1000); -Environment.Exit(1); +//System.Diagnostics.Process proc = new System.Diagnostics.Process(); +//proc.EnableRaisingEvents=false; +//proc.StartInfo.FileName = "/bin/kill"; +//proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); +//proc.Start(); +//proc.WaitForExit(); +//Thread.Sleep(1000); +//Environment.Exit(1); HeartbeatThread.Abort(); Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); HeartbeatThread = null; -- cgit v1.1 From 19d6aa2bc98cbeb6df089d89d8fc07a08fbdfec4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 4 Dec 2011 20:16:07 +0100 Subject: Don't allow position update on sitting avatar. Don't bounds check sitting avatars as they will be crossed by the vehicle and not individually --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0eaac64..0dd338e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -547,8 +547,12 @@ namespace OpenSim.Region.Framework.Scenes } } - m_pos = value; - ParentPosition = Vector3.Zero; + // Don't update while sitting + if (ParentID == 0) + { + m_pos = value; + ParentPosition = Vector3.Zero; + } // m_log.DebugFormat( // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", @@ -2758,6 +2762,9 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; + if (ParentID != 0) + return; + Vector3 pos2 = AbsolutePosition; Vector3 vel = Velocity; int neighbor = 0; -- cgit v1.1 From 35800d6a8639c033aa9934b493320ec0ba961fda Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 15:26:22 +0100 Subject: Reinstate setter for OffsetPosition to allow setting the offset by script while seated --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0dd338e..21c9402 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -567,6 +567,13 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 OffsetPosition { get { return m_pos; } + set + { + // There is no offset position when not seated + if (ParentID == 0) + return; + m_pos = value; + } } /// -- cgit v1.1 From 2a8a46a32d49fa6629ae3c35365456e0625e3ba5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 18:32:40 +0100 Subject: Fix CHANGED_TEXTURE and CHANGED_COLOR. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 79 +++++++++++----------- 1 file changed, 40 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 11040b7..c88e1d7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3231,7 +3231,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SetFaceColor(Vector3 color, int face) { - Primitive.TextureEntry tex = Shape.Textures; + // The only way to get a deep copy/ If we don't do this, we can + // mever detect color changes further down. + Byte[] buf = Shape.Textures.GetBytes(); + Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length); Color4 texcolor; if (face >= 0 && face < GetNumberOfSides()) { @@ -3240,8 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); tex.FaceTextures[face].RGBA = texcolor; - UpdateTexture(tex); - TriggerScriptChangedEvent(Changed.COLOR); + UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ALL_SIDES) @@ -3262,8 +3264,7 @@ namespace OpenSim.Region.Framework.Scenes texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); tex.DefaultTexture.RGBA = texcolor; } - UpdateTexture(tex); - TriggerScriptChangedEvent(Changed.COLOR); + UpdateTextureEntry(tex.GetBytes()); return; } } @@ -4585,46 +4586,46 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Update the textures on the part. - /// - /// - /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() - /// not handling RGBA properly. Cycles through, and "fixes" the color - /// info - /// - /// - public void UpdateTexture(Primitive.TextureEntry tex) - { - //Color4 tmpcolor; - //for (uint i = 0; i < 32; i++) - //{ - // if (tex.FaceTextures[i] != null) - // { - // tmpcolor = tex.GetFace((uint) i).RGBA; - // tmpcolor.A = tmpcolor.A*255; - // tmpcolor.R = tmpcolor.R*255; - // tmpcolor.G = tmpcolor.G*255; - // tmpcolor.B = tmpcolor.B*255; - // tex.FaceTextures[i].RGBA = tmpcolor; - // } - //} - //tmpcolor = tex.DefaultTexture.RGBA; - //tmpcolor.A = tmpcolor.A*255; - //tmpcolor.R = tmpcolor.R*255; - //tmpcolor.G = tmpcolor.G*255; - //tmpcolor.B = tmpcolor.B*255; - //tex.DefaultTexture.RGBA = tmpcolor; - UpdateTextureEntry(tex.GetBytes()); - } - - /// /// Update the texture entry for this part. /// /// public void UpdateTextureEntry(byte[] textureEntry) { + Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length); + Primitive.TextureEntry oldTex = Shape.Textures; + + Changed changeFlags = 0; + + for (int i = 0 ; i < GetNumberOfSides(); i++) + { + Primitive.TextureEntryFace newFace = newTex.DefaultTexture; + Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; + + if (oldTex.FaceTextures[i] != null) + oldFace = oldTex.FaceTextures[i]; + if (newTex.FaceTextures[i] != null) + newFace = newTex.FaceTextures[i]; + + Color4 oldRGBA = oldFace.RGBA; + Color4 newRGBA = newFace.RGBA; + + if (oldRGBA.R != newRGBA.R || + oldRGBA.G != newRGBA.G || + oldRGBA.B != newRGBA.B || + oldRGBA.A != newRGBA.A) + changeFlags |= Changed.COLOR; + + if (oldFace.TextureID != newFace.TextureID) + changeFlags |= Changed.TEXTURE; + + // Max change, skip the rest of testing + if (changeFlags == (Changed.TEXTURE | Changed.COLOR)) + break; + } + m_shape.TextureEntry = textureEntry; - TriggerScriptChangedEvent(Changed.TEXTURE); + if (changeFlags != 0) + TriggerScriptChangedEvent(changeFlags); UpdateFlag = UpdateRequired.FULL; ParentGroup.HasGroupChanged = true; -- cgit v1.1 From 6362df1202aa1b44dc576128bcd6afd597046792 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 19:33:25 +0100 Subject: Serialize the Volume Detect field --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +-- .../Framework/Scenes/Serialization/SceneObjectSerializer.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dbf29d0..3bce3c0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -220,8 +220,7 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 RotationAxis = Vector3.One; - public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this - // Certainly this must be a persistant setting finally + public bool VolumeDetectActive; public bool IsWaitingForFirstSpinUpdatePacket; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 680a6fa..5f2f7d8 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -347,6 +347,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); + m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); #endregion #region TaskInventoryXmlProcessors initialization @@ -736,6 +737,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.Buoyancy = (int)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); } + private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) + { + obj.VolumeDetectActive = Util.ReadBoolean(reader); + } + #endregion #region TaskInventoryXmlProcessors @@ -1220,6 +1226,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); + writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); writer.WriteEndElement(); } @@ -1586,4 +1593,4 @@ namespace OpenSim.Region.Framework.Scenes.Serialization #endregion } -} \ No newline at end of file +} -- cgit v1.1 From 5490a3e549c2c1753bf562cef53ad70250731081 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Dec 2011 19:44:45 +0100 Subject: Fix phantom and temp flags not taking --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index dd5e986..cf2161a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2811,11 +2811,11 @@ namespace OpenSim.Region.Framework.Scenes } } - RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, SetVolumeDetect); + RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); for (int i = 0; i < parts.Length; i++) { if (parts[i] != RootPart) - parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, SetVolumeDetect); + parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3bce3c0..0e48515 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4307,6 +4307,9 @@ namespace OpenSim.Region.Framework.Scenes bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); bool wasVD = VolumeDetectActive; +// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD); +// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD); + if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) return; @@ -4336,6 +4339,11 @@ namespace OpenSim.Region.Framework.Scenes SetPhantom = false; } } + else if (wasVD) + { + // Correspondingly, if VD is turned off, also turn off phantom + SetPhantom = false; + } if (UsePhysics && IsJoint()) { -- cgit v1.1 From 00b36eb0fedc8de0d3a3ce9461828970fbd50fd8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 9 Dec 2011 20:55:48 +0100 Subject: Restore the Avination way of position and angle calculation so resizers work again. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0e48515..428fe1c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -682,7 +682,7 @@ namespace OpenSim.Region.Framework.Scenes { // If this is a linkset, we don't want the physics engine mucking up our group position here. PhysicsActor actor = PhysActor; - if (actor != null && ParentID == 0) + if (ParentID == 0) { if (actor != null) m_groupPosition = actor.Position; @@ -1080,10 +1080,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (ParentGroup.IsAttachment) - return GroupPosition; - - return m_offsetPosition + m_groupPosition; + return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); } } -- cgit v1.1 From db98698bbea1777fd3ba50d7c441d581a733addd Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 10 Dec 2011 14:47:00 +0100 Subject: Prevent spurious error message when client tries to move a null item --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 258 +++++++++++---------- 2 files changed, 143 insertions(+), 119 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 83990b1..1746cfe 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1105,6 +1105,10 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetSceneObjectPart(primLocalId); + // Can't move a null item + if (itemId == UUID.Zero) + return; + if (null == part) { m_log.WarnFormat( diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5dda9e1..8ff804b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -214,6 +214,9 @@ namespace OpenSim.Region.Framework.Scenes //private int m_moveToPositionStateStatus; //***************************************************** + private bool m_collisionEventFlag = false; + private object m_collisionEventLock = new Object(); + protected AvatarAppearance m_appearance; public AvatarAppearance Appearance @@ -3860,147 +3863,164 @@ namespace OpenSim.Region.Framework.Scenes private void RaiseCollisionScriptEvents(Dictionary coldata) { - List thisHitColliders = new List(); - List endedColliders = new List(); - List startedColliders = new List(); - - foreach (uint localid in coldata.Keys) - { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) + lock(m_collisionEventLock) { - if (!thisHitColliders.Contains(localID)) - { - endedColliders.Add(localID); - } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); + if (m_collisionEventFlag) + return; + m_collisionEventFlag = true; } - // do event notification - if (startedColliders.Count > 0) + Util.FireAndForget(delegate(object x) { - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) + try { - if (localId == 0) - continue; + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) + foreach (uint localid in coldata.Keys) { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + { + startedColliders.Add(localid); + } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } + + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) + { + endedColliders.Add(localID); + } + } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); } - } - if (colliding.Count > 0) - { - StartCollidingMessage.Colliders = colliding; + // do event notification + if (startedColliders.Count > 0) + { + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); - } - } + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } - if (endedColliders.Count > 0) - { - ColliderArgs EndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in endedColliders) - { - if (localId == 0) - continue; + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); + foreach (SceneObjectGroup att in GetAttachments()) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } } - } - if (colliding.Count > 0) - { - EndCollidingMessage.Colliders = colliding; + if (endedColliders.Count > 0) + { + ColliderArgs EndCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in endedColliders) + { + if (localId == 0) + continue; - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); - } - } + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } - if (thisHitColliders.Count > 0) - { - ColliderArgs CollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in thisHitColliders) - { - if (localId == 0) - continue; + if (colliding.Count > 0) + { + EndCollidingMessage.Colliders = colliding; - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); + foreach (SceneObjectGroup att in GetAttachments()) + Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); + } } - } - - if (colliding.Count > 0) - { - CollidingMessage.Colliders = colliding; - lock (m_attachments) + if (thisHitColliders.Count > 0) { - foreach (SceneObjectGroup att in m_attachments) - Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + ColliderArgs CollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in thisHitColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + CollidingMessage.Colliders = colliding; + + lock (m_attachments) + { + foreach (SceneObjectGroup att in m_attachments) + Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); + } + } } } - } + finally + { + m_collisionEventFlag = false; + } + }); } } } -- cgit v1.1 From 323ffd7a893e76f097487c1ab461923d996dc1ca Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 10 Dec 2011 15:28:32 +0100 Subject: Fix a regression that causes data from the attachments module to fail loading --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8ff804b..4034621 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1058,6 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes if (PhysicsActor != null) isFlying = PhysicsActor.Flying; + m_log.DebugFormat("[SCENE PRESENCCE]: Local teleport, flying = {0}", isFlying); RemoveFromPhysicalScene(); Velocity = Vector3.Zero; CheckLandingPoint(ref pos); -- cgit v1.1 From 943b37b8e66f21cab9c52e6f5120d86085d0179c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Dec 2011 11:08:50 +0100 Subject: Send changed animation event asynchronously --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 31 +++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4034621..32e44fb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3556,26 +3556,29 @@ namespace OpenSim.Region.Framework.Scenes /// The arguments for the event public void SendScriptEventToAttachments(string eventName, Object[] args) { - if (m_scriptEngines.Length == 0) - return; - - lock (m_attachments) + Util.FireAndForget(delegate(object x) { - foreach (SceneObjectGroup grp in m_attachments) + if (m_scriptEngines.Length == 0) + return; + + lock (m_attachments) { - // 16384 is CHANGED_ANIMATION - // - // Send this to all attachment root prims - // - foreach (IScriptModule m in m_scriptEngines) + foreach (SceneObjectGroup grp in m_attachments) { - if (m == null) // No script engine loaded - continue; + // 16384 is CHANGED_ANIMATION + // + // Send this to all attachment root prims + // + foreach (IScriptModule m in m_scriptEngines) + { + if (m == null) // No script engine loaded + continue; - m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); + m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); + } } } - } + }); } internal void PushForce(Vector3 impulse) -- cgit v1.1 From afab4b276ebc87f70307ac65e158bb3489d7634b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Dec 2011 13:51:31 +0100 Subject: Remove spammy log messages when querying sim health --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ad2192d..bfabcc2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1171,8 +1171,8 @@ namespace OpenSim.Region.Framework.Scenes if(m_hbRestarts > 10) Environment.Exit(1); m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); - int pid = System.Diagnostics.Process.GetCurrentProcess().Id; - + +//int pid = System.Diagnostics.Process.GetCurrentProcess().Id; //System.Diagnostics.Process proc = new System.Diagnostics.Process(); //proc.EnableRaisingEvents=false; //proc.StartInfo.FileName = "/bin/kill"; @@ -4630,6 +4630,18 @@ namespace OpenSim.Region.Framework.Scenes health+=1; flags |= 4; } + else + { +int pid = System.Diagnostics.Process.GetCurrentProcess().Id; +System.Diagnostics.Process proc = new System.Diagnostics.Process(); +proc.EnableRaisingEvents=false; +proc.StartInfo.FileName = "/bin/kill"; +proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); +proc.Start(); +proc.WaitForExit(); +Thread.Sleep(1000); +Environment.Exit(1); + } if (flags != 7) return health; -- cgit v1.1 From 8418288e26a8373536fc1993cb3d8ca8a8518a44 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Dec 2011 18:29:54 +0100 Subject: Make m_attachments private --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b1b2dc7..3b85a0f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is /// necessary. /// - protected List m_attachments = new List(); + private List m_attachments = new List(); public Object AttachmentsSyncLock { get; private set; } -- cgit v1.1 From d18a9f22e798e239bf989bad2e261283fd737b73 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Dec 2011 23:43:45 +0100 Subject: Prevent a nasty deadlock on teleport --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 ++++++++++++------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3b85a0f..49acc02 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3135,30 +3135,28 @@ namespace OpenSim.Region.Framework.Scenes catch { } // Attachment objects - lock (m_attachments) - { - if (m_attachments.Count > 0) - { - cAgent.AttachmentObjects = new List(); - cAgent.AttachmentObjectStates = new List(); - // IScriptModule se = m_scene.RequestModuleInterface(); - InTransitScriptStates.Clear(); - - foreach (SceneObjectGroup sog in m_attachments) - { - // We need to make a copy and pass that copy - // because of transfers withn the same sim - ISceneObject clone = sog.CloneForNewScene(); - // Attachment module assumes that GroupPosition holds the offsets...! - ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; - ((SceneObjectGroup)clone).IsAttachment = false; - cAgent.AttachmentObjects.Add(clone); - string state = sog.GetStateSnapshot(); - cAgent.AttachmentObjectStates.Add(state); - InTransitScriptStates.Add(state); - // Let's remove the scripts of the original object here - sog.RemoveScriptInstances(true); - } + List attachments = GetAttachments(); + if (attachments.Count > 0) + { + cAgent.AttachmentObjects = new List(); + cAgent.AttachmentObjectStates = new List(); +// IScriptModule se = m_scene.RequestModuleInterface(); + InTransitScriptStates.Clear(); + + foreach (SceneObjectGroup sog in attachments) + { + // We need to make a copy and pass that copy + // because of transfers withn the same sim + ISceneObject clone = sog.CloneForNewScene(); + // Attachment module assumes that GroupPosition holds the offsets...! + ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; + ((SceneObjectGroup)clone).IsAttachment = false; + cAgent.AttachmentObjects.Add(clone); + string state = sog.GetStateSnapshot(); + cAgent.AttachmentObjectStates.Add(state); + InTransitScriptStates.Add(state); + // Let's remove the scripts of the original object here + sog.RemoveScriptInstances(true); } } } -- cgit v1.1 From 6d1d1c0dbfc01891b2b18ccf3137f995ecfda367 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 13 Dec 2011 00:36:44 +0100 Subject: Comment debug spam --- OpenSim/Region/Framework/Scenes/SceneManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index d73a959..e4eaf3a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -356,7 +356,7 @@ namespace OpenSim.Region.Framework.Scenes public bool TrySetCurrentScene(UUID regionID) { - m_log.Debug("Searching for Region: '" + regionID + "'"); +// m_log.Debug("Searching for Region: '" + regionID + "'"); lock (m_localScenes) { -- cgit v1.1 From 8a9a8ed5c903f3f685dfff2fd81a2c9594a12584 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 17 Dec 2011 12:31:25 +0100 Subject: Fix hit testing link sets properly. Fix raycasting for LSL. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 67eafd5..09cbbfe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -789,6 +789,10 @@ namespace OpenSim.Region.Framework.Scenes EntityIntersection result = new EntityIntersection(); SceneObjectPart[] parts = m_parts.GetArray(); + + // Find closest hit here + float idist = float.MaxValue; + for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; @@ -803,11 +807,6 @@ namespace OpenSim.Region.Framework.Scenes EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); - // This may need to be updated to the maximum draw distance possible.. - // We might (and probably will) be checking for prim creation from other sims - // when the camera crosses the border. - float idist = Constants.RegionSize; - if (inter.HitTF) { // We need to find the closest prim to return to the testcaller along the ray @@ -818,8 +817,9 @@ namespace OpenSim.Region.Framework.Scenes result.obj = part; result.normal = inter.normal; result.distance = inter.distance; + + idist = inter.distance; } - } } return result; -- cgit v1.1 From 5b28e2953061a4a02a4e7c5c1f38b22fca305cc7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 24 Dec 2011 01:40:58 +0100 Subject: Fix camera orientation for sit targets to use the prim actually sat on. Now SL compatible. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 587ef1c..845553a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1978,7 +1978,7 @@ namespace OpenSim.Region.Framework.Scenes forceMouselook = part.GetForceMouselook(); ControllingClient.SendSitResponse( - targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); + part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); m_requestedSitTargetUUID = targetID; -- cgit v1.1 From 32b8fa4a77fb7837b8f583243babca225eac6277 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jan 2012 07:37:09 +0100 Subject: Prevent spurious "CHANGED_POSITION" during region backup --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 48a870e..3b0d1cd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -481,13 +481,14 @@ namespace OpenSim.Region.Framework.Scenes } } SceneObjectPart[] parts = m_parts.GetArray(); + bool triggerScriptEvent = m_rootPart.GroupPosition != val; + if (m_dupeInProgress) + triggerScriptEvent = false; foreach (SceneObjectPart part in parts) { part.GroupPosition = val; - if (!m_dupeInProgress) - { + if (triggerScriptEvent) part.TriggerScriptChangedEvent(Changed.POSITION); - } } if (!m_dupeInProgress) { -- cgit v1.1 From 045f3b8b110780953953b0b5187be69ea75b7c65 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jan 2012 07:37:31 +0100 Subject: Clean up GetWorldPosition --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fa8b1c0..c45cfb8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2015,13 +2015,9 @@ namespace OpenSim.Region.Framework.Scenes axPos *= parentRot; Vector3 translationOffsetPosition = axPos; if(_parentID == 0) - { - return GroupPosition; - } - else - { - return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position - } + return GroupPosition; + else + return ParentGroup.AbsolutePosition + translationOffsetPosition; } /// -- cgit v1.1 From e9296721c74e8d33017efd3974491d62d0a5011d Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jan 2012 08:04:04 +0100 Subject: That needs to be callable from elsewhere! --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d2e0ab0..4de494f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5303,7 +5303,7 @@ Environment.Exit(1); } } - private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) + public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) { RegenerateMaptile(); -- cgit v1.1 From 31dc5aa7287596cfa89112475bcb120f00cde228 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 13:15:04 +0100 Subject: If dragging a script that is no copy from prim inventory into agent inventory, stop it first in scene. If deleting from prims, move to trash rather then making it poof. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1746cfe..e005698 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -996,13 +996,24 @@ namespace OpenSim.Region.Framework.Scenes if (item == null) return; - if (item.Type == 10) + InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); + + // Move the item to trash. If this is a copiable item, only + // a copy will be moved and we will still need to delete + // the item from the prim. If it was no copy, is will be + // deleted by this method. + MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID); + + if (group.GetInventoryItem(localID, itemID) != null) { - part.RemoveScriptEvents(itemID); - EventManager.TriggerRemoveScript(localID, itemID); - } + if (item.Type == 10) + { + part.RemoveScriptEvents(itemID); + EventManager.TriggerRemoveScript(localID, itemID); + } - group.RemoveInventoryItem(localID, itemID); + group.RemoveInventoryItem(localID, itemID); + } part.SendPropertiesToClient(remoteClient); } } @@ -1065,7 +1076,15 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + if (taskItem.Type == 10) + { + part.RemoveScriptEvents(itemId); + EventManager.TriggerRemoveScript(part.LocalId, itemId); + } + part.Inventory.RemoveInventoryItem(itemId); + } } return agentItem; -- cgit v1.1 From d5c5bbe0a171aa35d4a0612317b25c8b4b2a7f51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Jan 2012 23:36:49 +0000 Subject: Update teleport routing to match Avination --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1232d0c..e17d886 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1188,6 +1188,7 @@ namespace OpenSim.Region.Framework.Scenes client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); Vector3 look = Velocity; + if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) { look = new Vector3(0.99f, 0.042f, 0); @@ -3816,7 +3817,7 @@ namespace OpenSim.Region.Framework.Scenes m_reprioritization_called = false; } } - + private void CheckLandingPoint(ref Vector3 pos) { // Never constrain lures -- cgit v1.1 From 5d9e135b5cdf23325448c14086e1a40d0ea6f948 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 12 Jan 2012 01:11:05 +0100 Subject: Remove ViewObjectInventory method unsupported by core --- OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 48beb9c..e1fedf4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -49,7 +49,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); - public delegate bool ViewObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); @@ -117,7 +116,6 @@ namespace OpenSim.Region.Framework.Scenes public event DuplicateObjectHandler OnDuplicateObject; public event EditObjectHandler OnEditObject; public event EditObjectInventoryHandler OnEditObjectInventory; - public event ViewObjectInventoryHandler OnViewObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; public event ReturnObjectsHandler OnReturnObjects; @@ -403,21 +401,6 @@ namespace OpenSim.Region.Framework.Scenes return true; } - public bool CanViewObjectInventory(UUID objectID, UUID editorID) - { - ViewObjectInventoryHandler handler = OnViewObjectInventory; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (ViewObjectInventoryHandler h in list) - { - if (h(objectID, editorID, m_scene) == false) - return false; - } - } - return true; - } - #endregion #region MOVE OBJECT -- cgit v1.1 From 4cbf8d728e3bc4286463ef0e7cb611b10f594321 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 14 Jan 2012 05:39:56 +0100 Subject: Fix merge --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c9a8832..b232855 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2747,11 +2747,6 @@ namespace OpenSim.Region.Framework.Scenes public void RotLookAt(Quaternion target, float strength, float damping) { - m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup. - } - - public void rotLookAt(Quaternion target, float strength, float damping) - { if (ParentGroup.IsAttachment) { /* -- cgit v1.1 From 0369d219173fdb7ad9c19cf93d055480d80912fc Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 03:13:44 +0100 Subject: Add teleport routing, first part --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fdbcbb0..bac356e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3844,8 +3844,67 @@ namespace OpenSim.Region.Framework.Scenes } } + private void CheckAndAdjustTelehub(SceneObjectGroup telehub, ref Vector3 pos) + { + if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == + (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || + (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || + (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) + { + if (GodLevel < 200 && + ((!m_scene.Permissions.IsGod(m_uuid) && + !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || + (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || + (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) + { + SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); + if (spawnPoints.Length == 0) + return; + + float distance = 9999; + int closest = -1; + + for (int i = 0 ; i < spawnPoints.Length ; i++) + { + Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + Vector3 offset = spawnPosition - pos; + float d = Vector3.Mag(offset); + if (d >= distance) + continue; + ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); + if (land == null) + continue; + if (land.IsEitherBannedOrRestricted(UUID)) + continue; + distance = d; + closest = i; + } + if (closest == -1) + return; + + pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + } + } + } + private void CheckAndAdjustLandingPoint(ref Vector3 pos) { + string reason; + + // Honor bans + if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) + return; + + SceneObjectGroup telehub = null; + if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) + { + if (!m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) + { + CheckAndAdjustTelehub(telehub, ref pos); + return; + } + } ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (land != null) -- cgit v1.1 From f10288ceae9b029249ec72d04b39b3c9e3ae00ed Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 03:14:00 +0100 Subject: Add handling bans properly --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fc1e85a..0ebdbb7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3573,7 +3573,7 @@ namespace OpenSim.Region.Framework.Scenes return true; } - private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) + public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { reason = String.Empty; if (Permissions.IsGod(agentID)) -- cgit v1.1 From a0206e5a17a128a03e93b48ffedea709f8470f09 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 22:30:20 +0100 Subject: Comment debug spam --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bac356e..c7c90da 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1755,9 +1755,9 @@ namespace OpenSim.Region.Framework.Scenes if (pos.Z - terrainHeight < 0.2) pos.Z = terrainHeight; - m_log.DebugFormat( - "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", - Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", +// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); if (noFly) Flying = false; -- cgit v1.1 From 45ad9e39a668fc283b392746572729659fb9539d Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 01:05:14 +0100 Subject: Improve reliability of script state saving by covering various saving and loading scenarios which resulted in loss of continuity on item ids --- .../Framework/Scenes/SceneObjectPartInventory.cs | 24 ++++++++++++++-------- .../Scenes/Serialization/SceneObjectSerializer.cs | 5 +---- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2335ad5..dc64281 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -370,10 +370,11 @@ namespace OpenSim.Region.Framework.Scenes else { if (m_part.ParentGroup.m_savedScriptState != null) - RestoreSavedScriptState(item.OldItemID, item.ItemID); + item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); m_items.LockItemsForWrite(true); + m_items[item.ItemID].OldItemID = item.OldItemID; m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; @@ -392,17 +393,20 @@ namespace OpenSim.Region.Framework.Scenes } } - private void RestoreSavedScriptState(UUID oldID, UUID newID) + private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); if (engines.Length == 0) // No engine at all - return; + return oldID; - if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) + UUID stateID = oldID; + if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) + stateID = loadedID; + if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID)) { XmlDocument doc = new XmlDocument(); - doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); + doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); ////////// CRUFT WARNING /////////////////////////////////// // @@ -419,7 +423,7 @@ namespace OpenSim.Region.Framework.Scenes XmlElement rootN = newDoc.CreateElement("", "State", ""); XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); - uuidA.Value = oldID.ToString(); + uuidA.Value = stateID.ToString(); rootN.Attributes.Append(uuidA); XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); engineA.Value = "XEngine"; @@ -433,20 +437,22 @@ namespace OpenSim.Region.Framework.Scenes // This created document has only the minimun data // necessary for XEngine to parse it successfully - m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; + m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; } foreach (IScriptModule e in engines) { if (e != null) { - if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) + if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID])) break; } } - m_part.ParentGroup.m_savedScriptState.Remove(oldID); + m_part.ParentGroup.m_savedScriptState.Remove(stateID); } + + return stateID; } /// diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 2b0e115..6303cb1 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -807,10 +807,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) { - Util.ReadUUID(reader, "OldItemID"); - // On deserialization, the old item id MUST BE UUID.Zero!!!!! - // Setting this to the saved value will BREAK script persistence! - // item.OldItemID = Util.ReadUUID(reader, "OldItemID"); + item.OldItemID = Util.ReadUUID(reader, "OldItemID"); } private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) -- cgit v1.1 From 6fe4b6fbe807672ec64700ff8c6307a2a3e4f084 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 02:51:59 +0100 Subject: Fix remembering attachment point and position when an item is rezzed in world. Also fix PRIM_LOCAL_POS returning 0 when used on child prims from a script in the root. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c31cbab..6485710 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2351,6 +2351,11 @@ namespace OpenSim.Region.Framework.Scenes /// The group of prims which should be linked to this group public void LinkToGroup(SceneObjectGroup objectGroup) { + LinkToGroup(objectGroup, false); + } + + public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) + { // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); @@ -2380,7 +2385,20 @@ namespace OpenSim.Region.Framework.Scenes lock (m_parts.SyncRoot) { - int linkNum = PrimCount + 1; + int linkNum; + if (insert) + { + linkNum = 2; + foreach (SceneObjectPart part in Parts) + { + if (part.LinkNum > 1) + part.LinkNum++; + } + } + else + { + linkNum = PrimCount + 1; + } m_parts.Add(linkPart.UUID, linkPart); -- cgit v1.1 From fd7e82ee7237617a8e19b1eede3cf5164a587a67 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 16:51:39 +0100 Subject: Streamline banning code using existing methods. --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b37df82..128954f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4855,9 +4855,14 @@ Environment.Exit(1); get { return m_allowScriptCrossings; } } - public Vector3? GetNearestAllowedPosition(ScenePresence avatar) + public Vector3 GetNearestAllowedPosition(ScenePresence avatar) { - ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + return GetNearestAllowedPosition(avatar, null); + } + + public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) + { + ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); if (nearestParcel != null) { @@ -4916,13 +4921,18 @@ Environment.Exit(1); public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) { + return GetNearestAllowedParcel(avatarId, x, y, null); + } + + public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) + { List all = AllParcels(); float minParcelDistance = float.MaxValue; ILandObject nearestParcel = null; foreach (var parcel in all) { - if (!parcel.IsEitherBannedOrRestricted(avatarId)) + if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) { float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); if (parcelDistance < minParcelDistance) -- cgit v1.1 From 6cc9aa30ac40ecb62870d8ecf566680a1a83d630 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 8 Feb 2012 15:45:44 +0000 Subject: first change in SOP. in AddPrimShape(..) give physics the world rotation and not local offset. Currently physics interface only knows about world frame --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ac39b6b..1696dc5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1539,7 +1539,8 @@ namespace OpenSim.Region.Framework.Scenes Shape, AbsolutePosition, Scale, - RotationOffset, +// RotationOffset, + GetWorldRotation(), // physics wants world rotation RigidBody, m_localId); } @@ -4366,7 +4367,8 @@ namespace OpenSim.Region.Framework.Scenes Shape, AbsolutePosition, Scale, - RotationOffset, +// RotationOffset, + GetWorldRotation(), //physics wants world rotation like all other functions send UsePhysics, m_localId); -- cgit v1.1 From 6af01f6767838235091b9e34cdaea05951d68f68 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 8 Feb 2012 23:14:53 +0000 Subject: initial introdution of physics actor building control. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 47 +++++++++++++++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 ++++++++- 3 files changed, 58 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ec5cf32..456e86b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4766,7 +4766,7 @@ Environment.Exit(1); bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); if (wasUsingPhysics) { - jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock + jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 46c4d7b..2a3d735 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1281,7 +1281,8 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.SetParentLocalId(0); AttachmentPoint = (byte)0; - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); + // must check if buildind should be true or false here + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); HasGroupChanged = true; RootPart.Rezzed = DateTime.Now; RootPart.RemFlag(PrimFlags.TemporaryOnRez); @@ -1581,21 +1582,33 @@ namespace OpenSim.Region.Framework.Scenes public void ApplyPhysics() { // Apply physics to the root prim - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); + // m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); // Apply physics to child prims SceneObjectPart[] parts = m_parts.GetArray(); if (parts.Length > 1) { + ResetChildPrimPhysicsPositions(); + + // Apply physics to the root prim + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; if (part.LocalId != m_rootPart.LocalId) - part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); - } +// part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); + part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); + } // Hack to get the physics scene geometries in the right spot - ResetChildPrimPhysicsPositions(); +// ResetChildPrimPhysicsPositions(); + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + } + else + { + // Apply physics to the root prim + m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); } } @@ -1829,13 +1842,16 @@ namespace OpenSim.Region.Framework.Scenes pbs, newPart.AbsolutePosition, newPart.Scale, - newPart.RotationOffset, + //newPart.RotationOffset, + newPart.GetWorldRotation(), part.PhysActor.IsPhysical, newPart.LocalId); newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); } } + if (dupe.m_rootPart.PhysActor != null && userExposed) + dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building if (userExposed) { @@ -2849,12 +2865,31 @@ namespace OpenSim.Region.Framework.Scenes } } +/* RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); for (int i = 0; i < parts.Length; i++) { if (parts[i] != RootPart) parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); } +*/ + if (parts.Length > 1) + { + m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); + + for (int i = 0; i < parts.Length; i++) + { + + if (parts[i].UUID != m_rootPart.UUID) + parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); + } + + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + } + else + m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); + } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1696dc5..577c0d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1503,7 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) +// public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) + public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building) { if (!ParentGroup.Scene.CollidablePrims) return; @@ -1557,6 +1558,8 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.SetMaterial(Material); DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + if (!building) + PhysActor.Building = false; } } } @@ -1792,6 +1795,10 @@ namespace OpenSim.Region.Framework.Scenes if (!isNew) ParentGroup.Scene.RemovePhysicalPrim(1); + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + AngularVelocity = new Vector3(0, 0, 0); + PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; PhysActor.delink(); @@ -4268,7 +4275,8 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) +// public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) + public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) { bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); @@ -4286,6 +4294,9 @@ namespace OpenSim.Region.Framework.Scenes // that... // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. + // do this first + if (building && PhysActor != null && PhysActor.Building != building) + PhysActor.Building = building; if (SetVD) // VD is active, special logic applies { // State machine logic for VolumeDetect @@ -4448,6 +4459,9 @@ namespace OpenSim.Region.Framework.Scenes } // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); + // and last in case we have a new actor and not building + if (PhysActor != null && PhysActor.Building != building) + PhysActor.Building = building; if (ParentGroup != null) { ParentGroup.HasGroupChanged = true; -- cgit v1.1 From 09f6647aa37be99191263a20a98a5b992f62a3de Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Feb 2012 17:48:49 +0000 Subject: scenepresence change! in standup() give avatar a physical actor after deciding the new position. This reduces a bit the odds of it being still coliding with object. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c7c90da..9100c29 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1814,8 +1814,11 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); SitGround = false; + +/* move this down so avatar gets physical in the new position and not where it is siting if (PhysicsActor == null) AddToPhysicalScene(false); + */ if (ParentID != 0) { @@ -1850,6 +1853,10 @@ namespace OpenSim.Region.Framework.Scenes ParentPosition = Vector3.Zero; ParentID = 0; + + if (PhysicsActor == null) + AddToPhysicalScene(false); + SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; @@ -1857,6 +1864,9 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } + else if (PhysicsActor == null) + AddToPhysicalScene(false); + Animator.TrySetMovementAnimation("STAND"); } -- cgit v1.1 From e3213065173e1408a138eb0bce0c9e936073b19b Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Feb 2012 00:02:53 +0100 Subject: Prevent object loss and positioning outside the region with failed object sim crossings --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 683aafc..877fe96 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -466,6 +466,10 @@ namespace OpenSim.Region.Framework.Scenes && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + + if (IsDeleted) + return; + val = AbsolutePosition; } } -- cgit v1.1 From 2d3381b795611a8857077d1effb41323c2cb8658 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Feb 2012 23:16:20 +0100 Subject: Implement region crossing of sitting avatars. Edit mode and llSetPos work but unscripted default sit anim is lost. Still some Gfx glitching. Physical crossing doesn't work yet. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 89 ++++++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 139 +++++++++++++-------- 2 files changed, 174 insertions(+), 54 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 877fe96..a4ca0fb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -465,10 +465,76 @@ namespace OpenSim.Region.Framework.Scenes || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { - m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface(); + uint x = 0; + uint y = 0; + string version = String.Empty; + Vector3 newpos = Vector3.Zero; + OpenSim.Services.Interfaces.GridRegion destination = null; + + bool canCross = true; + foreach (ScenePresence av in m_linkedAvatars) + { + // We need to cross these agents. First, let's find + // out if any of them can't cross for some reason. + // We have to deny the crossing entirely if any + // of them are banned. Alternatively, we could + // unsit banned agents.... + + + // We set the avatar position as being the object + // position to get the region to send to + if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) + { + canCross = false; + break; + } + + m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); + } + + if (canCross) + { + // We unparent the SP quietly so that it won't + // be made to stand up + foreach (ScenePresence av in m_linkedAvatars) + { + SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); + if (parentPart != null) + av.ParentUUID = parentPart.UUID; + + av.ParentID = 0; + } + + m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + + // Normalize + if (val.X >= Constants.RegionSize) + val.X -= Constants.RegionSize; + if (val.Y >= Constants.RegionSize) + val.Y -= Constants.RegionSize; + if (val.X < 0) + val.X += Constants.RegionSize; + if (val.Y < 0) + val.Y += Constants.RegionSize; + + // If it's deleted, crossing was successful + if (IsDeleted) + { + foreach (ScenePresence av in m_linkedAvatars) + { + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); + + av.IsInTransit = true; + + CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; + d.BeginInvoke(av, val, x, y, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + } + + return; + } + } - if (IsDeleted) - return; val = AbsolutePosition; } } @@ -528,6 +594,23 @@ namespace OpenSim.Region.Framework.Scenes } } + private void CrossAgentToNewRegionCompleted(IAsyncResult iar) + { + CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; + ScenePresence agent = icon.EndInvoke(iar); + + //// If the cross was successful, this agent is a child agent + //if (agent.IsChildAgent) + // agent.Reset(); + //else // Not successful + // agent.RestoreInCurrentScene(); + + // In any case + agent.IsInTransit = false; + + m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); + } + public override uint LocalId { get { return m_rootPart.LocalId; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c7c90da..e44060c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -233,6 +233,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_collisionEventFlag = false; private object m_collisionEventLock = new Object(); + private Vector3 m_prevSitOffset; + protected AvatarAppearance m_appearance; public AvatarAppearance Appearance @@ -647,6 +649,13 @@ namespace OpenSim.Region.Framework.Scenes } private uint m_parentID; + public UUID ParentUUID + { + get { return m_parentUUID; } + set { m_parentUUID = value; } + } + private UUID m_parentUUID = UUID.Zero; + public float Health { get { return m_health; } @@ -868,7 +877,26 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE]: Upgrading child to root agent for {0} in {1}", Name, m_scene.RegionInfo.RegionName); - //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); + if (ParentUUID != UUID.Zero) + { + m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); + SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); + if (part == null) + { + m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); + } + else + { + part.ParentGroup.AddAvatar(UUID); + if (part.SitTargetPosition != Vector3.Zero) + part.SitTargetAvatar = UUID; + ParentPosition = part.GetWorldPosition(); + ParentID = part.LocalId; + m_pos = m_prevSitOffset; + pos = ParentPosition; + } + ParentUUID = UUID.Zero; + } bool wasChild = IsChildAgent; IsChildAgent = false; @@ -881,62 +909,64 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); - // Moved this from SendInitialData to ensure that Appearance is initialized - // before the inventory is processed in MakeRootAgent. This fixes a race condition - // related to the handling of attachments - //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); - if (m_scene.TestBorderCross(pos, Cardinals.E)) + if (ParentID == 0) { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); - pos.X = crossedBorder.BorderLine.Z - 1; - } + // Moved this from SendInitialData to ensure that Appearance is initialized + // before the inventory is processed in MakeRootAgent. This fixes a race condition + // related to the handling of attachments + //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); + if (m_scene.TestBorderCross(pos, Cardinals.E)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); + pos.X = crossedBorder.BorderLine.Z - 1; + } - if (m_scene.TestBorderCross(pos, Cardinals.N)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); - pos.Y = crossedBorder.BorderLine.Z - 1; - } + if (m_scene.TestBorderCross(pos, Cardinals.N)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); + pos.Y = crossedBorder.BorderLine.Z - 1; + } - CheckAndAdjustLandingPoint(ref pos); + CheckAndAdjustLandingPoint(ref pos); - if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) - { - m_log.WarnFormat( - "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", - pos, Name, UUID); + if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", + pos, Name, UUID); - if (pos.X < 0f) pos.X = 0f; - if (pos.Y < 0f) pos.Y = 0f; - if (pos.Z < 0f) pos.Z = 0f; - } + if (pos.X < 0f) pos.X = 0f; + if (pos.Y < 0f) pos.Y = 0f; + if (pos.Z < 0f) pos.Z = 0f; + } - float localAVHeight = 1.56f; - if (Appearance.AvatarHeight > 0) - localAVHeight = Appearance.AvatarHeight; + float localAVHeight = 1.56f; + if (Appearance.AvatarHeight > 0) + localAVHeight = Appearance.AvatarHeight; - float posZLimit = 0; + float posZLimit = 0; - if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) - posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; - - float newPosZ = posZLimit + localAVHeight / 2; - if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - pos.Z = newPosZ; - } - AbsolutePosition = pos; + if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) + posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; + + float newPosZ = posZLimit + localAVHeight / 2; + if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + pos.Z = newPosZ; + } + AbsolutePosition = pos; - AddToPhysicalScene(isFlying); + AddToPhysicalScene(isFlying); - if (ForceFly) - { - Flying = true; - } - else if (FlyDisabled) - { - Flying = false; + if (ForceFly) + { + Flying = true; + } + else if (FlyDisabled) + { + Flying = false; + } } - // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying // avatar to return to the standing position in mid-air. On login it looks like this is being sent // elsewhere anyway @@ -954,11 +984,13 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); // Resume scripts - foreach (SceneObjectGroup sog in m_attachments) - { - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); - sog.ResumeScripts(); - } + Util.FireAndForget(delegate(object x) { + foreach (SceneObjectGroup sog in m_attachments) + { + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); + sog.ResumeScripts(); + } + }); } } @@ -3112,6 +3144,9 @@ namespace OpenSim.Region.Framework.Scenes cAgent.AlwaysRun = SetAlwaysRun; cAgent.Appearance = new AvatarAppearance(Appearance); + + cAgent.ParentPart = ParentUUID; + cAgent.SitOffset = m_pos; lock (scriptedcontrols) { @@ -3171,6 +3206,8 @@ namespace OpenSim.Region.Framework.Scenes CameraAtAxis = cAgent.AtAxis; CameraLeftAxis = cAgent.LeftAxis; m_CameraUpAxis = cAgent.UpAxis; + ParentUUID = cAgent.ParentPart; + m_prevSitOffset = cAgent.SitOffset; // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the -- cgit v1.1 From f6f0d884bda8b5179d04a9cfe15efa3908552bcc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 15 Feb 2012 17:08:33 +0000 Subject: try to make crossings work better. chode no longer prevents crossings i hope --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 ++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a4ca0fb..d964a6f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -461,8 +461,11 @@ namespace OpenSim.Region.Framework.Scenes if (Scene != null) { - if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) - || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + // if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) + // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + // && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) + if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) + || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface(); @@ -489,7 +492,7 @@ namespace OpenSim.Region.Framework.Scenes canCross = false; break; } - + m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ac39b6b..f9e61be 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2612,9 +2612,9 @@ namespace OpenSim.Region.Framework.Scenes Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) - | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) - | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) - | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) + || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) + || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) + || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) { ParentGroup.AbsolutePosition = newpos; return; -- cgit v1.1 From a758abaa9fa7250d1b61bcd906ca12539307851d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 15 Feb 2012 17:08:33 +0000 Subject: try to make crossings work better. chode no longer prevents crossings i hope --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 ++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 644b78a..77e67ba 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -461,8 +461,11 @@ namespace OpenSim.Region.Framework.Scenes if (Scene != null) { - if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) - || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + // if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) + // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + // && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) + if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) + || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface(); @@ -489,7 +492,7 @@ namespace OpenSim.Region.Framework.Scenes canCross = false; break; } - + m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 577c0d3..19dedde 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2620,9 +2620,9 @@ namespace OpenSim.Region.Framework.Scenes Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) - | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) - | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) - | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) + || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) + || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) + || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) { ParentGroup.AbsolutePosition = newpos; return; -- cgit v1.1 From b59275355e9dd8fbc126faf5bded8e61e84df4e8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 15 Feb 2012 19:44:54 +0000 Subject: don't freeze with a sitted avatar in a border without other sim. Still messy :( --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 77e67ba..53edcd6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -537,8 +537,15 @@ namespace OpenSim.Region.Framework.Scenes return; } } + else if (RootPart.PhysActor != null) + { + RootPart.PhysActor.CrossingFailure(); + } - val = AbsolutePosition; + Vector3 oldp = AbsolutePosition; + val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); + val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); + val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } -- cgit v1.1 From 3bffdddc9d0f0f62d7cf4bc6c271a865052ee119 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 15 Feb 2012 19:44:54 +0000 Subject: don't freeze with a sitted avatar in a border without other sim. Still messy :( --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d964a6f..e7c6ee8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -537,8 +537,15 @@ namespace OpenSim.Region.Framework.Scenes return; } } + else if (RootPart.PhysActor != null) + { + RootPart.PhysActor.CrossingFailure(); + } - val = AbsolutePosition; + Vector3 oldp = AbsolutePosition; + val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); + val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); + val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } -- cgit v1.1 From 5351ff925c20c0fd189ee7de85c31521aca8cdf3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 14:08:42 +0000 Subject: let SOG know about vehicles. Still needs serialization and applyphyscis on deserialize, etc --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 431 +++++++++++++++++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 98 ++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 42 +- 3 files changed, 541 insertions(+), 30 deletions(-) create mode 100644 OpenSim/Region/Framework/Scenes/SOGVehicle.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs new file mode 100644 index 0000000..d6e9a3a --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -0,0 +1,431 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; + + +namespace OpenSim.Region.Framework.Scenes +{ + public class SOGVehicle + { + public Vehicle Type + { + get { return m_type; } + } + private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier + private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ? + + private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind + + private VehicleFlag m_flags = (VehicleFlag)0; + private Vector3 m_BlockingEndPoint = Vector3.Zero; // not sl + + // Linear properties + private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time + private Vector3 m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); + private float m_linearMotorDecayTimescale = 120; + private float m_linearMotorTimescale = 1000; + private Vector3 m_linearMotorOffset = Vector3.Zero; + + //Angular properties + private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor + private float m_angularMotorTimescale = 1000; // motor angular velocity ramp up rate + private float m_angularMotorDecayTimescale = 120; // motor angular velocity decay rate + private Vector3 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); // body angular velocity decay rate + + //Deflection properties + private float m_angularDeflectionEfficiency = 0; + private float m_angularDeflectionTimescale = 1000; + private float m_linearDeflectionEfficiency = 0; + private float m_linearDeflectionTimescale = 1000; + + //Banking properties + private float m_bankingEfficiency = 0; + private float m_bankingMix = 0; + private float m_bankingTimescale = 0; + + //Hover and Buoyancy properties + private float m_VhoverHeight = 0f; + private float m_VhoverEfficiency = 0f; + private float m_VhoverTimescale = 1000f; + private float m_VehicleBuoyancy = 0f; + + //Attractor properties + private float m_verticalAttractionEfficiency = 1.0f; // damped + private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. + + public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) + { + float len; + float timestep = 0.01f; + switch (pParam) + { + case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + m_angularDeflectionEfficiency = pValue; + break; + case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_angularDeflectionTimescale = pValue; + break; + case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: + if (pValue < timestep) pValue = timestep; + else if (pValue > 120) pValue = 120; + m_angularMotorDecayTimescale = pValue; + break; + case Vehicle.ANGULAR_MOTOR_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_angularMotorTimescale = pValue; + break; + case Vehicle.BANKING_EFFICIENCY: + if (pValue < -1f) pValue = -1f; + if (pValue > 1f) pValue = 1f; + m_bankingEfficiency = pValue; + break; + case Vehicle.BANKING_MIX: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + m_bankingMix = pValue; + break; + case Vehicle.BANKING_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_bankingTimescale = pValue; + break; + case Vehicle.BUOYANCY: + if (pValue < -1f) pValue = -1f; + if (pValue > 1f) pValue = 1f; + m_VehicleBuoyancy = pValue; + break; + case Vehicle.HOVER_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + m_VhoverEfficiency = pValue; + break; + case Vehicle.HOVER_HEIGHT: + m_VhoverHeight = pValue; + break; + case Vehicle.HOVER_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_VhoverTimescale = pValue; + break; + case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + m_linearDeflectionEfficiency = pValue; + break; + case Vehicle.LINEAR_DEFLECTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_linearDeflectionTimescale = pValue; + break; + case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: + // if (pValue < timestep) pValue = timestep; + // try to make impulses to work a bit better + if (pValue < timestep) pValue = timestep; + else if (pValue > 120) pValue = 120; + m_linearMotorDecayTimescale = pValue; + break; + case Vehicle.LINEAR_MOTOR_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_linearMotorTimescale = pValue; + break; + case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + m_verticalAttractionEfficiency = pValue; + break; + case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_verticalAttractionTimescale = pValue; + break; + + // These are vector properties but the engine lets you use a single float value to + // set all of the components to the same value + case Vehicle.ANGULAR_FRICTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); + break; + case Vehicle.ANGULAR_MOTOR_DIRECTION: + m_angularMotorDirection = new Vector3(pValue, pValue, pValue); + len = m_angularMotorDirection.Length(); + if (len > 12.566f) + m_angularMotorDirection *= (12.566f / len); + break; + case Vehicle.LINEAR_FRICTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); + break; + case Vehicle.LINEAR_MOTOR_DIRECTION: + m_linearMotorDirection = new Vector3(pValue, pValue, pValue); + len = m_linearMotorDirection.Length(); + if (len > 30.0f) + m_linearMotorDirection *= (30.0f / len); + break; + case Vehicle.LINEAR_MOTOR_OFFSET: + m_linearMotorOffset = new Vector3(pValue, pValue, pValue); + len = m_linearMotorOffset.Length(); + if (len > 100.0f) + m_linearMotorOffset *= (100.0f / len); + break; + } + }//end ProcessFloatVehicleParam + + public void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) + { + float len; + float timestep = 0.01f; + switch (pParam) + { + case Vehicle.ANGULAR_FRICTION_TIMESCALE: + if (pValue.X < timestep) pValue.X = timestep; + if (pValue.Y < timestep) pValue.Y = timestep; + if (pValue.Z < timestep) pValue.Z = timestep; + + m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); + break; + case Vehicle.ANGULAR_MOTOR_DIRECTION: + m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); + // Limit requested angular speed to 2 rps= 4 pi rads/sec + len = m_angularMotorDirection.Length(); + if (len > 12.566f) + m_angularMotorDirection *= (12.566f / len); + break; + case Vehicle.LINEAR_FRICTION_TIMESCALE: + if (pValue.X < timestep) pValue.X = timestep; + if (pValue.Y < timestep) pValue.Y = timestep; + if (pValue.Z < timestep) pValue.Z = timestep; + m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); + break; + case Vehicle.LINEAR_MOTOR_DIRECTION: + m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); + len = m_linearMotorDirection.Length(); + if (len > 30.0f) + m_linearMotorDirection *= (30.0f / len); + break; + case Vehicle.LINEAR_MOTOR_OFFSET: + m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); + len = m_linearMotorOffset.Length(); + if (len > 100.0f) + m_linearMotorOffset *= (100.0f / len); + break; + case Vehicle.BLOCK_EXIT: + m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z); + break; + } + }//end ProcessVectorVehicleParam + + public void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) + { + switch (pParam) + { + case Vehicle.REFERENCE_FRAME: + m_referenceFrame = Quaternion.Inverse(pValue); + break; + case Vehicle.ROLL_FRAME: + m_RollreferenceFrame = pValue; + break; + } + }//end ProcessRotationVehicleParam + + public void ProcessVehicleFlags(int pParam, bool remove) + { + if (remove) + { + m_flags &= ~((VehicleFlag)pParam); + } + else + { + m_flags |= (VehicleFlag)pParam; + } + }//end ProcessVehicleFlags + + public void ProcessTypeChange(Vehicle pType) + { + m_linearMotorDirection = Vector3.Zero; + m_angularMotorDirection = Vector3.Zero; + + m_BlockingEndPoint = Vector3.Zero; + m_RollreferenceFrame = Quaternion.Identity; + m_linearMotorOffset = Vector3.Zero; + + m_referenceFrame = Quaternion.Identity; + + // Set Defaults For Type + m_type = pType; + switch (pType) + { + case Vehicle.TYPE_NONE: // none sense this will never exist + m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); + m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + m_linearMotorTimescale = 1000; + m_linearMotorDecayTimescale = 120; + m_angularMotorTimescale = 1000; + m_angularMotorDecayTimescale = 1000; + m_VhoverHeight = 0; + m_VhoverTimescale = 1000; + m_VehicleBuoyancy = 0; + m_flags = (VehicleFlag)0; + break; + + case Vehicle.TYPE_SLED: + m_linearFrictionTimescale = new Vector3(30, 1, 1000); + m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + m_linearMotorTimescale = 1000; + m_linearMotorDecayTimescale = 120; + m_angularMotorTimescale = 1000; + m_angularMotorDecayTimescale = 120; + m_VhoverHeight = 0; + m_VhoverEfficiency = 1; + m_VhoverTimescale = 10; + m_VehicleBuoyancy = 0; + m_linearDeflectionEfficiency = 1; + m_linearDeflectionTimescale = 1; + m_angularDeflectionEfficiency = 0; + m_angularDeflectionTimescale = 1000; + m_bankingEfficiency = 0; + m_bankingMix = 1; + m_bankingTimescale = 10; + m_flags &= + ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); + m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); + break; + case Vehicle.TYPE_CAR: + m_linearFrictionTimescale = new Vector3(100, 2, 1000); + m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + m_linearMotorTimescale = 1; + m_linearMotorDecayTimescale = 60; + m_angularMotorTimescale = 1; + m_angularMotorDecayTimescale = 0.8f; + m_VhoverHeight = 0; + m_VhoverEfficiency = 0; + m_VhoverTimescale = 1000; + m_VehicleBuoyancy = 0; + m_linearDeflectionEfficiency = 1; + m_linearDeflectionTimescale = 2; + m_angularDeflectionEfficiency = 0; + m_angularDeflectionTimescale = 10; + m_verticalAttractionEfficiency = 1f; + m_verticalAttractionTimescale = 10f; + m_bankingEfficiency = -0.2f; + m_bankingMix = 1; + m_bankingTimescale = 1; + m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); + m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | + VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); + break; + case Vehicle.TYPE_BOAT: + m_linearFrictionTimescale = new Vector3(10, 3, 2); + m_angularFrictionTimescale = new Vector3(10, 10, 10); + m_linearMotorTimescale = 5; + m_linearMotorDecayTimescale = 60; + m_angularMotorTimescale = 4; + m_angularMotorDecayTimescale = 4; + m_VhoverHeight = 0; + m_VhoverEfficiency = 0.5f; + m_VhoverTimescale = 2; + m_VehicleBuoyancy = 1; + m_linearDeflectionEfficiency = 0.5f; + m_linearDeflectionTimescale = 3; + m_angularDeflectionEfficiency = 0.5f; + m_angularDeflectionTimescale = 5; + m_verticalAttractionEfficiency = 0.5f; + m_verticalAttractionTimescale = 5f; + m_bankingEfficiency = -0.3f; + m_bankingMix = 0.8f; + m_bankingTimescale = 1; + m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT | + VehicleFlag.HOVER_UP_ONLY | + VehicleFlag.LIMIT_ROLL_ONLY); + m_flags |= (VehicleFlag.NO_DEFLECTION_UP | + VehicleFlag.LIMIT_MOTOR_UP | + VehicleFlag.HOVER_WATER_ONLY); + break; + case Vehicle.TYPE_AIRPLANE: + m_linearFrictionTimescale = new Vector3(200, 10, 5); + m_angularFrictionTimescale = new Vector3(20, 20, 20); + m_linearMotorTimescale = 2; + m_linearMotorDecayTimescale = 60; + m_angularMotorTimescale = 4; + m_angularMotorDecayTimescale = 8; + m_VhoverHeight = 0; + m_VhoverEfficiency = 0.5f; + m_VhoverTimescale = 1000; + m_VehicleBuoyancy = 0; + m_linearDeflectionEfficiency = 0.5f; + m_linearDeflectionTimescale = 0.5f; + m_angularDeflectionEfficiency = 1; + m_angularDeflectionTimescale = 2; + m_verticalAttractionEfficiency = 0.9f; + m_verticalAttractionTimescale = 2f; + m_bankingEfficiency = 1; + m_bankingMix = 0.7f; + m_bankingTimescale = 2; + m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | + VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT | + VehicleFlag.HOVER_UP_ONLY | + VehicleFlag.NO_DEFLECTION_UP | + VehicleFlag.LIMIT_MOTOR_UP); + m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); + break; + case Vehicle.TYPE_BALLOON: + m_linearFrictionTimescale = new Vector3(5, 5, 5); + m_angularFrictionTimescale = new Vector3(10, 10, 10); + m_linearMotorTimescale = 5; + m_linearMotorDecayTimescale = 60; + m_angularMotorTimescale = 6; + m_angularMotorDecayTimescale = 10; + m_VhoverHeight = 5; + m_VhoverEfficiency = 0.8f; + m_VhoverTimescale = 10; + m_VehicleBuoyancy = 1; + m_linearDeflectionEfficiency = 0; + m_linearDeflectionTimescale = 5; + m_angularDeflectionEfficiency = 0; + m_angularDeflectionTimescale = 5; + m_verticalAttractionEfficiency = 0f; + m_verticalAttractionTimescale = 1000f; + m_bankingEfficiency = 0; + m_bankingMix = 0.7f; + m_bankingTimescale = 5; + m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | + VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_UP_ONLY | + VehicleFlag.NO_DEFLECTION_UP | + VehicleFlag.LIMIT_MOTOR_UP); + m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT); + break; + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 53edcd6..1bac4d8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -43,6 +43,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; namespace OpenSim.Region.Framework.Scenes { + [Flags] public enum scriptEvents { @@ -114,6 +115,90 @@ namespace OpenSim.Region.Framework.Scenes private bool m_suspendUpdates; private List m_linkedAvatars = new List(); + private SOGVehicle m_vehicle = null; + + public int VehicleType + { + get + { + if (m_vehicle == null) + return (int)Vehicle.TYPE_NONE; + else + return (int)m_vehicle.Type; + } + set + { + m_vehicle = null; + if (value == (int)Vehicle.TYPE_NONE) + { + if (RootPart.PhysActor != null) + RootPart.PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; + return; + } + m_vehicle = new SOGVehicle(); + m_vehicle.ProcessTypeChange((Vehicle)value); + { + if (RootPart.PhysActor != null) + RootPart.PhysActor.VehicleType = value; + return; + } + + } + } + + public void SetVehicleFlags(int param, bool remove) + { + if (m_vehicle == null) + return; + + m_vehicle.ProcessVehicleFlags(param, remove); + + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.VehicleFlags(param, remove); + } + } + + public void SetVehicleFloatParam(int param, float value) + { + if (m_vehicle == null) + return; + + m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); + + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.VehicleFloatParam(param, value); + } + } + + public void SetVehicleVectorParam(int param, Vector3 value) + { + if (m_vehicle == null) + return; + + m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); + + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.VehicleVectorParam(param, value); + } + } + + public void SetVehicleRotationParam(int param, Quaternion rotation) + { + if (m_vehicle == null) + return; + + m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); + + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.VehicleRotationParam(param, rotation); + } + } + + public bool areUpdatesSuspended { get @@ -1678,10 +1763,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void ApplyPhysics() { - // Apply physics to the root prim - // m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); - - // Apply physics to child prims SceneObjectPart[] parts = m_parts.GetArray(); if (parts.Length > 1) { @@ -1689,18 +1770,21 @@ namespace OpenSim.Region.Framework.Scenes // Apply physics to the root prim m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); + + for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; if (part.LocalId != m_rootPart.LocalId) -// part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); - } // Hack to get the physics scene geometries in the right spot // ResetChildPrimPhysicsPositions(); - if (m_rootPart.PhysActor != null) + if (m_rootPart.PhysActor != null) + { m_rootPart.PhysActor.Building = false; + + } } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 19dedde..6438694 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3170,34 +3170,37 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleType(int type) { - if (PhysActor != null) - { - PhysActor.VehicleType = type; - } + if (ParentGroup.IsDeleted) + return; + ParentGroup.VehicleType = type; + } + + public void SetVehicleFlags(int param, bool remove) + { + if (ParentGroup.IsDeleted) + return; + ParentGroup.SetVehicleFlags(param, remove); } public void SetVehicleFloatParam(int param, float value) { - if (PhysActor != null) - { - PhysActor.VehicleFloatParam(param, value); - } + if (ParentGroup.IsDeleted) + return; + ParentGroup.SetVehicleFloatParam(param, value); } public void SetVehicleVectorParam(int param, Vector3 value) { - if (PhysActor != null) - { - PhysActor.VehicleVectorParam(param, value); - } + if (ParentGroup.IsDeleted) + return; + ParentGroup.SetVehicleVectorParam(param, value); } public void SetVehicleRotationParam(int param, Quaternion rotation) { - if (PhysActor != null) - { - PhysActor.VehicleRotationParam(param, rotation); - } + if (ParentGroup.IsDeleted) + return; + ParentGroup.SetVehicleRotationParam(param, rotation); } /// @@ -3381,13 +3384,6 @@ namespace OpenSim.Region.Framework.Scenes hasProfileCut = hasDimple; // is it the same thing? } - public void SetVehicleFlags(int param, bool remove) - { - if (PhysActor != null) - { - PhysActor.VehicleFlags(param, remove); - } - } public void SetGroup(UUID groupID, IClientAPI client) { -- cgit v1.1 From 91a326331fedc702cc3f04a628841447b90d009a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 16:16:48 +0000 Subject: vehicle parameters do cross (i hope) on regions in same instance ( others need xml) --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 63 +++++++++++++++++----- .../Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++- 2 files changed, 57 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs index d6e9a3a..b7c93e5 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -39,13 +39,9 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_type; } } - private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier - private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ? private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind - private VehicleFlag m_flags = (VehicleFlag)0; - private Vector3 m_BlockingEndPoint = Vector3.Zero; // not sl // Linear properties private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time @@ -81,6 +77,9 @@ namespace OpenSim.Region.Framework.Scenes private float m_verticalAttractionEfficiency = 1.0f; // damped private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. + // Axis + public Quaternion m_referenceFrame = Quaternion.Identity; + public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) { float len; @@ -235,9 +234,6 @@ namespace OpenSim.Region.Framework.Scenes if (len > 100.0f) m_linearMotorOffset *= (100.0f / len); break; - case Vehicle.BLOCK_EXIT: - m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z); - break; } }//end ProcessVectorVehicleParam @@ -248,9 +244,6 @@ namespace OpenSim.Region.Framework.Scenes case Vehicle.REFERENCE_FRAME: m_referenceFrame = Quaternion.Inverse(pValue); break; - case Vehicle.ROLL_FRAME: - m_RollreferenceFrame = pValue; - break; } }//end ProcessRotationVehicleParam @@ -271,8 +264,6 @@ namespace OpenSim.Region.Framework.Scenes m_linearMotorDirection = Vector3.Zero; m_angularMotorDirection = Vector3.Zero; - m_BlockingEndPoint = Vector3.Zero; - m_RollreferenceFrame = Quaternion.Identity; m_linearMotorOffset = Vector3.Zero; m_referenceFrame = Quaternion.Identity; @@ -427,5 +418,53 @@ namespace OpenSim.Region.Framework.Scenes break; } } + public void SetVehicle(PhysicsActor ph) + { + + // crap crap crap + if (ph == null) // what ?? + return; + + ph.VehicleType = (int)m_type; + + // Linear properties + ph.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_DIRECTION, m_linearMotorDirection); + ph.VehicleVectorParam((int)Vehicle.LINEAR_FRICTION_TIMESCALE, m_linearFrictionTimescale); + ph.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, m_linearMotorDecayTimescale); + ph.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_TIMESCALE, m_linearMotorTimescale); + ph.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_OFFSET, m_linearMotorOffset); + + //Angular properties + ph.VehicleVectorParam((int)Vehicle.ANGULAR_MOTOR_DIRECTION, m_angularMotorDirection); + ph.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_TIMESCALE, m_angularMotorTimescale); + ph.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, m_angularMotorDecayTimescale); + ph.VehicleVectorParam((int)Vehicle.ANGULAR_FRICTION_TIMESCALE, m_angularFrictionTimescale); + + //Deflection properties + ph.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, m_angularDeflectionEfficiency); + ph.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_TIMESCALE, m_angularDeflectionTimescale); + ph.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_EFFICIENCY, m_linearDeflectionEfficiency); + ph.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_TIMESCALE, m_linearDeflectionTimescale); + + //Banking properties + ph.VehicleFloatParam((int)Vehicle.BANKING_EFFICIENCY, m_bankingEfficiency); + ph.VehicleFloatParam((int)Vehicle.BANKING_MIX, m_bankingMix); + ph.VehicleFloatParam((int)Vehicle.BANKING_TIMESCALE, m_bankingTimescale); + + //Hover and Buoyancy properties + ph.VehicleFloatParam((int)Vehicle.HOVER_HEIGHT, m_VhoverHeight); + ph.VehicleFloatParam((int)Vehicle.HOVER_EFFICIENCY, m_VhoverEfficiency); + ph.VehicleFloatParam((int)Vehicle.HOVER_TIMESCALE, m_VhoverTimescale); + ph.VehicleFloatParam((int)Vehicle.BUOYANCY, m_VehicleBuoyancy); + + //Attractor properties + ph.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, m_verticalAttractionEfficiency); + ph.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_TIMESCALE, m_verticalAttractionTimescale); + + ph.VehicleRotationParam((int)Vehicle.REFERENCE_FRAME, m_referenceFrame); + + ph.VehicleFlags(~(int)m_flags, true); + ph.VehicleFlags((int)m_flags, false); + } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1bac4d8..324fdb8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1782,14 +1782,19 @@ namespace OpenSim.Region.Framework.Scenes // ResetChildPrimPhysicsPositions(); if (m_rootPart.PhysActor != null) { + if (m_vehicle != null) + m_vehicle.SetVehicle(m_rootPart.PhysActor); m_rootPart.PhysActor.Building = false; - } } else { // Apply physics to the root prim m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); + if (m_rootPart.PhysActor != null && m_vehicle != null) + { + m_vehicle.SetVehicle(m_rootPart.PhysActor); + } } } -- cgit v1.1 From 3aee642190add7045f78e522ae7b2221b3566f1e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 17:42:14 +0000 Subject: changed how vehicle data is stored and passed to physics. use unsafe in serializer, tried to control m_dupeInProgress --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 336 +++++++++++---------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 + 2 files changed, 175 insertions(+), 163 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs index b7c93e5..470f403 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -37,9 +37,11 @@ namespace OpenSim.Region.Framework.Scenes { public Vehicle Type { - get { return m_type; } + get { return vd.m_type; } } + public VehicleData vd; +/* private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind private VehicleFlag m_flags = (VehicleFlag)0; @@ -78,7 +80,13 @@ namespace OpenSim.Region.Framework.Scenes private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. // Axis - public Quaternion m_referenceFrame = Quaternion.Identity; + public Quaternion m_referenceFrame = Quaternion.Identity; +*/ + public SOGVehicle() + { + vd = new VehicleData(); + ProcessTypeChange(Vehicle.TYPE_NONE); // is needed? + } public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) { @@ -89,109 +97,109 @@ namespace OpenSim.Region.Framework.Scenes case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: if (pValue < 0f) pValue = 0f; if (pValue > 1f) pValue = 1f; - m_angularDeflectionEfficiency = pValue; + vd.m_angularDeflectionEfficiency = pValue; break; case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_angularDeflectionTimescale = pValue; + vd.m_angularDeflectionTimescale = pValue; break; case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: if (pValue < timestep) pValue = timestep; else if (pValue > 120) pValue = 120; - m_angularMotorDecayTimescale = pValue; + vd.m_angularMotorDecayTimescale = pValue; break; case Vehicle.ANGULAR_MOTOR_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_angularMotorTimescale = pValue; + vd.m_angularMotorTimescale = pValue; break; case Vehicle.BANKING_EFFICIENCY: if (pValue < -1f) pValue = -1f; if (pValue > 1f) pValue = 1f; - m_bankingEfficiency = pValue; + vd.m_bankingEfficiency = pValue; break; case Vehicle.BANKING_MIX: if (pValue < 0f) pValue = 0f; if (pValue > 1f) pValue = 1f; - m_bankingMix = pValue; + vd.m_bankingMix = pValue; break; case Vehicle.BANKING_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_bankingTimescale = pValue; + vd.m_bankingTimescale = pValue; break; case Vehicle.BUOYANCY: if (pValue < -1f) pValue = -1f; if (pValue > 1f) pValue = 1f; - m_VehicleBuoyancy = pValue; + vd.m_VehicleBuoyancy = pValue; break; case Vehicle.HOVER_EFFICIENCY: if (pValue < 0f) pValue = 0f; if (pValue > 1f) pValue = 1f; - m_VhoverEfficiency = pValue; + vd.m_VhoverEfficiency = pValue; break; case Vehicle.HOVER_HEIGHT: - m_VhoverHeight = pValue; + vd.m_VhoverHeight = pValue; break; case Vehicle.HOVER_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_VhoverTimescale = pValue; + vd.m_VhoverTimescale = pValue; break; case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: if (pValue < 0f) pValue = 0f; if (pValue > 1f) pValue = 1f; - m_linearDeflectionEfficiency = pValue; + vd.m_linearDeflectionEfficiency = pValue; break; case Vehicle.LINEAR_DEFLECTION_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_linearDeflectionTimescale = pValue; + vd.m_linearDeflectionTimescale = pValue; break; case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: // if (pValue < timestep) pValue = timestep; // try to make impulses to work a bit better if (pValue < timestep) pValue = timestep; else if (pValue > 120) pValue = 120; - m_linearMotorDecayTimescale = pValue; + vd.m_linearMotorDecayTimescale = pValue; break; case Vehicle.LINEAR_MOTOR_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_linearMotorTimescale = pValue; + vd.m_linearMotorTimescale = pValue; break; case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: if (pValue < 0f) pValue = 0f; if (pValue > 1f) pValue = 1f; - m_verticalAttractionEfficiency = pValue; + vd.m_verticalAttractionEfficiency = pValue; break; case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_verticalAttractionTimescale = pValue; + vd.m_verticalAttractionTimescale = pValue; break; // These are vector properties but the engine lets you use a single float value to // set all of the components to the same value case Vehicle.ANGULAR_FRICTION_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); + vd.m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); break; case Vehicle.ANGULAR_MOTOR_DIRECTION: - m_angularMotorDirection = new Vector3(pValue, pValue, pValue); - len = m_angularMotorDirection.Length(); + vd.m_angularMotorDirection = new Vector3(pValue, pValue, pValue); + len = vd.m_angularMotorDirection.Length(); if (len > 12.566f) - m_angularMotorDirection *= (12.566f / len); + vd.m_angularMotorDirection *= (12.566f / len); break; case Vehicle.LINEAR_FRICTION_TIMESCALE: if (pValue < timestep) pValue = timestep; - m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); + vd.m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); break; case Vehicle.LINEAR_MOTOR_DIRECTION: - m_linearMotorDirection = new Vector3(pValue, pValue, pValue); - len = m_linearMotorDirection.Length(); + vd.m_linearMotorDirection = new Vector3(pValue, pValue, pValue); + len = vd.m_linearMotorDirection.Length(); if (len > 30.0f) - m_linearMotorDirection *= (30.0f / len); + vd.m_linearMotorDirection *= (30.0f / len); break; case Vehicle.LINEAR_MOTOR_OFFSET: - m_linearMotorOffset = new Vector3(pValue, pValue, pValue); - len = m_linearMotorOffset.Length(); + vd.m_linearMotorOffset = new Vector3(pValue, pValue, pValue); + len = vd.m_linearMotorOffset.Length(); if (len > 100.0f) - m_linearMotorOffset *= (100.0f / len); + vd.m_linearMotorOffset *= (100.0f / len); break; } }//end ProcessFloatVehicleParam @@ -207,32 +215,32 @@ namespace OpenSim.Region.Framework.Scenes if (pValue.Y < timestep) pValue.Y = timestep; if (pValue.Z < timestep) pValue.Z = timestep; - m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); + vd.m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); break; case Vehicle.ANGULAR_MOTOR_DIRECTION: - m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); + vd.m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); // Limit requested angular speed to 2 rps= 4 pi rads/sec - len = m_angularMotorDirection.Length(); + len = vd.m_angularMotorDirection.Length(); if (len > 12.566f) - m_angularMotorDirection *= (12.566f / len); + vd.m_angularMotorDirection *= (12.566f / len); break; case Vehicle.LINEAR_FRICTION_TIMESCALE: if (pValue.X < timestep) pValue.X = timestep; if (pValue.Y < timestep) pValue.Y = timestep; if (pValue.Z < timestep) pValue.Z = timestep; - m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); + vd.m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); break; case Vehicle.LINEAR_MOTOR_DIRECTION: - m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); - len = m_linearMotorDirection.Length(); + vd.m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); + len = vd.m_linearMotorDirection.Length(); if (len > 30.0f) - m_linearMotorDirection *= (30.0f / len); + vd.m_linearMotorDirection *= (30.0f / len); break; case Vehicle.LINEAR_MOTOR_OFFSET: - m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); - len = m_linearMotorOffset.Length(); + vd.m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); + len = vd.m_linearMotorOffset.Length(); if (len > 100.0f) - m_linearMotorOffset *= (100.0f / len); + vd.m_linearMotorOffset *= (100.0f / len); break; } }//end ProcessVectorVehicleParam @@ -242,7 +250,7 @@ namespace OpenSim.Region.Framework.Scenes switch (pParam) { case Vehicle.REFERENCE_FRAME: - m_referenceFrame = Quaternion.Inverse(pValue); + vd.m_referenceFrame = Quaternion.Inverse(pValue); break; } }//end ProcessRotationVehicleParam @@ -251,169 +259,169 @@ namespace OpenSim.Region.Framework.Scenes { if (remove) { - m_flags &= ~((VehicleFlag)pParam); + vd.m_flags &= ~((VehicleFlag)pParam); } else { - m_flags |= (VehicleFlag)pParam; + vd.m_flags |= (VehicleFlag)pParam; } }//end ProcessVehicleFlags public void ProcessTypeChange(Vehicle pType) { - m_linearMotorDirection = Vector3.Zero; - m_angularMotorDirection = Vector3.Zero; + vd.m_linearMotorDirection = Vector3.Zero; + vd.m_angularMotorDirection = Vector3.Zero; - m_linearMotorOffset = Vector3.Zero; + vd.m_linearMotorOffset = Vector3.Zero; - m_referenceFrame = Quaternion.Identity; + vd.m_referenceFrame = Quaternion.Identity; // Set Defaults For Type - m_type = pType; + vd.m_type = pType; switch (pType) { case Vehicle.TYPE_NONE: // none sense this will never exist - m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); - m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); - m_linearMotorTimescale = 1000; - m_linearMotorDecayTimescale = 120; - m_angularMotorTimescale = 1000; - m_angularMotorDecayTimescale = 1000; - m_VhoverHeight = 0; - m_VhoverTimescale = 1000; - m_VehicleBuoyancy = 0; - m_flags = (VehicleFlag)0; + vd.m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_linearMotorTimescale = 1000; + vd.m_linearMotorDecayTimescale = 120; + vd.m_angularMotorTimescale = 1000; + vd.m_angularMotorDecayTimescale = 1000; + vd.m_VhoverHeight = 0; + vd.m_VhoverTimescale = 1000; + vd.m_VehicleBuoyancy = 0; + vd.m_flags = (VehicleFlag)0; break; case Vehicle.TYPE_SLED: - m_linearFrictionTimescale = new Vector3(30, 1, 1000); - m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); - m_linearMotorTimescale = 1000; - m_linearMotorDecayTimescale = 120; - m_angularMotorTimescale = 1000; - m_angularMotorDecayTimescale = 120; - m_VhoverHeight = 0; - m_VhoverEfficiency = 1; - m_VhoverTimescale = 10; - m_VehicleBuoyancy = 0; - m_linearDeflectionEfficiency = 1; - m_linearDeflectionTimescale = 1; - m_angularDeflectionEfficiency = 0; - m_angularDeflectionTimescale = 1000; - m_bankingEfficiency = 0; - m_bankingMix = 1; - m_bankingTimescale = 10; - m_flags &= + vd.m_linearFrictionTimescale = new Vector3(30, 1, 1000); + vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_linearMotorTimescale = 1000; + vd.m_linearMotorDecayTimescale = 120; + vd.m_angularMotorTimescale = 1000; + vd.m_angularMotorDecayTimescale = 120; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 1; + vd.m_VhoverTimescale = 10; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 1; + vd.m_linearDeflectionTimescale = 1; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 1000; + vd.m_bankingEfficiency = 0; + vd.m_bankingMix = 1; + vd.m_bankingTimescale = 10; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); - m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); + vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); break; case Vehicle.TYPE_CAR: - m_linearFrictionTimescale = new Vector3(100, 2, 1000); - m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); - m_linearMotorTimescale = 1; - m_linearMotorDecayTimescale = 60; - m_angularMotorTimescale = 1; - m_angularMotorDecayTimescale = 0.8f; - m_VhoverHeight = 0; - m_VhoverEfficiency = 0; - m_VhoverTimescale = 1000; - m_VehicleBuoyancy = 0; - m_linearDeflectionEfficiency = 1; - m_linearDeflectionTimescale = 2; - m_angularDeflectionEfficiency = 0; - m_angularDeflectionTimescale = 10; - m_verticalAttractionEfficiency = 1f; - m_verticalAttractionTimescale = 10f; - m_bankingEfficiency = -0.2f; - m_bankingMix = 1; - m_bankingTimescale = 1; - m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); - m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | + vd.m_linearFrictionTimescale = new Vector3(100, 2, 1000); + vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_linearMotorTimescale = 1; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 1; + vd.m_angularMotorDecayTimescale = 0.8f; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 0; + vd.m_VhoverTimescale = 1000; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 1; + vd.m_linearDeflectionTimescale = 2; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 10; + vd.m_verticalAttractionEfficiency = 1f; + vd.m_verticalAttractionTimescale = 10f; + vd.m_bankingEfficiency = -0.2f; + vd.m_bankingMix = 1; + vd.m_bankingTimescale = 1; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); + vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); break; case Vehicle.TYPE_BOAT: - m_linearFrictionTimescale = new Vector3(10, 3, 2); - m_angularFrictionTimescale = new Vector3(10, 10, 10); - m_linearMotorTimescale = 5; - m_linearMotorDecayTimescale = 60; - m_angularMotorTimescale = 4; - m_angularMotorDecayTimescale = 4; - m_VhoverHeight = 0; - m_VhoverEfficiency = 0.5f; - m_VhoverTimescale = 2; - m_VehicleBuoyancy = 1; - m_linearDeflectionEfficiency = 0.5f; - m_linearDeflectionTimescale = 3; - m_angularDeflectionEfficiency = 0.5f; - m_angularDeflectionTimescale = 5; - m_verticalAttractionEfficiency = 0.5f; - m_verticalAttractionTimescale = 5f; - m_bankingEfficiency = -0.3f; - m_bankingMix = 0.8f; - m_bankingTimescale = 1; - m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | + vd.m_linearFrictionTimescale = new Vector3(10, 3, 2); + vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); + vd.m_linearMotorTimescale = 5; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 4; + vd.m_angularMotorDecayTimescale = 4; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 0.5f; + vd.m_VhoverTimescale = 2; + vd.m_VehicleBuoyancy = 1; + vd.m_linearDeflectionEfficiency = 0.5f; + vd.m_linearDeflectionTimescale = 3; + vd.m_angularDeflectionEfficiency = 0.5f; + vd.m_angularDeflectionTimescale = 5; + vd.m_verticalAttractionEfficiency = 0.5f; + vd.m_verticalAttractionTimescale = 5f; + vd.m_bankingEfficiency = -0.3f; + vd.m_bankingMix = 0.8f; + vd.m_bankingTimescale = 1; + vd.m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_ROLL_ONLY); - m_flags |= (VehicleFlag.NO_DEFLECTION_UP | + vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_WATER_ONLY); break; case Vehicle.TYPE_AIRPLANE: - m_linearFrictionTimescale = new Vector3(200, 10, 5); - m_angularFrictionTimescale = new Vector3(20, 20, 20); - m_linearMotorTimescale = 2; - m_linearMotorDecayTimescale = 60; - m_angularMotorTimescale = 4; - m_angularMotorDecayTimescale = 8; - m_VhoverHeight = 0; - m_VhoverEfficiency = 0.5f; - m_VhoverTimescale = 1000; - m_VehicleBuoyancy = 0; - m_linearDeflectionEfficiency = 0.5f; - m_linearDeflectionTimescale = 0.5f; - m_angularDeflectionEfficiency = 1; - m_angularDeflectionTimescale = 2; - m_verticalAttractionEfficiency = 0.9f; - m_verticalAttractionTimescale = 2f; - m_bankingEfficiency = 1; - m_bankingMix = 0.7f; - m_bankingTimescale = 2; - m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | + vd.m_linearFrictionTimescale = new Vector3(200, 10, 5); + vd.m_angularFrictionTimescale = new Vector3(20, 20, 20); + vd.m_linearMotorTimescale = 2; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 4; + vd.m_angularMotorDecayTimescale = 8; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 0.5f; + vd.m_VhoverTimescale = 1000; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 0.5f; + vd.m_linearDeflectionTimescale = 0.5f; + vd.m_angularDeflectionEfficiency = 1; + vd.m_angularDeflectionTimescale = 2; + vd.m_verticalAttractionEfficiency = 0.9f; + vd.m_verticalAttractionTimescale = 2f; + vd.m_bankingEfficiency = 1; + vd.m_bankingMix = 0.7f; + vd.m_bankingTimescale = 2; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); - m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); + vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); break; case Vehicle.TYPE_BALLOON: - m_linearFrictionTimescale = new Vector3(5, 5, 5); - m_angularFrictionTimescale = new Vector3(10, 10, 10); - m_linearMotorTimescale = 5; - m_linearMotorDecayTimescale = 60; - m_angularMotorTimescale = 6; - m_angularMotorDecayTimescale = 10; - m_VhoverHeight = 5; - m_VhoverEfficiency = 0.8f; - m_VhoverTimescale = 10; - m_VehicleBuoyancy = 1; - m_linearDeflectionEfficiency = 0; - m_linearDeflectionTimescale = 5; - m_angularDeflectionEfficiency = 0; - m_angularDeflectionTimescale = 5; - m_verticalAttractionEfficiency = 0f; - m_verticalAttractionTimescale = 1000f; - m_bankingEfficiency = 0; - m_bankingMix = 0.7f; - m_bankingTimescale = 5; - m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | + vd.m_linearFrictionTimescale = new Vector3(5, 5, 5); + vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); + vd.m_linearMotorTimescale = 5; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 6; + vd.m_angularMotorDecayTimescale = 10; + vd.m_VhoverHeight = 5; + vd.m_VhoverEfficiency = 0.8f; + vd.m_VhoverTimescale = 10; + vd.m_VehicleBuoyancy = 1; + vd.m_linearDeflectionEfficiency = 0; + vd.m_linearDeflectionTimescale = 5; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 5; + vd.m_verticalAttractionEfficiency = 0f; + vd.m_verticalAttractionTimescale = 1000f; + vd.m_bankingEfficiency = 0; + vd.m_bankingMix = 0.7f; + vd.m_bankingTimescale = 5; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); - m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | + vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); break; } @@ -424,7 +432,8 @@ namespace OpenSim.Region.Framework.Scenes // crap crap crap if (ph == null) // what ?? return; - + ph.SetVehicle(vd); +/* ph.VehicleType = (int)m_type; // Linear properties @@ -465,6 +474,7 @@ namespace OpenSim.Region.Framework.Scenes ph.VehicleFlags(~(int)m_flags, true); ph.VehicleFlags((int)m_flags, false); + */ } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 324fdb8..1cce4c0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1965,6 +1965,7 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup Copy(bool userExposed) { + m_dupeInProgress = true; SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); dupe.m_isBackedUp = false; dupe.m_parts = new MapAndArray(); @@ -2048,6 +2049,7 @@ namespace OpenSim.Region.Framework.Scenes ScheduleGroupForFullUpdate(); } + m_dupeInProgress = false; return dupe; } -- cgit v1.1 From 70b3b599bc09385c03cea0b0aca655f090b02e9f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 18:25:48 +0000 Subject: added some ToXml2 to SOGVehicle ( unused untested ) --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 85 ++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs index 470f403..d06224c 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -29,7 +29,10 @@ using System; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; - +using System.Xml; +using OpenSim.Framework.Serialization; +using OpenSim.Framework.Serialization.External; +using OpenSim.Region.Framework.Scenes.Serialization; namespace OpenSim.Region.Framework.Scenes { @@ -476,5 +479,85 @@ namespace OpenSim.Region.Framework.Scenes ph.VehicleFlags((int)m_flags, false); */ } + + private XmlTextWriter writer; + + private void XWint(string name, int i) + { + writer.WriteElementString(name, i.ToString()); + } + private void XWfloat(string name, float f) + { + writer.WriteElementString(name, f.ToString()); + } + + private void XWVector(string name, Vector3 vec) + { + writer.WriteStartElement(name); + writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + + + + private void XWQuat(string name, Quaternion quat) + { + writer.WriteStartElement(name); + writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); + writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + + public void ToXml2(XmlTextWriter twriter) + { + writer = twriter; + writer.WriteStartElement("SceneObjectVehicle"); + + XWint("V_Type", (int)vd.m_type); + XWint("V_Flags", (int)vd.m_flags); + + // Linear properties + XWVector("LM_DIRECTION", vd.m_linearMotorDirection); + XWVector("LM_FRICTION_TIMESCALE", vd.m_linearFrictionTimescale); + XWfloat("LM_DECAY_TIMESCALE", vd.m_linearMotorDecayTimescale); + XWfloat("LM_TIMESCALE", vd.m_linearMotorTimescale); + XWVector("LM_OFFSET", vd.m_linearMotorOffset); + + //Angular properties + XWVector("AM_DIRECTION", vd.m_angularMotorDirection); + XWfloat("AM_TIMESCALE", vd.m_angularMotorTimescale); + XWfloat("AM_DECAY_TIMESCALE", vd.m_angularMotorDecayTimescale); + XWVector("AM_FRICTION_TIMESCALE", vd.m_angularFrictionTimescale); + + //Deflection properties + XWfloat("AD_EFFICIENCY", vd.m_angularDeflectionEfficiency); + XWfloat("AD_TIMESCALE", vd.m_angularDeflectionTimescale); + XWfloat("LD_EFFICIENCY", vd.m_linearDeflectionEfficiency); + XWfloat("LD_TIMESCALE", vd.m_linearDeflectionTimescale); + + //Banking properties + XWfloat("B_EFFICIENCY", vd.m_bankingEfficiency); + XWfloat("B_MIX", vd.m_bankingMix); + XWfloat("B_TIMESCALE", vd.m_bankingTimescale); + + //Hover and Buoyancy properties + XWfloat("H_HEIGHT", vd.m_VhoverHeight); + XWfloat("H_EFFICIENCY", vd.m_VhoverEfficiency); + XWfloat("H_TIMESCALE", vd.m_VhoverTimescale); + XWfloat("VBUOYANCY", vd.m_VehicleBuoyancy); + + //Attractor properties + XWfloat("VA_EFFICIENCY", vd.m_verticalAttractionEfficiency); + XWfloat("VA_TIMESCALE", vd.m_verticalAttractionTimescale); + + XWQuat("REF_FRAME", vd.m_referenceFrame); + + writer.WriteEndElement(); + writer = null; + } } } \ No newline at end of file -- cgit v1.1 From 028dc1f4ed2e8bdc5e3d5e3d493a743e6d7b557f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 18:33:41 +0000 Subject: a bit less human readable xml --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 50 +++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs index d06224c..5a875ee 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -515,44 +515,44 @@ namespace OpenSim.Region.Framework.Scenes public void ToXml2(XmlTextWriter twriter) { writer = twriter; - writer.WriteStartElement("SceneObjectVehicle"); + writer.WriteStartElement("SOGVehicle"); - XWint("V_Type", (int)vd.m_type); - XWint("V_Flags", (int)vd.m_flags); + XWint("TYPE", (int)vd.m_type); + XWint("FLAGS", (int)vd.m_flags); // Linear properties - XWVector("LM_DIRECTION", vd.m_linearMotorDirection); - XWVector("LM_FRICTION_TIMESCALE", vd.m_linearFrictionTimescale); - XWfloat("LM_DECAY_TIMESCALE", vd.m_linearMotorDecayTimescale); - XWfloat("LM_TIMESCALE", vd.m_linearMotorTimescale); - XWVector("LM_OFFSET", vd.m_linearMotorOffset); + XWVector("LMDIR", vd.m_linearMotorDirection); + XWVector("LMFTIME", vd.m_linearFrictionTimescale); + XWfloat("LMDTIME", vd.m_linearMotorDecayTimescale); + XWfloat("LMTIME", vd.m_linearMotorTimescale); + XWVector("LMOFF", vd.m_linearMotorOffset); //Angular properties - XWVector("AM_DIRECTION", vd.m_angularMotorDirection); - XWfloat("AM_TIMESCALE", vd.m_angularMotorTimescale); - XWfloat("AM_DECAY_TIMESCALE", vd.m_angularMotorDecayTimescale); - XWVector("AM_FRICTION_TIMESCALE", vd.m_angularFrictionTimescale); + XWVector("AMDIR", vd.m_angularMotorDirection); + XWfloat("AMTIME", vd.m_angularMotorTimescale); + XWfloat("AMDTIME", vd.m_angularMotorDecayTimescale); + XWVector("AMFTIME", vd.m_angularFrictionTimescale); //Deflection properties - XWfloat("AD_EFFICIENCY", vd.m_angularDeflectionEfficiency); - XWfloat("AD_TIMESCALE", vd.m_angularDeflectionTimescale); - XWfloat("LD_EFFICIENCY", vd.m_linearDeflectionEfficiency); - XWfloat("LD_TIMESCALE", vd.m_linearDeflectionTimescale); + XWfloat("ADEFF", vd.m_angularDeflectionEfficiency); + XWfloat("ADTIME", vd.m_angularDeflectionTimescale); + XWfloat("LDEFF", vd.m_linearDeflectionEfficiency); + XWfloat("LDTIME", vd.m_linearDeflectionTimescale); //Banking properties - XWfloat("B_EFFICIENCY", vd.m_bankingEfficiency); - XWfloat("B_MIX", vd.m_bankingMix); - XWfloat("B_TIMESCALE", vd.m_bankingTimescale); + XWfloat("BEFF", vd.m_bankingEfficiency); + XWfloat("BMIX", vd.m_bankingMix); + XWfloat("BTIME", vd.m_bankingTimescale); //Hover and Buoyancy properties - XWfloat("H_HEIGHT", vd.m_VhoverHeight); - XWfloat("H_EFFICIENCY", vd.m_VhoverEfficiency); - XWfloat("H_TIMESCALE", vd.m_VhoverTimescale); - XWfloat("VBUOYANCY", vd.m_VehicleBuoyancy); + XWfloat("HHEI", vd.m_VhoverHeight); + XWfloat("HEFF", vd.m_VhoverEfficiency); + XWfloat("HTIME", vd.m_VhoverTimescale); + XWfloat("VBUO", vd.m_VehicleBuoyancy); //Attractor properties - XWfloat("VA_EFFICIENCY", vd.m_verticalAttractionEfficiency); - XWfloat("VA_TIMESCALE", vd.m_verticalAttractionTimescale); + XWfloat("VAEFF", vd.m_verticalAttractionEfficiency); + XWfloat("VATIME", vd.m_verticalAttractionTimescale); XWQuat("REF_FRAME", vd.m_referenceFrame); -- cgit v1.1 From a62baf8ea453c7798057895d7c09ac0b81116f27 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 18:37:29 +0000 Subject: added a EnUsCulture whatever that is.. --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs index 5a875ee..ac70d04 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -484,11 +484,12 @@ namespace OpenSim.Region.Framework.Scenes private void XWint(string name, int i) { - writer.WriteElementString(name, i.ToString()); + writer.WriteElementString(name, i.ToString()); } + private void XWfloat(string name, float f) { - writer.WriteElementString(name, f.ToString()); + writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); } private void XWVector(string name, Vector3 vec) @@ -500,8 +501,6 @@ namespace OpenSim.Region.Framework.Scenes writer.WriteEndElement(); } - - private void XWQuat(string name, Quaternion quat) { writer.WriteStartElement(name); -- cgit v1.1 From 7a1ab03b7534fdd76bb0266216e3a5990b93ee77 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Feb 2012 19:31:36 +0000 Subject: missing paramenters init plus some cleaning --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 107 ++++---------------------- 1 file changed, 16 insertions(+), 91 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs index ac70d04..5651de3 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs @@ -38,53 +38,13 @@ namespace OpenSim.Region.Framework.Scenes { public class SOGVehicle { + public VehicleData vd; + public Vehicle Type { get { return vd.m_type; } } - - public VehicleData vd; -/* - private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind - private VehicleFlag m_flags = (VehicleFlag)0; - - // Linear properties - private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time - private Vector3 m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); - private float m_linearMotorDecayTimescale = 120; - private float m_linearMotorTimescale = 1000; - private Vector3 m_linearMotorOffset = Vector3.Zero; - - //Angular properties - private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor - private float m_angularMotorTimescale = 1000; // motor angular velocity ramp up rate - private float m_angularMotorDecayTimescale = 120; // motor angular velocity decay rate - private Vector3 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); // body angular velocity decay rate - - //Deflection properties - private float m_angularDeflectionEfficiency = 0; - private float m_angularDeflectionTimescale = 1000; - private float m_linearDeflectionEfficiency = 0; - private float m_linearDeflectionTimescale = 1000; - - //Banking properties - private float m_bankingEfficiency = 0; - private float m_bankingMix = 0; - private float m_bankingTimescale = 0; - - //Hover and Buoyancy properties - private float m_VhoverHeight = 0f; - private float m_VhoverEfficiency = 0f; - private float m_VhoverTimescale = 1000f; - private float m_VehicleBuoyancy = 0f; - - //Attractor properties - private float m_verticalAttractionEfficiency = 1.0f; // damped - private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. - - // Axis - public Quaternion m_referenceFrame = Quaternion.Identity; -*/ + public SOGVehicle() { vd = new VehicleData(); @@ -274,16 +234,14 @@ namespace OpenSim.Region.Framework.Scenes { vd.m_linearMotorDirection = Vector3.Zero; vd.m_angularMotorDirection = Vector3.Zero; - vd.m_linearMotorOffset = Vector3.Zero; - vd.m_referenceFrame = Quaternion.Identity; // Set Defaults For Type vd.m_type = pType; switch (pType) { - case Vehicle.TYPE_NONE: // none sense this will never exist + case Vehicle.TYPE_NONE: vd.m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); vd.m_linearMotorTimescale = 1000; @@ -291,8 +249,19 @@ namespace OpenSim.Region.Framework.Scenes vd.m_angularMotorTimescale = 1000; vd.m_angularMotorDecayTimescale = 1000; vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 1; vd.m_VhoverTimescale = 1000; vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 0; + vd.m_linearDeflectionTimescale = 1000; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 1000; + vd.m_bankingEfficiency = 0; + vd.m_bankingMix = 1; + vd.m_bankingTimescale = 1000; + vd.m_verticalAttractionEfficiency = 0; + vd.m_verticalAttractionTimescale = 1000; + vd.m_flags = (VehicleFlag)0; break; @@ -431,53 +400,9 @@ namespace OpenSim.Region.Framework.Scenes } public void SetVehicle(PhysicsActor ph) { - - // crap crap crap - if (ph == null) // what ?? + if (ph == null) return; ph.SetVehicle(vd); -/* - ph.VehicleType = (int)m_type; - - // Linear properties - ph.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_DIRECTION, m_linearMotorDirection); - ph.VehicleVectorParam((int)Vehicle.LINEAR_FRICTION_TIMESCALE, m_linearFrictionTimescale); - ph.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, m_linearMotorDecayTimescale); - ph.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_TIMESCALE, m_linearMotorTimescale); - ph.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_OFFSET, m_linearMotorOffset); - - //Angular properties - ph.VehicleVectorParam((int)Vehicle.ANGULAR_MOTOR_DIRECTION, m_angularMotorDirection); - ph.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_TIMESCALE, m_angularMotorTimescale); - ph.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, m_angularMotorDecayTimescale); - ph.VehicleVectorParam((int)Vehicle.ANGULAR_FRICTION_TIMESCALE, m_angularFrictionTimescale); - - //Deflection properties - ph.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, m_angularDeflectionEfficiency); - ph.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_TIMESCALE, m_angularDeflectionTimescale); - ph.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_EFFICIENCY, m_linearDeflectionEfficiency); - ph.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_TIMESCALE, m_linearDeflectionTimescale); - - //Banking properties - ph.VehicleFloatParam((int)Vehicle.BANKING_EFFICIENCY, m_bankingEfficiency); - ph.VehicleFloatParam((int)Vehicle.BANKING_MIX, m_bankingMix); - ph.VehicleFloatParam((int)Vehicle.BANKING_TIMESCALE, m_bankingTimescale); - - //Hover and Buoyancy properties - ph.VehicleFloatParam((int)Vehicle.HOVER_HEIGHT, m_VhoverHeight); - ph.VehicleFloatParam((int)Vehicle.HOVER_EFFICIENCY, m_VhoverEfficiency); - ph.VehicleFloatParam((int)Vehicle.HOVER_TIMESCALE, m_VhoverTimescale); - ph.VehicleFloatParam((int)Vehicle.BUOYANCY, m_VehicleBuoyancy); - - //Attractor properties - ph.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, m_verticalAttractionEfficiency); - ph.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_TIMESCALE, m_verticalAttractionTimescale); - - ph.VehicleRotationParam((int)Vehicle.REFERENCE_FRAME, m_referenceFrame); - - ph.VehicleFlags(~(int)m_flags, true); - ph.VehicleFlags((int)m_flags, false); - */ } private XmlTextWriter writer; -- cgit v1.1 From b77d354e6dcf1eb31486f0db3236780f63f23844 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 19 Feb 2012 13:21:01 +0000 Subject: moved vehicle from SOG to SOP --- OpenSim/Region/Framework/Scenes/SOGVehicle.cs | 487 --------------------- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 487 +++++++++++++++++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 90 ---- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 87 +++- 4 files changed, 563 insertions(+), 588 deletions(-) delete mode 100644 OpenSim/Region/Framework/Scenes/SOGVehicle.cs create mode 100644 OpenSim/Region/Framework/Scenes/SOPVehicle.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOGVehicle.cs deleted file mode 100644 index 5651de3..0000000 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Physics.Manager; -using System.Xml; -using OpenSim.Framework.Serialization; -using OpenSim.Framework.Serialization.External; -using OpenSim.Region.Framework.Scenes.Serialization; - -namespace OpenSim.Region.Framework.Scenes -{ - public class SOGVehicle - { - public VehicleData vd; - - public Vehicle Type - { - get { return vd.m_type; } - } - - public SOGVehicle() - { - vd = new VehicleData(); - ProcessTypeChange(Vehicle.TYPE_NONE); // is needed? - } - - public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) - { - float len; - float timestep = 0.01f; - switch (pParam) - { - case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: - if (pValue < 0f) pValue = 0f; - if (pValue > 1f) pValue = 1f; - vd.m_angularDeflectionEfficiency = pValue; - break; - case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_angularDeflectionTimescale = pValue; - break; - case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: - if (pValue < timestep) pValue = timestep; - else if (pValue > 120) pValue = 120; - vd.m_angularMotorDecayTimescale = pValue; - break; - case Vehicle.ANGULAR_MOTOR_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_angularMotorTimescale = pValue; - break; - case Vehicle.BANKING_EFFICIENCY: - if (pValue < -1f) pValue = -1f; - if (pValue > 1f) pValue = 1f; - vd.m_bankingEfficiency = pValue; - break; - case Vehicle.BANKING_MIX: - if (pValue < 0f) pValue = 0f; - if (pValue > 1f) pValue = 1f; - vd.m_bankingMix = pValue; - break; - case Vehicle.BANKING_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_bankingTimescale = pValue; - break; - case Vehicle.BUOYANCY: - if (pValue < -1f) pValue = -1f; - if (pValue > 1f) pValue = 1f; - vd.m_VehicleBuoyancy = pValue; - break; - case Vehicle.HOVER_EFFICIENCY: - if (pValue < 0f) pValue = 0f; - if (pValue > 1f) pValue = 1f; - vd.m_VhoverEfficiency = pValue; - break; - case Vehicle.HOVER_HEIGHT: - vd.m_VhoverHeight = pValue; - break; - case Vehicle.HOVER_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_VhoverTimescale = pValue; - break; - case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: - if (pValue < 0f) pValue = 0f; - if (pValue > 1f) pValue = 1f; - vd.m_linearDeflectionEfficiency = pValue; - break; - case Vehicle.LINEAR_DEFLECTION_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_linearDeflectionTimescale = pValue; - break; - case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: - // if (pValue < timestep) pValue = timestep; - // try to make impulses to work a bit better - if (pValue < timestep) pValue = timestep; - else if (pValue > 120) pValue = 120; - vd.m_linearMotorDecayTimescale = pValue; - break; - case Vehicle.LINEAR_MOTOR_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_linearMotorTimescale = pValue; - break; - case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: - if (pValue < 0f) pValue = 0f; - if (pValue > 1f) pValue = 1f; - vd.m_verticalAttractionEfficiency = pValue; - break; - case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_verticalAttractionTimescale = pValue; - break; - - // These are vector properties but the engine lets you use a single float value to - // set all of the components to the same value - case Vehicle.ANGULAR_FRICTION_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); - break; - case Vehicle.ANGULAR_MOTOR_DIRECTION: - vd.m_angularMotorDirection = new Vector3(pValue, pValue, pValue); - len = vd.m_angularMotorDirection.Length(); - if (len > 12.566f) - vd.m_angularMotorDirection *= (12.566f / len); - break; - case Vehicle.LINEAR_FRICTION_TIMESCALE: - if (pValue < timestep) pValue = timestep; - vd.m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); - break; - case Vehicle.LINEAR_MOTOR_DIRECTION: - vd.m_linearMotorDirection = new Vector3(pValue, pValue, pValue); - len = vd.m_linearMotorDirection.Length(); - if (len > 30.0f) - vd.m_linearMotorDirection *= (30.0f / len); - break; - case Vehicle.LINEAR_MOTOR_OFFSET: - vd.m_linearMotorOffset = new Vector3(pValue, pValue, pValue); - len = vd.m_linearMotorOffset.Length(); - if (len > 100.0f) - vd.m_linearMotorOffset *= (100.0f / len); - break; - } - }//end ProcessFloatVehicleParam - - public void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) - { - float len; - float timestep = 0.01f; - switch (pParam) - { - case Vehicle.ANGULAR_FRICTION_TIMESCALE: - if (pValue.X < timestep) pValue.X = timestep; - if (pValue.Y < timestep) pValue.Y = timestep; - if (pValue.Z < timestep) pValue.Z = timestep; - - vd.m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); - break; - case Vehicle.ANGULAR_MOTOR_DIRECTION: - vd.m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); - // Limit requested angular speed to 2 rps= 4 pi rads/sec - len = vd.m_angularMotorDirection.Length(); - if (len > 12.566f) - vd.m_angularMotorDirection *= (12.566f / len); - break; - case Vehicle.LINEAR_FRICTION_TIMESCALE: - if (pValue.X < timestep) pValue.X = timestep; - if (pValue.Y < timestep) pValue.Y = timestep; - if (pValue.Z < timestep) pValue.Z = timestep; - vd.m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); - break; - case Vehicle.LINEAR_MOTOR_DIRECTION: - vd.m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); - len = vd.m_linearMotorDirection.Length(); - if (len > 30.0f) - vd.m_linearMotorDirection *= (30.0f / len); - break; - case Vehicle.LINEAR_MOTOR_OFFSET: - vd.m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); - len = vd.m_linearMotorOffset.Length(); - if (len > 100.0f) - vd.m_linearMotorOffset *= (100.0f / len); - break; - } - }//end ProcessVectorVehicleParam - - public void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) - { - switch (pParam) - { - case Vehicle.REFERENCE_FRAME: - vd.m_referenceFrame = Quaternion.Inverse(pValue); - break; - } - }//end ProcessRotationVehicleParam - - public void ProcessVehicleFlags(int pParam, bool remove) - { - if (remove) - { - vd.m_flags &= ~((VehicleFlag)pParam); - } - else - { - vd.m_flags |= (VehicleFlag)pParam; - } - }//end ProcessVehicleFlags - - public void ProcessTypeChange(Vehicle pType) - { - vd.m_linearMotorDirection = Vector3.Zero; - vd.m_angularMotorDirection = Vector3.Zero; - vd.m_linearMotorOffset = Vector3.Zero; - vd.m_referenceFrame = Quaternion.Identity; - - // Set Defaults For Type - vd.m_type = pType; - switch (pType) - { - case Vehicle.TYPE_NONE: - vd.m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); - vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); - vd.m_linearMotorTimescale = 1000; - vd.m_linearMotorDecayTimescale = 120; - vd.m_angularMotorTimescale = 1000; - vd.m_angularMotorDecayTimescale = 1000; - vd.m_VhoverHeight = 0; - vd.m_VhoverEfficiency = 1; - vd.m_VhoverTimescale = 1000; - vd.m_VehicleBuoyancy = 0; - vd.m_linearDeflectionEfficiency = 0; - vd.m_linearDeflectionTimescale = 1000; - vd.m_angularDeflectionEfficiency = 0; - vd.m_angularDeflectionTimescale = 1000; - vd.m_bankingEfficiency = 0; - vd.m_bankingMix = 1; - vd.m_bankingTimescale = 1000; - vd.m_verticalAttractionEfficiency = 0; - vd.m_verticalAttractionTimescale = 1000; - - vd.m_flags = (VehicleFlag)0; - break; - - case Vehicle.TYPE_SLED: - vd.m_linearFrictionTimescale = new Vector3(30, 1, 1000); - vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); - vd.m_linearMotorTimescale = 1000; - vd.m_linearMotorDecayTimescale = 120; - vd.m_angularMotorTimescale = 1000; - vd.m_angularMotorDecayTimescale = 120; - vd.m_VhoverHeight = 0; - vd.m_VhoverEfficiency = 1; - vd.m_VhoverTimescale = 10; - vd.m_VehicleBuoyancy = 0; - vd.m_linearDeflectionEfficiency = 1; - vd.m_linearDeflectionTimescale = 1; - vd.m_angularDeflectionEfficiency = 0; - vd.m_angularDeflectionTimescale = 1000; - vd.m_bankingEfficiency = 0; - vd.m_bankingMix = 1; - vd.m_bankingTimescale = 10; - vd.m_flags &= - ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | - VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); - vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); - break; - case Vehicle.TYPE_CAR: - vd.m_linearFrictionTimescale = new Vector3(100, 2, 1000); - vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); - vd.m_linearMotorTimescale = 1; - vd.m_linearMotorDecayTimescale = 60; - vd.m_angularMotorTimescale = 1; - vd.m_angularMotorDecayTimescale = 0.8f; - vd.m_VhoverHeight = 0; - vd.m_VhoverEfficiency = 0; - vd.m_VhoverTimescale = 1000; - vd.m_VehicleBuoyancy = 0; - vd.m_linearDeflectionEfficiency = 1; - vd.m_linearDeflectionTimescale = 2; - vd.m_angularDeflectionEfficiency = 0; - vd.m_angularDeflectionTimescale = 10; - vd.m_verticalAttractionEfficiency = 1f; - vd.m_verticalAttractionTimescale = 10f; - vd.m_bankingEfficiency = -0.2f; - vd.m_bankingMix = 1; - vd.m_bankingTimescale = 1; - vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); - vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | - VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); - break; - case Vehicle.TYPE_BOAT: - vd.m_linearFrictionTimescale = new Vector3(10, 3, 2); - vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); - vd.m_linearMotorTimescale = 5; - vd.m_linearMotorDecayTimescale = 60; - vd.m_angularMotorTimescale = 4; - vd.m_angularMotorDecayTimescale = 4; - vd.m_VhoverHeight = 0; - vd.m_VhoverEfficiency = 0.5f; - vd.m_VhoverTimescale = 2; - vd.m_VehicleBuoyancy = 1; - vd.m_linearDeflectionEfficiency = 0.5f; - vd.m_linearDeflectionTimescale = 3; - vd.m_angularDeflectionEfficiency = 0.5f; - vd.m_angularDeflectionTimescale = 5; - vd.m_verticalAttractionEfficiency = 0.5f; - vd.m_verticalAttractionTimescale = 5f; - vd.m_bankingEfficiency = -0.3f; - vd.m_bankingMix = 0.8f; - vd.m_bankingTimescale = 1; - vd.m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | - VehicleFlag.HOVER_GLOBAL_HEIGHT | - VehicleFlag.HOVER_UP_ONLY | - VehicleFlag.LIMIT_ROLL_ONLY); - vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | - VehicleFlag.LIMIT_MOTOR_UP | - VehicleFlag.HOVER_WATER_ONLY); - break; - case Vehicle.TYPE_AIRPLANE: - vd.m_linearFrictionTimescale = new Vector3(200, 10, 5); - vd.m_angularFrictionTimescale = new Vector3(20, 20, 20); - vd.m_linearMotorTimescale = 2; - vd.m_linearMotorDecayTimescale = 60; - vd.m_angularMotorTimescale = 4; - vd.m_angularMotorDecayTimescale = 8; - vd.m_VhoverHeight = 0; - vd.m_VhoverEfficiency = 0.5f; - vd.m_VhoverTimescale = 1000; - vd.m_VehicleBuoyancy = 0; - vd.m_linearDeflectionEfficiency = 0.5f; - vd.m_linearDeflectionTimescale = 0.5f; - vd.m_angularDeflectionEfficiency = 1; - vd.m_angularDeflectionTimescale = 2; - vd.m_verticalAttractionEfficiency = 0.9f; - vd.m_verticalAttractionTimescale = 2f; - vd.m_bankingEfficiency = 1; - vd.m_bankingMix = 0.7f; - vd.m_bankingTimescale = 2; - vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | - VehicleFlag.HOVER_TERRAIN_ONLY | - VehicleFlag.HOVER_GLOBAL_HEIGHT | - VehicleFlag.HOVER_UP_ONLY | - VehicleFlag.NO_DEFLECTION_UP | - VehicleFlag.LIMIT_MOTOR_UP); - vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); - break; - case Vehicle.TYPE_BALLOON: - vd.m_linearFrictionTimescale = new Vector3(5, 5, 5); - vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); - vd.m_linearMotorTimescale = 5; - vd.m_linearMotorDecayTimescale = 60; - vd.m_angularMotorTimescale = 6; - vd.m_angularMotorDecayTimescale = 10; - vd.m_VhoverHeight = 5; - vd.m_VhoverEfficiency = 0.8f; - vd.m_VhoverTimescale = 10; - vd.m_VehicleBuoyancy = 1; - vd.m_linearDeflectionEfficiency = 0; - vd.m_linearDeflectionTimescale = 5; - vd.m_angularDeflectionEfficiency = 0; - vd.m_angularDeflectionTimescale = 5; - vd.m_verticalAttractionEfficiency = 0f; - vd.m_verticalAttractionTimescale = 1000f; - vd.m_bankingEfficiency = 0; - vd.m_bankingMix = 0.7f; - vd.m_bankingTimescale = 5; - vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | - VehicleFlag.HOVER_TERRAIN_ONLY | - VehicleFlag.HOVER_UP_ONLY | - VehicleFlag.NO_DEFLECTION_UP | - VehicleFlag.LIMIT_MOTOR_UP); - vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | - VehicleFlag.HOVER_GLOBAL_HEIGHT); - break; - } - } - public void SetVehicle(PhysicsActor ph) - { - if (ph == null) - return; - ph.SetVehicle(vd); - } - - private XmlTextWriter writer; - - private void XWint(string name, int i) - { - writer.WriteElementString(name, i.ToString()); - } - - private void XWfloat(string name, float f) - { - writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); - } - - private void XWVector(string name, Vector3 vec) - { - writer.WriteStartElement(name); - writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); - writer.WriteEndElement(); - } - - private void XWQuat(string name, Quaternion quat) - { - writer.WriteStartElement(name); - writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); - writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); - writer.WriteEndElement(); - } - - public void ToXml2(XmlTextWriter twriter) - { - writer = twriter; - writer.WriteStartElement("SOGVehicle"); - - XWint("TYPE", (int)vd.m_type); - XWint("FLAGS", (int)vd.m_flags); - - // Linear properties - XWVector("LMDIR", vd.m_linearMotorDirection); - XWVector("LMFTIME", vd.m_linearFrictionTimescale); - XWfloat("LMDTIME", vd.m_linearMotorDecayTimescale); - XWfloat("LMTIME", vd.m_linearMotorTimescale); - XWVector("LMOFF", vd.m_linearMotorOffset); - - //Angular properties - XWVector("AMDIR", vd.m_angularMotorDirection); - XWfloat("AMTIME", vd.m_angularMotorTimescale); - XWfloat("AMDTIME", vd.m_angularMotorDecayTimescale); - XWVector("AMFTIME", vd.m_angularFrictionTimescale); - - //Deflection properties - XWfloat("ADEFF", vd.m_angularDeflectionEfficiency); - XWfloat("ADTIME", vd.m_angularDeflectionTimescale); - XWfloat("LDEFF", vd.m_linearDeflectionEfficiency); - XWfloat("LDTIME", vd.m_linearDeflectionTimescale); - - //Banking properties - XWfloat("BEFF", vd.m_bankingEfficiency); - XWfloat("BMIX", vd.m_bankingMix); - XWfloat("BTIME", vd.m_bankingTimescale); - - //Hover and Buoyancy properties - XWfloat("HHEI", vd.m_VhoverHeight); - XWfloat("HEFF", vd.m_VhoverEfficiency); - XWfloat("HTIME", vd.m_VhoverTimescale); - XWfloat("VBUO", vd.m_VehicleBuoyancy); - - //Attractor properties - XWfloat("VAEFF", vd.m_verticalAttractionEfficiency); - XWfloat("VATIME", vd.m_verticalAttractionTimescale); - - XWQuat("REF_FRAME", vd.m_referenceFrame); - - writer.WriteEndElement(); - writer = null; - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs new file mode 100644 index 0000000..39786bd --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -0,0 +1,487 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; +using System.Xml; +using OpenSim.Framework.Serialization; +using OpenSim.Framework.Serialization.External; +using OpenSim.Region.Framework.Scenes.Serialization; + +namespace OpenSim.Region.Framework.Scenes +{ + public class SOPVehicle + { + public VehicleData vd; + + public Vehicle Type + { + get { return vd.m_type; } + } + + public SOPVehicle() + { + vd = new VehicleData(); + ProcessTypeChange(Vehicle.TYPE_NONE); // is needed? + } + + public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) + { + float len; + float timestep = 0.01f; + switch (pParam) + { + case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + vd.m_angularDeflectionEfficiency = pValue; + break; + case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_angularDeflectionTimescale = pValue; + break; + case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: + if (pValue < timestep) pValue = timestep; + else if (pValue > 120) pValue = 120; + vd.m_angularMotorDecayTimescale = pValue; + break; + case Vehicle.ANGULAR_MOTOR_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_angularMotorTimescale = pValue; + break; + case Vehicle.BANKING_EFFICIENCY: + if (pValue < -1f) pValue = -1f; + if (pValue > 1f) pValue = 1f; + vd.m_bankingEfficiency = pValue; + break; + case Vehicle.BANKING_MIX: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + vd.m_bankingMix = pValue; + break; + case Vehicle.BANKING_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_bankingTimescale = pValue; + break; + case Vehicle.BUOYANCY: + if (pValue < -1f) pValue = -1f; + if (pValue > 1f) pValue = 1f; + vd.m_VehicleBuoyancy = pValue; + break; + case Vehicle.HOVER_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + vd.m_VhoverEfficiency = pValue; + break; + case Vehicle.HOVER_HEIGHT: + vd.m_VhoverHeight = pValue; + break; + case Vehicle.HOVER_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_VhoverTimescale = pValue; + break; + case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + vd.m_linearDeflectionEfficiency = pValue; + break; + case Vehicle.LINEAR_DEFLECTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_linearDeflectionTimescale = pValue; + break; + case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: + // if (pValue < timestep) pValue = timestep; + // try to make impulses to work a bit better + if (pValue < timestep) pValue = timestep; + else if (pValue > 120) pValue = 120; + vd.m_linearMotorDecayTimescale = pValue; + break; + case Vehicle.LINEAR_MOTOR_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_linearMotorTimescale = pValue; + break; + case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: + if (pValue < 0f) pValue = 0f; + if (pValue > 1f) pValue = 1f; + vd.m_verticalAttractionEfficiency = pValue; + break; + case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_verticalAttractionTimescale = pValue; + break; + + // These are vector properties but the engine lets you use a single float value to + // set all of the components to the same value + case Vehicle.ANGULAR_FRICTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); + break; + case Vehicle.ANGULAR_MOTOR_DIRECTION: + vd.m_angularMotorDirection = new Vector3(pValue, pValue, pValue); + len = vd.m_angularMotorDirection.Length(); + if (len > 12.566f) + vd.m_angularMotorDirection *= (12.566f / len); + break; + case Vehicle.LINEAR_FRICTION_TIMESCALE: + if (pValue < timestep) pValue = timestep; + vd.m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); + break; + case Vehicle.LINEAR_MOTOR_DIRECTION: + vd.m_linearMotorDirection = new Vector3(pValue, pValue, pValue); + len = vd.m_linearMotorDirection.Length(); + if (len > 30.0f) + vd.m_linearMotorDirection *= (30.0f / len); + break; + case Vehicle.LINEAR_MOTOR_OFFSET: + vd.m_linearMotorOffset = new Vector3(pValue, pValue, pValue); + len = vd.m_linearMotorOffset.Length(); + if (len > 100.0f) + vd.m_linearMotorOffset *= (100.0f / len); + break; + } + }//end ProcessFloatVehicleParam + + public void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) + { + float len; + float timestep = 0.01f; + switch (pParam) + { + case Vehicle.ANGULAR_FRICTION_TIMESCALE: + if (pValue.X < timestep) pValue.X = timestep; + if (pValue.Y < timestep) pValue.Y = timestep; + if (pValue.Z < timestep) pValue.Z = timestep; + + vd.m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); + break; + case Vehicle.ANGULAR_MOTOR_DIRECTION: + vd.m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); + // Limit requested angular speed to 2 rps= 4 pi rads/sec + len = vd.m_angularMotorDirection.Length(); + if (len > 12.566f) + vd.m_angularMotorDirection *= (12.566f / len); + break; + case Vehicle.LINEAR_FRICTION_TIMESCALE: + if (pValue.X < timestep) pValue.X = timestep; + if (pValue.Y < timestep) pValue.Y = timestep; + if (pValue.Z < timestep) pValue.Z = timestep; + vd.m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); + break; + case Vehicle.LINEAR_MOTOR_DIRECTION: + vd.m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); + len = vd.m_linearMotorDirection.Length(); + if (len > 30.0f) + vd.m_linearMotorDirection *= (30.0f / len); + break; + case Vehicle.LINEAR_MOTOR_OFFSET: + vd.m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); + len = vd.m_linearMotorOffset.Length(); + if (len > 100.0f) + vd.m_linearMotorOffset *= (100.0f / len); + break; + } + }//end ProcessVectorVehicleParam + + public void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) + { + switch (pParam) + { + case Vehicle.REFERENCE_FRAME: + vd.m_referenceFrame = Quaternion.Inverse(pValue); + break; + } + }//end ProcessRotationVehicleParam + + public void ProcessVehicleFlags(int pParam, bool remove) + { + if (remove) + { + vd.m_flags &= ~((VehicleFlag)pParam); + } + else + { + vd.m_flags |= (VehicleFlag)pParam; + } + }//end ProcessVehicleFlags + + public void ProcessTypeChange(Vehicle pType) + { + vd.m_linearMotorDirection = Vector3.Zero; + vd.m_angularMotorDirection = Vector3.Zero; + vd.m_linearMotorOffset = Vector3.Zero; + vd.m_referenceFrame = Quaternion.Identity; + + // Set Defaults For Type + vd.m_type = pType; + switch (pType) + { + case Vehicle.TYPE_NONE: + vd.m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_linearMotorTimescale = 1000; + vd.m_linearMotorDecayTimescale = 120; + vd.m_angularMotorTimescale = 1000; + vd.m_angularMotorDecayTimescale = 1000; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 1; + vd.m_VhoverTimescale = 1000; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 0; + vd.m_linearDeflectionTimescale = 1000; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 1000; + vd.m_bankingEfficiency = 0; + vd.m_bankingMix = 1; + vd.m_bankingTimescale = 1000; + vd.m_verticalAttractionEfficiency = 0; + vd.m_verticalAttractionTimescale = 1000; + + vd.m_flags = (VehicleFlag)0; + break; + + case Vehicle.TYPE_SLED: + vd.m_linearFrictionTimescale = new Vector3(30, 1, 1000); + vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_linearMotorTimescale = 1000; + vd.m_linearMotorDecayTimescale = 120; + vd.m_angularMotorTimescale = 1000; + vd.m_angularMotorDecayTimescale = 120; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 1; + vd.m_VhoverTimescale = 10; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 1; + vd.m_linearDeflectionTimescale = 1; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 1000; + vd.m_bankingEfficiency = 0; + vd.m_bankingMix = 1; + vd.m_bankingTimescale = 10; + vd.m_flags &= + ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); + vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); + break; + case Vehicle.TYPE_CAR: + vd.m_linearFrictionTimescale = new Vector3(100, 2, 1000); + vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); + vd.m_linearMotorTimescale = 1; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 1; + vd.m_angularMotorDecayTimescale = 0.8f; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 0; + vd.m_VhoverTimescale = 1000; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 1; + vd.m_linearDeflectionTimescale = 2; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 10; + vd.m_verticalAttractionEfficiency = 1f; + vd.m_verticalAttractionTimescale = 10f; + vd.m_bankingEfficiency = -0.2f; + vd.m_bankingMix = 1; + vd.m_bankingTimescale = 1; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); + vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | + VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); + break; + case Vehicle.TYPE_BOAT: + vd.m_linearFrictionTimescale = new Vector3(10, 3, 2); + vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); + vd.m_linearMotorTimescale = 5; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 4; + vd.m_angularMotorDecayTimescale = 4; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 0.5f; + vd.m_VhoverTimescale = 2; + vd.m_VehicleBuoyancy = 1; + vd.m_linearDeflectionEfficiency = 0.5f; + vd.m_linearDeflectionTimescale = 3; + vd.m_angularDeflectionEfficiency = 0.5f; + vd.m_angularDeflectionTimescale = 5; + vd.m_verticalAttractionEfficiency = 0.5f; + vd.m_verticalAttractionTimescale = 5f; + vd.m_bankingEfficiency = -0.3f; + vd.m_bankingMix = 0.8f; + vd.m_bankingTimescale = 1; + vd.m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT | + VehicleFlag.HOVER_UP_ONLY | + VehicleFlag.LIMIT_ROLL_ONLY); + vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | + VehicleFlag.LIMIT_MOTOR_UP | + VehicleFlag.HOVER_WATER_ONLY); + break; + case Vehicle.TYPE_AIRPLANE: + vd.m_linearFrictionTimescale = new Vector3(200, 10, 5); + vd.m_angularFrictionTimescale = new Vector3(20, 20, 20); + vd.m_linearMotorTimescale = 2; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 4; + vd.m_angularMotorDecayTimescale = 8; + vd.m_VhoverHeight = 0; + vd.m_VhoverEfficiency = 0.5f; + vd.m_VhoverTimescale = 1000; + vd.m_VehicleBuoyancy = 0; + vd.m_linearDeflectionEfficiency = 0.5f; + vd.m_linearDeflectionTimescale = 0.5f; + vd.m_angularDeflectionEfficiency = 1; + vd.m_angularDeflectionTimescale = 2; + vd.m_verticalAttractionEfficiency = 0.9f; + vd.m_verticalAttractionTimescale = 2f; + vd.m_bankingEfficiency = 1; + vd.m_bankingMix = 0.7f; + vd.m_bankingTimescale = 2; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | + VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT | + VehicleFlag.HOVER_UP_ONLY | + VehicleFlag.NO_DEFLECTION_UP | + VehicleFlag.LIMIT_MOTOR_UP); + vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); + break; + case Vehicle.TYPE_BALLOON: + vd.m_linearFrictionTimescale = new Vector3(5, 5, 5); + vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); + vd.m_linearMotorTimescale = 5; + vd.m_linearMotorDecayTimescale = 60; + vd.m_angularMotorTimescale = 6; + vd.m_angularMotorDecayTimescale = 10; + vd.m_VhoverHeight = 5; + vd.m_VhoverEfficiency = 0.8f; + vd.m_VhoverTimescale = 10; + vd.m_VehicleBuoyancy = 1; + vd.m_linearDeflectionEfficiency = 0; + vd.m_linearDeflectionTimescale = 5; + vd.m_angularDeflectionEfficiency = 0; + vd.m_angularDeflectionTimescale = 5; + vd.m_verticalAttractionEfficiency = 0f; + vd.m_verticalAttractionTimescale = 1000f; + vd.m_bankingEfficiency = 0; + vd.m_bankingMix = 0.7f; + vd.m_bankingTimescale = 5; + vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | + VehicleFlag.HOVER_TERRAIN_ONLY | + VehicleFlag.HOVER_UP_ONLY | + VehicleFlag.NO_DEFLECTION_UP | + VehicleFlag.LIMIT_MOTOR_UP); + vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | + VehicleFlag.HOVER_GLOBAL_HEIGHT); + break; + } + } + public void SetVehicle(PhysicsActor ph) + { + if (ph == null) + return; + ph.SetVehicle(vd); + } + + private XmlTextWriter writer; + + private void XWint(string name, int i) + { + writer.WriteElementString(name, i.ToString()); + } + + private void XWfloat(string name, float f) + { + writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); + } + + private void XWVector(string name, Vector3 vec) + { + writer.WriteStartElement(name); + writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + + private void XWQuat(string name, Quaternion quat) + { + writer.WriteStartElement(name); + writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); + writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); + writer.WriteEndElement(); + } + + public void ToXml2(XmlTextWriter twriter) + { + writer = twriter; + writer.WriteStartElement("SOGVehicle"); + + XWint("TYPE", (int)vd.m_type); + XWint("FLAGS", (int)vd.m_flags); + + // Linear properties + XWVector("LMDIR", vd.m_linearMotorDirection); + XWVector("LMFTIME", vd.m_linearFrictionTimescale); + XWfloat("LMDTIME", vd.m_linearMotorDecayTimescale); + XWfloat("LMTIME", vd.m_linearMotorTimescale); + XWVector("LMOFF", vd.m_linearMotorOffset); + + //Angular properties + XWVector("AMDIR", vd.m_angularMotorDirection); + XWfloat("AMTIME", vd.m_angularMotorTimescale); + XWfloat("AMDTIME", vd.m_angularMotorDecayTimescale); + XWVector("AMFTIME", vd.m_angularFrictionTimescale); + + //Deflection properties + XWfloat("ADEFF", vd.m_angularDeflectionEfficiency); + XWfloat("ADTIME", vd.m_angularDeflectionTimescale); + XWfloat("LDEFF", vd.m_linearDeflectionEfficiency); + XWfloat("LDTIME", vd.m_linearDeflectionTimescale); + + //Banking properties + XWfloat("BEFF", vd.m_bankingEfficiency); + XWfloat("BMIX", vd.m_bankingMix); + XWfloat("BTIME", vd.m_bankingTimescale); + + //Hover and Buoyancy properties + XWfloat("HHEI", vd.m_VhoverHeight); + XWfloat("HEFF", vd.m_VhoverEfficiency); + XWfloat("HTIME", vd.m_VhoverTimescale); + XWfloat("VBUO", vd.m_VehicleBuoyancy); + + //Attractor properties + XWfloat("VAEFF", vd.m_verticalAttractionEfficiency); + XWfloat("VATIME", vd.m_verticalAttractionTimescale); + + XWQuat("REF_FRAME", vd.m_referenceFrame); + + writer.WriteEndElement(); + writer = null; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1cce4c0..3427199 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -115,90 +115,6 @@ namespace OpenSim.Region.Framework.Scenes private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - private SOGVehicle m_vehicle = null; - - public int VehicleType - { - get - { - if (m_vehicle == null) - return (int)Vehicle.TYPE_NONE; - else - return (int)m_vehicle.Type; - } - set - { - m_vehicle = null; - if (value == (int)Vehicle.TYPE_NONE) - { - if (RootPart.PhysActor != null) - RootPart.PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; - return; - } - m_vehicle = new SOGVehicle(); - m_vehicle.ProcessTypeChange((Vehicle)value); - { - if (RootPart.PhysActor != null) - RootPart.PhysActor.VehicleType = value; - return; - } - - } - } - - public void SetVehicleFlags(int param, bool remove) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessVehicleFlags(param, remove); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleFlags(param, remove); - } - } - - public void SetVehicleFloatParam(int param, float value) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleFloatParam(param, value); - } - } - - public void SetVehicleVectorParam(int param, Vector3 value) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleVectorParam(param, value); - } - } - - public void SetVehicleRotationParam(int param, Quaternion rotation) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleRotationParam(param, rotation); - } - } - - public bool areUpdatesSuspended { get @@ -1782,8 +1698,6 @@ namespace OpenSim.Region.Framework.Scenes // ResetChildPrimPhysicsPositions(); if (m_rootPart.PhysActor != null) { - if (m_vehicle != null) - m_vehicle.SetVehicle(m_rootPart.PhysActor); m_rootPart.PhysActor.Building = false; } } @@ -1791,10 +1705,6 @@ namespace OpenSim.Region.Framework.Scenes { // Apply physics to the root prim m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); - if (m_rootPart.PhysActor != null && m_vehicle != null) - { - m_vehicle.SetVehicle(m_rootPart.PhysActor); - } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6438694..eb59ffd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -310,6 +310,9 @@ namespace OpenSim.Region.Framework.Scenes private UUID m_collisionSound; private float m_collisionSoundVolume; + + private SOPVehicle m_vehicle = null; + #endregion Fields // ~SceneObjectPart() @@ -1556,8 +1559,14 @@ namespace OpenSim.Region.Framework.Scenes { PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info PhysActor.SetMaterial(Material); + + // if root part apply vehicle + if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicle.SetVehicle(PhysActor); + DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + if (!building) PhysActor.Building = false; } @@ -3168,39 +3177,90 @@ namespace OpenSim.Region.Framework.Scenes } } + + public int VehicleType + { + get + { + if (m_vehicle == null) + return (int)Vehicle.TYPE_NONE; + else + return (int)m_vehicle.Type; + } + set + { + SetVehicleType(value); + } + } + public void SetVehicleType(int type) { - if (ParentGroup.IsDeleted) - return; - ParentGroup.VehicleType = type; + m_vehicle = null; + if (type == (int)Vehicle.TYPE_NONE) + { + if (_parentID ==0 && PhysActor != null) + PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; + return; + } + m_vehicle = new SOPVehicle(); + m_vehicle.ProcessTypeChange((Vehicle)type); + { + if (_parentID ==0 && PhysActor != null) + PhysActor.VehicleType = type; + return; + } } public void SetVehicleFlags(int param, bool remove) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleFlags(param, remove); + + m_vehicle.ProcessVehicleFlags(param, remove); + + if (_parentID ==0 && PhysActor != null) + { + PhysActor.VehicleFlags(param, remove); + } } public void SetVehicleFloatParam(int param, float value) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleFloatParam(param, value); + + m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); + + if (_parentID == 0 && PhysActor != null) + { + PhysActor.VehicleFloatParam(param, value); + } } public void SetVehicleVectorParam(int param, Vector3 value) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleVectorParam(param, value); + + m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); + + if (_parentID == 0 && PhysActor != null) + { + PhysActor.VehicleVectorParam(param, value); + } } public void SetVehicleRotationParam(int param, Quaternion rotation) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleRotationParam(param, rotation); + + m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); + + if (_parentID == 0 && PhysActor != null) + { + PhysActor.VehicleRotationParam(param, rotation); + } } /// @@ -4380,6 +4440,11 @@ namespace OpenSim.Region.Framework.Scenes m_localId); PhysActor.SetMaterial(Material); + + // if root part apply vehicle + if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicle.SetVehicle(PhysActor); + DoPhysicsPropertyUpdate(UsePhysics, true); if (!ParentGroup.IsDeleted) -- cgit v1.1 From 60d68ee3122a974007adec6e651fad461d8abda4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 19 Feb 2012 18:10:00 +0000 Subject: Vehicle XML serialization more complete. Inactived by coments in SceneObjectSerializar.cs until proper testing --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 223 ++++++++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 ++ .../Scenes/Serialization/SceneObjectSerializer.cs | 28 +++ 3 files changed, 260 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 39786bd..b462867 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; @@ -33,6 +34,7 @@ using System.Xml; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Region.Framework.Scenes.Serialization; namespace OpenSim.Region.Framework.Scenes { @@ -44,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes { get { return vd.m_type; } } - + public SOPVehicle() { vd = new VehicleData(); @@ -116,8 +118,6 @@ namespace OpenSim.Region.Framework.Scenes vd.m_linearDeflectionTimescale = pValue; break; case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: - // if (pValue < timestep) pValue = timestep; - // try to make impulses to work a bit better if (pValue < timestep) pValue = timestep; else if (pValue > 120) pValue = 120; vd.m_linearMotorDecayTimescale = pValue; @@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes public void ToXml2(XmlTextWriter twriter) { writer = twriter; - writer.WriteStartElement("SOGVehicle"); + writer.WriteStartElement("Vehicle"); XWint("TYPE", (int)vd.m_type); XWint("FLAGS", (int)vd.m_flags); @@ -483,5 +483,220 @@ namespace OpenSim.Region.Framework.Scenes writer.WriteEndElement(); writer = null; } + + private int XRint(XmlTextReader reader, string name) + { + return reader.ReadElementContentAsInt(name, String.Empty); + } + + private float XRfloat(XmlTextReader reader, string name) + { + return reader.ReadElementContentAsFloat(name, String.Empty); + } + + public Vector3 XRvector(XmlTextReader reader, string name) + { + Vector3 vec; + reader.ReadStartElement(name); + vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x + vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y + vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z + reader.ReadEndElement(); + return vec; + } + + public Quaternion XRquat(XmlTextReader reader, string name) + { + Quaternion q; + reader.ReadStartElement(name); + q.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + q.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + q.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + q.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + reader.ReadEndElement(); + return q; + } + + public void FromXml2(XmlTextReader reader, out bool errors) + { + errors = false; + + Dictionary> m_VehicleXmlProcessors + = new Dictionary>(); + + m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type); + m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags); + + // Linear properties + m_VehicleXmlProcessors.Add("LMDIR", ProcessXR_linearMotorDirection); + m_VehicleXmlProcessors.Add("LMFTIME", ProcessXR_linearFrictionTimescale); + m_VehicleXmlProcessors.Add("LMDTIME", ProcessXR_linearMotorDecayTimescale); + m_VehicleXmlProcessors.Add("LMTIME", ProcessXR_linearMotorTimescale); + m_VehicleXmlProcessors.Add("LMOFF", ProcessXR_linearMotorOffset); + + //Angular properties + m_VehicleXmlProcessors.Add("AMDIR", ProcessXR_angularMotorDirection); + m_VehicleXmlProcessors.Add("AMTIME", ProcessXR_angularMotorTimescale); + m_VehicleXmlProcessors.Add("AMDTIME", ProcessXR_angularMotorDecayTimescale); + m_VehicleXmlProcessors.Add("AMFTIME", ProcessXR_angularFrictionTimescale); + + //Deflection properties + m_VehicleXmlProcessors.Add("ADEFF", ProcessXR_angularDeflectionEfficiency); + m_VehicleXmlProcessors.Add("ADTIME", ProcessXR_angularDeflectionTimescale); + m_VehicleXmlProcessors.Add("LDEFF", ProcessXR_linearDeflectionEfficiency); + m_VehicleXmlProcessors.Add("LDTIME", ProcessXR_linearDeflectionTimescale); + + //Banking properties + m_VehicleXmlProcessors.Add("BEFF", ProcessXR_bankingEfficiency); + m_VehicleXmlProcessors.Add("BMIX", ProcessXR_bankingMix); + m_VehicleXmlProcessors.Add("BTIME", ProcessXR_bankingTimescale); + + //Hover and Buoyancy properties + m_VehicleXmlProcessors.Add("HHEI", ProcessXR_VhoverHeight); + m_VehicleXmlProcessors.Add("HEFF", ProcessXR_VhoverEfficiency); + m_VehicleXmlProcessors.Add("HTIME", ProcessXR_VhoverTimescale); + + m_VehicleXmlProcessors.Add("VBUO", ProcessXR_VehicleBuoyancy); + + //Attractor properties + m_VehicleXmlProcessors.Add("VAEFF", ProcessXR_verticalAttractionEfficiency); + m_VehicleXmlProcessors.Add("VATIME", ProcessXR_verticalAttractionTimescale); + + m_VehicleXmlProcessors.Add("REF_FRAME", ProcessXR_referenceFrame); + + vd = new VehicleData(); + + reader.ReadStartElement("Vehicle", String.Empty); + + errors = ExternalRepresentationUtils.ExecuteReadProcessors( + vd, + m_VehicleXmlProcessors, + reader, + (o, nodeName, e) + => + { + } + ); + + reader.ReadEndElement(); + } + + private void ProcessXR_type(VehicleData obj, XmlTextReader reader) + { + vd.m_type = (Vehicle)XRint(reader, "TYPE"); + } + private void ProcessXR_flags(VehicleData obj, XmlTextReader reader) + { + vd.m_flags = (VehicleFlag)XRint(reader, "FLAGS"); + } + // Linear properties + private void ProcessXR_linearMotorDirection(VehicleData obj, XmlTextReader reader) + { + vd.m_linearMotorDirection = XRvector(reader, "LMDIR"); + } + + private void ProcessXR_linearFrictionTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_linearFrictionTimescale = XRvector(reader, "LMFTIME"); + } + + private void ProcessXR_linearMotorDecayTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_linearMotorDecayTimescale = XRfloat(reader, "LMDTIME"); + } + private void ProcessXR_linearMotorTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_linearMotorTimescale = XRfloat(reader, "LMTIME"); + } + private void ProcessXR_linearMotorOffset(VehicleData obj, XmlTextReader reader) + { + vd.m_linearMotorOffset = XRvector(reader, "LMOFF"); + } + + + //Angular properties + private void ProcessXR_angularMotorDirection(VehicleData obj, XmlTextReader reader) + { + vd.m_angularMotorDirection = XRvector(reader, "AMDIR"); + } + private void ProcessXR_angularMotorTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_angularMotorTimescale = XRfloat(reader, "AMTIME"); + } + private void ProcessXR_angularMotorDecayTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_angularMotorDecayTimescale = XRfloat(reader, "AMDTIME"); + } + private void ProcessXR_angularFrictionTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_angularFrictionTimescale = XRvector(reader, "AMFTIME"); + } + + //Deflection properties + private void ProcessXR_angularDeflectionEfficiency(VehicleData obj, XmlTextReader reader) + { + vd.m_angularDeflectionEfficiency = XRfloat(reader, "ADEFF"); + } + private void ProcessXR_angularDeflectionTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_angularDeflectionTimescale = XRfloat(reader, "ADTIME"); + } + private void ProcessXR_linearDeflectionEfficiency(VehicleData obj, XmlTextReader reader) + { + vd.m_linearDeflectionEfficiency = XRfloat(reader, "LDEFF"); + } + private void ProcessXR_linearDeflectionTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_linearDeflectionTimescale = XRfloat(reader, "LDTIME"); + } + + //Banking properties + private void ProcessXR_bankingEfficiency(VehicleData obj, XmlTextReader reader) + { + vd.m_bankingEfficiency = XRfloat(reader, "BEFF"); + } + private void ProcessXR_bankingMix(VehicleData obj, XmlTextReader reader) + { + vd.m_bankingMix = XRfloat(reader, "BMIX"); + } + private void ProcessXR_bankingTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_bankingTimescale = XRfloat(reader, "BTIME"); + } + + //Hover and Buoyancy properties + private void ProcessXR_VhoverHeight(VehicleData obj, XmlTextReader reader) + { + vd.m_VhoverHeight = XRfloat(reader, "HHEI"); + } + private void ProcessXR_VhoverEfficiency(VehicleData obj, XmlTextReader reader) + { + vd.m_VhoverEfficiency = XRfloat(reader, "HEFF"); + } + private void ProcessXR_VhoverTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_VhoverTimescale = XRfloat(reader, "HTIME"); + } + + private void ProcessXR_VehicleBuoyancy(VehicleData obj, XmlTextReader reader) + { + vd.m_VehicleBuoyancy = XRfloat(reader, "VBUO"); + } + + //Attractor properties + private void ProcessXR_verticalAttractionEfficiency(VehicleData obj, XmlTextReader reader) + { + vd.m_verticalAttractionEfficiency = XRfloat(reader, "VAEFF"); + } + private void ProcessXR_verticalAttractionTimescale(VehicleData obj, XmlTextReader reader) + { + vd.m_verticalAttractionTimescale = XRfloat(reader, "VATIME"); + } + + private void ProcessXR_referenceFrame(VehicleData obj, XmlTextReader reader) + { + vd.m_referenceFrame = XRquat(reader, "REF_FRAME"); + + } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index eb59ffd..4cd5183 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3177,6 +3177,18 @@ namespace OpenSim.Region.Framework.Scenes } } + public SOPVehicle sopVehicle + { + get + { + return m_vehicle; + } + set + { + m_vehicle = value; + } + } + public int VehicleType { @@ -3196,6 +3208,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleType(int type) { m_vehicle = null; + if (type == (int)Vehicle.TYPE_NONE) { if (_parentID ==0 && PhysActor != null) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 4b80e37..eaf32b8 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -349,6 +349,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); + + //Ubit comented until proper testing + // m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); + + #endregion #region TaskInventoryXmlProcessors initialization @@ -571,6 +576,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); } + private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) + { + bool errors = false; + SOPVehicle _vehicle = new SOPVehicle(); + + _vehicle.FromXml2(reader, out errors); + + if (errors) + { + obj.sopVehicle = null; + m_log.DebugFormat( + "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", + obj.Name, obj.UUID); + } + else + obj.sopVehicle = _vehicle; + } + + private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) { bool errors = false; @@ -1231,6 +1255,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); + //Ubit comented until proper testing + // if (sop.sopVehicle != null) + // sop.sopVehicle.ToXml2(writer); + writer.WriteEndElement(); } -- cgit v1.1 From 3c9b7f2c0c40e6a976be708763ab166fcdee66b1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 19 Feb 2012 19:27:01 +0000 Subject: simplified vehicle fromXml. Use still comented on SceneObjectSerialized.cs --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 194 ++++++++++++++++---------- 1 file changed, 117 insertions(+), 77 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index b462867..d3c2d27 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -484,45 +484,91 @@ namespace OpenSim.Region.Framework.Scenes writer = null; } - private int XRint(XmlTextReader reader, string name) + + + XmlTextReader reader; + + private int XRint() { - return reader.ReadElementContentAsInt(name, String.Empty); + return reader.ReadElementContentAsInt(); } - private float XRfloat(XmlTextReader reader, string name) + private float XRfloat() { - return reader.ReadElementContentAsFloat(name, String.Empty); + return reader.ReadElementContentAsFloat(); } - public Vector3 XRvector(XmlTextReader reader, string name) + public Vector3 XRvector() { Vector3 vec; - reader.ReadStartElement(name); - vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x - vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y - vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z + reader.ReadStartElement(); + vec.X = reader.ReadElementContentAsFloat(); + vec.Y = reader.ReadElementContentAsFloat(); + vec.Z = reader.ReadElementContentAsFloat(); reader.ReadEndElement(); return vec; } - public Quaternion XRquat(XmlTextReader reader, string name) + public Quaternion XRquat() { Quaternion q; - reader.ReadStartElement(name); - q.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); - q.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); - q.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); - q.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); + reader.ReadStartElement(); + q.X = reader.ReadElementContentAsFloat(); + q.Y = reader.ReadElementContentAsFloat(); + q.Z = reader.ReadElementContentAsFloat(); + q.W = reader.ReadElementContentAsFloat(); reader.ReadEndElement(); return q; } - public void FromXml2(XmlTextReader reader, out bool errors) + public static bool EReadProcessors( + Dictionary processors, + XmlTextReader xtr) + { + bool errors = false; + + string nodeName = string.Empty; + while (xtr.NodeType != XmlNodeType.EndElement) + { + nodeName = xtr.Name; + + // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); + + Action p = null; + if (processors.TryGetValue(xtr.Name, out p)) + { + // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); + + try + { + p(); + } + catch (Exception e) + { + errors = true; + if (xtr.NodeType == XmlNodeType.EndElement) + xtr.Read(); + } + } + else + { + // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); + xtr.ReadOuterXml(); // ignore + } + } + + return errors; + } + + + + public void FromXml2(XmlTextReader _reader, out bool errors) { errors = false; + reader = _reader; - Dictionary> m_VehicleXmlProcessors - = new Dictionary>(); + Dictionary m_VehicleXmlProcessors + = new Dictionary(); m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type); m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags); @@ -568,135 +614,129 @@ namespace OpenSim.Region.Framework.Scenes reader.ReadStartElement("Vehicle", String.Empty); - errors = ExternalRepresentationUtils.ExecuteReadProcessors( - vd, + errors = EReadProcessors( m_VehicleXmlProcessors, - reader, - (o, nodeName, e) - => - { - } - ); + reader); reader.ReadEndElement(); + reader = null; } - private void ProcessXR_type(VehicleData obj, XmlTextReader reader) + private void ProcessXR_type() { - vd.m_type = (Vehicle)XRint(reader, "TYPE"); + vd.m_type = (Vehicle)XRint(); } - private void ProcessXR_flags(VehicleData obj, XmlTextReader reader) + private void ProcessXR_flags() { - vd.m_flags = (VehicleFlag)XRint(reader, "FLAGS"); + vd.m_flags = (VehicleFlag)XRint(); } // Linear properties - private void ProcessXR_linearMotorDirection(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearMotorDirection() { - vd.m_linearMotorDirection = XRvector(reader, "LMDIR"); + vd.m_linearMotorDirection = XRvector(); } - private void ProcessXR_linearFrictionTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearFrictionTimescale() { - vd.m_linearFrictionTimescale = XRvector(reader, "LMFTIME"); + vd.m_linearFrictionTimescale = XRvector(); } - private void ProcessXR_linearMotorDecayTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearMotorDecayTimescale() { - vd.m_linearMotorDecayTimescale = XRfloat(reader, "LMDTIME"); + vd.m_linearMotorDecayTimescale = XRfloat(); } - private void ProcessXR_linearMotorTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearMotorTimescale() { - vd.m_linearMotorTimescale = XRfloat(reader, "LMTIME"); + vd.m_linearMotorTimescale = XRfloat(); } - private void ProcessXR_linearMotorOffset(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearMotorOffset() { - vd.m_linearMotorOffset = XRvector(reader, "LMOFF"); + vd.m_linearMotorOffset = XRvector(); } //Angular properties - private void ProcessXR_angularMotorDirection(VehicleData obj, XmlTextReader reader) + private void ProcessXR_angularMotorDirection() { - vd.m_angularMotorDirection = XRvector(reader, "AMDIR"); + vd.m_angularMotorDirection = XRvector(); } - private void ProcessXR_angularMotorTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_angularMotorTimescale() { - vd.m_angularMotorTimescale = XRfloat(reader, "AMTIME"); + vd.m_angularMotorTimescale = XRfloat(); } - private void ProcessXR_angularMotorDecayTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_angularMotorDecayTimescale() { - vd.m_angularMotorDecayTimescale = XRfloat(reader, "AMDTIME"); + vd.m_angularMotorDecayTimescale = XRfloat(); } - private void ProcessXR_angularFrictionTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_angularFrictionTimescale() { - vd.m_angularFrictionTimescale = XRvector(reader, "AMFTIME"); + vd.m_angularFrictionTimescale = XRvector(); } //Deflection properties - private void ProcessXR_angularDeflectionEfficiency(VehicleData obj, XmlTextReader reader) + private void ProcessXR_angularDeflectionEfficiency() { - vd.m_angularDeflectionEfficiency = XRfloat(reader, "ADEFF"); + vd.m_angularDeflectionEfficiency = XRfloat(); } - private void ProcessXR_angularDeflectionTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_angularDeflectionTimescale() { - vd.m_angularDeflectionTimescale = XRfloat(reader, "ADTIME"); + vd.m_angularDeflectionTimescale = XRfloat(); } - private void ProcessXR_linearDeflectionEfficiency(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearDeflectionEfficiency() { - vd.m_linearDeflectionEfficiency = XRfloat(reader, "LDEFF"); + vd.m_linearDeflectionEfficiency = XRfloat(); } - private void ProcessXR_linearDeflectionTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_linearDeflectionTimescale() { - vd.m_linearDeflectionTimescale = XRfloat(reader, "LDTIME"); + vd.m_linearDeflectionTimescale = XRfloat(); } //Banking properties - private void ProcessXR_bankingEfficiency(VehicleData obj, XmlTextReader reader) + private void ProcessXR_bankingEfficiency() { - vd.m_bankingEfficiency = XRfloat(reader, "BEFF"); + vd.m_bankingEfficiency = XRfloat(); } - private void ProcessXR_bankingMix(VehicleData obj, XmlTextReader reader) + private void ProcessXR_bankingMix() { - vd.m_bankingMix = XRfloat(reader, "BMIX"); + vd.m_bankingMix = XRfloat(); } - private void ProcessXR_bankingTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_bankingTimescale() { - vd.m_bankingTimescale = XRfloat(reader, "BTIME"); + vd.m_bankingTimescale = XRfloat(); } //Hover and Buoyancy properties - private void ProcessXR_VhoverHeight(VehicleData obj, XmlTextReader reader) + private void ProcessXR_VhoverHeight() { - vd.m_VhoverHeight = XRfloat(reader, "HHEI"); + vd.m_VhoverHeight = XRfloat(); } - private void ProcessXR_VhoverEfficiency(VehicleData obj, XmlTextReader reader) + private void ProcessXR_VhoverEfficiency() { - vd.m_VhoverEfficiency = XRfloat(reader, "HEFF"); + vd.m_VhoverEfficiency = XRfloat(); } - private void ProcessXR_VhoverTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_VhoverTimescale() { - vd.m_VhoverTimescale = XRfloat(reader, "HTIME"); + vd.m_VhoverTimescale = XRfloat(); } - private void ProcessXR_VehicleBuoyancy(VehicleData obj, XmlTextReader reader) + private void ProcessXR_VehicleBuoyancy() { - vd.m_VehicleBuoyancy = XRfloat(reader, "VBUO"); + vd.m_VehicleBuoyancy = XRfloat(); } //Attractor properties - private void ProcessXR_verticalAttractionEfficiency(VehicleData obj, XmlTextReader reader) + private void ProcessXR_verticalAttractionEfficiency() { - vd.m_verticalAttractionEfficiency = XRfloat(reader, "VAEFF"); + vd.m_verticalAttractionEfficiency = XRfloat(); } - private void ProcessXR_verticalAttractionTimescale(VehicleData obj, XmlTextReader reader) + private void ProcessXR_verticalAttractionTimescale() { - vd.m_verticalAttractionTimescale = XRfloat(reader, "VATIME"); + vd.m_verticalAttractionTimescale = XRfloat(); } - private void ProcessXR_referenceFrame(VehicleData obj, XmlTextReader reader) + private void ProcessXR_referenceFrame() { - vd.m_referenceFrame = XRquat(reader, "REF_FRAME"); - + vd.m_referenceFrame = XRquat(); } } } \ No newline at end of file -- cgit v1.1 From 4bc3a0ecf46178a50730990f07cff25904b332ad Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 19 Feb 2012 20:25:20 +0100 Subject: Uncomment serialization --- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9f6dabb..72a0ec3 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -352,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); //Ubit comented until proper testing - // m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); + m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); #endregion @@ -1259,8 +1259,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); //Ubit comented until proper testing - // if (sop.sopVehicle != null) - // sop.sopVehicle.ToXml2(writer); + if (sop.sopVehicle != null) + sop.sopVehicle.ToXml2(writer); writer.WriteEndElement(); } -- cgit v1.1 From 8f8206f47841cb0dd9db4e28377e32dd21f0dec0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 20 Feb 2012 16:55:12 +0100 Subject: Add an override to make SOG.Velocity work as expected --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2481dd2..cf8637f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -605,6 +605,12 @@ namespace OpenSim.Region.Framework.Scenes } } + public override Vector3 Velocity + { + get { return RootPart.Velocity; } + set { RootPart.Velocity = value; } + } + private void CrossAgentToNewRegionCompleted(IAsyncResult iar) { CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; -- cgit v1.1 From d6b8febbf44e5aed73153129a4fa55c3fb10eee2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 20 Feb 2012 19:49:01 +0100 Subject: Make vehicles retain velocity when crossing between regions. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 613f9b5..d32b20a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1539,6 +1539,7 @@ namespace OpenSim.Region.Framework.Scenes // or flexible if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) { + Vector3 velocity = Velocity; try { PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( @@ -1570,6 +1571,9 @@ namespace OpenSim.Region.Framework.Scenes DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + Velocity = velocity; + PhysActor.Velocity = velocity; + if (!building) PhysActor.Building = false; } -- cgit v1.1 From 0e4d5a4d3ce54530f39d513146b066a55769d231 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Feb 2012 10:10:04 +0100 Subject: Also preserve angular velocity on crossing. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d32b20a..dd9431b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1540,6 +1540,7 @@ namespace OpenSim.Region.Framework.Scenes if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) { Vector3 velocity = Velocity; + Vector3 rotationalVelocity = AngularVelocity; try { PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( @@ -1572,7 +1573,9 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); Velocity = velocity; + AngularVelocity = rotationalVelocity; PhysActor.Velocity = velocity; + PhysActor.RotationalVelocity = rotationalVelocity; if (!building) PhysActor.Building = false; -- cgit v1.1 From 1e1270166f6d574916ada7b2bd5923115bd07052 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 22 Feb 2012 20:40:44 +0100 Subject: Adjust sit target and the llSetLinkPrimitiveParams sit position hack to match SL. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 283de39..ec8716b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.Framework.Scenes /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis /// issue #1716 /// - public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); + public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); /// /// Movement updates for agents in neighboring regions are sent directly to clients. @@ -2301,7 +2301,27 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + double x, y, z, m; + + Quaternion r = sitTargetOrient; + m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; + + if (Math.Abs(1.0 - m) > 0.000001) + { + m = 1.0 / Math.Sqrt(m); + r.X *= (float)m; + r.Y *= (float)m; + r.Z *= (float)m; + r.W *= (float)m; + } + + x = 2 * (r.X * r.Z + r.Y * r.W); + y = 2 * (-r.X * r.W + r.Y * r.Z); + z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; + + Vector3 up = new Vector3((float)x, (float)y, (float)z); + Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; + m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); -- cgit v1.1 From dc835717d66678eddfd802717a068c6131e460fc Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 14:08:35 +0100 Subject: Properly sequence updates of avatars and attachments so that we don't update attachments on child avatars or intermingle agent and attachment updates, which would render the root prim of huds invisible --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a3839c2..2c118d6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -984,6 +984,7 @@ namespace OpenSim.Region.Framework.Scenes Util.FireAndForget(delegate(object x) { foreach (SceneObjectGroup sog in m_attachments) { + sog.ScheduleGroupForFullUpdate(); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); } @@ -991,6 +992,8 @@ namespace OpenSim.Region.Framework.Scenes } } + SendAvatarDataToAllAgents(); + // send the animations of the other presences to me m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { -- cgit v1.1 From f3ea2bde617fa6c55b89973cdea2fb8e217d83bd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 20:32:35 +0100 Subject: Fix preserving the animation state of a crossing seated avatar --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2c118d6..06da741 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -874,6 +874,8 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE]: Upgrading child to root agent for {0} in {1}", Name, m_scene.RegionInfo.RegionName); + bool wasChild = IsChildAgent; + if (ParentUUID != UUID.Zero) { m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); @@ -893,10 +895,16 @@ namespace OpenSim.Region.Framework.Scenes pos = ParentPosition; } ParentUUID = UUID.Zero; + + IsChildAgent = false; + + Animator.TrySetMovementAnimation("SIT"); + } + else + { + IsChildAgent = false; } - bool wasChild = IsChildAgent; - IsChildAgent = false; IGroupsModule gm = m_scene.RequestModuleInterface(); if (gm != null) -- cgit v1.1 From e74bf4600759c3fee6aa62ee808bbf214c019b6d Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 23:18:01 +0100 Subject: Prevent a nullref when nonphysical motion objects cross sim boundaries --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cf8637f..248d4c6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -582,7 +582,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence av in m_linkedAvatars) { SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); - if (m_parts.TryGetValue(p.UUID, out p)) + if (p != null && m_parts.TryGetValue(p.UUID, out p)) { Vector3 offset = p.GetWorldPosition() - av.ParentPosition; av.AbsolutePosition += offset; -- cgit v1.1 From daf58575f8a8a4610dab833d00b94811732c33cc Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 23:05:04 +0000 Subject: Partially apply the core banlines fix --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b7162da..fcbed9f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5472,7 +5472,7 @@ Environment.Exit(1); // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToTargetUpdate(ref agent_control_v3); + presence.HandleMoveToTargetUpdate(1, ref agent_control_v3); presence.AddNewMovement(agent_control_v3); } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 06da741..26fa6c0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1095,7 +1095,7 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// + /// Do not call this directly. Call Scene.RequestTeleportLocation() instead. /// /// public void Teleport(Vector3 pos) @@ -1569,7 +1569,10 @@ namespace OpenSim.Region.Framework.Scenes } else if (bAllowUpdateMoveToPosition) { - if (HandleMoveToTargetUpdate(ref agent_control_v3)) + // The UseClientAgentPosition is set if parcel ban is forcing the avatar to move to a + // certain position. It's only check for tolerance on returning to that position is 0.2 + // rather than 1, at which point it removes its force target. + if (HandleMoveToTargetUpdate(agentData.UseClientAgentPosition ? 0.2 : 1, ref agent_control_v3)) update_movementflag = true; } } @@ -1631,7 +1634,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Cumulative agent movement that this method will update. /// True if movement has been updated in some way. False otherwise. - public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) + public bool HandleMoveToTargetUpdate(double tolerance, ref Vector3 agent_control_v3) { // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); @@ -1648,7 +1651,7 @@ namespace OpenSim.Region.Framework.Scenes // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); // Check the error term of the current position in relation to the target position - if (distanceToTarget <= 1) + if (distanceToTarget <= tolerance) { // We are close enough to the target AbsolutePosition = MoveToPositionTarget; @@ -1824,7 +1827,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation); Vector3 agent_control_v3 = new Vector3(); - HandleMoveToTargetUpdate(ref agent_control_v3); + HandleMoveToTargetUpdate(1, ref agent_control_v3); AddNewMovement(agent_control_v3); } -- cgit v1.1 From 991826ca76a80f8a1e03ce63d759185fddd5da4f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 24 Feb 2012 19:31:27 +0100 Subject: Try not to send the avatar updates on login. This may mean loggin in with invisible attachments again but could help the appearance issues. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 26fa6c0..01053bf 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1000,7 +1000,8 @@ namespace OpenSim.Region.Framework.Scenes } } - SendAvatarDataToAllAgents(); + if (wasChild) + SendAvatarDataToAllAgents(); // send the animations of the other presences to me m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) -- cgit v1.1 From 5eb1679367754d530edb4c50d432847ed1a027af Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 Feb 2012 12:25:16 +0100 Subject: Delay the sending of the initial werables update until the inventory and VFS in the viewer are ready. We're much faster than SL and that exposes this race condition. Also reinstate the extra avatar data send on login --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 01053bf..26fa6c0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1000,8 +1000,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (wasChild) - SendAvatarDataToAllAgents(); + SendAvatarDataToAllAgents(); // send the animations of the other presences to me m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) -- cgit v1.1 From e07440d0c53fdc8e90f4887242e3b21049a729c0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 25 Feb 2012 22:20:25 +0000 Subject: changed SOP Force and Torque, adding XML (de/)serialization, also changed Buoyance. PLEASE trap deserialization from inventory etc, making force and torque vector3.Zero, unless we want then to rez moving. (needs checking/testing as usual) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 23 +----- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 93 +++++++++++++++++++--- .../Scenes/Serialization/SceneObjectSerializer.cs | 17 +++- 3 files changed, 98 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 248d4c6..e9021f1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2045,30 +2045,9 @@ namespace OpenSim.Region.Framework.Scenes } } - public void setAngularImpulse(Vector3 impulse) - { - if (RootPart.PhysActor != null) - { - if (!IsAttachment) - { - RootPart.PhysActor.Torque = impulse; - m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); - } - } - } - public Vector3 GetTorque() { - if (RootPart.PhysActor != null) - { - if (!IsAttachment) - { - Vector3 torque = RootPart.PhysActor.Torque; - return torque; - } - } - - return Vector3.Zero; + return RootPart.Torque; } // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dd9431b..f35a27e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -294,6 +294,8 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastAngularVelocity; protected int m_lastTerseSent; protected float m_buoyancy = 0.0f; + protected Vector3 m_force; + protected Vector3 m_torque; /// /// Stores media texture data @@ -1302,14 +1304,66 @@ namespace OpenSim.Region.Framework.Scenes public float Buoyancy { - get { return m_buoyancy; } + get + { + if (ParentID != 0 && ParentGroup != null) + m_buoyancy = ParentGroup.RootPart.Buoyancy; + return m_buoyancy; + } set { m_buoyancy = value; - if (PhysActor != null) + if (ParentID != 0) { + if (ParentGroup != null) + ParentGroup.RootPart.Buoyancy = value; + } + else if (PhysActor != null) PhysActor.Buoyancy = value; + } + } + + public Vector3 Force + { + get + { + if (ParentID != 0 && ParentGroup != null) + m_force = ParentGroup.RootPart.Force; + return m_force; + } + + set + { + m_force = value; + if (ParentID != 0) + { + if (ParentGroup != null) + ParentGroup.RootPart.Force = value; } + else if (PhysActor != null) + PhysActor.Force = value; + } + } + + public Vector3 Torque + { + get + { + if (ParentID != 0 && ParentGroup != null) + m_torque = ParentGroup.RootPart.Torque; + return m_torque; + } + + set + { + m_torque = value; + if (ParentID != 0) + { + if (ParentGroup != null) + ParentGroup.RootPart.Torque = value; + } + else if (PhysActor != null) + PhysActor.Torque = value; } } @@ -1488,20 +1542,24 @@ namespace OpenSim.Region.Framework.Scenes /// /// Vector force /// true for the local frame, false for the global frame - public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) + + // this is actualy Set Torque.. keeping naming so not to edit lslapi also + public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) { - Vector3 impulse = impulsei; + Vector3 torque = torquei; if (localGlobalTF) { +/* Quaternion grot = GetWorldRotation(); Quaternion AXgrot = grot; Vector3 AXimpulsei = impulsei; Vector3 newimpulse = AXimpulsei * AXgrot; - impulse = newimpulse; + */ + torque *= GetWorldRotation(); } - ParentGroup.setAngularImpulse(impulse); + Torque = torque; } /// @@ -1571,14 +1629,22 @@ namespace OpenSim.Region.Framework.Scenes DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + + if (!building) + PhysActor.Building = false; Velocity = velocity; AngularVelocity = rotationalVelocity; PhysActor.Velocity = velocity; PhysActor.RotationalVelocity = rotationalVelocity; - if (!building) - PhysActor.Building = false; + // if not vehicle and root part apply force and torque + if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) + && LocalId == ParentGroup.RootPart.LocalId) + { + PhysActor.Force = Force; + PhysActor.Torque = Torque; + } } } } @@ -2002,10 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetForce() { - if (PhysActor != null) - return PhysActor.Force; - else - return Vector3.Zero; + return Force; } /// @@ -3150,10 +3213,13 @@ namespace OpenSim.Region.Framework.Scenes public void SetBuoyancy(float fvalue) { + Buoyancy = fvalue; +/* if (PhysActor != null) { PhysActor.Buoyancy = fvalue; } + */ } public void SetDieAtEdge(bool p) @@ -3181,10 +3247,13 @@ namespace OpenSim.Region.Framework.Scenes public void SetForce(Vector3 force) { + Force = force; +/* if (PhysActor != null) { PhysActor.Force = force; } + */ } public SOPVehicle sopVehicle diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 72a0ec3..ed761da 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -349,6 +349,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); + m_SOPXmlProcessors.Add("Force", ProcessForce); + m_SOPXmlProcessors.Add("Torque", ProcessTorque); m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); //Ubit comented until proper testing @@ -762,7 +764,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) { - obj.Buoyancy = (int)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); + obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); + } + + private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader) + { + obj.Force = Util.ReadVector(reader, "Force"); + } + private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader) + { + obj.Torque = Util.ReadVector(reader, "Torque"); } private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) @@ -1256,6 +1267,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); + + WriteVector(writer, "Force", sop.Force); + WriteVector(writer, "Torque", sop.Torque); + writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); //Ubit comented until proper testing -- cgit v1.1 From c82709c0d6c72852d8614651f9cb31df09fff883 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 02:36:34 +0100 Subject: Implement llSetKeyframedMotion. No persistence, no region crossing. Yet. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 315 +++++++++++++++++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 12 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 + 3 files changed, 330 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/KeyframeMotion.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs new file mode 100644 index 0000000..239f7ca --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -0,0 +1,315 @@ +// Proprietary code of Avination Virtual Limited +// (c) 2012 Melanie Thielker +// + +using System; +using System.Timers; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Reflection; +using System.Threading; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Framework.Scenes.Serialization; +using Timer = System.Timers.Timer; +using log4net; + +namespace OpenSim.Region.Framework.Scenes +{ + public class KeyframeMotion + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public enum PlayMode : int + { + Forward = 0, + Reverse = 1, + Loop = 2, + PingPong = 3 + }; + + [Flags] + public enum DataFormat : int + { + Translation = 1, + Rotation = 2 + } + + public struct Keyframe + { + public Vector3? Position; + public Quaternion? Rotation; + public Quaternion StartRotation; + public int TimeMS; + public int TimeTotal; + public Vector3 AngularVelocity; + }; + + private Vector3 m_basePosition; + private Quaternion m_baseRotation; + + private Keyframe m_currentFrame; + private List m_frames = new List(); + + private Keyframe[] m_keyframes; + + private Timer m_timer = new Timer(); + + private readonly SceneObjectGroup m_group; + + private PlayMode m_mode = PlayMode.Forward; + private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; + + private int m_iterations = 0; + + private const double timerInterval = 50.0; + + public DataFormat Data + { + get { return m_data; } + } + + public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) + { + m_mode = mode; + m_data = data; + + m_group = grp; + m_basePosition = grp.AbsolutePosition; + m_baseRotation = grp.GroupRotation; + + m_timer.Interval = (int)timerInterval; + m_timer.AutoReset = true; + m_timer.Elapsed += OnTimer; + } + + public void SetKeyframes(Keyframe[] frames) + { + m_keyframes = frames; + } + + public void Start() + { + if (m_keyframes.Length > 0) + m_timer.Start(); + } + + public void Stop() + { + m_timer.Stop(); + + m_basePosition = m_group.AbsolutePosition; + m_baseRotation = m_group.GroupRotation; + + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + m_group.SendGroupRootTerseUpdate(); + + m_frames.Clear(); + } + + public void Pause() + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + m_group.SendGroupRootTerseUpdate(); + + m_timer.Stop(); + } + + private void GetNextList() + { + m_frames.Clear(); + Vector3 pos = m_basePosition; + Quaternion rot = m_baseRotation; + + if (m_mode == PlayMode.Loop || m_mode == PlayMode.PingPong || m_iterations == 0) + { + int direction = 1; + if (m_mode == PlayMode.Reverse || ((m_mode == PlayMode.PingPong) && ((m_iterations & 1) != 0))) + direction = -1; + + int start = 0; + int end = m_keyframes.Length; +// if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1) +// end = m_keyframes.Length - 1; + + if (direction < 0) + { + start = m_keyframes.Length - 1; + end = -1; +// if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1) +// end = 0; + } + + for (int i = start; i != end ; i += direction) + { + Keyframe k = m_keyframes[i]; + + if (k.Position.HasValue) + k.Position = (k.Position * direction) + pos; + else + k.Position = pos; + + k.StartRotation = rot; + if (k.Rotation.HasValue) + { + if (direction == -1) + k.Rotation = Quaternion.Conjugate((Quaternion)k.Rotation); + k.Rotation = rot * k.Rotation; + } + else + { + k.Rotation = rot; + } + + float angle = 0; + + float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W; + float bb = ((Quaternion)k.Rotation).X * ((Quaternion)k.Rotation).X + ((Quaternion)k.Rotation).Y * ((Quaternion)k.Rotation).Y + ((Quaternion)k.Rotation).Z * ((Quaternion)k.Rotation).Z + ((Quaternion)k.Rotation).W * ((Quaternion)k.Rotation).W; + float aa_bb = aa * bb; + + if (aa_bb == 0) + { + angle = 0; + } + else + { + float ab = k.StartRotation.X * ((Quaternion)k.Rotation).X + + k.StartRotation.Y * ((Quaternion)k.Rotation).Y + + k.StartRotation.Z * ((Quaternion)k.Rotation).Z + + k.StartRotation.W * ((Quaternion)k.Rotation).W; + float q = (ab * ab) / aa_bb; + + if (q > 1.0f) + { + angle = 0; + } + else + { + angle = (float)Math.Acos(2 * q - 1); + } + } + + m_log.DebugFormat("[KEYFRAME]: Angle {0} aabb {1}", angle, aa_bb); + k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000)); + k.TimeTotal = k.TimeMS; + + m_frames.Add(k); + + pos = (Vector3)k.Position; + rot = (Quaternion)k.Rotation; + } + + m_basePosition = pos; + m_baseRotation = rot; + + m_iterations++; + } + } + + private void OnTimer(object sender, ElapsedEventArgs e) + { + if (m_frames.Count == 0) + { + GetNextList(); + + if (m_frames.Count == 0) + { + Stop(); + return; + } + + m_currentFrame = m_frames[0]; + } + + // Do the frame processing + double steps = (double)m_currentFrame.TimeMS / timerInterval; + float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; + + if (steps <= 1.0) + { + m_currentFrame.TimeMS = 0; + + m_group.AbsolutePosition = (Vector3)m_currentFrame.Position; + m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + } + else + { + Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; + Vector3 motionThisFrame = v / (float)steps; + v = v * 1000 / m_currentFrame.TimeMS; + + bool update = false; + + if (Vector3.Mag(motionThisFrame) >= 0.05f) + { + m_group.AbsolutePosition += motionThisFrame; + m_group.RootPart.Velocity = v; + update = true; + } + + if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) + { + Quaternion current = m_group.GroupRotation; + + Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); + + float angle = 0; + + float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; + float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; + float aa_bb = aa * bb; + + if (aa_bb == 0) + { + angle = 0; + } + else + { + float ab = current.X * step.X + + current.Y * step.Y + + current.Z * step.Z + + current.W * step.W; + float q = (ab * ab) / aa_bb; + + if (q > 1.0f) + { + angle = 0; + } + else + { + angle = (float)Math.Acos(2 * q - 1); + } + } + + if (angle > 0.01f) + { + m_group.UpdateGroupRotationR(step); + //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); + update = true; + } + } + + if (update) + m_group.SendGroupRootTerseUpdate(); + } + + m_currentFrame.TimeMS -= (int)timerInterval; + + if (m_currentFrame.TimeMS <= 0) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + m_group.SendGroupRootTerseUpdate(); + + m_frames.RemoveAt(0); + if (m_frames.Count > 0) + m_currentFrame = m_frames[0]; + } + } + } +} diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 248d4c6..5ccea13 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -114,6 +114,12 @@ namespace OpenSim.Region.Framework.Scenes private Random m_rand; private bool m_suspendUpdates; private List m_linkedAvatars = new List(); + private KeyframeMotion m_keyframeMotion = null; + + public KeyframeMotion KeyframeMotion + { + get; set; + } public bool areUpdatesSuspended { @@ -1982,6 +1988,12 @@ namespace OpenSim.Region.Framework.Scenes public void ScriptSetPhysicsStatus(bool usePhysics) { + if (usePhysics) + { + if (KeyframeMotion != null) + KeyframeMotion.Stop(); + KeyframeMotion = null; + } UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dd9431b..b6d5c4b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1855,6 +1855,9 @@ namespace OpenSim.Region.Framework.Scenes { if (UsePhysics) { + if (ParentGroup.KeyframeMotion != null) + ParentGroup.KeyframeMotion.Stop(); + ParentGroup.KeyframeMotion = null; ParentGroup.Scene.AddPhysicalPrim(1); PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; -- cgit v1.1 From aa552d0526349f0db6911dbd867c847cf4e810f6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 12:29:35 +0100 Subject: Serialize Keyframe motion for region crossings --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 71 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/Scene.cs | 2 + .../Region/Framework/Scenes/SceneObjectGroup.cs | 5 ++ .../Scenes/Serialization/SceneObjectSerializer.cs | 22 ++++++- 4 files changed, 96 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 239f7ca..73db25b 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -4,6 +4,7 @@ using System; using System.Timers; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Diagnostics; @@ -14,11 +15,14 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Framework.Scenes.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.Runtime.Serialization; using Timer = System.Timers.Timer; using log4net; namespace OpenSim.Region.Framework.Scenes { + [Serializable] public class KeyframeMotion { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -38,6 +42,7 @@ namespace OpenSim.Region.Framework.Scenes Rotation = 2 } + [Serializable] public struct Keyframe { public Vector3? Position; @@ -50,19 +55,24 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_basePosition; private Quaternion m_baseRotation; + private Vector3 m_serializedPosition; private Keyframe m_currentFrame; private List m_frames = new List(); private Keyframe[] m_keyframes; - private Timer m_timer = new Timer(); + [NonSerialized()] + protected Timer m_timer = new Timer(); - private readonly SceneObjectGroup m_group; + [NonSerialized()] + private SceneObjectGroup m_group; private PlayMode m_mode = PlayMode.Forward; private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; + private bool m_running = false; + private int m_iterations = 0; private const double timerInterval = 50.0; @@ -72,6 +82,41 @@ namespace OpenSim.Region.Framework.Scenes get { return m_data; } } + public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) + { + MemoryStream ms = new MemoryStream(data); + + BinaryFormatter fmt = new BinaryFormatter(); + + KeyframeMotion newMotion = (KeyframeMotion)fmt.Deserialize(ms); + + // This will be started when position is updated + newMotion.m_timer = new Timer(); + newMotion.m_timer.Interval = (int)timerInterval; + newMotion.m_timer.AutoReset = true; + newMotion.m_timer.Elapsed += newMotion.OnTimer; + + return newMotion; + } + + public void UpdateSceneObject(SceneObjectGroup grp) + { + m_group = grp; + Vector3 offset = grp.AbsolutePosition - m_serializedPosition; + + m_basePosition += offset; + m_currentFrame.Position += offset; + for (int i = 0 ; i < m_frames.Count ; i++) + { + Keyframe k = m_frames[i]; + k.Position += offset; + m_frames[i] = k; + } + + if (m_running) + Start(); + } + public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) { m_mode = mode; @@ -95,10 +140,14 @@ namespace OpenSim.Region.Framework.Scenes { if (m_keyframes.Length > 0) m_timer.Start(); + m_running = true; } public void Stop() { + // Failed object creation + if (m_timer == null) + return; m_timer.Stop(); m_basePosition = m_group.AbsolutePosition; @@ -109,6 +158,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); m_frames.Clear(); + m_running = false; } public void Pause() @@ -118,6 +168,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); m_timer.Stop(); + m_running = false; } private void GetNextList() @@ -211,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes } } - private void OnTimer(object sender, ElapsedEventArgs e) + protected void OnTimer(object sender, ElapsedEventArgs e) { if (m_frames.Count == 0) { @@ -311,5 +362,19 @@ namespace OpenSim.Region.Framework.Scenes m_currentFrame = m_frames[0]; } } + + public Byte[] Serialize() + { + MemoryStream ms = new MemoryStream(); + m_timer.Stop(); + + BinaryFormatter fmt = new BinaryFormatter(); + SceneObjectGroup tmp = m_group; + m_group = null; + m_serializedPosition = tmp.AbsolutePosition; + fmt.Serialize(ms, this); + m_group = tmp; + return ms.ToArray(); + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fcbed9f..c20da4b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2421,6 +2421,8 @@ namespace OpenSim.Region.Framework.Scenes if (newPosition != Vector3.Zero) newObject.RootPart.GroupPosition = newPosition; + if (newObject.KeyframeMotion != null) + newObject.KeyframeMotion.UpdateSceneObject(newObject); if (!AddSceneObject(newObject)) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9898681..d488189 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1823,6 +1823,11 @@ namespace OpenSim.Region.Framework.Scenes // Name, UUID, m_scene.RegionInfo.RegionName); SceneObjectGroup backup_group = Copy(false); + if (KeyframeMotion != null) + { + backup_group.KeyframeMotion = KeyframeMotion.FromData(backup_group, KeyframeMotion.Serialize()); + KeyframeMotion.UpdateSceneObject(this); + } backup_group.RootPart.Velocity = RootPart.Velocity; backup_group.RootPart.Acceleration = RootPart.Acceleration; backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index ed761da..a9f3e84 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -244,6 +244,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization sr.Close(); } + XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); + if (keymotion.Count > 0) + { + m_log.DebugFormat("[SERIALIZER]: Deserialized KeyframeMotion"); + sceneObject.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); + } + else + { + sceneObject.KeyframeMotion = null; + } + // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(doc); @@ -597,7 +608,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.sopVehicle = _vehicle; } - private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) { List errorNodeNames; @@ -1168,6 +1178,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization }); writer.WriteEndElement(); + + if (sog.KeyframeMotion != null) + { + Byte[] data = sog.KeyframeMotion.Serialize(); + + writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); + writer.WriteBase64(data, 0, data.Length); + writer.WriteEndElement(); + } + writer.WriteEndElement(); } -- cgit v1.1 From 9a15bba99bad2861813660c1c1da236d154809e5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 13:22:17 +0100 Subject: Fix an infinite recursion caused by checking the wrong values for Buoyancy, Force and Torque --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 51 ++++++++++++---------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 825f2a3..3ab7e5a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1306,19 +1306,20 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (ParentID != 0 && ParentGroup != null) - m_buoyancy = ParentGroup.RootPart.Buoyancy; - return m_buoyancy; + if (ParentGroup.RootPart == this) + return m_buoyancy; + + return ParentGroup.RootPart.Buoyancy; } set { - m_buoyancy = value; - if (ParentID != 0) + if (ParentGroup.RootPart != this) { - if (ParentGroup != null) - ParentGroup.RootPart.Buoyancy = value; + ParentGroup.RootPart.Buoyancy = value; + return; } - else if (PhysActor != null) + m_buoyancy = value; + if (PhysActor != null) PhysActor.Buoyancy = value; } } @@ -1327,20 +1328,21 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (ParentID != 0 && ParentGroup != null) - m_force = ParentGroup.RootPart.Force; - return m_force; + if (ParentGroup.RootPart == this) + return m_force; + + return ParentGroup.RootPart.Force; } set { - m_force = value; - if (ParentID != 0) + if (ParentGroup.RootPart != this) { - if (ParentGroup != null) - ParentGroup.RootPart.Force = value; + ParentGroup.RootPart.Force = value; + return; } - else if (PhysActor != null) + m_force = value; + if (PhysActor != null) PhysActor.Force = value; } } @@ -1349,20 +1351,21 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (ParentID != 0 && ParentGroup != null) - m_torque = ParentGroup.RootPart.Torque; - return m_torque; + if (ParentGroup.RootPart == this) + return m_torque; + + return ParentGroup.RootPart.Torque; } set { - m_torque = value; - if (ParentID != 0) + if (ParentGroup.RootPart != this) { - if (ParentGroup != null) - ParentGroup.RootPart.Torque = value; + ParentGroup.RootPart.Torque = value; + return; } - else if (PhysActor != null) + m_torque = value; + if (PhysActor != null) PhysActor.Torque = value; } } -- cgit v1.1 From 8cdc115c91bd074539c5fbae719313d4dc616355 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 14:30:24 +0100 Subject: Fix deserialization of Buoyancy, Force and Torque. Remove debug from the new code. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 1 - OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 5 ----- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 73db25b..7f651aa 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -245,7 +245,6 @@ namespace OpenSim.Region.Framework.Scenes } } - m_log.DebugFormat("[KEYFRAME]: Angle {0} aabb {1}", angle, aa_bb); k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000)); k.TimeTotal = k.TimeMS; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d488189..ac2fe82 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -896,6 +896,10 @@ namespace OpenSim.Region.Framework.Scenes ApplyPhysics(); if (RootPart.PhysActor != null) + RootPart.Force = RootPart.Force; + if (RootPart.PhysActor != null) + RootPart.Torque = RootPart.Torque; + if (RootPart.PhysActor != null) RootPart.Buoyancy = RootPart.Buoyancy; // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3ab7e5a..0728042 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1313,7 +1313,7 @@ namespace OpenSim.Region.Framework.Scenes } set { - if (ParentGroup.RootPart != this) + if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) { ParentGroup.RootPart.Buoyancy = value; return; @@ -1336,7 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes set { - if (ParentGroup.RootPart != this) + if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) { ParentGroup.RootPart.Force = value; return; @@ -1359,7 +1359,7 @@ namespace OpenSim.Region.Framework.Scenes set { - if (ParentGroup.RootPart != this) + if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) { ParentGroup.RootPart.Torque = value; return; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index a9f3e84..118a63a 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -246,14 +246,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); if (keymotion.Count > 0) - { - m_log.DebugFormat("[SERIALIZER]: Deserialized KeyframeMotion"); sceneObject.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); - } else - { sceneObject.KeyframeMotion = null; - } // Script state may, or may not, exist. Not having any, is NOT // ever a problem. -- cgit v1.1 From ac1e30156a7ec8e461b3378149a082b3b5d57884 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 15:09:00 +0100 Subject: Implement proper selection behavior --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 31 ++++++++++++++++++++++ .../Framework/Scenes/Scene.PacketHandlers.cs | 6 +++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 ++ 3 files changed, 37 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 7f651aa..bf18f4d 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -72,6 +72,8 @@ namespace OpenSim.Region.Framework.Scenes private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; private bool m_running = false; + [NonSerialized()] + private bool m_selected = false; private int m_iterations = 0; @@ -82,6 +84,25 @@ namespace OpenSim.Region.Framework.Scenes get { return m_data; } } + public bool Selected + { + set + { + if (value) + { + // Once we're let go, recompute positions + if (m_selected) + UpdateSceneObject(m_group); + } + else + { + // Save selection position in case we get moved + if (!m_selected) + m_serializedPosition = m_group.AbsolutePosition; + } + m_selected = value; } + } + public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) { MemoryStream ms = new MemoryStream(data); @@ -276,6 +297,16 @@ namespace OpenSim.Region.Framework.Scenes m_currentFrame = m_frames[0]; } + if (m_selected) + { + if (m_group.RootPart.Velocity != Vector3.Zero) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + } + return; + } + // Do the frame processing double steps = (double)m_currentFrame.TimeMS / timerInterval; float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index bf2e775..b006045 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -138,12 +138,12 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup sog = part.ParentGroup; sog.SendPropertiesToClient(remoteClient); - sog.IsSelected = true; // A prim is only tainted if it's allowed to be edited by the person clicking it. if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) { + sog.IsSelected = true; EventManager.TriggerParcelPrimCountTainted(); } } @@ -215,7 +215,9 @@ namespace OpenSim.Region.Framework.Scenes // handled by group, but by prim. Legacy cruft. // TODO: Make selection flagging per prim! // - part.ParentGroup.IsSelected = false; + if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) + || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) + part.ParentGroup.IsSelected = false; if (part.ParentGroup.IsAttachment) isAttachment = true; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ac2fe82..e509d4e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -726,6 +726,8 @@ namespace OpenSim.Region.Framework.Scenes child.PhysActor.Selected = value; } } + if (KeyframeMotion != null) + KeyframeMotion.Selected = value; } } -- cgit v1.1 From fca8c82232a42191270cb8d18dba6b54d382a2c2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 18:11:38 +0100 Subject: Move KeyframeMotion from SOG to SOP because we can't persist it any other way because SOG doesn't technically exist in the DB --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 +++++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 26 +++++++++------------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 +++++++++--- .../Scenes/Serialization/SceneObjectSerializer.cs | 8 +++---- 5 files changed, 38 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c20da4b..11a41aa 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2421,8 +2421,8 @@ namespace OpenSim.Region.Framework.Scenes if (newPosition != Vector3.Zero) newObject.RootPart.GroupPosition = newPosition; - if (newObject.KeyframeMotion != null) - newObject.KeyframeMotion.UpdateSceneObject(newObject); + if (newObject.RootPart.KeyframeMotion != null) + newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); if (!AddSceneObject(newObject)) { diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5a7f124..a320601 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1731,6 +1731,12 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void LinkObjects(SceneObjectPart root, List children) { + if (root.KeyframeMotion != null) + { + root.KeyframeMotion.Stop(); + root.KeyframeMotion = null; + } + SceneObjectGroup parentGroup = root.ParentGroup; if (parentGroup == null) return; @@ -1823,6 +1829,11 @@ namespace OpenSim.Region.Framework.Scenes { if (part != null) { + if (part.KeyframeMotion != null) + { + part.KeyframeMotion.Stop(); + part.KeyframeMotion = null; + } if (part.ParentGroup.PrimCount != 1) // Skip single { if (part.LinkNum < 2) // Root diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e509d4e..fefae9d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -114,12 +114,6 @@ namespace OpenSim.Region.Framework.Scenes private Random m_rand; private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - private KeyframeMotion m_keyframeMotion = null; - - public KeyframeMotion KeyframeMotion - { - get; set; - } public bool areUpdatesSuspended { @@ -726,8 +720,8 @@ namespace OpenSim.Region.Framework.Scenes child.PhysActor.Selected = value; } } - if (KeyframeMotion != null) - KeyframeMotion.Selected = value; + if (RootPart.KeyframeMotion != null) + RootPart.KeyframeMotion.Selected = value; } } @@ -1829,11 +1823,6 @@ namespace OpenSim.Region.Framework.Scenes // Name, UUID, m_scene.RegionInfo.RegionName); SceneObjectGroup backup_group = Copy(false); - if (KeyframeMotion != null) - { - backup_group.KeyframeMotion = KeyframeMotion.FromData(backup_group, KeyframeMotion.Serialize()); - KeyframeMotion.UpdateSceneObject(this); - } backup_group.RootPart.Velocity = RootPart.Velocity; backup_group.RootPart.Acceleration = RootPart.Acceleration; backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; @@ -1846,6 +1835,11 @@ namespace OpenSim.Region.Framework.Scenes backup_group.ForEachPart(delegate(SceneObjectPart part) { + if (part.KeyframeMotion != null) + { + part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); + part.KeyframeMotion.UpdateSceneObject(this); + } part.Inventory.ProcessInventoryBackup(datastore); }); @@ -2001,9 +1995,9 @@ namespace OpenSim.Region.Framework.Scenes { if (usePhysics) { - if (KeyframeMotion != null) - KeyframeMotion.Stop(); - KeyframeMotion = null; + if (RootPart.KeyframeMotion != null) + RootPart.KeyframeMotion.Stop(); + RootPart.KeyframeMotion = null; } UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0728042..ea3d716 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -315,6 +315,14 @@ namespace OpenSim.Region.Framework.Scenes private SOPVehicle m_vehicle = null; + private KeyframeMotion m_keyframeMotion = null; + + public KeyframeMotion KeyframeMotion + { + get; set; + } + + #endregion Fields // ~SceneObjectPart() @@ -1924,9 +1932,9 @@ namespace OpenSim.Region.Framework.Scenes { if (UsePhysics) { - if (ParentGroup.KeyframeMotion != null) - ParentGroup.KeyframeMotion.Stop(); - ParentGroup.KeyframeMotion = null; + if (ParentGroup.RootPart.KeyframeMotion != null) + ParentGroup.RootPart.KeyframeMotion.Stop(); + ParentGroup.RootPart.KeyframeMotion = null; ParentGroup.Scene.AddPhysicalPrim(1); PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 118a63a..51a3320 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -246,9 +246,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); if (keymotion.Count > 0) - sceneObject.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); + sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); else - sceneObject.KeyframeMotion = null; + sceneObject.RootPart.KeyframeMotion = null; // Script state may, or may not, exist. Not having any, is NOT // ever a problem. @@ -1174,9 +1174,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); - if (sog.KeyframeMotion != null) + if (sog.RootPart.KeyframeMotion != null) { - Byte[] data = sog.KeyframeMotion.Serialize(); + Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); writer.WriteBase64(data, 0, data.Length); -- cgit v1.1 From e5e5b94cbe6076f74d5ad2358d020f7d4f7ac18f Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 Feb 2012 21:16:24 +0100 Subject: Make llSetKeyframedMotion prims waut at the borders of down sims and try again periodically. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index bf18f4d..b7b0d27 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -406,5 +406,17 @@ namespace OpenSim.Region.Framework.Scenes m_group = tmp; return ms.ToArray(); } + + public void CrossingFailure() + { + // The serialization has stopped the timer, so let's wait a moment + // then retry the crossing. We'll get back here if it fails. + Util.FireAndForget(delegate (object x) + { + Thread.Sleep(60000); + if (m_running) + m_timer.Start(); + }); + } } } -- cgit v1.1 From aee4ca2f1cfa2aaee88ebbf72513d6a06cefeb65 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 27 Feb 2012 08:50:19 +0100 Subject: Fix vehicles going physical stopping llTargetOmega parts (boat radar) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ea3d716..1c72b10 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -916,7 +916,7 @@ namespace OpenSim.Region.Framework.Scenes get { PhysicsActor actor = PhysActor; - if ((actor != null) && actor.IsPhysical) + if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) { m_angularVelocity = actor.RotationalVelocity; } @@ -1893,7 +1893,8 @@ namespace OpenSim.Region.Framework.Scenes Velocity = new Vector3(0, 0, 0); Acceleration = new Vector3(0, 0, 0); - AngularVelocity = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; @@ -1917,7 +1918,8 @@ namespace OpenSim.Region.Framework.Scenes // velocity-vector. Velocity = new Vector3(0, 0, 0); Acceleration = new Vector3(0, 0, 0); - AngularVelocity = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); //RotationalVelocity = new Vector3(0, 0, 0); } -- cgit v1.1 From 6dc4a6dfb1af79ea116d1b5ca8dcd82307349c64 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 4 Mar 2012 00:06:07 +0100 Subject: Zero velocity when drag-copying --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fefae9d..c9ea8e4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1989,6 +1989,8 @@ namespace OpenSim.Region.Framework.Scenes public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); + if (userExposed) + RootPart.Velocity = Vector3.Zero; // In case source is moving } public void ScriptSetPhysicsStatus(bool usePhysics) -- cgit v1.1 From 0ed4f24b3432d282f2f1517d403341cde069af29 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Mar 2012 02:14:27 +0100 Subject: A stab at making llEjectFromLand work in all cases --- OpenSim/Region/Framework/Scenes/Scene.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 11a41aa..5d27d86 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4938,9 +4938,16 @@ Environment.Exit(1); return nearestPoint.Value; } - //Ultimate backup if we have no idea where they are - Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); - return avatar.lastKnownAllowedPosition; + ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); + if (dest != excludeParcel) + { + // Ultimate backup if we have no idea where they are and + // the last allowed position was in another parcel + Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); + return avatar.lastKnownAllowedPosition; + } + + // else fall through to region edge } //Go to the edge, this happens in teleporting to a region with no available parcels -- cgit v1.1 From cca94aaefc36fad366e789d6d2e902dda078e3f7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 6 Mar 2012 05:13:39 +0000 Subject: make copied parts have diferent LocalIds than original. More building control for ubitODE. for all let physics know about linking of physical parts. Assume UNTESTED --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 74 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +- 2 files changed, 74 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c9ea8e4..b99f80d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -957,12 +957,21 @@ namespace OpenSim.Region.Framework.Scenes /// public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) { + /* ???? maxX = -256f; maxY = -256f; maxZ = -256f; minX = 256f; minY = 256f; minZ = 8192f; + */ + + maxX = float.MinValue; + maxY = float.MinValue; + maxZ = float.MinValue; + minX = float.MaxValue; + minY = float.MaxValue; + minZ = float.MaxValue; SceneObjectPart[] parts = m_parts.GetArray(); foreach (SceneObjectPart part in parts) @@ -1918,6 +1927,8 @@ namespace OpenSim.Region.Framework.Scenes dupe.IsAttachment = previousAttachmentStatus; } + + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; @@ -1988,7 +1999,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); + // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); + // give newpart a new local ID lettng old part keep same + SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); + newpart.LocalId = m_scene.AllocateLocalId(); + + SetRootPart(newpart); if (userExposed) RootPart.Velocity = Vector3.Zero; // In case source is moving } @@ -2191,7 +2207,10 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); + // give new ID to the new part, letting old keep original + // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); + SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); + newPart.LocalId = m_scene.AllocateLocalId(); newPart.SetParent(this); AddPart(newPart); @@ -2485,6 +2504,11 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart linkPart = objectGroup.m_rootPart; + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + if (linkPart.PhysActor != null) + linkPart.PhysActor.Building = true; + Vector3 oldGroupPosition = linkPart.GroupPosition; Quaternion oldRootRotation = linkPart.RotationOffset; @@ -2528,6 +2552,13 @@ namespace OpenSim.Region.Framework.Scenes linkPart.SetParent(this); linkPart.CreateSelected = true; + // let physics know + if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) + { + linkPart.PhysActor.link(m_rootPart.PhysActor); + this.Scene.PhysicsScene.AddPhysicsActorTaint(linkPart.PhysActor); + } + linkPart.LinkNum = linkNum++; SceneObjectPart[] ogParts = objectGroup.Parts; @@ -2540,7 +2571,15 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = ogParts[i]; if (part.UUID != objectGroup.m_rootPart.UUID) + { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); + // let physics know + if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) + { + part.PhysActor.link(m_rootPart.PhysActor); + this.Scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); + } + } part.ClearUndoState(); } } @@ -2560,6 +2599,9 @@ namespace OpenSim.Region.Framework.Scenes // unmoved prims! ResetChildPrimPhysicsPositions(); + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + //HasGroupChanged = true; //ScheduleGroupForFullUpdate(); } @@ -2612,7 +2654,10 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); - + + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + linkPart.ClearUndoState(); Quaternion worldRot = linkPart.GetWorldRotation(); @@ -2672,6 +2717,10 @@ namespace OpenSim.Region.Framework.Scenes // When we delete a group, we currently have to force persist to the database if the object id has changed // (since delete works by deleting all rows which have a given object id) + + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + objectGroup.HasGroupChangedDueToDelink = true; return objectGroup; @@ -3284,6 +3333,10 @@ namespace OpenSim.Region.Framework.Scenes part.StoreUndoState(false); part.IgnoreUndoUpdate = true; +// unlock parts position change + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootPosition(pos); @@ -3293,6 +3346,9 @@ namespace OpenSim.Region.Framework.Scenes part.UpdateOffSet(pos); } + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + HasGroupChanged = true; part.IgnoreUndoUpdate = false; } @@ -3434,6 +3490,9 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); @@ -3442,6 +3501,9 @@ namespace OpenSim.Region.Framework.Scenes { part.UpdateRotation(rot); } + + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; } } @@ -3462,6 +3524,9 @@ namespace OpenSim.Region.Framework.Scenes part.StoreUndoState(); part.IgnoreUndoUpdate = true; + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); @@ -3482,6 +3547,9 @@ namespace OpenSim.Region.Framework.Scenes part.OffsetPosition = pos; } + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + part.IgnoreUndoUpdate = false; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1c72b10..b132a19 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1727,8 +1727,6 @@ namespace OpenSim.Region.Framework.Scenes // Move afterwards ResetIDs as it clears the localID dupe.LocalId = localID; - if(dupe.PhysActor != null) - dupe.PhysActor.LocalID = localID; // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. dupe.LastOwnerID = OwnerID; @@ -1749,6 +1747,9 @@ namespace OpenSim.Region.Framework.Scenes dupe.DoPhysicsPropertyUpdate(UsePhysics, true); } + if (dupe.PhysActor != null) + dupe.PhysActor.LocalID = localID; + ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); -- cgit v1.1 From de03d1ece0f4b4b9337ded53a71fcc68676c77d9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Mar 2012 09:56:19 +0100 Subject: Removed some whitespace errors - don't be naughty, don't use hard tabs! Also removed commented code block. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b99f80d..8809cd0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -957,15 +957,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) { - /* ???? - maxX = -256f; - maxY = -256f; - maxZ = -256f; - minX = 256f; - minY = 256f; - minZ = 8192f; - */ - maxX = float.MinValue; maxY = float.MinValue; maxZ = float.MinValue; @@ -1927,8 +1918,6 @@ namespace OpenSim.Region.Framework.Scenes dupe.IsAttachment = previousAttachmentStatus; } - - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; -- cgit v1.1 From 17b1454d6f3b45618b1007c85fe97242284aff3c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Mar 2012 20:20:12 +0100 Subject: Null PhysActor on SOP.Copy() to prevent clobbering the original one --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b132a19..9c06786 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1691,10 +1691,9 @@ namespace OpenSim.Region.Framework.Scenes if (userExposed) dupe.UUID = UUID.Random(); - //memberwiseclone means it also clones the physics actor reference - // This will make physical prim 'bounce' if not set to null. - if (!userExposed) - dupe.PhysActor = null; + // The PhysActor cannot be valid on a copy because the copy is not in the scene yet. + // Null it, the caller has to create a new one once the object is added to a scene + dupe.PhysActor = null; dupe.OwnerID = AgentID; dupe.GroupID = GroupID; -- cgit v1.1 From 5884d080623fddb3ee50b8215d896bdee3fa31a4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Mar 2012 00:58:01 +0000 Subject: Fix merge issue --- OpenSim/Region/Framework/Scenes/Scene.cs | 155 ++++++++++++++++--------------- 1 file changed, 79 insertions(+), 76 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fc72946..d016887 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -653,99 +653,102 @@ namespace OpenSim.Region.Framework.Scenes // Region config overrides global config // - if (m_config.Configs["Startup"] != null) + try { - IConfig startupConfig = m_config.Configs["Startup"]; + if (m_config.Configs["Startup"] != null) + { + IConfig startupConfig = m_config.Configs["Startup"]; - m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); - m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); - if (!m_useBackup) - m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); - - //Animation states - m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); + m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); + m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); + if (!m_useBackup) + m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); + + //Animation states + m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); - PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); - CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); + PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); + CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); - m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); - if (RegionInfo.NonphysPrimMax > 0) - { - m_maxNonphys = RegionInfo.NonphysPrimMax; - } + m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); + if (RegionInfo.NonphysPrimMax > 0) + { + m_maxNonphys = RegionInfo.NonphysPrimMax; + } - m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); + m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); - if (RegionInfo.PhysPrimMax > 0) - { - m_maxPhys = RegionInfo.PhysPrimMax; - } + if (RegionInfo.PhysPrimMax > 0) + { + m_maxPhys = RegionInfo.PhysPrimMax; + } - // Here, if clamping is requested in either global or - // local config, it will be used - // - m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); - if (RegionInfo.ClampPrimSize) - { - m_clampPrimSize = true; - } + // Here, if clamping is requested in either global or + // local config, it will be used + // + m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); + if (RegionInfo.ClampPrimSize) + { + m_clampPrimSize = true; + } - m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); - m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); - m_dontPersistBefore = - startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); - m_dontPersistBefore *= 10000000; - m_persistAfter = - startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); - m_persistAfter *= 10000000; + m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); + m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); + m_dontPersistBefore = + startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); + m_dontPersistBefore *= 10000000; + m_persistAfter = + startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); + m_persistAfter *= 10000000; - m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); - m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); + m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); + m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); - IConfig packetConfig = m_config.Configs["PacketPool"]; - if (packetConfig != null) - { - PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); - PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); - } + IConfig packetConfig = m_config.Configs["PacketPool"]; + if (packetConfig != null) + { + PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); + PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); + } - m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); - m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); - CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); + m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); + m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); + CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); - m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); - if (m_generateMaptiles) - { - int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); - if (maptileRefresh != 0) + m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); + if (m_generateMaptiles) { - m_mapGenerationTimer.Interval = maptileRefresh * 1000; - m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; - m_mapGenerationTimer.AutoReset = true; - m_mapGenerationTimer.Start(); + int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); + if (maptileRefresh != 0) + { + m_mapGenerationTimer.Interval = maptileRefresh * 1000; + m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; + m_mapGenerationTimer.AutoReset = true; + m_mapGenerationTimer.Start(); + } } - } - else - { - string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); - UUID tileID; - - if (UUID.TryParse(tile, out tileID)) + else { - RegionInfo.RegionSettings.TerrainImageID = tileID; + string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); + UUID tileID; + + if (UUID.TryParse(tile, out tileID)) + { + RegionInfo.RegionSettings.TerrainImageID = tileID; + } } - } - MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); - m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); - m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); - m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); - m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); - m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); - m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); - m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); - m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); - m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); + MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); + m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); + m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); + m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); + m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); + m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); + m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); + m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); + m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); + m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); + } } catch (Exception e) { -- cgit v1.1 From 3d3b81e67698cc361a9eca28083f5f526ff1de2e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 7 Mar 2012 07:31:26 +0000 Subject: changes on undo/redo (untested/incomplete). Think we may consider moving this mfrom SOP to client side. At least does seem to work a bit better ( again there wwas a issue on sop.copy ) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 8 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 72 ++++------- OpenSim/Region/Framework/Scenes/UndoState.cs | 139 +++++---------------- 3 files changed, 66 insertions(+), 153 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8809cd0..038eaa4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -549,11 +549,12 @@ namespace OpenSim.Region.Framework.Scenes val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } - +/* don't see the need but worse don't see where is restored to false if things stay in foreach (SceneObjectPart part in m_parts.GetArray()) { part.IgnoreUndoUpdate = true; } + */ if (RootPart.GetStatusSandbox()) { if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) @@ -3519,7 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); - if (!m_rootPart.Undoing) +/* if (!m_rootPart.Undoing) { m_rootPart.Undoing = true; AbsolutePosition = pos; @@ -3527,8 +3528,9 @@ namespace OpenSim.Region.Framework.Scenes } else { + */ AbsolutePosition = pos; - } +// } } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9c06786..8dd2c76 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -263,8 +263,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_occupied; // KF if any av is sitting on this prim private string m_text = String.Empty; private string m_touchName = String.Empty; - private readonly Stack m_undo = new Stack(5); - private readonly Stack m_redo = new Stack(5); + private Stack m_undo = new Stack(5); + private Stack m_redo = new Stack(5); private bool m_passTouches; @@ -1711,6 +1711,11 @@ namespace OpenSim.Region.Framework.Scenes dupe.Category = Category; dupe.m_rezzed = m_rezzed; + dupe.m_undo = new Stack(5); + dupe.m_redo = new Stack(5); + dupe.IgnoreUndoUpdate = false; + dupe.Undoing = false; + dupe.m_inventory = new SceneObjectPartInventory(dupe); dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); @@ -3661,61 +3666,38 @@ namespace OpenSim.Region.Framework.Scenes public void StoreUndoState(bool forGroup) { - if (!Undoing) + if (!Undoing && !IgnoreUndoUpdate) // just to read better - undo is in progress, or suspended { - if (!IgnoreUndoUpdate) + if (ParentGroup != null) { - if (ParentGroup != null) + lock (m_undo) { - lock (m_undo) + if (m_undo.Count > 0) { - if (m_undo.Count > 0) - { - UndoState last = m_undo.Peek(); - if (last != null) - { - // TODO: May need to fix for group comparison - if (last.Compare(this)) - { - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", - // Name, LocalId, m_undo.Count); + // see if we had a change - return; - } + UndoState last = m_undo.Peek(); + if (last != null) + { + if (last.Compare(this, forGroup)) + { + return; } } - - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", - // Name, LocalId, forGroup, m_undo.Count); - - if (ParentGroup.GetSceneMaxUndo() > 0) - { - UndoState nUndo = new UndoState(this, forGroup); + } - m_undo.Push(nUndo); + if (ParentGroup.GetSceneMaxUndo() > 0) + { + UndoState nUndo = new UndoState(this, forGroup); - if (m_redo.Count > 0) - m_redo.Clear(); + m_undo.Push(nUndo); - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", - // Name, LocalId, forGroup, m_undo.Count); - } + if (m_redo.Count > 0) + m_redo.Clear(); } } } - // else - // { - // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); - // } } - // else - // { - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); - // } } /// @@ -3751,7 +3733,7 @@ namespace OpenSim.Region.Framework.Scenes nUndo = new UndoState(this, goback.ForGroup); } - goback.PlaybackState(this); + goback.PlayState(this); if (nUndo != null) m_redo.Push(nUndo); @@ -3785,7 +3767,7 @@ namespace OpenSim.Region.Framework.Scenes m_undo.Push(nUndo); } - gofwd.PlayfwdState(this); + gofwd.PlayState(this); } // m_log.DebugFormat( diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 5ed3c79..029c828 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -66,43 +66,25 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// True if the undo is for an entire group + /// only for root parts ???? public UndoState(SceneObjectPart part, bool forGroup) { if (part.ParentID == 0) { ForGroup = forGroup; - - // if (ForGroup) Position = part.ParentGroup.AbsolutePosition; - // else - // Position = part.OffsetPosition; - - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo position {0} for root part", Position); - Rotation = part.RotationOffset; - - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); - - Scale = part.Shape.Scale; - - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); + if (!forGroup) + Scale = part.Shape.Scale; + else + Scale = Vector3.Zero; // until we fix it } else { + ForGroup = false; // previus code implies only root parts can undo grp Position = part.OffsetPosition; - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo position {0} for child part", Position); - Rotation = part.RotationOffset; - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); - Scale = part.Shape.Scale; - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); } } @@ -111,35 +93,42 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// true if both the part's position, rotation and scale match those in this undo state. False otherwise. - public bool Compare(SceneObjectPart part) + public bool Compare(SceneObjectPart part, bool forgrp) { + if (ForGroup != forgrp) // if diferent targets, then they are diferent + return false; + if (part != null) { if (part.ParentID == 0) - return - Position == part.ParentGroup.AbsolutePosition - && Rotation == part.RotationOffset - && Scale == part.Shape.Scale; + { + // root part + // grp position is same as part + if (Position != part.ParentGroup.AbsolutePosition) + return false; + if (Rotation != part.RotationOffset) + return false; + if (ForGroup) + return true; // for now don't do grp scale + return (Scale == part.Shape.Scale); + } else - return - Position == part.OffsetPosition + { + return (Position == part.OffsetPosition && Rotation == part.RotationOffset - && Scale == part.Shape.Scale; + && Scale == part.Shape.Scale); + } } return false; } - public void PlaybackState(SceneObjectPart part) + public void PlayState(SceneObjectPart part) { part.Undoing = true; if (part.ParentID == 0) { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", - // Position, part.Name, part.LocalId); - if (Position != Vector3.Zero) { if (ForGroup) @@ -148,10 +137,6 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.UpdateRootPosition(Position); } - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", - // part.RotationOffset, Rotation, part.Name, part.LocalId); - if (ForGroup) part.UpdateRotation(Rotation); else @@ -159,86 +144,30 @@ namespace OpenSim.Region.Framework.Scenes if (Scale != Vector3.Zero) { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", - // part.Shape.Scale, Scale, part.Name, part.LocalId); - - if (ForGroup) - part.ParentGroup.GroupResize(Scale); - else + // if (ForGroup) + // part.ParentGroup.GroupResize(Scale); + // else + if (!ForGroup) // we don't have grp scale for now part.Resize(Scale); } - part.ParentGroup.ScheduleGroupForTerseUpdate(); } else { - // Note: Updating these properties on sop automatically schedules an update if needed - if (Position != Vector3.Zero) - { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", - // part.OffsetPosition, Position, part.Name, part.LocalId); - - part.OffsetPosition = Position; - } - - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", - // part.RotationOffset, Rotation, part.Name, part.LocalId); + if (ForGroup) // trap for group since seems parts can't do it + return; + // Note: Updating these properties on sop automatically schedules an update if needed + part.OffsetPosition = Position; part.UpdateRotation(Rotation); - if (Scale != Vector3.Zero) { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", - // part.Shape.Scale, Scale, part.Name, part.LocalId); - part.Resize(Scale); } } part.Undoing = false; } - - public void PlayfwdState(SceneObjectPart part) - { - part.Undoing = true; - - if (part.ParentID == 0) - { - if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; - - if (Rotation != Quaternion.Identity) - part.UpdateRotation(Rotation); - - if (Scale != Vector3.Zero) - { - if (ForGroup) - part.ParentGroup.GroupResize(Scale); - else - part.Resize(Scale); - } - - part.ParentGroup.ScheduleGroupForTerseUpdate(); - } - else - { - // Note: Updating these properties on sop automatically schedules an update if needed - if (Position != Vector3.Zero) - part.OffsetPosition = Position; - - if (Rotation != Quaternion.Identity) - part.UpdateRotation(Rotation); - - if (Scale != Vector3.Zero) - part.Resize(Scale); - } - - part.Undoing = false; - } } public class LandUndoState -- cgit v1.1 From b8c27252c1c65cab64cff4e143c70be6441099c9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 8 Mar 2012 18:31:58 +0100 Subject: Hold a ref to the prim we're sat on rather than querying scene each time the check for significant is carried out. Prevents a deadlock condition. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 57 +++++++++++++----------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 26fa6c0..8a7c06a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -527,15 +527,8 @@ namespace OpenSim.Region.Framework.Scenes // without the parent rotation applied. if (ParentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); - if (part != null) - { + SceneObjectPart part = ParentPart; return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); - } - else - { - return ParentPosition + m_pos; - } } } return m_pos; @@ -653,6 +646,13 @@ namespace OpenSim.Region.Framework.Scenes } private UUID m_parentUUID = UUID.Zero; + public SceneObjectPart ParentPart + { + get { return m_parentPart; } + set { m_parentPart = value; } + } + private SceneObjectPart m_parentPart = null; + public float Health { get { return m_health; } @@ -891,6 +891,7 @@ namespace OpenSim.Region.Framework.Scenes part.SitTargetAvatar = UUID; ParentPosition = part.GetWorldPosition(); ParentID = part.LocalId; + ParentPart = part; m_pos = m_prevSitOffset; pos = ParentPosition; } @@ -1865,37 +1866,35 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); - if (part != null) + SceneObjectPart part = ParentPart; + TaskInventoryDictionary taskIDict = part.TaskInventory; + if (taskIDict != null) { - TaskInventoryDictionary taskIDict = part.TaskInventory; - if (taskIDict != null) + lock (taskIDict) { - lock (taskIDict) + foreach (UUID taskID in taskIDict.Keys) { - foreach (UUID taskID in taskIDict.Keys) - { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS - } + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS } } + } - // Reset sit target. - if (part.SitTargetAvatar == UUID) - part.SitTargetAvatar = UUID.Zero; + // Reset sit target. + if (part.SitTargetAvatar == UUID) + part.SitTargetAvatar = UUID.Zero; - part.ParentGroup.DeleteAvatar(UUID); - ParentPosition = part.GetWorldPosition(); - ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - } + part.ParentGroup.DeleteAvatar(UUID); + ParentPosition = part.GetWorldPosition(); + ControllingClient.SendClearFollowCamProperties(part.ParentUUID); m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); ParentPosition = Vector3.Zero; ParentID = 0; + ParentPart = null; if (PhysicsActor == null) AddToPhysicalScene(false); @@ -2356,6 +2355,10 @@ namespace OpenSim.Region.Framework.Scenes return; } + ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + if (ParentPart == null) + return; + ParentID = m_requestedSitTargetID; Velocity = Vector3.Zero; -- cgit v1.1 From 05cdf9bda910ced0da29474b8b40a58e8a423d69 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 9 Mar 2012 01:53:58 +0000 Subject: more changes in undo/redo. Basicly moved control to llclientview.cs. later we can move back to a dispatcher function on SOG that handles the several cases( in a viwer independent way (?)) and calls current exec funtions. made cosmetic changes replacing decimals by hexs so bits are easier to read. Changed behavour of case 12 and 28 ( 0x0c and 0x1c) to make identical to 0x0d and 0x1d ( scale only and scale plus position). DOn't see 12 and 28 in use... cases 1c and 1d still broken --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 62 +++++++++++----------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +- 2 files changed, 33 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 038eaa4..2d71372 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1569,7 +1569,7 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", // remoteClient.Name, part.Name, part.LocalId, offsetPos); - part.StoreUndoState(); +// part.StoreUndoState(); part.OnGrab(offsetPos, remoteClient); } @@ -3119,7 +3119,7 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); - RootPart.StoreUndoState(true); +// RootPart.StoreUndoState(true); scale.X = Math.Min(scale.X, Scene.m_maxNonphys); scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); @@ -3230,7 +3230,7 @@ namespace OpenSim.Region.Framework.Scenes if (obPart.UUID != m_rootPart.UUID) { - obPart.IgnoreUndoUpdate = true; +// obPart.IgnoreUndoUpdate = true; Vector3 currentpos = new Vector3(obPart.OffsetPosition); currentpos.X *= x; @@ -3245,7 +3245,7 @@ namespace OpenSim.Region.Framework.Scenes obPart.Resize(newSize); obPart.UpdateOffSet(currentpos); - obPart.IgnoreUndoUpdate = false; +// obPart.IgnoreUndoUpdate = false; } // obPart.IgnoreUndoUpdate = false; @@ -3270,7 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); - RootPart.StoreUndoState(true); +// RootPart.StoreUndoState(true); // SceneObjectPart[] parts = m_parts.GetArray(); // for (int i = 0; i < parts.Length; i++) @@ -3311,17 +3311,17 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetChildPart(localID); - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].StoreUndoState(); +// SceneObjectPart[] parts = m_parts.GetArray(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].StoreUndoState(); if (part != null) { // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); - part.StoreUndoState(false); - part.IgnoreUndoUpdate = true; +// part.StoreUndoState(false); +// part.IgnoreUndoUpdate = true; // unlock parts position change if (m_rootPart.PhysActor != null) @@ -3340,7 +3340,7 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.PhysActor.Building = false; HasGroupChanged = true; - part.IgnoreUndoUpdate = false; +// part.IgnoreUndoUpdate = false; } } @@ -3377,16 +3377,16 @@ namespace OpenSim.Region.Framework.Scenes } //We have to set undoing here because otherwise an undo state will be saved - if (!m_rootPart.Undoing) - { - m_rootPart.Undoing = true; - AbsolutePosition = newPos; - m_rootPart.Undoing = false; - } - else - { +// if (!m_rootPart.Undoing) +// { +// m_rootPart.Undoing = true; AbsolutePosition = newPos; - } +// m_rootPart.Undoing = false; +// } +// else +// { +// AbsolutePosition = newPos; +// } HasGroupChanged = true; if (m_rootPart.Undoing) @@ -3416,9 +3416,9 @@ namespace OpenSim.Region.Framework.Scenes // for (int i = 0; i < parts.Length; i++) // parts[i].StoreUndoState(); - m_rootPart.StoreUndoState(true); +// m_rootPart.StoreUndoState(true); - m_rootPart.UpdateRotation(rot); +// m_rootPart.UpdateRotation(rot); PhysicsActor actor = m_rootPart.PhysActor; if (actor != null) @@ -3445,8 +3445,8 @@ namespace OpenSim.Region.Framework.Scenes // for (int i = 0; i < parts.Length; i++) // parts[i].StoreUndoState(); - RootPart.StoreUndoState(true); - RootPart.IgnoreUndoUpdate = true; +// RootPart.StoreUndoState(true); +// RootPart.IgnoreUndoUpdate = true; m_rootPart.UpdateRotation(rot); @@ -3462,7 +3462,7 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; ScheduleGroupForTerseUpdate(); - RootPart.IgnoreUndoUpdate = false; +// RootPart.IgnoreUndoUpdate = false; } /// @@ -3511,8 +3511,8 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", // part.Name, part.LocalId, rot); - part.StoreUndoState(); - part.IgnoreUndoUpdate = true; +// part.StoreUndoState(); +// part.IgnoreUndoUpdate = true; if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = true; @@ -3541,7 +3541,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = false; - part.IgnoreUndoUpdate = false; +// part.IgnoreUndoUpdate = false; } } @@ -3557,7 +3557,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; - m_rootPart.StoreUndoState(); +// m_rootPart.StoreUndoState(); //Don't use UpdateRotation because it schedules an update prematurely m_rootPart.RotationOffset = rot; @@ -3573,7 +3573,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart prim = parts[i]; if (prim.UUID != m_rootPart.UUID) { - prim.IgnoreUndoUpdate = true; +// prim.IgnoreUndoUpdate = true; Quaternion NewRot = oldParentRot * prim.RotationOffset; NewRot = Quaternion.Inverse(axRot) * NewRot; @@ -3585,7 +3585,7 @@ namespace OpenSim.Region.Framework.Scenes axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; - prim.IgnoreUndoUpdate = false; +// prim.IgnoreUndoUpdate = false; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8dd2c76..4ba04c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -828,7 +828,7 @@ namespace OpenSim.Region.Framework.Scenes set { - StoreUndoState(); +// StoreUndoState(); m_rotationOffset = value; PhysicsActor actor = PhysActor; @@ -1007,7 +1007,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_shape != null) { - StoreUndoState(); +// StoreUndoState(); m_shape.Scale = value; -- cgit v1.1 From e5786ba0435bee04246fcd689a103f2df338dba9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 9 Mar 2012 02:56:14 +0000 Subject: more changes on undo/redo group scaling seems to work better --- OpenSim/Region/Framework/Scenes/UndoState.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 029c828..38474de 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -74,14 +74,11 @@ namespace OpenSim.Region.Framework.Scenes ForGroup = forGroup; Position = part.ParentGroup.AbsolutePosition; Rotation = part.RotationOffset; - if (!forGroup) - Scale = part.Shape.Scale; - else - Scale = Vector3.Zero; // until we fix it + Scale = part.Shape.Scale; } else { - ForGroup = false; // previus code implies only root parts can undo grp + ForGroup = false; // only root parts can undo grp Position = part.OffsetPosition; Rotation = part.RotationOffset; Scale = part.Shape.Scale; @@ -108,9 +105,7 @@ namespace OpenSim.Region.Framework.Scenes return false; if (Rotation != part.RotationOffset) return false; - if (ForGroup) - return true; // for now don't do grp scale - return (Scale == part.Shape.Scale); + return Scale == part.Shape.Scale; } else { @@ -144,10 +139,9 @@ namespace OpenSim.Region.Framework.Scenes if (Scale != Vector3.Zero) { - // if (ForGroup) - // part.ParentGroup.GroupResize(Scale); - // else - if (!ForGroup) // we don't have grp scale for now + if (ForGroup) + part.ParentGroup.GroupResize(Scale); + else part.Resize(Scale); } part.ParentGroup.ScheduleGroupForTerseUpdate(); -- cgit v1.1 From e83a2181d06717afe3e5a02d8c918effbe80f226 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 9 Mar 2012 17:19:10 +0000 Subject: on linking update linked parts physical flags acording to new parent ones ( untested ) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2d71372..5818798 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2499,6 +2499,11 @@ namespace OpenSim.Region.Framework.Scenes if (linkPart.PhysActor != null) linkPart.PhysActor.Building = true; + // physics flags from group to be applied to linked parts + bool grpusephys = UsesPhysics; + bool grptemporary = IsTemporary; + bool gprphantom = IsPhantom; + Vector3 oldGroupPosition = linkPart.GroupPosition; Quaternion oldRootRotation = linkPart.RotationOffset; @@ -2542,7 +2547,8 @@ namespace OpenSim.Region.Framework.Scenes linkPart.SetParent(this); linkPart.CreateSelected = true; - // let physics know + // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now + linkPart.UpdatePrimFlags(grpusephys, grptemporary, gprphantom, linkPart.VolumeDetectActive, true); if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { linkPart.PhysActor.link(m_rootPart.PhysActor); @@ -2564,6 +2570,7 @@ namespace OpenSim.Region.Framework.Scenes { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); // let physics know + part.UpdatePrimFlags(grpusephys, grptemporary, gprphantom, part.VolumeDetectActive, true); if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { part.PhysActor.link(m_rootPart.PhysActor); -- cgit v1.1 From 908abb1c3dded307e769abac71f660b835875975 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 10 Mar 2012 20:32:19 +0000 Subject: BIG MESS. changed Iclient interface so only one event is used to inform scene about position scale or rotation change by client (others can be added). Its served at SceneGraph that does permition checks, undostore and sends down to SOG. changed values are stored in a class (ObjectChangeData) and what is changed as a enum (ObjectChangeWhat) with bit fields and 'macros' of this for better readability (at top of scenegraph.cs lasy to find better place for now) this can be extended for other things clients changes and need undo/redo. SOG process acording to what is changed. Changed UNDO/redo to use this also (warning is only storing what is changed, previus stored all, this must be checked for side efects. to save all PRS change commented line in scenegraph). Still have excessive calls to ScheduleGroupForTerseUpdate. **** UNTESTED **** --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 + OpenSim/Region/Framework/Scenes/SceneGraph.cs | 152 +++++++++++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 204 +++++++++------------ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 47 ++++- OpenSim/Region/Framework/Scenes/UndoState.cs | 113 +++++++++++- 5 files changed, 394 insertions(+), 126 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 68c05f8..a3358a5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2811,6 +2811,8 @@ namespace OpenSim.Region.Framework.Scenes client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; + client.onClientChangeObject += m_sceneGraph.ClientChangeObject; + client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; @@ -2940,6 +2942,8 @@ namespace OpenSim.Region.Framework.Scenes client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; + client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; + client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 3cd4a10..5e770ba 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -47,6 +47,57 @@ namespace OpenSim.Region.Framework.Scenes public delegate void ChangedBackupDelegate(SceneObjectGroup sog); + + public enum ObjectChangeWhat : uint + { + // bits definitions + Position = 0x01, + Rotation = 0x02, + Scale = 0x04, + Group = 0x08, + UniformScale = 0x10, + + // macros from above + // single prim + primP = 0x01, + primR = 0x02, + primPR = 0x03, + primS = 0x04, + primPS = 0x05, + primRS = 0x06, + primPSR = 0x07, + + primUS = 0x14, + primPUS = 0x15, + primRUS = 0x16, + primPUSR = 0x17, + + // group + groupP = 0x09, + groupR = 0x0A, + groupPR = 0x0B, + groupS = 0x0C, + groupPS = 0x0D, + groupRS = 0x0E, + groupPSR = 0x0F, + + groupUS = 0x1C, + groupPUS = 0x1D, + groupRUS = 0x1E, + groupPUSR = 0x1F, + + PRSmask = 0x07 + } + + public struct ObjectChangeData + { + public Quaternion rotation; + public Vector3 position; + public Vector3 scale; + public ObjectChangeWhat what; + } + + /// /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components /// should be migrated out over time. @@ -1289,6 +1340,87 @@ namespace OpenSim.Region.Framework.Scenes #region Client Event handlers + protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient) + { + SceneObjectPart part = GetSceneObjectPart(localID); + ObjectChangeData data = (ObjectChangeData)odata; + + if (part != null) + { + SceneObjectGroup grp = part.ParentGroup; + if (grp != null) + { + if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) + { +// part.StoreUndoState(data.what | ObjectChangeWhat.PRSmask); // for now save all to keep previus behavour ??? + part.StoreUndoState(data.what); // lets test only saving what we changed + grp.doChangeObject(part, (ObjectChangeData)data); + } + } + } + } + +/* moved to SOG + protected internal void doChangeObject(SceneObjectPart part, ObjectChangeData data) + { + if (part != null && part.ParentGroup != null) + { + ObjectChangeWhat what = data.what; + bool togroup = ((what & ObjectChangeWhat.Group) != 0); +// bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use + + SceneObjectGroup group = part.ParentGroup; + PhysicsActor pha = group.RootPart.PhysActor; + + if (togroup) + { + // related to group + if ((what & ObjectChangeWhat.Position) != 0) + group.AbsolutePosition = data.position; + if ((what & ObjectChangeWhat.Rotation) != 0) + group.RootPart.UpdateRotation(data.rotation); + if ((what & ObjectChangeWhat.Scale) != 0) + { + if (pha != null) + pha.Building = true; + group.GroupResize(data.scale); + if (pha != null) + pha.Building = false; + } + } + else + { + // related to single prim in a link-set ( ie group) + if (pha != null) + pha.Building = true; + + // must deal with root part specially for position and rotation + // so parts offset positions or rotations are fixed + + if (part == group.RootPart) + { + if ((what & ObjectChangeWhat.Position) != 0) + group.UpdateRootPosition(data.position); + if ((what & ObjectChangeWhat.Rotation) != 0) + group.UpdateRootRotation(data.rotation); + } + else + { + if ((what & ObjectChangeWhat.Position) != 0) + part.OffsetPosition = data.position; + if ((what & ObjectChangeWhat.Rotation) != 0) + part.UpdateRotation(data.rotation); + } + + if ((what & ObjectChangeWhat.Scale) != 0) + part.Resize(data.scale); + + if (pha != null) + pha.Building = false; + } + } + } +*/ /// /// Update the scale of an individual prim. /// @@ -1303,7 +1435,17 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) { + bool physbuild = false; + if (part.ParentGroup.RootPart.PhysActor != null) + { + part.ParentGroup.RootPart.PhysActor.Building = true; + physbuild = true; + } + part.Resize(scale); + + if (physbuild) + part.ParentGroup.RootPart.PhysActor.Building = false; } } } @@ -1315,7 +1457,17 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) { + bool physbuild = false; + if (group.RootPart.PhysActor != null) + { + group.RootPart.PhysActor.Building = true; + physbuild = true; + } + group.GroupResize(scale); + + if (physbuild) + group.RootPart.PhysActor.Building = false; } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5818798..92f2d54 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3124,10 +3124,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void GroupResize(Vector3 scale) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); -// RootPart.StoreUndoState(true); - scale.X = Math.Min(scale.X, Scene.m_maxNonphys); scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); @@ -3152,7 +3148,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart obPart = parts[i]; if (obPart.UUID != m_rootPart.UUID) { -// obPart.IgnoreUndoUpdate = true; Vector3 oldSize = new Vector3(obPart.Scale); float f = 1.0f; @@ -3216,8 +3211,6 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } } - -// obPart.IgnoreUndoUpdate = false; } } } @@ -3226,9 +3219,8 @@ namespace OpenSim.Region.Framework.Scenes prevScale.X *= x; prevScale.Y *= y; prevScale.Z *= z; -// RootPart.IgnoreUndoUpdate = true; + RootPart.Resize(prevScale); -// RootPart.IgnoreUndoUpdate = false; parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -3237,8 +3229,6 @@ namespace OpenSim.Region.Framework.Scenes if (obPart.UUID != m_rootPart.UUID) { -// obPart.IgnoreUndoUpdate = true; - Vector3 currentpos = new Vector3(obPart.OffsetPosition); currentpos.X *= x; currentpos.Y *= y; @@ -3251,18 +3241,12 @@ namespace OpenSim.Region.Framework.Scenes obPart.Resize(newSize); obPart.UpdateOffSet(currentpos); - -// obPart.IgnoreUndoUpdate = false; } -// obPart.IgnoreUndoUpdate = false; HasGroupChanged = true; m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); ScheduleGroupForTerseUpdate(); } - -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); } #endregion @@ -3275,14 +3259,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupPosition(Vector3 pos) { -// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); - -// RootPart.StoreUndoState(true); - -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); - if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { if (IsAttachment) @@ -3314,22 +3290,14 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// + /// + public void UpdateSinglePosition(Vector3 pos, uint localID) { SceneObjectPart part = GetChildPart(localID); -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); - if (part != null) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); - -// part.StoreUndoState(false); -// part.IgnoreUndoUpdate = true; - // unlock parts position change if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = true; @@ -3347,7 +3315,6 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.PhysActor.Building = false; HasGroupChanged = true; -// part.IgnoreUndoUpdate = false; } } @@ -3357,13 +3324,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateRootPosition(Vector3 pos) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); - -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); - + // needs to be called with phys building true Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); Vector3 oldPos = new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, @@ -3383,17 +3344,7 @@ namespace OpenSim.Region.Framework.Scenes obPart.OffsetPosition = obPart.OffsetPosition + diff; } - //We have to set undoing here because otherwise an undo state will be saved -// if (!m_rootPart.Undoing) -// { -// m_rootPart.Undoing = true; - AbsolutePosition = newPos; -// m_rootPart.Undoing = false; -// } -// else -// { -// AbsolutePosition = newPos; -// } + AbsolutePosition = newPos; HasGroupChanged = true; if (m_rootPart.Undoing) @@ -3416,17 +3367,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationR(Quaternion rot) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); - -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); - -// m_rootPart.StoreUndoState(true); - -// m_rootPart.UpdateRotation(rot); - PhysicsActor actor = m_rootPart.PhysActor; if (actor != null) { @@ -3445,16 +3385,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); - -// SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].StoreUndoState(); - -// RootPart.StoreUndoState(true); -// RootPart.IgnoreUndoUpdate = true; - m_rootPart.UpdateRotation(rot); PhysicsActor actor = m_rootPart.PhysActor; @@ -3468,8 +3398,6 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; ScheduleGroupForTerseUpdate(); - -// RootPart.IgnoreUndoUpdate = false; } /// @@ -3484,9 +3412,6 @@ namespace OpenSim.Region.Framework.Scenes if (part != null) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); - if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = true; @@ -3514,30 +3439,13 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", -// part.Name, part.LocalId, rot); - -// part.StoreUndoState(); -// part.IgnoreUndoUpdate = true; - if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = true; if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); -/* if (!m_rootPart.Undoing) - { - m_rootPart.Undoing = true; - AbsolutePosition = pos; - m_rootPart.Undoing = false; - } - else - { - */ - AbsolutePosition = pos; -// } + AbsolutePosition = pos; } else { @@ -3547,8 +3455,6 @@ namespace OpenSim.Region.Framework.Scenes if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = false; - -// part.IgnoreUndoUpdate = false; } } @@ -3558,13 +3464,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateRootRotation(Quaternion rot) { -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", -// Name, LocalId, rot); - + // needs to be called with phys building true Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; -// m_rootPart.StoreUndoState(); //Don't use UpdateRotation because it schedules an update prematurely m_rootPart.RotationOffset = rot; @@ -3580,8 +3482,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart prim = parts[i]; if (prim.UUID != m_rootPart.UUID) { -// prim.IgnoreUndoUpdate = true; - Quaternion NewRot = oldParentRot * prim.RotationOffset; NewRot = Quaternion.Inverse(axRot) * NewRot; prim.RotationOffset = NewRot; @@ -3591,26 +3491,88 @@ namespace OpenSim.Region.Framework.Scenes axPos *= oldParentRot; axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; - -// prim.IgnoreUndoUpdate = false; } } -// for (int i = 0; i < parts.Length; i++) -// { -// SceneObjectPart childpart = parts[i]; -// if (childpart != m_rootPart) -// { -//// childpart.IgnoreUndoUpdate = false; -//// childpart.StoreUndoState(); -// } -// } HasGroupChanged = true; ScheduleGroupForFullUpdate(); + } -// m_log.DebugFormat( -// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", -// Name, LocalId, rot); + public void doChangeObject(SceneObjectPart part, ObjectChangeData data) + { + // TODO this still as excessive ScheduleGroupForTerseUpdate()s + + if (part != null && part.ParentGroup != null) + { + ObjectChangeWhat what = data.what; + bool togroup = ((what & ObjectChangeWhat.Group) != 0); + // bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use + + SceneObjectGroup group = part.ParentGroup; + PhysicsActor pha = group.RootPart.PhysActor; + + bool needgrpUpdate = false; + + if (togroup) + { + // related to group + if ((what & ObjectChangeWhat.Position) != 0) + { + group.AbsolutePosition = data.position; + needgrpUpdate = true; + } + if ((what & ObjectChangeWhat.Rotation) != 0) + group.RootPart.UpdateRotation(data.rotation); + if ((what & ObjectChangeWhat.Scale) != 0) + { + if (pha != null) + pha.Building = true; + group.GroupResize(data.scale); + if (pha != null) + pha.Building = false; + } + } + else + { + // related to single prim in a link-set ( ie group) + if (pha != null) + pha.Building = true; + + // must deal with root part specially for position and rotation + // so parts offset positions or rotations are fixed + + if (part == group.RootPart) + { + if ((what & ObjectChangeWhat.Position) != 0) + group.UpdateRootPosition(data.position); + if ((what & ObjectChangeWhat.Rotation) != 0) + group.UpdateRootRotation(data.rotation); + } + else + { + + if ((what & ObjectChangeWhat.Position) != 0) + { + part.OffsetPosition = data.position; + needgrpUpdate = true; + } + if ((what & ObjectChangeWhat.Rotation) != 0) + part.UpdateRotation(data.rotation); + } + + if ((what & ObjectChangeWhat.Scale) != 0) + part.Resize(data.scale); + + if (pha != null) + pha.Building = false; + } + + if (needgrpUpdate) + { + HasGroupChanged = true; + ScheduleGroupForTerseUpdate(); + } + } } #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6622495..c806fda 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1944,6 +1944,7 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds += PhysicsOutOfBounds; + if (ParentID != 0 && ParentID != LocalId) { if (ParentGroup.RootPart.PhysActor != null) @@ -3656,7 +3657,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.ScheduleGroupForTerseUpdate(); //ParentGroup.ScheduleGroupForFullUpdate(); } - +/* public void StoreUndoState() { StoreUndoState(false); @@ -3697,6 +3698,44 @@ namespace OpenSim.Region.Framework.Scenes } } } +*/ + + + public void StoreUndoState(ObjectChangeWhat what) + { + if (!Undoing && !IgnoreUndoUpdate) // just to read better - undo is in progress, or suspended + { + if (ParentGroup != null) + { + lock (m_undo) + { + if (m_undo.Count > 0) + { + // see if we had a change + + UndoState last = m_undo.Peek(); + if (last != null) + { + if (last.Compare(this, what)) + { + return; + } + } + } + + if (ParentGroup.GetSceneMaxUndo() > 0) + { + UndoState nUndo = new UndoState(this, what); + + m_undo.Push(nUndo); + + if (m_redo.Count > 0) + m_redo.Clear(); + } + } + } + } + } /// /// Return number of undos on the stack. Here temporarily pending a refactor. @@ -3725,10 +3764,10 @@ namespace OpenSim.Region.Framework.Scenes if (goback != null) { UndoState nUndo = null; - + if (ParentGroup.GetSceneMaxUndo() > 0) { - nUndo = new UndoState(this, goback.ForGroup); + nUndo = new UndoState(this, goback.data.what); } goback.PlayState(this); @@ -3760,7 +3799,7 @@ namespace OpenSim.Region.Framework.Scenes { if (ParentGroup.GetSceneMaxUndo() > 0) { - UndoState nUndo = new UndoState(this, gofwd.ForGroup); + UndoState nUndo = new UndoState(this, gofwd.data.what); m_undo.Push(nUndo); } diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 38474de..eb76ca5 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -48,6 +48,7 @@ namespace OpenSim.Region.Framework.Scenes STATE_ALL = 63 } +/* public class UndoState { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -121,9 +122,16 @@ namespace OpenSim.Region.Framework.Scenes public void PlayState(SceneObjectPart part) { part.Undoing = true; - + bool physbuilding = false; + if (part.ParentID == 0) { + if (!ForGroup && part.PhysActor != null) + { + part.PhysActor.Building = true; + physbuilding = true; + } + if (Position != Vector3.Zero) { if (ForGroup) @@ -139,17 +147,34 @@ namespace OpenSim.Region.Framework.Scenes if (Scale != Vector3.Zero) { + if (!physbuilding && part.PhysActor != null) + { + part.PhysActor.Building = true; + physbuilding = true; + } + if (ForGroup) part.ParentGroup.GroupResize(Scale); else part.Resize(Scale); } + + if (physbuilding) + part.PhysActor.Building = false; + part.ParentGroup.ScheduleGroupForTerseUpdate(); } else { if (ForGroup) // trap for group since seems parts can't do it return; + + // changing a part invalidates entire object physical rep + if (part.ParentGroup != null && part.ParentGroup.RootPart != null && part.ParentGroup.RootPart.PhysActor != null) + { + part.ParentGroup.RootPart.PhysActor.Building = true; + physbuilding = true; + } // Note: Updating these properties on sop automatically schedules an update if needed part.OffsetPosition = Position; @@ -158,12 +183,98 @@ namespace OpenSim.Region.Framework.Scenes { part.Resize(Scale); } + + if (physbuilding) + part.ParentGroup.RootPart.PhysActor.Building = false; + } + + part.Undoing = false; + } + } +*/ + public class UndoState + { + public ObjectChangeData data; + /// + /// Constructor. + /// + /// + /// True if the undo is for an entire group + /// only for root parts ???? + public UndoState(SceneObjectPart part, ObjectChangeWhat what) + { + data = new ObjectChangeData(); + + data.what = what; + + if (part.ParentGroup.RootPart == part) + { + if ((what & ObjectChangeWhat.Position) != 0) + data.position = part.ParentGroup.AbsolutePosition; + if ((what & ObjectChangeWhat.Rotation) != 0) + data.rotation = part.RotationOffset; + if ((what & ObjectChangeWhat.Scale) != 0) + data.scale = part.Shape.Scale; + } + else + { + if ((what & ObjectChangeWhat.Position) != 0) + data.position = part.OffsetPosition; + if ((what & ObjectChangeWhat.Rotation) != 0) + data.rotation = part.RotationOffset; + if ((what & ObjectChangeWhat.Scale) != 0) + data.scale = part.Shape.Scale; + } + } + + /// + /// Compare the relevant state in the given part to this state. + /// + /// + /// true if both the part's position, rotation and scale match those in this undo state. False otherwise. + public bool Compare(SceneObjectPart part, ObjectChangeWhat what) + { + if (data.what != what) // if diferent targets, then they are diferent + return false; + + if (part != null) + { + if (part.ParentID == 0) + { + if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) + return false; + } + else + { + if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.OffsetPosition) + return false; + } + + if ((what & ObjectChangeWhat.Rotation) != 0 && data.rotation != part.RotationOffset) + return false; + if ((what & ObjectChangeWhat.Rotation) != 0 && data.scale == part.Shape.Scale) + return false; + return true; + } + return false; + } + public void PlayState(SceneObjectPart part) + { + part.Undoing = true; + + SceneObjectGroup grp = part.ParentGroup; + + if (grp != null) + { + grp.doChangeObject(part, data); + } part.Undoing = false; } } + public class LandUndoState { public ITerrainModule m_terrainModule; -- cgit v1.1 From ab235abc46e3d902a7aaf61e589b81f826a2d7a5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 00:36:34 +0000 Subject: Changed undo redo internals. moved exec code to UndoState.cs from sop that now only sees a unified UndoRedoStore class, added size limit on buffers so only last 5 undo/redo are kept. (5 is hardcode like it was ) ***UNTESTED*** --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 155 +++--------------- OpenSim/Region/Framework/Scenes/UndoState.cs | 176 ++++++++++++++++++++- 2 files changed, 195 insertions(+), 136 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c806fda..f70b259 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -263,8 +263,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_occupied; // KF if any av is sitting on this prim private string m_text = String.Empty; private string m_touchName = String.Empty; - private Stack m_undo = new Stack(5); - private Stack m_redo = new Stack(5); + private UndoRedoState m_UndoRedo = new UndoRedoState(5); private bool m_passTouches; @@ -1709,8 +1708,8 @@ namespace OpenSim.Region.Framework.Scenes dupe.Category = Category; dupe.m_rezzed = m_rezzed; - dupe.m_undo = new Stack(5); - dupe.m_redo = new Stack(5); + dupe.m_UndoRedo = new UndoRedoState(5); + dupe.IgnoreUndoUpdate = false; dupe.Undoing = false; @@ -3657,82 +3656,14 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.ScheduleGroupForTerseUpdate(); //ParentGroup.ScheduleGroupForFullUpdate(); } -/* - public void StoreUndoState() - { - StoreUndoState(false); - } - - public void StoreUndoState(bool forGroup) - { - if (!Undoing && !IgnoreUndoUpdate) // just to read better - undo is in progress, or suspended - { - if (ParentGroup != null) - { - lock (m_undo) - { - if (m_undo.Count > 0) - { - // see if we had a change - - UndoState last = m_undo.Peek(); - if (last != null) - { - if (last.Compare(this, forGroup)) - { - return; - } - } - } - - if (ParentGroup.GetSceneMaxUndo() > 0) - { - UndoState nUndo = new UndoState(this, forGroup); - - m_undo.Push(nUndo); - - if (m_redo.Count > 0) - m_redo.Clear(); - } - } - } - } - } -*/ - public void StoreUndoState(ObjectChangeWhat what) { - if (!Undoing && !IgnoreUndoUpdate) // just to read better - undo is in progress, or suspended + lock (m_UndoRedo) { - if (ParentGroup != null) + if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended { - lock (m_undo) - { - if (m_undo.Count > 0) - { - // see if we had a change - - UndoState last = m_undo.Peek(); - if (last != null) - { - if (last.Compare(this, what)) - { - return; - } - } - } - - if (ParentGroup.GetSceneMaxUndo() > 0) - { - UndoState nUndo = new UndoState(this, what); - - m_undo.Push(nUndo); - - if (m_redo.Count > 0) - m_redo.Clear(); - } - } + m_UndoRedo.StoreUndo(this, what); } } } @@ -3744,84 +3675,42 @@ namespace OpenSim.Region.Framework.Scenes { get { - lock (m_undo) - return m_undo.Count; + lock (m_UndoRedo) + return m_UndoRedo.Count; } } public void Undo() { - lock (m_undo) + lock (m_UndoRedo) { -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", -// Name, LocalId, m_undo.Count); - - if (m_undo.Count > 0) - { - UndoState goback = m_undo.Pop(); - - if (goback != null) - { - UndoState nUndo = null; - - if (ParentGroup.GetSceneMaxUndo() > 0) - { - nUndo = new UndoState(this, goback.data.what); - } - - goback.PlayState(this); - - if (nUndo != null) - m_redo.Push(nUndo); - } - } + if (Undoing || ParentGroup == null) + return; -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", -// Name, LocalId, m_undo.Count); + Undoing = true; + m_UndoRedo.Undo(this); + Undoing = false; } } public void Redo() { - lock (m_undo) + lock (m_UndoRedo) { -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", -// Name, LocalId, m_redo.Count); - - if (m_redo.Count > 0) - { - UndoState gofwd = m_redo.Pop(); - - if (gofwd != null) - { - if (ParentGroup.GetSceneMaxUndo() > 0) - { - UndoState nUndo = new UndoState(this, gofwd.data.what); - - m_undo.Push(nUndo); - } - - gofwd.PlayState(this); - } + if (Undoing || ParentGroup == null) + return; -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", -// Name, LocalId, m_redo.Count); - } + Undoing = true; + m_UndoRedo.Redo(this); + Undoing = false; } } public void ClearUndoState() { -// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); - - lock (m_undo) + lock (m_UndoRedo) { - m_undo.Clear(); - m_redo.Clear(); + m_UndoRedo.Clear(); } } diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index eb76ca5..668b53b 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -27,6 +27,7 @@ using System; using System.Reflection; +using System.Collections.Generic; using log4net; using OpenMetaverse; using OpenSim.Region.Framework.Interfaces; @@ -34,6 +35,8 @@ using System; namespace OpenSim.Region.Framework.Scenes { + +/* [Flags] public enum UndoType { @@ -48,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes STATE_ALL = 63 } -/* + public class UndoState { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -194,7 +197,10 @@ namespace OpenSim.Region.Framework.Scenes */ public class UndoState { + const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) + public ObjectChangeData data; + public DateTime creationtime; /// /// Constructor. /// @@ -204,8 +210,8 @@ namespace OpenSim.Region.Framework.Scenes public UndoState(SceneObjectPart part, ObjectChangeWhat what) { data = new ObjectChangeData(); - data.what = what; + creationtime = DateTime.UtcNow; if (part.ParentGroup.RootPart == part) { @@ -227,12 +233,25 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool checkExpire() + { + TimeSpan t = DateTime.UtcNow - creationtime; + if (t.Seconds > UNDOEXPIRESECONDS) + return true; + return false; + } + + public void updateExpire() + { + creationtime = DateTime.UtcNow; + } + /// /// Compare the relevant state in the given part to this state. /// /// /// true if both the part's position, rotation and scale match those in this undo state. False otherwise. - public bool Compare(SceneObjectPart part, ObjectChangeWhat what) + public bool Compare(SceneObjectPart part, ObjectChangeWhat what) { if (data.what != what) // if diferent targets, then they are diferent return false; @@ -274,6 +293,157 @@ namespace OpenSim.Region.Framework.Scenes } } + public class UndoRedoState + { + int size; + public LinkedList m_redo = new LinkedList(); + public LinkedList m_undo = new LinkedList(); + + public UndoRedoState() + { + size = 5; + } + + public UndoRedoState(int _size) + { + if (_size < 3) + size = 3; + else + size = _size; + } + + public int Count + { + get { return m_undo.Count; } + } + + public void Clear() + { + m_undo.Clear(); + m_redo.Clear(); + } + + public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what) + { + lock (m_undo) + { + UndoState last; + + if (m_redo.Count > 0) // last code seems to clear redo on every new undo + { + m_redo.Clear(); + } + + if (m_undo.Count > 0) + { + // check expired entry + last = m_undo.First.Value; + if (last != null && last.checkExpire()) + m_undo.Clear(); + else + { + // see if we actually have a change + if (last != null) + { + if (last.Compare(part, what)) + return; + } + } + } + + // limite size + while (m_undo.Count >= size) + m_undo.RemoveLast(); + + UndoState nUndo = new UndoState(part, what); + m_undo.AddFirst(nUndo); + } + } + + public void Undo(SceneObjectPart part) + { + lock (m_undo) + { + UndoState nUndo; + + // expire redo + if (m_redo.Count > 0) + { + nUndo = m_redo.First.Value; + if (nUndo != null && nUndo.checkExpire()) + m_redo.Clear(); + } + + if (m_undo.Count > 0) + { + UndoState goback = m_undo.First.Value; + // check expired + if (goback != null && goback.checkExpire()) + { + m_undo.Clear(); + return; + } + + if (goback != null) + { + m_undo.RemoveFirst(); + + // redo limite size + while (m_redo.Count >= size) + m_redo.RemoveLast(); + + nUndo = new UndoState(part, goback.data.what); // new value in part should it be full goback copy? + m_redo.AddFirst(nUndo); + + goback.PlayState(part); + } + } + } + } + + public void Redo(SceneObjectPart part) + { + lock (m_undo) + { + UndoState nUndo; + + // expire undo + if (m_undo.Count > 0) + { + nUndo = m_undo.First.Value; + if (nUndo != null && nUndo.checkExpire()) + m_undo.Clear(); + } + + if (m_redo.Count > 0) + { + UndoState gofwd = m_redo.First.Value; + // check expired + if (gofwd != null && gofwd.checkExpire()) + { + m_redo.Clear(); + return; + } + + if (gofwd != null) + { + m_redo.RemoveFirst(); + + // limite undo size + while (m_undo.Count >= size) + m_undo.RemoveLast(); + + nUndo = new UndoState(part, gofwd.data.what); // new value in part should it be full gofwd copy? + m_undo.AddFirst(nUndo); + + gofwd.PlayState(part); + } + } + } + } + + + } public class LandUndoState { -- cgit v1.1 From dba0d79833632227a806e1a46047607a0f653b58 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 02:55:39 +0000 Subject: minor changes on updates control on doChangeObject(..) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 58 ++++++++++++++++++---- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 92f2d54..92fd1fa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3498,6 +3498,15 @@ namespace OpenSim.Region.Framework.Scenes ScheduleGroupForFullUpdate(); } + private enum updatetype :int + { + none = 0, + partterse = 1, + partfull = 2, + groupterse = 3, + groupfull = 4 + } + public void doChangeObject(SceneObjectPart part, ObjectChangeData data) { // TODO this still as excessive ScheduleGroupForTerseUpdate()s @@ -3511,7 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; PhysicsActor pha = group.RootPart.PhysActor; - bool needgrpUpdate = false; + updatetype updateType = updatetype.none; if (togroup) { @@ -3519,15 +3528,21 @@ namespace OpenSim.Region.Framework.Scenes if ((what & ObjectChangeWhat.Position) != 0) { group.AbsolutePosition = data.position; - needgrpUpdate = true; + updateType = updatetype.groupterse; } if ((what & ObjectChangeWhat.Rotation) != 0) + { group.RootPart.UpdateRotation(data.rotation); + updateType = updatetype.none; + } if ((what & ObjectChangeWhat.Scale) != 0) { if (pha != null) pha.Building = true; + group.GroupResize(data.scale); + updateType = updatetype.none; + if (pha != null) pha.Building = false; } @@ -3547,30 +3562,53 @@ namespace OpenSim.Region.Framework.Scenes group.UpdateRootPosition(data.position); if ((what & ObjectChangeWhat.Rotation) != 0) group.UpdateRootRotation(data.rotation); + if ((what & ObjectChangeWhat.Scale) != 0) + part.Resize(data.scale); } else { - if ((what & ObjectChangeWhat.Position) != 0) { part.OffsetPosition = data.position; - needgrpUpdate = true; + updateType = updatetype.partterse; } if ((what & ObjectChangeWhat.Rotation) != 0) + { part.UpdateRotation(data.rotation); + updateType = updatetype.none; + } + if ((what & ObjectChangeWhat.Scale) != 0) + { + part.Resize(data.scale); + updateType = updatetype.none; + } } - if ((what & ObjectChangeWhat.Scale) != 0) - part.Resize(data.scale); - if (pha != null) pha.Building = false; } - if (needgrpUpdate) + if (updateType != updatetype.none) { - HasGroupChanged = true; - ScheduleGroupForTerseUpdate(); + group.HasGroupChanged = true; + + switch (updateType) + { + case updatetype.partterse: + part.ScheduleTerseUpdate(); + break; + case updatetype.partfull: + part.ScheduleFullUpdate(); + break; + case updatetype.groupterse: + group.ScheduleGroupForTerseUpdate(); + break; + case updatetype.groupfull: + group.ScheduleGroupForFullUpdate(); + break; + default: + break; + } } } } -- cgit v1.1 From 80160c128de25e6f0013640f57e3bea0a89aeb7a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 02:58:56 +0000 Subject: coments change.. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 92fd1fa..bb554e1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3509,7 +3509,7 @@ namespace OpenSim.Region.Framework.Scenes public void doChangeObject(SceneObjectPart part, ObjectChangeData data) { - // TODO this still as excessive ScheduleGroupForTerseUpdate()s + // TODO this still as excessive *.Schedule*Update()s if (part != null && part.ParentGroup != null) { @@ -3553,8 +3553,8 @@ namespace OpenSim.Region.Framework.Scenes if (pha != null) pha.Building = true; - // must deal with root part specially for position and rotation - // so parts offset positions or rotations are fixed + // root part is special + // parts offset positions or rotations need to change also if (part == group.RootPart) { -- cgit v1.1 From 53bda83cc292786e5ee7e1914bbc0c959f065b75 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 03:14:15 +0000 Subject: cleanup + comments --- OpenSim/Region/Framework/Scenes/UndoState.cs | 219 +++++++-------------------- 1 file changed, 52 insertions(+), 167 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 668b53b..fd90714 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -31,170 +31,9 @@ using System.Collections.Generic; using log4net; using OpenMetaverse; using OpenSim.Region.Framework.Interfaces; -using System; namespace OpenSim.Region.Framework.Scenes { - -/* - [Flags] - public enum UndoType - { - STATE_PRIM_POSITION = 1, - STATE_PRIM_ROTATION = 2, - STATE_PRIM_SCALE = 4, - STATE_PRIM_ALL = 7, - STATE_GROUP_POSITION = 8, - STATE_GROUP_ROTATION = 16, - STATE_GROUP_SCALE = 32, - STATE_GROUP_ALL = 56, - STATE_ALL = 63 - } - - - public class UndoState - { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public Vector3 Position = Vector3.Zero; - public Vector3 Scale = Vector3.Zero; - public Quaternion Rotation = Quaternion.Identity; - - /// - /// Is this undo state for an entire group? - /// - public bool ForGroup; - - /// - /// Constructor. - /// - /// - /// True if the undo is for an entire group - /// only for root parts ???? - public UndoState(SceneObjectPart part, bool forGroup) - { - if (part.ParentID == 0) - { - ForGroup = forGroup; - Position = part.ParentGroup.AbsolutePosition; - Rotation = part.RotationOffset; - Scale = part.Shape.Scale; - } - else - { - ForGroup = false; // only root parts can undo grp - Position = part.OffsetPosition; - Rotation = part.RotationOffset; - Scale = part.Shape.Scale; - } - } - - /// - /// Compare the relevant state in the given part to this state. - /// - /// - /// true if both the part's position, rotation and scale match those in this undo state. False otherwise. - public bool Compare(SceneObjectPart part, bool forgrp) - { - if (ForGroup != forgrp) // if diferent targets, then they are diferent - return false; - - if (part != null) - { - if (part.ParentID == 0) - { - // root part - // grp position is same as part - if (Position != part.ParentGroup.AbsolutePosition) - return false; - if (Rotation != part.RotationOffset) - return false; - return Scale == part.Shape.Scale; - } - else - { - return (Position == part.OffsetPosition - && Rotation == part.RotationOffset - && Scale == part.Shape.Scale); - } - } - - return false; - } - - public void PlayState(SceneObjectPart part) - { - part.Undoing = true; - bool physbuilding = false; - - if (part.ParentID == 0) - { - if (!ForGroup && part.PhysActor != null) - { - part.PhysActor.Building = true; - physbuilding = true; - } - - if (Position != Vector3.Zero) - { - if (ForGroup) - part.ParentGroup.AbsolutePosition = Position; - else - part.ParentGroup.UpdateRootPosition(Position); - } - - if (ForGroup) - part.UpdateRotation(Rotation); - else - part.ParentGroup.UpdateRootRotation(Rotation); - - if (Scale != Vector3.Zero) - { - if (!physbuilding && part.PhysActor != null) - { - part.PhysActor.Building = true; - physbuilding = true; - } - - if (ForGroup) - part.ParentGroup.GroupResize(Scale); - else - part.Resize(Scale); - } - - if (physbuilding) - part.PhysActor.Building = false; - - part.ParentGroup.ScheduleGroupForTerseUpdate(); - } - else - { - if (ForGroup) // trap for group since seems parts can't do it - return; - - // changing a part invalidates entire object physical rep - if (part.ParentGroup != null && part.ParentGroup.RootPart != null && part.ParentGroup.RootPart.PhysActor != null) - { - part.ParentGroup.RootPart.PhysActor.Building = true; - physbuilding = true; - } - - // Note: Updating these properties on sop automatically schedules an update if needed - part.OffsetPosition = Position; - part.UpdateRotation(Rotation); - if (Scale != Vector3.Zero) - { - part.Resize(Scale); - } - - if (physbuilding) - part.ParentGroup.RootPart.PhysActor.Building = false; - } - - part.Undoing = false; - } - } -*/ public class UndoState { const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) @@ -205,8 +44,8 @@ namespace OpenSim.Region.Framework.Scenes /// Constructor. /// /// - /// True if the undo is for an entire group - /// only for root parts ???? + /// bit field with what is changed + /// public UndoState(SceneObjectPart part, ObjectChangeWhat what) { data = new ObjectChangeData(); @@ -232,6 +71,9 @@ namespace OpenSim.Region.Framework.Scenes data.scale = part.Shape.Scale; } } + /// + /// check if undo or redo is too old + /// public bool checkExpire() { @@ -241,6 +83,9 @@ namespace OpenSim.Region.Framework.Scenes return false; } + /// + /// updates undo or redo creation time to now + /// public void updateExpire() { creationtime = DateTime.UtcNow; @@ -250,7 +95,8 @@ namespace OpenSim.Region.Framework.Scenes /// Compare the relevant state in the given part to this state. /// /// - /// true if both the part's position, rotation and scale match those in this undo state. False otherwise. + /// true what fiels and related data are equal, False otherwise. + /// public bool Compare(SceneObjectPart part, ObjectChangeWhat what) { if (data.what != what) // if diferent targets, then they are diferent @@ -279,6 +125,12 @@ namespace OpenSim.Region.Framework.Scenes return false; } + /// + /// executes the undo or redo to a part or its group + /// + /// + /// + public void PlayState(SceneObjectPart part) { part.Undoing = true; @@ -298,12 +150,21 @@ namespace OpenSim.Region.Framework.Scenes int size; public LinkedList m_redo = new LinkedList(); public LinkedList m_undo = new LinkedList(); - + + /// + /// creates a new UndoRedoState with default states memory size + /// + public UndoRedoState() { size = 5; } + /// + /// creates a new UndoRedoState with states memory having indicated size + /// + /// + public UndoRedoState(int _size) { if (_size < 3) @@ -312,17 +173,31 @@ namespace OpenSim.Region.Framework.Scenes size = _size; } + /// + /// returns number of undo entries in memory + /// + public int Count { get { return m_undo.Count; } } + /// + /// clears all undo and redo entries + /// + public void Clear() { m_undo.Clear(); m_redo.Clear(); } + /// + /// adds a new state undo to part or its group, with changes indicated by what bits + /// + /// + /// bit field with what is changed + public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what) { lock (m_undo) @@ -360,6 +235,12 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// executes last state undo to part or its group + /// current state is pushed into redo + /// + /// + public void Undo(SceneObjectPart part) { lock (m_undo) @@ -401,6 +282,12 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// executes last state redo to part or its group + /// current state is pushed into undo + /// + /// + public void Redo(SceneObjectPart part) { lock (m_undo) @@ -441,8 +328,6 @@ namespace OpenSim.Region.Framework.Scenes } } } - - } public class LandUndoState -- cgit v1.1 From dab7e0358499702754fbc1aaa932767c77153453 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 08:43:53 +0000 Subject: bug fix (??) in sog copy() --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bb554e1..2654563 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1940,37 +1940,46 @@ namespace OpenSim.Region.Framework.Scenes { newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); newPart.LinkNum = part.LinkNum; - } + if (userExposed) + newPart.ParentID = dupe.m_rootPart.LocalId; + } else { newPart = dupe.m_rootPart; } +/* + bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); + bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); // Need to duplicate the physics actor as well - if (part.PhysActor != null && userExposed) + if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) { PrimitiveBaseShape pbs = newPart.Shape; - newPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( string.Format("{0}/{1}", newPart.Name, newPart.UUID), pbs, newPart.AbsolutePosition, newPart.Scale, - //newPart.RotationOffset, newPart.GetWorldRotation(), - part.PhysActor.IsPhysical, + isphys, + isphan, newPart.LocalId); - newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); - } + newPart.DoPhysicsPropertyUpdate(isphys, true); + */ + if (userExposed) + newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); +// } } - if (dupe.m_rootPart.PhysActor != null && userExposed) - dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building if (userExposed) { - dupe.UpdateParentIDs(); +// done above dupe.UpdateParentIDs(); + + if (dupe.m_rootPart.PhysActor != null) + dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building + dupe.HasGroupChanged = true; dupe.AttachToBackup(); -- cgit v1.1 From 7832889437c801836aef50edee43862bc6b290b6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 11:01:38 +0000 Subject: Physical phantoms testable with chOde. Volume detection was changed and also needs testing. Started making it more independent of phantom acording to new sl. ** 99.999...% UNTESTED *** --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 283 +++++++++++---------- 1 file changed, 145 insertions(+), 138 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f70b259..a17862e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1577,16 +1577,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// -// public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) + public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building) { if (!ParentGroup.Scene.CollidablePrims) return; -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}", -// Name, LocalId, UUID, m_physicalPrim); - bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; @@ -1597,15 +1593,16 @@ namespace OpenSim.Region.Framework.Scenes else { // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored - if (VolumeDetectActive) - isPhantom = false; +// if (VolumeDetectActive) +// isPhantom = false; // Added clarification.. since A rigid body is an object that you can kick around, etc. - bool RigidBody = isPhysical && !isPhantom; +// bool RigidBody = isPhysical && !isPhantom; // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition // or flexible - if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) + // if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) + if ((!isPhantom || isPhysical || VolumeDetectActive) && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) { Vector3 velocity = Velocity; Vector3 rotationalVelocity = AngularVelocity; @@ -1616,9 +1613,9 @@ namespace OpenSim.Region.Framework.Scenes Shape, AbsolutePosition, Scale, -// RotationOffset, - GetWorldRotation(), // physics wants world rotation - RigidBody, + GetWorldRotation(), + isPhysical, + isPhantom, m_localId); } catch @@ -1637,8 +1634,9 @@ namespace OpenSim.Region.Framework.Scenes if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) m_vehicle.SetVehicle(PhysActor); - DoPhysicsPropertyUpdate(RigidBody, true); - PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + DoPhysicsPropertyUpdate(isPhysical, true); + if(VolumeDetectActive) // change if not the default only + PhysActor.SetVolumeDetect(1); if (!building) PhysActor.Building = false; @@ -1888,73 +1886,62 @@ namespace OpenSim.Region.Framework.Scenes { if (UsePhysics != PhysActor.IsPhysical || isNew) { - if (PhysActor.IsPhysical) // implies UsePhysics==false for this block + if (PhysActor.IsPhysical) { - if (!isNew) + if (!isNew) // implies UsePhysics==false for this block + { ParentGroup.Scene.RemovePhysicalPrim(1); - Velocity = new Vector3(0, 0, 0); - Acceleration = new Vector3(0, 0, 0); - if (ParentGroup.RootPart == this) - AngularVelocity = new Vector3(0, 0, 0); + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); - PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; - PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; - PhysActor.delink(); + if (PhysActor.Phantom) + { + RemoveFromPhysics(); + return; + } - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) - { - // destroy all joints connected to this now deactivated body - ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); + PhysActor.IsPhysical = UsePhysics; + PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; + PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; + PhysActor.delink(); + if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + { + // destroy all joints connected to this now deactivated body + ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); + } } - - // stop client-side interpolation of all joint proxy objects that have just been deleted - // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, - // which stops client-side interpolation of deactivated joint proxy objects. - } - - if (!UsePhysics && !isNew) - { - // reset velocity to 0 on physics switch-off. Without that, the client thinks the - // prim still has velocity and continues to interpolate its position along the old - // velocity-vector. - Velocity = new Vector3(0, 0, 0); - Acceleration = new Vector3(0, 0, 0); - if (ParentGroup.RootPart == this) - AngularVelocity = new Vector3(0, 0, 0); - //RotationalVelocity = new Vector3(0, 0, 0); } - PhysActor.IsPhysical = UsePhysics; - - // If we're not what we're supposed to be in the physics scene, recreate ourselves. - //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); - /// that's not wholesome. Had to make Scene public - //PhysActor = null; + if (PhysActor.IsPhysical != UsePhysics) + PhysActor.IsPhysical = UsePhysics; - if ((Flags & PrimFlags.Phantom) == 0) + if (UsePhysics) { - if (UsePhysics) - { - if (ParentGroup.RootPart.KeyframeMotion != null) - ParentGroup.RootPart.KeyframeMotion.Stop(); - ParentGroup.RootPart.KeyframeMotion = null; - ParentGroup.Scene.AddPhysicalPrim(1); + if (ParentGroup.RootPart.KeyframeMotion != null) + ParentGroup.RootPart.KeyframeMotion.Stop(); + ParentGroup.RootPart.KeyframeMotion = null; + ParentGroup.Scene.AddPhysicalPrim(1); - PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; - PhysActor.OnOutOfBounds += PhysicsOutOfBounds; + PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; + PhysActor.OnOutOfBounds += PhysicsOutOfBounds; - if (ParentID != 0 && ParentID != LocalId) + if (ParentID != 0 && ParentID != LocalId) + { + if (ParentGroup.RootPart.PhysActor != null) { - if (ParentGroup.RootPart.PhysActor != null) - { - PhysActor.link(ParentGroup.RootPart.PhysActor); - } + PhysActor.link(ParentGroup.RootPart.PhysActor); } } - } + } } + bool phan = ((Flags & PrimFlags.Phantom) != 0); + if (PhysActor.Phantom != phan) + PhysActor.Phantom = phan; + // If this part is a sculpt then delay the physics update until we've asynchronously loaded the // mesh data. if (Shape.SculptEntry) @@ -4355,40 +4342,45 @@ namespace OpenSim.Region.Framework.Scenes bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); bool wasVD = VolumeDetectActive; -// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD); -// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD); - if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) return; + // do this first + if (building && PhysActor != null && PhysActor.Building != building) + PhysActor.Building = building; + // Special cases for VD. VD can only be called from a script // and can't be combined with changes to other states. So we can rely // that... // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. - // do this first - if (building && PhysActor != null && PhysActor.Building != building) - PhysActor.Building = building; + if (SetVD) // VD is active, special logic applies - { - // State machine logic for VolumeDetect - // More logic below - bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; - if (phanReset) // Phantom changes from on to off switch VD off too - { - SetVD = false; // Switch it of for the course of this routine - VolumeDetectActive = false; // and also permanently - if (PhysActor != null) - PhysActor.SetVolumeDetect(0); // Let physics know about it too - } - else - { - // If volumedetect is active we don't want phantom to be applied. - // If this is a new call to VD out of the state "phantom" - // this will also cause the prim to be visible to physics + /* volume detection is now independent of phantom in sl + + { + // State machine logic for VolumeDetect + // More logic below + + + bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; + + if (phanReset) // Phantom changes from on to off switch VD off too + { + SetVD = false; // Switch it of for the course of this routine + VolumeDetectActive = false; // and also permanently + if (PhysActor != null) + PhysActor.SetVolumeDetect(0); // Let physics know about it too + } + else + { + // If volumedetect is active we don't want phantom to be applied. + // If this is a new call to VD out of the state "phantom" + // this will also cause the prim to be visible to physics + */ SetPhantom = false; - } +/* } } else if (wasVD) { @@ -4400,10 +4392,11 @@ namespace OpenSim.Region.Framework.Scenes { SetPhantom = true; } - +*/ if (UsePhysics) { AddFlag(PrimFlags.Physics); +/* if (!wasUsingPhysics) { DoPhysicsPropertyUpdate(UsePhysics, false); @@ -4416,84 +4409,99 @@ namespace OpenSim.Region.Framework.Scenes } } } + */ } else { RemFlag(PrimFlags.Physics); +/* if (wasUsingPhysics) { DoPhysicsPropertyUpdate(UsePhysics, false); } - } +*/ + } - if (SetPhantom - || ParentGroup.IsAttachment + if (SetPhantom) + AddFlag(PrimFlags.Phantom); + else + RemFlag(PrimFlags.Phantom); + + if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints { AddFlag(PrimFlags.Phantom); + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); + if (PhysActor != null) + { + ParentGroup.Scene.RemovePhysicalPrim(1); RemoveFromPhysics(); + } } - else // Not phantom + else { - RemFlag(PrimFlags.Phantom); - if (ParentGroup.Scene == null) return; - if (ParentGroup.Scene.CollidablePrims && PhysActor == null) + if (ParentGroup.Scene.CollidablePrims) { - // It's not phantom anymore. So make sure the physics engine get's knowledge of it - PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", Name, UUID), - Shape, - AbsolutePosition, - Scale, -// RotationOffset, - GetWorldRotation(), //physics wants world rotation like all other functions send - UsePhysics, - m_localId); + if (PhysActor == null) + { + PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( + string.Format("{0}/{1}", Name, UUID), + Shape, + AbsolutePosition, + Scale, + GetWorldRotation(), //physics wants world rotation like all other functions send + UsePhysics, + SetPhantom, + m_localId); - PhysActor.SetMaterial(Material); + PhysActor.SetMaterial(Material); + + // if root part apply vehicle + if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicle.SetVehicle(PhysActor); - // if root part apply vehicle - if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) - m_vehicle.SetVehicle(PhysActor); + DoPhysicsPropertyUpdate(UsePhysics, true); - DoPhysicsPropertyUpdate(UsePhysics, true); + if (!ParentGroup.IsDeleted) + { + if (LocalId == ParentGroup.RootPart.LocalId) + { + ParentGroup.CheckSculptAndLoad(); + } + } - if (!ParentGroup.IsDeleted) - { - if (LocalId == ParentGroup.RootPart.LocalId) + if ( + ((AggregateScriptEvents & scriptEvents.collision) != 0) || + ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || + ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + (CollisionSound != UUID.Zero) + ) { - ParentGroup.CheckSculptAndLoad(); + PhysActor.OnCollisionUpdate += PhysicsCollision; + PhysActor.SubscribeEvents(1000); } } - - if ( - ((AggregateScriptEvents & scriptEvents.collision) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - (CollisionSound != UUID.Zero) - ) + else // it already has a physical representation { - PhysActor.OnCollisionUpdate += PhysicsCollision; - PhysActor.SubscribeEvents(1000); - } - } - else // it already has a physical representation - { - DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim + DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. - if (!ParentGroup.IsDeleted) - { - if (LocalId == ParentGroup.RootPart.LocalId) + if (!ParentGroup.IsDeleted) { - ParentGroup.CheckSculptAndLoad(); + if (LocalId == ParentGroup.RootPart.LocalId) + { + ParentGroup.CheckSculptAndLoad(); + } } } } @@ -4509,7 +4517,7 @@ namespace OpenSim.Region.Framework.Scenes if (this.PhysActor != null) { PhysActor.SetVolumeDetect(1); - AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active +// AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active this.VolumeDetectActive = true; } } @@ -4517,8 +4525,7 @@ namespace OpenSim.Region.Framework.Scenes { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) - PhysicsActor pa = this.PhysActor; - if (pa != null) + if (this.PhysActor != null) { PhysActor.SetVolumeDetect(0); } -- cgit v1.1 From a35e00e81eba1d3b0990c9c8139d77d34d6cbb7e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 12 Mar 2012 07:50:14 +0000 Subject: allocate UndoRedoStore only on demand --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a17862e..94e4560 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -263,7 +263,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_occupied; // KF if any av is sitting on this prim private string m_text = String.Empty; private string m_touchName = String.Empty; - private UndoRedoState m_UndoRedo = new UndoRedoState(5); + private UndoRedoState m_UndoRedo = null; private bool m_passTouches; @@ -1706,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes dupe.Category = Category; dupe.m_rezzed = m_rezzed; - dupe.m_UndoRedo = new UndoRedoState(5); + dupe.m_UndoRedo = null; dupe.IgnoreUndoUpdate = false; dupe.Undoing = false; @@ -3646,6 +3646,9 @@ namespace OpenSim.Region.Framework.Scenes public void StoreUndoState(ObjectChangeWhat what) { + if (m_UndoRedo == null) + m_UndoRedo = new UndoRedoState(5); + lock (m_UndoRedo) { if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended @@ -3662,18 +3665,19 @@ namespace OpenSim.Region.Framework.Scenes { get { - lock (m_UndoRedo) - return m_UndoRedo.Count; + if (m_UndoRedo == null) + return 0; + return m_UndoRedo.Count; } } public void Undo() { + if (m_UndoRedo == null || Undoing || ParentGroup == null) + return; + lock (m_UndoRedo) { - if (Undoing || ParentGroup == null) - return; - Undoing = true; m_UndoRedo.Undo(this); Undoing = false; @@ -3682,11 +3686,11 @@ namespace OpenSim.Region.Framework.Scenes public void Redo() { + if (m_UndoRedo == null || Undoing || ParentGroup == null) + return; + lock (m_UndoRedo) { - if (Undoing || ParentGroup == null) - return; - Undoing = true; m_UndoRedo.Redo(this); Undoing = false; @@ -3695,6 +3699,9 @@ namespace OpenSim.Region.Framework.Scenes public void ClearUndoState() { + if (m_UndoRedo == null || Undoing) + return; + lock (m_UndoRedo) { m_UndoRedo.Clear(); -- cgit v1.1 From edc8a15487554cf28a1843e3cbff343a782b1a94 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Mar 2012 14:06:39 +0100 Subject: Restore duplication of the SL bug where linking phantom to solid lets the child prim remain phantom --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2654563..e5cfed0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2511,7 +2511,6 @@ namespace OpenSim.Region.Framework.Scenes // physics flags from group to be applied to linked parts bool grpusephys = UsesPhysics; bool grptemporary = IsTemporary; - bool gprphantom = IsPhantom; Vector3 oldGroupPosition = linkPart.GroupPosition; Quaternion oldRootRotation = linkPart.RotationOffset; @@ -2557,7 +2556,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.CreateSelected = true; // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now - linkPart.UpdatePrimFlags(grpusephys, grptemporary, gprphantom, linkPart.VolumeDetectActive, true); + linkPart.UpdatePrimFlags(grpusephys, grptemporary, (linkPart.Flags & PrimFlags.Phantom) != null, linkPart.VolumeDetectActive, true); if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { linkPart.PhysActor.link(m_rootPart.PhysActor); @@ -2579,7 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); // let physics know - part.UpdatePrimFlags(grpusephys, grptemporary, gprphantom, part.VolumeDetectActive, true); + part.UpdatePrimFlags(grpusephys, grptemporary, (part.Flags & PrimFlags.Phantom) != null, part.VolumeDetectActive, true); if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { part.PhysActor.link(m_rootPart.PhysActor); -- cgit v1.1 From ebcd4910a21726c830796cfe14c0792007b766b7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 13 Mar 2012 13:08:32 +0100 Subject: Refactor, move OjectChangeData into it's own file and rename ObjectChnageWhat what into ObjectChangeType change. What is no name for a variable or type! --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 115 +-------------------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 24 ++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +- OpenSim/Region/Framework/Scenes/UndoState.cs | 43 ++++---- 4 files changed, 37 insertions(+), 149 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5e770ba..e6e3ad0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -47,57 +47,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate void ChangedBackupDelegate(SceneObjectGroup sog); - - public enum ObjectChangeWhat : uint - { - // bits definitions - Position = 0x01, - Rotation = 0x02, - Scale = 0x04, - Group = 0x08, - UniformScale = 0x10, - - // macros from above - // single prim - primP = 0x01, - primR = 0x02, - primPR = 0x03, - primS = 0x04, - primPS = 0x05, - primRS = 0x06, - primPSR = 0x07, - - primUS = 0x14, - primPUS = 0x15, - primRUS = 0x16, - primPUSR = 0x17, - - // group - groupP = 0x09, - groupR = 0x0A, - groupPR = 0x0B, - groupS = 0x0C, - groupPS = 0x0D, - groupRS = 0x0E, - groupPSR = 0x0F, - - groupUS = 0x1C, - groupPUS = 0x1D, - groupRUS = 0x1E, - groupPUSR = 0x1F, - - PRSmask = 0x07 - } - - public struct ObjectChangeData - { - public Quaternion rotation; - public Vector3 position; - public Vector3 scale; - public ObjectChangeWhat what; - } - - /// /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components /// should be migrated out over time. @@ -1352,75 +1301,13 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) { -// part.StoreUndoState(data.what | ObjectChangeWhat.PRSmask); // for now save all to keep previus behavour ??? - part.StoreUndoState(data.what); // lets test only saving what we changed + part.StoreUndoState(data.change); // lets test only saving what we changed grp.doChangeObject(part, (ObjectChangeData)data); } } } } -/* moved to SOG - protected internal void doChangeObject(SceneObjectPart part, ObjectChangeData data) - { - if (part != null && part.ParentGroup != null) - { - ObjectChangeWhat what = data.what; - bool togroup = ((what & ObjectChangeWhat.Group) != 0); -// bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use - - SceneObjectGroup group = part.ParentGroup; - PhysicsActor pha = group.RootPart.PhysActor; - - if (togroup) - { - // related to group - if ((what & ObjectChangeWhat.Position) != 0) - group.AbsolutePosition = data.position; - if ((what & ObjectChangeWhat.Rotation) != 0) - group.RootPart.UpdateRotation(data.rotation); - if ((what & ObjectChangeWhat.Scale) != 0) - { - if (pha != null) - pha.Building = true; - group.GroupResize(data.scale); - if (pha != null) - pha.Building = false; - } - } - else - { - // related to single prim in a link-set ( ie group) - if (pha != null) - pha.Building = true; - - // must deal with root part specially for position and rotation - // so parts offset positions or rotations are fixed - - if (part == group.RootPart) - { - if ((what & ObjectChangeWhat.Position) != 0) - group.UpdateRootPosition(data.position); - if ((what & ObjectChangeWhat.Rotation) != 0) - group.UpdateRootRotation(data.rotation); - } - else - { - if ((what & ObjectChangeWhat.Position) != 0) - part.OffsetPosition = data.position; - if ((what & ObjectChangeWhat.Rotation) != 0) - part.UpdateRotation(data.rotation); - } - - if ((what & ObjectChangeWhat.Scale) != 0) - part.Resize(data.scale); - - if (pha != null) - pha.Building = false; - } - } - } -*/ /// /// Update the scale of an individual prim. /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e5cfed0..b2502e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3521,9 +3521,9 @@ namespace OpenSim.Region.Framework.Scenes if (part != null && part.ParentGroup != null) { - ObjectChangeWhat what = data.what; - bool togroup = ((what & ObjectChangeWhat.Group) != 0); - // bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use + ObjectChangeType change = data.change; + bool togroup = ((change & ObjectChangeType.Group) != 0); + // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use SceneObjectGroup group = part.ParentGroup; PhysicsActor pha = group.RootPart.PhysActor; @@ -3533,17 +3533,17 @@ namespace OpenSim.Region.Framework.Scenes if (togroup) { // related to group - if ((what & ObjectChangeWhat.Position) != 0) + if ((change & ObjectChangeType.Position) != 0) { group.AbsolutePosition = data.position; updateType = updatetype.groupterse; } - if ((what & ObjectChangeWhat.Rotation) != 0) + if ((change & ObjectChangeType.Rotation) != 0) { group.RootPart.UpdateRotation(data.rotation); updateType = updatetype.none; } - if ((what & ObjectChangeWhat.Scale) != 0) + if ((change & ObjectChangeType.Scale) != 0) { if (pha != null) pha.Building = true; @@ -3566,26 +3566,26 @@ namespace OpenSim.Region.Framework.Scenes if (part == group.RootPart) { - if ((what & ObjectChangeWhat.Position) != 0) + if ((change & ObjectChangeType.Position) != 0) group.UpdateRootPosition(data.position); - if ((what & ObjectChangeWhat.Rotation) != 0) + if ((change & ObjectChangeType.Rotation) != 0) group.UpdateRootRotation(data.rotation); - if ((what & ObjectChangeWhat.Scale) != 0) + if ((change & ObjectChangeType.Scale) != 0) part.Resize(data.scale); } else { - if ((what & ObjectChangeWhat.Position) != 0) + if ((change & ObjectChangeType.Position) != 0) { part.OffsetPosition = data.position; updateType = updatetype.partterse; } - if ((what & ObjectChangeWhat.Rotation) != 0) + if ((change & ObjectChangeType.Rotation) != 0) { part.UpdateRotation(data.rotation); updateType = updatetype.none; } - if ((what & ObjectChangeWhat.Scale) != 0) + if ((change & ObjectChangeType.Scale) != 0) { part.Resize(data.scale); updateType = updatetype.none; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 94e4560..f647544 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3644,7 +3644,7 @@ namespace OpenSim.Region.Framework.Scenes //ParentGroup.ScheduleGroupForFullUpdate(); } - public void StoreUndoState(ObjectChangeWhat what) + public void StoreUndoState(ObjectChangeType change) { if (m_UndoRedo == null) m_UndoRedo = new UndoRedoState(5); @@ -3653,7 +3653,7 @@ namespace OpenSim.Region.Framework.Scenes { if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended { - m_UndoRedo.StoreUndo(this, what); + m_UndoRedo.StoreUndo(this, change); } } } diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index fd90714..7bbf1bd 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -30,6 +30,7 @@ using System.Reflection; using System.Collections.Generic; using log4net; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.Framework.Scenes @@ -44,30 +45,30 @@ namespace OpenSim.Region.Framework.Scenes /// Constructor. /// /// - /// bit field with what is changed + /// bit field with what is changed /// - public UndoState(SceneObjectPart part, ObjectChangeWhat what) + public UndoState(SceneObjectPart part, ObjectChangeType change) { data = new ObjectChangeData(); - data.what = what; + data.change = change; creationtime = DateTime.UtcNow; if (part.ParentGroup.RootPart == part) { - if ((what & ObjectChangeWhat.Position) != 0) + if ((change & ObjectChangeType.Position) != 0) data.position = part.ParentGroup.AbsolutePosition; - if ((what & ObjectChangeWhat.Rotation) != 0) + if ((change & ObjectChangeType.Rotation) != 0) data.rotation = part.RotationOffset; - if ((what & ObjectChangeWhat.Scale) != 0) + if ((change & ObjectChangeType.Scale) != 0) data.scale = part.Shape.Scale; } else { - if ((what & ObjectChangeWhat.Position) != 0) + if ((change & ObjectChangeType.Position) != 0) data.position = part.OffsetPosition; - if ((what & ObjectChangeWhat.Rotation) != 0) + if ((change & ObjectChangeType.Rotation) != 0) data.rotation = part.RotationOffset; - if ((what & ObjectChangeWhat.Scale) != 0) + if ((change & ObjectChangeType.Scale) != 0) data.scale = part.Shape.Scale; } } @@ -97,27 +98,27 @@ namespace OpenSim.Region.Framework.Scenes /// /// true what fiels and related data are equal, False otherwise. /// - public bool Compare(SceneObjectPart part, ObjectChangeWhat what) + public bool Compare(SceneObjectPart part, ObjectChangeType change) { - if (data.what != what) // if diferent targets, then they are diferent + if (data.change != change) // if diferent targets, then they are diferent return false; if (part != null) { if (part.ParentID == 0) { - if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) + if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) return false; } else { - if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.OffsetPosition) + if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition) return false; } - if ((what & ObjectChangeWhat.Rotation) != 0 && data.rotation != part.RotationOffset) + if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset) return false; - if ((what & ObjectChangeWhat.Rotation) != 0 && data.scale == part.Shape.Scale) + if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale) return false; return true; @@ -196,9 +197,9 @@ namespace OpenSim.Region.Framework.Scenes /// adds a new state undo to part or its group, with changes indicated by what bits /// /// - /// bit field with what is changed + /// bit field with what is changed - public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what) + public void StoreUndo(SceneObjectPart part, ObjectChangeType change) { lock (m_undo) { @@ -220,7 +221,7 @@ namespace OpenSim.Region.Framework.Scenes // see if we actually have a change if (last != null) { - if (last.Compare(part, what)) + if (last.Compare(part, change)) return; } } @@ -230,7 +231,7 @@ namespace OpenSim.Region.Framework.Scenes while (m_undo.Count >= size) m_undo.RemoveLast(); - UndoState nUndo = new UndoState(part, what); + UndoState nUndo = new UndoState(part, change); m_undo.AddFirst(nUndo); } } @@ -273,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes while (m_redo.Count >= size) m_redo.RemoveLast(); - nUndo = new UndoState(part, goback.data.what); // new value in part should it be full goback copy? + nUndo = new UndoState(part, goback.data.change); // new value in part should it be full goback copy? m_redo.AddFirst(nUndo); goback.PlayState(part); @@ -320,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes while (m_undo.Count >= size) m_undo.RemoveLast(); - nUndo = new UndoState(part, gofwd.data.what); // new value in part should it be full gofwd copy? + nUndo = new UndoState(part, gofwd.data.change); // new value in part should it be full gofwd copy? m_undo.AddFirst(nUndo); gofwd.PlayState(part); -- cgit v1.1 From 22e0cc09ac4bc4ed639d1203d930309f687fdb6f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 13 Mar 2012 13:12:14 +0100 Subject: Ensure child prims of a phantom prim are marked as phantom --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b2502e0..314705e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2556,7 +2556,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.CreateSelected = true; // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now - linkPart.UpdatePrimFlags(grpusephys, grptemporary, (linkPart.Flags & PrimFlags.Phantom) != null, linkPart.VolumeDetectActive, true); + linkPart.UpdatePrimFlags(grpusephys, grptemporary, IsPhantom || ((linkPart.Flags & PrimFlags.Phantom) != null), linkPart.VolumeDetectActive, true); if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { linkPart.PhysActor.link(m_rootPart.PhysActor); @@ -2578,7 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); // let physics know - part.UpdatePrimFlags(grpusephys, grptemporary, (part.Flags & PrimFlags.Phantom) != null, part.VolumeDetectActive, true); + part.UpdatePrimFlags(grpusephys, grptemporary, IsPhantom || ((part.Flags & PrimFlags.Phantom) != null), part.VolumeDetectActive, true); if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { part.PhysActor.link(m_rootPart.PhysActor); -- cgit v1.1 From 3de3b9e63c07bc4b8e6c76d60167f9ead8a07f49 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 17:56:32 +0000 Subject: initial suport for ExtraPhysical parts parameters. Reading from llclientView to SOP including SOPserialization (not to databases). No action on physics still. No send to viewer, etc --- OpenSim/Region/Framework/Scenes/SOPMaterial.cs | 95 +++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 114 ++++++++++++++++++--- 4 files changed, 205 insertions(+), 17 deletions(-) create mode 100644 OpenSim/Region/Framework/Scenes/SOPMaterial.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs new file mode 100644 index 0000000..10ac37c --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs @@ -0,0 +1,95 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Scenes +{ + public static class SOPMaterialData + { + public enum SopMaterial : int // redundante and not in use for now + { + Stone = 0, + Metal = 1, + Glass = 2, + Wood = 3, + Flesh = 4, + Plastic = 5, + Rubber = 6, + light = 7 // compatibility with old viewers + } + + private struct MaterialData + { + public float friction; + public float bounce; + public MaterialData(float f, float b) + { + friction = f; + bounce = b; + } + } + + private static MaterialData[] m_materialdata = { + new MaterialData(0.8f,0.4f), // Stone + new MaterialData(0.3f,0.4f), // Metal + new MaterialData(0.2f,0.7f), // Glass + new MaterialData(0.6f,0.5f), // Wood + new MaterialData(0.9f,0.3f), // Flesh + new MaterialData(0.4f,0.7f), // Plastic + new MaterialData(0.9f,0.95f), // Rubber + new MaterialData(0.0f,0.0f) // light ?? + }; + + public static Material MaxMaterial + { + get { return (Material)(m_materialdata.Length - 1); } + } + + public static float friction(Material material) + { + int indx = (int)material; + if (indx < m_materialdata.Length) + return (m_materialdata[indx].friction); + else + return 0; + } + + public static float bounce(Material material) + { + int indx = (int)material; + if (indx < m_materialdata.Length) + return (m_materialdata[indx].bounce); + else + return 0; + } + + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a3358a5..24e6eb1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4882,7 +4882,7 @@ Environment.Exit(1); private void CheckHeartbeat() { - if (m_firstHeartbeat) +// if (m_firstHeartbeat) return; if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e6e3ad0..7b77ea0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1536,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// protected internal void UpdatePrimFlags( - uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, IClientAPI remoteClient) + uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) @@ -1544,7 +1544,14 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) { // VolumeDetect can't be set via UI and will always be off when a change is made there - group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); + if (PhysData.PhysShapeType == PhysShapeType.invalid) + group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); + else + { + SceneObjectPart part = GetSceneObjectPart(localID); + if (part != null) + part.UpdateExtraPhysics(PhysData); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f647544..ace53f6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -295,7 +295,13 @@ namespace OpenSim.Region.Framework.Scenes protected float m_buoyancy = 0.0f; protected Vector3 m_force; protected Vector3 m_torque; - + + protected byte m_physicsShapeType = (byte)PhysShapeType.prim; + protected float m_density = 1000.0f; // in kg/m^3 + protected float m_gravitymod = 1.0f; + protected float m_friction = 0.6f; // wood + protected float m_bounce = 0.5f; // wood + /// /// Stores media texture data /// @@ -556,19 +562,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public byte Material - { - get { return (byte) m_material; } - set - { - m_material = (Material)value; - if (PhysActor != null) - { - PhysActor.SetMaterial((int)value); - } - } - } - public bool PassTouches { get { return m_passTouches; } @@ -1377,6 +1370,87 @@ namespace OpenSim.Region.Framework.Scenes } } + public byte Material + { + get { return (byte)m_material; } + set + { + if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) + { + m_material = (Material)value; + m_friction = SOPMaterialData.friction(m_material); + m_bounce = SOPMaterialData.bounce(m_material); + if (PhysActor != null) + { + PhysActor.SetMaterial((int)value); + } + } + } + } + + public byte PhysicsShapeType + { + get { return m_physicsShapeType; } + set + { + if (value < 0 || value >= (byte)PhysShapeType.convex) + value = (byte)PhysShapeType.prim; //convex not supported ? + + else if (value == (byte)PhysShapeType.none) + { + if (ParentGroup == null || ParentGroup.RootPart == this) + value = (byte)PhysShapeType.prim; + } + m_physicsShapeType = value; + } + } + + public float Density // in kg/m^3 + { + get { return m_density; } + set + { + if (value >=1 && value <= 22587.0) + { + m_density = value; + } + } + } + + public float GravityModifier + { + get { return m_gravitymod; } + set + { if( value >= -1 && value <=28.0f) + m_gravitymod = value; + } + } + + public float Friction + { + get { return m_friction; } + set + { + if (value >= 0 && value <= 255.0f) + { + m_friction = value; + } + } + } + + public float Bounciness + { + get { return m_bounce; } + set + { + if (value >= 0 && value <= 1.0f) + { + m_bounce = value; + } + } + } + + #endregion Public Properties with only Get private uint ApplyMask(uint val, bool set, uint mask) @@ -4334,6 +4408,18 @@ namespace OpenSim.Region.Framework.Scenes } } + + public void UpdateExtraPhysics(ExtraPhysicsData physdata) + { + if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) + return; + + PhysicsShapeType = (byte)physdata.PhysShapeType; + Density = physdata.Density; + GravityModifier = physdata.GravitationModifier; + Friction = physdata.Friction; + Bounciness = physdata.Bounce; + } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. /// -- cgit v1.1 From 923db53975cd91dca86aee8c7a6c07c25b26db87 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 18:10:43 +0000 Subject: let checkheartbeat work ( bad ideia :p ) commited by mistake my local copy with it disabled... --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 24e6eb1..a3358a5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4882,7 +4882,7 @@ Environment.Exit(1); private void CheckHeartbeat() { -// if (m_firstHeartbeat) + if (m_firstHeartbeat) return; if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) -- cgit v1.1 From bf2a5508debe058cbf48fc1da52d2a6d96954f80 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:17:32 +0000 Subject: bug fix --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 314705e..6feb333 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2556,7 +2556,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.CreateSelected = true; // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now - linkPart.UpdatePrimFlags(grpusephys, grptemporary, IsPhantom || ((linkPart.Flags & PrimFlags.Phantom) != null), linkPart.VolumeDetectActive, true); + linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { linkPart.PhysActor.link(m_rootPart.PhysActor); @@ -2578,7 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); // let physics know - part.UpdatePrimFlags(grpusephys, grptemporary, IsPhantom || ((part.Flags & PrimFlags.Phantom) != null), part.VolumeDetectActive, true); + part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { part.PhysActor.link(m_rootPart.PhysActor); -- cgit v1.1 From 741badc4fa1da61d86fdbb2d33056fa8c6599e69 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:24:41 +0000 Subject: let PhysicsShapeType none remove physics remove physics on child parts **UnTested** --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 48 +++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ace53f6..a68b3eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1657,9 +1657,13 @@ namespace OpenSim.Region.Framework.Scenes if (!ParentGroup.Scene.CollidablePrims) return; + if (PhysicsShapeType == (byte)PhysShapeType.none) + return; + bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; + if (IsJoint()) { DoPhysicsPropertyUpdate(isPhysical, true); @@ -2016,6 +2020,7 @@ namespace OpenSim.Region.Framework.Scenes if (PhysActor.Phantom != phan) PhysActor.Phantom = phan; + // If this part is a sculpt then delay the physics update until we've asynchronously loaded the // mesh data. if (Shape.SculptEntry) @@ -4414,11 +4419,34 @@ namespace OpenSim.Region.Framework.Scenes if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) return; - PhysicsShapeType = (byte)physdata.PhysShapeType; - Density = physdata.Density; - GravityModifier = physdata.GravitationModifier; - Friction = physdata.Friction; - Bounciness = physdata.Bounce; + if (PhysicsShapeType != (byte)physdata.PhysShapeType) + { + PhysicsShapeType = (byte)physdata.PhysShapeType; + + if (PhysicsShapeType == (byte)PhysShapeType.none) + { + if (PhysActor != null) + { + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); + ParentGroup.Scene.RemovePhysicalPrim(1); + RemoveFromPhysics(); + } + } + else if (PhysActor == null) + ApplyPhysics((uint)Flags, VolumeDetectActive, false); + } + + if(Density != physdata.Density) + Density = physdata.Density; + if(GravityModifier != physdata.GravitationModifier) + GravityModifier = physdata.GravitationModifier; + if(Friction != physdata.Friction) + Friction = physdata.Friction; + if(Bounciness != physdata.Bounce) + Bounciness = physdata.Bounce; } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. @@ -4448,9 +4476,10 @@ namespace OpenSim.Region.Framework.Scenes // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. +/* if (SetVD) // VD is active, special logic applies - /* volume detection is now independent of phantom in sl + volume detection is now independent of phantom in sl { // State machine logic for VolumeDetect @@ -4471,9 +4500,8 @@ namespace OpenSim.Region.Framework.Scenes // If volumedetect is active we don't want phantom to be applied. // If this is a new call to VD out of the state "phantom" // this will also cause the prim to be visible to physics - */ SetPhantom = false; -/* } + } } else if (wasVD) { @@ -4520,10 +4548,10 @@ namespace OpenSim.Region.Framework.Scenes else RemFlag(PrimFlags.Phantom); - if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment + if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints { - AddFlag(PrimFlags.Phantom); +// AddFlag(PrimFlags.Phantom); Velocity = new Vector3(0, 0, 0); Acceleration = new Vector3(0, 0, 0); -- cgit v1.1 From 577d07aa44b5ba7ed4fc3a56a81eeec6c141543a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:51:41 +0000 Subject: missed commit of extraphysics parameters serialization.. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 52 +++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 51a3320..dfa24e5 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -359,9 +359,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("Torque", ProcessTorque); m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); - //Ubit comented until proper testing - m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); + m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); + + m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); + m_SOPXmlProcessors.Add("Density", ProcessDensity); + m_SOPXmlProcessors.Add("Friction", ProcessFriction); + m_SOPXmlProcessors.Add("Bounce", ProcessBounce); + m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); #endregion @@ -390,7 +395,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); - + #endregion #region ShapeXmlProcessors initialization @@ -585,6 +590,31 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); } + private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlTextReader reader) + { + obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty); + } + + private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader) + { + obj.Density = (byte)reader.ReadElementContentAsInt("Density", String.Empty); + } + + private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader) + { + obj.Friction = (byte)reader.ReadElementContentAsInt("Friction", String.Empty); + } + + private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) + { + obj.Bounciness = (byte)reader.ReadElementContentAsInt("Bounce", String.Empty); + } + + private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) + { + obj.GravityModifier = (byte)reader.ReadElementContentAsInt("GravityModifier", String.Empty); + } + private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) { bool errors = false; @@ -1288,9 +1318,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); - //Ubit comented until proper testing - if (sop.sopVehicle != null) - sop.sopVehicle.ToXml2(writer); + if (sop.sopVehicle != null) + sop.sopVehicle.ToXml2(writer); + + if(sop.PhysicsShapeType != (byte)PhysShapeType.prim) + writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); + if (sop.Density != 1000.0f) + writer.WriteElementString("Density", sop.Density.ToString().ToLower()); + if (sop.Friction != 0.6f) + writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); + if (sop.Bounciness != 0.5f) + writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); + if (sop.GravityModifier != 1.0f) + writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); writer.WriteEndElement(); } -- cgit v1.1 From cf9ebd301c32fa7cd991e78647ce011b0aefc796 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 14 Mar 2012 18:24:04 +0000 Subject: bug fixs, added a default physics shape estimator based on being a mesh or not and use it on unlink if new root part as type none. Viewer doesn't get updated even with fullupdates we are missing something still --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 84 ++++++++++++++++++---- .../Scenes/Serialization/SceneObjectSerializer.cs | 10 +-- 3 files changed, 80 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6feb333..5507aa0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2723,6 +2723,10 @@ namespace OpenSim.Region.Framework.Scenes // When we delete a group, we currently have to force persist to the database if the object id has changed // (since delete works by deleting all rows which have a given object id) + // this is as it seems to be in sl now + if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) + linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now + if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = false; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a68b3eb..84ed40c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -986,7 +986,11 @@ namespace OpenSim.Region.Framework.Scenes public PrimitiveBaseShape Shape { get { return m_shape; } - set { m_shape = value;} + set + { + m_shape = value; + m_physicsShapeType = DefaultPhysicsShapeType(); + } } /// @@ -1377,31 +1381,68 @@ namespace OpenSim.Region.Framework.Scenes { if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) { - m_material = (Material)value; - m_friction = SOPMaterialData.friction(m_material); - m_bounce = SOPMaterialData.bounce(m_material); - if (PhysActor != null) + bool update = false; + + if (m_material != (Material)value) + { + update = true; + m_material = (Material)value; + } + + if (m_friction != SOPMaterialData.friction(m_material)) + { + update = true; + m_friction = SOPMaterialData.friction(m_material); + } + + if (m_bounce != SOPMaterialData.bounce(m_material)) { - PhysActor.SetMaterial((int)value); + update = true; + m_bounce = SOPMaterialData.bounce(m_material); + } + + if (update) + { + if (PhysActor != null) + { + PhysActor.SetMaterial((int)value); + } + if(ParentGroup != null) + ParentGroup.HasGroupChanged = true; + ScheduleFullUpdateIfNone(); } } } } + // not a propriety to move to methods place later + public byte DefaultPhysicsShapeType() + { + byte type; + + if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) + type = (byte)PhysShapeType.convex; + else + type = (byte)PhysShapeType.prim; + + return type; + } + public byte PhysicsShapeType { get { return m_physicsShapeType; } set { - if (value < 0 || value >= (byte)PhysShapeType.convex) - value = (byte)PhysShapeType.prim; //convex not supported ? - - else if (value == (byte)PhysShapeType.none) + if (value >= 0 && value <= (byte)PhysShapeType.convex) { - if (ParentGroup == null || ParentGroup.RootPart == this) - value = (byte)PhysShapeType.prim; + if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this) + m_physicsShapeType = DefaultPhysicsShapeType(); + else + m_physicsShapeType = value; + ScheduleFullUpdateIfNone(); } - m_physicsShapeType = value; + else + m_physicsShapeType = DefaultPhysicsShapeType(); } } @@ -1413,6 +1454,7 @@ namespace OpenSim.Region.Framework.Scenes if (value >=1 && value <= 22587.0) { m_density = value; + ScheduleFullUpdateIfNone(); } } } @@ -1423,6 +1465,7 @@ namespace OpenSim.Region.Framework.Scenes set { if( value >= -1 && value <=28.0f) m_gravitymod = value; + ScheduleFullUpdateIfNone(); } } @@ -1434,6 +1477,7 @@ namespace OpenSim.Region.Framework.Scenes if (value >= 0 && value <= 255.0f) { m_friction = value; + ScheduleFullUpdateIfNone(); } } } @@ -1446,6 +1490,7 @@ namespace OpenSim.Region.Framework.Scenes if (value >= 0 && value <= 1.0f) { m_bounce = value; + ScheduleFullUpdateIfNone(); } } } @@ -2942,6 +2987,19 @@ namespace OpenSim.Region.Framework.Scenes APIDTarget = Quaternion.Identity; } + + + public void ScheduleFullUpdateIfNone() + { + if (ParentGroup == null) + return; + +// ??? ParentGroup.HasGroupChanged = true; + + if (UpdateFlag != UpdateRequired.FULL) + ScheduleFullUpdate(); + } + /// /// Schedules this prim for a full update /// diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index dfa24e5..1cd8189 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -597,22 +597,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader) { - obj.Density = (byte)reader.ReadElementContentAsInt("Density", String.Empty); + obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty); } private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader) { - obj.Friction = (byte)reader.ReadElementContentAsInt("Friction", String.Empty); + obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty); } private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) { - obj.Bounciness = (byte)reader.ReadElementContentAsInt("Bounce", String.Empty); + obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty); } private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) { - obj.GravityModifier = (byte)reader.ReadElementContentAsInt("GravityModifier", String.Empty); + obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); } private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) @@ -1321,7 +1321,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (sop.sopVehicle != null) sop.sopVehicle.ToXml2(writer); - if(sop.PhysicsShapeType != (byte)PhysShapeType.prim) + if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); if (sop.Density != 1000.0f) writer.WriteElementString("Density", sop.Density.ToString().ToLower()); -- cgit v1.1 From 84ca09f7c5cec051014181853083e52691bb7e07 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 15 Mar 2012 02:24:13 +0000 Subject: added ObjectPhysicsProperties http event message to send viewer that data. For now on caps/EventQueue, and still only used on a material change... --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 7b77ea0..4e9a8f8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1695,6 +1695,7 @@ namespace OpenSim.Region.Framework.Scenes { part.Material = Convert.ToByte(material); group.HasGroupChanged = true; + remoteClient.SendPartPhysicsProprieties(part); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 84ed40c..f188e8d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4730,7 +4730,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.HasGroupChanged = true; ScheduleFullUpdate(); } - + // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); } -- cgit v1.1 From ae8e089b9c73a6a675038759e3e3f9491819eb72 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Mar 2012 15:33:49 +0000 Subject: some more work on costs --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 96 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 62 ++++++++++++++ 2 files changed, 158 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5507aa0..3e4d552 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1231,6 +1231,102 @@ namespace OpenSim.Region.Framework.Scenes #endregion + public void GetResourcesCosts(SceneObjectPart apart, + out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) + { + // this information may need to be cached + + float cost; + float tmpcost; + + bool ComplexCost = false; + + SceneObjectPart p; + SceneObjectPart[] parts; + + lock (m_parts) + { + parts = m_parts.GetArray(); + } + + int nparts = parts.Length; + + + for (int i = 0; i < nparts; i++) + { + p = parts[i]; + + if (p.UsesComplexCost) + { + ComplexCost = true; + break; + } + } + + if (ComplexCost) + { + linksetResCost = 0; + linksetPhysCost = 0; + partCost = 0; + partPhysCost = 0; + + for (int i = 0; i < nparts; i++) + { + p = parts[i]; + + cost = p.StreamingCost; + tmpcost = p.SimulationCost; + if (tmpcost > cost) + cost = tmpcost; + tmpcost = p.PhysicsCost; + if (tmpcost > cost) + cost = tmpcost; + + linksetPhysCost += tmpcost; + linksetResCost += cost; + + if (p == apart) + { + partCost = cost; + partPhysCost = tmpcost; + } + } + } + else + { + partPhysCost = 1.0f; + partCost = 1.0f; + linksetResCost = (float)nparts; + linksetPhysCost = linksetResCost; + } + } + + public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) + { + SceneObjectPart p; + SceneObjectPart[] parts; + + lock (m_parts) + { + parts = m_parts.GetArray(); + } + + int nparts = parts.Length; + + PhysCost = 0; + StreamCost = 0; + SimulCost = 0; + + for (int i = 0; i < nparts; i++) + { + p = parts[i]; + + StreamCost += p.StreamingCost; + SimulCost += p.SimulationCost; + PhysCost += p.PhysicsCost; + } + } + public void SaveScriptedState(XmlTextWriter writer) { SaveScriptedState(writer, false); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f188e8d..fbe959a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1416,6 +1416,14 @@ namespace OpenSim.Region.Framework.Scenes } // not a propriety to move to methods place later + private bool HasMesh() + { + if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) + return true; + return false; + } + + // not a propriety to move to methods place later public byte DefaultPhysicsShapeType() { byte type; @@ -1428,6 +1436,60 @@ namespace OpenSim.Region.Framework.Scenes return type; } + [XmlIgnore] + public bool UsesComplexCost + { + get + { + byte pst = PhysicsShapeType; + if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) + return true; + return false; + } + } + + [XmlIgnore] + public float PhysicsCost + { + get + { + if(PhysicsShapeType == (byte)PhysShapeType.none) + return 0; + + float cost = 0.1f; + if (PhysActor != null) +// cost += PhysActor.Cost; + + if ((Flags & PrimFlags.Physics) != 0) + cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 + return cost; + } + } + + [XmlIgnore] + public float StreamingCost + { + get + { + + + return 0.1f; + } + } + + [XmlIgnore] + public float SimulationCost + { + get + { + // ignoring scripts. Don't like considering them for this + if((Flags & PrimFlags.Physics) != 0) + return 1.0f; + + return 0.5f; + } + } + public byte PhysicsShapeType { get { return m_physicsShapeType; } -- cgit v1.1 From f2d17433bbb942e6b97fe7879f910f8fd2d7a0d6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 20 Mar 2012 12:34:06 +0100 Subject: Cause prims to be saved if extra physics parameters are changed --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fbe959a..9914c78 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1505,6 +1505,7 @@ namespace OpenSim.Region.Framework.Scenes } else m_physicsShapeType = DefaultPhysicsShapeType(); + ParentGroup.HasGroupChanged = true; } } @@ -1518,6 +1519,7 @@ namespace OpenSim.Region.Framework.Scenes m_density = value; ScheduleFullUpdateIfNone(); } + ParentGroup.HasGroupChanged = true; } } @@ -1528,6 +1530,7 @@ namespace OpenSim.Region.Framework.Scenes { if( value >= -1 && value <=28.0f) m_gravitymod = value; ScheduleFullUpdateIfNone(); + ParentGroup.HasGroupChanged = true; } } @@ -1541,6 +1544,7 @@ namespace OpenSim.Region.Framework.Scenes m_friction = value; ScheduleFullUpdateIfNone(); } + ParentGroup.HasGroupChanged = true; } } @@ -1554,6 +1558,7 @@ namespace OpenSim.Region.Framework.Scenes m_bounce = value; ScheduleFullUpdateIfNone(); } + ParentGroup.HasGroupChanged = true; } } -- cgit v1.1 From efd7ff31468755c7066c68fb6b5910f7b18aa3f0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 20 Mar 2012 16:46:16 +0000 Subject: add some more notifications about changes on physical parameters ( still incomple and there should be a better away ) --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 19 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 18069af..ccc3f32 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1521,7 +1521,11 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) + { part.UpdateExtraPhysics(PhysData); + if (part.UpdatePhysRequired) + remoteClient.SendPartPhysicsProprieties(part); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9914c78..0ffd114 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1030,6 +1030,7 @@ namespace OpenSim.Region.Framework.Scenes } public UpdateRequired UpdateFlag { get; set; } + public bool UpdatePhysRequired { get; set; } /// /// Used for media on a prim. @@ -1410,6 +1411,7 @@ namespace OpenSim.Region.Framework.Scenes if(ParentGroup != null) ParentGroup.HasGroupChanged = true; ScheduleFullUpdateIfNone(); + UpdatePhysRequired = true; } } } @@ -1501,11 +1503,12 @@ namespace OpenSim.Region.Framework.Scenes m_physicsShapeType = DefaultPhysicsShapeType(); else m_physicsShapeType = value; - ScheduleFullUpdateIfNone(); } else m_physicsShapeType = DefaultPhysicsShapeType(); - ParentGroup.HasGroupChanged = true; + + if(m_physicsShapeType != value) + UpdatePhysRequired = true; } } @@ -1517,9 +1520,8 @@ namespace OpenSim.Region.Framework.Scenes if (value >=1 && value <= 22587.0) { m_density = value; - ScheduleFullUpdateIfNone(); + UpdatePhysRequired = true; } - ParentGroup.HasGroupChanged = true; } } @@ -1529,8 +1531,7 @@ namespace OpenSim.Region.Framework.Scenes set { if( value >= -1 && value <=28.0f) m_gravitymod = value; - ScheduleFullUpdateIfNone(); - ParentGroup.HasGroupChanged = true; + UpdatePhysRequired = true; } } @@ -1542,9 +1543,8 @@ namespace OpenSim.Region.Framework.Scenes if (value >= 0 && value <= 255.0f) { m_friction = value; - ScheduleFullUpdateIfNone(); + UpdatePhysRequired = true; } - ParentGroup.HasGroupChanged = true; } } @@ -1556,9 +1556,8 @@ namespace OpenSim.Region.Framework.Scenes if (value >= 0 && value <= 1.0f) { m_bounce = value; - ScheduleFullUpdateIfNone(); + UpdatePhysRequired = true; } - ParentGroup.HasGroupChanged = true; } } -- cgit v1.1 From 7f7801ecb9cff8c31eee732c18f540afc67c6d38 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 20 Mar 2012 18:02:43 +0100 Subject: Cover the case where prims are loaded and ParentGroup is not yet set --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9914c78..84b4bb3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1505,7 +1505,8 @@ namespace OpenSim.Region.Framework.Scenes } else m_physicsShapeType = DefaultPhysicsShapeType(); - ParentGroup.HasGroupChanged = true; + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; } } @@ -1519,7 +1520,8 @@ namespace OpenSim.Region.Framework.Scenes m_density = value; ScheduleFullUpdateIfNone(); } - ParentGroup.HasGroupChanged = true; + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; } } @@ -1530,7 +1532,8 @@ namespace OpenSim.Region.Framework.Scenes { if( value >= -1 && value <=28.0f) m_gravitymod = value; ScheduleFullUpdateIfNone(); - ParentGroup.HasGroupChanged = true; + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; } } @@ -1544,7 +1547,8 @@ namespace OpenSim.Region.Framework.Scenes m_friction = value; ScheduleFullUpdateIfNone(); } - ParentGroup.HasGroupChanged = true; + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; } } @@ -1558,7 +1562,8 @@ namespace OpenSim.Region.Framework.Scenes m_bounce = value; ScheduleFullUpdateIfNone(); } - ParentGroup.HasGroupChanged = true; + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; } } -- cgit v1.1 From 5233e335e90b2ef8fc423cf9fe907134b164e652 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 21 Mar 2012 00:00:32 +0000 Subject: Move the health monitoring stuff where it will do some good --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f9b89fb..44ee453 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1232,9 +1232,6 @@ namespace OpenSim.Region.Framework.Scenes while (!shuttingdown) Update(-1); - - m_lastUpdate = Util.EnvironmentTickCount(); - m_firstHeartbeat = false; } finally { @@ -1441,6 +1438,9 @@ namespace OpenSim.Region.Framework.Scenes if (maintc > 0) Thread.Sleep(maintc); + m_lastUpdate = Util.EnvironmentTickCount(); + m_firstHeartbeat = false; + // Optionally warn if a frame takes double the amount of time that it should. // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) // m_log.WarnFormat( -- cgit v1.1 From 11ed932263161d1dbea99d4a5699ba6d00894053 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Mar 2012 01:46:41 +0000 Subject: Tell physics about physics shape when creating. Added some virtual methods to get/set density,gravmod, frition,bounce and shape type ( not in use ). UbitOde now should do convex type on creation or everytime the mesh is changed ( as in change size, shape, etc ) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 85d2bee..a494864 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1832,6 +1832,7 @@ namespace OpenSim.Region.Framework.Scenes GetWorldRotation(), isPhysical, isPhantom, + PhysicsShapeType, m_localId); } catch @@ -4732,6 +4733,7 @@ namespace OpenSim.Region.Framework.Scenes GetWorldRotation(), //physics wants world rotation like all other functions send UsePhysics, SetPhantom, + PhysicsShapeType, m_localId); PhysActor.SetMaterial(Material); -- cgit v1.1 From f6cbafcaf0f33b37d076d654e35c20990eb205d8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Mar 2012 02:39:16 +0000 Subject: Changes of PrimShapeType should now work with UbitOde ( almost untested ) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 43 +++++++++++++--------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a494864..51a3c18 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1497,6 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes get { return m_physicsShapeType; } set { + byte oldv = m_physicsShapeType; if (value >= 0 && value <= (byte)PhysShapeType.convex) { if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this) @@ -1507,11 +1508,33 @@ namespace OpenSim.Region.Framework.Scenes else m_physicsShapeType = DefaultPhysicsShapeType(); - if (ParentGroup != null) - ParentGroup.HasGroupChanged = true; - if(m_physicsShapeType != value) + if (m_physicsShapeType != oldv && ParentGroup != null) + { + if (m_physicsShapeType == (byte)PhysShapeType.none) + { + if (PhysActor != null) + { + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); + ParentGroup.Scene.RemovePhysicalPrim(1); + RemoveFromPhysics(); + } + } + else if (PhysActor == null) + ApplyPhysics((uint)Flags, VolumeDetectActive, false); + else + PhysActor.PhysicsShapeType = m_physicsShapeType; + } + if (m_physicsShapeType != value) + { + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; + UpdatePhysRequired = true; + } } } @@ -4575,20 +4598,6 @@ namespace OpenSim.Region.Framework.Scenes { PhysicsShapeType = (byte)physdata.PhysShapeType; - if (PhysicsShapeType == (byte)PhysShapeType.none) - { - if (PhysActor != null) - { - Velocity = new Vector3(0, 0, 0); - Acceleration = new Vector3(0, 0, 0); - if (ParentGroup.RootPart == this) - AngularVelocity = new Vector3(0, 0, 0); - ParentGroup.Scene.RemovePhysicalPrim(1); - RemoveFromPhysics(); - } - } - else if (PhysActor == null) - ApplyPhysics((uint)Flags, VolumeDetectActive, false); } if(Density != physdata.Density) -- cgit v1.1 From 68736aa460869717a24ec5d68053b7a1f540b853 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Mar 2012 15:27:33 +0000 Subject: fix a bad reset of shapetype on pbshape change, added missing checksculpload ( to reload mesh on change ) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 51a3c18..cfa3cd4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -989,7 +989,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_shape = value; - m_physicsShapeType = DefaultPhysicsShapeType(); } } @@ -1003,7 +1002,6 @@ namespace OpenSim.Region.Framework.Scenes { if (m_shape != null) { -// StoreUndoState(); m_shape.Scale = value; @@ -1498,6 +1496,7 @@ namespace OpenSim.Region.Framework.Scenes set { byte oldv = m_physicsShapeType; + if (value >= 0 && value <= (byte)PhysShapeType.convex) { if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this) @@ -1508,7 +1507,6 @@ namespace OpenSim.Region.Framework.Scenes else m_physicsShapeType = DefaultPhysicsShapeType(); - if (m_physicsShapeType != oldv && ParentGroup != null) { if (m_physicsShapeType == (byte)PhysShapeType.none) @@ -1526,13 +1524,18 @@ namespace OpenSim.Region.Framework.Scenes else if (PhysActor == null) ApplyPhysics((uint)Flags, VolumeDetectActive, false); else - PhysActor.PhysicsShapeType = m_physicsShapeType; - } - if (m_physicsShapeType != value) - { + { + PhysActor.PhysicsShapeType = m_physicsShapeType; + if (Shape.SculptEntry) + CheckSculptAndLoad(); + } + if (ParentGroup != null) ParentGroup.HasGroupChanged = true; + } + if (m_physicsShapeType != value) + { UpdatePhysRequired = true; } } -- cgit v1.1 From ade164667fb7bd9d1996a8791a1f751f191c16bc Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Mar 2012 03:16:07 +0100 Subject: Make anims way more snappy. Decouple SP animation handling from physics frame time. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 43 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2346c60..a23dc31 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -233,6 +233,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_collisionEventFlag = false; private object m_collisionEventLock = new Object(); + private int m_movementAnimationUpdateCounter = 0; + private Vector3 m_prevSitOffset; protected AvatarAppearance m_appearance; @@ -741,6 +743,26 @@ namespace OpenSim.Region.Framework.Scenes Appearance = appearance; } + private void RegionHeartbeatEnd(Scene scene) + { + if (IsChildAgent) + return; + + m_movementAnimationUpdateCounter ++; + if (m_movementAnimationUpdateCounter >= 2) + { + m_movementAnimationUpdateCounter = 0; + if (Animator != null) + { + Animator.UpdateMovementAnimations(); + } + else + { + m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; + } + } + } + public void RegisterToEvents() { ControllingClient.OnCompleteMovementToRegion += CompleteMovement; @@ -952,6 +974,8 @@ namespace OpenSim.Region.Framework.Scenes MovementFlag = 0; m_scene.EventManager.TriggerOnMakeRootAgent(this); + + m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; } public int GetStateSource() @@ -979,6 +1003,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void MakeChildAgent() { + m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; + m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); // Reset these so that teleporting in and walking out isn't seen @@ -2377,14 +2403,15 @@ namespace OpenSim.Region.Framework.Scenes direc.Z *= 2.6f; // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. - Animator.TrySetMovementAnimation("PREJUMP"); - Animator.TrySetMovementAnimation("JUMP"); +// Animator.TrySetMovementAnimation("PREJUMP"); +// Animator.TrySetMovementAnimation("JUMP"); } } } // TODO: Add the force instead of only setting it to support multiple forces per frame? m_forceToApply = direc; + Animator.UpdateMovementAnimations(); } #endregion @@ -3334,18 +3361,6 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) - // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( - // as of this comment the interval is set in AddToPhysicalScene - if (Animator != null) - { -// if (m_updateCount > 0) -// { - Animator.UpdateMovementAnimations(); -// m_updateCount--; -// } - } - CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; -- cgit v1.1 From 1c4bcf3fedbdb3c8143f364c43c939da810e896e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 Apr 2012 23:13:48 +0200 Subject: Fix merge artefacts --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 27 +--------------------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 2 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5b47fc0..ca6b5cb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2181,20 +2181,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void applyAngularImpulse(Vector3 impulse) - { - PhysicsActor pa = RootPart.PhysActor; - - if (pa != null) - { - if (!IsAttachment) - { - pa.AddAngularForce(impulse, true); - m_scene.PhysicsScene.AddPhysicsActorTaint(pa); - } - } - } - public void setAngularImpulse(Vector3 impulse) { PhysicsActor pa = RootPart.PhysActor; @@ -2211,18 +2197,7 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetTorque() { - PhysicsActor pa = RootPart.PhysActor; - - if (pa != null) - { - if (!IsAttachment) - { - Vector3 torque = pa.Torque; - return torque; - } - } - - return Vector3.Zero; + return Torque; } // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 83b0b18..9ba3e92 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1803,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes impulse = newimpulse; } - ParentGroup.applyAngularImpulse(impulse); + ParentGroup.setAngularImpulse(impulse); } /// -- cgit v1.1 From 7154d480b9fe1e2098ac536285f4c3f643e42f0c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 Apr 2012 23:18:07 +0200 Subject: Remove duplicate implementation of Material { get; set; } --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9ba3e92..5c28d89 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -571,20 +571,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public byte Material - { - get { return (byte) m_material; } - set - { - m_material = (Material)value; - - PhysicsActor pa = PhysActor; - - if (pa != null) - pa.SetMaterial((int)value); - } - } - public bool PassTouches { get { return m_passTouches; } -- cgit v1.1 From dbec5e98595cfe87d26ef74703433db7956ab66d Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 Apr 2012 23:22:47 +0200 Subject: Fix more merge artefacts --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5c28d89..9cd438c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4837,11 +4837,11 @@ namespace OpenSim.Region.Framework.Scenes { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) - if (this.PhysActor != null) + if (pa != null) { PhysActor.SetVolumeDetect(0); - - this.VolumeDetectActive = false; + this.VolumeDetectActive = false; + } } if (SetTemporary) -- cgit v1.1 From 1bded840b9f1b93829090a33a9f56dbfed2ce02a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 Apr 2012 23:25:34 +0200 Subject: More artefact --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ca6b5cb..fde146c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2197,7 +2197,7 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetTorque() { - return Torque; + return RootPart.Torque; } // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object -- cgit v1.1 From 726915e9ef369a5b4cb7089ec9301c5c927dd862 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 Apr 2012 23:38:12 +0200 Subject: Fix the last merge artefacts --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 - OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fde146c..5f33452 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3583,7 +3583,6 @@ namespace OpenSim.Region.Framework.Scenes Quaternion axRot = rot; Quaternion oldParentRot = m_rootPart.RotationOffset; - m_rootPart.StoreUndoState(); //Don't use UpdateRotation because it schedules an update prematurely m_rootPart.RotationOffset = rot; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9cd438c..aed25a7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4819,6 +4819,7 @@ namespace OpenSim.Region.Framework.Scenes } } + PhysicsActor pa = PhysActor; if (SetVD) { // If the above logic worked (this is urgent candidate to unit tests!) @@ -4828,7 +4829,7 @@ namespace OpenSim.Region.Framework.Scenes // logic should make sure, this Physactor is always here. if (pa != null) { - PhysActor.SetVolumeDetect(1); + pa.SetVolumeDetect(1); // AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active this.VolumeDetectActive = true; } @@ -4839,7 +4840,7 @@ namespace OpenSim.Region.Framework.Scenes // (mumbles, well, at least if you have infinte CPU powers :-)) if (pa != null) { - PhysActor.SetVolumeDetect(0); + pa.SetVolumeDetect(0); this.VolumeDetectActive = false; } } @@ -4856,8 +4857,8 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); // and last in case we have a new actor and not building - if (PhysActor != null && PhysActor.Building != building) - PhysActor.Building = building; + if (pa != null && pa.Building != building) + pa.Building = building; if (ParentGroup != null) { ParentGroup.HasGroupChanged = true; -- cgit v1.1 From 787cc0d076f0a56cf48dbef4475ec991da00adf0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Apr 2012 16:38:29 +0100 Subject: reverted changes to llApplyRotationalImpulse execution in SOP/SOG. This functions naming is misleading, Here Apply means to apply a instante impulse that may add to previus unprocessed ones and not setting a permanente torque (that is done by llSetTorque). --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5f33452..54e8d50 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2181,7 +2181,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void setAngularImpulse(Vector3 impulse) + public void ApplyAngularImpulse(Vector3 impulse) { PhysicsActor pa = RootPart.PhysActor; @@ -2189,7 +2189,7 @@ namespace OpenSim.Region.Framework.Scenes { if (!IsAttachment) { - pa.Torque = impulse; + pa.AddAngularForce(impulse, true); m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index aed25a7..f091a91 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1789,7 +1789,7 @@ namespace OpenSim.Region.Framework.Scenes impulse = newimpulse; } - ParentGroup.setAngularImpulse(impulse); + ParentGroup.ApplyAngularImpulse(impulse); } /// -- cgit v1.1 From 867d50d14c1ad0ae1e885e163dfc4f2e9afc6749 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Apr 2012 17:01:29 +0100 Subject: remove more merge artefacts --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f091a91..83021b0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2186,18 +2186,11 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0 && ParentID != LocalId) { - ParentGroup.Scene.AddPhysicalPrim(1); + PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; - pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; - pa.OnOutOfBounds += PhysicsOutOfBounds; - if (ParentID != 0 && ParentID != LocalId) + if (parentPa != null) { - PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; - - if (parentPa != null) - { - pa.link(parentPa); - } + pa.link(parentPa); } } } -- cgit v1.1 From 016079ef2775d66ea85d9c62c5aef93ae2162821 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Apr 2012 18:24:56 +0100 Subject: minor changes.. a few physicsactor -> pa and a use a constant with |'ed bit fields in place of 6 individual checks ||'ed --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 66 ++++++++++------------ 1 file changed, 31 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 83021b0..951e987 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2153,26 +2153,26 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup.RootPart == this) AngularVelocity = new Vector3(0, 0, 0); - if (PhysActor.Phantom) + if (pa.Phantom) { RemoveFromPhysics(); return; } - PhysActor.IsPhysical = UsePhysics; - PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; - PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; - PhysActor.delink(); + pa.IsPhysical = UsePhysics; + pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; + pa.OnOutOfBounds -= PhysicsOutOfBounds; + pa.delink(); if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { // destroy all joints connected to this now deactivated body - ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); + ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); } } } - if (PhysActor.IsPhysical != UsePhysics) - PhysActor.IsPhysical = UsePhysics; + if (pa.IsPhysical != UsePhysics) + pa.IsPhysical = UsePhysics; if (UsePhysics) { @@ -2197,8 +2197,8 @@ namespace OpenSim.Region.Framework.Scenes } bool phan = ((Flags & PrimFlags.Phantom) != 0); - if (PhysActor.Phantom != phan) - PhysActor.Phantom = phan; + if (pa.Phantom != phan) + pa.Phantom = phan; // If this part is a sculpt then delay the physics update until we've asynchronously loaded the @@ -2320,7 +2320,10 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = PhysActor; if (pa != null) - return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); + { + Vector3 vtmp = pa.CenterOfMass; + return vtmp; + } else return new Vector3(0, 0, 0); } @@ -3524,18 +3527,12 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = PhysActor; if (pa != null) - pa.FloatOnWater = floatYN == 1; + pa.FloatOnWater = (floatYN == 1); } public void SetForce(Vector3 force) { Force = force; -/* - if (PhysActor != null) - { - PhysActor.Force = force; - } - */ } public SOPVehicle sopVehicle @@ -5066,33 +5063,32 @@ namespace OpenSim.Region.Framework.Scenes } PhysicsActor pa = PhysActor; - - if ( - ((AggregateScriptEvents & scriptEvents.collision) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - (CollisionSound != UUID.Zero) - ) + if (pa != null) { - // subscribe to physics updates. - if (pa != null) + const scriptEvents NeededSubsEvents = ( + scriptEvents.collision | scriptEvents.collision_start| scriptEvents.collision_end | + scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end + ); + if ( +// ((AggregateScriptEvents & scriptEvents.collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + ((AggregateScriptEvents & NeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) + ) { + // subscribe to physics updates. pa.OnCollisionUpdate += PhysicsCollision; pa.SubscribeEvents(1000); } - } - else - { - if (pa != null) + else { pa.UnSubscribeEvents(); pa.OnCollisionUpdate -= PhysicsCollision; } } - //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) //{ // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; -- cgit v1.1 From ad544bdd3d37700af7c8d05bafaed7cdd3dd3cd6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 9 Apr 2012 18:03:37 +0100 Subject: sop.AddToPhysics(..) fixed and in use. For now it seems it needs to set sop.PhysActor, so made it return void. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 410 ++++++++------------- 1 file changed, 147 insertions(+), 263 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 969ddaf..d419710 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -122,6 +122,11 @@ namespace OpenSim.Region.Framework.Scenes /// Denote all sides of the prim /// public const int ALL_SIDES = -1; + + private const scriptEvents PhyscicsNeededSubsEvents = ( + scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | + scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end + ); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -1821,18 +1826,20 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// + /// - public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building) + public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) { + VolumeDetectActive = _VolumeDetectActive; //?? as is used this is redundante + if (!ParentGroup.Scene.CollidablePrims) return; if (PhysicsShapeType == (byte)PhysShapeType.none) return; - bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; - bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; - + bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; + bool isPhantom = (_ObjectFlags & (uint) PrimFlags.Phantom) != 0; if (IsJoint()) { @@ -1840,68 +1847,11 @@ namespace OpenSim.Region.Framework.Scenes } else { - // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored -// if (VolumeDetectActive) -// isPhantom = false; - - // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition - // or flexible - // if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) - if ((!isPhantom || isPhysical || VolumeDetectActive) && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) - { - Vector3 velocity = Velocity; - Vector3 rotationalVelocity = AngularVelocity; - try - { - PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", Name, UUID), - Shape, - AbsolutePosition, - Scale, - GetWorldRotation(), - isPhysical, - isPhantom, - PhysicsShapeType, - m_localId); - } - catch - { - m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); - PhysActor = null; - } - - PhysicsActor pa = PhysActor; - - if (pa != null) - { - pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info - pa.SetMaterial(Material); - - // if root part apply vehicle - if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) - m_vehicle.SetVehicle(pa); - - DoPhysicsPropertyUpdate(isPhysical, true); - if(VolumeDetectActive) // change if not the default only - pa.SetVolumeDetect(1); - - if (!building) - pa.Building = false; - - Velocity = velocity; - AngularVelocity = rotationalVelocity; - pa.Velocity = velocity; - pa.RotationalVelocity = rotationalVelocity; - - // if not vehicle and root part apply force and torque - if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) - && LocalId == ParentGroup.RootPart.LocalId) - { - pa.Force = Force; - pa.Torque = Torque; - } - } - } + if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment + && !(Shape.PathCurve == (byte)Extrusion.Flexible)) + AddToPhysics(isPhysical, isPhantom, building, true); + else + PhysActor = null; // just to be sure } } @@ -4628,7 +4578,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// -// public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) { bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); @@ -4639,209 +4588,92 @@ namespace OpenSim.Region.Framework.Scenes if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) return; - // do this first - if (building && PhysActor != null && PhysActor.Building != building) - PhysActor.Building = building; - - // Special cases for VD. VD can only be called from a script - // and can't be combined with changes to other states. So we can rely - // that... - // ... if VD is changed, all others are not. - // ... if one of the others is changed, VD is not. - -/* - if (SetVD) // VD is active, special logic applies - - volume detection is now independent of phantom in sl - - { - // State machine logic for VolumeDetect - // More logic below - - - bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; - - if (phanReset) // Phantom changes from on to off switch VD off too - { - SetVD = false; // Switch it of for the course of this routine - VolumeDetectActive = false; // and also permanently - if (PhysActor != null) - PhysActor.SetVolumeDetect(0); // Let physics know about it too - } - else - { - // If volumedetect is active we don't want phantom to be applied. - // If this is a new call to VD out of the state "phantom" - // this will also cause the prim to be visible to physics - SetPhantom = false; - } - } - else if (wasVD) - { - // Correspondingly, if VD is turned off, also turn off phantom - SetPhantom = false; - } - - if (UsePhysics && IsJoint()) - { - SetPhantom = true; - } -*/ if (UsePhysics) - { AddFlag(PrimFlags.Physics); -/* - if (!wasUsingPhysics) - { - DoPhysicsPropertyUpdate(UsePhysics, false); - - if (!ParentGroup.IsDeleted) - { - if (LocalId == ParentGroup.RootPart.LocalId) - { - ParentGroup.CheckSculptAndLoad(); - } - } - } - */ - } else - { RemFlag(PrimFlags.Physics); -/* - if (wasUsingPhysics) - { - DoPhysicsPropertyUpdate(UsePhysics, false); - } -*/ - } if (SetPhantom) AddFlag(PrimFlags.Phantom); else RemFlag(PrimFlags.Phantom); + if (SetTemporary) + AddFlag(PrimFlags.TemporaryOnRez); + else + RemFlag(PrimFlags.TemporaryOnRez); + + VolumeDetectActive = SetVD; + + if (ParentGroup.Scene == null) + return; + + PhysicsActor pa = PhysActor; + + if (pa != null && building && pa.Building != building) + pa.Building = building; + if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none - || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints + || (Shape.PathCurve == (byte)Extrusion.Flexible)) { -// AddFlag(PrimFlags.Phantom); + if (pa != null) + { + ParentGroup.Scene.RemovePhysicalPrim(1); + RemoveFromPhysics(); + } Velocity = new Vector3(0, 0, 0); Acceleration = new Vector3(0, 0, 0); if (ParentGroup.RootPart == this) AngularVelocity = new Vector3(0, 0, 0); - - if (PhysActor != null) - { - ParentGroup.Scene.RemovePhysicalPrim(1); - RemoveFromPhysics(); - } } else { - if (ParentGroup.Scene == null) - return; - if (ParentGroup.Scene.CollidablePrims) { - if (PhysActor == null) + if (pa == null) { - PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", Name, UUID), - Shape, - AbsolutePosition, - Scale, - GetWorldRotation(), //physics wants world rotation like all other functions send - UsePhysics, - SetPhantom, - PhysicsShapeType, - m_localId); - - PhysActor.SetMaterial(Material); - - // if root part apply vehicle - if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) - m_vehicle.SetVehicle(PhysActor); - - DoPhysicsPropertyUpdate(UsePhysics, true); - - if (!ParentGroup.IsDeleted) + AddToPhysics(UsePhysics, SetPhantom, building , false); + pa = PhysActor; + + if (pa != null) { - if (LocalId == ParentGroup.RootPart.LocalId) + if ( +// ((AggregateScriptEvents & scriptEvents.collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) +// (CollisionSound != UUID.Zero) + ) { - ParentGroup.CheckSculptAndLoad(); + pa.OnCollisionUpdate += PhysicsCollision; + pa.SubscribeEvents(1000); } } - - if ( - ((AggregateScriptEvents & scriptEvents.collision) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - (CollisionSound != UUID.Zero) - ) - { - PhysActor.OnCollisionUpdate += PhysicsCollision; - PhysActor.SubscribeEvents(1000); - } } + else // it already has a physical representation { DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. - if (!ParentGroup.IsDeleted) - { - if (LocalId == ParentGroup.RootPart.LocalId) - { - ParentGroup.CheckSculptAndLoad(); - } - } - } - } - } + if(VolumeDetectActive) + pa.SetVolumeDetect(1); + else + pa.SetVolumeDetect(0); - PhysicsActor pa = PhysActor; - if (SetVD) - { - // If the above logic worked (this is urgent candidate to unit tests!) - // we now have a physicsactor. - // Defensive programming calls for a check here. - // Better would be throwing an exception that could be catched by a unit test as the internal - // logic should make sure, this Physactor is always here. - if (pa != null) - { - pa.SetVolumeDetect(1); -// AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active - this.VolumeDetectActive = true; - } - } - else - { - // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like - // (mumbles, well, at least if you have infinte CPU powers :-)) - if (pa != null) - { - pa.SetVolumeDetect(0); - this.VolumeDetectActive = false; + if (pa.Building != building) + pa.Building = building; + } } - } - - if (SetTemporary) - { - AddFlag(PrimFlags.TemporaryOnRez); - } - else - { - RemFlag(PrimFlags.TemporaryOnRez); - } + } // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); // and last in case we have a new actor and not building - if (pa != null && pa.Building != building) - pa.Building = building; + if (ParentGroup != null) { ParentGroup.HasGroupChanged = true; @@ -4853,48 +4685,104 @@ namespace OpenSim.Region.Framework.Scenes /// /// Adds this part to the physics scene. + /// and sets the PhysActor property /// - /// This method also sets the PhysActor property. - /// Add this prim with a rigid body. - /// - /// The physics actor. null if there was a failure. - /// - private PhysicsActor AddToPhysics(bool rigidBody) - { + /// Add this prim as physical. + /// Add this prim as phantom. + /// tells physics to delay full construction of object + /// applies velocities, force and torque + private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) + { PhysicsActor pa; + Vector3 velocity = Velocity; + Vector3 rotationalVelocity = AngularVelocity;; + try { pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", Name, UUID), - Shape, - AbsolutePosition, - Scale, - RotationOffset, - rigidBody, - m_localId); + string.Format("{0}/{1}", Name, UUID), + Shape, + AbsolutePosition, + Scale, + GetWorldRotation(), + isPhysical, + isPhantom, + PhysicsShapeType, + m_localId); } - catch + catch (Exception ex) { - m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); + m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); pa = null; } - - // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical - // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor - // being set. - PhysActor = pa; - - // Basic Physics can also return null as well as an exception catch. + if (pa != null) { pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info pa.SetMaterial(Material); - DoPhysicsPropertyUpdate(rigidBody, true); + + if (VolumeDetectActive) // change if not the default only + pa.SetVolumeDetect(1); + + if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicle.SetVehicle(pa); + + // we are going to tell rest of code about physics so better have this here + PhysActor = pa; + + // DoPhysicsPropertyUpdate(isPhysical, true); + // lets expand it here just with what it really needs to do + + if (isPhysical) + { + if (ParentGroup.RootPart.KeyframeMotion != null) + ParentGroup.RootPart.KeyframeMotion.Stop(); + ParentGroup.RootPart.KeyframeMotion = null; + ParentGroup.Scene.AddPhysicalPrim(1); + + pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; + pa.OnOutOfBounds += PhysicsOutOfBounds; + + if (ParentID != 0 && ParentID != LocalId) + { + PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; + + if (parentPa != null) + { + pa.link(parentPa); + } + } + } + + if (applyDynamics) + // do independent of isphysical so parameters get setted (at least some) + { + Velocity = velocity; + AngularVelocity = rotationalVelocity; + pa.Velocity = velocity; + pa.RotationalVelocity = rotationalVelocity; + + // if not vehicle and root part apply force and torque + if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) + && LocalId == ParentGroup.RootPart.LocalId) + { + pa.Force = Force; + pa.Torque = Torque; + } + } + + if (Shape.SculptEntry) + CheckSculptAndLoad(); + else + ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + + if (!building) + pa.Building = false; } - return pa; - } + PhysActor = pa; + } /// /// This removes the part from the physics scene. @@ -5103,10 +4991,6 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = PhysActor; if (pa != null) { - const scriptEvents NeededSubsEvents = ( - scriptEvents.collision | scriptEvents.collision_start| scriptEvents.collision_end | - scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end - ); if ( // ((AggregateScriptEvents & scriptEvents.collision) != 0) || // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || @@ -5114,7 +4998,7 @@ namespace OpenSim.Region.Framework.Scenes // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & NeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) + ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) ) { // subscribe to physics updates. -- cgit v1.1 From c4a9eae961030280473f6df77e59cb53865535b6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 9 Apr 2012 23:33:42 +0100 Subject: make llGetGeometricCenter() work as in current SL. Now this is not real geom center but a average of positions relative to root prim ignoring prims details, so no need to use physics engine. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 30 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 29 ++++++++++++++------- 2 files changed, 49 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 107d9b6..3fd1f5e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3955,7 +3955,35 @@ namespace OpenSim.Region.Framework.Scenes } } } - + + public Vector3 GetGeometricCenter() + { + // this is not real geometric center but a average of positions relative to root prim acording to + // http://wiki.secondlife.com/wiki/llGetGeometricCenter + // ignoring tortured prims details since sl also seems to ignore + // so no real use in doing it on physics + + Vector3 gc = Vector3.Zero; + + int nparts = m_parts.Count; + if (nparts <= 1) + return gc; + + SceneObjectPart[] parts = m_parts.GetArray(); + nparts = parts.Length; // just in case it changed + if (nparts <= 1) + return gc; + + // average all parts positions + for (int i = 0; i < nparts; i++) + gc += parts[i].GetWorldPosition(); + gc /= nparts; + + // relative to root: + gc -= AbsolutePosition; + return gc; + } + public float GetMass() { float retmass = 0f; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d419710..511ab19 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2260,18 +2260,29 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GetGeometricCenter() { - PhysicsActor pa = PhysActor; - - if (pa != null) - { - Vector3 vtmp = pa.CenterOfMass; - return vtmp; - } - else + // this is not real geometric center but a average of positions relative to root prim acording to + // http://wiki.secondlife.com/wiki/llGetGeometricCenter + // ignoring tortured prims details since sl also seems to ignore + // so no real use in doing it on physics + if (ParentGroup.IsDeleted) return new Vector3(0, 0, 0); + + return ParentGroup.GetGeometricCenter(); + + /* + PhysicsActor pa = PhysActor; + + if (pa != null) + { + Vector3 vtmp = pa.CenterOfMass; + return vtmp; + } + else + return new Vector3(0, 0, 0); + */ } - public float GetMass() + public float GetMass() { PhysicsActor pa = PhysActor; -- cgit v1.1 From 5da77e047a59601cdb6f78f30af4a32a094d861d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Apr 2012 17:50:03 +0100 Subject: don't do Animator.UpdateMovementAnimations() in scenepresence RegionHeartbeatEnd if agent is sitting. Also restore Velocity in teleportWithMomentum() --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b51d41b..c4b75bd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -753,7 +753,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_movementAnimationUpdateCounter >= 2) { m_movementAnimationUpdateCounter = 0; - if (Animator != null) + if (Animator != null && ParentID == 0) // don't do it sitting { Animator.UpdateMovementAnimations(); } @@ -1077,11 +1077,12 @@ namespace OpenSim.Region.Framework.Scenes public void TeleportWithMomentum(Vector3 pos) { bool isFlying = Flying; + Vector3 vel = Velocity; RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); - + Velocity = vel; SendTerseUpdateToAllClients(); } -- cgit v1.1 From b574d43c5d5706cf6325c909ddf0ff573e44e49b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Apr 2012 20:34:56 +0100 Subject: Use presence absolute position to request raycast to camera. Used m_pos maybe a sitting offset. For reasons i don't understand that also seems to crash ode more when i let this rays colide with heighmaps (ubitODE with normal ode lib). --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c4b75bd..855a341 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -753,7 +753,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_movementAnimationUpdateCounter >= 2) { m_movementAnimationUpdateCounter = 0; - if (Animator != null && ParentID == 0) // don't do it sitting + if (Animator != null && ParentID == 0) // skip it if sitting { Animator.UpdateMovementAnimations(); } @@ -1386,8 +1386,16 @@ namespace OpenSim.Region.Framework.Scenes { if (m_followCamAuto) { - Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; - m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); + // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; + // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); + Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; + Vector3 distTocam = CameraPosition - posAdjusted; + float distTocamlen = distTocam.Length(); + if (distTocamlen > 0) + { + distTocam *= 1.0f / distTocamlen; + m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); + } } } -- cgit v1.1 From 3999822e13d7ae2f6ab1c19a19a01e0cc7c7acd7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Apr 2012 05:07:52 +0100 Subject: Use chode character actor.SetMomentum() to force full restore Velocity in scenepresence TeleportWithMomentum(), since actor.Velocity was selected by original coders as the input of a desired velocity (even 'forces') that is modified by character conditions, like not changing velocity.Z if it is in free fall. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 855a341..8ac09e9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1082,7 +1082,9 @@ namespace OpenSim.Region.Framework.Scenes CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); - Velocity = vel; + if (PhysicsActor != null) + PhysicsActor.SetMomentum(vel); + SendTerseUpdateToAllClients(); } -- cgit v1.1 From 25a2f97bc2bb26fdb0d5856340f3ec8ce3ca9b98 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 16 Apr 2012 16:33:57 +0100 Subject: added suport funtions for ubitODE raycastFiltered --- OpenSim/Region/Framework/Scenes/Scene.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a34079c..3e08128 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1891,6 +1891,19 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerPrimsLoaded(this); } + public bool SuportsRayCastFiltered() + { + if (PhysicsScene == null) + return false; + return PhysicsScene.SuportsRaycastWorldFiltered(); + } + + public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) + { + if (PhysicsScene == null) + return null; + return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); + } /// /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. -- cgit v1.1 From 0fe0b2ceec2440ff284d7a494d090ce43449fd97 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 17 Apr 2012 23:39:41 +0200 Subject: Prevent objects rezzed in sim from being seen as attachments and becoming uneditable or crashers. (Foxtail of death) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3fd1f5e..47020af 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1941,6 +1941,12 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE]: Storing {0}, {1} in {2}", // Name, UUID, m_scene.RegionInfo.RegionName); + if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) + { + RootPart.Shape.State = 0; + ScheduleGroupForFullUpdate(); + } + SceneObjectGroup backup_group = Copy(false); backup_group.RootPart.Velocity = RootPart.Velocity; backup_group.RootPart.Acceleration = RootPart.Acceleration; -- cgit v1.1 From 411bd0574d371315c0134b30f1984fc035d84272 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Apr 2012 22:16:59 +0200 Subject: Allow setting a specific target velocity on TeleportWithMomentum --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8ac09e9..1211792 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1076,6 +1076,11 @@ namespace OpenSim.Region.Framework.Scenes public void TeleportWithMomentum(Vector3 pos) { + TeleportWithMomentum(pos, null); + } + + public void TeleportWithMomentum(Vector3 pos, Vector3? v) + { bool isFlying = Flying; Vector3 vel = Velocity; RemoveFromPhysicalScene(); @@ -1083,7 +1088,12 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = pos; AddToPhysicalScene(isFlying); if (PhysicsActor != null) - PhysicsActor.SetMomentum(vel); + { + if (v.HasValue) + PhysicsActor.SetMomentum((Vector3)v); + else + PhysicsActor.SetMomentum(vel); + } SendTerseUpdateToAllClients(); } -- cgit v1.1 From aeb5aed5b70bbe9c54ec7647a70f8fca7d0aee7e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 19 Apr 2012 23:01:22 +0100 Subject: changed - VolumeDetect and phantom setting interaction. Script VD(true) forces phantom ON. UI phantom off turns off VD. Other transitions should only change specific parameter. This is not as current SL. - Fixed volumedetect prims being wrongly removed from physics. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ++++++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 39 ++++++++++++++++------ 2 files changed, 40 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index cd4bd42..b7dc335 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1516,8 +1516,18 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) { // VolumeDetect can't be set via UI and will always be off when a change is made there - if (PhysData.PhysShapeType == PhysShapeType.invalid) - group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); + // now only change volume dtc if phantom off + + if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data + { + bool vdtc; + if (SetPhantom) // if phantom keep volumedtc + vdtc = group.RootPart.VolumeDetectActive; + else // else turn it off + vdtc = false; + + group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, vdtc); + } else { SceneObjectPart part = GetSceneObjectPart(localID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 511ab19..c73fc98 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1830,7 +1830,7 @@ namespace OpenSim.Region.Framework.Scenes public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) { - VolumeDetectActive = _VolumeDetectActive; //?? as is used this is redundante + VolumeDetectActive = _VolumeDetectActive; if (!ParentGroup.Scene.CollidablePrims) return; @@ -1839,7 +1839,10 @@ namespace OpenSim.Region.Framework.Scenes return; bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; - bool isPhantom = (_ObjectFlags & (uint) PrimFlags.Phantom) != 0; + bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; + + if (_VolumeDetectActive) + isPhantom = true; if (IsJoint()) { @@ -2065,6 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Do a physics propery update for this part. + /// now also updates phantom and volume detector /// /// /// @@ -2096,7 +2100,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup.RootPart == this) AngularVelocity = new Vector3(0, 0, 0); - if (pa.Phantom) + if (pa.Phantom && !VolumeDetectActive) { RemoveFromPhysics(); return; @@ -2143,6 +2147,14 @@ namespace OpenSim.Region.Framework.Scenes if (pa.Phantom != phan) pa.Phantom = phan; +// some engines dont' have this check still +// if (VolumeDetectActive != pa.IsVolumeDtc) + { + if (VolumeDetectActive) + pa.SetVolumeDetect(1); + else + pa.SetVolumeDetect(0); + } // If this part is a sculpt then delay the physics update until we've asynchronously loaded the // mesh data. @@ -4599,6 +4611,12 @@ namespace OpenSim.Region.Framework.Scenes if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) return; + VolumeDetectActive = SetVD; + + // volume detector implies phantom + if (VolumeDetectActive) + SetPhantom = true; + if (UsePhysics) AddFlag(PrimFlags.Physics); else @@ -4614,7 +4632,6 @@ namespace OpenSim.Region.Framework.Scenes else RemFlag(PrimFlags.TemporaryOnRez); - VolumeDetectActive = SetVD; if (ParentGroup.Scene == null) return; @@ -4624,7 +4641,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null && building && pa.Building != building) pa.Building = building; - if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none + if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none || (Shape.PathCurve == (byte)Extrusion.Flexible)) { if (pa != null) @@ -4669,12 +4686,12 @@ namespace OpenSim.Region.Framework.Scenes else // it already has a physical representation { DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. - - if(VolumeDetectActive) - pa.SetVolumeDetect(1); - else - pa.SetVolumeDetect(0); - + /* moved into DoPhysicsPropertyUpdate + if(VolumeDetectActive) + pa.SetVolumeDetect(1); + else + pa.SetVolumeDetect(0); + */ if (pa.Building != building) pa.Building = building; } -- cgit v1.1 From 3b56c4445390461ea6cdef7bc9ad8f8b26fc97c1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 20 Apr 2012 18:51:32 +0100 Subject: changed seletion code. SOP now knows about parts selection. UI actions are sent to SOP and this reports to SOG. Group is selected if any part is selected.sop.isSelect get() is only used in SOG. Will need to be improved for better performance on largelinksets. *UNTESTED* NEEDS CHECKING for side efects --- .../Framework/Scenes/Scene.PacketHandlers.cs | 66 +++++++++++++++++----- .../Region/Framework/Scenes/SceneObjectGroup.cs | 48 +++++++++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 +++++ 3 files changed, 104 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 35ac908..3ef1e29 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -129,27 +129,47 @@ namespace OpenSim.Region.Framework.Scenes /// public void SelectPrim(uint primLocalID, IClientAPI remoteClient) { + /* + SceneObjectPart part = GetSceneObjectPart(primLocalID); + + if (null == part) + return; + + if (part.IsRoot) + { + SceneObjectGroup sog = part.ParentGroup; + sog.SendPropertiesToClient(remoteClient); + + // A prim is only tainted if it's allowed to be edited by the person clicking it. + if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) + || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) + { + sog.IsSelected = true; + EventManager.TriggerParcelPrimCountTainted(); + } + } + else + { + part.SendPropertiesToClient(remoteClient); + } + */ SceneObjectPart part = GetSceneObjectPart(primLocalID); if (null == part) return; - if (part.IsRoot) - { - SceneObjectGroup sog = part.ParentGroup; - sog.SendPropertiesToClient(remoteClient); + SceneObjectGroup sog = part.ParentGroup; + if (sog == null) + return; - // A prim is only tainted if it's allowed to be edited by the person clicking it. - if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) - || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) - { - sog.IsSelected = true; - EventManager.TriggerParcelPrimCountTainted(); - } - } - else + part.SendPropertiesToClient(remoteClient); + + // A prim is only tainted if it's allowed to be edited by the person clicking it. + if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) + || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) { - part.SendPropertiesToClient(remoteClient); + part.IsSelected = true; + EventManager.TriggerParcelPrimCountTainted(); } } @@ -202,7 +222,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetSceneObjectPart(primLocalID); if (part == null) return; - + /* // A deselect packet contains all the local prims being deselected. However, since selection is still // group based we only want the root prim to trigger a full update - otherwise on objects with many prims // we end up sending many duplicate ObjectUpdates @@ -237,6 +257,22 @@ namespace OpenSim.Region.Framework.Scenes part.UUID, remoteClient.AgentId)) EventManager.TriggerParcelPrimCountTainted(); } + */ + + bool oldgprSelect = part.ParentGroup.IsSelected; + + // This is wrong, wrong, wrong. Selection should not be + // handled by group, but by prim. Legacy cruft. + // TODO: Make selection flagging per prim! + // + if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) + || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) + { + part.IsSelected = false; + if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) + EventManager.TriggerParcelPrimCountTainted(); + } + } public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 47020af..0100ab3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -726,6 +726,11 @@ namespace OpenSim.Region.Framework.Scenes m_isSelected = value; // Tell physics engine that group is selected + // this is not right + // but ode engines should only really need to know about root part + // so they can put entire object simulation on hold and not colliding + // keep as was for now + PhysicsActor pa = m_rootPart.PhysActor; if (pa != null) { @@ -747,6 +752,40 @@ namespace OpenSim.Region.Framework.Scenes } } + public void PartSelectChanged(bool partSelect) + { + // any part selected makes group selected + if (m_isSelected == partSelect) + return; + + if (partSelect) + { + IsSelected = partSelect; +// if (!IsAttachment) +// ScheduleGroupForFullUpdate(); + } + else + { + // bad bad bad 2 heavy for large linksets + // since viewer does send lot of (un)selects + // this needs to be replaced by a specific list or count ? + // but that will require extra code in several places + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + if (part.IsSelected) + return; + } + IsSelected = partSelect; + if (!IsAttachment) + { + ScheduleGroupForFullUpdate(); + } + } + } + private SceneObjectPart m_PlaySoundMasterPrim = null; public SceneObjectPart PlaySoundMasterPrim { @@ -3139,14 +3178,6 @@ namespace OpenSim.Region.Framework.Scenes } } -/* - RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); - for (int i = 0; i < parts.Length; i++) - { - if (parts[i] != RootPart) - parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); - } -*/ if (parts.Length > 1) { m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); @@ -3163,7 +3194,6 @@ namespace OpenSim.Region.Framework.Scenes } else m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); - } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c73fc98..c9659cb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -304,6 +304,9 @@ namespace OpenSim.Region.Framework.Scenes protected float m_friction = 0.6f; // wood protected float m_bounce = 0.5f; // wood + + protected bool m_isSelected = false; + /// /// Stores media texture data /// @@ -577,6 +580,16 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool IsSelected + { + get { return m_isSelected; } + set + { + m_isSelected = value; + if (ParentGroup != null) + ParentGroup.PartSelectChanged(value); + } + } public Dictionary CollisionFilter @@ -1907,6 +1920,7 @@ namespace OpenSim.Region.Framework.Scenes dupe.m_rezzed = m_rezzed; dupe.m_UndoRedo = null; + dupe.m_isSelected = false; dupe.IgnoreUndoUpdate = false; dupe.Undoing = false; -- cgit v1.1 From 26fd1e3a0c77a5b88429513b47cdd6d16d5867f5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 22 Apr 2012 03:08:47 +0100 Subject: fix a bug i added fixing another.... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1211792..108b044 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -753,9 +753,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_movementAnimationUpdateCounter >= 2) { m_movementAnimationUpdateCounter = 0; - if (Animator != null && ParentID == 0) // skip it if sitting + if (Animator != null) { - Animator.UpdateMovementAnimations(); + if(ParentID == 0) // skip it if sitting + Animator.UpdateMovementAnimations(); } else { @@ -1400,6 +1401,7 @@ namespace OpenSim.Region.Framework.Scenes { // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); + Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; Vector3 distTocam = CameraPosition - posAdjusted; float distTocamlen = distTocam.Length(); @@ -1408,6 +1410,7 @@ namespace OpenSim.Region.Framework.Scenes distTocam *= 1.0f / distTocamlen; m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); } + } } -- cgit v1.1 From b019b20eb89aab60df1a1a5c47b5b5cc4aebc4d9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 03:05:29 +0100 Subject: *testing* changed stats time reports to be per reported frame and not acumulated in about 1second. Total Frame Time is not just 1/reported sim fps --- .../Region/Framework/Scenes/SimStatsReporter.cs | 75 ++++++++++++++++++---- 1 file changed, 64 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 5c56264..31f5b88 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -75,7 +75,20 @@ namespace OpenSim.Region.Framework.Scenes OutPacketsPerSecond = 18, PendingDownloads = 19, PendingUploads = 20, + VirtualSizeKB = 21, + ResidentSizeKB = 22, + PendingLocalUploads = 23, UnAckedBytes = 24, + PhysicsPinnedTasks = 25, + PhysicsLODTasks = 26, + PhysicsStepMS = 27, + PhysicsShapeMS = 28, + PhysicsOtherMS = 29, + PhysicsMemory = 30, + ScriptEPS = 31, + SimSpareTime = 32, + SimSleepTime = 33, + IOPumpTime = 34 } /// @@ -123,7 +136,7 @@ namespace OpenSim.Region.Framework.Scenes // saved last reported value so there is something available for llGetRegionFPS private float lastReportedSimFPS = 0; - private float[] lastReportedSimStats = new float[21]; + private float[] lastReportedSimStats = new float[23]; private float m_pfps = 0; /// @@ -142,6 +155,8 @@ namespace OpenSim.Region.Framework.Scenes private int m_physicsMS = 0; private int m_imageMS = 0; private int m_otherMS = 0; + private int m_sleeptimeMS = 0; + //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. //Ckrinke private int m_scriptMS = 0; @@ -200,7 +215,7 @@ namespace OpenSim.Region.Framework.Scenes private void statsHeartBeat(object sender, EventArgs e) { - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21]; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); // Know what's not thread safe in Mono... modifying timers. @@ -249,7 +264,26 @@ namespace OpenSim.Region.Framework.Scenes // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change // values to X-per-second values. - for (int i = 0; i < 21; i++) + float factor = 1 / statsUpdateFactor; + if (reportedFPS <= 0) + reportedFPS = 1; + float TotalFrameTime = 1000.0f * statsUpdateFactor / (float)reportedFPS; + float perframe = 1.0f / (float)reportedFPS; + + float sparetime; + if (m_nominalReportedFps <= 0) + sparetime = 0; + else + { + sparetime = 1000.0f / (float)m_nominalReportedFps; + sparetime -= m_frameMS * perframe; + if (sparetime < 0) + sparetime = 0; + else if (sparetime > TotalFrameTime) + sparetime = TotalFrameTime; + } + + for (int i = 0; i < 23; i++) { sb[i] = new SimStatsPacket.StatBlock(); } @@ -279,19 +313,25 @@ namespace OpenSim.Region.Framework.Scenes sb[7].StatValue = m_activePrim; sb[8].StatID = (uint)Stats.FrameMS; - sb[8].StatValue = m_frameMS / statsUpdateFactor; + // sb[8].StatValue = m_frameMS / statsUpdateFactor; + sb[8].StatValue = TotalFrameTime; sb[9].StatID = (uint)Stats.NetMS; - sb[9].StatValue = m_netMS / statsUpdateFactor; + // sb[9].StatValue = m_netMS / statsUpdateFactor; + sb[9].StatValue = m_netMS * perframe; sb[10].StatID = (uint)Stats.PhysicsMS; - sb[10].StatValue = m_physicsMS / statsUpdateFactor; + // sb[10].StatValue = m_physicsMS / statsUpdateFactor; + sb[10].StatValue = m_physicsMS * perframe; sb[11].StatID = (uint)Stats.ImageMS ; - sb[11].StatValue = m_imageMS / statsUpdateFactor; + // sb[11].StatValue = m_imageMS / statsUpdateFactor; + sb[11].StatValue = m_imageMS * perframe; sb[12].StatID = (uint)Stats.OtherMS; - sb[12].StatValue = m_otherMS / statsUpdateFactor; + // sb[12].StatValue = m_otherMS / statsUpdateFactor; + sb[12].StatValue = m_otherMS * perframe; + sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); @@ -303,7 +343,8 @@ namespace OpenSim.Region.Framework.Scenes sb[15].StatValue = m_unAckedBytes; sb[16].StatID = (uint)Stats.AgentMS; - sb[16].StatValue = m_agentMS / statsUpdateFactor; +// sb[16].StatValue = m_agentMS / statsUpdateFactor; + sb[16].StatValue = m_agentMS * perframe; sb[17].StatID = (uint)Stats.PendingDownloads; sb[17].StatValue = m_pendingDownloads; @@ -316,8 +357,14 @@ namespace OpenSim.Region.Framework.Scenes sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; - - for (int i = 0; i < 21; i++) + + sb[21].StatID = (uint)Stats.SimSpareTime; + sb[21].StatValue = sparetime; + + sb[22].StatID = (uint)Stats.SimSleepTime; + sb[22].StatValue = m_sleeptimeMS * perframe; + + for (int i = 0; i < 23; i++) { lastReportedSimStats[i] = sb[i].StatValue; } @@ -358,6 +405,7 @@ namespace OpenSim.Region.Framework.Scenes m_physicsMS = 0; m_imageMS = 0; m_otherMS = 0; + m_sleeptimeMS = 0; //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. //Ckrinke m_scriptMS = 0; @@ -484,6 +532,11 @@ namespace OpenSim.Region.Framework.Scenes m_otherMS += ms; } + public void addSleepMS(int ms) + { + m_sleeptimeMS += ms; + } + public void AddPendingDownloads(int count) { m_pendingDownloads += count; -- cgit v1.1 From f1d6b3e710787f89b76bc85aff83feac1d22dd0b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 03:38:13 +0100 Subject: some reduction on time resolution efects on spare time report --- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 31f5b88..2d73380 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -267,21 +267,25 @@ namespace OpenSim.Region.Framework.Scenes float factor = 1 / statsUpdateFactor; if (reportedFPS <= 0) reportedFPS = 1; - float TotalFrameTime = 1000.0f * statsUpdateFactor / (float)reportedFPS; + float perframe = 1.0f / (float)reportedFPS; + float TotalFrameTime = 1000.0f * statsUpdateFactor * perframe; + + float targetframetime = 1100.0f / (float)m_nominalReportedFps; + float sparetime; - if (m_nominalReportedFps <= 0) + if (TotalFrameTime > targetframetime ) sparetime = 0; else { - sparetime = 1000.0f / (float)m_nominalReportedFps; - sparetime -= m_frameMS * perframe; + sparetime = TotalFrameTime - m_frameMS * perframe; if (sparetime < 0) sparetime = 0; else if (sparetime > TotalFrameTime) sparetime = TotalFrameTime; } + for (int i = 0; i < 23; i++) { -- cgit v1.1 From 95bb2049a08ed61820ac14442ef1d5de382927b7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 04:01:29 +0100 Subject: fix Simulation time report --- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 2d73380..e9589b8 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -286,6 +286,13 @@ namespace OpenSim.Region.Framework.Scenes sparetime = TotalFrameTime; } + // other MS is actually simulation time + // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; + // m_imageMS m_netMS are not included in m_frameMS + + m_otherMS = m_frameMS - m_physicsMS - m_agentMS; + if (m_otherMS < 0) + m_otherMS = 0; for (int i = 0; i < 23; i++) { -- cgit v1.1 From 1cfee4e84cd13c06d3450a6a286c4acf0443eed9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 04:57:59 +0100 Subject: display heatbeat sleep time in stats. This may not be good for general use, but for testing/debug --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3e08128..32a98b4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1390,6 +1390,7 @@ namespace OpenSim.Region.Framework.Scenes int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; int previousFrameTick; int maintc; + int sleepMS; while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { @@ -1557,9 +1558,13 @@ namespace OpenSim.Region.Framework.Scenes m_firstHeartbeat = false; + sleepMS = Util.EnvironmentTickCount(); if (maintc > 0) Thread.Sleep(maintc); + sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); + StatsReporter.addSleepMS(sleepMS); + // Optionally warn if a frame takes double the amount of time that it should. if (DebugUpdates && Util.EnvironmentTickCountSubtract( -- cgit v1.1 From 1848ceac955e3b41130edbd0cf33bdcc6186d9f8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 05:42:47 +0100 Subject: "save the catgirls" --- OpenSim/Region/Framework/Scenes/Scene.cs | 13 +++++++++---- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 18 ++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 32a98b4..a9a4cda 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1391,10 +1391,11 @@ namespace OpenSim.Region.Framework.Scenes int previousFrameTick; int maintc; int sleepMS; + int framestart; while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { - maintc = Util.EnvironmentTickCount(); + framestart = Util.EnvironmentTickCount(); ++Frame; // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); @@ -1481,7 +1482,7 @@ namespace OpenSim.Region.Framework.Scenes // landMS = Util.EnvironmentTickCountSubtract(ldMS); //} - frameMS = Util.EnvironmentTickCountSubtract(maintc); + // frameMS = Util.EnvironmentTickCountSubtract(maintc); otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; // if (Frame%m_update_avatars == 0) @@ -1496,7 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes // frameMS currently records work frame times, not total frame times (work + any required sleep to // reach min frame time. - StatsReporter.addFrameMS(frameMS); + // StatsReporter.addFrameMS(frameMS); StatsReporter.addAgentMS(agentMS); StatsReporter.addPhysicsMS(physicsMS + physicsMS2); @@ -1553,17 +1554,21 @@ namespace OpenSim.Region.Framework.Scenes previousFrameTick = m_lastFrameTick; m_lastFrameTick = Util.EnvironmentTickCount(); - maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); + maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); maintc = (int)(MinFrameTime * 1000) - maintc; m_firstHeartbeat = false; + sleepMS = Util.EnvironmentTickCount(); + if (maintc > 0) Thread.Sleep(maintc); sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); + frameMS = Util.EnvironmentTickCountSubtract(framestart); StatsReporter.addSleepMS(sleepMS); + StatsReporter.addFrameMS(frameMS); // Optionally warn if a frame takes double the amount of time that it should. if (DebugUpdates diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index e9589b8..94f1b15 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -253,24 +253,13 @@ namespace OpenSim.Region.Framework.Scenes physfps = 0; #endregion - - //Our time dilation is 0.91 when we're running a full speed, - // therefore to make sure we get an appropriate range, - // we have to factor in our error. (0.10f * statsUpdateFactor) - // multiplies the fix for the error times the amount of times it'll occur a second - // / 10 divides the value by the number of times the sim heartbeat runs (10fps) - // Then we divide the whole amount by the amount of seconds pass in between stats updates. - - // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change - // values to X-per-second values. - float factor = 1 / statsUpdateFactor; if (reportedFPS <= 0) reportedFPS = 1; float perframe = 1.0f / (float)reportedFPS; - float TotalFrameTime = 1000.0f * statsUpdateFactor * perframe; + float TotalFrameTime = m_frameMS * perframe; float targetframetime = 1100.0f / (float)m_nominalReportedFps; @@ -279,7 +268,8 @@ namespace OpenSim.Region.Framework.Scenes sparetime = 0; else { - sparetime = TotalFrameTime - m_frameMS * perframe; + sparetime = m_frameMS - m_physicsMS - m_agentMS; + sparetime *= perframe; if (sparetime < 0) sparetime = 0; else if (sparetime > TotalFrameTime) @@ -290,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; // m_imageMS m_netMS are not included in m_frameMS - m_otherMS = m_frameMS - m_physicsMS - m_agentMS; + m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; if (m_otherMS < 0) m_otherMS = 0; -- cgit v1.1 From f0ba6c84e487887eb438235db7010e93b4186261 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 07:27:14 +0100 Subject: fix animations if sited in ground also --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 108b044..46a9469 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -755,7 +755,7 @@ namespace OpenSim.Region.Framework.Scenes m_movementAnimationUpdateCounter = 0; if (Animator != null) { - if(ParentID == 0) // skip it if sitting + if(ParentID == 0 && !SitGround) // skip it if sitting Animator.UpdateMovementAnimations(); } else -- cgit v1.1 From 816a44d6dad4f20bbdc3d90cb60a862790ae97f3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 21:48:12 +0100 Subject: SOG bug fix in UI object changes --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0100ab3..b0f0a5d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3685,16 +3685,25 @@ namespace OpenSim.Region.Framework.Scenes if (togroup) { - // related to group - if ((change & ObjectChangeType.Position) != 0) + // related to group + if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) { - group.AbsolutePosition = data.position; - updateType = updatetype.groupterse; - } - if ((change & ObjectChangeType.Rotation) != 0) - { - group.RootPart.UpdateRotation(data.rotation); - updateType = updatetype.none; + if ((change & ObjectChangeType.Rotation) != 0) + { + group.RootPart.UpdateRotation(data.rotation); + updateType = updatetype.none; + } + if ((change & ObjectChangeType.Position) != 0) + { + group.AbsolutePosition = data.position; + updateType = updatetype.groupterse; + } + else + // ugly rotation update of all parts + { + group.AbsolutePosition = AbsolutePosition; + } + } if ((change & ObjectChangeType.Scale) != 0) { @@ -3719,10 +3728,10 @@ namespace OpenSim.Region.Framework.Scenes if (part == group.RootPart) { - if ((change & ObjectChangeType.Position) != 0) - group.UpdateRootPosition(data.position); if ((change & ObjectChangeType.Rotation) != 0) group.UpdateRootRotation(data.rotation); + if ((change & ObjectChangeType.Position) != 0) + group.UpdateRootPosition(data.position); if ((change & ObjectChangeType.Scale) != 0) part.Resize(data.scale); } -- cgit v1.1 From 22ea2ef9a0bc45b54ecad3ccfe450dcaae5b9648 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 25 Apr 2012 17:11:32 +0100 Subject: set PIDHoverTau and not PIDTau since all physics need that --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b0f0a5d..ba353c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2339,7 +2339,7 @@ namespace OpenSim.Region.Framework.Scenes { pa.PIDHoverHeight = height; pa.PIDHoverType = hoverType; - pa.PIDTau = tau; + pa.PIDHoverTau = tau; pa.PIDHoverActive = true; } else @@ -2660,19 +2660,21 @@ namespace OpenSim.Region.Framework.Scenes Quaternion oldRootRotation = linkPart.RotationOffset; linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + linkPart.ParentID = m_rootPart.LocalId; - linkPart.GroupPosition = AbsolutePosition; - Vector3 axPos = linkPart.OffsetPosition; + + linkPart.GroupPosition = AbsolutePosition; + Vector3 axPos = linkPart.OffsetPosition; Quaternion parentRot = m_rootPart.RotationOffset; axPos *= Quaternion.Inverse(parentRot); - linkPart.OffsetPosition = axPos; + Quaternion oldRot = linkPart.RotationOffset; Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; linkPart.RotationOffset = newRot; - linkPart.ParentID = m_rootPart.LocalId; +// linkPart.ParentID = m_rootPart.LocalId; done above if (m_rootPart.LinkNum == 0) m_rootPart.LinkNum = 1; -- cgit v1.1 From fd19601c6ba3b474201e2dde514c7d7c94e74e82 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 26 Apr 2012 16:17:46 +0100 Subject: Help big boobies to dance (avatar visualParams). May not persist and need more lobe ? --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b7dc335..d4965ea 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -354,7 +354,7 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); sceneObject.Velocity = vel; } - + return true; } -- cgit v1.1 From 2cf6023892545e1e61669e67f9251858a09edd83 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 01:06:07 +0100 Subject: TEST added avnLocalTeleport(Vector3 newpos, Quaternion? newrot, bool Stopped) to scenepresence.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 46a9469..d8203dd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1099,6 +1099,28 @@ namespace OpenSim.Region.Framework.Scenes SendTerseUpdateToAllClients(); } + public void avnLocalTeleport(Vector3 newpos, Quaternion? newrot, bool Stopped) + { + CheckLandingPoint(ref newpos); + AbsolutePosition = newpos; + + if (newrot.HasValue) + { + // TODO + } + + if (Stopped) + { + if (PhysicsActor != null) // speed up physics stop + PhysicsActor.SetMomentum(Vector3.Zero); + Velocity = Vector3.Zero; + } + + SendTerseUpdateToAllClients(); + } + + + public void StopFlying() { ControllingClient.StopFlying(this); -- cgit v1.1 From 61e99fba87ce6e353a459ba77ae1afae9d41039c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 01:18:30 +0100 Subject: TEST more options to avnLocalTeleport --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d8203dd..d53e5c3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1099,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes SendTerseUpdateToAllClients(); } - public void avnLocalTeleport(Vector3 newpos, Quaternion? newrot, bool Stopped) + public void avnLocalTeleport(Vector3 newpos, Quaternion? newrot,Vector3? v, bool Stopit) { CheckLandingPoint(ref newpos); AbsolutePosition = newpos; @@ -1109,11 +1109,16 @@ namespace OpenSim.Region.Framework.Scenes // TODO } - if (Stopped) + if (v.HasValue) { - if (PhysicsActor != null) // speed up physics stop + if (PhysicsActor != null) + PhysicsActor.SetMomentum((Vector3)v); + } + else if (Stopit) + { + if (PhysicsActor != null) // speedup PhysicsActor.SetMomentum(Vector3.Zero); - Velocity = Vector3.Zero; + Velocity = Vector3.Zero; // zero any velocity request } SendTerseUpdateToAllClients(); -- cgit v1.1 From 30ab9647bae51b34cd266aea0eacfd9c4b5aea29 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 01:24:44 +0100 Subject: TEST more changes --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d53e5c3..6ef0c4e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1111,8 +1111,9 @@ namespace OpenSim.Region.Framework.Scenes if (v.HasValue) { - if (PhysicsActor != null) + if (PhysicsActor != null) // speedup PhysicsActor.SetMomentum((Vector3)v); + Velocity = (Vector3)v; } else if (Stopit) { -- cgit v1.1 From a64a9e48de5226da055b0196125c8f576c462a80 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 01:43:27 +0100 Subject: TESTING --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6ef0c4e..e9ff07a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1111,15 +1111,15 @@ namespace OpenSim.Region.Framework.Scenes if (v.HasValue) { - if (PhysicsActor != null) // speedup + if (PhysicsActor != null) PhysicsActor.SetMomentum((Vector3)v); - Velocity = (Vector3)v; + m_velocity = (Vector3)v; } else if (Stopit) { - if (PhysicsActor != null) // speedup + if (PhysicsActor != null) PhysicsActor.SetMomentum(Vector3.Zero); - Velocity = Vector3.Zero; // zero any velocity request + m_velocity = Vector3.Zero; } SendTerseUpdateToAllClients(); -- cgit v1.1 From 76d9040ed41facca73b8628f381dd8bdec3c9dc2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 02:54:39 +0100 Subject: testing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e9ff07a..37196b0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1113,7 +1113,7 @@ namespace OpenSim.Region.Framework.Scenes { if (PhysicsActor != null) PhysicsActor.SetMomentum((Vector3)v); - m_velocity = (Vector3)v; +// m_velocity = (Vector3)v; } else if (Stopit) { -- cgit v1.1 From 03450dee39460f92d293621bb2fbcf93582397fc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 08:11:18 +0100 Subject: testing.... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 39 +++++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 37196b0..32a17ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1099,27 +1099,36 @@ namespace OpenSim.Region.Framework.Scenes SendTerseUpdateToAllClients(); } - public void avnLocalTeleport(Vector3 newpos, Quaternion? newrot,Vector3? v, bool Stopit) + public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) { CheckLandingPoint(ref newpos); AbsolutePosition = newpos; - if (newrot.HasValue) + if (newvel.HasValue) { - // TODO - } + if (newvel == Vector3.Zero) + { + if (PhysicsActor != null) + PhysicsActor.SetMomentum(Vector3.Zero); + m_velocity = Vector3.Zero; + } + else + { + if (rotateToVelXY) + { + float x = ((Vector3)newvel).X; + float y = ((Vector3)newvel).Y; - if (v.HasValue) - { - if (PhysicsActor != null) - PhysicsActor.SetMomentum((Vector3)v); -// m_velocity = (Vector3)v; - } - else if (Stopit) - { - if (PhysicsActor != null) - PhysicsActor.SetMomentum(Vector3.Zero); - m_velocity = Vector3.Zero; + x = 0.5f * (float)Math.Atan2(y, x); + y = (float)Math.Cos(x); + x = (float)Math.Sin(x); + Rotation = new Quaternion(0f, 0f, x, y); + } + + if (PhysicsActor != null) + PhysicsActor.SetMomentum((Vector3)newvel); + m_velocity = (Vector3)newvel; + } } SendTerseUpdateToAllClients(); -- cgit v1.1 From b948826b7ee73d01759f96959dbb901de682d523 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 09:09:29 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 32a17ce..2c12b01 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1103,7 +1103,7 @@ namespace OpenSim.Region.Framework.Scenes { CheckLandingPoint(ref newpos); AbsolutePosition = newpos; - +/* if (newvel.HasValue) { if (newvel == Vector3.Zero) @@ -1130,7 +1130,7 @@ namespace OpenSim.Region.Framework.Scenes m_velocity = (Vector3)newvel; } } - +*/ SendTerseUpdateToAllClients(); } -- cgit v1.1 From cadbfcc01115500924df4ebcea88ca962680890c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 09:15:31 +0100 Subject: itest --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2c12b01..d2e0726 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1103,7 +1103,10 @@ namespace OpenSim.Region.Framework.Scenes { CheckLandingPoint(ref newpos); AbsolutePosition = newpos; -/* + + + m_log.DebugFormat("[avnLocalTeleport] {0} {1}", newpos, rotateToVelXY); + if (newvel.HasValue) { if (newvel == Vector3.Zero) @@ -1130,7 +1133,7 @@ namespace OpenSim.Region.Framework.Scenes m_velocity = (Vector3)newvel; } } -*/ + SendTerseUpdateToAllClients(); } -- cgit v1.1 From fedc9eb1056d02c7f99fb4f55a46fdafec02054a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 09:50:53 +0100 Subject: itest --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d2e0726..25409c5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1105,11 +1105,11 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = newpos; - m_log.DebugFormat("[avnLocalTeleport] {0} {1}", newpos, rotateToVelXY); + m_log.DebugFormat("[avnLocalTeleport] to {0} {1} init rotation {3}", newpos, rotateToVelXY,Rotation); if (newvel.HasValue) { - if (newvel == Vector3.Zero) + if ((Vector3)newvel == Vector3.Zero) { if (PhysicsActor != null) PhysicsActor.SetMomentum(Vector3.Zero); @@ -1126,6 +1126,7 @@ namespace OpenSim.Region.Framework.Scenes y = (float)Math.Cos(x); x = (float)Math.Sin(x); Rotation = new Quaternion(0f, 0f, x, y); + m_log.DebugFormat("[avnLocalTeleport] final rotation {0}", Rotation); } if (PhysicsActor != null) -- cgit v1.1 From 2419de2b6dfc023afbd864046e512ec5f193dc9e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 10:10:31 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 25409c5..ef281a6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1105,7 +1105,7 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = newpos; - m_log.DebugFormat("[avnLocalTeleport] to {0} {1} init rotation {3}", newpos, rotateToVelXY,Rotation); + m_log.DebugFormat("[avnLocalTeleport] to {0} {1} init rotation {2}", newpos, rotateToVelXY,Rotation); if (newvel.HasValue) { -- cgit v1.1 From 2006188ee5e5a7ce9cc3f879a37a49337f2e93f2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 10:49:32 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ef281a6..840bdef 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1117,21 +1117,18 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (rotateToVelXY) - { - float x = ((Vector3)newvel).X; - float y = ((Vector3)newvel).Y; - - x = 0.5f * (float)Math.Atan2(y, x); - y = (float)Math.Cos(x); - x = (float)Math.Sin(x); - Rotation = new Quaternion(0f, 0f, x, y); - m_log.DebugFormat("[avnLocalTeleport] final rotation {0}", Rotation); - } - if (PhysicsActor != null) PhysicsActor.SetMomentum((Vector3)newvel); m_velocity = (Vector3)newvel; + + if (rotateToVelXY) + { + Vector3 lookAt = (Vector3)newvel; + lookAt.Z = 0; + lookAt.Normalize(); + ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); + return; + } } } -- cgit v1.1 From 8ef7df5a563a850fea6c1a6f22de55a09cecebe7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 11:01:34 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 840bdef..80f21ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1104,9 +1104,6 @@ namespace OpenSim.Region.Framework.Scenes CheckLandingPoint(ref newpos); AbsolutePosition = newpos; - - m_log.DebugFormat("[avnLocalTeleport] to {0} {1} init rotation {2}", newpos, rotateToVelXY,Rotation); - if (newvel.HasValue) { if ((Vector3)newvel == Vector3.Zero) -- cgit v1.1 From dd745f60c201aee7ff48ba81d567e7b38a8f186c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 28 Apr 2012 21:36:38 +0100 Subject: fix llGetCenterOfMass ( checked with ubitODE only) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 33 ++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 40 ++++++++++++++++++++-- 2 files changed, 70 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ba353c4..b0f2015 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4041,6 +4041,39 @@ namespace OpenSim.Region.Framework.Scenes return retmass; } + // center of mass of full object + public Vector3 GetCenterOfMass() + { + PhysicsActor pa = RootPart.PhysActor; + + if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) + { + // physics knows better about center of mass of physical prims + Vector3 tmp = pa.CenterOfMass; + return tmp; + } + + Vector3 Ptot = Vector3.Zero; + float totmass = 0f; + float m; + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + m = parts[i].GetMass(); + Ptot += parts[i].GetPartCenterOfMass() * m; + totmass += m; + } + + if (totmass == 0) + totmass = 0; + else + totmass = 1 / totmass; + Ptot *= totmass; + + return Ptot; + } + /// /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that /// the physics engine can use it. diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c9659cb..b198ca7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1865,7 +1865,7 @@ namespace OpenSim.Region.Framework.Scenes { if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) - AddToPhysics(isPhysical, isPhantom, building, true); + AddToPhysics(isPhysical, isPhantom, building, isPhysical); else PhysActor = null; // just to be sure } @@ -2308,7 +2308,7 @@ namespace OpenSim.Region.Framework.Scenes */ } - public float GetMass() + public float GetMass() { PhysicsActor pa = PhysActor; @@ -2318,6 +2318,40 @@ namespace OpenSim.Region.Framework.Scenes return 0; } + public Vector3 GetCenterOfMass() + { + if (ParentGroup.RootPart == this) + { + if (ParentGroup.IsDeleted) + return AbsolutePosition; + return ParentGroup.GetCenterOfMass(); + } + + PhysicsActor pa = PhysActor; + + if (pa != null) + { + Vector3 tmp = pa.CenterOfMass; + return tmp; + } + else + return AbsolutePosition; + } + + public Vector3 GetPartCenterOfMass() + { + PhysicsActor pa = PhysActor; + + if (pa != null) + { + Vector3 tmp = pa.CenterOfMass; + return tmp; + } + else + return AbsolutePosition; + } + + public Vector3 GetForce() { return Force; @@ -4802,7 +4836,7 @@ namespace OpenSim.Region.Framework.Scenes { Velocity = velocity; AngularVelocity = rotationalVelocity; - pa.Velocity = velocity; +// pa.Velocity = velocity; pa.RotationalVelocity = rotationalVelocity; // if not vehicle and root part apply force and torque -- cgit v1.1 From df9935273f59371061bda7e61dbdd38594e5c85a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 29 Apr 2012 00:41:51 +0100 Subject: SOG bug fix in group rotations updates --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b0f2015..f870b58 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2667,11 +2667,11 @@ namespace OpenSim.Region.Framework.Scenes Vector3 axPos = linkPart.OffsetPosition; Quaternion parentRot = m_rootPart.RotationOffset; - axPos *= Quaternion.Inverse(parentRot); + axPos *= Quaternion.Conjugate(parentRot); linkPart.OffsetPosition = axPos; Quaternion oldRot = linkPart.RotationOffset; - Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; + Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; linkPart.RotationOffset = newRot; // linkPart.ParentID = m_rootPart.LocalId; done above @@ -2923,12 +2923,12 @@ namespace OpenSim.Region.Framework.Scenes Quaternion rootRotation = m_rootPart.RotationOffset; Vector3 pos = part.OffsetPosition; - pos *= Quaternion.Inverse(rootRotation); + pos *= Quaternion.Conjugate(rootRotation); part.OffsetPosition = pos; parentRot = m_rootPart.RotationOffset; oldRot = part.RotationOffset; - Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; + Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; part.RotationOffset = newRot; } @@ -3526,6 +3526,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationR(Quaternion rot) { + m_rootPart.UpdateRotation(rot); + PhysicsActor actor = m_rootPart.PhysActor; if (actor != null) { -- cgit v1.1 From c7c0d5558bc7f51f2da19782cf83362f766d831a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 29 Apr 2012 01:00:46 +0100 Subject: remove repeated set of group rotation to physics --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f870b58..bc2ca4c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3527,14 +3527,15 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateGroupRotationR(Quaternion rot) { m_rootPart.UpdateRotation(rot); - + +/* this is done by rootpart RotationOffset set called by UpdateRotation PhysicsActor actor = m_rootPart.PhysActor; if (actor != null) { actor.Orientation = m_rootPart.RotationOffset; m_scene.PhysicsScene.AddPhysicsActorTaint(actor); } - +*/ HasGroupChanged = true; ScheduleGroupForTerseUpdate(); } -- cgit v1.1 From 84b5b3e89b4814c29b7782578dfcd6fa2f0c77f9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 29 Apr 2012 06:39:09 +0100 Subject: llGetGeometricCenter... --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bc2ca4c..f81cfe2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4024,13 +4024,25 @@ namespace OpenSim.Region.Framework.Scenes if (nparts <= 1) return gc; + Quaternion parentRot = RootPart.RotationOffset; + Vector3 pPos; + // average all parts positions for (int i = 0; i < nparts; i++) - gc += parts[i].GetWorldPosition(); + { + // do it directly + // gc += parts[i].GetWorldPosition(); + if (parts[i] != RootPart) + { + pPos = parts[i].OffsetPosition; + gc += pPos; + } + + } gc /= nparts; // relative to root: - gc -= AbsolutePosition; +// gc -= AbsolutePosition; return gc; } -- cgit v1.1 From fc3cf2b5a3ec6d5405db41c2729a968d11c4a8fb Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 1 May 2012 23:21:28 +0200 Subject: Fix saving of attachment positions --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bc2ca4c..10d53d7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3700,7 +3700,7 @@ namespace OpenSim.Region.Framework.Scenes } if ((change & ObjectChangeType.Position) != 0) { - group.AbsolutePosition = data.position; + UpdateGroupPosition(data.position); updateType = updatetype.groupterse; } else -- cgit v1.1 From 98e9f225446ade7f1650db96fb4b8d763af1730e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 May 2012 00:29:56 +0200 Subject: Preserve attachment rotation on objects rezzed via a script. Makes toasters work right, finally. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++ OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 + 2 files changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b198ca7..b0bc188 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -197,6 +197,9 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 AttachOffset = Vector3.Zero; [XmlIgnore] + public Quaternion AttachRotation = Quaternion.Identity; + + [XmlIgnore] public int STATUS_ROTATE_X; public int STATUS_ROTATE_Y; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a2649ee..959046a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -812,6 +812,7 @@ namespace OpenSim.Region.Framework.Scenes group.RootPart.AttachPoint = group.RootPart.Shape.State; group.RootPart.AttachOffset = group.AbsolutePosition; + group.RootPart.AttachRotation = group.GroupRotation; group.ResetIDs(); -- cgit v1.1 From a135e51d232143556e8154ccffeaf4860e02e33d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 2 May 2012 22:08:09 +0100 Subject: Improved sitted avatars crossings ( plus tests on vehicles) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 76804d7..8e1f447 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -634,10 +634,18 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence agent = icon.EndInvoke(iar); //// If the cross was successful, this agent is a child agent - //if (agent.IsChildAgent) - // agent.Reset(); - //else // Not successful - // agent.RestoreInCurrentScene(); + if (agent.IsChildAgent) + { + if (agent.ParentUUID != UUID.Zero) + { + agent.ParentPart = null; + agent.ParentPosition = Vector3.Zero; + } + } + +// agent.Reset(); +// else // Not successful +// agent.RestoreInCurrentScene(); // In any case agent.IsInTransit = false; -- cgit v1.1 From 9f9693dab825c7753af49c6838a484653047d4ae Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 3 May 2012 01:18:51 +0200 Subject: Clear permissions given to the object we stand up from --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 80f21ce..b0147f2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -62,6 +62,7 @@ namespace OpenSim.Region.Framework.Scenes struct ScriptControllers { + public UUID objectID; public UUID itemID; public ScriptControlled ignoreControls; public ScriptControlled eventControls; @@ -1890,6 +1891,8 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0) { SceneObjectPart part = ParentPart; + UnRegisterSeatControls(part.ParentGroup.UUID); + TaskInventoryDictionary taskIDict = part.TaskInventory; if (taskIDict != null) { @@ -3217,7 +3220,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScriptControllers c in scriptedcontrols.Values) { - controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); + controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); } cAgent.Controllers = controls; } @@ -3307,6 +3310,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ControllerData c in cAgent.Controllers) { ScriptControllers sc = new ScriptControllers(); + sc.objectID = c.ObjectID; sc.itemID = c.ItemID; sc.ignoreControls = (ScriptControlled)c.IgnoreControls; sc.eventControls = (ScriptControlled)c.EventControls; @@ -3702,10 +3706,15 @@ namespace OpenSim.Region.Framework.Scenes public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) { + SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); + if (p == null) + return; + ScriptControllers obj = new ScriptControllers(); obj.ignoreControls = ScriptControlled.CONTROL_ZERO; obj.eventControls = ScriptControlled.CONTROL_ZERO; + obj.objectID = p.ParentGroup.UUID; obj.itemID = Script_item_UUID; if (pass_on == 0 && accept == 0) { @@ -3754,6 +3763,21 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendTakeControls(int.MaxValue, false, false); } + private void UnRegisterSeatControls(UUID obj) + { + List takers = new List(); + + foreach (ScriptControllers c in scriptedcontrols.Values) + { + if (c.objectID == obj) + takers.Add(c.itemID); + } + foreach (UUID t in takers) + { + UnRegisterControlEventsToScript(0, t); + } + } + public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) { ScriptControllers takecontrols; -- cgit v1.1 From 2af7f50f26271129a2265f0cae7a5515cc7ba315 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 3 May 2012 02:07:55 +0200 Subject: Stabilize sit position on region crossing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b0147f2..7136cfc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -756,7 +756,13 @@ namespace OpenSim.Region.Framework.Scenes m_movementAnimationUpdateCounter = 0; if (Animator != null) { - if(ParentID == 0 && !SitGround) // skip it if sitting + // If the parentID == 0 we are not sitting + // if !SitGournd then we are not sitting on the ground + // Fairly straightforward, now here comes the twist + // if ParentUUID is NOT UUID.Zero, we are looking to + // be sat on an object that isn't there yet. Should + // be treated as if sat. + if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting Animator.UpdateMovementAnimations(); } else -- cgit v1.1 From 58a1a0710c971b83142bf21fa6259c95aa9d99dd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 4 May 2012 11:32:37 +0100 Subject: SOG copy bug fix, now new group has own empty list of sitted avatars. Also changed crossing code to restore sitting avas in case of group cross fail --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 66 ++++++++++++++++++---- 1 file changed, 54 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8e1f447..7e6b077 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -465,7 +465,15 @@ namespace OpenSim.Region.Framework.Scenes { return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); } - + + + + private struct avtocrossInfo + { + public ScenePresence av; + public uint ParentID; + } + /// /// The absolute position of this scene object in the scene /// @@ -517,15 +525,24 @@ namespace OpenSim.Region.Framework.Scenes { // We unparent the SP quietly so that it won't // be made to stand up + + List avsToCross = new List(); + foreach (ScenePresence av in m_linkedAvatars) { + avtocrossInfo avinfo = new avtocrossInfo(); SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); if (parentPart != null) av.ParentUUID = parentPart.UUID; + avinfo.av = av; + avinfo.ParentID = av.ParentID; + avsToCross.Add(avinfo); + av.ParentID = 0; } +// m_linkedAvatars.Clear(); m_scene.CrossPrimGroupIntoNewRegion(val, this, true); // Normalize @@ -541,18 +558,37 @@ namespace OpenSim.Region.Framework.Scenes // If it's deleted, crossing was successful if (IsDeleted) { - foreach (ScenePresence av in m_linkedAvatars) + // foreach (ScenePresence av in m_linkedAvatars) + foreach (avtocrossInfo avinfo in avsToCross) { - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); - - av.IsInTransit = true; - - CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; - d.BeginInvoke(av, val, x, y, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + ScenePresence av = avinfo.av; + if (!av.IsInTransit) // just in case... + { + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); + + av.IsInTransit = true; + + CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; + d.BeginInvoke(av, val, x, y, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + } + else + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); } - + avsToCross.Clear(); return; } + else // cross failed, put avas back ?? + { + foreach (avtocrossInfo avinfo in avsToCross) + { + ScenePresence av = avinfo.av; + av.ParentUUID = UUID.Zero; + av.ParentID = avinfo.ParentID; +// m_linkedAvatars.Add(av); + } + } + avsToCross.Clear(); + } else if (RootPart.PhysActor != null) { @@ -565,6 +601,7 @@ namespace OpenSim.Region.Framework.Scenes val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } + /* don't see the need but worse don't see where is restored to false if things stay in foreach (SceneObjectPart part in m_parts.GetArray()) { @@ -640,9 +677,12 @@ namespace OpenSim.Region.Framework.Scenes { agent.ParentPart = null; agent.ParentPosition = Vector3.Zero; + // agent.ParentUUID = UUID.Zero; } } + agent.ParentUUID = UUID.Zero; + // agent.Reset(); // else // Not successful // agent.RestoreInCurrentScene(); @@ -1779,15 +1819,14 @@ namespace OpenSim.Region.Framework.Scenes part.ClearUpdateSchedule(); if (part == m_rootPart) { - if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || + if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || (AttachmentPoint < 31) || (AttachmentPoint > 38)) avatar.ControllingClient.SendKillObject(m_regionHandle, new List { part.LocalId }); } } }); } - - + } public void AddScriptLPS(int count) @@ -2069,6 +2108,9 @@ namespace OpenSim.Region.Framework.Scenes dupe.m_isBackedUp = false; dupe.m_parts = new MapAndArray(); + // new group as no sitting avatars + dupe.m_linkedAvatars = new List(); + // Warning, The following code related to previousAttachmentStatus is needed so that clones of // attachments do not bordercross while they're being duplicated. This is hacktastic! // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! -- cgit v1.1 From 12c9916193bbb87aaa95407f798c241cbe5e23cb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 4 May 2012 19:19:54 +0100 Subject: *TO TEST/REVIEW* added current default animation in animationSet.cs to/fromArray in array element 0. This may cause compatibilities issues, but think this information is needed for proper crossings. OSG regions did survived tps in/out with this. ALso added velocity in crossings cases, for now detected by Teleport flag equal to Default (0); --- .../Framework/Scenes/Animation/AnimationSet.cs | 13 +++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 +++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 33041e9..da1b9e0 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -168,10 +168,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation public OpenSim.Framework.Animation[] ToArray() { - OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count]; + OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count + 1]; uint i = 0; try { + theArray[i++] = m_defaultAnimation; foreach (OpenSim.Framework.Animation anim in m_animations) theArray[i++] = anim; } @@ -184,8 +185,14 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void FromArray(OpenSim.Framework.Animation[] theArray) { - foreach (OpenSim.Framework.Animation anim in theArray) - m_animations.Add(anim); +// foreach (OpenSim.Framework.Animation anim in theArray) +// m_animations.Add(anim); + if (theArray.Length > 0) + { + m_defaultAnimation = theArray[0]; + for (int i = 1; i < theArray.Length; i++) + m_animations.Add(theArray[i]); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7136cfc..991074b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -866,7 +866,7 @@ namespace OpenSim.Region.Framework.Scenes IsChildAgent = false; - Animator.TrySetMovementAnimation("SIT"); +// Animator.TryFixMovementAnimation("SIT"); } else { @@ -929,7 +929,15 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = pos; - AddToPhysicalScene(isFlying); + if (m_teleportFlags == TeleportFlags.Default) + { + Vector3 vel = Velocity; + AddToPhysicalScene(isFlying); + if (PhysicsActor != null) + PhysicsActor.SetMomentum(vel); + } + else + AddToPhysicalScene(isFlying); if (ForceFly) { @@ -943,7 +951,8 @@ namespace OpenSim.Region.Framework.Scenes // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying // avatar to return to the standing position in mid-air. On login it looks like this is being sent // elsewhere anyway - // Animator.SendAnimPack(); +// Animator.SendAnimPack(); + m_scene.SwapRootAgentCount(false); @@ -980,6 +989,7 @@ namespace OpenSim.Region.Framework.Scenes // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement // recorded, which stops the input from being processed. + MovementFlag = 0; m_scene.EventManager.TriggerOnMakeRootAgent(this); @@ -1020,6 +1030,8 @@ namespace OpenSim.Region.Framework.Scenes // as teleporting back TeleportFlags = TeleportFlags.Default; + MovementFlag = 0; + // It looks like Animator is set to null somewhere, and MakeChild // is called after that. Probably in aborted teleports. if (Animator == null) @@ -1027,6 +1039,7 @@ namespace OpenSim.Region.Framework.Scenes else Animator.ResetAnimations(); + // m_log.DebugFormat( // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", // Name, UUID, m_scene.RegionInfo.RegionName); @@ -1053,9 +1066,9 @@ namespace OpenSim.Region.Framework.Scenes { // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - PhysicsActor.UnSubscribeEvents(); PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor.UnSubscribeEvents(); + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); PhysicsActor = null; } // else -- cgit v1.1 From 88c4c7283f7b867aa27b344061c7c9be965db9aa Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 May 2012 20:02:14 +0200 Subject: Revert "*TO TEST/REVIEW* added current default animation in animationSet.cs to/fromArray in array element 0. This may cause compatibilities issues, but think this information is needed for proper crossings. OSG regions did survived tps in/out with this. ALso added velocity in crossings cases, for now detected by Teleport flag equal to Default (0);" This reverts commit 12c9916193bbb87aaa95407f798c241cbe5e23cb. --- .../Framework/Scenes/Animation/AnimationSet.cs | 13 +++--------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 +++++----------------- 2 files changed, 8 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index da1b9e0..33041e9 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -168,11 +168,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation public OpenSim.Framework.Animation[] ToArray() { - OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count + 1]; + OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count]; uint i = 0; try { - theArray[i++] = m_defaultAnimation; foreach (OpenSim.Framework.Animation anim in m_animations) theArray[i++] = anim; } @@ -185,14 +184,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void FromArray(OpenSim.Framework.Animation[] theArray) { -// foreach (OpenSim.Framework.Animation anim in theArray) -// m_animations.Add(anim); - if (theArray.Length > 0) - { - m_defaultAnimation = theArray[0]; - for (int i = 1; i < theArray.Length; i++) - m_animations.Add(theArray[i]); - } + foreach (OpenSim.Framework.Animation anim in theArray) + m_animations.Add(anim); } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 991074b..7136cfc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -866,7 +866,7 @@ namespace OpenSim.Region.Framework.Scenes IsChildAgent = false; -// Animator.TryFixMovementAnimation("SIT"); + Animator.TrySetMovementAnimation("SIT"); } else { @@ -929,15 +929,7 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = pos; - if (m_teleportFlags == TeleportFlags.Default) - { - Vector3 vel = Velocity; - AddToPhysicalScene(isFlying); - if (PhysicsActor != null) - PhysicsActor.SetMomentum(vel); - } - else - AddToPhysicalScene(isFlying); + AddToPhysicalScene(isFlying); if (ForceFly) { @@ -951,8 +943,7 @@ namespace OpenSim.Region.Framework.Scenes // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying // avatar to return to the standing position in mid-air. On login it looks like this is being sent // elsewhere anyway -// Animator.SendAnimPack(); - + // Animator.SendAnimPack(); m_scene.SwapRootAgentCount(false); @@ -989,7 +980,6 @@ namespace OpenSim.Region.Framework.Scenes // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement // recorded, which stops the input from being processed. - MovementFlag = 0; m_scene.EventManager.TriggerOnMakeRootAgent(this); @@ -1030,8 +1020,6 @@ namespace OpenSim.Region.Framework.Scenes // as teleporting back TeleportFlags = TeleportFlags.Default; - MovementFlag = 0; - // It looks like Animator is set to null somewhere, and MakeChild // is called after that. Probably in aborted teleports. if (Animator == null) @@ -1039,7 +1027,6 @@ namespace OpenSim.Region.Framework.Scenes else Animator.ResetAnimations(); - // m_log.DebugFormat( // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", // Name, UUID, m_scene.RegionInfo.RegionName); @@ -1066,9 +1053,9 @@ namespace OpenSim.Region.Framework.Scenes { // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; - PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; - PhysicsActor.UnSubscribeEvents(); m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); + PhysicsActor.UnSubscribeEvents(); + PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; PhysicsActor = null; } // else -- cgit v1.1 From 1183310a05ed3232c5b73374e72a6695517d63e5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 May 2012 20:05:51 +0200 Subject: Retain velocity on walking crossing - adapted from Ubit's reverted patch --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7136cfc..43b8746 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -929,7 +929,15 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = pos; - AddToPhysicalScene(isFlying); + if (m_teleportFlags == TeleportFlags.Default) + { + Vector3 vel = Velocity; + AddToPhysicalScene(isFlying); + if (PhysicsActor != null) + PhysicsActor.SetMomentum(vel); + } + else + AddToPhysicalScene(isFlying); if (ForceFly) { @@ -980,6 +988,7 @@ namespace OpenSim.Region.Framework.Scenes // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement // recorded, which stops the input from being processed. + MovementFlag = 0; m_scene.EventManager.TriggerOnMakeRootAgent(this); @@ -1020,6 +1029,8 @@ namespace OpenSim.Region.Framework.Scenes // as teleporting back TeleportFlags = TeleportFlags.Default; + MovementFlag = 0; + // It looks like Animator is set to null somewhere, and MakeChild // is called after that. Probably in aborted teleports. if (Animator == null) @@ -1027,6 +1038,7 @@ namespace OpenSim.Region.Framework.Scenes else Animator.ResetAnimations(); + // m_log.DebugFormat( // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", // Name, UUID, m_scene.RegionInfo.RegionName); -- cgit v1.1 From b5b21013da0663db2aacac3c2361e9904bb7a457 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 May 2012 20:06:42 +0200 Subject: Reverse the order of physics event unsubscription to allow GC. Adapted from Unit's reverted patch --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 43b8746..ad6679e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1065,9 +1065,9 @@ namespace OpenSim.Region.Framework.Scenes { // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - PhysicsActor.UnSubscribeEvents(); PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor.UnSubscribeEvents(); + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); PhysicsActor = null; } // else -- cgit v1.1 From 333d013b5c34d7ed8c016251e50b80b62500aa3f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 May 2012 20:33:48 +0200 Subject: Add the default animation to the child agent data update --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ad6679e..212720e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3249,6 +3249,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.Anims = Animator.Animations.ToArray(); } catch { } + cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; // Attachment objects List attachments = GetAttachments(); @@ -3343,6 +3344,8 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? if (cAgent.Anims != null) Animator.Animations.FromArray(cAgent.Anims); + if (cAgent.DefaultAnim != null) + Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) { -- cgit v1.1 From e3226aecd9fd1859f450f7912a6544c563834fcf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 5 May 2012 10:47:51 +0100 Subject: SOG: tell physics about when we want a force or a impulse. (sorry add to change here also) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7e6b077..f9c2193 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2276,7 +2276,8 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { - pa.AddForce(impulse, true); + // false to be applied as a impulse + pa.AddForce(impulse, false); m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } } @@ -2290,7 +2291,8 @@ namespace OpenSim.Region.Framework.Scenes { if (!IsAttachment) { - pa.AddAngularForce(impulse, true); + // false to be applied as a impulse + pa.AddAngularForce(impulse, false); m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } } -- cgit v1.1 From 74eafb78ebe854c5c36f489b92c8c68328e2a80d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 7 May 2012 23:03:07 +0200 Subject: Fix moving no-mod objects. Fixes a regression introduced with the undo fix --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d4965ea..0d178c3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1273,9 +1273,36 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) { + // These two are exceptions SL makes in the interpretation + // of the change flags. Must check them here because otherwise + // the group flag (see below) would be lost + if (data.change == ObjectChangeType.groupS) + data.change = ObjectChangeType.primS; + if (data.change == ObjectChangeType.groupPS) + data.change = ObjectChangeType.primPS; part.StoreUndoState(data.change); // lets test only saving what we changed grp.doChangeObject(part, (ObjectChangeData)data); } + else + { + // Is this any kind of group operation? + if ((data.change & ObjectChangeType.Group) != 0) + { + // Is a move and/or rotation requested? + if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) + { + // Are we allowed to move it? + if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) + { + // Strip all but move and rotation from request + data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); + + part.StoreUndoState(data.change); + grp.doChangeObject(part, (ObjectChangeData)data); + } + } + } + } } } } -- cgit v1.1 From 7461fe4554f8104212071e3e01b07786f8eb546f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 12 May 2012 15:27:37 +0100 Subject: ªTEST MESS* reduce animation packets send. Added onchangeanim event with parameters to define if to add or remove, and if to send anims pack on that evocation, etc --- .../Scenes/Animation/ScenePresenceAnimator.cs | 20 ++++++++++++++++++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index f5623bd..e577958 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -79,13 +79,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_scenePresence = sp; CurrentMovementAnimation = "CROUCH"; } - + public void AddAnimation(UUID animID, UUID objectID) { if (m_scenePresence.IsChildAgent) return; -// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); + // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) SendAnimPack(); @@ -117,6 +117,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation SendAnimPack(); } + public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack) + { + if (m_scenePresence.IsChildAgent) + return; + + if (animID != UUID.Zero) + { + if (addRemove) + m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); + else + m_animations.Remove(animID); + } + if(sendPack) + SendAnimPack(); + } + // Called from scripts public void RemoveAnimation(string name) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 212720e..ba0ed95 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -781,6 +781,7 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; ControllingClient.OnStartAnim += HandleStartAnim; ControllingClient.OnStopAnim += HandleStopAnim; + ControllingClient.OnChangeAnim += avnHandleChangeAnim; ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; ControllingClient.OnAutoPilotGo += MoveToTarget; @@ -2432,6 +2433,13 @@ namespace OpenSim.Region.Framework.Scenes Animator.RemoveAnimation(animID); } + public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) + { + Animator.avnChangeAnim(animID, addRemove, sendPack); + } + + + /// /// Rotate the avatar to the given rotation and apply a movement in the given relative vector /// -- cgit v1.1 From 9b7023a159c69d599248783d88ba96a328a584f2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 12 May 2012 17:58:36 +0100 Subject: display a sleep time of zero if forced spare time to zero, when sim fps is lower than desired, for better display coerence. --- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 94f1b15..a4afd47 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -264,8 +264,12 @@ namespace OpenSim.Region.Framework.Scenes float targetframetime = 1100.0f / (float)m_nominalReportedFps; float sparetime; - if (TotalFrameTime > targetframetime ) + float sleeptime; + if (TotalFrameTime > targetframetime) + { sparetime = 0; + sleeptime = 0; + } else { sparetime = m_frameMS - m_physicsMS - m_agentMS; @@ -274,6 +278,7 @@ namespace OpenSim.Region.Framework.Scenes sparetime = 0; else if (sparetime > TotalFrameTime) sparetime = TotalFrameTime; + sleeptime = m_sleeptimeMS * perframe; } // other MS is actually simulation time @@ -363,7 +368,7 @@ namespace OpenSim.Region.Framework.Scenes sb[21].StatValue = sparetime; sb[22].StatID = (uint)Stats.SimSleepTime; - sb[22].StatValue = m_sleeptimeMS * perframe; + sb[22].StatValue = sleeptime; for (int i = 0; i < 23; i++) { -- cgit v1.1 From 59826c15cea3ba4aa647d5d9545341d3e6df731f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 14 May 2012 01:21:10 +0200 Subject: Allow non-gods to deed no-mod objects --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0089c7d..29465c0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2338,7 +2338,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) + if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) + continue; + + if (!Permissions.CanTransferObject(sog.UUID, groupID)) continue; if (sog.GroupID != groupID) -- cgit v1.1 From e78043cb705520d1754a1a9450a4f82ff3deba53 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 14 May 2012 01:32:22 +0200 Subject: Check parcel entry permissions when moving objects --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f9c2193..fd25194 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3752,7 +3752,8 @@ namespace OpenSim.Region.Framework.Scenes } if ((change & ObjectChangeType.Position) != 0) { - UpdateGroupPosition(data.position); + if (m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) + UpdateGroupPosition(data.position); updateType = updatetype.groupterse; } else -- cgit v1.1 From e3c376156c37fe8bf1b0e0b69cb4acd655d3528f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 14 May 2012 22:45:54 +0200 Subject: Completely revamp collision handling. Now works as it is supposed to. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 11 - OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 672 ++++++--------------- .../Scenes/Serialization/SceneObjectSerializer.cs | 7 + 3 files changed, 178 insertions(+), 512 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fd25194..a6551c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -755,17 +755,6 @@ namespace OpenSim.Region.Framework.Scenes get { return true; } } - private bool m_passCollision; - public bool PassCollision - { - get { return m_passCollision; } - set - { - m_passCollision = value; - HasGroupChanged = true; - } - } - public bool IsSelected { get { return m_isSelected; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b0bc188..f7edd31 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -271,7 +271,8 @@ namespace OpenSim.Region.Framework.Scenes private string m_touchName = String.Empty; private UndoRedoState m_UndoRedo = null; - private bool m_passTouches; + private bool m_passTouches = false; + private bool m_passCollisions = false; protected Vector3 m_acceleration; protected Vector3 m_angularVelocity; @@ -571,6 +572,7 @@ namespace OpenSim.Region.Framework.Scenes } } + [XmlIgnore] public bool PassTouches { get { return m_passTouches; } @@ -583,6 +585,18 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool PassCollisions + { + get { return m_passCollisions; } + set + { + m_passCollisions = value; + + if (ParentGroup != null) + ParentGroup.HasGroupChanged = true; + } + } + public bool IsSelected { get { return m_isSelected; } @@ -2433,546 +2447,202 @@ namespace OpenSim.Region.Framework.Scenes { } - public void PhysicsCollision(EventArgs e) + private bool CollisionFilteredOut(SceneObjectPart dest, UUID objectID, string objectName) { -// m_log.DebugFormat("Invoking PhysicsCollision on {0} {1} {2}", Name, LocalId, UUID); - - // single threaded here - - CollisionEventUpdate a = (CollisionEventUpdate)e; - Dictionary collissionswith = a.m_objCollisionList; - List thisHitColliders = new List(); - List endedColliders = new List(); - List startedColliders = new List(); - - // calculate things that started colliding this time - // and build up list of colliders this time - foreach (uint localid in collissionswith.Keys) - { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) - { - endedColliders.Add(localID); - } - } + if(dest.CollisionFilter.Count == 0) + return false; - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) + if (dest.CollisionFilter.ContainsValue(objectID.ToString()) || + dest.CollisionFilter.ContainsValue(objectID.ToString() + objectName) || + dest.CollisionFilter.ContainsValue(UUID.Zero.ToString() + objectName)) { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); + if (dest.CollisionFilter.ContainsKey(1)) + return false; + return true; } - if (ParentGroup.IsDeleted) - return; + if (dest.CollisionFilter.ContainsKey(1)) + return true; - // play the sound. - if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) - { - SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); - } + return false; + } - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) - { - // do event notification - if (startedColliders.Count > 0) - { - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - continue; + private DetectedObject CreateDetObject(SceneObjectPart obj) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; - if (ParentGroup.Scene == null) - return; + return detobj; + } - SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - if (ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) - || ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this object - if (found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - //If it is 0, it is to not accept collisions from this object - else - { - } - } - else - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this object, so this other object will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - } - else - { - ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) - { - if (av.LocalId == localId) - { - if (ParentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) - || ParentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this avatar - if (found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - //If it is 0, it is to not accept collisions from this avatar - else - { - } - } - else - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - } + private DetectedObject CreateDetObject(ScenePresence av) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.ControllingClient.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; - } - }); - } - } + return detobj; + } - if (colliding.Count > 0) - { - StartCollidingMessage.Colliders = colliding; + private DetectedObject CreateDetObjectForGround() + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = UUID.Zero; + detobj.nameStr = ""; + detobj.ownerUUID = UUID.Zero; + detobj.posVector = ParentGroup.RootPart.AbsolutePosition; + detobj.rotQuat = Quaternion.Identity; + detobj.velVector = Vector3.Zero; + detobj.colliderType = 0; + detobj.groupUUID = UUID.Zero; - if (ParentGroup.Scene == null) - return; + return detobj; + } -// if (m_parentGroup.PassCollision == true) -// { -// //TODO: Add pass to root prim! -// } + private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List colliders) + { + ColliderArgs colliderArgs = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in colliders) + { + if (localId == 0) + continue; - ParentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage); - } + SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); + if (obj != null) + { + if (!dest.CollisionFilteredOut(this, obj.UUID, obj.Name)) + colliding.Add(CreateDetObject(obj)); } - } - - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision) != 0) - { - if (m_lastColliders.Count > 0) + else { - ColliderArgs CollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in m_lastColliders) + ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); + if (av != null && (!av.IsChildAgent)) { - // always running this check because if the user deletes the object it would return a null reference. - if (localId == 0) - continue; - - if (ParentGroup.Scene == null) - return; - - SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - if (ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) - || ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); - //If it is 1, it is to accept ONLY collisions from this object - if (found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - //If it is 0, it is to not accept collisions from this object - else - { - } - } - else - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); - //If it is 1, it is to accept ONLY collisions from this object, so this other object will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - } - else - { - ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) - { - if (av.LocalId == localId) - { - if (ParentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) - || ParentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this avatar - if (found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - //If it is 0, it is to not accept collisions from this avatar - else - { - } - } - else - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - } - - } - }); - } - } - if (colliding.Count > 0) - { - CollidingMessage.Colliders = colliding; - - if (ParentGroup.Scene == null) - return; - - ParentGroup.Scene.EventManager.TriggerScriptColliding(LocalId, CollidingMessage); + if (!dest.CollisionFilteredOut(this, av.UUID, av.Name)) + colliding.Add(CreateDetObject(av)); } } } - - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_end) != 0) - { - if (endedColliders.Count > 0) - { - ColliderArgs EndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in endedColliders) - { - if (localId == 0) - continue; - if (ParentGroup.Scene == null) - return; + colliderArgs.Colliders = colliding; - SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - if (ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); - //If it is 1, it is to accept ONLY collisions from this object - if (found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - //If it is 0, it is to not accept collisions from this object - else - { - } - } - else - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); - //If it is 1, it is to accept ONLY collisions from this object, so this other object will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } - } - else - { - ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) - { - if (av.LocalId == localId) - { - if (ParentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) - || ParentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this avatar - if (found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - //If it is 0, it is to not accept collisions from this avatar - else - { - } - } - else - { - bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); - //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - } + return colliderArgs; + } - } - }); - } - } - - if (colliding.Count > 0) - { - EndCollidingMessage.Colliders = colliding; - - if (ParentGroup.Scene == null) - return; - - ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd(LocalId, EndCollidingMessage); - } - } - } + private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); + + private void SendCollisionEvent(scriptEvents ev, List colliders, ScriptCollidingNotification notify) + { + bool sendToRoot = false; + ColliderArgs CollidingMessage; - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_start) != 0) + if (colliders.Count > 0) { - if (startedColliders.Count > 0) + if ((ScriptEvents & ev) != 0) { - ColliderArgs LandStartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - { - //Hope that all is left is ground! - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = UUID.Zero; - detobj.nameStr = ""; - detobj.ownerUUID = UUID.Zero; - detobj.posVector = ParentGroup.RootPart.AbsolutePosition; - detobj.rotQuat = Quaternion.Identity; - detobj.velVector = Vector3.Zero; - detobj.colliderType = 0; - detobj.groupUUID = UUID.Zero; - colliding.Add(detobj); - } - } - - if (colliding.Count > 0) - { - LandStartCollidingMessage.Colliders = colliding; + CollidingMessage = CreateColliderArgs(this, colliders); - if (ParentGroup.Scene == null) - return; + if (CollidingMessage.Colliders.Count > 0) + notify(LocalId, CollidingMessage); - ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart(LocalId, LandStartCollidingMessage); - } + if (PassCollisions) + sendToRoot = true; + } + else + { + if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) + sendToRoot = true; + } + if (sendToRoot && ParentGroup.RootPart != this) + { + CollidingMessage = CreateColliderArgs(ParentGroup.RootPart, colliders); + if (CollidingMessage.Colliders.Count > 0) + notify(ParentGroup.RootPart.LocalId, CollidingMessage); } } + } - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.land_collision) != 0) + private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) + { + if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) { - if (m_lastColliders.Count > 0) - { - ColliderArgs LandCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - { - //Hope that all is left is ground! - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = UUID.Zero; - detobj.nameStr = ""; - detobj.ownerUUID = UUID.Zero; - detobj.posVector = ParentGroup.RootPart.AbsolutePosition; - detobj.rotQuat = Quaternion.Identity; - detobj.velVector = Vector3.Zero; - detobj.colliderType = 0; - detobj.groupUUID = UUID.Zero; - colliding.Add(detobj); - } - } + ColliderArgs LandCollidingMessage = new ColliderArgs(); + List colliding = new List(); + + colliding.Add(CreateDetObjectForGround()); + LandCollidingMessage.Colliders = colliding; - if (colliding.Count > 0) - { - LandCollidingMessage.Colliders = colliding; + notify(LocalId, LandCollidingMessage); + } + } - if (ParentGroup.Scene == null) - return; + public void PhysicsCollision(EventArgs e) + { + if (ParentGroup.Scene == null || ParentGroup.IsDeleted) + return; - ParentGroup.Scene.EventManager.TriggerScriptLandColliding(LocalId, LandCollidingMessage); - } - } + // single threaded here + CollisionEventUpdate a = (CollisionEventUpdate)e; + Dictionary collissionswith = a.m_objCollisionList; + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); + + // calculate things that started colliding this time + // and build up list of colliders this time + foreach (uint localid in collissionswith.Keys) + { + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + startedColliders.Add(localid); } - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_end) != 0) + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) { - if (endedColliders.Count > 0) - { - ColliderArgs LandEndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - { - //Hope that all is left is ground! - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = UUID.Zero; - detobj.nameStr = ""; - detobj.ownerUUID = UUID.Zero; - detobj.posVector = ParentGroup.RootPart.AbsolutePosition; - detobj.rotQuat = Quaternion.Identity; - detobj.velVector = Vector3.Zero; - detobj.colliderType = 0; - detobj.groupUUID = UUID.Zero; - colliding.Add(detobj); - } - } + if (!thisHitColliders.Contains(localID)) + endedColliders.Add(localID); + } - if (colliding.Count > 0) - { - LandEndCollidingMessage.Colliders = colliding; + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + m_lastColliders.Add(localID); - if (ParentGroup.Scene == null) - return; + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + m_lastColliders.Remove(localID); - ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd(LocalId, LandEndCollidingMessage); - } - } + // play the sound. + if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) + SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); + + SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); + SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); + SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); + + if (startedColliders.Contains(0)) + { + if (m_lastColliders.Contains(0)) + SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); + else + SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); } + if (endedColliders.Contains(0)) + SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); } public void PhysicsOutOfBounds(Vector3 pos) @@ -4724,7 +4394,7 @@ namespace OpenSim.Region.Framework.Scenes // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) + ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) // (CollisionSound != UUID.Zero) ) { @@ -5077,7 +4747,7 @@ namespace OpenSim.Region.Framework.Scenes // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) + ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) ) { // subscribe to physics updates. diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 1cd8189..151eba2 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -307,6 +307,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("Name", ProcessName); m_SOPXmlProcessors.Add("Material", ProcessMaterial); m_SOPXmlProcessors.Add("PassTouches", ProcessPassTouches); + m_SOPXmlProcessors.Add("PassCollisions", ProcessPassCollisions); m_SOPXmlProcessors.Add("RegionHandle", ProcessRegionHandle); m_SOPXmlProcessors.Add("ScriptAccessPin", ProcessScriptAccessPin); m_SOPXmlProcessors.Add("GroupPosition", ProcessGroupPosition); @@ -506,6 +507,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.PassTouches = Util.ReadBoolean(reader); } + private static void ProcessPassCollisions(SceneObjectPart obj, XmlTextReader reader) + { + obj.PassCollisions = Util.ReadBoolean(reader); + } + private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader) { obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty); @@ -1246,6 +1252,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Name", sop.Name); writer.WriteElementString("Material", sop.Material.ToString()); writer.WriteElementString("PassTouches", sop.PassTouches.ToString().ToLower()); + writer.WriteElementString("PassCollisions", sop.PassCollisions.ToString().ToLower()); writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString()); writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString()); -- cgit v1.1 From e9e797b6814b960b140094bbff137e38f96d4ca8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 15 May 2012 00:15:44 +0200 Subject: Fix an omission --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f7edd31..4884469 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2564,7 +2564,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) + if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) sendToRoot = true; } if (sendToRoot && ParentGroup.RootPart != this) -- cgit v1.1 From 325973d36f98a4b2fb0291e8bdc0063c4264329d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 15 May 2012 01:40:46 +0100 Subject: don't send colision events to volume detectors --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4884469..81244ef 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2631,7 +2631,8 @@ namespace OpenSim.Region.Framework.Scenes SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); - SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); + if(!ParentGroup.RootPart.VolumeDetectActive) + SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); if (startedColliders.Contains(0)) -- cgit v1.1 From 995cd25f3027e1debb0ae5fc60b5dde831c31d17 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 15 May 2012 02:36:11 +0200 Subject: Port the mel/dahlia fix --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 81244ef..7a1720c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4706,6 +4706,9 @@ namespace OpenSim.Region.Framework.Scenes public void aggregateScriptEvents() { + if (ParentGroup == null || ParentGroup.RootPart == null) + return; + AggregateScriptEvents = 0; // Aggregate script events -- cgit v1.1 From ca14534b91342f55e30838ccafba25424628f5b4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 15 May 2012 15:54:02 +0100 Subject: sop: - added UpdatePhysicsSubscribedEvents() to update physics ator collision events subcription where needed. Made it consider also VolumeDtc and phantom cases. - added extra calls to it on physics ator proprieties changes. - Fixed land collisions reports. - Handle the case of physics sending a last zero colisions reports to trigger collision_end. - Made the physics collisions report rate be 20 per second. (needs review/testing) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 166 +++++++++++++++------ 1 file changed, 118 insertions(+), 48 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7a1720c..11d6b57 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -123,11 +123,17 @@ namespace OpenSim.Region.Framework.Scenes /// public const int ALL_SIDES = -1; - private const scriptEvents PhyscicsNeededSubsEvents = ( + private const scriptEvents PhysicsNeededSubsEvents = ( scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end ); - + private const scriptEvents PhyscicsPhantonSubsEvents = ( + scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end + ); + private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( + scriptEvents.collision_start | scriptEvents.collision_end + ); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// @@ -1882,7 +1888,10 @@ namespace OpenSim.Region.Framework.Scenes { if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) + { AddToPhysics(isPhysical, isPhantom, building, isPhysical); + UpdatePhysicsSubscribedEvents(); // not sure if appliable here + } else PhysActor = null; // just to be sure } @@ -1975,6 +1984,7 @@ namespace OpenSim.Region.Framework.Scenes bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); dupe.DoPhysicsPropertyUpdate(UsePhysics, true); +// dupe.UpdatePhysicsSubscribedEvents(); // not sure... } if (dupe.PhysActor != null) @@ -2602,30 +2612,45 @@ namespace OpenSim.Region.Framework.Scenes List endedColliders = new List(); List startedColliders = new List(); - // calculate things that started colliding this time - // and build up list of colliders this time - foreach (uint localid in collissionswith.Keys) + if (collissionswith.Count == 0) { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - startedColliders.Add(localid); - } + if (m_lastColliders.Count == 0) + return; // nothing to do - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) + foreach (uint localID in m_lastColliders) + { endedColliders.Add(localID); + } + m_lastColliders.Clear(); } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - m_lastColliders.Add(localID); + else + { + + // calculate things that started colliding this time + // and build up list of colliders this time + foreach (uint localid in collissionswith.Keys) + { + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) + startedColliders.Add(localid); + } + + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) + endedColliders.Add(localID); + } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - m_lastColliders.Remove(localID); + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + m_lastColliders.Add(localID); + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + m_lastColliders.Remove(localID); + } // play the sound. if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); @@ -2636,12 +2661,9 @@ namespace OpenSim.Region.Framework.Scenes SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); if (startedColliders.Contains(0)) - { - if (m_lastColliders.Contains(0)) - SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); - else - SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); - } + SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); + if (m_lastColliders.Contains(0)) + SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); if (endedColliders.Contains(0)) SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); } @@ -4383,26 +4405,28 @@ namespace OpenSim.Region.Framework.Scenes { if (pa == null) { - AddToPhysics(UsePhysics, SetPhantom, building , false); + AddToPhysics(UsePhysics, SetPhantom, building, false); pa = PhysActor; - - if (pa != null) - { - if ( -// ((AggregateScriptEvents & scriptEvents.collision) != 0) || -// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || -// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || -// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || -// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || -// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) -// (CollisionSound != UUID.Zero) - ) - { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); - } - } + /* + if (pa != null) + { + if ( + // ((AggregateScriptEvents & scriptEvents.collision) != 0) || + // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || + // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || + // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || + // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || + // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || + (CollisionSound != UUID.Zero) + ) + { + pa.OnCollisionUpdate += PhysicsCollision; + pa.SubscribeEvents(1000); + } + } + */ } else // it already has a physical representation @@ -4414,9 +4438,13 @@ namespace OpenSim.Region.Framework.Scenes else pa.SetVolumeDetect(0); */ + + if (pa.Building != building) pa.Building = building; } + + UpdatePhysicsSubscribedEvents(); } } @@ -4539,8 +4567,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// This isn't the same as turning off physical, since even without being physical the prim has a physics - /// representation for collision detection. Rather, this would be used in situations such as making a prim - /// phantom. + /// representation for collision detection. /// public void RemoveFromPhysics() { @@ -4704,6 +4731,46 @@ namespace OpenSim.Region.Framework.Scenes ScheduleFullUpdate(); } + + private void UpdatePhysicsSubscribedEvents() + { + PhysicsActor pa = PhysActor; + if (pa == null) + return; + + pa.OnCollisionUpdate -= PhysicsCollision; + + bool hassound = ( CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f); + scriptEvents CombinedEvents = AggregateScriptEvents; + + // merge with root part + if (ParentGroup != null && ParentGroup.RootPart != null) + CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; + + // submit to this part case + if (VolumeDetectActive) + { + CombinedEvents &= PhyscicsVolumeDtcSubsEvents; + hassound = false; + } + else if ((Flags & PrimFlags.Phantom) != 0) + CombinedEvents &= PhyscicsPhantonSubsEvents; + else + CombinedEvents &= PhysicsNeededSubsEvents; + + if (hassound || CombinedEvents != 0) + { + // subscribe to physics updates. + pa.OnCollisionUpdate += PhysicsCollision; + pa.SubscribeEvents(50); // 20 reports per second + } + else + { + pa.UnSubscribeEvents(); + } + } + + public void aggregateScriptEvents() { if (ParentGroup == null || ParentGroup.RootPart == null) @@ -4740,7 +4807,7 @@ namespace OpenSim.Region.Framework.Scenes { objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; } - +/* PhysicsActor pa = PhysActor; if (pa != null) { @@ -4751,7 +4818,7 @@ namespace OpenSim.Region.Framework.Scenes // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) + ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) ) { // subscribe to physics updates. @@ -4764,6 +4831,9 @@ namespace OpenSim.Region.Framework.Scenes pa.OnCollisionUpdate -= PhysicsCollision; } } + */ + UpdatePhysicsSubscribedEvents(); + //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) //{ // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; -- cgit v1.1 From accab1e086b8a77b233371b07b648195355d6603 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 15 May 2012 16:56:43 +0100 Subject: sop colisions don't play sounds on volume detectors --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 11d6b57..3850e46 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2652,7 +2652,7 @@ namespace OpenSim.Region.Framework.Scenes m_lastColliders.Remove(localID); } // play the sound. - if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) + if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f && !ParentGroup.RootPart.VolumeDetectActive) SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); -- cgit v1.1 From 81d7844f5196aeee7a02c924448795820dbf5e8b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 15 May 2012 17:01:00 +0100 Subject: use part VolumeDetectActive and not rootPart.VolumeDetectActive to be coerent with other places in case of future changes. Should be equivalent if all is well. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3850e46..8716e20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2652,11 +2652,14 @@ namespace OpenSim.Region.Framework.Scenes m_lastColliders.Remove(localID); } // play the sound. - if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f && !ParentGroup.RootPart.VolumeDetectActive) + + bool IsNotVolumeDtc = !VolumeDetectActive; + + if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f && IsNotVolumeDtc) SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); - if(!ParentGroup.RootPart.VolumeDetectActive) + if (IsNotVolumeDtc) SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); -- cgit v1.1 From ea47b0362548101d201f3bef26436d3420d791fd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 May 2012 12:27:49 +0100 Subject: Added a invalidCollisionSoundUUID so that scripts can stop all collision sounds with llCollisionSound("",...). UUID.Zero means defaults should be used. In case part has several scripts with confliting llCollisionSound result depende on exec order. Specially on reset the efect of "" depends on reset order, it should override the others. This is intermediate improve(?) since collisions sounds seem to need a deaper revision. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8716e20..2fb42f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1336,11 +1336,13 @@ namespace OpenSim.Region.Framework.Scenes set { m_sitAnimation = value; } } + public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); + public UUID CollisionSound { get { return m_collisionSound; } set - { + { m_collisionSound = value; aggregateScriptEvents(); } @@ -2655,8 +2657,15 @@ namespace OpenSim.Region.Framework.Scenes bool IsNotVolumeDtc = !VolumeDetectActive; - if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f && IsNotVolumeDtc) - SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); + if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSoundVolume > 0.0f && CollisionSound != invalidCollisionSoundUUID) + { + if(CollisionSound != UUID.Zero) + SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); + else + { + // default sounds + } + } SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); if (IsNotVolumeDtc) @@ -4743,7 +4752,7 @@ namespace OpenSim.Region.Framework.Scenes pa.OnCollisionUpdate -= PhysicsCollision; - bool hassound = ( CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f); + bool hassound = ( CollisionSound != invalidCollisionSoundUUID); scriptEvents CombinedEvents = AggregateScriptEvents; // merge with root part -- cgit v1.1 From 0de7219485b55ce297d963c46e5ba869eeb1b8e3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 May 2012 23:36:37 +0100 Subject: collision sounds: simplify send code a bit and limit sending rate to 5 per sec per part ??? --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2fb42f4..38e7a12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -188,6 +188,7 @@ namespace OpenSim.Region.Framework.Scenes public double SoundRadius; + public uint TimeStampFull; public uint TimeStampLastActivity; // Will be used for AutoReturn @@ -332,6 +333,8 @@ namespace OpenSim.Region.Framework.Scenes private UUID m_collisionSound; private float m_collisionSoundVolume; + private DateTime LastColSoundSentTime; + private SOPVehicle m_vehicle = null; @@ -371,6 +374,7 @@ namespace OpenSim.Region.Framework.Scenes // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log m_inventory = new SceneObjectPartInventory(this); + LastColSoundSentTime = DateTime.UtcNow; } /// @@ -2660,7 +2664,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSoundVolume > 0.0f && CollisionSound != invalidCollisionSoundUUID) { if(CollisionSound != UUID.Zero) - SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); + SendCollisionSound(CollisionSound, CollisionSoundVolume); else { // default sounds @@ -3199,6 +3203,37 @@ namespace OpenSim.Region.Framework.Scenes } } + public void SendCollisionSound(UUID soundID, double volume) + { + if (soundID == UUID.Zero) + return; + + + ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); + if (soundModule == null) + return; + + if (volume > 1) + volume = 1; + if (volume < 0) + volume = 0; + + DateTime now = DateTime.UtcNow; + if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? + return; + + LastColSoundSentTime = now; + + UUID ownerID = OwnerID; + UUID objectID = ParentGroup.RootPart.UUID; + UUID parentID = ParentGroup.UUID; + Vector3 position = AbsolutePosition; // region local + ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; + + soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0); + } + + /// /// Send a terse update to all clients /// -- cgit v1.1 From 7cbc54d92a4702efb8a7bc1b0ec611c4abbc104b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 17 May 2012 01:04:30 +0100 Subject: default collision sounds. Incomplete, untested, needs revision --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 204 +++++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/Framework/Scenes/CollisionSounds.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs new file mode 100644 index 0000000..65c8012 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -0,0 +1,204 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +// Ubit 2012 + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Scenes +{ + public static class CollisionSounds + { + // defines for cases + // only know one UUID for now (woodflesh) + + private const int MaxMaterials = 7; + // part part + private static UUID snd_StoneStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StoneMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StoneGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StoneWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StoneFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StonePlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StoneRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + private static UUID snd_MetalStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_MetalMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_MetalGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_MetalWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_MetalFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_MetalPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_MetalRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + private static UUID snd_GlassStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_GlassMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_GlassGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_GlassWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_GlassFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_GlassPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_GlassRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + private static UUID snd_WoodStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_WoodMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_WoodGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_WoodWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_WoodFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_WoodPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_WoodRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + private static UUID snd_FleshStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_FleshMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_FleshGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_FleshWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_FleshFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_FleshPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_FleshRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + private static UUID snd_PlasticStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_PlasticMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_PlasticGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_PlasticWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_PlasticFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_PlasticPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_PlasticRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + private static UUID snd_RubberStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_RubberMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_RubberGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_RubberWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_RubberFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_RubberPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_RubberRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + // terrain part + private static UUID snd_TerrainStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + + public static UUID[] m_TerrainPart = { + snd_TerrainStone, + snd_TerrainMetal, + snd_TerrainGlass, + snd_TerrainWood, + snd_TerrainFlesh, + snd_TerrainPlastic, + snd_TerrainRubber + }; + + public static UUID[] m_PartPart = { + snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, + snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, + snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, + snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, + snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, + snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, + snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber + }; + + public static void PartCollisionSound(SceneObjectPart part,List Colliders) + { + if(Colliders.Count == 0 || part == null) + return; + + if ((part.Flags & PrimFlags.Physics) == 0) // let only active prims trigger sounds + return; + + if (part.ParentGroup == null) + return; + + if (part.CollisionSound == part.invalidCollisionSoundUUID) + return; + + UUID soundID; + int otherMaterial; + + int thisMaterial = (int) part.Material; + if (thisMaterial >= MaxMaterials) + thisMaterial = 3; + + int thisMatScaled = thisMaterial * MaxMaterials; + int index; + + bool doneownsound = false; + + foreach (uint Id in Colliders) + { + if (Id == 0) + { + if (!doneownsound) + { + soundID = m_TerrainPart[thisMaterial]; + part.SendCollisionSound(soundID, 1.0); + doneownsound = true; + } + continue; + } + + SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); + if (otherPart != null) + { + if (otherPart.CollisionSound == part.invalidCollisionSoundUUID) + continue; + if (otherPart.CollisionSound != UUID.Zero) + otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume); + else + { + otherMaterial = (int)otherPart.Material; + if (otherMaterial >= MaxMaterials) + otherMaterial = 3; + index = thisMatScaled + otherMaterial; + soundID = m_PartPart[index]; + if (doneownsound) + otherPart.SendCollisionSound(soundID, 1.0); + else + { + part.SendCollisionSound(soundID, 1.0); + doneownsound = true; + } + } + } + else if (!doneownsound) + { + ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); + if (av != null && (!av.IsChildAgent)) + { + index = thisMatScaled + 4; // flesh + soundID = m_PartPart[index]; + part.SendCollisionSound(soundID, 1.0); + doneownsound = true; + } + } + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 38e7a12..af9b7eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2667,7 +2667,7 @@ namespace OpenSim.Region.Framework.Scenes SendCollisionSound(CollisionSound, CollisionSoundVolume); else { - // default sounds + CollisionSounds.PartCollisionSound(this, startedColliders); } } -- cgit v1.1 From b743835f9ed665c85eb78569b2bc31853eb64332 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 17 May 2012 01:36:42 +0100 Subject: default colisionVolume is 0, use it only for user specified sound --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index af9b7eb..5874d34 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2661,10 +2661,13 @@ namespace OpenSim.Region.Framework.Scenes bool IsNotVolumeDtc = !VolumeDetectActive; - if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSoundVolume > 0.0f && CollisionSound != invalidCollisionSoundUUID) + if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) { - if(CollisionSound != UUID.Zero) - SendCollisionSound(CollisionSound, CollisionSoundVolume); + if (CollisionSound != UUID.Zero) + { + if (CollisionSoundVolume > 0.0f) + SendCollisionSound(CollisionSound, CollisionSoundVolume); + } else { CollisionSounds.PartCollisionSound(this, startedColliders); -- cgit v1.1 From 038986baffff3d2a6b2ec4f10ae8c40635b5398b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 17 May 2012 04:14:13 +0100 Subject: add avatar colision sounds. Changed test sound UUID --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 180 ++++++++++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 + 2 files changed, 120 insertions(+), 62 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 65c8012..a22ee10 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -40,70 +40,70 @@ namespace OpenSim.Region.Framework.Scenes private const int MaxMaterials = 7; // part part - private static UUID snd_StoneStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_StoneMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_StoneGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_StoneWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_StoneFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_StonePlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_StoneRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - - private static UUID snd_MetalStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_MetalMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_MetalGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_MetalWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_MetalFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_MetalPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_MetalRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - - private static UUID snd_GlassStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_GlassMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_GlassGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_GlassWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_GlassFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_GlassPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_GlassRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - - private static UUID snd_WoodStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_WoodMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_WoodGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_WoodWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_WoodFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_WoodPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_WoodRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - - private static UUID snd_FleshStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_FleshMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_FleshGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_FleshWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_FleshFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_FleshPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_FleshRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - - private static UUID snd_PlasticStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_PlasticMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_PlasticGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_PlasticWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_PlasticFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_PlasticPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_PlasticRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - - private static UUID snd_RubberStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_RubberMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_RubberGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_RubberWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_RubberFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_RubberPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_RubberRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + private static UUID snd_MetalStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + private static UUID snd_GlassStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + private static UUID snd_WoodStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + private static UUID snd_FleshStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + private static UUID snd_PlasticStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + private static UUID snd_RubberStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_RubberMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_RubberGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_RubberWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_RubberFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_RubberPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); // terrain part - private static UUID snd_TerrainStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_TerrainMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_TerrainGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_TerrainWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_TerrainFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_TerrainPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); - private static UUID snd_TerrainRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); + private static UUID snd_TerrainStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_TerrainMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_TerrainGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_TerrainWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_TerrainFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_TerrainPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_TerrainRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); public static UUID[] m_TerrainPart = { snd_TerrainStone, @@ -187,6 +187,7 @@ namespace OpenSim.Region.Framework.Scenes } } } +/* avatars get notification let them trigger the sound else if (!doneownsound) { ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); @@ -198,7 +199,62 @@ namespace OpenSim.Region.Framework.Scenes doneownsound = true; } } + */ + } + } + + public static void AvatarCollisionSound(ScenePresence av, List Colliders) + { + if (Colliders.Count == 0 || av == null) + return; + + UUID soundID; + int otherMaterial; + + int thisMaterial = 3; + + int thisMatScaled = thisMaterial * MaxMaterials; + int index; +// bool doneownsound = false; + + foreach (uint Id in Colliders) + { + if (Id == 0) + { + continue; + } + + SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); + if (otherPart != null) + { + if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) + continue; + if (otherPart.CollisionSound != UUID.Zero) + otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume); + else + { + otherMaterial = (int)otherPart.Material; + if (otherMaterial >= MaxMaterials) + otherMaterial = 3; + index = thisMatScaled + otherMaterial; + soundID = m_PartPart[index]; + otherPart.SendCollisionSound(soundID, 1.0); + } + } +/* + else if (!doneownsound) + { + ScenePresence otherav = av.Scene.GetScenePresence(Id); + if (otherav != null && (!otherav.IsChildAgent)) + { + soundID = snd_FleshFlesh; + av.SendCollisionSound(soundID, 1.0); + doneownsound = true; + } + } + */ } } + } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ba0ed95..b8c33b0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4145,6 +4145,8 @@ namespace OpenSim.Region.Framework.Scenes // do event notification if (startedColliders.Count > 0) { + CollisionSounds.AvatarCollisionSound(this, startedColliders); + ColliderArgs StartCollidingMessage = new ColliderArgs(); List colliding = new List(); foreach (uint localId in startedColliders) -- cgit v1.1 From e4231e95a976f8b3c02add39b94721eebb639674 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 17 May 2012 04:41:46 +0100 Subject: increase avatars collisions report to 10 per sec, Stopped sound on avatar to volumedetect collision --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index a22ee10..c46756c 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -167,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); if (otherPart != null) { - if (otherPart.CollisionSound == part.invalidCollisionSoundUUID) + if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) continue; if (otherPart.CollisionSound != UUID.Zero) otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b8c33b0..ebddf21 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3425,7 +3425,7 @@ namespace OpenSim.Region.Framework.Scenes //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong - PhysicsActor.SubscribeEvents(500); + PhysicsActor.SubscribeEvents(100); PhysicsActor.LocalID = LocalId; } -- cgit v1.1 From 6af78836a540c9b0a5972ab241364dae52e8e74d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 17 May 2012 12:17:29 +0100 Subject: trigger collision sounds on active agent position for better spatial effect without using the detailed collision position. (current error will be half max physical prim size). Moved some checks from sop to collisionSound code --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 25 ++++++++++++++++------ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++------------- 2 files changed, 22 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index c46756c..5d43027 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.Framework.Scenes if(Colliders.Count == 0 || part == null) return; - if ((part.Flags & PrimFlags.Physics) == 0) // let only active prims trigger sounds + if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) return; if (part.ParentGroup == null) @@ -142,6 +142,15 @@ namespace OpenSim.Region.Framework.Scenes UUID soundID; int otherMaterial; + Vector3 position = part.AbsolutePosition; + + if (part.CollisionSound != UUID.Zero) + { + if (part.CollisionSoundVolume > 0.0f) + part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position); + return; + } + int thisMaterial = (int) part.Material; if (thisMaterial >= MaxMaterials) thisMaterial = 3; @@ -158,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes if (!doneownsound) { soundID = m_TerrainPart[thisMaterial]; - part.SendCollisionSound(soundID, 1.0); + part.SendCollisionSound(soundID, 1.0, position); doneownsound = true; } continue; @@ -170,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) continue; if (otherPart.CollisionSound != UUID.Zero) - otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume); + otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); else { otherMaterial = (int)otherPart.Material; @@ -179,10 +188,10 @@ namespace OpenSim.Region.Framework.Scenes index = thisMatScaled + otherMaterial; soundID = m_PartPart[index]; if (doneownsound) - otherPart.SendCollisionSound(soundID, 1.0); + otherPart.SendCollisionSound(soundID, 1.0, position); else { - part.SendCollisionSound(soundID, 1.0); + part.SendCollisionSound(soundID, 1.0, position); doneownsound = true; } } @@ -217,6 +226,8 @@ namespace OpenSim.Region.Framework.Scenes int index; // bool doneownsound = false; + Vector3 position = av.AbsolutePosition; + foreach (uint Id in Colliders) { if (Id == 0) @@ -230,7 +241,7 @@ namespace OpenSim.Region.Framework.Scenes if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) continue; if (otherPart.CollisionSound != UUID.Zero) - otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume); + otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); else { otherMaterial = (int)otherPart.Material; @@ -238,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes otherMaterial = 3; index = thisMatScaled + otherMaterial; soundID = m_PartPart[index]; - otherPart.SendCollisionSound(soundID, 1.0); + otherPart.SendCollisionSound(soundID, 1.0, position); } } /* diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5874d34..b5705b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2632,7 +2632,6 @@ namespace OpenSim.Region.Framework.Scenes else { - // calculate things that started colliding this time // and build up list of colliders this time foreach (uint localid in collissionswith.Keys) @@ -2657,22 +2656,13 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint localID in endedColliders) m_lastColliders.Remove(localID); } + // play the sound. bool IsNotVolumeDtc = !VolumeDetectActive; if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) - { - if (CollisionSound != UUID.Zero) - { - if (CollisionSoundVolume > 0.0f) - SendCollisionSound(CollisionSound, CollisionSoundVolume); - } - else - { - CollisionSounds.PartCollisionSound(this, startedColliders); - } - } + CollisionSounds.PartCollisionSound(this, startedColliders); SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); if (IsNotVolumeDtc) @@ -3206,12 +3196,11 @@ namespace OpenSim.Region.Framework.Scenes } } - public void SendCollisionSound(UUID soundID, double volume) + public void SendCollisionSound(UUID soundID, double volume, Vector3 position) { if (soundID == UUID.Zero) return; - ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); if (soundModule == null) return; @@ -3230,10 +3219,9 @@ namespace OpenSim.Region.Framework.Scenes UUID ownerID = OwnerID; UUID objectID = ParentGroup.RootPart.UUID; UUID parentID = ParentGroup.UUID; - Vector3 position = AbsolutePosition; // region local ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0); + soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); } -- cgit v1.1 From 511fc663a24db9d042d0c5a97820870bbff6c085 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 17 May 2012 21:36:27 +0200 Subject: Temprorarily disable collision sounds until we have some sound bites --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 5d43027..130eb20 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -127,6 +127,8 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part,List Colliders) { + return; + if(Colliders.Count == 0 || part == null) return; @@ -214,6 +216,8 @@ namespace OpenSim.Region.Framework.Scenes public static void AvatarCollisionSound(ScenePresence av, List Colliders) { + return; + if (Colliders.Count == 0 || av == null) return; @@ -268,4 +272,4 @@ namespace OpenSim.Region.Framework.Scenes } } -} \ No newline at end of file +} -- cgit v1.1 From 0d0c472181ef3d719388e9a9ff89680e763ff713 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 17 May 2012 23:15:07 +0100 Subject: removed redundant colision sounds. Temporary muted sounds ( returns at top of funtions ). --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 41 +++++++--------------- 1 file changed, 13 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 5d43027..4522f9e 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes private const int MaxMaterials = 7; // part part - private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -48,7 +48,6 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -56,44 +55,24 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_RubberStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_RubberMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_RubberGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_RubberWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_RubberFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_RubberPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); // terrain part @@ -117,16 +96,19 @@ namespace OpenSim.Region.Framework.Scenes public static UUID[] m_PartPart = { snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, - snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, - snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, - snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, - snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, - snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, - snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber + snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, + snd_StoneGlass, snd_MetalGlass, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, + snd_StoneWood, snd_MetalWood, snd_GlassWood, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, + snd_StoneFlesh, snd_MetalFlesh, snd_GlassFlesh, snd_WoodFlesh, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, + snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, + snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber }; public static void PartCollisionSound(SceneObjectPart part,List Colliders) { + // temporary mute sounds + return; + if(Colliders.Count == 0 || part == null) return; @@ -214,6 +196,9 @@ namespace OpenSim.Region.Framework.Scenes public static void AvatarCollisionSound(ScenePresence av, List Colliders) { + // temporary mute sounds + return; + if (Colliders.Count == 0 || av == null) return; -- cgit v1.1 From 98a2c7bfeec6eda7cffbe5c84083ef3a736e306d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 01:10:39 +0100 Subject: modulate collision sounds intensity with relative collision speed --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 74 ++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 127 +++++++++++++-------- 2 files changed, 120 insertions(+), 81 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 4522f9e..724ecb6 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -33,14 +33,24 @@ using OpenSim.Framework; namespace OpenSim.Region.Framework.Scenes { + public struct CollisionForSoundInfo + { + public uint colliderID; + public Vector3 position; + public float relativeVel; + } + public static class CollisionSounds { + + + // defines for cases // only know one UUID for now (woodflesh) private const int MaxMaterials = 7; // part part - private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -48,29 +58,29 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -107,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part,List Colliders) { // temporary mute sounds - return; +// return; if(Colliders.Count == 0 || part == null) return; @@ -178,28 +188,15 @@ namespace OpenSim.Region.Framework.Scenes } } } -/* avatars get notification let them trigger the sound - else if (!doneownsound) - { - ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); - if (av != null && (!av.IsChildAgent)) - { - index = thisMatScaled + 4; // flesh - soundID = m_PartPart[index]; - part.SendCollisionSound(soundID, 1.0); - doneownsound = true; - } - } - */ } } - public static void AvatarCollisionSound(ScenePresence av, List Colliders) + public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) { // temporary mute sounds - return; +// return; - if (Colliders.Count == 0 || av == null) + if (collidersinfolist.Count == 0 || av == null) return; UUID soundID; @@ -211,30 +208,43 @@ namespace OpenSim.Region.Framework.Scenes int index; // bool doneownsound = false; - Vector3 position = av.AbsolutePosition; + CollisionForSoundInfo colInfo; + uint id; + float volume; - foreach (uint Id in Colliders) + for(int i = 0; i< collidersinfolist.Count; i++) { - if (Id == 0) + colInfo = collidersinfolist[i]; + + volume = Math.Abs(colInfo.relativeVel); + if(volume < 0.2f) + continue; + + id = colInfo.colliderID; + + if (id == 0) // no terrain collision sounds for now { continue; } - SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); + SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); if (otherPart != null) { if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) continue; if (otherPart.CollisionSound != UUID.Zero) - otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); + otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); else { + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) otherMaterial = 3; index = thisMatScaled + otherMaterial; soundID = m_PartPart[index]; - otherPart.SendCollisionSound(soundID, 1.0, position); + otherPart.SendCollisionSound(soundID, volume, colInfo.position); } } /* diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebddf21..06dec8f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4112,71 +4112,100 @@ namespace OpenSim.Region.Framework.Scenes List thisHitColliders = new List(); List endedColliders = new List(); List startedColliders = new List(); + List soundinfolist = new List(); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; - foreach (uint localid in coldata.Keys) + if (coldata.Count == 0) { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) + if (m_lastColliders.Count == 0) + return; // nothing to do + + foreach (uint localID in m_lastColliders) { endedColliders.Add(localID); } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); + m_lastColliders.Clear(); } - // do event notification - if (startedColliders.Count > 0) + else { - CollisionSounds.AvatarCollisionSound(this, startedColliders); - - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) + foreach (uint id in coldata.Keys) { - if (localId == 0) - continue; + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + { + startedColliders.Add(id); + curcontact = coldata[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + { + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); + } + } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); + endedColliders.Add(localID); } } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } - if (colliding.Count > 0) + if (soundinfolist.Count > 0) + CollisionSounds.AvatarCollisionSound(this, soundinfolist); + + // do event notification + if (startedColliders.Count > 0) { - StartCollidingMessage.Colliders = colliding; - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in GetAttachments()) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } } } -- cgit v1.1 From 9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 02:04:10 +0100 Subject: modulate collision sound intensity with collision relative velocity for parts also --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 90 ++++++++++++++-------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 45 +++++++---- 2 files changed, 89 insertions(+), 46 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 724ecb6..1f43843 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -114,12 +114,9 @@ namespace OpenSim.Region.Framework.Scenes snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber }; - public static void PartCollisionSound(SceneObjectPart part,List Colliders) + public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { - // temporary mute sounds -// return; - - if(Colliders.Count == 0 || part == null) + if (collidersinfolist.Count == 0 || part == null) return; if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) @@ -128,19 +125,20 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentGroup == null) return; - if (part.CollisionSound == part.invalidCollisionSoundUUID) + UUID soundID = part.CollisionSound; + if (soundID == part.invalidCollisionSoundUUID) return; - UUID soundID; + float volume = 0.0f; int otherMaterial; + bool HaveSound = false; - Vector3 position = part.AbsolutePosition; - - if (part.CollisionSound != UUID.Zero) + if (soundID != UUID.Zero) { - if (part.CollisionSoundVolume > 0.0f) - part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position); - return; + volume = part.CollisionSoundVolume; + if (volume == 0.0f) + return; + HaveSound = true; } int thisMaterial = (int) part.Material; @@ -152,41 +150,73 @@ namespace OpenSim.Region.Framework.Scenes bool doneownsound = false; - foreach (uint Id in Colliders) + CollisionForSoundInfo colInfo; + uint id; + + for(int i = 0; i< collidersinfolist.Count; i++) { - if (Id == 0) + colInfo = collidersinfolist[i]; + + if (!HaveSound) + { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + } + + id = colInfo.colliderID; + if (id == 0) { if (!doneownsound) { - soundID = m_TerrainPart[thisMaterial]; - part.SendCollisionSound(soundID, 1.0, position); + if (!HaveSound) + { + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; + soundID = m_TerrainPart[thisMaterial]; + } + part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } continue; } - SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); + SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); if (otherPart != null) { if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) continue; - if (otherPart.CollisionSound != UUID.Zero) - otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); - else + + if (!HaveSound) { - otherMaterial = (int)otherPart.Material; - if (otherMaterial >= MaxMaterials) - otherMaterial = 3; - index = thisMatScaled + otherMaterial; - soundID = m_PartPart[index]; - if (doneownsound) - otherPart.SendCollisionSound(soundID, 1.0, position); + if (otherPart.CollisionSound != UUID.Zero) + { + soundID = otherPart.CollisionSound; + volume = otherPart.CollisionSoundVolume; + if (volume == 0.0f) + continue; + } else { - part.SendCollisionSound(soundID, 1.0, position); - doneownsound = true; + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; + otherMaterial = (int)otherPart.Material; + if (otherMaterial >= MaxMaterials) + otherMaterial = 3; + index = thisMatScaled + otherMaterial; + soundID = m_PartPart[index]; } } + + if (doneownsound) + otherPart.SendCollisionSound(soundID, volume, colInfo.position); + else + { + part.SendCollisionSound(soundID, volume, colInfo.position); + doneownsound = true; + } } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b5705b7..467b625 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -333,7 +333,7 @@ namespace OpenSim.Region.Framework.Scenes private UUID m_collisionSound; private float m_collisionSoundVolume; - private DateTime LastColSoundSentTime; + private int LastColSoundSentTime; private SOPVehicle m_vehicle = null; @@ -374,7 +374,7 @@ namespace OpenSim.Region.Framework.Scenes // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log m_inventory = new SceneObjectPartInventory(this); - LastColSoundSentTime = DateTime.UtcNow; + LastColSoundSentTime = Util.EnvironmentTickCount(); } /// @@ -2632,13 +2632,29 @@ namespace OpenSim.Region.Framework.Scenes else { + List soundinfolist = new List(); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; + // calculate things that started colliding this time // and build up list of colliders this time - foreach (uint localid in collissionswith.Keys) + foreach (uint id in collissionswith.Keys) { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - startedColliders.Add(localid); + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + { + startedColliders.Add(id); + + curcontact = collissionswith[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + { + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); + } + } } // calculate things that ended colliding @@ -2655,17 +2671,14 @@ namespace OpenSim.Region.Framework.Scenes // remove things that ended colliding from the last colliders list foreach (uint localID in endedColliders) m_lastColliders.Remove(localID); - } - - // play the sound. - bool IsNotVolumeDtc = !VolumeDetectActive; - - if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) - CollisionSounds.PartCollisionSound(this, startedColliders); + // play sounds. + if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) + CollisionSounds.PartCollisionSound(this, soundinfolist); + } SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); - if (IsNotVolumeDtc) + if (!VolumeDetectActive) SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); @@ -3210,8 +3223,8 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - DateTime now = DateTime.UtcNow; - if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? + int now = Util.EnvironmentTickCount(); + if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) return; LastColSoundSentTime = now; -- cgit v1.1 From d69f197a5d8946c576b5e799f04f209400e2e227 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 May 2012 12:35:07 +0200 Subject: Fix setting positions of attachments. The recent security fix regarding prim entry messed it up. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a6551c1..7568888 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3741,7 +3741,7 @@ namespace OpenSim.Region.Framework.Scenes } if ((change & ObjectChangeType.Position) != 0) { - if (m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) + if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) UpdateGroupPosition(data.position); updateType = updatetype.groupterse; } -- cgit v1.1 From a2c64d9795b82e02d8f75976da9cbb9749f69627 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 12:25:31 +0100 Subject: temp work: sounds simetric acording to materials, still 'window close' test sound. Included in coment full assimetric ( since seems we have files for it now ) case with some uuids --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 128 ++++++++++++++++----- 1 file changed, 98 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 1f43843..c593b63 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -42,34 +42,94 @@ namespace OpenSim.Region.Framework.Scenes public static class CollisionSounds { - - - - // defines for cases - // only know one UUID for now (woodflesh) - private const int MaxMaterials = 7; // part part +/* + private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66"); + private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66"); + private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66"); + private static UUID snd_StoneWood = new UUID("be7295c0-a158-11e1-b3dd-0800203c9a66"); + private static UUID snd_StoneFlesh = new UUID("be7295c0-a158-11e1-b3dd-0800204c9a66"); + private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66"); + private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66"); + + private static UUID snd_MetalStone = new UUID("be7295c0-a158-11e1-b3dd-0801200c9a66"); + private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66"); + private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66"); + private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66"); + private static UUID snd_MetalFlesh = new UUID("be7295c0-a158-11e1-b3dd-0801204c9a66"); + private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66"); + private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66"); + + private static UUID snd_GlassStone = new UUID("be7295c0-a158-11e1-b3dd-0802200c9a66"); + private static UUID snd_GlassMetal = new UUID("be7295c0-a158-11e1-b3dd-0802201c9a66"); + private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66"); + private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66"); + private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66"); + private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66"); + private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66"); + + private static UUID snd_WoodStone = new UUID("be7295c0-a158-11e1-b3dd-0803200c9a66"); + private static UUID snd_WoodMetal = new UUID("be7295c0-a158-11e1-b3dd-0803201c9a66"); + private static UUID snd_WoodGlass = new UUID("be7295c0-a158-11e1-b3dd-0803202c9a66"); + private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66"); + private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66"); + private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66"); + private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66"); + + private static UUID snd_FleshStone = new UUID("be7295c0-a158-11e1-b3dd-0804200c9a66"); + private static UUID snd_FleshMetal = new UUID("be7295c0-a158-11e1-b3dd-0804201c9a66"); + private static UUID snd_FleshGlass = new UUID("be7295c0-a158-11e1-b3dd-0804202c9a66"); + private static UUID snd_FleshWood = new UUID("be7295c0-a158-11e1-b3dd-0804203c9a66"); + private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66"); + private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66"); + private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66"); + + private static UUID snd_PlasticStone = new UUID("be7295c0-a158-11e1-b3dd-0805200c9a66"); + private static UUID snd_PlasticMetal = new UUID("be7295c0-a158-11e1-b3dd-0805201c9a66"); + private static UUID snd_PlasticGlass = new UUID("be7295c0-a158-11e1-b3dd-0805202c9a66"); + private static UUID snd_PlasticWood = new UUID("be7295c0-a158-11e1-b3dd-0805203c9a66"); + private static UUID snd_PlasticFlesh = new UUID("be7295c0-a158-11e1-b3dd-0805204c9a66"); + private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66"); + private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66"); + + private static UUID snd_RubberStone = new UUID("be7295c0-a158-11e1-b3dd-0806200c9a66"); + private static UUID snd_RubberMetal = new UUID("be7295c0-a158-11e1-b3dd-0806201c9a66"); + private static UUID snd_RubberGlass = new UUID("be7295c0-a158-11e1-b3dd-0806202c9a66"); + private static UUID snd_RubberWood = new UUID("be7295c0-a158-11e1-b3dd-0806203c9a66"); + private static UUID snd_RubberFlesh = new UUID("be7295c0-a158-11e1-b3dd-0806204c9a66"); + private static UUID snd_RubberPlastic = new UUID("be7295c0-a158-11e1-b3dd-0806205c9a66"); + private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66"); + + // terrain part + private static UUID snd_TerrainStone = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainMetal = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainGlass = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainWood = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); +*/ private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -77,11 +137,11 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -103,7 +163,19 @@ namespace OpenSim.Region.Framework.Scenes snd_TerrainPlastic, snd_TerrainRubber }; - +/* + //full assimetric sounds + public static UUID[] m_PartPart = { + snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, + snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, + snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, + snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, + snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, + snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, + snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber + }; +*/ + // simetric sounds public static UUID[] m_PartPart = { snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, @@ -113,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber }; - + public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { if (collidersinfolist.Count == 0 || part == null) @@ -223,9 +295,6 @@ namespace OpenSim.Region.Framework.Scenes public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) { - // temporary mute sounds -// return; - if (collidersinfolist.Count == 0 || av == null) return; @@ -291,6 +360,5 @@ namespace OpenSim.Region.Framework.Scenes */ } } - } } \ No newline at end of file -- cgit v1.1 From 2c498baf58005be487b4e457455a9896a96b90d3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 13:53:49 +0100 Subject: a bit faster collision sound type verification plus a few fixes/changes --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 73 +++++++++++--------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 80 ++++++++++++++++------ 2 files changed, 100 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index c593b63..476eccd 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -197,30 +197,29 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentGroup == null) return; - UUID soundID = part.CollisionSound; - if (soundID == part.invalidCollisionSoundUUID) + if (part.CollisionSoundType < 0) return; float volume = 0.0f; - int otherMaterial; bool HaveSound = false; - if (soundID != UUID.Zero) + UUID soundID = part.CollisionSound; + + if (part.CollisionSoundType > 0) { + // soundID = part.CollisionSound; volume = part.CollisionSoundVolume; if (volume == 0.0f) return; HaveSound = true; } - int thisMaterial = (int) part.Material; + bool doneownsound = false; + + int thisMaterial = (int)part.Material; if (thisMaterial >= MaxMaterials) thisMaterial = 3; - int thisMatScaled = thisMaterial * MaxMaterials; - int index; - - bool doneownsound = false; CollisionForSoundInfo colInfo; uint id; @@ -229,23 +228,21 @@ namespace OpenSim.Region.Framework.Scenes { colInfo = collidersinfolist[i]; - if (!HaveSound) - { - volume = Math.Abs(colInfo.relativeVel); - if (volume < 0.2f) - continue; - } - id = colInfo.colliderID; - if (id == 0) + if (id == 0) // terrain collision { if (!doneownsound) { if (!HaveSound) { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) volume = 1.0f; + soundID = m_TerrainPart[thisMaterial]; } part.SendCollisionSound(soundID, volume, colInfo.position); @@ -257,12 +254,12 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); if (otherPart != null) { - if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) + if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) continue; if (!HaveSound) { - if (otherPart.CollisionSound != UUID.Zero) + if (otherPart.CollisionSoundType > 0) { soundID = otherPart.CollisionSound; volume = otherPart.CollisionSoundVolume; @@ -271,14 +268,19 @@ namespace OpenSim.Region.Framework.Scenes } else { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) volume = 1.0f; - otherMaterial = (int)otherPart.Material; + + int otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) otherMaterial = 3; - index = thisMatScaled + otherMaterial; - soundID = m_PartPart[index]; + + soundID = m_PartPart[thisMatScaled + otherMaterial]; } } @@ -301,11 +303,11 @@ namespace OpenSim.Region.Framework.Scenes UUID soundID; int otherMaterial; - int thisMaterial = 3; + int thisMaterial = 4; // flesh int thisMatScaled = thisMaterial * MaxMaterials; - int index; -// bool doneownsound = false; + + // bool doneownsound = false; CollisionForSoundInfo colInfo; uint id; @@ -315,36 +317,41 @@ namespace OpenSim.Region.Framework.Scenes { colInfo = collidersinfolist[i]; - volume = Math.Abs(colInfo.relativeVel); - if(volume < 0.2f) - continue; - id = colInfo.colliderID; if (id == 0) // no terrain collision sounds for now { continue; +// volume = Math.Abs(colInfo.relativeVel); +// if (volume < 0.2f) +// continue; + } SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); if (otherPart != null) { - if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) + if (otherPart.CollisionSoundType < 0) continue; - if (otherPart.CollisionSound != UUID.Zero) + if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); else { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) volume = 1.0f; otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) otherMaterial = 3; - index = thisMatScaled + otherMaterial; - soundID = m_PartPart[index]; + + soundID = m_PartPart[thisMatScaled + otherMaterial]; otherPart.SendCollisionSound(soundID, volume, colInfo.position); } + continue; } /* else if (!doneownsound) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 467b625..5fddaed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -329,7 +329,9 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_cameraAtOffset; private bool m_forceMouselook; - // TODO: Collision sound should have default. + + // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound + private sbyte m_collisionSoundType; private UUID m_collisionSound; private float m_collisionSoundVolume; @@ -1342,12 +1344,39 @@ namespace OpenSim.Region.Framework.Scenes public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); + // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound + // runtime thing.. do not persist + [XmlIgnore] + public sbyte CollisionSoundType + { + get + { + return m_collisionSoundType; + } + set + { + m_collisionSoundType = value; + if (value == -1) + m_collisionSound = invalidCollisionSoundUUID; + else if (value == 0) + m_collisionSound = UUID.Zero; + } + } + public UUID CollisionSound { get { return m_collisionSound; } set { m_collisionSound = value; + + if (value == invalidCollisionSoundUUID) + m_collisionSoundType = -1; + else if (value == UUID.Zero) + m_collisionSoundType = 0; + else + m_collisionSoundType = 1; + aggregateScriptEvents(); } } @@ -2633,29 +2662,42 @@ namespace OpenSim.Region.Framework.Scenes else { List soundinfolist = new List(); - CollisionForSoundInfo soundinfo; - ContactPoint curcontact; // calculate things that started colliding this time // and build up list of colliders this time - foreach (uint id in collissionswith.Keys) + if (!VolumeDetectActive && CollisionSoundType >= 0) { - thisHitColliders.Add(id); - if (!m_lastColliders.Contains(id)) - { - startedColliders.Add(id); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; - curcontact = collissionswith[id]; - if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + foreach (uint id in collissionswith.Keys) + { + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) { - soundinfo = new CollisionForSoundInfo(); - soundinfo.colliderID = id; - soundinfo.position = curcontact.Position; - soundinfo.relativeVel = curcontact.RelativeSpeed; - soundinfolist.Add(soundinfo); + startedColliders.Add(id); + + curcontact = collissionswith[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + { + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); + } } } } + else + { + foreach (uint id in collissionswith.Keys) + { + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + startedColliders.Add(id); + } + } // calculate things that ended colliding foreach (uint localID in m_lastColliders) @@ -2673,7 +2715,7 @@ namespace OpenSim.Region.Framework.Scenes m_lastColliders.Remove(localID); // play sounds. - if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) + if (soundinfolist.Count > 0) CollisionSounds.PartCollisionSound(this, soundinfolist); } @@ -4791,7 +4833,8 @@ namespace OpenSim.Region.Framework.Scenes pa.OnCollisionUpdate -= PhysicsCollision; - bool hassound = ( CollisionSound != invalidCollisionSoundUUID); + bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); + scriptEvents CombinedEvents = AggregateScriptEvents; // merge with root part @@ -4800,10 +4843,7 @@ namespace OpenSim.Region.Framework.Scenes // submit to this part case if (VolumeDetectActive) - { CombinedEvents &= PhyscicsVolumeDtcSubsEvents; - hassound = false; - } else if ((Flags & PrimFlags.Phantom) != 0) CombinedEvents &= PhyscicsPhantonSubsEvents; else -- cgit v1.1 From 10889c86d9d67ca994a090166ad53840ed1dedd0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 16:35:48 +0100 Subject: reduce useless waste of cpu. Make character collision events be done similiar to parts. Let same thread do it all ( like in parts ) ( to change this some structs copies must be added) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 06dec8f..be94508 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4098,6 +4098,7 @@ namespace OpenSim.Region.Framework.Scenes private void RaiseCollisionScriptEvents(Dictionary coldata) { + /* lock(m_collisionEventLock) { if (m_collisionEventFlag) @@ -4107,6 +4108,7 @@ namespace OpenSim.Region.Framework.Scenes Util.FireAndForget(delegate(object x) { + */ try { List thisHitColliders = new List(); @@ -4286,7 +4288,7 @@ namespace OpenSim.Region.Framework.Scenes { m_collisionEventFlag = false; } - }); +// }); } private void TeleportFlagsDebug() { -- cgit v1.1 From 2767574d0f17c0bb43c0322505e07d58c60f2f06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 18:10:44 +0100 Subject: fix m_sitAvatarHeight to be half size.z, reduced default to a more resonable value ( 1m); --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index be94508..5a3b518 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2032,7 +2032,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); if (PhysicsActor != null) - m_sitAvatarHeight = PhysicsActor.Size.Z; + m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; bool canSit = false; pos = part.AbsolutePosition + offset; -- cgit v1.1 From 32e63fc04fcf08163289c108b278c990208568d5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 May 2012 17:30:01 +0100 Subject: missing update script events call --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5fddaed..2852c4b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1604,7 +1604,10 @@ namespace OpenSim.Region.Framework.Scenes } } else if (PhysActor == null) + { ApplyPhysics((uint)Flags, VolumeDetectActive, false); + UpdatePhysicsSubscribedEvents(); + } else { PhysActor.PhysicsShapeType = m_physicsShapeType; @@ -4664,7 +4667,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveFromPhysics() { - ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); + PhysicsActor pa = PhysActor; + if (pa != null) + { + pa.OnCollisionUpdate -= PhysicsCollision; + pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; + pa.OnOutOfBounds -= PhysicsOutOfBounds; + + ParentGroup.Scene.PhysicsScene.RemovePrim(pa); + } PhysActor = null; } -- cgit v1.1 From bbaf450c30a0822c8ffcc40bf75961f2c3c214e4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 May 2012 02:14:14 +0200 Subject: Modify SceneManeger to use a DoubleDictionary and work without locks. Changes to the scenes dictionary are exceedingly rare and using atomic operations makes the chance of collisions nearly nil in any case. --- OpenSim/Region/Framework/Scenes/SceneManager.cs | 266 ++++++++---------------- 1 file changed, 90 insertions(+), 176 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index e4eaf3a..e3fed49 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -53,12 +53,12 @@ namespace OpenSim.Region.Framework.Scenes get { return m_instance; } } - private readonly List m_localScenes = new List(); + private readonly DoubleDictionary m_localScenes = new DoubleDictionary(); private Scene m_currentScene = null; public List Scenes { - get { return new List(m_localScenes); } + get { return new List(m_localScenes.FindAll(delegate(Scene s) { return true; })); } } public Scene CurrentScene @@ -72,13 +72,10 @@ namespace OpenSim.Region.Framework.Scenes { if (m_currentScene == null) { - lock (m_localScenes) - { - if (m_localScenes.Count > 0) - return m_localScenes[0]; - else - return null; - } + List sceneList = Scenes; + if (sceneList.Count == 0) + return null; + return sceneList[0]; } else { @@ -90,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes public SceneManager() { m_instance = this; - m_localScenes = new List(); + m_localScenes = new DoubleDictionary(); } public void Close() @@ -98,20 +95,18 @@ namespace OpenSim.Region.Framework.Scenes // collect known shared modules in sharedModules Dictionary sharedModules = new Dictionary(); - lock (m_localScenes) + List sceneList = Scenes; + for (int i = 0; i < sceneList.Count; i++) { - for (int i = 0; i < m_localScenes.Count; i++) + // extract known shared modules from scene + foreach (string k in sceneList[i].Modules.Keys) { - // extract known shared modules from scene - foreach (string k in m_localScenes[i].Modules.Keys) - { - if (m_localScenes[i].Modules[k].IsSharedModule && - !sharedModules.ContainsKey(k)) - sharedModules[k] = m_localScenes[i].Modules[k]; - } - // close scene/region - m_localScenes[i].Close(); + if (sceneList[i].Modules[k].IsSharedModule && + !sharedModules.ContainsKey(k)) + sharedModules[k] = sceneList[i].Modules[k]; } + // close scene/region + sceneList[i].Close(); } // all regions/scenes are now closed, we can now safely @@ -120,31 +115,22 @@ namespace OpenSim.Region.Framework.Scenes { mod.Close(); } + + m_localScenes.Clear(); } public void Close(Scene cscene) { - lock (m_localScenes) - { - if (m_localScenes.Contains(cscene)) - { - for (int i = 0; i < m_localScenes.Count; i++) - { - if (m_localScenes[i].Equals(cscene)) - { - m_localScenes[i].Close(); - } - } - } - } + if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID)) + return; + cscene.Close(); } public void Add(Scene scene) { scene.OnRestart += HandleRestart; - lock (m_localScenes) - m_localScenes.Add(scene); + m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); } public void HandleRestart(RegionInfo rdata) @@ -152,24 +138,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); int RegionSceneElement = -1; - lock (m_localScenes) - { - for (int i = 0; i < m_localScenes.Count; i++) - { - if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) - { - RegionSceneElement = i; - } - } - - // Now we make sure the region is no longer known about by the SceneManager - // Prevents duplicates. - - if (RegionSceneElement >= 0) - { - m_localScenes.RemoveAt(RegionSceneElement); - } - } + m_localScenes.Remove(rdata.RegionID); // Send signal to main that we're restarting this sim. OnRestartSim(rdata); @@ -179,32 +148,29 @@ namespace OpenSim.Region.Framework.Scenes { RegionInfo Result = null; - lock (m_localScenes) - { - for (int i = 0; i < m_localScenes.Count; i++) - { - if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) + Scene s = m_localScenes.FindValue(delegate(Scene x) { - // Inform other regions to tell their avatar about me - Result = m_localScenes[i].RegionInfo; - } - } + if (x.RegionInfo.RegionHandle == regionHandle) + return true; + return false; + }); - if (Result != null) + if (s != null) + { + List sceneList = Scenes; + + for (int i = 0; i < sceneList.Count; i++) { - for (int i = 0; i < m_localScenes.Count; i++) + if (sceneList[i]!= s) { - if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) - { - // Inform other regions to tell their avatar about me - //m_localScenes[i].OtherRegionUp(Result); - } + // Inform other regions to tell their avatar about me + //sceneList[i].OtherRegionUp(Result); } } - else - { - m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); - } + } + else + { + m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); } } @@ -308,8 +274,8 @@ namespace OpenSim.Region.Framework.Scenes { if (m_currentScene == null) { - lock (m_localScenes) - m_localScenes.ForEach(func); + List sceneList = Scenes; + sceneList.ForEach(func); } else { @@ -338,16 +304,12 @@ namespace OpenSim.Region.Framework.Scenes } else { - lock (m_localScenes) + Scene s; + + if (m_localScenes.TryGetValue(regionName, out s)) { - foreach (Scene scene in m_localScenes) - { - if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) - { - m_currentScene = scene; - return true; - } - } + m_currentScene = s; + return true; } return false; @@ -358,16 +320,12 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.Debug("Searching for Region: '" + regionID + "'"); - lock (m_localScenes) + Scene s; + + if (m_localScenes.TryGetValue(regionID, out s)) { - foreach (Scene scene in m_localScenes) - { - if (scene.RegionInfo.RegionID == regionID) - { - m_currentScene = scene; - return true; - } - } + m_currentScene = s; + return true; } return false; @@ -375,52 +333,24 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetScene(string regionName, out Scene scene) { - lock (m_localScenes) - { - foreach (Scene mscene in m_localScenes) - { - if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) - { - scene = mscene; - return true; - } - } - } - - scene = null; - return false; + return m_localScenes.TryGetValue(regionName, out scene); } public bool TryGetScene(UUID regionID, out Scene scene) { - lock (m_localScenes) - { - foreach (Scene mscene in m_localScenes) - { - if (mscene.RegionInfo.RegionID == regionID) - { - scene = mscene; - return true; - } - } - } - - scene = null; - return false; + return m_localScenes.TryGetValue(regionID, out scene); } public bool TryGetScene(uint locX, uint locY, out Scene scene) { - lock (m_localScenes) + List sceneList = Scenes; + foreach (Scene mscene in sceneList) { - foreach (Scene mscene in m_localScenes) + if (mscene.RegionInfo.RegionLocX == locX && + mscene.RegionInfo.RegionLocY == locY) { - if (mscene.RegionInfo.RegionLocX == locX && - mscene.RegionInfo.RegionLocY == locY) - { - scene = mscene; - return true; - } + scene = mscene; + return true; } } @@ -430,16 +360,14 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) { - lock (m_localScenes) + List sceneList = Scenes; + foreach (Scene mscene in sceneList) { - foreach (Scene mscene in m_localScenes) + if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && + (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) { - if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && - (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) - { - scene = mscene; - return true; - } + scene = mscene; + return true; } } @@ -504,15 +432,10 @@ namespace OpenSim.Region.Framework.Scenes public RegionInfo GetRegionInfo(UUID regionID) { - lock (m_localScenes) + Scene s; + if (m_localScenes.TryGetValue(regionID, out s)) { - foreach (Scene scene in m_localScenes) - { - if (scene.RegionInfo.RegionID == regionID) - { - return scene.RegionInfo; - } - } + return s.RegionInfo; } return null; @@ -530,14 +453,12 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) { - lock (m_localScenes) + List sceneList = Scenes; + foreach (Scene scene in sceneList) { - foreach (Scene scene in m_localScenes) + if (scene.TryGetScenePresence(avatarId, out avatar)) { - if (scene.TryGetScenePresence(avatarId, out avatar)) - { - return true; - } + return true; } } @@ -547,15 +468,13 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) { - lock (m_localScenes) + List sceneList = Scenes; + foreach (Scene scene in sceneList) { - foreach (Scene scene in m_localScenes) - { - avatar = scene.GetScenePresence(avatarId); + avatar = scene.GetScenePresence(avatarId); - if (avatar != null && !avatar.IsChildAgent) - return true; - } + if (avatar != null && !avatar.IsChildAgent) + return true; } avatar = null; @@ -564,22 +483,19 @@ namespace OpenSim.Region.Framework.Scenes public void CloseScene(Scene scene) { - lock (m_localScenes) - m_localScenes.Remove(scene); + m_localScenes.Remove(scene.RegionInfo.RegionID); scene.Close(); } public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) { - lock (m_localScenes) + List sceneList = Scenes; + foreach (Scene scene in sceneList) { - foreach (Scene scene in m_localScenes) + if (scene.TryGetAvatarByName(avatarName, out avatar)) { - if (scene.TryGetAvatarByName(avatarName, out avatar)) - { - return true; - } + return true; } } @@ -589,14 +505,12 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) { - lock (m_localScenes) + List sceneList = Scenes; + foreach (Scene scene in sceneList) { - foreach (Scene scene in m_localScenes) - { - sp = scene.GetScenePresence(firstName, lastName); - if (sp != null && !sp.IsChildAgent) - return true; - } + sp = scene.GetScenePresence(firstName, lastName); + if (sp != null && !sp.IsChildAgent) + return true; } sp = null; @@ -605,8 +519,8 @@ namespace OpenSim.Region.Framework.Scenes public void ForEachScene(Action action) { - lock (m_localScenes) - m_localScenes.ForEach(action); + List sceneList = Scenes; + sceneList.ForEach(action); } } } -- cgit v1.1 From b70fb7df789ba40b520b8bf0794b32c8099ef202 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 May 2012 11:28:46 +0200 Subject: Place the return back into collision sounds. --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 81ca9f1..a02f108 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -188,6 +188,8 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { + return; + if (collidersinfolist.Count == 0 || part == null) return; @@ -297,6 +299,8 @@ namespace OpenSim.Region.Framework.Scenes public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) { + return; + if (collidersinfolist.Count == 0 || av == null) return; -- cgit v1.1 From 121433d03aad53bfa8d50854115c0496317b00eb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 28 May 2012 13:10:02 +0100 Subject: disable collision sounds for now --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 81ca9f1..de82ddc 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -188,6 +188,9 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { + // disable for now + return; + if (collidersinfolist.Count == 0 || part == null) return; @@ -296,7 +299,10 @@ namespace OpenSim.Region.Framework.Scenes } public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) - { + { + // disable for now + return; + if (collidersinfolist.Count == 0 || av == null) return; @@ -368,4 +374,4 @@ namespace OpenSim.Region.Framework.Scenes } } } -} +} \ No newline at end of file -- cgit v1.1 From 10e9ad0086056f4afde081d629eca7cc6520a1ba Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 May 2012 16:56:04 +0200 Subject: Fix collision filtering --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2852c4b..a57e9bc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2495,21 +2495,21 @@ namespace OpenSim.Region.Framework.Scenes { } - private bool CollisionFilteredOut(SceneObjectPart dest, UUID objectID, string objectName) + public bool CollisionFilteredOut(UUID objectID, string objectName) { - if(dest.CollisionFilter.Count == 0) + if(CollisionFilter.Count == 0) return false; - if (dest.CollisionFilter.ContainsValue(objectID.ToString()) || - dest.CollisionFilter.ContainsValue(objectID.ToString() + objectName) || - dest.CollisionFilter.ContainsValue(UUID.Zero.ToString() + objectName)) + if (CollisionFilter.ContainsValue(objectID.ToString()) || + CollisionFilter.ContainsValue(objectID.ToString() + objectName) || + CollisionFilter.ContainsValue(UUID.Zero.ToString() + objectName)) { - if (dest.CollisionFilter.ContainsKey(1)) + if (CollisionFilter.ContainsKey(1)) return false; return true; } - if (dest.CollisionFilter.ContainsKey(1)) + if (CollisionFilter.ContainsKey(1)) return true; return false; @@ -2572,7 +2572,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); if (obj != null) { - if (!dest.CollisionFilteredOut(this, obj.UUID, obj.Name)) + if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) colliding.Add(CreateDetObject(obj)); } else @@ -2580,7 +2580,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); if (av != null && (!av.IsChildAgent)) { - if (!dest.CollisionFilteredOut(this, av.UUID, av.Name)) + if (!dest.CollisionFilteredOut(av.UUID, av.Name)) colliding.Add(CreateDetObject(av)); } } @@ -2724,7 +2724,7 @@ namespace OpenSim.Region.Framework.Scenes SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); if (!VolumeDetectActive) - SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); + SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); if (startedColliders.Contains(0)) -- cgit v1.1 From c46b31a9b4cc8a1a731b0e109cd2ebd52c1425d6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 May 2012 16:58:08 +0200 Subject: Re-add script collisions that were lost in a merge --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 225d4c9..1adf13e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3513,6 +3513,8 @@ namespace OpenSim.Region.Framework.Scenes } } + RaiseCollisionScriptEvents(coldata); + // Gods do not take damage and Invulnerable is set depending on parcel/region flags if (Invulnerable || GodLevel > 0) return; -- cgit v1.1 From 100d2968c4ebe3f544e770ef66826d7036d4ed77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 May 2012 17:24:17 +0200 Subject: Add advanced collision processing into ScenePresence --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 324 +++++++++++------------ 1 file changed, 162 insertions(+), 162 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5a3b518..e2f32dd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3499,7 +3499,7 @@ namespace OpenSim.Region.Framework.Scenes RaiseCollisionScriptEvents(coldata); - if (Invulnerable) + if (Invulnerable || GodLevel >= 200) return; float starthealth = Health; @@ -4096,199 +4096,199 @@ namespace OpenSim.Region.Framework.Scenes } } - private void RaiseCollisionScriptEvents(Dictionary coldata) + private DetectedObject CreateDetObject(SceneObjectPart obj) { - /* - lock(m_collisionEventLock) - { - if (m_collisionEventFlag) - return; - m_collisionEventFlag = true; - } + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; - Util.FireAndForget(delegate(object x) + return detobj; + } + + private DetectedObject CreateDetObject(ScenePresence av) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.ControllingClient.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; + + return detobj; + } + + private DetectedObject CreateDetObjectForGround() + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = UUID.Zero; + detobj.nameStr = ""; + detobj.ownerUUID = UUID.Zero; + detobj.posVector = AbsolutePosition; + detobj.rotQuat = Quaternion.Identity; + detobj.velVector = Vector3.Zero; + detobj.colliderType = 0; + detobj.groupUUID = UUID.Zero; + + return detobj; + } + + private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List colliders) + { + ColliderArgs colliderArgs = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in colliders) { - */ - try + if (localId == 0) + continue; + + SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); + if (obj != null) { - List thisHitColliders = new List(); - List endedColliders = new List(); - List startedColliders = new List(); - List soundinfolist = new List(); - CollisionForSoundInfo soundinfo; - ContactPoint curcontact; - - if (coldata.Count == 0) + if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) + colliding.Add(CreateDetObject(obj)); + } + else + { + ScenePresence av = m_scene.GetScenePresence(localId); + if (av != null && (!av.IsChildAgent)) { - if (m_lastColliders.Count == 0) - return; // nothing to do - - foreach (uint localID in m_lastColliders) - { - endedColliders.Add(localID); - } - m_lastColliders.Clear(); + if (!dest.CollisionFilteredOut(av.UUID, av.Name)) + colliding.Add(CreateDetObject(av)); } + } + } - else - { - foreach (uint id in coldata.Keys) - { - thisHitColliders.Add(id); - if (!m_lastColliders.Contains(id)) - { - startedColliders.Add(id); - curcontact = coldata[id]; - if (Math.Abs(curcontact.RelativeSpeed) > 0.2) - { - soundinfo = new CollisionForSoundInfo(); - soundinfo.colliderID = id; - soundinfo.position = curcontact.Position; - soundinfo.relativeVel = curcontact.RelativeSpeed; - soundinfolist.Add(soundinfo); - } - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } + colliderArgs.Colliders = colliding; - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) - { - endedColliders.Add(localID); - } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); - } + return colliderArgs; + } - if (soundinfolist.Count > 0) - CollisionSounds.AvatarCollisionSound(this, soundinfolist); + private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); - // do event notification - if (startedColliders.Count > 0) - { + private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List colliders, ScriptCollidingNotification notify) + { + ColliderArgs CollidingMessage; - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) - { - if (localId == 0) - continue; + if (colliders.Count > 0) + { + if ((dest.RootPart.ScriptEvents & ev) != 0) + { + CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } + if (CollidingMessage.Colliders.Count > 0) + notify(dest.RootPart.LocalId, CollidingMessage); + } + } + } - if (colliding.Count > 0) - { - StartCollidingMessage.Colliders = colliding; + private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) + { + if ((dest.RootPart.ScriptEvents & ev) != 0) + { + ColliderArgs LandCollidingMessage = new ColliderArgs(); + List colliding = new List(); - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); - } - } - } + colliding.Add(CreateDetObjectForGround()); + LandCollidingMessage.Colliders = colliding; - if (endedColliders.Count > 0) - { - ColliderArgs EndCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in endedColliders) - { - if (localId == 0) - continue; + notify(dest.RootPart.LocalId, LandCollidingMessage); + } + } - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - } + private void RaiseCollisionScriptEvents(Dictionary coldata) + { + try + { + List thisHitColliders = new List(); + List endedColliders = new List(); + List startedColliders = new List(); + List soundinfolist = new List(); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; - if (colliding.Count > 0) - { - EndCollidingMessage.Colliders = colliding; + if (coldata.Count == 0) + { + if (m_lastColliders.Count == 0) + return; // nothing to do - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); - } + foreach (uint localID in m_lastColliders) + { + endedColliders.Add(localID); } + m_lastColliders.Clear(); + } - if (thisHitColliders.Count > 0) + else + { + foreach (uint id in coldata.Keys) { - ColliderArgs CollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in thisHitColliders) + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) + startedColliders.Add(id); + curcontact = coldata[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); } } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + } - if (colliding.Count > 0) + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) { - CollidingMessage.Colliders = colliding; - - lock (m_attachments) - { - foreach (SceneObjectGroup att in m_attachments) - Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); - } + endedColliders.Add(localID); } } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } + + if (soundinfolist.Count > 0) + CollisionSounds.AvatarCollisionSound(this, soundinfolist); } - finally + + foreach (SceneObjectGroup att in GetAttachments()) { - m_collisionEventFlag = false; + SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); + SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); + SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); + + if (startedColliders.Contains(0)) + SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); + if (m_lastColliders.Contains(0)) + SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); + if (endedColliders.Contains(0)) + SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); } -// }); + } + finally + { + m_collisionEventFlag = false; + } } private void TeleportFlagsDebug() { -- cgit v1.1 From 928e3e9e21f17ee6cfe8850a903acaad490719d1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 1 Jun 2012 23:04:28 +0200 Subject: Fix LSL animation state reporting and animation state transitions on crossing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e2f32dd..2b1fb3d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -867,7 +867,7 @@ namespace OpenSim.Region.Framework.Scenes IsChildAgent = false; - Animator.TrySetMovementAnimation("SIT"); +// Animator.TrySetMovementAnimation("SIT"); } else { -- cgit v1.1 From 28e5abd9176aeba3b5004d07748ae88cccbcd57a Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jun 2012 21:05:56 +0200 Subject: Fix llAttachToAvatar and "Attach" viewer option to preserve saved attach positions. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a9a4cda..6a120c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2692,7 +2692,7 @@ namespace OpenSim.Region.Framework.Scenes RootPrim.RemFlag(PrimFlags.TemporaryOnRez); if (AttachmentsModule != null) - AttachmentsModule.AttachObject(sp, grp, 0, false); + AttachmentsModule.AttachObject(sp, grp, 0, false, false); } else { -- cgit v1.1 From fd176aab8f97aaad037eefc1ae7dc5b9fb670a99 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jun 2012 22:41:29 +0200 Subject: Actually trigger land collisions in the root even when a child collides --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a57e9bc..5694c8c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2634,7 +2634,7 @@ namespace OpenSim.Region.Framework.Scenes colliding.Add(CreateDetObjectForGround()); LandCollidingMessage.Colliders = colliding; - notify(LocalId, LandCollidingMessage); + notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); } } -- cgit v1.1 From 170b820a114e5a53e70d7f1624109239b182ec9f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 5 Jun 2012 01:53:25 +0200 Subject: Fix land collisions to work like SL. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5694c8c..8e74dc8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2626,14 +2626,24 @@ namespace OpenSim.Region.Framework.Scenes private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) { - if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) + bool sendToRoot = true; + + ColliderArgs LandCollidingMessage = new ColliderArgs(); + List colliding = new List(); + + colliding.Add(CreateDetObjectForGround()); + LandCollidingMessage.Colliders = colliding; + + if (Inventory.ContainsScripts()) { - ColliderArgs LandCollidingMessage = new ColliderArgs(); - List colliding = new List(); - - colliding.Add(CreateDetObjectForGround()); - LandCollidingMessage.Colliders = colliding; + if (!PassCollisions) + sendToRoot = false; + } + if ((ScriptEvents & ev) != 0) + notify(LocalId, LandCollidingMessage); + if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) + { notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); } } -- cgit v1.1 From bdc62144ae19749751bd437c5bde12e2f453dfa5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 5 Jun 2012 05:53:44 +0100 Subject: fix the real cause of double velocity --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0d178c3..b7466be 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -352,7 +352,6 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null && pa.IsPhysical && vel != Vector3.Zero) { sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); - sceneObject.Velocity = vel; } return true; -- cgit v1.1 From 67483a6e50e491b65ce5fdbd36e06ba697772b36 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Jun 2012 20:36:47 +0200 Subject: Remove two causes of recursive locking. Merge artefact cleanup. --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f5b9825..81477e7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -176,16 +176,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void ChangeInventoryOwner(UUID ownerId) { - m_items.LockItemsForWrite(true); - if (0 == Items.Count) - { - m_items.LockItemsForWrite(false); + List items = GetInventoryItems(); + + if (items.Count == 0) return; - } + m_items.LockItemsForWrite(true); HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; - List items = GetInventoryItems(); foreach (TaskInventoryItem item in items) { if (ownerId != item.OwnerID) @@ -766,8 +764,8 @@ namespace OpenSim.Region.Framework.Scenes { if (item.Name == name) { - return item; m_items.LockItemsForRead(false); + return item; } } m_items.LockItemsForRead(false); -- cgit v1.1 From 64aefe9c28fd5ceb9c92b4069d7915d6b77356fa Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Jun 2012 17:59:38 +0200 Subject: Disable default collision sounds until they can be uploaded, but enable custom ones --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 111 +++++++++++---------- 1 file changed, 56 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index de82ddc..d72cf41 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -188,9 +188,6 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { - // disable for now - return; - if (collidersinfolist.Count == 0 || part == null) return; @@ -238,17 +235,19 @@ namespace OpenSim.Region.Framework.Scenes { if (!HaveSound) { - volume = Math.Abs(colInfo.relativeVel); - if (volume < 0.2f) - continue; - - volume *= volume * .0625f; // 4m/s == full volume - if (volume > 1.0f) - volume = 1.0f; - - soundID = m_TerrainPart[thisMaterial]; +// TODO: Import real collision sounds and uncomment this +// volume = Math.Abs(colInfo.relativeVel); +// if (volume < 0.2f) +// continue; +// +// volume *= volume * .0625f; // 4m/s == full volume +// if (volume > 1.0f) +// volume = 1.0f; +// +// soundID = m_TerrainPart[thisMaterial]; } - part.SendCollisionSound(soundID, volume, colInfo.position); + else // Remove this else when uncommenting the above + part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } continue; @@ -269,40 +268,41 @@ namespace OpenSim.Region.Framework.Scenes if (volume == 0.0f) continue; } +// TODO: Import real collision sounds and uncomment this +// else +// { +// volume = Math.Abs(colInfo.relativeVel); +// if (volume < 0.2f) +// continue; +// +// volume *= volume * .0625f; // 4m/s == full volume +// if (volume > 1.0f) +// volume = 1.0f; +// +// int otherMaterial = (int)otherPart.Material; +// if (otherMaterial >= MaxMaterials) +// otherMaterial = 3; +// +// soundID = m_PartPart[thisMatScaled + otherMaterial]; +// } + } + + if (soundID != UUID.Zero) // Remove when sounds are there + { // Remove when sounds are there + if (doneownsound) + otherPart.SendCollisionSound(soundID, volume, colInfo.position); else { - volume = Math.Abs(colInfo.relativeVel); - if (volume < 0.2f) - continue; - - volume *= volume * .0625f; // 4m/s == full volume - if (volume > 1.0f) - volume = 1.0f; - - int otherMaterial = (int)otherPart.Material; - if (otherMaterial >= MaxMaterials) - otherMaterial = 3; - - soundID = m_PartPart[thisMatScaled + otherMaterial]; + part.SendCollisionSound(soundID, volume, colInfo.position); + doneownsound = true; } - } - - if (doneownsound) - otherPart.SendCollisionSound(soundID, volume, colInfo.position); - else - { - part.SendCollisionSound(soundID, volume, colInfo.position); - doneownsound = true; - } + } // Remove when sounds are there } } } public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) { - // disable for now - return; - if (collidersinfolist.Count == 0 || av == null) return; @@ -341,22 +341,23 @@ namespace OpenSim.Region.Framework.Scenes continue; if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); - else - { - volume = Math.Abs(colInfo.relativeVel); - if (volume < 0.2f) - continue; - - volume *= volume * .0625f; // 4m/s == full volume - if (volume > 1.0f) - volume = 1.0f; - otherMaterial = (int)otherPart.Material; - if (otherMaterial >= MaxMaterials) - otherMaterial = 3; - - soundID = m_PartPart[thisMatScaled + otherMaterial]; - otherPart.SendCollisionSound(soundID, volume, colInfo.position); - } +//TODO: uncomment below when sounds are uploaded +// else +// { +// volume = Math.Abs(colInfo.relativeVel); +// if (volume < 0.2f) +// continue; +// +// volume *= volume * .0625f; // 4m/s == full volume +// if (volume > 1.0f) +// volume = 1.0f; +// otherMaterial = (int)otherPart.Material; +// if (otherMaterial >= MaxMaterials) +// otherMaterial = 3; +// +// soundID = m_PartPart[thisMatScaled + otherMaterial]; +// otherPart.SendCollisionSound(soundID, volume, colInfo.position); +// } continue; } /* @@ -374,4 +375,4 @@ namespace OpenSim.Region.Framework.Scenes } } } -} \ No newline at end of file +} -- cgit v1.1 From f5cbe56c569ad9453a055adba0636cf4a6614ec3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Jun 2012 19:01:33 +0200 Subject: Make not_at_target stop when the target is reached even if the script is not listening to at_target --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7568888..8fa7880 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3926,10 +3926,11 @@ namespace OpenSim.Region.Framework.Scenes scriptPosTarget target = m_targets[idx]; if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) { + at_target = true; + // trigger at_target if (m_scriptListens_atTarget) { - at_target = true; scriptPosTarget att = new scriptPosTarget(); att.targetPos = target.targetPos; att.tolerance = target.tolerance; -- cgit v1.1 From 49423144350b6195a51931bc18a01be337f80f8b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Jun 2012 20:51:03 +0200 Subject: Implement playing of the real collision sounds, change scaling for avatar collisions to make them really soft because otherwise climbing stairs makes an unbearable amount of noise. --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 190 +++++++-------------- 1 file changed, 57 insertions(+), 133 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index d72cf41..a95e75a 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -27,9 +27,11 @@ // Ubit 2012 using System; +using System.Reflection; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; +using log4net; namespace OpenSim.Region.Framework.Scenes { @@ -42,9 +44,11 @@ namespace OpenSim.Region.Framework.Scenes public static class CollisionSounds { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private const int MaxMaterials = 7; // part part -/* + private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66"); private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66"); private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66"); @@ -53,7 +57,6 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66"); private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66"); - private static UUID snd_MetalStone = new UUID("be7295c0-a158-11e1-b3dd-0801200c9a66"); private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66"); private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66"); private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66"); @@ -61,44 +64,24 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66"); private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66"); - private static UUID snd_GlassStone = new UUID("be7295c0-a158-11e1-b3dd-0802200c9a66"); - private static UUID snd_GlassMetal = new UUID("be7295c0-a158-11e1-b3dd-0802201c9a66"); private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66"); private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66"); private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66"); private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66"); private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66"); - private static UUID snd_WoodStone = new UUID("be7295c0-a158-11e1-b3dd-0803200c9a66"); - private static UUID snd_WoodMetal = new UUID("be7295c0-a158-11e1-b3dd-0803201c9a66"); - private static UUID snd_WoodGlass = new UUID("be7295c0-a158-11e1-b3dd-0803202c9a66"); private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66"); private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66"); private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66"); private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66"); - private static UUID snd_FleshStone = new UUID("be7295c0-a158-11e1-b3dd-0804200c9a66"); - private static UUID snd_FleshMetal = new UUID("be7295c0-a158-11e1-b3dd-0804201c9a66"); - private static UUID snd_FleshGlass = new UUID("be7295c0-a158-11e1-b3dd-0804202c9a66"); - private static UUID snd_FleshWood = new UUID("be7295c0-a158-11e1-b3dd-0804203c9a66"); private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66"); private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66"); private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66"); - private static UUID snd_PlasticStone = new UUID("be7295c0-a158-11e1-b3dd-0805200c9a66"); - private static UUID snd_PlasticMetal = new UUID("be7295c0-a158-11e1-b3dd-0805201c9a66"); - private static UUID snd_PlasticGlass = new UUID("be7295c0-a158-11e1-b3dd-0805202c9a66"); - private static UUID snd_PlasticWood = new UUID("be7295c0-a158-11e1-b3dd-0805203c9a66"); - private static UUID snd_PlasticFlesh = new UUID("be7295c0-a158-11e1-b3dd-0805204c9a66"); private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66"); private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66"); - private static UUID snd_RubberStone = new UUID("be7295c0-a158-11e1-b3dd-0806200c9a66"); - private static UUID snd_RubberMetal = new UUID("be7295c0-a158-11e1-b3dd-0806201c9a66"); - private static UUID snd_RubberGlass = new UUID("be7295c0-a158-11e1-b3dd-0806202c9a66"); - private static UUID snd_RubberWood = new UUID("be7295c0-a158-11e1-b3dd-0806203c9a66"); - private static UUID snd_RubberFlesh = new UUID("be7295c0-a158-11e1-b3dd-0806204c9a66"); - private static UUID snd_RubberPlastic = new UUID("be7295c0-a158-11e1-b3dd-0806205c9a66"); private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66"); // terrain part @@ -109,50 +92,6 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); -*/ - private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - - // terrain part - private static UUID snd_TerrainStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_TerrainMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_TerrainGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_TerrainWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_TerrainFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_TerrainPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_TerrainRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); public static UUID[] m_TerrainPart = { snd_TerrainStone, @@ -163,18 +102,7 @@ namespace OpenSim.Region.Framework.Scenes snd_TerrainPlastic, snd_TerrainRubber }; -/* - //full assimetric sounds - public static UUID[] m_PartPart = { - snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, - snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, - snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, - snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, - snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, - snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, - snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber - }; -*/ + // simetric sounds public static UUID[] m_PartPart = { snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, @@ -235,19 +163,17 @@ namespace OpenSim.Region.Framework.Scenes { if (!HaveSound) { -// TODO: Import real collision sounds and uncomment this -// volume = Math.Abs(colInfo.relativeVel); -// if (volume < 0.2f) -// continue; -// -// volume *= volume * .0625f; // 4m/s == full volume -// if (volume > 1.0f) -// volume = 1.0f; -// -// soundID = m_TerrainPart[thisMaterial]; + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; + + soundID = m_TerrainPart[thisMaterial]; } - else // Remove this else when uncommenting the above - part.SendCollisionSound(soundID, volume, colInfo.position); + part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } continue; @@ -268,35 +194,31 @@ namespace OpenSim.Region.Framework.Scenes if (volume == 0.0f) continue; } -// TODO: Import real collision sounds and uncomment this -// else -// { -// volume = Math.Abs(colInfo.relativeVel); -// if (volume < 0.2f) -// continue; -// -// volume *= volume * .0625f; // 4m/s == full volume -// if (volume > 1.0f) -// volume = 1.0f; -// -// int otherMaterial = (int)otherPart.Material; -// if (otherMaterial >= MaxMaterials) -// otherMaterial = 3; -// -// soundID = m_PartPart[thisMatScaled + otherMaterial]; -// } - } - - if (soundID != UUID.Zero) // Remove when sounds are there - { // Remove when sounds are there - if (doneownsound) - otherPart.SendCollisionSound(soundID, volume, colInfo.position); else { - part.SendCollisionSound(soundID, volume, colInfo.position); - doneownsound = true; + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; + + int otherMaterial = (int)otherPart.Material; + if (otherMaterial >= MaxMaterials) + otherMaterial = 3; + + soundID = m_PartPart[thisMatScaled + otherMaterial]; } - } // Remove when sounds are there + } + + if (doneownsound) + otherPart.SendCollisionSound(soundID, volume, colInfo.position); + else + { + part.SendCollisionSound(soundID, volume, colInfo.position); + doneownsound = true; + } } } } @@ -341,23 +263,25 @@ namespace OpenSim.Region.Framework.Scenes continue; if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); -//TODO: uncomment below when sounds are uploaded -// else -// { -// volume = Math.Abs(colInfo.relativeVel); -// if (volume < 0.2f) -// continue; -// -// volume *= volume * .0625f; // 4m/s == full volume -// if (volume > 1.0f) -// volume = 1.0f; -// otherMaterial = (int)otherPart.Material; -// if (otherMaterial >= MaxMaterials) -// otherMaterial = 3; -// -// soundID = m_PartPart[thisMatScaled + otherMaterial]; -// otherPart.SendCollisionSound(soundID, volume, colInfo.position); -// } + else + { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + m_log.DebugFormat("Collision speed was {0}", volume); + + // Cap to 0.2 times volume because climbing stairs should not be noisy + // Also changed scaling + volume *= volume * .0125f; // 4m/s == volume 0.2 + if (volume > 0.2f) + volume = 0.2f; + otherMaterial = (int)otherPart.Material; + if (otherMaterial >= MaxMaterials) + otherMaterial = 3; + + soundID = m_PartPart[thisMatScaled + otherMaterial]; + otherPart.SendCollisionSound(soundID, volume, colInfo.position); + } continue; } /* -- cgit v1.1 From ad1df330063ff2786b1ed8aae65f0198285ccd9c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Jun 2012 23:41:10 +0200 Subject: Further limit the amount of avatar collisions that will actually trigger sounds. They are distracting. --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index a95e75a..3ec3cf7 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -266,9 +266,11 @@ namespace OpenSim.Region.Framework.Scenes else { volume = Math.Abs(colInfo.relativeVel); - if (volume < 0.2f) + // Most noral collisions (running into walls, stairs) + // should never be heard. + if (volume < 2.0f) continue; - m_log.DebugFormat("Collision speed was {0}", volume); +// m_log.DebugFormat("Collision speed was {0}", volume); // Cap to 0.2 times volume because climbing stairs should not be noisy // Also changed scaling -- cgit v1.1 From 038acc39bef922b823964ac43083b24c129fca81 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Jun 2012 00:09:30 +0200 Subject: Cut off collision sounds with avatar at 3.2. This makes most walkig collisions with walls and stairs silent. Falls from greater height and running into things will still be heard. a CollisionSound defined for the object will override this so one can still script a soccer ball with sounds. --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 3ec3cf7..075724e 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -268,7 +268,7 @@ namespace OpenSim.Region.Framework.Scenes volume = Math.Abs(colInfo.relativeVel); // Most noral collisions (running into walls, stairs) // should never be heard. - if (volume < 2.0f) + if (volume < 3.2f) continue; // m_log.DebugFormat("Collision speed was {0}", volume); -- cgit v1.1 From 2d98d6354ce04b655e8d9062a209f5af1565c78c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Jun 2012 15:14:38 +0200 Subject: Add a frame based watchdog function to keyframed motion --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index b7b0d27..0219d9c 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -64,6 +64,10 @@ namespace OpenSim.Region.Framework.Scenes [NonSerialized()] protected Timer m_timer = new Timer(); + [NonSerialized()] + protected bool m_frameHooked; + [NonSerialized()] + protected int frameCount = 0; [NonSerialized()] private SceneObjectGroup m_group; @@ -162,6 +166,22 @@ namespace OpenSim.Region.Framework.Scenes if (m_keyframes.Length > 0) m_timer.Start(); m_running = true; + if (!m_frameHooked) + { + m_group.Scene.EventManager.OnFrame += OnFrame; + m_frameHooked = true; + } + } + + private void OnFrame() + { + frameCount++; + if (frameCount >= 30) + { + frameCount = 0; + if (m_running) + Start(); + } } public void Stop() -- cgit v1.1 From 1eee525c886f55e63a1d6ebf6ba224a73d4c4178 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Jun 2012 16:54:47 +0200 Subject: Revert "Add a frame based watchdog function to keyframed motion" This reverts commit 2d98d6354ce04b655e8d9062a209f5af1565c78c. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 0219d9c..b7b0d27 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -64,10 +64,6 @@ namespace OpenSim.Region.Framework.Scenes [NonSerialized()] protected Timer m_timer = new Timer(); - [NonSerialized()] - protected bool m_frameHooked; - [NonSerialized()] - protected int frameCount = 0; [NonSerialized()] private SceneObjectGroup m_group; @@ -166,22 +162,6 @@ namespace OpenSim.Region.Framework.Scenes if (m_keyframes.Length > 0) m_timer.Start(); m_running = true; - if (!m_frameHooked) - { - m_group.Scene.EventManager.OnFrame += OnFrame; - m_frameHooked = true; - } - } - - private void OnFrame() - { - frameCount++; - if (frameCount >= 30) - { - frameCount = 0; - if (m_running) - Start(); - } } public void Stop() -- cgit v1.1 From efff5a7c0da115c21720b879194ed87dc63def2d Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Jun 2012 18:25:36 +0200 Subject: Fix a corner case where checking for region corssing may cross an avatar back if it's pending to be sat onto a vehicle that is in the process of crossing. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2b1fb3d..a810de2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1051,6 +1051,7 @@ namespace OpenSim.Region.Framework.Scenes IsChildAgent = true; m_scene.SwapRootAgentCount(true); RemoveFromPhysicalScene(); + ParentID = 0; // Child agents can't be sitting // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into @@ -2091,6 +2092,9 @@ namespace OpenSim.Region.Framework.Scenes public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) { + if (IsChildAgent) + return; + if (ParentID != 0) { StandUp(); @@ -2893,8 +2897,9 @@ namespace OpenSim.Region.Framework.Scenes // If we don't have a PhysActor, we can't cross anyway // Also don't do this while sat, sitting avatars cross with the - // object they sit on. - if (ParentID != 0 || PhysicsActor == null) + // object they sit on. ParentUUID denoted a pending sit, don't + // interfere with it. + if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) return; if (!IsInTransit) -- cgit v1.1 From cd4994947858516f9177501499a1139f23ddd3cf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 11 Jun 2012 22:43:35 +0100 Subject: change object drag so it applies a impulse and not a push force so it works as before my fix to impulse/forces --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8fa7880..aab6a49 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2992,10 +2992,14 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_rootPart.BlockGrab) { - Vector3 llmoveforce = pos - AbsolutePosition; +/* Vector3 llmoveforce = pos - AbsolutePosition; Vector3 grabforce = llmoveforce; grabforce = (grabforce / 10) * pa.Mass; - pa.AddForce(grabforce, true); + */ + // empirically convert distance diference to a impulse + Vector3 grabforce = pos - AbsolutePosition; + grabforce = grabforce * (pa.Mass/ 10.0f); + pa.AddForce(grabforce, false); m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } } -- cgit v1.1 From 24e8e5d8188dd2e8656feb5e43193e7475fa2acc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 01:26:03 +0100 Subject: *UNTESTED* extended llGet*PrimitiveParam() to support avatars. Some auxiliar code in SOP.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a810de2..21e2878 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -519,6 +519,40 @@ namespace OpenSim.Region.Framework.Scenes } } + // returns offset position relative to root prim of object when siting + public Vector3 OffsetPositionToSOGRoot + { + get + { + if (ParentPart != null) + return ParentPart.OffsetPosition + (m_pos * ParentPart.RotationOffset); + else + return m_pos; + } + } + + public Quaternion OffsetRotationToSOGRoot + { + get + { + if (ParentPart != null) + return ParentPart.RotationOffset * Rotation; + else + return Rotation; + } + } + + public Quaternion WorldRotation + { + get + { + if (ParentPart != null) + return ParentPart.GetWorldRotation() * Rotation; + else + return Rotation; + } + } + /// /// Current velocity of the avatar. /// -- cgit v1.1 From 5fd6f678a46de8109d7178ba788e458053e34c06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 02:20:47 +0100 Subject: Moved auxiliar funtions of last commit from sop to lsl api since they are only used on one place each --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 ------------------------ 1 file changed, 34 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 21e2878..a810de2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -519,40 +519,6 @@ namespace OpenSim.Region.Framework.Scenes } } - // returns offset position relative to root prim of object when siting - public Vector3 OffsetPositionToSOGRoot - { - get - { - if (ParentPart != null) - return ParentPart.OffsetPosition + (m_pos * ParentPart.RotationOffset); - else - return m_pos; - } - } - - public Quaternion OffsetRotationToSOGRoot - { - get - { - if (ParentPart != null) - return ParentPart.RotationOffset * Rotation; - else - return Rotation; - } - } - - public Quaternion WorldRotation - { - get - { - if (ParentPart != null) - return ParentPart.GetWorldRotation() * Rotation; - else - return Rotation; - } - } - /// /// Current velocity of the avatar. /// -- cgit v1.1 From b4ab9a735007604caba2253077434299b4f81b65 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 01:26:15 +0100 Subject: *TEST this will affect inworld sittargets by +-0.1m, so may be very BAD *. Changed the sign of the sitoffset dependent on avatar size in SP.cs. Removed that offset correction from SET/GET..primitiveParams in LSL api. If the sign needs to be the previus one, then all references to avatar positions on LSL api need to be fixed with that correction, not only SET/GETprimitiveParams. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a810de2..059d4c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2383,7 +2383,8 @@ namespace OpenSim.Region.Framework.Scenes Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; - m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; +// m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); -- cgit v1.1 From 7bd274b3d34b5f7cbdc4e4d9e9f6915392b004b8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 04:59:09 +0100 Subject: Changed t adding the avatar dependent sit offset and not subtracting, so not to break inworld contents. SL ported scripts will show a sit error around 0.1m. Added respective compensation in LSL api to maintain coerence. Fixed several bugs still on SET/GET[link]PrimitiveParams[fast] and llGetObjectDetails() --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 059d4c2..87b4d9f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2383,8 +2383,10 @@ namespace OpenSim.Region.Framework.Scenes Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; -// m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; + + m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; + +// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); -- cgit v1.1 From 065cda37112fecc00e3c10fe966edde2ddc46b4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 12:19:42 +0100 Subject: Add sop IsPhysical and IsPhantom to be used gradually in core in place of asking physics engines all the time. Some engines delays may make them give wrong answers. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8e74dc8..b51ce38 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -611,7 +611,10 @@ namespace OpenSim.Region.Framework.Scenes public bool IsSelected { - get { return m_isSelected; } + get + { + return m_isSelected; + } set { m_isSelected = value; @@ -619,8 +622,23 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.PartSelectChanged(value); } } - - + + public bool IsPhysical + { + get + { + return ((Flags & PrimFlags.Physics) != 0); + } + } + + public bool IsPhantom + { + get + { + return ((Flags & PrimFlags.Phantom) != 0); + } + } + public Dictionary CollisionFilter { get { return m_CollisionFilter; } -- cgit v1.1 From 5d329791705fa5d82d37f5c3ff03d0f4f597c2e1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 14:31:35 +0100 Subject: Revert changes... This reverts commit c8227e1bb70817351de283fb647ec39f090fc9f1. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 24 +++------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b51ce38..8e74dc8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -611,10 +611,7 @@ namespace OpenSim.Region.Framework.Scenes public bool IsSelected { - get - { - return m_isSelected; - } + get { return m_isSelected; } set { m_isSelected = value; @@ -622,23 +619,8 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.PartSelectChanged(value); } } - - public bool IsPhysical - { - get - { - return ((Flags & PrimFlags.Physics) != 0); - } - } - - public bool IsPhantom - { - get - { - return ((Flags & PrimFlags.Phantom) != 0); - } - } - + + public Dictionary CollisionFilter { get { return m_CollisionFilter; } -- cgit v1.1 From 8cf414ba32ba995562e574cd2a58ce7ee204a562 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 11:38:40 +0100 Subject: *CHECK/REVIEW* comented out not used sp.ParentPosition. Comented out SOG.AbsolutePosition changing 'linked' avatars positions ( reason in code coment ) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 18 +++++++++++++----- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 +++++++++++--------- 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index aab6a49..96eeec4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -631,6 +631,14 @@ namespace OpenSim.Region.Framework.Scenes if (triggerScriptEvent) part.TriggerScriptChangedEvent(Changed.POSITION); } + +/* + This seems not needed and should not be needed: + sp absolute position depends on sit part absolute position fixed above. + sp ParentPosition is not used anywhere. + Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it + Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. + if (!m_dupeInProgress) { foreach (ScenePresence av in m_linkedAvatars) @@ -640,12 +648,12 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 offset = p.GetWorldPosition() - av.ParentPosition; av.AbsolutePosition += offset; - av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition +// av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition av.SendAvatarDataToAllAgents(); } } } - +*/ //if (m_rootPart.PhysActor != null) //{ //m_rootPart.PhysActor.Position = @@ -676,8 +684,8 @@ namespace OpenSim.Region.Framework.Scenes if (agent.ParentUUID != UUID.Zero) { agent.ParentPart = null; - agent.ParentPosition = Vector3.Zero; - // agent.ParentUUID = UUID.Zero; +// agent.ParentPosition = Vector3.Zero; +// agent.ParentUUID = UUID.Zero; } } @@ -3752,7 +3760,7 @@ namespace OpenSim.Region.Framework.Scenes else // ugly rotation update of all parts { - group.AbsolutePosition = AbsolutePosition; + group.ResetChildPrimPhysicsPositions(); } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 87b4d9f..a068aab 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -433,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes get { return (IClientCore)ControllingClient; } } - public Vector3 ParentPosition { get; set; } +// public Vector3 ParentPosition { get; set; } /// /// Position of this avatar relative to the region the avatar is in @@ -491,7 +491,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID == 0) { m_pos = value; - ParentPosition = Vector3.Zero; +// ParentPosition = Vector3.Zero; } //m_log.DebugFormat( @@ -857,11 +857,12 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.AddAvatar(UUID); if (part.SitTargetPosition != Vector3.Zero) part.SitTargetAvatar = UUID; - ParentPosition = part.GetWorldPosition(); +// ParentPosition = part.GetWorldPosition(); ParentID = part.LocalId; ParentPart = part; m_pos = m_prevSitOffset; - pos = ParentPosition; +// pos = ParentPosition; + pos = part.GetWorldPosition(); } ParentUUID = UUID.Zero; @@ -1933,11 +1934,12 @@ namespace OpenSim.Region.Framework.Scenes part.SitTargetAvatar = UUID.Zero; part.ParentGroup.DeleteAvatar(UUID); - ParentPosition = part.GetWorldPosition(); +// ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); - ParentPosition = Vector3.Zero; +// m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); +// ParentPosition = Vector3.Zero; + m_pos += part.GetWorldPosition() + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); ParentID = 0; ParentPart = null; @@ -2388,13 +2390,13 @@ namespace OpenSim.Region.Framework.Scenes // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; - ParentPosition = part.AbsolutePosition; +// ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); } else { m_pos -= part.AbsolutePosition; - ParentPosition = part.AbsolutePosition; +// ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); // m_log.DebugFormat( -- cgit v1.1 From 909572ed8618f15c7603cbb8a91563d55dc42061 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Jun 2012 09:40:51 +0100 Subject: fix SceneGraph Add/Remove PhysicalPrim counters --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b7466be..a600b86 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -585,12 +585,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal void AddPhysicalPrim(int number) { - m_physicalPrim++; + m_physicalPrim += number; } protected internal void RemovePhysicalPrim(int number) { - m_physicalPrim--; + m_physicalPrim -= number; } protected internal void AddToScriptLPS(int number) -- cgit v1.1 From c8f7cd60cd5e16b6917c0b67358bee4eb04716d1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Jun 2012 19:05:36 +0100 Subject: fix turning off phanton always decreasing number of physical parts --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8e74dc8..a48605d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4496,7 +4496,8 @@ namespace OpenSim.Region.Framework.Scenes { if (pa != null) { - ParentGroup.Scene.RemovePhysicalPrim(1); + if(wasUsingPhysics) + ParentGroup.Scene.RemovePhysicalPrim(1); RemoveFromPhysics(); } @@ -4513,38 +4514,37 @@ namespace OpenSim.Region.Framework.Scenes { AddToPhysics(UsePhysics, SetPhantom, building, false); pa = PhysActor; - /* - if (pa != null) - { - if ( - // ((AggregateScriptEvents & scriptEvents.collision) != 0) || - // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || - (CollisionSound != UUID.Zero) - ) - { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); - } - } - */ +/* + if (pa != null) + { + if ( +// ((AggregateScriptEvents & scriptEvents.collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || + (CollisionSound != UUID.Zero) + ) + { + pa.OnCollisionUpdate += PhysicsCollision; + pa.SubscribeEvents(1000); + } + } +*/ } else // it already has a physical representation { DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. - /* moved into DoPhysicsPropertyUpdate - if(VolumeDetectActive) - pa.SetVolumeDetect(1); - else - pa.SetVolumeDetect(0); - */ - +/* moved into DoPhysicsPropertyUpdate + if(VolumeDetectActive) + pa.SetVolumeDetect(1); + else + pa.SetVolumeDetect(0); +*/ if (pa.Building != building) pa.Building = building; -- cgit v1.1 From 9ca9770cf69bb148c9509c9dbe2f6c981aec36a5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 25 Jun 2012 00:44:09 +0100 Subject: fix a seg fault in sp.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a068aab..4940063 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3570,7 +3570,8 @@ namespace OpenSim.Region.Framework.Scenes // m_reprioritizationTimer.Dispose(); RemoveFromPhysicalScene(); - Animator.Close(); + if(Animator != null) + Animator.Close(); Animator = null; } -- cgit v1.1 From c87f0ac2261d1aa5226957aff63bfc8ac0efaffd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 21:23:42 +0200 Subject: Fix llRegionSayTo the right way --- OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 3ef1e29..431b903 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -38,8 +38,8 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { - protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, bool fromAgent, bool broadcast) + public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, + UUID fromID, bool fromAgent, bool broadcast, UUID destination) { OSChatMessage args = new OSChatMessage(); @@ -49,6 +49,7 @@ namespace OpenSim.Region.Framework.Scenes args.Position = fromPos; args.SenderUUID = fromID; args.Scene = this; + args.Destination = destination; if (fromAgent) { @@ -71,6 +72,12 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnChatFromWorld(this, args); } + protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, + UUID fromID, bool fromAgent, bool broadcast) + { + SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, broadcast, UUID.Zero); + } + /// /// /// -- cgit v1.1 From a1a22a2f1034a1feb67b141abf4b138248cdb356 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 22:02:20 +0100 Subject: Revert "Mantis 5977 Corrections to llRegionSayTo" This reverts commit 679da63da617d031e5e7ae3f2d2a29db1a23ace3. Conflicts: OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs --- .../Framework/Scenes/Scene.PacketHandlers.cs | 26 +++------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index cf68ff4..3ef1e29 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -38,9 +38,8 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { - protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, UUID targetID, bool fromAgent, bool broadcast) + UUID fromID, bool fromAgent, bool broadcast) { OSChatMessage args = new OSChatMessage(); @@ -64,20 +63,14 @@ namespace OpenSim.Region.Framework.Scenes } args.From = fromName; - args.TargetUUID = targetID; + //args. if (broadcast) EventManager.TriggerOnChatBroadcast(this, args); else EventManager.TriggerOnChatFromWorld(this, args); } - - protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, bool fromAgent, bool broadcast) - { - SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast); - } - + /// /// /// @@ -115,19 +108,6 @@ namespace OpenSim.Region.Framework.Scenes { SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); } - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) - { - SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); - } /// /// Invoked when the client requests a prim. -- cgit v1.1 From ce7864632bf239a44321cc5806a95a78e0f259ed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jul 2012 17:13:11 +0100 Subject: added llSetVelocity. will refuse to work on vehicles and on attachments ( this last may need fix) added also some code for llSetAngularVelocity but not working still --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a48605d..ed32adc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1845,6 +1845,34 @@ namespace OpenSim.Region.Framework.Scenes } } +// SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future + public void SetVelocity(Vector3 pVel, bool localGlobalTF) + { + if (ParentGroup == null || ParentGroup.IsDeleted) + return; + + if (ParentGroup.IsAttachment) + return; // don't work on attachments (for now ??) + + SceneObjectPart root = ParentGroup.RootPart; + + if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles + return; + + PhysicsActor pa = root.PhysActor; + + if (pa == null || !pa.IsPhysical) + return; + + if (localGlobalTF) + { + pVel = pVel * GetWorldRotation(); + } + + ParentGroup.Velocity = pVel; + } + + /// /// hook to the physics scene to apply angular impulse /// This is sent up to the group, which then finds the root prim -- cgit v1.1 From 6535f23e4b8fec9578dae5275db69b237a99e498 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 7 Jul 2012 02:05:01 +0200 Subject: Add saving vehicle physics data to the database --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 33 +++++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 40 +++++++++++----------- .../Scenes/Serialization/SceneObjectSerializer.cs | 8 ++--- 3 files changed, 56 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index d3c2d27..45ca00c 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -30,6 +30,8 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; +using System.Text; +using System.IO; using System.Xml; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; @@ -561,6 +563,35 @@ namespace OpenSim.Region.Framework.Scenes } + public string ToXml2() + { + MemoryStream ms = new MemoryStream(); + UTF8Encoding enc = new UTF8Encoding(); + XmlTextWriter writer = new XmlTextWriter(ms, null); + ToXml2(writer); + return enc.GetString(ms.ToArray()); + } + + public static SOPVehicle FromXml2(string text) + { + if (text == String.Empty) + return null; + UTF8Encoding enc = new UTF8Encoding(); + MemoryStream ms = new MemoryStream(enc.GetBytes(text)); + XmlTextReader reader = new XmlTextReader(ms); + + SOPVehicle v = new SOPVehicle(); + bool error; + + v.FromXml2(reader, out error); + if (error) + { + v = null; + return null; + } + + return v; + } public void FromXml2(XmlTextReader _reader, out bool errors) { @@ -739,4 +770,4 @@ namespace OpenSim.Region.Framework.Scenes vd.m_referenceFrame = XRquat(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ed32adc..dd30a59 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -338,7 +338,7 @@ namespace OpenSim.Region.Framework.Scenes private int LastColSoundSentTime; - private SOPVehicle m_vehicle = null; + private SOPVehicle m_vehicleParams = null; private KeyframeMotion m_keyframeMotion = null; @@ -3379,15 +3379,15 @@ namespace OpenSim.Region.Framework.Scenes Force = force; } - public SOPVehicle sopVehicle + public SOPVehicle VehicleParams { get { - return m_vehicle; + return m_vehicleParams; } set { - m_vehicle = value; + m_vehicleParams = value; } } @@ -3396,10 +3396,10 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (m_vehicle == null) + if (m_vehicleParams == null) return (int)Vehicle.TYPE_NONE; else - return (int)m_vehicle.Type; + return (int)m_vehicleParams.Type; } set { @@ -3409,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleType(int type) { - m_vehicle = null; + m_vehicleParams = null; if (type == (int)Vehicle.TYPE_NONE) { @@ -3417,8 +3417,8 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; return; } - m_vehicle = new SOPVehicle(); - m_vehicle.ProcessTypeChange((Vehicle)type); + m_vehicleParams = new SOPVehicle(); + m_vehicleParams.ProcessTypeChange((Vehicle)type); { if (_parentID ==0 && PhysActor != null) PhysActor.VehicleType = type; @@ -3428,10 +3428,10 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleFlags(int param, bool remove) { - if (m_vehicle == null) + if (m_vehicleParams == null) return; - m_vehicle.ProcessVehicleFlags(param, remove); + m_vehicleParams.ProcessVehicleFlags(param, remove); if (_parentID ==0 && PhysActor != null) { @@ -3441,10 +3441,10 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleFloatParam(int param, float value) { - if (m_vehicle == null) + if (m_vehicleParams == null) return; - m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); + m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); if (_parentID == 0 && PhysActor != null) { @@ -3454,10 +3454,10 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleVectorParam(int param, Vector3 value) { - if (m_vehicle == null) + if (m_vehicleParams == null) return; - m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); + m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); if (_parentID == 0 && PhysActor != null) { @@ -3467,10 +3467,10 @@ namespace OpenSim.Region.Framework.Scenes public void SetVehicleRotationParam(int param, Quaternion rotation) { - if (m_vehicle == null) + if (m_vehicleParams == null) return; - m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); + m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); if (_parentID == 0 && PhysActor != null) { @@ -4637,8 +4637,8 @@ namespace OpenSim.Region.Framework.Scenes if (VolumeDetectActive) // change if not the default only pa.SetVolumeDetect(1); - if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) - m_vehicle.SetVehicle(pa); + if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicleParams.SetVehicle(pa); // we are going to tell rest of code about physics so better have this here PhysActor = pa; @@ -4676,7 +4676,7 @@ namespace OpenSim.Region.Framework.Scenes pa.RotationalVelocity = rotationalVelocity; // if not vehicle and root part apply force and torque - if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) + if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) && LocalId == ParentGroup.RootPart.LocalId) { pa.Force = Force; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 151eba2..c7e4c3e 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -630,13 +630,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (errors) { - obj.sopVehicle = null; + obj.VehicleParams = null; m_log.DebugFormat( "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", obj.Name, obj.UUID); } else - obj.sopVehicle = _vehicle; + obj.VehicleParams = _vehicle; } private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) @@ -1325,8 +1325,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); - if (sop.sopVehicle != null) - sop.sopVehicle.ToXml2(writer); + if (sop.VehicleParams != null) + sop.VehicleParams.ToXml2(writer); if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); -- cgit v1.1 From afa02aa104e0cfbedd0e1b6c1d7b60522a79a4e8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jul 2012 07:41:11 +0100 Subject: fix vehicle to XML string --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 45ca00c..e2ef77b 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -565,31 +565,37 @@ namespace OpenSim.Region.Framework.Scenes public string ToXml2() { - MemoryStream ms = new MemoryStream(); + MemoryStream ms = new MemoryStream(512); UTF8Encoding enc = new UTF8Encoding(); - XmlTextWriter writer = new XmlTextWriter(ms, null); - ToXml2(writer); - return enc.GetString(ms.ToArray()); + XmlTextWriter xwriter = new XmlTextWriter(ms, enc); + ToXml2(xwriter); + xwriter.Flush(); + string s = ms.GetStreamString(); + xwriter.Close(); + return s; } public static SOPVehicle FromXml2(string text) { if (text == String.Empty) return null; + UTF8Encoding enc = new UTF8Encoding(); MemoryStream ms = new MemoryStream(enc.GetBytes(text)); - XmlTextReader reader = new XmlTextReader(ms); + XmlTextReader xreader = new XmlTextReader(ms); SOPVehicle v = new SOPVehicle(); bool error; - v.FromXml2(reader, out error); + v.FromXml2(xreader, out error); + + xreader.Close(); + if (error) { v = null; return null; } - return v; } -- cgit v1.1 From 470019b52a72de1a8777933ce3254cde87e184f9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 7 Jul 2012 19:59:55 +0200 Subject: Change semantics of FromXML on vehicle data to make the serializer a bit cleaner --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 15 ++++++++++++++- .../Scenes/Serialization/SceneObjectSerializer.cs | 11 +++++------ 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index e2ef77b..41e8944 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -599,7 +599,20 @@ namespace OpenSim.Region.Framework.Scenes return v; } - public void FromXml2(XmlTextReader _reader, out bool errors) + public static SOPVehicle FromXml2(XmlTextReader reader) + { + SOPVehicle vehicle = new SOPVehicle(); + + bool errors = false; + + vehicle.FromXml2(reader, out errors); + if (errors) + return null; + + return vehicle; + } + + private void FromXml2(XmlTextReader _reader, out bool errors) { errors = false; reader = _reader; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index c7e4c3e..abca14f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -623,12 +623,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) { - bool errors = false; - SOPVehicle _vehicle = new SOPVehicle(); + SOPVehicle vehicle = SOPVehicle.FromXml2(reader); - _vehicle.FromXml2(reader, out errors); - - if (errors) + if (vehicle == null) { obj.VehicleParams = null; m_log.DebugFormat( @@ -636,7 +633,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.Name, obj.UUID); } else - obj.VehicleParams = _vehicle; + { + obj.VehicleParams = vehicle; + } } private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) -- cgit v1.1 From 652ac5f66bacb048628bc953497ffe4256676f05 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 10 Jul 2012 05:28:47 +0100 Subject: more work on llSetAngularVelocity() --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dd30a59..0f44823 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1845,7 +1845,7 @@ namespace OpenSim.Region.Framework.Scenes } } -// SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future + // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future public void SetVelocity(Vector3 pVel, bool localGlobalTF) { if (ParentGroup == null || ParentGroup.IsDeleted) @@ -1871,6 +1871,33 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.Velocity = pVel; } + + // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future + public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) + { + if (ParentGroup == null || ParentGroup.IsDeleted) + return; + + if (ParentGroup.IsAttachment) + return; // don't work on attachments (for now ??) + + SceneObjectPart root = ParentGroup.RootPart; + + if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles + return; + + PhysicsActor pa = root.PhysActor; + + if (pa == null || !pa.IsPhysical) + return; + + if (localGlobalTF) + { + pAngVel = pAngVel * GetWorldRotation(); + } + + root.AngularVelocity = pAngVel; + } /// -- cgit v1.1 From acec9da95c2faa861ee37cc5e820118fc4649c80 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 10 Jul 2012 05:37:41 +0100 Subject: let SOP AngularVelocity set physics actor angular velocity if it's physical root prim and not a vehicle. With this llSetAngularVelocity should work and also llTargetOmega will do the same in this case. but for now this llTargetOmega is being a normal physical rotation with damping, and stops with selection. Thats not like SL apparently --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0f44823..16a8588 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -959,7 +959,15 @@ namespace OpenSim.Region.Framework.Scenes } return m_angularVelocity; } - set { m_angularVelocity = value; } + set + { + m_angularVelocity = value; + PhysicsActor actor = PhysActor; + if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) + { + actor.RotationalVelocity = m_angularVelocity; + } + } } /// -- cgit v1.1 From 7836933133a27bb57cd89663134f37b78fed5f7c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 11 Jul 2012 03:58:58 +0100 Subject: Melanie fix: detach SOGs from backup on linking --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a600b86..0587846 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1820,6 +1820,8 @@ namespace OpenSim.Region.Framework.Scenes { parentGroup.LinkToGroup(child); + child.DetachFromBackup(); + // this is here so physics gets updated! // Don't remove! Bad juju! Stay away! or fix physics! child.AbsolutePosition = child.AbsolutePosition; -- cgit v1.1 From 59cd0a2419266f190375074e2bede0d9a10de370 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 11 Jul 2012 23:32:12 +0200 Subject: Change order of operations on backup to ensure keyframe motions are backed up properly --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 96eeec4..1734ab7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2039,8 +2039,6 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChangedDueToDelink = false; m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); - datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); - backup_group.ForEachPart(delegate(SceneObjectPart part) { if (part.KeyframeMotion != null) @@ -2048,6 +2046,12 @@ namespace OpenSim.Region.Framework.Scenes part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); part.KeyframeMotion.UpdateSceneObject(this); } + }); + + datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); + + backup_group.ForEachPart(delegate(SceneObjectPart part) + { part.Inventory.ProcessInventoryBackup(datastore); }); -- cgit v1.1 From ea91a36483f3eba90e16b664715d152f9eca2980 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 11 Jul 2012 23:33:13 +0200 Subject: Add instrumentation to log finalizer being called. Suppressed for backup interim copies to avoid spammage. Not for release to the grid, must be reverted first! --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1734ab7..1730723 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2045,6 +2045,7 @@ namespace OpenSim.Region.Framework.Scenes { part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); part.KeyframeMotion.UpdateSceneObject(this); + part.SuppressFinalizerLogging = true; } }); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 16a8588..4d43943 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -149,6 +149,8 @@ namespace OpenSim.Region.Framework.Scenes #region Fields + public bool SuppressFinalizerLogging = false; + public bool AllowedDrop; public bool DIE_AT_EDGE; @@ -350,15 +352,18 @@ namespace OpenSim.Region.Framework.Scenes #endregion Fields -// ~SceneObjectPart() -// { + ~SceneObjectPart() + { + if (SuppressFinalizerLogging) + return; + // Console.WriteLine( // "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", // Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", -// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); -// } + m_log.DebugFormat( + "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", + Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); + } #region Constructors -- cgit v1.1 From d9b0b03aa3f92bcd860e4edb656cf6b1221776a6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 11 Jul 2012 23:54:45 +0200 Subject: Place instrumentation in the proper place. This needs reverting, too! --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1730723..efeb551 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2045,8 +2045,8 @@ namespace OpenSim.Region.Framework.Scenes { part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); part.KeyframeMotion.UpdateSceneObject(this); - part.SuppressFinalizerLogging = true; } + part.SuppressFinalizerLogging = true; }); datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); -- cgit v1.1 From c66367e6194f22da86a3bf972ec107212e732d80 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 12 Jul 2012 00:16:19 +0200 Subject: Add "gc collect" console command for debugging memleaks --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6a120c1..48aca98 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -831,6 +831,8 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; + + MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); } /// @@ -5637,5 +5639,10 @@ Environment.Exit(1); } } } + + private void HandleGcCollect(string module, string[] args) + { + GC.Collect(); + } } } -- cgit v1.1 From bae35ad97e10df4cfd3ecb73fab84081d85ede20 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 12 Jul 2012 01:01:29 +0200 Subject: Revert "Place instrumentation in the proper place. This needs reverting, too!" This reverts commit d9b0b03aa3f92bcd860e4edb656cf6b1221776a6. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index efeb551..1730723 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2045,8 +2045,8 @@ namespace OpenSim.Region.Framework.Scenes { part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); part.KeyframeMotion.UpdateSceneObject(this); + part.SuppressFinalizerLogging = true; } - part.SuppressFinalizerLogging = true; }); datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); -- cgit v1.1 From 906ac4adc4adc8eef84a584b73323fda25127806 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 12 Jul 2012 01:01:43 +0200 Subject: Revert "Add instrumentation to log finalizer being called. Suppressed for backup" This reverts commit ea91a36483f3eba90e16b664715d152f9eca2980. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 - OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1730723..1734ab7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2045,7 +2045,6 @@ namespace OpenSim.Region.Framework.Scenes { part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); part.KeyframeMotion.UpdateSceneObject(this); - part.SuppressFinalizerLogging = true; } }); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4d43943..16a8588 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -149,8 +149,6 @@ namespace OpenSim.Region.Framework.Scenes #region Fields - public bool SuppressFinalizerLogging = false; - public bool AllowedDrop; public bool DIE_AT_EDGE; @@ -352,18 +350,15 @@ namespace OpenSim.Region.Framework.Scenes #endregion Fields - ~SceneObjectPart() - { - if (SuppressFinalizerLogging) - return; - +// ~SceneObjectPart() +// { // Console.WriteLine( // "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", // Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); - m_log.DebugFormat( - "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", - Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); - } +// m_log.DebugFormat( +// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", +// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); +// } #region Constructors -- cgit v1.1 From 39262f6232978f63ce997288052b4bfab433a2f6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Jul 2012 20:25:47 +0100 Subject: missed fix on vehicle reference frame --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 41e8944..9cb901a 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -36,7 +36,6 @@ using System.Xml; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Region.Framework.Scenes.Serialization; namespace OpenSim.Region.Framework.Scenes { @@ -215,7 +214,7 @@ namespace OpenSim.Region.Framework.Scenes switch (pParam) { case Vehicle.REFERENCE_FRAME: - vd.m_referenceFrame = Quaternion.Inverse(pValue); + vd.m_referenceFrame = pValue; break; } }//end ProcessRotationVehicleParam -- cgit v1.1 From 1dca94c72fabf06da4d85d6acad5894dabe79c5a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2012 20:10:38 +0100 Subject: don't subscribe collision events for nonphysical parts only because of collision sounds. Let them be passive --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 075724e..21c9ab9 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -31,6 +31,7 @@ using System.Reflection; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; using log4net; namespace OpenSim.Region.Framework.Scenes diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 16a8588..735bd32 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4917,7 +4917,7 @@ namespace OpenSim.Region.Framework.Scenes pa.OnCollisionUpdate -= PhysicsCollision; - bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); + bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); scriptEvents CombinedEvents = AggregateScriptEvents; -- cgit v1.1 From a492b6f6934f76dc54740264d49fad958428ff36 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2012 20:13:40 +0100 Subject: remove forgotten line... --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 21c9ab9..075724e 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -31,7 +31,6 @@ using System.Reflection; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Region.Physics.Manager; using log4net; namespace OpenSim.Region.Framework.Scenes -- cgit v1.1 From 130668057fef7512a4caa162f02c407bad819ed9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 17 Jul 2012 01:42:42 +0200 Subject: Fix merge artefacts --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneBase.cs | 1 - OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 9 ++------- 3 files changed, 4 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f437bc8..05af942 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -639,7 +639,7 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService = sceneGridService; m_SimulationDataService = simDataService; m_EstateDataService = estateDataService; - m_regionHandle = m_regInfo.RegionHandle; + m_regionHandle = RegionInfo.RegionHandle; m_lastIncoming = 0; m_lastOutgoing = 0; @@ -4156,7 +4156,7 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence int flags = GetUserFlags(cAgentData.AgentID); - if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) + if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) { m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); return false; diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index e8134cd..8db4397 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -113,7 +113,6 @@ namespace OpenSim.Region.Framework.Scenes protected ulong m_regionHandle; protected string m_regionName; - protected RegionInfo m_regInfo; public ITerrainChannel Heightmap; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 1c9a17e..e010864 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -355,6 +355,8 @@ namespace OpenSim.Region.Framework.Scenes AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); if (null == asset) { + string msg = String.Format("asset ID {0} could not be found", item.AssetID); + StoreScriptError(item.ItemID, msg); m_log.ErrorFormat( "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", item.Name, item.ItemID, m_part.AbsolutePosition, @@ -367,13 +369,6 @@ namespace OpenSim.Region.Framework.Scenes if (m_part.ParentGroup.m_savedScriptState != null) item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); - string msg = String.Format("asset ID {0} could not be found", item.AssetID); - StoreScriptError(item.ItemID, msg); - m_log.ErrorFormat( - "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", - item.Name, item.ItemID, m_part.AbsolutePosition, - m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); - m_items.LockItemsForWrite(true); m_items[item.ItemID].OldItemID = item.OldItemID; -- cgit v1.1 From f004db65726fc2e00fe14d9c343ef46136f350f9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 03:45:16 +0100 Subject: fix our stats ( old schema ) --- OpenSim/Region/Framework/Scenes/Scene.cs | 47 ++++++++------- .../Region/Framework/Scenes/SimStatsReporter.cs | 67 +++++++++++++--------- 2 files changed, 66 insertions(+), 48 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 05af942..f501828 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -225,7 +225,6 @@ namespace OpenSim.Region.Framework.Scenes private int backupMS; private int terrainMS; private int landMS; - private int spareMS; /// /// Tick at which the last frame was processed. @@ -1434,16 +1433,20 @@ namespace OpenSim.Region.Framework.Scenes endFrame = Frame + frames; float physicsFPS = 0f; - int previousFrameTick, tmpMS; - int maintc = Util.EnvironmentTickCount(); + int tmpMS; + int previousFrameTick; + int maintc; + int sleepMS; + int framestart; while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { + framestart = Util.EnvironmentTickCount(); ++Frame; // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); - agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; + agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; try { @@ -1495,6 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.UpdatePresences(); agentMS += Util.EnvironmentTickCountSubtract(tmpMS); + // Delete temp-on-rez stuff if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) @@ -1573,36 +1577,37 @@ namespace OpenSim.Region.Framework.Scenes Watchdog.UpdateThread(); + otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; + + StatsReporter.AddPhysicsFPS(physicsFPS); + StatsReporter.AddTimeDilation(TimeDilation); + StatsReporter.AddFPS(1); + + StatsReporter.addAgentMS(agentMS); + StatsReporter.addPhysicsMS(physicsMS + physicsMS2); + StatsReporter.addOtherMS(otherMS); + StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); + previousFrameTick = m_lastFrameTick; m_lastFrameTick = Util.EnvironmentTickCount(); - tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); + tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); tmpMS = (int)(MinFrameTime * 1000) - tmpMS; m_firstHeartbeat = false; + sleepMS = Util.EnvironmentTickCount(); + if (tmpMS > 0) - { Thread.Sleep(tmpMS); - spareMS += tmpMS; - } - frameMS = Util.EnvironmentTickCountSubtract(maintc); - maintc = Util.EnvironmentTickCount(); - - otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; + sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); + frameMS = Util.EnvironmentTickCountSubtract(framestart); + StatsReporter.addSleepMS(sleepMS); + StatsReporter.addFrameMS(frameMS); // if (Frame%m_update_avatars == 0) // UpdateInWorldTime(); - StatsReporter.AddPhysicsFPS(physicsFPS); - StatsReporter.AddTimeDilation(TimeDilation); - StatsReporter.AddFPS(1); - StatsReporter.addFrameMS(frameMS); - StatsReporter.addAgentMS(agentMS); - StatsReporter.addPhysicsMS(physicsMS + physicsMS2); - StatsReporter.addOtherMS(otherMS); - StatsReporter.AddSpareMS(spareMS); - StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); // Optionally warn if a frame takes double the amount of time that it should. if (DebugUpdates diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 18e6ece..d6ff5a2 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -164,7 +164,7 @@ namespace OpenSim.Region.Framework.Scenes // saved last reported value so there is something available for llGetRegionFPS private float lastReportedSimFPS; - private float[] lastReportedSimStats = new float[22]; + private float[] lastReportedSimStats = new float[23]; private float m_pfps; /// @@ -178,12 +178,13 @@ namespace OpenSim.Region.Framework.Scenes private int m_objectUpdates; private int m_frameMS; - private int m_spareMS; + private int m_netMS; private int m_agentMS; private int m_physicsMS; private int m_imageMS; private int m_otherMS; + private int m_sleeptimeMS; //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. //Ckrinke private int m_scriptMS = 0; @@ -260,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes private void statsHeartBeat(object sender, EventArgs e) { - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); // Know what's not thread safe in Mono... modifying timers. @@ -298,6 +299,8 @@ namespace OpenSim.Region.Framework.Scenes physfps = 0; #endregion + float factor = 1 / m_statsUpdateFactor; + if (reportedFPS <= 0) reportedFPS = 1; @@ -308,9 +311,22 @@ namespace OpenSim.Region.Framework.Scenes float targetframetime = 1100.0f / (float)m_nominalReportedFps; float sparetime; + float sleeptime; + if (TotalFrameTime > targetframetime) { sparetime = 0; + sleeptime = 0; + } + else + { + sparetime = m_frameMS - m_physicsMS - m_agentMS; + sparetime *= perframe; + if (sparetime < 0) + sparetime = 0; + else if (sparetime > TotalFrameTime) + sparetime = TotalFrameTime; + sleeptime = m_sleeptimeMS * perframe; } m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); @@ -327,19 +343,11 @@ namespace OpenSim.Region.Framework.Scenes // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; // m_imageMS m_netMS are not included in m_frameMS - m_otherMS = m_frameMS - m_physicsMS - m_agentMS; + m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; if (m_otherMS < 0) m_otherMS = 0; - uint thisFrame = m_scene.Frame; - float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; - m_lastUpdateFrame = thisFrame; - - // Avoid div-by-zero if somehow we've not updated any frames. - if (framesUpdated == 0) - framesUpdated = 1; - - for (int i = 0; i < 22; i++) + for (int i = 0; i < 23; i++) { sb[i] = new SimStatsPacket.StatBlock(); } @@ -369,19 +377,19 @@ namespace OpenSim.Region.Framework.Scenes sb[7].StatValue = m_activePrim; sb[8].StatID = (uint)Stats.FrameMS; - sb[8].StatValue = m_frameMS / framesUpdated; + sb[8].StatValue = TotalFrameTime; sb[9].StatID = (uint)Stats.NetMS; - sb[9].StatValue = m_netMS / framesUpdated; + sb[9].StatValue = m_netMS * perframe; sb[10].StatID = (uint)Stats.PhysicsMS; - sb[10].StatValue = m_physicsMS / framesUpdated; + sb[10].StatValue = m_physicsMS * perframe; sb[11].StatID = (uint)Stats.ImageMS ; - sb[11].StatValue = m_imageMS / framesUpdated; + sb[11].StatValue = m_imageMS * perframe; sb[12].StatID = (uint)Stats.OtherMS; - sb[12].StatValue = m_otherMS / framesUpdated; + sb[12].StatValue = m_otherMS * perframe; sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); @@ -393,7 +401,7 @@ namespace OpenSim.Region.Framework.Scenes sb[15].StatValue = m_unAckedBytes; sb[16].StatID = (uint)Stats.AgentMS; - sb[16].StatValue = m_agentMS / framesUpdated; + sb[16].StatValue = m_agentMS * perframe; sb[17].StatID = (uint)Stats.PendingDownloads; sb[17].StatValue = m_pendingDownloads; @@ -408,7 +416,10 @@ namespace OpenSim.Region.Framework.Scenes sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; sb[21].StatID = (uint)Stats.SimSpareMs; - sb[21].StatValue = m_spareMS / framesUpdated; + sb[21].StatValue = sparetime; + + sb[22].StatID = (uint)Stats.SimSleepMs; + sb[22].StatValue = sleeptime; for (int i = 0; i < 22; i++) { @@ -441,13 +452,14 @@ namespace OpenSim.Region.Framework.Scenes // Need to change things so that stats source can indicate whether they are per second or // per frame. if (tuple.Key.EndsWith("MS")) - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; else m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; } } } +// LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; ResetValues(); } } @@ -470,7 +482,8 @@ namespace OpenSim.Region.Framework.Scenes m_physicsMS = 0; m_imageMS = 0; m_otherMS = 0; - m_spareMS = 0; +// m_spareMS = 0; + m_sleeptimeMS = 0; //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. //Ckrinke m_scriptMS = 0; @@ -549,11 +562,6 @@ namespace OpenSim.Region.Framework.Scenes m_frameMS += ms; } - public void AddSpareMS(int ms) - { - m_spareMS += ms; - } - public void addNetMS(int ms) { m_netMS += ms; @@ -579,6 +587,11 @@ namespace OpenSim.Region.Framework.Scenes m_otherMS += ms; } + public void addSleepMS(int ms) + { + m_sleeptimeMS += ms; + } + public void AddPendingDownloads(int count) { m_pendingDownloads += count; -- cgit v1.1 From 1ff498266cd5ecc4ed8f3b1de86758b78a327f61 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 05:25:34 +0100 Subject: minor changes, removed extra parts physics updates on linking nonroot prims --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f1f94a7..6ab0027 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3066,7 +3066,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = linkNum; // Compute the new position of this SOP relative to the group position - part.OffsetPosition = part.GroupPosition - AbsolutePosition; + part.OffsetPosition = newPos - AbsolutePosition; // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. // It would have the affect of setting the physics engine position multiple @@ -3087,7 +3087,8 @@ namespace OpenSim.Region.Framework.Scenes // Since this SOP's state has changed, push those changes into the physics engine // and the simulator. - part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); + // done on caller +// part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); } /// -- cgit v1.1 From b35f97db4658f0dd4af0ad1f56a6303d6d45d51e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 17 Jul 2012 10:21:12 +0200 Subject: Replace PollServiceRequestManager with older version, add extra logging to event exceptions to see call path leading up to it. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 76a952b..d783e57 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -1210,6 +1210,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat( "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", e.Message, e.StackTrace); + m_log.ErrorFormat(Environment.StackTrace); } } } -- cgit v1.1 From 9e00e2ddecdafa489de0ae67b78cf6971e55fe80 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 23 Jul 2012 21:08:02 +0200 Subject: Change attachment handling to remove object from the scene first as per justincc's original work. Sample scripts before doing so. Also refactor some crucial common code and eliminate parameters that were only ever used with the same constant value. --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 +----------- .../Scenes/Serialization/SceneObjectSerializer.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f501828..ad9e91d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3461,17 +3461,7 @@ namespace OpenSim.Region.Framework.Scenes { if (AttachmentsModule != null) { - // Don't save attachments for HG visitors, it - // messes up their inventory. When a HG visitor logs - // out on a foreign grid, their attachments will be - // reloaded in the state they were in when they left - // the home grid. This is best anyway as the visited - // grid may use an incompatible script engine. - bool saveChanged - = avatar.PresenceType != PresenceType.Npc - && (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID)); - - AttachmentsModule.DeRezAttachments(avatar, saveChanged, false); + AttachmentsModule.DeRezAttachments(avatar); } ForEachClient( diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 2372d6b..0d292e7 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -151,6 +151,24 @@ namespace OpenSim.Region.Framework.Scenes.Serialization ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false); } + public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, string scriptedState) + { + using (StringWriter sw = new StringWriter()) + { + using (XmlTextWriter writer = new XmlTextWriter(sw)) + { + writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); + + ToOriginalXmlFormat(sceneObject, writer, false, true); + + writer.WriteRaw(scriptedState); + + writer.WriteEndElement(); + } + return sw.ToString(); + } + } + /// /// Serialize a scene object to the original xml format /// -- cgit v1.1 From 45b72bf01c99697e65b6cda5515bbadc4a9442da Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 28 Jul 2012 01:06:28 +0100 Subject: Fix some merge issues and a functional issue in the scene manager --- OpenSim/Region/Framework/Scenes/SceneManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index a412414..f1b09ca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -192,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes private void HandleRegionReadyStatusChange(IScene scene) { lock (m_localScenes) - AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); + AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0; } public void SendSimOnlineNotification(ulong regionHandle) -- cgit v1.1 From 729046e1ade1dd4c65fbeaf849d7788233593ad2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 29 Jul 2012 15:10:12 +0200 Subject: See that if controls are taken, those are released before taking new ones --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e27d309..89df0ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3816,6 +3816,9 @@ namespace OpenSim.Region.Framework.Scenes if (p == null) return; + ControllingClient.SendTakeControls(controls, false, false); + ControllingClient.SendTakeControls(controls, true, false); + ScriptControllers obj = new ScriptControllers(); obj.ignoreControls = ScriptControlled.CONTROL_ZERO; obj.eventControls = ScriptControlled.CONTROL_ZERO; -- cgit v1.1 From 30784ab9e15a65e67bba8a75cf4e8786064bc12d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 29 Jul 2012 15:12:03 +0200 Subject: Fix an exception while outputting a log message --- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 5d8447b..775a4c2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.WarnFormat( "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", - x / Constants.RegionSize, y / Constants.RegionSize); + m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize); } } -- cgit v1.1 From bd262fe3eda78e97c00bfc285a7c4a7214268de8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jul 2012 03:05:57 +0200 Subject: Correct StandUp position and rotation --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 89df0ce..cdabd45 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1952,7 +1952,9 @@ namespace OpenSim.Region.Framework.Scenes // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); // ParentPosition = Vector3.Zero; - m_pos += part.GetWorldPosition() + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + if (part.SitTargetAvatar == UUID) + m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; ParentID = 0; ParentPart = null; -- cgit v1.1 From e40e1dc9e6739aa927ae0e752bd9d6d9de714ca5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 31 Jul 2012 23:38:01 +0200 Subject: Reverse a senseless change in the prioritizer. Why I would want avatars to render according to their camera position is beyond me. --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 0a34a4c..ddae073 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -212,9 +212,15 @@ namespace OpenSim.Region.Framework.Scenes } // Use the camera position for local agents and avatar position for remote agents - Vector3 presencePos = (presence.IsChildAgent) ? - presence.AbsolutePosition : - presence.CameraPosition; + // Why would I want that? They could be camming but I still see them at the + // avatar position, so why should I update them as if they were at their + // camera positions? Makes no sense! + // TODO: Fix this mess + //Vector3 presencePos = (presence.IsChildAgent) ? + // presence.AbsolutePosition : + // presence.CameraPosition; + + Vector3 presencePos = presence.AbsolutePosition; // Compute the distance... double distance = Vector3.Distance(presencePos, entityPos); -- cgit v1.1 From 3460319f1e4eab5529df83f9c873a14df414d525 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Aug 2012 02:20:57 +0200 Subject: Make sure the position of a loggin-in agent is within region boundaries since out of bounds positions cause a rejection of the login. --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3a28d42..bf2db58 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3886,6 +3886,15 @@ namespace OpenSim.Region.Framework.Scenes public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { + if (posX < 0) + posX = 0; + else if (posX >= 256) + posX = 255.999f; + if (posY < 0) + posY = 0; + else if (posY >= 256) + posY = 255.999f; + reason = String.Empty; if (Permissions.IsGod(agentID)) return true; -- cgit v1.1 From a4c59b1fd2dd1fbf73a43981a9c729cef1001176 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 3 Aug 2012 15:21:29 +0100 Subject: minor change avoiding a null reference --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bf2db58..c260fb2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2966,10 +2966,12 @@ namespace OpenSim.Region.Framework.Scenes try { ScenePresence sp = GetScenePresence(agentID); - PresenceService.LogoutAgent(sp.ControllingClient.SessionId); - + if (sp != null) + { + PresenceService.LogoutAgent(sp.ControllingClient.SessionId); sp.ControllingClient.Close(); + } // BANG! SLASH! m_authenticateHandler.RemoveCircuit(agentID); -- cgit v1.1 From 83deb4603204c01fd6fc6b0a0e04afbeeae73771 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Aug 2012 16:03:40 +0200 Subject: Make WaitGetScenePresence wait for up to 20 seconds --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c260fb2..3db7c7d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4255,7 +4255,7 @@ namespace OpenSim.Region.Framework.Scenes /// protected virtual ScenePresence WaitGetScenePresence(UUID agentID) { - int ntimes = 10; + int ntimes = 20; ScenePresence sp = null; while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) Thread.Sleep(1000); -- cgit v1.1 From b95caaa453c3a6b5c27725b308061376f8d7e816 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 3 Aug 2012 20:13:51 +0100 Subject: on presence close(), release animator and OnRegionHeartbeatEnd event --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4d3ab51..47b2ead 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3585,6 +3585,13 @@ namespace OpenSim.Region.Framework.Scenes // m_reprioritizationTimer.Dispose(); RemoveFromPhysicalScene(); + + m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; + +// if (Animator != null) +// Animator.Close(); + Animator = null; + } public void AddAttachment(SceneObjectGroup gobj) -- cgit v1.1 From 7d1bec00d5cda6d7024a3d64b5913b5c08c15a3f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 01:08:30 +0200 Subject: Add a skeleton for a name value storage associated with regions --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1fc4c52..79ebc6e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -177,6 +177,8 @@ namespace OpenSim.Region.Framework.Scenes protected ICapabilitiesModule m_capsModule; protected IGroupsModule m_groupsModule; + private Dictionary m_extraSettings; + /// /// Current scene frame number /// @@ -658,6 +660,8 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new // region is set up and avoid these gyrations. RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID); + m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID); + bool updatedTerrainTextures = false; if (rs.TerrainTexture1 == UUID.Zero) { -- cgit v1.1 From da0f6b926fdc40cf729bfc3ace4367758adf8f93 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:22:16 +0200 Subject: Add support for the extra params to scene and the event manager --- OpenSim/Region/Framework/Scenes/EventManager.cs | 23 +++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 39 +++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7cb3811..eee5960 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -217,6 +217,9 @@ namespace OpenSim.Region.Framework.Scenes /// public event NewScript OnNewScript; + public delegate void ExtraSettingChangedDelegate(Scene scene, string name, string value); + public event ExtraSettingChangedDelegate OnExtraSettingChanged; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) { NewScript handlerNewScript = OnNewScript; @@ -2616,5 +2619,25 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerExtraSettingChanged(Scene scene, string name, string val) + { + ExtraSettingChangedDelegate handler = OnExtraSettingChanged; + + if (handler != null) + { + foreach (ExtraSettingChangedDelegate d in handler.GetInvocationList()) + { + try + { + d(scene, name, val); + } + catch (Exception e) + { + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for ExtraSettingChanged failed - continuing {0} - {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 79ebc6e..a5f0bff 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5854,5 +5854,44 @@ Environment.Exit(1); callback(asset); } + + public string GetExtraSetting(string name) + { + string val; + + if (!m_extraSettings.TryGetValue(name, out val)) + return String.Empty; + + return val; + } + + public void StoreExtraSetting(string name, string val) + { + string oldVal; + + if (m_extraSettings.TryGetValue(name, out oldVal)) + { + if (oldVal == val) + return; + } + + m_extraSettings[name] = val; + + m_SimulationDataService.SaveExtra(RegionInfo.RegionID, name, val); + + m_eventManager.TriggerExtraSettingChanged(this, name, val); + } + + public void RemoveExtraSetting(string name) + { + if (!m_extraSettings.ContainsKey(name)) + return; + + m_extraSettings.Remove(name); + + m_SimulationDataService.RemoveExtra(RegionInfo.RegionID, name); + + m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); + } } } -- cgit v1.1 From b97053269b33c4fc733372cf44f0f16d244d87b8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 16 Aug 2012 01:02:20 +0200 Subject: Change case of areUpdatesSuspended to upper case as is proper for a property --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 +++++++------- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e0260e2..a1da5ee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1793,7 +1793,7 @@ namespace OpenSim.Region.Framework.Scenes try { - parentGroup.areUpdatesSuspended = true; + parentGroup.AreUpdatesSuspended = true; List childGroups = new List(); @@ -1850,7 +1850,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } - parentGroup.areUpdatesSuspended = false; + parentGroup.AreUpdatesSuspended = false; parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); @@ -1896,7 +1896,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) { - group.areUpdatesSuspended = true; + group.AreUpdatesSuspended = true; affectedGroups.Add(group); } } @@ -1922,7 +1922,7 @@ namespace OpenSim.Region.Framework.Scenes // However, editing linked parts and unlinking may be different // SceneObjectGroup group = root.ParentGroup; - group.areUpdatesSuspended = true; + group.AreUpdatesSuspended = true; List newSet = new List(group.Parts); int numChildren = newSet.Count; @@ -1945,7 +1945,7 @@ namespace OpenSim.Region.Framework.Scenes group.DelinkFromGroup(p, sendEventsToRemainder); if (numChildren > 2) { - p.ParentGroup.areUpdatesSuspended = true; + p.ParentGroup.AreUpdatesSuspended = true; } else { @@ -1980,7 +1980,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart newChild in newSet) newChild.ClearUpdateSchedule(); - newRoot.ParentGroup.areUpdatesSuspended = true; + newRoot.ParentGroup.AreUpdatesSuspended = true; LinkObjects(newRoot, newSet); if (!affectedGroups.Contains(newRoot.ParentGroup)) affectedGroups.Add(newRoot.ParentGroup); @@ -1998,7 +1998,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist - g.areUpdatesSuspended = false; + g.AreUpdatesSuspended = false; g.ScheduleGroupForFullUpdate(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d837adb..4d610f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - public bool areUpdatesSuspended + public bool AreUpdatesSuspended { get { -- cgit v1.1 From bbac8f76faff387756bfa55dea83fa3bd589ef79 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 16 Aug 2012 01:18:32 +0200 Subject: Remove AreUpdatesSuspended flag because it does nothing --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 7 ------- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 17 ----------------- 2 files changed, 24 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a1da5ee..e29b2c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1793,7 +1793,6 @@ namespace OpenSim.Region.Framework.Scenes try { - parentGroup.AreUpdatesSuspended = true; List childGroups = new List(); @@ -1850,7 +1849,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } - parentGroup.AreUpdatesSuspended = false; parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); @@ -1896,7 +1894,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) { - group.AreUpdatesSuspended = true; affectedGroups.Add(group); } } @@ -1922,7 +1919,6 @@ namespace OpenSim.Region.Framework.Scenes // However, editing linked parts and unlinking may be different // SceneObjectGroup group = root.ParentGroup; - group.AreUpdatesSuspended = true; List newSet = new List(group.Parts); int numChildren = newSet.Count; @@ -1945,7 +1941,6 @@ namespace OpenSim.Region.Framework.Scenes group.DelinkFromGroup(p, sendEventsToRemainder); if (numChildren > 2) { - p.ParentGroup.AreUpdatesSuspended = true; } else { @@ -1980,7 +1975,6 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart newChild in newSet) newChild.ClearUpdateSchedule(); - newRoot.ParentGroup.AreUpdatesSuspended = true; LinkObjects(newRoot, newSet); if (!affectedGroups.Contains(newRoot.ParentGroup)) affectedGroups.Add(newRoot.ParentGroup); @@ -1998,7 +1992,6 @@ namespace OpenSim.Region.Framework.Scenes m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist - g.AreUpdatesSuspended = false; g.ScheduleGroupForFullUpdate(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4d610f4..6104c66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -113,25 +113,8 @@ namespace OpenSim.Region.Framework.Scenes private long m_maxPersistTime = 0; private long m_minPersistTime = 0; private Random m_rand; - private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - public bool AreUpdatesSuspended - { - get - { - return m_suspendUpdates; - } - set - { - m_suspendUpdates = value; - if (!value) - { - QueueForUpdateCheck(); - } - } - } - /// /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage /// (the database). -- cgit v1.1 From f2ac1b9e8aa80a250cba46fec1aa7cf97c6caaf8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Aug 2012 16:41:08 +0200 Subject: Add Camera Offsets to serialization --- .../Scenes/Serialization/SceneObjectSerializer.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 0d292e7..134bd9d 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -386,6 +386,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("Friction", ProcessFriction); m_SOPXmlProcessors.Add("Bounce", ProcessBounce); m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); + m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); + m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); #endregion @@ -639,6 +641,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); } + private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlTextReader reader) + { + obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset")); + } + + private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlTextReader reader) + { + obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); + } + private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) { SOPVehicle vehicle = SOPVehicle.FromXml2(reader); @@ -1355,6 +1367,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); if (sop.GravityModifier != 1.0f) writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); + WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); + WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); writer.WriteEndElement(); } -- cgit v1.1 From 26224704de9c641cebcc0b47197e1c5a677861cf Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Aug 2012 19:24:41 +0200 Subject: Cause a persistence save if prim flags change --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6104c66..cb4aa2d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3306,6 +3306,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) { + HasGroupChanged = true; + SceneObjectPart selectionPart = GetPart(localID); if (SetTemporary && Scene != null) -- cgit v1.1 From 526445c39456763577d0b013ccab8af16a9edee0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 21 Aug 2012 23:28:00 +0200 Subject: Fix group return stuff --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0b73df5..f8c0431 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2050,7 +2050,7 @@ namespace OpenSim.Region.Framework.Scenes if (Permissions.CanReturnObjects( null, remoteClient.AgentId, - deleteGroups)) + new List() {grp})) { permissionToTake = true; permissionToDelete = true; -- cgit v1.1 From 450207d4d8004aadbbc7146869132e8245d58ada Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 22 Aug 2012 00:27:54 +0200 Subject: Make terrain save every 1000 frames instead of every 50. Database load is a sim killer. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a5f0bff..57fcf51 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -215,7 +215,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_update_presences = 1; // Update scene presence movements private int m_update_events = 1; private int m_update_backup = 200; - private int m_update_terrain = 50; + private int m_update_terrain = 1000; private int m_update_land = 10; private int m_update_coarse_locations = 50; -- cgit v1.1 From c1a0c7fad17bb2aead1539b61fe82fee16686190 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Aug 2012 23:09:32 +0200 Subject: Fix bad child prim permissions that can make objects change perms after rezzing --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 +++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 18 +++++++++++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f8c0431..1309623 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1983,6 +1983,9 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup grp = part.ParentGroup; + // If child prims have invalid perms, fix them + grp.AdjustChildPrimPermissions(); + if (remoteClient == null) { // Autoreturn has a null client. Nothing else does. So diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cb4aa2d..eee53d7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2852,6 +2852,9 @@ namespace OpenSim.Region.Framework.Scenes // Can't do this yet since backup still makes use of the root part without any synchronization // objectGroup.m_rootPart = null; + // If linking prims with different permissions, fix them + AdjustChildPrimPermissions(); + AttachToBackup(); // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the @@ -3391,12 +3394,21 @@ namespace OpenSim.Region.Framework.Scenes } } + public void AdjustChildPrimPermissions() + { + ForEachPart(part => + { + if (part != RootPart) + part.ClonePermissions(RootPart); + }); + } + public void UpdatePermissions(UUID AgentID, byte field, uint localID, uint mask, byte addRemTF) { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].UpdatePermissions(AgentID, field, localID, mask, addRemTF); + RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); + + AdjustChildPrimPermissions(); HasGroupChanged = true; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ce652b4..ed626d0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4487,6 +4487,27 @@ namespace OpenSim.Region.Framework.Scenes } } + public void ClonePermissions(SceneObjectPart source) + { + bool update = false; + + if (BaseMask != source.BaseMask || + OwnerMask != source.OwnerMask || + GroupMask != source.GroupMask || + EveryoneMask != source.EveryoneMask || + NextOwnerMask != source.NextOwnerMask) + update = true; + + BaseMask = source.BaseMask; + OwnerMask = source.OwnerMask; + GroupMask = source.GroupMask; + EveryoneMask = source.EveryoneMask; + NextOwnerMask = source.NextOwnerMask; + + if (update) + SendFullUpdateToAllClients(); + } + public bool IsHingeJoint() { // For now, we use the NINJA naming scheme for identifying joints. -- cgit v1.1 From 1eb1c1bd4bc972e2df301b9dafb40fbb2f37b40c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 Aug 2012 18:19:51 +0100 Subject: renaming to be similar to equivalent Set command Conflicts: OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fcc2953..5b529c3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3737,7 +3737,7 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", sp.Name, sp.UUID, RegionInfo.RegionName); - sp.ControllingClient.Close(true); + sp.ControllingClient.Close(true, true); sp = null; } -- cgit v1.1 From b1d0fab954545e1ed9aa13c0c760b3371042c437 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Aug 2012 20:33:45 +0100 Subject: fix incoerence btw KFM_TRANSLATION and ROTATION LSL constants and internal DataFormat enum, using values from the KFM constants --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index b7b0d27..6ee09b7 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -38,8 +38,8 @@ namespace OpenSim.Region.Framework.Scenes [Flags] public enum DataFormat : int { - Translation = 1, - Rotation = 2 + Translation = 2, + Rotation = 1 } [Serializable] -- cgit v1.1 From ef6e007a4c7301dbd7a1a0392a07664e7034201b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 28 Aug 2012 03:21:03 +0100 Subject: [possible still very broken] mess around keyframes. timer events threads overlaps, some null objects exceptions, region crossing... --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 368 +++++++++++++++------ OpenSim/Region/Framework/Scenes/Scene.cs | 6 + .../Region/Framework/Scenes/SceneObjectGroup.cs | 29 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +- .../Scenes/Serialization/SceneObjectSerializer.cs | 2 +- 5 files changed, 299 insertions(+), 111 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 6ee09b7..4e6425f 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -58,12 +58,31 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_serializedPosition; private Keyframe m_currentFrame; + private List m_frames = new List(); private Keyframe[] m_keyframes; [NonSerialized()] - protected Timer m_timer = new Timer(); + protected Timer m_timer = null; + + // timer lock + [NonSerialized()] + private object m_onTimerLock; + + // timer overrun detect + // prevents overlap or timer events threads frozen on the lock + [NonSerialized()] + private bool m_inOnTimer; + + // skip timer events. + //timer.stop doesn't assure there aren't event threads still being fired + [NonSerialized()] + private bool m_skipOnTimer; + + // retry position for cross fail + [NonSerialized()] + private Vector3 m_nextPosition; [NonSerialized()] private SceneObjectGroup m_group; @@ -88,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes { set { - if (value) + if (!value) { // Once we're let go, recompute positions if (m_selected) @@ -100,7 +119,8 @@ namespace OpenSim.Region.Framework.Scenes if (!m_selected) m_serializedPosition = m_group.AbsolutePosition; } - m_selected = value; } + m_selected = value; + } } public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) @@ -111,31 +131,65 @@ namespace OpenSim.Region.Framework.Scenes KeyframeMotion newMotion = (KeyframeMotion)fmt.Deserialize(ms); +/* + * create timer in start() + * this was creating unneeded timers + // This will be started when position is updated + newMotion.m_timer = new Timer(); newMotion.m_timer.Interval = (int)timerInterval; newMotion.m_timer.AutoReset = true; newMotion.m_timer.Elapsed += newMotion.OnTimer; +*/ + newMotion.m_group = grp; + if (grp != null && grp.IsSelected) + newMotion.m_selected = true; + + newMotion.m_onTimerLock = new object(); + newMotion.m_skipOnTimer = false; + newMotion.m_inOnTimer = false; return newMotion; } public void UpdateSceneObject(SceneObjectGroup grp) { - m_group = grp; - Vector3 offset = grp.AbsolutePosition - m_serializedPosition; - - m_basePosition += offset; - m_currentFrame.Position += offset; - for (int i = 0 ; i < m_frames.Count ; i++) +// lock (m_onTimerLock) { - Keyframe k = m_frames[i]; - k.Position += offset; - m_frames[i] = k; - } + m_skipOnTimer = true; + if (m_timer != null) + m_timer.Stop(); + + m_group = grp; + Vector3 grppos = grp.AbsolutePosition; + Vector3 offset = grppos - m_serializedPosition; + // avoid doing it more than once + // current this will happen draging a prim to other region + m_serializedPosition = grppos; + + m_basePosition += offset; + m_currentFrame.Position += offset; + + m_nextPosition += offset; +/* + for (int i = 0; i < m_frames.Count; i++) + { + Keyframe k = m_frames[i]; + k.Position += offset; + m_frames[i] = k; + } +*/ + for (int i = 0; i < m_frames.Count; i++) + { + Keyframe k = m_frames[i]; + k.Position += offset; + m_frames[i]=k; + } - if (m_running) - Start(); + if (m_running) + Start(); + } } public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) @@ -143,13 +197,16 @@ namespace OpenSim.Region.Framework.Scenes m_mode = mode; m_data = data; + m_onTimerLock = new object(); + m_group = grp; m_basePosition = grp.AbsolutePosition; m_baseRotation = grp.GroupRotation; - +/* m_timer.Interval = (int)timerInterval; m_timer.AutoReset = true; m_timer.Elapsed += OnTimer; + */ } public void SetKeyframes(Keyframe[] frames) @@ -157,19 +214,63 @@ namespace OpenSim.Region.Framework.Scenes m_keyframes = frames; } + public void Delete() + { + m_skipOnTimer = true; + m_frames.Clear(); + m_keyframes = null; + m_running = false; + + if (m_timer == null) + return; + + m_timer.Stop(); + m_timer.Elapsed -= OnTimer; + m_timer = null; + } + public void Start() { if (m_keyframes.Length > 0) + { + if (m_timer == null) + { + m_timer = new Timer(); + m_timer.Interval = (int)timerInterval; + m_timer.AutoReset = true; + m_timer.Elapsed += OnTimer; + } + + m_skipOnTimer = false; + m_inOnTimer = false; + m_timer.Start(); - m_running = true; + m_running = true; + } + else + { + m_running = false; + m_skipOnTimer = true; + if (m_timer != null) + { + m_timer.Stop(); + m_timer.Elapsed -= OnTimer; + m_timer = null; + } + } } public void Stop() { + m_skipOnTimer = true; + // Failed object creation if (m_timer == null) return; + m_timer.Stop(); + m_timer.Elapsed -= OnTimer; + m_timer = null; m_basePosition = m_group.AbsolutePosition; m_baseRotation = m_group.GroupRotation; @@ -184,6 +285,8 @@ namespace OpenSim.Region.Framework.Scenes public void Pause() { + m_skipOnTimer = true; + m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); m_group.SendGroupRootTerseUpdate(); @@ -284,138 +387,197 @@ namespace OpenSim.Region.Framework.Scenes protected void OnTimer(object sender, ElapsedEventArgs e) { - if (m_frames.Count == 0) - { - GetNextList(); - - if (m_frames.Count == 0) - { - Stop(); - return; - } - - m_currentFrame = m_frames[0]; - } - - if (m_selected) + if (m_inOnTimer) { - if (m_group.RootPart.Velocity != Vector3.Zero) - { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); - } + m_log.Error("[KeyFrame]: timer overrun"); return; } - // Do the frame processing - double steps = (double)m_currentFrame.TimeMS / timerInterval; - float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; - - if (steps <= 1.0) +// lock (m_onTimerLock) { - m_currentFrame.TimeMS = 0; - - m_group.AbsolutePosition = (Vector3)m_currentFrame.Position; - m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); - } - else - { - Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; - Vector3 motionThisFrame = v / (float)steps; - v = v * 1000 / m_currentFrame.TimeMS; - - bool update = false; + if (m_skipOnTimer) + return; - if (Vector3.Mag(motionThisFrame) >= 0.05f) + m_inOnTimer = true; + try { - m_group.AbsolutePosition += motionThisFrame; - m_group.RootPart.Velocity = v; - update = true; - } + if (m_frames.Count == 0) + { + GetNextList(); - if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) - { - Quaternion current = m_group.GroupRotation; + if (m_frames.Count == 0) + { + Stop(); + m_inOnTimer = false; + return; + } - Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); + m_currentFrame = m_frames[0]; + } - float angle = 0; + if (m_selected) + { + if (m_group.RootPart.Velocity != Vector3.Zero) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + } + m_inOnTimer = false; + return; + } - float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; - float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; - float aa_bb = aa * bb; + // Do the frame processing + double steps = (double)m_currentFrame.TimeMS / timerInterval; + float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; - if (aa_bb == 0) + if (steps <= 1.0) { - angle = 0; + m_currentFrame.TimeMS = 0; + + // m_group.AbsolutePosition = (Vector3)m_currentFrame.Position; + m_nextPosition = (Vector3)m_currentFrame.Position; + m_group.AbsolutePosition = m_nextPosition; + + m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); } else { - float ab = current.X * step.X + - current.Y * step.Y + - current.Z * step.Z + - current.W * step.W; - float q = (ab * ab) / aa_bb; + Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; + Vector3 motionThisFrame = v / (float)steps; + v = v * 1000 / m_currentFrame.TimeMS; - if (q > 1.0f) + bool update = false; + + if (Vector3.Mag(motionThisFrame) >= 0.05f) { - angle = 0; + // m_group.AbsolutePosition += motionThisFrame; + m_nextPosition = m_group.AbsolutePosition + motionThisFrame; + m_group.AbsolutePosition = m_nextPosition; + + m_group.RootPart.Velocity = v; + update = true; } - else + + if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) { - angle = (float)Math.Acos(2 * q - 1); + Quaternion current = m_group.GroupRotation; + + Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); + + float angle = 0; + + float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; + float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; + float aa_bb = aa * bb; + + if (aa_bb == 0) + { + angle = 0; + } + else + { + float ab = current.X * step.X + + current.Y * step.Y + + current.Z * step.Z + + current.W * step.W; + float q = (ab * ab) / aa_bb; + + if (q > 1.0f) + { + angle = 0; + } + else + { + angle = (float)Math.Acos(2 * q - 1); + } + } + + if (angle > 0.01f) + { + m_group.UpdateGroupRotationR(step); + //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); + update = true; + } } + + if (update) + m_group.SendGroupRootTerseUpdate(); } - if (angle > 0.01f) + m_currentFrame.TimeMS -= (int)timerInterval; + + if (m_currentFrame.TimeMS <= 0) { - m_group.UpdateGroupRotationR(step); - //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); - update = true; + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + m_group.SendGroupRootTerseUpdate(); + + m_frames.RemoveAt(0); + if (m_frames.Count > 0) + m_currentFrame = m_frames[0]; } } - - if (update) - m_group.SendGroupRootTerseUpdate(); + finally + { + m_inOnTimer = false; + } } + } - m_currentFrame.TimeMS -= (int)timerInterval; - - if (m_currentFrame.TimeMS <= 0) + public Byte[] Serialize(bool StopMoveTimer) + { + MemoryStream ms = new MemoryStream(); + if (StopMoveTimer && m_timer != null) { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); - m_group.SendGroupRootTerseUpdate(); + m_skipOnTimer = true; + m_timer.Stop(); + } - m_frames.RemoveAt(0); - if (m_frames.Count > 0) - m_currentFrame = m_frames[0]; +// lock (m_onTimerLock) + { + BinaryFormatter fmt = new BinaryFormatter(); + SceneObjectGroup tmp = m_group; + m_group = null; + if(!m_selected) + m_serializedPosition = tmp.AbsolutePosition; + fmt.Serialize(ms, this); + m_group = tmp; + return ms.ToArray(); } } - public Byte[] Serialize() + public void StartCrossingCheck() { - MemoryStream ms = new MemoryStream(); - m_timer.Stop(); + m_skipOnTimer = true; + if (m_timer != null) + m_timer.Stop(); - BinaryFormatter fmt = new BinaryFormatter(); - SceneObjectGroup tmp = m_group; - m_group = null; - m_serializedPosition = tmp.AbsolutePosition; - fmt.Serialize(ms, this); - m_group = tmp; - return ms.ToArray(); + if (m_group.RootPart.Velocity != Vector3.Zero) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + } } public void CrossingFailure() { // The serialization has stopped the timer, so let's wait a moment // then retry the crossing. We'll get back here if it fails. + // if it is a open border there is no serialization + // so make sure timer is actually stopped + + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + Util.FireAndForget(delegate (object x) { Thread.Sleep(60000); if (m_running) + { + m_skipOnTimer = false; m_timer.Start(); + m_group.AbsolutePosition = m_nextPosition; + } }); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 57fcf51..0237021 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2346,6 +2346,12 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart part in partList) { + if (part.KeyframeMotion != null) + { + part.KeyframeMotion.Delete(); + part.KeyframeMotion = null; + } + if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) { PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index eee53d7..65a1da2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -509,6 +509,9 @@ namespace OpenSim.Region.Framework.Scenes Vector3 newpos = Vector3.Zero; OpenSim.Services.Interfaces.GridRegion destination = null; + if (m_rootPart.KeyframeMotion != null) + m_rootPart.KeyframeMotion.StartCrossingCheck(); + bool canCross = true; foreach (ScenePresence av in m_linkedAvatars) { @@ -551,7 +554,7 @@ namespace OpenSim.Region.Framework.Scenes av.ParentID = 0; } -// m_linkedAvatars.Clear(); + // m_linkedAvatars.Clear(); m_scene.CrossPrimGroupIntoNewRegion(val, this, true); // Normalize @@ -599,11 +602,16 @@ namespace OpenSim.Region.Framework.Scenes avsToCross.Clear(); } - else if (RootPart.PhysActor != null) + else { - RootPart.PhysActor.CrossingFailure(); - } + if (m_rootPart.KeyframeMotion != null) + m_rootPart.KeyframeMotion.CrossingFailure(); + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.CrossingFailure(); + } + } Vector3 oldp = AbsolutePosition; val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); @@ -2058,8 +2066,8 @@ namespace OpenSim.Region.Framework.Scenes { if (part.KeyframeMotion != null) { - part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); - part.KeyframeMotion.UpdateSceneObject(this); + part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize(false)); +// part.KeyframeMotion.UpdateSceneObject(this); } }); @@ -4407,6 +4415,15 @@ namespace OpenSim.Region.Framework.Scenes public virtual ISceneObject CloneForNewScene() { SceneObjectGroup sog = Copy(false); + sog.ForEachPart(delegate(SceneObjectPart part) + { + if (part.KeyframeMotion != null) + { + part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize(true)); + // this is called later +// part.KeyframeMotion.UpdateSceneObject(this); + } + }); sog.IsDeleted = false; return sog; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ed626d0..bf5fc99 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -769,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes { m_groupPosition = value; PhysicsActor actor = PhysActor; - if (actor != null) + if (actor != null && ParentGroup.Scene.PhysicsScene != null) { try { @@ -3408,6 +3408,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { + if (ParentGroup == null || ParentGroup.Scene == null) + return; + ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { SendTerseUpdateToClient(client); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 134bd9d..1c75607 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1241,7 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (sog.RootPart.KeyframeMotion != null) { - Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); + Byte[] data = sog.RootPart.KeyframeMotion.Serialize(true); writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); writer.WriteBase64(data, 0, data.Length); -- cgit v1.1 From 5284e514d5e71e6f1637bff133db6de73e6ff7ef Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 28 Aug 2012 22:16:01 +0200 Subject: Fix a nullref while object is being created --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index eee53d7..da312f3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3025,7 +3025,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void DetachFromBackup() { - m_scene.SceneGraph.FireDetachFromBackup(this); + if (m_scene != null) + m_scene.SceneGraph.FireDetachFromBackup(this); if (m_isBackedUp && Scene != null) m_scene.EventManager.OnBackup -= ProcessBackup; -- cgit v1.1 From 72ac0665b207f7f840b861086b3a620a9942775f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 29 Aug 2012 00:35:06 +0100 Subject: [Potentially broken] keyframes changes.. since it's there, use timer for crossing retries and not still another thread, etc... --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 280 +++++++++++++--------- 1 file changed, 165 insertions(+), 115 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 4e6425f..5333177 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -53,9 +53,9 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 AngularVelocity; }; + private Vector3 m_serializedPosition; private Vector3 m_basePosition; private Quaternion m_baseRotation; - private Vector3 m_serializedPosition; private Keyframe m_currentFrame; @@ -78,7 +78,13 @@ namespace OpenSim.Region.Framework.Scenes // skip timer events. //timer.stop doesn't assure there aren't event threads still being fired [NonSerialized()] - private bool m_skipOnTimer; + private bool m_timerStopped; + + [NonSerialized()] + private bool m_crossing; + + [NonSerialized()] + private int m_crossFailcntr; // retry position for cross fail [NonSerialized()] @@ -107,6 +113,8 @@ namespace OpenSim.Region.Framework.Scenes { set { + m_crossing = false; + m_crossFailcntr = 0; if (!value) { // Once we're let go, recompute positions @@ -117,39 +125,58 @@ namespace OpenSim.Region.Framework.Scenes { // Save selection position in case we get moved if (!m_selected) + { + StopTimer(); m_serializedPosition = m_group.AbsolutePosition; + } } m_selected = value; } } - public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) + private void StartTimer() + { + if (m_timer == null) + return; + m_timerStopped = false; + m_timer.Start(); + } + + private void StopTimer() { - MemoryStream ms = new MemoryStream(data); + if (m_timer == null || m_timerStopped) + return; + m_timerStopped = true; + m_timer.Stop(); + } - BinaryFormatter fmt = new BinaryFormatter(); + public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) + { + KeyframeMotion newMotion = null; - KeyframeMotion newMotion = (KeyframeMotion)fmt.Deserialize(ms); + try + { + MemoryStream ms = new MemoryStream(data); + BinaryFormatter fmt = new BinaryFormatter(); -/* - * create timer in start() - * this was creating unneeded timers + newMotion = (KeyframeMotion)fmt.Deserialize(ms); - // This will be started when position is updated + newMotion.m_group = grp; - newMotion.m_timer = new Timer(); - newMotion.m_timer.Interval = (int)timerInterval; - newMotion.m_timer.AutoReset = true; - newMotion.m_timer.Elapsed += newMotion.OnTimer; -*/ - newMotion.m_group = grp; + if (grp != null && grp.IsSelected) + newMotion.m_selected = true; - if (grp != null && grp.IsSelected) - newMotion.m_selected = true; + newMotion.m_onTimerLock = new object(); + newMotion.m_timerStopped = false; + newMotion.m_inOnTimer = false; + newMotion.m_crossing = false; + newMotion.m_crossFailcntr = 0; + } + catch + { + newMotion = null; + } - newMotion.m_onTimerLock = new object(); - newMotion.m_skipOnTimer = false; - newMotion.m_inOnTimer = false; return newMotion; } @@ -157,9 +184,9 @@ namespace OpenSim.Region.Framework.Scenes { // lock (m_onTimerLock) { - m_skipOnTimer = true; - if (m_timer != null) - m_timer.Stop(); + m_crossing = false; + m_crossFailcntr = 0; + StopTimer(); m_group = grp; Vector3 grppos = grp.AbsolutePosition; @@ -172,14 +199,7 @@ namespace OpenSim.Region.Framework.Scenes m_currentFrame.Position += offset; m_nextPosition += offset; -/* - for (int i = 0; i < m_frames.Count; i++) - { - Keyframe k = m_frames[i]; - k.Position += offset; - m_frames[i] = k; - } -*/ + for (int i = 0; i < m_frames.Count; i++) { Keyframe k = m_frames[i]; @@ -202,11 +222,8 @@ namespace OpenSim.Region.Framework.Scenes m_group = grp; m_basePosition = grp.AbsolutePosition; m_baseRotation = grp.GroupRotation; -/* - m_timer.Interval = (int)timerInterval; - m_timer.AutoReset = true; - m_timer.Elapsed += OnTimer; - */ + m_crossing = false; + m_crossFailcntr = 0; } public void SetKeyframes(Keyframe[] frames) @@ -216,21 +233,23 @@ namespace OpenSim.Region.Framework.Scenes public void Delete() { - m_skipOnTimer = true; + m_running = false; + m_crossing = false; + m_crossFailcntr = 0; + StopTimer(); m_frames.Clear(); m_keyframes = null; - m_running = false; if (m_timer == null) return; - - m_timer.Stop(); m_timer.Elapsed -= OnTimer; m_timer = null; } public void Start() { + m_crossing = false; + m_crossFailcntr = 0; if (m_keyframes.Length > 0) { if (m_timer == null) @@ -241,19 +260,16 @@ namespace OpenSim.Region.Framework.Scenes m_timer.Elapsed += OnTimer; } - m_skipOnTimer = false; m_inOnTimer = false; - - m_timer.Start(); + StartTimer(); m_running = true; } else { m_running = false; - m_skipOnTimer = true; if (m_timer != null) { - m_timer.Stop(); + StopTimer(); m_timer.Elapsed -= OnTimer; m_timer = null; } @@ -262,13 +278,11 @@ namespace OpenSim.Region.Framework.Scenes public void Stop() { - m_skipOnTimer = true; - - // Failed object creation - if (m_timer == null) - return; + m_running = false; + m_crossing = false; + m_crossFailcntr = 0; - m_timer.Stop(); + StopTimer(); m_timer.Elapsed -= OnTimer; m_timer = null; @@ -280,19 +294,17 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); m_frames.Clear(); - m_running = false; } public void Pause() { - m_skipOnTimer = true; + m_running = false; + m_crossFailcntr = 0; + StopTimer(); m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); m_group.SendGroupRootTerseUpdate(); - - m_timer.Stop(); - m_running = false; } private void GetNextList() @@ -325,9 +337,16 @@ namespace OpenSim.Region.Framework.Scenes Keyframe k = m_keyframes[i]; if (k.Position.HasValue) - k.Position = (k.Position * direction) + pos; + { + k.Position = (k.Position * direction); +// k.Velocity = (Vector3)k.Position / (k.TimeMS / 1000.0f); + k.Position += pos; + } else + { k.Position = pos; +// k.Velocity = Vector3.Zero; + } k.StartRotation = rot; if (k.Rotation.HasValue) @@ -341,6 +360,8 @@ namespace OpenSim.Region.Framework.Scenes k.Rotation = rot; } +/* ang vel not in use for now + float angle = 0; float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W; @@ -370,6 +391,7 @@ namespace OpenSim.Region.Framework.Scenes } k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000)); + */ k.TimeTotal = k.TimeMS; m_frames.Add(k); @@ -387,20 +409,56 @@ namespace OpenSim.Region.Framework.Scenes protected void OnTimer(object sender, ElapsedEventArgs e) { - if (m_inOnTimer) + if (m_timerStopped) // trap events still in air even after a timer.stop + return; + + if (m_inOnTimer) // don't let overruns to happen { - m_log.Error("[KeyFrame]: timer overrun"); + m_log.Warn("[KeyFrame]: timer overrun"); return; } + if (m_group == null) + return; + // lock (m_onTimerLock) { - if (m_skipOnTimer) - return; m_inOnTimer = true; + + bool update = false; + try { + if (m_selected) + { + if (m_group.RootPart.Velocity != Vector3.Zero) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + } + m_inOnTimer = false; + return; + } + + if (m_crossing) + { + // if crossing and timer running then cross failed + // wait some time then + // retry to set the position that evtually caused the outbound + // if still outside region this will call startCrossing below + m_crossing = false; + m_group.AbsolutePosition = m_nextPosition; + if (!m_crossing) + { + StopTimer(); + m_timer.Interval = timerInterval; + StartTimer(); + } + m_inOnTimer = false; + return; + } + if (m_frames.Count == 0) { GetNextList(); @@ -413,41 +471,41 @@ namespace OpenSim.Region.Framework.Scenes } m_currentFrame = m_frames[0]; - } + m_currentFrame.TimeMS += (int)timerInterval; - if (m_selected) - { - if (m_group.RootPart.Velocity != Vector3.Zero) - { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); - } - m_inOnTimer = false; - return; + //force a update on a keyframe transition + update = true; } + m_currentFrame.TimeMS -= (int)timerInterval; + // Do the frame processing double steps = (double)m_currentFrame.TimeMS / timerInterval; - float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; - if (steps <= 1.0) + if (steps <= 0.0) { - m_currentFrame.TimeMS = 0; + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); - // m_group.AbsolutePosition = (Vector3)m_currentFrame.Position; m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + + m_frames.RemoveAt(0); + if (m_frames.Count > 0) + m_currentFrame = m_frames[0]; + + update = true; } else { + float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; + Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; Vector3 motionThisFrame = v / (float)steps; v = v * 1000 / m_currentFrame.TimeMS; - bool update = false; - if (Vector3.Mag(motionThisFrame) >= 0.05f) { // m_group.AbsolutePosition += motionThisFrame; @@ -463,8 +521,8 @@ namespace OpenSim.Region.Framework.Scenes Quaternion current = m_group.GroupRotation; Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); - - float angle = 0; +/* use simpler change detection + * float angle = 0; float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; @@ -493,6 +551,12 @@ namespace OpenSim.Region.Framework.Scenes } if (angle > 0.01f) + */ + if(Math.Abs(step.X -current.X) > 0.001f + || Math.Abs(step.Y -current.Y) > 0.001f + || Math.Abs(step.Z -current.Z) > 0.001f) + // assuming w is a dependente var + { m_group.UpdateGroupRotationR(step); //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); @@ -500,25 +564,22 @@ namespace OpenSim.Region.Framework.Scenes } } - if (update) - m_group.SendGroupRootTerseUpdate(); } - m_currentFrame.TimeMS -= (int)timerInterval; - - if (m_currentFrame.TimeMS <= 0) - { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + if (update) m_group.SendGroupRootTerseUpdate(); - m_frames.RemoveAt(0); - if (m_frames.Count > 0) - m_currentFrame = m_frames[0]; - } } + catch ( Exception ex) + { + // still happening sometimes + // lets try to see what + m_log.Warn("[KeyFrame]: timer overrun" + ex.Message); + } + finally { + // make sure we do not let this frozen m_inOnTimer = false; } } @@ -528,10 +589,7 @@ namespace OpenSim.Region.Framework.Scenes { MemoryStream ms = new MemoryStream(); if (StopMoveTimer && m_timer != null) - { - m_skipOnTimer = true; - m_timer.Stop(); - } + StopTimer(); // lock (m_onTimerLock) { @@ -548,10 +606,9 @@ namespace OpenSim.Region.Framework.Scenes public void StartCrossingCheck() { - m_skipOnTimer = true; - if (m_timer != null) - m_timer.Stop(); - + StopTimer(); + m_crossing = true; +// to remove / retune to smoth crossings if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; @@ -561,24 +618,17 @@ namespace OpenSim.Region.Framework.Scenes public void CrossingFailure() { - // The serialization has stopped the timer, so let's wait a moment - // then retry the crossing. We'll get back here if it fails. - // if it is a open border there is no serialization - // so make sure timer is actually stopped - - m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); - - Util.FireAndForget(delegate (object x) + if (m_group != null) { - Thread.Sleep(60000); - if (m_running) + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + + if (m_running && m_timer != null) { - m_skipOnTimer = false; - m_timer.Start(); - m_group.AbsolutePosition = m_nextPosition; + m_timer.Interval = 60000; + StartTimer(); } - }); + } } } } -- cgit v1.1 From 2e54c3cc8f4caf6b6d056ae04419b171942a17d7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 29 Aug 2012 03:19:47 +0100 Subject: A few more changes to keyframes --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 174 +++++++++++++-------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 +- .../Scenes/Serialization/SceneObjectSerializer.cs | 2 +- 3 files changed, 116 insertions(+), 64 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 5333177..42e3860 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -81,10 +81,10 @@ namespace OpenSim.Region.Framework.Scenes private bool m_timerStopped; [NonSerialized()] - private bool m_crossing; + private bool m_isCrossing; [NonSerialized()] - private int m_crossFailcntr; + private bool m_waitingCrossing; // retry position for cross fail [NonSerialized()] @@ -112,9 +112,7 @@ namespace OpenSim.Region.Framework.Scenes public bool Selected { set - { - m_crossing = false; - m_crossFailcntr = 0; + { if (!value) { // Once we're let go, recompute positions @@ -130,6 +128,8 @@ namespace OpenSim.Region.Framework.Scenes m_serializedPosition = m_group.AbsolutePosition; } } + m_isCrossing = false; + m_waitingCrossing = false; m_selected = value; } } @@ -150,6 +150,17 @@ namespace OpenSim.Region.Framework.Scenes m_timer.Stop(); } + private void RemoveTimer() + { + if (m_timer == null) + return; + m_timerStopped = true; + m_timer.Stop(); + m_timer.Elapsed -= OnTimer; + m_timer = null; + } + + public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) { KeyframeMotion newMotion = null; @@ -169,8 +180,8 @@ namespace OpenSim.Region.Framework.Scenes newMotion.m_onTimerLock = new object(); newMotion.m_timerStopped = false; newMotion.m_inOnTimer = false; - newMotion.m_crossing = false; - newMotion.m_crossFailcntr = 0; + newMotion.m_isCrossing = false; + newMotion.m_waitingCrossing = false; } catch { @@ -184,8 +195,8 @@ namespace OpenSim.Region.Framework.Scenes { // lock (m_onTimerLock) { - m_crossing = false; - m_crossFailcntr = 0; + m_isCrossing = false; + m_waitingCrossing = false; StopTimer(); m_group = grp; @@ -220,10 +231,13 @@ namespace OpenSim.Region.Framework.Scenes m_onTimerLock = new object(); m_group = grp; - m_basePosition = grp.AbsolutePosition; - m_baseRotation = grp.GroupRotation; - m_crossing = false; - m_crossFailcntr = 0; + if (grp != null) + { + m_basePosition = grp.AbsolutePosition; + m_baseRotation = grp.GroupRotation; + } + m_isCrossing = false; + m_waitingCrossing = false; } public void SetKeyframes(Keyframe[] frames) @@ -231,34 +245,74 @@ namespace OpenSim.Region.Framework.Scenes m_keyframes = frames; } + public KeyframeMotion Copy(SceneObjectGroup newgrp) + { + StopTimer(); + + KeyframeMotion newmotion = new KeyframeMotion(newgrp, m_mode, m_data); + + if (newgrp != null && newgrp.IsSelected) + newmotion.m_selected = true; + + if (m_keyframes != null) + m_keyframes.CopyTo(newmotion.m_keyframes, 0); + + newmotion.m_frames = new List(m_frames); + newmotion.m_currentFrame = m_currentFrame; + + newmotion.m_nextPosition = m_nextPosition; + if (m_selected) + newmotion.m_serializedPosition = m_serializedPosition; + else + { + if (m_group != null) + newmotion.m_serializedPosition = m_group.AbsolutePosition; + else + newmotion.m_serializedPosition = m_serializedPosition; + } + + newmotion.m_iterations = m_iterations; + + newmotion.m_onTimerLock = new object(); + newmotion.m_timerStopped = false; + newmotion.m_inOnTimer = false; + newmotion.m_isCrossing = false; + newmotion.m_waitingCrossing = false; + + if (m_running && !m_waitingCrossing) + StartTimer(); + + return newmotion; + } + public void Delete() { m_running = false; - m_crossing = false; - m_crossFailcntr = 0; - StopTimer(); + RemoveTimer(); + m_isCrossing = false; + m_waitingCrossing = false; m_frames.Clear(); m_keyframes = null; - - if (m_timer == null) - return; - m_timer.Elapsed -= OnTimer; - m_timer = null; } public void Start() { - m_crossing = false; - m_crossFailcntr = 0; + m_isCrossing = false; + m_waitingCrossing = false; if (m_keyframes.Length > 0) { if (m_timer == null) { m_timer = new Timer(); - m_timer.Interval = (int)timerInterval; + m_timer.Interval = timerInterval; m_timer.AutoReset = true; m_timer.Elapsed += OnTimer; } + else + { + StopTimer(); + m_timer.Interval = timerInterval; + } m_inOnTimer = false; StartTimer(); @@ -267,24 +321,17 @@ namespace OpenSim.Region.Framework.Scenes else { m_running = false; - if (m_timer != null) - { - StopTimer(); - m_timer.Elapsed -= OnTimer; - m_timer = null; - } + RemoveTimer(); } } public void Stop() { m_running = false; - m_crossing = false; - m_crossFailcntr = 0; + m_isCrossing = false; + m_waitingCrossing = false; - StopTimer(); - m_timer.Elapsed -= OnTimer; - m_timer = null; + RemoveTimer(); m_basePosition = m_group.AbsolutePosition; m_baseRotation = m_group.GroupRotation; @@ -299,8 +346,7 @@ namespace OpenSim.Region.Framework.Scenes public void Pause() { m_running = false; - m_crossFailcntr = 0; - StopTimer(); + RemoveTimer(); m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); @@ -421,7 +467,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group == null) return; -// lock (m_onTimerLock) + lock (m_onTimerLock) { m_inOnTimer = true; @@ -441,15 +487,15 @@ namespace OpenSim.Region.Framework.Scenes return; } - if (m_crossing) + if (m_isCrossing) { // if crossing and timer running then cross failed // wait some time then // retry to set the position that evtually caused the outbound // if still outside region this will call startCrossing below - m_crossing = false; + m_isCrossing = false; m_group.AbsolutePosition = m_nextPosition; - if (!m_crossing) + if (!m_isCrossing) { StopTimer(); m_timer.Interval = timerInterval; @@ -552,9 +598,9 @@ namespace OpenSim.Region.Framework.Scenes if (angle > 0.01f) */ - if(Math.Abs(step.X -current.X) > 0.001f - || Math.Abs(step.Y -current.Y) > 0.001f - || Math.Abs(step.Z -current.Z) > 0.001f) + if(Math.Abs(step.X - current.X) > 0.001f + || Math.Abs(step.Y - current.Y) > 0.001f + || Math.Abs(step.Z - current.Z) > 0.001f) // assuming w is a dependente var { @@ -563,7 +609,6 @@ namespace OpenSim.Region.Framework.Scenes update = true; } } - } if (update) @@ -573,7 +618,7 @@ namespace OpenSim.Region.Framework.Scenes catch ( Exception ex) { // still happening sometimes - // lets try to see what + // lets try to see where m_log.Warn("[KeyFrame]: timer overrun" + ex.Message); } @@ -585,29 +630,34 @@ namespace OpenSim.Region.Framework.Scenes } } - public Byte[] Serialize(bool StopMoveTimer) + public Byte[] Serialize() { + StopTimer(); MemoryStream ms = new MemoryStream(); - if (StopMoveTimer && m_timer != null) - StopTimer(); -// lock (m_onTimerLock) - { - BinaryFormatter fmt = new BinaryFormatter(); - SceneObjectGroup tmp = m_group; - m_group = null; - if(!m_selected) - m_serializedPosition = tmp.AbsolutePosition; - fmt.Serialize(ms, this); - m_group = tmp; - return ms.ToArray(); - } + BinaryFormatter fmt = new BinaryFormatter(); + SceneObjectGroup tmp = m_group; + m_group = null; + if (!m_selected && tmp != null) + m_serializedPosition = tmp.AbsolutePosition; + fmt.Serialize(ms, this); + m_group = tmp; + if (m_running && !m_waitingCrossing) + StartTimer(); + + return ms.ToArray(); } public void StartCrossingCheck() { + // timer will be restart by crossingFailure + // or never since crossing worked and this + // should be deleted StopTimer(); - m_crossing = true; + + m_isCrossing = true; + m_waitingCrossing = true; + // to remove / retune to smoth crossings if (m_group.RootPart.Velocity != Vector3.Zero) { @@ -618,6 +668,8 @@ namespace OpenSim.Region.Framework.Scenes public void CrossingFailure() { + m_waitingCrossing = false; + if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 65a1da2..834d27b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2066,7 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes { if (part.KeyframeMotion != null) { - part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize(false)); + part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); // part.KeyframeMotion.UpdateSceneObject(this); } }); @@ -4419,7 +4419,7 @@ namespace OpenSim.Region.Framework.Scenes { if (part.KeyframeMotion != null) { - part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize(true)); + part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize()); // this is called later // part.KeyframeMotion.UpdateSceneObject(this); } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 1c75607..123c158 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1241,7 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (sog.RootPart.KeyframeMotion != null) { - Byte[] data = sog.RootPart.KeyframeMotion.Serialize(true); + Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); writer.WriteBase64(data, 0, data.Length); -- cgit v1.1 From 211f4fb4114b2b26abe9c056bca9f6159ccbd125 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 30 Aug 2012 00:34:12 +0200 Subject: Sequence inventory descendents requests to reduce inventory server load and movement lag. --- .../Framework/Scenes/Scene.PacketHandlers.cs | 60 ++++++++++++++++++++-- 1 file changed, 55 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 431b903..e970543 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -422,6 +422,20 @@ namespace OpenSim.Region.Framework.Scenes ); } + private class DescendentsRequestData + { + public IClientAPI RemoteClient; + public UUID FolderID; + public UUID OwnerID; + public bool FetchFolders; + public bool FetchItems; + public int SortOrder; + } + + private Queue m_descendentsRequestQueue = new Queue(); + private Object m_descendentsRequestLock = new Object(); + private bool m_descendentsRequestProcessing = false; + /// /// Tell the client about the various child items and folders contained in the requested folder. /// @@ -458,17 +472,38 @@ namespace OpenSim.Region.Framework.Scenes } } - // We're going to send the reply async, because there may be - // an enormous quantity of packets -- basically the entire inventory! - // We don't want to block the client thread while all that is happening. - SendInventoryDelegate d = SendInventoryAsync; - d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); + lock (m_descendentsRequestLock) + { + if (!m_descendentsRequestProcessing) + { + m_descendentsRequestProcessing = true; + + // We're going to send the reply async, because there may be + // an enormous quantity of packets -- basically the entire inventory! + // We don't want to block the client thread while all that is happening. + SendInventoryDelegate d = SendInventoryAsync; + d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); + + return; + } + + DescendentsRequestData req = new DescendentsRequestData(); + req.RemoteClient = remoteClient; + req.FolderID = folderID; + req.OwnerID = ownerID; + req.FetchFolders = fetchFolders; + req.FetchItems = fetchItems; + req.SortOrder = sortOrder; + + m_descendentsRequestQueue.Enqueue(req); + } } delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { + Thread.Sleep(20); SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); } @@ -476,6 +511,21 @@ namespace OpenSim.Region.Framework.Scenes { SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; d.EndInvoke(iar); + + lock (m_descendentsRequestLock) + { + if (m_descendentsRequestQueue.Count > 0) + { + DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); + + d = SendInventoryAsync; + d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); + + return; + } + + m_descendentsRequestProcessing = false; + } } /// -- cgit v1.1 From c821153a4fcc0a0d806d2c9be63cf48494e4dd06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 30 Aug 2012 00:15:46 +0100 Subject: [possible still bad] make use of keyframemotion.copy on sop.copy, replacing fromdata(seralize). for now its called with null group since sop.copy() hasn't usable new group information, so for copied keyframes be fully operational UpdateSceneObject(newgroup) needs to be called on them. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 58 ++++++++++++---------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 12 +---- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++ 3 files changed, 38 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 42e3860..e4e6f2c 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -112,20 +112,23 @@ namespace OpenSim.Region.Framework.Scenes public bool Selected { set - { - if (!value) - { - // Once we're let go, recompute positions - if (m_selected) - UpdateSceneObject(m_group); - } - else + { + if (m_group != null) { - // Save selection position in case we get moved - if (!m_selected) + if (!value) { - StopTimer(); - m_serializedPosition = m_group.AbsolutePosition; + // Once we're let go, recompute positions + if (m_selected) + UpdateSceneObject(m_group); + } + else + { + // Save selection position in case we get moved + if (!m_selected) + { + StopTimer(); + m_serializedPosition = m_group.AbsolutePosition; + } } } m_isCrossing = false; @@ -199,6 +202,9 @@ namespace OpenSim.Region.Framework.Scenes m_waitingCrossing = false; StopTimer(); + if (grp == null) + return; + m_group = grp; Vector3 grppos = grp.AbsolutePosition; Vector3 offset = grppos - m_serializedPosition; @@ -228,14 +234,16 @@ namespace OpenSim.Region.Framework.Scenes m_mode = mode; m_data = data; - m_onTimerLock = new object(); - m_group = grp; if (grp != null) { m_basePosition = grp.AbsolutePosition; m_baseRotation = grp.GroupRotation; } + + m_onTimerLock = new object(); + m_timerStopped = true; + m_inOnTimer = false; m_isCrossing = false; m_waitingCrossing = false; } @@ -249,18 +257,23 @@ namespace OpenSim.Region.Framework.Scenes { StopTimer(); - KeyframeMotion newmotion = new KeyframeMotion(newgrp, m_mode, m_data); + KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data); - if (newgrp != null && newgrp.IsSelected) - newmotion.m_selected = true; + newmotion.m_group = newgrp; if (m_keyframes != null) + { + newmotion.m_keyframes = new Keyframe[m_keyframes.Length]; m_keyframes.CopyTo(newmotion.m_keyframes, 0); + } newmotion.m_frames = new List(m_frames); + + newmotion.m_basePosition = m_basePosition; + newmotion.m_baseRotation = m_baseRotation; + newmotion.m_currentFrame = m_currentFrame; - newmotion.m_nextPosition = m_nextPosition; if (m_selected) newmotion.m_serializedPosition = m_serializedPosition; else @@ -272,12 +285,7 @@ namespace OpenSim.Region.Framework.Scenes } newmotion.m_iterations = m_iterations; - - newmotion.m_onTimerLock = new object(); - newmotion.m_timerStopped = false; - newmotion.m_inOnTimer = false; - newmotion.m_isCrossing = false; - newmotion.m_waitingCrossing = false; + newmotion.m_running = m_running; if (m_running && !m_waitingCrossing) StartTimer(); @@ -299,7 +307,7 @@ namespace OpenSim.Region.Framework.Scenes { m_isCrossing = false; m_waitingCrossing = false; - if (m_keyframes.Length > 0) + if (m_keyframes != null && m_group != null && m_keyframes.Length > 0) { if (m_timer == null) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 834d27b..fe34ad4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2062,6 +2062,7 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChangedDueToDelink = false; m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); +/* backup_group.ForEachPart(delegate(SceneObjectPart part) { if (part.KeyframeMotion != null) @@ -2070,7 +2071,7 @@ namespace OpenSim.Region.Framework.Scenes // part.KeyframeMotion.UpdateSceneObject(this); } }); - +*/ datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); backup_group.ForEachPart(delegate(SceneObjectPart part) @@ -4415,15 +4416,6 @@ namespace OpenSim.Region.Framework.Scenes public virtual ISceneObject CloneForNewScene() { SceneObjectGroup sog = Copy(false); - sog.ForEachPart(delegate(SceneObjectPart part) - { - if (part.KeyframeMotion != null) - { - part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize()); - // this is called later -// part.KeyframeMotion.UpdateSceneObject(this); - } - }); sog.IsDeleted = false; return sog; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index bf5fc99..4788a24 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2110,6 +2110,9 @@ namespace OpenSim.Region.Framework.Scenes Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; + if (KeyframeMotion != null) + dupe.KeyframeMotion = KeyframeMotion.Copy(null); + if (userExposed) { if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero) -- cgit v1.1 From a7281003d85b6e9620d02387d4d9a42dcae27b24 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 30 Aug 2012 01:30:56 +0100 Subject: move keyframemotion.copy from sop.copy to sog.copy, where there is newgroup information avaiable. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index e4e6f2c..233e559 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -272,8 +272,6 @@ namespace OpenSim.Region.Framework.Scenes newmotion.m_basePosition = m_basePosition; newmotion.m_baseRotation = m_baseRotation; - newmotion.m_currentFrame = m_currentFrame; - if (m_selected) newmotion.m_serializedPosition = m_serializedPosition; else @@ -284,6 +282,8 @@ namespace OpenSim.Region.Framework.Scenes newmotion.m_serializedPosition = m_serializedPosition; } + newmotion.m_currentFrame = m_currentFrame; + newmotion.m_iterations = m_iterations; newmotion.m_running = m_running; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index df4bd0d..bc0f5b6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2159,6 +2159,7 @@ namespace OpenSim.Region.Framework.Scenes dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; + if (userExposed) dupe.m_rootPart.TrimPermissions(); @@ -2209,6 +2210,9 @@ namespace OpenSim.Region.Framework.Scenes if (userExposed) newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); // } + // copy keyframemotion + if (part.KeyframeMotion != null) + newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); } if (userExposed) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4788a24..56d289f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2110,8 +2110,8 @@ namespace OpenSim.Region.Framework.Scenes Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; - if (KeyframeMotion != null) - dupe.KeyframeMotion = KeyframeMotion.Copy(null); + // safeguard actual copy is done in sog.copy + dupe.KeyframeMotion = null; if (userExposed) { -- cgit v1.1 From 7cfcca87c6f9a9b280ab5e13ba92fff1830ee203 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 3 Sep 2012 13:25:31 +0200 Subject: Prevent a nullref if SimStatsReporter tries to report on a sim where psysics are not yet initialized --- .../Region/Framework/Scenes/SimStatsReporter.cs | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 20919a1..756b1f4 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -438,23 +438,26 @@ namespace OpenSim.Region.Framework.Scenes } // Extra statistics that aren't currently sent to clients - lock (m_lastReportedExtraSimStats) + if (m_scene.PhysicsScene != null) { - m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; - - Dictionary physicsStats = m_scene.PhysicsScene.GetStats(); - - if (physicsStats != null) + lock (m_lastReportedExtraSimStats) { - foreach (KeyValuePair tuple in physicsStats) + m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; + + Dictionary physicsStats = m_scene.PhysicsScene.GetStats(); + + if (physicsStats != null) { - // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second - // Need to change things so that stats source can indicate whether they are per second or - // per frame. - if (tuple.Key.EndsWith("MS")) - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; - else - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; + foreach (KeyValuePair tuple in physicsStats) + { + // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second + // Need to change things so that stats source can indicate whether they are per second or + // per frame. + if (tuple.Key.EndsWith("MS")) + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; + else + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; + } } } } -- cgit v1.1 From 056e66b3dec555613bd96b153ba03a124863dbf2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Sep 2012 03:14:39 +0200 Subject: Refactor avatar transfer so that the heavy (UpdateAgent) part is separated into it's own sub-method --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bc0f5b6..4798481 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes av.IsInTransit = true; CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; - d.BeginInvoke(av, val, x, y, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); } else m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); -- cgit v1.1 From d4fad2ba42445f72b8a04378b21818ec82ab1089 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 4 Sep 2012 07:32:03 +0100 Subject: a forgotten file plus minor changes. Imp and SL viewer seem to preserve flight. FS 4.2.2 does not. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 47b2ead..34ac7d4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1264,7 +1264,8 @@ namespace OpenSim.Region.Framework.Scenes Vector3 look = Velocity; - if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) + // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) + if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) { look = new Vector3(0.99f, 0.042f, 0); } -- cgit v1.1 From 9ae293881addf98844b8f292298bc0674ebbed0d Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Sep 2012 22:53:52 +0200 Subject: Make friend notifies and closing child agents async because both can block the heartbeat thread if the sim being contacted is unresponsive --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 34ac7d4..433efc7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3432,7 +3432,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void PhysicsCollisionUpdate(EventArgs e) { - if (IsChildAgent) + if (IsChildAgent || Animator == null) return; //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) -- cgit v1.1 From 23be1cf1cd0722d48e7e15d2e2bb4e85eef1016e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Sep 2012 09:40:28 +0100 Subject: remove fireandforget call to EnableChildAgents at end on CompleteMovement, since this is already on own thread and its at the end of it. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 433efc7..a8aa551 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1315,13 +1315,15 @@ namespace OpenSim.Region.Framework.Scenes // Create child agents in neighbouring regions if (openChildAgents && !IsChildAgent) { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) - Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); + m_agentTransfer.EnableChildAgents(this); IFriendsModule friendsModule = m_scene.RequestModuleInterface(); if (friendsModule != null) friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + } // m_log.DebugFormat( -- cgit v1.1 From 71d2d327d075824d9a9d3e4cd22c8a460301b837 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Sep 2012 12:50:38 +0100 Subject: One more redundante ParcelProprieties on login --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0237021..0dae946 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2890,9 +2890,11 @@ namespace OpenSim.Region.Framework.Scenes { EventManager.TriggerOnClientLogin(client); // Send initial parcel data +/* this is done on TriggerOnNewClient by landmanegement respective event handler Vector3 pos = sp.AbsolutePosition; ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); land.SendLandUpdateToClient(client); +*/ } return sp; -- cgit v1.1 From bd1d9a214b7f8750427d670566c8f99ff62f33c4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:28:13 +0200 Subject: Add the option to have variable costing for uploads --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1309623..2d9a035 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -101,12 +101,12 @@ namespace OpenSim.Region.Framework.Scenes engine.StartProcessing(); } - public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) + public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) { IMoneyModule money = RequestModuleInterface(); if (money != null) { - money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); + money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); } AddInventoryItem(item); -- cgit v1.1 From e1e9855edec647efd721b0ff34956f9a7f68942f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 00:12:41 +0200 Subject: Wait a bit longer for new scene presences to aid tps into laggy regions --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0dae946..9b9ad80 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4274,7 +4274,7 @@ namespace OpenSim.Region.Framework.Scenes /// protected virtual ScenePresence WaitGetScenePresence(UUID agentID) { - int ntimes = 20; + int ntimes = 30; ScenePresence sp = null; while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) Thread.Sleep(1000); -- cgit v1.1 From 7d5942d15445810e4b00289b80c33a4fba7b093b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Sep 2012 22:51:04 +0200 Subject: Make IncomingCloseChildAgent not send a stop packet. This may prevent a viewer from being logged out after an otherwise successful teleport. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9b9ad80..8034bc6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4326,7 +4326,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); if (presence != null) { - presence.ControllingClient.Close(); + presence.ControllingClient.Close(false); return true; } -- cgit v1.1 From a5d969d92f906b035da1a0489a7e4163d3e43aad Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 Sep 2012 20:57:36 +0200 Subject: Comment out asset error for sculpts/meshes. If an asset is missing it's missing. We can't put it back so we don't need to know. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 56d289f..e6ad89c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2146,10 +2146,10 @@ namespace OpenSim.Region.Framework.Scenes { if (asset != null) SculptTextureCallback(asset); - else - m_log.WarnFormat( - "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", - Name, UUID, id); +// else +// m_log.WarnFormat( +// "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", +// Name, UUID, id); } /// -- cgit v1.1 From ca67ee60ac0e0c26d6d32fc68d48ef63570f034d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Sep 2012 21:22:08 +0100 Subject: add missing transactionID in SendInventoryItemCreateUpdate. and make use of it on inventoryAccessModule, etc. Most likelly it's needs where there is a transactionID not zero --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2d9a035..dd9210f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -904,11 +904,22 @@ namespace OpenSim.Region.Framework.Scenes public void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, - AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) + AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) { CreateNewInventoryItem( remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, - (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); + (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate, transationID); + } + + + private void CreateNewInventoryItem( + IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, + string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) + { + CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, + name, description, flags, callbackID, asset, invType, + baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); } /// @@ -933,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes private void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, - uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) { InventoryItemBase item = new InventoryItemBase(); item.Owner = remoteClient.AgentId; @@ -956,7 +967,7 @@ namespace OpenSim.Region.Framework.Scenes if (AddInventoryItem(item)) { - remoteClient.SendInventoryItemCreateUpdate(item, callbackID); + remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); } else { -- cgit v1.1 From 9eca154bced7423867e8f9597b8baf214de79087 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 26 Sep 2012 23:17:21 +0100 Subject: Make it possible to rescale SOGs when they are not in a scene. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 53 ++++++++++++---------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++---- 2 files changed, 42 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f1df6d6..ddcc956 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3483,27 +3483,35 @@ namespace OpenSim.Region.Framework.Scenes /// public void GroupResize(Vector3 scale) { - scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); - scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y)); - scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z)); +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); PhysicsActor pa = m_rootPart.PhysActor; - if (pa != null && pa.IsPhysical) + RootPart.StoreUndoState(true); + + if (Scene != null) { - scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X)); - scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y)); - scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z)); + scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); + scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y)); + scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z)); + + if (pa != null && pa.IsPhysical) + { + scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X)); + scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y)); + scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z)); + } } float x = (scale.X / RootPart.Scale.X); float y = (scale.Y / RootPart.Scale.Y); float z = (scale.Z / RootPart.Scale.Z); - SceneObjectPart[] parts; - if (x > 1.0f || y > 1.0f || z > 1.0f) + SceneObjectPart[] parts = m_parts.GetArray(); + + if (Scene != null & (x > 1.0f || y > 1.0f || z > 1.0f)) { - parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart obPart = parts[i]; @@ -3516,7 +3524,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null && pa.IsPhysical) { - if (oldSize.X * x > m_scene.m_maxPhys) + if (oldSize.X * x > Scene.m_maxPhys) { f = m_scene.m_maxPhys / oldSize.X; a = f / x; @@ -3524,7 +3532,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.X * x < m_scene.m_minPhys) + else if (oldSize.X * x < Scene.m_minPhys) { f = m_scene.m_minPhys / oldSize.X; a = f / x; @@ -3533,7 +3541,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Y * y > m_scene.m_maxPhys) + if (oldSize.Y * y > Scene.m_maxPhys) { f = m_scene.m_maxPhys / oldSize.Y; a = f / y; @@ -3541,7 +3549,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Y * y < m_scene.m_minPhys) + else if (oldSize.Y * y < Scene.m_minPhys) { f = m_scene.m_minPhys / oldSize.Y; a = f / y; @@ -3550,7 +3558,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Z * z > m_scene.m_maxPhys) + if (oldSize.Z * z > Scene.m_maxPhys) { f = m_scene.m_maxPhys / oldSize.Z; a = f / z; @@ -3558,7 +3566,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Z * z < m_scene.m_minPhys) + else if (oldSize.Z * z < Scene.m_minPhys) { f = m_scene.m_minPhys / oldSize.Z; a = f / z; @@ -3569,7 +3577,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (oldSize.X * x > m_scene.m_maxNonphys) + if (oldSize.X * x > Scene.m_maxNonphys) { f = m_scene.m_maxNonphys / oldSize.X; a = f / x; @@ -3577,7 +3585,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.X * x < m_scene.m_minNonphys) + else if (oldSize.X * x < Scene.m_minNonphys) { f = m_scene.m_minNonphys / oldSize.X; a = f / x; @@ -3586,7 +3594,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Y * y > m_scene.m_maxNonphys) + if (oldSize.Y * y > Scene.m_maxNonphys) { f = m_scene.m_maxNonphys / oldSize.Y; a = f / y; @@ -3594,7 +3602,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Y * y < m_scene.m_minNonphys) + else if (oldSize.Y * y < Scene.m_minNonphys) { f = m_scene.m_minNonphys / oldSize.Y; a = f / y; @@ -3603,7 +3611,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Z * z > m_scene.m_maxNonphys) + if (oldSize.Z * z > Scene.m_maxNonphys) { f = m_scene.m_maxNonphys / oldSize.Z; a = f / z; @@ -3611,7 +3619,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Z * z < m_scene.m_minNonphys) + else if (oldSize.Z * z < Scene.m_minNonphys) { f = m_scene.m_minNonphys / oldSize.Z; a = f / z; @@ -3631,7 +3639,6 @@ namespace OpenSim.Region.Framework.Scenes RootPart.Resize(prevScale); - parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart obPart = parts[i]; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4af508e..44573eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2972,16 +2972,20 @@ namespace OpenSim.Region.Framework.Scenes /// public void Resize(Vector3 scale) { - scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X)); - scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y)); - scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z)); - PhysicsActor pa = PhysActor; - if (pa != null && pa.IsPhysical) + + if (ParentGroup.Scene != null) { - scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X)); - scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y)); - scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z)); + scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X)); + scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y)); + scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z)); + + if (pa != null && pa.IsPhysical) + { + scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X)); + scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y)); + scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z)); + } } // m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale); -- cgit v1.1 From b52311b8f80db28183069901d5540d61db0bd8ea Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 Sep 2012 17:16:39 +0100 Subject: Remove a core undo call that we don't need. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ddcc956..bf898bb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3488,8 +3488,6 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = m_rootPart.PhysActor; - RootPart.StoreUndoState(true); - if (Scene != null) { scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); -- cgit v1.1 From 9988558ec16144f1a69b666d39428cda4c0849c3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 3 Oct 2012 23:14:56 +0100 Subject: meshworker basic replacement of SOP CheckSculptAndLoad ( for now disabled for all physics engines) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e6ad89c..1bddf22 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4902,6 +4902,8 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); + return; + if (ParentGroup.IsDeleted) return; -- cgit v1.1 From efb9b7014e928aa9be8200d18248518bb503ad7c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Oct 2012 15:20:04 +0200 Subject: Allow default animation to be stopped to be replaced with another one. Fixes Mantis #6327 --- .../Framework/Scenes/Animation/AnimationSet.cs | 27 ++++++++++++++-------- .../Scenes/Animation/ScenePresenceAnimator.cs | 18 ++++++++++----- 2 files changed, 29 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 33041e9..ad421ee 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { if (m_defaultAnimation.AnimID == animID) { - ResetDefaultAnimation(); + m_defaultAnimation = new OpenSim.Framework.Animation(UUID.Zero, 1, UUID.Zero); } else if (HasAnimation(animID)) { @@ -149,19 +149,26 @@ namespace OpenSim.Region.Framework.Scenes.Animation { lock (m_animations) { - animIDs = new UUID[m_animations.Count + 1]; - sequenceNums = new int[m_animations.Count + 1]; - objectIDs = new UUID[m_animations.Count + 1]; + int defaultSize = 0; + if (m_defaultAnimation.AnimID != UUID.Zero) + defaultSize++; - animIDs[0] = m_defaultAnimation.AnimID; - sequenceNums[0] = m_defaultAnimation.SequenceNum; - objectIDs[0] = m_defaultAnimation.ObjectID; + animIDs = new UUID[m_animations.Count + defaultSize]; + sequenceNums = new int[m_animations.Count + defaultSize]; + objectIDs = new UUID[m_animations.Count + defaultSize]; + + if (m_defaultAnimation.AnimID != UUID.Zero) + { + animIDs[0] = m_defaultAnimation.AnimID; + sequenceNums[0] = m_defaultAnimation.SequenceNum; + objectIDs[0] = m_defaultAnimation.ObjectID; + } for (int i = 0; i < m_animations.Count; ++i) { - animIDs[i + 1] = m_animations[i].AnimID; - sequenceNums[i + 1] = m_animations[i].SequenceNum; - objectIDs[i + 1] = m_animations[i].ObjectID; + animIDs[i + defaultSize] = m_animations[i].AnimID; + sequenceNums[i + defaultSize] = m_animations[i].SequenceNum; + objectIDs[i + defaultSize] = m_animations[i].ObjectID; } } } diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 50a176b..9458079 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -424,13 +424,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation { lock (m_animations) { - CurrentMovementAnimation = DetermineMovementAnimation(); + string newMovementAnimation = DetermineMovementAnimation(); + if (CurrentMovementAnimation != newMovementAnimation) + { + CurrentMovementAnimation = DetermineMovementAnimation(); -// m_log.DebugFormat( -// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", -// CurrentMovementAnimation, m_scenePresence.Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", +// CurrentMovementAnimation, m_scenePresence.Name); - TrySetMovementAnimation(CurrentMovementAnimation); + // Only set it if it's actually changed, give a script + // a chance to stop a default animation + TrySetMovementAnimation(CurrentMovementAnimation); + } } } @@ -552,4 +558,4 @@ namespace OpenSim.Region.Framework.Scenes.Animation SendAnimPack(animIDs, sequenceNums, objectIDs); } } -} \ No newline at end of file +} -- cgit v1.1 From 78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 7 Oct 2012 01:20:52 +0100 Subject: [DANGER UNTESTED] ODE mesh assets. Other plugins will not do meshs/sculpts now --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 +-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 38 ++++++++++++---------- 2 files changed, 23 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4798481..4b22ebe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4299,8 +4299,8 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].CheckSculptAndLoad(); +// for (int i = 0; i < parts.Length; i++) +// parts[i].CheckSculptAndLoad(); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1bddf22..633cd3b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1095,9 +1095,9 @@ namespace OpenSim.Region.Framework.Scenes { actor.Size = m_shape.Scale; - if (Shape.SculptEntry) - CheckSculptAndLoad(); - else +// if (Shape.SculptEntry) +// CheckSculptAndLoad(); +// else ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } } @@ -1654,8 +1654,8 @@ namespace OpenSim.Region.Framework.Scenes else { PhysActor.PhysicsShapeType = m_physicsShapeType; - if (Shape.SculptEntry) - CheckSculptAndLoad(); +// if (Shape.SculptEntry) +// CheckSculptAndLoad(); } if (ParentGroup != null) @@ -2115,12 +2115,13 @@ namespace OpenSim.Region.Framework.Scenes if (userExposed) { +/* if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero) { ParentGroup.Scene.AssetService.Get( dupe.m_shape.SculptTexture.ToString(), dupe, dupe.AssetReceived); } - +*/ bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); dupe.DoPhysicsPropertyUpdate(UsePhysics, true); // dupe.UpdatePhysicsSubscribedEvents(); // not sure... @@ -2142,6 +2143,7 @@ namespace OpenSim.Region.Framework.Scenes /// ID of asset received /// Register /// +/* protected void AssetReceived(string id, Object sender, AssetBase asset) { if (asset != null) @@ -2151,7 +2153,7 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", // Name, UUID, id); } - +*/ /// /// Do a physics property update for a NINJA joint. /// @@ -2341,9 +2343,9 @@ namespace OpenSim.Region.Framework.Scenes // If this part is a sculpt then delay the physics update until we've asynchronously loaded the // mesh data. - if (Shape.SculptEntry) - CheckSculptAndLoad(); - else +// if (Shape.SculptEntry) +// CheckSculptAndLoad(); +// else ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); } } @@ -3125,6 +3127,7 @@ namespace OpenSim.Region.Framework.Scenes /// Set sculpt and mesh data, and tell the physics engine to process the change. /// /// The mesh itself. +/* public void SculptTextureCallback(AssetBase texture) { if (m_shape.SculptEntry) @@ -3152,7 +3155,7 @@ namespace OpenSim.Region.Framework.Scenes } } } - +*/ /// /// Send a full update to the client for the given part /// @@ -4377,7 +4380,7 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateExtraParam(ushort type, bool inUse, byte[] data) { m_shape.ReadInUpdateExtraParam(type, inUse, data); - +/* if (type == 0x30) { if (m_shape.SculptEntry && m_shape.SculptTexture != UUID.Zero) @@ -4385,7 +4388,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.Scene.AssetService.Get(m_shape.SculptTexture.ToString(), this, AssetReceived); } } - +*/ if (ParentGroup != null) { ParentGroup.HasGroupChanged = true; @@ -4793,9 +4796,9 @@ namespace OpenSim.Region.Framework.Scenes } } - if (Shape.SculptEntry) - CheckSculptAndLoad(); - else +// if (Shape.SculptEntry) +// CheckSculptAndLoad(); +// else ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); if (!building) @@ -4898,6 +4901,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// When the physics engine has finished with it, the sculpt data is discarded to save memory. /// +/* public void CheckSculptAndLoad() { // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); @@ -4925,7 +4929,7 @@ namespace OpenSim.Region.Framework.Scenes } } } - +*/ /// /// Update the texture entry for this part. /// -- cgit v1.1 From 9be2d5c77da8c2fc6c953e26a8b1412642588eb2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 7 Oct 2012 03:03:24 +0100 Subject: Fix merge issues --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6e3e436..8d112db 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -825,13 +825,6 @@ namespace OpenSim.Region.Framework.Scenes m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); - IConfig packetConfig = m_config.Configs["PacketPool"]; - if (packetConfig != null) - { - PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); - PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); - } - m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); -- cgit v1.1 From 48d8fbc9aedb3247a1dfd25be1b7dfbdd8719790 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 7 Oct 2012 08:53:55 +0100 Subject: bug fix + make costs visible for testing --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 633cd3b..66d85c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1583,7 +1583,9 @@ namespace OpenSim.Region.Framework.Scenes float cost = 0.1f; if (PhysActor != null) -// cost += PhysActor.Cost; + cost = PhysActor.PhysicsCost; + else + cost = 0.1f; if ((Flags & PrimFlags.Physics) != 0) cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 @@ -1596,9 +1598,12 @@ namespace OpenSim.Region.Framework.Scenes { get { - - - return 0.1f; + float cost; + if (PhysActor != null) + cost = PhysActor.StreamCost; + else + cost = 1.0f; + return 1.0f; } } -- cgit v1.1 From 8894f4ad7735fc0a37fd62c89467163f6ec503cb Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 8 Oct 2012 01:34:32 +0200 Subject: Change permissions on child prim inventory items when god mode "force permissive" is used. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4798481..9dd6639 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3422,8 +3422,16 @@ namespace OpenSim.Region.Framework.Scenes { RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); + bool god = Scene.Permissions.IsGod(AgentID); + AdjustChildPrimPermissions(); + if (field == 1 && god) // Base mask was set. Update all child part inventories + { + foreach (SceneObjectPart part in Parts) + part.Inventory.ApplyGodPermissions(RootPart.BaseMask); + } + HasGroupChanged = true; // Send the group's properties to all clients once all parts are updated diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e6ad89c..c2d4764 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4460,7 +4460,7 @@ namespace OpenSim.Region.Framework.Scenes if (god) { BaseMask = ApplyMask(BaseMask, set, mask); - Inventory.ApplyGodPermissions(_baseMask); + Inventory.ApplyGodPermissions(BaseMask); } break; @@ -4479,7 +4479,7 @@ namespace OpenSim.Region.Framework.Scenes case 16: NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & baseMask; - // Prevent the client from creating no mod, no copy + // Prevent the client from creating no copy, no transfer // objects if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) NextOwnerMask |= (uint)PermissionMask.Transfer; -- cgit v1.1 From d554c0d574f9c4763df0bbff931de0f944db53a5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 10 Oct 2012 01:37:59 +0100 Subject: normalize quaternion.Slerp outputs --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 233e559..edf2bef 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -575,6 +575,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion current = m_group.GroupRotation; Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); + step.Normalize(); /* use simpler change detection * float angle = 0; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 66d85c4..1857757 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5202,6 +5202,7 @@ namespace OpenSim.Region.Framework.Scenes } Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations); + rot.Normalize(); UpdateRotation(rot); m_APIDIterations--; -- cgit v1.1 From aba078c93f4966cf6be10fc02228323843b9249e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 14 Oct 2012 17:32:46 +0200 Subject: Fix perms when linking an object. Set root part perms to the perms of the link set to make the build floater behave consistently. Fixes permissions exploit introduced on 23 August. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 +++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 ++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 28 +++++++++++----------- 4 files changed, 29 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index dd9210f..ff8589a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2503,6 +2503,12 @@ namespace OpenSim.Region.Framework.Scenes } m_sceneGraph.LinkObjects(root, children); + + ScenePresence sp; + if (TryGetScenePresence(agentId, out sp)) + { + root.SendPropertiesToClient(sp.ControllingClient); + } } private string PermissionString(uint permissions) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e29b2c1..af13b46 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1849,6 +1849,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } + parentGroup.AdjustChildPrimPermissions(); parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); @@ -1989,6 +1990,7 @@ namespace OpenSim.Region.Framework.Scenes // return unless the root is deleted. This will remove them // from the database. They will be rewritten immediately, // minus the rows for the unlinked child prims. + g.AdjustChildPrimPermissions(); m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9dd6639..053bfb4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3410,11 +3410,18 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustChildPrimPermissions() { + uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits + uint foldedPerms = RootPart.OwnerMask & 3; + ForEachPart(part => { + newOwnerMask &= part.BaseMask; if (part != RootPart) part.ClonePermissions(RootPart); }); + + RootPart.OwnerMask = newOwnerMask | foldedPerms; + RootPart.ScheduleFullUpdate(); } public void UpdatePermissions(UUID AgentID, byte field, uint localID, diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c2d4764..3274cbd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4497,20 +4497,20 @@ namespace OpenSim.Region.Framework.Scenes { bool update = false; - if (BaseMask != source.BaseMask || - OwnerMask != source.OwnerMask || - GroupMask != source.GroupMask || - EveryoneMask != source.EveryoneMask || - NextOwnerMask != source.NextOwnerMask) - update = true; - - BaseMask = source.BaseMask; - OwnerMask = source.OwnerMask; - GroupMask = source.GroupMask; - EveryoneMask = source.EveryoneMask; - NextOwnerMask = source.NextOwnerMask; - - if (update) + uint prevOwnerMask = OwnerMask; + uint prevGroupMask = GroupMask; + uint prevEveryoneMask = EveryoneMask; + uint prevNextOwnerMask = NextOwnerMask; + + OwnerMask = source.OwnerMask & BaseMask; + GroupMask = source.GroupMask & BaseMask; + EveryoneMask = source.EveryoneMask & BaseMask; + NextOwnerMask = source.NextOwnerMask & BaseMask; + + if (OwnerMask != prevOwnerMask || + GroupMask != prevGroupMask || + EveryoneMask != prevEveryoneMask || + NextOwnerMask != prevNextOwnerMask) SendFullUpdateToAllClients(); } -- cgit v1.1 From 7228ad7a51e7f976e58331e06aba133528ee2cb3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 18 Oct 2012 15:30:42 +0100 Subject: extend coment to include all unused SOG CheckSculptAndLoad() --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4b22ebe..f490d90 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4287,6 +4287,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// When the physics engine has finished with it, the sculpt data is discarded to save memory. /// +/* public void CheckSculptAndLoad() { if (IsDeleted) @@ -4299,10 +4300,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = m_parts.GetArray(); -// for (int i = 0; i < parts.Length; i++) -// parts[i].CheckSculptAndLoad(); + for (int i = 0; i < parts.Length; i++) + parts[i].CheckSculptAndLoad(); } - +*/ /// /// Set the user group to which this scene object belongs. /// -- cgit v1.1 From aa97014ee4563883ddd84dd1607b143394412f49 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 28 Oct 2012 09:51:27 +0000 Subject: Add some extra debug on scene close --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8034bc6..32a7935 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1255,9 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes // Stop all client threads. ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); - m_log.Debug("[SCENE]: Persisting changed objects"); + m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); EventManager.TriggerSceneShuttingDown(this); + m_log.Debug("[SCENE]: Persisting changed objects"); + EntityBase[] entities = GetEntities(); foreach (EntityBase entity in entities) { @@ -1267,10 +1269,12 @@ namespace OpenSim.Region.Framework.Scenes } } + m_log.Debug("[SCENE]: Graph close"); m_sceneGraph.Close(); if (PhysicsScene != null) { + m_log.Debug("[SCENE]: Dispose Physics"); PhysicsScene phys = PhysicsScene; // remove the physics engine from both Scene and SceneGraph PhysicsScene = null; @@ -1282,6 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); // call the base class Close method. + m_log.Debug("[SCENE]: Base close"); base.Close(); } @@ -1317,6 +1322,9 @@ namespace OpenSim.Region.Framework.Scenes } // m_lastUpdate = Util.EnvironmentTickCount(); + m_sceneGraph.PreparePhysicsSimulation(); + + m_heartbeatThread = Watchdog.StartThread( Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); -- cgit v1.1 From e297e90bda74a901dbf473abca3e34e724f999e9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 28 Oct 2012 09:57:41 +0000 Subject: remove pre physics build testing --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 32a7935..ccb4aad 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1322,7 +1322,7 @@ namespace OpenSim.Region.Framework.Scenes } // m_lastUpdate = Util.EnvironmentTickCount(); - m_sceneGraph.PreparePhysicsSimulation(); +// m_sceneGraph.PreparePhysicsSimulation(); m_heartbeatThread -- cgit v1.1 From ad7f273d95b941e5556c875d1a2b6ea1cef34604 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 28 Oct 2012 10:25:58 +0000 Subject: more debug --- OpenSim/Region/Framework/Scenes/EventManager.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index eee5960..7916c42 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -2458,6 +2458,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (Action d in handler.GetInvocationList()) { + m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); try { d(s); @@ -2470,6 +2471,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + m_log.Info("[EVENT MANAGER]: TriggerSceneShuttingDown done"); } public void TriggerOnRegionStarted(Scene scene) -- cgit v1.1 From 0d00b97aecf07a19d50ba57e7e717ffbbcd10658 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Oct 2012 18:41:47 +0000 Subject: Deep copy the collection of at_target objects so it can't be modified while it's being iterated --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8034bc6..05ce00a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1666,7 +1666,10 @@ namespace OpenSim.Region.Framework.Scenes { List objs = new List(); lock (m_groupsWithTargets) - objs = new List(m_groupsWithTargets.Values); + { + foreach (SceneObjectGroup grp in m_groupsWithTargets.Values) + objs.Add(grp); + } foreach (SceneObjectGroup entry in objs) entry.checkAtTargets(); -- cgit v1.1 From 1a34f42426b5819f97079c138c596182bf683416 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Oct 2012 18:34:57 +0100 Subject: Add a property to determine if a link set is stored in the database. Also, fix a bug where "Force object permissive" god action would fail to reset child prim permissions. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b12d0e0..ee61de6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -307,6 +307,11 @@ namespace OpenSim.Region.Framework.Scenes private bool m_isBackedUp; + public bool IsBackedUp + { + get { return m_isBackedUp; } + } + protected MapAndArray m_parts = new MapAndArray(); protected ulong m_regionHandle; @@ -3431,6 +3436,14 @@ namespace OpenSim.Region.Framework.Scenes bool god = Scene.Permissions.IsGod(AgentID); + if (field == 1 && god) + { + ForEachPart(part => + { + part.BaseMask = RootPart.BaseMask; + }); + } + AdjustChildPrimPermissions(); if (field == 1 && god) // Base mask was set. Update all child part inventories -- cgit v1.1 From dc2c198e5df6cd264e9f171a66b1926d850ea361 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Oct 2012 19:09:14 +0100 Subject: Set the script state to new rez when a scriptis saved, rather than region start. Prevents CHANGED_REGION_RESTART being sent to scripts when saving. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ff8589a..906c1ee 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.Framework.Scenes { // Needs to determine which engine was running it and use that // - errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); + errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); } // Tell anyone managing scripts that a script has been reloaded/changed -- cgit v1.1 From d15d71a7efd2e1d3510111cbc9e617fc113fc29c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Oct 2012 01:28:03 +0000 Subject: Put back the collision sound shim into SOP --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b7f4291..5714fdd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2864,6 +2864,35 @@ namespace OpenSim.Region.Framework.Scenes SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); } + // The Collision sounds code calls this + public void SendCollisionSound(UUID soundID, double volume, Vector3 position) + { + if (soundID == UUID.Zero) + return; + + ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); + if (soundModule == null) + return; + + if (volume > 1) + volume = 1; + if (volume < 0) + volume = 0; + + int now = Util.EnvironmentTickCount(); + if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) + return; + + LastColSoundSentTime = now; + + UUID ownerID = OwnerID; + UUID objectID = ParentGroup.RootPart.UUID; + UUID parentID = ParentGroup.UUID; + ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; + + soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); + } + public void PhysicsOutOfBounds(Vector3 pos) { m_log.Error("[PHYSICS]: Physical Object went out of bounds."); -- cgit v1.1 From 5328808b1825ef7d73809c8ddd67542ee05bf575 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Oct 2012 21:19:00 +0100 Subject: Make sure we're not accessing a physics scene if we're not in one yet. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 49b771f..165dd85 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -813,7 +813,7 @@ namespace OpenSim.Region.Framework.Scenes actor.Orientation = GetWorldRotation(); // Tell the physics engines that this prim changed. - if (ParentGroup.Scene != null) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } -- cgit v1.1 From b8c19fe1a9dc49a060be7afce6d317d52db1983a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 2 Nov 2012 17:40:17 +0000 Subject: Create a new random when needed using normal time based seed instead of reusing a shared one than may not be valid --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ee61de6..6339522 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.Framework.Scenes private long timeLastChanged = 0; private long m_maxPersistTime = 0; private long m_minPersistTime = 0; - private Random m_rand; +// private Random m_rand; private List m_linkedAvatars = new List(); /// @@ -130,6 +130,7 @@ namespace OpenSim.Region.Framework.Scenes { if (value) { + if (m_isBackedUp) { m_scene.SceneGraph.FireChangeBackup(this); @@ -139,13 +140,15 @@ namespace OpenSim.Region.Framework.Scenes timeFirstChanged = DateTime.Now.Ticks; if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) { +/* if (m_rand == null) { byte[] val = new byte[16]; m_rootPart.UUID.ToBytes(val, 0); m_rand = new Random(BitConverter.ToInt32(val, 0)); } - + */ + Random m_rand = new Random(); if (m_scene.GetRootAgentCount() == 0) { //If the region is empty, this change has been made by an automated process -- cgit v1.1 From e642b80a79bc2a5585972caa14a8f5f59a5dc6fb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 2 Nov 2012 17:49:54 +0000 Subject: actually remove the use of random on persist timmings --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6339522..e94ecee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -148,13 +148,13 @@ namespace OpenSim.Region.Framework.Scenes m_rand = new Random(BitConverter.ToInt32(val, 0)); } */ - Random m_rand = new Random(); if (m_scene.GetRootAgentCount() == 0) { //If the region is empty, this change has been made by an automated process //and thus we delay the persist time by a random amount between 1.5 and 2.5. - float factor = 1.5f + (float)(m_rand.NextDouble()); +// float factor = 1.5f + (float)(m_rand.NextDouble()); + float factor = 2.0f; m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); } @@ -162,8 +162,10 @@ namespace OpenSim.Region.Framework.Scenes { //If the region is not empty, we want to obey the minimum and maximum persist times //but add a random factor so we stagger the object persistance a little - m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 - m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 +// m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 +// m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 + m_maxPersistTime = m_scene.m_persistAfter; + m_minPersistTime = m_scene.m_dontPersistBefore; } } } -- cgit v1.1 From 4fa088bafb4c78ad3177b0e944a4312bd6abdea7 Mon Sep 17 00:00:00 2001 From: teravus Date: Sun, 4 Nov 2012 22:57:24 -0500 Subject: Pipe Throttle Update Event to EventManager, client --> ScenePresence --> EventManager, so that modules can know when throttles are updated. The event contains no client specific data to preserve the possibility of 'multiple clients' and you must still call ControllingClient.GetThrottlesPacked(f) to see what the throttles actually are once the event fires. Hook EventManager.OnUpdateThrottle to GetTextureModule. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 13 +++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++++ 2 files changed, 18 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7916c42..4a19c3b 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -376,6 +376,10 @@ namespace OpenSim.Region.Framework.Scenes public event ParcelPrimCountTainted OnParcelPrimCountTainted; public event GetScriptRunning OnGetScriptRunning; + public delegate void ThrottleUpdate(ScenePresence scenePresence); + + public event ThrottleUpdate OnThrottleUpdate; + /// /// RegisterCapsEvent is called by Scene after the Caps object /// has been instantiated and before it is return to the @@ -2641,5 +2645,14 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void TriggerThrottleUpdate(ScenePresence scenePresence) + { + ThrottleUpdate handler = OnThrottleUpdate; + if (handler != null) + { + handler(scenePresence); + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a8aa551..2b9665c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -793,6 +793,7 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.OnChangeAnim += avnHandleChangeAnim; ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; ControllingClient.OnAutoPilotGo += MoveToTarget; + ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); @@ -3166,6 +3167,10 @@ namespace OpenSim.Region.Framework.Scenes } private static Vector3 marker = new Vector3(-1f, -1f, -1f); + private void RaiseUpdateThrottles() + { + m_scene.EventManager.TriggerThrottleUpdate(this); + } /// /// This updates important decision making data about a child agent /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region -- cgit v1.1 From b09fb01571f97643fd66a32a1fe75fc45863cc73 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 02:03:44 +0000 Subject: Fix a build break introduced by us having a more efficient DoubleDictionary where core has a simple list --- OpenSim/Region/Framework/Scenes/SceneManager.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index a88e86d..ff12d94 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -138,12 +138,16 @@ namespace OpenSim.Region.Framework.Scenes public void Close() { + List localScenes = null; + lock (m_localScenes) { - for (int i = 0; i < m_localScenes.Count; i++) - { - m_localScenes[i].Close(); - } + localScenes = Scenes; + } + + for (int i = 0; i < localScenes.Count; i++) + { + localScenes[i].Close(); } } -- cgit v1.1 From 8aa5fdb6a3f1e4b349757df5d9fcc06ab8dfdb64 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 3 Dec 2012 17:05:05 +0000 Subject: *TEST* diferent avatar collider --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7f07d73..bacc9c9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -571,7 +571,18 @@ namespace OpenSim.Region.Framework.Scenes set { m_bodyRot = value; -// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); + // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); + if (PhysicsActor != null) + { + try + { + PhysicsActor.Orientation = value; + } + catch (Exception e) + { + m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); + } + } } } @@ -3435,7 +3446,7 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor = scene.AddAvatar( LocalId, Firstname + "." + Lastname, pVec, - new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); + new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; -- cgit v1.1 From de3180a63ecb89971321b7dce60dd86703f87e6d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 5 Dec 2012 23:19:18 +0000 Subject: avatar collision plane send to viewer is only relative to feet. change avatar collider, just rounding the boxes, etc --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bacc9c9..f5d609d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3465,6 +3465,7 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); } + /// /// Event called by the physics plugin to tell the avatar about a collision. /// @@ -3494,7 +3495,6 @@ namespace OpenSim.Region.Framework.Scenes CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; - CollisionPlane = Vector4.UnitW; // // No collisions at all means we may be flying. Update always // // to make falling work @@ -3504,6 +3504,8 @@ namespace OpenSim.Region.Framework.Scenes // m_lastColCount = coldata.Count; // } + CollisionPlane = Vector4.UnitW; + if (coldata.Count != 0) { switch (Animator.CurrentMovementAnimation) @@ -3517,17 +3519,22 @@ namespace OpenSim.Region.Framework.Scenes ContactPoint lowest; lowest.SurfaceNormal = Vector3.Zero; lowest.Position = Vector3.Zero; - lowest.Position.Z = Single.NaN; + lowest.Position.Z = float.MaxValue; foreach (ContactPoint contact in coldata.Values) { - if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) + + if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) { lowest = contact; } } - CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + if (lowest.Position.Z != float.MaxValue) + { + lowest.SurfaceNormal = -lowest.SurfaceNormal; + CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + } } break; } -- cgit v1.1 From d2499c4c314b290c42f454913305d97c6eec92d6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 15:54:46 +0000 Subject: *TEST* Use new avatar size in ubitODE. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f5d609d..b6eae8e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1260,6 +1260,12 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); } + public void SetSize(Vector3 size, float feetoffset) + { + if (PhysicsActor != null && !IsChildAgent) + PhysicsActor.setAvatarSize(size, feetoffset); + } + /// /// Complete Avatar's movement into the region. /// -- cgit v1.1 From 2ea0dc55d7ea6da6e91ab614856cdeece7eae5d2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 20:06:35 +0000 Subject: create a new ode character also with the new information --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b6eae8e..7602d6b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3450,9 +3450,15 @@ namespace OpenSim.Region.Framework.Scenes Vector3 pVec = AbsolutePosition; +/* PhysicsActor = scene.AddAvatar( LocalId, Firstname + "." + Lastname, pVec, new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); +*/ + + PhysicsActor = scene.AddAvatar( + LocalId, Firstname + "." + Lastname, pVec, + Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; -- cgit v1.1 From 93bede4e6aa0838e14f39f5e641b028267d2683c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 21:26:58 +0000 Subject: revert the use of avatar skeleton and use avatar size provided by viewers, since at least for now seems good enought --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7602d6b..9dfccca 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3443,8 +3443,8 @@ namespace OpenSim.Region.Framework.Scenes Name, Scene.RegionInfo.RegionName); } - if (Appearance.AvatarHeight == 0) - Appearance.SetHeight(); +// if (Appearance.AvatarHeight == 0) +// Appearance.SetHeight(); PhysicsScene scene = m_scene.PhysicsScene; -- cgit v1.1 From c73c2fb0707ee4dc78a354d932293f3e7e83ac50 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 21:53:33 +0000 Subject: add some default size setting and checks --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9dfccca..9ada5bb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3443,8 +3443,9 @@ namespace OpenSim.Region.Framework.Scenes Name, Scene.RegionInfo.RegionName); } -// if (Appearance.AvatarHeight == 0) + if (Appearance.AvatarHeight == 0) // Appearance.SetHeight(); + Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); PhysicsScene scene = m_scene.PhysicsScene; -- cgit v1.1 From b3a77c16bd2ad83076ddf19275b2f104210bba07 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:34:27 +0000 Subject: FIX small avatars movement on terrain. (avatar appearance getting even more messy) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 40 +++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9ada5bb..6299a8e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; + private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); + private Vector3? m_forceToApply; private int m_userFlags; @@ -563,6 +565,23 @@ namespace OpenSim.Region.Framework.Scenes } } + public override Vector3 AngularVelocity + { + get + { + if (PhysicsActor != null) + { + m_rotationalvelocity = PhysicsActor.RotationalVelocity; + + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", + // m_velocity, Name, Scene.RegionInfo.RegionName); + } + + return m_rotationalvelocity; + } + } + private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation @@ -1264,6 +1283,7 @@ namespace OpenSim.Region.Framework.Scenes { if (PhysicsActor != null && !IsChildAgent) PhysicsActor.setAvatarSize(size, feetoffset); + } /// @@ -2572,9 +2592,13 @@ namespace OpenSim.Region.Framework.Scenes // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity + if (Appearance.AvatarSize != m_lastSize) + { + m_lastSize = Appearance.AvatarSize; + SendAvatarDataToAllAgents(); + } - // Throw away duplicate or insignificant updates - if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) { @@ -2872,6 +2896,8 @@ namespace OpenSim.Region.Framework.Scenes avatar.ControllingClient.SendAppearance( UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); + + } #endregion @@ -3517,10 +3543,9 @@ namespace OpenSim.Region.Framework.Scenes // m_lastColCount = coldata.Count; // } - CollisionPlane = Vector4.UnitW; - if (coldata.Count != 0) { +/* switch (Animator.CurrentMovementAnimation) { case "STAND": @@ -3529,6 +3554,7 @@ namespace OpenSim.Region.Framework.Scenes case "CROUCH": case "CROUCHWALK": { + */ ContactPoint lowest; lowest.SurfaceNormal = Vector3.Zero; lowest.Position = Vector3.Zero; @@ -3548,10 +3574,16 @@ namespace OpenSim.Region.Framework.Scenes lowest.SurfaceNormal = -lowest.SurfaceNormal; CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); } + else + CollisionPlane = Vector4.UnitW; +/* } break; } +*/ } + else + CollisionPlane = Vector4.UnitW; RaiseCollisionScriptEvents(coldata); -- cgit v1.1 From c0368f4143ae13b847bc6b10198de7f09414caee Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:39:10 +0000 Subject: fix coment out code not in use --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6299a8e..92a4748 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -564,7 +564,7 @@ namespace OpenSim.Region.Framework.Scenes // Scene.RegionInfo.RegionName, Name, m_velocity); } } - +// public override Vector3 AngularVelocity { get @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes return m_rotationalvelocity; } } - +// private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation -- cgit v1.1 From 94a659a9e08cb5e6cb4d5b3aa7d46b11217098a0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:46:33 +0000 Subject: fix the 'fix' --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 92a4748..45cae51 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -564,7 +564,7 @@ namespace OpenSim.Region.Framework.Scenes // Scene.RegionInfo.RegionName, Name, m_velocity); } } -// +/* public override Vector3 AngularVelocity { get @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes return m_rotationalvelocity; } } -// +/* private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation -- cgit v1.1 From 5ad424a79278e0079d1f2540d470541f276ce71c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:48:29 +0000 Subject: right fix this time ?? --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 45cae51..e026ffd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes return m_rotationalvelocity; } } -/* +*/ private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation -- cgit v1.1 From d2695cb3f7356a5c4047bbef2ac8f83fc8350976 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 15 Dec 2012 16:26:03 -0500 Subject: * Fix for Prim Locking. Prior to the merge, it was just a clone of the root part to each of the child parts. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b9f9c86..0b82093 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3439,17 +3439,17 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustChildPrimPermissions() { - uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits - uint foldedPerms = RootPart.OwnerMask & 3; + //uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits + //uint foldedPerms = RootPart.OwnerMask & 3; ForEachPart(part => { - newOwnerMask &= part.BaseMask; + //newOwnerMask &= part.BaseMask; if (part != RootPart) part.ClonePermissions(RootPart); }); - RootPart.OwnerMask = newOwnerMask | foldedPerms; + //RootPart.OwnerMask = newOwnerMask | foldedPerms; RootPart.ScheduleFullUpdate(); } -- cgit v1.1 From 7d8c2b342c77cd4c5b26ee9500b5d9383b8bae77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Dec 2012 02:05:01 +0100 Subject: Fix locking objects --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b9f9c86..4ad8b11 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3449,7 +3449,9 @@ namespace OpenSim.Region.Framework.Scenes part.ClonePermissions(RootPart); }); - RootPart.OwnerMask = newOwnerMask | foldedPerms; + uint lockMask = ~(uint)PermissionMask.Move; + uint lockBit = RootPart.OwnerMask & (uint)PermissionMask.Move; + RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); RootPart.ScheduleFullUpdate(); } -- cgit v1.1 From d003aa2e7b690d21f7d6094431c16ad0de5776d4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Dec 2012 01:40:48 +0000 Subject: * TEST * unscripted sit --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 222 +++++------------------ 1 file changed, 48 insertions(+), 174 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e026ffd..7ff163b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2103,12 +2103,29 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) - { +// if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) +// { // m_log.DebugFormat( // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", // Name, part.Name, part.LocalId); + if (m_scene.PhysicsScene != null && + part.PhysActor != null && + Util.GetDistanceTo(AbsolutePosition, pos) <= 30) + { + + Vector3 camdif = CameraPosition - part.AbsolutePosition; + camdif.Normalize(); + +// m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString()); + + if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) + return; + } + + if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) + { + AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); canSit = true; } @@ -2196,197 +2213,54 @@ namespace OpenSim.Region.Framework.Scenes SendSitResponse(targetID, offset, Quaternion.Identity); } - /* - public void SitRayCastAvatarPosition(SceneObjectPart part) + public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) { - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); - } - public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else + if (status < 0) { ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; + return; } - } - - public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) - { - // Next, try to raycast from the camera Z position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); - } + if (status == 0) + return; - public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) + SceneObjectPart part = m_scene.GetSceneObjectPart(partID); + if (part == null || part.ParentGroup.IsAttachment) { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; + return; } - } +// m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); - public void SitRayCastCameraPosition(SceneObjectPart part) - { - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); - } + part.AddSittingAvatar(UUID); - public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayHorizontal(part); - } - } - else - { - SitRayHorizontal(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } + Vector3 cameraAtOffset = part.GetCameraAtOffset(); + Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); + bool forceMouselook = part.GetForceMouselook(); - } + ControllingClient.SendSitResponse( + part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); - public void SitRayHorizontal(SceneObjectPart part) - { - // Next, try to raycast from the avatar position to fwd - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); - } + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } + // assuming no autopilot in use + Velocity = Vector3.Zero; + RemoveFromPhysicalScene(); - } + Rotation = Orientation; + m_pos = offset; - private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) - { - int i = 0; - //throw new NotImplementedException(); - //m_requestedSitTargetUUID = UUID.Zero; - //m_requestedSitTargetID = 0; - //m_requestedSitOffset = Vector3.Zero; + m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now + part.ParentGroup.AddAvatar(UUID); - SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); + ParentPart = part; + ParentID = part.LocalId; + + Animator.TrySetMovementAnimation("SIT"); + SendAvatarDataToAllAgents(); } - */ + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) { -- cgit v1.1 From 9089bc7e37879867756740cfbd0456ad51244ca0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Dec 2012 22:11:29 +0000 Subject: some clean up/fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 93 ++++++++++++------------ 1 file changed, 46 insertions(+), 47 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7ff163b..646e0e2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2082,9 +2082,6 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; - // TODO: determine position to sit at based on scene geometry; don't trust offset from client - // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - if (PhysicsActor != null) m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; @@ -2103,25 +2100,8 @@ namespace OpenSim.Region.Framework.Scenes } else { -// if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) -// { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", -// Name, part.Name, part.LocalId); - - if (m_scene.PhysicsScene != null && - part.PhysActor != null && - Util.GetDistanceTo(AbsolutePosition, pos) <= 30) - { - - Vector3 camdif = CameraPosition - part.AbsolutePosition; - camdif.Normalize(); - -// m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString()); - - if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) - return; - } + if (PhysicsSit(part,offset)) // physics engine + return; if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) { @@ -2129,12 +2109,6 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); canSit = true; } -// else -// { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", -// Name, part.Name, part.LocalId); -// } } if (canSit) @@ -2196,14 +2170,6 @@ namespace OpenSim.Region.Framework.Scenes m_requestedSitTargetID = part.LocalId; m_requestedSitTargetUUID = targetID; -// m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - - if (m_scene.PhysicsScene.SupportsRayCast()) - { - //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); - //SitRayCastAvatarPosition(part); - //return; - } } else { @@ -2213,24 +2179,57 @@ namespace OpenSim.Region.Framework.Scenes SendSitResponse(targetID, offset, Quaternion.Identity); } - public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) + // returns false if does not suport so older sit can be tried + public bool PhysicsSit(SceneObjectPart part, Vector3 offset) { + if (part == null || part.ParentGroup.IsAttachment) + { + return true; + } - if (status < 0) + if ( m_scene.PhysicsScene == null) + return false; + + if (part.PhysActor == null) { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - return; + // none physcis shape + if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) + ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); + else + { // non physical phantom TODO + ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); + return false; + } + return true; } - if (status == 0) + // not doing autopilot + m_requestedSitTargetID = 0; + + if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) + return true; + + return false; + } + + // status + // < 0 ignore + // 0 bad sit spot + public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) + { + if (status < 0) return; - SceneObjectPart part = m_scene.GetSceneObjectPart(partID); - if (part == null || part.ParentGroup.IsAttachment) + if (status == 0) { + ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); return; } + SceneObjectPart part = m_scene.GetSceneObjectPart(partID); + if (part == null) + return; + // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); part.AddSittingAvatar(UUID); @@ -2242,16 +2241,14 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendSitResponse( part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - - // assuming no autopilot in use + // not using autopilot Velocity = Vector3.Zero; RemoveFromPhysicalScene(); Rotation = Orientation; m_pos = offset; - m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now + m_requestedSitTargetID = 0; part.ParentGroup.AddAvatar(UUID); ParentPart = part; @@ -2259,6 +2256,8 @@ namespace OpenSim.Region.Framework.Scenes Animator.TrySetMovementAnimation("SIT"); SendAvatarDataToAllAgents(); + + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } -- cgit v1.1 From 861477d85e794d067f372587ccf56d8887e5ec63 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 Dec 2012 09:32:05 +0100 Subject: Fix locking for good --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0b974c6..4ad8b11 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3439,12 +3439,12 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustChildPrimPermissions() { - //uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits - //uint foldedPerms = RootPart.OwnerMask & 3; + uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits + uint foldedPerms = RootPart.OwnerMask & 3; ForEachPart(part => { - //newOwnerMask &= part.BaseMask; + newOwnerMask &= part.BaseMask; if (part != RootPart) part.ClonePermissions(RootPart); }); -- cgit v1.1 From f9051c22d8170bb2824d9a38540f2fdce4367f6e Mon Sep 17 00:00:00 2001 From: teravus Date: Wed, 19 Dec 2012 22:14:20 -0500 Subject: * Send an Unsolicited AgentDataUpdate packet upon Root Agent Status to synchronize with Agni. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7ff163b..70e7af5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -925,6 +925,26 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); + UUID groupUUID = UUID.Zero; + string GroupName = string.Empty; + ulong groupPowers = 0; + + // ---------------------------------- + // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status + if (gm != null) + { + groupUUID = ControllingClient.ActiveGroupId; + GroupRecord record = gm.GetGroupRecord(groupUUID); + if (record != null) + GroupName = record.GroupName; + GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); + if (groupMembershipData != null) + groupPowers = groupMembershipData.GroupPowers; + } + ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, + Grouptitle); + // ------------------------------------ + if (ParentID == 0) { // Moved this from SendInitialData to ensure that Appearance is initialized -- cgit v1.1 From 77cc7ce399d1b1a710f3b3f4337932febdef66c8 Mon Sep 17 00:00:00 2001 From: teravus Date: Fri, 21 Dec 2012 19:12:30 -0500 Subject: * Partial Commit for Avatar Appearance to include the functionality of Cached Bakes. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 70e7af5..ff9df37 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -931,18 +931,25 @@ namespace OpenSim.Region.Framework.Scenes // ---------------------------------- // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status - if (gm != null) + try + { + if (gm != null) + { + groupUUID = ControllingClient.ActiveGroupId; + GroupRecord record = gm.GetGroupRecord(groupUUID); + if (record != null) + GroupName = record.GroupName; + GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); + if (groupMembershipData != null) + groupPowers = groupMembershipData.GroupPowers; + } + ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, + Grouptitle); + } + catch (Exception e) { - groupUUID = ControllingClient.ActiveGroupId; - GroupRecord record = gm.GetGroupRecord(groupUUID); - if (record != null) - GroupName = record.GroupName; - GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); - if (groupMembershipData != null) - groupPowers = groupMembershipData.GroupPowers; + m_log.Debug("[AGENTUPDATE]: " + e.ToString()); } - ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, - Grouptitle); // ------------------------------------ if (ParentID == 0) -- cgit v1.1 From 7980a1d8496b71e46eeead7d77382cd10ac9fa78 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 2 Jan 2013 19:39:46 +0000 Subject: *TEST* avatar unscripted sit. Some guessing/automation --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 85f4ee5..2a39ffd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2280,8 +2280,10 @@ namespace OpenSim.Region.Framework.Scenes ParentPart = part; ParentID = part.LocalId; - - Animator.TrySetMovementAnimation("SIT"); + if(status == 3) + Animator.TrySetMovementAnimation("SIT_GROUND"); + else + Animator.TrySetMovementAnimation("SIT"); SendAvatarDataToAllAgents(); part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); -- cgit v1.1 From d40cdd26496c267b7de4cf7005eb6c933d7ad238 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 3 Jan 2013 02:25:27 +0000 Subject: cancel MoveToTarget (viewer 'go here") on sits --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2a39ffd..704bad8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2140,12 +2140,21 @@ namespace OpenSim.Region.Framework.Scenes if (canSit) { + if (PhysicsActor != null) { // We can remove the physicsActor until they stand up. RemoveFromPhysicalScene(); } + if (MovingToTarget) + { + ResetMoveToTarget(); + m_forceToApply = null; + } + + Velocity = Vector3.Zero; + part.AddSittingAvatar(UUID); cameraAtOffset = part.GetCameraAtOffset(); @@ -2230,6 +2239,7 @@ namespace OpenSim.Region.Framework.Scenes return true; } + // not doing autopilot m_requestedSitTargetID = 0; @@ -2259,8 +2269,19 @@ namespace OpenSim.Region.Framework.Scenes // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); + RemoveFromPhysicalScene(); + + if (MovingToTarget) + { + ResetMoveToTarget(); + m_forceToApply = null; + } + + Velocity = Vector3.Zero; + part.AddSittingAvatar(UUID); + Vector3 cameraAtOffset = part.GetCameraAtOffset(); Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); bool forceMouselook = part.GetForceMouselook(); @@ -2269,8 +2290,6 @@ namespace OpenSim.Region.Framework.Scenes part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); // not using autopilot - Velocity = Vector3.Zero; - RemoveFromPhysicalScene(); Rotation = Orientation; m_pos = offset; @@ -2317,6 +2336,7 @@ namespace OpenSim.Region.Framework.Scenes return; } + if (part.SitTargetAvatar == UUID) { Vector3 sitTargetPos = part.SitTargetPosition; -- cgit v1.1 From 1665a0d636a0d4e97000e16bd7a2b482e966c446 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 3 Jan 2013 03:29:40 +0000 Subject: make ResetMoveToTarget cancel any 'force' waiting to be applied to avatar ( by the odd use of Velocity) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 704bad8..c16c544 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1990,7 +1990,8 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); MovingToTarget = false; - MoveToPositionTarget = Vector3.Zero; +// MoveToPositionTarget = Vector3.Zero; + m_forceToApply = null; // cancel possible last action // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. @@ -2148,10 +2149,7 @@ namespace OpenSim.Region.Framework.Scenes } if (MovingToTarget) - { ResetMoveToTarget(); - m_forceToApply = null; - } Velocity = Vector3.Zero; @@ -2272,10 +2270,7 @@ namespace OpenSim.Region.Framework.Scenes RemoveFromPhysicalScene(); if (MovingToTarget) - { ResetMoveToTarget(); - m_forceToApply = null; - } Velocity = Vector3.Zero; -- cgit v1.1 From a285ff7e6942f9b55b18b00a765a5b4491fba011 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 3 Jan 2013 14:27:21 +0000 Subject: check land permitions on sit target for unscripted sits --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c16c544..5087882 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2247,6 +2247,17 @@ namespace OpenSim.Region.Framework.Scenes return false; } + + private bool CanEnterLandPosition(Vector3 testPos) + { + ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); + + if (land == null || land.LandData.Name == "NO_LAND") + return true; + + return land.CanBeOnThisLand(UUID,testPos.Z); + } + // status // < 0 ignore // 0 bad sit spot @@ -2265,6 +2276,12 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; + Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); + if(!CanEnterLandPosition(targetPos)) + { + ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); + return; + } // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); RemoveFromPhysicalScene(); -- cgit v1.1 From ca40e656ab4f0915b37356a9f6394f93cd1119a3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 7 Jan 2013 10:35:55 +0000 Subject: in raycast for camera exclude self detection --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5087882..4504e18 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1415,8 +1415,9 @@ namespace OpenSim.Region.Framework.Scenes if (m_followCamAuto) { - if (hitYN) + if (hitYN && localid != LocalId) { + CameraConstraintActive = true; //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); @@ -2282,7 +2283,6 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); return; } -// m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); RemoveFromPhysicalScene(); @@ -2293,7 +2293,6 @@ namespace OpenSim.Region.Framework.Scenes part.AddSittingAvatar(UUID); - Vector3 cameraAtOffset = part.GetCameraAtOffset(); Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); bool forceMouselook = part.GetForceMouselook(); -- cgit v1.1 From d5066ae6787ac860e673a91bf207bf2b397a2714 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Jan 2013 00:21:09 +0000 Subject: * DAnger, TEST * change camera plane collision detection. Still bounces on * prim edges due to camera lag --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 108 +++++++++++++---------- 1 file changed, 59 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4504e18..5d0baf3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -227,8 +227,6 @@ namespace OpenSim.Region.Framework.Scenes /// public bool LandAtTarget { get; private set; } - private bool m_followCamAuto; - private int m_movementUpdateCount; private const int NumMovementsBetweenRayCast = 5; @@ -357,6 +355,9 @@ namespace OpenSim.Region.Framework.Scenes /// protected Vector3 m_lastCameraPosition; + private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); + private bool m_doingCamRayCast = false; + public Vector3 CameraPosition { get; set; } public Quaternion CameraRotation @@ -1407,36 +1408,40 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) + /// + + private void UpdateCameraCollisionPlane(Vector4 plane) { - const float POSITION_TOLERANCE = 0.02f; - const float VELOCITY_TOLERANCE = 0.02f; - const float ROTATION_TOLERANCE = 0.02f; + if (m_lastCameraCollisionPlane != plane) + { + m_lastCameraCollisionPlane = plane; + ControllingClient.SendCameraConstraint(plane); + } + } - if (m_followCamAuto) + public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) + { + m_doingCamRayCast = false; + if (hitYN && localid != LocalId) { - if (hitYN && localid != LocalId) - { + CameraConstraintActive = true; + pNormal.X = (float)Math.Round(pNormal.X, 2); + pNormal.Y = (float)Math.Round(pNormal.Y, 2); + pNormal.Z = (float)Math.Round(pNormal.Z, 2); + pNormal.Normalize(); + collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); + collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); + collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); + + Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); + UpdateCameraCollisionPlane(plane); + } + else + { + Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... + UpdateCameraCollisionPlane(plane); - CameraConstraintActive = true; - //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); - - Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); - ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); - } - else - { - if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) - { - if (CameraConstraintActive) - { - ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); - CameraConstraintActive = false; - } - } - } + CameraConstraintActive = false; } } @@ -1511,12 +1516,6 @@ namespace OpenSim.Region.Framework.Scenes // DrawDistance = agentData.Far; DrawDistance = Scene.DefaultDrawDistance; - // Check if Client has camera in 'follow cam' or 'build' mode. - Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); - - m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) - && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; - m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; @@ -1536,26 +1535,37 @@ namespace OpenSim.Region.Framework.Scenes StandUp(); } - //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); // Raycast from the avatar's head to the camera to see if there's anything blocking the view - if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) + // this exclude checks may not be complete + + if (!m_doingCamRayCast && !m_mouseLook && m_scene.PhysicsScene.SupportsRayCast() && ParentID == 0) { - if (m_followCamAuto) + Vector3 posAdjusted = AbsolutePosition; + posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; + + Vector3 tocam = CameraPosition - posAdjusted; + tocam.X = (float)Math.Round(tocam.X, 1); + tocam.Y = (float)Math.Round(tocam.Y, 1); + tocam.Z = (float)Math.Round(tocam.Z, 1); + + float distTocamlen = tocam.Length(); + if (distTocamlen > 0.3f) { - // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; - // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); - - Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; - Vector3 distTocam = CameraPosition - posAdjusted; - float distTocamlen = distTocam.Length(); - if (distTocamlen > 0) - { - distTocam *= 1.0f / distTocamlen; - m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); - } - + tocam *= (1.0f / distTocamlen); + posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); + posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); + posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); + + m_doingCamRayCast = true; + m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); } } + else if (CameraConstraintActive && (m_mouseLook || ParentID != 0) ) + { + Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... + UpdateCameraCollisionPlane(plane); + CameraConstraintActive = false; + } uint flagsForScripts = (uint)flags; flags = RemoveIgnoredControls(flags, IgnoredControls); -- cgit v1.1 From 1bf553fd6593672c4ac5cd74c180367fcdb18c79 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Jan 2013 01:12:00 +0000 Subject: reduce sampling of camera raycasts to previus value --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 49 +++++++++++++----------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5d0baf3..a19f029 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1538,33 +1538,36 @@ namespace OpenSim.Region.Framework.Scenes // Raycast from the avatar's head to the camera to see if there's anything blocking the view // this exclude checks may not be complete - if (!m_doingCamRayCast && !m_mouseLook && m_scene.PhysicsScene.SupportsRayCast() && ParentID == 0) + if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) { - Vector3 posAdjusted = AbsolutePosition; - posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; - - Vector3 tocam = CameraPosition - posAdjusted; - tocam.X = (float)Math.Round(tocam.X, 1); - tocam.Y = (float)Math.Round(tocam.Y, 1); - tocam.Z = (float)Math.Round(tocam.Z, 1); - - float distTocamlen = tocam.Length(); - if (distTocamlen > 0.3f) + if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) { - tocam *= (1.0f / distTocamlen); - posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); - posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); - posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); + Vector3 posAdjusted = AbsolutePosition; + posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; + + Vector3 tocam = CameraPosition - posAdjusted; + tocam.X = (float)Math.Round(tocam.X, 1); + tocam.Y = (float)Math.Round(tocam.Y, 1); + tocam.Z = (float)Math.Round(tocam.Z, 1); - m_doingCamRayCast = true; - m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); + float distTocamlen = tocam.Length(); + if (distTocamlen > 0.3f) + { + tocam *= (1.0f / distTocamlen); + posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); + posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); + posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); + + m_doingCamRayCast = true; + m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); + } + } + else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) + { + Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... + UpdateCameraCollisionPlane(plane); + CameraConstraintActive = false; } - } - else if (CameraConstraintActive && (m_mouseLook || ParentID != 0) ) - { - Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... - UpdateCameraCollisionPlane(plane); - CameraConstraintActive = false; } uint flagsForScripts = (uint)flags; -- cgit v1.1 From 126e73c5ed7bb95b36739d46921375b78f6207e1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Jan 2013 02:29:21 +0000 Subject: put back position and rot change check before sending releasing plane constrain --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a19f029..cdba282 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1421,6 +1421,9 @@ namespace OpenSim.Region.Framework.Scenes public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) { + const float POSITION_TOLERANCE = 0.02f; + const float ROTATION_TOLERANCE = 0.02f; + m_doingCamRayCast = false; if (hitYN && localid != LocalId) { @@ -1436,11 +1439,11 @@ namespace OpenSim.Region.Framework.Scenes Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); UpdateCameraCollisionPlane(plane); } - else + else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || + !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) { Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... UpdateCameraCollisionPlane(plane); - CameraConstraintActive = false; } } @@ -1543,8 +1546,8 @@ namespace OpenSim.Region.Framework.Scenes if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) { Vector3 posAdjusted = AbsolutePosition; - posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; - +// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; + posAdjusted.Z += 1.0f; // viewer current camera focus point Vector3 tocam = CameraPosition - posAdjusted; tocam.X = (float)Math.Round(tocam.X, 1); tocam.Y = (float)Math.Round(tocam.Y, 1); -- cgit v1.1 From d1fa650c3f16ee74cd39d9258c5ef7aa4869ca03 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 12:08:34 +0100 Subject: Remove sending AvatarData because this also happens on login, where it chokes Firestorm, Singularity and other viewers with the new appearance pipeline. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4504e18..b6407d2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,8 +140,6 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; - private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); - private Vector3? m_forceToApply; private int m_userFlags; @@ -2525,13 +2523,7 @@ namespace OpenSim.Region.Framework.Scenes // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity - if (Appearance.AvatarSize != m_lastSize) - { - m_lastSize = Appearance.AvatarSize; - SendAvatarDataToAllAgents(); - } - - else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) { -- cgit v1.1 From 09d41f4f7892b2d40b692f0cdd451fea07ad0cf0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 13:11:04 +0100 Subject: Revert "Remove sending AvatarData because this also happens on login, where it chokes" This reverts commit d1fa650c3f16ee74cd39d9258c5ef7aa4869ca03. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index be3a39a..cdba282 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; + private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); + private Vector3? m_forceToApply; private int m_userFlags; @@ -2539,7 +2541,13 @@ namespace OpenSim.Region.Framework.Scenes // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity - if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + if (Appearance.AvatarSize != m_lastSize) + { + m_lastSize = Appearance.AvatarSize; + SendAvatarDataToAllAgents(); + } + + else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) { -- cgit v1.1 From ef8f03b711e7d15443b9f0a597632e75e3d86ddc Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 13:57:45 +0100 Subject: Prevent avatar data from being sent during login when it's not valid and crashes login on some viewers. --- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c99e37e..23006f2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2977,6 +2977,7 @@ namespace OpenSim.Region.Framework.Scenes // start the scripts again (since this is done in RezAttachments()). // XXX: This is convoluted. sp.IsChildAgent = false; + sp.IsLoggingIn = true; if (AttachmentsModule != null) Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cdba282..48212d0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -607,6 +607,7 @@ namespace OpenSim.Region.Framework.Scenes } public bool IsChildAgent { get; set; } + public bool IsLoggingIn { get; set; } /// /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. @@ -743,6 +744,7 @@ namespace OpenSim.Region.Framework.Scenes AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; + IsLoggingIn = false; m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); PresenceType = type; @@ -915,6 +917,7 @@ namespace OpenSim.Region.Framework.Scenes else { IsChildAgent = false; + IsLoggingIn = false; } @@ -2541,13 +2544,13 @@ namespace OpenSim.Region.Framework.Scenes // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity - if (Appearance.AvatarSize != m_lastSize) + if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) { m_lastSize = Appearance.AvatarSize; SendAvatarDataToAllAgents(); } - else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) { -- cgit v1.1 From fb088a48ac6cd737a25ce46f76e988879c0f0255 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Jan 2013 14:09:01 +0000 Subject: also update m_lastSize in SendAvatarDataToAllAgents so more paths update it --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cdba282..a90bee4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2738,6 +2738,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + m_lastSize = Appearance.AvatarSize; + int count = 0; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { -- cgit v1.1 From 0aabb93ef3aa6217cb5f3312f864e46465204d48 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 14:00:40 +0100 Subject: Remove now superfluous update of m_lastSize --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1c27202..a9195f7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2545,10 +2545,7 @@ namespace OpenSim.Region.Framework.Scenes // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) - { - m_lastSize = Appearance.AvatarSize; SendAvatarDataToAllAgents(); - } if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || -- cgit v1.1 From ab053df706055b0aa8fe2d10f89488be97d36841 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 23:01:09 +0100 Subject: Prevent empty Anim Packs --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 65ae445..d2fc7f1 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -164,7 +164,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation { int defaultSize = 0; if (m_defaultAnimation.AnimID != UUID.Zero) + { + defaultSize++; + } + else if (m_animations.Count == 0) + { defaultSize++; + } animIDs = new UUID[m_animations.Count + defaultSize]; sequenceNums = new int[m_animations.Count + defaultSize]; @@ -176,6 +182,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation sequenceNums[0] = m_defaultAnimation.SequenceNum; objectIDs[0] = m_defaultAnimation.ObjectID; } + else if (m_animations.Count == 0) + { + animIDs[0] = m_implicitDefaultAnimation.AnimID; + sequenceNums[0] = m_defaultAnimation.SequenceNum; + objectIDs[0] = m_implicitDefaultAnimation.ObjectID; + } for (int i = 0; i < m_animations.Count; ++i) { -- cgit v1.1 From 8f37f2ca7edd408f30165fef9817375a9813ce90 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 23:24:34 +0100 Subject: Fix sequence id fr default anim --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index d2fc7f1..64c31f8 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (m_animations.Count == 0) { animIDs[0] = m_implicitDefaultAnimation.AnimID; - sequenceNums[0] = m_defaultAnimation.SequenceNum; + sequenceNums[0] = m_implicitDefaultAnimation.SequenceNum; objectIDs[0] = m_implicitDefaultAnimation.ObjectID; } -- cgit v1.1 From be844030ce75907a85ff00cdac4d9b706ccc3101 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jan 2013 00:10:57 +0100 Subject: Revert "Fix sequence id fr default anim" This reverts commit 8f37f2ca7edd408f30165fef9817375a9813ce90. --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 64c31f8..d2fc7f1 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (m_animations.Count == 0) { animIDs[0] = m_implicitDefaultAnimation.AnimID; - sequenceNums[0] = m_implicitDefaultAnimation.SequenceNum; + sequenceNums[0] = m_defaultAnimation.SequenceNum; objectIDs[0] = m_implicitDefaultAnimation.ObjectID; } -- cgit v1.1 From 92db4ef0686d0cce11cf23de926352ace0104bb7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jan 2013 00:11:08 +0100 Subject: Revert "Prevent empty Anim Packs" This reverts commit ab053df706055b0aa8fe2d10f89488be97d36841. --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index d2fc7f1..65ae445 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -164,13 +164,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { int defaultSize = 0; if (m_defaultAnimation.AnimID != UUID.Zero) - { - defaultSize++; - } - else if (m_animations.Count == 0) - { defaultSize++; - } animIDs = new UUID[m_animations.Count + defaultSize]; sequenceNums = new int[m_animations.Count + defaultSize]; @@ -182,12 +176,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation sequenceNums[0] = m_defaultAnimation.SequenceNum; objectIDs[0] = m_defaultAnimation.ObjectID; } - else if (m_animations.Count == 0) - { - animIDs[0] = m_implicitDefaultAnimation.AnimID; - sequenceNums[0] = m_defaultAnimation.SequenceNum; - objectIDs[0] = m_implicitDefaultAnimation.ObjectID; - } for (int i = 0; i < m_animations.Count; ++i) { -- cgit v1.1 From 949da1d4af77247786b00041bc0d1732617b7286 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jan 2013 20:07:21 +0100 Subject: Change IsRoot to use ReferenceEquals to prevent operator == messiness --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2191cfa..b62667f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -144,7 +144,7 @@ namespace OpenSim.Region.Framework.Scenes /// public bool IsRoot { - get { return ParentGroup.RootPart == this; } + get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } } /// -- cgit v1.1 From 756d53db5e9c7a2ac73e501b7883381026f3c608 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 13:39:14 +0000 Subject: keyframe. Don't use group UpdateRotation since this enqueues a terse update and we are sending them imediatly --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index edf2bef..995060b 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -544,8 +544,10 @@ namespace OpenSim.Region.Framework.Scenes m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; - m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + // we are sending imediate updates, no doing force a extra terseUpdate +// m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; m_frames.RemoveAt(0); if (m_frames.Count > 0) m_currentFrame = m_frames[0]; @@ -613,7 +615,9 @@ namespace OpenSim.Region.Framework.Scenes // assuming w is a dependente var { - m_group.UpdateGroupRotationR(step); +// m_group.UpdateGroupRotationR(step); + m_group.RootPart.RotationOffset = step; + //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); update = true; } -- cgit v1.1 From 1f9dbdf8b8d8c70e654199c5f9a4258e0e6693f9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 14:16:45 +0000 Subject: same for AngularVelocity. Use normal terse updates in place of sending imediatly. If that's good for physics, needs to be good for this --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 28 +++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 995060b..43f46d1 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -345,9 +345,9 @@ namespace OpenSim.Region.Framework.Scenes m_baseRotation = m_group.GroupRotation; m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); - m_group.SendGroupRootTerseUpdate(); - + m_group.RootPart.AngularVelocity = Vector3.Zero; +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -357,8 +357,10 @@ namespace OpenSim.Region.Framework.Scenes RemoveTimer(); m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); - m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.AngularVelocity = Vector3.Zero; +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); + } private void GetNextList() @@ -489,7 +491,9 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); + } m_inOnTimer = false; return; @@ -539,7 +543,7 @@ namespace OpenSim.Region.Framework.Scenes if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + m_group.RootPart.AngularVelocity = Vector3.Zero; m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; @@ -625,7 +629,9 @@ namespace OpenSim.Region.Framework.Scenes } if (update) - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); + } catch ( Exception ex) @@ -675,7 +681,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); } } @@ -686,7 +693,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); if (m_running && m_timer != null) { -- cgit v1.1 From 819f4b338d7c998a6e93b4558d6bd005a097904d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 16:02:14 +0000 Subject: remove redundant lastPhysGroupPos and lastPhysGroupRot checks in SOG Update(). rootpart does more complet checks --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4ad8b11..b008e66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -307,9 +307,6 @@ namespace OpenSim.Region.Framework.Scenes get { return RootPart.VolumeDetectActive; } } - private Vector3 lastPhysGroupPos; - private Quaternion lastPhysGroupRot; - private bool m_isBackedUp; public bool IsBackedUp @@ -2525,6 +2522,7 @@ namespace OpenSim.Region.Framework.Scenes #endregion + public override void Update() { // Check that the group was not deleted before the scheduled update @@ -2543,19 +2541,8 @@ namespace OpenSim.Region.Framework.Scenes // check to see if the physical position or rotation warrant an update. if (m_rootPart.UpdateFlag == UpdateRequired.NONE) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - - if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) - { - m_rootPart.UpdateFlag = UpdateRequired.TERSE; - lastPhysGroupPos = AbsolutePosition; - } - - if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) - { - m_rootPart.UpdateFlag = UpdateRequired.TERSE; - lastPhysGroupRot = GroupRotation; - } + // rootpart SendScheduledUpdates will check if a update is needed + m_rootPart.UpdateFlag = UpdateRequired.TERSE; } SceneObjectPart[] parts = m_parts.GetArray(); -- cgit v1.1 From d7f0bf04f6b69d7ea616f02d3f7f4381debda00e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 16:24:48 +0000 Subject: update the last information sent in terse updates where they are sent to all clients and not only on Scheduled sends --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2191cfa..ff4ae85 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -144,7 +144,7 @@ namespace OpenSim.Region.Framework.Scenes /// public bool IsRoot { - get { return ParentGroup.RootPart == this; } + get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } } /// @@ -319,7 +319,7 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastVelocity; protected Vector3 m_lastAcceleration; protected Vector3 m_lastAngularVelocity; - protected int m_lastTerseSent; + protected int m_lastUpdateSentTime; protected float m_buoyancy = 0.0f; protected Vector3 m_force; protected Vector3 m_torque; @@ -3198,6 +3198,14 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup == null) return; + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = Velocity; + m_lastAcceleration = Acceleration; + m_lastAngularVelocity = AngularVelocity; + m_lastUpdateSentTime = Environment.TickCount; + ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { SendFullUpdate(avatar.ControllingClient); @@ -3271,17 +3279,10 @@ namespace OpenSim.Region.Framework.Scenes Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) + Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) { SendTerseUpdateToAllClients(); - // Update the "last" values - m_lastPosition = OffsetPosition; - m_lastRotation = RotationOffset; - m_lastVelocity = Velocity; - m_lastAcceleration = Acceleration; - m_lastAngularVelocity = AngularVelocity; - m_lastTerseSent = Environment.TickCount; } break; } @@ -3302,6 +3303,14 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup == null || ParentGroup.Scene == null) return; + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = Velocity; + m_lastAcceleration = Acceleration; + m_lastAngularVelocity = AngularVelocity; + m_lastUpdateSentTime = Environment.TickCount; + ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { SendTerseUpdateToClient(client); -- cgit v1.1 From a892dbba63fe85e36d242e5f7dc41bc37aaafc9e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 18:18:22 +0000 Subject: go back bypassing sog updates control (test) --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 43f46d1..5cfba39 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -346,8 +346,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -358,8 +358,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } @@ -491,8 +491,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } m_inOnTimer = false; @@ -629,8 +629,8 @@ namespace OpenSim.Region.Framework.Scenes } if (update) -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } @@ -681,8 +681,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } } @@ -693,8 +693,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); if (m_running && m_timer != null) { -- cgit v1.1 From 818254916cb562422b3a3301b9f35fafd64ee3fe Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 16 Jan 2013 15:47:55 +0000 Subject: JustinCC's core re-merge --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 65c50bf..9f0a0e2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1783,6 +1783,21 @@ namespace OpenSim.Region.Framework.Scenes /// The part where the script was rezzed if successful. False otherwise. public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) { + return RezNewScript( + agentID, + itemBase, + "default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"); + } + + /// + /// Rez a new script from nothing with given script text. + /// + /// + /// Template item. + /// + /// The part where the script was rezzed if successful. False otherwise. + public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase, string scriptText) + { // The part ID is the folder ID! SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) @@ -1802,9 +1817,14 @@ namespace OpenSim.Region.Framework.Scenes return null; } - AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, - Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), - agentID); + AssetBase asset + = CreateAsset( + itemBase.Name, + itemBase.Description, + (sbyte)itemBase.AssetType, + Encoding.ASCII.GetBytes(scriptText), + agentID); + AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); -- cgit v1.1 From de49440839e905cc4b3668962be96f8e274704d0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 Jan 2013 22:17:10 +0000 Subject: dont send a full grp update on stopmovetotarget. just a rootpart terse --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 ++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b008e66..b474979 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2369,6 +2369,8 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) pa.PIDActive = false; + + RootPart.ScheduleTerseUpdate(); // send a stop information } public void rotLookAt(Quaternion target, float strength, float damping) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ff4ae85..8528edc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3760,7 +3760,7 @@ namespace OpenSim.Region.Framework.Scenes { ParentGroup.stopMoveToTarget(); - ParentGroup.ScheduleGroupForTerseUpdate(); +// ParentGroup.ScheduleGroupForTerseUpdate(); //ParentGroup.ScheduleGroupForFullUpdate(); } -- cgit v1.1 From 80529a6baca35e61e684fa3eb1a40c141101ff2c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Jan 2013 01:47:09 +0100 Subject: Prevent scene from holding references to SOGs with attargets beyond SOG deletion --- OpenSim/Region/Framework/Scenes/Scene.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 23006f2..9d07537 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -282,7 +282,7 @@ namespace OpenSim.Region.Framework.Scenes private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing private volatile bool m_backingup; private Dictionary m_returns = new Dictionary(); - private Dictionary m_groupsWithTargets = new Dictionary(); + private Dictionary m_groupsWithTargets = new Dictionary(); private bool m_physics_enabled = true; private bool m_scripts_enabled = true; @@ -1736,7 +1736,7 @@ namespace OpenSim.Region.Framework.Scenes public void AddGroupTarget(SceneObjectGroup grp) { lock (m_groupsWithTargets) - m_groupsWithTargets[grp.UUID] = grp; + m_groupsWithTargets[grp.UUID] = 0; } public void RemoveGroupTarget(SceneObjectGroup grp) @@ -1747,18 +1747,24 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAtTargets() { - List objs = null; + List objs = null; lock (m_groupsWithTargets) { if (m_groupsWithTargets.Count != 0) - objs = new List(m_groupsWithTargets.Values); + objs = new List(m_groupsWithTargets.Keys); } if (objs != null) { - foreach (SceneObjectGroup entry in objs) - entry.checkAtTargets(); + foreach (UUID entry in objs) + { + SceneObjectGroup grp = GetSceneObjectGroup(entry); + if (grp == null) + m_groupsWithTargets.Remove(entry); + else + grp.checkAtTargets(); + } } } -- cgit v1.1 From a291e6be93ada150e35e141dbeb37a31d580f87d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Jan 2013 01:47:54 +0100 Subject: Limit active at targets to 8 --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b474979..17f5a0f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -320,8 +320,8 @@ namespace OpenSim.Region.Framework.Scenes protected SceneObjectPart m_rootPart; // private Dictionary m_scriptEvents = new Dictionary(); - private Dictionary m_targets = new Dictionary(); - private Dictionary m_rotTargets = new Dictionary(); + private SortedDictionary m_targets = new SortedDictionary(); + private SortedDictionary m_rotTargets = new SortedDictionary(); private bool m_scriptListens_atTarget; private bool m_scriptListens_notAtTarget; @@ -4112,6 +4112,8 @@ namespace OpenSim.Region.Framework.Scenes waypoint.handle = handle; lock (m_rotTargets) { + if (m_rotTargets.Count >= 8) + m_rotTargets.Remove(m_rotTargets.ElementAt(0).Key); m_rotTargets.Add(handle, waypoint); } m_scene.AddGroupTarget(this); @@ -4137,6 +4139,8 @@ namespace OpenSim.Region.Framework.Scenes waypoint.handle = handle; lock (m_targets) { + if (m_targets.Count >= 8) + m_targets.Remove(m_targets.ElementAt(0).Key); m_targets.Add(handle, waypoint); } m_scene.AddGroupTarget(this); -- cgit v1.1 From da6f589885b7acf5f85aaeb2c011792b9d41a22e Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Jan 2013 08:36:21 +0100 Subject: Add accessors to allow serializing rot and position targets --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 17f5a0f..ed1bbd8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -79,14 +79,14 @@ namespace OpenSim.Region.Framework.Scenes object_rez = 4194304 } - struct scriptPosTarget + public struct scriptPosTarget { public Vector3 targetPos; public float tolerance; public uint handle; } - struct scriptRotTarget + public struct scriptRotTarget { public Quaternion targetRot; public float tolerance; @@ -323,6 +323,16 @@ namespace OpenSim.Region.Framework.Scenes private SortedDictionary m_targets = new SortedDictionary(); private SortedDictionary m_rotTargets = new SortedDictionary(); + public SortedDictionary AtTargets + { + get { return m_targets; } + } + + public SortedDictionary RotTargets + { + get { return m_rotTargets; } + } + private bool m_scriptListens_atTarget; private bool m_scriptListens_notAtTarget; private bool m_scriptListens_atRotTarget; -- cgit v1.1 From c75508ec8d236b45c65c80d479ed7c24dd3343ce Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 23 Jan 2013 20:29:05 +0100 Subject: Fix a type (Suports => Supports). Also put the normal terrain collision check into the physics check patch for now since physics doesn't properly return land for some reason (as tested by Nebadon) --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9d07537..e3bc8c7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2065,11 +2065,11 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerPrimsLoaded(this); } - public bool SuportsRayCastFiltered() + public bool SupportsRayCastFiltered() { if (PhysicsScene == null) return false; - return PhysicsScene.SuportsRaycastWorldFiltered(); + return PhysicsScene.SupportsRaycastWorldFiltered(); } public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) -- cgit v1.1 From 1b5d5d70401ef69bf3e9da0bb1e668d4ccd520ce Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 26 Jan 2013 18:03:18 +0100 Subject: Stop temp-on-rez object from being deleted while an avatar sits on them --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ed1bbd8..41f04e2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2023,7 +2023,7 @@ namespace OpenSim.Region.Framework.Scenes (parcel.LandData.GroupID != GroupID || parcel.LandData.GroupID == UUID.Zero)) { - if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes > + if (GetSittingAvatarsCount() == 0 && (DateTime.UtcNow - RootPart.Rezzed).TotalMinutes > parcel.LandData.OtherCleanTime) { DetachFromBackup(); -- cgit v1.1 From f1fbb774b6f08acde0c88618911dd4dc311217ad Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 26 Jan 2013 20:39:17 +0100 Subject: Reinstate cleaning objects from parcel when avatars sit on them. Instead do it properly for temp-on-rez. Auto-return overrides sitting. Temp does not. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e3bc8c7..c7a38f7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5122,7 +5122,7 @@ namespace OpenSim.Region.Framework.Scenes { if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) { - if (grp.RootPart.Expires <= DateTime.Now) + if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) DeleteSceneObject(grp, false); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 41f04e2..ed1bbd8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2023,7 +2023,7 @@ namespace OpenSim.Region.Framework.Scenes (parcel.LandData.GroupID != GroupID || parcel.LandData.GroupID == UUID.Zero)) { - if (GetSittingAvatarsCount() == 0 && (DateTime.UtcNow - RootPart.Rezzed).TotalMinutes > + if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes > parcel.LandData.OtherCleanTime) { DetachFromBackup(); -- cgit v1.1 From 380b017e3295eaf30a4a96c23faed5be78495256 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Jan 2013 00:20:34 +0100 Subject: Prevent items being destroyed by rename operations. Renaming of a wearable also sends an asset transaciton but it is empty. So we can't ignore name data when a transaction is present and can't treat every transaction as valid. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index c9d1205..4130029 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -401,17 +401,17 @@ namespace OpenSim.Region.Framework.Scenes if (item.Owner != remoteClient.AgentId) return; - if (UUID.Zero == transactionID) - { - item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); - item.Name = itemUpd.Name; - item.Description = itemUpd.Description; + item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); + item.Name = itemUpd.Name; + item.Description = itemUpd.Description; // m_log.DebugFormat( // "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}", // itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags, // item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions); + if (itemUpd.NextPermissions != 0) // Use this to determine validity. Can never be 0 if valid + { if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; @@ -446,7 +446,8 @@ namespace OpenSim.Region.Framework.Scenes InventoryService.UpdateItem(item); } - else + + if (UUID.Zero != transactionID) { if (AgentTransactionsModule != null) { -- cgit v1.1 From e336c50813b0bf1fff463e3d54e13530cb95ff0e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Jan 2013 23:35:53 +0100 Subject: Send moving_end event to scripts when keyframed motion ends. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 5cfba39..134a620 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -525,6 +525,16 @@ namespace OpenSim.Region.Framework.Scenes { Stop(); m_inOnTimer = false; + Scene scene = m_group.Scene; + + IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); + foreach (IScriptModule m in scriptModules) + { + if (m == null) + continue; + m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); + } + return; } -- cgit v1.1 From d1ebb0a8f91ff61138831b51c04e5c14650f938c Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 30 Jan 2013 15:54:14 +0100 Subject: Change keyframe motion to use a single timer for all objects. This is required to prevent slippage between objects that are meant to move synchronously or keep their relative positions/rotations. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 465 +++++++++++----------- 1 file changed, 229 insertions(+), 236 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 134a620..5a1fd13 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -22,6 +22,77 @@ using log4net; namespace OpenSim.Region.Framework.Scenes { + public static class KeyframeTimer + { + private static Timer m_timer; + private static Dictionary m_motions = new Dictionary(); + private static object m_lockObject = new object(); + private static object m_timerLock = new object(); + public const double timerInterval = 50.0; + + static KeyframeTimer() + { + m_timer = new Timer(); + m_timer.Interval = timerInterval; + m_timer.AutoReset = true; + m_timer.Elapsed += OnTimer; + + m_timer.Start(); + } + + private static void OnTimer(object sender, ElapsedEventArgs ea) + { + if (!Monitor.TryEnter(m_timerLock)) + return; + + try + { + List motions; + + lock (m_lockObject) + { + motions = new List(m_motions.Keys); + } + + foreach (KeyframeMotion m in motions) + { + try + { + m.OnTimer(); + } + catch (Exception inner) + { + // Don't stop processing + } + } + } + catch (Exception e) + { + // Keep running no matter what + } + finally + { + Monitor.Exit(m_timerLock); + } + } + + public static void Add(KeyframeMotion motion) + { + lock (m_lockObject) + { + m_motions[motion] = null; + } + } + + public static void Remove(KeyframeMotion motion) + { + lock (m_lockObject) + { + m_motions.Remove(motion); + } + } + } + [Serializable] public class KeyframeMotion { @@ -63,18 +134,6 @@ namespace OpenSim.Region.Framework.Scenes private Keyframe[] m_keyframes; - [NonSerialized()] - protected Timer m_timer = null; - - // timer lock - [NonSerialized()] - private object m_onTimerLock; - - // timer overrun detect - // prevents overlap or timer events threads frozen on the lock - [NonSerialized()] - private bool m_inOnTimer; - // skip timer events. //timer.stop doesn't assure there aren't event threads still being fired [NonSerialized()] @@ -102,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_iterations = 0; - private const double timerInterval = 50.0; + private int m_skipLoops = 0; public DataFormat Data { @@ -139,31 +198,16 @@ namespace OpenSim.Region.Framework.Scenes private void StartTimer() { - if (m_timer == null) - return; + KeyframeTimer.Add(this); m_timerStopped = false; - m_timer.Start(); } private void StopTimer() { - if (m_timer == null || m_timerStopped) - return; m_timerStopped = true; - m_timer.Stop(); + KeyframeTimer.Remove(this); } - private void RemoveTimer() - { - if (m_timer == null) - return; - m_timerStopped = true; - m_timer.Stop(); - m_timer.Elapsed -= OnTimer; - m_timer = null; - } - - public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) { KeyframeMotion newMotion = null; @@ -180,9 +224,7 @@ namespace OpenSim.Region.Framework.Scenes if (grp != null && grp.IsSelected) newMotion.m_selected = true; - newMotion.m_onTimerLock = new object(); newMotion.m_timerStopped = false; - newMotion.m_inOnTimer = false; newMotion.m_isCrossing = false; newMotion.m_waitingCrossing = false; } @@ -196,37 +238,34 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateSceneObject(SceneObjectGroup grp) { -// lock (m_onTimerLock) - { - m_isCrossing = false; - m_waitingCrossing = false; - StopTimer(); - - if (grp == null) - return; + m_isCrossing = false; + m_waitingCrossing = false; + StopTimer(); - m_group = grp; - Vector3 grppos = grp.AbsolutePosition; - Vector3 offset = grppos - m_serializedPosition; - // avoid doing it more than once - // current this will happen draging a prim to other region - m_serializedPosition = grppos; + if (grp == null) + return; - m_basePosition += offset; - m_currentFrame.Position += offset; + m_group = grp; + Vector3 grppos = grp.AbsolutePosition; + Vector3 offset = grppos - m_serializedPosition; + // avoid doing it more than once + // current this will happen draging a prim to other region + m_serializedPosition = grppos; - m_nextPosition += offset; + m_basePosition += offset; + m_currentFrame.Position += offset; - for (int i = 0; i < m_frames.Count; i++) - { - Keyframe k = m_frames[i]; - k.Position += offset; - m_frames[i]=k; - } + m_nextPosition += offset; - if (m_running) - Start(); + for (int i = 0; i < m_frames.Count; i++) + { + Keyframe k = m_frames[i]; + k.Position += offset; + m_frames[i]=k; } + + if (m_running) + Start(); } public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) @@ -241,9 +280,7 @@ namespace OpenSim.Region.Framework.Scenes m_baseRotation = grp.GroupRotation; } - m_onTimerLock = new object(); m_timerStopped = true; - m_inOnTimer = false; m_isCrossing = false; m_waitingCrossing = false; } @@ -296,7 +333,7 @@ namespace OpenSim.Region.Framework.Scenes public void Delete() { m_running = false; - RemoveTimer(); + StopTimer(); m_isCrossing = false; m_waitingCrossing = false; m_frames.Clear(); @@ -309,27 +346,13 @@ namespace OpenSim.Region.Framework.Scenes m_waitingCrossing = false; if (m_keyframes != null && m_group != null && m_keyframes.Length > 0) { - if (m_timer == null) - { - m_timer = new Timer(); - m_timer.Interval = timerInterval; - m_timer.AutoReset = true; - m_timer.Elapsed += OnTimer; - } - else - { - StopTimer(); - m_timer.Interval = timerInterval; - } - - m_inOnTimer = false; StartTimer(); m_running = true; } else { m_running = false; - RemoveTimer(); + StopTimer(); } } @@ -339,7 +362,7 @@ namespace OpenSim.Region.Framework.Scenes m_isCrossing = false; m_waitingCrossing = false; - RemoveTimer(); + StopTimer(); m_basePosition = m_group.AbsolutePosition; m_baseRotation = m_group.GroupRotation; @@ -354,7 +377,7 @@ namespace OpenSim.Region.Framework.Scenes public void Pause() { m_running = false; - RemoveTimer(); + StopTimer(); m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; @@ -377,15 +400,11 @@ namespace OpenSim.Region.Framework.Scenes int start = 0; int end = m_keyframes.Length; -// if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1) -// end = m_keyframes.Length - 1; if (direction < 0) { start = m_keyframes.Length - 1; end = -1; -// if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1) -// end = 0; } for (int i = start; i != end ; i += direction) @@ -463,199 +482,172 @@ namespace OpenSim.Region.Framework.Scenes } } - protected void OnTimer(object sender, ElapsedEventArgs e) + public void OnTimer() { - if (m_timerStopped) // trap events still in air even after a timer.stop - return; - - if (m_inOnTimer) // don't let overruns to happen + if (m_skipLoops > 0) { - m_log.Warn("[KeyFrame]: timer overrun"); + m_skipLoops--; return; } + if (m_timerStopped) // trap events still in air even after a timer.stop + return; + if (m_group == null) return; - lock (m_onTimerLock) - { + bool update = false; - m_inOnTimer = true; + if (m_selected) + { + if (m_group.RootPart.Velocity != Vector3.Zero) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); - bool update = false; + } + return; + } - try + if (m_isCrossing) + { + // if crossing and timer running then cross failed + // wait some time then + // retry to set the position that evtually caused the outbound + // if still outside region this will call startCrossing below + m_isCrossing = false; + m_group.AbsolutePosition = m_nextPosition; + if (!m_isCrossing) { - if (m_selected) - { - if (m_group.RootPart.Velocity != Vector3.Zero) - { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); -// m_group.RootPart.ScheduleTerseUpdate(); + StopTimer(); + StartTimer(); + } + return; + } - } - m_inOnTimer = false; - return; - } + if (m_frames.Count == 0) + { + GetNextList(); - if (m_isCrossing) - { - // if crossing and timer running then cross failed - // wait some time then - // retry to set the position that evtually caused the outbound - // if still outside region this will call startCrossing below - m_isCrossing = false; - m_group.AbsolutePosition = m_nextPosition; - if (!m_isCrossing) - { - StopTimer(); - m_timer.Interval = timerInterval; - StartTimer(); - } - m_inOnTimer = false; - return; - } + if (m_frames.Count == 0) + { + Stop(); + Scene scene = m_group.Scene; - if (m_frames.Count == 0) + IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); + foreach (IScriptModule m in scriptModules) { - GetNextList(); + if (m == null) + continue; + m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); + } - if (m_frames.Count == 0) - { - Stop(); - m_inOnTimer = false; - Scene scene = m_group.Scene; - - IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); - foreach (IScriptModule m in scriptModules) - { - if (m == null) - continue; - m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); - } - - return; - } + return; + } - m_currentFrame = m_frames[0]; - m_currentFrame.TimeMS += (int)timerInterval; + m_currentFrame = m_frames[0]; + m_currentFrame.TimeMS += (int)KeyframeTimer.timerInterval; - //force a update on a keyframe transition - update = true; - } + //force a update on a keyframe transition + update = true; + } - m_currentFrame.TimeMS -= (int)timerInterval; + m_currentFrame.TimeMS -= (int)KeyframeTimer.timerInterval; - // Do the frame processing - double steps = (double)m_currentFrame.TimeMS / timerInterval; + // Do the frame processing + double steps = (double)m_currentFrame.TimeMS / KeyframeTimer.timerInterval; - if (steps <= 0.0) - { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.AngularVelocity = Vector3.Zero; + if (steps <= 0.0) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.AngularVelocity = Vector3.Zero; - m_nextPosition = (Vector3)m_currentFrame.Position; - m_group.AbsolutePosition = m_nextPosition; + m_nextPosition = (Vector3)m_currentFrame.Position; + m_group.AbsolutePosition = m_nextPosition; - // we are sending imediate updates, no doing force a extra terseUpdate -// m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + // we are sending imediate updates, no doing force a extra terseUpdate + // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); - m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; - m_frames.RemoveAt(0); - if (m_frames.Count > 0) - m_currentFrame = m_frames[0]; + m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; + m_frames.RemoveAt(0); + if (m_frames.Count > 0) + m_currentFrame = m_frames[0]; - update = true; - } - else - { - float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; + update = true; + } + else + { + float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; - Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; - Vector3 motionThisFrame = v / (float)steps; - v = v * 1000 / m_currentFrame.TimeMS; + Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; + Vector3 motionThisFrame = v / (float)steps; + v = v * 1000 / m_currentFrame.TimeMS; - if (Vector3.Mag(motionThisFrame) >= 0.05f) - { - // m_group.AbsolutePosition += motionThisFrame; - m_nextPosition = m_group.AbsolutePosition + motionThisFrame; - m_group.AbsolutePosition = m_nextPosition; + if (Vector3.Mag(motionThisFrame) >= 0.05f) + { + // m_group.AbsolutePosition += motionThisFrame; + m_nextPosition = m_group.AbsolutePosition + motionThisFrame; + m_group.AbsolutePosition = m_nextPosition; - m_group.RootPart.Velocity = v; - update = true; - } + m_group.RootPart.Velocity = v; + update = true; + } - if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) - { - Quaternion current = m_group.GroupRotation; + if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) + { + Quaternion current = m_group.GroupRotation; - Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); - step.Normalize(); + Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); + step.Normalize(); /* use simpler change detection - * float angle = 0; - - float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; - float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; - float aa_bb = aa * bb; - - if (aa_bb == 0) - { - angle = 0; - } - else - { - float ab = current.X * step.X + - current.Y * step.Y + - current.Z * step.Z + - current.W * step.W; - float q = (ab * ab) / aa_bb; - - if (q > 1.0f) - { - angle = 0; - } - else - { - angle = (float)Math.Acos(2 * q - 1); - } - } - - if (angle > 0.01f) - */ - if(Math.Abs(step.X - current.X) > 0.001f - || Math.Abs(step.Y - current.Y) > 0.001f - || Math.Abs(step.Z - current.Z) > 0.001f) - // assuming w is a dependente var +* float angle = 0; - { -// m_group.UpdateGroupRotationR(step); - m_group.RootPart.RotationOffset = step; + float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; + float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; + float aa_bb = aa * bb; + + if (aa_bb == 0) + { + angle = 0; + } + else + { + float ab = current.X * step.X + + current.Y * step.Y + + current.Z * step.Z + + current.W * step.W; + float q = (ab * ab) / aa_bb; - //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); - update = true; - } + if (q > 1.0f) + { + angle = 0; + } + else + { + angle = (float)Math.Acos(2 * q - 1); } } - if (update) - m_group.SendGroupRootTerseUpdate(); -// m_group.RootPart.ScheduleTerseUpdate(); + if (angle > 0.01f) +*/ + if(Math.Abs(step.X - current.X) > 0.001f + || Math.Abs(step.Y - current.Y) > 0.001f + || Math.Abs(step.Z - current.Z) > 0.001f) + // assuming w is a dependente var + { +// m_group.UpdateGroupRotationR(step); + m_group.RootPart.RotationOffset = step; + //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); + update = true; + } } - catch ( Exception ex) - { - // still happening sometimes - // lets try to see where - m_log.Warn("[KeyFrame]: timer overrun" + ex.Message); - } + } - finally - { - // make sure we do not let this frozen - m_inOnTimer = false; - } + if (update) + { + m_group.SendGroupRootTerseUpdate(); } } @@ -687,7 +679,7 @@ namespace OpenSim.Region.Framework.Scenes m_isCrossing = true; m_waitingCrossing = true; -// to remove / retune to smoth crossings + // to remove / retune to smoth crossings if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; @@ -706,9 +698,10 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); - if (m_running && m_timer != null) + if (m_running) { - m_timer.Interval = 60000; + StopTimer(); + m_skipLoops = 1200; // 60 seconds StartTimer(); } } -- cgit v1.1 From cc1781926b4c49c72977d4ddb16cc583a9ffeb80 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Jan 2013 20:37:58 +0000 Subject: * Adds a satisfying angular roll when an avatar is flying and turning. (General, not physics). Makes flying not feel as stiff. Conflicts: OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 81 ++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a9195f7..3e5f947 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -204,6 +204,11 @@ namespace OpenSim.Region.Framework.Scenes private const int LAND_VELOCITYMAG_MAX = 12; + private const float FLY_ROLL_MAX_RADIANS = 1.1f; + + private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f; + private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f; + private float m_health = 100f; protected ulong crossingFromRegion; @@ -606,6 +611,14 @@ namespace OpenSim.Region.Framework.Scenes } } + // Used for limited viewer 'fake' user rotations. + private Vector3 m_AngularVelocity = Vector3.Zero; + + public Vector3 AngularVelocity + { + get { return m_AngularVelocity; } + } + public bool IsChildAgent { get; set; } public bool IsLoggingIn { get; set; } @@ -736,6 +749,8 @@ namespace OpenSim.Region.Framework.Scenes #endregion + + #region Constructor(s) public ScenePresence( @@ -1225,6 +1240,49 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.StopFlying(this); } + /// + /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. + /// + /// Postive or negative roll amount in radians + private void ApplyFlyingRoll(float amount) + { + float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f); + float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise; + m_AngularVelocity.Z = rollAmount; + } + + /// + /// incrementally sets roll amount to zero + /// + /// Positive roll amount in radians + /// + private float CalculateFlyingRollResetToZero(float amount) + { + const float rollMinRadians = 0f; + + if (m_AngularVelocity.Z > 0) + { + + float leftOverToMin = m_AngularVelocity.Z - rollMinRadians; + if (amount > leftOverToMin) + return -leftOverToMin; + else + return -amount; + + } + else + { + + float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians; + if (amount > leftOverToMin) + return leftOverToMin; + else + return amount; + } + } + + + // neighbouring regions we have enabled a child agent in // holds the seed cap for the child agent in that region private Dictionary m_knownChildRegions = new Dictionary(); @@ -1741,6 +1799,29 @@ namespace OpenSim.Region.Framework.Scenes bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + + + // Applies a satisfying roll effect to the avatar when flying. + if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) + { + ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND); + + } + else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && + ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) + { + ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND); + + } + else + { + if (m_AngularVelocity.Z != 0) + m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND); + + } + + + if (Flying && IsColliding && controlland) { // nesting this check because LengthSquared() is expensive and we don't -- cgit v1.1 From bfe0f5d0819577c854a9f814620635dc0e7db1b2 Mon Sep 17 00:00:00 2001 From: teravus Date: Wed, 30 Jan 2013 07:34:48 -0500 Subject: * This adds a bit more to the previous flying roll effect by adding additional roll when pressing page down, and reducing your roll when pressing page up to make it feel more responsive and give the user more visual feedback. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 60 ++++++++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3e5f947..471caa2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -206,8 +206,8 @@ namespace OpenSim.Region.Framework.Scenes private const float FLY_ROLL_MAX_RADIANS = 1.1f; - private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f; - private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f; + private const float FLY_ROLL_RADIANS_PER_UPDATE = 0.06f; + private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f; private float m_health = 100f; @@ -1244,11 +1244,47 @@ namespace OpenSim.Region.Framework.Scenes /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. /// /// Postive or negative roll amount in radians - private void ApplyFlyingRoll(float amount) + private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown) { - float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f); - float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise; + + float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS); m_AngularVelocity.Z = rollAmount; + + // APPLY EXTRA consideration for flying up and flying down during this time. + // if we're turning left + if (amount > 0) + { + + // If we're at the max roll and pressing up, we want to swing BACK a bit + // Automatically adds noise + if (PressingUp) + { + if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f) + m_AngularVelocity.Z -= 0.9f; + } + // If we're at the max roll and pressing down, we want to swing MORE a bit + if (PressingDown) + { + if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f) + m_AngularVelocity.Z += 0.6f; + } + } + else // we're turning right. + { + // If we're at the max roll and pressing up, we want to swing BACK a bit + // Automatically adds noise + if (PressingUp) + { + if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS)) + m_AngularVelocity.Z += 0.6f; + } + // If we're at the max roll and pressing down, we want to swing MORE a bit + if (PressingDown) + { + if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f) + m_AngularVelocity.Z -= 0.6f; + } + } } /// @@ -1800,26 +1836,30 @@ namespace OpenSim.Region.Framework.Scenes ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - + //m_log.Debug("[CONTROL]: " +flags); // Applies a satisfying roll effect to the avatar when flying. if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) { - ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND); + + ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); + } else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) { - ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND); + ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); + } else { if (m_AngularVelocity.Z != 0) - m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND); + m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); } - + + if (Flying && IsColliding && controlland) -- cgit v1.1 From 598f891d703593bde4b96472b5d1b1ce6aaf4c74 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Feb 2013 04:03:32 +0100 Subject: Move SoubleQueu to Util. Change HTTP inv to prioritize COF. Determine COF for SP --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 2 files changed, 9 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c7a38f7..e58aadc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2970,6 +2970,13 @@ namespace OpenSim.Region.Framework.Scenes SubscribeToClientEvents(client); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); + InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); + if (cof == null) + sp.COF = UUID.Zero; + else + sp.COF = cof.ID; + + m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); m_eventManager.TriggerOnNewPresence(sp); sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 471caa2..91f9c0b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -443,6 +443,8 @@ namespace OpenSim.Region.Framework.Scenes get { return (IClientCore)ControllingClient; } } + public UUID COF { get; set; } + // public Vector3 ParentPosition { get; set; } /// -- cgit v1.1 From 6aa876a83b08390ab057eb012fd2c730010f79d8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 03:40:48 +0000 Subject: Rename Bounciness to Restitution --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 05b69c1..415a82b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1736,7 +1736,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public float Bounciness + public float Restitution { get { return m_bounce; } set @@ -4494,8 +4494,8 @@ namespace OpenSim.Region.Framework.Scenes GravityModifier = physdata.GravitationModifier; if(Friction != physdata.Friction) Friction = physdata.Friction; - if(Bounciness != physdata.Bounce) - Bounciness = physdata.Bounce; + if(Restitution != physdata.Bounce) + Restitution = physdata.Bounce; } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 5c37c07..ce4fb40 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -634,7 +634,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) { - obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty); + obj.Restitution = reader.ReadElementContentAsFloat("Bounce", String.Empty); } private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) @@ -1377,8 +1377,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Density", sop.Density.ToString().ToLower()); if (sop.Friction != 0.6f) writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); - if (sop.Bounciness != 0.5f) - writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); + if (sop.Restitution != 0.5f) + writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); if (sop.GravityModifier != 1.0f) writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); -- cgit v1.1 From bbda7b94b3fe2350d5413879388cfce7309ca907 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 03:40:48 +0000 Subject: Rename Bounciness to Restitution --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8528edc..0d2da03 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1729,7 +1729,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public float Bounciness + public float Restitution { get { return m_bounce; } set @@ -4493,8 +4493,8 @@ namespace OpenSim.Region.Framework.Scenes GravityModifier = physdata.GravitationModifier; if(Friction != physdata.Friction) Friction = physdata.Friction; - if(Bounciness != physdata.Bounce) - Bounciness = physdata.Bounce; + if(Restitution != physdata.Bounce) + Restitution = physdata.Bounce; } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 123c158..2984782 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -633,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) { - obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty); + obj.Restitution = reader.ReadElementContentAsFloat("Bounce", String.Empty); } private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) @@ -1363,8 +1363,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Density", sop.Density.ToString().ToLower()); if (sop.Friction != 0.6f) writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); - if (sop.Bounciness != 0.5f) - writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); + if (sop.Restitution != 0.5f) + writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); if (sop.GravityModifier != 1.0f) writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); -- cgit v1.1 From 8008938550f5f60b3233a09ca642ea6a45052704 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 23:34:47 +0000 Subject: Actually plumb the new values to physics. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0d2da03..20a6626 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1689,6 +1689,10 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup != null) ParentGroup.HasGroupChanged = true; + + PhysicsActor pa = PhysActor; + if (pa != null) + pa.Density = Density; } } @@ -1708,6 +1712,9 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup != null) ParentGroup.HasGroupChanged = true; + PhysicsActor pa = PhysActor; + if (pa != null) + pa.GravModifier = GravityModifier; } } @@ -1726,6 +1733,10 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup != null) ParentGroup.HasGroupChanged = true; + + PhysicsActor pa = PhysActor; + if (pa != null) + pa.Friction = Friction; } } @@ -1744,6 +1755,10 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup != null) ParentGroup.HasGroupChanged = true; + + PhysicsActor pa = PhysActor; + if (pa != null) + pa.Restitution = Restitution; } } @@ -4657,6 +4672,11 @@ namespace OpenSim.Region.Framework.Scenes pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info pa.SetMaterial(Material); + pa.Density = Density; + pa.GravModifier = GravityModifier; + pa.Friction = Friction; + pa.Restitution = Restitution; + if (VolumeDetectActive) // change if not the default only pa.SetVolumeDetect(1); -- cgit v1.1 From e31bc8dc963ff9bc09f0c2dbd68b8a43fee851d6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 11 Feb 2013 23:07:04 +0100 Subject: Refactor KeyframeMotion to use one timer class per scene --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 95 ++++++++++++++++++----- 1 file changed, 75 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 5a1fd13..6dc6504 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -22,25 +22,36 @@ using log4net; namespace OpenSim.Region.Framework.Scenes { - public static class KeyframeTimer + public class KeyframeTimer { - private static Timer m_timer; - private static Dictionary m_motions = new Dictionary(); - private static object m_lockObject = new object(); - private static object m_timerLock = new object(); - public const double timerInterval = 50.0; + private static Dictionarym_timers = + new Dictionary(); - static KeyframeTimer() + private Timer m_timer; + private Dictionary m_motions = new Dictionary(); + private object m_lockObject = new object(); + private object m_timerLock = new object(); + private const double m_tickDuration = 50.0; + private Scene m_scene; + + public double TickDuration + { + get { return m_tickDuration; } + } + + public KeyframeTimer(Scene scene) { m_timer = new Timer(); - m_timer.Interval = timerInterval; + m_timer.Interval = TickDuration; m_timer.AutoReset = true; m_timer.Elapsed += OnTimer; + m_scene = scene; + m_timer.Start(); } - private static void OnTimer(object sender, ElapsedEventArgs ea) + private void OnTimer(object sender, ElapsedEventArgs ea) { if (!Monitor.TryEnter(m_timerLock)) return; @@ -58,7 +69,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - m.OnTimer(); + m.OnTimer(TickDuration); } catch (Exception inner) { @@ -78,17 +89,44 @@ namespace OpenSim.Region.Framework.Scenes public static void Add(KeyframeMotion motion) { - lock (m_lockObject) + KeyframeTimer timer; + + if (motion.Scene == null) + return; + + lock (m_timers) { - m_motions[motion] = null; + if (!m_timers.TryGetValue(motion.Scene, out timer)) + { + timer = new KeyframeTimer(motion.Scene); + m_timers[motion.Scene] = timer; + } + } + + lock (timer.m_lockObject) + { + timer.m_motions[motion] = null; } } public static void Remove(KeyframeMotion motion) { - lock (m_lockObject) + KeyframeTimer timer; + + if (motion.Scene == null) + return; + + lock (m_timers) { - m_motions.Remove(motion); + if (!m_timers.TryGetValue(motion.Scene, out timer)) + { + return; + } + } + + lock (timer.m_lockObject) + { + timer.m_motions.Remove(motion); } } } @@ -156,6 +194,7 @@ namespace OpenSim.Region.Framework.Scenes private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; private bool m_running = false; + [NonSerialized()] private bool m_selected = false; @@ -163,6 +202,14 @@ namespace OpenSim.Region.Framework.Scenes private int m_skipLoops = 0; + [NonSerialized()] + private Scene m_scene; + + public Scene Scene + { + get { return m_scene; } + } + public DataFormat Data { get { return m_data; } @@ -221,8 +268,12 @@ namespace OpenSim.Region.Framework.Scenes newMotion.m_group = grp; - if (grp != null && grp.IsSelected) - newMotion.m_selected = true; + if (grp != null) + { + newMotion.m_scene = grp.Scene; + if (grp.IsSelected) + newMotion.m_selected = true; + } newMotion.m_timerStopped = false; newMotion.m_isCrossing = false; @@ -246,6 +297,8 @@ namespace OpenSim.Region.Framework.Scenes return; m_group = grp; + m_scene = grp.Scene; + Vector3 grppos = grp.AbsolutePosition; Vector3 offset = grppos - m_serializedPosition; // avoid doing it more than once @@ -278,6 +331,7 @@ namespace OpenSim.Region.Framework.Scenes { m_basePosition = grp.AbsolutePosition; m_baseRotation = grp.GroupRotation; + m_scene = grp.Scene; } m_timerStopped = true; @@ -297,6 +351,7 @@ namespace OpenSim.Region.Framework.Scenes KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data); newmotion.m_group = newgrp; + newmotion.m_scene = newgrp.Scene; if (m_keyframes != null) { @@ -482,7 +537,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void OnTimer() + public void OnTimer(double tickDuration) { if (m_skipLoops > 0) { @@ -546,16 +601,16 @@ namespace OpenSim.Region.Framework.Scenes } m_currentFrame = m_frames[0]; - m_currentFrame.TimeMS += (int)KeyframeTimer.timerInterval; + m_currentFrame.TimeMS += (int)tickDuration; //force a update on a keyframe transition update = true; } - m_currentFrame.TimeMS -= (int)KeyframeTimer.timerInterval; + m_currentFrame.TimeMS -= (int)tickDuration; // Do the frame processing - double steps = (double)m_currentFrame.TimeMS / KeyframeTimer.timerInterval; + double steps = (double)m_currentFrame.TimeMS / tickDuration; if (steps <= 0.0) { -- cgit v1.1 From e85a6237bfc0f00de4a183e29e515fa5baf1aa7f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 11 Feb 2013 23:49:05 +0100 Subject: Make keyframes use the sim's frame timer --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 6dc6504..75b16dc 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -27,12 +27,11 @@ namespace OpenSim.Region.Framework.Scenes private static Dictionarym_timers = new Dictionary(); - private Timer m_timer; private Dictionary m_motions = new Dictionary(); private object m_lockObject = new object(); - private object m_timerLock = new object(); private const double m_tickDuration = 50.0; private Scene m_scene; + private int m_prevTick; public double TickDuration { @@ -41,20 +40,18 @@ namespace OpenSim.Region.Framework.Scenes public KeyframeTimer(Scene scene) { - m_timer = new Timer(); - m_timer.Interval = TickDuration; - m_timer.AutoReset = true; - m_timer.Elapsed += OnTimer; + m_prevTick = Util.EnvironmentTickCount(); m_scene = scene; - m_timer.Start(); + m_scene.EventManager.OnFrame += OnTimer; } - private void OnTimer(object sender, ElapsedEventArgs ea) + private void OnTimer() { - if (!Monitor.TryEnter(m_timerLock)) - return; + int thisTick = Util.EnvironmentTickCount(); + int tickdiff = Util.EnvironmentTickCountSubtract(thisTick, m_prevTick); + m_prevTick = thisTick; try { @@ -69,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - m.OnTimer(TickDuration); + m.OnTimer(tickdiff); } catch (Exception inner) { @@ -81,10 +78,6 @@ namespace OpenSim.Region.Framework.Scenes { // Keep running no matter what } - finally - { - Monitor.Exit(m_timerLock); - } } public static void Add(KeyframeMotion motion) -- cgit v1.1 From 04235e58e87ae42617111cad2884e42785914d4e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 12 Feb 2013 01:02:16 +0100 Subject: Push updates from keyframe directly to the front of the output queue rather than through the update system. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 12 ++++++------ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 75b16dc..722c031 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -417,7 +417,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); + m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); // m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -429,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); + m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); // m_group.RootPart.ScheduleTerseUpdate(); } @@ -551,7 +551,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); + m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); } return; @@ -695,7 +695,7 @@ namespace OpenSim.Region.Framework.Scenes if (update) { - m_group.SendGroupRootTerseUpdate(); + m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); } } @@ -731,7 +731,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); + m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); // m_group.RootPart.ScheduleTerseUpdate(); } } @@ -743,7 +743,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); + m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); // m_group.RootPart.ScheduleTerseUpdate(); if (m_running) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ed1bbd8..910f42e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2638,10 +2638,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendGroupRootTerseUpdate() { + SendGroupRootTerseUpdate(0); + } + + public void SendGroupRootTerseUpdate(PrimUpdateFlags flags) + { if (IsDeleted) return; - RootPart.SendTerseUpdateToAllClients(); + RootPart.SendTerseUpdateToAllClients(flags); } public void QueueForUpdateCheck() diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 20a6626..7e94eda 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3315,6 +3315,11 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { + SendTerseUpdateToAllClients(0); + } + + public void SendTerseUpdateToAllClients(PrimUpdateFlags flags) + { if (ParentGroup == null || ParentGroup.Scene == null) return; @@ -3328,7 +3333,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { - SendTerseUpdateToClient(client); + SendTerseUpdateToClient(client, flags); }); } @@ -5133,6 +5138,11 @@ namespace OpenSim.Region.Framework.Scenes public void SendTerseUpdateToClient(IClientAPI remoteClient) { + SendTerseUpdateToClient(remoteClient, 0); + } + + public void SendTerseUpdateToClient(IClientAPI remoteClient, PrimUpdateFlags flags) + { if (ParentGroup.IsDeleted) return; @@ -5146,7 +5156,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient.SendEntityUpdate( this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity | flags); ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); } -- cgit v1.1 From 14c064c65da3d9cce045664f83daaeb7a79edcdd Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 12 Feb 2013 03:15:40 +0100 Subject: Revert "Push updates from keyframe directly to the front of the output queue rather" This reverts commit 04235e58e87ae42617111cad2884e42785914d4e. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 12 ++++++------ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 +------ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 ++------------ 3 files changed, 9 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 722c031..75b16dc 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -417,7 +417,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); + m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -429,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); + m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); } @@ -551,7 +551,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); + m_group.SendGroupRootTerseUpdate(); } return; @@ -695,7 +695,7 @@ namespace OpenSim.Region.Framework.Scenes if (update) { - m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); + m_group.SendGroupRootTerseUpdate(); } } @@ -731,7 +731,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); + m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); } } @@ -743,7 +743,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(PrimUpdateFlags.Immediate); + m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); if (m_running) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 910f42e..ed1bbd8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2638,15 +2638,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendGroupRootTerseUpdate() { - SendGroupRootTerseUpdate(0); - } - - public void SendGroupRootTerseUpdate(PrimUpdateFlags flags) - { if (IsDeleted) return; - RootPart.SendTerseUpdateToAllClients(flags); + RootPart.SendTerseUpdateToAllClients(); } public void QueueForUpdateCheck() diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7e94eda..20a6626 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3315,11 +3315,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { - SendTerseUpdateToAllClients(0); - } - - public void SendTerseUpdateToAllClients(PrimUpdateFlags flags) - { if (ParentGroup == null || ParentGroup.Scene == null) return; @@ -3333,7 +3328,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { - SendTerseUpdateToClient(client, flags); + SendTerseUpdateToClient(client); }); } @@ -5138,11 +5133,6 @@ namespace OpenSim.Region.Framework.Scenes public void SendTerseUpdateToClient(IClientAPI remoteClient) { - SendTerseUpdateToClient(remoteClient, 0); - } - - public void SendTerseUpdateToClient(IClientAPI remoteClient, PrimUpdateFlags flags) - { if (ParentGroup.IsDeleted) return; @@ -5156,7 +5146,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient.SendEntityUpdate( this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity | flags); + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); } -- cgit v1.1 From d5b401a478d9756bd5ce0185896262f6985d2ade Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 12 Feb 2013 22:20:16 +0100 Subject: Revert "Make keyframes use the sim's frame timer" This reverts commit e85a6237bfc0f00de4a183e29e515fa5baf1aa7f. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 75b16dc..6dc6504 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -27,11 +27,12 @@ namespace OpenSim.Region.Framework.Scenes private static Dictionarym_timers = new Dictionary(); + private Timer m_timer; private Dictionary m_motions = new Dictionary(); private object m_lockObject = new object(); + private object m_timerLock = new object(); private const double m_tickDuration = 50.0; private Scene m_scene; - private int m_prevTick; public double TickDuration { @@ -40,18 +41,20 @@ namespace OpenSim.Region.Framework.Scenes public KeyframeTimer(Scene scene) { - m_prevTick = Util.EnvironmentTickCount(); + m_timer = new Timer(); + m_timer.Interval = TickDuration; + m_timer.AutoReset = true; + m_timer.Elapsed += OnTimer; m_scene = scene; - m_scene.EventManager.OnFrame += OnTimer; + m_timer.Start(); } - private void OnTimer() + private void OnTimer(object sender, ElapsedEventArgs ea) { - int thisTick = Util.EnvironmentTickCount(); - int tickdiff = Util.EnvironmentTickCountSubtract(thisTick, m_prevTick); - m_prevTick = thisTick; + if (!Monitor.TryEnter(m_timerLock)) + return; try { @@ -66,7 +69,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - m.OnTimer(tickdiff); + m.OnTimer(TickDuration); } catch (Exception inner) { @@ -78,6 +81,10 @@ namespace OpenSim.Region.Framework.Scenes { // Keep running no matter what } + finally + { + Monitor.Exit(m_timerLock); + } } public static void Add(KeyframeMotion motion) -- cgit v1.1 From 8c0b9080a4fb013d559966fc8c8175fb16162c2d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 18 Feb 2013 21:09:14 +0100 Subject: Fix an issue where the viewer would request the seed cap before there was a handler for it. --- OpenSim/Region/Framework/Scenes/Scene.cs | 50 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e58aadc..7fcbed4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3622,7 +3622,7 @@ namespace OpenSim.Region.Framework.Scenes // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI if (closeChildAgents && CapsModule != null) - CapsModule.RemoveCaps(agentID); + CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); // // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever // // this method is doing is HORRIBLE!!! @@ -3853,20 +3853,36 @@ namespace OpenSim.Region.Framework.Scenes return false; } - ScenePresence sp = GetScenePresence(agent.AgentID); - if (sp != null && !sp.IsChildAgent) + // If we have noo presence here or if that presence is a zombie root + // presence that will be kicled, we need a new CAPS object. + if (sp == null || (sp != null && !sp.IsChildAgent)) { - // We have a zombie from a crashed session. - // Or the same user is trying to be root twice here, won't work. - // Kill it. - m_log.WarnFormat( - "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", - sp.Name, sp.UUID, RegionInfo.RegionName); + if (CapsModule != null) + { + lock (agent) + { + CapsModule.SetAgentCapsSeeds(agent); + CapsModule.CreateCaps(agent.AgentID, agent.circuitcode); + } + } + } + + if (sp != null) + { + if (!sp.IsChildAgent) + { + // We have a zombie from a crashed session. + // Or the same user is trying to be root twice here, won't work. + // Kill it. + m_log.WarnFormat( + "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", + sp.Name, sp.UUID, RegionInfo.RegionName); - sp.ControllingClient.Close(true, true); - sp = null; + sp.ControllingClient.Close(true, true); + sp = null; + } } lock (agent) @@ -3907,7 +3923,9 @@ namespace OpenSim.Region.Framework.Scenes if (vialogin || (!m_seeIntoBannedRegion)) { if (!AuthorizeUser(agent, out reason)) + { return false; + } } } catch (Exception e) @@ -3922,11 +3940,6 @@ namespace OpenSim.Region.Framework.Scenes RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode); - if (CapsModule != null) - { - CapsModule.SetAgentCapsSeeds(agent); - CapsModule.CreateCaps(agent.AgentID); - } } else { @@ -3952,6 +3965,11 @@ namespace OpenSim.Region.Framework.Scenes agent.teleportFlags = teleportFlags; m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); + if (CapsModule != null) + { + CapsModule.ActivateCaps(agent.circuitcode); + } + if (vialogin) { // CleanDroppedAttachments(); -- cgit v1.1 From 34bb2fd015178dd97efb0f6c83f61a079781dcae Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 3 Mar 2013 12:48:36 +0100 Subject: Make Keyframe motion cross regions again --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 6dc6504..b102e48 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -276,6 +276,7 @@ namespace OpenSim.Region.Framework.Scenes } newMotion.m_timerStopped = false; + newMotion.m_running = true; newMotion.m_isCrossing = false; newMotion.m_waitingCrossing = false; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7fcbed4..05d5ccd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2769,8 +2769,6 @@ namespace OpenSim.Region.Framework.Scenes if (newPosition != Vector3.Zero) newObject.RootPart.GroupPosition = newPosition; - if (newObject.RootPart.KeyframeMotion != null) - newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); if (!AddSceneObject(newObject)) { @@ -2798,6 +2796,9 @@ namespace OpenSim.Region.Framework.Scenes // before we restart the scripts, or else some functions won't work. newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); newObject.ResumeScripts(); + + if (newObject.RootPart.KeyframeMotion != null) + newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); } // Do this as late as possible so that listeners have full access to the incoming object -- cgit v1.1 From 797bfbfcfaf5485db755ad6a5b19a064210505fd Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 5 Mar 2013 12:02:22 +0100 Subject: Multiattach, part 1 --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 05d5ccd..2e64819 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2866,7 +2866,7 @@ namespace OpenSim.Region.Framework.Scenes RootPrim.RemFlag(PrimFlags.TemporaryOnRez); if (AttachmentsModule != null) - AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); + AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); } else { -- cgit v1.1 From f954c53ddb009009e386a4046857cc20d0fd656c Mon Sep 17 00:00:00 2001 From: teravus Date: Wed, 6 Mar 2013 17:02:53 -0500 Subject: * Separate two if trees that got merged into one if tree with borked logic. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7cab841..e22cf47 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4574,7 +4574,8 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup.RootPart == this) AngularVelocity = new Vector3(0, 0, 0); } - else if (SetVD != wasVD) + + else { if (ParentGroup.Scene.CollidablePrims) { @@ -4620,9 +4621,31 @@ namespace OpenSim.Region.Framework.Scenes UpdatePhysicsSubscribedEvents(); } } - + if (SetVD) + { + // If the above logic worked (this is urgent candidate to unit tests!) + // we now have a physicsactor. + // Defensive programming calls for a check here. + // Better would be throwing an exception that could be catched by a unit test as the internal + // logic should make sure, this Physactor is always here. + if (pa != null) + { + pa.SetVolumeDetect(1); + AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active + VolumeDetectActive = true; + } // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); + } + else if (SetVD != wasVD) + { + // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like + // (mumbles, well, at least if you have infinte CPU powers :-)) + if (pa != null) + pa.SetVolumeDetect(0); + RemFlag(PrimFlags.Phantom); + VolumeDetectActive = false; + } // and last in case we have a new actor and not building if (ParentGroup != null) -- cgit v1.1 From 455da9dd20dc6a992c7adc1a8fd851ab586392a1 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 16 Mar 2013 11:09:49 -0400 Subject: * Ignores VolumeDetect enabled prim in the camera raycast call. Note: The SceneRaycast call doesn't have a filter option in the interface and physics will use the lower level one for all sorts of goodies so it wouldn't be appropriate to ignore it at the physics layer yet.. though that would be better once the API has filters. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 47 ++++++++++++++++++------ 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 91f9c0b..230cb23 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1526,17 +1526,42 @@ namespace OpenSim.Region.Framework.Scenes m_doingCamRayCast = false; if (hitYN && localid != LocalId) { - CameraConstraintActive = true; - pNormal.X = (float)Math.Round(pNormal.X, 2); - pNormal.Y = (float)Math.Round(pNormal.Y, 2); - pNormal.Z = (float)Math.Round(pNormal.Z, 2); - pNormal.Normalize(); - collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); - collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); - collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); - - Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); - UpdateCameraCollisionPlane(plane); + SceneObjectGroup group = m_scene.GetGroupByPrim(localid); + bool IsPrim = group != null; + if (IsPrim) + { + SceneObjectPart part = group.GetPart(localid); + if (part != null && !part.VolumeDetectActive) + { + CameraConstraintActive = true; + pNormal.X = (float) Math.Round(pNormal.X, 2); + pNormal.Y = (float) Math.Round(pNormal.Y, 2); + pNormal.Z = (float) Math.Round(pNormal.Z, 2); + pNormal.Normalize(); + collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); + collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); + collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); + + Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, + Vector3.Dot(collisionPoint, pNormal)); + UpdateCameraCollisionPlane(plane); + } + } + else + { + CameraConstraintActive = true; + pNormal.X = (float) Math.Round(pNormal.X, 2); + pNormal.Y = (float) Math.Round(pNormal.Y, 2); + pNormal.Z = (float) Math.Round(pNormal.Z, 2); + pNormal.Normalize(); + collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); + collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); + collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); + + Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, + Vector3.Dot(collisionPoint, pNormal)); + UpdateCameraCollisionPlane(plane); + } } else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) -- cgit v1.1 From cc504eb0d136d6555ddae990a98592eaf123816a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 21 Mar 2013 01:44:09 +0100 Subject: Fix SceneManager to use the new automatic property throughout. --- OpenSim/Region/Framework/Scenes/SceneManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index c307f7a..c70342f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -100,7 +100,6 @@ namespace OpenSim.Region.Framework.Scenes } private readonly DoubleDictionary m_localScenes = new DoubleDictionary(); - private Scene m_currentScene = null; public List Scenes { @@ -354,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_localScenes.TryGetValue(regionName, out s)) { - m_currentScene = s; + CurrentScene = s; return true; } @@ -370,7 +369,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_localScenes.TryGetValue(regionID, out s)) { - m_currentScene = s; + CurrentScene = s; return true; } -- cgit v1.1 From c341664c1b8ccf3bd7b81795b900b971a15ff318 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 24 Mar 2013 18:56:28 +0100 Subject: Phase 1 of implementing a transfer permission. Overwrite libOMV's PermissionMask with our own and add export permissions as well as a new definition for "All" as meaning "all conventional permissions" rather than "all possible permissions" --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 ++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a9e1fc2..6a3fb24 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -39,6 +39,7 @@ using OpenSim.Region.Framework; using OpenSim.Framework.Client; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Serialization; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.Framework.Scenes { @@ -907,7 +908,7 @@ namespace OpenSim.Region.Framework.Scenes { CreateNewInventoryItem( remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, - (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate, transationID); + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID); } @@ -1036,8 +1037,8 @@ namespace OpenSim.Region.Framework.Scenes CreateNewInventoryItem( remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, description, 0, callbackID, asset, invType, - (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, - (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch()); } else { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6b031ae..357a94b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -51,6 +51,7 @@ using OpenSim.Region.Physics.Manager; using Timer=System.Timers.Timer; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.Framework.Scenes { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 26524fb..f8624e7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -34,6 +34,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using System.Collections.Generic; using System.Xml; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.Framework.Scenes { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0f5d116..b109b4f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -41,6 +41,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Framework.Scenes.Serialization; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.Framework.Scenes { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ffde415..9265805 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -43,6 +43,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Physics.Manager; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.Framework.Scenes { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3a9a146..d04d87b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -38,6 +38,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.Framework.Scenes.Serialization; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.Framework.Scenes { -- cgit v1.1 From 4bf9c4bbb833f8ecbd0757b333da76ffaea14bc7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 31 Mar 2013 20:25:32 +0200 Subject: Export permission, part two. Setting export perms for textures and clothing works. Setting perms for prims also works but they don't propagate correctly yet. NOT FOR PRODUCTIN USE. Your database will need to be updated before you can use this! --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 46 ++++++++++++++++++++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 29 ++++++++++---- 3 files changed, 66 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 6a3fb24..d2e41f8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -413,18 +413,57 @@ namespace OpenSim.Region.Framework.Scenes if (itemUpd.NextPermissions != 0) // Use this to determine validity. Can never be 0 if valid { + // Create a set of base permissions that will not include export if the user + // is not allowed to change the export flag. + bool denyExportChange = false; + + m_log.InfoFormat("[XXX]: B: {0} O: {1} E: {2}", itemUpd.BasePermissions, itemUpd.CurrentPermissions, itemUpd.EveryOnePermissions); + + // If the user is not the creator or doesn't have "E" in both "B" and "O", deny setting export + if ((item.BasePermissions & (uint)(PermissionMask.All | PermissionMask.Export)) != (uint)(PermissionMask.All | PermissionMask.Export) || (item.CurrentPermissions & (uint)PermissionMask.Export) == 0 || item.CreatorIdAsUuid != item.Owner) + denyExportChange = true; + + m_log.InfoFormat("[XXX]: Deny Export Update {0}", denyExportChange); + + // If it is already set, force it set and also force full perm + // else prevent setting it. It can and should never be set unless + // set in base, so the condition above is valid + if (denyExportChange) + { + // If we are not allowed to change it, then force it to the + // original item's setting and if it was on, also force full perm + if ((item.EveryOnePermissions & (uint)PermissionMask.Export) != 0) + { + itemUpd.NextPermissions = (uint)(PermissionMask.All); + itemUpd.EveryOnePermissions |= (uint)PermissionMask.Export; + } + else + { + itemUpd.EveryOnePermissions &= ~(uint)PermissionMask.Export; + } + } + else + { + // If the new state is exportable, force full perm + if ((itemUpd.EveryOnePermissions & (uint)PermissionMask.Export) != 0) + { + m_log.InfoFormat("[XXX]: Force full perm"); + itemUpd.NextPermissions = (uint)(PermissionMask.All); + } + } + if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; + if (item.EveryOnePermissions != (itemUpd.EveryOnePermissions & item.BasePermissions)) item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions; + if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions)) item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; - -// m_log.DebugFormat("[USER INVENTORY]: item.Flags {0}", item.Flags); - item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions; + item.GroupID = itemUpd.GroupID; item.GroupOwned = itemUpd.GroupOwned; item.CreationDate = itemUpd.CreationDate; @@ -446,6 +485,7 @@ namespace OpenSim.Region.Framework.Scenes item.SaleType = itemUpd.SaleType; InventoryService.UpdateItem(item); + remoteClient.SendBulkUpdateInventory(item); } if (UUID.Zero != transactionID) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b109b4f..69fb6df 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3468,7 +3468,7 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustChildPrimPermissions() { - uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits + uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff8; // Mask folded bits uint foldedPerms = RootPart.OwnerMask & 3; ForEachPart(part => diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9265805..c2f0792 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -470,8 +470,8 @@ namespace OpenSim.Region.Framework.Scenes private uint _category; private Int32 _creationDate; private uint _parentID = 0; - private uint _baseMask = (uint)PermissionMask.All; - private uint _ownerMask = (uint)PermissionMask.All; + private uint _baseMask = (uint)(PermissionMask.All | PermissionMask.Export); + private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); private uint _groupMask = (uint)PermissionMask.None; private uint _everyoneMask = (uint)PermissionMask.None; private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); @@ -4319,10 +4319,10 @@ namespace OpenSim.Region.Framework.Scenes public void TrimPermissions() { - BaseMask &= (uint)PermissionMask.All; - OwnerMask &= (uint)PermissionMask.All; + BaseMask &= (uint)(PermissionMask.All | PermissionMask.Export); + OwnerMask &= (uint)(PermissionMask.All | PermissionMask.Export); GroupMask &= (uint)PermissionMask.All; - EveryoneMask &= (uint)PermissionMask.All; + EveryoneMask &= (uint)(PermissionMask.All | PermissionMask.Export); NextOwnerMask &= (uint)PermissionMask.All; } @@ -4425,10 +4425,22 @@ namespace OpenSim.Region.Framework.Scenes baseMask; break; case 8: + // Trying to set export permissions - extra checks + if (set && (mask & (uint)PermissionMask.Export) != 0) + { + if ((OwnerMask & (uint)PermissionMask.Export) == 0 || (BaseMask & (uint)PermissionMask.Export) == 0 || (NextOwnerMask & (uint)PermissionMask.All) != (uint)PermissionMask.All) + mask &= ~(uint)PermissionMask.Export; + } EveryoneMask = ApplyMask(EveryoneMask, set, mask) & baseMask; break; case 16: + // Force full perm if export + if ((EveryoneMask & (uint)PermissionMask.Export) != 0) + { + NextOwnerMask = (uint)PermissionMask.All; + break; + } NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & baseMask; // Prevent the client from creating no copy, no transfer @@ -5225,9 +5237,12 @@ namespace OpenSim.Region.Framework.Scenes public void ApplyNextOwnerPermissions() { - BaseMask &= NextOwnerMask; + // Export needs to be preserved in the base and everyone + // mask, but removed in the owner mask as a next owner + // can never change the export status + BaseMask &= NextOwnerMask | (uint)PermissionMask.Export; OwnerMask &= NextOwnerMask; - EveryoneMask &= NextOwnerMask; + EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export; Inventory.ApplyNextOwnerPermissions(); } -- cgit v1.1 From 8ade6fa617f611fc3b470e279e4a5c50177bd5f0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 11 May 2013 16:15:39 +0200 Subject: Refactor to get closer to core --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 28fce53..584ffea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3380,7 +3380,7 @@ namespace OpenSim.Region.Framework.Scenes { if (EntityTransferModule != null) { - EntityTransferModule.TeleportHome(agentId, client); + return EntityTransferModule.TeleportHome(agentId, client); } else { -- cgit v1.1 From 3f6071ce3a2a8970419186fa7d5715f2af8b53ae Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 11 May 2013 16:16:02 +0200 Subject: Guard against trying to access terrain heights out of bounds. Clamp to sim. --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index c0ca48e..b6e0a97 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -131,7 +131,15 @@ namespace OpenSim.Region.Framework.Scenes public double this[int x, int y] { - get { return map[x, y]; } + get + { + if (x < 0) x = 0; + if (y < 0) y = 0; + if (x >= (int)Constants.RegionSize) x = (int)Constants.RegionSize - 1; + if (y >= (int)Constants.RegionSize) y = (int)Constants.RegionSize - 1; + + return map[x, y]; + } set { // Will "fix" terrain hole problems. Although not fantastically. -- cgit v1.1 From 9ba35c6b7e36a675f8fd3fe1c372ec40a5b0216a Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 24 May 2013 00:45:30 +0200 Subject: Port fix from justicc - decouple pay prices on drag-copied prims --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 42644dc..261e958 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2161,6 +2161,7 @@ namespace OpenSim.Region.Framework.Scenes // safeguard actual copy is done in sog.copy dupe.KeyframeMotion = null; + dupe.PayPrice = (int[])PayPrice.Clone(); dupe.DynAttrs.CopyFrom(DynAttrs); -- cgit v1.1 From a348c8e44a72bd2de0151fc6db7a229cd8ee86a2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 26 May 2013 14:11:48 +0200 Subject: Allow Linden trees to preserve their type when taken into inventory and rezzed again. Allow Linden trees to be sensed by LLSensor as PASSIVE objects. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 69fb6df..0ea4e09 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -272,6 +272,11 @@ namespace OpenSim.Region.Framework.Scenes { AttachmentPoint = 0; + // Don't zap trees + if (RootPart.Shape.PCode == (byte)PCode.Tree || + RootPart.Shape.PCode == (byte)PCode.NewTree) + return; + // Even though we don't use child part state parameters for attachments any more, we still need to set // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if // we store them correctly, scene objects that we receive from elsewhere might not. -- cgit v1.1 From 70d5c29310492e0481b6df91edefdce729573e2e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 31 May 2013 21:55:56 +0200 Subject: Stop sending velocity to avoid snap-back --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index b102e48..d773ee7 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -645,7 +645,7 @@ namespace OpenSim.Region.Framework.Scenes m_nextPosition = m_group.AbsolutePosition + motionThisFrame; m_group.AbsolutePosition = m_nextPosition; - m_group.RootPart.Velocity = v; + //m_group.RootPart.Velocity = v; update = true; } -- cgit v1.1 From e2d4cb870ed4bccb4ee127b079742a67ec1ad752 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 2 Jun 2013 23:53:07 +0200 Subject: Unsit seated avatars when an object is deleted --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 584ffea..2b58795 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2440,6 +2440,14 @@ namespace OpenSim.Region.Framework.Scenes else group.StopScriptInstances(); + List avatars = group.GetSittingAvatars(); + foreach (UUID av in avatars) + { + ScenePresence p = GetScenePresence(av); + if (p != null) + p.StandUp(); + } + SceneObjectPart[] partList = group.Parts; foreach (SceneObjectPart part in partList) -- cgit v1.1 From 18e4496d2dd41acce1b2183c10499ac24a58e573 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 6 Jun 2013 18:57:32 +0100 Subject: keyframe: add more locks, change timming stop, added Suspend and resume --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 79 ++++++++++++++++++----- 1 file changed, 64 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index d773ee7..09481a7 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -245,14 +245,17 @@ namespace OpenSim.Region.Framework.Scenes private void StartTimer() { - KeyframeTimer.Add(this); - m_timerStopped = false; + lock (m_frames) + { + KeyframeTimer.Add(this); + m_timerStopped = false; + } } private void StopTimer() { - m_timerStopped = true; - KeyframeTimer.Remove(this); + lock (m_frames) + m_timerStopped = true; } public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) @@ -407,19 +410,18 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_running = false; StopTimer(); + m_running = false; } } public void Stop() { + StopTimer(); m_running = false; m_isCrossing = false; m_waitingCrossing = false; - StopTimer(); - m_basePosition = m_group.AbsolutePosition; m_baseRotation = m_group.GroupRotation; @@ -432,14 +434,34 @@ namespace OpenSim.Region.Framework.Scenes public void Pause() { - m_running = false; StopTimer(); + m_running = false; m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); + } + public void Suspend() + { + lock (m_frames) + { + if (m_timerStopped) + return; + m_timerStopped = true; + } + } + + public void Resume() + { + lock (m_frames) + { + if (!m_timerStopped) + return; + if (m_running && !m_waitingCrossing) + StartTimer(); + } } private void GetNextList() @@ -529,6 +551,7 @@ namespace OpenSim.Region.Framework.Scenes pos = (Vector3)k.Position; rot = (Quaternion)k.Rotation; + } m_basePosition = pos; @@ -540,14 +563,41 @@ namespace OpenSim.Region.Framework.Scenes public void OnTimer(double tickDuration) { + if (!Monitor.TryEnter(m_frames)) + return; + if (m_timerStopped) + KeyframeTimer.Remove(this); + else + DoOnTimer(tickDuration); + Monitor.Exit(m_frames); + } + + private void Done() + { + KeyframeTimer.Remove(this); + m_timerStopped = true; + m_running = false; + m_isCrossing = false; + m_waitingCrossing = false; + + m_basePosition = m_group.AbsolutePosition; + m_baseRotation = m_group.GroupRotation; + + m_group.RootPart.Velocity = Vector3.Zero; + m_group.RootPart.AngularVelocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); + // m_group.RootPart.ScheduleTerseUpdate(); + m_frames.Clear(); + } + + private void DoOnTimer(double tickDuration) + { if (m_skipLoops > 0) { m_skipLoops--; return; } - if (m_timerStopped) // trap events still in air even after a timer.stop - return; if (m_group == null) return; @@ -587,7 +637,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_frames.Count == 0) { - Stop(); + Done(); Scene scene = m_group.Scene; IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); @@ -686,11 +736,10 @@ namespace OpenSim.Region.Framework.Scenes if (angle > 0.01f) */ - if(Math.Abs(step.X - current.X) > 0.001f - || Math.Abs(step.Y - current.Y) > 0.001f + if (Math.Abs(step.X - current.X) > 0.001f + || Math.Abs(step.Y - current.Y) > 0.001f || Math.Abs(step.Z - current.Z) > 0.001f) - // assuming w is a dependente var - + // assuming w is a dependente var { // m_group.UpdateGroupRotationR(step); m_group.RootPart.RotationOffset = step; -- cgit v1.1 From 689969e143dad47fd9c257f9824ec71e3fafc8e6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 13 Jun 2013 02:50:39 +0100 Subject: * This fixes having to select and deselect prim to get keyframemotion to start running when pulled from data storage. Conflicts: OpenSim/Data/SQLite/SQLiteSimulationData.cs --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0ea4e09..a99261f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1072,6 +1072,11 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; + if (part.KeyframeMotion != null) + { + part.KeyframeMotion.UpdateSceneObject(this); + } + if (Object.ReferenceEquals(part, m_rootPart)) continue; -- cgit v1.1 From 8e9d6c6c56c7169adfa4b99c328933df4b68107b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 Jun 2013 01:14:07 +0200 Subject: Fix prim locking to behave like SL --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a99261f..f306651 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3488,8 +3488,8 @@ namespace OpenSim.Region.Framework.Scenes part.ClonePermissions(RootPart); }); - uint lockMask = ~(uint)PermissionMask.Move; - uint lockBit = RootPart.OwnerMask & (uint)PermissionMask.Move; + uint lockMask = ~(uint)(PermissionMask.Move | PermissionMask.Modify); + uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move | PermissionMask.Modify); RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); RootPart.ScheduleFullUpdate(); } -- cgit v1.1 From 55400ff7be55b1c8dbededca68e6fce42cd6ce0f Mon Sep 17 00:00:00 2001 From: teravus Date: Fri, 23 Aug 2013 00:28:36 -0500 Subject: * This increases accuracy when border crossing (the reason is.. the border crossing code will use velocity to predict where the object should be, so setting it to zero. It still looses about 0.0045 per loop. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index d773ee7..f96b56a 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -644,8 +644,8 @@ namespace OpenSim.Region.Framework.Scenes // m_group.AbsolutePosition += motionThisFrame; m_nextPosition = m_group.AbsolutePosition + motionThisFrame; m_group.AbsolutePosition = m_nextPosition; - - //m_group.RootPart.Velocity = v; + if ((m_group.AbsolutePosition.X < 10 || m_group.AbsolutePosition.Y < 10 || m_group.AbsolutePosition.X > Constants.RegionSize - 10 || m_group.AbsolutePosition.Y > Constants.RegionSize - 10)) + m_group.RootPart.Velocity = v; update = true; } @@ -736,12 +736,12 @@ namespace OpenSim.Region.Framework.Scenes m_waitingCrossing = true; // to remove / retune to smoth crossings - if (m_group.RootPart.Velocity != Vector3.Zero) - { - m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); + //if (m_group.RootPart.Velocity != Vector3.Zero) + //{ + // m_group.RootPart.Velocity = Vector3.Zero; + // m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); - } + //} } public void CrossingFailure() -- cgit v1.1 From 58359788a915afd80d5fb2ff9f069cda6c841c81 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 24 Aug 2013 05:54:08 -0500 Subject: Revert "* This increases accuracy when border crossing (the reason is.. the border crossing code will use velocity to predict where the object should be, so setting it to zero. It still looses about 0.0045 per loop." This reverts commit 55400ff7be55b1c8dbededca68e6fce42cd6ce0f. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index f96b56a..d773ee7 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -644,8 +644,8 @@ namespace OpenSim.Region.Framework.Scenes // m_group.AbsolutePosition += motionThisFrame; m_nextPosition = m_group.AbsolutePosition + motionThisFrame; m_group.AbsolutePosition = m_nextPosition; - if ((m_group.AbsolutePosition.X < 10 || m_group.AbsolutePosition.Y < 10 || m_group.AbsolutePosition.X > Constants.RegionSize - 10 || m_group.AbsolutePosition.Y > Constants.RegionSize - 10)) - m_group.RootPart.Velocity = v; + + //m_group.RootPart.Velocity = v; update = true; } @@ -736,12 +736,12 @@ namespace OpenSim.Region.Framework.Scenes m_waitingCrossing = true; // to remove / retune to smoth crossings - //if (m_group.RootPart.Velocity != Vector3.Zero) - //{ - // m_group.RootPart.Velocity = Vector3.Zero; - // m_group.SendGroupRootTerseUpdate(); + if (m_group.RootPart.Velocity != Vector3.Zero) + { + m_group.RootPart.Velocity = Vector3.Zero; + m_group.SendGroupRootTerseUpdate(); // m_group.RootPart.ScheduleTerseUpdate(); - //} + } } public void CrossingFailure() -- cgit v1.1 From e0399ccaec68889c12e4679b4d62142b49b379df Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 24 Aug 2013 18:55:21 -0500 Subject: * This fixes the border crossing offsets by storing the final keyframe location in the hijacked variable KeyFrame.AngularVelocity. When steps in OnTimer <= 0.0, normalize the final position by Constants.RegionSize and move the object there. The hack here is KeyFrame.AngularVelocity probably isn't the right name for this variable because it's the un-mucked with keyframe position. When you determine the feasibility of changing the name without affecting the serialization of existing objects in world... It's simply a name change to KeyFrame.FinalPosition or something proper. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index d773ee7..d9df95c 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -478,6 +478,7 @@ namespace OpenSim.Region.Framework.Scenes k.Position = pos; // k.Velocity = Vector3.Zero; } + k.AngularVelocity = (Vector3)k.Position; k.StartRotation = rot; if (k.Rotation.HasValue) @@ -612,13 +613,13 @@ namespace OpenSim.Region.Framework.Scenes // Do the frame processing double steps = (double)m_currentFrame.TimeMS / tickDuration; - + if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_nextPosition = (Vector3)m_currentFrame.Position; + m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); m_group.AbsolutePosition = m_nextPosition; // we are sending imediate updates, no doing force a extra terseUpdate @@ -706,7 +707,26 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); } } + private Vector3 NormalizeVector(Vector3? pPosition) + { + if (pPosition == null) + return Vector3.Zero; + + Vector3 tmp = (Vector3) pPosition; + while (tmp.X > Constants.RegionSize) + tmp.X -= Constants.RegionSize; + while (tmp.X < 0) + tmp.X += Constants.RegionSize; + while (tmp.Y > Constants.RegionSize) + tmp.Y -= Constants.RegionSize; + while (tmp.Y < 0) + tmp.Y += Constants.RegionSize; + + return tmp; + + + } public Byte[] Serialize() { StopTimer(); -- cgit v1.1 From f7378829c3da999fcd200a5d0e6189a563cbda39 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 25 Aug 2013 06:26:56 +0200 Subject: Fix the root cause of keyframe motion region crossing offset - UpdateSceneObject was being called twice on each crossing. --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 22 +--------------------- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++-- 2 files changed, 5 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index d9df95c..276b61f 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -478,7 +478,6 @@ namespace OpenSim.Region.Framework.Scenes k.Position = pos; // k.Velocity = Vector3.Zero; } - k.AngularVelocity = (Vector3)k.Position; k.StartRotation = rot; if (k.Rotation.HasValue) @@ -619,7 +618,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); + m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; // we are sending imediate updates, no doing force a extra terseUpdate @@ -707,26 +706,7 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); } } - private Vector3 NormalizeVector(Vector3? pPosition) - { - if (pPosition == null) - return Vector3.Zero; - - Vector3 tmp = (Vector3) pPosition; - - while (tmp.X > Constants.RegionSize) - tmp.X -= Constants.RegionSize; - while (tmp.X < 0) - tmp.X += Constants.RegionSize; - while (tmp.Y > Constants.RegionSize) - tmp.Y -= Constants.RegionSize; - while (tmp.Y < 0) - tmp.Y += Constants.RegionSize; - return tmp; - - - } public Byte[] Serialize() { StopTimer(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2b58795..b189599 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2802,8 +2802,10 @@ namespace OpenSim.Region.Framework.Scenes newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); newObject.ResumeScripts(); - if (newObject.RootPart.KeyframeMotion != null) - newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); + // AddSceneObject already does this and doing it again messes + // up region crossings, so don't. + //if (newObject.RootPart.KeyframeMotion != null) + // newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); } // Do this as late as possible so that listeners have full access to the incoming object -- cgit v1.1 From b41ae0f98f85db76b9a412cee29e9bcba5b4d9d9 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 8 Sep 2013 17:54:00 +0200 Subject: Harmonize the class name, ID and Name of the default perms module --- OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | 4 ++-- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 52ad538..9557cd0 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Startup"); config.Set("serverside_object_permissions", true); - SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() }); + SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() }); IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. @@ -112,7 +112,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Startup"); config.Set("serverside_object_permissions", true); - SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() }); + SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() }); IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. @@ -195,4 +195,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests // Assert.That(retrievedPart, Is.Null); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index c7eaff9..e7a1fe0 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs @@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests SceneHelpers.SetupSceneModules( scene, configSource, new object[] - { new PermissionsModule(), + { new DefaultPermissionsModule(), new GroupsModule(), new MockGroupsServicesConnector() }); @@ -82,4 +82,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests groupsModule.CreateGroup(client, "group1", "To boldly go", true, UUID.Zero, 5, true, true, true); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index de4458d..8d94d29 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -216,7 +216,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests // We need to set up the permisions module on scene B so that our later use of agent limit to deny // QueryAccess won't succeed anyway because administrators are always allowed in and the default // IsAdministrator if no permissions module is present is true. - SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); + SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB }); // Shared scene modules SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); @@ -381,7 +381,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests // We need to set up the permisions module on scene B so that our later use of agent limit to deny // QueryAccess won't succeed anyway because administrators are always allowed in and the default // IsAdministrator if no permissions module is present is true. - SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); + SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB }); // Shared scene modules SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); @@ -507,4 +507,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests // TestHelpers.DisableLogging(); } } -} \ No newline at end of file +} -- cgit v1.1 From ddf67bf929fbc32d8319f777b248642b4da0305a Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Sep 2013 19:41:51 +0200 Subject: Mono 2.0 fix - call ToArray() explicitly --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f306651..3e1dcaa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -591,6 +591,7 @@ namespace OpenSim.Region.Framework.Scenes avinfo.ParentID = av.ParentID; avsToCross.Add(avinfo); + av.PrevSitOffset = av.OffsetPosition; av.ParentID = 0; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0ab267a..7004d23 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -242,7 +242,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_movementAnimationUpdateCounter = 0; - private Vector3 m_prevSitOffset; + public Vector3 PrevSitOffset { get; set; } protected AvatarAppearance m_appearance; @@ -957,7 +957,7 @@ namespace OpenSim.Region.Framework.Scenes // ParentPosition = part.GetWorldPosition(); ParentID = part.LocalId; ParentPart = part; - m_pos = m_prevSitOffset; + m_pos = PrevSitOffset; // pos = ParentPosition; pos = part.GetWorldPosition(); } @@ -2261,6 +2261,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0) { + PrevSitOffset = m_pos; // Save sit offset SceneObjectPart part = ParentPart; UnRegisterSeatControls(part.ParentGroup.UUID); @@ -3487,7 +3488,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.Appearance = new AvatarAppearance(Appearance); cAgent.ParentPart = ParentUUID; - cAgent.SitOffset = m_pos; + cAgent.SitOffset = PrevSitOffset; lock (scriptedcontrols) { @@ -3530,7 +3531,7 @@ namespace OpenSim.Region.Framework.Scenes CameraLeftAxis = cAgent.LeftAxis; CameraUpAxis = cAgent.UpAxis; ParentUUID = cAgent.ParentPart; - m_prevSitOffset = cAgent.SitOffset; + PrevSitOffset = cAgent.SitOffset; // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the -- cgit v1.1 From 120b6948ed873a3af7713b411b956b8cb4c7f516 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 24 Aug 2013 18:55:21 -0500 Subject: * This fixes the border crossing offsets by storing the final keyframe location in the hijacked variable KeyFrame.AngularVelocity. When steps in OnTimer <= 0.0, normalize the final position by Constants.RegionSize and move the object there. The hack here is KeyFrame.AngularVelocity probably isn't the right name for this variable because it's the un-mucked with keyframe position. When you determine the feasibility of changing the name without affecting the serialization of existing objects in world... It's simply a name change to KeyFrame.FinalPosition or something proper. (cherry picked from commit e0399ccaec68889c12e4679b4d62142b49b379df) --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 29652aa..4d153da 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -498,6 +498,7 @@ namespace OpenSim.Region.Framework.Scenes k.Position = pos; // k.Velocity = Vector3.Zero; } + k.AngularVelocity = (Vector3)k.Position; k.StartRotation = rot; if (k.Rotation.HasValue) @@ -632,13 +633,13 @@ namespace OpenSim.Region.Framework.Scenes // Do the frame processing double steps = (double)m_currentFrame.TimeMS / tickDuration; - + if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_nextPosition = (Vector3)m_currentFrame.Position; + m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); m_group.AbsolutePosition = m_nextPosition; // we are sending imediate updates, no doing force a extra terseUpdate @@ -726,7 +727,26 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); } } + private Vector3 NormalizeVector(Vector3? pPosition) + { + if (pPosition == null) + return Vector3.Zero; + + Vector3 tmp = (Vector3) pPosition; + while (tmp.X > Constants.RegionSize) + tmp.X -= Constants.RegionSize; + while (tmp.X < 0) + tmp.X += Constants.RegionSize; + while (tmp.Y > Constants.RegionSize) + tmp.Y -= Constants.RegionSize; + while (tmp.Y < 0) + tmp.Y += Constants.RegionSize; + + return tmp; + + + } public Byte[] Serialize() { StopTimer(); -- cgit v1.1 From ece2d24077cacba677de5cebdd3a9da463306ecd Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 5 Oct 2013 17:36:58 -0500 Subject: * Fixes cases where Last Attachment Point gets overwritten with 0 when it shouldn't * Fixes cases where Last Attachment Point doesn't get written when it should. * Fixes Null Reference in BaseHttpServer when shutting down, null path provided. * Drop then Wear retains Last Attachment Point --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6deb870..997a1be 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1667,7 +1667,8 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar == null) return; - + m_rootPart.Shape.LastAttachPoint = m_rootPart.Shape.State; + m_rootPart.AttachedPos = m_rootPart.OffsetPosition; avatar.RemoveAttachment(this); Vector3 detachedpos = new Vector3(127f,127f,127f); @@ -2107,6 +2108,7 @@ namespace OpenSim.Region.Framework.Scenes if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) { + RootPart.Shape.LastAttachPoint = RootPart.Shape.State; RootPart.Shape.State = 0; ScheduleGroupForFullUpdate(); } -- cgit v1.1 From a30ad71651cb49720bf8b04e2d651bd28f5b8ea2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 25 Mar 2014 03:17:44 +0100 Subject: Guard against Scene being null in attachments it the wearing avatar is in the process of logging out. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3e1dcaa..86f60bb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1886,25 +1886,27 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = parts[i]; - Scene.ForEachRootScenePresence(delegate(ScenePresence avatar) + if (Scene != null) { - if (avatar.ParentID == LocalId) - avatar.StandUp(); - - if (!silent) + Scene.ForEachRootScenePresence(delegate(ScenePresence avatar) { - part.ClearUpdateSchedule(); - if (part == m_rootPart) + if (avatar.ParentID == LocalId) + avatar.StandUp(); + + if (!silent) { - if (!IsAttachment - || AttachedAvatar == avatar.ControllingClient.AgentId - || !HasPrivateAttachmentPoint) - avatar.ControllingClient.SendKillObject(m_regionHandle, new List { part.LocalId }); + part.ClearUpdateSchedule(); + if (part == m_rootPart) + { + if (!IsAttachment + || AttachedAvatar == avatar.ControllingClient.AgentId + || !HasPrivateAttachmentPoint) + avatar.ControllingClient.SendKillObject(m_regionHandle, new List { part.LocalId }); + } } - } - }); + }); + } } - } public void AddScriptLPS(int count) -- cgit v1.1 From d97896d39a50cdcbf1d96a9a9382b4dde7b76b53 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 26 Apr 2014 20:32:27 +0200 Subject: Differentiate between requests only the owner should be able to do and those that managers can do when setting parcel data --- OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 535d87a..4d90726 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); public delegate bool IsAdministratorHandler(UUID user); public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); - public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); + public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager); public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); @@ -763,7 +763,7 @@ namespace OpenSim.Region.Framework.Scenes #region EDIT PARCEL - public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p) + public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, bool allowManager) { EditParcelPropertiesHandler handler = OnEditParcelProperties; if (handler != null) @@ -771,7 +771,7 @@ namespace OpenSim.Region.Framework.Scenes Delegate[] list = handler.GetInvocationList(); foreach (EditParcelPropertiesHandler h in list) { - if (h(user, parcel, p, m_scene) == false) + if (h(user, parcel, p, m_scene, allowManager) == false) return false; } } -- cgit v1.1 From 95b89dd450cb55393a882272da06f404aed04ba8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 Jul 2014 20:27:05 +0100 Subject: fix attachments --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cba75f1..d87091c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2332,13 +2332,15 @@ namespace OpenSim.Region.Framework.Scenes if (e == null || attachment) // Single { SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); - - g.RootPart.AttachPoint = g.RootPart.Shape.State; - g.RootPart.AttachOffset = g.AbsolutePosition; - g.RootPart.AttachRotation = g.GroupRotation; - if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && - g.RootPart.Shape.PCode != (byte)PCode.Tree) - g.RootPart.Shape.State = 0; + if (!attachment) + { + g.RootPart.AttachPoint = g.RootPart.Shape.State; + g.RootPart.AttachOffset = g.AbsolutePosition; + g.RootPart.AttachRotation = g.GroupRotation; + if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && + g.RootPart.Shape.PCode != (byte)PCode.Tree) + g.RootPart.Shape.State = 0; + } objlist.Add(g); veclist.Add(new Vector3(0, 0, 0)); -- cgit v1.1 From dc717303d4a361815e84312ce1c66528b58de2e5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 Jul 2014 01:15:33 +0100 Subject: replace old Attachoffset by AttachedPos. Comented out possible merge artifacts --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 11 ++++++----- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index d87091c..746b703 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2332,16 +2332,17 @@ namespace OpenSim.Region.Framework.Scenes if (e == null || attachment) // Single { SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); +/* if (!attachment) { g.RootPart.AttachPoint = g.RootPart.Shape.State; - g.RootPart.AttachOffset = g.AbsolutePosition; + g.RootPart.AttachedPos = g.AbsolutePosition; g.RootPart.AttachRotation = g.GroupRotation; if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && g.RootPart.Shape.PCode != (byte)PCode.Tree) g.RootPart.Shape.State = 0; } - +*/ objlist.Add(g); veclist.Add(new Vector3(0, 0, 0)); bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); @@ -2360,14 +2361,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (XmlNode n in groups) { SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); - +/* g.RootPart.AttachPoint = g.RootPart.Shape.State; - g.RootPart.AttachOffset = g.AbsolutePosition; + g.RootPart.AttachedPos = g.AbsolutePosition; g.RootPart.AttachRotation = g.GroupRotation; if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && g.RootPart.Shape.PCode != (byte)PCode.Tree) g.RootPart.Shape.State = 0; - +*/ objlist.Add(g); XmlElement el = (XmlElement)n; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ce9baaa..ab1d2bd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -251,9 +251,6 @@ namespace OpenSim.Region.Framework.Scenes public byte AttachPoint = 0; [XmlIgnore] - public Vector3 AttachOffset = Vector3.Zero; - - [XmlIgnore] public Quaternion AttachRotation = Quaternion.Identity; [XmlIgnore] diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8893cc0..257e01e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -904,11 +904,11 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < objlist.Count; i++) { SceneObjectGroup group = objlist[i]; - +/* group.RootPart.AttachPoint = group.RootPart.Shape.State; - group.RootPart.AttachOffset = group.AbsolutePosition; + group.RootPart.AttachedPos = group.AbsolutePosition; group.RootPart.AttachRotation = group.GroupRotation; - +*/ group.ResetIDs(); SceneObjectPart rootPart = group.GetPart(group.UUID); -- cgit v1.1 From 32b060a608d2bdb007f0d1fb65251f1e1fd5f3c5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 Jul 2014 05:54:51 +0100 Subject: physics engine cannot change internal positions of linksets, at least not in teaseupdates --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ab1d2bd..fe1f00b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2956,7 +2956,7 @@ namespace OpenSim.Region.Framework.Scenes } //ParentGroup.RootPart.m_groupPosition = newpos; } - +/* ubit: there are no flexible links if (pa != null && ParentID != 0 && ParentGroup != null) { // Special case where a child object is requesting property updates. @@ -2976,7 +2976,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); } - +*/ ScheduleTerseUpdate(); } -- cgit v1.1 From 79aea3e588c7458cee9ec1ee7a66dac389475e62 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 Jul 2014 09:21:00 +0100 Subject: physicsSit SendSitResponse also relative to parent prim --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f57d4fe..f54ba9c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2824,14 +2824,20 @@ namespace OpenSim.Region.Framework.Scenes Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); bool forceMouselook = part.GetForceMouselook(); - ControllingClient.SendSitResponse( - part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); - - // not using autopilot - Rotation = Orientation; m_pos = offset; + if (!part.IsRoot) + { + Orientation = part.RotationOffset * Orientation; + offset = offset * part.RotationOffset; + offset += part.OffsetPosition; + } + + ControllingClient.SendSitResponse( + part.ParentGroup.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); + + m_requestedSitTargetID = 0; part.ParentGroup.AddAvatar(UUID); -- cgit v1.1 From d6f56a4f99f19aba06420002d185246dd03ee656 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 Jul 2014 16:03:05 +0100 Subject: change avatar standup code --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 53 +++++++++++------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f54ba9c..d4361b8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1881,6 +1881,7 @@ namespace OpenSim.Region.Framework.Scenes // (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) // m_updateCount = UPDATE_COUNT; + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); @@ -1949,10 +1950,8 @@ namespace OpenSim.Region.Framework.Scenes if (AllowMovement && !SitGround) { -// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); - +// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); bool update_rotation = false; - if (agentData.BodyRotation != Rotation) { Rotation = agentData.BodyRotation; @@ -2524,49 +2523,46 @@ namespace OpenSim.Region.Framework.Scenes } part.ParentGroup.DeleteAvatar(UUID); - Vector3 sitPartWorldPosition = part.GetWorldPosition(); + + Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset; + Vector3 sitPartWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation; ControllingClient.SendClearFollowCamProperties(part.ParentUUID); ParentID = 0; ParentPart = null; - Quaternion standRotation; if (part.SitTargetAvatar == UUID) - { - standRotation = part.GetWorldRotation(); + standRotation = standRotation * part.SitTargetOrientation; + else + standRotation = part.GetWorldRotation() * m_bodyRot; + + m_bodyRot = standRotation; - if (!part.IsRoot) - standRotation = standRotation * part.SitTargetOrientation; -// standRotation = part.RotationOffset * part.SitTargetOrientation; -// else -// standRotation = part.SitTargetOrientation; + Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W); + float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z; + if (t > 0) + { + t = 1.0f / (float)Math.Sqrt(t); + standRotationZ.W *= t; + standRotationZ.Z *= t; } else { - standRotation = Rotation; + standRotationZ.W = 1.0f; + standRotationZ.Z = 0f; } - //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); - //Vector3 standPos = ParentPosition; - -// Vector3 standPositionAdjustment -// = part.SitTargetPosition + new Vector3(0.5f, 0f, m_sitAvatarHeight / 2f); - Vector3 adjustmentForSitPosition = part.SitTargetPosition * part.GetWorldRotation(); - - // XXX: This is based on the physics capsule sizes. Need to find a better way to read this rather than - // hardcoding here. - Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; + Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight + .3f) * standRotationZ; - Vector3 standPos = sitPartWorldPosition + adjustmentForSitPosition + adjustmentForSitPose; + Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose; // m_log.DebugFormat( // "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", // standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); - Rotation = standRotation; - AbsolutePosition = standPos; + m_pos = standPos; } // We need to wait until we have calculated proper stand positions before sitting up the physical @@ -2824,8 +2820,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); bool forceMouselook = part.GetForceMouselook(); - Rotation = Orientation; - m_pos = offset; + m_bodyRot = Orientation; if (!part.IsRoot) { @@ -2834,6 +2829,8 @@ namespace OpenSim.Region.Framework.Scenes offset += part.OffsetPosition; } + m_pos = offset; + ControllingClient.SendSitResponse( part.ParentGroup.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); -- cgit v1.1 From 5f364dbed5ecc46240c727cdc8103db2d4d2dce3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 Jul 2014 16:09:34 +0100 Subject: another change to standup --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d4361b8..a5c2e0d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2535,7 +2535,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.SitTargetAvatar == UUID) standRotation = standRotation * part.SitTargetOrientation; else - standRotation = part.GetWorldRotation() * m_bodyRot; + standRotation = standRotation * m_bodyRot; m_bodyRot = standRotation; -- cgit v1.1 From 719880a6ff3a784ddb9db7bb6a646a78c691bad3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 Jul 2014 20:20:59 +0100 Subject: make sittarget camera relative to root prim Please enter the commit message for your changes. Lines starting --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a5c2e0d..93bcef2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2631,6 +2631,7 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; + if (PhysicsActor != null) m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; @@ -2638,23 +2639,9 @@ namespace OpenSim.Region.Framework.Scenes if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied", -// Name, part.Name, part.LocalId); - offset = part.SitTargetPosition; sitOrientation = part.SitTargetOrientation; - if (!part.IsRoot) - { - // m_log.DebugFormat("Old sit orient {0}", sitOrientation); - sitOrientation = part.RotationOffset * sitOrientation; - // m_log.DebugFormat("New sit orient {0}", sitOrientation); -// m_log.DebugFormat("Old sit offset {0}", offset); - offset = offset * part.RotationOffset; -// m_log.DebugFormat("New sit offset {0}", offset); - } - canSit = true; } else @@ -2691,9 +2678,18 @@ namespace OpenSim.Region.Framework.Scenes cameraEyeOffset = part.GetCameraEyeOffset(); forceMouselook = part.GetForceMouselook(); - // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is - // being sat upon. - offset += part.OffsetPosition; + if (!part.IsRoot) + { + sitOrientation = part.RotationOffset * sitOrientation; + offset = offset * part.RotationOffset; + cameraAtOffset = cameraAtOffset * part.RotationOffset; + cameraEyeOffset = cameraEyeOffset * part.RotationOffset; + + offset += part.OffsetPosition; + cameraAtOffset += part.OffsetPosition; + cameraEyeOffset += part.OffsetPosition; + } + ControllingClient.SendSitResponse( part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); @@ -2826,7 +2822,12 @@ namespace OpenSim.Region.Framework.Scenes { Orientation = part.RotationOffset * Orientation; offset = offset * part.RotationOffset; + cameraAtOffset = cameraAtOffset * part.RotationOffset; + cameraEyeOffset = cameraEyeOffset * part.RotationOffset; + offset += part.OffsetPosition; + cameraAtOffset += part.OffsetPosition; + cameraEyeOffset += part.OffsetPosition; } m_pos = offset; -- cgit v1.1 From 5cdd205ee7f3f785d9d6dd6eca1fcfb8e414313b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 21 Jul 2014 21:31:48 +0100 Subject: change presence movetotarget avoiding trying to go undergroud or fly when it can walk. ( still needs better code ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 93bcef2..3d361d6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2431,6 +2431,8 @@ namespace OpenSim.Region.Framework.Scenes targetScene = m_scene; float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; + // dont try to land underground + terrainHeight += Appearance.AvatarHeight / 2; pos.Z = Math.Max(terrainHeight, pos.Z); // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is @@ -2442,10 +2444,11 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", // Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); + if (noFly) Flying = false; - else if (pos.Z > terrainHeight) + else if (pos.Z > terrainHeight + Appearance.AvatarHeight / 2 || Flying) Flying = true; LandAtTarget = landAtTarget; -- cgit v1.1 From 243499ea4e10cb90f863199b83cd299afbd46c28 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 01:11:18 +0100 Subject: send updates on selected attachments as sl ( warinin if reverted then a fix is needed elsewhere since the changes are never sent) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fe1f00b..055473d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3289,9 +3289,9 @@ namespace OpenSim.Region.Framework.Scenes return; // Suppress full updates during attachment editing - // - if (ParentGroup.IsSelected && ParentGroup.IsAttachment) - return; + // sl Does send them + // if (ParentGroup.IsSelected && ParentGroup.IsAttachment) + // return; if (ParentGroup.IsDeleted) return; -- cgit v1.1 From 0e4a9e35c75a466f4b98f1d4aa7d862e98da5e5d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 04:10:51 +0100 Subject: bug fix. Child position got broken because first prim i parts array may not be the root prim --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cfa862e..745872a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -681,8 +681,13 @@ namespace OpenSim.Region.Framework.Scenes bool triggerScriptEvent = m_rootPart.GroupPosition != val; if (m_dupeInProgress) triggerScriptEvent = false; + m_rootPart.GroupPosition = val; + if (triggerScriptEvent) + m_rootPart.TriggerScriptChangedEvent(Changed.POSITION); foreach (SceneObjectPart part in parts) { + if (part == m_rootPart) + continue; part.GroupPosition = val; if (triggerScriptEvent) part.TriggerScriptChangedEvent(Changed.POSITION); -- cgit v1.1 From 5269511339738b465938e5cfd3da12cfa0594e28 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 14:31:47 +0100 Subject: dont try to cross with avatars on DIE_AT_EDGE or RETURN_AT_EDGE sog --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 180 +++++++++++---------- 1 file changed, 96 insertions(+), 84 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 745872a..299effa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -550,114 +550,126 @@ namespace OpenSim.Region.Framework.Scenes Vector3 newpos = Vector3.Zero; OpenSim.Services.Interfaces.GridRegion destination = null; - if (m_rootPart.KeyframeMotion != null) - m_rootPart.KeyframeMotion.StartCrossingCheck(); - - bool canCross = true; - foreach (ScenePresence av in m_linkedAvatars) + if (m_rootPart.DIE_AT_EDGE || m_rootPart.RETURN_AT_EDGE) { - // We need to cross these agents. First, let's find - // out if any of them can't cross for some reason. - // We have to deny the crossing entirely if any - // of them are banned. Alternatively, we could - // unsit banned agents.... - - - // We set the avatar position as being the object - // position to get the region to send to - if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) - { - canCross = false; - break; - } - - m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); + // this should delete the grp in this case + m_scene.CrossPrimGroupIntoNewRegion(val, this, true); } - - if (canCross) + else { - // We unparent the SP quietly so that it won't - // be made to stand up + if (m_rootPart.KeyframeMotion != null) + m_rootPart.KeyframeMotion.StartCrossingCheck(); - List avsToCross = new List(); + bool canCross = true; foreach (ScenePresence av in m_linkedAvatars) { - avtocrossInfo avinfo = new avtocrossInfo(); - SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); - if (parentPart != null) - av.ParentUUID = parentPart.UUID; + // We need to cross these agents. First, let's find + // out if any of them can't cross for some reason. + // We have to deny the crossing entirely if any + // of them are banned. Alternatively, we could + // unsit banned agents.... - avinfo.av = av; - avinfo.ParentID = av.ParentID; - avsToCross.Add(avinfo); - av.PrevSitOffset = av.OffsetPosition; - av.ParentID = 0; - } + // We set the avatar position as being the object + // position to get the region to send to + if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) + { + canCross = false; + break; + } - // m_linkedAvatars.Clear(); - m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); + } - // Normalize - if (val.X >= Constants.RegionSize) - val.X -= Constants.RegionSize; - if (val.Y >= Constants.RegionSize) - val.Y -= Constants.RegionSize; - if (val.X < 0) - val.X += Constants.RegionSize; - if (val.Y < 0) - val.Y += Constants.RegionSize; - - // If it's deleted, crossing was successful - if (IsDeleted) + if (canCross) { - // foreach (ScenePresence av in m_linkedAvatars) - foreach (avtocrossInfo avinfo in avsToCross) + // We unparent the SP quietly so that it won't + // be made to stand up + + List avsToCross = new List(); + + foreach (ScenePresence av in m_linkedAvatars) { - ScenePresence av = avinfo.av; - if (!av.IsInTransit) // just in case... - { - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); + avtocrossInfo avinfo = new avtocrossInfo(); + SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); + if (parentPart != null) + av.ParentUUID = parentPart.UUID; + + avinfo.av = av; + avinfo.ParentID = av.ParentID; + avsToCross.Add(avinfo); - av.IsInTransit = true; + av.PrevSitOffset = av.OffsetPosition; + av.ParentID = 0; + } - CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; - d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + // m_linkedAvatars.Clear(); + m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + + // Normalize + if (val.X >= Constants.RegionSize) + val.X -= Constants.RegionSize; + if (val.Y >= Constants.RegionSize) + val.Y -= Constants.RegionSize; + if (val.X < 0) + val.X += Constants.RegionSize; + if (val.Y < 0) + val.Y += Constants.RegionSize; + + // If it's deleted, crossing was successful + if (IsDeleted) + { + // foreach (ScenePresence av in m_linkedAvatars) + foreach (avtocrossInfo avinfo in avsToCross) + { + ScenePresence av = avinfo.av; + if (!av.IsInTransit) // just in case... + { + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); + + av.IsInTransit = true; + + CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; + d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + } + else + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); } - else - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); + avsToCross.Clear(); + return; } - avsToCross.Clear(); - return; - } - else // cross failed, put avas back ?? - { - foreach (avtocrossInfo avinfo in avsToCross) + else // cross failed, put avas back ?? { - ScenePresence av = avinfo.av; - av.ParentUUID = UUID.Zero; - av.ParentID = avinfo.ParentID; -// m_linkedAvatars.Add(av); + foreach (avtocrossInfo avinfo in avsToCross) + { + ScenePresence av = avinfo.av; + av.ParentUUID = UUID.Zero; + av.ParentID = avinfo.ParentID; + // m_linkedAvatars.Add(av); + } } - } - avsToCross.Clear(); + avsToCross.Clear(); - } - else - { - if (m_rootPart.KeyframeMotion != null) - m_rootPart.KeyframeMotion.CrossingFailure(); + } + // else + // we need to do this on all fails - if (RootPart.PhysActor != null) { - RootPart.PhysActor.CrossingFailure(); + if (m_rootPart.KeyframeMotion != null) + m_rootPart.KeyframeMotion.CrossingFailure(); + + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.CrossingFailure(); + } } + Vector3 oldp = AbsolutePosition; + val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); + val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); + // dont crash land StarShips + // val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } - Vector3 oldp = AbsolutePosition; - val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); - val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); - val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } -- cgit v1.1 From cf132430ae6d989412cccc0e9c8148798b1382d5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 14:50:17 +0100 Subject: tell scripts about positions changes after they are actually changed --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 299effa..48aacfe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -687,22 +687,30 @@ namespace OpenSim.Region.Framework.Scenes } } - // Restuff the new GroupPosition into each SOP of the linkset. - // This has the affect of resetting and tainting the physics actors. - SceneObjectPart[] parts = m_parts.GetArray(); bool triggerScriptEvent = m_rootPart.GroupPosition != val; - if (m_dupeInProgress) + if (m_dupeInProgress || IsDeleted) triggerScriptEvent = false; + m_rootPart.GroupPosition = val; - if (triggerScriptEvent) - m_rootPart.TriggerScriptChangedEvent(Changed.POSITION); + + // Restuff the new GroupPosition into each child SOP of the linkset. + // this is needed because physics may not have linksets but just loose SOPs in world + + SceneObjectPart[] parts = m_parts.GetArray(); + foreach (SceneObjectPart part in parts) { - if (part == m_rootPart) - continue; - part.GroupPosition = val; - if (triggerScriptEvent) + if (part != m_rootPart) + part.GroupPosition = val; + } + + // now that position is changed tell it to scripts + if (triggerScriptEvent) + { + foreach (SceneObjectPart part in parts) + { part.TriggerScriptChangedEvent(Changed.POSITION); + } } /* -- cgit v1.1 From f9fdf26ec37f9f7e0478deb6d9bfe3a3efcbc39e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 15:13:37 +0100 Subject: make ResetChildPrimPhysicsPositions only do what it is supposed to do and not what AbsolutePosition does --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 48aacfe..c7f4684 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1840,11 +1840,21 @@ namespace OpenSim.Region.Framework.Scenes // Setting this SOG's absolute position also loops through and sets the positions // of the SOP's in this SOG's linkset. This has the side affect of making sure // the physics world matches the simulated world. - AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? + // AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? // teravus: AbsolutePosition is NOT a normal property! // the code in the getter of AbsolutePosition is significantly different then the code in the setter! // jhurliman: Then why is it a property instead of two methods? + + // do only what is supposed to do + Vector3 groupPosition = m_rootPart.GroupPosition; + SceneObjectPart[] parts = m_parts.GetArray(); + + foreach (SceneObjectPart part in parts) + { + if (part != m_rootPart) + part.GroupPosition = groupPosition; + } } public UUID GetPartsFullID(uint localID) -- cgit v1.1 From ed905418b3dc0a2ec569af610024b8c4fe7a0389 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 15:47:42 +0100 Subject: consider that CrossPrimGroupIntoNewRegion removes DIE_AT_EDGE and RETURN_AT_EDGE from simulation --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c7f4684..d4051c0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -554,6 +554,8 @@ namespace OpenSim.Region.Framework.Scenes { // this should delete the grp in this case m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + // actually assume this sog was removed from simulation + return; } else { -- cgit v1.1 From fe900b28c69ad0970c273ea25f4194c7f4456520 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 15:56:20 +0100 Subject: CrossPrimGroupIntoNewRegion does keyframes and physics crossing fails, so revert previus change assuming it didnt. remove a no longer needed else {} --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 177 ++++++++++----------- 1 file changed, 86 insertions(+), 91 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d4051c0..4ac6743 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -557,121 +557,116 @@ namespace OpenSim.Region.Framework.Scenes // actually assume this sog was removed from simulation return; } - else + + if (m_rootPart.KeyframeMotion != null) + m_rootPart.KeyframeMotion.StartCrossingCheck(); + + bool canCross = true; + + foreach (ScenePresence av in m_linkedAvatars) { - if (m_rootPart.KeyframeMotion != null) - m_rootPart.KeyframeMotion.StartCrossingCheck(); + // We need to cross these agents. First, let's find + // out if any of them can't cross for some reason. + // We have to deny the crossing entirely if any + // of them are banned. Alternatively, we could + // unsit banned agents.... - bool canCross = true; - foreach (ScenePresence av in m_linkedAvatars) + // We set the avatar position as being the object + // position to get the region to send to + if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) { - // We need to cross these agents. First, let's find - // out if any of them can't cross for some reason. - // We have to deny the crossing entirely if any - // of them are banned. Alternatively, we could - // unsit banned agents.... + canCross = false; + break; + } + m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); + } - // We set the avatar position as being the object - // position to get the region to send to - if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) - { - canCross = false; - break; - } + if (canCross) + { + // We unparent the SP quietly so that it won't + // be made to stand up - m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); - } + List avsToCross = new List(); - if (canCross) + foreach (ScenePresence av in m_linkedAvatars) { - // We unparent the SP quietly so that it won't - // be made to stand up + avtocrossInfo avinfo = new avtocrossInfo(); + SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); + if (parentPart != null) + av.ParentUUID = parentPart.UUID; - List avsToCross = new List(); + avinfo.av = av; + avinfo.ParentID = av.ParentID; + avsToCross.Add(avinfo); - foreach (ScenePresence av in m_linkedAvatars) - { - avtocrossInfo avinfo = new avtocrossInfo(); - SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); - if (parentPart != null) - av.ParentUUID = parentPart.UUID; - - avinfo.av = av; - avinfo.ParentID = av.ParentID; - avsToCross.Add(avinfo); + av.PrevSitOffset = av.OffsetPosition; + av.ParentID = 0; + } - av.PrevSitOffset = av.OffsetPosition; - av.ParentID = 0; - } + // m_linkedAvatars.Clear(); + m_scene.CrossPrimGroupIntoNewRegion(val, this, true); - // m_linkedAvatars.Clear(); - m_scene.CrossPrimGroupIntoNewRegion(val, this, true); - - // Normalize - if (val.X >= Constants.RegionSize) - val.X -= Constants.RegionSize; - if (val.Y >= Constants.RegionSize) - val.Y -= Constants.RegionSize; - if (val.X < 0) - val.X += Constants.RegionSize; - if (val.Y < 0) - val.Y += Constants.RegionSize; - - // If it's deleted, crossing was successful - if (IsDeleted) - { - // foreach (ScenePresence av in m_linkedAvatars) - foreach (avtocrossInfo avinfo in avsToCross) - { - ScenePresence av = avinfo.av; - if (!av.IsInTransit) // just in case... - { - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); - - av.IsInTransit = true; - - CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; - d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); - } - else - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); - } - avsToCross.Clear(); - return; - } - else // cross failed, put avas back ?? + // Normalize + if (val.X >= Constants.RegionSize) + val.X -= Constants.RegionSize; + if (val.Y >= Constants.RegionSize) + val.Y -= Constants.RegionSize; + if (val.X < 0) + val.X += Constants.RegionSize; + if (val.Y < 0) + val.Y += Constants.RegionSize; + + // If it's deleted, crossing was successful + if (IsDeleted) + { + // foreach (ScenePresence av in m_linkedAvatars) + foreach (avtocrossInfo avinfo in avsToCross) { - foreach (avtocrossInfo avinfo in avsToCross) + ScenePresence av = avinfo.av; + if (!av.IsInTransit) // just in case... { - ScenePresence av = avinfo.av; - av.ParentUUID = UUID.Zero; - av.ParentID = avinfo.ParentID; - // m_linkedAvatars.Add(av); + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); + + av.IsInTransit = true; + + CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; + d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); } + else + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); } avsToCross.Clear(); - + return; } - // else - // we need to do this on all fails - + else // cross failed, put avas back ?? { - if (m_rootPart.KeyframeMotion != null) - m_rootPart.KeyframeMotion.CrossingFailure(); - - if (RootPart.PhysActor != null) + foreach (avtocrossInfo avinfo in avsToCross) { - RootPart.PhysActor.CrossingFailure(); + ScenePresence av = avinfo.av; + av.ParentUUID = UUID.Zero; + av.ParentID = avinfo.ParentID; + // m_linkedAvatars.Add(av); } } - Vector3 oldp = AbsolutePosition; - val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); - val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); - // dont crash land StarShips - // val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); + avsToCross.Clear(); + } + else + { + if (m_rootPart.KeyframeMotion != null) + m_rootPart.KeyframeMotion.CrossingFailure(); + + if (RootPart.PhysActor != null) + { + RootPart.PhysActor.CrossingFailure(); + } } + Vector3 oldp = AbsolutePosition; + val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); + val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); + // dont crash land StarShips + // val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } -- cgit v1.1 From 0331159d2cec44a96ebaadcc427b2dd697605c5e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Jul 2014 21:34:21 +0100 Subject: clamp avatar standup position within region --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3d361d6..0aeb69a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2565,6 +2565,8 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", // standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); + standPos.X = Util.Clamp(standPos.X, 0.5f, (float)Constants.RegionSize - 0.5f); + standPos.Y = Util.Clamp(standPos.Y, 0.5f, (float)Constants.RegionSize - 0.5f); m_pos = standPos; } -- cgit v1.1 From d64a50ac9bc6326cd98f9b1733a2ae4504259ed4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 23 Jul 2014 19:56:06 +0100 Subject: changed locations of m_originRegionID setting to where current core has them. Changed avatar AbsolutePosition, it still didnt assume m_pos as relative to root prim. ( forgot to commit before) ( this sit may still have loose ends, specially around the use of OffsetPosition that is now relative to root prim and was relative to prim) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0aeb69a..258ca20 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -534,10 +534,14 @@ namespace OpenSim.Region.Framework.Scenes // in the sim unless the avatar is on a sit target. While // on a sit target, m_pos will contain the desired offset // without the parent rotation applied. - SceneObjectPart sitPart = ParentPart; - - if (sitPart != null) - return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); + if (ParentPart != null) + { + SceneObjectPart rootPart = ParentPart.ParentGroup.RootPart; + // if (sitPart != null) + // return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); + if (rootPart != null) + return rootPart.AbsolutePosition + (m_pos * rootPart.GetWorldRotation()); + } } return m_pos; @@ -1275,6 +1279,11 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); + // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating + // from the source simulator has completed on a V2 teleport. + lock (m_originRegionIDAccessLock) + m_originRegionID = UUID.Zero; + // Reset these so that teleporting in and walking out isn't seen // as teleporting back TeleportFlags = TeleportFlags.Default; @@ -3853,8 +3862,6 @@ namespace OpenSim.Region.Framework.Scenes private void CopyFrom(AgentData cAgent) { - lock (m_originRegionIDAccessLock) - m_originRegionID = cAgent.RegionID; m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( @@ -3928,6 +3935,10 @@ namespace OpenSim.Region.Framework.Scenes if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); + + lock (m_originRegionIDAccessLock) + m_originRegionID = cAgent.RegionID; + } public bool CopyAgent(out IAgentData agent) -- cgit v1.1 From 237075ce21ddde71e8bba475fc4f37525cfcf098 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 23 Jul 2014 20:31:54 +0100 Subject: cleanup a bit presence CheckForBorderCrossing removing dead code --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 239 +++++++++++------------ 1 file changed, 113 insertions(+), 126 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 258ca20..8e6e8fd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3475,7 +3475,7 @@ namespace OpenSim.Region.Framework.Scenes protected void CheckForBorderCrossing() { // Check that we we are not a child - if (IsChildAgent) + if (IsChildAgent) return; // If we don't have a PhysActor, we can't cross anyway @@ -3485,140 +3485,127 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) return; - if (!IsInTransit) - { - Vector3 pos2 = AbsolutePosition; - Vector3 vel = Velocity; - int neighbor = 0; - int[] fix = new int[2]; + if (IsInTransit) + return; - float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); + Vector3 pos2 = AbsolutePosition; + Vector3 vel = Velocity; + int neighbor = 0; + int[] fix = new int[2]; - if (!IsInTransit) - { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", -// pos2, Name, Scene.Name); + float timeStep = 0.1f; + pos2.X = pos2.X + (vel.X * timeStep); + pos2.Y = pos2.Y + (vel.Y * timeStep); + pos2.Z = pos2.Z + (vel.Z * timeStep); - // Checks if where it's headed exists a region - bool needsTransit = false; - if (m_scene.TestBorderCross(pos2, Cardinals.W)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); - } - else - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.E)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); - } - else - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); - } - // Makes sure avatar does not end up outside region - if (neighbor <= 0) - { - if (needsTransit) - { - if (m_requestedSitTargetUUID == UUID.Zero) - { - bool isFlying = Flying; - RemoveFromPhysicalScene(); - - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y * 2; - Velocity = Vector3.Zero; - AbsolutePosition = pos; - -// m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); - - AddToPhysicalScene(isFlying); - } - } - } - else if (neighbor > 0) + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", + // pos2, Name, Scene.Name); + + // Checks if where it's headed exists a region + bool needsTransit = false; + if (m_scene.TestBorderCross(pos2, Cardinals.W)) + { + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); + } + else + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); + } + } + else if (m_scene.TestBorderCross(pos2, Cardinals.E)) + { + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); + } + else + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); + } + } + else if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); + } + + // Makes sure avatar does not end up outside region + if (neighbor <= 0) + { + if (needsTransit) + { + if (m_requestedSitTargetUUID == UUID.Zero) { - if (!CrossToNewRegion()) - { - if (m_requestedSitTargetUUID == UUID.Zero) - { - bool isFlying = Flying; - RemoveFromPhysicalScene(); - - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y * 2; - Velocity = Vector3.Zero; - AbsolutePosition = pos; - - AddToPhysicalScene(isFlying); - } - } + bool isFlying = Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + // m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); + + AddToPhysicalScene(isFlying); } } - else + } + else if (neighbor > 0) + { + if (!CrossToNewRegion()) { - // This constant has been inferred from experimentation - // I'm not sure what this value should be, so I tried a few values. - timeStep = 0.04f; - pos2 = AbsolutePosition; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - // Don't touch the Z - m_pos = pos2; - m_log.DebugFormat("[SCENE PRESENCE]: In transit m_pos={0}", m_pos); + if (m_requestedSitTargetUUID == UUID.Zero) + { + bool isFlying = Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + } } - } + } + } /// -- cgit v1.1 From f9ae7ea2e6677c8d7ca7570e771be66de8b98a49 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 23 Jul 2014 21:14:35 +0100 Subject: do CompleteMovement with InTransit set as core --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 173 ++++++++++++----------- 1 file changed, 91 insertions(+), 82 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8e6e8fd..07564ba 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1646,109 +1646,118 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", client.Name, Scene.Name, AbsolutePosition); - // Make sure it's not a login agent. We don't want to wait for updates during login - if (PresenceType != PresenceType.Npc && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) + bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + + IsInTransit = true; + try { - // Let's wait until UpdateAgent (called by departing region) is done - if (!WaitForUpdateAgent(client)) - // The sending region never sent the UpdateAgent data, we have to refuse - return; - } + // Make sure it's not a login agent. We don't want to wait for updates during login + if (PresenceType != PresenceType.Npc && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) + { + // Let's wait until UpdateAgent (called by departing region) is done + if (!WaitForUpdateAgent(client)) + // The sending region never sent the UpdateAgent data, we have to refuse + return; + } - Vector3 look = Velocity; + Vector3 look = Velocity; - // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) - if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) - { - look = new Vector3(0.99f, 0.042f, 0); - } + // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) + if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) + { + look = new Vector3(0.99f, 0.042f, 0); + } - // Prevent teleporting to an underground location - // (may crash client otherwise) - // - Vector3 pos = AbsolutePosition; - float ground = m_scene.GetGroundHeight(pos.X, pos.Y); - if (pos.Z < ground + 1.5f) - { - pos.Z = ground + 1.5f; - AbsolutePosition = pos; - } + // Prevent teleporting to an underground location + // (may crash client otherwise) + // + Vector3 pos = AbsolutePosition; + float ground = m_scene.GetGroundHeight(pos.X, pos.Y); + if (pos.Z < ground + 1.5f) + { + pos.Z = ground + 1.5f; + AbsolutePosition = pos; + } - bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); - if (!MakeRootAgent(AbsolutePosition, flying)) - { - m_log.DebugFormat( - "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", - Name, Scene.Name); - return; - } + if (!MakeRootAgent(AbsolutePosition, flying)) + { + m_log.DebugFormat( + "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", + Name, Scene.Name); - // Tell the client that we're totally ready - ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); + return; + } - // Remember in HandleUseCircuitCode, we delayed this to here - if (m_teleportFlags > 0) - SendInitialDataToMe(); + // Tell the client that we're totally ready + ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); -// m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); + // Remember in HandleUseCircuitCode, we delayed this to here + if (m_teleportFlags > 0) + SendInitialDataToMe(); - if (!string.IsNullOrEmpty(m_callbackURI)) - { - // We cannot sleep here since this would hold up the inbound packet processing thread, as - // CompleteMovement() is executed synchronously. However, it might be better to delay the release - // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete - // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this - // region as the current region, meaning that a close sent before then will fail the teleport. -// System.Threading.Thread.Sleep(2000); + // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); - m_log.DebugFormat( - "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", - client.Name, client.AgentId, m_callbackURI); + if (!string.IsNullOrEmpty(m_callbackURI)) + { + // We cannot sleep here since this would hold up the inbound packet processing thread, as + // CompleteMovement() is executed synchronously. However, it might be better to delay the release + // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete + // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this + // region as the current region, meaning that a close sent before then will fail the teleport. + // System.Threading.Thread.Sleep(2000); - UUID originID; + m_log.DebugFormat( + "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", + client.Name, client.AgentId, m_callbackURI); - lock (m_originRegionIDAccessLock) - originID = m_originRegionID; + UUID originID; - Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); - m_callbackURI = null; - } -// else -// { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}", -// client.Name, client.AgentId, m_scene.RegionInfo.RegionName); -// } + lock (m_originRegionIDAccessLock) + originID = m_originRegionID; - ValidateAndSendAppearanceAndAgentData(); + Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); + m_callbackURI = null; + } + // else + // { + // m_log.DebugFormat( + // "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}", + // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); + // } - // Create child agents in neighbouring regions - if (openChildAgents && !IsChildAgent) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); + ValidateAndSendAppearanceAndAgentData(); - IFriendsModule friendsModule = m_scene.RequestModuleInterface(); - if (friendsModule != null) - friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + // Create child agents in neighbouring regions + if (openChildAgents && !IsChildAgent) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); - } + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); - // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region - // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work. - // This may be due to viewer code or it may be something we're not doing properly simulator side. - lock (m_attachments) - { - foreach (SceneObjectGroup sog in m_attachments) - sog.ScheduleGroupForFullUpdate(); - } + } -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", -// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); + // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region + // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work. + // This may be due to viewer code or it may be something we're not doing properly simulator side. + lock (m_attachments) + { + foreach (SceneObjectGroup sog in m_attachments) + sog.ScheduleGroupForFullUpdate(); + } + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", + // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); + } + finally + { + IsInTransit = false; + } } /// -- cgit v1.1 From f6af5f49966f1a2269ee6ceb5e7694a8e3f67cdd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 23 Jul 2014 22:28:51 +0100 Subject: change last commit setting intransit without messing flight --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 07564ba..e7462ba 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1646,9 +1646,9 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", client.Name, Scene.Name, AbsolutePosition); - bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + - IsInTransit = true; + m_inTransit = true; try { // Make sure it's not a login agent. We don't want to wait for updates during login @@ -1679,7 +1679,7 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = pos; } - + bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (!MakeRootAgent(AbsolutePosition, flying)) { m_log.DebugFormat( @@ -1756,7 +1756,7 @@ namespace OpenSim.Region.Framework.Scenes } finally { - IsInTransit = false; + m_inTransit = false; } } -- cgit v1.1 From 8808549669002c42c62c6ed602f7753571346d56 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 23 Jul 2014 23:09:13 +0100 Subject: on sit use root prim camera at and eye if child as neither --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 37 +++++++++++++++++------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e7462ba..5c76964 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2705,12 +2705,20 @@ namespace OpenSim.Region.Framework.Scenes { sitOrientation = part.RotationOffset * sitOrientation; offset = offset * part.RotationOffset; - cameraAtOffset = cameraAtOffset * part.RotationOffset; - cameraEyeOffset = cameraEyeOffset * part.RotationOffset; - offset += part.OffsetPosition; - cameraAtOffset += part.OffsetPosition; - cameraEyeOffset += part.OffsetPosition; + + if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero) + { + CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset(); + cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); + } + else + { + cameraAtOffset = cameraAtOffset * part.RotationOffset; + cameraAtOffset += part.OffsetPosition; + cameraEyeOffset = cameraEyeOffset * part.RotationOffset; + cameraEyeOffset += part.OffsetPosition; + } } @@ -2845,12 +2853,21 @@ namespace OpenSim.Region.Framework.Scenes { Orientation = part.RotationOffset * Orientation; offset = offset * part.RotationOffset; - cameraAtOffset = cameraAtOffset * part.RotationOffset; - cameraEyeOffset = cameraEyeOffset * part.RotationOffset; - offset += part.OffsetPosition; - cameraAtOffset += part.OffsetPosition; - cameraEyeOffset += part.OffsetPosition; + + if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero) + { + CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset(); + cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); + } + else + { + cameraAtOffset = cameraAtOffset * part.RotationOffset; + cameraAtOffset += part.OffsetPosition; + cameraEyeOffset = cameraEyeOffset * part.RotationOffset; + cameraEyeOffset += part.OffsetPosition; + } + } m_pos = offset; -- cgit v1.1 From 4aa55204a29b7424d9eafb594717d2c5394c26ed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 26 Jul 2014 05:27:36 +0100 Subject: allow reset default animation to default as core does --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index c1394aa..ecd6a09 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -151,7 +151,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (addRemove) m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); else - m_animations.Remove(animID, true); + m_animations.Remove(animID, false); } if(sendPack) SendAnimPack(); -- cgit v1.1 From b6af41ec1168e2548659fd8dbfaa774bd1c49c20 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 26 Jul 2014 05:59:38 +0100 Subject: dont standup avatar on crossing --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55766cf..0765b3f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2469,7 +2469,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (UUID av in avatars) { ScenePresence p = GetScenePresence(av); - if (p != null) + if (p != null && p.ParentUUID == UUID.Zero) p.StandUp(); } @@ -3134,7 +3134,7 @@ namespace OpenSim.Region.Framework.Scenes // and the scene presence and the client, if they exist try { - ScenePresence sp = GetScenePresence(agentID); + ScenePresence sp = WaitGetScenePresence(agentID); if (sp != null) { -- cgit v1.1 From 43cf184603389d188bbbac14e5f14022be658a1e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 26 Jul 2014 16:56:21 +0100 Subject: clear script controls on crossing (untested)(possible should be done elsewhere/othe way) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4ac6743..9527fa5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -761,6 +761,7 @@ namespace OpenSim.Region.Framework.Scenes { if (agent.ParentUUID != UUID.Zero) { + agent.ClearControls(); agent.ParentPart = null; // agent.ParentPosition = Vector3.Zero; // agent.ParentUUID = UUID.Zero; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5c76964..ca63d04 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4512,6 +4512,15 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendTakeControls(int.MaxValue, false, false); } + public void ClearControls() + { + IgnoredControls = ScriptControlled.CONTROL_ZERO; + lock (scriptedcontrols) + { + scriptedcontrols.Clear(); + } + } + private void UnRegisterSeatControls(UUID obj) { List takers = new List(); -- cgit v1.1 From eb55e69d4ade5bb825c65bbda7cd71564fa4f51d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 27 Jul 2014 08:08:01 +0100 Subject: serialize sound parameters for llLoopSound --- .../Scenes/Serialization/SceneObjectSerializer.cs | 49 +++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 5372360..3b3a99b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -268,10 +268,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization else sceneObject.RootPart.KeyframeMotion = null; + + XmlNodeList SOGSound = doc.GetElementsByTagName("SOGSound"); + if (SOGSound.Count > 0) + { + + } + // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(doc); - + return sceneObject; } catch (Exception e) @@ -391,6 +398,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); + m_SOPXmlProcessors.Add("SoundID", ProcessSoundID); + m_SOPXmlProcessors.Add("SoundGain", ProcessSoundGain); + m_SOPXmlProcessors.Add("SoundFlags", ProcessSoundFlags); + m_SOPXmlProcessors.Add("SoundRadius", ProcessSoundRadius); + m_SOPXmlProcessors.Add("SoundQueueing", ProcessSoundQueueing); + #endregion #region TaskInventoryXmlProcessors initialization @@ -654,6 +667,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); } + private static void ProcessSoundID(SceneObjectPart obj, XmlTextReader reader) + { + obj.Sound = Util.ReadUUID(reader, "SoundID"); + } + + private static void ProcessSoundGain(SceneObjectPart obj, XmlTextReader reader) + { + obj.SoundGain = reader.ReadElementContentAsDouble("SoundGain", String.Empty); + } + + private static void ProcessSoundFlags(SceneObjectPart obj, XmlTextReader reader) + { + obj.SoundFlags = (byte)reader.ReadElementContentAsInt("SoundFlags", String.Empty); + } + + private static void ProcessSoundRadius(SceneObjectPart obj, XmlTextReader reader) + { + obj.SoundRadius = reader.ReadElementContentAsDouble("SoundRadius", String.Empty); + } + + private static void ProcessSoundQueueing(SceneObjectPart obj, XmlTextReader reader) + { + obj.SoundQueueing = Util.ReadBoolean(reader); + } private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) { SOPVehicle vehicle = SOPVehicle.FromXml2(reader); @@ -1265,6 +1302,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteBase64(data, 0, data.Length); writer.WriteEndElement(); } + writer.WriteEndElement(); } @@ -1397,6 +1435,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); + // if (sop.Sound != UUID.Zero) force it till sop crossing does clear it on child prim + { + WriteUUID(writer, "SoundID", sop.Sound, options); + writer.WriteElementString("SoundGain", sop.SoundGain.ToString().ToLower()); + writer.WriteElementString("SoundFlags", sop.SoundFlags.ToString().ToLower()); + writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString().ToLower()); + } + writer.WriteElementString("SoundQueueing", sop.SoundQueueing.ToString().ToLower()); + writer.WriteEndElement(); } -- cgit v1.1 From 5a7a609683e8d77a8e2eb70573c07f205e1574a1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 27 Jul 2014 08:11:27 +0100 Subject: remove forgotten lines --- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3b3a99b..52bd5c9 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -268,13 +268,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization else sceneObject.RootPart.KeyframeMotion = null; - - XmlNodeList SOGSound = doc.GetElementsByTagName("SOGSound"); - if (SOGSound.Count > 0) - { - - } - // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(doc); -- cgit v1.1 From c3b5a6c2abaa5f508344f75d338fc7ff1be08538 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 27 Jul 2014 08:18:27 +0100 Subject: change how sounds work. May be bad.. needs testing --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9527fa5..ba97c47 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -908,14 +908,14 @@ namespace OpenSim.Region.Framework.Scenes } } } - + // PlaySoundMasterPrim no longer in use to remove private SceneObjectPart m_PlaySoundMasterPrim = null; public SceneObjectPart PlaySoundMasterPrim { get { return m_PlaySoundMasterPrim; } set { m_PlaySoundMasterPrim = value; } } - + // PlaySoundSlavePrims no longer in use to remove private List m_PlaySoundSlavePrims = new List(); public List PlaySoundSlavePrims { @@ -923,6 +923,7 @@ namespace OpenSim.Region.Framework.Scenes set { m_PlaySoundSlavePrims = value; } } + // LoopSoundMasterPrim no longer in use to remove private SceneObjectPart m_LoopSoundMasterPrim = null; public SceneObjectPart LoopSoundMasterPrim { @@ -930,6 +931,7 @@ namespace OpenSim.Region.Framework.Scenes set { m_LoopSoundMasterPrim = value; } } + // m_LoopSoundSlavePrims no longer in use to remove private List m_LoopSoundSlavePrims = new List(); public List LoopSoundSlavePrims { -- cgit v1.1 From 2a2a77240877668222ecff5b7ef994783bc6dd30 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 30 Jul 2014 15:36:49 +0100 Subject: mute avatar collision sounds if parcel doesnt allow --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ca63d04..3c64219 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -482,6 +482,22 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool ParcelAllowSounds + { + get + { + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land == null) + return true; + + if (land.LandData.AnyAVSounds) + return true; + if (!land.LandData.GroupAVSounds) + return false; + return land.LandData.GroupID == ControllingClient.ActiveGroupId; + } + } + public byte State { get; set; } private AgentManager.ControlFlags m_AgentControlFlags; @@ -5048,6 +5064,8 @@ namespace OpenSim.Region.Framework.Scenes else { + bool candoparcelSound = ParcelAllowSounds; + foreach (uint id in coldata.Keys) { thisHitColliders.Add(id); @@ -5055,7 +5073,7 @@ namespace OpenSim.Region.Framework.Scenes { startedColliders.Add(id); curcontact = coldata[id]; - if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + if (candoparcelSound && Math.Abs(curcontact.RelativeSpeed) > 0.2) { soundinfo = new CollisionForSoundInfo(); soundinfo.colliderID = id; -- cgit v1.1 From 17f9f1c247679363321b73ec75aed890eaf1b778 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 30 Jul 2014 16:32:25 +0100 Subject: restrict other avatar sounds to parcel flags ( untested ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3c64219..6b627be 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -482,7 +482,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public bool ParcelAllowSounds + public bool ParcelAllowThisAvatarSounds { get { @@ -5064,7 +5064,7 @@ namespace OpenSim.Region.Framework.Scenes else { - bool candoparcelSound = ParcelAllowSounds; + bool candoparcelSound = ParcelAllowThisAvatarSounds; foreach (uint id in coldata.Keys) { -- cgit v1.1 From a5e9429f2bb2276486cc2f1ed2249e14fba90d6a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 31 Jul 2014 03:10:50 +0100 Subject: MESS: changes in MakeRootAgent and CompleteMovement reordering things. Added sending of land overlay and parcel information. This in order to only send avatar related information after having its position well defined and on the right parcel. THIS MAY STILL BE BAD :) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 143 +++++++++++++++++++---- 1 file changed, 118 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6b627be..5775747 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,8 +140,67 @@ namespace OpenSim.Region.Framework.Scenes /// public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; - public UUID currentParcelUUID = UUID.Zero; + private UUID m_currentParcelUUID = UUID.Zero; + private object parcelLock = new Object(); + public UUID currentParcelUUID + { + get { return m_currentParcelUUID; } + set + { + lock (parcelLock) + { + m_currentParcelUUID = value; + } + } + } + + public bool ParcelAllowThisAvatarSounds + { + get + { + try + { + lock (parcelLock) + { + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land == null) + return true; + if (land.LandData.AnyAVSounds) + return true; + if (!land.LandData.GroupAVSounds) + return false; + return land.LandData.GroupID == ControllingClient.ActiveGroupId; + } + } + catch + { + return true; + } + } + } + + public bool ParcelHideThisAvatar + { + get + { + try + { + lock (parcelLock) + { + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land == null || !land.LandData.SeeAVs) + return false; + return true; + } + } + catch + { + return false; + } + } + } + /// /// The animator for this avatar /// @@ -482,21 +541,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public bool ParcelAllowThisAvatarSounds - { - get - { - ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); - if (land == null) - return true; - if (land.LandData.AnyAVSounds) - return true; - if (!land.LandData.GroupAVSounds) - return false; - return land.LandData.GroupID == ControllingClient.ActiveGroupId; - } - } public byte State { get; set; } @@ -1023,6 +1068,9 @@ namespace OpenSim.Region.Framework.Scenes /// This method is on the critical path for transferring an avatar from one region to another. Delay here /// delays that crossing. /// + + + // only in use as part of completemovement private bool MakeRootAgent(Vector3 pos, bool isFlying) { lock (m_completeMovementLock) @@ -1229,6 +1277,7 @@ namespace OpenSim.Region.Framework.Scenes // // One cannot simply iterate over attachments in a fire and forget thread because this would no longer // be locked, allowing race conditions if other code changes the attachments list. + List attachments = GetAttachments(); if (attachments.Count > 0) @@ -1236,16 +1285,19 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - // Resume scripts + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? foreach (SceneObjectGroup sog in attachments) { - sog.ScheduleGroupForFullUpdate(); +// sending attachments before the avatar ? +// moved to completemovement where it already was +// sog.ScheduleGroupForFullUpdate(); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); } } } +/* SendAvatarDataToAllAgents(); // send the animations of the other presences to me @@ -1254,6 +1306,7 @@ namespace OpenSim.Region.Framework.Scenes if (presence != this) presence.Animator.SendAnimPackToClient(ControllingClient); }); +*/ // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement @@ -1421,6 +1474,9 @@ namespace OpenSim.Region.Framework.Scenes public void StopFlying() { + if (IsInTransit) + return; + Vector3 pos = AbsolutePosition; if (Appearance.AvatarHeight != 127.0f) pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f)); @@ -1661,9 +1717,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.InfoFormat( "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", client.Name, Scene.Name, AbsolutePosition); - - - + m_inTransit = true; try { @@ -1709,8 +1763,9 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); // Remember in HandleUseCircuitCode, we delayed this to here - if (m_teleportFlags > 0) - SendInitialDataToMe(); +// this prims etc, moved down +// if (m_teleportFlags > 0) +// SendInitialDataToMe(); // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); @@ -1742,6 +1797,20 @@ namespace OpenSim.Region.Framework.Scenes // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); // } + // send initial land overlay and parcel + if (!IsChildAgent) + { + ILandChannel landch = m_scene.LandChannel; + if (landch != null) + { + landch.sendClientInitialLandInfo(client); + } + } + + // send agentData to all clients including us (?) + // get appearance + // if in cache sent it to all clients + // send what we have to us, even if not in cache ( bad? ) ValidateAndSendAppearanceAndAgentData(); // Create child agents in neighbouring regions @@ -1750,11 +1819,11 @@ namespace OpenSim.Region.Framework.Scenes IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) m_agentTransfer.EnableChildAgents(this); - +/* moved down IFriendsModule friendsModule = m_scene.RequestModuleInterface(); if (friendsModule != null) friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); - +*/ } // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region @@ -1769,6 +1838,27 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); + + // send the rest of the world + if (m_teleportFlags > 0) + SendInitialDataToMe(); + + if (!IsChildAgent) + { +// moved from makeroot missing in sendInitialDataToMe ? + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) + { + if (presence != this) + presence.Animator.SendAnimPackToClient(ControllingClient); + }); + + if (openChildAgents) + { + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + } + } } finally { @@ -1864,6 +1954,9 @@ namespace OpenSim.Region.Framework.Scenes return; } + if (IsInTransit) + return; + #region Sanity Checking // This is irritating. Really. @@ -3307,13 +3400,13 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); // This invocation always shows up in the viewer logs as an error. Is it needed? + // try to send what we have even if not in cache SendAppearanceToAgent(this); // If we are using the the cached appearance then send it out to everyone if (cachedappearance) { m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); - // If the avatars baked textures are all in the cache, then we have a // complete appearance... send it out, if not, then we'll send it when // the avatar finishes updating its appearance -- cgit v1.1 From 0a1e9d731daa9a599c7c18b9777497592aadc235 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 1 Aug 2014 00:34:52 +0100 Subject: work on hide avatars --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 278 +++++++++++++++++++---- 1 file changed, 238 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5775747..b8ad78e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,7 +140,10 @@ namespace OpenSim.Region.Framework.Scenes /// public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; - private UUID m_currentParcelUUID = UUID.Zero; + private UUID m_previusParcelUUID = UUID.Zero; + private UUID m_currentParcelUUID = UUID.Zero; + private bool m_previusParcelHide = false; + private bool m_currentParcelHide = false; private object parcelLock = new Object(); public UUID currentParcelUUID @@ -150,7 +153,15 @@ namespace OpenSim.Region.Framework.Scenes { lock (parcelLock) { + m_previusParcelHide = m_currentParcelHide; + m_previusParcelUUID = m_currentParcelUUID; m_currentParcelUUID = value; + m_currentParcelHide = false; + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land != null && !land.LandData.SeeAVs) + m_currentParcelHide = true; + if (m_previusParcelUUID != UUID.Zero) + ParcelCrossCheck(); } } } @@ -188,10 +199,7 @@ namespace OpenSim.Region.Framework.Scenes { lock (parcelLock) { - ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); - if (land == null || !land.LandData.SeeAVs) - return false; - return true; + return m_currentParcelHide; } } catch @@ -542,7 +550,6 @@ namespace OpenSim.Region.Framework.Scenes } - public byte State { get; set; } private AgentManager.ControlFlags m_AgentControlFlags; @@ -1071,6 +1078,7 @@ namespace OpenSim.Region.Framework.Scenes // only in use as part of completemovement + // other uses need fix private bool MakeRootAgent(Vector3 pos, bool isFlying) { lock (m_completeMovementLock) @@ -1097,16 +1105,12 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.AddAvatar(UUID); if (part.SitTargetPosition != Vector3.Zero) part.SitTargetAvatar = UUID; - // ParentPosition = part.GetWorldPosition(); ParentID = part.LocalId; ParentPart = part; m_pos = PrevSitOffset; - // pos = ParentPosition; pos = part.GetWorldPosition(); } ParentUUID = UUID.Zero; - - // Animator.TrySetMovementAnimation("SIT"); } else { @@ -1161,7 +1165,7 @@ namespace OpenSim.Region.Framework.Scenes // Moved this from SendInitialData to ensure that Appearance is initialized // before the inventory is processed in MakeRootAgent. This fixes a race condition // related to the handling of attachments - //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); + if (m_scene.TestBorderCross(pos, Cardinals.E)) { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); @@ -1496,7 +1500,7 @@ namespace OpenSim.Region.Framework.Scenes else CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f / 6f)); - ControllingClient.SendAgentTerseUpdate(this); + SendAgentTerseUpdate(this); } /// @@ -1797,6 +1801,9 @@ namespace OpenSim.Region.Framework.Scenes // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); // } + m_currentParcelHide = false; + m_currentParcelUUID = UUID.Zero; + // send initial land overlay and parcel if (!IsChildAgent) { @@ -1807,6 +1814,9 @@ namespace OpenSim.Region.Framework.Scenes } } + m_previusParcelHide = m_currentParcelHide; + m_previusParcelUUID = m_currentParcelUUID; + // send agentData to all clients including us (?) // get appearance // if in cache sent it to all clients @@ -1819,11 +1829,6 @@ namespace OpenSim.Region.Framework.Scenes IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) m_agentTransfer.EnableChildAgents(this); -/* moved down - IFriendsModule friendsModule = m_scene.RequestModuleInterface(); - if (friendsModule != null) - friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); -*/ } // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region @@ -1845,13 +1850,15 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) { -// moved from makeroot missing in sendInitialDataToMe ? +// moved from makeroot missing in sendInitialDataToMe +// its already there +/* m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { if (presence != this) presence.Animator.SendAnimPackToClient(ControllingClient); }); - +*/ if (openChildAgents) { IFriendsModule friendsModule = m_scene.RequestModuleInterface(); @@ -2064,7 +2071,7 @@ namespace OpenSim.Region.Framework.Scenes // We need to send this back to the client in order to stop the edit beams if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None) - ControllingClient.SendAgentTerseUpdate(this); + SendAgentTerseUpdate(this); PhysicsActor actor = PhysicsActor; @@ -2303,7 +2310,7 @@ namespace OpenSim.Region.Framework.Scenes // We need to send this back to the client in order to see the edit beams if ((State & (uint)AgentState.Editing) != 0) - ControllingClient.SendAgentTerseUpdate(this); + SendAgentTerseUpdate(this); m_scene.EventManager.TriggerOnClientMovement(this); } @@ -3230,6 +3237,9 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent == false) { + if (IsInTransit) + return; + // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity @@ -3258,9 +3268,16 @@ namespace OpenSim.Region.Framework.Scenes #region Update Client(s) + // this is diferente from SendTerseUpdateToClient + // this sends bypassing ententies updates + public void SendAgentTerseUpdate(ISceneEntity p) + { + ControllingClient.SendAgentTerseUpdate(p); + } /// /// Sends a location update to the client connected to this scenePresence + /// via entity updates /// /// public void SendTerseUpdateToClient(IClientAPI remoteClient) @@ -3270,7 +3287,6 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient.IsActive) { //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); - remoteClient.SendEntityUpdate( this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity @@ -3280,6 +3296,34 @@ namespace OpenSim.Region.Framework.Scenes } } + public void SendTerseUpdateToAgentClient(ScenePresence p) + { + // messy checks because a client doesn't know what presence it belongs too + if (p.IsChildAgent) + return; + + if (p.IsInTransit) + return; + + IClientAPI remoteClient = p.ControllingClient; + if (remoteClient == null) + return; + + if (!remoteClient.IsActive) + return; + + if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID) + return; + + + //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); + remoteClient.SendEntityUpdate( + this, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + + m_scene.StatsReporter.AddAgentUpdates(1); + } // vars to support reduced update frequency when velocity is unchanged private Vector3 lastVelocitySentToAllClients = Vector3.Zero; @@ -3321,7 +3365,8 @@ namespace OpenSim.Region.Framework.Scenes lastPositionSentToAllClients = OffsetPosition; // Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); - m_scene.ForEachClient(SendTerseUpdateToClient); +// m_scene.ForEachClient(SendTerseUpdateToClient); + m_scene.ForEachScenePresence(SendTerseUpdateToAgentClient); } TriggerScenePresenceUpdated(); } @@ -3389,6 +3434,8 @@ namespace OpenSim.Region.Framework.Scenes if (!cachedappearance) { Appearance.ResetAppearance(); +// save what ???? +// maybe needed so the tryretry repair works? if (m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(UUID); } @@ -3400,10 +3447,13 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); // This invocation always shows up in the viewer logs as an error. Is it needed? - // try to send what we have even if not in cache + // send all information we have + // possible not needed since viewer should ask about it + // least it all ask for baked SendAppearanceToAgent(this); // If we are using the the cached appearance then send it out to everyone + // send even grays if (cachedappearance) { m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); @@ -3432,17 +3482,17 @@ namespace OpenSim.Region.Framework.Scenes } m_lastSize = Appearance.AvatarSize; - int count = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - SendAvatarDataToAgent(scenePresence); - count++; - }); + { + SendAvatarDataToAgent(scenePresence); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } - + /// /// Send avatar data for all other root agents to this agent, this agent /// can be either a child or root @@ -3450,12 +3500,13 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarDataToMe() { int count = 0; + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) return; - + scenePresence.SendAvatarDataToAgent(this); count++; }); @@ -3470,7 +3521,8 @@ namespace OpenSim.Region.Framework.Scenes public void SendAvatarDataToAgent(ScenePresence avatar) { //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); - + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID) + return; avatar.ControllingClient.SendAvatarDataImmediate(this); Animator.SendAnimPackToClient(avatar.ControllingClient); } @@ -3481,7 +3533,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendAppearanceToAllOtherAgents() { -// m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID); + // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID); // only send update from root agents to other clients; children are only "listening posts" if (IsChildAgent) @@ -3492,7 +3544,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - + int count = 0; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { @@ -3503,7 +3555,6 @@ namespace OpenSim.Region.Framework.Scenes SendAppearanceToAgent(scenePresence); count++; }); - m_scene.StatsReporter.AddAgentUpdates(count); } @@ -3537,11 +3588,10 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat( // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); - + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID) + return; avatar.ControllingClient.SendAppearance( - UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); - - + UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); } #endregion @@ -4077,6 +4127,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateMovement() { + if (IsInTransit) + return; if (m_forceToApply.HasValue) { Vector3 force = m_forceToApply.Value; @@ -4155,7 +4207,9 @@ namespace OpenSim.Region.Framework.Scenes { if (IsChildAgent || Animator == null) return; - + + if(IsInTransit) + return; //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene @@ -4503,6 +4557,18 @@ namespace OpenSim.Region.Framework.Scenes return validated; } + + public void SendAttachmentsToClient(IClientAPI client) + { + lock (m_attachments) + { + foreach (SceneObjectGroup gobj in m_attachments) + { + gobj.SendFullUpdateToClient(client); + } + } + } + /// /// Send a script event to this scene presence's attachments /// @@ -5245,5 +5311,137 @@ namespace OpenSim.Region.Framework.Scenes m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); } + + private void ParcelCrossCheck() + { + List killsToSendto = new List(); + List killsToSendme = new List(); + List viewsToSendto = new List(); + List viewsToSendme = new List(); + List allpresences = null; + + if (m_currentParcelHide) + { + // now on a private parcel + allpresences = m_scene.GetScenePresences(); + + if (m_previusParcelHide && m_previusParcelUUID != UUID.Zero) + { + foreach (ScenePresence p in allpresences) + { + if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + // only those on previus parcel need receive kills + if (m_previusParcelUUID == p.currentParcelUUID) + { + killsToSendto.Add(p); // they dont see me + killsToSendme.Add(p); // i dont see them + } + // only those on new parcel need see + if (m_currentParcelUUID == p.currentParcelUUID) + { + viewsToSendto.Add(p); // they see me + viewsToSendme.Add(p); // i see them + } + } + } + else + { + //was on a public area + allpresences = m_scene.GetScenePresences(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + // those not on new parcel dont see me + if (m_currentParcelUUID != p.currentParcelUUID) + { + killsToSendto.Add(p); // they dont see me + } + else + { + viewsToSendme.Add(p); // i see those on it + } + } + } + allpresences.Clear(); + } // now on a private parcel end + + else + { + // now on public parcel + if (m_previusParcelHide && m_previusParcelUUID != UUID.Zero) + { + // was on private area + allpresences = m_scene.GetScenePresences(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + // only those old parcel need receive kills + if (m_previusParcelUUID == p.currentParcelUUID) + { + killsToSendme.Add(p); // i dont see them + } + else + { + viewsToSendto.Add(p); // they see me + } + } + } + else + return; // was on a public area also + } // now on public parcel end + + // send the things + // kill main avatar object + if (killsToSendto.Count > 0) + { + foreach (ScenePresence p in killsToSendto) + { + try { p.ControllingClient.SendKillObject(new List { LocalId }); } + catch (NullReferenceException) { } + } + } + + if (killsToSendme.Count > 0) + { + foreach (ScenePresence p in killsToSendme) + { + try {ControllingClient.SendKillObject(new List { p.LocalId }); } + catch (NullReferenceException) { } + } + } + + if (viewsToSendto.Count > 0) + { + foreach (ScenePresence p in viewsToSendto) + { + p.ControllingClient.SendAvatarDataImmediate(this); + SendAppearanceToAgent(p); + SendAttachmentsToClient(p.ControllingClient); + if (Animator != null) + Animator.SendAnimPackToClient(p.ControllingClient); + } + } + + if (viewsToSendme.Count > 0) + { + foreach (ScenePresence p in viewsToSendme) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } + } + + + } } } -- cgit v1.1 From ef1f37cf20b756e8549305f2d405ea8e9bbda9ff Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 1 Aug 2014 18:59:08 +0100 Subject: handle change of hide avatars flag. Parcel limits edition still need work --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 154 ++++++++++++++--------- 1 file changed, 97 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b8ad78e..ae14af2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -153,15 +153,21 @@ namespace OpenSim.Region.Framework.Scenes { lock (parcelLock) { - m_previusParcelHide = m_currentParcelHide; - m_previusParcelUUID = m_currentParcelUUID; + bool oldhide = m_currentParcelHide; + bool check = true; + if (value != m_currentParcelUUID) + { + m_previusParcelHide = m_currentParcelHide; + m_previusParcelUUID = m_currentParcelUUID; + check = false; + } m_currentParcelUUID = value; m_currentParcelHide = false; ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); if (land != null && !land.LandData.SeeAVs) m_currentParcelHide = true; if (m_previusParcelUUID != UUID.Zero) - ParcelCrossCheck(); + ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,check); } } } @@ -195,17 +201,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - try - { - lock (parcelLock) - { - return m_currentParcelHide; - } - } - catch - { - return false; - } + return m_currentParcelHide; } } @@ -5312,7 +5308,8 @@ namespace OpenSim.Region.Framework.Scenes } - private void ParcelCrossCheck() + private void ParcelCrossCheck(UUID currentParcelUUID,UUID previusParcelUUID, + bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) { List killsToSendto = new List(); List killsToSendme = new List(); @@ -5320,82 +5317,125 @@ namespace OpenSim.Region.Framework.Scenes List viewsToSendme = new List(); List allpresences = null; - if (m_currentParcelHide) + if (check) { - // now on a private parcel + if (currentParcelUUID == null || oldhide == currentParcelHide) + return; + allpresences = m_scene.GetScenePresences(); - if (m_previusParcelHide && m_previusParcelUUID != UUID.Zero) - { + if (oldhide) + { // where private foreach (ScenePresence p in allpresences) { if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - // only those on previus parcel need receive kills - if (m_previusParcelUUID == p.currentParcelUUID) - { - killsToSendto.Add(p); // they dont see me - killsToSendme.Add(p); // i dont see them - } - // only those on new parcel need see - if (m_currentParcelUUID == p.currentParcelUUID) + // those on not on parcel see me + if (currentParcelUUID != p.currentParcelUUID) { viewsToSendto.Add(p); // they see me - viewsToSendme.Add(p); // i see them } } - } - else - { - //was on a public area - allpresences = m_scene.GetScenePresences(); + } // where private end + else + { // where public foreach (ScenePresence p in allpresences) { if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - // those not on new parcel dont see me - if (m_currentParcelUUID != p.currentParcelUUID) + // those not on parcel dont see me + if (currentParcelUUID != p.currentParcelUUID) { killsToSendto.Add(p); // they dont see me } - else - { - viewsToSendme.Add(p); // i see those on it - } } - } - allpresences.Clear(); - } // now on a private parcel end + } // where public end + + allpresences.Clear(); + } else - { - // now on public parcel - if (m_previusParcelHide && m_previusParcelUUID != UUID.Zero) + { + if (currentParcelHide) { - // was on private area + // now on a private parcel allpresences = m_scene.GetScenePresences(); - foreach (ScenePresence p in allpresences) + if (previusParcelHide && previusParcelUUID != UUID.Zero) { - if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - // only those old parcel need receive kills - if (m_previusParcelUUID == p.currentParcelUUID) + foreach (ScenePresence p in allpresences) { - killsToSendme.Add(p); // i dont see them + if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + // only those on previus parcel need receive kills + if (previusParcelUUID == p.currentParcelUUID) + { + killsToSendto.Add(p); // they dont see me + killsToSendme.Add(p); // i dont see them + } + // only those on new parcel need see + if (currentParcelUUID == p.currentParcelUUID) + { + viewsToSendto.Add(p); // they see me + viewsToSendme.Add(p); // i see them + } } - else + } + else + { + //was on a public area + allpresences = m_scene.GetScenePresences(); + + foreach (ScenePresence p in allpresences) { - viewsToSendto.Add(p); // they see me + if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + // those not on new parcel dont see me + if (currentParcelUUID != p.currentParcelUUID) + { + killsToSendto.Add(p); // they dont see me + } + else + { + viewsToSendme.Add(p); // i see those on it + } } } - } + allpresences.Clear(); + } // now on a private parcel end + else - return; // was on a public area also - } // now on public parcel end + { + // now on public parcel + if (previusParcelHide && previusParcelUUID != UUID.Zero) + { + // was on private area + allpresences = m_scene.GetScenePresences(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + // only those old parcel need receive kills + if (previusParcelUUID == p.currentParcelUUID) + { + killsToSendme.Add(p); // i dont see them + } + else + { + viewsToSendto.Add(p); // they see me + } + } + } + else + return; // was on a public area also + } // now on public parcel end + } // send the things // kill main avatar object -- cgit v1.1 From e296f25445ef5d0fc8d114aed6241da664c57b34 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 1 Aug 2014 19:52:55 +0100 Subject: sitting avatars hidding by their position. This is not as SL that uses avatar sitting on root prim. All cases have good and bad situations, this is simpler. Only SOG position changes triggers checks, rotation alone will not. ( as happens in other cases ) (UNTESTED, as usual ) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 36 +++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ba97c47..28758a9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -701,6 +701,11 @@ namespace OpenSim.Region.Framework.Scenes part.GroupPosition = val; } + foreach (ScenePresence av in m_linkedAvatars) + { + av.sitSOGmoved(); + } + // now that position is changed tell it to scripts if (triggerScriptEvent) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ae14af2..494c9e0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -163,6 +163,7 @@ namespace OpenSim.Region.Framework.Scenes } m_currentParcelUUID = value; m_currentParcelHide = false; + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); if (land != null && !land.LandData.SeeAVs) m_currentParcelHide = true; @@ -172,6 +173,23 @@ namespace OpenSim.Region.Framework.Scenes } } + public void sitSOGmoved() + { + if (IsDeleted || !IsSatOnObject) + //what me? nahh + return; + if (IsInTransit) + return; + + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land == null) + return; //?? + UUID parcelID = land.LandData.GlobalID; + if (m_currentParcelUUID != parcelID) + currentParcelUUID = parcelID; + } + + public bool ParcelAllowThisAvatarSounds { get @@ -2707,7 +2725,7 @@ namespace OpenSim.Region.Framework.Scenes if (satOnObject) { - SendAvatarDataToAllAgents(); +// SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; part.RemoveSittingAvatar(UUID); @@ -2719,6 +2737,22 @@ namespace OpenSim.Region.Framework.Scenes AddToPhysicalScene(false); Animator.TrySetMovementAnimation("STAND"); + + if (satOnObject) + { + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X,AbsolutePosition.Y); + if (land != null) + { + UUID parcelID = land.LandData.GlobalID; + if (m_currentParcelUUID != parcelID) + currentParcelUUID = parcelID; + else + SendAvatarDataToAllAgents(); + } + else + SendAvatarDataToAllAgents(); + } + TriggerScenePresenceUpdated(); } -- cgit v1.1 From bdac5058c87c0903df90ed340e3c81d70bbdb682 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 01:21:24 +0100 Subject: remove some ischild tests --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 494c9e0..c3ef314 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5362,7 +5362,7 @@ namespace OpenSim.Region.Framework.Scenes { // where private foreach (ScenePresence p in allpresences) { - if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // those on not on parcel see me @@ -5377,7 +5377,7 @@ namespace OpenSim.Region.Framework.Scenes { // where public foreach (ScenePresence p in allpresences) { - if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // those not on parcel dont see me @@ -5402,7 +5402,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in allpresences) { - if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // only those on previus parcel need receive kills @@ -5426,7 +5426,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in allpresences) { - if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // those not on new parcel dont see me @@ -5453,7 +5453,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in allpresences) { - if (p.IsChildAgent || p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // only those old parcel need receive kills if (previusParcelUUID == p.currentParcelUUID) -- cgit v1.1 From 46add9807125b05f18e36df1bedb738e4d2f45ad Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 01:45:32 +0100 Subject: remove a few more --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c3ef314..2ebcfb4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3329,12 +3329,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendTerseUpdateToAgentClient(ScenePresence p) { // messy checks because a client doesn't know what presence it belongs too - if (p.IsChildAgent) - return; - - if (p.IsInTransit) - return; - + IClientAPI remoteClient = p.ControllingClient; if (remoteClient == null) return; -- cgit v1.1 From c11c4c0daa6342decc293ac51171fffdf412f6d3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 02:26:54 +0100 Subject: add a hide check at end of region arrival --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2ebcfb4..948e040 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1885,6 +1885,10 @@ namespace OpenSim.Region.Framework.Scenes { m_inTransit = false; } + // if hide force a check + if (!IsChildAgent && m_currentParcelHide) + ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, + true, m_previusParcelHide, false, true); } /// @@ -5346,6 +5350,9 @@ namespace OpenSim.Region.Framework.Scenes List viewsToSendme = new List(); List allpresences = null; + if (IsInTransit) + return; + if (check) { if (currentParcelUUID == null || oldhide == currentParcelHide) -- cgit v1.1 From 20eeeba0d2a79fb77257b48b1feeb47101bf3d4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 03:17:39 +0100 Subject: initial state change --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 948e040..62cc28e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1815,6 +1815,8 @@ namespace OpenSim.Region.Framework.Scenes // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); // } + m_previusParcelHide = false; + m_previusParcelUUID = UUID.Zero; m_currentParcelHide = false; m_currentParcelUUID = UUID.Zero; @@ -1828,8 +1830,6 @@ namespace OpenSim.Region.Framework.Scenes } } - m_previusParcelHide = m_currentParcelHide; - m_previusParcelUUID = m_currentParcelUUID; // send agentData to all clients including us (?) // get appearance -- cgit v1.1 From b0864a2f0f46db1656951633b6a9da363bf62c6c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 14:17:00 +0100 Subject: crossing into a hide parcel may work now. Not nice fix.. need get back to this later --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 62cc28e..415dbcd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1737,6 +1737,7 @@ namespace OpenSim.Region.Framework.Scenes client.Name, Scene.Name, AbsolutePosition); m_inTransit = true; + bool newhide = false; try { // Make sure it's not a login agent. We don't want to wait for updates during login @@ -1819,6 +1820,7 @@ namespace OpenSim.Region.Framework.Scenes m_previusParcelUUID = UUID.Zero; m_currentParcelHide = false; m_currentParcelUUID = UUID.Zero; + // send initial land overlay and parcel if (!IsChildAgent) @@ -1827,6 +1829,8 @@ namespace OpenSim.Region.Framework.Scenes if (landch != null) { landch.sendClientInitialLandInfo(client); + newhide = m_currentParcelHide; + m_currentParcelHide = false; } } @@ -1886,7 +1890,7 @@ namespace OpenSim.Region.Framework.Scenes m_inTransit = false; } // if hide force a check - if (!IsChildAgent && m_currentParcelHide) + if (!IsChildAgent && newhide) ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, true, m_previusParcelHide, false, true); } -- cgit v1.1 From 74447d14cda441408419bc90828975cf4b751692 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 18:32:28 +0100 Subject: add some filters for NPCs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 61 +++++++++++++++++------- 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 415dbcd..faaf74c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -88,7 +88,17 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerScenePresenceUpdated(this); } - public PresenceType PresenceType { get; private set; } + public bool isNPC { get; private set; } + + private PresenceType m_presenceType; + public PresenceType PresenceType { + get {return m_presenceType;} + private set + { + m_presenceType = value; + isNPC = (m_presenceType == PresenceType.Npc); + } + } private ScenePresenceStateMachine m_stateMachine; @@ -1258,6 +1268,7 @@ namespace OpenSim.Region.Framework.Scenes // and it has already rezzed the attachments and started their scripts. // We do the following only for non-login agents, because their scripts // haven't started yet. +/* moved down if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { // Viewers which have a current outfit folder will actually rez their own attachments. However, @@ -1273,6 +1284,7 @@ namespace OpenSim.Region.Framework.Scenes }); } else + { // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently @@ -1314,7 +1326,7 @@ namespace OpenSim.Region.Framework.Scenes } } } - +*/ /* SendAvatarDataToAllAgents(); @@ -1741,7 +1753,7 @@ namespace OpenSim.Region.Framework.Scenes try { // Make sure it's not a login agent. We don't want to wait for updates during login - if (PresenceType != PresenceType.Npc && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) + if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) { // Let's wait until UpdateAgent (called by departing region) is done if (!WaitForUpdateAgent(client)) @@ -1820,7 +1832,6 @@ namespace OpenSim.Region.Framework.Scenes m_previusParcelUUID = UUID.Zero; m_currentParcelHide = false; m_currentParcelUUID = UUID.Zero; - // send initial land overlay and parcel if (!IsChildAgent) @@ -1842,28 +1853,48 @@ namespace OpenSim.Region.Framework.Scenes ValidateAndSendAppearanceAndAgentData(); // Create child agents in neighbouring regions - if (openChildAgents && !IsChildAgent) + if (openChildAgents && !IsChildAgent && !isNPC) { IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) m_agentTransfer.EnableChildAgents(this); } - // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region - // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work. - // This may be due to viewer code or it may be something we're not doing properly simulator side. - lock (m_attachments) + + // attachments + if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { - foreach (SceneObjectGroup sog in m_attachments) - sog.ScheduleGroupForFullUpdate(); + if (Scene.AttachmentsModule != null) + Util.FireAndForget( + o => + { + Scene.AttachmentsModule.RezAttachments(this); + }); } + else + { + List attachments = GetAttachments(); + if (attachments.Count > 0) + { + m_log.DebugFormat( + "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? + foreach (SceneObjectGroup sog in attachments) + { + sog.ScheduleGroupForFullUpdate(); + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); + sog.ResumeScripts(); + } + } + } // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); // send the rest of the world - if (m_teleportFlags > 0) + if (m_teleportFlags > 0 && !isNPC) SendInitialDataToMe(); if (!IsChildAgent) @@ -5488,7 +5519,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (killsToSendme.Count > 0) + if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in killsToSendme) { @@ -5509,7 +5540,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (viewsToSendme.Count > 0) + if (viewsToSendme.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in viewsToSendme) { @@ -5520,8 +5551,6 @@ namespace OpenSim.Region.Framework.Scenes p.Animator.SendAnimPackToClient(ControllingClient); } } - - } } } -- cgit v1.1 From 46da95d1b73ebe4a8fe4f27a3b16f46317a403ef Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 19:33:38 +0100 Subject: bug hunt: disable group for npc --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index faaf74c..edaa69c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1149,10 +1149,14 @@ namespace OpenSim.Region.Framework.Scenes // Should not be needed if we are not trying to tell this region to close // DoNotCloseAfterTeleport = false; - IGroupsModule gm = m_scene.RequestModuleInterface(); - if (gm != null) - Grouptitle = gm.GetGroupTitle(m_uuid); + IGroupsModule gm = null; + if (!isNPC) // disable groups ofr NPCs BUG HUNT + { + gm = m_scene.RequestModuleInterface(); + if (gm != null) + Grouptitle = gm.GetGroupTitle(m_uuid); + } RegionHandle = m_scene.RegionInfo.RegionHandle; m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); @@ -1165,6 +1169,7 @@ namespace OpenSim.Region.Framework.Scenes // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status try { + if (gm != null) { groupUUID = ControllingClient.ActiveGroupId; -- cgit v1.1 From 35616339f3a57b27601495aaee9599554f0e779d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 21:01:44 +0100 Subject: remove the groups restrictions for npcs since they do nothing usefull --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index edaa69c..a9a6ba4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -984,7 +984,7 @@ namespace OpenSim.Region.Framework.Scenes IGroupsModule gm = m_scene.RequestModuleInterface(); if (gm != null) - Grouptitle = gm.GetGroupTitle(m_uuid); + Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces(); @@ -1149,14 +1149,10 @@ namespace OpenSim.Region.Framework.Scenes // Should not be needed if we are not trying to tell this region to close // DoNotCloseAfterTeleport = false; - IGroupsModule gm = null; - if (!isNPC) // disable groups ofr NPCs BUG HUNT - { - - gm = m_scene.RequestModuleInterface(); - if (gm != null) - Grouptitle = gm.GetGroupTitle(m_uuid); - } + IGroupsModule gm = m_scene.RequestModuleInterface(); + if (gm != null) + Grouptitle = gm.GetGroupTitle(m_uuid); + RegionHandle = m_scene.RegionInfo.RegionHandle; m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); @@ -1858,7 +1854,7 @@ namespace OpenSim.Region.Framework.Scenes ValidateAndSendAppearanceAndAgentData(); // Create child agents in neighbouring regions - if (openChildAgents && !IsChildAgent && !isNPC) + if (openChildAgents && !IsChildAgent) { IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) -- cgit v1.1 From 580604c231a77ab25b49dbbb3e209780ad1bfc4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 22:32:51 +0100 Subject: let gods see hidden avatars ( test ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a9a6ba4..3bdfb32 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3377,7 +3377,7 @@ namespace OpenSim.Region.Framework.Scenes if (!remoteClient.IsActive) return; - if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID) + if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) return; @@ -3586,7 +3586,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAvatarDataToAgent(ScenePresence avatar) { //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); - if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID) + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) return; avatar.ControllingClient.SendAvatarDataImmediate(this); Animator.SendAnimPackToClient(avatar.ControllingClient); @@ -3653,7 +3653,7 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat( // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); - if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID) + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) return; avatar.ControllingClient.SendAppearance( UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); @@ -3947,6 +3947,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) { + int oldgodlevel = GodLevel; + if (godStatus) { // For now, assign god level 200 to anyone @@ -3967,6 +3969,10 @@ namespace OpenSim.Region.Framework.Scenes } ControllingClient.SendAdminResponse(token, (uint)GodLevel); + + if(oldgodlevel != GodLevel) // force a visibility check + ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, + true, m_previusParcelHide, false, true); } #region Child Agent Updates @@ -5404,7 +5410,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those on not on parcel see me - if (currentParcelUUID != p.currentParcelUUID) + if (currentParcelUUID != p.currentParcelUUID || p.GodLevel >= 200) { viewsToSendto.Add(p); // they see me } @@ -5419,7 +5425,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on parcel dont see me - if (currentParcelUUID != p.currentParcelUUID) + if (currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) { killsToSendto.Add(p); // they dont see me } @@ -5444,13 +5450,13 @@ namespace OpenSim.Region.Framework.Scenes continue; // only those on previus parcel need receive kills - if (previusParcelUUID == p.currentParcelUUID) + if (previusParcelUUID == p.currentParcelUUID && p.GodLevel < 200) { killsToSendto.Add(p); // they dont see me killsToSendme.Add(p); // i dont see them } // only those on new parcel need see - if (currentParcelUUID == p.currentParcelUUID) + if (currentParcelUUID == p.currentParcelUUID || p.GodLevel >= 200) { viewsToSendto.Add(p); // they see me viewsToSendme.Add(p); // i see them @@ -5468,7 +5474,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on new parcel dont see me - if (currentParcelUUID != p.currentParcelUUID) + if (currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) { killsToSendto.Add(p); // they dont see me } @@ -5494,7 +5500,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // only those old parcel need receive kills - if (previusParcelUUID == p.currentParcelUUID) + if (previusParcelUUID == p.currentParcelUUID && p.GodLevel < 200) { killsToSendme.Add(p); // i dont see them } -- cgit v1.1 From e87f70e277e78fb37100b2750fcb09b3aacb1734 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 22:45:28 +0100 Subject: god also read local chat --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3bdfb32..5327b82 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3972,7 +3972,7 @@ namespace OpenSim.Region.Framework.Scenes if(oldgodlevel != GodLevel) // force a visibility check ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, - true, m_previusParcelHide, false, true); + m_currentParcelHide , m_previusParcelHide, false, true); } #region Child Agent Updates -- cgit v1.1 From 009e8ee76c23c8ba796d48a99e224c06f8c8e1d8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 23:04:18 +0100 Subject: testing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5327b82..2b7c702 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3972,7 +3972,7 @@ namespace OpenSim.Region.Framework.Scenes if(oldgodlevel != GodLevel) // force a visibility check ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, - m_currentParcelHide , m_previusParcelHide, false, true); + !m_currentParcelHide, m_previusParcelHide, m_currentParcelHide, true); } #region Child Agent Updates @@ -5402,7 +5402,21 @@ namespace OpenSim.Region.Framework.Scenes allpresences = m_scene.GetScenePresences(); - if (oldhide) + if (GodLevel >= 200) + { + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + if (p.ParcelHideThisAvatar) + { + viewsToSendto.Add(p); // they see me + } + } + } + + else if (oldhide) { // where private foreach (ScenePresence p in allpresences) { -- cgit v1.1 From addca0737c10ee813f89e0417f53b22468d39cd1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 2 Aug 2014 23:38:18 +0100 Subject: testing... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 87 ++++++++++++++++++------ 1 file changed, 67 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2b7c702..f3b5a54 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3970,9 +3970,8 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAdminResponse(token, (uint)GodLevel); - if(oldgodlevel != GodLevel) // force a visibility check - ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, - !m_currentParcelHide, m_previusParcelHide, m_currentParcelHide, true); + if(oldgodlevel != GodLevel) + parcelGodCheck(m_currentParcelUUID, GodLevel >= 200); } #region Child Agent Updates @@ -5383,6 +5382,68 @@ namespace OpenSim.Region.Framework.Scenes } + private void parcelGodCheck(UUID currentParcelUUID, bool isGod) + { + List allpresences = null; + + + allpresences = m_scene.GetScenePresences(); + + if (isGod) + { + List viewsToSendme = new List(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID) + { + viewsToSendme.Add(p); // i see them + } + } + + if (viewsToSendme.Count > 0) + { + foreach (ScenePresence p in viewsToSendme) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } + } + } + else + { + List killsToSendme = new List(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID) + { + killsToSendme.Add(p); + } + } + + if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + { + foreach (ScenePresence p in killsToSendme) + { + try { ControllingClient.SendKillObject(new List { p.LocalId }); } + catch (NullReferenceException) { } + } + } + } + + } + + private void ParcelCrossCheck(UUID currentParcelUUID,UUID previusParcelUUID, bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) { @@ -5397,26 +5458,13 @@ namespace OpenSim.Region.Framework.Scenes if (check) { + // check is relative to current parcel only if (currentParcelUUID == null || oldhide == currentParcelHide) return; allpresences = m_scene.GetScenePresences(); - if (GodLevel >= 200) - { - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (p.ParcelHideThisAvatar) - { - viewsToSendto.Add(p); // they see me - } - } - } - - else if (oldhide) + if (oldhide) { // where private foreach (ScenePresence p in allpresences) { @@ -5424,7 +5472,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those on not on parcel see me - if (currentParcelUUID != p.currentParcelUUID || p.GodLevel >= 200) + if (currentParcelUUID != p.currentParcelUUID) { viewsToSendto.Add(p); // they see me } @@ -5446,7 +5494,6 @@ namespace OpenSim.Region.Framework.Scenes } } // where public end - allpresences.Clear(); } else -- cgit v1.1 From 9f5e19127d79a8790c31e80a4c6ae8d04d79d6ac Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 00:22:21 +0100 Subject: comment out a debug msg. more on gods being Gods --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f3b5a54..4faad98 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -164,12 +164,12 @@ namespace OpenSim.Region.Framework.Scenes lock (parcelLock) { bool oldhide = m_currentParcelHide; - bool check = true; + bool checksame = true; if (value != m_currentParcelUUID) { m_previusParcelHide = m_currentParcelHide; m_previusParcelUUID = m_currentParcelUUID; - check = false; + checksame = false; } m_currentParcelUUID = value; m_currentParcelHide = false; @@ -177,8 +177,9 @@ namespace OpenSim.Region.Framework.Scenes ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); if (land != null && !land.LandData.SeeAVs) m_currentParcelHide = true; + if (m_previusParcelUUID != UUID.Zero) - ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,check); + ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,checksame); } } } @@ -1923,8 +1924,11 @@ namespace OpenSim.Region.Framework.Scenes } // if hide force a check if (!IsChildAgent && newhide) + { ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, true, m_previusParcelHide, false, true); + m_currentParcelHide = newhide; + } } /// @@ -5511,13 +5515,15 @@ namespace OpenSim.Region.Framework.Scenes continue; // only those on previus parcel need receive kills - if (previusParcelUUID == p.currentParcelUUID && p.GodLevel < 200) + if (previusParcelUUID == p.currentParcelUUID) { - killsToSendto.Add(p); // they dont see me - killsToSendme.Add(p); // i dont see them + if(p.GodLevel < 200) + killsToSendto.Add(p); // they dont see me + if(GodLevel < 200) + killsToSendme.Add(p); // i dont see them } // only those on new parcel need see - if (currentParcelUUID == p.currentParcelUUID || p.GodLevel >= 200) + if (currentParcelUUID == p.currentParcelUUID) { viewsToSendto.Add(p); // they see me viewsToSendme.Add(p); // i see them @@ -5561,7 +5567,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // only those old parcel need receive kills - if (previusParcelUUID == p.currentParcelUUID && p.GodLevel < 200) + if (previusParcelUUID == p.currentParcelUUID && GodLevel < 200) { killsToSendme.Add(p); // i dont see them } -- cgit v1.1 From 53e95803a554b35305b4931d26b4a15dd422e2d5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 01:20:34 +0100 Subject: test not rezzing attachments on a FireAndForget --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4faad98..e1d0fb4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1854,24 +1854,15 @@ namespace OpenSim.Region.Framework.Scenes // send what we have to us, even if not in cache ( bad? ) ValidateAndSendAppearanceAndAgentData(); - // Create child agents in neighbouring regions - if (openChildAgents && !IsChildAgent) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); - } - - // attachments if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { - if (Scene.AttachmentsModule != null) - Util.FireAndForget( - o => - { +// if (Scene.AttachmentsModule != null) +// Util.FireAndForget( +// o => +// { Scene.AttachmentsModule.RezAttachments(this); - }); +// }); } else { @@ -1895,6 +1886,14 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); + // Create child agents in neighbouring regions + if (openChildAgents && !IsChildAgent) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); + } + // send the rest of the world if (m_teleportFlags > 0 && !isNPC) SendInitialDataToMe(); -- cgit v1.1 From b9443b186ede80bb74e2d3b5e095d13b183ef670 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 02:09:07 +0100 Subject: test... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 76 +++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e1d0fb4..eec1b21 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1924,8 +1924,7 @@ namespace OpenSim.Region.Framework.Scenes // if hide force a check if (!IsChildAgent && newhide) { - ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, - true, m_previusParcelHide, false, true); + ParcelLoginCheck(m_currentParcelUUID); m_currentParcelHide = newhide; } } @@ -5446,6 +5445,79 @@ namespace OpenSim.Region.Framework.Scenes } + private void ParcelLoginCheck(UUID currentParcelUUID) + { + List killsToSendto = new List(); + List killsToSendme = new List(); + List viewsToSendto = new List(); + List viewsToSendme = new List(); + List allpresences = null; + + allpresences = m_scene.GetScenePresences(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + // those not on parcel dont see me + if (currentParcelUUID != p.currentParcelUUID) + { + if (p.GodLevel < 200) + killsToSendto.Add(p); // they dont see me + } + else + { + viewsToSendto.Add(p); + viewsToSendme.Add(p); + } + } + allpresences.Clear(); + + // send the things + // kill main avatar object + if (killsToSendto.Count > 0) + { + foreach (ScenePresence p in killsToSendto) + { + try { p.ControllingClient.SendKillObject(new List { LocalId }); } + catch (NullReferenceException) { } + } + } + + if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + { + foreach (ScenePresence p in killsToSendme) + { + try { ControllingClient.SendKillObject(new List { p.LocalId }); } + catch (NullReferenceException) { } + } + } + + if (viewsToSendto.Count > 0) + { + foreach (ScenePresence p in viewsToSendto) + { + p.ControllingClient.SendAvatarDataImmediate(this); + SendAppearanceToAgent(p); + SendAttachmentsToClient(p.ControllingClient); + if (Animator != null) + Animator.SendAnimPackToClient(p.ControllingClient); + } + } + + if (viewsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + { + foreach (ScenePresence p in viewsToSendme) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } + } + } private void ParcelCrossCheck(UUID currentParcelUUID,UUID previusParcelUUID, bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) -- cgit v1.1 From cc16fe68ccf64102f1eea718d42234639a5725f3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 02:26:39 +0100 Subject: .... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index eec1b21..61f66d9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5459,12 +5459,13 @@ namespace OpenSim.Region.Framework.Scenes { if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - - // those not on parcel dont see me + if (currentParcelUUID != p.currentParcelUUID) { if (p.GodLevel < 200) - killsToSendto.Add(p); // they dont see me + killsToSendto.Add(p); + if (GodLevel < 200 && p.ParcelHideThisAvatar) + killsToSendme.Add(p); } else { -- cgit v1.1 From bcab663ad7b6495dc63a6dae46f939d530284cc0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 06:16:30 +0100 Subject: debug... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 135 ++++++++++++++++++----- 1 file changed, 110 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 61f66d9..7b0b103 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3868,14 +3868,21 @@ namespace OpenSim.Region.Framework.Scenes /// protected bool CrossToNewRegion() { + bool result = false; + parcelRegionCross(false); try { - return m_scene.CrossAgentToNewRegion(this, Flying); + result = m_scene.CrossAgentToNewRegion(this, Flying); } catch { - return m_scene.CrossAgentToNewRegion(this, false); + result = m_scene.CrossAgentToNewRegion(this, false); } + if(!result) + parcelRegionCross(true); + + return result; + } public void Reset() @@ -5384,7 +5391,7 @@ namespace OpenSim.Region.Framework.Scenes } - private void parcelGodCheck(UUID currentParcelUUID, bool isGod) + private void parcelGodCheck(UUID currentParcelID, bool isGod) { List allpresences = null; @@ -5400,7 +5407,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID) + if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) { viewsToSendme.Add(p); // i see them } @@ -5410,6 +5417,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendme) { + m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5427,16 +5435,17 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID) + if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) { killsToSendme.Add(p); } } - if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + if (killsToSendme.Count > 0) { foreach (ScenePresence p in killsToSendme) { + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5445,7 +5454,7 @@ namespace OpenSim.Region.Framework.Scenes } - private void ParcelLoginCheck(UUID currentParcelUUID) + private void ParcelLoginCheck(UUID currentParcelID) { List killsToSendto = new List(); List killsToSendme = new List(); @@ -5460,7 +5469,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - if (currentParcelUUID != p.currentParcelUUID) + if (currentParcelID != p.currentParcelUUID) { if (p.GodLevel < 200) killsToSendto.Add(p); @@ -5477,28 +5486,31 @@ namespace OpenSim.Region.Framework.Scenes // send the things // kill main avatar object - if (killsToSendto.Count > 0) + if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in killsToSendto) { + m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); try { p.ControllingClient.SendKillObject(new List { LocalId }); } catch (NullReferenceException) { } } } - if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + if (killsToSendme.Count > 0) { foreach (ScenePresence p in killsToSendme) { + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } } - if (viewsToSendto.Count > 0) + if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in viewsToSendto) { + m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); p.ControllingClient.SendAvatarDataImmediate(this); SendAppearanceToAgent(p); SendAttachmentsToClient(p.ControllingClient); @@ -5507,10 +5519,11 @@ namespace OpenSim.Region.Framework.Scenes } } - if (viewsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + if (viewsToSendme.Count > 0) { foreach (ScenePresence p in viewsToSendme) { + m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5520,7 +5533,74 @@ namespace OpenSim.Region.Framework.Scenes } } - private void ParcelCrossCheck(UUID currentParcelUUID,UUID previusParcelUUID, + private void parcelRegionCross(bool abort) + { + if (!ParcelHideThisAvatar) + return; + + List allpresences = null; + allpresences = m_scene.GetScenePresences(); + + if (abort) + { + + List viewsToSendme = new List(); + + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + if (p.currentParcelUUID == m_currentParcelUUID) + { + viewsToSendme.Add(p); + } + } + + if (viewsToSendme.Count > 0) + { + foreach (ScenePresence p in viewsToSendme) + { + m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } + } + } + else + { + if (GodLevel >= 200) + return; + + List killsToSendme = new List(); + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + + if (p.currentParcelUUID == m_currentParcelUUID) + { + killsToSendme.Add(p); + } + } + + if (killsToSendme.Count > 0) + { + foreach (ScenePresence p in killsToSendme) + { + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + try { ControllingClient.SendKillObject(new List { p.LocalId }); } + catch (NullReferenceException) { } + } + } + } + } + + + private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) { List killsToSendto = new List(); @@ -5548,8 +5628,9 @@ namespace OpenSim.Region.Framework.Scenes continue; // those on not on parcel see me - if (currentParcelUUID != p.currentParcelUUID) + if (currentParcelID != p.currentParcelUUID) { + m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); viewsToSendto.Add(p); // they see me } } @@ -5563,7 +5644,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on parcel dont see me - if (currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) { killsToSendto.Add(p); // they dont see me } @@ -5579,7 +5660,7 @@ namespace OpenSim.Region.Framework.Scenes // now on a private parcel allpresences = m_scene.GetScenePresences(); - if (previusParcelHide && previusParcelUUID != UUID.Zero) + if (previusParcelHide && previusParcelID != UUID.Zero) { foreach (ScenePresence p in allpresences) { @@ -5587,7 +5668,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // only those on previus parcel need receive kills - if (previusParcelUUID == p.currentParcelUUID) + if (previusParcelID == p.currentParcelUUID) { if(p.GodLevel < 200) killsToSendto.Add(p); // they dont see me @@ -5595,7 +5676,7 @@ namespace OpenSim.Region.Framework.Scenes killsToSendme.Add(p); // i dont see them } // only those on new parcel need see - if (currentParcelUUID == p.currentParcelUUID) + if (currentParcelID == p.currentParcelUUID) { viewsToSendto.Add(p); // they see me viewsToSendme.Add(p); // i see them @@ -5613,7 +5694,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on new parcel dont see me - if (currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) { killsToSendto.Add(p); // they dont see me } @@ -5629,7 +5710,7 @@ namespace OpenSim.Region.Framework.Scenes else { // now on public parcel - if (previusParcelHide && previusParcelUUID != UUID.Zero) + if (previusParcelHide && previusParcelID != UUID.Zero) { // was on private area allpresences = m_scene.GetScenePresences(); @@ -5639,7 +5720,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // only those old parcel need receive kills - if (previusParcelUUID == p.currentParcelUUID && GodLevel < 200) + if (previusParcelID == p.currentParcelUUID && GodLevel < 200) { killsToSendme.Add(p); // i dont see them } @@ -5656,28 +5737,31 @@ namespace OpenSim.Region.Framework.Scenes // send the things // kill main avatar object - if (killsToSendto.Count > 0) + if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in killsToSendto) { + m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); try { p.ControllingClient.SendKillObject(new List { LocalId }); } catch (NullReferenceException) { } } } - if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + if (killsToSendme.Count > 0 ) { foreach (ScenePresence p in killsToSendme) { + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try {ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } } - if (viewsToSendto.Count > 0) + if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in viewsToSendto) { + m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); p.ControllingClient.SendAvatarDataImmediate(this); SendAppearanceToAgent(p); SendAttachmentsToClient(p.ControllingClient); @@ -5686,10 +5770,11 @@ namespace OpenSim.Region.Framework.Scenes } } - if (viewsToSendme.Count > 0 && PresenceType != PresenceType.Npc) + if (viewsToSendme.Count > 0 ) { foreach (ScenePresence p in viewsToSendme) { + m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); -- cgit v1.1 From ed4787419774d20110f10eff918f5a304819cb09 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 18:22:00 +0100 Subject: several debug msgs, need to be removed asap --- OpenSim/Region/Framework/Scenes/EventManager.cs | 5 +++++ OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7f06e82..182c3fd 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -1366,7 +1366,9 @@ namespace OpenSim.Region.Framework.Scenes { try { + m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate: {0}",d.Target.ToString()); d(agentId); + m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate done "); } catch (Exception e) { @@ -2037,7 +2039,10 @@ namespace OpenSim.Region.Framework.Scenes { try { + m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed: {0}", d.Target.ToString()); d(ClientID, scene); + m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed done "); + } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0765b3f..c53f7af 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3640,13 +3640,17 @@ namespace OpenSim.Region.Framework.Scenes } m_eventManager.TriggerClientClosed(agentID, this); + m_log.Debug("[Scene]TriggerClientClosed done"); m_eventManager.TriggerOnRemovePresence(agentID); + m_log.Debug("[Scene]TriggerOnRemovePresence done"); if (!isChildAgent) { if (AttachmentsModule != null) { + m_log.Debug("[Scene]DeRezAttachments"); AttachmentsModule.DeRezAttachments(avatar); + m_log.Debug("[Scene]DeRezAttachments done"); } ForEachClient( @@ -3660,7 +3664,10 @@ namespace OpenSim.Region.Framework.Scenes // It's possible for child agents to have transactions if changes are being made cross-border. if (AgentTransactionsModule != null) + { + m_log.Debug("[Scene]RemoveAgentAssetTransactions"); AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); + } m_log.Debug("[Scene] The avatar has left the building"); } catch (Exception e) -- cgit v1.1 From ca8b0e6a1d373b55137febaafd2797e59016d5a8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 19:00:01 +0100 Subject: replace debug msgs by others --- OpenSim/Region/Framework/Scenes/EventManager.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 182c3fd..692e0c9 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -1366,9 +1366,9 @@ namespace OpenSim.Region.Framework.Scenes { try { - m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate: {0}",d.Target.ToString()); +// m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate: {0}",d.Target.ToString()); d(agentId); - m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate done "); +// m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate done "); } catch (Exception e) { @@ -2039,9 +2039,9 @@ namespace OpenSim.Region.Framework.Scenes { try { - m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed: {0}", d.Target.ToString()); +// m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed: {0}", d.Target.ToString()); d(ClientID, scene); - m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed done "); +// m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed done "); } catch (Exception e) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c53f7af..0266faf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3640,17 +3640,17 @@ namespace OpenSim.Region.Framework.Scenes } m_eventManager.TriggerClientClosed(agentID, this); - m_log.Debug("[Scene]TriggerClientClosed done"); +// m_log.Debug("[Scene]TriggerClientClosed done"); m_eventManager.TriggerOnRemovePresence(agentID); - m_log.Debug("[Scene]TriggerOnRemovePresence done"); +// m_log.Debug("[Scene]TriggerOnRemovePresence done"); if (!isChildAgent) { if (AttachmentsModule != null) { - m_log.Debug("[Scene]DeRezAttachments"); +// m_log.Debug("[Scene]DeRezAttachments"); AttachmentsModule.DeRezAttachments(avatar); - m_log.Debug("[Scene]DeRezAttachments done"); +// m_log.Debug("[Scene]DeRezAttachments done"); } ForEachClient( @@ -3665,7 +3665,7 @@ namespace OpenSim.Region.Framework.Scenes // It's possible for child agents to have transactions if changes are being made cross-border. if (AgentTransactionsModule != null) { - m_log.Debug("[Scene]RemoveAgentAssetTransactions"); +// m_log.Debug("[Scene]RemoveAgentAssetTransactions"); AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); } m_log.Debug("[Scene] The avatar has left the building"); -- cgit v1.1 From 0d71a2bb8fe90bfaaae4e62d921dbf94e69064b4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 22:38:50 +0100 Subject: mess update ( hide avatars ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 60 ++++++++++++++---------- 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7b0b103..03eac77 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -178,7 +178,7 @@ namespace OpenSim.Region.Framework.Scenes if (land != null && !land.LandData.SeeAVs) m_currentParcelHide = true; - if (m_previusParcelUUID != UUID.Zero) + if (m_previusParcelUUID != UUID.Zero || checksame) ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,checksame); } } @@ -1847,7 +1847,6 @@ namespace OpenSim.Region.Framework.Scenes } } - // send agentData to all clients including us (?) // get appearance // if in cache sent it to all clients @@ -1857,7 +1856,7 @@ namespace OpenSim.Region.Framework.Scenes // attachments if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { -// if (Scene.AttachmentsModule != null) + if (Scene.AttachmentsModule != null) // Util.FireAndForget( // o => // { @@ -5418,11 +5417,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in viewsToSendme) { m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); + if (!p.IsChildAgent) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } } } } @@ -5524,11 +5526,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in viewsToSendme) { m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); + if (!p.IsChildAgent) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } } } } @@ -5562,11 +5567,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in viewsToSendme) { m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); + if (!p.IsChildAgent) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } } } } @@ -5629,8 +5637,7 @@ namespace OpenSim.Region.Framework.Scenes // those on not on parcel see me if (currentParcelID != p.currentParcelUUID) - { - m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); + { viewsToSendto.Add(p); // they see me } } @@ -5775,11 +5782,14 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in viewsToSendme) { m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); + if (!p.IsChildAgent) + { + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); + } } } } -- cgit v1.1 From bad01fbb418e8df5caa2735bf62ec41f8b378f10 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 22:57:08 +0100 Subject: some mess cleanup --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 75 +++++++++++------------- 1 file changed, 35 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 03eac77..8d254f2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1836,12 +1836,12 @@ namespace OpenSim.Region.Framework.Scenes m_currentParcelUUID = UUID.Zero; // send initial land overlay and parcel - if (!IsChildAgent) + ILandChannel landch = m_scene.LandChannel; + if (landch != null) { - ILandChannel landch = m_scene.LandChannel; - if (landch != null) + landch.sendClientInitialLandInfo(client); + if (!IsChildAgent) { - landch.sendClientInitialLandInfo(client); newhide = m_currentParcelHide; m_currentParcelHide = false; } @@ -5416,15 +5416,14 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendme) { + if (p.IsChildAgent) + continue; m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); - if (!p.IsChildAgent) - { - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - } + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); } } } @@ -5526,14 +5525,13 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in viewsToSendme) { m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - if (!p.IsChildAgent) - { - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - } + if (p.IsChildAgent) + continue; + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); } } } @@ -5548,7 +5546,6 @@ namespace OpenSim.Region.Framework.Scenes if (abort) { - List viewsToSendme = new List(); foreach (ScenePresence p in allpresences) @@ -5566,15 +5563,14 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendme) { - m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - if (!p.IsChildAgent) - { - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - } + if (p.IsChildAgent) + continue; +// m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); } } } @@ -5768,8 +5764,8 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendto) { - m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); p.ControllingClient.SendAvatarDataImmediate(this); +// m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); SendAppearanceToAgent(p); SendAttachmentsToClient(p.ControllingClient); if (Animator != null) @@ -5781,15 +5777,14 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendme) { - m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - if (!p.IsChildAgent) - { - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - } + if (p.IsChildAgent) + continue; +// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); + ControllingClient.SendAvatarDataImmediate(p); + p.SendAppearanceToAgent(this); + p.SendAttachmentsToClient(ControllingClient); + if (p.Animator != null) + p.Animator.SendAnimPackToClient(ControllingClient); } } } -- cgit v1.1 From b07b0ff555ee0d930e350ba56bcb389543d22e06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 4 Aug 2014 00:16:56 +0100 Subject: missing child login parcel overlay --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8d254f2..24a92eb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3465,6 +3465,14 @@ namespace OpenSim.Region.Framework.Scenes // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) + if (m_teleportFlags <= 0) + { + ILandChannel landch = m_scene.LandChannel; + if (landch != null) + { + landch.sendClientInitialLandInfo(ControllingClient); + } + } SendOtherAgentsAvatarDataToMe(); SendOtherAgentsAppearanceToMe(); -- cgit v1.1 From 05a2feba5d780c57c252891a20071800fd9f2e3e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 4 Aug 2014 19:57:47 +0100 Subject: start sending terrain in scenePresence after well defined avatar. Minor change on significante AgentUpdate check. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 1160 +++++++++++----------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +- 3 files changed, 592 insertions(+), 591 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0266faf..ec54e15 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3179,7 +3179,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientTerrainEvents(IClientAPI client) { - client.OnRegionHandShakeReply += SendLayerData; +// client.OnRegionHandShakeReply += SendLayerData; } public virtual void SubscribeToClientPrimEvents(IClientAPI client) @@ -3307,7 +3307,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) { - client.OnRegionHandShakeReply -= SendLayerData; +// client.OnRegionHandShakeReply -= SendLayerData; } public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 08e26c5..6adccca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -1,581 +1,581 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using OpenMetaverse; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; - -using OpenSim.Region.Framework.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Region.Framework.Scenes -{ - public abstract class SceneBase : IScene - { +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using OpenMetaverse; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Console; + +using OpenSim.Region.Framework.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.Framework.Scenes +{ + public abstract class SceneBase : IScene + { protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static readonly string LogHeader = "[SCENE]"; - - #region Events - - public event restart OnRestart; - - #endregion - - #region Fields - - public string Name { get { return RegionInfo.RegionName; } } - - public IConfigSource Config - { - get { return GetConfig(); } - } - - protected virtual IConfigSource GetConfig() - { - return null; - } - - /// - /// All the region modules attached to this scene. - /// - public Dictionary RegionModules - { - get { return m_regionModules; } - } - private Dictionary m_regionModules = new Dictionary(); - - /// - /// The module interfaces available from this scene. - /// - protected Dictionary> ModuleInterfaces = new Dictionary>(); - - protected Dictionary ModuleAPIMethods = new Dictionary(); - - /// - /// The module commanders available from this scene - /// - protected Dictionary m_moduleCommanders = new Dictionary(); - - /// - /// Registered classes that are capable of creating entities. - /// - protected Dictionary m_entityCreators = new Dictionary(); - - /// - /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is - /// dispensed. - /// - protected uint m_lastAllocatedLocalId = 720000; - - private readonly Mutex _primAllocateMutex = new Mutex(false); - - protected readonly ClientManager m_clientManager = new ClientManager(); - - public bool LoginsEnabled - { - get - { - return m_loginsEnabled; - } - - set - { - if (m_loginsEnabled != value) - { - m_loginsEnabled = value; - EventManager.TriggerRegionLoginsStatusChange(this); - } - } - } - private bool m_loginsEnabled; - - public bool Ready - { - get - { - return m_ready; - } - - set - { - if (m_ready != value) - { - m_ready = value; - EventManager.TriggerRegionReadyStatusChange(this); - } - } - } - private bool m_ready; - - public float TimeDilation - { - get { return 1.0f; } - } - - protected ulong m_regionHandle; - protected string m_regionName; - - public ITerrainChannel Heightmap; - - /// - /// Allows retrieval of land information for this scene. - /// - public ILandChannel LandChannel; - - /// - /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules - /// to subscribe to scene events. - /// - public EventManager EventManager - { - get { return m_eventManager; } - } - protected EventManager m_eventManager; - - protected ScenePermissions m_permissions; - public ScenePermissions Permissions - { - get { return m_permissions; } - } - - protected string m_datastore; - - /* Used by the loadbalancer plugin on GForge */ - protected RegionStatus m_regStatus; - public RegionStatus RegionStatus - { - get { return m_regStatus; } - set { m_regStatus = value; } - } - - #endregion - - public SceneBase(RegionInfo regInfo) - { - RegionInfo = regInfo; - } - - #region Update Methods - - /// - /// Called to update the scene loop by a number of frames and until shutdown. - /// - /// - /// Number of frames to update. Exits on shutdown even if there are frames remaining. - /// If -1 then updates until shutdown. - /// - public abstract void Update(int frames); - - #endregion - - #region Terrain Methods - - /// - /// Loads the World heightmap - /// - public abstract void LoadWorldMap(); - - /// - /// Send the region heightmap to the client - /// - /// Client to send to - public virtual void SendLayerData(IClientAPI RemoteClient) - { - RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); - } - - #endregion - - #region Add/Remove Agent/Avatar - - public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); - - public abstract bool CloseAgent(UUID agentID, bool force); - - public bool TryGetScenePresence(UUID agentID, out object scenePresence) - { - scenePresence = null; - ScenePresence sp = null; - if (TryGetScenePresence(agentID, out sp)) - { - scenePresence = sp; - return true; - } - - return false; - } - - /// - /// Try to get a scene presence from the scene - /// - /// - /// null if there is no scene presence with the given agent id - /// true if there was a scene presence with the given id, false otherwise. - public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); - - #endregion - - /// - /// - /// - /// - public virtual RegionInfo RegionInfo { get; private set; } - - #region admin stuff - - public abstract void OtherRegionUp(GridRegion otherRegion); - - public virtual string GetSimulatorVersion() - { - return "OpenSimulator Server"; - } - - #endregion - - #region Shutdown - - /// - /// Tidy before shutdown - /// - public virtual void Close() - { - try - { - EventManager.TriggerShutdown(); - } - catch (Exception e) - { - m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); - } - } - - #endregion - - /// - /// Returns a new unallocated local ID - /// - /// A brand new local ID - public uint AllocateLocalId() - { - uint myID; - - _primAllocateMutex.WaitOne(); - myID = ++m_lastAllocatedLocalId; - _primAllocateMutex.ReleaseMutex(); - - return myID; - } - - #region Module Methods - - /// - /// Add a region-module to this scene. TODO: This will replace AddModule in the future. - /// - /// - /// - public void AddRegionModule(string name, IRegionModuleBase module) - { - if (!RegionModules.ContainsKey(name)) - { - RegionModules.Add(name, module); - } - } - - public void RemoveRegionModule(string name) - { - RegionModules.Remove(name); - } - - /// - /// Register a module commander. - /// - /// - public void RegisterModuleCommander(ICommander commander) - { - lock (m_moduleCommanders) - { - m_moduleCommanders.Add(commander.Name, commander); - } - } - - /// - /// Unregister a module commander and all its commands - /// - /// - public void UnregisterModuleCommander(string name) - { - lock (m_moduleCommanders) - { - ICommander commander; - if (m_moduleCommanders.TryGetValue(name, out commander)) - m_moduleCommanders.Remove(name); - } - } - - /// - /// Get a module commander - /// - /// - /// The module commander, null if no module commander with that name was found - public ICommander GetCommander(string name) - { - lock (m_moduleCommanders) - { - if (m_moduleCommanders.ContainsKey(name)) - return m_moduleCommanders[name]; - } - - return null; - } - - public Dictionary GetCommanders() - { - return m_moduleCommanders; - } - - /// - /// Register an interface to a region module. This allows module methods to be called directly as - /// well as via events. If there is already a module registered for this interface, it is not replaced - /// (is this the best behaviour?) - /// - /// - public void RegisterModuleInterface(M mod) - { -// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); - - List l = null; - if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) - { - l = new List(); - ModuleInterfaces.Add(typeof(M), l); - } - - if (l.Count > 0) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - } - - public void UnregisterModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.TryGetValue(typeof(M), out l)) - { - if (l.Remove(mod)) - { - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = null; - } - } - } - } - } - - public void StackModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.ContainsKey(typeof(M))) - l = ModuleInterfaces[typeof(M)]; - else - l = new List(); - - if (l.Contains(mod)) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - - ModuleInterfaces[typeof(M)] = l; - } - - /// - /// For the given interface, retrieve the region module which implements it. - /// - /// null if there is no registered module implementing that interface - public T RequestModuleInterface() - { - if (ModuleInterfaces.ContainsKey(typeof(T)) && - (ModuleInterfaces[typeof(T)].Count > 0)) - return (T)ModuleInterfaces[typeof(T)][0]; - else - return default(T); - } - - /// - /// For the given interface, retrieve an array of region modules that implement it. - /// - /// an empty array if there are no registered modules implementing that interface - public T[] RequestModuleInterfaces() - { - if (ModuleInterfaces.ContainsKey(typeof(T))) - { - List ret = new List(); - - foreach (Object o in ModuleInterfaces[typeof(T)]) - ret.Add((T)o); - return ret.ToArray(); - } - else - { - return new T[] {}; - } - } - - #endregion - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// - /// - /// - /// - public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) - { - AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// The use of IRegionModuleBase is a cheap trick to get a different method signature, - /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. - /// - /// - /// Category of the command. This is the section under which it will appear when the user asks for help - /// - /// - /// - /// - /// - public void AddCommand( - string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) - { - AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// - /// - /// - /// - /// - public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) - { - string moduleName = ""; - - if (module != null) - moduleName = module.Name; - - AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// Category of the command. This is the section under which it will appear when the user asks for help - /// - /// - /// - /// - /// - /// - /// - public void AddCommand( - string category, IRegionModuleBase module, string command, - string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) - { - if (MainConsole.Instance == null) - return; - - bool shared = false; - - if (module != null) - shared = module is ISharedRegionModule; - - MainConsole.Instance.Commands.AddCommand( - category, shared, command, shorthelp, longhelp, descriptivehelp, callback); - } - - public virtual ISceneObject DeserializeObject(string representation) - { - return null; - } - - public virtual bool AllowScriptCrossings - { - get { return false; } - } - - public virtual void Start() - { - } - - public void Restart() - { - // This has to be here to fire the event - restart handlerPhysicsCrash = OnRestart; - if (handlerPhysicsCrash != null) - handlerPhysicsCrash(RegionInfo); - } - - public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); - } -} + protected static readonly string LogHeader = "[SCENE]"; + + #region Events + + public event restart OnRestart; + + #endregion + + #region Fields + + public string Name { get { return RegionInfo.RegionName; } } + + public IConfigSource Config + { + get { return GetConfig(); } + } + + protected virtual IConfigSource GetConfig() + { + return null; + } + + /// + /// All the region modules attached to this scene. + /// + public Dictionary RegionModules + { + get { return m_regionModules; } + } + private Dictionary m_regionModules = new Dictionary(); + + /// + /// The module interfaces available from this scene. + /// + protected Dictionary> ModuleInterfaces = new Dictionary>(); + + protected Dictionary ModuleAPIMethods = new Dictionary(); + + /// + /// The module commanders available from this scene + /// + protected Dictionary m_moduleCommanders = new Dictionary(); + + /// + /// Registered classes that are capable of creating entities. + /// + protected Dictionary m_entityCreators = new Dictionary(); + + /// + /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is + /// dispensed. + /// + protected uint m_lastAllocatedLocalId = 720000; + + private readonly Mutex _primAllocateMutex = new Mutex(false); + + protected readonly ClientManager m_clientManager = new ClientManager(); + + public bool LoginsEnabled + { + get + { + return m_loginsEnabled; + } + + set + { + if (m_loginsEnabled != value) + { + m_loginsEnabled = value; + EventManager.TriggerRegionLoginsStatusChange(this); + } + } + } + private bool m_loginsEnabled; + + public bool Ready + { + get + { + return m_ready; + } + + set + { + if (m_ready != value) + { + m_ready = value; + EventManager.TriggerRegionReadyStatusChange(this); + } + } + } + private bool m_ready; + + public float TimeDilation + { + get { return 1.0f; } + } + + protected ulong m_regionHandle; + protected string m_regionName; + + public ITerrainChannel Heightmap; + + /// + /// Allows retrieval of land information for this scene. + /// + public ILandChannel LandChannel; + + /// + /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules + /// to subscribe to scene events. + /// + public EventManager EventManager + { + get { return m_eventManager; } + } + protected EventManager m_eventManager; + + protected ScenePermissions m_permissions; + public ScenePermissions Permissions + { + get { return m_permissions; } + } + + protected string m_datastore; + + /* Used by the loadbalancer plugin on GForge */ + protected RegionStatus m_regStatus; + public RegionStatus RegionStatus + { + get { return m_regStatus; } + set { m_regStatus = value; } + } + + #endregion + + public SceneBase(RegionInfo regInfo) + { + RegionInfo = regInfo; + } + + #region Update Methods + + /// + /// Called to update the scene loop by a number of frames and until shutdown. + /// + /// + /// Number of frames to update. Exits on shutdown even if there are frames remaining. + /// If -1 then updates until shutdown. + /// + public abstract void Update(int frames); + + #endregion + + #region Terrain Methods + + /// + /// Loads the World heightmap + /// + public abstract void LoadWorldMap(); + + /// + /// Send the region heightmap to the client + /// + /// Client to send to + public virtual void SendLayerData(IClientAPI RemoteClient) + { + RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); + } + + #endregion + + #region Add/Remove Agent/Avatar + + public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); + + public abstract bool CloseAgent(UUID agentID, bool force); + + public bool TryGetScenePresence(UUID agentID, out object scenePresence) + { + scenePresence = null; + ScenePresence sp = null; + if (TryGetScenePresence(agentID, out sp)) + { + scenePresence = sp; + return true; + } + + return false; + } + + /// + /// Try to get a scene presence from the scene + /// + /// + /// null if there is no scene presence with the given agent id + /// true if there was a scene presence with the given id, false otherwise. + public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); + + #endregion + + /// + /// + /// + /// + public virtual RegionInfo RegionInfo { get; private set; } + + #region admin stuff + + public abstract void OtherRegionUp(GridRegion otherRegion); + + public virtual string GetSimulatorVersion() + { + return "OpenSimulator Server"; + } + + #endregion + + #region Shutdown + + /// + /// Tidy before shutdown + /// + public virtual void Close() + { + try + { + EventManager.TriggerShutdown(); + } + catch (Exception e) + { + m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); + } + } + + #endregion + + /// + /// Returns a new unallocated local ID + /// + /// A brand new local ID + public uint AllocateLocalId() + { + uint myID; + + _primAllocateMutex.WaitOne(); + myID = ++m_lastAllocatedLocalId; + _primAllocateMutex.ReleaseMutex(); + + return myID; + } + + #region Module Methods + + /// + /// Add a region-module to this scene. TODO: This will replace AddModule in the future. + /// + /// + /// + public void AddRegionModule(string name, IRegionModuleBase module) + { + if (!RegionModules.ContainsKey(name)) + { + RegionModules.Add(name, module); + } + } + + public void RemoveRegionModule(string name) + { + RegionModules.Remove(name); + } + + /// + /// Register a module commander. + /// + /// + public void RegisterModuleCommander(ICommander commander) + { + lock (m_moduleCommanders) + { + m_moduleCommanders.Add(commander.Name, commander); + } + } + + /// + /// Unregister a module commander and all its commands + /// + /// + public void UnregisterModuleCommander(string name) + { + lock (m_moduleCommanders) + { + ICommander commander; + if (m_moduleCommanders.TryGetValue(name, out commander)) + m_moduleCommanders.Remove(name); + } + } + + /// + /// Get a module commander + /// + /// + /// The module commander, null if no module commander with that name was found + public ICommander GetCommander(string name) + { + lock (m_moduleCommanders) + { + if (m_moduleCommanders.ContainsKey(name)) + return m_moduleCommanders[name]; + } + + return null; + } + + public Dictionary GetCommanders() + { + return m_moduleCommanders; + } + + /// + /// Register an interface to a region module. This allows module methods to be called directly as + /// well as via events. If there is already a module registered for this interface, it is not replaced + /// (is this the best behaviour?) + /// + /// + public void RegisterModuleInterface(M mod) + { +// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); + + List l = null; + if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) + { + l = new List(); + ModuleInterfaces.Add(typeof(M), l); + } + + if (l.Count > 0) + return; + + l.Add(mod); + + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = entityCreator; + } + } + } + + public void UnregisterModuleInterface(M mod) + { + List l; + if (ModuleInterfaces.TryGetValue(typeof(M), out l)) + { + if (l.Remove(mod)) + { + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = null; + } + } + } + } + } + + public void StackModuleInterface(M mod) + { + List l; + if (ModuleInterfaces.ContainsKey(typeof(M))) + l = ModuleInterfaces[typeof(M)]; + else + l = new List(); + + if (l.Contains(mod)) + return; + + l.Add(mod); + + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = entityCreator; + } + } + + ModuleInterfaces[typeof(M)] = l; + } + + /// + /// For the given interface, retrieve the region module which implements it. + /// + /// null if there is no registered module implementing that interface + public T RequestModuleInterface() + { + if (ModuleInterfaces.ContainsKey(typeof(T)) && + (ModuleInterfaces[typeof(T)].Count > 0)) + return (T)ModuleInterfaces[typeof(T)][0]; + else + return default(T); + } + + /// + /// For the given interface, retrieve an array of region modules that implement it. + /// + /// an empty array if there are no registered modules implementing that interface + public T[] RequestModuleInterfaces() + { + if (ModuleInterfaces.ContainsKey(typeof(T))) + { + List ret = new List(); + + foreach (Object o in ModuleInterfaces[typeof(T)]) + ret.Add((T)o); + return ret.ToArray(); + } + else + { + return new T[] {}; + } + } + + #endregion + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// The use of IRegionModuleBase is a cheap trick to get a different method signature, + /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + public void AddCommand( + string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + /// + public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + string moduleName = ""; + + if (module != null) + moduleName = module.Name; + + AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + /// + /// + public void AddCommand( + string category, IRegionModuleBase module, string command, + string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + if (MainConsole.Instance == null) + return; + + bool shared = false; + + if (module != null) + shared = module is ISharedRegionModule; + + MainConsole.Instance.Commands.AddCommand( + category, shared, command, shorthelp, longhelp, descriptivehelp, callback); + } + + public virtual ISceneObject DeserializeObject(string representation) + { + return null; + } + + public virtual bool AllowScriptCrossings + { + get { return false; } + } + + public virtual void Start() + { + } + + public void Restart() + { + // This has to be here to fire the event + restart handlerPhysicsCrash = OnRestart; + if (handlerPhysicsCrash != null) + handlerPhysicsCrash(RegionInfo); + } + + public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); + } +} diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 24a92eb..8088dd3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3473,6 +3473,7 @@ namespace OpenSim.Region.Framework.Scenes landch.sendClientInitialLandInfo(ControllingClient); } } + m_scene.SendLayerData(ControllingClient); SendOtherAgentsAvatarDataToMe(); SendOtherAgentsAppearanceToMe(); @@ -5426,7 +5427,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p.IsChildAgent) continue; - m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5454,7 +5455,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5499,7 +5500,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendto) { - m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); try { p.ControllingClient.SendKillObject(new List { LocalId }); } catch (NullReferenceException) { } } @@ -5509,7 +5510,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5519,7 +5520,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendto) { - m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); p.ControllingClient.SendAvatarDataImmediate(this); SendAppearanceToAgent(p); SendAttachmentsToClient(p.ControllingClient); @@ -5532,9 +5533,9 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendme) { - m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); if (p.IsChildAgent) continue; +// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5603,7 +5604,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5752,7 +5753,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendto) { - m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); try { p.ControllingClient.SendKillObject(new List { LocalId }); } catch (NullReferenceException) { } } @@ -5762,7 +5763,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); +// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try {ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } -- cgit v1.1 From 3d81f25e34cd7d536ad0e36242703ac1bc56038d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 4 Aug 2014 20:32:11 +0100 Subject: Revert "start sending terrain in scenePresence after well defined avatar. Minor" This reverts commit 05a2feba5d780c57c252891a20071800fd9f2e3e. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 1160 +++++++++++----------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +- 3 files changed, 591 insertions(+), 592 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ec54e15..0266faf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3179,7 +3179,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientTerrainEvents(IClientAPI client) { -// client.OnRegionHandShakeReply += SendLayerData; + client.OnRegionHandShakeReply += SendLayerData; } public virtual void SubscribeToClientPrimEvents(IClientAPI client) @@ -3307,7 +3307,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) { -// client.OnRegionHandShakeReply -= SendLayerData; + client.OnRegionHandShakeReply -= SendLayerData; } public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 6adccca..08e26c5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -1,581 +1,581 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using OpenMetaverse; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; - -using OpenSim.Region.Framework.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Region.Framework.Scenes -{ - public abstract class SceneBase : IScene - { +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using OpenMetaverse; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Console; + +using OpenSim.Region.Framework.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.Framework.Scenes +{ + public abstract class SceneBase : IScene + { protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static readonly string LogHeader = "[SCENE]"; - - #region Events - - public event restart OnRestart; - - #endregion - - #region Fields - - public string Name { get { return RegionInfo.RegionName; } } - - public IConfigSource Config - { - get { return GetConfig(); } - } - - protected virtual IConfigSource GetConfig() - { - return null; - } - - /// - /// All the region modules attached to this scene. - /// - public Dictionary RegionModules - { - get { return m_regionModules; } - } - private Dictionary m_regionModules = new Dictionary(); - - /// - /// The module interfaces available from this scene. - /// - protected Dictionary> ModuleInterfaces = new Dictionary>(); - - protected Dictionary ModuleAPIMethods = new Dictionary(); - - /// - /// The module commanders available from this scene - /// - protected Dictionary m_moduleCommanders = new Dictionary(); - - /// - /// Registered classes that are capable of creating entities. - /// - protected Dictionary m_entityCreators = new Dictionary(); - - /// - /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is - /// dispensed. - /// - protected uint m_lastAllocatedLocalId = 720000; - - private readonly Mutex _primAllocateMutex = new Mutex(false); - - protected readonly ClientManager m_clientManager = new ClientManager(); - - public bool LoginsEnabled - { - get - { - return m_loginsEnabled; - } - - set - { - if (m_loginsEnabled != value) - { - m_loginsEnabled = value; - EventManager.TriggerRegionLoginsStatusChange(this); - } - } - } - private bool m_loginsEnabled; - - public bool Ready - { - get - { - return m_ready; - } - - set - { - if (m_ready != value) - { - m_ready = value; - EventManager.TriggerRegionReadyStatusChange(this); - } - } - } - private bool m_ready; - - public float TimeDilation - { - get { return 1.0f; } - } - - protected ulong m_regionHandle; - protected string m_regionName; - - public ITerrainChannel Heightmap; - - /// - /// Allows retrieval of land information for this scene. - /// - public ILandChannel LandChannel; - - /// - /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules - /// to subscribe to scene events. - /// - public EventManager EventManager - { - get { return m_eventManager; } - } - protected EventManager m_eventManager; - - protected ScenePermissions m_permissions; - public ScenePermissions Permissions - { - get { return m_permissions; } - } - - protected string m_datastore; - - /* Used by the loadbalancer plugin on GForge */ - protected RegionStatus m_regStatus; - public RegionStatus RegionStatus - { - get { return m_regStatus; } - set { m_regStatus = value; } - } - - #endregion - - public SceneBase(RegionInfo regInfo) - { - RegionInfo = regInfo; - } - - #region Update Methods - - /// - /// Called to update the scene loop by a number of frames and until shutdown. - /// - /// - /// Number of frames to update. Exits on shutdown even if there are frames remaining. - /// If -1 then updates until shutdown. - /// - public abstract void Update(int frames); - - #endregion - - #region Terrain Methods - - /// - /// Loads the World heightmap - /// - public abstract void LoadWorldMap(); - - /// - /// Send the region heightmap to the client - /// - /// Client to send to - public virtual void SendLayerData(IClientAPI RemoteClient) - { - RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); - } - - #endregion - - #region Add/Remove Agent/Avatar - - public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); - - public abstract bool CloseAgent(UUID agentID, bool force); - - public bool TryGetScenePresence(UUID agentID, out object scenePresence) - { - scenePresence = null; - ScenePresence sp = null; - if (TryGetScenePresence(agentID, out sp)) - { - scenePresence = sp; - return true; - } - - return false; - } - - /// - /// Try to get a scene presence from the scene - /// - /// - /// null if there is no scene presence with the given agent id - /// true if there was a scene presence with the given id, false otherwise. - public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); - - #endregion - - /// - /// - /// - /// - public virtual RegionInfo RegionInfo { get; private set; } - - #region admin stuff - - public abstract void OtherRegionUp(GridRegion otherRegion); - - public virtual string GetSimulatorVersion() - { - return "OpenSimulator Server"; - } - - #endregion - - #region Shutdown - - /// - /// Tidy before shutdown - /// - public virtual void Close() - { - try - { - EventManager.TriggerShutdown(); - } - catch (Exception e) - { - m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); - } - } - - #endregion - - /// - /// Returns a new unallocated local ID - /// - /// A brand new local ID - public uint AllocateLocalId() - { - uint myID; - - _primAllocateMutex.WaitOne(); - myID = ++m_lastAllocatedLocalId; - _primAllocateMutex.ReleaseMutex(); - - return myID; - } - - #region Module Methods - - /// - /// Add a region-module to this scene. TODO: This will replace AddModule in the future. - /// - /// - /// - public void AddRegionModule(string name, IRegionModuleBase module) - { - if (!RegionModules.ContainsKey(name)) - { - RegionModules.Add(name, module); - } - } - - public void RemoveRegionModule(string name) - { - RegionModules.Remove(name); - } - - /// - /// Register a module commander. - /// - /// - public void RegisterModuleCommander(ICommander commander) - { - lock (m_moduleCommanders) - { - m_moduleCommanders.Add(commander.Name, commander); - } - } - - /// - /// Unregister a module commander and all its commands - /// - /// - public void UnregisterModuleCommander(string name) - { - lock (m_moduleCommanders) - { - ICommander commander; - if (m_moduleCommanders.TryGetValue(name, out commander)) - m_moduleCommanders.Remove(name); - } - } - - /// - /// Get a module commander - /// - /// - /// The module commander, null if no module commander with that name was found - public ICommander GetCommander(string name) - { - lock (m_moduleCommanders) - { - if (m_moduleCommanders.ContainsKey(name)) - return m_moduleCommanders[name]; - } - - return null; - } - - public Dictionary GetCommanders() - { - return m_moduleCommanders; - } - - /// - /// Register an interface to a region module. This allows module methods to be called directly as - /// well as via events. If there is already a module registered for this interface, it is not replaced - /// (is this the best behaviour?) - /// - /// - public void RegisterModuleInterface(M mod) - { -// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); - - List l = null; - if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) - { - l = new List(); - ModuleInterfaces.Add(typeof(M), l); - } - - if (l.Count > 0) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - } - - public void UnregisterModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.TryGetValue(typeof(M), out l)) - { - if (l.Remove(mod)) - { - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = null; - } - } - } - } - } - - public void StackModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.ContainsKey(typeof(M))) - l = ModuleInterfaces[typeof(M)]; - else - l = new List(); - - if (l.Contains(mod)) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - - ModuleInterfaces[typeof(M)] = l; - } - - /// - /// For the given interface, retrieve the region module which implements it. - /// - /// null if there is no registered module implementing that interface - public T RequestModuleInterface() - { - if (ModuleInterfaces.ContainsKey(typeof(T)) && - (ModuleInterfaces[typeof(T)].Count > 0)) - return (T)ModuleInterfaces[typeof(T)][0]; - else - return default(T); - } - - /// - /// For the given interface, retrieve an array of region modules that implement it. - /// - /// an empty array if there are no registered modules implementing that interface - public T[] RequestModuleInterfaces() - { - if (ModuleInterfaces.ContainsKey(typeof(T))) - { - List ret = new List(); - - foreach (Object o in ModuleInterfaces[typeof(T)]) - ret.Add((T)o); - return ret.ToArray(); - } - else - { - return new T[] {}; - } - } - - #endregion - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// - /// - /// - /// - public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) - { - AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// The use of IRegionModuleBase is a cheap trick to get a different method signature, - /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. - /// - /// - /// Category of the command. This is the section under which it will appear when the user asks for help - /// - /// - /// - /// - /// - public void AddCommand( - string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) - { - AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// - /// - /// - /// - /// - public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) - { - string moduleName = ""; - - if (module != null) - moduleName = module.Name; - - AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// Category of the command. This is the section under which it will appear when the user asks for help - /// - /// - /// - /// - /// - /// - /// - public void AddCommand( - string category, IRegionModuleBase module, string command, - string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) - { - if (MainConsole.Instance == null) - return; - - bool shared = false; - - if (module != null) - shared = module is ISharedRegionModule; - - MainConsole.Instance.Commands.AddCommand( - category, shared, command, shorthelp, longhelp, descriptivehelp, callback); - } - - public virtual ISceneObject DeserializeObject(string representation) - { - return null; - } - - public virtual bool AllowScriptCrossings - { - get { return false; } - } - - public virtual void Start() - { - } - - public void Restart() - { - // This has to be here to fire the event - restart handlerPhysicsCrash = OnRestart; - if (handlerPhysicsCrash != null) - handlerPhysicsCrash(RegionInfo); - } - - public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); - } -} + protected static readonly string LogHeader = "[SCENE]"; + + #region Events + + public event restart OnRestart; + + #endregion + + #region Fields + + public string Name { get { return RegionInfo.RegionName; } } + + public IConfigSource Config + { + get { return GetConfig(); } + } + + protected virtual IConfigSource GetConfig() + { + return null; + } + + /// + /// All the region modules attached to this scene. + /// + public Dictionary RegionModules + { + get { return m_regionModules; } + } + private Dictionary m_regionModules = new Dictionary(); + + /// + /// The module interfaces available from this scene. + /// + protected Dictionary> ModuleInterfaces = new Dictionary>(); + + protected Dictionary ModuleAPIMethods = new Dictionary(); + + /// + /// The module commanders available from this scene + /// + protected Dictionary m_moduleCommanders = new Dictionary(); + + /// + /// Registered classes that are capable of creating entities. + /// + protected Dictionary m_entityCreators = new Dictionary(); + + /// + /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is + /// dispensed. + /// + protected uint m_lastAllocatedLocalId = 720000; + + private readonly Mutex _primAllocateMutex = new Mutex(false); + + protected readonly ClientManager m_clientManager = new ClientManager(); + + public bool LoginsEnabled + { + get + { + return m_loginsEnabled; + } + + set + { + if (m_loginsEnabled != value) + { + m_loginsEnabled = value; + EventManager.TriggerRegionLoginsStatusChange(this); + } + } + } + private bool m_loginsEnabled; + + public bool Ready + { + get + { + return m_ready; + } + + set + { + if (m_ready != value) + { + m_ready = value; + EventManager.TriggerRegionReadyStatusChange(this); + } + } + } + private bool m_ready; + + public float TimeDilation + { + get { return 1.0f; } + } + + protected ulong m_regionHandle; + protected string m_regionName; + + public ITerrainChannel Heightmap; + + /// + /// Allows retrieval of land information for this scene. + /// + public ILandChannel LandChannel; + + /// + /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules + /// to subscribe to scene events. + /// + public EventManager EventManager + { + get { return m_eventManager; } + } + protected EventManager m_eventManager; + + protected ScenePermissions m_permissions; + public ScenePermissions Permissions + { + get { return m_permissions; } + } + + protected string m_datastore; + + /* Used by the loadbalancer plugin on GForge */ + protected RegionStatus m_regStatus; + public RegionStatus RegionStatus + { + get { return m_regStatus; } + set { m_regStatus = value; } + } + + #endregion + + public SceneBase(RegionInfo regInfo) + { + RegionInfo = regInfo; + } + + #region Update Methods + + /// + /// Called to update the scene loop by a number of frames and until shutdown. + /// + /// + /// Number of frames to update. Exits on shutdown even if there are frames remaining. + /// If -1 then updates until shutdown. + /// + public abstract void Update(int frames); + + #endregion + + #region Terrain Methods + + /// + /// Loads the World heightmap + /// + public abstract void LoadWorldMap(); + + /// + /// Send the region heightmap to the client + /// + /// Client to send to + public virtual void SendLayerData(IClientAPI RemoteClient) + { + RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); + } + + #endregion + + #region Add/Remove Agent/Avatar + + public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); + + public abstract bool CloseAgent(UUID agentID, bool force); + + public bool TryGetScenePresence(UUID agentID, out object scenePresence) + { + scenePresence = null; + ScenePresence sp = null; + if (TryGetScenePresence(agentID, out sp)) + { + scenePresence = sp; + return true; + } + + return false; + } + + /// + /// Try to get a scene presence from the scene + /// + /// + /// null if there is no scene presence with the given agent id + /// true if there was a scene presence with the given id, false otherwise. + public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); + + #endregion + + /// + /// + /// + /// + public virtual RegionInfo RegionInfo { get; private set; } + + #region admin stuff + + public abstract void OtherRegionUp(GridRegion otherRegion); + + public virtual string GetSimulatorVersion() + { + return "OpenSimulator Server"; + } + + #endregion + + #region Shutdown + + /// + /// Tidy before shutdown + /// + public virtual void Close() + { + try + { + EventManager.TriggerShutdown(); + } + catch (Exception e) + { + m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); + } + } + + #endregion + + /// + /// Returns a new unallocated local ID + /// + /// A brand new local ID + public uint AllocateLocalId() + { + uint myID; + + _primAllocateMutex.WaitOne(); + myID = ++m_lastAllocatedLocalId; + _primAllocateMutex.ReleaseMutex(); + + return myID; + } + + #region Module Methods + + /// + /// Add a region-module to this scene. TODO: This will replace AddModule in the future. + /// + /// + /// + public void AddRegionModule(string name, IRegionModuleBase module) + { + if (!RegionModules.ContainsKey(name)) + { + RegionModules.Add(name, module); + } + } + + public void RemoveRegionModule(string name) + { + RegionModules.Remove(name); + } + + /// + /// Register a module commander. + /// + /// + public void RegisterModuleCommander(ICommander commander) + { + lock (m_moduleCommanders) + { + m_moduleCommanders.Add(commander.Name, commander); + } + } + + /// + /// Unregister a module commander and all its commands + /// + /// + public void UnregisterModuleCommander(string name) + { + lock (m_moduleCommanders) + { + ICommander commander; + if (m_moduleCommanders.TryGetValue(name, out commander)) + m_moduleCommanders.Remove(name); + } + } + + /// + /// Get a module commander + /// + /// + /// The module commander, null if no module commander with that name was found + public ICommander GetCommander(string name) + { + lock (m_moduleCommanders) + { + if (m_moduleCommanders.ContainsKey(name)) + return m_moduleCommanders[name]; + } + + return null; + } + + public Dictionary GetCommanders() + { + return m_moduleCommanders; + } + + /// + /// Register an interface to a region module. This allows module methods to be called directly as + /// well as via events. If there is already a module registered for this interface, it is not replaced + /// (is this the best behaviour?) + /// + /// + public void RegisterModuleInterface(M mod) + { +// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); + + List l = null; + if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) + { + l = new List(); + ModuleInterfaces.Add(typeof(M), l); + } + + if (l.Count > 0) + return; + + l.Add(mod); + + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = entityCreator; + } + } + } + + public void UnregisterModuleInterface(M mod) + { + List l; + if (ModuleInterfaces.TryGetValue(typeof(M), out l)) + { + if (l.Remove(mod)) + { + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = null; + } + } + } + } + } + + public void StackModuleInterface(M mod) + { + List l; + if (ModuleInterfaces.ContainsKey(typeof(M))) + l = ModuleInterfaces[typeof(M)]; + else + l = new List(); + + if (l.Contains(mod)) + return; + + l.Add(mod); + + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = entityCreator; + } + } + + ModuleInterfaces[typeof(M)] = l; + } + + /// + /// For the given interface, retrieve the region module which implements it. + /// + /// null if there is no registered module implementing that interface + public T RequestModuleInterface() + { + if (ModuleInterfaces.ContainsKey(typeof(T)) && + (ModuleInterfaces[typeof(T)].Count > 0)) + return (T)ModuleInterfaces[typeof(T)][0]; + else + return default(T); + } + + /// + /// For the given interface, retrieve an array of region modules that implement it. + /// + /// an empty array if there are no registered modules implementing that interface + public T[] RequestModuleInterfaces() + { + if (ModuleInterfaces.ContainsKey(typeof(T))) + { + List ret = new List(); + + foreach (Object o in ModuleInterfaces[typeof(T)]) + ret.Add((T)o); + return ret.ToArray(); + } + else + { + return new T[] {}; + } + } + + #endregion + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// The use of IRegionModuleBase is a cheap trick to get a different method signature, + /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + public void AddCommand( + string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + /// + public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + string moduleName = ""; + + if (module != null) + moduleName = module.Name; + + AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + /// + /// + public void AddCommand( + string category, IRegionModuleBase module, string command, + string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + if (MainConsole.Instance == null) + return; + + bool shared = false; + + if (module != null) + shared = module is ISharedRegionModule; + + MainConsole.Instance.Commands.AddCommand( + category, shared, command, shorthelp, longhelp, descriptivehelp, callback); + } + + public virtual ISceneObject DeserializeObject(string representation) + { + return null; + } + + public virtual bool AllowScriptCrossings + { + get { return false; } + } + + public virtual void Start() + { + } + + public void Restart() + { + // This has to be here to fire the event + restart handlerPhysicsCrash = OnRestart; + if (handlerPhysicsCrash != null) + handlerPhysicsCrash(RegionInfo); + } + + public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); + } +} diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8088dd3..24a92eb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3473,7 +3473,6 @@ namespace OpenSim.Region.Framework.Scenes landch.sendClientInitialLandInfo(ControllingClient); } } - m_scene.SendLayerData(ControllingClient); SendOtherAgentsAvatarDataToMe(); SendOtherAgentsAppearanceToMe(); @@ -5427,7 +5426,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p.IsChildAgent) continue; -// m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5455,7 +5454,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { -// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5500,7 +5499,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendto) { -// m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); try { p.ControllingClient.SendKillObject(new List { LocalId }); } catch (NullReferenceException) { } } @@ -5510,7 +5509,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { -// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5520,7 +5519,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendto) { -// m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); p.ControllingClient.SendAvatarDataImmediate(this); SendAppearanceToAgent(p); SendAttachmentsToClient(p.ControllingClient); @@ -5533,9 +5532,9 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendme) { + m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); if (p.IsChildAgent) continue; -// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5604,7 +5603,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { -// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try { ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } @@ -5753,7 +5752,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendto) { -// m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); try { p.ControllingClient.SendKillObject(new List { LocalId }); } catch (NullReferenceException) { } } @@ -5763,7 +5762,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendme) { -// m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); try {ControllingClient.SendKillObject(new List { p.LocalId }); } catch (NullReferenceException) { } } -- cgit v1.1 From 3cca5ec6674b413a419d3f1c42467e57fb883f56 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 4 Aug 2014 21:52:29 +0100 Subject: check... --- OpenSim/Region/Framework/Scenes/SceneBase.cs | 1160 +++++++++++----------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +- 2 files changed, 581 insertions(+), 589 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 08e26c5..dd0c828 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -1,581 +1,581 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using OpenMetaverse; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; - -using OpenSim.Region.Framework.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Region.Framework.Scenes -{ - public abstract class SceneBase : IScene - { +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using OpenMetaverse; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Console; + +using OpenSim.Region.Framework.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.Framework.Scenes +{ + public abstract class SceneBase : IScene + { protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static readonly string LogHeader = "[SCENE]"; - - #region Events - - public event restart OnRestart; - - #endregion - - #region Fields - - public string Name { get { return RegionInfo.RegionName; } } - - public IConfigSource Config - { - get { return GetConfig(); } - } - - protected virtual IConfigSource GetConfig() - { - return null; - } - - /// - /// All the region modules attached to this scene. - /// - public Dictionary RegionModules - { - get { return m_regionModules; } - } - private Dictionary m_regionModules = new Dictionary(); - - /// - /// The module interfaces available from this scene. - /// - protected Dictionary> ModuleInterfaces = new Dictionary>(); - - protected Dictionary ModuleAPIMethods = new Dictionary(); - - /// - /// The module commanders available from this scene - /// - protected Dictionary m_moduleCommanders = new Dictionary(); - - /// - /// Registered classes that are capable of creating entities. - /// - protected Dictionary m_entityCreators = new Dictionary(); - - /// - /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is - /// dispensed. - /// - protected uint m_lastAllocatedLocalId = 720000; - - private readonly Mutex _primAllocateMutex = new Mutex(false); - - protected readonly ClientManager m_clientManager = new ClientManager(); - - public bool LoginsEnabled - { - get - { - return m_loginsEnabled; - } - - set - { - if (m_loginsEnabled != value) - { - m_loginsEnabled = value; - EventManager.TriggerRegionLoginsStatusChange(this); - } - } - } - private bool m_loginsEnabled; - - public bool Ready - { - get - { - return m_ready; - } - - set - { - if (m_ready != value) - { - m_ready = value; - EventManager.TriggerRegionReadyStatusChange(this); - } - } - } - private bool m_ready; - - public float TimeDilation - { - get { return 1.0f; } - } - - protected ulong m_regionHandle; - protected string m_regionName; - - public ITerrainChannel Heightmap; - - /// - /// Allows retrieval of land information for this scene. - /// - public ILandChannel LandChannel; - - /// - /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules - /// to subscribe to scene events. - /// - public EventManager EventManager - { - get { return m_eventManager; } - } - protected EventManager m_eventManager; - - protected ScenePermissions m_permissions; - public ScenePermissions Permissions - { - get { return m_permissions; } - } - - protected string m_datastore; - - /* Used by the loadbalancer plugin on GForge */ - protected RegionStatus m_regStatus; - public RegionStatus RegionStatus - { - get { return m_regStatus; } - set { m_regStatus = value; } - } - - #endregion - - public SceneBase(RegionInfo regInfo) - { - RegionInfo = regInfo; - } - - #region Update Methods - - /// - /// Called to update the scene loop by a number of frames and until shutdown. - /// - /// - /// Number of frames to update. Exits on shutdown even if there are frames remaining. - /// If -1 then updates until shutdown. - /// - public abstract void Update(int frames); - - #endregion - - #region Terrain Methods - - /// - /// Loads the World heightmap - /// - public abstract void LoadWorldMap(); - - /// - /// Send the region heightmap to the client - /// - /// Client to send to - public virtual void SendLayerData(IClientAPI RemoteClient) - { - RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); - } - - #endregion - - #region Add/Remove Agent/Avatar - - public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); - - public abstract bool CloseAgent(UUID agentID, bool force); - - public bool TryGetScenePresence(UUID agentID, out object scenePresence) - { - scenePresence = null; - ScenePresence sp = null; - if (TryGetScenePresence(agentID, out sp)) - { - scenePresence = sp; - return true; - } - - return false; - } - - /// - /// Try to get a scene presence from the scene - /// - /// - /// null if there is no scene presence with the given agent id - /// true if there was a scene presence with the given id, false otherwise. - public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); - - #endregion - - /// - /// - /// - /// - public virtual RegionInfo RegionInfo { get; private set; } - - #region admin stuff - - public abstract void OtherRegionUp(GridRegion otherRegion); - - public virtual string GetSimulatorVersion() - { - return "OpenSimulator Server"; - } - - #endregion - - #region Shutdown - - /// - /// Tidy before shutdown - /// - public virtual void Close() - { - try - { - EventManager.TriggerShutdown(); - } - catch (Exception e) - { - m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); - } - } - - #endregion - - /// - /// Returns a new unallocated local ID - /// - /// A brand new local ID - public uint AllocateLocalId() - { - uint myID; - - _primAllocateMutex.WaitOne(); - myID = ++m_lastAllocatedLocalId; - _primAllocateMutex.ReleaseMutex(); - - return myID; - } - - #region Module Methods - - /// - /// Add a region-module to this scene. TODO: This will replace AddModule in the future. - /// - /// - /// - public void AddRegionModule(string name, IRegionModuleBase module) - { - if (!RegionModules.ContainsKey(name)) - { - RegionModules.Add(name, module); - } - } - - public void RemoveRegionModule(string name) - { - RegionModules.Remove(name); - } - - /// - /// Register a module commander. - /// - /// - public void RegisterModuleCommander(ICommander commander) - { - lock (m_moduleCommanders) - { - m_moduleCommanders.Add(commander.Name, commander); - } - } - - /// - /// Unregister a module commander and all its commands - /// - /// - public void UnregisterModuleCommander(string name) - { - lock (m_moduleCommanders) - { - ICommander commander; - if (m_moduleCommanders.TryGetValue(name, out commander)) - m_moduleCommanders.Remove(name); - } - } - - /// - /// Get a module commander - /// - /// - /// The module commander, null if no module commander with that name was found - public ICommander GetCommander(string name) - { - lock (m_moduleCommanders) - { - if (m_moduleCommanders.ContainsKey(name)) - return m_moduleCommanders[name]; - } - - return null; - } - - public Dictionary GetCommanders() - { - return m_moduleCommanders; - } - - /// - /// Register an interface to a region module. This allows module methods to be called directly as - /// well as via events. If there is already a module registered for this interface, it is not replaced - /// (is this the best behaviour?) - /// - /// - public void RegisterModuleInterface(M mod) - { -// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); - - List l = null; - if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) - { - l = new List(); - ModuleInterfaces.Add(typeof(M), l); - } - - if (l.Count > 0) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - } - - public void UnregisterModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.TryGetValue(typeof(M), out l)) - { - if (l.Remove(mod)) - { - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = null; - } - } - } - } - } - - public void StackModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.ContainsKey(typeof(M))) - l = ModuleInterfaces[typeof(M)]; - else - l = new List(); - - if (l.Contains(mod)) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - - ModuleInterfaces[typeof(M)] = l; - } - - /// - /// For the given interface, retrieve the region module which implements it. - /// - /// null if there is no registered module implementing that interface - public T RequestModuleInterface() - { - if (ModuleInterfaces.ContainsKey(typeof(T)) && - (ModuleInterfaces[typeof(T)].Count > 0)) - return (T)ModuleInterfaces[typeof(T)][0]; - else - return default(T); - } - - /// - /// For the given interface, retrieve an array of region modules that implement it. - /// - /// an empty array if there are no registered modules implementing that interface - public T[] RequestModuleInterfaces() - { - if (ModuleInterfaces.ContainsKey(typeof(T))) - { - List ret = new List(); - - foreach (Object o in ModuleInterfaces[typeof(T)]) - ret.Add((T)o); - return ret.ToArray(); - } - else - { - return new T[] {}; - } - } - - #endregion - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// - /// - /// - /// - public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) - { - AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// The use of IRegionModuleBase is a cheap trick to get a different method signature, - /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. - /// - /// - /// Category of the command. This is the section under which it will appear when the user asks for help - /// - /// - /// - /// - /// - public void AddCommand( - string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) - { - AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// - /// - /// - /// - /// - public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) - { - string moduleName = ""; - - if (module != null) - moduleName = module.Name; - - AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); - } - - /// - /// Call this from a region module to add a command to the OpenSim console. - /// - /// - /// Category of the command. This is the section under which it will appear when the user asks for help - /// - /// - /// - /// - /// - /// - /// - public void AddCommand( - string category, IRegionModuleBase module, string command, - string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) - { - if (MainConsole.Instance == null) - return; - - bool shared = false; - - if (module != null) - shared = module is ISharedRegionModule; - - MainConsole.Instance.Commands.AddCommand( - category, shared, command, shorthelp, longhelp, descriptivehelp, callback); - } - - public virtual ISceneObject DeserializeObject(string representation) - { - return null; - } - - public virtual bool AllowScriptCrossings - { - get { return false; } - } - - public virtual void Start() - { - } - - public void Restart() - { - // This has to be here to fire the event - restart handlerPhysicsCrash = OnRestart; - if (handlerPhysicsCrash != null) - handlerPhysicsCrash(RegionInfo); - } - - public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); - } -} + protected static readonly string LogHeader = "[SCENE]"; + + #region Events + + public event restart OnRestart; + + #endregion + + #region Fields + + public string Name { get { return RegionInfo.RegionName; } } + + public IConfigSource Config + { + get { return GetConfig(); } + } + + protected virtual IConfigSource GetConfig() + { + return null; + } + + /// + /// All the region modules attached to this scene. + /// + public Dictionary RegionModules + { + get { return m_regionModules; } + } + private Dictionary m_regionModules = new Dictionary(); + + /// + /// The module interfaces available from this scene. + /// + protected Dictionary> ModuleInterfaces = new Dictionary>(); + + protected Dictionary ModuleAPIMethods = new Dictionary(); + + /// + /// The module commanders available from this scene + /// + protected Dictionary m_moduleCommanders = new Dictionary(); + + /// + /// Registered classes that are capable of creating entities. + /// + protected Dictionary m_entityCreators = new Dictionary(); + + /// + /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is + /// dispensed. + /// + protected uint m_lastAllocatedLocalId = 720000; + + private readonly Mutex _primAllocateMutex = new Mutex(false); + + protected readonly ClientManager m_clientManager = new ClientManager(); + + public bool LoginsEnabled + { + get + { + return m_loginsEnabled; + } + + set + { + if (m_loginsEnabled != value) + { + m_loginsEnabled = value; + EventManager.TriggerRegionLoginsStatusChange(this); + } + } + } + private bool m_loginsEnabled; + + public bool Ready + { + get + { + return m_ready; + } + + set + { + if (m_ready != value) + { + m_ready = value; + EventManager.TriggerRegionReadyStatusChange(this); + } + } + } + private bool m_ready; + + public float TimeDilation + { + get { return 1.0f; } + } + + protected ulong m_regionHandle; + protected string m_regionName; + + public ITerrainChannel Heightmap; + + /// + /// Allows retrieval of land information for this scene. + /// + public ILandChannel LandChannel; + + /// + /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules + /// to subscribe to scene events. + /// + public EventManager EventManager + { + get { return m_eventManager; } + } + protected EventManager m_eventManager; + + protected ScenePermissions m_permissions; + public ScenePermissions Permissions + { + get { return m_permissions; } + } + + protected string m_datastore; + + /* Used by the loadbalancer plugin on GForge */ + protected RegionStatus m_regStatus; + public RegionStatus RegionStatus + { + get { return m_regStatus; } + set { m_regStatus = value; } + } + + #endregion + + public SceneBase(RegionInfo regInfo) + { + RegionInfo = regInfo; + } + + #region Update Methods + + /// + /// Called to update the scene loop by a number of frames and until shutdown. + /// + /// + /// Number of frames to update. Exits on shutdown even if there are frames remaining. + /// If -1 then updates until shutdown. + /// + public abstract void Update(int frames); + + #endregion + + #region Terrain Methods + + /// + /// Loads the World heightmap + /// + public abstract void LoadWorldMap(); + + /// + /// Send the region heightmap to the client + /// + /// Client to send to + public virtual void SendLayerData(IClientAPI RemoteClient) + { + RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); + } + + #endregion + + #region Add/Remove Agent/Avatar + + public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); + + public abstract bool CloseAgent(UUID agentID, bool force); + + public bool TryGetScenePresence(UUID agentID, out object scenePresence) + { + scenePresence = null; + ScenePresence sp = null; + if (TryGetScenePresence(agentID, out sp)) + { + scenePresence = sp; + return true; + } + + return false; + } + + /// + /// Try to get a scene presence from the scene + /// + /// + /// null if there is no scene presence with the given agent id + /// true if there was a scene presence with the given id, false otherwise. + public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); + + #endregion + + /// + /// + /// + /// + public virtual RegionInfo RegionInfo { get; private set; } + + #region admin stuff + + public abstract void OtherRegionUp(GridRegion otherRegion); + + public virtual string GetSimulatorVersion() + { + return "OpenSimulator Server"; + } + + #endregion + + #region Shutdown + + /// + /// Tidy before shutdown + /// + public virtual void Close() + { + try + { + EventManager.TriggerShutdown(); + } + catch (Exception e) + { + m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); + } + } + + #endregion + + /// + /// Returns a new unallocated local ID + /// + /// A brand new local ID + public uint AllocateLocalId() + { + uint myID; + + _primAllocateMutex.WaitOne(); + myID = ++m_lastAllocatedLocalId; + _primAllocateMutex.ReleaseMutex(); + + return myID; + } + + #region Module Methods + + /// + /// Add a region-module to this scene. TODO: This will replace AddModule in the future. + /// + /// + /// + public void AddRegionModule(string name, IRegionModuleBase module) + { + if (!RegionModules.ContainsKey(name)) + { + RegionModules.Add(name, module); + } + } + + public void RemoveRegionModule(string name) + { + RegionModules.Remove(name); + } + + /// + /// Register a module commander. + /// + /// + public void RegisterModuleCommander(ICommander commander) + { + lock (m_moduleCommanders) + { + m_moduleCommanders.Add(commander.Name, commander); + } + } + + /// + /// Unregister a module commander and all its commands + /// + /// + public void UnregisterModuleCommander(string name) + { + lock (m_moduleCommanders) + { + ICommander commander; + if (m_moduleCommanders.TryGetValue(name, out commander)) + m_moduleCommanders.Remove(name); + } + } + + /// + /// Get a module commander + /// + /// + /// The module commander, null if no module commander with that name was found + public ICommander GetCommander(string name) + { + lock (m_moduleCommanders) + { + if (m_moduleCommanders.ContainsKey(name)) + return m_moduleCommanders[name]; + } + + return null; + } + + public Dictionary GetCommanders() + { + return m_moduleCommanders; + } + + /// + /// Register an interface to a region module. This allows module methods to be called directly as + /// well as via events. If there is already a module registered for this interface, it is not replaced + /// (is this the best behaviour?) + /// + /// + public void RegisterModuleInterface(M mod) + { +// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); + + List l = null; + if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) + { + l = new List(); + ModuleInterfaces.Add(typeof(M), l); + } + + if (l.Count > 0) + return; + + l.Add(mod); + + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = entityCreator; + } + } + } + + public void UnregisterModuleInterface(M mod) + { + List l; + if (ModuleInterfaces.TryGetValue(typeof(M), out l)) + { + if (l.Remove(mod)) + { + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = null; + } + } + } + } + } + + public void StackModuleInterface(M mod) + { + List l; + if (ModuleInterfaces.ContainsKey(typeof(M))) + l = ModuleInterfaces[typeof(M)]; + else + l = new List(); + + if (l.Contains(mod)) + return; + + l.Add(mod); + + if (mod is IEntityCreator) + { + IEntityCreator entityCreator = (IEntityCreator)mod; + foreach (PCode pcode in entityCreator.CreationCapabilities) + { + m_entityCreators[pcode] = entityCreator; + } + } + + ModuleInterfaces[typeof(M)] = l; + } + + /// + /// For the given interface, retrieve the region module which implements it. + /// + /// null if there is no registered module implementing that interface + public T RequestModuleInterface() + { + if (ModuleInterfaces.ContainsKey(typeof(T)) && + (ModuleInterfaces[typeof(T)].Count > 0)) + return (T)ModuleInterfaces[typeof(T)][0]; + else + return default(T); + } + + /// + /// For the given interface, retrieve an array of region modules that implement it. + /// + /// an empty array if there are no registered modules implementing that interface + public T[] RequestModuleInterfaces() + { + if (ModuleInterfaces.ContainsKey(typeof(T))) + { + List ret = new List(); + + foreach (Object o in ModuleInterfaces[typeof(T)]) + ret.Add((T)o); + return ret.ToArray(); + } + else + { + return new T[] {}; + } + } + + #endregion + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// The use of IRegionModuleBase is a cheap trick to get a different method signature, + /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + public void AddCommand( + string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + /// + public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + string moduleName = ""; + + if (module != null) + moduleName = module.Name; + + AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + /// + /// + public void AddCommand( + string category, IRegionModuleBase module, string command, + string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + if (MainConsole.Instance == null) + return; + + bool shared = false; + + if (module != null) + shared = module is ISharedRegionModule; + + MainConsole.Instance.Commands.AddCommand( + category, shared, command, shorthelp, longhelp, descriptivehelp, callback); + } + + public virtual ISceneObject DeserializeObject(string representation) + { + return null; + } + + public virtual bool AllowScriptCrossings + { + get { return false; } + } + + public virtual void Start() + { + } + + public void Restart() + { + // This has to be here to fire the event + restart handlerPhysicsCrash = OnRestart; + if (handlerPhysicsCrash != null) + handlerPhysicsCrash(RegionInfo); + } + + public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); + } +} diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 24a92eb..596feb1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3369,19 +3369,11 @@ namespace OpenSim.Region.Framework.Scenes public void SendTerseUpdateToAgentClient(ScenePresence p) { - // messy checks because a client doesn't know what presence it belongs too - IClientAPI remoteClient = p.ControllingClient; - if (remoteClient == null) - return; - - if (!remoteClient.IsActive) - return; - + if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) return; - //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); remoteClient.SendEntityUpdate( this, -- cgit v1.1 From 507a29d5819fcbbac4eb22b0e45b11cf3afb5096 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 4 Aug 2014 21:55:58 +0100 Subject: diference fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 596feb1..f41a828 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3370,7 +3370,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendTerseUpdateToAgentClient(ScenePresence p) { IClientAPI remoteClient = p.ControllingClient; - + + if (!remoteClient.IsActive) + return; + if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) return; -- cgit v1.1 From c80322f1e69123922d9611b678e91323de97b835 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 5 Aug 2014 19:03:11 +0100 Subject: dont change agentItem.BasePermissions where avination-current didn't change --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 746b703..8634a3a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1234,8 +1234,9 @@ namespace OpenSim.Region.Framework.Scenes { uint perms = taskItem.CurrentPermissions; PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); - agentItem.BasePermissions = perms | (uint)PermissionMask.Move; - agentItem.CurrentPermissions = agentItem.BasePermissions; +// agentItem.BasePermissions = perms | (uint)PermissionMask.Move; +// agentItem.CurrentPermissions = agentItem.BasePermissions; + agentItem.CurrentPermissions = perms | (uint)PermissionMask.Move; } else { -- cgit v1.1 From 2c4908578ed40c743d566a3cd1995a4e69ed17c8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 5 Aug 2014 21:55:42 +0100 Subject: revert to old avn-current code, not using ApplyPermissionsOnRez() till its reviewed/fixed --- .../Framework/Scenes/SceneObjectPartInventory.cs | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 257e01e..400a415 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -922,7 +922,7 @@ namespace OpenSim.Region.Framework.Scenes rootPart.Name = item.Name; rootPart.Description = item.Description; } - +/* reverted to old code till part.ApplyPermissionsOnRez is better reviewed/fixed group.SetGroup(m_part.GroupID, null); foreach (SceneObjectPart part in group.Parts) @@ -938,7 +938,49 @@ namespace OpenSim.Region.Framework.Scenes part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); } +*/ +// old code start + SceneObjectPart[] partList = group.Parts; + + group.SetGroup(m_part.GroupID, null); + + // TODO: Remove magic number badness + if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number + { + if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) + { + foreach (SceneObjectPart part in partList) + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + part.EveryoneMask = item.EveryonePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + part.GroupMask = item.GroupPermissions; + } + group.ApplyNextOwnerPermissions(); + } + } + + foreach (SceneObjectPart part in partList) + { + // TODO: Remove magic number badness + if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.OwnerID; + part.Inventory.ChangeInventoryOwner(item.OwnerID); + } + + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + part.EveryoneMask = item.EveryonePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + part.GroupMask = item.GroupPermissions; + } +// old code end rootPart.TrimPermissions(); } -- cgit v1.1 From 3c321e5bb37d0430085c361632fb668824e9b500 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 5 Aug 2014 22:49:41 +0100 Subject: dont mess with names and descriptions on coalescence objects. Inventory name can change for inventory purposes only. --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 400a415..657d7c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -917,7 +917,9 @@ namespace OpenSim.Region.Framework.Scenes // in the serialization, transfer the correct name from the inventory to the // object itself before we rez. // Only do these for the first object if we are rezzing a coalescence. - if (i == 0) + // nahh dont mess with coalescence objects, + // the name in inventory can be change for inventory purpuses only + if (i == 0 && objlist.Count == 1) { rootPart.Name = item.Name; rootPart.Description = item.Description; -- cgit v1.1 From e1a5a1f829ad7b82fa8dc5b81248dff45b586f40 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 5 Aug 2014 23:25:08 +0100 Subject: apply objectSlamSale to all roots of coalescence objects. replace the single object condition for renaming --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 657d7c1..a6a963b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -919,7 +919,7 @@ namespace OpenSim.Region.Framework.Scenes // Only do these for the first object if we are rezzing a coalescence. // nahh dont mess with coalescence objects, // the name in inventory can be change for inventory purpuses only - if (i == 0 && objlist.Count == 1) + if (objlist.Count == 1) { rootPart.Name = item.Name; rootPart.Description = item.Description; -- cgit v1.1 From c3f9c99fb32d15e57b24502b71c79fe028ed3007 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 7 Aug 2014 05:20:45 +0100 Subject: DANGER... changed bakedtextures caching. Assuming grid baking is cache only, reduced number of accesses to it. TESTING --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f41a828..965d7c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3502,7 +3502,7 @@ namespace OpenSim.Region.Framework.Scenes // If we aren't using a cached appearance, then clear out the baked textures if (!cachedappearance) { - Appearance.ResetAppearance(); +// Appearance.ResetAppearance(); // save what ???? // maybe needed so the tryretry repair works? if (m_scene.AvatarFactory != null) -- cgit v1.1 From b7f24bacce523240b73fba7ea0f3403dc59c3596 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 7 Aug 2014 06:09:56 +0100 Subject: bugg --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 965d7c2..8fae032 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3525,7 +3525,7 @@ namespace OpenSim.Region.Framework.Scenes // send even grays if (cachedappearance) { - m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); +// m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); // If the avatars baked textures are all in the cache, then we have a // complete appearance... send it out, if not, then we'll send it when // the avatar finishes updating its appearance -- cgit v1.1 From dc7b9c1cc328084bf8f730337ae5c44005f935b9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 9 Aug 2014 15:12:02 +0100 Subject: dont do for children what is for growups ( root agents) ( needs check) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 86 +++++++++++------------- 1 file changed, 39 insertions(+), 47 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8fae032..5acd51e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1823,12 +1823,12 @@ namespace OpenSim.Region.Framework.Scenes Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); m_callbackURI = null; } - // else - // { - // m_log.DebugFormat( - // "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}", - // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); - // } +// else +// { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}", +// client.Name, client.AgentId, m_scene.RegionInfo.RegionName); +// } m_previusParcelHide = false; m_previusParcelUUID = UUID.Zero; @@ -1838,59 +1838,51 @@ namespace OpenSim.Region.Framework.Scenes // send initial land overlay and parcel ILandChannel landch = m_scene.LandChannel; if (landch != null) - { landch.sendClientInitialLandInfo(client); - if (!IsChildAgent) - { - newhide = m_currentParcelHide; - m_currentParcelHide = false; - } - } - - // send agentData to all clients including us (?) - // get appearance - // if in cache sent it to all clients - // send what we have to us, even if not in cache ( bad? ) - ValidateAndSendAppearanceAndAgentData(); - // attachments - if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) + if (!IsChildAgent) { - if (Scene.AttachmentsModule != null) + newhide = m_currentParcelHide; + m_currentParcelHide = false; + + ValidateAndSendAppearanceAndAgentData(); + + // attachments + if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) + { + if (Scene.AttachmentsModule != null) // Util.FireAndForget( // o => // { - Scene.AttachmentsModule.RezAttachments(this); -// }); - } - else - { - List attachments = GetAttachments(); - - if (attachments.Count > 0) + Scene.AttachmentsModule.RezAttachments(this); + // }); + } + else { - m_log.DebugFormat( - "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + List attachments = GetAttachments(); - // Resume scripts this possible should also be moved down after sending the avatar to viewer ? - foreach (SceneObjectGroup sog in attachments) + if (attachments.Count > 0) { - sog.ScheduleGroupForFullUpdate(); - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); - sog.ResumeScripts(); + m_log.DebugFormat( + "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? + foreach (SceneObjectGroup sog in attachments) + { + sog.ScheduleGroupForFullUpdate(); + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); + sog.ResumeScripts(); + } } } - } - // m_log.DebugFormat( - // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", - // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); - // Create child agents in neighbouring regions - if (openChildAgents && !IsChildAgent) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); + // Create child agents in neighbouring regions + if (openChildAgents) + { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); + } } // send the rest of the world -- cgit v1.1 From 7fcd1068e742d88fbda94ae079e900424807d021 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 10 Aug 2014 20:09:02 +0100 Subject: TEST move parcelRegionCross to EntityTransferModule cross so it works on sitting avatars. (may be bad) comented out sending root avatars information to the child that was just a root it should have it all already. Dont turn a sitting avatar physical, that needs to be a stand at SOG --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5acd51e..d65c250 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3863,7 +3863,7 @@ namespace OpenSim.Region.Framework.Scenes protected bool CrossToNewRegion() { bool result = false; - parcelRegionCross(false); +// parcelRegionCross(false); try { result = m_scene.CrossAgentToNewRegion(this, Flying); @@ -3872,8 +3872,8 @@ namespace OpenSim.Region.Framework.Scenes { result = m_scene.CrossAgentToNewRegion(this, false); } - if(!result) - parcelRegionCross(true); + // if(!result) + // parcelRegionCross(true); return result; @@ -5531,7 +5531,7 @@ namespace OpenSim.Region.Framework.Scenes } } - private void parcelRegionCross(bool abort) + public void parcelRegionCross(bool abort) { if (!ParcelHideThisAvatar) return; -- cgit v1.1 From 01e381fa33a7bd8ca9141a73f8dca0ff7832aaca Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 11 Aug 2014 02:07:23 +0200 Subject: Make texture anims work right on singu --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 055473d..a292c79 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1878,22 +1878,29 @@ namespace OpenSim.Region.Framework.Scenes public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) { - byte[] data = new byte[16]; - int pos = 0; + if (((int)pTexAnim.Flags & 1) == 0) // ANIM_ON + { + byte[] data = new byte[16]; + int pos = 0; - // The flags don't like conversion from uint to byte, so we have to do - // it the crappy way. See the above function :( + // The flags don't like conversion from uint to byte, so we have to do + // it the crappy way. See the above function :( - data[pos] = ConvertScriptUintToByte((uint)pTexAnim.Flags); pos++; - data[pos] = (byte)pTexAnim.Face; pos++; - data[pos] = (byte)pTexAnim.SizeX; pos++; - data[pos] = (byte)pTexAnim.SizeY; pos++; + data[pos] = ConvertScriptUintToByte((uint)pTexAnim.Flags); pos++; + data[pos] = (byte)pTexAnim.Face; pos++; + data[pos] = (byte)pTexAnim.SizeX; pos++; + data[pos] = (byte)pTexAnim.SizeY; pos++; - Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); - Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); - Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); + Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); + Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); + Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); - m_TextureAnimation = data; + m_TextureAnimation = data; + } + else + { + m_TextureAnimation = Utils.EmptyBytes; + } } public void AdjustSoundGain(double volume) -- cgit v1.1 From 036017bba7195d052efa9eb4d289c87cd38515e0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 11 Aug 2014 02:07:23 +0200 Subject: Make texture anims work right on singu --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 261e958..a3c60ea 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1880,22 +1880,29 @@ namespace OpenSim.Region.Framework.Scenes public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) { - byte[] data = new byte[16]; - int pos = 0; + if (((int)pTexAnim.Flags & 1) == 0) // ANIM_ON + { + byte[] data = new byte[16]; + int pos = 0; - // The flags don't like conversion from uint to byte, so we have to do - // it the crappy way. See the above function :( + // The flags don't like conversion from uint to byte, so we have to do + // it the crappy way. See the above function :( - data[pos] = ConvertScriptUintToByte((uint)pTexAnim.Flags); pos++; - data[pos] = (byte)pTexAnim.Face; pos++; - data[pos] = (byte)pTexAnim.SizeX; pos++; - data[pos] = (byte)pTexAnim.SizeY; pos++; + data[pos] = ConvertScriptUintToByte((uint)pTexAnim.Flags); pos++; + data[pos] = (byte)pTexAnim.Face; pos++; + data[pos] = (byte)pTexAnim.SizeX; pos++; + data[pos] = (byte)pTexAnim.SizeY; pos++; - Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); - Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); - Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); + Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); + Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); + Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); - m_TextureAnimation = data; + m_TextureAnimation = data; + } + else + { + m_TextureAnimation = Utils.EmptyBytes; + } } public void AdjustSoundGain(double volume) -- cgit v1.1 From 519df0d2a3e63190a56062859f79e5fabab23e26 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 11 Aug 2014 02:30:09 +0200 Subject: Fix a condition check --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a292c79..98ea880 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1878,7 +1878,7 @@ namespace OpenSim.Region.Framework.Scenes public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) { - if (((int)pTexAnim.Flags & 1) == 0) // ANIM_ON + if (((int)pTexAnim.Flags & 1) != 0) // ANIM_ON { byte[] data = new byte[16]; int pos = 0; -- cgit v1.1 From 0eaabef1dc8ac18319fa77c699e50226df5ca2bd Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 11 Aug 2014 02:30:09 +0200 Subject: Fix a condition check --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a3c60ea..566605a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1880,7 +1880,7 @@ namespace OpenSim.Region.Framework.Scenes public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) { - if (((int)pTexAnim.Flags & 1) == 0) // ANIM_ON + if (((int)pTexAnim.Flags & 1) != 0) // ANIM_ON { byte[] data = new byte[16]; int pos = 0; -- cgit v1.1 From ba33d78af90ca0649ffb5150eadffc185bf224fe Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 11 Aug 2014 01:44:12 +0100 Subject: dont do ParcelCrossCheck() on child avatars --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d65c250..6cd951d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5611,6 +5611,9 @@ namespace OpenSim.Region.Framework.Scenes if (IsInTransit) return; + if (IsChildAgent) + return; + if (check) { // check is relative to current parcel only -- cgit v1.1 From 2cc8e90bd2079798b4e4538fefeb23ea3f81488e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 11 Aug 2014 02:51:34 +0100 Subject: remove a land.SendLandUpdateToClient() since its now done for all cases in completmovement and not only that specific one --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6cd951d..62dea07 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5158,8 +5158,8 @@ namespace OpenSim.Region.Framework.Scenes pos = land.LandData.UserLocation; } } - - land.SendLandUpdateToClient(ControllingClient); +// this is now done in completeMovement for all cases and not just this +// land.SendLandUpdateToClient(ControllingClient); } } -- cgit v1.1 From a0f26dc6ec2323ffa09070e80564d3dd691408cb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 18:28:01 +0100 Subject: change XMLIrpgGroups attach to events, using the more correct \addons\Groups\... model --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 307 ++++++++++++----------- 1 file changed, 156 insertions(+), 151 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 62dea07..5387910 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1158,177 +1158,182 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); +/* this is now done by groups module on TriggerOnMakeRootAgent(this) below + at least XmlIRpcGroups UUID groupUUID = UUID.Zero; string GroupName = string.Empty; ulong groupPowers = 0; - // ---------------------------------- - // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status - try - { - - if (gm != null) - { - groupUUID = ControllingClient.ActiveGroupId; - GroupRecord record = gm.GetGroupRecord(groupUUID); - if (record != null) - GroupName = record.GroupName; - GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); - if (groupMembershipData != null) - groupPowers = groupMembershipData.GroupPowers; - } - ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, - Grouptitle); - } - catch (Exception e) - { - m_log.Debug("[AGENTUPDATE]: " + e.ToString()); - } - // ------------------------------------ - if (ParentID == 0) - { - // Moved this from SendInitialData to ensure that Appearance is initialized - // before the inventory is processed in MakeRootAgent. This fixes a race condition - // related to the handling of attachments - - if (m_scene.TestBorderCross(pos, Cardinals.E)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); - pos.X = crossedBorder.BorderLine.Z - 1; - } - if (m_scene.TestBorderCross(pos, Cardinals.N)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); - pos.Y = crossedBorder.BorderLine.Z - 1; - } - CheckAndAdjustLandingPoint(ref pos); + // ---------------------------------- + // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status + try + { + + if (gm != null) + { + groupUUID = ControllingClient.ActiveGroupId; + GroupRecord record = gm.GetGroupRecord(groupUUID); + if (record != null) + GroupName = record.GroupName; + GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); + if (groupMembershipData != null) + groupPowers = groupMembershipData.GroupPowers; + } + ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, + Grouptitle); + } + catch (Exception e) + { + m_log.Debug("[AGENTUPDATE]: " + e.ToString()); + } + // ------------------------------------ +*/ + if (ParentID == 0) + { + // Moved this from SendInitialData to ensure that Appearance is initialized + // before the inventory is processed in MakeRootAgent. This fixes a race condition + // related to the handling of attachments - if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) - { - m_log.WarnFormat( - "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", - pos, Name, UUID); + if (m_scene.TestBorderCross(pos, Cardinals.E)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); + pos.X = crossedBorder.BorderLine.Z - 1; + } - if (pos.X < 0f) pos.X = 0f; - if (pos.Y < 0f) pos.Y = 0f; - if (pos.Z < 0f) pos.Z = 0f; - } + if (m_scene.TestBorderCross(pos, Cardinals.N)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); + pos.Y = crossedBorder.BorderLine.Z - 1; + } - float localAVHeight = 1.56f; - if (Appearance.AvatarHeight > 0) - localAVHeight = Appearance.AvatarHeight; + CheckAndAdjustLandingPoint(ref pos); - float posZLimit = 0; + if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", + pos, Name, UUID); - if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) - posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; - - float newPosZ = posZLimit + localAVHeight / 2; - if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - pos.Z = newPosZ; - } - AbsolutePosition = pos; + if (pos.X < 0f) pos.X = 0f; + if (pos.Y < 0f) pos.Y = 0f; + if (pos.Z < 0f) pos.Z = 0f; + } - if (m_teleportFlags == TeleportFlags.Default) - { - Vector3 vel = Velocity; - AddToPhysicalScene(isFlying); - if (PhysicsActor != null) - PhysicsActor.SetMomentum(vel); - } - else - AddToPhysicalScene(isFlying); + float localAVHeight = 1.56f; + if (Appearance.AvatarHeight > 0) + localAVHeight = Appearance.AvatarHeight; - // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a - // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it - // since it requires a physics actor to be present. If it is left any later, then physics appears to reset - // the value to a negative position which does not trigger the border cross. - // This may not be the best location for this. - CheckForBorderCrossing(); + float posZLimit = 0; - if (ForceFly) - { - Flying = true; - } - else if (FlyDisabled) - { - Flying = false; - } - } - // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying - // avatar to return to the standing position in mid-air. On login it looks like this is being sent - // elsewhere anyway - // Animator.SendAnimPack(); - - m_scene.SwapRootAgentCount(false); - - // The initial login scene presence is already root when it gets here - // and it has already rezzed the attachments and started their scripts. - // We do the following only for non-login agents, because their scripts - // haven't started yet. -/* moved down - if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) - { - // Viewers which have a current outfit folder will actually rez their own attachments. However, - // viewers without (e.g. v1 viewers) will not, so we still need to make this call. - if (Scene.AttachmentsModule != null) - Util.FireAndForget( - o => - { -// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) -// System.Threading.Thread.Sleep(7000); + if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) + posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; + + float newPosZ = posZLimit + localAVHeight / 2; + if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + pos.Z = newPosZ; + } + AbsolutePosition = pos; - Scene.AttachmentsModule.RezAttachments(this); - }); - } - else + if (m_teleportFlags == TeleportFlags.Default) + { + Vector3 vel = Velocity; + AddToPhysicalScene(isFlying); + if (PhysicsActor != null) + PhysicsActor.SetMomentum(vel); + } + else + AddToPhysicalScene(isFlying); - { - // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT - // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently - // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are - // not transporting the required data. - // - // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT - // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently - // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are - // not transporting the required data. - // - // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of - // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here - // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. - // - // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). - // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing - // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the - // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. - // - // One cannot simply iterate over attachments in a fire and forget thread because this would no longer - // be locked, allowing race conditions if other code changes the attachments list. + // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a + // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it + // since it requires a physics actor to be present. If it is left any later, then physics appears to reset + // the value to a negative position which does not trigger the border cross. + // This may not be the best location for this. + CheckForBorderCrossing(); - List attachments = GetAttachments(); + if (ForceFly) + { + Flying = true; + } + else if (FlyDisabled) + { + Flying = false; + } + } + // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying + // avatar to return to the standing position in mid-air. On login it looks like this is being sent + // elsewhere anyway + // Animator.SendAnimPack(); + + m_scene.SwapRootAgentCount(false); + + // The initial login scene presence is already root when it gets here + // and it has already rezzed the attachments and started their scripts. + // We do the following only for non-login agents, because their scripts + // haven't started yet. + /* moved down + if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) + { + // Viewers which have a current outfit folder will actually rez their own attachments. However, + // viewers without (e.g. v1 viewers) will not, so we still need to make this call. + if (Scene.AttachmentsModule != null) + Util.FireAndForget( + o => + { + // if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) + // System.Threading.Thread.Sleep(7000); + + Scene.AttachmentsModule.RezAttachments(this); + }); + } + else - if (attachments.Count > 0) - { - m_log.DebugFormat( - "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + { + // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT + // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently + // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are + // not transporting the required data. + // + // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT + // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently + // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are + // not transporting the required data. + // + // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of + // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here + // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. + // + // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). + // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing + // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the + // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. + // + // One cannot simply iterate over attachments in a fire and forget thread because this would no longer + // be locked, allowing race conditions if other code changes the attachments list. + + List attachments = GetAttachments(); + + if (attachments.Count > 0) + { + m_log.DebugFormat( + "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - // Resume scripts this possible should also be moved down after sending the avatar to viewer ? - foreach (SceneObjectGroup sog in attachments) - { -// sending attachments before the avatar ? -// moved to completemovement where it already was -// sog.ScheduleGroupForFullUpdate(); - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); - sog.ResumeScripts(); - } - } - } -*/ + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? + foreach (SceneObjectGroup sog in attachments) + { + // sending attachments before the avatar ? + // moved to completemovement where it already was + // sog.ScheduleGroupForFullUpdate(); + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); + sog.ResumeScripts(); + } + } + } + */ /* SendAvatarDataToAllAgents(); -- cgit v1.1 From 4997a9e87a860e3c39c164bf8a4079ef4ff63089 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 18:42:18 +0100 Subject: fix VS creative indentation --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 272 +++++++++++------------ 1 file changed, 136 insertions(+), 136 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5387910..762dbd4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1113,9 +1113,9 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); - // m_log.InfoFormat( - // "[SCENE]: Upgrading child to root agent for {0} in {1}", - // Name, m_scene.RegionInfo.RegionName); + // m_log.InfoFormat( + // "[SCENE]: Upgrading child to root agent for {0} in {1}", + // Name, m_scene.RegionInfo.RegionName); if (ParentUUID != UUID.Zero) { @@ -1148,17 +1148,17 @@ namespace OpenSim.Region.Framework.Scenes // Must reset this here so that a teleport to a region next to an existing region does not keep the flag // set and prevent the close of the connection on a subsequent re-teleport. // Should not be needed if we are not trying to tell this region to close -// DoNotCloseAfterTeleport = false; + // DoNotCloseAfterTeleport = false; IGroupsModule gm = m_scene.RequestModuleInterface(); if (gm != null) Grouptitle = gm.GetGroupTitle(m_uuid); - + RegionHandle = m_scene.RegionInfo.RegionHandle; m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); -/* this is now done by groups module on TriggerOnMakeRootAgent(this) below +/* this should be done by groups module on TriggerOnMakeRootAgent(this) below at least XmlIRpcGroups UUID groupUUID = UUID.Zero; string GroupName = string.Empty; @@ -1191,149 +1191,149 @@ namespace OpenSim.Region.Framework.Scenes } // ------------------------------------ */ - if (ParentID == 0) - { - // Moved this from SendInitialData to ensure that Appearance is initialized - // before the inventory is processed in MakeRootAgent. This fixes a race condition - // related to the handling of attachments + if (ParentID == 0) + { + // Moved this from SendInitialData to ensure that Appearance is initialized + // before the inventory is processed in MakeRootAgent. This fixes a race condition + // related to the handling of attachments - if (m_scene.TestBorderCross(pos, Cardinals.E)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); - pos.X = crossedBorder.BorderLine.Z - 1; - } + if (m_scene.TestBorderCross(pos, Cardinals.E)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); + pos.X = crossedBorder.BorderLine.Z - 1; + } - if (m_scene.TestBorderCross(pos, Cardinals.N)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); - pos.Y = crossedBorder.BorderLine.Z - 1; - } + if (m_scene.TestBorderCross(pos, Cardinals.N)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); + pos.Y = crossedBorder.BorderLine.Z - 1; + } - CheckAndAdjustLandingPoint(ref pos); + CheckAndAdjustLandingPoint(ref pos); - if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) - { - m_log.WarnFormat( - "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", - pos, Name, UUID); + if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", + pos, Name, UUID); - if (pos.X < 0f) pos.X = 0f; - if (pos.Y < 0f) pos.Y = 0f; - if (pos.Z < 0f) pos.Z = 0f; - } + if (pos.X < 0f) pos.X = 0f; + if (pos.Y < 0f) pos.Y = 0f; + if (pos.Z < 0f) pos.Z = 0f; + } - float localAVHeight = 1.56f; - if (Appearance.AvatarHeight > 0) - localAVHeight = Appearance.AvatarHeight; + float localAVHeight = 1.56f; + if (Appearance.AvatarHeight > 0) + localAVHeight = Appearance.AvatarHeight; - float posZLimit = 0; + float posZLimit = 0; - if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) - posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; - - float newPosZ = posZLimit + localAVHeight / 2; - if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - pos.Z = newPosZ; - } - AbsolutePosition = pos; + if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) + posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; - if (m_teleportFlags == TeleportFlags.Default) - { - Vector3 vel = Velocity; - AddToPhysicalScene(isFlying); - if (PhysicsActor != null) - PhysicsActor.SetMomentum(vel); - } - else - AddToPhysicalScene(isFlying); + float newPosZ = posZLimit + localAVHeight / 2; + if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + pos.Z = newPosZ; + } + AbsolutePosition = pos; - // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a - // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it - // since it requires a physics actor to be present. If it is left any later, then physics appears to reset - // the value to a negative position which does not trigger the border cross. - // This may not be the best location for this. - CheckForBorderCrossing(); + if (m_teleportFlags == TeleportFlags.Default) + { + Vector3 vel = Velocity; + AddToPhysicalScene(isFlying); + if (PhysicsActor != null) + PhysicsActor.SetMomentum(vel); + } + else + AddToPhysicalScene(isFlying); - if (ForceFly) - { - Flying = true; - } - else if (FlyDisabled) - { - Flying = false; - } - } - // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying - // avatar to return to the standing position in mid-air. On login it looks like this is being sent - // elsewhere anyway - // Animator.SendAnimPack(); - - m_scene.SwapRootAgentCount(false); - - // The initial login scene presence is already root when it gets here - // and it has already rezzed the attachments and started their scripts. - // We do the following only for non-login agents, because their scripts - // haven't started yet. - /* moved down - if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) - { - // Viewers which have a current outfit folder will actually rez their own attachments. However, - // viewers without (e.g. v1 viewers) will not, so we still need to make this call. - if (Scene.AttachmentsModule != null) - Util.FireAndForget( - o => - { - // if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) - // System.Threading.Thread.Sleep(7000); - - Scene.AttachmentsModule.RezAttachments(this); - }); - } - else + // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a + // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it + // since it requires a physics actor to be present. If it is left any later, then physics appears to reset + // the value to a negative position which does not trigger the border cross. + // This may not be the best location for this. + CheckForBorderCrossing(); - { - // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT - // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently - // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are - // not transporting the required data. - // - // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT - // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently - // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are - // not transporting the required data. - // - // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of - // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here - // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. - // - // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). - // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing - // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the - // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. - // - // One cannot simply iterate over attachments in a fire and forget thread because this would no longer - // be locked, allowing race conditions if other code changes the attachments list. - - List attachments = GetAttachments(); - - if (attachments.Count > 0) - { - m_log.DebugFormat( - "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + if (ForceFly) + { + Flying = true; + } + else if (FlyDisabled) + { + Flying = false; + } + } + // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying + // avatar to return to the standing position in mid-air. On login it looks like this is being sent + // elsewhere anyway + // Animator.SendAnimPack(); - // Resume scripts this possible should also be moved down after sending the avatar to viewer ? - foreach (SceneObjectGroup sog in attachments) - { - // sending attachments before the avatar ? - // moved to completemovement where it already was - // sog.ScheduleGroupForFullUpdate(); - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); - sog.ResumeScripts(); - } - } - } - */ + m_scene.SwapRootAgentCount(false); + + // The initial login scene presence is already root when it gets here + // and it has already rezzed the attachments and started their scripts. + // We do the following only for non-login agents, because their scripts + // haven't started yet. +/* moved down + if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) + { + // Viewers which have a current outfit folder will actually rez their own attachments. However, + // viewers without (e.g. v1 viewers) will not, so we still need to make this call. + if (Scene.AttachmentsModule != null) + Util.FireAndForget( + o => + { +// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) +// System.Threading.Thread.Sleep(7000); + + Scene.AttachmentsModule.RezAttachments(this); + }); + } + else + + { + // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT + // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently + // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are + // not transporting the required data. + // + // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT + // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently + // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are + // not transporting the required data. + // + // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of + // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here + // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. + // + // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). + // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing + // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the + // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. + // + // One cannot simply iterate over attachments in a fire and forget thread because this would no longer + // be locked, allowing race conditions if other code changes the attachments list. + + List attachments = GetAttachments(); + + if (attachments.Count > 0) + { + m_log.DebugFormat( + "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? + foreach (SceneObjectGroup sog in attachments) + { +// sending attachments before the avatar ? +// moved to completemovement where it already was +// sog.ScheduleGroupForFullUpdate(); + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); + sog.ResumeScripts(); + } + } + } +*/ /* SendAvatarDataToAllAgents(); -- cgit v1.1 From c7e3e59953d68dd9428188f8a19f055a73bd333b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 20:37:34 +0100 Subject: try no send current LookAt, remove redundant incomplete position height check --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 762dbd4..c49559a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1768,17 +1768,11 @@ namespace OpenSim.Region.Framework.Scenes return; } - Vector3 look = Velocity; - - // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) - if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) - { - look = new Vector3(0.99f, 0.042f, 0); - } - // Prevent teleporting to an underground location // (may crash client otherwise) // + +/* this is done in MakeRootAgent Vector3 pos = AbsolutePosition; float ground = m_scene.GetGroundHeight(pos.X, pos.Y); if (pos.Z < ground + 1.5f) @@ -1786,7 +1780,7 @@ namespace OpenSim.Region.Framework.Scenes pos.Z = ground + 1.5f; AbsolutePosition = pos; } - +*/ bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (!MakeRootAgent(AbsolutePosition, flying)) { @@ -1797,6 +1791,16 @@ namespace OpenSim.Region.Framework.Scenes return; } + Vector3 look = Lookat; + if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) + { + look = Velocity; + look.Z = 0; + look = Util.GetNormalizedVector(look); + if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) ) + look = new Vector3(0.99f, 0.042f, 0); + } + // Tell the client that we're totally ready ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); -- cgit v1.1 From bf269c871adb13915c510f6471028df2cce657b7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 20:59:36 +0100 Subject: use Vector3.normalize in place of util.GetNormalize --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c49559a..77d74ee 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -530,11 +530,8 @@ namespace OpenSim.Region.Framework.Scenes get { Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0); - - if (a == Vector3.Zero) - return a; - - return Util.GetNormalizedVector(a); + a.Normalize(); + return a; } } #endregion @@ -1796,7 +1793,7 @@ namespace OpenSim.Region.Framework.Scenes { look = Velocity; look.Z = 0; - look = Util.GetNormalizedVector(look); + look.Normalize(); if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) ) look = new Vector3(0.99f, 0.042f, 0); } -- cgit v1.1 From 0a1ffad07c0265d880121603062ec8e40e70822a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Aug 2014 03:01:49 +0100 Subject: TEST do a Animator.UpdateMovementAnimations() when making root ( in validate appearence just before sending animation --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 77d74ee..e362063 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3506,7 +3506,11 @@ namespace OpenSim.Region.Framework.Scenes if (m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(UUID); } - + + + if (!IsSatOnObject && Animator != null) + Animator.UpdateMovementAnimations(); + // This agent just became root. We are going to tell everyone about it. The process of // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it // again here... this comes after the cached appearance check because the avatars -- cgit v1.1 From 444b41b22a91c9ec53a28ee0e4449aefb348ec0c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Aug 2014 03:11:55 +0100 Subject: reverted last change since it did nothing usefull --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e362063..ebde92e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3508,9 +3508,6 @@ namespace OpenSim.Region.Framework.Scenes } - if (!IsSatOnObject && Animator != null) - Animator.UpdateMovementAnimations(); - // This agent just became root. We are going to tell everyone about it. The process of // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it // again here... this comes after the cached appearance check because the avatars -- cgit v1.1 From 92117d48afd453ce636f4e4bb8cf6885da9931ab Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Aug 2014 03:54:13 +0100 Subject: remove the region where we are root from the list of Neighbours and childSeeds --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebde92e..67a33ae 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1650,6 +1650,14 @@ namespace OpenSim.Region.Framework.Scenes } } + public void DropThisRootRegionFromNeighbours() + { + ulong handle = m_scene.RegionInfo.RegionHandle; + RemoveNeighbourRegion(handle); + Scene.CapsModule.DropChildSeed(UUID, handle); + } + + public Dictionary KnownRegions { get @@ -1851,6 +1859,10 @@ namespace OpenSim.Region.Framework.Scenes newhide = m_currentParcelHide; m_currentParcelHide = false; + // take this region out of children Neighbours list + // possible should be done elsewhere + DropThisRootRegionFromNeighbours(); + ValidateAndSendAppearanceAndAgentData(); // attachments -- cgit v1.1 From 483afe68679b7c4b5a36917e5fa41d4b0a0e0db4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Aug 2014 18:52:13 +0100 Subject: remove creative hack and try to fix --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 192 +++++++++++----------- 1 file changed, 92 insertions(+), 100 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 49b71e5..902e60b 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -323,22 +323,25 @@ namespace OpenSim.Region.Framework.Scenes m_group = grp; m_scene = grp.Scene; - Vector3 grppos = grp.AbsolutePosition; - Vector3 offset = grppos - m_serializedPosition; - // avoid doing it more than once - // current this will happen draging a prim to other region - m_serializedPosition = grppos; + lock (m_frames) + { + Vector3 grppos = grp.AbsolutePosition; + Vector3 offset = grppos - m_serializedPosition; + // avoid doing it more than once + // current this will happen draging a prim to other region + m_serializedPosition = grppos; - m_basePosition += offset; - m_currentFrame.Position += offset; + m_basePosition += offset; + m_currentFrame.Position += offset; - m_nextPosition += offset; + m_nextPosition += offset; - for (int i = 0; i < m_frames.Count; i++) - { - Keyframe k = m_frames[i]; - k.Position += offset; - m_frames[i]=k; + for (int i = 0; i < m_frames.Count; i++) + { + Keyframe k = m_frames[i]; + k.Position += offset; + m_frames[i] = k; + } } if (m_running) @@ -383,25 +386,28 @@ namespace OpenSim.Region.Framework.Scenes m_keyframes.CopyTo(newmotion.m_keyframes, 0); } - newmotion.m_frames = new List(m_frames); + lock (m_frames) + { + newmotion.m_frames = new List(m_frames); - newmotion.m_basePosition = m_basePosition; - newmotion.m_baseRotation = m_baseRotation; + newmotion.m_basePosition = m_basePosition; + newmotion.m_baseRotation = m_baseRotation; - if (m_selected) - newmotion.m_serializedPosition = m_serializedPosition; - else - { - if (m_group != null) - newmotion.m_serializedPosition = m_group.AbsolutePosition; - else + if (m_selected) newmotion.m_serializedPosition = m_serializedPosition; - } + else + { + if (m_group != null) + newmotion.m_serializedPosition = m_group.AbsolutePosition; + else + newmotion.m_serializedPosition = m_serializedPosition; + } - newmotion.m_currentFrame = m_currentFrame; + newmotion.m_currentFrame = m_currentFrame; - newmotion.m_iterations = m_iterations; - newmotion.m_running = m_running; + newmotion.m_iterations = m_iterations; + newmotion.m_running = m_running; + } if (m_running && !m_waitingCrossing) StartTimer(); @@ -520,7 +526,6 @@ namespace OpenSim.Region.Framework.Scenes k.Position = pos; // k.Velocity = Vector3.Zero; } - k.AngularVelocity = (Vector3)k.Position; k.StartRotation = rot; if (k.Rotation.HasValue) @@ -654,27 +659,29 @@ namespace OpenSim.Region.Framework.Scenes if (m_frames.Count == 0) { - GetNextList(); - - if (m_frames.Count == 0) + lock (m_frames) { - Done(); - Scene scene = m_group.Scene; + GetNextList(); - IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); - foreach (IScriptModule m in scriptModules) + if (m_frames.Count == 0) { - if (m == null) - continue; - m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); - } + Done(); + Scene scene = m_group.Scene; - return; - } + IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); + foreach (IScriptModule m in scriptModules) + { + if (m == null) + continue; + m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); + } - m_currentFrame = m_frames[0]; - m_currentFrame.TimeMS += (int)tickDuration; + return; + } + m_currentFrame = m_frames[0]; + m_currentFrame.TimeMS += (int)tickDuration; + } //force a update on a keyframe transition update = true; } @@ -683,22 +690,26 @@ namespace OpenSim.Region.Framework.Scenes // Do the frame processing double steps = (double)m_currentFrame.TimeMS / tickDuration; - + if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); + m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; // we are sending imediate updates, no doing force a extra terseUpdate // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; - m_frames.RemoveAt(0); - if (m_frames.Count > 0) - m_currentFrame = m_frames[0]; + + lock (m_frames) + { + m_frames.RemoveAt(0); + if (m_frames.Count > 0) + m_currentFrame = m_frames[0]; + } update = true; } @@ -714,7 +725,6 @@ namespace OpenSim.Region.Framework.Scenes { // m_group.AbsolutePosition += motionThisFrame; m_nextPosition = m_group.AbsolutePosition + motionThisFrame; - m_group.AbsolutePosition = m_nextPosition; //m_group.RootPart.Velocity = v; update = true; @@ -726,43 +736,43 @@ namespace OpenSim.Region.Framework.Scenes Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); step.Normalize(); -/* use simpler change detection -* float angle = 0; - - float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; - float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; - float aa_bb = aa * bb; - - if (aa_bb == 0) - { - angle = 0; - } - else - { - float ab = current.X * step.X + - current.Y * step.Y + - current.Z * step.Z + - current.W * step.W; - float q = (ab * ab) / aa_bb; - - if (q > 1.0f) - { - angle = 0; - } - else - { - angle = (float)Math.Acos(2 * q - 1); - } - } - - if (angle > 0.01f) -*/ + /* use simpler change detection + * float angle = 0; + + float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; + float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; + float aa_bb = aa * bb; + + if (aa_bb == 0) + { + angle = 0; + } + else + { + float ab = current.X * step.X + + current.Y * step.Y + + current.Z * step.Z + + current.W * step.W; + float q = (ab * ab) / aa_bb; + + if (q > 1.0f) + { + angle = 0; + } + else + { + angle = (float)Math.Acos(2 * q - 1); + } + } + + if (angle > 0.01f) + */ if (Math.Abs(step.X - current.X) > 0.001f || Math.Abs(step.Y - current.Y) > 0.001f || Math.Abs(step.Z - current.Z) > 0.001f) // assuming w is a dependente var { -// m_group.UpdateGroupRotationR(step); + // m_group.UpdateGroupRotationR(step); m_group.RootPart.RotationOffset = step; //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); @@ -773,29 +783,11 @@ namespace OpenSim.Region.Framework.Scenes if (update) { + m_group.AbsolutePosition = m_nextPosition; m_group.SendGroupRootTerseUpdate(); } } - private Vector3 NormalizeVector(Vector3? pPosition) - { - if (pPosition == null) - return Vector3.Zero; - - Vector3 tmp = (Vector3) pPosition; - while (tmp.X > Constants.RegionSize) - tmp.X -= Constants.RegionSize; - while (tmp.X < 0) - tmp.X += Constants.RegionSize; - while (tmp.Y > Constants.RegionSize) - tmp.Y -= Constants.RegionSize; - while (tmp.Y < 0) - tmp.Y += Constants.RegionSize; - - return tmp; - - - } public Byte[] Serialize() { StopTimer(); -- cgit v1.1 From ca28062722cfa6f4a6221930ad4e988ae1ebeea6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 14 Aug 2014 12:34:07 +0100 Subject: dont mess with Throttles in code also used to send to main regions. Use full parameters on appearance cloning so its clear we want it all --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 67a33ae..0f67d07 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4073,6 +4073,9 @@ namespace OpenSim.Region.Framework.Scenes // Throttles float multiplier = 1; + +/* this is also used to send to new main regions not children + int childRegions = KnownRegionCount; if (childRegions != 0) multiplier = 1f / childRegions; @@ -4080,7 +4083,7 @@ namespace OpenSim.Region.Framework.Scenes // Minimum throttle for a child region is 1/4 of the root region throttle if (multiplier <= 0.25f) multiplier = 0.25f; - +*/ cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); cAgent.HeadRotation = m_headrotation; @@ -4094,7 +4097,8 @@ namespace OpenSim.Region.Framework.Scenes cAgent.AlwaysRun = SetAlwaysRun; - cAgent.Appearance = new AvatarAppearance(Appearance); + // make clear we want the all thing + cAgent.Appearance = new AvatarAppearance(Appearance,true,true); cAgent.ParentPart = ParentUUID; cAgent.SitOffset = PrevSitOffset; -- cgit v1.1 From dc178959c5c4e29890e09056e5528e9bf311fe5f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 16 Aug 2014 14:52:09 +0100 Subject: change how avatar data, appearance and animations are sent, specially the order --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 210 +++++++++++------------ 1 file changed, 98 insertions(+), 112 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0f67d07..faa5334 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1806,6 +1806,17 @@ namespace OpenSim.Region.Framework.Scenes look = new Vector3(0.99f, 0.042f, 0); } + if (!IsChildAgent) + { + InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46); + if (cof == null) + COF = UUID.Zero; + else + COF = cof.ID; + + m_log.DebugFormat("[ScenePresence]: CompleteMovement COF for {0} is {1}", client.AgentId, COF); + } + // Tell the client that we're totally ready ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); @@ -2776,34 +2787,15 @@ namespace OpenSim.Region.Framework.Scenes if (satOnObject) { -// SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; - part.RemoveSittingAvatar(UUID); - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - } - else if (PhysicsActor == null) - AddToPhysicalScene(false); + SendAvatarDataToAllAgents(); + } Animator.TrySetMovementAnimation("STAND"); - if (satOnObject) - { - ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X,AbsolutePosition.Y); - if (land != null) - { - UUID parcelID = land.LandData.GlobalID; - if (m_currentParcelUUID != parcelID) - currentParcelUUID = parcelID; - else - SendAvatarDataToAllAgents(); - } - else - SendAvatarDataToAllAgents(); - } - TriggerScenePresenceUpdated(); } @@ -3078,11 +3070,14 @@ namespace OpenSim.Region.Framework.Scenes ParentPart = part; ParentID = part.LocalId; + + SendAvatarDataToAllAgents(); + if(status == 3) Animator.TrySetMovementAnimation("SIT_GROUND"); else Animator.TrySetMovementAnimation("SIT"); - SendAvatarDataToAllAgents(); + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } @@ -3182,13 +3177,14 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; RemoveFromPhysicalScene(); + SendAvatarDataToAllAgents(); + String sitAnimation = "SIT"; if (!String.IsNullOrEmpty(part.SitAnimation)) { sitAnimation = part.SitAnimation; } Animator.TrySetMovementAnimation(sitAnimation); - SendAvatarDataToAllAgents(); TriggerScenePresenceUpdated(); } } @@ -3478,8 +3474,8 @@ namespace OpenSim.Region.Framework.Scenes landch.sendClientInitialLandInfo(ControllingClient); } } - SendOtherAgentsAvatarDataToMe(); - SendOtherAgentsAppearanceToMe(); + + SendOtherAgentsAvatarFullToMe(); EntityBase[] entities = Scene.Entities.GetEntities(); foreach (EntityBase e in entities) @@ -3508,40 +3504,45 @@ namespace OpenSim.Region.Framework.Scenes // to see if all the baked textures are already here. if (m_scene.AvatarFactory != null) cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this); - + // If we aren't using a cached appearance, then clear out the baked textures if (!cachedappearance) { -// Appearance.ResetAppearance(); -// save what ???? -// maybe needed so the tryretry repair works? if (m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(UUID); } - - // This agent just became root. We are going to tell everyone about it. The process of - // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it - // again here... this comes after the cached appearance check because the avatars - // appearance goes into the avatar update packet SendAvatarDataToAllAgents(); - - // This invocation always shows up in the viewer logs as an error. Is it needed? - // send all information we have - // possible not needed since viewer should ask about it - // least it all ask for baked SendAppearanceToAgent(this); - // If we are using the the cached appearance then send it out to everyone - // send even grays - if (cachedappearance) +// if (cachedappearance) +// { + SendAppearanceToAllOtherAgents(); +// } + Animator.SendAnimPack(); + } + + /// + /// Send avatar full data appearance and animations for all other root agents to this agent, this agent + /// can be either a child or root + /// + public void SendOtherAgentsAvatarFullToMe() + { + int count = 0; + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { -// m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); - // If the avatars baked textures are all in the cache, then we have a - // complete appearance... send it out, if not, then we'll send it when - // the avatar finishes updating its appearance - SendAppearanceToAllOtherAgents(); - } + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; + + scenePresence.SendAvatarDataToAgent(this); + scenePresence.SendAppearanceToAgent(this); + scenePresence.SendAnimPackToAgent(this); + // for now attachments are sent with all SOG + count++; + }); + + m_scene.StatsReporter.AddAgentUpdates(count); } /// @@ -3566,33 +3567,12 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { - SendAvatarDataToAgent(scenePresence); - count++; + SendAvatarDataToAgent(scenePresence); + count++; }); m_scene.StatsReporter.AddAgentUpdates(count); } - - /// - /// Send avatar data for all other root agents to this agent, this agent - /// can be either a child or root - /// - public void SendOtherAgentsAvatarDataToMe() - { - int count = 0; - - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) - { - // only send information about other root agents - if (scenePresence.UUID == UUID) - return; - - scenePresence.SendAvatarDataToAgent(this); - count++; - }); - - m_scene.StatsReporter.AddAgentUpdates(count); - } /// /// Send avatar data to an agent. @@ -3604,7 +3584,6 @@ namespace OpenSim.Region.Framework.Scenes if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) return; avatar.ControllingClient.SendAvatarDataImmediate(this); - Animator.SendAnimPackToClient(avatar.ControllingClient); } /// @@ -3639,28 +3618,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Send appearance from all other root agents to this agent. this agent - /// can be either root or child - /// - public void SendOtherAgentsAppearanceToMe() - { -// m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID); - - int count = 0; - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) - { - // only send information about other root agents - if (scenePresence.UUID == UUID) - return; - - scenePresence.SendAppearanceToAgent(this); - count++; - }); - - m_scene.StatsReporter.AddAgentUpdates(count); - } - - /// /// Send appearance data to an agent. /// /// @@ -3674,6 +3631,30 @@ namespace OpenSim.Region.Framework.Scenes UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); } + public void SendAnimPackToAgent(ScenePresence p) + { + if (IsChildAgent || Animator == null) + return; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + Animator.SendAnimPackToClient(p.ControllingClient); + } + + public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) + { + if (IsChildAgent) + return; + + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); + }); + } + #endregion #region Significant Movement Method @@ -4193,13 +4174,15 @@ namespace OpenSim.Region.Framework.Scenes } catch { } + Animator.ResetAnimations(); + // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? - if (cAgent.Anims != null) - Animator.Animations.FromArray(cAgent.Anims); if (cAgent.DefaultAnim != null) Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); if (cAgent.AnimState != null) Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); + if (cAgent.Anims != null) + Animator.Animations.FromArray(cAgent.Anims); if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); @@ -5442,6 +5425,7 @@ namespace OpenSim.Region.Framework.Scenes p.SendAttachmentsToClient(ControllingClient); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); + } } } @@ -5597,36 +5581,37 @@ namespace OpenSim.Region.Framework.Scenes if (GodLevel >= 200) return; - List killsToSendme = new List(); + List killsToSendme = new List(); foreach (ScenePresence p in allpresences) { if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; if (p.currentParcelUUID == m_currentParcelUUID) - { - killsToSendme.Add(p); + { + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + killsToSendme.Add(p.LocalId); } } if (killsToSendme.Count > 0) { - foreach (ScenePresence p in killsToSendme) + try { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); - try { ControllingClient.SendKillObject(new List { p.LocalId }); } - catch (NullReferenceException) { } + ControllingClient.SendKillObject(killsToSendme); } + catch (NullReferenceException) { } } + + } } - private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) { List killsToSendto = new List(); - List killsToSendme = new List(); + List killsToSendme = new List(); List viewsToSendto = new List(); List viewsToSendme = new List(); List allpresences = null; @@ -5697,7 +5682,7 @@ namespace OpenSim.Region.Framework.Scenes if(p.GodLevel < 200) killsToSendto.Add(p); // they dont see me if(GodLevel < 200) - killsToSendme.Add(p); // i dont see them + killsToSendme.Add(p.LocalId); // i dont see them } // only those on new parcel need see if (currentParcelID == p.currentParcelUUID) @@ -5746,7 +5731,7 @@ namespace OpenSim.Region.Framework.Scenes // only those old parcel need receive kills if (previusParcelID == p.currentParcelUUID && GodLevel < 200) { - killsToSendme.Add(p); // i dont see them + killsToSendme.Add(p.LocalId); // i dont see them } else { @@ -5771,14 +5756,15 @@ namespace OpenSim.Region.Framework.Scenes } } - if (killsToSendme.Count > 0 ) + if (killsToSendme.Count > 0) { - foreach (ScenePresence p in killsToSendme) + m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString()); + try { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); - try {ControllingClient.SendKillObject(new List { p.LocalId }); } - catch (NullReferenceException) { } + ControllingClient.SendKillObject(killsToSendme); } + catch (NullReferenceException) { } + } if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) -- cgit v1.1 From f6642a1cc88db4d021a5f6ed8e983622bb598003 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 16 Aug 2014 21:53:45 +0100 Subject: minor low resolution debug timming --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index faa5334..fc08b07 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1754,7 +1754,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void CompleteMovement(IClientAPI client, bool openChildAgents) { -// DateTime startTime = DateTime.Now; + int ts = Util.EnvironmentTickCount(); m_log.InfoFormat( "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", @@ -1947,6 +1947,8 @@ namespace OpenSim.Region.Framework.Scenes ParcelLoginCheck(m_currentParcelUUID); m_currentParcelHide = newhide; } + + m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); } /// -- cgit v1.1 From f8b8cf3d8f6c5454967ce1707a007383e3fc5a42 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 16 Aug 2014 22:16:15 +0100 Subject: more detailed timing on completmovement --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fc08b07..5af6a6c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1786,6 +1786,9 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = pos; } */ + + m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (!MakeRootAgent(AbsolutePosition, flying)) { @@ -1796,6 +1799,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + Vector3 look = Lookat; if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) { @@ -1827,6 +1832,8 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); + m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + if (!string.IsNullOrEmpty(m_callbackURI)) { // We cannot sleep here since this would hold up the inbound packet processing thread, as @@ -1855,6 +1862,8 @@ namespace OpenSim.Region.Framework.Scenes // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); // } + m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + m_previusParcelHide = false; m_previusParcelUUID = UUID.Zero; m_currentParcelHide = false; @@ -1876,6 +1885,8 @@ namespace OpenSim.Region.Framework.Scenes ValidateAndSendAppearanceAndAgentData(); + m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + // attachments if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { @@ -1905,6 +1916,8 @@ namespace OpenSim.Region.Framework.Scenes } } + m_log.DebugFormat("[CompleteMovement] attachments: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + // Create child agents in neighbouring regions if (openChildAgents) { @@ -1914,10 +1927,14 @@ namespace OpenSim.Region.Framework.Scenes } } + m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + // send the rest of the world if (m_teleportFlags > 0 && !isNPC) SendInitialDataToMe(); + m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + if (!IsChildAgent) { // moved from makeroot missing in sendInitialDataToMe @@ -1934,6 +1951,8 @@ namespace OpenSim.Region.Framework.Scenes IFriendsModule friendsModule = m_scene.RequestModuleInterface(); if (friendsModule != null) friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + + m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); } } } -- cgit v1.1 From 31a2c07e833cab6ca2f14e493fd1b96e776097c2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Aug 2014 09:54:38 +0100 Subject: put bake bakes, plus a missing change forcing animations to pass by scenepresence --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index ecd6a09..668087f 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -557,6 +557,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) { +/* if (m_scenePresence.IsChildAgent) return; @@ -571,6 +572,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation { client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs); }); + */ + m_scenePresence.SendAnimPack(animations, seqs, objectIDs); } public void SendAnimPackToClient(IClientAPI client) @@ -602,7 +605,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); - SendAnimPack(animIDs, sequenceNums, objectIDs); +// SendAnimPack(animIDs, sequenceNums, objectIDs); + m_scenePresence.SendAnimPack(animIDs, sequenceNums, objectIDs); } public string GetAnimName(UUID animId) -- cgit v1.1 From f8e4805d98dc464b703beb21b5896b62a9efded2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Aug 2014 01:34:16 +0100 Subject: NOT GOOD. Changed hide code on crossing/tp. Send needed avatar and attachments kills, visible so we can see what is going on, to try to improve later (this are always needed, hidding just made issues more visible ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 95 +++++++++++++++--------- 1 file changed, 60 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5af6a6c..977ff24 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1400,7 +1400,7 @@ namespace OpenSim.Region.Framework.Scenes else Animator.ResetAnimations(); - + // m_log.DebugFormat( // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", // Name, UUID, m_scene.RegionInfo.RegionName); @@ -1876,17 +1876,14 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) { - newhide = m_currentParcelHide; - m_currentParcelHide = false; - // take this region out of children Neighbours list - // possible should be done elsewhere - DropThisRootRegionFromNeighbours(); ValidateAndSendAppearanceAndAgentData(); m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + List attachments = GetAttachments(); + // attachments if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { @@ -1899,8 +1896,6 @@ namespace OpenSim.Region.Framework.Scenes } else { - List attachments = GetAttachments(); - if (attachments.Count > 0) { m_log.DebugFormat( @@ -1930,7 +1925,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts)); // send the rest of the world - if (m_teleportFlags > 0 && !isNPC) + if (m_teleportFlags > 0 && !isNPC || m_currentParcelHide) SendInitialDataToMe(); m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -1961,11 +1956,11 @@ namespace OpenSim.Region.Framework.Scenes m_inTransit = false; } // if hide force a check - if (!IsChildAgent && newhide) - { - ParcelLoginCheck(m_currentParcelUUID); - m_currentParcelHide = newhide; - } + // if (!IsChildAgent && newhide) + // { + // ParcelLoginCheck(m_currentParcelUUID); + // m_currentParcelHide = newhide; + // } m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); } @@ -3533,14 +3528,25 @@ namespace OpenSim.Region.Framework.Scenes m_scene.AvatarFactory.QueueAppearanceSave(UUID); } + bool newhide = m_currentParcelHide; + m_currentParcelHide = false; + SendAvatarDataToAllAgents(); + + if (newhide) + { + ParcelLoginCheck(m_currentParcelUUID); + m_currentParcelHide = true; + } + SendAppearanceToAgent(this); // if (cachedappearance) // { SendAppearanceToAllOtherAgents(); // } - Animator.SendAnimPack(); + if(Animator!= null) + Animator.SendAnimPack(); } /// @@ -5481,7 +5487,7 @@ namespace OpenSim.Region.Framework.Scenes private void ParcelLoginCheck(UUID currentParcelID) { List killsToSendto = new List(); - List killsToSendme = new List(); + List killsToSendme = new List(); List viewsToSendto = new List(); List viewsToSendme = new List(); List allpresences = null; @@ -5498,7 +5504,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.GodLevel < 200) killsToSendto.Add(p); if (GodLevel < 200 && p.ParcelHideThisAvatar) - killsToSendme.Add(p); + killsToSendme.Add(p.LocalId); } else { @@ -5522,14 +5528,15 @@ namespace OpenSim.Region.Framework.Scenes if (killsToSendme.Count > 0) { - foreach (ScenePresence p in killsToSendme) + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + killsToSendme.Count.ToString()); + try { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); - try { ControllingClient.SendKillObject(new List { p.LocalId }); } - catch (NullReferenceException) { } + ControllingClient.SendKillObject(killsToSendme); } - } + catch (NullReferenceException) { } + } +/* if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) { foreach (ScenePresence p in viewsToSendto) @@ -5557,16 +5564,18 @@ namespace OpenSim.Region.Framework.Scenes p.Animator.SendAnimPackToClient(ControllingClient); } } +*/ } public void parcelRegionCross(bool abort) { - if (!ParcelHideThisAvatar) - return; +// if (!ParcelHideThisAvatar) +// return; List allpresences = null; allpresences = m_scene.GetScenePresences(); +// abort no longer complet if (abort) { List viewsToSendme = new List(); @@ -5588,7 +5597,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p.IsChildAgent) continue; -// m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); + // m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); p.SendAttachmentsToClient(ControllingClient); @@ -5599,22 +5608,36 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (GodLevel >= 200) - return; + bool inprivate = ParcelHideThisAvatar && GodLevel < 200; List killsToSendme = new List(); - foreach (ScenePresence p in allpresences) + + if (inprivate) { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; - if (p.currentParcelUUID == m_currentParcelUUID) - { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); - killsToSendme.Add(p.LocalId); + if (p.currentParcelUUID == m_currentParcelUUID) + { + m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); + killsToSendme.Add(p.LocalId); + } } } +/* + else + { + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + killsToSendme.Add(p.LocalId); + } + } +*/ if (killsToSendme.Count > 0) { try @@ -5623,8 +5646,10 @@ namespace OpenSim.Region.Framework.Scenes } catch (NullReferenceException) { } } + + if (Scene.AttachmentsModule != null) + Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); - } } -- cgit v1.1 From 96de2a2fd2feed899d19fabc077a1bd3f7cc3fc8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Aug 2014 04:07:40 +0100 Subject: reduce the kills sent, hide attachments kills on origin --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 89 +++++------------------- 1 file changed, 17 insertions(+), 72 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 977ff24..20d0f29 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5503,8 +5503,8 @@ namespace OpenSim.Region.Framework.Scenes { if (p.GodLevel < 200) killsToSendto.Add(p); - if (GodLevel < 200 && p.ParcelHideThisAvatar) - killsToSendme.Add(p.LocalId); +// if (GodLevel < 200 && p.ParcelHideThisAvatar) +// killsToSendme.Add(p.LocalId); } else { @@ -5567,89 +5567,34 @@ namespace OpenSim.Region.Framework.Scenes */ } - public void parcelRegionCross(bool abort) + public void parcelRegionCross() { -// if (!ParcelHideThisAvatar) -// return; + if (!ParcelHideThisAvatar || GodLevel >= 200) + return; List allpresences = null; allpresences = m_scene.GetScenePresences(); -// abort no longer complet - if (abort) - { - List viewsToSendme = new List(); - - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (p.currentParcelUUID == m_currentParcelUUID) - { - viewsToSendme.Add(p); - } - } + List killsToSendme = new List(); - if (viewsToSendme.Count > 0) - { - foreach (ScenePresence p in viewsToSendme) - { - if (p.IsChildAgent) - continue; - // m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - } - } - } - else + foreach (ScenePresence p in allpresences) { + if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; - bool inprivate = ParcelHideThisAvatar && GodLevel < 200; - List killsToSendme = new List(); - - if (inprivate) + if (p.currentParcelUUID == m_currentParcelUUID) { - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (p.currentParcelUUID == m_currentParcelUUID) - { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); - killsToSendme.Add(p.LocalId); - } - } + killsToSendme.Add(p.LocalId); } -/* - else - { - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; + } - killsToSendme.Add(p.LocalId); - } - } -*/ - if (killsToSendme.Count > 0) + if (killsToSendme.Count > 0) + { + try { - try - { - ControllingClient.SendKillObject(killsToSendme); - } - catch (NullReferenceException) { } + ControllingClient.SendKillObject(killsToSendme); } - - if (Scene.AttachmentsModule != null) - Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); - + catch (NullReferenceException) { } } } -- cgit v1.1 From 83e545df934fc93698b53f9e1ec9621157e93c39 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Aug 2014 19:14:53 +0100 Subject: *DANGER* *HACKS* on reusing child presences: partA send kills to viewers, partB keep using same localID (as before) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 20d0f29..3c7e4a2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5567,6 +5567,7 @@ namespace OpenSim.Region.Framework.Scenes */ } + public void parcelRegionCross() { if (!ParcelHideThisAvatar || GodLevel >= 200) -- cgit v1.1 From 73b8dc4183772f584e9c3477217e8736311ebd88 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Aug 2014 19:19:25 +0100 Subject: missing file for previus commit --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0266faf..dc3f57a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3903,6 +3903,16 @@ namespace OpenSim.Region.Framework.Scenes sp.LifecycleState = ScenePresenceState.Running; + + //HACK part A + // kill in viewers sp.localID that they may still know about + + SendKillObject(new List { sp.LocalId }); + + //HACK part B + // keep using same localID + + if (EntityTransferModule.IsInTransit(sp.UUID)) { sp.DoNotCloseAfterTeleport = true; -- cgit v1.1 From d31f361e8900aebb27f220bf0120dec5eb14c78a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Aug 2014 19:41:16 +0100 Subject: moved hacks to scene presence completemovement, possible only needed there? --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ---------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dc3f57a..0266faf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3903,16 +3903,6 @@ namespace OpenSim.Region.Framework.Scenes sp.LifecycleState = ScenePresenceState.Running; - - //HACK part A - // kill in viewers sp.localID that they may still know about - - SendKillObject(new List { sp.LocalId }); - - //HACK part B - // keep using same localID - - if (EntityTransferModule.IsInTransit(sp.UUID)) { sp.DoNotCloseAfterTeleport = true; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3c7e4a2..1ace0d9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1767,10 +1767,20 @@ namespace OpenSim.Region.Framework.Scenes // Make sure it's not a login agent. We don't want to wait for updates during login if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) { + // Let's wait until UpdateAgent (called by departing region) is done if (!WaitForUpdateAgent(client)) // The sending region never sent the UpdateAgent data, we have to refuse return; + + //HACK part A + // kill in viewers sp.localID that they may still know about + m_log.DebugFormat("[CompleteMovement] send old child kills"); + m_scene.SendKillObject(new List { LocalId }); + + //HACK part B + // keep using same localID + } // Prevent teleporting to an underground location -- cgit v1.1 From ffcc1d7fa2735e478b5d020950aa7152e6da2713 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Aug 2014 23:14:04 +0100 Subject: undo the hack.. its useless --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 --------- 1 file changed, 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1ace0d9..6811546 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1772,15 +1772,6 @@ namespace OpenSim.Region.Framework.Scenes if (!WaitForUpdateAgent(client)) // The sending region never sent the UpdateAgent data, we have to refuse return; - - //HACK part A - // kill in viewers sp.localID that they may still know about - m_log.DebugFormat("[CompleteMovement] send old child kills"); - m_scene.SendKillObject(new List { LocalId }); - - //HACK part B - // keep using same localID - } // Prevent teleporting to an underground location -- cgit v1.1 From e77fafe12d622ba7ce251b1c686fc6fb5fd9579a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 02:15:01 +0100 Subject: *test* send attachments in sync, resend avatar at end --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6811546..fe9b1bb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1905,7 +1905,15 @@ namespace OpenSim.Region.Framework.Scenes // Resume scripts this possible should also be moved down after sending the avatar to viewer ? foreach (SceneObjectGroup sog in attachments) { - sog.ScheduleGroupForFullUpdate(); + // sog.ScheduleGroupForFullUpdate(); + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + sog.SendFullUpdateToClient(p.ControllingClient); + p.ControllingClient.SendAvatarDataImmediate(this); // resend our data -> test + }); + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); } -- cgit v1.1 From 9914e371af90da86c47fe1f57ecfd578cd8e1169 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 04:54:25 +0100 Subject: minor changes to GetPriorityByBestAvatarResponsiveness code --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index ddae073..36a3e37 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -157,30 +157,31 @@ namespace OpenSim.Region.Framework.Scenes private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) { - uint pqueue = ComputeDistancePriority(client,entity,false); + uint pqueue = 2; // keep compiler happy ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { - if (!presence.IsChildAgent) + // All avatars other than our own go into pqueue 1 + if (entity is ScenePresence) + return 1; + + if (entity is SceneObjectPart) { - // All avatars other than our own go into pqueue 1 - if (entity is ScenePresence) + // Attachments are high priority, + if (((SceneObjectPart)entity).ParentGroup.IsAttachment) return 1; - - if (entity is SceneObjectPart) - { - // Attachments are high priority, - if (((SceneObjectPart)entity).ParentGroup.IsAttachment) - return 1; - // Non physical prims are lower priority than physical prims - PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; - if (physActor == null || !physActor.IsPhysical) - pqueue++; - } + pqueue = ComputeDistancePriority(client, entity, false); + + // Non physical prims are lower priority than physical prims + PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; + if (physActor == null || !physActor.IsPhysical) + pqueue++; } } + else + pqueue = ComputeDistancePriority(client, entity, false); return pqueue; } -- cgit v1.1 From 42a58101cf21a52d6a0cdb9068c102fac6fe6e63 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 04:56:33 +0100 Subject: HACK force GetPriorityByBestAvatarResponsiveness ignoring configuration --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 36a3e37..19d2689 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -91,6 +91,11 @@ namespace OpenSim.Region.Framework.Scenes return 0; uint priority; + + + // HACK + return GetPriorityByBestAvatarResponsiveness(client, entity); + switch (m_scene.UpdatePrioritizationScheme) { -- cgit v1.1 From 1c9af8727d73f64fdf50f6ec9a95dc4b9b77f0cd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 05:13:18 +0100 Subject: send the avatar data after sending attachments, by the same Entity updates path --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 48 ++++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fe9b1bb..f58d7f2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1908,10 +1908,12 @@ namespace OpenSim.Region.Framework.Scenes // sog.ScheduleGroupForFullUpdate(); m_scene.ForEachScenePresence(delegate(ScenePresence p) { + if (p != this && sog.HasPrivateAttachmentPoint) + return; if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; sog.SendFullUpdateToClient(p.ControllingClient); - p.ControllingClient.SendAvatarDataImmediate(this); // resend our data -> test + SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); @@ -3377,6 +3379,16 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAgentTerseUpdate(p); } + public void SendFullUpdateToClient(IClientAPI remoteClient) + { + if (remoteClient.IsActive) + { + //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); + remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate); + m_scene.StatsReporter.AddAgentUpdates(1); + } + } + /// /// Sends a location update to the client connected to this scenePresence /// via entity updates @@ -4672,15 +4684,37 @@ namespace OpenSim.Region.Framework.Scenes return validated; } + public void SendAttachmentsToAllAgents() + { + lock (m_attachments) + { + foreach (SceneObjectGroup sog in m_attachments) + { + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (p != this && sog.HasPrivateAttachmentPoint) + return; + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + sog.SendFullUpdateToClient(p.ControllingClient); + SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path + }); + } + } + } - public void SendAttachmentsToClient(IClientAPI client) + // send attachments to a client without filters except for huds + // for now they are checked in several places down the line... + public void SendAttachmentsToAgentNF(ScenePresence p) { lock (m_attachments) { - foreach (SceneObjectGroup gobj in m_attachments) + foreach (SceneObjectGroup sog in m_attachments) { - gobj.SendFullUpdateToClient(client); + if (p == this || !sog.HasPrivateAttachmentPoint) + sog.SendFullUpdateToClient(p.ControllingClient); } + SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path } } @@ -5458,7 +5492,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); + p.SendAttachmentsToAgentNF(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); @@ -5775,7 +5809,7 @@ namespace OpenSim.Region.Framework.Scenes p.ControllingClient.SendAvatarDataImmediate(this); // m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); SendAppearanceToAgent(p); - SendAttachmentsToClient(p.ControllingClient); + SendAttachmentsToAgentNF(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); } @@ -5790,7 +5824,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); + p.SendAttachmentsToAgentNF(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); } -- cgit v1.1 From 65983cc4fcef4ebba0d288301b8db73ee0981992 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 06:23:30 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f58d7f2..6208416 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1882,9 +1882,7 @@ namespace OpenSim.Region.Framework.Scenes ValidateAndSendAppearanceAndAgentData(); m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - - List attachments = GetAttachments(); - + // attachments if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { @@ -1897,13 +1895,13 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (attachments.Count > 0) + if (m_attachments.Count > 0) { m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); // Resume scripts this possible should also be moved down after sending the avatar to viewer ? - foreach (SceneObjectGroup sog in attachments) + foreach (SceneObjectGroup sog in m_attachments) { // sog.ScheduleGroupForFullUpdate(); m_scene.ForEachScenePresence(delegate(ScenePresence p) @@ -5809,9 +5807,9 @@ namespace OpenSim.Region.Framework.Scenes p.ControllingClient.SendAvatarDataImmediate(this); // m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); SendAppearanceToAgent(p); - SendAttachmentsToAgentNF(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); + SendAttachmentsToAgentNF(p); } } @@ -5824,9 +5822,9 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); ControllingClient.SendAvatarDataImmediate(p); p.SendAppearanceToAgent(this); - p.SendAttachmentsToAgentNF(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); + p.SendAttachmentsToAgentNF(this); } } } -- cgit v1.1 From e883fb519b51642320526dad279e85c1e13646d9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 06:53:02 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 53 ++++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6208416..e3e8871 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1912,6 +1912,7 @@ namespace OpenSim.Region.Framework.Scenes return; sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path + SendTerseUpdateToAgent(p); }); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); @@ -3370,11 +3371,16 @@ namespace OpenSim.Region.Framework.Scenes #region Update Client(s) - // this is diferente from SendTerseUpdateToClient - // this sends bypassing ententies updates - public void SendAgentTerseUpdate(ISceneEntity p) + public void SendUpdateToAgent(ScenePresence p) { - ControllingClient.SendAgentTerseUpdate(p); + IClientAPI remoteClient = p.ControllingClient; + + if (remoteClient.IsActive) + { + //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); + remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate); + m_scene.StatsReporter.AddAgentUpdates(1); + } } public void SendFullUpdateToClient(IClientAPI remoteClient) @@ -3387,6 +3393,13 @@ namespace OpenSim.Region.Framework.Scenes } } + // this is diferente from SendTerseUpdateToClient + // this sends bypassing entities updates + public void SendAgentTerseUpdate(ISceneEntity p) + { + ControllingClient.SendAgentTerseUpdate(p); + } + /// /// Sends a location update to the client connected to this scenePresence /// via entity updates @@ -3408,7 +3421,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void SendTerseUpdateToAgentClient(ScenePresence p) + public void SendTerseUpdateToAgent(ScenePresence p) { IClientAPI remoteClient = p.ControllingClient; @@ -3427,6 +3440,18 @@ namespace OpenSim.Region.Framework.Scenes m_scene.StatsReporter.AddAgentUpdates(1); } + public void SendTerseUpdateToAgentNF(ScenePresence p) + { + IClientAPI remoteClient = p.ControllingClient; + if (remoteClient.IsActive) + { + //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); + remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate); + m_scene.StatsReporter.AddAgentUpdates(1); + } + } + + // vars to support reduced update frequency when velocity is unchanged private Vector3 lastVelocitySentToAllClients = Vector3.Zero; private Vector3 lastPositionSentToAllClients = Vector3.Zero; @@ -3468,7 +3493,7 @@ namespace OpenSim.Region.Framework.Scenes // Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); // m_scene.ForEachClient(SendTerseUpdateToClient); - m_scene.ForEachScenePresence(SendTerseUpdateToAgentClient); + m_scene.ForEachScenePresence(SendTerseUpdateToAgent); } TriggerScenePresenceUpdated(); } @@ -5487,13 +5512,13 @@ namespace OpenSim.Region.Framework.Scenes { if (p.IsChildAgent) continue; - m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); + + p.SendUpdateToAgent(this); + p.SendAgentTerseUpdate(this); p.SendAppearanceToAgent(this); - p.SendAttachmentsToAgentNF(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); - + p.SendAttachmentsToAgentNF(this); } } } @@ -5804,8 +5829,8 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendto) { - p.ControllingClient.SendAvatarDataImmediate(this); -// m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); + SendUpdateToAgent(p); + SendAgentTerseUpdate(p); SendAppearanceToAgent(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); @@ -5820,7 +5845,9 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsChildAgent) continue; // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - ControllingClient.SendAvatarDataImmediate(p); + + p.SendUpdateToAgent(this); + p.SendAgentTerseUpdate(this); p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); -- cgit v1.1 From b0253362c7f93543b50943f71485a3b3d9bcf2f2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 09:18:29 +0100 Subject: remove the silly sendTerseUpdates. I was fooled by wingridproxy not decoding updates correctly --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e3e8871..4f768bb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5514,7 +5514,6 @@ namespace OpenSim.Region.Framework.Scenes continue; p.SendUpdateToAgent(this); - p.SendAgentTerseUpdate(this); p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); @@ -5830,7 +5829,6 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in viewsToSendto) { SendUpdateToAgent(p); - SendAgentTerseUpdate(p); SendAppearanceToAgent(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); @@ -5847,7 +5845,6 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); p.SendUpdateToAgent(this); - p.SendAgentTerseUpdate(this); p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); -- cgit v1.1 From ca43a7fe63f8c2582c59419ce29687609e5e4257 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 09:42:45 +0100 Subject: variationsss... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4f768bb..8c3f516 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1912,7 +1912,6 @@ namespace OpenSim.Region.Framework.Scenes return; sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path - SendTerseUpdateToAgent(p); }); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); @@ -3657,6 +3656,11 @@ namespace OpenSim.Region.Framework.Scenes avatar.ControllingClient.SendAvatarDataImmediate(this); } + public void SendAvatarDataToAgentNF(ScenePresence avatar) + { + avatar.ControllingClient.SendAvatarDataImmediate(this); + } + /// /// Send this agent's appearance to all other root and child agents in the scene /// This agent must be root. @@ -5513,7 +5517,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsChildAgent) continue; - p.SendUpdateToAgent(this); + p.SendAvatarDataToAgentNF(this); p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); @@ -5828,7 +5832,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in viewsToSendto) { - SendUpdateToAgent(p); + SendAvatarDataToAgentNF(p); SendAppearanceToAgent(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); @@ -5844,7 +5848,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - p.SendUpdateToAgent(this); + p.SendAvatarDataToAgentNF(this); p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); -- cgit v1.1 From cca2ae3c896fd61cb66d31cc59ace2b1361cdcd5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 19:47:41 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 150 ++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8c3f516..ad70ce3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4745,6 +4745,152 @@ namespace OpenSim.Region.Framework.Scenes } } + public void SendAttachmentsToAgentNFPK(ScenePresence p) + { + lock (m_attachments) + { + List pk = new List(); + foreach (SceneObjectGroup sog in m_attachments) + { + foreach (SceneObjectPart part in sog.Parts) + pk.Add(part.LocalId); + } + + p.ControllingClient.SendKillObject(pk); + + foreach (SceneObjectGroup sog in m_attachments) + { + if (p == this || !sog.HasPrivateAttachmentPoint) + sog.SendFullUpdateToClient(p.ControllingClient); + } + SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path + } + } + + + public void SendAttachmentScheduleUpdate(SceneObjectGroup sog) + { + if (IsChildAgent) + return; + + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (p != this && sog.HasPrivateAttachmentPoint) + return; + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + SceneObjectPart[] parts = sog.Parts; + + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + if (part.UpdateFlag == UpdateRequired.TERSE) + { + p.ControllingClient.SendEntityUpdate(part, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + part.UpdateFlag = 0; + } + else if (part.UpdateFlag == UpdateRequired.FULL) + { + p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); + part.UpdateFlag = 0; + } + } + }); + } + + public void SendAttachmentScheduleUpdate(SceneObjectPart part) + { + if (IsChildAgent) + return; + + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (p != this && part.ParentGroup.HasPrivateAttachmentPoint) + return; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + if (part.UpdateFlag == UpdateRequired.TERSE) + { + p.ControllingClient.SendEntityUpdate(part, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + part.UpdateFlag = 0; + } + else if (part.UpdateFlag == UpdateRequired.FULL) + { + p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); + part.UpdateFlag = 0; + } + }); + } + + public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) + { + if (IsChildAgent) + return; + + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (p != this && sog.HasPrivateAttachmentPoint) + return; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + SceneObjectPart[] parts = sog.Parts; + + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + if (UpdateFlag == UpdateRequired.TERSE) + { + p.ControllingClient.SendEntityUpdate(part, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + part.UpdateFlag = 0; + } + else if (UpdateFlag == UpdateRequired.FULL) + { + p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); + part.UpdateFlag = 0; + } + } + }); + } + + public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) + { + if (IsChildAgent) + return; + + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (p != this && part.ParentGroup.HasPrivateAttachmentPoint) + return; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + if (UpdateFlag == UpdateRequired.TERSE) + { + p.ControllingClient.SendEntityUpdate(part, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + part.UpdateFlag = 0; + } + else if (UpdateFlag == UpdateRequired.FULL) + { + p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); + part.UpdateFlag = 0; + } + }); + } + /// /// Send a script event to this scene presence's attachments /// @@ -5521,7 +5667,7 @@ namespace OpenSim.Region.Framework.Scenes p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); - p.SendAttachmentsToAgentNF(this); + p.SendAttachmentsToAgentNFPK(this); } } } @@ -5852,7 +5998,7 @@ namespace OpenSim.Region.Framework.Scenes p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); - p.SendAttachmentsToAgentNF(this); + p.SendAttachmentsToAgentNFPK(this); } } } -- cgit v1.1 From 6aa60a5d970ef88cce639c92184e0590c2f25903 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 19:56:43 +0100 Subject: test .... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ad70ce3..a1d40fd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5982,7 +5982,7 @@ namespace OpenSim.Region.Framework.Scenes SendAppearanceToAgent(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); - SendAttachmentsToAgentNF(p); + SendAttachmentsToAgentNFPK(p); } } -- cgit v1.1 From d16f7df673def43dfe922689a8c301ffe034ecaa Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 19 Aug 2014 20:33:26 +0100 Subject: also send attachment pre-kills on crossings --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a1d40fd..a0c3ba9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1900,22 +1900,35 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); + List kk = new List(); + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? foreach (SceneObjectGroup sog in m_attachments) { + foreach (SceneObjectPart part in sog.Parts) + kk.Add(part.LocalId); + + sog.SendFullUpdateToClient(ControllingClient); + SendFullUpdateToClient(ControllingClient); + // sog.ScheduleGroupForFullUpdate(); m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (p != this && sog.HasPrivateAttachmentPoint) + if (p == this) + return; + if (sog.HasPrivateAttachmentPoint) return; if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; + + p.ControllingClient.SendKillObject(kk); sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); + kk.Clear(); } } } -- cgit v1.1 From b21b6532b07a7a5b50e62de2f9b074c768a14e74 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 20 Aug 2014 17:48:10 +0100 Subject: sending attachment kills before putting them back doesnt cover all cases and seems heavy for viewers --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 45 +++++++++++------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a0c3ba9..864f54d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1878,7 +1878,6 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) { - ValidateAndSendAppearanceAndAgentData(); m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -1900,35 +1899,30 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - List kk = new List(); - // Resume scripts this possible should also be moved down after sending the avatar to viewer ? foreach (SceneObjectGroup sog in m_attachments) { - foreach (SceneObjectPart part in sog.Parts) - kk.Add(part.LocalId); - sog.SendFullUpdateToClient(ControllingClient); SendFullUpdateToClient(ControllingClient); - // sog.ScheduleGroupForFullUpdate(); - m_scene.ForEachScenePresence(delegate(ScenePresence p) + if (!sog.HasPrivateAttachmentPoint) { - if (p == this) - return; - if (sog.HasPrivateAttachmentPoint) - return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) - return; - - p.ControllingClient.SendKillObject(kk); - sog.SendFullUpdateToClient(p.ControllingClient); - SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path - }); - + // sog.ScheduleGroupForFullUpdate(); + m_scene.ForEachScenePresence(delegate(ScenePresence p) + { + if (p == this) + return; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + sog.SendFullUpdateToClient(p.ControllingClient); + SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path + }); + } + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); - kk.Clear(); } } } @@ -4758,6 +4752,9 @@ namespace OpenSim.Region.Framework.Scenes } } + // send attachments to a client without filters except for huds + // for now they are checked in several places down the line... + // kills all parts before sending public void SendAttachmentsToAgentNFPK(ScenePresence p) { lock (m_attachments) @@ -5680,7 +5677,7 @@ namespace OpenSim.Region.Framework.Scenes p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); - p.SendAttachmentsToAgentNFPK(this); + p.SendAttachmentsToAgentNF(this); } } } @@ -5995,7 +5992,7 @@ namespace OpenSim.Region.Framework.Scenes SendAppearanceToAgent(p); if (Animator != null) Animator.SendAnimPackToClient(p.ControllingClient); - SendAttachmentsToAgentNFPK(p); + SendAttachmentsToAgentNF(p); } } @@ -6011,7 +6008,7 @@ namespace OpenSim.Region.Framework.Scenes p.SendAppearanceToAgent(this); if (p.Animator != null) p.Animator.SendAnimPackToClient(ControllingClient); - p.SendAttachmentsToAgentNFPK(this); + p.SendAttachmentsToAgentNF(this); } } } -- cgit v1.1 From 16cf3967b4b2929e20f13a5d9ae91dc0e7ac03ef Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 20 Aug 2014 17:54:23 +0100 Subject: Reserve a extra localID for a presence ( it will be localID + 1 ) --- OpenSim/Region/Framework/Scenes/SceneBase.cs | 12 ++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index dd0c828..f5be7a7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -295,6 +295,18 @@ namespace OpenSim.Region.Framework.Scenes return myID; } + + public uint AllocatePresenceLocalId() + { + uint myID; + + _primAllocateMutex.WaitOne(); + myID = ++m_lastAllocatedLocalId; + ++m_lastAllocatedLocalId; + _primAllocateMutex.ReleaseMutex(); + + return myID; + } #region Module Methods diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 864f54d..5ebf3db 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -969,7 +969,7 @@ namespace OpenSim.Region.Framework.Scenes m_name = String.Format("{0} {1}", Firstname, Lastname); m_scene = world; m_uuid = client.AgentId; - LocalId = m_scene.AllocateLocalId(); + LocalId = m_scene.AllocatePresenceLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) -- cgit v1.1 From 88587b4e73b240693bd03172d52c4f13b5f47868 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 20 Aug 2014 21:41:16 +0100 Subject: reserve updates priority queue 2 for attachments, send them by it on BestAvatarResp scheme. Attachments cannot be sent on imediate queues, since they will block everything. Changed distance to priority math, keeping identical result, shifted to start at queue 3. --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 19d2689..c0405ad 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes { // Attachments are high priority, if (((SceneObjectPart)entity).ParentGroup.IsAttachment) - return 1; + return 2; pqueue = ComputeDistancePriority(client, entity, false); @@ -233,16 +233,28 @@ namespace OpenSim.Region.Framework.Scenes // And convert the distance to a priority queue, this computation gives queues // at 10, 20, 40, 80, 160, 320, 640, and 1280m - uint pqueue = PriorityQueue.NumberOfImmediateQueues; + uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; - +/* for (int i = 0; i < queues - 1; i++) { if (distance < 30 * Math.Pow(2.0,i)) break; pqueue++; } - +*/ + if (distance > 10f) + { + float tmp = (float)Math.Log((double)distance) * 1.4426950408889634073599246810019f - 3.3219280948873623478703194294894f; + // for a map identical to original: + // now + // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) + // 2st constant makes it be log2(distance/10) + pqueue += (uint)tmp; + if (pqueue > queues - 1) + pqueue = queues - 1; + } + // If this is a root agent, then determine front & back // Bump up the priority queue (drop the priority) for any objects behind the avatar if (useFrontBack && ! presence.IsChildAgent) -- cgit v1.1 From 5bf145a3977a55c474106bbe2a6c107dd9457f0d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 00:49:10 +0100 Subject: add a direct sendpartfullUpdate to send a full object update to a part, optionally overriding its parentID. check what it does to attachments --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5ebf3db..73283ed 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1916,6 +1916,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; + p.ControllingClient.SendPartFullUpdate(sog.RootPart,LocalId + 1); sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); @@ -4746,7 +4747,10 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectGroup sog in m_attachments) { if (p == this || !sog.HasPrivateAttachmentPoint) + { + p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); sog.SendFullUpdateToClient(p.ControllingClient); + } } SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path } -- cgit v1.1 From 87f03c040c13c7456e228174dbc32f9425504407 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 04:07:23 +0100 Subject: bad test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 73283ed..6e69606 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1916,7 +1916,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; - p.ControllingClient.SendPartFullUpdate(sog.RootPart,LocalId + 1); + p.ControllingClient.SendPartFullUpdate(sog.RootPart,0); sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); @@ -4748,7 +4748,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p == this || !sog.HasPrivateAttachmentPoint) { - p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); + p.ControllingClient.SendPartFullUpdate(sog.RootPart, 0); sog.SendFullUpdateToClient(p.ControllingClient); } } -- cgit v1.1 From 6acfa779192d09fb144a1ae3a5002bbe547b301d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 04:35:04 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 44 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6e69606..ebdf52f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1916,7 +1916,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; - p.ControllingClient.SendPartFullUpdate(sog.RootPart,0); + p.ControllingClient.SendPartFullUpdate(sog.RootPart,LocalId + 1); sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); @@ -4748,7 +4748,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p == this || !sog.HasPrivateAttachmentPoint) { - p.ControllingClient.SendPartFullUpdate(sog.RootPart, 0); + p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId +1 ); sog.SendFullUpdateToClient(p.ControllingClient); } } @@ -5805,7 +5805,7 @@ namespace OpenSim.Region.Framework.Scenes List allpresences = null; allpresences = m_scene.GetScenePresences(); - List killsToSendme = new List(); + List killsToSendme = new List(); foreach (ScenePresence p in allpresences) { @@ -5814,17 +5814,19 @@ namespace OpenSim.Region.Framework.Scenes if (p.currentParcelUUID == m_currentParcelUUID) { - killsToSendme.Add(p.LocalId); + killsToSendme.Add(p); } } if (killsToSendme.Count > 0) { - try - { - ControllingClient.SendKillObject(killsToSendme); - } - catch (NullReferenceException) { } + foreach (ScenePresence p in killsToSendme) + p.SendKillTo(this); +// try +// { +// ControllingClient.SendKillObject(killsToSendme); +// } +// catch (NullReferenceException) { } } } @@ -5832,7 +5834,7 @@ namespace OpenSim.Region.Framework.Scenes bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) { List killsToSendto = new List(); - List killsToSendme = new List(); + List killsToSendme = new List(); List viewsToSendto = new List(); List viewsToSendme = new List(); List allpresences = null; @@ -5903,7 +5905,7 @@ namespace OpenSim.Region.Framework.Scenes if(p.GodLevel < 200) killsToSendto.Add(p); // they dont see me if(GodLevel < 200) - killsToSendme.Add(p.LocalId); // i dont see them + killsToSendme.Add(p); // i dont see them } // only those on new parcel need see if (currentParcelID == p.currentParcelUUID) @@ -5952,7 +5954,7 @@ namespace OpenSim.Region.Framework.Scenes // only those old parcel need receive kills if (previusParcelID == p.currentParcelUUID && GodLevel < 200) { - killsToSendme.Add(p.LocalId); // i dont see them + killsToSendme.Add(p); // i dont see them } else { @@ -5971,18 +5973,23 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ScenePresence p in killsToSendto) { + m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); - try { p.ControllingClient.SendKillObject(new List { LocalId }); } - catch (NullReferenceException) { } + + SendKillTo(p); +// try { p.ControllingClient.SendKillObject(new List { LocalId }); } +// catch (NullReferenceException) { } } } if (killsToSendme.Count > 0) { m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString()); + + foreach (ScenePresence p in killsToSendto) try { - ControllingClient.SendKillObject(killsToSendme); + p.SendKillTo(this); } catch (NullReferenceException) { } @@ -6016,5 +6023,12 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void SendKillTo(ScenePresence p) + { + foreach (SceneObjectGroup sog in m_attachments) + p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); + p.ControllingClient.SendKillObject(new List { LocalId }); + } } } -- cgit v1.1 From d2f3a19838f10363c77aaa537400a64d1b39a45e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 05:00:51 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebdf52f..ac77e2a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5716,7 +5716,7 @@ namespace OpenSim.Region.Framework.Scenes private void ParcelLoginCheck(UUID currentParcelID) { List killsToSendto = new List(); - List killsToSendme = new List(); + List killsToSendme = new List(); List viewsToSendto = new List(); List viewsToSendme = new List(); List allpresences = null; @@ -5750,19 +5750,19 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in killsToSendto) { m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); - try { p.ControllingClient.SendKillObject(new List { LocalId }); } - catch (NullReferenceException) { } + SendKillTo(p); +// try { p.ControllingClient.SendKillObject(new List { LocalId }); } +// catch (NullReferenceException) { } } } if (killsToSendme.Count > 0) { m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + killsToSendme.Count.ToString()); - try + foreach (ScenePresence p in killsToSendme) { - ControllingClient.SendKillObject(killsToSendme); + SendKillTo(this); } - catch (NullReferenceException) { } } /* -- cgit v1.1 From d98d64a61ab465ba745dd09b6db272034b96aef6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 05:28:35 +0100 Subject: bug fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ac77e2a..ea09379 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5951,7 +5951,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - // only those old parcel need receive kills + // only those old parcel need kills if (previusParcelID == p.currentParcelUUID && GodLevel < 200) { killsToSendme.Add(p); // i dont see them @@ -5986,7 +5986,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString()); - foreach (ScenePresence p in killsToSendto) + foreach (ScenePresence p in killsToSendme) try { p.SendKillTo(this); -- cgit v1.1 From ad6f9422792f981cf1c4b240a2a443075624b614 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 06:11:19 +0100 Subject: add filter sog updates --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 40 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 -- 2 files changed, 40 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 28758a9..dd5ee65 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2636,6 +2636,16 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.UpdateFlag = UpdateRequired.TERSE; } + if (IsAttachment) + { + ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentScheduleUpdate(this); + return; + } + } + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { @@ -2697,6 +2707,16 @@ namespace OpenSim.Region.Framework.Scenes return; // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); + + if (IsAttachment) + { + ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentUpdate(this,UpdateRequired.FULL); + return; + } + } RootPart.SendFullUpdateToAllClients(); @@ -2720,6 +2740,16 @@ namespace OpenSim.Region.Framework.Scenes if (IsDeleted) return; + if (IsAttachment) + { + ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentUpdate(RootPart, UpdateRequired.TERSE); + return; + } + } + RootPart.SendTerseUpdateToAllClients(); } @@ -2739,6 +2769,16 @@ namespace OpenSim.Region.Framework.Scenes if (IsDeleted) return; + if (IsAttachment) + { + ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentUpdate(this, UpdateRequired.TERSE); + return; + } + } + SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) parts[i].SendTerseUpdateToAllClients(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ea09379..34d0eaa 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1916,7 +1916,6 @@ namespace OpenSim.Region.Framework.Scenes if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; - p.ControllingClient.SendPartFullUpdate(sog.RootPart,LocalId + 1); sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); @@ -4748,7 +4747,6 @@ namespace OpenSim.Region.Framework.Scenes { if (p == this || !sog.HasPrivateAttachmentPoint) { - p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId +1 ); sog.SendFullUpdateToClient(p.ControllingClient); } } -- cgit v1.1 From 5f1cb6542d8b99674bd74147b2f43ef5432b0d15 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 06:35:11 +0100 Subject: test --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 37 ++++++++++++++---------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 34d0eaa..9e9a83f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4787,10 +4787,12 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (p != this && sog.HasPrivateAttachmentPoint) - return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (p != this) + { + if (sog.HasPrivateAttachmentPoint || + (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) return; + } SceneObjectPart[] parts = sog.Parts; @@ -4820,11 +4822,13 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (p != this && part.ParentGroup.HasPrivateAttachmentPoint) - return; + if (p != this) + { - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) - return; + if (part.ParentGroup.HasPrivateAttachmentPoint || + (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) + return; + } if (part.UpdateFlag == UpdateRequired.TERSE) { @@ -4848,11 +4852,12 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (p != this && sog.HasPrivateAttachmentPoint) - return; - - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (p != this) + { + if (sog.HasPrivateAttachmentPoint || + (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) return; + } SceneObjectPart[] parts = sog.Parts; @@ -4882,11 +4887,13 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (p != this && part.ParentGroup.HasPrivateAttachmentPoint) - return; + if (p != this) + { - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) - return; + if (part.ParentGroup.HasPrivateAttachmentPoint || + (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) + return; + } if (UpdateFlag == UpdateRequired.TERSE) { -- cgit v1.1 From 114144407bd72cb9ccbdf6981d8fec86cbba6a24 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 09:32:36 +0100 Subject: variations.. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 243 +++++------------------ 1 file changed, 48 insertions(+), 195 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9e9a83f..333eb9b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1920,7 +1920,6 @@ namespace OpenSim.Region.Framework.Scenes SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); } - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); } @@ -3542,14 +3541,12 @@ namespace OpenSim.Region.Framework.Scenes } SendOtherAgentsAvatarFullToMe(); - EntityBase[] entities = Scene.Entities.GetEntities(); foreach (EntityBase e in entities) { if (e != null && e is SceneObjectGroup) ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); } - }); } @@ -4754,32 +4751,6 @@ namespace OpenSim.Region.Framework.Scenes } } - // send attachments to a client without filters except for huds - // for now they are checked in several places down the line... - // kills all parts before sending - public void SendAttachmentsToAgentNFPK(ScenePresence p) - { - lock (m_attachments) - { - List pk = new List(); - foreach (SceneObjectGroup sog in m_attachments) - { - foreach (SceneObjectPart part in sog.Parts) - pk.Add(part.LocalId); - } - - p.ControllingClient.SendKillObject(pk); - - foreach (SceneObjectGroup sog in m_attachments) - { - if (p == this || !sog.HasPrivateAttachmentPoint) - sog.SendFullUpdateToClient(p.ControllingClient); - } - SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path - } - } - - public void SendAttachmentScheduleUpdate(SceneObjectGroup sog) { if (IsChildAgent) @@ -4796,9 +4767,27 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = sog.Parts; + SendFullUpdateToClient(p.ControllingClient); + + SceneObjectPart rootpart = sog.RootPart; + if (rootpart.UpdateFlag == UpdateRequired.TERSE) + { + p.ControllingClient.SendEntityUpdate(rootpart, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + rootpart.UpdateFlag = 0; + } + else if (rootpart.UpdateFlag == UpdateRequired.FULL) + { + p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate); + rootpart.UpdateFlag = 0; + } + for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; + if (part == rootpart) + continue; if (part.UpdateFlag == UpdateRequired.TERSE) { p.ControllingClient.SendEntityUpdate(part, @@ -5655,183 +5644,56 @@ namespace OpenSim.Region.Framework.Scenes private void parcelGodCheck(UUID currentParcelID, bool isGod) { - List allpresences = null; - + List allpresences = m_scene.GetScenePresences(); - allpresences = m_scene.GetScenePresences(); - - if (isGod) - { - List viewsToSendme = new List(); - - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) - { - viewsToSendme.Add(p); // i see them - } - } - - if (viewsToSendme.Count > 0) - { - foreach (ScenePresence p in viewsToSendme) - { - if (p.IsChildAgent) - continue; - - p.SendAvatarDataToAgentNF(this); - p.SendAppearanceToAgent(this); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - p.SendAttachmentsToAgentNF(this); - } - } - } - else + foreach (ScenePresence p in allpresences) { - List killsToSendme = new List(); - - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) - { - killsToSendme.Add(p); - } - } + if (p.IsDeleted || p.IsChildAgent || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; - if (killsToSendme.Count > 0) + if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) { - foreach (ScenePresence p in killsToSendme) - { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); - try { ControllingClient.SendKillObject(new List { p.LocalId }); } - catch (NullReferenceException) { } - } + if (isGod) + p.SendViewTo(this); + else + p.SendKillTo(this); } } - } private void ParcelLoginCheck(UUID currentParcelID) { - List killsToSendto = new List(); - List killsToSendme = new List(); - List viewsToSendto = new List(); - List viewsToSendme = new List(); - List allpresences = null; - - allpresences = m_scene.GetScenePresences(); + List allpresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allpresences) { if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; - if (currentParcelID != p.currentParcelUUID) - { - if (p.GodLevel < 200) - killsToSendto.Add(p); -// if (GodLevel < 200 && p.ParcelHideThisAvatar) -// killsToSendme.Add(p.LocalId); - } - else + if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) { - viewsToSendto.Add(p); - viewsToSendme.Add(p); - } - } - allpresences.Clear(); - - // send the things - // kill main avatar object - if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc) - { - foreach (ScenePresence p in killsToSendto) - { - m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); SendKillTo(p); -// try { p.ControllingClient.SendKillObject(new List { LocalId }); } -// catch (NullReferenceException) { } - } - } - - if (killsToSendme.Count > 0) - { - m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + killsToSendme.Count.ToString()); - foreach (ScenePresence p in killsToSendme) - { - SendKillTo(this); - } - - } -/* - if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) - { - foreach (ScenePresence p in viewsToSendto) - { - m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname); - p.ControllingClient.SendAvatarDataImmediate(this); - SendAppearanceToAgent(p); - SendAttachmentsToClient(p.ControllingClient); - if (Animator != null) - Animator.SendAnimPackToClient(p.ControllingClient); - } - } - - if (viewsToSendme.Count > 0) - { - foreach (ScenePresence p in viewsToSendme) - { - m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - if (p.IsChildAgent) - continue; - ControllingClient.SendAvatarDataImmediate(p); - p.SendAppearanceToAgent(this); - p.SendAttachmentsToClient(ControllingClient); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); } } -*/ } - public void parcelRegionCross() { - if (!ParcelHideThisAvatar || GodLevel >= 200) + if (!ParcelHideThisAvatar || IsChildAgent || GodLevel >= 200) return; List allpresences = null; allpresences = m_scene.GetScenePresences(); - List killsToSendme = new List(); - foreach (ScenePresence p in allpresences) { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) + if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; if (p.currentParcelUUID == m_currentParcelUUID) { - killsToSendme.Add(p); - } - } - - if (killsToSendme.Count > 0) - { - foreach (ScenePresence p in killsToSendme) p.SendKillTo(this); -// try -// { -// ControllingClient.SendKillObject(killsToSendme); -// } -// catch (NullReferenceException) { } + } } } @@ -5844,10 +5706,7 @@ namespace OpenSim.Region.Framework.Scenes List viewsToSendme = new List(); List allpresences = null; - if (IsInTransit) - return; - - if (IsChildAgent) + if (IsInTransit || IsChildAgent) return; if (check) @@ -5973,17 +5832,13 @@ namespace OpenSim.Region.Framework.Scenes } // send the things - // kill main avatar object - if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc) + + if (killsToSendto.Count > 0) { foreach (ScenePresence p in killsToSendto) { - m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); - SendKillTo(p); -// try { p.ControllingClient.SendKillObject(new List { LocalId }); } -// catch (NullReferenceException) { } } } @@ -5992,23 +5847,17 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString()); foreach (ScenePresence p in killsToSendme) - try { + m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname); p.SendKillTo(this); } - catch (NullReferenceException) { } - } - if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) + if (viewsToSendto.Count > 0) { foreach (ScenePresence p in viewsToSendto) { - SendAvatarDataToAgentNF(p); - SendAppearanceToAgent(p); - if (Animator != null) - Animator.SendAnimPackToClient(p.ControllingClient); - SendAttachmentsToAgentNF(p); + SendViewTo(p); } } @@ -6019,12 +5868,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsChildAgent) continue; // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); - - p.SendAvatarDataToAgentNF(this); - p.SendAppearanceToAgent(this); - if (p.Animator != null) - p.Animator.SendAnimPackToClient(ControllingClient); - p.SendAttachmentsToAgentNF(this); + p.SendViewTo(this); } } } @@ -6035,5 +5879,14 @@ namespace OpenSim.Region.Framework.Scenes p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); p.ControllingClient.SendKillObject(new List { LocalId }); } + + public void SendViewTo(ScenePresence p) + { + SendAvatarDataToAgentNF(p); + SendAppearanceToAgent(p); + if (Animator != null) + Animator.SendAnimPackToClient(p.ControllingClient); + SendAttachmentsToAgentNF(p); + } } } -- cgit v1.1 From b68c814bc6e8f538c02bcf674a51810fc03287d6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 10:53:59 +0100 Subject: ... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 333eb9b..7eda10e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4756,7 +4756,8 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - m_scene.ForEachScenePresence(delegate(ScenePresence p) + List allPresences = m_scene.GetScenePresences(); + foreach(ScenePresence p in allPresences) { if (p != this) { @@ -4801,7 +4802,7 @@ namespace OpenSim.Region.Framework.Scenes part.UpdateFlag = 0; } } - }); + } } public void SendAttachmentScheduleUpdate(SceneObjectPart part) -- cgit v1.1 From ad83b18634f368a493432888d93af6c2715a2472 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 14:07:55 +0100 Subject: some cleanup.. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 320 +++++++++++------------ 1 file changed, 146 insertions(+), 174 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7eda10e..c46a5ad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1268,79 +1268,6 @@ namespace OpenSim.Region.Framework.Scenes m_scene.SwapRootAgentCount(false); - // The initial login scene presence is already root when it gets here - // and it has already rezzed the attachments and started their scripts. - // We do the following only for non-login agents, because their scripts - // haven't started yet. -/* moved down - if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) - { - // Viewers which have a current outfit folder will actually rez their own attachments. However, - // viewers without (e.g. v1 viewers) will not, so we still need to make this call. - if (Scene.AttachmentsModule != null) - Util.FireAndForget( - o => - { -// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) -// System.Threading.Thread.Sleep(7000); - - Scene.AttachmentsModule.RezAttachments(this); - }); - } - else - - { - // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT - // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently - // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are - // not transporting the required data. - // - // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT - // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently - // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are - // not transporting the required data. - // - // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of - // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here - // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. - // - // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). - // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing - // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the - // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. - // - // One cannot simply iterate over attachments in a fire and forget thread because this would no longer - // be locked, allowing race conditions if other code changes the attachments list. - - List attachments = GetAttachments(); - - if (attachments.Count > 0) - { - m_log.DebugFormat( - "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - - // Resume scripts this possible should also be moved down after sending the avatar to viewer ? - foreach (SceneObjectGroup sog in attachments) - { -// sending attachments before the avatar ? -// moved to completemovement where it already was -// sog.ScheduleGroupForFullUpdate(); - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); - sog.ResumeScripts(); - } - } - } -*/ -/* - SendAvatarDataToAllAgents(); - - // send the animations of the other presences to me - m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) - { - if (presence != this) - presence.Animator.SendAnimPackToClient(ControllingClient); - }); -*/ // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement @@ -4132,19 +4059,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.Far = DrawDistance; // Throttles - float multiplier = 1; - -/* this is also used to send to new main regions not children - - int childRegions = KnownRegionCount; - if (childRegions != 0) - multiplier = 1f / childRegions; - - // Minimum throttle for a child region is 1/4 of the root region throttle - if (multiplier <= 0.25f) - multiplier = 0.25f; -*/ - cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); + cAgent.Throttles = ControllingClient.GetThrottlesPacked(1); cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; @@ -4756,118 +4671,167 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - List allPresences = m_scene.GetScenePresences(); - foreach(ScenePresence p in allPresences) + SceneObjectPart[] origparts = sog.Parts; + SceneObjectPart[] parts = new SceneObjectPart[origparts.Length]; + PrimUpdateFlags[] flags = new PrimUpdateFlags[origparts.Length]; + + SceneObjectPart rootpart = sog.RootPart; + UpdateRequired rootreq = sog.RootPart.UpdateFlag; + + int j = 0; + bool allterse = true; + + for (int i = 0; i < origparts.Length; i++) { - if (p != this) + switch (origparts[i].UpdateFlag) { - if (sog.HasPrivateAttachmentPoint || - (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - return; + case UpdateRequired.TERSE: + flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; + parts[j] = origparts[i]; + j++; + break; + + case UpdateRequired.FULL: + flags[j] = PrimUpdateFlags.FullUpdate; + parts[j] = origparts[i]; + j++; + allterse = false; + break; } + origparts[i].UpdateFlag = 0; + } + + if (j == 0) + return; - SceneObjectPart[] parts = sog.Parts; + if (rootreq == UpdateRequired.NONE) + { + if (allterse) + rootreq = UpdateRequired.TERSE; + else + rootreq = UpdateRequired.FULL; + } - SendFullUpdateToClient(p.ControllingClient); + PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate; + if (rootreq == UpdateRequired.TERSE) + rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; - SceneObjectPart rootpart = sog.RootPart; - if (rootpart.UpdateFlag == UpdateRequired.TERSE) - { - p.ControllingClient.SendEntityUpdate(rootpart, - PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - rootpart.UpdateFlag = 0; - } - else if (rootpart.UpdateFlag == UpdateRequired.FULL) + int nparts = j; + + bool priv = sog.HasPrivateAttachmentPoint; + + List allPresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allPresences) + { + if (p != this) { - p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate); - rootpart.UpdateFlag = 0; + if (priv || + (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) + continue; } - for (int i = 0; i < parts.Length; i++) + p.ControllingClient.SendEntityUpdate(rootpart, rootflag); + + for (int i = 0; i < nparts; i++) { SceneObjectPart part = parts[i]; if (part == rootpart) continue; - if (part.UpdateFlag == UpdateRequired.TERSE) - { - p.ControllingClient.SendEntityUpdate(part, - PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - part.UpdateFlag = 0; - } - else if (part.UpdateFlag == UpdateRequired.FULL) - { - p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); - part.UpdateFlag = 0; - } + p.ControllingClient.SendEntityUpdate(part, flags[i]); } - } + } } - public void SendAttachmentScheduleUpdate(SceneObjectPart part) + public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) { if (IsChildAgent) return; - m_scene.ForEachScenePresence(delegate(ScenePresence p) + PrimUpdateFlags flag; + switch (UpdateFlag) + { + case UpdateRequired.TERSE: + flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; + break; + + case UpdateRequired.FULL: + flag = PrimUpdateFlags.FullUpdate; + break; + + default: + return; + } + + SceneObjectPart[] parts = sog.Parts; + SceneObjectPart rootpart = sog.RootPart; + + bool priv = sog.HasPrivateAttachmentPoint; + + List allPresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allPresences) { if (p != this) { - - if (part.ParentGroup.HasPrivateAttachmentPoint || + if (priv || (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - return; + continue; } - if (part.UpdateFlag == UpdateRequired.TERSE) - { - p.ControllingClient.SendEntityUpdate(part, - PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - part.UpdateFlag = 0; - } - else if (part.UpdateFlag == UpdateRequired.FULL) + p.ControllingClient.SendEntityUpdate(rootpart, flag); + rootpart.UpdateFlag = 0; + + for (int i = 0; i < parts.Length; i++) { - p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); + SceneObjectPart part = parts[i]; + if (part == rootpart) + continue; + p.ControllingClient.SendEntityUpdate(part, flag); part.UpdateFlag = 0; } - }); + } } - public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) + public void SendAttachmentScheduleUpdate(SceneObjectPart part) { if (IsChildAgent) return; - m_scene.ForEachScenePresence(delegate(ScenePresence p) + + PrimUpdateFlags flag; + switch (part.UpdateFlag) { - if (p != this) - { - if (sog.HasPrivateAttachmentPoint || - (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) + case UpdateRequired.TERSE: + flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; + break; + + case UpdateRequired.FULL: + flag = PrimUpdateFlags.FullUpdate; + break; + + default: return; - } + } - SceneObjectPart[] parts = sog.Parts; + bool priv = part.ParentGroup.HasPrivateAttachmentPoint; - for (int i = 0; i < parts.Length; i++) + List allPresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allPresences) + { + if (p != this) { - SceneObjectPart part = parts[i]; - if (UpdateFlag == UpdateRequired.TERSE) - { - p.ControllingClient.SendEntityUpdate(part, - PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - part.UpdateFlag = 0; - } - else if (UpdateFlag == UpdateRequired.FULL) - { - p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); - part.UpdateFlag = 0; - } + + if (priv || + (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) + continue; } - }); + + p.ControllingClient.SendEntityUpdate(part, flag); + part.UpdateFlag = 0; + } } public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) @@ -4875,29 +4839,37 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - m_scene.ForEachScenePresence(delegate(ScenePresence p) + PrimUpdateFlags flag; + switch (UpdateFlag) + { + case UpdateRequired.TERSE: + flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; + break; + + case UpdateRequired.FULL: + flag = PrimUpdateFlags.FullUpdate; + break; + + default: + return; + } + + bool priv = part.ParentGroup.HasPrivateAttachmentPoint; + + List allPresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allPresences) { if (p != this) { - - if (part.ParentGroup.HasPrivateAttachmentPoint || + if ( priv || (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - return; + continue; } - if (UpdateFlag == UpdateRequired.TERSE) - { - p.ControllingClient.SendEntityUpdate(part, - PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); - part.UpdateFlag = 0; - } - else if (UpdateFlag == UpdateRequired.FULL) - { - p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); - part.UpdateFlag = 0; - } - }); + p.ControllingClient.SendEntityUpdate(part, flag); + part.UpdateFlag = 0; + } } /// -- cgit v1.1 From 6674548af006484da0d213f2775b9406a163f31f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 22:42:45 +0100 Subject: replace AgentHasMovedAway + KillEntity by a hacked version on teleports --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c46a5ad..f9266b4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5652,7 +5652,7 @@ namespace OpenSim.Region.Framework.Scenes public void parcelRegionCross() { - if (!ParcelHideThisAvatar || IsChildAgent || GodLevel >= 200) + if (!ParcelHideThisAvatar || GodLevel >= 200) return; List allpresences = null; @@ -5846,6 +5846,15 @@ namespace OpenSim.Region.Framework.Scenes } } + public void HasMovedAway() + { + List allpresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allpresences) + SendKillTo(p); + if (Scene.AttachmentsModule != null) + Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); + } + public void SendKillTo(ScenePresence p) { foreach (SceneObjectGroup sog in m_attachments) -- cgit v1.1 From d5bb80798d106f0460ea57b0a0cf22e1829cd96d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 23:18:51 +0100 Subject: make the hack more extensive. Forbid sog/sop updates if Intransit but release it sooner --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f9266b4..fd1ec82 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3515,10 +3515,10 @@ namespace OpenSim.Region.Framework.Scenes SendAppearanceToAgent(this); -// if (cachedappearance) -// { + m_inTransit = false; + SendAppearanceToAllOtherAgents(); -// } + if(Animator!= null) Animator.SendAnimPack(); } @@ -4668,7 +4668,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAttachmentScheduleUpdate(SceneObjectGroup sog) { - if (IsChildAgent) + if (IsChildAgent || IsInTransit) return; SceneObjectPart[] origparts = sog.Parts; @@ -4746,7 +4746,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) { - if (IsChildAgent) + if (IsChildAgent || IsInTransit) return; PrimUpdateFlags flag; @@ -4796,7 +4796,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAttachmentScheduleUpdate(SceneObjectPart part) { - if (IsChildAgent) + if (IsChildAgent || IsInTransit) return; @@ -4836,7 +4836,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) { - if (IsChildAgent) + if (IsChildAgent || IsInTransit) return; PrimUpdateFlags flag; @@ -5850,7 +5850,12 @@ namespace OpenSim.Region.Framework.Scenes { List allpresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allpresences) - SendKillTo(p); + { + if (p == this) + continue; + SendKillTo(p); + p.SendKillTo(this); + } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } -- cgit v1.1 From be02fb3904dbe8f7071ad393229c3e04b08bb697 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Aug 2014 23:43:06 +0100 Subject: replace hack by sog kills on tp out --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fd1ec82..260dfc8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5848,18 +5848,32 @@ namespace OpenSim.Region.Framework.Scenes public void HasMovedAway() { + List myids = new List(); + foreach (SceneObjectGroup sog in m_attachments) + myids.Add(sog.RootPart.LocalId); + myids.Add(LocalId); + List allpresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allpresences) { if (p == this) continue; - SendKillTo(p); + p.ControllingClient.SendKillObject(myids); p.SendKillTo(this); } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } + public void SendFullKillsTo(ScenePresence p) + { + List ids = new List(); + foreach (SceneObjectGroup sog in m_attachments) + ids.Add(sog.RootPart.LocalId); + ids.Add(LocalId); + p.ControllingClient.SendKillObject(ids); + } + public void SendKillTo(ScenePresence p) { foreach (SceneObjectGroup sog in m_attachments) -- cgit v1.1 From 0da7f8e863ae185c38cbcee0d0fe0f11e09647b9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Aug 2014 00:01:50 +0100 Subject: silly... --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 260dfc8..d3ed228 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5858,8 +5858,8 @@ namespace OpenSim.Region.Framework.Scenes { if (p == this) continue; - p.ControllingClient.SendKillObject(myids); - p.SendKillTo(this); + p.ControllingClient.SendKillObject(myids); + p.SendFullKillsTo(this); } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); -- cgit v1.1 From c95fd60806d28c7e68b8a03d9a0e2d41604ac92c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Aug 2014 00:28:05 +0100 Subject: revert the kills, they seem even worse --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d3ed228..5bfc640 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5848,18 +5848,13 @@ namespace OpenSim.Region.Framework.Scenes public void HasMovedAway() { - List myids = new List(); - foreach (SceneObjectGroup sog in m_attachments) - myids.Add(sog.RootPart.LocalId); - myids.Add(LocalId); - List allpresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allpresences) { if (p == this) continue; - p.ControllingClient.SendKillObject(myids); - p.SendFullKillsTo(this); + SendKillTo(p); + p.SendKillTo(this); } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); @@ -5869,7 +5864,7 @@ namespace OpenSim.Region.Framework.Scenes { List ids = new List(); foreach (SceneObjectGroup sog in m_attachments) - ids.Add(sog.RootPart.LocalId); + p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); ids.Add(LocalId); p.ControllingClient.SendKillObject(ids); } -- cgit v1.1 From 0295e6822dd6408b6dc6580b4a7a92b0f057d4b8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Aug 2014 20:01:07 +0100 Subject: some cleanup ( well or not ) --- .../Scenes/Animation/ScenePresenceAnimator.cs | 10 + OpenSim/Region/Framework/Scenes/Scene.cs | 11 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 18 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 73 +++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 203 +++++++++++++++------ 5 files changed, 234 insertions(+), 81 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 668087f..fdadd32 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -576,6 +576,16 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_scenePresence.SendAnimPack(animations, seqs, objectIDs); } + public void GetArrays(out UUID[] animIDs, out int[] sequenceNums, out UUID[] objectIDs) + { + animIDs = null; + sequenceNums = null; + objectIDs = null; + + if(m_animations != null) + m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); + } + public void SendAnimPackToClient(IClientAPI client) { if (m_scenePresence.IsChildAgent) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0266faf..aa81000 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3000,13 +3000,18 @@ namespace OpenSim.Region.Framework.Scenes if (sp == null) { m_log.DebugFormat( - "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}", - client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos); + "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}, tpflags: {4}", + client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos, + ((TPFlags)aCircuit.teleportFlags).ToString()); m_clientManager.Add(client); SubscribeToClientEvents(client); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); + + sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; + +/* done in completMovement InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); if (cof == null) sp.COF = UUID.Zero; @@ -3014,9 +3019,9 @@ namespace OpenSim.Region.Framework.Scenes sp.COF = cof.ID; m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); + */ m_eventManager.TriggerOnNewPresence(sp); - sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index dd5ee65..d3dd5d7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2717,15 +2717,15 @@ namespace OpenSim.Region.Framework.Scenes return; } } - - RootPart.SendFullUpdateToAllClients(); + + RootPart.SendFullUpdateToAllClientsInternal(); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; if (part != RootPart) - part.SendFullUpdateToAllClients(); + part.SendFullUpdateToAllClientsInternal(); } } @@ -2740,16 +2740,6 @@ namespace OpenSim.Region.Framework.Scenes if (IsDeleted) return; - if (IsAttachment) - { - ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); - if (sp != null) - { - sp.SendAttachmentUpdate(RootPart, UpdateRequired.TERSE); - return; - } - } - RootPart.SendTerseUpdateToAllClients(); } @@ -2781,7 +2771,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - parts[i].SendTerseUpdateToAllClients(); + parts[i].SendTerseUpdateToAllClientsInternal(); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 98ea880..0930820 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -862,7 +862,8 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 offset = (m_offsetPosition - oldpos); av.AbsolutePosition += offset; - av.SendAvatarDataToAllAgents(); +// av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); } } } @@ -3257,7 +3258,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Send a full update for this part to all clients. /// - public void SendFullUpdateToAllClients() + public void SendFullUpdateToAllClientsInternal() { if (ParentGroup == null) return; @@ -3276,6 +3277,36 @@ namespace OpenSim.Region.Framework.Scenes }); } + public void SendFullUpdateToAllClients() + { + if (ParentGroup == null) + return; + + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = Velocity; + m_lastAcceleration = Acceleration; + m_lastAngularVelocity = AngularVelocity; + m_lastUpdateSentTime = Environment.TickCount; + + if (ParentGroup.IsAttachment) + { + ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentUpdate(this, UpdateRequired.FULL); + } + } + else + { + ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + { + SendFullUpdate(avatar.ControllingClient); + }); + } + } + /// /// Sends a full update to the client /// @@ -3345,24 +3376,24 @@ namespace OpenSim.Region.Framework.Scenes !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) { - SendTerseUpdateToAllClients(); - + SendTerseUpdateToAllClientsInternal(); } break; } case UpdateRequired.FULL: { ClearUpdateSchedule(); - SendFullUpdateToAllClients(); + SendFullUpdateToAllClientsInternal(); break; } } } + /// /// Send a terse update to all clients /// - public void SendTerseUpdateToAllClients() + public void SendTerseUpdateToAllClientsInternal() { if (ParentGroup == null || ParentGroup.Scene == null) return; @@ -3381,6 +3412,36 @@ namespace OpenSim.Region.Framework.Scenes }); } + public void SendTerseUpdateToAllClients() + { + if (ParentGroup == null || ParentGroup.Scene == null) + return; + + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = Velocity; + m_lastAcceleration = Acceleration; + m_lastAngularVelocity = AngularVelocity; + m_lastUpdateSentTime = Environment.TickCount; + + if (ParentGroup.IsAttachment) + { + ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentUpdate(this, UpdateRequired.TERSE); + } + } + else + { + ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) + { + SendTerseUpdateToClient(client); + }); + } + } + public void SetAxisRotation(int axis, int rotate) { ParentGroup.SetAxisRotation(axis, rotate); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5bfc640..faa07d4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1341,6 +1341,11 @@ namespace OpenSim.Region.Framework.Scenes RemoveFromPhysicalScene(); ParentID = 0; // Child agents can't be sitting +// we dont have land information for child + m_previusParcelHide = false; + m_previusParcelUUID = UUID.Zero; + m_currentParcelHide = false; + m_currentParcelUUID = UUID.Zero; // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into m_scene.EventManager.TriggerOnMakeChildAgent(this); @@ -1753,13 +1758,6 @@ namespace OpenSim.Region.Framework.Scenes // Tell the client that we're totally ready ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); - // Remember in HandleUseCircuitCode, we delayed this to here -// this prims etc, moved down -// if (m_teleportFlags > 0) -// SendInitialDataToMe(); - - // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); - m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); if (!string.IsNullOrEmpty(m_callbackURI)) @@ -1805,19 +1803,82 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) { - ValidateAndSendAppearanceAndAgentData(); + // ValidateAndSendAppearanceAndAgentData(); + + // do it here in line + // so sequence is clear + + // verify baked textures and cache + + bool cachedbaked = false; + + if (m_scene.AvatarFactory != null) + cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this); + + // not sure we need this + if (!cachedbaked) + { + if (m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(UUID); + } + + List allpresences = m_scene.GetScenePresences(); + + // send avatar object to all presences including us, so they cross it into region + // then hide if necessary + SendInitialAvatarDataToAllAgents(allpresences); + + // send this look + SendAppearanceToAgent(this); + + // send this animations + UUID[] animIDs = null; + int[] animseqs = null; + UUID[] animsobjs = null; + + if (Animator != null) + Animator.GetArrays(out animIDs, out animseqs, out animsobjs); + + bool haveAnims = (animIDs != null && animseqs != null && animsobjs != null); + + if(haveAnims) + SendAnimPackToAgent(this, animIDs, animseqs, animsobjs); + + // we should be able to receive updates, etc + // so release them + m_inTransit = false; + + // send look and animations to others + // if not cached we send greys + // uncomented if will wait till avatar does baking + //if (cachedbaked) + { + foreach (ScenePresence p in allpresences) + { + if (p == this) + continue; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + continue; + + SendAppearanceToAgentNF(p); + if (haveAnims) + SendAnimPackToAgentNF(p, animIDs, animseqs, animsobjs); + } + } // greys if m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); // attachments + if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { if (Scene.AttachmentsModule != null) -// Util.FireAndForget( -// o => -// { + // Util.FireAndForget( + // o => + // { Scene.AttachmentsModule.RezAttachments(this); - // }); + // }); } else { @@ -1829,23 +1890,23 @@ namespace OpenSim.Region.Framework.Scenes // Resume scripts this possible should also be moved down after sending the avatar to viewer ? foreach (SceneObjectGroup sog in m_attachments) { - sog.SendFullUpdateToClient(ControllingClient); SendFullUpdateToClient(ControllingClient); + sog.SendFullUpdateToClient(ControllingClient); if (!sog.HasPrivateAttachmentPoint) { // sog.ScheduleGroupForFullUpdate(); - m_scene.ForEachScenePresence(delegate(ScenePresence p) + foreach(ScenePresence p in allpresences) { if (p == this) - return; + continue; if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) - return; + continue; - sog.SendFullUpdateToClient(p.ControllingClient); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path - }); + sog.SendFullUpdateToClient(p.ControllingClient); + }; } sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); @@ -1872,25 +1933,14 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - if (!IsChildAgent) + if (!IsChildAgent && openChildAgents) { -// moved from makeroot missing in sendInitialDataToMe -// its already there -/* - m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) - { - if (presence != this) - presence.Animator.SendAnimPackToClient(ControllingClient); - }); -*/ - if (openChildAgents) - { IFriendsModule friendsModule = m_scene.RequestModuleInterface(); if (friendsModule != null) friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - } + } } finally @@ -3481,6 +3531,8 @@ namespace OpenSim.Region.Framework.Scenes /// Do everything required once a client completes its movement into a region and becomes /// a root agent. /// + /// +/* only called from on place, do done inline there private void ValidateAndSendAppearanceAndAgentData() { //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); @@ -3502,11 +3554,13 @@ namespace OpenSim.Region.Framework.Scenes m_scene.AvatarFactory.QueueAppearanceSave(UUID); } + // send avatar object to all viewers so they cross it into region bool newhide = m_currentParcelHide; m_currentParcelHide = false; SendAvatarDataToAllAgents(); + // now hide if (newhide) { ParcelLoginCheck(m_currentParcelUUID); @@ -3522,7 +3576,7 @@ namespace OpenSim.Region.Framework.Scenes if(Animator!= null) Animator.SendAnimPack(); } - +*/ /// /// Send avatar full data appearance and animations for all other root agents to this agent, this agent /// can be either a child or root @@ -3530,15 +3584,18 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarFullToMe() { int count = 0; - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence p) { // only send information about other root agents - if (scenePresence.UUID == UUID) + if (p.UUID == UUID) return; - scenePresence.SendAvatarDataToAgent(this); - scenePresence.SendAppearanceToAgent(this); - scenePresence.SendAnimPackToAgent(this); + if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodLevel < 200) + return; + + p.SendAvatarDataToAgentNF(this); + p.SendAppearanceToAgentNF(this); + p.SendAnimPackToAgentNF(this); // for now attachments are sent with all SOG count++; }); @@ -3559,7 +3616,6 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat( "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", Name, Scene.RegionInfo.RegionName); - return; } @@ -3575,6 +3631,26 @@ namespace OpenSim.Region.Framework.Scenes m_scene.StatsReporter.AddAgentUpdates(count); } + // sends avatar object to all clients so they cross it into region + // then sends kills to hide + public void SendInitialAvatarDataToAllAgents(List presences) + { + m_lastSize = Appearance.AvatarSize; + int count = 0; + + foreach (ScenePresence p in presences) + { + p.ControllingClient.SendAvatarDataImmediate(this); + if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + // either just kill the object + // p.ControllingClient.SendKillObject(new List {LocalId}); + // or also attachments viewer may still know about + SendKillTo(p); + count++; + } + m_scene.StatsReporter.AddAgentUpdates(count); + } + /// /// Send avatar data to an agent. /// @@ -3589,9 +3665,9 @@ namespace OpenSim.Region.Framework.Scenes public void SendAvatarDataToAgentNF(ScenePresence avatar) { - avatar.ControllingClient.SendAvatarDataImmediate(this); + avatar.ControllingClient.SendAvatarDataImmediate(this); } - + /// /// Send this agent's appearance to all other root and child agents in the scene /// This agent must be root. @@ -3637,6 +3713,12 @@ namespace OpenSim.Region.Framework.Scenes UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); } + public void SendAppearanceToAgentNF(ScenePresence avatar) + { + avatar.ControllingClient.SendAppearance( + UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); + } + public void SendAnimPackToAgent(ScenePresence p) { if (IsChildAgent || Animator == null) @@ -3648,6 +3730,29 @@ namespace OpenSim.Region.Framework.Scenes Animator.SendAnimPackToClient(p.ControllingClient); } + public void SendAnimPackToAgent(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs) + { + if (IsChildAgent) + return; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + return; + + p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); + } + + public void SendAnimPackToAgentNF(ScenePresence p) + { + if (IsChildAgent || Animator == null) + return; + Animator.SendAnimPackToClient(p.ControllingClient); + } + + public void SendAnimPackToAgentNF(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs) + { + p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); + } + public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) { if (IsChildAgent) @@ -5634,22 +5739,6 @@ namespace OpenSim.Region.Framework.Scenes } } - private void ParcelLoginCheck(UUID currentParcelID) - { - List allpresences = m_scene.GetScenePresences(); - - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) - { - SendKillTo(p); - } - } - } - public void parcelRegionCross() { if (!ParcelHideThisAvatar || GodLevel >= 200) @@ -5817,8 +5906,6 @@ namespace OpenSim.Region.Framework.Scenes if (killsToSendme.Count > 0) { - m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString()); - foreach (ScenePresence p in killsToSendme) { m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname); -- cgit v1.1 From 1aa335078a15b176215df963980fdb1141494324 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Aug 2014 21:54:00 +0100 Subject: sop SendFullUpdate() goes by presence if it is a attachment --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 15 +++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 32 +++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0930820..6fbe732 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3237,7 +3237,19 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); - + + + if (ParentGroup.IsAttachment) + { + ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); + if (sp != null) + { + sp.SendAttachmentUpdate(this, UpdateRequired.FULL); + } + } + +/* this does nothing +SendFullUpdateToClient(remoteClient, Position) ignores position parameter if (IsRoot) { if (ParentGroup.IsAttachment) @@ -3249,6 +3261,7 @@ namespace OpenSim.Region.Framework.Scenes SendFullUpdateToClient(remoteClient, AbsolutePosition); } } +*/ else { SendFullUpdateToClient(remoteClient); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index faa07d4..d471930 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1891,7 +1891,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectGroup sog in m_attachments) { SendFullUpdateToClient(ControllingClient); - sog.SendFullUpdateToClient(ControllingClient); + SendAttachmentFullUpdateToAgentNF(sog, this); if (!sog.HasPrivateAttachmentPoint) { @@ -1905,7 +1905,7 @@ namespace OpenSim.Region.Framework.Scenes continue; SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path - sog.SendFullUpdateToClient(p.ControllingClient); + SendAttachmentFullUpdateToAgentNF(sog, p); }; } sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); @@ -4745,9 +4745,11 @@ namespace OpenSim.Region.Framework.Scenes { if (p != this && sog.HasPrivateAttachmentPoint) return; + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; - sog.SendFullUpdateToClient(p.ControllingClient); + + SendAttachmentFullUpdateToAgentNF(sog, p); SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); } @@ -4762,15 +4764,31 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectGroup sog in m_attachments) { - if (p == this || !sog.HasPrivateAttachmentPoint) - { - sog.SendFullUpdateToClient(p.ControllingClient); - } + SendAttachmentFullUpdateToAgentNF(sog, p); } SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path } } + public void SendAttachmentFullUpdateToAgentNF(SceneObjectGroup sog, ScenePresence p) + { + if (p != this && sog.HasPrivateAttachmentPoint) + return; + + SceneObjectPart[] parts = sog.Parts; + SceneObjectPart rootpart = sog.RootPart; + + p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate); + + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + if (part == rootpart) + continue; + p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); + } + } + public void SendAttachmentScheduleUpdate(SceneObjectGroup sog) { if (IsChildAgent || IsInTransit) -- cgit v1.1 From 8fd836c29921fdf7c52d7ca99b9c88dd87f8a3c7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 23 Aug 2014 12:03:55 +0100 Subject: back to sending attachment sog kills in place of the hack. This is the official way of doing it --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d471930..4632402 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5965,22 +5965,25 @@ namespace OpenSim.Region.Framework.Scenes Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } - public void SendFullKillsTo(ScenePresence p) +// kill with attachs root kills + public void SendKillTo(ScenePresence p) { - List ids = new List(); - foreach (SceneObjectGroup sog in m_attachments) - p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); + List ids = new List(m_attachments.Count + 1); ids.Add(LocalId); + foreach (SceneObjectGroup sog in m_attachments) + ids.Add(sog.RootPart.LocalId); p.ControllingClient.SendKillObject(ids); } +/* +// kill with hack public void SendKillTo(ScenePresence p) { foreach (SceneObjectGroup sog in m_attachments) p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); p.ControllingClient.SendKillObject(new List { LocalId }); } - +*/ public void SendViewTo(ScenePresence p) { SendAvatarDataToAgentNF(p); -- cgit v1.1 From 06b6238d007123d23f394f38b44f0aced997269e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 23 Aug 2014 22:24:28 +0100 Subject: send avatar kills after attachments, send otherattachments before rest of sog ( updates will mess this again but well... ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4632402..f0ea0ba 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3521,7 +3521,7 @@ namespace OpenSim.Region.Framework.Scenes EntityBase[] entities = Scene.Entities.GetEntities(); foreach (EntityBase e in entities) { - if (e != null && e is SceneObjectGroup) + if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); } }); @@ -3596,7 +3596,7 @@ namespace OpenSim.Region.Framework.Scenes p.SendAvatarDataToAgentNF(this); p.SendAppearanceToAgentNF(this); p.SendAnimPackToAgentNF(this); - // for now attachments are sent with all SOG + p.SendAttachmentsToAgentNF(this); count++; }); @@ -5969,9 +5969,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendKillTo(ScenePresence p) { List ids = new List(m_attachments.Count + 1); - ids.Add(LocalId); foreach (SceneObjectGroup sog in m_attachments) ids.Add(sog.RootPart.LocalId); + + ids.Add(LocalId); p.ControllingClient.SendKillObject(ids); } -- cgit v1.1 From f4a6be86546b3bfeefbdbade33f2faabdd080c1f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 24 Aug 2014 00:44:14 +0100 Subject: clean sendKill a bit, remove a IsChild that is set too early in a calling path --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f0ea0ba..e61e856 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3590,10 +3590,12 @@ namespace OpenSim.Region.Framework.Scenes if (p.UUID == UUID) return; + // get the avatar, then a kill if can't see it + p.SendInitialAvatarDataToAgent(this); + if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodLevel < 200) return; - p.SendAvatarDataToAgentNF(this); p.SendAppearanceToAgentNF(this); p.SendAnimPackToAgentNF(this); p.SendAttachmentsToAgentNF(this); @@ -3651,6 +3653,16 @@ namespace OpenSim.Region.Framework.Scenes m_scene.StatsReporter.AddAgentUpdates(count); } + public void SendInitialAvatarDataToAgent(ScenePresence p) + { + p.ControllingClient.SendAvatarDataImmediate(this); + if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + // either just kill the object + // p.ControllingClient.SendKillObject(new List {LocalId}); + // or also attachments viewer may still know about + SendKillTo(p); + } + /// /// Send avatar data to an agent. /// @@ -5959,7 +5971,8 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; SendKillTo(p); - p.SendKillTo(this); + if (!p.IsChildAgent) + p.SendKillTo(this); } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); -- cgit v1.1 From 385fcbb75ea9456997194c8fbe155cff41e95605 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 25 Aug 2014 13:58:50 +0100 Subject: *test* send kills and hack --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e61e856..fb2d29b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5983,7 +5983,10 @@ namespace OpenSim.Region.Framework.Scenes { List ids = new List(m_attachments.Count + 1); foreach (SceneObjectGroup sog in m_attachments) + { + p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); ids.Add(sog.RootPart.LocalId); + } ids.Add(LocalId); p.ControllingClient.SendKillObject(ids); -- cgit v1.1 From b1f14ad62f23d4cdb44ec529704d53e6eef7eb55 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 25 Aug 2014 14:15:53 +0100 Subject: back to just kills --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fb2d29b..4fa95fd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5984,7 +5984,6 @@ namespace OpenSim.Region.Framework.Scenes List ids = new List(m_attachments.Count + 1); foreach (SceneObjectGroup sog in m_attachments) { - p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); ids.Add(sog.RootPart.LocalId); } -- cgit v1.1 From 6857afe2a4ca73da904b9928c282c0087ff4b3bf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 25 Aug 2014 23:31:04 +0100 Subject: *test* back to no sog kills, little retouch on attachment updates, NameValue AttachItemID is a root part thing only --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4fa95fd..58d3ef6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5982,10 +5982,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendKillTo(ScenePresence p) { List ids = new List(m_attachments.Count + 1); - foreach (SceneObjectGroup sog in m_attachments) - { - ids.Add(sog.RootPart.LocalId); - } +// foreach (SceneObjectGroup sog in m_attachments) +// { +// ids.Add(sog.RootPart.LocalId); +// } ids.Add(LocalId); p.ControllingClient.SendKillObject(ids); -- cgit v1.1 From 3ee6144d0ca1d35d6660b006b89fc883e1a2bfda Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 26 Aug 2014 00:00:21 +0100 Subject: even less kills on tps --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 58d3ef6..9fe3a9e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5966,7 +5966,7 @@ namespace OpenSim.Region.Framework.Scenes public void HasMovedAway() { List allpresences = m_scene.GetScenePresences(); - foreach (ScenePresence p in allpresences) + /* foreach (ScenePresence p in allpresences) { if (p == this) continue; @@ -5974,6 +5974,7 @@ namespace OpenSim.Region.Framework.Scenes if (!p.IsChildAgent) p.SendKillTo(this); } + */ if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } -- cgit v1.1 From dde2ac254497053bb7ec8e5f1757ddf13e5ea033 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 26 Aug 2014 02:22:25 +0100 Subject: still testing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9fe3a9e..2b1b342 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1887,29 +1887,26 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - // Resume scripts this possible should also be moved down after sending the avatar to viewer ? - foreach (SceneObjectGroup sog in m_attachments) + foreach(SceneObjectGroup sog in m_attachments) { - SendFullUpdateToClient(ControllingClient); - SendAttachmentFullUpdateToAgentNF(sog, this); + sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); + sog.ResumeScripts(); + } - if (!sog.HasPrivateAttachmentPoint) + foreach (ScenePresence p in allpresences) + { + if (p == this) { - // sog.ScheduleGroupForFullUpdate(); - foreach(ScenePresence p in allpresences) - { - if (p == this) - continue; + SendTerseUpdateToAgentNF(this); + SendAttachmentsToAgentNF(this); + continue; + } - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) - continue; + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + continue; - SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path - SendAttachmentFullUpdateToAgentNF(sog, p); - }; - } - sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); - sog.ResumeScripts(); + SendTerseUpdateToAgentNF(p); + SendAttachmentsToAgentNF(p); } } } @@ -3428,7 +3425,9 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient.IsActive) { //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); - remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate); + remoteClient.SendEntityUpdate(this, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); m_scene.StatsReporter.AddAgentUpdates(1); } } @@ -4761,8 +4760,8 @@ namespace OpenSim.Region.Framework.Scenes if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) return; + SendTerseUpdateToAgentNF(p); SendAttachmentFullUpdateToAgentNF(sog, p); - SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path }); } } @@ -4772,13 +4771,13 @@ namespace OpenSim.Region.Framework.Scenes // for now they are checked in several places down the line... public void SendAttachmentsToAgentNF(ScenePresence p) { + SendTerseUpdateToAgentNF(p); lock (m_attachments) { foreach (SceneObjectGroup sog in m_attachments) { SendAttachmentFullUpdateToAgentNF(sog, p); - } - SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path + } } } @@ -5966,7 +5965,7 @@ namespace OpenSim.Region.Framework.Scenes public void HasMovedAway() { List allpresences = m_scene.GetScenePresences(); - /* foreach (ScenePresence p in allpresences) + foreach (ScenePresence p in allpresences) { if (p == this) continue; @@ -5974,19 +5973,20 @@ namespace OpenSim.Region.Framework.Scenes if (!p.IsChildAgent) p.SendKillTo(this); } - */ + if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } + // kill with attachs root kills public void SendKillTo(ScenePresence p) { List ids = new List(m_attachments.Count + 1); -// foreach (SceneObjectGroup sog in m_attachments) -// { -// ids.Add(sog.RootPart.LocalId); -// } + foreach (SceneObjectGroup sog in m_attachments) + { + ids.Add(sog.RootPart.LocalId); + } ids.Add(LocalId); p.ControllingClient.SendKillObject(ids); -- cgit v1.1 From 620443f85840aab0f2ddc4a88656a166cc148b69 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 27 Aug 2014 00:37:05 +0100 Subject: on TPs to nearby regions, only send kills if needed by parcel privacy --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 38 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2b1b342..d7656e8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5962,18 +5962,38 @@ namespace OpenSim.Region.Framework.Scenes } } - public void HasMovedAway() + public void HasMovedAway(bool nearRegion) { - List allpresences = m_scene.GetScenePresences(); - foreach (ScenePresence p in allpresences) + + if (nearRegion) { - if (p == this) - continue; - SendKillTo(p); - if (!p.IsChildAgent) - p.SendKillTo(this); - } + if (!ParcelHideThisAvatar || GodLevel >= 200) + return; + + List allpresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allpresences) + { + if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive) + continue; + if (p.currentParcelUUID == m_currentParcelUUID) + { + p.SendKillTo(this); + } + } + } + else + { + List allpresences = m_scene.GetScenePresences(); + foreach (ScenePresence p in allpresences) + { + if (p == this) + continue; + SendKillTo(p); + if (!p.IsChildAgent) + p.SendKillTo(this); + } + } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } -- cgit v1.1 From 07ee101a057c9b5dee27c4248ce15dd8bfaae380 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 27 Aug 2014 01:09:11 +0100 Subject: bug fix. Was not deleting attachments if on public parcel --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d7656e8..5868251 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5967,6 +5967,9 @@ namespace OpenSim.Region.Framework.Scenes if (nearRegion) { + if (Scene.AttachmentsModule != null) + Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); + if (!ParcelHideThisAvatar || GodLevel >= 200) return; @@ -5993,9 +5996,10 @@ namespace OpenSim.Region.Framework.Scenes if (!p.IsChildAgent) p.SendKillTo(this); } + + if (Scene.AttachmentsModule != null) + Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } - if (Scene.AttachmentsModule != null) - Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); } -- cgit v1.1 From 73cdafd6c9530b9484875c4939558b451b656660 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 27 Aug 2014 15:57:12 +0100 Subject: dont mess throotles values sent to child presences. Some cleanup --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 91 ++++++++++-------------- 1 file changed, 38 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5868251..8198481 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3811,6 +3811,11 @@ namespace OpenSim.Region.Framework.Scenes // Throttles float multiplier = 1; + +/* dont messup throttles + * child agent is a full presence that can be just a few meters away across border + * sending this is possible wrong since viewers may send own needs to each region + * int childRegions = KnownRegionCount; if (childRegions != 0) multiplier = 1f / childRegions; @@ -3818,7 +3823,7 @@ namespace OpenSim.Region.Framework.Scenes // Minimum throttle for a child region is 1/4 of the root region throttle if (multiplier <= 0.25f) multiplier = 0.25f; - +*/ cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); cadu.Velocity = Velocity; @@ -4814,43 +4819,43 @@ namespace OpenSim.Region.Framework.Scenes int j = 0; bool allterse = true; - for (int i = 0; i < origparts.Length; i++) { - switch (origparts[i].UpdateFlag) + if (origparts[i] != rootpart) { - case UpdateRequired.TERSE: - flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity - | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; - parts[j] = origparts[i]; - j++; - break; - - case UpdateRequired.FULL: - flags[j] = PrimUpdateFlags.FullUpdate; - parts[j] = origparts[i]; - j++; - allterse = false; - break; + switch (origparts[i].UpdateFlag) + { + case UpdateRequired.NONE: + break; + + case UpdateRequired.TERSE: + flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; + parts[j] = origparts[i]; + j++; + break; + + case UpdateRequired.FULL: + flags[j] = PrimUpdateFlags.FullUpdate; + allterse = false; + parts[j] = origparts[i]; + j++; + break; + } } origparts[i].UpdateFlag = 0; } - if (j == 0) + if (j == 0 && rootreq == UpdateRequired.NONE) return; - if (rootreq == UpdateRequired.NONE) - { - if (allterse) - rootreq = UpdateRequired.TERSE; - else - rootreq = UpdateRequired.FULL; - } - PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate; - if (rootreq == UpdateRequired.TERSE) + + if (rootreq != UpdateRequired.FULL && allterse) + { rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; + } int nparts = j; @@ -4870,10 +4875,7 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < nparts; i++) { - SceneObjectPart part = parts[i]; - if (part == rootpart) - continue; - p.ControllingClient.SendEntityUpdate(part, flags[i]); + p.ControllingClient.SendEntityUpdate(parts[i], flags[i]); } } } @@ -4902,6 +4904,8 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = sog.Parts; SceneObjectPart rootpart = sog.RootPart; + rootpart.UpdateFlag = 0; + bool priv = sog.HasPrivateAttachmentPoint; List allPresences = m_scene.GetScenePresences(); @@ -4915,7 +4919,6 @@ namespace OpenSim.Region.Framework.Scenes } p.ControllingClient.SendEntityUpdate(rootpart, flag); - rootpart.UpdateFlag = 0; for (int i = 0; i < parts.Length; i++) { @@ -4950,6 +4953,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + part.UpdateFlag = 0; + bool priv = part.ParentGroup.HasPrivateAttachmentPoint; List allPresences = m_scene.GetScenePresences(); @@ -4964,7 +4969,6 @@ namespace OpenSim.Region.Framework.Scenes } p.ControllingClient.SendEntityUpdate(part, flag); - part.UpdateFlag = 0; } } @@ -4989,6 +4993,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + part.UpdateFlag = 0; + bool priv = part.ParentGroup.HasPrivateAttachmentPoint; List allPresences = m_scene.GetScenePresences(); @@ -5002,7 +5008,6 @@ namespace OpenSim.Region.Framework.Scenes } p.ControllingClient.SendEntityUpdate(part, flag); - part.UpdateFlag = 0; } } @@ -5768,26 +5773,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void parcelRegionCross() - { - if (!ParcelHideThisAvatar || GodLevel >= 200) - return; - - List allpresences = null; - allpresences = m_scene.GetScenePresences(); - - foreach (ScenePresence p in allpresences) - { - if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive) - continue; - - if (p.currentParcelUUID == m_currentParcelUUID) - { - p.SendKillTo(this); - } - } - } - private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) { -- cgit v1.1 From b871029a30d47c0e9f91510ee392fd8ac8793533 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 27 Aug 2014 18:05:40 +0100 Subject: dont create a cadu that is not used. Add a root region global position --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8198481..f2353b9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -494,11 +494,18 @@ namespace OpenSim.Region.Framework.Scenes } private ulong m_rootRegionHandle; + private Vector3 m_rootRegionPosition = new Vector3(); public ulong RegionHandle { get { return m_rootRegionHandle; } - private set { m_rootRegionHandle = value; } + private set + { + m_rootRegionHandle = value; + // position rounded to lower multiple of 256m + m_rootRegionPosition.X = (float)((m_rootRegionHandle >> 32) & 0xffffff00); + m_rootRegionPosition.Y = (float)(m_rootRegionHandle & 0xffffff00); + } } #region Client Camera @@ -3798,6 +3805,7 @@ namespace OpenSim.Region.Framework.Scenes m_lastChildAgentUpdatePosition = AbsolutePosition; // m_lastChildAgentUpdateCamPosition = CameraPosition; +/* cadu is not used ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); cadu.ActiveGroupID = UUID.Zero.Guid; cadu.AgentID = UUID.Guid; @@ -3812,10 +3820,6 @@ namespace OpenSim.Region.Framework.Scenes // Throttles float multiplier = 1; -/* dont messup throttles - * child agent is a full presence that can be just a few meters away across border - * sending this is possible wrong since viewers may send own needs to each region - * int childRegions = KnownRegionCount; if (childRegions != 0) multiplier = 1f / childRegions; @@ -3823,12 +3827,25 @@ namespace OpenSim.Region.Framework.Scenes // Minimum throttle for a child region is 1/4 of the root region throttle if (multiplier <= 0.25f) multiplier = 0.25f; -*/ + cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); cadu.Velocity = Velocity; - +*/ AgentPosition agentpos = new AgentPosition(); - agentpos.CopyFrom(cadu, ControllingClient.SessionId); +// agentpos.CopyFrom(cadu, ControllingClient.SessionId); + + agentpos.AgentID = new UUID(UUID.Guid); + agentpos.SessionID = ControllingClient.SessionId; + + agentpos.Size = Appearance.AvatarSize; + + agentpos.Center = CameraPosition; + agentpos.Far = DrawDistance; + agentpos.Position = AbsolutePosition; + agentpos.Velocity = Velocity; + agentpos.RegionHandle = RegionHandle; + agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); + // Let's get this out of the update loop Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); }); @@ -4131,6 +4148,8 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) return; + RegionHandle = cAgentData.RegionHandle; + //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; @@ -4158,7 +4177,6 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); //cAgentData.AVHeight; - RegionHandle = cAgentData.RegionHandle; //m_velocity = cAgentData.Velocity; } -- cgit v1.1 From 38fc1cc4452a29fe552efcfbda95cb0eabb0e082 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 28 Aug 2014 00:44:59 +0100 Subject: try to make child presence know its root region. Incomplete, some paths dont send the information. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 ++++-------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f2353b9..47acb0b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1162,45 +1162,9 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); -/* this should be done by groups module on TriggerOnMakeRootAgent(this) below - at least XmlIRpcGroups - UUID groupUUID = UUID.Zero; - string GroupName = string.Empty; - ulong groupPowers = 0; - - - - // ---------------------------------- - // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status - try - { - - if (gm != null) - { - groupUUID = ControllingClient.ActiveGroupId; - GroupRecord record = gm.GetGroupRecord(groupUUID); - if (record != null) - GroupName = record.GroupName; - GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); - if (groupMembershipData != null) - groupPowers = groupMembershipData.GroupPowers; - } - ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, - Grouptitle); - } - catch (Exception e) - { - m_log.Debug("[AGENTUPDATE]: " + e.ToString()); - } - // ------------------------------------ -*/ if (ParentID == 0) { - // Moved this from SendInitialData to ensure that Appearance is initialized - // before the inventory is processed in MakeRootAgent. This fixes a race condition - // related to the handling of attachments - if (m_scene.TestBorderCross(pos, Cardinals.E)) { Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); @@ -1310,11 +1274,14 @@ namespace OpenSim.Region.Framework.Scenes /// It doesn't get called for a teleport. Reason being, an agent that /// teleports out may not end up anywhere near this region /// - public void MakeChildAgent() + public void MakeChildAgent(ulong newRegionHandle) { m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; - m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); + RegionHandle = newRegionHandle; + + m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1} from root region {2}", + Name, Scene.RegionInfo.RegionName, newRegionHandle); // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating // from the source simulator has completed on a V2 teleport. @@ -4023,6 +3990,7 @@ namespace OpenSim.Region.Framework.Scenes } +/* useless. Either use MakeChild or delete the presence public void Reset() { // m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName); @@ -4033,7 +4001,7 @@ namespace OpenSim.Region.Framework.Scenes Animator.ResetAnimations(); } - +*/ /// /// Computes which child agents to close when the scene presence moves to another region. /// Removes those regions from m_knownRegions. -- cgit v1.1 From cf1d58d164cc536f13c1d9ab2b1aeac98e802003 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 5 Sep 2014 15:16:13 +0100 Subject: do not send objectproprieties on sop.SetGroup(). I many cases this will arrive before creating the object in viewer with respective full update --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6fbe732..43ae880 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3807,8 +3807,8 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter // Name, groupID, OwnerID); GroupID = groupID; - if (client != null) - SendPropertiesToClient(client); +// if (client != null) +// SendPropertiesToClient(client); UpdateFlag = UpdateRequired.FULL; } -- cgit v1.1 From 8e15d4ad57de6f2a0c900968ef778fba7cdced63 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 8 Sep 2014 23:58:49 +0100 Subject: limit number of prims on physical objects. Not all cases covered still --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 +++ OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 10 ++++- .../Region/Framework/Scenes/SceneObjectGroup.cs | 46 +++++++++++++++++++++- 4 files changed, 67 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 8634a3a..e003a59 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2705,12 +2705,17 @@ namespace OpenSim.Region.Framework.Scenes return; } + bool oldUsePhysics = (root.Flags & PrimFlags.Physics) != 0; m_sceneGraph.LinkObjects(root, children); ScenePresence sp; if (TryGetScenePresence(agentId, out sp)) { root.SendPropertiesToClient(sp.ControllingClient); + if (oldUsePhysics && (root.Flags & PrimFlags.Physics) == 0) + { + sp.ControllingClient.SendAlertMessage("Object physics canceled"); + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index aa81000..323b588 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -204,6 +204,12 @@ namespace OpenSim.Region.Framework.Scenes /// public int m_linksetCapacity = 0; + /// + /// Max prims an Physical object will hold + /// + /// + public int m_linksetPhysCapacity = 5; + public bool m_clampPrimSize; public bool m_trustBinaries; public bool m_allowScriptCrossings; @@ -901,6 +907,9 @@ namespace OpenSim.Region.Framework.Scenes m_linksetCapacity = RegionInfo.LinksetCapacity; } + m_linksetPhysCapacity = startupConfig.GetInt("LinksetPhysPrims", m_linksetPhysCapacity); + + SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b0f8991..973891b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1547,6 +1547,7 @@ namespace OpenSim.Region.Framework.Scenes // VolumeDetect can't be set via UI and will always be off when a change is made there // now only change volume dtc if phantom off + bool wantedPhys = UsePhysics; if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data { bool vdtc; @@ -1563,10 +1564,17 @@ namespace OpenSim.Region.Framework.Scenes if (part != null) { part.UpdateExtraPhysics(PhysData); - if (part.UpdatePhysRequired) + if (part.UpdatePhysRequired && remoteClient != null) remoteClient.SendPartPhysicsProprieties(part); } } + + if (wantedPhys != group.UsesPhysics && remoteClient != null) + { + remoteClient.SendAlertMessage("Object physics canceled because exceeds the limit of " + + m_parentScene.m_linksetPhysCapacity + " physical prims with shape type not set to None"); + group.RootPart.ScheduleFullUpdate(); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d3dd5d7..d4a563f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1712,7 +1712,9 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.SetParentLocalId(0); AttachmentPoint = (byte)0; // must check if buildind should be true or false here - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); +// m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); + ApplyPhysics(); + HasGroupChanged = true; RootPart.Rezzed = DateTime.Now; RootPart.RemFlag(PrimFlags.TemporaryOnRez); @@ -2879,6 +2881,33 @@ namespace OpenSim.Region.Framework.Scenes return; } + // physical prims count limit + // not very eficient :( + + if (UsesPhysics && m_scene.m_linksetPhysCapacity > 0 && (PrimCount + objectGroup.PrimCount) > + m_scene.m_linksetPhysCapacity) + { + int cntr = 0; + foreach (SceneObjectPart part in Parts) + { + if (part.PhysicsShapeType != (byte)PhysicsShapeType.None) + cntr++; + } + foreach (SceneObjectPart part in objectGroup.Parts) + { + if (part.PhysicsShapeType != (byte)PhysicsShapeType.None) + cntr++; + } + + if (cntr > m_scene.m_linksetPhysCapacity) + { + // cancel physics + RootPart.Flags &= ~PrimFlags.Physics; + ApplyPhysics(); + } + } + + // 'linkPart' == the root of the group being linked into this group SceneObjectPart linkPart = objectGroup.m_rootPart; @@ -3477,8 +3506,12 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart[] parts = m_parts.GetArray(); - if (Scene != null) + if (Scene != null && UsePhysics) { + int maxprims = m_scene.m_linksetPhysCapacity; + bool checkShape = (maxprims > 0 && + parts.Length > maxprims); + for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; @@ -3489,6 +3522,15 @@ namespace OpenSim.Region.Framework.Scenes UsePhysics = false; // Reset physics break; } + + if (checkShape && part.PhysicsShapeType != (byte)PhysicsShapeType.None) + { + if (--maxprims < 0) + { + UsePhysics = false; + break; + } + } } } -- cgit v1.1 From 51697944b62954ee94dd4da50dd37847535bdcb3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 00:09:39 +0100 Subject: dont send fullObjectUpdate on deselect --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d4a563f..15349e3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -907,10 +907,10 @@ namespace OpenSim.Region.Framework.Scenes return; } IsSelected = partSelect; - if (!IsAttachment) - { - ScheduleGroupForFullUpdate(); - } +// if (!IsAttachment) +// { +// ScheduleGroupForFullUpdate(); +// } } } // PlaySoundMasterPrim no longer in use to remove -- cgit v1.1 From f2390f7c72c70912da8c5d4626064996d42811bc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 03:01:05 +0200 Subject: Plumb llSetAnimationOverride --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 47acb0b..4d5f747 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -6004,5 +6004,9 @@ namespace OpenSim.Region.Framework.Scenes Animator.SendAnimPackToClient(p.ControllingClient); SendAttachmentsToAgentNF(p); } + + public void SetAnimationOverride(string animState, UUID animID) + { + } } } -- cgit v1.1 From 17154fbffa06e9a9c969d57fd39c04caccc9427d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 02:22:07 +0100 Subject: set default LinksetPhysPrims to 0 so max number of prims for physical object is disabled --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 323b588..7275c15 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -208,7 +208,7 @@ namespace OpenSim.Region.Framework.Scenes /// Max prims an Physical object will hold /// /// - public int m_linksetPhysCapacity = 5; + public int m_linksetPhysCapacity = 0; public bool m_clampPrimSize; public bool m_trustBinaries; -- cgit v1.1 From 18023169e79584cd3ddb4f544f9d485edc9e1b85 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 04:12:10 +0200 Subject: Actually do the overriding --- .../Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 8 +++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index fdadd32..3cb8f59 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -196,7 +196,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation // "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", // anim, m_scenePresence.Name); - if (m_animations.TrySetDefaultAnimation( + UUID overridenAnim = m_scenePresence.Overrides.GetOverriddenAnimation(anim); + if (overridenAnim != UUID.Zero) + { + m_animations.SetDefaultAnimation(overridenAnim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); + ret = true; + } + else if (m_animations.TrySetDefaultAnimation( anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) { // m_log.DebugFormat( diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4d5f747..8f6b41b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -239,6 +239,11 @@ namespace OpenSim.Region.Framework.Scenes /// public ScenePresenceAnimator Animator { get; private set; } + /// + /// Server Side Animation Override + /// + public MovementAnimationOverrides Overrides { get; private set; } + /// /// Attachments recorded on this avatar. /// @@ -967,6 +972,7 @@ namespace OpenSim.Region.Framework.Scenes IsLoggingIn = false; m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); + Overrides = new MovementAnimationOverrides(); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; @@ -6007,6 +6013,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetAnimationOverride(string animState, UUID animID) { + Overrides.SetOverride(animState, animID); } } } -- cgit v1.1 From d2324b64c719f429e11b3946936341343d70d750 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 04:12:58 +0200 Subject: Add missing file --- .../Scenes/Animation/MovementAnimationOverrides.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs new file mode 100644 index 0000000..04dccc8 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using System.Timers; +using Timer = System.Timers.Timer; +using OpenMetaverse; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes.Animation; +using OpenSim.Region.Framework.Scenes.Types; +using OpenSim.Region.Physics.Manager; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Services.Interfaces; +using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; + +namespace OpenSim.Region.Framework.Scenes +{ + public class MovementAnimationOverrides + { + private Dictionary m_overrides = new Dictionary(); + public void SetOverride(string state, UUID animID) + { + if (animID == UUID.Zero) + { + m_overrides.Remove(state); + return; + } + + lock (m_overrides) + m_overrides[state] = animID; + } + + public UUID GetOverriddenAnimation(string state) + { + lock (m_overrides) + { + if (m_overrides.ContainsKey(state)) + return m_overrides[state]; + } + + return UUID.Zero; + } + } +} -- cgit v1.1 From aa84ad369caf922534e85b5d2da12d716d6696f6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 04:35:08 +0200 Subject: Add some forgotten calls --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 3cb8f59..9fd5e64 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -200,6 +200,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (overridenAnim != UUID.Zero) { m_animations.SetDefaultAnimation(overridenAnim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); + m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); + SendAnimPack(); ret = true; } else if (m_animations.TrySetDefaultAnimation( -- cgit v1.1 From 347c5b3070f7ce6ecc2a617e09fd02e4616061ba Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 05:20:53 +0200 Subject: Add perms check --- .../Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs index 04dccc8..f77d29a 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs @@ -49,6 +49,9 @@ namespace OpenSim.Region.Framework.Scenes { public class MovementAnimationOverrides { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_overrides = new Dictionary(); public void SetOverride(string state, UUID animID) { @@ -58,6 +61,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + m_log.DebugFormat("Setting override for {0} to {1}", state, animID); + lock (m_overrides) m_overrides[state] = animID; } -- cgit v1.1 From 4ed3461573fccf6a8016c01b2b27f69bdf88a168 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 05:20:43 +0100 Subject: huds bug fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 78 +++++++++++++++--------- 1 file changed, 50 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4d5f747..19fd542 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4845,17 +4845,24 @@ namespace OpenSim.Region.Framework.Scenes int nparts = j; - bool priv = sog.HasPrivateAttachmentPoint; + ControllingClient.SendEntityUpdate(rootpart, rootflag); + + for (int i = 0; i < nparts; i++) + { + ControllingClient.SendEntityUpdate(parts[i], flags[i]); + } + + if (sog.HasPrivateAttachmentPoint) + return; List allPresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allPresences) { - if (p != this) - { - if (priv || - (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - continue; - } + if (p == this) + continue; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + continue; p.ControllingClient.SendEntityUpdate(rootpart, rootflag); @@ -4892,17 +4899,29 @@ namespace OpenSim.Region.Framework.Scenes rootpart.UpdateFlag = 0; - bool priv = sog.HasPrivateAttachmentPoint; + ControllingClient.SendEntityUpdate(rootpart, flag); + + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + if (part == rootpart) + continue; + ControllingClient.SendEntityUpdate(part, flag); + part.UpdateFlag = 0; + } + + if (sog.HasPrivateAttachmentPoint) + return; + List allPresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allPresences) { - if (p != this) - { - if (priv || - (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - continue; - } + if (p == this) + continue; + + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + continue; p.ControllingClient.SendEntityUpdate(rootpart, flag); @@ -4941,23 +4960,25 @@ namespace OpenSim.Region.Framework.Scenes part.UpdateFlag = 0; - bool priv = part.ParentGroup.HasPrivateAttachmentPoint; + ControllingClient.SendEntityUpdate(part, flag); + + if (part.ParentGroup.HasPrivateAttachmentPoint) + return; List allPresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allPresences) { - if (p != this) - { + if (p == this) + continue; - if (priv || - (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - continue; - } + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + continue; p.ControllingClient.SendEntityUpdate(part, flag); } } + public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) { if (IsChildAgent || IsInTransit) @@ -4981,17 +5002,18 @@ namespace OpenSim.Region.Framework.Scenes part.UpdateFlag = 0; - bool priv = part.ParentGroup.HasPrivateAttachmentPoint; + ControllingClient.SendEntityUpdate(part, flag); + + if (part.ParentGroup.HasPrivateAttachmentPoint) + return; List allPresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allPresences) { - if (p != this) - { - if ( priv || - (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) - continue; - } + if (p == this) + continue; + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + continue; p.ControllingClient.SendEntityUpdate(part, flag); } -- cgit v1.1 From 683f2cc892d453635ec12f34fd0c8a21bad00926 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 13:32:22 +0100 Subject: only cancel attchment needed update type on sending sheduled updates. This is wrong but its as original worked --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 19fd542..f3e6e89 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4897,7 +4897,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = sog.Parts; SceneObjectPart rootpart = sog.RootPart; - rootpart.UpdateFlag = 0; +// rootpart.UpdateFlag = 0; ControllingClient.SendEntityUpdate(rootpart, flag); @@ -4907,7 +4907,7 @@ namespace OpenSim.Region.Framework.Scenes if (part == rootpart) continue; ControllingClient.SendEntityUpdate(part, flag); - part.UpdateFlag = 0; +// part.UpdateFlag = 0; } if (sog.HasPrivateAttachmentPoint) @@ -4931,7 +4931,6 @@ namespace OpenSim.Region.Framework.Scenes if (part == rootpart) continue; p.ControllingClient.SendEntityUpdate(part, flag); - part.UpdateFlag = 0; } } } @@ -5000,7 +4999,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - part.UpdateFlag = 0; +// part.UpdateFlag = 0; ControllingClient.SendEntityUpdate(part, flag); -- cgit v1.1 From 002a2deaf9e5003075756d91cfaa95763ca60aea Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 19:09:06 +0100 Subject: add full delete if uuid iz zero and state is ALL --- .../Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs index f77d29a..db4003e 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs @@ -57,7 +57,10 @@ namespace OpenSim.Region.Framework.Scenes { if (animID == UUID.Zero) { - m_overrides.Remove(state); + if (state == "ALL") + m_overrides.Clear(); + else + m_overrides.Remove(state); return; } -- cgit v1.1 From 2d2823f1deb833a3d60ac6f4eb49f04c6cb7bdd2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 20:16:02 +0200 Subject: Add some case magic and send an anim pack when an override is set --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4aa38be..cecb9cf 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -6035,6 +6035,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetAnimationOverride(string animState, UUID animID) { Overrides.SetOverride(animState, animID); + Animator.SendAnimPack(); } } } -- cgit v1.1 From 87a4abac5085f7554699375eaf3d4b6cc621318a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2014 20:50:41 +0200 Subject: Plumb the rest of the serverside AO --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cecb9cf..b6eb4e4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -6037,5 +6037,10 @@ namespace OpenSim.Region.Framework.Scenes Overrides.SetOverride(animState, animID); Animator.SendAnimPack(); } + + public UUID GetAnimationOverride(string animState) + { + return Overrides.GetOverriddenAnimation(animState); + } } } -- cgit v1.1 From 016e58e354e11825510e1c4bc534e275168577bc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 21:53:27 +0100 Subject: *test* --- .../Scenes/Animation/MovementAnimationOverrides.cs | 17 +++++++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs index db4003e..31fdb2c 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs @@ -80,5 +80,22 @@ namespace OpenSim.Region.Framework.Scenes return UUID.Zero; } + + public Dictionary CloneAOPairs() + { + lock (m_overrides) + { + return new Dictionary(m_overrides); + } + } + + public void CopyAOPairsFrom(Dictionary src) + { + lock (m_overrides) + { + m_overrides.Clear(); + m_overrides = new Dictionary(src); + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b6eb4e4..7c515d5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4212,6 +4212,8 @@ namespace OpenSim.Region.Framework.Scenes cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; + cAgent.MovementAnimationOverRides = Overrides.CloneAOPairs(); + if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(this, cAgent); } @@ -4282,7 +4284,9 @@ namespace OpenSim.Region.Framework.Scenes catch { } Animator.ResetAnimations(); - + + Overrides.CopyAOPairsFrom(cAgent.MovementAnimationOverRides); + // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? if (cAgent.DefaultAnim != null) Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); -- cgit v1.1 From 9d815e2d2ab01cd69a568d90c44029cef808f85f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 22:07:03 +0100 Subject: on SetAnimationOverride do a UpdateMovementAnimations(); --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7c515d5..c24a4a2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -6039,7 +6039,8 @@ namespace OpenSim.Region.Framework.Scenes public void SetAnimationOverride(string animState, UUID animID) { Overrides.SetOverride(animState, animID); - Animator.SendAnimPack(); +// Animator.SendAnimPack(); + Animator.UpdateMovementAnimations(); } public UUID GetAnimationOverride(string animState) -- cgit v1.1 From e37fd5e716a44a57290d87239d52b2b62c0dae4a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 9 Sep 2014 22:27:21 +0100 Subject: force update of movement animation --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 15 ++++++++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 9fd5e64..bbc5745 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -475,7 +475,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation string newMovementAnimation = DetermineMovementAnimation(); if (CurrentMovementAnimation != newMovementAnimation) { - CurrentMovementAnimation = DetermineMovementAnimation(); + CurrentMovementAnimation = newMovementAnimation; // m_log.DebugFormat( // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", @@ -489,6 +489,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation return ret; } + public bool ForceUpdateMovementAnimations() + { + // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); + + bool ret = false; + lock (m_animations) + { + string newMovementAnimation = DetermineMovementAnimation(); + ret = TrySetMovementAnimation(newMovementAnimation); + } + return ret; + } + public UUID[] GetAnimationArray() { UUID[] animIDs; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c24a4a2..5da92f9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -6040,7 +6040,7 @@ namespace OpenSim.Region.Framework.Scenes { Overrides.SetOverride(animState, animID); // Animator.SendAnimPack(); - Animator.UpdateMovementAnimations(); + Animator.ForceUpdateMovementAnimations(); } public UUID GetAnimationOverride(string animState) -- cgit v1.1 From 0caa59b286dd9716da821fb32c23c8d63ff53729 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 10 Sep 2014 02:43:51 +0200 Subject: Fix a nullref that can hit Vivox voice --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7275c15..d336eda 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4982,7 +4982,10 @@ namespace OpenSim.Region.Framework.Scenes public LandData GetLandData(float x, float y) { - return LandChannel.GetLandObject(x, y).LandData; + ILandObject parcel = LandChannel.GetLandObject(x, y); + if (parcel == null) + return null; + return parcel.LandData; } /// @@ -4998,7 +5001,10 @@ namespace OpenSim.Region.Framework.Scenes public LandData GetLandData(uint x, uint y) { m_log.DebugFormat("[SCENE]: returning land for {0},{1}", x, y); - return LandChannel.GetLandObject((int)x, (int)y).LandData; + ILandObject parcel = LandChannel.GetLandObject((int)x, (int)y); + if (parcel == null) + return null; + return parcel.LandData; } #endregion -- cgit v1.1 From f66b58cf00d4dcbd9d11030809bf9766330966f2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 10 Sep 2014 19:30:57 +0100 Subject: *TEST* add movement states SIT and SITGROUND. ScenePresence on SIT, SITGROUND or STAND, sets directly the state, and desired sitAnimation for default sits --- .../Scenes/Animation/ScenePresenceAnimator.cs | 47 +++++++++++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 28 ++++++++++--- 2 files changed, 54 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index bbc5745..4d1d913 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -200,21 +200,28 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (overridenAnim != UUID.Zero) { m_animations.SetDefaultAnimation(overridenAnim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); - m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); + m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); SendAnimPack(); ret = true; } - else if (m_animations.TrySetDefaultAnimation( - anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) + else { -// m_log.DebugFormat( -// "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", -// anim, m_scenePresence.Name); + // translate sit and sitground state animations + if (anim == "SIT" || anim == "SITGROUND") + anim = m_scenePresence.sitAnimation; - // 16384 is CHANGED_ANIMATION - m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); - SendAnimPack(); - ret = true; + if (m_animations.TrySetDefaultAnimation( + anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) + { + // m_log.DebugFormat( + // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", + // anim, m_scenePresence.Name); + + // 16384 is CHANGED_ANIMATION + m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); + SendAnimPack(); + ret = true; + } } } else @@ -236,6 +243,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation const float JUMP_PERIOD = 800f; #region Inputs + if (m_scenePresence.SitGround) + return "SITGROUND"; + if (m_scenePresence.ParentID != 0 || m_scenePresence.ParentUUID != UUID.Zero) + return "SIT"; + AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; PhysicsActor actor = m_scenePresence.PhysicsActor; @@ -491,15 +503,20 @@ namespace OpenSim.Region.Framework.Scenes.Animation public bool ForceUpdateMovementAnimations() { - // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); + lock (m_animations) + { + CurrentMovementAnimation = DetermineMovementAnimation(); + return TrySetMovementAnimation(CurrentMovementAnimation); + } + } - bool ret = false; + public bool SetMovementAnimations(string motionState) + { lock (m_animations) { - string newMovementAnimation = DetermineMovementAnimation(); - ret = TrySetMovementAnimation(newMovementAnimation); + CurrentMovementAnimation = motionState; + return TrySetMovementAnimation(CurrentMovementAnimation); } - return ret; } public UUID[] GetAnimationArray() diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5da92f9..fd1bab6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -243,7 +243,7 @@ namespace OpenSim.Region.Framework.Scenes /// Server Side Animation Override /// public MovementAnimationOverrides Overrides { get; private set; } - + public String sitAnimation = "SIT"; /// /// Attachments recorded on this avatar. /// @@ -2779,7 +2779,11 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); } - Animator.TrySetMovementAnimation("STAND"); + // reset to default sitAnimation + sitAnimation = "SIT"; + +// Animator.TrySetMovementAnimation("STAND"); + Animator.SetMovementAnimations("STAND"); TriggerScenePresenceUpdated(); } @@ -3058,11 +3062,18 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); +/* if(status == 3) Animator.TrySetMovementAnimation("SIT_GROUND"); else Animator.TrySetMovementAnimation("SIT"); +*/ + if (status == 3) + sitAnimation = "SIT_GROUND"; + else + sitAnimation = "SIT"; + Animator.SetMovementAnimations("SIT"); part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } @@ -3164,12 +3175,13 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); - String sitAnimation = "SIT"; + sitAnimation = "SIT"; if (!String.IsNullOrEmpty(part.SitAnimation)) { sitAnimation = part.SitAnimation; } - Animator.TrySetMovementAnimation(sitAnimation); +// Animator.TrySetMovementAnimation(sitAnimation); + Animator.SetMovementAnimations("SIT"); TriggerScenePresenceUpdated(); } } @@ -3181,10 +3193,14 @@ namespace OpenSim.Region.Framework.Scenes // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. m_AngularVelocity = Vector3.Zero; - Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); - TriggerScenePresenceUpdated(); + sitAnimation = "SIT_GROUND_CONSTRAINED"; +// Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); +// TriggerScenePresenceUpdated(); SitGround = true; RemoveFromPhysicalScene(); + + Animator.SetMovementAnimations("SITGROUND"); + TriggerScenePresenceUpdated(); } /// -- cgit v1.1 From df8eae1957141bff721a40eeb07b14584fea473f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 10 Sep 2014 20:55:00 +0100 Subject: handle AO sit ground case --- .../Scenes/Animation/ScenePresenceAnimator.cs | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 4d1d913..db3b834 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -181,12 +181,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animations.Clear(); } - + + + UUID aoSitGndAnim = UUID.Zero; + /// /// The movement animation is reserved for "main" animations /// that are mutually exclusive, e.g. flying and sitting. /// /// 'true' if the animation was updated + /// + + + public bool TrySetMovementAnimation(string anim) { bool ret = false; @@ -196,10 +203,28 @@ namespace OpenSim.Region.Framework.Scenes.Animation // "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", // anim, m_scenePresence.Name); + if (aoSitGndAnim != UUID.Zero) + { + avnChangeAnim(aoSitGndAnim, false, false); + aoSitGndAnim = UUID.Zero; + } + UUID overridenAnim = m_scenePresence.Overrides.GetOverriddenAnimation(anim); if (overridenAnim != UUID.Zero) { - m_animations.SetDefaultAnimation(overridenAnim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); + if (anim == "SITGROUND") + { + UUID defsit = DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]; + if (defsit == UUID.Zero) + return false; + m_animations.SetDefaultAnimation(defsit, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); + aoSitGndAnim = overridenAnim; + avnChangeAnim(overridenAnim, true, false); + } + else + { + m_animations.SetDefaultAnimation(overridenAnim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); + } m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); SendAnimPack(); ret = true; -- cgit v1.1 From ffe5ede55086e8e680b770481604defd4125b398 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 12 Sep 2014 11:48:43 +0100 Subject: taskInventory request: give each transfer a diferent filename, Add more agressive lock --- .../Framework/Scenes/SceneObjectPartInventory.cs | 197 ++++++++++----------- 1 file changed, 96 insertions(+), 101 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a6a963b..7328a39 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -46,10 +46,10 @@ namespace OpenSim.Region.Framework.Scenes { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private string m_inventoryFileName = String.Empty; private byte[] m_inventoryFileData = new byte[0]; private uint m_inventoryFileNameSerial = 0; private bool m_inventoryPrivileged = false; + private object m_inventoryFileLock = new object(); private Dictionary m_scriptErrors = new Dictionary(); @@ -1110,23 +1110,6 @@ namespace OpenSim.Region.Framework.Scenes return -1; } - private bool CreateInventoryFileName() - { -// m_log.DebugFormat( -// "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", -// m_part.Name, m_part.UUID, m_part.LocalId, m_inventorySerial); - - if (m_inventoryFileName == String.Empty || - m_inventoryFileNameSerial < m_inventorySerial) - { - m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; - m_inventoryFileNameSerial = m_inventorySerial; - - return true; - } - - return false; - } /// /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client @@ -1134,110 +1117,122 @@ namespace OpenSim.Region.Framework.Scenes /// public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { - bool changed = CreateInventoryFileName(); - - bool includeAssets = false; - if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) - includeAssets = true; - - if (m_inventoryPrivileged != includeAssets) - changed = true; - - InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); - Items.LockItemsForRead(true); - - if (m_inventorySerial == 0) // No inventory + lock (m_inventoryFileLock) { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); - Items.LockItemsForRead(false); - return; - } + string filename = "inventory_" + UUID.Random().ToString() + ".tmp"; - if (m_items.Count == 0) // No inventory - { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); - Items.LockItemsForRead(false); - return; - } - - if (!changed) - { - if (m_inventoryFileData.Length > 2) + bool changed = false; + if (m_inventoryFileNameSerial < m_inventorySerial) { - xferManager.AddNewFile(m_inventoryFileName, - m_inventoryFileData); - client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, - Util.StringToBytes256(m_inventoryFileName)); - - Items.LockItemsForRead(false); - return; + m_inventoryFileNameSerial = m_inventorySerial; + changed = true; } - } - m_inventoryPrivileged = includeAssets; + if (m_inventoryFileData.Length < 2) + changed = true; - foreach (TaskInventoryItem item in m_items.Values) - { - UUID ownerID = item.OwnerID; - uint everyoneMask = 0; - uint baseMask = item.BasePermissions; - uint ownerMask = item.CurrentPermissions; - uint groupMask = item.GroupPermissions; + bool includeAssets = false; + if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) + includeAssets = true; - invString.AddItemStart(); - invString.AddNameValueLine("item_id", item.ItemID.ToString()); - invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); + if (m_inventoryPrivileged != includeAssets) + changed = true; - invString.AddPermissionsStart(); - invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); - invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); - invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); - invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); - invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); + Items.LockItemsForRead(true); - invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); - invString.AddNameValueLine("owner_id", ownerID.ToString()); + if (m_inventorySerial == 0) // No inventory + { + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + Items.LockItemsForRead(false); + return; + } - invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); + if (m_items.Count == 0) // No inventory + { + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + Items.LockItemsForRead(false); + return; + } - invString.AddNameValueLine("group_id", item.GroupID.ToString()); - invString.AddSectionEnd(); + if (!changed) + { + xferManager.AddNewFile(filename, + m_inventoryFileData); + client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, + Util.StringToBytes256(filename)); - if (includeAssets) - invString.AddNameValueLine("asset_id", item.AssetID.ToString()); - else - invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); - invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); - invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); - invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); + Items.LockItemsForRead(false); + return; + } - invString.AddSaleStart(); - invString.AddNameValueLine("sale_type", "not"); - invString.AddNameValueLine("sale_price", "0"); - invString.AddSectionEnd(); + m_inventoryPrivileged = includeAssets; - invString.AddNameValueLine("name", item.Name + "|"); - invString.AddNameValueLine("desc", item.Description + "|"); + InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); - invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); - invString.AddSectionEnd(); - } + foreach (TaskInventoryItem item in m_items.Values) + { + UUID ownerID = item.OwnerID; + uint everyoneMask = 0; + uint baseMask = item.BasePermissions; + uint ownerMask = item.CurrentPermissions; + uint groupMask = item.GroupPermissions; + + invString.AddItemStart(); + invString.AddNameValueLine("item_id", item.ItemID.ToString()); + invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); + + invString.AddPermissionsStart(); + + invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); + invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); + invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); + invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); + invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); + + invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); + invString.AddNameValueLine("owner_id", ownerID.ToString()); + + invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); + + invString.AddNameValueLine("group_id", item.GroupID.ToString()); + invString.AddSectionEnd(); + + if (includeAssets) + invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + else + invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); + invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); + invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); + invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); + + invString.AddSaleStart(); + invString.AddNameValueLine("sale_type", "not"); + invString.AddNameValueLine("sale_price", "0"); + invString.AddSectionEnd(); + + invString.AddNameValueLine("name", item.Name + "|"); + invString.AddNameValueLine("desc", item.Description + "|"); + + invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); + invString.AddSectionEnd(); + } - Items.LockItemsForRead(false); + Items.LockItemsForRead(false); - m_inventoryFileData = Utils.StringToBytes(invString.BuildString); + m_inventoryFileData = Utils.StringToBytes(invString.BuildString); - if (m_inventoryFileData.Length > 2) - { - xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); - client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, - Util.StringToBytes256(m_inventoryFileName)); - return; - } + if (m_inventoryFileData.Length > 2) + { + xferManager.AddNewFile(filename, m_inventoryFileData); + client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, + Util.StringToBytes256(filename)); + return; + } - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + } } /// -- cgit v1.1 From 8ab5f2ce849276dbc1fb92c288fb06fed1123f31 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 13 Sep 2014 16:39:56 +0200 Subject: When CloseAgnt is called with an agent id that doesn't have a presence, check for stray clients and clean them up instead of failing. --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d336eda..55e7da4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4743,6 +4743,18 @@ namespace OpenSim.Region.Framework.Scenes if (sp == null) { + // If there is no scene presence, we may be handling a dead + // client. These can keep an avatar from reentering a region + // and since they don't get cleaned up they will stick + // around until region restart. So, if there is no SP, + // remove the client as well. + IClientAPI client = null; + if (m_clientManager.TryGetValue(agentID, out client)) + { + m_clientManager.Remove(agentID); + m_log.DebugFormat( "[SCENE]: Dead client for agent ID {0} was cleaned up in {1}", agentID, Name); + return true; + } m_log.DebugFormat( "[SCENE]: Called CloseClient() with agent ID {0} but no such presence is in {1}", agentID, Name); -- cgit v1.1 From affcdcce8b2bd59f3c7f83e38adb9e1246f7d00f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 16 Sep 2014 21:25:06 +0100 Subject: try to send fly state on tps --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fd1bab6..dba95c7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4268,10 +4268,11 @@ namespace OpenSim.Region.Framework.Scenes GodLevel = cAgent.GodLevel; SetAlwaysRun = cAgent.AlwaysRun; + bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + Appearance = new AvatarAppearance(cAgent.Appearance); if (PhysicsActor != null) { - bool isFlying = Flying; RemoveFromPhysicalScene(); AddToPhysicalScene(isFlying); } -- cgit v1.1 From 1953a0f4e02f939f11879e826f99dd53bc9efce9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 17 Sep 2014 13:36:39 +0100 Subject: Dont add to physics in a child update. It is missing several checks like sit. makeroot should to it --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dba95c7..9d06c26 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4268,15 +4268,17 @@ namespace OpenSim.Region.Framework.Scenes GodLevel = cAgent.GodLevel; SetAlwaysRun = cAgent.AlwaysRun; - bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); Appearance = new AvatarAppearance(cAgent.Appearance); +/* + bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + if (PhysicsActor != null) { RemoveFromPhysicalScene(); AddToPhysicalScene(isFlying); } - +*/ try { lock (scriptedcontrols) -- cgit v1.1 From 242bb425f37ebe258d2df46babc4e4553a4ad33e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 19 Sep 2014 01:07:20 +0100 Subject: fix positions on same frames transitions --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 902e60b..a3ebe6f 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -624,7 +624,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - if (m_group == null) return; @@ -636,7 +635,6 @@ namespace OpenSim.Region.Framework.Scenes { m_group.RootPart.Velocity = Vector3.Zero; m_group.SendGroupRootTerseUpdate(); - } return; } @@ -683,6 +681,7 @@ namespace OpenSim.Region.Framework.Scenes m_currentFrame.TimeMS += (int)tickDuration; } //force a update on a keyframe transition + m_nextPosition = m_group.AbsolutePosition; update = true; } @@ -721,14 +720,10 @@ namespace OpenSim.Region.Framework.Scenes Vector3 motionThisFrame = v / (float)steps; v = v * 1000 / m_currentFrame.TimeMS; - if (Vector3.Mag(motionThisFrame) >= 0.05f) - { - // m_group.AbsolutePosition += motionThisFrame; - m_nextPosition = m_group.AbsolutePosition + motionThisFrame; + m_nextPosition = m_group.AbsolutePosition + motionThisFrame; - //m_group.RootPart.Velocity = v; + if (Vector3.Mag(motionThisFrame) >= 0.05f) update = true; - } if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) { -- cgit v1.1 From 9c552212a983c7e076c53340af9f47584d641aff Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 19 Sep 2014 16:51:51 +0100 Subject: exclude npcs from baked cache --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9d06c26..9c55d4a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1703,6 +1703,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + if (!MakeRootAgent(AbsolutePosition, flying)) { m_log.DebugFormat( @@ -1724,7 +1725,7 @@ namespace OpenSim.Region.Framework.Scenes look = new Vector3(0.99f, 0.042f, 0); } - if (!IsChildAgent) + if (!IsChildAgent && !isNPC) { InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46); if (cof == null) @@ -1790,16 +1791,22 @@ namespace OpenSim.Region.Framework.Scenes // verify baked textures and cache + bool cachedbaked = false; - if (m_scene.AvatarFactory != null) - cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this); - - // not sure we need this - if (!cachedbaked) + if (isNPC) + cachedbaked = true; + else { if (m_scene.AvatarFactory != null) - m_scene.AvatarFactory.QueueAppearanceSave(UUID); + cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this); + + // not sure we need this + if (!cachedbaked) + { + if (m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(UUID); + } } List allpresences = m_scene.GetScenePresences(); -- cgit v1.1 From 51ec2d83ac6a609ce6757af2b04fcd1e9cfd769d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 22:43:17 +0100 Subject: remove redundant code --- .../Framework/Scenes/SceneObjectPartInventory.cs | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7328a39..147d530 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -505,35 +505,22 @@ namespace OpenSim.Region.Framework.Scenes private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) { m_items.LockItemsForRead(true); + if (m_items.ContainsKey(itemId)) { - if (m_items.ContainsKey(itemId)) - { - m_items.LockItemsForRead(false); - CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); - } - else - { - m_items.LockItemsForRead(false); - string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, - m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); - StoreScriptError(itemId, msg); - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't start script with ID {0} since it {1}", itemId, msg); - } + m_items.LockItemsForRead(false); + CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); } else { m_items.LockItemsForRead(false); - string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); + string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, + m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); StoreScriptError(itemId, msg); m_log.ErrorFormat( - "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", - itemId, m_part.Name, m_part.UUID, - m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); + "[PRIM INVENTORY]: " + + "Couldn't start script with ID {0} since it {1}", itemId, msg); } - } /// -- cgit v1.1 From adda696cd09426c4d59c2850cd6ae3bab52fbf6d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 22:46:44 +0100 Subject: protect getting the item --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 147d530..5b167a2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -508,8 +508,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_items.ContainsKey(itemId)) { + TaskInventoryItem it = m_items[itemId]; m_items.LockItemsForRead(false); - CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); + + CreateScriptInstance(it, startParam, postOnRez, engine, stateSource); } else { -- cgit v1.1 From d1ccc6d5cc6488939b8f35d1c84a9c6d5d675b76 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 23:23:20 +0100 Subject: release lock a bit sooner when not needed, add a try on more complex db store call --- .../Region/Framework/Scenes/SceneObjectPartInventory.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5b167a2..aeec54e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1133,26 +1133,28 @@ namespace OpenSim.Region.Framework.Scenes if (m_inventorySerial == 0) // No inventory { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); Items.LockItemsForRead(false); + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + return; } if (m_items.Count == 0) // No inventory { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); Items.LockItemsForRead(false); + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } if (!changed) { + Items.LockItemsForRead(false); + xferManager.AddNewFile(filename, m_inventoryFileData); client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, Util.StringToBytes256(filename)); - Items.LockItemsForRead(false); return; } @@ -1238,7 +1240,12 @@ namespace OpenSim.Region.Framework.Scenes // if (HasInventoryChanged) // { Items.LockItemsForRead(true); - datastore.StorePrimInventory(m_part.UUID, Items.Values); + try + { + datastore.StorePrimInventory(m_part.UUID, Items.Values); + } + catch(){} + Items.LockItemsForRead(false); HasInventoryChanged = false; -- cgit v1.1 From a70ed79c392ea25b4476401c7250402745fa0287 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 23:26:17 +0100 Subject: compile fix --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index aeec54e..2fa9139 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1244,11 +1244,13 @@ namespace OpenSim.Region.Framework.Scenes { datastore.StorePrimInventory(m_part.UUID, Items.Values); } - catch(){} - - Items.LockItemsForRead(false); + catch {} HasInventoryChanged = false; + + Items.LockItemsForRead(false); + + // } } -- cgit v1.1 From bcaf202e34ab058a049c921e1279793d61eef5ea Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 13:59:23 +0100 Subject: update scenegraph group find by part information in sog link, so script link functions do update that also. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 21 ++++++++++++++++++--- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 +++++--- 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55e7da4..c583ce7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2548,6 +2548,11 @@ namespace OpenSim.Region.Framework.Scenes return false; } + + public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp) + { + m_sceneGraph.updateScenePartGroup(part, grp); + } /// /// Move the given scene object into a new region depending on which region its absolute position has moved /// into. diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 973891b..bc91961 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -462,6 +462,20 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp) + { + // no tests, caller has responsability... + lock (SceneObjectGroupsByFullPartID) + { + SceneObjectGroupsByFullPartID[part.UUID] = grp; + } + + lock (SceneObjectGroupsByLocalPartID) + { + SceneObjectGroupsByLocalPartID[part.LocalId] = grp; + } + } + /// /// Delete an object from the scene /// @@ -1804,7 +1818,7 @@ namespace OpenSim.Region.Framework.Scenes List childGroups = new List(); // We do this in reverse to get the link order of the prims correct - for (int i = 0 ; i < children.Count ; i++) + for (int i = 0; i < children.Count; i++) { SceneObjectGroup child = children[i].ParentGroup; @@ -1815,7 +1829,7 @@ namespace OpenSim.Region.Framework.Scenes // Make sure no child prim is set for sale // So that, on delink, no prims are unwittingly // left for sale and sold off - + if (child != null) { child.RootPart.ObjectSaleType = 0; @@ -1850,12 +1864,13 @@ namespace OpenSim.Region.Framework.Scenes } finally { +/* lock (SceneObjectGroupsByLocalPartID) { foreach (SceneObjectPart part in parentGroup.Parts) SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } - +*/ parentGroup.AdjustChildPrimPermissions(); parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 15349e3..b939b58 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2560,11 +2560,8 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - // give new ID to the new part, letting old keep original - // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); newPart.LocalId = m_scene.AllocateLocalId(); - newPart.SetParent(this); AddPart(newPart); @@ -2977,6 +2974,8 @@ namespace OpenSim.Region.Framework.Scenes m_parts.Add(linkPart.UUID, linkPart); linkPart.SetParent(this); + m_scene.updateScenePartGroup(linkPart, this); + linkPart.CreateSelected = true; // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now @@ -3238,9 +3237,12 @@ namespace OpenSim.Region.Framework.Scenes part.SetParent(this); part.ParentID = m_rootPart.LocalId; m_parts.Add(part.UUID, part); + part.LinkNum = linkNum; + m_scene.updateScenePartGroup(part, this); + // Compute the new position of this SOP relative to the group position part.OffsetPosition = newPos - AbsolutePosition; -- cgit v1.1 From fe3c1b9e98d9100a6ae04f077644e0c3790f6b4d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 14:32:56 +0100 Subject: send to world or backup, after setting finding information --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index bc91961..fe785dd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -432,13 +432,9 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.AttachToScene(m_parentScene); - if (sendClientUpdates) - sceneObject.ScheduleGroupForFullUpdate(); Entities.Add(sceneObject); - if (attachToBackup) - sceneObject.AttachToBackup(); lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; @@ -459,6 +455,12 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; } + if (sendClientUpdates) + sceneObject.ScheduleGroupForFullUpdate(); + + if (attachToBackup) + sceneObject.AttachToBackup(); + return true; } -- cgit v1.1 From b7fca5bcac4e26ec6381e6fc7d085149e8cbc869 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 14:44:47 +0100 Subject: same in a few more spots --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fe785dd..f4ff902 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -296,13 +296,15 @@ namespace OpenSim.Region.Framework.Scenes } } + bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + if (attachToBackup && (!alreadyPersisted)) { sceneObject.ForceInventoryPersistence(); sceneObject.HasGroupChanged = true; } - return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + return ret; } /// @@ -319,12 +321,17 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - // Ensure that we persist this new scene object if it's not an + + + bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + + // Ensure that we persist this new scene object if it's not an // attachment + if (attachToBackup) sceneObject.HasGroupChanged = true; - return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + return ret; } /// -- cgit v1.1 From ea4a526095c7797e3863f540abb8d439dac3f9d3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 16:09:39 +0100 Subject: a few more changes on link/unlink --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 17 +++++++---------- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f4ff902..8a65b06 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1962,20 +1962,17 @@ namespace OpenSim.Region.Framework.Scenes // slated for unlink, we need to do this // Unlink the remaining set // - bool sendEventsToRemainder = true; - if (numChildren > 1) - sendEventsToRemainder = false; + bool sendEventsToRemainder = false; + if (numChildren == 2) // only one child prim no re-link needed + sendEventsToRemainder = true; foreach (SceneObjectPart p in newSet) { if (p != group.RootPart) { group.DelinkFromGroup(p, sendEventsToRemainder); - if (numChildren > 2) - { - } - else - { + if (sendEventsToRemainder) // finish single child prim now + { p.ParentGroup.HasGroupChanged = true; p.ParentGroup.ScheduleGroupForFullUpdate(); } @@ -2008,8 +2005,8 @@ namespace OpenSim.Region.Framework.Scenes newChild.ClearUpdateSchedule(); LinkObjects(newRoot, newSet); - if (!affectedGroups.Contains(newRoot.ParentGroup)) - affectedGroups.Add(newRoot.ParentGroup); +// if (!affectedGroups.Contains(newRoot.ParentGroup)) +// affectedGroups.Add(newRoot.ParentGroup); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b939b58..ca6f457 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3177,9 +3177,6 @@ namespace OpenSim.Region.Framework.Scenes m_scene.AddNewSceneObject(objectGroup, true); - if (sendEvents) - linkPart.TriggerScriptChangedEvent(Changed.LINK); - linkPart.Rezzed = RootPart.Rezzed; // When we delete a group, we currently have to force persist to the database if the object id has changed @@ -3194,6 +3191,9 @@ namespace OpenSim.Region.Framework.Scenes objectGroup.HasGroupChangedDueToDelink = true; + if (sendEvents) + linkPart.TriggerScriptChangedEvent(Changed.LINK); + return objectGroup; } -- cgit v1.1 From 0bfba122f0b9ea036d18020c64110d041ff56151 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 22 Sep 2014 18:49:08 +0200 Subject: When a ghosted avatar is removed, also remove any remaining CAPS --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55e7da4..769b4e8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4752,6 +4752,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_clientManager.TryGetValue(agentID, out client)) { m_clientManager.Remove(agentID); + if (CapsModule != null) + CapsModule.RemoveCaps(agentID, 0); m_log.DebugFormat( "[SCENE]: Dead client for agent ID {0} was cleaned up in {1}", agentID, Name); return true; } -- cgit v1.1 From c82e456345103f6a9b1a0f8bf32caf7ffd96f7b5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 21:13:36 +0100 Subject: debug show stack trace --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 8a65b06..dbe0e57 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -950,7 +950,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat( "[SCENE GRAPH]: Found scene object {0} {1} {2} via SceneObjectGroupsByLocalPartID index but it doesn't contain part with local id {3}. Removing from entry from index in {4}.", sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName); - + m_log.WarnFormat("stack: {0}", Environment.StackTrace); SceneObjectGroupsByLocalPartID.Remove(localID); } } -- cgit v1.1 From 79e47eb60e304fba1bdf04b57d374a843c250ef8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 23:32:55 +0100 Subject: some changes in link/unlink code, bypassing complex variables set methods --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 50 +++++++++++----------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 23 +++++++++- 2 files changed, 47 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ca6f457..0eed64e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2929,22 +2929,24 @@ namespace OpenSim.Region.Framework.Scenes // First move the new group's root SOP's position to be relative to ours // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not, // this code can be reordered to have a more logical flow.) - linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + linkPart.setOffsetPosition(linkPart.GroupPosition - AbsolutePosition); // Assign the new parent to the root of the old group linkPart.ParentID = m_rootPart.LocalId; // Now that it's a child, it's group position is our root position - linkPart.GroupPosition = AbsolutePosition; + linkPart.setGroupPosition(AbsolutePosition); - Vector3 axPos = linkPart.OffsetPosition; // Rotate the linking root SOP's position to be relative to the new root prim Quaternion parentRot = m_rootPart.RotationOffset; - axPos *= Quaternion.Conjugate(parentRot); - linkPart.OffsetPosition = axPos; // Make the linking root SOP's rotation relative to the new root prim Quaternion oldRot = linkPart.RotationOffset; Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; - linkPart.RotationOffset = newRot; + linkPart.setRotationOffset(newRot); + + Vector3 axPos = linkPart.OffsetPosition; + axPos *= Quaternion.Conjugate(parentRot); + linkPart.OffsetPosition = axPos; + // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. // Now that we know this SOG has at least two SOPs in it, the new root @@ -3168,9 +3170,9 @@ namespace OpenSim.Region.Framework.Scenes linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.OffsetPosition = new Vector3(0, 0, 0); */ - linkPart.GroupPosition = worldPos; - linkPart.OffsetPosition = Vector3.Zero; - linkPart.RotationOffset = worldRot; + linkPart.setGroupPosition(worldPos); + linkPart.setOffsetPosition(Vector3.Zero); + linkPart.setRotationOffset(worldRot); // Create a new SOG to go around this unlinked and unattached SOP SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); @@ -3221,15 +3223,14 @@ namespace OpenSim.Region.Framework.Scenes Quaternion parentRot = oldGroupRotation; Quaternion oldRot = part.RotationOffset; - // Move our position to not be relative to the old parent + // Move our position in world Vector3 axPos = part.OffsetPosition; axPos *= parentRot; - part.OffsetPosition = axPos; - Vector3 newPos = oldGroupPosition + part.OffsetPosition; - part.GroupPosition = newPos; - part.OffsetPosition = Vector3.Zero; + Vector3 newPos = oldGroupPosition + axPos; + part.setGroupPosition(newPos); + part.setOffsetPosition(Vector3.Zero); - // Compution our rotation to be not relative to the old parent + // Compution our rotation in world Quaternion worldRot = parentRot * oldRot; part.RotationOffset = worldRot; @@ -3237,31 +3238,30 @@ namespace OpenSim.Region.Framework.Scenes part.SetParent(this); part.ParentID = m_rootPart.LocalId; m_parts.Add(part.UUID, part); - part.LinkNum = linkNum; m_scene.updateScenePartGroup(part, this); // Compute the new position of this SOP relative to the group position - part.OffsetPosition = newPos - AbsolutePosition; + part.setOffsetPosition(newPos - AbsolutePosition); // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. // It would have the affect of setting the physics engine position multiple // times. In theory, that is not necessary but I don't have a good linkset // test to know that cleaning up this code wouldn't break things.) - // Rotate the relative position by the rotation of the group - Quaternion rootRotation = m_rootPart.RotationOffset; - Vector3 pos = part.OffsetPosition; - pos *= Quaternion.Conjugate(rootRotation); - part.OffsetPosition = pos; - // Compute the SOP's rotation relative to the rotation of the group. parentRot = m_rootPart.RotationOffset; + oldRot = part.RotationOffset; Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; - part.RotationOffset = newRot; + part.setRotationOffset(newRot); + + Vector3 pos = part.OffsetPosition; + pos *= Quaternion.Conjugate(parentRot); + + part.OffsetPosition = pos; // update position and orientation on physics also // Since this SOP's state has changed, push those changes into the physics engine // and the simulator. @@ -3947,7 +3947,7 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = newPos; - + if (IsAttachment) m_rootPart.AttachedPos = newPos; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 43ae880..de07131 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -771,9 +771,20 @@ namespace OpenSim.Region.Framework.Scenes set { m_damage = value; } } + + + + public void setGroupPosition(Vector3 pos) + { + m_groupPosition = pos; + } + /// /// The position of the entire group that this prim belongs to. /// + /// + + public Vector3 GroupPosition { get @@ -811,7 +822,7 @@ namespace OpenSim.Region.Framework.Scenes // Root prim actually goes at Position if (ParentID == 0) { - actor.Position = value; + actor.Position = value; } else { @@ -832,6 +843,11 @@ namespace OpenSim.Region.Framework.Scenes } } + public void setOffsetPosition(Vector3 pos) + { + m_offsetPosition = pos; + } + public Vector3 OffsetPosition { get { return m_offsetPosition; } @@ -890,6 +906,11 @@ namespace OpenSim.Region.Framework.Scenes } } + public void setRotationOffset(Quaternion q) + { + m_rotationOffset = q; + } + public Quaternion RotationOffset { get -- cgit v1.1 From 309cfeff88e9b348c9170ecd1818df68a1835681 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 23 Sep 2014 21:53:09 +0200 Subject: If an agent is logging in, rather than teleporting, make sure all known circuits for that agent are closed. --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 087df70..8cb795d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3988,6 +3988,12 @@ namespace OpenSim.Region.Framework.Scenes // We need the circuit data here for some of the subsequent checks. (groups, for example) // If the checks fail, we remove the circuit. acd.teleportFlags = teleportFlags; + + // Remove any preexisting circuit - we don't want duplicates + // This is a stab at preventing avatar "ghosting" + if (vialogin) + m_authenticateHandler.RemoveCircuit(acd.AgentID); + m_authenticateHandler.AddNewCircuit(acd.circuitcode, acd); land = LandChannel.GetLandObject(acd.startpos.X, acd.startpos.Y); -- cgit v1.1 From 6d2cdd31fe2bc330485cc519133e6d38562255ba Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 Sep 2014 23:59:05 +0100 Subject: populate collision lists with LinkNumber, and detected structure in Xengine --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index de07131..6daa109 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2707,6 +2707,7 @@ namespace OpenSim.Region.Framework.Scenes detobj.velVector = obj.Velocity; detobj.colliderType = 0; detobj.groupUUID = obj.GroupID; + detobj.linkNumber = LinkNum; // pass my link number return detobj; } @@ -2722,6 +2723,7 @@ namespace OpenSim.Region.Framework.Scenes detobj.velVector = av.Velocity; detobj.colliderType = 0; detobj.groupUUID = av.ControllingClient.ActiveGroupId; + detobj.linkNumber = LinkNum; // pass my link number return detobj; } @@ -2737,6 +2739,7 @@ namespace OpenSim.Region.Framework.Scenes detobj.velVector = Vector3.Zero; detobj.colliderType = 0; detobj.groupUUID = UUID.Zero; + detobj.linkNumber = LinkNum; // pass my link number not sure needed.. but no harm return detobj; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9c55d4a..b19d20d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -5586,6 +5586,7 @@ namespace OpenSim.Region.Framework.Scenes detobj.velVector = obj.Velocity; detobj.colliderType = 0; detobj.groupUUID = obj.GroupID; + detobj.linkNumber = 0; return detobj; } @@ -5601,6 +5602,7 @@ namespace OpenSim.Region.Framework.Scenes detobj.velVector = av.Velocity; detobj.colliderType = 0; detobj.groupUUID = av.ControllingClient.ActiveGroupId; + detobj.linkNumber = 0; return detobj; } @@ -5616,7 +5618,7 @@ namespace OpenSim.Region.Framework.Scenes detobj.velVector = Vector3.Zero; detobj.colliderType = 0; detobj.groupUUID = UUID.Zero; - + detobj.linkNumber = 0; return detobj; } -- cgit v1.1 From d96fe6eaf55974f01d430d560d457c8faa51c9a6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Sep 2014 01:37:51 +0100 Subject: replace a lock on a unkown origin object with a lock on a well defined one. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8cb795d..7eda4e4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3803,6 +3803,9 @@ namespace OpenSim.Region.Framework.Scenes /// or other applications where a full grid/Hypergrid presence may not be required. /// True if the region accepts this agent. False if it does not. False will /// also return a reason. + /// + private object m_newUserConnLock = new object(); + public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, out string reason, bool requirePresenceLookup) { bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || @@ -3961,7 +3964,7 @@ namespace OpenSim.Region.Framework.Scenes } // TODO: can we remove this lock? - lock (acd) + lock (m_newUserConnLock) { if (sp != null && !sp.IsChildAgent) { -- cgit v1.1 From 4206c1248f13ad24f3ebd03988a296fe1d8fe635 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Sep 2014 01:51:36 +0100 Subject: same thing on another lock(acd) --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7eda4e4..ff93941 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3583,6 +3583,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// Close the neighbour child agents associated with this client. /// + /// + + private object m_removeClientPrivLock = new Object(); + public void RemoveClient(UUID agentID, bool closeChildAgents) { AgentCircuitData acd = m_authenticateHandler.GetAgentCircuitData(agentID); @@ -3603,7 +3607,7 @@ namespace OpenSim.Region.Framework.Scenes } // TODO: Can we now remove this lock? - lock (acd) + lock (m_removeClientPrivLock) { bool isChildAgent = false; -- cgit v1.1 From 46bf6d1640c451ee47839bb637d983bb1aefb804 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Sep 2014 18:29:23 +0100 Subject: add stack trace debug message --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ff93941..63cc107 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3841,6 +3841,8 @@ namespace OpenSim.Region.Framework.Scenes acd.startpos ); + m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace); + if (!LoginsEnabled) { reason = "Logins Disabled"; -- cgit v1.1 From c9079360b9b44443a9394f6ee5fbff741e7ccced Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Sep 2014 18:37:59 +0100 Subject: coment out stack trace at newUserConnection, add log msh at createAgent --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 63cc107..608f071 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3841,7 +3841,7 @@ namespace OpenSim.Region.Framework.Scenes acd.startpos ); - m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace); +// m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace); if (!LoginsEnabled) { -- cgit v1.1 From 8c687726242193098cb170976e520449b295982c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 00:54:06 +0100 Subject: bug fix: add missing attach to region heartbeat event to update animations --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b19d20d..5946979 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1938,6 +1938,8 @@ namespace OpenSim.Region.Framework.Scenes // m_currentParcelHide = newhide; // } + m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; + m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); } -- cgit v1.1 From 598ab37b97fc1ff189f61c3416a8732b698a76af Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 02:52:44 +0100 Subject: debug msg --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e003a59..ac0b69c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -133,8 +133,13 @@ namespace OpenSim.Region.Framework.Scenes /// public bool AddInventoryItem(InventoryItemBase item) { + m_log.DebugFormat("[AGENT INVENTORY]: item {0}", item.Name); + if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) { + m_log.DebugFormat( + "[AGENT INVENTORY]: added item {0}",item.Name); + int userlevel = 0; if (Permissions.IsGod(item.Owner)) { -- cgit v1.1 From d29a04fc20a7d8a72944ffe835c7e758aa2712ed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 03:52:10 +0100 Subject: remove debug msgs --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ac0b69c..e003a59 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -133,13 +133,8 @@ namespace OpenSim.Region.Framework.Scenes /// public bool AddInventoryItem(InventoryItemBase item) { - m_log.DebugFormat("[AGENT INVENTORY]: item {0}", item.Name); - if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) { - m_log.DebugFormat( - "[AGENT INVENTORY]: added item {0}",item.Name); - int userlevel = 0; if (Permissions.IsGod(item.Owner)) { -- cgit v1.1 From 09e05d48b9cb45c7211145bf325dc3ab144a03a1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 13:28:24 +0100 Subject: refuse to do a inventory link if provided asset type is not a link or folderlink --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e003a59..5197f58 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1063,6 +1063,10 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) return; + if (type != (sbyte)AssetType.Link || type != (sbyte)AssetType.LinkFolder) + return; + + ScenePresence presence; if (TryGetScenePresence(remoteClient.AgentId, out presence)) { -- cgit v1.1 From 3052a5388954592861e0a55681844115485b6ae7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 29 Sep 2014 20:17:05 +0100 Subject: change avatar physics and motion control. Still not that good :( --- .../Scenes/Animation/ScenePresenceAnimator.cs | 147 ++++++++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 169 +++++++++------------ 2 files changed, 173 insertions(+), 143 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index db3b834..6003e92 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -56,11 +56,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// The current movement animation /// public string CurrentMovementAnimation { get; private set; } - + private int m_animTickFall; - public int m_animTickJump; // ScenePresence has to see this to control +Z force + private int m_animTickLand; + private int m_animTickJump; + public bool m_jumping = false; - public float m_jumpVelocity = 0f; + // private int m_landing = 0; /// @@ -68,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public bool Falling { get; private set; } - private float m_fallHeight; + private float m_lastFallVelocity; /// /// The scene presence that this animator applies to @@ -205,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (aoSitGndAnim != UUID.Zero) { - avnChangeAnim(aoSitGndAnim, false, false); + avnChangeAnim(aoSitGndAnim, false, true); aoSitGndAnim = UUID.Zero; } @@ -258,20 +260,38 @@ namespace OpenSim.Region.Framework.Scenes.Animation return ret; } + public enum motionControlStates : byte + { + sitted = 0, + flying, + falling, + jumping, + landing, + onsurface + } + + public motionControlStates currentControlState = motionControlStates.onsurface; + /// /// This method determines the proper movement related animation /// private string DetermineMovementAnimation() { - const float FALL_DELAY = 800f; - const float PREJUMP_DELAY = 200f; - const float JUMP_PERIOD = 800f; + const int FALL_DELAY = 800; + const int PREJUMP_DELAY = 200; + const int JUMP_PERIOD = 800; #region Inputs if (m_scenePresence.SitGround) + { + currentControlState = motionControlStates.sitted; return "SITGROUND"; + } if (m_scenePresence.ParentID != 0 || m_scenePresence.ParentUUID != UUID.Zero) + { + currentControlState = motionControlStates.sitted; return "SIT"; + } AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; PhysicsActor actor = m_scenePresence.PhysicsActor; @@ -311,17 +331,31 @@ namespace OpenSim.Region.Framework.Scenes.Animation // bool moving = (move != Vector3.Zero); #endregion Inputs + // no physics actor case + if (actor == null) + { + // well what to do? + + currentControlState = motionControlStates.onsurface; + if (move.X != 0f || move.Y != 0f) + return "WALK"; + + return "STAND"; + } + + #region Flying - if (actor != null && actor.Flying) + bool isColliding = actor.IsColliding; + + if (actor.Flying) { m_animTickFall = 0; m_animTickJump = 0; m_jumping = false; Falling = false; - m_jumpVelocity = 0f; - actor.Selected = false; - m_fallHeight = actor.Position.Z; // save latest flying height + + currentControlState = motionControlStates.flying; if (move.X != 0f || move.Y != 0f) { @@ -333,8 +367,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (move.Z < 0f) { - if (actor != null && actor.IsColliding) + if (isColliding) + { + actor.Flying = false; + currentControlState = motionControlStates.landing; + m_animTickLand = Environment.TickCount; return "LAND"; + } else return "HOVER_DOWN"; } @@ -343,29 +382,41 @@ namespace OpenSim.Region.Framework.Scenes.Animation return "HOVER"; } } + else + { + if (isColliding && currentControlState == motionControlStates.flying) + { + currentControlState = motionControlStates.landing; + m_animTickLand = Environment.TickCount; + return "LAND"; + } + } #endregion Flying #region Falling/Floating/Landing - if ((actor == null || !actor.IsColliding) && !m_jumping) + if (!isColliding && currentControlState != motionControlStates.jumping) { - float fallElapsed = (float)(Environment.TickCount - m_animTickFall); - float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; + float fallVelocity = actor.Velocity.Z; - if (!m_jumping && (fallVelocity < -3.0f)) + if (fallVelocity < -2.5f) Falling = true; - if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) + if (m_animTickFall == 0 || (fallVelocity >= -0.5f)) { - // not falling yet, or going up - // reset start of fall time m_animTickFall = Environment.TickCount; } - else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) + else { - // Falling long enough to trigger the animation - return "FALLDOWN"; + int fallElapsed = (Environment.TickCount - m_animTickFall); + if ((fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f)) + { + currentControlState = motionControlStates.falling; + m_lastFallVelocity = fallVelocity; + // Falling long enough to trigger the animation + return "FALLDOWN"; + } } // Check if the user has stopped walking just now @@ -375,49 +426,44 @@ namespace OpenSim.Region.Framework.Scenes.Animation return CurrentMovementAnimation; } - #endregion Falling/Floating/Landing + m_animTickFall = 0; + #endregion Falling/Floating/Landing #region Jumping // section added for jumping... - int jumptime; - jumptime = Environment.TickCount - m_animTickJump; - - if ((move.Z > 0f) && (!m_jumping)) + if (isColliding && move.Z > 0f && currentControlState != motionControlStates.jumping) { // Start jumping, prejump - m_animTickFall = 0; + currentControlState = motionControlStates.jumping; m_jumping = true; Falling = false; - actor.Selected = true; // borrowed for jumping flag m_animTickJump = Environment.TickCount; - m_jumpVelocity = 0.35f; return "PREJUMP"; } - if (m_jumping) + if (currentControlState == motionControlStates.jumping) { + int jumptime = Environment.TickCount - m_animTickJump; if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) { // end jumping m_jumping = false; Falling = false; actor.Selected = false; // borrowed for jumping flag - m_jumpVelocity = 0f; - m_animTickFall = Environment.TickCount; + m_animTickLand = Environment.TickCount; + currentControlState = motionControlStates.landing; return "LAND"; } else if (jumptime > JUMP_PERIOD) { // jump down - m_jumpVelocity = 0f; return "JUMP"; } else if (jumptime > PREJUMP_DELAY) { // jump up m_jumping = true; - m_jumpVelocity = 10f; return "JUMP"; } } @@ -426,42 +472,48 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Ground Movement - if (CurrentMovementAnimation == "FALLDOWN") + if (currentControlState == motionControlStates.falling) { Falling = false; - m_animTickFall = Environment.TickCount; + currentControlState = motionControlStates.landing; + m_animTickLand = Environment.TickCount; // TODO: SOFT_LAND support - float fallHeight = m_fallHeight - actor.Position.Z; - if (fallHeight > 15.0f) + float fallVsq =m_lastFallVelocity*m_lastFallVelocity; + if (fallVsq > 300f) // aprox 20*h return "STANDUP"; - else if (fallHeight > 8.0f) + else if (fallVsq > 160f) return "SOFT_LAND"; else return "LAND"; } - else if ((CurrentMovementAnimation == "LAND") || (CurrentMovementAnimation == "SOFT_LAND") || (CurrentMovementAnimation == "STANDUP")) + + + if (currentControlState == motionControlStates.landing) { - int landElapsed = Environment.TickCount - m_animTickFall; + Falling = false; + int landElapsed = Environment.TickCount - m_animTickLand; int limit = 1000; if (CurrentMovementAnimation == "LAND") limit = 350; // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client - if ((m_animTickFall != 0) && (landElapsed <= limit)) + if ((m_animTickLand != 0) && (landElapsed <= limit)) { return CurrentMovementAnimation; } else { - m_fallHeight = actor.Position.Z; // save latest flying height + currentControlState = motionControlStates.onsurface; + m_animTickLand = 0; return "STAND"; } } + // next section moved outside paren. and realigned for jumping if (move.X != 0f || move.Y != 0f) { - m_fallHeight = actor.Position.Z; // save latest flying height + currentControlState = motionControlStates.onsurface; Falling = false; // Walking / crouchwalking / running if (move.Z < 0f) @@ -480,6 +532,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (!m_jumping) { + currentControlState = motionControlStates.onsurface; Falling = false; // Not walking if (move.Z < 0) @@ -493,8 +546,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation } #endregion Ground Movement - Falling = false; - return CurrentMovementAnimation; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5946979..e6a366d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -287,14 +287,7 @@ namespace OpenSim.Region.Framework.Scenes set { PhysicsActor.Flying = value; } } - // add for fly velocity control - private bool FlyingOld {get; set;} - public bool WasFlying - { - get; private set; - } - - public bool IsColliding + public bool IsColliding { get { return PhysicsActor != null && PhysicsActor.IsColliding; } // We would expect setting IsColliding to be private but it's used by a hack in Scene @@ -936,7 +929,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. /// - private float AgentControlStopSlowWhilstMoving = 0.5f; + private float AgentControlStopSlowWhilstMoving = 0.2f; private bool m_forceFly; @@ -2174,7 +2167,7 @@ namespace OpenSim.Region.Framework.Scenes bool DCFlagKeyPressed = false; Vector3 agent_control_v3 = Vector3.Zero; - bool newFlying = actor.Flying; + bool newFlying = false; if (ForceFly) newFlying = true; @@ -2286,11 +2279,11 @@ namespace OpenSim.Region.Framework.Scenes if (Flying && !ForceFly) { // Need to stop in mid air if user holds down AGENT_CONTROL_STOP - if (AgentControlStopActive) - { - agent_control_v3 = Vector3.Zero; - } - else + // if (AgentControlStopActive) + // { + // agent_control_v3 = Vector3.Zero; + // } + // else { // Landing detection code @@ -2298,38 +2291,44 @@ namespace OpenSim.Region.Framework.Scenes bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - //m_log.Debug("[CONTROL]: " +flags); + //m_log.Debug("[CONTROL]: " +flags); // Applies a satisfying roll effect to the avatar when flying. if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) { ApplyFlyingRoll( - FLY_ROLL_RADIANS_PER_UPDATE, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, + FLY_ROLL_RADIANS_PER_UPDATE, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); - } + } else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) { ApplyFlyingRoll( - -FLY_ROLL_RADIANS_PER_UPDATE, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); + -FLY_ROLL_RADIANS_PER_UPDATE, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); } else { if (m_AngularVelocity.Z != 0) - m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); - } - - if (Flying && IsColliding && controlland) - { - // nesting this check because LengthSquared() is expensive and we don't - // want to do it every step when flying. - if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) - StopFlying(); + m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); } + + /* + if (Flying && IsColliding && controlland) + { + // nesting this check because LengthSquared() is expensive and we don't + // want to do it every step when flying. + if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) + StopFlying(); + } + */ } } + else if (IsColliding && agent_control_v3.Z < 0f) + agent_control_v3.Z = 0; +// else if(AgentControlStopActive %% Velocity.Z <0.01f) + // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); @@ -2342,32 +2341,22 @@ namespace OpenSim.Region.Framework.Scenes if (update_movementflag || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) { -// if (update_movementflag || !AgentControlStopActive || MovementFlag != 0) -// { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}", -// m_scene.RegionInfo.RegionName, agent_control_v3, Name, -// update_movementflag, MovementFlag, update_rotation); - - float speedModifier; - if (AgentControlStopActive) - speedModifier = AgentControlStopSlowWhilstMoving; + if (AgentControlStopActive) + { +// if (MovementFlag == 0 && Animator.Falling) + if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) + { + AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving, true); + } else - speedModifier = 1; + AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving); + } + + else + AddNewMovement(agent_control_v3); - AddNewMovement(agent_control_v3, speedModifier); -// } } -// else -// { -// if (!update_movementflag) -// { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", -// m_scene.RegionInfo.RegionName, agent_control_v3, Name); -// } -// } if (update_movementflag && ParentID == 0) { @@ -3246,68 +3235,58 @@ namespace OpenSim.Region.Framework.Scenes /// The vector in which to move. This is relative to the rotation argument /// /// Optional additional speed modifier for this particular add. Default is 1 - public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1) + public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1, bool breaking = false) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", -// vec, Rotation, thisAddSpeedModifier, Name); + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", + // vec, Rotation, thisAddSpeedModifier, Name); Vector3 direc = vec * Rotation; direc.Normalize(); - if (Flying != FlyingOld) // add for fly velocity control - { - FlyingOld = Flying; // add for fly velocity control - if (!Flying) - WasFlying = true; // add for fly velocity control - } - - if (IsColliding) - WasFlying = false; // add for fly velocity control - if ((vec.Z == 0f) && !Flying) direc.Z = 0f; // Prevent camera WASD up. direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; -// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); + // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); - if (PhysicsActor != null) + if (Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) { - if (Flying) - { + if (breaking) + direc.Z = -9999f; //hack + else + direc = Vector3.Zero; + } + else if (Flying) + { + if(IsColliding) + direc = Vector3.Zero; + else direc *= 4.0f; - //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - //if (controlland) - // m_log.Info("[AGENT]: landCommand"); - //if (IsColliding) - // m_log.Info("[AGENT]: colliding"); - //if (Flying && IsColliding && controlland) - //{ - // StopFlying(); - // m_log.Info("[AGENT]: Stop Flying"); - //} - } - if (Animator.Falling && WasFlying) // if falling from flying, disable motion add + } + else if (IsColliding) + { + if (direc.Z > 2.0f) { - direc *= 0.0f; + direc.Z *= 2.6f; } - else if (!Flying && IsColliding) + else if (direc.Z < 0) + direc.Z = 0; +/* + float c = CollisionPlane.Z; + if (c > 0.2f && c < 0.94f && (direc.X != 0 || direc.Y != 0)) { - if (direc.Z > 2.0f) - { - direc.Z *= 2.6f; - - // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. -// Animator.TrySetMovementAnimation("PREJUMP"); -// Animator.TrySetMovementAnimation("JUMP"); - } + float p = direc.X * CollisionPlane.X + direc.Y * CollisionPlane.Y; + direc.X -= p * CollisionPlane.X; + direc.Y -= p * CollisionPlane.Y; + direc.Z -= p * c; } + */ } -// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); + // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); - // TODO: Add the force instead of only setting it to support multiple forces per frame? m_forceToApply = direc; Animator.UpdateMovementAnimations(); } -- cgit v1.1 From 2af7205813b2171b5da92c4e17e9a575ac049087 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 30 Sep 2014 00:13:52 +0100 Subject: keep same animation if in transit --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 6003e92..1017c1d 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -282,6 +282,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation const int JUMP_PERIOD = 800; #region Inputs + if (m_scenePresence.IsInTransit) + return CurrentMovementAnimation; + if (m_scenePresence.SitGround) { currentControlState = motionControlStates.sitted; -- cgit v1.1 From b9be9097aab3fdb2b4a1f3373d253012f56814f0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 30 Sep 2014 17:02:24 +0100 Subject: fix a incomplet landing handling case --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 25 +++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e6a366d..42d3684 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3241,12 +3241,17 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", // vec, Rotation, thisAddSpeedModifier, Name); + // rotate from avatar coord space to world + // for now all controls assume this is only a rotation around Z + // if not all checks below need to be done before this rotation Vector3 direc = vec * Rotation; direc.Normalize(); + // mouse look situation ? if ((vec.Z == 0f) && !Flying) direc.Z = 0f; // Prevent camera WASD up. + // odd rescalings direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); @@ -3254,35 +3259,27 @@ namespace OpenSim.Region.Framework.Scenes if (Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) { if (breaking) - direc.Z = -9999f; //hack + direc.Z = -9999f; //hack to tell physics to stop on Z else direc = Vector3.Zero; } else if (Flying) { - if(IsColliding) + if (IsColliding && direc.Z < 0) + // landing situation, prevent avatar moving or it may fail to land + // animator will handle this condition and do the land direc = Vector3.Zero; else direc *= 4.0f; } else if (IsColliding) { - if (direc.Z > 2.0f) + if (direc.Z > 2.0f) // reinforce jumps { direc.Z *= 2.6f; } - else if (direc.Z < 0) + else if (direc.Z < 0) // on a surface moving down (pg down) only changes animation direc.Z = 0; -/* - float c = CollisionPlane.Z; - if (c > 0.2f && c < 0.94f && (direc.X != 0 || direc.Y != 0)) - { - float p = direc.X * CollisionPlane.X + direc.Y * CollisionPlane.Y; - direc.X -= p * CollisionPlane.X; - direc.Y -= p * CollisionPlane.Y; - direc.Z -= p * c; - } - */ } // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); -- cgit v1.1 From 4c8819a14363d33b11b4168c1291b74a1bc930ee Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 1 Oct 2014 04:32:19 +0100 Subject: removed useless unreal inworld movement vector estimation. Do animation state using movement control flags only, on avatar frame of reference. This will hold valid until the up direction is allowed to be diferent from the world one. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 167 ++++++++++++--------- 1 file changed, 97 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 1017c1d..56b8b30 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation public AnimationSet Animations { - get { return m_animations; } + get { return m_animations; } } protected AnimationSet m_animations = new AnimationSet(); @@ -61,9 +61,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation private int m_animTickLand; private int m_animTickJump; - public bool m_jumping = false; + public bool m_jumping = false; -// private int m_landing = 0; + // private int m_landing = 0; /// /// Is the avatar falling? @@ -76,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// The scene presence that this animator applies to /// protected ScenePresence m_scenePresence; - + public ScenePresenceAnimator(ScenePresence sp) { m_scenePresence = sp; @@ -91,7 +91,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); if (m_scenePresence.Scene.DebugAnimations) m_log.DebugFormat( - "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", + "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", GetAnimName(animID), animID, m_scenePresence.Name); if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) @@ -113,7 +113,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (animID == UUID.Zero) return; -// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name); + // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name); AddAnimation(animID, objectID); } @@ -133,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_scenePresence.Scene.DebugAnimations) m_log.DebugFormat( - "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}", + "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}", GetAnimName(animID), animID, m_scenePresence.Name); if (m_animations.Remove(animID, allowNoDefault)) @@ -155,7 +155,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else m_animations.Remove(animID, false); } - if(sendPack) + if (sendPack) SendAnimPack(); } @@ -201,9 +201,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation bool ret = false; if (!m_scenePresence.IsChildAgent) { -// m_log.DebugFormat( -// "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", -// anim, m_scenePresence.Name); + // m_log.DebugFormat( + // "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", + // anim, m_scenePresence.Name); if (aoSitGndAnim != UUID.Zero) { @@ -299,29 +299,44 @@ namespace OpenSim.Region.Framework.Scenes.Animation AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; PhysicsActor actor = m_scenePresence.PhysicsActor; + +// there is no point on having this meaningless movement values, much less in world coordenates +// situation may change if vertical Axis of avatar is allowed to rotate. +// then jumping etc will need some care + // Create forward and left vectors from the current avatar rotation - Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_scenePresence.Rotation); - Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); - Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); + /* yes matrix are better, but getting it from the Quaternion will kill the advantage + Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_scenePresence.Rotation); + Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); + Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); + */ + // there is still a better way +// Vector3 fwd = Vector3.UnitX * m_scenePresence.Rotation; +// Vector3 left = Vector3.UnitY * m_scenePresence.Rotation; // Check control flags - bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); - bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); - bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); - bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); + bool heldForward = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)) != 0); + bool heldBack = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG)) != 0); + bool heldLeft = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS)) != 0); + bool heldRight = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG)) != 0); bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; - bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; - bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; +// bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS)) != 0); + // excluded nudge up so it doesn't trigger jump state + bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS)) != 0); + bool heldDown = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG)) != 0); //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; - if (heldForward || heldBack || heldLeft || heldRight || heldUp || heldDown) + + bool heldOnXY = (heldForward || heldBack || heldLeft || heldRight); + if (heldOnXY || heldUp || heldDown) { heldTurnLeft = false; heldTurnRight = false; } // Direction in which the avatar is trying to move +/* Vector3 move = Vector3.Zero; if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } @@ -329,9 +344,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (heldRight) { move.X -= left.X; move.Y -= left.Y; } if (heldUp) { move.Z += 1; } if (heldDown) { move.Z -= 1; } +*/ + // Is the avatar trying to move? -// bool moving = (move != Vector3.Zero); + // bool moving = (move != Vector3.Zero); #endregion Inputs // no physics actor case @@ -340,13 +357,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation // well what to do? currentControlState = motionControlStates.onsurface; - if (move.X != 0f || move.Y != 0f) +// if (move.X != 0f || move.Y != 0f) + if (heldOnXY) return "WALK"; return "STAND"; } - #region Flying bool isColliding = actor.IsColliding; @@ -360,15 +377,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation currentControlState = motionControlStates.flying; - if (move.X != 0f || move.Y != 0f) +// if (move.X != 0f || move.Y != 0f) + if (heldOnXY) { return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY"); } - else if (move.Z > 0f) +// else if (move.Z > 0f) + else if (heldUp) + { return "HOVER_UP"; } - else if (move.Z < 0f) +// else if (move.Z < 0f) + else if (heldDown) { if (isColliding) { @@ -423,7 +444,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation } // Check if the user has stopped walking just now - if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero)) +// if (CurrentMovementAnimation == "WALK" && move == Vector3.Zero)) + if (CurrentMovementAnimation == "WALK" && !heldOnXY && !heldDown && !heldUp) return "STAND"; return CurrentMovementAnimation; @@ -435,8 +457,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Jumping // section added for jumping... - if (isColliding && move.Z > 0f && currentControlState != motionControlStates.jumping) - { +// if (isColliding && move.Z > 0f && currentControlState != motionControlStates.jumping) + if (isColliding && heldUp && currentControlState != motionControlStates.jumping) + { // Start jumping, prejump currentControlState = motionControlStates.jumping; m_jumping = true; @@ -481,7 +504,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation currentControlState = motionControlStates.landing; m_animTickLand = Environment.TickCount; // TODO: SOFT_LAND support - float fallVsq =m_lastFallVelocity*m_lastFallVelocity; + float fallVsq = m_lastFallVelocity * m_lastFallVelocity; if (fallVsq > 300f) // aprox 20*h return "STANDUP"; else if (fallVsq > 160f) @@ -514,12 +537,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation // next section moved outside paren. and realigned for jumping - if (move.X != 0f || move.Y != 0f) + +// if (move.X != 0f || move.Y != 0f) + if (heldOnXY) { currentControlState = motionControlStates.onsurface; Falling = false; // Walking / crouchwalking / running - if (move.Z < 0f) +// if (move.Z < 0f) + if (heldDown) { return "CROUCHWALK"; } @@ -538,7 +564,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation currentControlState = motionControlStates.onsurface; Falling = false; // Not walking - if (move.Z < 0) +// if (move.Z < 0) + if(heldDown) return "CROUCH"; else if (heldTurnLeft) return "TURNLEFT"; @@ -558,7 +585,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// 'true' if the animation was changed public bool UpdateMovementAnimations() { -// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); + // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); bool ret = false; lock (m_animations) @@ -568,9 +595,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation { CurrentMovementAnimation = newMovementAnimation; -// m_log.DebugFormat( -// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", -// CurrentMovementAnimation, m_scenePresence.Name); + // m_log.DebugFormat( + // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", + // CurrentMovementAnimation, m_scenePresence.Name); // Only set it if it's actually changed, give a script // a chance to stop a default animation @@ -606,19 +633,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); return animIDs; } - + public BinBVHAnimation GenerateRandomAnimation() { int rnditerations = 3; BinBVHAnimation anim = new BinBVHAnimation(); List parts = new List(); - parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso"); - parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft"); - parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck"); - parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight"); - parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight"); - parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight"); - parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft"); + parts.Add("mPelvis"); parts.Add("mHead"); parts.Add("mTorso"); + parts.Add("mHipLeft"); parts.Add("mHipRight"); parts.Add("mHipLeft"); parts.Add("mKneeLeft"); + parts.Add("mKneeRight"); parts.Add("mCollarLeft"); parts.Add("mCollarRight"); parts.Add("mNeck"); + parts.Add("mElbowLeft"); parts.Add("mElbowRight"); parts.Add("mWristLeft"); parts.Add("mWristRight"); + parts.Add("mShoulderLeft"); parts.Add("mShoulderRight"); parts.Add("mAnkleLeft"); parts.Add("mAnkleRight"); + parts.Add("mEyeRight"); parts.Add("mChest"); parts.Add("mToeLeft"); parts.Add("mToeRight"); + parts.Add("mFootLeft"); parts.Add("mFootRight"); parts.Add("mEyeLeft"); anim.HandPose = 1; anim.InPoint = 0; anim.OutPoint = (rnditerations * .10f); @@ -642,12 +669,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation for (int i = 0; i < rnditerations; i++) { anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); - anim.Joints[j].rotationkeys[i].time = (i*.10f); - anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1); - anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1); - anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1); + anim.Joints[j].rotationkeys[i].time = (i * .10f); + anim.Joints[j].rotationkeys[i].key_element.X = ((float)rnd.NextDouble() * 2 - 1); + anim.Joints[j].rotationkeys[i].key_element.Y = ((float)rnd.NextDouble() * 2 - 1); + anim.Joints[j].rotationkeys[i].key_element.Z = ((float)rnd.NextDouble() * 2 - 1); anim.Joints[j].positionkeys[i] = new binBVHJointKey(); - anim.Joints[j].positionkeys[i].time = (i*.10f); + anim.Joints[j].positionkeys[i].time = (i * .10f); anim.Joints[j].positionkeys[i].key_element.X = 0; anim.Joints[j].positionkeys[i].key_element.Y = 0; anim.Joints[j].positionkeys[i].key_element.Z = 0; @@ -674,22 +701,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) { -/* - if (m_scenePresence.IsChildAgent) - return; - -// m_log.DebugFormat( -// "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'", -// string.Join(",", Array.ConvertAll(animations, a => a.ToString())), -// string.Join(",", Array.ConvertAll(seqs, s => s.ToString())), -// string.Join(",", Array.ConvertAll(objectIDs, o => o.ToString()))); - - m_scenePresence.Scene.ForEachClient( - delegate(IClientAPI client) - { - client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs); - }); - */ + /* + if (m_scenePresence.IsChildAgent) + return; + + // m_log.DebugFormat( + // "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'", + // string.Join(",", Array.ConvertAll(animations, a => a.ToString())), + // string.Join(",", Array.ConvertAll(seqs, s => s.ToString())), + // string.Join(",", Array.ConvertAll(objectIDs, o => o.ToString()))); + + m_scenePresence.Scene.ForEachClient( + delegate(IClientAPI client) + { + client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs); + }); + */ m_scenePresence.SendAnimPack(animations, seqs, objectIDs); } @@ -699,7 +726,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation sequenceNums = null; objectIDs = null; - if(m_animations != null) + if (m_animations != null) m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); } @@ -722,7 +749,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void SendAnimPack() { //m_log.Debug("Sending animation pack to all"); - + if (m_scenePresence.IsChildAgent) return; @@ -732,7 +759,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); -// SendAnimPack(animIDs, sequenceNums, objectIDs); + // SendAnimPack(animIDs, sequenceNums, objectIDs); m_scenePresence.SendAnimPack(animIDs, sequenceNums, objectIDs); } -- cgit v1.1 From 6d1f1103f3f2cfd6e123e8b7c42ff7561109bc50 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 1 Oct 2014 16:36:06 +0100 Subject: clean up coments, use a even faster XY move request detection --- .../Scenes/Animation/ScenePresenceAnimator.cs | 84 +++++----------------- 1 file changed, 19 insertions(+), 65 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 56b8b30..2d1b0df 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -201,9 +201,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation bool ret = false; if (!m_scenePresence.IsChildAgent) { - // m_log.DebugFormat( - // "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", - // anim, m_scenePresence.Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", +// anim, m_scenePresence.Name); if (aoSitGndAnim != UUID.Zero) { @@ -240,9 +240,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_animations.TrySetDefaultAnimation( anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) { - // m_log.DebugFormat( - // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", - // anim, m_scenePresence.Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", +// anim, m_scenePresence.Name); // 16384 is CHANGED_ANIMATION m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); @@ -299,26 +299,20 @@ namespace OpenSim.Region.Framework.Scenes.Animation AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; PhysicsActor actor = m_scenePresence.PhysicsActor; - -// there is no point on having this meaningless movement values, much less in world coordenates -// situation may change if vertical Axis of avatar is allowed to rotate. -// then jumping etc will need some care - - // Create forward and left vectors from the current avatar rotation - /* yes matrix are better, but getting it from the Quaternion will kill the advantage - Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_scenePresence.Rotation); - Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); - Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); - */ - // there is still a better way -// Vector3 fwd = Vector3.UnitX * m_scenePresence.Rotation; -// Vector3 left = Vector3.UnitY * m_scenePresence.Rotation; + const AgentManager.ControlFlags ANYXYMASK = ( + AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | + AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG | + AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS | + AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG + ); // Check control flags +/* not in use bool heldForward = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)) != 0); bool heldBack = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG)) != 0); bool heldLeft = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS)) != 0); bool heldRight = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG)) != 0); +*/ bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; // bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS)) != 0); @@ -328,27 +322,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; - bool heldOnXY = (heldForward || heldBack || heldLeft || heldRight); + bool heldOnXY = ((controlFlags & ANYXYMASK) != 0); if (heldOnXY || heldUp || heldDown) { heldTurnLeft = false; heldTurnRight = false; } - - // Direction in which the avatar is trying to move -/* - Vector3 move = Vector3.Zero; - if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } - if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } - if (heldLeft) { move.X += left.X; move.Y += left.Y; } - if (heldRight) { move.X -= left.X; move.Y -= left.Y; } - if (heldUp) { move.Z += 1; } - if (heldDown) { move.Z -= 1; } -*/ - - - // Is the avatar trying to move? - // bool moving = (move != Vector3.Zero); + #endregion Inputs // no physics actor case @@ -357,7 +337,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation // well what to do? currentControlState = motionControlStates.onsurface; -// if (move.X != 0f || move.Y != 0f) if (heldOnXY) return "WALK"; @@ -377,18 +356,14 @@ namespace OpenSim.Region.Framework.Scenes.Animation currentControlState = motionControlStates.flying; -// if (move.X != 0f || move.Y != 0f) if (heldOnXY) { return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY"); } -// else if (move.Z > 0f) else if (heldUp) - { return "HOVER_UP"; } -// else if (move.Z < 0f) else if (heldDown) { if (isColliding) @@ -444,7 +419,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation } // Check if the user has stopped walking just now -// if (CurrentMovementAnimation == "WALK" && move == Vector3.Zero)) if (CurrentMovementAnimation == "WALK" && !heldOnXY && !heldDown && !heldUp) return "STAND"; @@ -457,7 +431,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Jumping // section added for jumping... -// if (isColliding && move.Z > 0f && currentControlState != motionControlStates.jumping) if (isColliding && heldUp && currentControlState != motionControlStates.jumping) { // Start jumping, prejump @@ -538,13 +511,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation // next section moved outside paren. and realigned for jumping -// if (move.X != 0f || move.Y != 0f) if (heldOnXY) { currentControlState = motionControlStates.onsurface; Falling = false; // Walking / crouchwalking / running -// if (move.Z < 0f) if (heldDown) { return "CROUCHWALK"; @@ -564,7 +535,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation currentControlState = motionControlStates.onsurface; Falling = false; // Not walking -// if (move.Z < 0) if(heldDown) return "CROUCH"; else if (heldTurnLeft) @@ -595,9 +565,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation { CurrentMovementAnimation = newMovementAnimation; - // m_log.DebugFormat( - // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", - // CurrentMovementAnimation, m_scenePresence.Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", +// CurrentMovementAnimation, m_scenePresence.Name); // Only set it if it's actually changed, give a script // a chance to stop a default animation @@ -701,22 +671,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) { - /* - if (m_scenePresence.IsChildAgent) - return; - - // m_log.DebugFormat( - // "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'", - // string.Join(",", Array.ConvertAll(animations, a => a.ToString())), - // string.Join(",", Array.ConvertAll(seqs, s => s.ToString())), - // string.Join(",", Array.ConvertAll(objectIDs, o => o.ToString()))); - - m_scenePresence.Scene.ForEachClient( - delegate(IClientAPI client) - { - client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs); - }); - */ m_scenePresence.SendAnimPack(animations, seqs, objectIDs); } -- cgit v1.1 From 94f42cef90a8d5732f4bf9e033ae5e9f5508ae7e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 3 Oct 2014 18:32:52 +0100 Subject: added a missing angularVelocity.Zero on sitting, removed odd camera based movement vectors, plus little other things --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 129 ++++++++++++----------- 1 file changed, 68 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 42d3684..dbeba9a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -336,7 +336,7 @@ namespace OpenSim.Region.Framework.Scenes protected ulong crossingFromRegion; - private readonly Vector3[] Dir_Vectors = new Vector3[11]; + private readonly Vector3[] Dir_Vectors = new Vector3[12]; protected Timer m_reprioritization_timer; protected bool m_reprioritizing; @@ -393,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Implemented Control Flags /// - private enum Dir_ControlFlags + private enum Dir_ControlFlags:uint { DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, @@ -405,6 +405,7 @@ namespace OpenSim.Region.Framework.Scenes DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, + DIR_CONTROL_FLAG_UP_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS, DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG } @@ -728,24 +729,7 @@ namespace OpenSim.Region.Framework.Scenes // Scene.RegionInfo.RegionName, Name, m_velocity); } } -/* - public override Vector3 AngularVelocity - { - get - { - if (PhysicsActor != null) - { - m_rotationalvelocity = PhysicsActor.RotationalVelocity; - // m_log.DebugFormat( - // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", - // m_velocity, Name, Scene.RegionInfo.RegionName); - } - - return m_rotationalvelocity; - } - } -*/ private Quaternion m_bodyRot = Quaternion.Identity; /// @@ -915,13 +899,6 @@ namespace OpenSim.Region.Framework.Scenes } } - private float m_speedModifier = 1.0f; - - public float SpeedModifier - { - get { return m_speedModifier; } - set { m_speedModifier = value; } - } /// /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running @@ -929,7 +906,20 @@ namespace OpenSim.Region.Framework.Scenes /// /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. /// - private float AgentControlStopSlowWhilstMoving = 0.2f; + private const float AgentControlStopSlowVel = 0.2f; + // velocities + public const float AgentControlNudgeVel = 1.0f; // setting this diferent from normal as no effect currently + public const float AgentControlNormalVel = 1.0f; + + // old normal speed was tuned to match sl normal plus Fast modifiers + // so we need to rescale it + private float m_speedModifier = 1.0f; + + public float SpeedModifier + { + get { return m_speedModifier; } + set { m_speedModifier = value; } + } private bool m_forceFly; @@ -1057,22 +1047,24 @@ namespace OpenSim.Region.Framework.Scenes private void SetDirectionVectors() { - Dir_Vectors[0] = Vector3.UnitX; //FORWARD - Dir_Vectors[1] = -Vector3.UnitX; //BACK - Dir_Vectors[2] = Vector3.UnitY; //LEFT - Dir_Vectors[3] = -Vector3.UnitY; //RIGHT - Dir_Vectors[4] = Vector3.UnitZ; //UP - Dir_Vectors[5] = -Vector3.UnitZ; //DOWN - Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE - Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE - Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE - Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE - Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge - } - + Dir_Vectors[0] = new Vector3(AgentControlNormalVel,0,0); //FORWARD + Dir_Vectors[1] = new Vector3(-AgentControlNormalVel,0,0);; //BACK + Dir_Vectors[2] = new Vector3(0,AgentControlNormalVel,0); //LEFT + Dir_Vectors[3] = new Vector3(0,-AgentControlNormalVel,0); //RIGHT + Dir_Vectors[4] = new Vector3(0,0,AgentControlNormalVel); //UP + Dir_Vectors[5] = new Vector3(0,0,-AgentControlNormalVel); //DOWN + Dir_Vectors[6] = new Vector3(AgentControlNudgeVel, 0f, 0f); //FORWARD_NUDGE + Dir_Vectors[7] = new Vector3(-AgentControlNudgeVel, 0f, 0f); //BACK_NUDGE + Dir_Vectors[8] = new Vector3(0f, AgentControlNudgeVel, 0f); //LEFT_NUDGE + Dir_Vectors[9] = new Vector3(0f, -AgentControlNudgeVel, 0f); //RIGHT_NUDGE + Dir_Vectors[10] = new Vector3(0f, 0f, AgentControlNudgeVel); //UP_Nudge + Dir_Vectors[11] = new Vector3(0f, 0f, -AgentControlNudgeVel); //DOWN_Nudge + } + +/* dont see any use for this private Vector3[] GetWalkDirectionVectors() { - Vector3[] vector = new Vector3[11]; + Vector3[] vector = new Vector3[12]; vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK vector[2] = Vector3.UnitY; //LEFT @@ -1083,10 +1075,11 @@ namespace OpenSim.Region.Framework.Scenes vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE vector[8] = Vector3.UnitY; //LEFT_NUDGE vector[9] = -Vector3.UnitY; //RIGHT_NUDGE - vector[10] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE + vector[10] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP_NUDGE + vector[11] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE return vector; } - +*/ #endregion #region Status Methods @@ -2192,11 +2185,12 @@ namespace OpenSim.Region.Framework.Scenes // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying // this prevents 'jumping' in inappropriate situations. - if (!Flying && (m_mouseLook || m_leftButtonDown)) - dirVectors = GetWalkDirectionVectors(); - else +// if (!Flying && (m_mouseLook || m_leftButtonDown)) +// dirVectors = GetWalkDirectionVectors(); +// else dirVectors = Dir_Vectors; + // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) { @@ -2214,10 +2208,10 @@ namespace OpenSim.Region.Framework.Scenes // Why did I get this? } - if (((MovementFlag & (uint)DCF) == 0) & !AgentControlStopActive) + if (((MovementFlag & (uint)DCF) == 0)) { //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); - MovementFlag += (uint)DCF; + MovementFlag |= (uint)DCF; update_movementflag = true; } } @@ -2226,7 +2220,7 @@ namespace OpenSim.Region.Framework.Scenes if ((MovementFlag & (uint)DCF) != 0) { //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); - MovementFlag -= (uint)DCF; + MovementFlag &= (uint)~DCF; update_movementflag = true; /* @@ -2344,17 +2338,18 @@ namespace OpenSim.Region.Framework.Scenes if (AgentControlStopActive) { -// if (MovementFlag == 0 && Animator.Falling) + // if (MovementFlag == 0 && Animator.Falling) if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) { - AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving, true); + AddNewMovement(agent_control_v3, AgentControlStopSlowVel, true); } else - AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving); + AddNewMovement(agent_control_v3, AgentControlStopSlowVel); } - else + { AddNewMovement(agent_control_v3); + } } @@ -2453,11 +2448,13 @@ namespace OpenSim.Region.Framework.Scenes bool updated = false; + Vector3 LocalVectorToTarget3D = MoveToPositionTarget - AbsolutePosition; + // m_log.DebugFormat( // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); - double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); + double distanceToTarget = LocalVectorToTarget3D.Length(); // m_log.DebugFormat( // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", @@ -2480,11 +2477,11 @@ namespace OpenSim.Region.Framework.Scenes // Theoretically we might need a more complex PID approach here if other // unknown forces are acting on the avatar and we need to adaptively respond // to such forces, but the following simple approach seems to works fine. - Vector3 LocalVectorToTarget3D = - (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords - * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords + + LocalVectorToTarget3D = LocalVectorToTarget3D * Quaternion.Inverse(Rotation); // change to avatar coords // Ignore z component of vector // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); + LocalVectorToTarget3D.Normalize(); // update avatar movement flags. the avatar coordinate system is as follows: @@ -2508,28 +2505,37 @@ namespace OpenSim.Region.Framework.Scenes // based on the above avatar coordinate system, classify the movement into // one of left/right/back/forward. + + const uint noMovFlagsMask = (uint)(~(Dir_ControlFlags.DIR_CONTROL_FLAG_BACK | + Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD | Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT | + Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT | Dir_ControlFlags.DIR_CONTROL_FLAG_UP | + Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN)); + + MovementFlag &= noMovFlagsMask; + AgentControlFlags &= noMovFlagsMask; + if (LocalVectorToTarget3D.X < 0) //MoveBack { - MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; + MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; updated = true; } else if (LocalVectorToTarget3D.X > 0) //Move Forward { - MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; + MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; updated = true; } if (LocalVectorToTarget3D.Y > 0) //MoveLeft { - MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; + MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; updated = true; } else if (LocalVectorToTarget3D.Y < 0) //MoveRight { - MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; + MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; updated = true; } @@ -3016,6 +3022,7 @@ namespace OpenSim.Region.Framework.Scenes ResetMoveToTarget(); Velocity = Vector3.Zero; + m_AngularVelocity = Vector3.Zero; part.AddSittingAvatar(UUID); -- cgit v1.1 From 4ae960a4f0b939ec1ce50414b771a0774bf991f8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 4 Oct 2014 03:43:20 +0100 Subject: bug fix: revert back check on creating link --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5197f58..0c51f7f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1023,6 +1023,10 @@ namespace OpenSim.Region.Framework.Scenes item.BasePermissions = baseMask; item.CreationDate = creationDate; + // special AnimationSet case + if (item.InvType == (int)CustomInventoryType.AnimationSet) + AnimationSet.enforceItemPermitions(item,true); + if (AddInventoryItem(item)) { remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); @@ -1063,10 +1067,6 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) return; - if (type != (sbyte)AssetType.Link || type != (sbyte)AssetType.LinkFolder) - return; - - ScenePresence presence; if (TryGetScenePresence(remoteClient.AgentId, out presence)) { -- cgit v1.1 From 6f149ef6aed517d3fb29598ce006ab4e9876be28 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 4 Oct 2014 07:49:05 +0100 Subject: bug fix: leave jumping state only to landing, without fallback into onsurface, etc --- .../Scenes/Animation/ScenePresenceAnimator.cs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 2d1b0df..ade908d 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -307,15 +307,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation ); // Check control flags -/* not in use - bool heldForward = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)) != 0); - bool heldBack = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG)) != 0); - bool heldLeft = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS)) != 0); - bool heldRight = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG)) != 0); -*/ + /* not in use + bool heldForward = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)) != 0); + bool heldBack = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG)) != 0); + bool heldLeft = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS)) != 0); + bool heldRight = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG)) != 0); + */ bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; -// bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS)) != 0); + // bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS)) != 0); // excluded nudge up so it doesn't trigger jump state bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS)) != 0); bool heldDown = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG)) != 0); @@ -328,7 +328,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation heldTurnLeft = false; heldTurnRight = false; } - + #endregion Inputs // no physics actor case @@ -432,7 +432,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Jumping // section added for jumping... if (isColliding && heldUp && currentControlState != motionControlStates.jumping) - { + { // Start jumping, prejump currentControlState = motionControlStates.jumping; m_jumping = true; @@ -465,6 +465,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_jumping = true; return "JUMP"; } + return CurrentMovementAnimation; } #endregion Jumping @@ -508,7 +509,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation } } - // next section moved outside paren. and realigned for jumping if (heldOnXY) @@ -530,12 +530,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation return "WALK"; } } - else if (!m_jumping) + else { currentControlState = motionControlStates.onsurface; Falling = false; // Not walking - if(heldDown) + if (heldDown) return "CROUCH"; else if (heldTurnLeft) return "TURNLEFT"; -- cgit v1.1 From 57caf468e8f999db49a383cf22e1f665488ca36f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 4 Oct 2014 08:30:04 +0100 Subject: bug fix: resend part targetOmega on deSelect --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6daa109..3fc741c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -666,6 +666,8 @@ namespace OpenSim.Region.Framework.Scenes m_isSelected = value; if (ParentGroup != null) ParentGroup.PartSelectChanged(value); + if (!m_isSelected && m_angularVelocity != Vector3.Zero) + ScheduleTerseUpdate(); } } -- cgit v1.1 From c0a75fcc038c50047e7fe3739f7b53d0e1310b03 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 6 Oct 2014 00:17:41 +0100 Subject: fix targetOmega resend on deselect on the right place, can't be at sop but packethandlers --- OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 4 ++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 46b2d2e..931093a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -291,6 +291,10 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerParcelPrimCountTainted(); } + // restore targetOmega + if (part.AngularVelocity != Vector3.Zero) + part.ScheduleTerseUpdate(); + } public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3fc741c..d5377d0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -666,8 +666,7 @@ namespace OpenSim.Region.Framework.Scenes m_isSelected = value; if (ParentGroup != null) ParentGroup.PartSelectChanged(value); - if (!m_isSelected && m_angularVelocity != Vector3.Zero) - ScheduleTerseUpdate(); + } } -- cgit v1.1 From 14259b5f995da0b87190d873d1e5dc7a94606445 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 16 Oct 2014 03:53:56 +0200 Subject: Fix an obscure permissions exploit. Taking items from a friend's prim could possibly result in a privilege escalation --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0c51f7f..87fee56 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1236,17 +1236,15 @@ namespace OpenSim.Region.Framework.Scenes agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); if (taskItem.InvType == (int)InventoryType.Object) { - uint perms = taskItem.CurrentPermissions; + uint perms = taskItem.BasePermissions & taskItem.NextPermissions; PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); // agentItem.BasePermissions = perms | (uint)PermissionMask.Move; // agentItem.CurrentPermissions = agentItem.BasePermissions; - agentItem.CurrentPermissions = perms | (uint)PermissionMask.Move; - } - else - { - agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; + agentItem.BasePermissions = perms | (uint)PermissionMask.Move; } + agentItem.CurrentPermissions = agentItem.BasePermissions; + agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); -- cgit v1.1 From 2bea66ed27d86ddd7f34ee1e7d0292ae4f1c5644 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 17 Oct 2014 14:07:11 +0100 Subject: send motion control state in update to childs. Reset CollisionPlane on makechild --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dbeba9a..3509ae7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1313,7 +1313,9 @@ namespace OpenSim.Region.Framework.Scenes m_currentParcelHide = false; m_currentParcelUUID = UUID.Zero; // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into - + + CollisionPlane = Vector4.UnitW; + m_scene.EventManager.TriggerOnMakeChildAgent(this); } @@ -1659,7 +1661,7 @@ namespace OpenSim.Region.Framework.Scenes client.Name, Scene.Name, AbsolutePosition); m_inTransit = true; - bool newhide = false; + try { // Make sure it's not a login agent. We don't want to wait for updates during login @@ -1805,6 +1807,7 @@ namespace OpenSim.Region.Framework.Scenes SendAppearanceToAgent(this); // send this animations + UUID[] animIDs = null; int[] animseqs = null; UUID[] animsobjs = null; @@ -4222,6 +4225,8 @@ namespace OpenSim.Region.Framework.Scenes cAgent.MovementAnimationOverRides = Overrides.CloneAOPairs(); + cAgent.MotionState = (byte)Animator.currentControlState; + if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(this, cAgent); } @@ -4305,6 +4310,8 @@ namespace OpenSim.Region.Framework.Scenes Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); if (cAgent.Anims != null) Animator.Animations.FromArray(cAgent.Anims); + if (cAgent.MotionState != 0) + Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState; if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); -- cgit v1.1 From f9588730cf1c130b0171377f182aabe7e42e101a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 17 Oct 2014 14:36:02 +0100 Subject: debug makeroot timing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3509ae7..fbb18b7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1102,11 +1102,14 @@ namespace OpenSim.Region.Framework.Scenes // other uses need fix private bool MakeRootAgent(Vector3 pos, bool isFlying) { + int ts = Util.EnvironmentTickCount(); + lock (m_completeMovementLock) { if (!IsChildAgent) return false; + m_log.DebugFormat("[MakeRootAgent] enter lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); // m_log.InfoFormat( @@ -1141,6 +1144,8 @@ namespace OpenSim.Region.Framework.Scenes IsChildAgent = false; } + m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + // Must reset this here so that a teleport to a region next to an existing region does not keep the flag // set and prevent the close of the connection on a subsequent re-teleport. // Should not be needed if we are not trying to tell this region to close @@ -1150,9 +1155,12 @@ namespace OpenSim.Region.Framework.Scenes if (gm != null) Grouptitle = gm.GetGroupTitle(m_uuid); + m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts)); + RegionHandle = m_scene.RegionInfo.RegionHandle; m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); + m_log.DebugFormat("[MakeRootAgent] TriggerSetRootAgentScene: {0}ms", Util.EnvironmentTickCountSubtract(ts)); if (ParentID == 0) @@ -1229,6 +1237,7 @@ namespace OpenSim.Region.Framework.Scenes // elsewhere anyway // Animator.SendAnimPack(); + m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts)); m_scene.SwapRootAgentCount(false); @@ -1239,6 +1248,7 @@ namespace OpenSim.Region.Framework.Scenes MovementFlag = 0; m_scene.EventManager.TriggerOnMakeRootAgent(this); + m_log.DebugFormat("[MakeRootAgent] TriggerOnMakeRootAgent and done: {0}ms", Util.EnvironmentTickCountSubtract(ts)); return true; } -- cgit v1.1 From b7708b9d1f9cee1c10283d3178eabc2ce0c8a81a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Oct 2014 18:27:38 +0100 Subject: change child agents creation/notification. As before this assumes that sending regions close out of view connections. --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 608f071..829d4ce 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4080,15 +4080,15 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat( "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", - acd.AgentID, RegionInfo.RegionName); - - sp.AdjustKnownSeeds(); + acd.AgentID, RegionInfo.RegionName); if (CapsModule != null) { CapsModule.SetAgentCapsSeeds(acd); CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); } + + sp.AdjustKnownSeeds(); } } -- cgit v1.1 From f44c29effbd0d14427f288470aee028e9e09d6e3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 19 Oct 2014 15:51:12 +0100 Subject: try to fix propagation of seeds to all relevante regions --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 +++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 +++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 829d4ce..4a6f72c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4558,8 +4558,14 @@ namespace OpenSim.Region.Framework.Scenes // a UseCircuitCode packet which in turn calls AddNewAgent which finally creates the ScenePresence. ScenePresence sp = WaitGetScenePresence(cAgentData.AgentID); - if (sp != null) + if (sp != null) { + if (!sp.IsChildAgent) + { + m_log.WarnFormat("[SCENE]: Ignoring a child update on a root agent {0} {1} in {2}", + sp.Name, sp.UUID, Name); + return false; + } if (cAgentData.SessionID != sp.ControllingClient.SessionId) { m_log.WarnFormat( diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fbb18b7..405ad73 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1684,20 +1684,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - // Prevent teleporting to an underground location - // (may crash client otherwise) - // - -/* this is done in MakeRootAgent - Vector3 pos = AbsolutePosition; - float ground = m_scene.GetGroundHeight(pos.X, pos.Y); - if (pos.Z < ground + 1.5f) - { - pos.Z = ground + 1.5f; - AbsolutePosition = pos; - } -*/ - m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); @@ -1904,7 +1890,9 @@ namespace OpenSim.Region.Framework.Scenes { IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) + { m_agentTransfer.EnableChildAgents(this); + } } } @@ -4171,6 +4159,16 @@ namespace OpenSim.Region.Framework.Scenes if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); + if(cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count >0) + { + if (Scene.CapsModule != null) + { + Scene.CapsModule.SetChildrenSeed(UUID, cAgentData.ChildrenCapSeeds); + } + + KnownRegions = cAgentData.ChildrenCapSeeds; + } + //cAgentData.AVHeight; //m_velocity = cAgentData.Velocity; } -- cgit v1.1 From afa9b4a002f0cc929d60e1770535eefcdefe3a43 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 20 Oct 2014 09:14:27 +0100 Subject: Assume childreen don't need to know caps seeds --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 405ad73..754dd96 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4262,6 +4262,15 @@ namespace OpenSim.Region.Framework.Scenes // DrawDistance = cAgent.Far; DrawDistance = Scene.DefaultDrawDistance; + if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0) + { + if (Scene.CapsModule != null) + { + Scene.CapsModule.SetChildrenSeed(UUID, cAgent.ChildrenCapSeeds); + } + KnownRegions = cAgent.ChildrenCapSeeds; + } + if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgent.Throttles); -- cgit v1.1 From 59413adceecd7f6c9132f03b436b7a0b5cabb443 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 21 Oct 2014 11:57:47 +0100 Subject: do agent crossing async, including QUERYACCESS ( need to check vehicles for this also ), so it doesn't stop heartbeat --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 754dd96..b746e3a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3980,6 +3980,30 @@ namespace OpenSim.Region.Framework.Scenes } + public void CrossToNewRegionFail() + { + if (m_requestedSitTargetUUID == UUID.Zero) + { + bool isFlying = Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + } + + } + /// /// Moves the agent outside the region bounds /// Tells neighbor region that we're crossing to it @@ -3996,7 +4020,7 @@ namespace OpenSim.Region.Framework.Scenes } catch { - result = m_scene.CrossAgentToNewRegion(this, false); +// result = m_scene.CrossAgentToNewRegion(this, false); } // if(!result) // parcelRegionCross(true); -- cgit v1.1 From b1ccf3f11088437840ee6b8aaa5cf5bb245d9013 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 21 Oct 2014 13:04:26 +0100 Subject: make sure we return false if catch() is triggered on crossing --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b746e3a..4cc4d94 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4021,6 +4021,7 @@ namespace OpenSim.Region.Framework.Scenes catch { // result = m_scene.CrossAgentToNewRegion(this, false); + return false; } // if(!result) // parcelRegionCross(true); -- cgit v1.1 From 31c036c04405d04aac5da19ca45fb2cb73d43dd7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 21 Oct 2014 19:22:51 +0100 Subject: refuse crossings if logins disabled Please enter the commit message for your changes. Lines starting --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4a6f72c..9e2f52c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4532,6 +4532,13 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); + if (!LoginsEnabled) + { +// reason = "Logins Disabled"; + m_log.DebugFormat( + "[SCENE]: update for {0} in {1} refused: Logins Disabled", cAgentData.AgentID, RegionInfo.RegionName); + return false; + } // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence int flags = GetUserFlags(cAgentData.AgentID); -- cgit v1.1 From 4571e5bc3e284c916d1ae4dd6429b80a8028b8e0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 24 Oct 2014 18:10:28 +0100 Subject: try to make SOG crossings full async. Simplify some borders checking.... --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 357 ++++++++++++--------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 146 ++++----- 2 files changed, 269 insertions(+), 234 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0eed64e..a7e7294 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -516,6 +516,10 @@ namespace OpenSim.Region.Framework.Scenes public uint ParentID; } + + public bool inTransit = false; + public delegate SceneObjectGroup SOGCrossDelegate(SceneObjectGroup sog,Vector3 pos); + /// /// The absolute position of this scene object in the scene /// @@ -525,8 +529,8 @@ namespace OpenSim.Region.Framework.Scenes set { Vector3 val = value; - - if (Scene != null) + + if (Scene != null && !inTransit) { if ( // (Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) @@ -543,130 +547,10 @@ namespace OpenSim.Region.Framework.Scenes || Scene.TestBorderCross(val, Cardinals.S)) && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) { - IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface(); - uint x = 0; - uint y = 0; - string version = String.Empty; - Vector3 newpos = Vector3.Zero; - OpenSim.Services.Interfaces.GridRegion destination = null; - - if (m_rootPart.DIE_AT_EDGE || m_rootPart.RETURN_AT_EDGE) - { - // this should delete the grp in this case - m_scene.CrossPrimGroupIntoNewRegion(val, this, true); - // actually assume this sog was removed from simulation - return; - } - - if (m_rootPart.KeyframeMotion != null) - m_rootPart.KeyframeMotion.StartCrossingCheck(); - - bool canCross = true; - - foreach (ScenePresence av in m_linkedAvatars) - { - // We need to cross these agents. First, let's find - // out if any of them can't cross for some reason. - // We have to deny the crossing entirely if any - // of them are banned. Alternatively, we could - // unsit banned agents.... - - - // We set the avatar position as being the object - // position to get the region to send to - if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) - { - canCross = false; - break; - } - - m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); - } - - if (canCross) - { - // We unparent the SP quietly so that it won't - // be made to stand up - - List avsToCross = new List(); - - foreach (ScenePresence av in m_linkedAvatars) - { - avtocrossInfo avinfo = new avtocrossInfo(); - SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); - if (parentPart != null) - av.ParentUUID = parentPart.UUID; - - avinfo.av = av; - avinfo.ParentID = av.ParentID; - avsToCross.Add(avinfo); - - av.PrevSitOffset = av.OffsetPosition; - av.ParentID = 0; - } - - // m_linkedAvatars.Clear(); - m_scene.CrossPrimGroupIntoNewRegion(val, this, true); - - // Normalize - if (val.X >= Constants.RegionSize) - val.X -= Constants.RegionSize; - if (val.Y >= Constants.RegionSize) - val.Y -= Constants.RegionSize; - if (val.X < 0) - val.X += Constants.RegionSize; - if (val.Y < 0) - val.Y += Constants.RegionSize; - - // If it's deleted, crossing was successful - if (IsDeleted) - { - // foreach (ScenePresence av in m_linkedAvatars) - foreach (avtocrossInfo avinfo in avsToCross) - { - ScenePresence av = avinfo.av; - if (!av.IsInTransit) // just in case... - { - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); - - av.IsInTransit = true; - - CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; - d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); - } - else - m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); - } - avsToCross.Clear(); - return; - } - else // cross failed, put avas back ?? - { - foreach (avtocrossInfo avinfo in avsToCross) - { - ScenePresence av = avinfo.av; - av.ParentUUID = UUID.Zero; - av.ParentID = avinfo.ParentID; - // m_linkedAvatars.Add(av); - } - } - avsToCross.Clear(); - } - else - { - if (m_rootPart.KeyframeMotion != null) - m_rootPart.KeyframeMotion.CrossingFailure(); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.CrossingFailure(); - } - } - Vector3 oldp = AbsolutePosition; - val.X = Util.Clamp(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); - val.Y = Util.Clamp(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); - // dont crash land StarShips - // val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); + inTransit = true; + SOGCrossDelegate d = CrossAsync; + d.BeginInvoke(this, val, CrossAsyncCompleted, d); + return; } } @@ -714,46 +598,197 @@ namespace OpenSim.Region.Framework.Scenes part.TriggerScriptChangedEvent(Changed.POSITION); } } + + Scene.EventManager.TriggerParcelPrimCountTainted(); + } + } -/* - This seems not needed and should not be needed: - sp absolute position depends on sit part absolute position fixed above. - sp ParentPosition is not used anywhere. - Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it - Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. - - if (!m_dupeInProgress) + public SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val) + { + Scene sogScene = sog.m_scene; + IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface(); + + Vector3 newpos = Vector3.Zero; + OpenSim.Services.Interfaces.GridRegion destination = null; + + if (sog.RootPart.DIE_AT_EDGE) + { + try + { + sogScene.DeleteSceneObject(sog, false); + } + catch (Exception) + { + m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); + } + return sog; + } + + if (sog.RootPart.RETURN_AT_EDGE) + { + // We remove the object here + try + { + List localIDs = new List(); + localIDs.Add(sog.RootPart.LocalId); + sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition, + "Returned at region cross"); + sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero); + } + catch (Exception) + { + m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); + } + return sog; + } + + if (sog.m_rootPart.KeyframeMotion != null) + sog.m_rootPart.KeyframeMotion.StartCrossingCheck(); + + if (entityTransfer == null) + return sog; + + destination = entityTransfer.GetObjectDestination(sog, val, out newpos); + if (destination == null) + return sog; + + if (sog.m_linkedAvatars.Count == 0) + { + entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true); + return sog; + } + + string reason = String.Empty; + string version = String.Empty; + + foreach (ScenePresence av in sog.m_linkedAvatars) + { + // We need to cross these agents. First, let's find + // out if any of them can't cross for some reason. + // We have to deny the crossing entirely if any + // of them are banned. Alternatively, we could + // unsit banned agents.... + + // We set the avatar position as being the object + // position to get the region to send to + if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, out version, out reason)) + { + return sog; + } + m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); + } + + // We unparent the SP quietly so that it won't + // be made to stand up + + List avsToCross = new List(); + + foreach (ScenePresence av in sog.m_linkedAvatars) + { + avtocrossInfo avinfo = new avtocrossInfo(); + SceneObjectPart parentPart = sogScene.GetSceneObjectPart(av.ParentID); + if (parentPart != null) + av.ParentUUID = parentPart.UUID; + + avinfo.av = av; + avinfo.ParentID = av.ParentID; + avsToCross.Add(avinfo); + + av.PrevSitOffset = av.OffsetPosition; + av.ParentID = 0; + } + + if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true)) + { + foreach (avtocrossInfo avinfo in avsToCross) { - foreach (ScenePresence av in m_linkedAvatars) + ScenePresence av = avinfo.av; + if (!av.IsInTransit) // just in case... { - SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); - if (p != null && m_parts.TryGetValue(p.UUID, out p)) + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); + + av.IsInTransit = true; + +// CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; +// d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); + entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, av.Flying, version); + if(av.IsChildAgent) { - Vector3 offset = p.GetWorldPosition() - av.ParentPosition; - av.AbsolutePosition += offset; -// av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition - av.SendAvatarDataToAllAgents(); + if (av.ParentUUID != UUID.Zero) + { + av.ClearControls(); + av.ParentPart = null; + } } + av.ParentUUID = UUID.Zero; + // In any case + av.IsInTransit = false; + + m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname); } + else + m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar already in transit {0} to {1}", av.Name, val); + } + avsToCross.Clear(); + return sog; + } + else // cross failed, put avas back ?? + { + foreach (avtocrossInfo avinfo in avsToCross) + { + ScenePresence av = avinfo.av; + av.ParentUUID = UUID.Zero; + av.ParentID = avinfo.ParentID; } -*/ - //if (m_rootPart.PhysActor != null) - //{ - //m_rootPart.PhysActor.Position = - //new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y, - //m_rootPart.GroupPosition.Z); - //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); - //} - - if (Scene != null) - Scene.EventManager.TriggerParcelPrimCountTainted(); } + avsToCross.Clear(); + + return sog; } - public override Vector3 Velocity + public void CrossAsyncCompleted(IAsyncResult iar) { - get { return RootPart.Velocity; } - set { RootPart.Velocity = value; } + SOGCrossDelegate icon = (SOGCrossDelegate)iar.AsyncState; + SceneObjectGroup sog = icon.EndInvoke(iar); + + if (sog.IsDeleted) + { + sog.inTransit = false; // just in case... + } + else + { + SceneObjectPart rootp = sog.m_rootPart; + Vector3 oldp = rootp.GroupPosition; + oldp.X = Util.Clamp(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f); + oldp.Y = Util.Clamp(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f); + rootp.GroupPosition = oldp; + + SceneObjectPart[] parts = sog.m_parts.GetArray(); + + foreach (SceneObjectPart part in parts) + { + if (part != rootp) + part.GroupPosition = oldp; + } + + foreach (ScenePresence av in sog.m_linkedAvatars) + { + av.sitSOGmoved(); + } + + sog.Velocity = Vector3.Zero; + + if (sog.m_rootPart.KeyframeMotion != null) + sog.m_rootPart.KeyframeMotion.CrossingFailure(); + + if (sog.RootPart.PhysActor != null) + { + sog.RootPart.PhysActor.CrossingFailure(); + } + + sog.inTransit = false; + sog.ScheduleGroupForFullUpdate(); + } } private void CrossAgentToNewRegionCompleted(IAsyncResult iar) @@ -784,6 +819,12 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); } + public override Vector3 Velocity + { + get { return RootPart.Velocity; } + set { RootPart.Velocity = value; } + } + public override uint LocalId { get { return m_rootPart.LocalId; } @@ -2620,7 +2661,7 @@ namespace OpenSim.Region.Framework.Scenes // an object has been deleted from a scene before update was processed. // A more fundamental overhaul of the update mechanism is required to eliminate all // the race conditions. - if (IsDeleted) + if (IsDeleted || inTransit) return; // Even temporary objects take part in physics (e.g. temp-on-rez bullets) @@ -2736,7 +2777,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendGroupRootTerseUpdate() { - if (IsDeleted) + if (IsDeleted || inTransit) return; RootPart.SendTerseUpdateToAllClients(); @@ -2755,7 +2796,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendGroupTerseUpdate() { - if (IsDeleted) + if (IsDeleted || inTransit) return; if (IsAttachment) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4cc4d94..56c3b52 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1123,6 +1123,11 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) { m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); + ParentID = 0; + ParentPart = null; + PrevSitOffset = Vector3.Zero; + ClearControls(); + IsLoggingIn = false; } else { @@ -1216,13 +1221,6 @@ namespace OpenSim.Region.Framework.Scenes else AddToPhysicalScene(isFlying); - // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a - // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it - // since it requires a physics actor to be present. If it is left any later, then physics appears to reset - // the value to a negative position which does not trigger the border cross. - // This may not be the best location for this. - CheckForBorderCrossing(); - if (ForceFly) { Flying = true; @@ -1231,12 +1229,18 @@ namespace OpenSim.Region.Framework.Scenes { Flying = false; } - } - // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying - // avatar to return to the standing position in mid-air. On login it looks like this is being sent - // elsewhere anyway - // Animator.SendAnimPack(); + // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a + // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it + // since it requires a physics actor to be present. If it is left any later, then physics appears to reset + // the value to a negative position which does not trigger the border cross. + // This may not be the best location for this. + + + // its not +// CheckForBorderCrossing(); + } + m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts)); m_scene.SwapRootAgentCount(false); @@ -2734,7 +2738,6 @@ namespace OpenSim.Region.Framework.Scenes ParentID = 0; ParentPart = null; - if (part.SitTargetAvatar == UUID) standRotation = standRotation * part.SitTargetOrientation; else @@ -2761,12 +2764,6 @@ namespace OpenSim.Region.Framework.Scenes Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose; -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", -// standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); - - standPos.X = Util.Clamp(standPos.X, 0.5f, (float)Constants.RegionSize - 0.5f); - standPos.Y = Util.Clamp(standPos.Y, 0.5f, (float)Constants.RegionSize - 0.5f); m_pos = standPos; } @@ -3308,6 +3305,8 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent == false) { + CheckForBorderCrossing(); + if (IsInTransit) return; @@ -3329,8 +3328,6 @@ namespace OpenSim.Region.Framework.Scenes m_lastVelocity = Velocity; } - CheckForBorderCrossing(); - CheckForSignificantMovement(); // sends update to the modules. } } @@ -3847,7 +3844,7 @@ namespace OpenSim.Region.Framework.Scenes protected void CheckForBorderCrossing() { // Check that we we are not a child - if (IsChildAgent) + if (IsChildAgent || IsInTransit) return; // If we don't have a PhysActor, we can't cross anyway @@ -3857,25 +3854,22 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) return; - if (IsInTransit) - return; - Vector3 pos2 = AbsolutePosition; Vector3 vel = Velocity; - int neighbor = 0; - int[] fix = new int[2]; float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); - + pos2.X += vel.X * timeStep; + pos2.Y += vel.Y * timeStep; + pos2.Z += vel.Z * timeStep; // m_log.DebugFormat( // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", // pos2, Name, Scene.Name); - +/* // Checks if where it's headed exists a region + int neighbor = 0; + int[] fix = new int[2]; + bool needsTransit = false; if (m_scene.TestBorderCross(pos2, Cardinals.W)) { @@ -3925,59 +3919,55 @@ namespace OpenSim.Region.Framework.Scenes } // Makes sure avatar does not end up outside region + if (neighbor <= 0) { if (needsTransit) { - if (m_requestedSitTargetUUID == UUID.Zero) - { - bool isFlying = Flying; - RemoveFromPhysicalScene(); - - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y * 2; - Velocity = Vector3.Zero; - AbsolutePosition = pos; - - // m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); - - AddToPhysicalScene(isFlying); - } + CrossToNewRegionFail(); } } else if (neighbor > 0) { if (!CrossToNewRegion()) { - if (m_requestedSitTargetUUID == UUID.Zero) - { - bool isFlying = Flying; - RemoveFromPhysicalScene(); - - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y * 2; - Velocity = Vector3.Zero; - AbsolutePosition = pos; - - AddToPhysicalScene(isFlying); - } + CrossToNewRegionFail(); } } + */ + bool needsTransit = false; + + if (pos2.X < 0) + needsTransit = true; + else if (pos2.X > m_scene.RegionInfo.RegionSizeX) + needsTransit = true; + else if (pos2.Y < 0) + needsTransit = true; + else if (pos2.Y > m_scene.RegionInfo.RegionSizeY) + needsTransit = true; + + if (needsTransit) + { + if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero) + { + // we don't have entity transfer module + Vector3 pos = AbsolutePosition; + float px = pos.X; + if (px < 0) + pos.X += Velocity.X * 2; + else if (px > m_scene.RegionInfo.RegionSizeX) + pos.X -= Velocity.X * 2; + float py = pos.Y; + if (py < 0) + pos.Y += Velocity.Y * 2; + else if (py > m_scene.RegionInfo.RegionSizeY) + pos.Y -= Velocity.Y * 2; + + Velocity = Vector3.Zero; + AbsolutePosition = pos; + } + } } public void CrossToNewRegionFail() @@ -3988,14 +3978,18 @@ namespace OpenSim.Region.Framework.Scenes RemoveFromPhysicalScene(); Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) + float px = pos.X; + if (px < 0) pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) + else if (px > m_scene.RegionInfo.RegionSizeX) pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) + + float py = pos.Y; + if (py < 0) pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) + else if (py > m_scene.RegionInfo.RegionSizeY) pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; AbsolutePosition = pos; -- cgit v1.1 From 16608ffb01e5eeda3f2122c35d288148c9bed8ca Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 24 Oct 2014 21:51:38 +0100 Subject: don't backup in transit SOGs --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a7e7294..a1cdfa5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2115,7 +2115,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - if (IsDeleted || UUID == UUID.Zero) + if (IsDeleted || inTransit || UUID == UUID.Zero) { // m_log.DebugFormat( // "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); -- cgit v1.1 From d9d58a7b33d07779c2034ec3a2978d716111f7c6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 25 Oct 2014 23:00:41 +0100 Subject: some code reorder/minor changes --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 90 ++++++++++++--------------- 1 file changed, 40 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index dbe0e57..92ce411 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -271,28 +271,40 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_parentScene.CombineRegions) { + // temporary checks to remove after varsize suport + float regionSizeX = m_parentScene.RegionInfo.RegionSizeX; + if (regionSizeX == 0) + regionSizeX = Constants.RegionSize; + float regionSizeY = m_parentScene.RegionInfo.RegionSizeY; + if (regionSizeY == 0) + regionSizeY = Constants.RegionSize; + // KF: Check for out-of-region, move inside and make static. Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, sceneObject.RootPart.GroupPosition.Y, sceneObject.RootPart.GroupPosition.Z); if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || - npos.X > Constants.RegionSize || - npos.Y > Constants.RegionSize)) + npos.X > regionSizeX || + npos.Y > regionSizeY)) { if (npos.X < 0.0) npos.X = 1.0f; if (npos.Y < 0.0) npos.Y = 1.0f; if (npos.Z < 0.0) npos.Z = 0.0f; - if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; - if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; - + if (npos.X > regionSizeX) npos.X = regionSizeX - 1.0f; + if (npos.Y > regionSizeY) npos.Y = regionSizeY - 1.0f; + + SceneObjectPart rootpart = sceneObject.RootPart; + rootpart.GroupPosition = npos; + foreach (SceneObjectPart part in sceneObject.Parts) { + if (part == rootpart) + continue; part.GroupPosition = npos; } - sceneObject.RootPart.Velocity = Vector3.Zero; - sceneObject.RootPart.AngularVelocity = Vector3.Zero; - sceneObject.RootPart.Acceleration = Vector3.Zero; - sceneObject.RootPart.Velocity = Vector3.Zero; + rootpart.Velocity = Vector3.Zero; + rootpart.AngularVelocity = Vector3.Zero; + rootpart.Acceleration = Vector3.Zero; } } @@ -321,7 +333,6 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); @@ -428,9 +439,9 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 scale = part.Shape.Scale; - scale.X = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.X)); - scale.Y = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Y)); - scale.Z = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Z)); + scale.X = Util.Clamp(scale.X, m_parentScene.m_minNonphys, m_parentScene.m_maxNonphys); + scale.Y = Util.Clamp(scale.Y, m_parentScene.m_minNonphys, m_parentScene.m_maxNonphys); + scale.Z = Util.Clamp(scale.Z, m_parentScene.m_minNonphys, m_parentScene.m_maxNonphys); part.Shape.Scale = scale; } @@ -439,26 +450,17 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.AttachToScene(m_parentScene); - Entities.Add(sceneObject); - lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; - lock (SceneObjectGroupsByFullPartID) + foreach (SceneObjectPart part in parts) { - foreach (SceneObjectPart part in parts) + lock (SceneObjectGroupsByFullPartID) SceneObjectGroupsByFullPartID[part.UUID] = sceneObject; - } - lock (SceneObjectGroupsByLocalPartID) - { -// m_log.DebugFormat( -// "[SCENE GRAPH]: Adding scene object {0} {1} {2} to SceneObjectGroupsByLocalPartID in {3}", -// sceneObject.Name, sceneObject.UUID, sceneObject.LocalId, m_parentScene.RegionInfo.RegionName); - - foreach (SceneObjectPart part in parts) + lock (SceneObjectGroupsByLocalPartID) SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; } @@ -475,14 +477,10 @@ namespace OpenSim.Region.Framework.Scenes { // no tests, caller has responsability... lock (SceneObjectGroupsByFullPartID) - { SceneObjectGroupsByFullPartID[part.UUID] = grp; - } lock (SceneObjectGroupsByLocalPartID) - { SceneObjectGroupsByLocalPartID[part.LocalId] = grp; - } } /// @@ -511,25 +509,23 @@ namespace OpenSim.Region.Framework.Scenes if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) RemovePhysicalPrim(grp.PrimCount); } - + + bool ret = Entities.Remove(uuid); + lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID.Remove(grp.UUID); - lock (SceneObjectGroupsByFullPartID) + SceneObjectPart[] parts = grp.Parts; + for (int i = 0; i < parts.Length; i++) { - SceneObjectPart[] parts = grp.Parts; - for (int i = 0; i < parts.Length; i++) + lock (SceneObjectGroupsByFullPartID) SceneObjectGroupsByFullPartID.Remove(parts[i].UUID); - } - lock (SceneObjectGroupsByLocalPartID) - { - SceneObjectPart[] parts = grp.Parts; - for (int i = 0; i < parts.Length; i++) + lock (SceneObjectGroupsByLocalPartID) SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId); } - return Entities.Remove(uuid); + return ret; } /// @@ -2133,21 +2129,15 @@ namespace OpenSim.Region.Framework.Scenes lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID[copy.UUID] = copy; - SceneObjectPart[] children = copy.Parts; - - lock (SceneObjectGroupsByFullPartID) + SceneObjectPart[] parts = copy.Parts; + foreach (SceneObjectPart part in parts) { - SceneObjectGroupsByFullPartID[copy.UUID] = copy; - foreach (SceneObjectPart part in children) + lock (SceneObjectGroupsByFullPartID) SceneObjectGroupsByFullPartID[part.UUID] = copy; - } - - lock (SceneObjectGroupsByLocalPartID) - { - SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; - foreach (SceneObjectPart part in children) + lock (SceneObjectGroupsByLocalPartID) SceneObjectGroupsByLocalPartID[part.LocalId] = copy; } + // PROBABLE END OF FIXME // Since we copy from a source group that is in selected -- cgit v1.1 From 639f128d2cace3a8efd10ffe9b9eba4d85ee7b1e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 01:27:43 +0100 Subject: some cleanup, localID coerence fix.. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 34 +++++----------------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ++-- 2 files changed, 10 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a1cdfa5..dea8f3e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2274,28 +2274,8 @@ namespace OpenSim.Region.Framework.Scenes // new group as no sitting avatars dupe.m_linkedAvatars = new List(); - - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state - - // This is only necessary when userExposed is false! - - bool previousAttachmentStatus = dupe.IsAttachment; - - if (!userExposed) - dupe.IsAttachment = true; - dupe.m_sittingAvatars = new List(); - if (!userExposed) - { - dupe.IsAttachment = previousAttachmentStatus; - } - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; @@ -2318,7 +2298,7 @@ namespace OpenSim.Region.Framework.Scenes { newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); newPart.LinkNum = part.LinkNum; - if (userExposed) +// if (userExposed) newPart.ParentID = dupe.m_rootPart.LocalId; } else @@ -2379,10 +2359,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); - // give newpart a new local ID lettng old part keep same - SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); - newpart.LocalId = m_scene.AllocateLocalId(); + SceneObjectPart newpart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed); +// SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); +// newpart.LocalId = m_scene.AllocateLocalId(); SetRootPart(newpart); if (userExposed) @@ -2601,8 +2580,9 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); - newPart.LocalId = m_scene.AllocateLocalId(); + SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); +// SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); +// newPart.LocalId = m_scene.AllocateLocalId(); AddPart(newPart); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d5377d0..91293c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2132,7 +2132,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// True if the duplicate will immediately be in the scene, false otherwise /// - public SceneObjectPart Copy(uint localID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed) + public SceneObjectPart Copy(uint plocalID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed) { SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone(); dupe.m_shape = m_shape.Copy(); @@ -2178,7 +2178,7 @@ namespace OpenSim.Region.Framework.Scenes } // Move afterwards ResetIDs as it clears the localID - dupe.LocalId = localID; + dupe.LocalId = plocalID; // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. dupe.LastOwnerID = OwnerID; @@ -2208,7 +2208,7 @@ namespace OpenSim.Region.Framework.Scenes } if (dupe.PhysActor != null) - dupe.PhysActor.LocalID = localID; + dupe.PhysActor.LocalID = plocalID; ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); -- cgit v1.1 From 139044fc79844b455574fd0be7baa1bab9bf78d9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 01:25:28 +0000 Subject: keep intransit flag even if deleted, dont set sog position if in transit --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 79 +++++++++++----------- 1 file changed, 38 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index dea8f3e..9f2a689 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -529,7 +529,7 @@ namespace OpenSim.Region.Framework.Scenes set { Vector3 val = value; - + if (Scene != null && !inTransit) { if ( @@ -552,54 +552,55 @@ namespace OpenSim.Region.Framework.Scenes d.BeginInvoke(this, val, CrossAsyncCompleted, d); return; } - } - if (RootPart.GetStatusSandbox()) - { - if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) + + if (RootPart.GetStatusSandbox()) { - RootPart.ScriptSetPhysicsStatus(false); - - if (Scene != null) - Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), - ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); - - return; - } - } + if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) + { + RootPart.ScriptSetPhysicsStatus(false); - bool triggerScriptEvent = m_rootPart.GroupPosition != val; - if (m_dupeInProgress || IsDeleted) - triggerScriptEvent = false; + if (Scene != null) + Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), + ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); - m_rootPart.GroupPosition = val; + return; + } + } - // Restuff the new GroupPosition into each child SOP of the linkset. - // this is needed because physics may not have linksets but just loose SOPs in world + bool triggerScriptEvent = m_rootPart.GroupPosition != val; + if (m_dupeInProgress || IsDeleted) + triggerScriptEvent = false; - SceneObjectPart[] parts = m_parts.GetArray(); + m_rootPart.GroupPosition = val; - foreach (SceneObjectPart part in parts) - { - if (part != m_rootPart) - part.GroupPosition = val; - } + // Restuff the new GroupPosition into each child SOP of the linkset. + // this is needed because physics may not have linksets but just loose SOPs in world - foreach (ScenePresence av in m_linkedAvatars) - { - av.sitSOGmoved(); - } + SceneObjectPart[] parts = m_parts.GetArray(); - // now that position is changed tell it to scripts - if (triggerScriptEvent) - { foreach (SceneObjectPart part in parts) { - part.TriggerScriptChangedEvent(Changed.POSITION); + if (part != m_rootPart) + part.GroupPosition = val; } + + foreach (ScenePresence av in m_linkedAvatars) + { + av.sitSOGmoved(); + } + + // now that position is changed tell it to scripts + if (triggerScriptEvent) + { + foreach (SceneObjectPart part in parts) + { + part.TriggerScriptChangedEvent(Changed.POSITION); + } + } + + Scene.EventManager.TriggerParcelPrimCountTainted(); } - - Scene.EventManager.TriggerParcelPrimCountTainted(); } } @@ -751,11 +752,7 @@ namespace OpenSim.Region.Framework.Scenes SOGCrossDelegate icon = (SOGCrossDelegate)iar.AsyncState; SceneObjectGroup sog = icon.EndInvoke(iar); - if (sog.IsDeleted) - { - sog.inTransit = false; // just in case... - } - else + if (!sog.IsDeleted) { SceneObjectPart rootp = sog.m_rootPart; Vector3 oldp = rootp.GroupPosition; -- cgit v1.1 From 6600282fe99fc1a3c7ff7b80f8aedbac8fe69015 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 10:08:13 +0000 Subject: another try to prevent double crossing --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 98 ++++++++++------------ 1 file changed, 46 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9f2a689..b9b5621 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -530,77 +530,71 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 val = value; - if (Scene != null && !inTransit) + if (!IsAttachmentCheckFull() && !Scene.LoadingPrims && + ( Scene.TestBorderCross(val, Cardinals.E) || + Scene.TestBorderCross(val, Cardinals.W) || + Scene.TestBorderCross(val, Cardinals.N) || + Scene.TestBorderCross(val, Cardinals.S)) + ) { - if ( - // (Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) - // || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) - // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) - // || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) - // Experimental change for better border crossings. - // The commented out original lines above would, it seems, trigger - // a border crossing a little early or late depending on which - // direction the object was moving. - (Scene.TestBorderCross(val, Cardinals.E) - || Scene.TestBorderCross(val, Cardinals.W) - || Scene.TestBorderCross(val, Cardinals.N) - || Scene.TestBorderCross(val, Cardinals.S)) - && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) + lock (m_parts) { - inTransit = true; - SOGCrossDelegate d = CrossAsync; - d.BeginInvoke(this, val, CrossAsyncCompleted, d); + if (!inTransit) + { + inTransit = true; + SOGCrossDelegate d = CrossAsync; + d.BeginInvoke(this, val, CrossAsyncCompleted, d); + } return; } + } - - if (RootPart.GetStatusSandbox()) + if (RootPart.GetStatusSandbox()) + { + if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) { - if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) - { - RootPart.ScriptSetPhysicsStatus(false); + RootPart.ScriptSetPhysicsStatus(false); - if (Scene != null) - Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), - ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); + if (Scene != null) + Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), + ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); - return; - } + return; } + } - bool triggerScriptEvent = m_rootPart.GroupPosition != val; - if (m_dupeInProgress || IsDeleted) - triggerScriptEvent = false; + bool triggerScriptEvent = m_rootPart.GroupPosition != val; + if (m_dupeInProgress || IsDeleted) + triggerScriptEvent = false; - m_rootPart.GroupPosition = val; + m_rootPart.GroupPosition = val; - // Restuff the new GroupPosition into each child SOP of the linkset. - // this is needed because physics may not have linksets but just loose SOPs in world + // Restuff the new GroupPosition into each child SOP of the linkset. + // this is needed because physics may not have linksets but just loose SOPs in world - SceneObjectPart[] parts = m_parts.GetArray(); + SceneObjectPart[] parts = m_parts.GetArray(); - foreach (SceneObjectPart part in parts) - { - if (part != m_rootPart) - part.GroupPosition = val; - } + foreach (SceneObjectPart part in parts) + { + if (part != m_rootPart) + part.GroupPosition = val; + } - foreach (ScenePresence av in m_linkedAvatars) - { - av.sitSOGmoved(); - } + foreach (ScenePresence av in m_linkedAvatars) + { + av.sitSOGmoved(); + } - // now that position is changed tell it to scripts - if (triggerScriptEvent) + // now that position is changed tell it to scripts + if (triggerScriptEvent) + { + foreach (SceneObjectPart part in parts) { - foreach (SceneObjectPart part in parts) - { - part.TriggerScriptChangedEvent(Changed.POSITION); - } + part.TriggerScriptChangedEvent(Changed.POSITION); } - - Scene.EventManager.TriggerParcelPrimCountTainted(); } + + Scene.EventManager.TriggerParcelPrimCountTainted(); } } -- cgit v1.1 From cfc8de096b969633775763051a7d9681b6f2ff77 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 10:48:53 +0000 Subject: remove lock that did nothing, DEBUG disable TriggerOnSceneObjectPreSave --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b9b5621..f0d5d28 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -537,8 +537,6 @@ namespace OpenSim.Region.Framework.Scenes Scene.TestBorderCross(val, Cardinals.S)) ) { - lock (m_parts) - { if (!inTransit) { inTransit = true; @@ -546,7 +544,6 @@ namespace OpenSim.Region.Framework.Scenes d.BeginInvoke(this, val, CrossAsyncCompleted, d); } return; - } } if (RootPart.GetStatusSandbox()) @@ -2191,7 +2188,9 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = false; HasGroupChangedDueToDelink = false; - m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); + +// DEBUG +// m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); /* backup_group.ForEachPart(delegate(SceneObjectPart part) { -- cgit v1.1 From b43ce909aa1bf8be0136b3b7325c9be84939db32 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 11:28:24 +0000 Subject: Debug... ( restored TriggerOnSceneObjectPreSave) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f0d5d28..25538de 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2187,20 +2187,16 @@ namespace OpenSim.Region.Framework.Scenes backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem; HasGroupChanged = false; HasGroupChangedDueToDelink = false; +// debug + if (RootPart.KeyframeMotion != null) + { + m_log.DebugFormat( + "[BACKUP]: test prim {0} {1}, intransit = {2}", + Name, UUID, inTransit); + } + m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); -// DEBUG -// m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); -/* - backup_group.ForEachPart(delegate(SceneObjectPart part) - { - if (part.KeyframeMotion != null) - { - part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); -// part.KeyframeMotion.UpdateSceneObject(this); - } - }); -*/ datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); backup_group.ForEachPart(delegate(SceneObjectPart part) @@ -2262,6 +2258,8 @@ namespace OpenSim.Region.Framework.Scenes dupe.m_isBackedUp = false; dupe.m_parts = new MapAndArray(); + dupe.inTransit = inTransit; // this shouldn't be needed TEST + // new group as no sitting avatars dupe.m_linkedAvatars = new List(); dupe.m_sittingAvatars = new List(); -- cgit v1.1 From 525322efa23966ed3b0e3422ae8ebc52fde6444d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 12:24:12 +0000 Subject: bug fix --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index a3ebe6f..e3f979f 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -785,6 +785,11 @@ namespace OpenSim.Region.Framework.Scenes public Byte[] Serialize() { + bool timerWasStopped; + lock (m_frames) + { + timerWasStopped = m_timerStopped; + } StopTimer(); MemoryStream ms = new MemoryStream(); @@ -795,7 +800,7 @@ namespace OpenSim.Region.Framework.Scenes m_serializedPosition = tmp.AbsolutePosition; fmt.Serialize(ms, this); m_group = tmp; - if (m_running && !m_waitingCrossing) + if (!timerWasStopped && m_running && !m_waitingCrossing) StartTimer(); return ms.ToArray(); -- cgit v1.1 From b07ea475bf0bce2bcd60d7444245e185af2e5740 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 12:30:11 +0000 Subject: delete keyframes on temporary backup group --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 25538de..01c38b9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2202,8 +2202,16 @@ namespace OpenSim.Region.Framework.Scenes backup_group.ForEachPart(delegate(SceneObjectPart part) { part.Inventory.ProcessInventoryBackup(datastore); + + // take the change to delete things + if(part.KeyframeMotion != null) + { + part.KeyframeMotion.Delete(); + part.KeyframeMotion = null; + } }); + backup_group = null; } // else -- cgit v1.1 From bc4d0179b31a3c8778477f97d618ba779638f3f0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Oct 2014 12:38:22 +0000 Subject: remove debug message --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 01c38b9..0e2e3c7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2187,13 +2187,6 @@ namespace OpenSim.Region.Framework.Scenes backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem; HasGroupChanged = false; HasGroupChangedDueToDelink = false; -// debug - if (RootPart.KeyframeMotion != null) - { - m_log.DebugFormat( - "[BACKUP]: test prim {0} {1}, intransit = {2}", - Name, UUID, inTransit); - } m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); -- cgit v1.1 From e4d84d8ff6595d124485921e36d62508660c996f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 28 Oct 2014 13:52:00 +0000 Subject: try to make a avatar usesable if its siting part didn't cross, or crossed back. This situation points to that sitted avatars should be sent in same http connection that crosses the object --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 98 +++--------------------- 1 file changed, 12 insertions(+), 86 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 56c3b52..c58847b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1126,7 +1126,7 @@ namespace OpenSim.Region.Framework.Scenes ParentID = 0; ParentPart = null; PrevSitOffset = Vector3.Zero; - ClearControls(); + HandleForceReleaseControls(ControllingClient, UUID); // needs testing IsLoggingIn = false; } else @@ -1211,6 +1211,7 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = pos; + if (m_teleportFlags == TeleportFlags.Default) { Vector3 vel = Velocity; @@ -1221,6 +1222,7 @@ namespace OpenSim.Region.Framework.Scenes else AddToPhysicalScene(isFlying); + if (ForceFly) { Flying = true; @@ -3862,91 +3864,15 @@ namespace OpenSim.Region.Framework.Scenes pos2.Y += vel.Y * timeStep; pos2.Z += vel.Z * timeStep; - // m_log.DebugFormat( - // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", - // pos2, Name, Scene.Name); -/* - // Checks if where it's headed exists a region - int neighbor = 0; - int[] fix = new int[2]; - - bool needsTransit = false; - if (m_scene.TestBorderCross(pos2, Cardinals.W)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); - } - else - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.E)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); - } - else - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); - } - - // Makes sure avatar does not end up outside region - - if (neighbor <= 0) - { - if (needsTransit) - { - CrossToNewRegionFail(); - } - } - else if (neighbor > 0) - { - if (!CrossToNewRegion()) - { - CrossToNewRegionFail(); - } - } - */ - bool needsTransit = false; - - if (pos2.X < 0) - needsTransit = true; - else if (pos2.X > m_scene.RegionInfo.RegionSizeX) - needsTransit = true; - else if (pos2.Y < 0) - needsTransit = true; - else if (pos2.Y > m_scene.RegionInfo.RegionSizeY) - needsTransit = true; - - if (needsTransit) +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", +// pos2, Name, Scene.Name); + + if( Scene.TestBorderCross(pos2, Cardinals.E) || + Scene.TestBorderCross(pos2, Cardinals.W) || + Scene.TestBorderCross(pos2, Cardinals.N) || + Scene.TestBorderCross(pos2, Cardinals.S) + ) { if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero) { -- cgit v1.1 From 3afd64f2f77a1460bb03ee1d4a43fea67e8e5005 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 30 Oct 2014 01:29:03 +0100 Subject: Fix a script load issue --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index d2e41f8..d70aa45 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1946,7 +1946,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - if (destPart.ScriptAccessPin != pin) + if (destPart.ScriptAccessPin == 0 || destPart.ScriptAccessPin != pin) { m_log.WarnFormat( "[PRIM INVENTORY]: " + -- cgit v1.1 From 37a5eab0f5eb51204a3d6bc0bbaa40a2b9afc989 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 3 Nov 2014 00:03:53 +0000 Subject: BUG FIX prevent references to null scene (as happens on mesh uploads) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0e2e3c7..9a2707b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -529,21 +529,21 @@ namespace OpenSim.Region.Framework.Scenes set { Vector3 val = value; - - if (!IsAttachmentCheckFull() && !Scene.LoadingPrims && - ( Scene.TestBorderCross(val, Cardinals.E) || + if (Scene != null && !IsAttachmentCheckFull() + && !Scene.LoadingPrims && + (Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) ) { - if (!inTransit) - { - inTransit = true; - SOGCrossDelegate d = CrossAsync; - d.BeginInvoke(this, val, CrossAsyncCompleted, d); - } - return; + if (!inTransit) + { + inTransit = true; + SOGCrossDelegate d = CrossAsync; + d.BeginInvoke(this, val, CrossAsyncCompleted, d); + } + return; } if (RootPart.GetStatusSandbox()) @@ -582,6 +582,7 @@ namespace OpenSim.Region.Framework.Scenes av.sitSOGmoved(); } + // now that position is changed tell it to scripts if (triggerScriptEvent) { @@ -591,7 +592,9 @@ namespace OpenSim.Region.Framework.Scenes } } - Scene.EventManager.TriggerParcelPrimCountTainted(); + if (Scene != null) + Scene.EventManager.TriggerParcelPrimCountTainted(); + } } @@ -789,7 +792,7 @@ namespace OpenSim.Region.Framework.Scenes { if (agent.ParentUUID != UUID.Zero) { - agent.ClearControls(); + agent.HandleForceReleaseControls(agent.ControllingClient,agent.UUID); agent.ParentPart = null; // agent.ParentPosition = Vector3.Zero; // agent.ParentUUID = UUID.Zero; -- cgit v1.1 From a6ffcbb7f9466ff9b254d8a814010415c1829d5f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 3 Nov 2014 00:56:48 +0000 Subject: always write physicsShapeType on sop serialization since default value can't be guessed in some cases --- OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 52bd5c9..40e88f1 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1415,8 +1415,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (sop.VehicleParams != null) sop.VehicleParams.ToXml2(writer); - if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) - writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); + writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); if (sop.Density != 1000.0f) writer.WriteElementString("Density", sop.Density.ToString().ToLower()); if (sop.Friction != 0.6f) -- cgit v1.1 From ead78764abfe3d91f79b55ec200bd0d5e8ca2151 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 6 Nov 2014 19:03:25 +0000 Subject: allow drawdistance to change between 32 and MaxDrawDistance, configurable value default to 256, so should have no effect. Next steps needed: reduce client udp Throttles with distance, update childreen connections with significat movement and view range changes, Make disconnect be delayed in time, make disconnects be receiving region action not sender on region changes. Allow distance less than 256 to only connect to visible regions, even none. Make this be relative to camera and not agent position or region centers as it is now. --- OpenSim/Region/Framework/Scenes/Scene.cs | 15 ++++++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9e2f52c..eb34f55 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -227,6 +227,13 @@ namespace OpenSim.Region.Framework.Scenes get { return m_defaultDrawDistance; } } +// protected float m_maxDrawDistance = 512.0f; + protected float m_maxDrawDistance = 256.0f; + public float MaxDrawDistance + { + get { return m_maxDrawDistance; } + } + private List m_AllowedViewers = new List(); private List m_BannedViewers = new List(); @@ -862,7 +869,8 @@ namespace OpenSim.Region.Framework.Scenes StartDisabled = startupConfig.GetBoolean("StartDisabled", false); - m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); + m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); + m_defaultDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); if (!UseBackup) m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); @@ -1069,7 +1077,7 @@ namespace OpenSim.Region.Framework.Scenes BordersLocked = true; Border northBorder = new Border(); - northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- + northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, RegionInfo.RegionSizeY); //<--- northBorder.CrossDirection = Cardinals.N; NorthBorders.Add(northBorder); @@ -1079,7 +1087,7 @@ namespace OpenSim.Region.Framework.Scenes SouthBorders.Add(southBorder); Border eastBorder = new Border(); - eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- + eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, RegionInfo.RegionSizeX); //<--- eastBorder.CrossDirection = Cardinals.E; EastBorders.Add(eastBorder); @@ -1092,6 +1100,7 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); + } #endregion diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c58847b..6a9e0ca 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2061,8 +2061,10 @@ namespace OpenSim.Region.Framework.Scenes // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the // region's draw distance. - // DrawDistance = agentData.Far; - DrawDistance = Scene.DefaultDrawDistance; + + DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance); + +// DrawDistance = Scene.DefaultDrawDistance; m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; @@ -2417,8 +2419,7 @@ namespace OpenSim.Region.Framework.Scenes // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the // region's draw distance. - // DrawDistance = agentData.Far; - DrawDistance = Scene.DefaultDrawDistance; + DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance); // Check if Client has camera in 'follow cam' or 'build' mode. Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); @@ -4011,6 +4012,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ulong handle in byebyeRegions) { RemoveNeighbourRegion(handle); + Scene.CapsModule.DropChildSeed(UUID, handle); } } @@ -4087,8 +4089,8 @@ namespace OpenSim.Region.Framework.Scenes // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the // region's draw distance. - // DrawDistance = cAgentData.Far; - DrawDistance = Scene.DefaultDrawDistance; + DrawDistance = cAgentData.Far; +// DrawDistance = Scene.DefaultDrawDistance; if (cAgentData.Position != marker) // UGH!! m_pos = cAgentData.Position + offset; @@ -4204,8 +4206,8 @@ namespace OpenSim.Region.Framework.Scenes // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the // region's draw distance. - // DrawDistance = cAgent.Far; - DrawDistance = Scene.DefaultDrawDistance; + DrawDistance = cAgent.Far; + //DrawDistance = Scene.DefaultDrawDistance; if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0) { -- cgit v1.1 From caddabb5c4f62767305a589e9d818ae3457a8030 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 6 Nov 2014 22:25:16 +0000 Subject: scale ChildAgentThrottles with distance (internal to child server and not root as was done before ) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6a9e0ca..3b64088 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4104,7 +4104,24 @@ namespace OpenSim.Region.Framework.Scenes CameraPosition = cAgentData.Center + offset; if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); + { + // some scaling factor + float x = m_pos.X; + if (x > m_scene.RegionInfo.RegionSizeX) + x -= m_scene.RegionInfo.RegionSizeX; + float y = m_pos.Y; + if (y > m_scene.RegionInfo.RegionSizeY) + y -= m_scene.RegionInfo.RegionSizeY; + + x = x * x + y * y; + + const float distScale = 0.4f / Constants.RegionSize / Constants.RegionSize; + float factor = 1.0f - distScale * x; + if (factor < 0.2f) + factor = 0.2f; + + ControllingClient.SetChildAgentThrottle(cAgentData.Throttles,factor); + } if(cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count >0) { -- cgit v1.1 From fdb05984464fa1450dff953da2230d5c9c5df2c5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 8 Nov 2014 00:25:44 +0000 Subject: remove duplicated lines --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cd8c9a5..746a5ce 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2096,9 +2096,6 @@ namespace OpenSim.Region.Framework.Scenes // If child prims have invalid perms, fix them grp.AdjustChildPrimPermissions(); - // If child prims have invalid perms, fix them - grp.AdjustChildPrimPermissions(); - if (remoteClient == null) { // Autoreturn has a null client. Nothing else does. So -- cgit v1.1 From 6d2e924f248941e34919b62fe383415d7e255370 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 10 Nov 2014 04:46:51 +0100 Subject: Call the bake module each time we see a new attachment to see if the attachment needs textures --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3b64088..7086b52 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4583,6 +4583,10 @@ namespace OpenSim.Region.Framework.Scenes m_attachments.Add(gobj); } + + IBakedTextureModule bakedModule = m_scene.RequestModuleInterface(); + if (bakedModule != null) + bakedModule.UpdateMeshAvatar(m_uuid); } /// -- cgit v1.1 From 64deb6ae6fdf586bcd2e940d3cbf3ee54367dc83 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 10 Nov 2014 19:49:58 +0100 Subject: Second part of invisible base avatar option --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7086b52..5a3e554 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -90,6 +90,7 @@ namespace OpenSim.Region.Framework.Scenes public bool isNPC { get; private set; } + public bool Invisible { get; set; } private PresenceType m_presenceType; public PresenceType PresenceType { get {return m_presenceType;} @@ -949,6 +950,7 @@ namespace OpenSim.Region.Framework.Scenes public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { + Invisible = false; AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; @@ -3709,14 +3711,17 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) return; - avatar.ControllingClient.SendAppearance( - UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); + SendAppearanceToAgentNF(avatar); } public void SendAppearanceToAgentNF(ScenePresence avatar) { - avatar.ControllingClient.SendAppearance( - UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); + if (Invisible) + avatar.ControllingClient.SendAppearance( + UUID, Appearance.VisualParams, AvatarAppearance.Invisible.GetBytes()); + else + avatar.ControllingClient.SendAppearance( + UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); } public void SendAnimPackToAgent(ScenePresence p) -- cgit v1.1 From bec456c2a529ca0b9ca7fd59e8110e5d5b27c126 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 11 Nov 2014 07:09:30 +0100 Subject: Remove the Invisible stuff and add more baked caching. Refactor selection of textures to save to Bakes module. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5a3e554..cd9dcf5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -90,7 +90,6 @@ namespace OpenSim.Region.Framework.Scenes public bool isNPC { get; private set; } - public bool Invisible { get; set; } private PresenceType m_presenceType; public PresenceType PresenceType { get {return m_presenceType;} @@ -950,7 +949,6 @@ namespace OpenSim.Region.Framework.Scenes public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { - Invisible = false; AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; @@ -3716,12 +3714,8 @@ namespace OpenSim.Region.Framework.Scenes public void SendAppearanceToAgentNF(ScenePresence avatar) { - if (Invisible) - avatar.ControllingClient.SendAppearance( - UUID, Appearance.VisualParams, AvatarAppearance.Invisible.GetBytes()); - else - avatar.ControllingClient.SendAppearance( - UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); + avatar.ControllingClient.SendAppearance( + UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); } public void SendAnimPackToAgent(ScenePresence p) -- cgit v1.1 From b4a91f5dde928154675da227ae70444bdc12a8bc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Nov 2014 16:43:56 +0000 Subject: return bbox and offsetHeight to RezObject --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 ++++-- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 9 ++++----- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 746a5ce..abf19d8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2470,8 +2470,10 @@ namespace OpenSim.Region.Framework.Scenes List objlist; List veclist; - - bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist); + Vector3 bbox; + float offsetHeight; + + bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist,out bbox, out offsetHeight); if (!success) return null; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2fa9139..b9f3f94 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -871,7 +871,7 @@ namespace OpenSim.Region.Framework.Scenes return items; } - public bool GetRezReadySceneObjects(TaskInventoryItem item, out List objlist, out List veclist) + public bool GetRezReadySceneObjects(TaskInventoryItem item, out List objlist, out List veclist, out Vector3 bbox, out float offsetHeight) { AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); @@ -882,12 +882,11 @@ namespace OpenSim.Region.Framework.Scenes item.AssetID, item.Name, m_part.Name); objlist = null; veclist = null; + bbox = Vector3.Zero; + offsetHeight = 0; return false; } - - Vector3 bbox; - float offsetHeight; - + bool single = m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); for (int i = 0; i < objlist.Count; i++) -- cgit v1.1 From 7bcb68d7c496cdf2979918a12cb9dc4929bfcdc3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Nov 2014 16:59:11 +0000 Subject: some steps to rez center or root of prim inventory object at requested position ( does nothing diferent still ) --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 +++-- OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index abf19d8..9721edb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2447,7 +2447,7 @@ namespace OpenSim.Region.Framework.Scenes RayStart, RayEnd, RayTargetID, Quaternion.Identity, BypassRayCast, bRayEndIsIntersection, true, scale, false); - RezObject(part, item, pos, null, Vector3.Zero, 0); + RezObject(part, item, pos, null, Vector3.Zero, 0, false); } } @@ -2463,7 +2463,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful public virtual List RezObject( - SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) + SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param, bool atRoot) { if (null == item) return null; @@ -2474,6 +2474,7 @@ namespace OpenSim.Region.Framework.Scenes float offsetHeight; bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist,out bbox, out offsetHeight); + if (!success) return null; diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 6e0ea7d..020bb6c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Tests Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f); Vector3 rezVel = new Vector3(2, 2, 2); - scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0); + scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0,false); SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso"); -- cgit v1.1 From bb5ab05482c2eb3b8d6c0ae41f54866f41105033 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Nov 2014 18:20:30 +0000 Subject: fix rez position being for root or center for a single object case --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9721edb..1dd3d2f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2491,6 +2491,28 @@ namespace OpenSim.Region.Framework.Scenes sourcePart.Inventory.RemoveInventoryItem(item.ItemID); } + SceneObjectGroup sog; + // position adjust + if (totalPrims > 1) // nothing to do on a single prim + { + if (objlist.Count == 1) + { + // current object position is root position + if(!atRoot) + { + sog = objlist[0]; + Quaternion orot; + if (rot == null) + orot = sog.RootPart.GetWorldRotation(); + else + orot = rot.Value; + Vector3 off = sog.GetGeometricCenter(); + off *= orot; + pos -= off; + } + } + } + for (int i = 0; i < objlist.Count; i++) { SceneObjectGroup group = objlist[i]; -- cgit v1.1 From 6bebb9206cc0ec966f75ab52c76c66b4546d730f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Nov 2014 20:11:16 +0000 Subject: fix stopMoveToTarget in attachments case ( similar to core fix) --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9a2707b..89c7a1a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2468,12 +2468,23 @@ namespace OpenSim.Region.Framework.Scenes public void stopMoveToTarget() { - PhysicsActor pa = RootPart.PhysActor; + if (IsAttachment) + { + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); + if (avatar != null) + { + avatar.ResetMoveToTarget(); + } + } + else + { + PhysicsActor pa = RootPart.PhysActor; - if (pa != null) - pa.PIDActive = false; + if (pa != null) + pa.PIDActive = false; - RootPart.ScheduleTerseUpdate(); // send a stop information + RootPart.ScheduleTerseUpdate(); // send a stop information + } } public void rotLookAt(Quaternion target, float strength, float damping) -- cgit v1.1 From e8d67af3e17a0e2f7b87bcc4e22fd519c549dca9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 27 Nov 2014 23:32:24 +0000 Subject: change/fix rez position and rotation on llRezObject and llRezAtRoot --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 51 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1dd3d2f..b45cc4d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2492,6 +2492,10 @@ namespace OpenSim.Region.Framework.Scenes } SceneObjectGroup sog; + + bool fixrot = false; + Quaternion netRot = Quaternion.Identity; + // position adjust if (totalPrims > 1) // nothing to do on a single prim { @@ -2506,17 +2510,50 @@ namespace OpenSim.Region.Framework.Scenes orot = sog.RootPart.GetWorldRotation(); else orot = rot.Value; + // possible should be bbox, but geometric center looks better Vector3 off = sog.GetGeometricCenter(); +// Vector3 off = bbox * 0.5f; off *= orot; pos -= off; } } + else + { + //veclist[] are relative to bbox corner with min X,Y and Z + // rez at root, and rot will be referenced to first object in list + if (rot == null) + { + // use original rotations + if (atRoot) + pos -= veclist[0]; + else + pos -= bbox / 2; + } + else + { + fixrot = true; + sog = objlist[0]; + netRot = Quaternion.Conjugate(sog.RootPart.GetWorldRotation()); + netRot = netRot * rot.Value; + Vector3 off; + if (atRoot) + off = veclist[0]; + else + off = bbox / 2; + off *= netRot; + pos -= off; + } + } } for (int i = 0; i < objlist.Count; i++) { SceneObjectGroup group = objlist[i]; - Vector3 curpos = pos + veclist[i]; + Vector3 curpos; + if(fixrot) + curpos = pos + veclist[i] * netRot; + else + curpos = pos + veclist[i]; if (group.IsAttachment == false && group.RootPart.Shape.State != 0) { @@ -2525,7 +2562,17 @@ namespace OpenSim.Region.Framework.Scenes } group.FromPartID = sourcePart.UUID; - AddNewSceneObject(group, true, curpos, rot, vel); + if( i == 0) + AddNewSceneObject(group, true, curpos, rot, vel); + else + { + Quaternion crot = objlist[i].RootPart.GetWorldRotation(); + if (fixrot) + { + crot *= netRot; + } + AddNewSceneObject(group, true, curpos, crot, vel); + } // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. -- cgit v1.1 From 9f18e3ba80a6469b7ff03c7cca595a0a3b999592 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 22 Mar 2015 21:53:02 -0700 Subject: Varregion: first cut at removing Border class checks for region crossings. Added Scene.PositionIsInCurrentRegion(pos) to sense when new position needs some crossing work. Many changes made to EntityTransferModule to accomodate new crossing sense logic. --- OpenSim/Region/Framework/Scenes/Scene.cs | 325 ++------------------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 10 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 60 ++-- 4 files changed, 51 insertions(+), 349 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eb34f55..03270d7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -160,11 +160,6 @@ namespace OpenSim.Region.Framework.Scenes /// public SimStatsReporter StatsReporter { get; private set; } - public List NorthBorders = new List(); - public List EastBorders = new List(); - public List SouthBorders = new List(); - public List WestBorders = new List(); - /// /// Controls whether physics can be applied to prims. Even if false, prims still have entries in a /// PhysicsScene in order to perform collision detection @@ -364,7 +359,6 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Possibly stop other classes being able to manipulate this directly. private SceneGraph m_sceneGraph; - private volatile int m_bordersLocked; private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing private volatile bool m_backingup; private Dictionary m_returns = new Dictionary(); @@ -446,18 +440,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_splitRegionID = value; } } - public bool BordersLocked - { - get { return m_bordersLocked == 1; } - set - { - if (value == true) - m_bordersLocked = 1; - else - m_bordersLocked = 0; - } - } - public new float TimeDilation { get { return m_sceneGraph.PhysicsScene.TimeDilation; } @@ -1075,28 +1057,6 @@ namespace OpenSim.Region.Framework.Scenes PeriodicBackup = true; UseBackup = true; - BordersLocked = true; - Border northBorder = new Border(); - northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, RegionInfo.RegionSizeY); //<--- - northBorder.CrossDirection = Cardinals.N; - NorthBorders.Add(northBorder); - - Border southBorder = new Border(); - southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //---> - southBorder.CrossDirection = Cardinals.S; - SouthBorders.Add(southBorder); - - Border eastBorder = new Border(); - eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, RegionInfo.RegionSizeX); //<--- - eastBorder.CrossDirection = Cardinals.E; - EastBorders.Add(eastBorder); - - Border westBorder = new Border(); - westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //---> - westBorder.CrossDirection = Cardinals.W; - WestBorders.Add(westBorder); - BordersLocked = false; - m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); @@ -2611,185 +2571,35 @@ namespace OpenSim.Region.Framework.Scenes EntityTransferModule.Cross(grp, attemptedPosition, silent); } - public Border GetCrossedBorder(Vector3 position, Cardinals gridline) + // Simple test to see if a position is in the current region. + // This test is mostly used to see if a region crossing is necessary. + // Assuming the position is relative to the region so anything outside its bounds. + // Return 'true' if position inside region. + public bool PositionIsInCurrentRegion(Vector3 pos) { - if (BordersLocked) - { - switch (gridline) - { - case Cardinals.N: - lock (NorthBorders) - { - foreach (Border b in NorthBorders) - { - if (b.TestCross(position)) - return b; - } - } - break; - case Cardinals.S: - lock (SouthBorders) - { - foreach (Border b in SouthBorders) - { - if (b.TestCross(position)) - return b; - } - } - - break; - case Cardinals.E: - lock (EastBorders) - { - foreach (Border b in EastBorders) - { - if (b.TestCross(position)) - return b; - } - } - - break; - case Cardinals.W: - - lock (WestBorders) - { - foreach (Border b in WestBorders) - { - if (b.TestCross(position)) - return b; - } - } - break; + bool ret = false; + int xx = (int)Math.Floor(pos.X); + int yy = (int)Math.Floor(pos.Y); + if (xx < 0 || yy < 0) + return false; - } + IRegionCombinerModule regionCombinerModule = RequestModuleInterface(); + if (regionCombinerModule == null) + { + // Regular region. Just check for region size + if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) + ret = true; } else { - switch (gridline) - { - case Cardinals.N: - foreach (Border b in NorthBorders) - { - if (b.TestCross(position)) - return b; - } - - break; - case Cardinals.S: - foreach (Border b in SouthBorders) - { - if (b.TestCross(position)) - return b; - } - break; - case Cardinals.E: - foreach (Border b in EastBorders) - { - if (b.TestCross(position)) - return b; - } - - break; - case Cardinals.W: - foreach (Border b in WestBorders) - { - if (b.TestCross(position)) - return b; - } - break; - - } + // We're in a mega-region so see if we are still in that larger region + ret = regionCombinerModule.PositionIsInMegaregion(this.RegionInfo.RegionID, xx, yy); } - return null; - } + return ret; - public bool TestBorderCross(Vector3 position, Cardinals border) - { - if (BordersLocked) - { - switch (border) - { - case Cardinals.N: - lock (NorthBorders) - { - foreach (Border b in NorthBorders) - { - if (b.TestCross(position)) - return true; - } - } - break; - case Cardinals.E: - lock (EastBorders) - { - foreach (Border b in EastBorders) - { - if (b.TestCross(position)) - return true; - } - } - break; - case Cardinals.S: - lock (SouthBorders) - { - foreach (Border b in SouthBorders) - { - if (b.TestCross(position)) - return true; - } - } - break; - case Cardinals.W: - lock (WestBorders) - { - foreach (Border b in WestBorders) - { - if (b.TestCross(position)) - return true; - } - } - break; - } - } - else - { - switch (border) - { - case Cardinals.N: - foreach (Border b in NorthBorders) - { - if (b.TestCross(position)) - return true; - } - break; - case Cardinals.E: - foreach (Border b in EastBorders) - { - if (b.TestCross(position)) - return true; - } - break; - case Cardinals.S: - foreach (Border b in SouthBorders) - { - if (b.TestCross(position)) - return true; - } - break; - case Cardinals.W: - foreach (Border b in WestBorders) - { - if (b.TestCross(position)) - return true; - } - break; - } - } - return false; } - /// /// Called when objects or attachments cross the border, or teleport, between regions. /// @@ -4116,60 +3926,11 @@ namespace OpenSim.Region.Framework.Scenes { // CleanDroppedAttachments(); - if (TestBorderCross(acd.startpos, Cardinals.E)) - { - Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); - acd.startpos.X = crossedBorder.BorderLine.Z - 1; - } - - if (TestBorderCross(acd.startpos, Cardinals.N)) - { - Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.N); - acd.startpos.Y = crossedBorder.BorderLine.Z - 1; - } - - //Mitigate http://opensimulator.org/mantis/view.php?id=3522 - // Check if start position is outside of region - // If it is, check the Z start position also.. if not, leave it alone. - if (BordersLocked) - { - lock (EastBorders) - { - if (acd.startpos.X > EastBorders[0].BorderLine.Z) - { - m_log.Warn("FIX AGENT POSITION"); - acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f; - if (acd.startpos.Z > 720) - acd.startpos.Z = 720; - } - } - lock (NorthBorders) - { - if (acd.startpos.Y > NorthBorders[0].BorderLine.Z) - { - m_log.Warn("FIX Agent POSITION"); - acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f; - if (acd.startpos.Z > 720) - acd.startpos.Z = 720; - } - } - } else - { - if (acd.startpos.X > EastBorders[0].BorderLine.Z) - { - m_log.Warn("FIX AGENT POSITION"); - acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f; - if (acd.startpos.Z > 720) - acd.startpos.Z = 720; - } - if (acd.startpos.Y > NorthBorders[0].BorderLine.Z) - { - m_log.Warn("FIX Agent POSITION"); - acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f; - if (acd.startpos.Z > 720) - acd.startpos.Z = 720; - } - } + // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking) + if (acd.startpos.X < 0) acd.startpos.X = 1f; + if (acd.startpos.X >= RegionInfo.RegionSizeX) acd.startpos.X = RegionInfo.RegionSizeX - 1f; + if (acd.startpos.Y < 0) acd.startpos.Y = 1f; + if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f; // m_log.DebugFormat( // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", @@ -4883,44 +4644,6 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = GetScenePresence(remoteClient.AgentId); if (sp != null) { - uint regionX = RegionInfo.RegionLocX; - uint regionY = RegionInfo.RegionLocY; - - Utils.LongToUInts(regionHandle, out regionX, out regionY); - - int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; - int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; - - position.X += shiftx; - position.Y += shifty; - - bool result = false; - - if (TestBorderCross(position,Cardinals.N)) - result = true; - - if (TestBorderCross(position, Cardinals.S)) - result = true; - - if (TestBorderCross(position, Cardinals.E)) - result = true; - - if (TestBorderCross(position, Cardinals.W)) - result = true; - - // bordercross if position is outside of region - - if (!result) - { - regionHandle = RegionInfo.RegionHandle; - } - else - { - // not in this region, undo the shift! - position.X -= shiftx; - position.Y -= shifty; - } - if (EntityTransferModule != null) { EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 89c7a1a..a99e469 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -529,12 +529,10 @@ namespace OpenSim.Region.Framework.Scenes set { Vector3 val = value; - if (Scene != null && !IsAttachmentCheckFull() - && !Scene.LoadingPrims && - (Scene.TestBorderCross(val, Cardinals.E) || - Scene.TestBorderCross(val, Cardinals.W) || - Scene.TestBorderCross(val, Cardinals.N) || - Scene.TestBorderCross(val, Cardinals.S)) + if (Scene != null + && Scene.PositionIsInCurrentRegion(val) + && !IsAttachmentCheckFull() + && !Scene.LoadingPrims ) { if (!inTransit) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 91293c4..8979659 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2979,10 +2979,7 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); - if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) - || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) - || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) - || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) + if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos)) { ParentGroup.AbsolutePosition = newpos; return; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd9dcf5..2965903 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1170,18 +1170,6 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID == 0) { - if (m_scene.TestBorderCross(pos, Cardinals.E)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); - pos.X = crossedBorder.BorderLine.Z - 1; - } - - if (m_scene.TestBorderCross(pos, Cardinals.N)) - { - Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); - pos.Y = crossedBorder.BorderLine.Z - 1; - } - CheckAndAdjustLandingPoint(ref pos); if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) @@ -3867,32 +3855,28 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", // pos2, Name, Scene.Name); - - if( Scene.TestBorderCross(pos2, Cardinals.E) || - Scene.TestBorderCross(pos2, Cardinals.W) || - Scene.TestBorderCross(pos2, Cardinals.N) || - Scene.TestBorderCross(pos2, Cardinals.S) - ) - { - if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero) - { - // we don't have entity transfer module - Vector3 pos = AbsolutePosition; - float px = pos.X; - if (px < 0) - pos.X += Velocity.X * 2; - else if (px > m_scene.RegionInfo.RegionSizeX) - pos.X -= Velocity.X * 2; - - float py = pos.Y; - if (py < 0) - pos.Y += Velocity.Y * 2; - else if (py > m_scene.RegionInfo.RegionSizeY) - pos.Y -= Velocity.Y * 2; - - Velocity = Vector3.Zero; - AbsolutePosition = pos; - } + + if (Scene.PositionIsInCurrentRegion(pos2)) + return; + + if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero) + { + // we don't have entity transfer module + Vector3 pos = AbsolutePosition; + float px = pos.X; + if (px < 0) + pos.X += Velocity.X * 2; + else if (px > m_scene.RegionInfo.RegionSizeX) + pos.X -= Velocity.X * 2; + + float py = pos.Y; + if (py < 0) + pos.Y += Velocity.Y * 2; + else if (py > m_scene.RegionInfo.RegionSizeY) + pos.Y -= Velocity.Y * 2; + + Velocity = Vector3.Zero; + AbsolutePosition = pos; } } -- cgit v1.1 From 752901c5f4d8f7d4c19839d9b053dfded2205f5b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 24 Mar 2015 01:37:14 +0100 Subject: Make attachment rezzing async again for NPC. Doing that sync causes a deadlock with the script thread. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd9dcf5..dff582b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1855,7 +1855,12 @@ namespace OpenSim.Region.Framework.Scenes // Util.FireAndForget( // o => // { - Scene.AttachmentsModule.RezAttachments(this); + if (!isNPC) + Scene.AttachmentsModule.RezAttachments(this); + else + Util.FireAndForget(x => { + Scene.AttachmentsModule.RezAttachments(this); + }); // }); } else -- cgit v1.1 From bedafb8fae9898ef0c5fc6470236ee7244e616a9 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 27 Mar 2015 19:32:50 -0700 Subject: varregion: refactor use of 'double heightmap[,]' into references to new class TerrainData and push the implementation from Scene into the database readers and writers. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 352 +++++++++++++++------- 2 files changed, 248 insertions(+), 108 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 03270d7..f5458c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1935,7 +1935,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); + TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); if (map == null) { // This should be in the Terrain module, but it isn't because @@ -1946,7 +1946,7 @@ namespace OpenSim.Region.Framework.Scenes m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); - Heightmap = new TerrainChannel(m_InitialTerrain); + Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); } diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index b6e0a97..3d563a6 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -25,14 +25,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; using System; +using System.IO; using System.Text; +using System.Reflection; using System.Xml; -using System.IO; using System.Xml.Serialization; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; + +using OpenMetaverse; + +using log4net; + namespace OpenSim.Region.Framework.Scenes { /// @@ -40,140 +47,136 @@ namespace OpenSim.Region.Framework.Scenes /// public class TerrainChannel : ITerrainChannel { - private readonly bool[,] taint; - private double[,] map; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static string LogHeader = "[TERRAIN CHANNEL]"; + protected TerrainData m_terrainData; + + public int Width { get { return m_terrainData.SizeX; } } // X dimension + // Unfortunately, for historical reasons, in this module 'Width' is X and 'Height' is Y + public int Height { get { return m_terrainData.SizeY; } } // Y dimension + public int Altitude { get { return m_terrainData.SizeZ; } } // Y dimension + + // Default, not-often-used builder public TerrainChannel() { - map = new double[Constants.RegionSize, Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; - - PinHeadIsland(); + m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); + FlatLand(); + // PinHeadIsland(); } - public TerrainChannel(String type) + // Create terrain of given size + public TerrainChannel(int pX, int pY) { - map = new double[Constants.RegionSize, Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; + m_terrainData = new HeightmapTerrainData(pX, pY, (int)Constants.RegionHeight); + } + // Create terrain of specified size and initialize with specified terrain. + // TODO: join this with the terrain initializers. + public TerrainChannel(String type, int pX, int pY, int pZ) + { + m_terrainData = new HeightmapTerrainData(pX, pY, pZ); if (type.Equals("flat")) FlatLand(); else PinHeadIsland(); } - public TerrainChannel(double[,] import) + // Create channel passed a heightmap and expected dimensions of the region. + // The heightmap might not fit the passed size so accomodations must be made. + public TerrainChannel(double[,] pM, int pSizeX, int pSizeY, int pAltitude) { - map = import; - taint = new bool[import.GetLength(0),import.GetLength(1)]; - } + int hmSizeX = pM.GetLength(0); + int hmSizeY = pM.GetLength(1); - public TerrainChannel(bool createMap) - { - if (createMap) - { - map = new double[Constants.RegionSize,Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; - } + m_terrainData = new HeightmapTerrainData(pSizeX, pSizeY, pAltitude); + + for (int xx = 0; xx < pSizeX; xx++) + for (int yy = 0; yy < pSizeY; yy++) + if (xx > hmSizeX || yy > hmSizeY) + m_terrainData[xx, yy] = TerrainData.DefaultTerrainHeight; + else + m_terrainData[xx, yy] = (float)pM[xx, yy]; } - public TerrainChannel(int w, int h) + public TerrainChannel(TerrainData pTerrData) { - map = new double[w,h]; - taint = new bool[w / 16,h / 16]; + m_terrainData = pTerrData; } #region ITerrainChannel Members - public int Width + // ITerrainChannel.MakeCopy() + public ITerrainChannel MakeCopy() { - get { return map.GetLength(0); } + return this.Copy(); } - public int Height + // ITerrainChannel.GetTerrainData() + public TerrainData GetTerrainData() { - get { return map.GetLength(1); } + return m_terrainData; } - public ITerrainChannel MakeCopy() + // ITerrainChannel.GetFloatsSerialized() + // This one dimensional version is ordered so height = map[y*sizeX+x]; + // DEPRECATED: don't use this function as it does not retain the dimensions of the terrain + // and the caller will probably do the wrong thing if the terrain is not the legacy 256x256. + public float[] GetFloatsSerialised() { - TerrainChannel copy = new TerrainChannel(false); - copy.map = (double[,]) map.Clone(); - - return copy; + return m_terrainData.GetFloatsSerialized(); } - public float[] GetFloatsSerialised() + // ITerrainChannel.GetDoubles() + public double[,] GetDoubles() { - // Move the member variables into local variables, calling - // member variables 256*256 times gets expensive - int w = Width; - int h = Height; - float[] heights = new float[w * h]; + double[,] heights = new double[Width, Height]; - int i, j; // map coordinates int idx = 0; // index into serialized array - for (i = 0; i < h; i++) + for (int ii = 0; ii < Width; ii++) { - for (j = 0; j < w; j++) + for (int jj = 0; jj < Height; jj++) { - heights[idx++] = (float)map[j, i]; + heights[ii, jj] = (double)m_terrainData[ii, jj]; + idx++; } } return heights; } - public double[,] GetDoubles() - { - return map; - } - + // ITerrainChannel.this[x,y] public double this[int x, int y] { - get - { - if (x < 0) x = 0; - if (y < 0) y = 0; - if (x >= (int)Constants.RegionSize) x = (int)Constants.RegionSize - 1; - if (y >= (int)Constants.RegionSize) y = (int)Constants.RegionSize - 1; - - return map[x, y]; + get { + if (x < 0 || x >= Width || y < 0 || y >= Height) + return 0; + return (double)m_terrainData[x, y]; } set { - // Will "fix" terrain hole problems. Although not fantastically. if (Double.IsNaN(value) || Double.IsInfinity(value)) return; - if (map[x, y] != value) - { - taint[x / 16, y / 16] = true; - map[x, y] = value; - } + m_terrainData[x, y] = (float)value; } } - public bool Tainted(int x, int y) + // ITerrainChannel.GetHieghtAtXYZ(x, y, z) + public float GetHeightAtXYZ(float x, float y, float z) { - if (taint[x / 16, y / 16]) - { - taint[x / 16, y / 16] = false; - return true; - } - return false; + if (x < 0 || x >= Width || y < 0 || y >= Height) + return 0; + return m_terrainData[(int)x, (int)y]; } - #endregion - - public TerrainChannel Copy() + // ITerrainChannel.Tainted() + public bool Tainted(int x, int y) { - TerrainChannel copy = new TerrainChannel(false); - copy.map = (double[,]) map.Clone(); - - return copy; + return m_terrainData.IsTaintedAt(x, y); } + // ITerrainChannel.SaveToXmlString() public string SaveToXmlString() { XmlWriterSettings settings = new XmlWriterSettings(); @@ -189,13 +192,7 @@ namespace OpenSim.Region.Framework.Scenes } } - private void WriteXml(XmlWriter writer) - { - writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); - ToXml(writer); - writer.WriteEndElement(); - } - + // ITerrainChannel.LoadFromXmlString() public void LoadFromXmlString(string data) { StringReader sr = new StringReader(data); @@ -207,12 +204,124 @@ namespace OpenSim.Region.Framework.Scenes sr.Close(); } + // ITerrainChannel.Merge + public void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement) + { + m_log.DebugFormat("{0} Merge. inSize=<{1},{2}>, disp={3}, rot={4}, rotDisp={5}, outSize=<{6},{7}>", LogHeader, + newTerrain.Width, newTerrain.Height, + displacement, radianRotation, rotationDisplacement, + m_terrainData.SizeX, m_terrainData.SizeY); + for (int xx = 0; xx < newTerrain.Width; xx++) + { + for (int yy = 0; yy < newTerrain.Height; yy++) + { + int dispX = (int)displacement.X; + int dispY = (int)displacement.Y; + float newHeight = (float)newTerrain[xx, yy] + displacement.Z; + if (radianRotation == 0) + { + // If no rotation, place the new height in the specified location + dispX += xx; + dispY += yy; + if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY) + { + m_terrainData[dispX, dispY] = newHeight; + } + } + else + { + // If rotating, we have to smooth the result because the conversion + // to ints will mean heightmap entries will not get changed + // First compute the rotation location for the new height. + dispX += (int)(rotationDisplacement.X + + ((float)xx - rotationDisplacement.X) * Math.Cos(radianRotation) + - ((float)yy - rotationDisplacement.Y) * Math.Sin(radianRotation) ); + + dispY += (int)(rotationDisplacement.Y + + ((float)xx - rotationDisplacement.X) * Math.Sin(radianRotation) + + ((float)yy - rotationDisplacement.Y) * Math.Cos(radianRotation) ); + + if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY) + { + float oldHeight = m_terrainData[dispX, dispY]; + // Smooth the heights around this location if the old height is far from this one + for (int sxx = dispX - 2; sxx < dispX + 2; sxx++) + { + for (int syy = dispY - 2; syy < dispY + 2; syy++) + { + if (sxx >= 0 && sxx < m_terrainData.SizeX && syy >= 0 && syy < m_terrainData.SizeY) + { + if (sxx == dispX && syy == dispY) + { + // Set height for the exact rotated point + m_terrainData[dispX, dispY] = newHeight; + } + else + { + if (Math.Abs(m_terrainData[sxx, syy] - newHeight) > 1f) + { + // If the adjacent height is far off, force it to this height + m_terrainData[sxx, syy] = newHeight; + } + } + } + } + } + } + + if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY) + { + m_terrainData[dispX, dispY] = (float)newTerrain[xx, yy]; + } + } + } + } + } + + #endregion + + public TerrainChannel Copy() + { + TerrainChannel copy = new TerrainChannel(); + copy.m_terrainData = m_terrainData.Clone(); + return copy; + } + + private void WriteXml(XmlWriter writer) + { + if (Width == Constants.RegionSize && Height == Constants.RegionSize) + { + // Downward compatibility for legacy region terrain maps. + // If region is exactly legacy size, return the old format XML. + writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); + ToXml(writer); + writer.WriteEndElement(); + } + else + { + // New format XML that includes width and length. + writer.WriteStartElement(String.Empty, "TerrainMap2", String.Empty); + ToXml2(writer); + writer.WriteEndElement(); + } + } + private void ReadXml(XmlReader reader) { - reader.ReadStartElement("TerrainMap"); - FromXml(reader); + // Check the first element. If legacy element, use the legacy reader. + if (reader.IsStartElement("TerrainMap")) + { + reader.ReadStartElement("TerrainMap"); + FromXml(reader); + } + else + { + reader.ReadStartElement("TerrainMap2"); + FromXml2(reader); + } } + // Write legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. private void ToXml(XmlWriter xmlWriter) { float[] mapData = GetFloatsSerialised(); @@ -226,12 +335,15 @@ namespace OpenSim.Region.Framework.Scenes serializer.Serialize(xmlWriter, buffer); } + // Read legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. private void FromXml(XmlReader xmlReader) { XmlSerializer serializer = new XmlSerializer(typeof(byte[])); byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); int index = 0; + m_terrainData = new HeightmapTerrainData(Height, Width, (int)Constants.RegionHeight); + for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) @@ -244,35 +356,63 @@ namespace OpenSim.Region.Framework.Scenes } } + private class TerrainChannelXMLPackage + { + public int Version; + public int SizeX; + public int SizeY; + public int SizeZ; + public float CompressionFactor; + public int[] Map; + public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, int[] pMap) + { + Version = 1; + SizeX = pX; + SizeY = pY; + SizeZ = pZ; + CompressionFactor = pCompressionFactor; + Map = pMap; + } + } + + // New terrain serialization format that includes the width and length. + private void ToXml2(XmlWriter xmlWriter) + { + TerrainChannelXMLPackage package = new TerrainChannelXMLPackage(Width, Height, Altitude, m_terrainData.CompressionFactor, + m_terrainData.GetCompressedMap()); + XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); + serializer.Serialize(xmlWriter, package); + } + + // New terrain serialization format that includes the width and length. + private void FromXml2(XmlReader xmlReader) + { + XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); + TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader); + m_terrainData = new HeightmapTerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ); + } + + // Fill the heightmap with the center bump terrain private void PinHeadIsland() { - int x; - for (x = 0; x < Constants.RegionSize; x++) + for (int x = 0; x < Width; x++) { - int y; - for (y = 0; y < Constants.RegionSize; y++) + for (int y = 0; y < Height; y++) { - map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; - double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; - double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; - if (map[x, y] < spherFacA) - map[x, y] = spherFacA; - if (map[x, y] < spherFacB) - map[x, y] = spherFacB; + m_terrainData[x, y] = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; + float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 50) * 0.01d); + float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 100) * 0.001d); + if (m_terrainData[x, y]< spherFacA) + m_terrainData[x, y]= spherFacA; + if (m_terrainData[x, y]< spherFacB) + m_terrainData[x, y] = spherFacB; } } } private void FlatLand() { - int x; - for (x = 0; x < Constants.RegionSize; x++) - { - int y; - for (y = 0; y < Constants.RegionSize; y++) - map[x, y] = 21; - } + m_terrainData.ClearLand(); } - } } -- cgit v1.1 From c5a7bf6601dfde518a008d45b4e4a8dc8de698bf Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 28 Mar 2015 08:30:52 -0700 Subject: varregion: add varregion and TerrainData use in LLClientView. Add sending multiple parcel patches and sending patches by avatar view distance. --- .../Region/Framework/Scenes/TerrainCompressor.cs | 948 +++++++++++++++++++++ 1 file changed, 948 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/TerrainCompressor.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs new file mode 100644 index 0000000..fc8f8cd --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs @@ -0,0 +1,948 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Freely adapted from the Aurora version of the terrain compressor. + * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ + */ + +using System; +using System.Reflection; + +using log4net; + +using OpenSim.Framework; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Scenes; + +using OpenMetaverse; +using OpenMetaverse.Packets; + +namespace OpenSim.Region.ClientStack.LindenUDP +{ + public static class OpenSimTerrainCompressor + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + +#pragma warning disable 414 + private static string LogHeader = "[TERRAIN COMPRESSOR]"; +#pragma warning restore 414 + + public const int END_OF_PATCHES = 97; + + private const float OO_SQRT2 = 0.7071067811865475244008443621049f; + private const int STRIDE = 264; + + private const int ZERO_CODE = 0x0; + private const int ZERO_EOB = 0x2; + private const int POSITIVE_VALUE = 0x6; + private const int NEGATIVE_VALUE = 0x7; + + private static readonly float[] DequantizeTable16 = + new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + private static readonly float[] DequantizeTable32 = + new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + private static readonly float[] CosineTable16 = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + //private static readonly float[] CosineTable32 = new float[Constants.TerrainPatchSize * Constants.TerrainPatchSize]; + private static readonly int[] CopyMatrix16 = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + private static readonly int[] CopyMatrix32 = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + private static readonly float[] QuantizeTable16 = + new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + static OpenSimTerrainCompressor() + { + // Initialize the decompression tables + BuildDequantizeTable16(); + SetupCosines16(); + BuildCopyMatrix16(); + BuildQuantizeTable16(); + } + + // Used to send cloud and wind patches + public static LayerDataPacket CreateLayerDataPacket(TerrainPatch[] patches, byte type, int pRegionSizeX, + int pRegionSizeY) + { + LayerDataPacket layer = new LayerDataPacket {LayerID = {Type = type}}; + + TerrainPatch.GroupHeader header = new TerrainPatch.GroupHeader + {Stride = STRIDE, PatchSize = Constants.TerrainPatchSize}; + + // Should be enough to fit even the most poorly packed data + byte[] data = new byte[patches.Length*Constants.TerrainPatchSize*Constants.TerrainPatchSize*2]; + BitPack bitpack = new BitPack(data, 0); + bitpack.PackBits(header.Stride, 16); + bitpack.PackBits(header.PatchSize, 8); + bitpack.PackBits(type, 8); + + foreach (TerrainPatch t in patches) + CreatePatch(bitpack, t.Data, t.X, t.Y, pRegionSizeX, pRegionSizeY); + + bitpack.PackBits(END_OF_PATCHES, 8); + + layer.LayerData.Data = new byte[bitpack.BytePos + 1]; + Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1); + + return layer; + } + + // Create a land packet for a single patch. + public static LayerDataPacket CreateLandPacket(TerrainData terrData, int patchX, int patchY) + { + int[] xPieces = new int[1]; + int[] yPieces = new int[1]; + xPieces[0] = patchX; // patch X dimension + yPieces[0] = patchY; + + return CreateLandPacket(terrData, xPieces, yPieces); + } + + public static LayerDataPacket CreateLandPacket(TerrainData terrData, int[] xPieces, int[] yPieces) + { + byte landPacketType = (byte)TerrainPatch.LayerType.Land; + if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize) + { + landPacketType = (byte)TerrainPatch.LayerType.LandExtended; + } + + return CreateLandPacket(terrData, xPieces, yPieces, landPacketType); + } + + /// + /// Creates a LayerData packet for compressed land data given a full + /// simulator heightmap and an array of indices of patches to compress + /// + /// + /// Terrain data that can result in a meter square heightmap. + /// + /// + /// Array of indexes in the grid of patches + /// for this simulator. + /// If creating a packet for multiple patches, there will be entries in + /// both the X and Y arrays for each of the patches. + /// For example if patches 1 and 17 are to be sent, + /// x[] = {1,1} and y[] = {0,1} which specifies the patches at + /// indexes <1,0> and <1,1> (presuming the terrain size is 16x16 patches). + /// + /// + /// Array of indexes in the grid of patches. + /// + /// + /// + public static LayerDataPacket CreateLandPacket(TerrainData terrData, int[] x, int[] y, byte type) + { + LayerDataPacket layer = new LayerDataPacket {LayerID = {Type = type}}; + + TerrainPatch.GroupHeader header = new TerrainPatch.GroupHeader + {Stride = STRIDE, PatchSize = Constants.TerrainPatchSize}; + + byte[] data = new byte[x.Length * Constants.TerrainPatchSize * Constants.TerrainPatchSize * 2]; + BitPack bitpack = new BitPack(data, 0); + bitpack.PackBits(header.Stride, 16); + bitpack.PackBits(header.PatchSize, 8); + bitpack.PackBits(type, 8); + + for (int i = 0; i < x.Length; i++) + CreatePatchFromHeightmap(bitpack, terrData, x[i], y[i]); + + bitpack.PackBits(END_OF_PATCHES, 8); + + layer.LayerData.Data = new byte[bitpack.BytePos + 1]; + Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1); + + return layer; + } + + // Unused: left for historical reference. + public static void CreatePatch(BitPack output, float[] patchData, int x, int y, int pRegionSizeX, int pRegionSizeY) + { + TerrainPatch.Header header = PrescanPatch(patchData); + header.QuantWBits = 136; + if (pRegionSizeX > Constants.RegionSize || pRegionSizeY > Constants.RegionSize) + { + header.PatchIDs = (y & 0xFFFF); + header.PatchIDs += (x << 16); + } + else + { + header.PatchIDs = (y & 0x1F); + header.PatchIDs += (x << 5); + } + + // NOTE: No idea what prequant and postquant should be or what they do + + int wbits; + int[] patch = CompressPatch(patchData, header, 10, out wbits); + wbits = EncodePatchHeader(output, header, patch, Constants.RegionSize, Constants.RegionSize, wbits); + EncodePatch(output, patch, 0, wbits); + } + + /// + /// Add a patch of terrain to a BitPacker + /// + /// BitPacker to write the patch to + /// + /// Heightmap of the simulator. Presumed to be an sizeX*sizeY array. + /// + /// + /// X offset of the patch to create. + /// + /// + /// Y offset of the patch to create. + /// + /// + /// + public static void CreatePatchFromHeightmap(BitPack output, TerrainData terrData, int patchX, int patchY) + { + TerrainPatch.Header header = PrescanPatch(terrData, patchX, patchY); + header.QuantWBits = 136; + + // If larger than legacy region size, pack patch X and Y info differently. + if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize) + { + header.PatchIDs = (patchY & 0xFFFF); + header.PatchIDs += (patchX << 16); + } + else + { + header.PatchIDs = (patchY & 0x1F); + header.PatchIDs += (patchX << 5); + } + + // m_log.DebugFormat("{0} CreatePatchFromHeightmap. patchX={1}, patchY={2}, DCOffset={3}, range={4}", + // LogHeader, patchX, patchY, header.DCOffset, header.Range); + + // NOTE: No idea what prequant and postquant should be or what they do + int wbits; + int[] patch = CompressPatch(terrData, patchX, patchY, header, 10, out wbits); + wbits = EncodePatchHeader(output, header, patch, (uint)terrData.SizeX, (uint)terrData.SizeY, wbits); + EncodePatch(output, patch, 0, wbits); + } + + private static TerrainPatch.Header PrescanPatch(float[] patch) + { + TerrainPatch.Header header = new TerrainPatch.Header(); + float zmax = -99999999.0f; + float zmin = 99999999.0f; + + for (int i = 0; i < Constants.TerrainPatchSize*Constants.TerrainPatchSize; i++) + { + float val = patch[i]; + if (val > zmax) zmax = val; + if (val < zmin) zmin = val; + } + + header.DCOffset = zmin; + header.Range = (int) ((zmax - zmin) + 1.0f); + + return header; + } + + // Scan the height info we're returning and return a patch packet header for this patch. + private static TerrainPatch.Header PrescanPatch(TerrainData terrData, int patchX, int patchY) + { + TerrainPatch.Header header = new TerrainPatch.Header(); + float zmax = -99999999.0f; + float zmin = 99999999.0f; + + for (int j = patchY*Constants.TerrainPatchSize; j < (patchY + 1)*Constants.TerrainPatchSize; j++) + { + for (int i = patchX*Constants.TerrainPatchSize; i < (patchX + 1)*Constants.TerrainPatchSize; i++) + { + float val = terrData[i, j]; + if (val > zmax) zmax = val; + if (val < zmin) zmin = val; + } + } + + header.DCOffset = zmin; + header.Range = (int)((zmax - zmin) + 1.0f); + + return header; + } + + public static TerrainPatch.Header DecodePatchHeader(BitPack bitpack) + { + TerrainPatch.Header header = new TerrainPatch.Header {QuantWBits = bitpack.UnpackBits(8)}; + + // Quantized word bits + if (header.QuantWBits == END_OF_PATCHES) + return header; + + // DC offset + header.DCOffset = bitpack.UnpackFloat(); + + // Range + header.Range = bitpack.UnpackBits(16); + + // Patch IDs (10 bits) + header.PatchIDs = bitpack.UnpackBits(10); + + // Word bits + header.WordBits = (uint) ((header.QuantWBits & 0x0f) + 2); + + return header; + } + + private static int EncodePatchHeader(BitPack output, TerrainPatch.Header header, int[] patch, uint pRegionSizeX, + uint pRegionSizeY, int wbits) + { + /* + int temp; + int wbits = (header.QuantWBits & 0x0f) + 2; + uint maxWbits = (uint)wbits + 5; + uint minWbits = ((uint)wbits >> 1); + int wbitsMaxValue; + */ + // goal is to determ minimum number of bits to use so all data fits + /* + wbits = (int)minWbits; + wbitsMaxValue = (1 << wbits); + + for (int i = 0; i < patch.Length; i++) + { + temp = patch[i]; + if (temp != 0) + { + // Get the absolute value + if (temp < 0) temp *= -1; + + no coments.. + + for (int j = (int)maxWbits; j > (int)minWbits; j--) + { + if ((temp & (1 << j)) != 0) + { + if (j > wbits) wbits = j; + break; + } + } + + while (temp > wbitsMaxValue) + { + wbits++; + if (wbits == maxWbits) + goto Done; + wbitsMaxValue = 1 << wbits; + } + } + } + + Done: + + // wbits += 1; + */ + // better check + if (wbits > 17) + wbits = 16; + else if (wbits < 3) + wbits = 3; + + header.QuantWBits &= 0xf0; + + header.QuantWBits |= (wbits - 2); + + output.PackBits(header.QuantWBits, 8); + output.PackFloat(header.DCOffset); + output.PackBits(header.Range, 16); + if (pRegionSizeX > Constants.RegionSize || pRegionSizeY > Constants.RegionSize) + output.PackBits(header.PatchIDs, 32); + else + output.PackBits(header.PatchIDs, 10); + + return wbits; + } + + private static void IDCTColumn16(float[] linein, float[] lineout, int column) + { + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + float total = OO_SQRT2*linein[column]; + + for (int u = 1; u < Constants.TerrainPatchSize; u++) + { + int usize = u*Constants.TerrainPatchSize; + total += linein[usize + column]*CosineTable16[usize + n]; + } + + lineout[Constants.TerrainPatchSize*n + column] = total; + } + } + + private static void IDCTLine16(float[] linein, float[] lineout, int line) + { + const float oosob = 2.0f/Constants.TerrainPatchSize; + int lineSize = line*Constants.TerrainPatchSize; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + float total = OO_SQRT2*linein[lineSize]; + + for (int u = 1; u < Constants.TerrainPatchSize; u++) + { + total += linein[lineSize + u]*CosineTable16[u*Constants.TerrainPatchSize + n]; + } + + lineout[lineSize + n] = total*oosob; + } + } + +/* + private static void DCTLine16(float[] linein, float[] lineout, int line) + { + float total = 0.0f; + int lineSize = line * Constants.TerrainPatchSize; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[lineSize + n]; + } + + lineout[lineSize] = OO_SQRT2 * total; + + int uptr = 0; + for (int u = 1; u < Constants.TerrainPatchSize; u++) + { + total = 0.0f; + uptr += Constants.TerrainPatchSize; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[lineSize + n] * CosineTable16[uptr + n]; + } + + lineout[lineSize + u] = total; + } + } +*/ + + private static void DCTLine16(float[] linein, float[] lineout, int line) + { + // outputs transpose data (lines exchanged with coluns ) + // so to save a bit of cpu when doing coluns + float total = 0.0f; + int lineSize = line*Constants.TerrainPatchSize; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[lineSize + n]; + } + + lineout[line] = OO_SQRT2*total; + + for (int u = Constants.TerrainPatchSize; + u < Constants.TerrainPatchSize*Constants.TerrainPatchSize; + u += Constants.TerrainPatchSize) + { + total = 0.0f; + for (int ptrn = lineSize, ptru = u; ptrn < lineSize + Constants.TerrainPatchSize; ptrn++,ptru++) + { + total += linein[ptrn]*CosineTable16[ptru]; + } + + lineout[line + u] = total; + } + } + + + /* + private static void DCTColumn16(float[] linein, int[] lineout, int column) + { + float total = 0.0f; + // const float oosob = 2.0f / Constants.TerrainPatchSize; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[Constants.TerrainPatchSize * n + column]; + } + + // lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * oosob * QuantizeTable16[column]); + lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * QuantizeTable16[column]); + + for (int uptr = Constants.TerrainPatchSize; uptr < Constants.TerrainPatchSize * Constants.TerrainPatchSize; uptr += Constants.TerrainPatchSize) + { + total = 0.0f; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[Constants.TerrainPatchSize * n + column] * CosineTable16[uptr + n]; + } + + // lineout[CopyMatrix16[Constants.TerrainPatchSize * u + column]] = (int)(total * oosob * QuantizeTable16[Constants.TerrainPatchSize * u + column]); + lineout[CopyMatrix16[uptr + column]] = (int)(total * QuantizeTable16[uptr + column]); + } + } + + private static void DCTColumn16(float[] linein, int[] lineout, int column) + { + // input columns are in fact stored in lines now + + float total = 0.0f; +// const float oosob = 2.0f / Constants.TerrainPatchSize; + int inlinesptr = Constants.TerrainPatchSize*column; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[inlinesptr + n]; + } + + // lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * oosob * QuantizeTable16[column]); + lineout[CopyMatrix16[column]] = (int) (OO_SQRT2*total*QuantizeTable16[column]); + + for (int uptr = Constants.TerrainPatchSize; + uptr < Constants.TerrainPatchSize*Constants.TerrainPatchSize; + uptr += Constants.TerrainPatchSize) + { + total = 0.0f; + + for (int n = inlinesptr, ptru = uptr; n < inlinesptr + Constants.TerrainPatchSize; n++, ptru++) + { + total += linein[n]*CosineTable16[ptru]; + } + +// lineout[CopyMatrix16[Constants.TerrainPatchSize * u + column]] = (int)(total * oosob * QuantizeTable16[Constants.TerrainPatchSize * u + column]); + lineout[CopyMatrix16[uptr + column]] = (int) (total*QuantizeTable16[uptr + column]); + } + } + */ + + private static int DCTColumn16Wbits(float[] linein, int[] lineout, int column, int wbits, int maxwbits) + { + // input columns are in fact stored in lines now + + bool dowbits = wbits != maxwbits; + int wbitsMaxValue = 1 << wbits; + + float total = 0.0f; + // const float oosob = 2.0f / Constants.TerrainPatchSize; + int inlinesptr = Constants.TerrainPatchSize*column; + + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + total += linein[inlinesptr + n]; + } + + // lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * oosob * QuantizeTable16[column]); + int tmp = (int) (OO_SQRT2*total*QuantizeTable16[column]); + lineout[CopyMatrix16[column]] = tmp; + + if (dowbits) + { + if (tmp < 0) tmp *= -1; + while (tmp > wbitsMaxValue) + { + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } + } + } + + for (int uptr = Constants.TerrainPatchSize; + uptr < Constants.TerrainPatchSize*Constants.TerrainPatchSize; + uptr += Constants.TerrainPatchSize) + { + total = 0.0f; + + for (int n = inlinesptr, ptru = uptr; n < inlinesptr + Constants.TerrainPatchSize; n++, ptru++) + { + total += linein[n]*CosineTable16[ptru]; + } + + tmp = (int) (total*QuantizeTable16[uptr + column]); + lineout[CopyMatrix16[uptr + column]] = tmp; + + if (dowbits) + { + if (tmp < 0) tmp *= -1; + while (tmp > wbitsMaxValue) + { + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } + } + } + } + return wbits; + } + + public static void DecodePatch(int[] patches, BitPack bitpack, TerrainPatch.Header header, int size) + { + for (int n = 0; n < size*size; n++) + { + // ? + int temp = bitpack.UnpackBits(1); + if (temp != 0) + { + // Value or EOB + temp = bitpack.UnpackBits(1); + if (temp != 0) + { + // Value + temp = bitpack.UnpackBits(1); + if (temp != 0) + { + // Negative + temp = bitpack.UnpackBits((int) header.WordBits); + patches[n] = temp*-1; + } + else + { + // Positive + temp = bitpack.UnpackBits((int) header.WordBits); + patches[n] = temp; + } + } + else + { + // Set the rest to zero + // TODO: This might not be necessary + for (int o = n; o < size*size; o++) + { + patches[o] = 0; + } + break; + } + } + else + { + patches[n] = 0; + } + } + } + + private static void EncodePatch(BitPack output, int[] patch, int postquant, int wbits) + { + int maxwbitssize = (1 << wbits) - 1; + + if (postquant > Constants.TerrainPatchSize*Constants.TerrainPatchSize || postquant < 0) + { + Logger.Log("Postquant is outside the range of allowed values in EncodePatch()", Helpers.LogLevel.Error); + return; + } + + if (postquant != 0) patch[Constants.TerrainPatchSize*Constants.TerrainPatchSize - postquant] = 0; + + for (int i = 0; i < Constants.TerrainPatchSize*Constants.TerrainPatchSize; i++) + { + int temp = patch[i]; + + if (temp == 0) + { + bool eob = true; + + for (int j = i; j < Constants.TerrainPatchSize*Constants.TerrainPatchSize - postquant; j++) + { + if (patch[j] != 0) + { + eob = false; + break; + } + } + + if (eob) + { + output.PackBits(ZERO_EOB, 2); + return; + } + output.PackBits(ZERO_CODE, 1); + } + else + { + if (temp < 0) + { + temp *= -1; + + if (temp > maxwbitssize) temp = maxwbitssize; + + output.PackBits(NEGATIVE_VALUE, 3); + output.PackBits(temp, wbits); + } + else + { + if (temp > maxwbitssize) temp = maxwbitssize; + + output.PackBits(POSITIVE_VALUE, 3); + output.PackBits(temp, wbits); + } + } + } + } + + public static float[] DecompressPatch(int[] patches, TerrainPatch.Header header, TerrainPatch.GroupHeader group) + { + float[] block = new float[group.PatchSize*group.PatchSize]; + float[] output = new float[group.PatchSize*group.PatchSize]; + int prequant = (header.QuantWBits >> 4) + 2; + int quantize = 1 << prequant; + float ooq = 1.0f/quantize; + float mult = ooq*header.Range; + float addval = mult*(1 << (prequant - 1)) + header.DCOffset; + + if (group.PatchSize == Constants.TerrainPatchSize) + { + for (int n = 0; n < Constants.TerrainPatchSize*Constants.TerrainPatchSize; n++) + { + block[n] = patches[CopyMatrix16[n]]*DequantizeTable16[n]; + } + + float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + for (int o = 0; o < Constants.TerrainPatchSize; o++) + IDCTColumn16(block, ftemp, o); + for (int o = 0; o < Constants.TerrainPatchSize; o++) + IDCTLine16(ftemp, block, o); + } + else + { + for (int n = 0; n < Constants.TerrainPatchSize*2*Constants.TerrainPatchSize*2; n++) + { + block[n] = patches[CopyMatrix32[n]]*DequantizeTable32[n]; + } + + Logger.Log("Implement IDCTPatchLarge", Helpers.LogLevel.Error); + } + + for (int j = 0; j < block.Length; j++) + { + output[j] = block[j]*mult + addval; + } + + return output; + } + + private static int[] CompressPatch(float[] patchData, TerrainPatch.Header header, int prequant, out int wbits) + { + float[] block = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + int wordsize = (prequant - 2) & 0x0f; + float oozrange = 1.0f/header.Range; + float range = (1 << prequant); + float premult = oozrange*range; + float sub = (1 << (prequant - 1)) + header.DCOffset*premult; + + header.QuantWBits = wordsize; + header.QuantWBits |= wordsize << 4; + + int k = 0; + for (int j = 0; j < Constants.TerrainPatchSize; j++) + { + for (int i = 0; i < Constants.TerrainPatchSize; i++) + block[k++] = patchData[j*Constants.TerrainPatchSize + i]*premult - sub; + } + + float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + int[] itemp = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + + int maxWbits = prequant + 5; + wbits = (prequant >> 1); + + for (int o = 0; o < Constants.TerrainPatchSize; o++) + DCTLine16(block, ftemp, o); + for (int o = 0; o < Constants.TerrainPatchSize; o++) + wbits = DCTColumn16Wbits(ftemp, itemp, o, wbits, maxWbits); + + return itemp; + } + + private static int[] CompressPatch(float[,] patchData, TerrainPatch.Header header, int prequant, out int wbits) + { + float[] block = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + float oozrange = 1.0f/header.Range; + float range = (1 << prequant); + float premult = oozrange*range; + float sub = (1 << (prequant - 1)) + header.DCOffset*premult; + int wordsize = (prequant - 2) & 0x0f; + + header.QuantWBits = wordsize; + header.QuantWBits |= wordsize << 4; + + int k = 0; + for (int j = 0; j < Constants.TerrainPatchSize; j++) + { + for (int i = 0; i < Constants.TerrainPatchSize; i++) + block[k++] = patchData[j, i]*premult - sub; + } + + float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + int[] itemp = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + int maxWbits = prequant + 5; + wbits = (prequant >> 1); + + for (int o = 0; o < Constants.TerrainPatchSize; o++) + DCTLine16(block, ftemp, o); + for (int o = 0; o < Constants.TerrainPatchSize; o++) + wbits = DCTColumn16Wbits(ftemp, itemp, o, wbits, maxWbits); + + return itemp; + } + + private static int[] CompressPatch(TerrainData terrData, int patchX, int patchY, TerrainPatch.Header header, + int prequant, out int wbits) + { + float[] block = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + int wordsize = prequant; + float oozrange = 1.0f/header.Range; + float range = (1 << prequant); + float premult = oozrange*range; + float sub = (1 << (prequant - 1)) + header.DCOffset*premult; + + header.QuantWBits = wordsize - 2; + header.QuantWBits |= (prequant - 2) << 4; + + int k = 0; + + int yPatchLimit = patchY >= (terrData.SizeY / Constants.TerrainPatchSize) ? + (terrData.SizeY - Constants.TerrainPatchSize) / Constants.TerrainPatchSize : patchY; + yPatchLimit = (yPatchLimit + 1) * Constants.TerrainPatchSize; + + int xPatchLimit = patchX >= (terrData.SizeX / Constants.TerrainPatchSize) ? + (terrData.SizeX - Constants.TerrainPatchSize) / Constants.TerrainPatchSize : patchX; + xPatchLimit = (xPatchLimit + 1) * Constants.TerrainPatchSize; + + for (int yy = patchY * Constants.TerrainPatchSize; yy < yPatchLimit; yy++) + { + for (int xx = patchX * Constants.TerrainPatchSize; xx < xPatchLimit; xx++) + { + block[k++] = terrData[xx, yy] * premult - sub; + } + } + + float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + int[] itemp = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; + + int maxWbits = prequant + 5; + wbits = (prequant >> 1); + + for (int o = 0; o < Constants.TerrainPatchSize; o++) + DCTLine16(block, ftemp, o); + for (int o = 0; o < Constants.TerrainPatchSize; o++) + wbits = DCTColumn16Wbits(ftemp, itemp, o, wbits, maxWbits); + + return itemp; + } + + #region Initialization + + private static void BuildDequantizeTable16() + { + for (int j = 0; j < Constants.TerrainPatchSize; j++) + { + for (int i = 0; i < Constants.TerrainPatchSize; i++) + { + DequantizeTable16[j*Constants.TerrainPatchSize + i] = 1.0f + 2.0f*(i + j); + } + } + } + + private static void BuildQuantizeTable16() + { + const float oosob = 2.0f/Constants.TerrainPatchSize; + for (int j = 0; j < Constants.TerrainPatchSize; j++) + { + for (int i = 0; i < Constants.TerrainPatchSize; i++) + { +// QuantizeTable16[j * Constants.TerrainPatchSize + i] = 1.0f / (1.0f + 2.0f * ((float)i + (float)j)); + QuantizeTable16[j*Constants.TerrainPatchSize + i] = oosob/(1.0f + 2.0f*(i + (float) j)); + } + } + } + + private static void SetupCosines16() + { + const float hposz = (float) Math.PI*0.5f/Constants.TerrainPatchSize; + + for (int u = 0; u < Constants.TerrainPatchSize; u++) + { + for (int n = 0; n < Constants.TerrainPatchSize; n++) + { + CosineTable16[u*Constants.TerrainPatchSize + n] = (float) Math.Cos((2.0f*n + 1.0f)*u*hposz); + } + } + } + + private static void BuildCopyMatrix16() + { + bool diag = false; + bool right = true; + int i = 0; + int j = 0; + int count = 0; + + while (i < Constants.TerrainPatchSize && j < Constants.TerrainPatchSize) + { + CopyMatrix16[j*Constants.TerrainPatchSize + i] = count++; + + if (!diag) + { + if (right) + { + if (i < Constants.TerrainPatchSize - 1) i++; + else j++; + + right = false; + diag = true; + } + else + { + if (j < Constants.TerrainPatchSize - 1) j++; + else i++; + + right = true; + diag = true; + } + } + else + { + if (right) + { + i++; + j--; + if (i == Constants.TerrainPatchSize - 1 || j == 0) diag = false; + } + else + { + i--; + j++; + if (j == Constants.TerrainPatchSize - 1 || i == 0) diag = false; + } + } + } + } + + #endregion Initialization + } +} -- cgit v1.1 From 07dead7dcb8b0f2a27a50748e4a460d9669903fc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 29 Mar 2015 14:25:12 -0700 Subject: varregion: any conversions of use of Constants.RegionSize converted into Util.cs routines to convert region coords to and from world coords or handles. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 11 ++------ OpenSim/Region/Framework/Scenes/Scene.cs | 33 ++++++++++++++++++---- .../Framework/Scenes/SceneCommunicationService.cs | 9 ++++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 25 +++++++--------- 5 files changed, 48 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b45cc4d..4ab5a4a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2221,14 +2221,9 @@ namespace OpenSim.Region.Framework.Scenes itemID = UUID.Zero; if (grp != null) { - Vector3 inventoryStoredPosition = new Vector3 - (((grp.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 - : grp.AbsolutePosition.X) - , - (grp.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 - : grp.AbsolutePosition.X, + Vector3 inventoryStoredPosition = new Vector3( + Math.Min(grp.AbsolutePosition.X, RegionInfo.RegionSizeX - 6), + Math.Min(grp.AbsolutePosition.Y, RegionInfo.RegionSizeY - 6), grp.AbsolutePosition.Z); Vector3 originalPosition = grp.AbsolutePosition; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f5458c1..46c9048 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -6,7 +6,7 @@ * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyrightD + * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the OpenSimulator Project nor the @@ -103,7 +103,29 @@ namespace OpenSim.Region.Framework.Scenes /// /// If false then physical objects are disabled, though collisions will continue as normal. /// - public bool PhysicsEnabled { get; set; } + public bool PhysicsEnabled + { + get + { + return m_physicsEnabled; + } + + set + { + m_physicsEnabled = value; + + if (PhysicsScene != null) + { + IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters; + + if (physScene != null) + physScene.SetPhysicsParameter( + "Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE); + } + } + } + + private bool m_physicsEnabled; /// /// If false then scripts are not enabled on the smiulator @@ -199,15 +221,16 @@ namespace OpenSim.Region.Framework.Scenes /// public int m_linksetCapacity = 0; + public bool m_clampPrimSize; + public bool m_trustBinaries; + public bool m_allowScriptCrossings = true; + /// /// Max prims an Physical object will hold /// /// public int m_linksetPhysCapacity = 0; - public bool m_clampPrimSize; - public bool m_trustBinaries; - public bool m_allowScriptCrossings; public bool m_useFlySlow; public bool m_useTrashOnDelete = true; diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 52f46f2..a2625c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.Framework.Scenes public class SceneCommunicationService //one instance per region { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static string LogHeader = "[SCENE COMMUNICATION SERVICE]"; protected RegionInfo m_regionInfo; protected Scene m_scene; @@ -100,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.WarnFormat( "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", - m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize); + m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y)); } } @@ -166,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes // we only want to send one update to each simulator; the simulator will // hand it off to the regions where a child agent exists, this does assume // that the region position is cached or performance will degrade - Utils.LongToUInts(regionHandle, out x, out y); + Util.RegionHandleToWorldLoc(regionHandle, out x, out y); GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (dest == null) continue; @@ -206,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); + Util.RegionHandleToWorldLoc(regionHandle, out x, out y); GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); @@ -226,6 +227,8 @@ namespace OpenSim.Region.Framework.Scenes { foreach (ulong handle in regionslst) { + // We must take a copy here since handle acts like a reference when used in an iterator. + // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region. ulong handleCopy = handle; Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); }); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a99e469..cb2f377 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -412,7 +412,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); + Vector3 minScale = new Vector3(Constants.MaximumRegionSize, Constants.MaximumRegionSize, Constants.MaximumRegionSize); Vector3 maxScale = Vector3.Zero; Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2965903..82508ad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -842,9 +842,8 @@ namespace OpenSim.Region.Framework.Scenes foreach (ulong handle in seeds.Keys) { uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; + Util.RegionHandleToRegionLoc(handle, out x, out y); + if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) { old.Add(handle); @@ -866,9 +865,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (KeyValuePair kvp in KnownRegions) { uint x, y; - Utils.LongToUInts(kvp.Key, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; + Util.RegionHandleToRegionLoc(kvp.Key, out x, out y); m_log.Info(" >> "+x+", "+y+": "+kvp.Value); } } @@ -1189,7 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes float posZLimit = 0; - if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) + if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY) posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; float newPosZ = posZLimit + localAVHeight / 2; @@ -2595,7 +2592,7 @@ namespace OpenSim.Region.Framework.Scenes if (regionCombinerModule != null) regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); else - regionSize = new Vector2(Constants.RegionSize); + regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY); if (pos.X < 0 || pos.X >= regionSize.X || pos.Y < 0 || pos.Y >= regionSize.Y @@ -2613,8 +2610,8 @@ namespace OpenSim.Region.Framework.Scenes // } // Get terrain height for sub-region in a megaregion if necessary - int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); - int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); + int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X); + int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); // If X and Y is NaN, target_region will be null if (target_region == null) @@ -2625,7 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) targetScene = m_scene; - float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; + float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; // dont try to land underground terrainHeight += Appearance.AvatarHeight / 2; pos.Z = Math.Max(terrainHeight, pos.Z); @@ -3941,7 +3938,7 @@ namespace OpenSim.Region.Framework.Scenes // Put the child agent back at the center AbsolutePosition - = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); + = new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70); Animator.ResetAnimations(); } @@ -3968,9 +3965,7 @@ namespace OpenSim.Region.Framework.Scenes if (handle != Scene.RegionInfo.RegionHandle) { uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; + Util.RegionHandleToRegionLoc(handle, out x, out y); // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); -- cgit v1.1 From 0af2fafddf36009ffe470da106dc6d0ceb3ced10 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Aug 2015 11:04:28 +0100 Subject: add missing regionExtent setup and Scene physicsscene configuration ( not exactly as core) --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 46c9048..fa5d021 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -760,7 +760,7 @@ namespace OpenSim.Region.Framework.Scenes #region Constructors - public Scene(RegionInfo regInfo, AgentCircuitManager authen, + public Scene(RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene, SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, IConfigSource config, string simulatorVersion) @@ -840,6 +840,7 @@ namespace OpenSim.Region.Framework.Scenes new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); m_sceneGraph = new SceneGraph(this); + m_sceneGraph.PhysicsScene = physicsScene; // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific @@ -1075,7 +1076,8 @@ namespace OpenSim.Region.Framework.Scenes { PhysicalPrims = true; CollidablePrims = true; - PhysicsEnabled = true; + // this is done above acording to config + // PhysicsEnabled = true; PeriodicBackup = true; UseBackup = true; -- cgit v1.1 From 7661366223f8598439c0fedcf79d8ceee42542df Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Aug 2015 15:24:12 +0100 Subject: minor change --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 3d563a6..282a44a 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -395,17 +395,21 @@ namespace OpenSim.Region.Framework.Scenes // Fill the heightmap with the center bump terrain private void PinHeadIsland() { + float cx = m_terrainData.SizeX * 0.5f; + float cy = m_terrainData.SizeY * 0.5f; + float h; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { - m_terrainData[x, y] = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; - float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 50) * 0.01d); - float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 100) * 0.001d); - if (m_terrainData[x, y]< spherFacA) - m_terrainData[x, y]= spherFacA; - if (m_terrainData[x, y]< spherFacB) - m_terrainData[x, y] = spherFacB; + h = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; + float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 50) * 0.01d); + float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 100) * 0.001d); + if (h < spherFacA) + h = spherFacA; + if (h < spherFacB) + h = spherFacB; + m_terrainData[x, y] = h; } } } -- cgit v1.1 From 601914ecd807d9e36c0d9898562e730155a6051e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Aug 2015 16:28:03 +0100 Subject: find sending of initial terrain using PushTerrain as os core --- OpenSim/Region/Framework/Scenes/SceneBase.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index f5be7a7..9648030 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -211,7 +211,12 @@ namespace OpenSim.Region.Framework.Scenes /// Client to send to public virtual void SendLayerData(IClientAPI RemoteClient) { - RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); +// RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); + ITerrainModule terrModule = RequestModuleInterface(); + if (terrModule != null) + { + terrModule.PushTerrain(RemoteClient); + } } #endregion -- cgit v1.1 From d2776ec64504769d69b7f9e9c781b5c0a28b224d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Aug 2015 17:14:29 +0100 Subject: funny bug --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cb2f377..1bb5854 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -530,7 +530,7 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 val = value; if (Scene != null - && Scene.PositionIsInCurrentRegion(val) + && !Scene.PositionIsInCurrentRegion(val) && !IsAttachmentCheckFull() && !Scene.LoadingPrims ) -- cgit v1.1 From f6a59f74ab6b0d5f12fddfb73d724dd902075d71 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 21 Aug 2015 00:35:55 +0100 Subject: remove a 256m check --- OpenSim/Region/Framework/Scenes/Scene.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fa5d021..d6a1fab 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2913,6 +2913,15 @@ namespace OpenSim.Region.Framework.Scenes return sp; } + public string GetAgentHomeURI(UUID agentID) + { + AgentCircuitData circuit = AuthenticateHandler.GetAgentCircuitData(agentID); + if (circuit != null && circuit.ServiceURLs != null && circuit.ServiceURLs.ContainsKey("HomeURI")) + return circuit.ServiceURLs["HomeURI"].ToString(); + else + return null; + } + /// /// Cache the user name for later use. /// @@ -4028,12 +4037,12 @@ namespace OpenSim.Region.Framework.Scenes { if (posX < 0) posX = 0; - else if (posX >= 256) - posX = 255.999f; + else if (posX >= RegionInfo.RegionSizeX) + posX = RegionInfo.RegionSizeX - 0.5f; if (posY < 0) posY = 0; - else if (posY >= 256) - posY = 255.999f; + else if (posY >= RegionInfo.RegionSizeY) + posY = RegionInfo.RegionSizeY - 0.5f; reason = String.Empty; if (Permissions.IsGod(agentID)) -- cgit v1.1 From 6555bbffaa9cc76851beca53c11833e00eae9ef3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 21 Aug 2015 00:47:44 +0100 Subject: remove the noise part on the PinHeadIsland. why to want something that does not compress well on island? --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 282a44a..684029d 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -402,7 +402,8 @@ namespace OpenSim.Region.Framework.Scenes { for (int y = 0; y < Height; y++) { - h = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; + // h = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; + h = 1.0f; float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 50) * 0.01d); float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 100) * 0.001d); if (h < spherFacA) -- cgit v1.1 From 3829df10595911de9ed1ce2f7b6cdd205828f8d0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Aug 2015 17:05:16 +0100 Subject: try to implement core load oar options --- .../Scenes/Serialization/SceneObjectSerializer.cs | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 40e88f1..3d14943 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -299,6 +299,71 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } + /// + /// Modifies a SceneObjectGroup. + /// + /// The object + /// Whether the object was actually modified + public delegate bool SceneObjectModifier(SceneObjectGroup sog); + + /// + /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing. + /// + /// The object's UUID + /// Serialized data + /// The function to run on each SceneObjectGroup + /// The new serialized object's data, or null if an error occurred + public static byte[] ModifySerializedObject(UUID assetId, byte[] data, SceneObjectModifier modifier) + { + List sceneObjects = new List(); + CoalescedSceneObjects coa = null; + + string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data)); + + if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) + { + // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); + + if (coa.Objects.Count == 0) + { + m_log.WarnFormat("[SERIALIZER]: Aborting load of coalesced object from asset {0} as it has zero loaded components", assetId); + return null; + } + + sceneObjects.AddRange(coa.Objects); + } + else + { + SceneObjectGroup deserializedObject = FromOriginalXmlFormat(xmlData); + + if (deserializedObject != null) + { + sceneObjects.Add(deserializedObject); + } + else + { + m_log.WarnFormat("[SERIALIZER]: Aborting load of object from asset {0} as deserialization failed", assetId); + return null; + } + } + + bool modified = false; + foreach (SceneObjectGroup sog in sceneObjects) + { + if (modifier(sog)) + modified = true; + } + + if (modified) + { + if (coa != null) + data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa)); + else + data = Utils.StringToBytes(ToOriginalXmlFormat(sceneObjects[0])); + } + + return data; + } #region manual serialization -- cgit v1.1 From 1c752296bfc25ca709117ad1c557aff2b6097ffb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Aug 2015 18:40:28 +0100 Subject: change internal representation of terrain from int to ushort. This will suporte height from 0 to 655.53m that includes SL limits ( still need to add code to trap eventual negative values from dbs or user input) --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 684029d..2dab246 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -363,8 +363,8 @@ namespace OpenSim.Region.Framework.Scenes public int SizeY; public int SizeZ; public float CompressionFactor; - public int[] Map; - public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, int[] pMap) + public ushort[] Map; + public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, ushort[] pMap) { Version = 1; SizeX = pX; -- cgit v1.1 From 64d05bab0fe9e12038309275a677e68518fb9b15 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Aug 2015 13:36:45 +0100 Subject: terrain stored as ushorts with gzip compression --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 2dab246..75c3a3b 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -157,7 +157,11 @@ namespace OpenSim.Region.Framework.Scenes { if (Double.IsNaN(value) || Double.IsInfinity(value)) return; - + if (value < 0) + value = 0; + else + if (value > 655.35) + value = 655.35; m_terrainData[x, y] = (float)value; } } -- cgit v1.1 From 244f0c6352a920b8bba5e13fadda49cb5b368e06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Aug 2015 16:51:48 +0100 Subject: change terrain internal representation to float. ushort work with legal sl terrain, but may break existent terrain and that may cost a lot more than the cost of memory --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 75c3a3b..6abdc29 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -367,8 +367,8 @@ namespace OpenSim.Region.Framework.Scenes public int SizeY; public int SizeZ; public float CompressionFactor; - public ushort[] Map; - public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, ushort[] pMap) + public float[] Map; + public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, float[] pMap) { Version = 1; SizeX = pX; -- cgit v1.1 From b82b16c954a0f3921efbdcfe7d7eb378f71e96be Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 27 Aug 2015 15:01:15 +0100 Subject: take taints check terrain out of Onframe event and add a new event for it. Slow it down to 1/4 heartbeat rate (once every 363ms aprox) --- OpenSim/Region/Framework/Scenes/EventManager.cs | 23 ++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 29 ++++++++++++++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 692e0c9..24fbef9 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -80,6 +80,7 @@ namespace OpenSim.Region.Framework.Scenes public event OnTerrainTaintedDelegate OnTerrainTainted; public delegate void OnTerrainTickDelegate(); + public delegate void OnTerrainCheckUpdatesDelegate(); /// /// Triggered if the terrain has been edited @@ -89,6 +90,7 @@ namespace OpenSim.Region.Framework.Scenes /// but is used by core solely to update the physics engine. /// public event OnTerrainTickDelegate OnTerrainTick; + public event OnTerrainCheckUpdatesDelegate OnTerrainCheckUpdates; public delegate void OnTerrainUpdateDelegate(); @@ -1484,6 +1486,27 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerTerrainCheckUpdates() + { + OnTerrainCheckUpdatesDelegate TerrainCheckUpdates = OnTerrainCheckUpdates; + if (TerrainCheckUpdates != null) + { + foreach (OnTerrainCheckUpdatesDelegate d in TerrainCheckUpdates.GetInvocationList()) + { + try + { + d(); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TerrainCheckUpdates failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + public void TriggerTerrainTainted() { OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d6a1fab..41f8871 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -245,8 +245,8 @@ namespace OpenSim.Region.Framework.Scenes get { return m_defaultDrawDistance; } } -// protected float m_maxDrawDistance = 512.0f; - protected float m_maxDrawDistance = 256.0f; + protected float m_maxDrawDistance = 512.0f; +// protected float m_maxDrawDistance = 256.0f; public float MaxDrawDistance { get { return m_maxDrawDistance; } @@ -1581,13 +1581,20 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerRegionHeartbeatStart(this); // Apply taints in terrain module to terrain in physics scene + + tmpMS = Util.EnvironmentTickCount(); + if (Frame % 4 == 0) + { + CheckTerrainUpdates(); + } + if (Frame % m_update_terrain == 0) { - tmpMS = Util.EnvironmentTickCount(); UpdateTerrain(); - terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); } + terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); + tmpMS = Util.EnvironmentTickCount(); if (PhysicsEnabled && Frame % m_update_physics == 0) m_sceneGraph.UpdatePreparePhysics(); @@ -1809,6 +1816,11 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerTerrainTick(); } + private void CheckTerrainUpdates() + { + EventManager.TriggerTerrainCheckUpdates(); + } + /// /// Back up queued up changes /// @@ -5880,11 +5892,12 @@ Environment.Exit(1); /// or corssing the broder walking, but will NOT prevent /// child agent creation, thereby emulating the SL behavior. /// - /// + /// The visitor's User ID + /// The visitor's Home URI (may be null) /// /// /// - public bool QueryAccess(UUID agentID, Vector3 position, out string reason) + public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string reason) { reason = "You are banned from the region"; @@ -5894,6 +5907,10 @@ Environment.Exit(1); return true; } + +// if (!AllowAvatarCrossing && !viaTeleport) +// return false; + // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. // However, the long term fix is to make sure root agent count is always accurate. m_sceneGraph.RecalculateStats(); -- cgit v1.1 From b114a04ed4f06afbdf673c28374e6e3cb9065096 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 29 Aug 2015 03:41:43 +0100 Subject: fix NeighborRegions code --- OpenSim/Region/Framework/Scenes/Scene.cs | 65 ++++++++------------------------ 1 file changed, 16 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 41f8871..605c788 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1129,17 +1129,9 @@ namespace OpenSim.Region.Framework.Scenes /// True after all operations complete, throws exceptions otherwise. public override void OtherRegionUp(GridRegion otherRegion) { - uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize); - uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize); - //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}", - // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell); - if (RegionInfo.RegionHandle != otherRegion.RegionHandle) { - // If these are cast to INT because long + negative values + abs returns invalid data - int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX); - int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); - if (resultX <= 1 && resultY <= 1) + if (isNeighborRegion(otherRegion)) { // Let the grid service module know, so this can be cached m_eventManager.TriggerOnRegionUp(otherRegion); @@ -1174,6 +1166,21 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool isNeighborRegion(GridRegion otherRegion) + { + int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; ; + + if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX) + return false; + + tmp = otherRegion.RegionLocY - (int)RegionInfo.WorldLocY; + + if (tmp < -otherRegion.RegionSizeY && tmp > RegionInfo.RegionSizeY) + return false; + + return true; + } + public void AddNeighborRegion(RegionInfo region) { lock (m_neighbours) @@ -1202,46 +1209,6 @@ namespace OpenSim.Region.Framework.Scenes return found; } - /// - /// Checks whether this region has a neighbour in the given direction. - /// - /// - /// - /// - /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. - /// Returns a positive integer if there is a region in that direction, a negative integer if not. - /// - public int HaveNeighbor(Cardinals car, ref int[] fix) - { - uint neighbourx = RegionInfo.RegionLocX; - uint neighboury = RegionInfo.RegionLocY; - - int dir = (int)car; - - if (dir > 1 && dir < 5) //Heading East - neighbourx++; - else if (dir > 5) // Heading West - neighbourx--; - - if (dir < 3 || dir == 8) // Heading North - neighboury++; - else if (dir > 3 && dir < 7) // Heading Sout - neighboury--; - - int x = (int)(neighbourx * Constants.RegionSize); - int y = (int)(neighboury * Constants.RegionSize); - GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y); - - if (neighbourRegion == null) - { - fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); - fix[1] = (int)(RegionInfo.RegionLocY - neighboury); - return dir * (-1); - } - else - return dir; - } - // Alias IncomingHelloNeighbour OtherRegionUp, for now public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) { -- cgit v1.1 From 0edffae7e42c0705303e015036fa85687508ecf0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 30 Aug 2015 19:17:35 +0100 Subject: more on tps and crossings --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 105 ++++++++++++++++------- 1 file changed, 76 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3e278a9..045a450 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -838,22 +838,24 @@ namespace OpenSim.Region.Framework.Scenes else seeds = new Dictionary(); +/* we can't do this anymore List old = new List(); foreach (ulong handle in seeds.Keys) { uint x, y; Util.RegionHandleToRegionLoc(handle, out x, out y); - - if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) +no information to check this +// if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY,)) { old.Add(handle); } } + DropOldNeighbours(old); if (Scene.CapsModule != null) Scene.CapsModule.SetChildrenSeed(UUID, seeds); - +*/ KnownRegions = seeds; //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); //DumpKnownRegions(); @@ -1517,15 +1519,46 @@ namespace OpenSim.Region.Framework.Scenes // holds the seed cap for the child agent in that region private Dictionary m_knownChildRegions = new Dictionary(); - public void AddNeighbourRegion(ulong regionHandle, string cap) + struct spRegionSizeInfo + { + public int sizeX; + public int sizeY; + } + + private Dictionary m_knownChildRegionsSizeInfo = new Dictionary(); + + + public void AddNeighbourRegionSizeInfo(GridRegion region) { lock (m_knownChildRegions) { - if (!m_knownChildRegions.ContainsKey(regionHandle)) + spRegionSizeInfo sizeInfo = new spRegionSizeInfo(); + sizeInfo.sizeX = region.RegionSizeX; + sizeInfo.sizeY = region.RegionSizeY; + ulong regionHandle = region.RegionHandle; + + if (!m_knownChildRegionsSizeInfo.ContainsKey(regionHandle)) { - uint x, y; - Utils.LongToUInts(regionHandle, out x, out y); - m_knownChildRegions.Add(regionHandle, cap); + m_knownChildRegionsSizeInfo.Add(regionHandle, sizeInfo); + + } + else + m_knownChildRegionsSizeInfo[regionHandle] = sizeInfo; + } + } + + public void SetNeighbourRegionSizeInfo(List regionsList) + { + lock (m_knownChildRegions) + { + m_knownChildRegionsSizeInfo.Clear(); + foreach (GridRegion region in regionsList) + { + spRegionSizeInfo sizeInfo = new spRegionSizeInfo(); + sizeInfo.sizeX = region.RegionSizeX; + sizeInfo.sizeY = region.RegionSizeY; + ulong regionHandle = region.RegionHandle; + m_knownChildRegionsSizeInfo.Add(regionHandle, sizeInfo); } } } @@ -1539,6 +1572,7 @@ namespace OpenSim.Region.Framework.Scenes //if (m_knownChildRegions.ContainsKey(regionHandle)) // m_log.DebugFormat(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); m_knownChildRegions.Remove(regionHandle); + m_knownChildRegionsSizeInfo.Remove(regionHandle); } } @@ -1558,7 +1592,6 @@ namespace OpenSim.Region.Framework.Scenes Scene.CapsModule.DropChildSeed(UUID, handle); } - public Dictionary KnownRegions { get @@ -1804,7 +1837,7 @@ namespace OpenSim.Region.Framework.Scenes bool haveAnims = (animIDs != null && animseqs != null && animsobjs != null); - if(haveAnims) + if (haveAnims) SendAnimPackToAgent(this, animIDs, animseqs, animsobjs); // we should be able to receive updates, etc @@ -1831,19 +1864,20 @@ namespace OpenSim.Region.Framework.Scenes } // greys if m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - + // attachments if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) { if (Scene.AttachmentsModule != null) - // Util.FireAndForget( - // o => - // { + // Util.FireAndForget( + // o => + // { if (!isNPC) Scene.AttachmentsModule.RezAttachments(this); else - Util.FireAndForget(x => { + Util.FireAndForget(x => + { Scene.AttachmentsModule.RezAttachments(this); }); // }); @@ -1855,7 +1889,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - foreach(SceneObjectGroup sog in m_attachments) + foreach (SceneObjectGroup sog in m_attachments) { sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); @@ -1880,10 +1914,9 @@ namespace OpenSim.Region.Framework.Scenes } m_log.DebugFormat("[CompleteMovement] attachments: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - - // Create child agents in neighbouring regions if (openChildAgents) { + // Create child agents in neighbouring regions IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) { @@ -3955,8 +3988,9 @@ namespace OpenSim.Region.Framework.Scenes /// The new region's x on the map /// The new region's y on the map /// - public void CloseChildAgents(uint newRegionX, uint newRegionY) + public void CloseChildAgents(ulong newRegionHandle, int newRegionSizeX, int newRegionSizeY) { + uint newRegionX, newRegionY; List byebyeRegions = new List(); List knownRegions = KnownRegionHandles; m_log.DebugFormat( @@ -3964,19 +3998,35 @@ namespace OpenSim.Region.Framework.Scenes knownRegions.Count, Scene.RegionInfo.RegionName); //DumpKnownRegions(); + Util.RegionHandleToRegionLoc(newRegionHandle, out newRegionX, out newRegionY); + + uint x, y; + spRegionSizeInfo regInfo; + foreach (ulong handle in knownRegions) { // Don't close the agent on this region yet if (handle != Scene.RegionInfo.RegionHandle) { - uint x, y; Util.RegionHandleToRegionLoc(handle, out x, out y); + if (m_knownChildRegionsSizeInfo.TryGetValue(handle, out regInfo)) + { -// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); -// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); - if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) + // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); + // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); + if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY, + regInfo.sizeX, regInfo.sizeY, newRegionSizeX, newRegionSizeY)) + { + byebyeRegions.Add(handle); + } + } + else { - byebyeRegions.Add(handle); + if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY, + (int)Constants.RegionSize, (int)Constants.RegionSize, newRegionSizeX, newRegionSizeY)) + { + byebyeRegions.Add(handle); + } } } } @@ -5382,11 +5432,8 @@ namespace OpenSim.Region.Framework.Scenes SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); if (spawnPoints.Length == 0) { - if(m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) - { - pos.X = 128.0f; - pos.Y = 128.0f; - } + pos.X = 128.0f; + pos.Y = 128.0f; return; } -- cgit v1.1 From 4905c74ddffba50bb3e576c69fdc71c64cfcc3b8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 31 Aug 2015 14:08:32 +0100 Subject: start sending terrain patchs in completmovement where we know its position. Also reset camera to position on makeroot --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 605c788..61e31e4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3030,7 +3030,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientTerrainEvents(IClientAPI client) { - client.OnRegionHandShakeReply += SendLayerData; +// client.OnRegionHandShakeReply += SendLayerData; } public virtual void SubscribeToClientPrimEvents(IClientAPI client) @@ -3158,7 +3158,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) { - client.OnRegionHandShakeReply -= SendLayerData; +// client.OnRegionHandShakeReply -= SendLayerData; } public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 045a450..cd5525c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1198,6 +1198,8 @@ no information to check this } AbsolutePosition = pos; + // reset camera to avatar pos + CameraPosition = pos; if (m_teleportFlags == TeleportFlags.Default) { @@ -1733,6 +1735,10 @@ no information to check this look = new Vector3(0.99f, 0.042f, 0); } +// start sending terrain patchs + if (!isNPC) + Scene.SendLayerData(ControllingClient); + if (!IsChildAgent && !isNPC) { InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46); -- cgit v1.1 From 31a50a73cbd80829f75c293087472b4ce9d6abc8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 31 Aug 2015 14:21:50 +0100 Subject: dont change camera on crossings --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd5525c..6390d26 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1198,9 +1198,6 @@ no information to check this } AbsolutePosition = pos; - // reset camera to avatar pos - CameraPosition = pos; - if (m_teleportFlags == TeleportFlags.Default) { Vector3 vel = Velocity; @@ -1209,8 +1206,11 @@ no information to check this PhysicsActor.SetMomentum(vel); } else + { AddToPhysicalScene(isFlying); - + // reset camera to avatar pos + CameraPosition = pos; + } if (ForceFly) { -- cgit v1.1