diff options
author | Melanie | 2012-12-17 02:01:47 +0100 |
---|---|---|
committer | Melanie | 2012-12-17 02:01:47 +0100 |
commit | 51354bad484befe0a3a4c0b1840523e24c145235 (patch) | |
tree | d75ba724c0ff04886e8680ce9e49a5e7d498dda4 /OpenSim/Region/Framework | |
parent | Merge branch 'avination' of ssh://3dhosting.de/var/git/careminster into avina... (diff) | |
parent | *TESTP unscripted sit: missing files (diff) | |
download | opensim-SC-51354bad484befe0a3a4c0b1840523e24c145235.zip opensim-SC-51354bad484befe0a3a4c0b1840523e24c145235.tar.gz opensim-SC-51354bad484befe0a3a4c0b1840523e24c145235.tar.bz2 opensim-SC-51354bad484befe0a3a4c0b1840523e24c145235.tar.xz |
Merge branch 'ubitwork' into avination
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 222 |
1 files changed, 48 insertions, 174 deletions
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 | |||
2103 | } | 2103 | } |
2104 | else | 2104 | else |
2105 | { | 2105 | { |
2106 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2106 | // if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2107 | { | 2107 | // { |
2108 | // m_log.DebugFormat( | 2108 | // m_log.DebugFormat( |
2109 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | 2109 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", |
2110 | // Name, part.Name, part.LocalId); | 2110 | // Name, part.Name, part.LocalId); |
2111 | 2111 | ||
2112 | if (m_scene.PhysicsScene != null && | ||
2113 | part.PhysActor != null && | ||
2114 | Util.GetDistanceTo(AbsolutePosition, pos) <= 30) | ||
2115 | { | ||
2116 | |||
2117 | Vector3 camdif = CameraPosition - part.AbsolutePosition; | ||
2118 | camdif.Normalize(); | ||
2119 | |||
2120 | // m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString()); | ||
2121 | |||
2122 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) | ||
2123 | return; | ||
2124 | } | ||
2125 | |||
2126 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | ||
2127 | { | ||
2128 | |||
2112 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2129 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2113 | canSit = true; | 2130 | canSit = true; |
2114 | } | 2131 | } |
@@ -2196,197 +2213,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
2196 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2213 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2197 | } | 2214 | } |
2198 | 2215 | ||
2199 | /* | 2216 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) |
2200 | public void SitRayCastAvatarPosition(SceneObjectPart part) | ||
2201 | { | 2217 | { |
2202 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2203 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2204 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2205 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2206 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2207 | } | ||
2208 | 2218 | ||
2209 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2219 | if (status < 0) |
2210 | { | ||
2211 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2212 | if (part != null) | ||
2213 | { | ||
2214 | if (hitYN) | ||
2215 | { | ||
2216 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2217 | { | ||
2218 | SitRaycastFindEdge(collisionPoint, normal); | ||
2219 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2220 | } | ||
2221 | else | ||
2222 | { | ||
2223 | SitRayCastAvatarPositionCameraZ(part); | ||
2224 | } | ||
2225 | } | ||
2226 | else | ||
2227 | { | ||
2228 | SitRayCastAvatarPositionCameraZ(part); | ||
2229 | } | ||
2230 | } | ||
2231 | else | ||
2232 | { | 2220 | { |
2233 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2221 | ControllingClient.SendAlertMessage("Sit position no longer exists"); |
2234 | m_requestedSitTargetUUID = UUID.Zero; | 2222 | return; |
2235 | m_requestedSitTargetID = 0; | ||
2236 | m_requestedSitOffset = Vector3.Zero; | ||
2237 | } | 2223 | } |
2238 | 2224 | ||
2239 | } | 2225 | if (status == 0) |
2240 | 2226 | return; | |
2241 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2242 | { | ||
2243 | // Next, try to raycast from the camera Z position | ||
2244 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2245 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2246 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2247 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2248 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2249 | } | ||
2250 | 2227 | ||
2251 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2228 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); |
2252 | { | 2229 | if (part == null || part.ParentGroup.IsAttachment) |
2253 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2254 | if (part != null) | ||
2255 | { | 2230 | { |
2256 | if (hitYN) | 2231 | return; |
2257 | { | ||
2258 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2259 | { | ||
2260 | SitRaycastFindEdge(collisionPoint, normal); | ||
2261 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2262 | } | ||
2263 | else | ||
2264 | { | ||
2265 | SitRayCastCameraPosition(part); | ||
2266 | } | ||
2267 | } | ||
2268 | else | ||
2269 | { | ||
2270 | SitRayCastCameraPosition(part); | ||
2271 | } | ||
2272 | } | ||
2273 | else | ||
2274 | { | ||
2275 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2276 | m_requestedSitTargetUUID = UUID.Zero; | ||
2277 | m_requestedSitTargetID = 0; | ||
2278 | m_requestedSitOffset = Vector3.Zero; | ||
2279 | } | 2232 | } |
2280 | 2233 | ||
2281 | } | 2234 | // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); |
2282 | 2235 | ||
2283 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2236 | part.AddSittingAvatar(UUID); |
2284 | { | ||
2285 | // Next, try to raycast from the camera position | ||
2286 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2287 | Vector3 StartRayCastPosition = CameraPosition; | ||
2288 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2289 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2290 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2291 | } | ||
2292 | 2237 | ||
2293 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2238 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); |
2294 | { | 2239 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); |
2295 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2240 | bool forceMouselook = part.GetForceMouselook(); |
2296 | if (part != null) | ||
2297 | { | ||
2298 | if (hitYN) | ||
2299 | { | ||
2300 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2301 | { | ||
2302 | SitRaycastFindEdge(collisionPoint, normal); | ||
2303 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2304 | } | ||
2305 | else | ||
2306 | { | ||
2307 | SitRayHorizontal(part); | ||
2308 | } | ||
2309 | } | ||
2310 | else | ||
2311 | { | ||
2312 | SitRayHorizontal(part); | ||
2313 | } | ||
2314 | } | ||
2315 | else | ||
2316 | { | ||
2317 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2318 | m_requestedSitTargetUUID = UUID.Zero; | ||
2319 | m_requestedSitTargetID = 0; | ||
2320 | m_requestedSitOffset = Vector3.Zero; | ||
2321 | } | ||
2322 | 2241 | ||
2323 | } | 2242 | ControllingClient.SendSitResponse( |
2243 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2324 | 2244 | ||
2325 | public void SitRayHorizontal(SceneObjectPart part) | 2245 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2326 | { | ||
2327 | // Next, try to raycast from the avatar position to fwd | ||
2328 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2329 | Vector3 StartRayCastPosition = CameraPosition; | ||
2330 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2331 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2332 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | ||
2333 | } | ||
2334 | 2246 | ||
2335 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2247 | // assuming no autopilot in use |
2336 | { | 2248 | Velocity = Vector3.Zero; |
2337 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2249 | RemoveFromPhysicalScene(); |
2338 | if (part != null) | ||
2339 | { | ||
2340 | if (hitYN) | ||
2341 | { | ||
2342 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2343 | { | ||
2344 | SitRaycastFindEdge(collisionPoint, normal); | ||
2345 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2346 | // Next, try to raycast from the camera position | ||
2347 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2348 | Vector3 StartRayCastPosition = CameraPosition; | ||
2349 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2350 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2351 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2352 | } | ||
2353 | else | ||
2354 | { | ||
2355 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2356 | m_requestedSitTargetUUID = UUID.Zero; | ||
2357 | m_requestedSitTargetID = 0; | ||
2358 | m_requestedSitOffset = Vector3.Zero; | ||
2359 | } | ||
2360 | } | ||
2361 | else | ||
2362 | { | ||
2363 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2364 | m_requestedSitTargetUUID = UUID.Zero; | ||
2365 | m_requestedSitTargetID = 0; | ||
2366 | m_requestedSitOffset = Vector3.Zero; | ||
2367 | } | ||
2368 | } | ||
2369 | else | ||
2370 | { | ||
2371 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2372 | m_requestedSitTargetUUID = UUID.Zero; | ||
2373 | m_requestedSitTargetID = 0; | ||
2374 | m_requestedSitOffset = Vector3.Zero; | ||
2375 | } | ||
2376 | 2250 | ||
2377 | } | 2251 | Rotation = Orientation; |
2252 | m_pos = offset; | ||
2378 | 2253 | ||
2379 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2254 | m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now |
2380 | { | 2255 | part.ParentGroup.AddAvatar(UUID); |
2381 | int i = 0; | ||
2382 | //throw new NotImplementedException(); | ||
2383 | //m_requestedSitTargetUUID = UUID.Zero; | ||
2384 | //m_requestedSitTargetID = 0; | ||
2385 | //m_requestedSitOffset = Vector3.Zero; | ||
2386 | 2256 | ||
2387 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2257 | ParentPart = part; |
2258 | ParentID = part.LocalId; | ||
2259 | |||
2260 | Animator.TrySetMovementAnimation("SIT"); | ||
2261 | SendAvatarDataToAllAgents(); | ||
2388 | } | 2262 | } |
2389 | */ | 2263 | |
2390 | 2264 | ||
2391 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2265 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2392 | { | 2266 | { |