aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs44
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs2
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs160
5 files changed, 108 insertions, 107 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index a5abe76..24a2db7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -166,8 +166,6 @@ namespace OpenSim.Region.Framework.Scenes
166 /// <param name="remoteClient"></param> 166 /// <param name="remoteClient"></param>
167 public void SelectPrim(List<uint> primIDs, IClientAPI remoteClient) 167 public void SelectPrim(List<uint> primIDs, IClientAPI remoteClient)
168 { 168 {
169 List<ISceneEntity> needUpdates = new List<ISceneEntity>();
170
171 foreach(uint primLocalID in primIDs) 169 foreach(uint primLocalID in primIDs)
172 { 170 {
173 SceneObjectPart part = GetSceneObjectPart(primLocalID); 171 SceneObjectPart part = GetSceneObjectPart(primLocalID);
@@ -179,8 +177,6 @@ namespace OpenSim.Region.Framework.Scenes
179 if (sog == null) 177 if (sog == null)
180 continue; 178 continue;
181 179
182 needUpdates.Add((ISceneEntity)part);
183
184 // waste of time because properties do not send prim flags as they should 180 // waste of time because properties do not send prim flags as they should
185 // if a friend got or lost edit rights after login, a full update is needed 181 // if a friend got or lost edit rights after login, a full update is needed
186 if(sog.OwnerID != remoteClient.AgentId) 182 if(sog.OwnerID != remoteClient.AgentId)
@@ -193,10 +189,9 @@ namespace OpenSim.Region.Framework.Scenes
193 part.IsSelected = true; 189 part.IsSelected = true;
194 EventManager.TriggerParcelPrimCountTainted(); 190 EventManager.TriggerParcelPrimCountTainted();
195 } 191 }
196 }
197 192
198 if(needUpdates.Count > 0) 193 part.SendPropertiesToClient(remoteClient);
199 remoteClient.SendSelectedPartsProprieties(needUpdates); 194 }
200 } 195 }
201 196
202 /// <summary> 197 /// <summary>
@@ -248,38 +243,7 @@ namespace OpenSim.Region.Framework.Scenes
248 SceneObjectPart part = GetSceneObjectPart(primLocalID); 243 SceneObjectPart part = GetSceneObjectPart(primLocalID);
249 if (part == null) 244 if (part == null)
250 return; 245 return;
251 /* 246
252 // A deselect packet contains all the local prims being deselected. However, since selection is still
253 // group based we only want the root prim to trigger a full update - otherwise on objects with many prims
254 // we end up sending many duplicate ObjectUpdates
255 if (part.ParentGroup.RootPart.LocalId != part.LocalId)
256 return;
257
258 // This is wrong, wrong, wrong. Selection should not be
259 // handled by group, but by prim. Legacy cruft.
260 // TODO: Make selection flagging per prim!
261 //
262 if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)
263 || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId))
264 part.ParentGroup.IsSelected = false;
265
266 part.ParentGroup.ScheduleGroupForFullUpdate();
267
268 // If it's not an attachment, and we are allowed to move it,
269 // then we might have done so. If we moved across a parcel
270 // boundary, we will need to recount prims on the parcels.
271 // For attachments, that makes no sense.
272 //
273 if (!part.ParentGroup.IsAttachment)
274 {
275 if (Permissions.CanEditObject(
276 part.UUID, remoteClient.AgentId)
277 || Permissions.CanMoveObject(
278 part.UUID, remoteClient.AgentId))
279 EventManager.TriggerParcelPrimCountTainted();
280 }
281 */
282
283 bool oldgprSelect = part.ParentGroup.IsSelected; 247 bool oldgprSelect = part.ParentGroup.IsSelected;
284 248
285 // This is wrong, wrong, wrong. Selection should not be 249 // This is wrong, wrong, wrong. Selection should not be
@@ -614,7 +578,7 @@ namespace OpenSim.Region.Framework.Scenes
614 { 578 {
615 m_log.Error( 579 m_log.Error(
616 string.Format( 580 string.Format(
617 "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e)); 581 "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e, folderID));
618 } 582 }
619 Thread.Sleep(20); 583 Thread.Sleep(20);
620 } 584 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 168080f..ca32940 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -67,8 +67,6 @@ namespace OpenSim.Region.Framework.Scenes
67 67
68 #region Fields 68 #region Fields
69 69
70 public bool EmergencyMonitoring = false;
71
72 /// <summary> 70 /// <summary>
73 /// Show debug information about animations. 71 /// Show debug information about animations.
74 /// </summary> 72 /// </summary>
@@ -4606,7 +4604,8 @@ Label_GroupsDone:
4606 } 4604 }
4607 4605
4608 // TODO: This check should probably be in QueryAccess(). 4606 // TODO: This check should probably be in QueryAccess().
4609 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); 4607 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID,
4608 (float)RegionInfo.RegionSizeX * 0.5f, (float)RegionInfo.RegionSizeY * 0.5f);
4610 if (nearestParcel == null) 4609 if (nearestParcel == null)
4611 { 4610 {
4612 m_log.InfoFormat( 4611 m_log.InfoFormat(
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 1de55ec..d406625 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -287,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes
287 } 287 }
288 catch (Exception e) 288 catch (Exception e)
289 { 289 {
290 m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); 290 m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception {0}", e));
291 } 291 }
292 } 292 }
293 293
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 1141f54..f5f83ca 100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -246,11 +246,11 @@ namespace OpenSim.Region.Framework.Scenes
246 // try to work around that scale down X and Y acording to region size, so reducing the resolution 246 // try to work around that scale down X and Y acording to region size, so reducing the resolution
247 // 247 //
248 // viewers need to scale up 248 // viewers need to scale up
249 float scaleX = m_parentScene.RegionInfo.RegionSizeX / Constants.RegionSize; 249 float scaleX = (float)m_parentScene.RegionInfo.RegionSizeX / (float)Constants.RegionSize;
250 if (scaleX == 0) 250 if (scaleX == 0)
251 scaleX = 1.0f; 251 scaleX = 1.0f;
252 scaleX = 1.0f / scaleX; 252 scaleX = 1.0f / scaleX;
253 float scaleY = m_parentScene.RegionInfo.RegionSizeY / Constants.RegionSize; 253 float scaleY = (float)m_parentScene.RegionInfo.RegionSizeY / (float)Constants.RegionSize;
254 if (scaleY == 0) 254 if (scaleY == 0)
255 scaleY = 1.0f; 255 scaleY = 1.0f;
256 scaleY = 1.0f / scaleY; 256 scaleY = 1.0f / scaleY;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6f4d6c3..3378ead 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -781,6 +781,34 @@ namespace OpenSim.Region.Framework.Scenes
781 } 781 }
782 } 782 }
783 783
784 // requested Velocity for physics engines avatar motors
785 // only makes sense if there is a physical rep
786 public Vector3 TargetVelocity
787 {
788 get
789 {
790 if (PhysicsActor != null)
791 return PhysicsActor.TargetVelocity;
792 else
793 return Vector3.Zero;
794 }
795
796 set
797 {
798 if (PhysicsActor != null)
799 {
800 try
801 {
802 PhysicsActor.TargetVelocity = value;
803 }
804 catch (Exception e)
805 {
806 m_log.Error("[SCENE PRESENCE]: TARGETVELOCITY " + e.Message);
807 }
808 }
809 }
810 }
811
784 private Quaternion m_bodyRot = Quaternion.Identity; 812 private Quaternion m_bodyRot = Quaternion.Identity;
785 813
786 /// <summary> 814 /// <summary>
@@ -2269,6 +2297,46 @@ namespace OpenSim.Region.Framework.Scenes
2269 /// <param name="distance"></param> 2297 /// <param name="distance"></param>
2270 /// 2298 ///
2271 2299
2300 private void checkCameraCollision()
2301 {
2302 if(!m_scene.PhysicsScene.SupportsRayCast())
2303 return;
2304
2305 ++m_movementUpdateCount;
2306 if (m_movementUpdateCount < 1)
2307 m_movementUpdateCount = 1;
2308
2309 if (m_doingCamRayCast || m_movementUpdateCount % NumMovementsBetweenRayCast != 0)
2310 return;
2311
2312 if (m_followCamAuto && !m_mouseLook)
2313 {
2314 Vector3 posAdjusted = AbsolutePosition;
2315// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
2316 // not good for tiny or huge avatars
2317 posAdjusted.Z += 1.0f; // viewer current camera focus point
2318 Vector3 tocam = CameraPosition - posAdjusted;
2319
2320 float distTocamlen = tocam.LengthSquared();
2321 if (distTocamlen > 0.08f && distTocamlen < 400)
2322 {
2323 distTocamlen = (float)Math.Sqrt(distTocamlen);
2324 tocam *= (1.0f / distTocamlen);
2325
2326 m_doingCamRayCast = true;
2327 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
2328 return;
2329 }
2330 }
2331
2332 if (CameraConstraintActive)
2333 {
2334 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
2335 UpdateCameraCollisionPlane(plane);
2336 CameraConstraintActive = false;
2337 }
2338 }
2339
2272 private void UpdateCameraCollisionPlane(Vector4 plane) 2340 private void UpdateCameraCollisionPlane(Vector4 plane)
2273 { 2341 {
2274 if (m_lastCameraCollisionPlane != plane) 2342 if (m_lastCameraCollisionPlane != plane)
@@ -2280,17 +2348,14 @@ namespace OpenSim.Region.Framework.Scenes
2280 2348
2281 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) 2349 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
2282 { 2350 {
2283 const float POSITION_TOLERANCE = 0.02f; 2351// const float POSITION_TOLERANCE = 0.02f;
2284 const float ROTATION_TOLERANCE = 0.02f; 2352// const float ROTATION_TOLERANCE = 0.02f;
2285 2353
2286 m_doingCamRayCast = false;
2287 if (hitYN && localid != LocalId) 2354 if (hitYN && localid != LocalId)
2288 { 2355 {
2289 SceneObjectGroup group = m_scene.GetGroupByPrim(localid); 2356 if (localid != 0)
2290 bool IsPrim = group != null;
2291 if (IsPrim)
2292 { 2357 {
2293 SceneObjectPart part = group.GetPart(localid); 2358 SceneObjectPart part = m_scene.GetSceneObjectPart(localid);
2294 if (part != null && !part.VolumeDetectActive) 2359 if (part != null && !part.VolumeDetectActive)
2295 { 2360 {
2296 CameraConstraintActive = true; 2361 CameraConstraintActive = true;
@@ -2323,13 +2388,16 @@ namespace OpenSim.Region.Framework.Scenes
2323 UpdateCameraCollisionPlane(plane); 2388 UpdateCameraCollisionPlane(plane);
2324 } 2389 }
2325 } 2390 }
2326 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 2391// else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
2327 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 2392// !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
2393 else if(CameraConstraintActive)
2328 { 2394 {
2329 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... 2395 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right...
2330 UpdateCameraCollisionPlane(plane); 2396 UpdateCameraCollisionPlane(plane);
2331 CameraConstraintActive = false; 2397 CameraConstraintActive = false;
2332 } 2398 }
2399
2400 m_doingCamRayCast = false;
2333 } 2401 }
2334 2402
2335 /// <summary> 2403 /// <summary>
@@ -2414,38 +2482,8 @@ namespace OpenSim.Region.Framework.Scenes
2414 2482
2415 // Raycast from the avatar's head to the camera to see if there's anything blocking the view 2483 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
2416 // this exclude checks may not be complete 2484 // this exclude checks may not be complete
2417 2485 if(agentData.NeedsCameraCollision && ParentID == 0) // condition parentID may be wrong
2418 if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) 2486 checkCameraCollision();
2419 {
2420 if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0)
2421 {
2422 Vector3 posAdjusted = AbsolutePosition;
2423// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
2424 posAdjusted.Z += 1.0f; // viewer current camera focus point
2425 Vector3 tocam = CameraPosition - posAdjusted;
2426 tocam.X = (float)Math.Round(tocam.X, 1);
2427 tocam.Y = (float)Math.Round(tocam.Y, 1);
2428 tocam.Z = (float)Math.Round(tocam.Z, 1);
2429
2430 float distTocamlen = tocam.Length();
2431 if (distTocamlen > 0.3f)
2432 {
2433 tocam *= (1.0f / distTocamlen);
2434 posAdjusted.X = (float)Math.Round(posAdjusted.X, 1);
2435 posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1);
2436 posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1);
2437
2438 m_doingCamRayCast = true;
2439 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
2440 }
2441 }
2442 else if (CameraConstraintActive && (m_mouseLook || ParentID != 0))
2443 {
2444 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
2445 UpdateCameraCollisionPlane(plane);
2446 CameraConstraintActive = false;
2447 }
2448 }
2449 2487
2450 uint flagsForScripts = (uint)flags; 2488 uint flagsForScripts = (uint)flags;
2451 flags = RemoveIgnoredControls(flags, IgnoredControls); 2489 flags = RemoveIgnoredControls(flags, IgnoredControls);
@@ -2714,14 +2752,10 @@ namespace OpenSim.Region.Framework.Scenes
2714 // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); 2752 // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
2715 2753
2716 if (IsChildAgent) 2754 if (IsChildAgent)
2717 {
2718 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
2719 return; 2755 return;
2720 }
2721 2756
2722 ++m_movementUpdateCount; 2757 if(IsInTransit)
2723 if (m_movementUpdateCount < 1) 2758 return;
2724 m_movementUpdateCount = 1;
2725 2759
2726// AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; 2760// AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
2727 2761
@@ -2731,7 +2765,7 @@ namespace OpenSim.Region.Framework.Scenes
2731 // Use these three vectors to figure out what the agent is looking at 2765 // Use these three vectors to figure out what the agent is looking at
2732 // Convert it to a Matrix and/or Quaternion 2766 // Convert it to a Matrix and/or Quaternion
2733 2767
2734 // this my need lock 2768 // this may need lock
2735 CameraAtAxis = agentData.CameraAtAxis; 2769 CameraAtAxis = agentData.CameraAtAxis;
2736 CameraLeftAxis = agentData.CameraLeftAxis; 2770 CameraLeftAxis = agentData.CameraLeftAxis;
2737 CameraUpAxis = agentData.CameraUpAxis; 2771 CameraUpAxis = agentData.CameraUpAxis;
@@ -2745,24 +2779,28 @@ namespace OpenSim.Region.Framework.Scenes
2745 2779
2746 DrawDistance = agentData.Far; 2780 DrawDistance = agentData.Far;
2747 2781
2748 // Check if Client has camera in 'follow cam' or 'build' mode.
2749 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
2750
2751 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
2752 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
2753 2782
2754 2783 // Check if Client has camera in 'follow cam' or 'build' mode.
2755 //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); 2784// Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
2756 // Raycast from the avatar's head to the camera to see if there's anything blocking the view 2785 m_followCamAuto = false;
2757 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) 2786 if(!m_mouseLook)
2758 { 2787 {
2759 if (m_followCamAuto) 2788 if((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f))
2760 { 2789 {
2761 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 2790 Vector3 camdif = new Vector3(1f, 0f, 0f) * Rotation;
2762 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 2791 float ftmp = camdif.X - CameraAtAxis.X;
2792 if(Math.Abs(ftmp) < 0.1f)
2793 {
2794 ftmp = camdif.Y - CameraAtAxis.Y;
2795 if(Math.Abs(ftmp) < 0.1f)
2796 m_followCamAuto = true;
2797 }
2763 } 2798 }
2764 } 2799 }
2765 2800
2801 if(agentData.NeedsCameraCollision)
2802 checkCameraCollision();
2803
2766 TriggerScenePresenceUpdated(); 2804 TriggerScenePresenceUpdated();
2767 } 2805 }
2768 2806
@@ -3649,7 +3687,7 @@ namespace OpenSim.Region.Framework.Scenes
3649 m_forceToApplyValid = true; 3687 m_forceToApplyValid = true;
3650 } 3688 }
3651*/ 3689*/
3652 Velocity = direc; 3690 TargetVelocity = direc;
3653 Animator.UpdateMovementAnimations(); 3691 Animator.UpdateMovementAnimations();
3654 } 3692 }
3655 3693