diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f96fb85..2ca218c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2297,6 +2297,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
2297 | /// <param name="distance"></param> | 2297 | /// <param name="distance"></param> |
2298 | /// | 2298 | /// |
2299 | 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 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
2317 | Vector3 tocam = CameraPosition - posAdjusted; | ||
2318 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
2319 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
2320 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
2321 | |||
2322 | float distTocamlen = tocam.Length(); | ||
2323 | if (distTocamlen > 0.3f) | ||
2324 | { | ||
2325 | tocam *= (1.0f / distTocamlen); | ||
2326 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
2327 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
2328 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
2329 | |||
2330 | m_doingCamRayCast = true; | ||
2331 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
2332 | } | ||
2333 | } | ||
2334 | else if (CameraConstraintActive) | ||
2335 | { | ||
2336 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... | ||
2337 | UpdateCameraCollisionPlane(plane); | ||
2338 | CameraConstraintActive = false; | ||
2339 | } | ||
2340 | } | ||
2341 | |||
2300 | private void UpdateCameraCollisionPlane(Vector4 plane) | 2342 | private void UpdateCameraCollisionPlane(Vector4 plane) |
2301 | { | 2343 | { |
2302 | if (m_lastCameraCollisionPlane != plane) | 2344 | if (m_lastCameraCollisionPlane != plane) |
@@ -2442,38 +2484,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2442 | 2484 | ||
2443 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 2485 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
2444 | // this exclude checks may not be complete | 2486 | // this exclude checks may not be complete |
2445 | 2487 | if(agentData.NeedsCameraCollision && ParentID == 0) // condition parentID may be wrong | |
2446 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 2488 | checkCameraCollision(); |
2447 | { | ||
2448 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) | ||
2449 | { | ||
2450 | Vector3 posAdjusted = AbsolutePosition; | ||
2451 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; | ||
2452 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
2453 | Vector3 tocam = CameraPosition - posAdjusted; | ||
2454 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
2455 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
2456 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
2457 | |||
2458 | float distTocamlen = tocam.Length(); | ||
2459 | if (distTocamlen > 0.3f) | ||
2460 | { | ||
2461 | tocam *= (1.0f / distTocamlen); | ||
2462 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
2463 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
2464 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
2465 | |||
2466 | m_doingCamRayCast = true; | ||
2467 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
2468 | } | ||
2469 | } | ||
2470 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
2471 | { | ||
2472 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... | ||
2473 | UpdateCameraCollisionPlane(plane); | ||
2474 | CameraConstraintActive = false; | ||
2475 | } | ||
2476 | } | ||
2477 | 2489 | ||
2478 | uint flagsForScripts = (uint)flags; | 2490 | uint flagsForScripts = (uint)flags; |
2479 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 2491 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
@@ -2742,14 +2754,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2742 | // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); | 2754 | // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); |
2743 | 2755 | ||
2744 | if (IsChildAgent) | 2756 | if (IsChildAgent) |
2745 | { | ||
2746 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); | ||
2747 | return; | 2757 | return; |
2748 | } | ||
2749 | 2758 | ||
2750 | ++m_movementUpdateCount; | 2759 | if(IsInTransit) |
2751 | if (m_movementUpdateCount < 1) | 2760 | return; |
2752 | m_movementUpdateCount = 1; | ||
2753 | 2761 | ||
2754 | // AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; | 2762 | // AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; |
2755 | 2763 | ||
@@ -2779,17 +2787,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2779 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) | 2787 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) |
2780 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | 2788 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; |
2781 | 2789 | ||
2782 | 2790 | if(agentData.NeedsCameraCollision) | |
2783 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | 2791 | checkCameraCollision(); |
2784 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | ||
2785 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
2786 | { | ||
2787 | if (m_followCamAuto) | ||
2788 | { | ||
2789 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | ||
2790 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | ||
2791 | } | ||
2792 | } | ||
2793 | 2792 | ||
2794 | TriggerScenePresenceUpdated(); | 2793 | TriggerScenePresenceUpdated(); |
2795 | } | 2794 | } |