diff options
5 files changed, 77 insertions, 60 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ff9df37..85f4ee5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2109,9 +2109,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2109 | if (part == null) | 2109 | if (part == null) |
2110 | return; | 2110 | return; |
2111 | 2111 | ||
2112 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2113 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2114 | |||
2115 | if (PhysicsActor != null) | 2112 | if (PhysicsActor != null) |
2116 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; | 2113 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2117 | 2114 | ||
@@ -2130,25 +2127,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2130 | } | 2127 | } |
2131 | else | 2128 | else |
2132 | { | 2129 | { |
2133 | // if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2130 | if (PhysicsSit(part,offset)) // physics engine |
2134 | // { | 2131 | return; |
2135 | // m_log.DebugFormat( | ||
2136 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2137 | // Name, part.Name, part.LocalId); | ||
2138 | |||
2139 | if (m_scene.PhysicsScene != null && | ||
2140 | part.PhysActor != null && | ||
2141 | Util.GetDistanceTo(AbsolutePosition, pos) <= 30) | ||
2142 | { | ||
2143 | |||
2144 | Vector3 camdif = CameraPosition - part.AbsolutePosition; | ||
2145 | camdif.Normalize(); | ||
2146 | |||
2147 | // m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString()); | ||
2148 | |||
2149 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) | ||
2150 | return; | ||
2151 | } | ||
2152 | 2132 | ||
2153 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2133 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2154 | { | 2134 | { |
@@ -2156,12 +2136,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2156 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2136 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2157 | canSit = true; | 2137 | canSit = true; |
2158 | } | 2138 | } |
2159 | // else | ||
2160 | // { | ||
2161 | // m_log.DebugFormat( | ||
2162 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2163 | // Name, part.Name, part.LocalId); | ||
2164 | // } | ||
2165 | } | 2139 | } |
2166 | 2140 | ||
2167 | if (canSit) | 2141 | if (canSit) |
@@ -2223,14 +2197,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2223 | m_requestedSitTargetID = part.LocalId; | 2197 | m_requestedSitTargetID = part.LocalId; |
2224 | m_requestedSitTargetUUID = targetID; | 2198 | m_requestedSitTargetUUID = targetID; |
2225 | 2199 | ||
2226 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2227 | |||
2228 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2229 | { | ||
2230 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2231 | //SitRayCastAvatarPosition(part); | ||
2232 | //return; | ||
2233 | } | ||
2234 | } | 2200 | } |
2235 | else | 2201 | else |
2236 | { | 2202 | { |
@@ -2240,24 +2206,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
2240 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2206 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2241 | } | 2207 | } |
2242 | 2208 | ||
2243 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | 2209 | // returns false if does not suport so older sit can be tried |
2210 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) | ||
2244 | { | 2211 | { |
2212 | if (part == null || part.ParentGroup.IsAttachment) | ||
2213 | { | ||
2214 | return true; | ||
2215 | } | ||
2245 | 2216 | ||
2246 | if (status < 0) | 2217 | if ( m_scene.PhysicsScene == null) |
2218 | return false; | ||
2219 | |||
2220 | if (part.PhysActor == null) | ||
2247 | { | 2221 | { |
2248 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2222 | // none physcis shape |
2249 | return; | 2223 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2224 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); | ||
2225 | else | ||
2226 | { // non physical phantom TODO | ||
2227 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); | ||
2228 | return false; | ||
2229 | } | ||
2230 | return true; | ||
2250 | } | 2231 | } |
2251 | 2232 | ||
2252 | if (status == 0) | 2233 | // not doing autopilot |
2234 | m_requestedSitTargetID = 0; | ||
2235 | |||
2236 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) | ||
2237 | return true; | ||
2238 | |||
2239 | return false; | ||
2240 | } | ||
2241 | |||
2242 | // status | ||
2243 | // < 0 ignore | ||
2244 | // 0 bad sit spot | ||
2245 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2246 | { | ||
2247 | if (status < 0) | ||
2253 | return; | 2248 | return; |
2254 | 2249 | ||
2255 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | 2250 | if (status == 0) |
2256 | if (part == null || part.ParentGroup.IsAttachment) | ||
2257 | { | 2251 | { |
2252 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); | ||
2258 | return; | 2253 | return; |
2259 | } | 2254 | } |
2260 | 2255 | ||
2256 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2257 | if (part == null) | ||
2258 | return; | ||
2259 | |||
2261 | // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); | 2260 | // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); |
2262 | 2261 | ||
2263 | part.AddSittingAvatar(UUID); | 2262 | part.AddSittingAvatar(UUID); |
@@ -2269,16 +2268,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2269 | ControllingClient.SendSitResponse( | 2268 | ControllingClient.SendSitResponse( |
2270 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2269 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
2271 | 2270 | ||
2272 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2271 | // not using autopilot |
2273 | |||
2274 | // assuming no autopilot in use | ||
2275 | Velocity = Vector3.Zero; | 2272 | Velocity = Vector3.Zero; |
2276 | RemoveFromPhysicalScene(); | 2273 | RemoveFromPhysicalScene(); |
2277 | 2274 | ||
2278 | Rotation = Orientation; | 2275 | Rotation = Orientation; |
2279 | m_pos = offset; | 2276 | m_pos = offset; |
2280 | 2277 | ||
2281 | m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now | 2278 | m_requestedSitTargetID = 0; |
2282 | part.ParentGroup.AddAvatar(UUID); | 2279 | part.ParentGroup.AddAvatar(UUID); |
2283 | 2280 | ||
2284 | ParentPart = part; | 2281 | ParentPart = part; |
@@ -2286,6 +2283,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2286 | 2283 | ||
2287 | Animator.TrySetMovementAnimation("SIT"); | 2284 | Animator.TrySetMovementAnimation("SIT"); |
2288 | SendAvatarDataToAllAgents(); | 2285 | SendAvatarDataToAllAgents(); |
2286 | |||
2287 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2289 | } | 2288 | } |
2290 | 2289 | ||
2291 | 2290 | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index a442cf0..86e0713 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -353,7 +353,7 @@ namespace OpenSim.Region.Physics.Manager | |||
353 | 353 | ||
354 | public virtual void RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, RaycastCallback retMethod){} | 354 | public virtual void RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, RaycastCallback retMethod){} |
355 | public virtual void RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) { } | 355 | public virtual void RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) { } |
356 | public virtual List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count) | 356 | public virtual List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags flags) |
357 | { | 357 | { |
358 | return new List<ContactResult>(); | 358 | return new List<ContactResult>(); |
359 | } | 359 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs index 561ab1c..54a83c2 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs | |||
@@ -199,6 +199,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
199 | m_PendingRequests.Enqueue(req); | 199 | m_PendingRequests.Enqueue(req); |
200 | } | 200 | } |
201 | 201 | ||
202 | public void QueueRequest(IntPtr geom, Vector3 position, Vector3 direction, float length, int count,RayFilterFlags flags, RayCallback retMethod) | ||
203 | { | ||
204 | ODERayRequest req = new ODERayRequest(); | ||
205 | req.geom = geom; | ||
206 | req.callbackMethod = retMethod; | ||
207 | req.length = length; | ||
208 | req.Normal = direction; | ||
209 | req.Origin = position; | ||
210 | req.Count = count; | ||
211 | req.filter = flags; | ||
212 | |||
213 | m_PendingRequests.Enqueue(req); | ||
214 | } | ||
215 | |||
202 | public void QueueRequest(Vector3 position, Vector3 direction, float length, int count, RaycastCallback retMethod) | 216 | public void QueueRequest(Vector3 position, Vector3 direction, float length, int count, RaycastCallback retMethod) |
203 | { | 217 | { |
204 | ODERayRequest req = new ODERayRequest(); | 218 | ODERayRequest req = new ODERayRequest(); |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs index 225bff8..fd3a3ba 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs | |||
@@ -52,6 +52,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
52 | } | 52 | } |
53 | 53 | ||
54 | private static Vector3 SitAjust = new Vector3(0, 0, 0.4f); | 54 | private static Vector3 SitAjust = new Vector3(0, 0, 0.4f); |
55 | private const RayFilterFlags RaySitFlags = RayFilterFlags.AllPrims | RayFilterFlags.ClosestHit; | ||
55 | 56 | ||
56 | public void Sit(PhysicsActor actor, Vector3 avPos, Vector3 avCameraPosition, Vector3 offset, Vector3 avOffset, SitAvatarCallback PhysicsSitResponse) | 57 | public void Sit(PhysicsActor actor, Vector3 avPos, Vector3 avCameraPosition, Vector3 offset, Vector3 avOffset, SitAvatarCallback PhysicsSitResponse) |
57 | { | 58 | { |
@@ -93,10 +94,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
93 | rayDir.Y *= t; | 94 | rayDir.Y *= t; |
94 | rayDir.Z *= t; | 95 | rayDir.Z *= t; |
95 | 96 | ||
96 | raylen += 0.5f; | 97 | raylen += 30f; // focal point may be far |
97 | List<ContactResult> rayResults; | 98 | List<ContactResult> rayResults; |
98 | 99 | ||
99 | rayResults = m_scene.RaycastActor(actor, avCameraPosition, rayDir , raylen, 1); | 100 | rayResults = m_scene.RaycastActor(actor, avCameraPosition, rayDir, raylen, 1, RaySitFlags); |
100 | if (rayResults.Count == 0 || rayResults[0].ConsumerID != actor.LocalID) | 101 | if (rayResults.Count == 0 || rayResults[0].ConsumerID != actor.LocalID) |
101 | { | 102 | { |
102 | d.GeomGetAABB(geom,out aabb); | 103 | d.GeomGetAABB(geom,out aabb); |
@@ -108,6 +109,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
108 | return; | 109 | return; |
109 | } | 110 | } |
110 | 111 | ||
112 | |||
111 | offset = rayResults[0].Pos - geopos; | 113 | offset = rayResults[0].Pos - geopos; |
112 | double ang; | 114 | double ang; |
113 | float s; | 115 | float s; |
@@ -156,13 +158,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
156 | return; | 158 | return; |
157 | } | 159 | } |
158 | 160 | ||
159 | Vector3 norm = rayResults[0].Normal; | 161 | /* |
162 | // contact normals aren't reliable on meshs or sculpts it seems | ||
163 | Vector3 norm = rayResults[0].Normal; | ||
160 | 164 | ||
161 | if (norm.Z < 0) | 165 | if (norm.Z < 0) |
162 | { | 166 | { |
163 | PhysicsSitResponse(0, actor.LocalID, offset, Quaternion.Identity); | 167 | PhysicsSitResponse(0, actor.LocalID, offset, Quaternion.Identity); |
164 | return; | 168 | return; |
165 | } | 169 | } |
170 | */ | ||
166 | 171 | ||
167 | ang = Math.Atan2(-rayDir.Y, -rayDir.X); | 172 | ang = Math.Atan2(-rayDir.Y, -rayDir.X); |
168 | ang *= 0.5d; | 173 | ang *= 0.5d; |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index fbf2f0d..d344d4d 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -2675,9 +2675,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2675 | m_rayCastManager.QueueRequest(geom,position, direction, length, Count, retMethod); | 2675 | m_rayCastManager.QueueRequest(geom,position, direction, length, Count, retMethod); |
2676 | } | 2676 | } |
2677 | } | 2677 | } |
2678 | 2678 | ||
2679 | // don't like this | 2679 | public override List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags flags) |
2680 | public override List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count) | ||
2681 | { | 2680 | { |
2682 | if (actor != null) | 2681 | if (actor != null) |
2683 | { | 2682 | { |
@@ -2698,7 +2697,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2698 | results.CopyTo(ourResults, 0); | 2697 | results.CopyTo(ourResults, 0); |
2699 | }; | 2698 | }; |
2700 | int waitTime = 0; | 2699 | int waitTime = 0; |
2701 | m_rayCastManager.QueueRequest(geom,position, direction, length, Count, retMethod); | 2700 | m_rayCastManager.QueueRequest(geom,position, direction, length, Count, flags, retMethod); |
2702 | while (ourResults == null && waitTime < 1000) | 2701 | while (ourResults == null && waitTime < 1000) |
2703 | { | 2702 | { |
2704 | Thread.Sleep(1); | 2703 | Thread.Sleep(1); |