aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs73
1 files changed, 72 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 87207a0..2a8436b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -186,6 +186,14 @@ namespace OpenSim.Region.Framework.Scenes
186 //PauPaw:Proper PID Controler for autopilot************ 186 //PauPaw:Proper PID Controler for autopilot************
187 private bool m_moveToPositionInProgress; 187 private bool m_moveToPositionInProgress;
188 private Vector3 m_moveToPositionTarget = Vector3.Zero; 188 private Vector3 m_moveToPositionTarget = Vector3.Zero;
189
190 private bool m_followCamAuto = false;
191
192 private int m_movementUpdateCount = 0;
193
194 private const int NumMovementsBetweenRayCast = 5;
195
196 private bool CameraConstraintActive = false;
189 //private int m_moveToPositionStateStatus = 0; 197 //private int m_moveToPositionStateStatus = 0;
190 //***************************************************** 198 //*****************************************************
191 199
@@ -1073,6 +1081,44 @@ namespace OpenSim.Region.Framework.Scenes
1073 } 1081 }
1074 } 1082 }
1075 1083
1084
1085 /// <summary>
1086 /// Callback for the Camera view block check. Gets called with the results of the camera view block test
1087 /// hitYN is true when there's something in the way.
1088 /// </summary>
1089 /// <param name="hitYN"></param>
1090 /// <param name="collisionPoint"></param>
1091 /// <param name="localid"></param>
1092 /// <param name="distance"></param>
1093 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance)
1094 {
1095 if (m_followCamAuto)
1096 {
1097
1098 if (hitYN)
1099 {
1100 CameraConstraintActive = true;
1101 //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance);
1102
1103 Vector3 normal = Vector3.Normalize(new Vector3(0,0,collisionPoint.Z) - collisionPoint);
1104 ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint)));
1105 }
1106 else
1107 {
1108 if (((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02)
1109 || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)
1110 || lastPhysRot != m_bodyRot))
1111 {
1112 if (CameraConstraintActive)
1113 {
1114 ControllingClient.SendCameraConstraint(new Vector4(0, 0.5f, 0.9f, -3000f));
1115 CameraConstraintActive = false;
1116 }
1117 }
1118 }
1119 }
1120 }
1121
1076 /// <summary> 1122 /// <summary>
1077 /// This is the event handler for client movement. If a client is moving, this event is triggering. 1123 /// This is the event handler for client movement. If a client is moving, this event is triggering.
1078 /// </summary> 1124 /// </summary>
@@ -1098,11 +1144,18 @@ namespace OpenSim.Region.Framework.Scenes
1098 // return; 1144 // return;
1099 //} 1145 //}
1100 1146
1147
1148 m_movementUpdateCount++;
1149 if (m_movementUpdateCount >= int.MaxValue)
1150 m_movementUpdateCount = 1;
1151
1152
1101 // Must check for standing up even when PhysicsActor is null, 1153 // Must check for standing up even when PhysicsActor is null,
1102 // since sitting currently removes avatar from physical scene 1154 // since sitting currently removes avatar from physical scene
1103 //m_log.Debug("agentPos:" + AbsolutePosition.ToString()); 1155 //m_log.Debug("agentPos:" + AbsolutePosition.ToString());
1104 1156
1105 // This is irritating. Really. 1157 // This is irritating. Really.
1158
1106 if (!AbsolutePosition.IsFinite()) 1159 if (!AbsolutePosition.IsFinite())
1107 { 1160 {
1108 RemoveFromPhysicalScene(); 1161 RemoveFromPhysicalScene();
@@ -1157,8 +1210,26 @@ namespace OpenSim.Region.Framework.Scenes
1157 { 1210 {
1158 StandUp(); 1211 StandUp();
1159 } 1212 }
1160
1161 1213
1214
1215
1216 // Check if Client has camera in 'follow cam' or 'build' mode.
1217 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
1218
1219 m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f)
1220 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
1221
1222
1223 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
1224 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
1225 {
1226
1227 if (m_followCamAuto)
1228 {
1229 Vector3 headadjustment = new Vector3(0, 0, 0.3f);
1230 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - (m_pos + headadjustment)), Vector3.Distance(m_CameraCenter, (m_pos + headadjustment)) + 0.3f, RayCastCameraCallback);
1231 }
1232 }
1162 1233
1163 m_mouseLook = (flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 1234 m_mouseLook = (flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1164 1235