* Commit some sit code that's commented out for now.

mysql-performance
Teravus Ovares (Dan Olivares) 2009-12-08 11:28:13 -05:00
parent dd5696e8bd
commit 2f8b9cbf2b
2 changed files with 223 additions and 14 deletions

View File

@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3? m_forceToApply; private Vector3? m_forceToApply;
private uint m_requestedSitTargetID; private uint m_requestedSitTargetID;
private UUID m_requestedSitTargetUUID; private UUID m_requestedSitTargetUUID;
private Vector3 m_requestedSitOffset;
private SendCourseLocationsMethod m_sendCourseLocationsMethod; private SendCourseLocationsMethod m_sendCourseLocationsMethod;
private bool m_startAnimationSet; private bool m_startAnimationSet;
@ -1663,11 +1664,11 @@ namespace OpenSim.Region.Framework.Scenes
return targetPart; return targetPart;
} }
private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset) private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation)
{ {
bool autopilot = true; bool autopilot = true;
Vector3 pos = new Vector3(); Vector3 pos = new Vector3();
Quaternion sitOrientation = Quaternion.Identity; Quaternion sitOrientation = pSitOrientation;
Vector3 cameraEyeOffset = Vector3.Zero; Vector3 cameraEyeOffset = Vector3.Zero;
Vector3 cameraAtOffset = Vector3.Zero; Vector3 cameraAtOffset = Vector3.Zero;
bool forceMouselook = false; bool forceMouselook = false;
@ -1766,12 +1767,17 @@ namespace OpenSim.Region.Framework.Scenes
m_nextSitAnimation = part.SitAnimation; m_nextSitAnimation = part.SitAnimation;
} }
m_requestedSitTargetID = part.LocalId; m_requestedSitTargetID = part.LocalId;
//m_requestedSitOffset = offset; m_requestedSitOffset = offset;
//offset.X += part.Scale.X;// *offset.X; m_requestedSitTargetUUID = targetID;
//offset.Y += part.Scale.Y;// * offset.Y;
//offset.Z += part.Scale.Z;// * offset.Z;
//m_requestedSitOffset = offset;
m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
if (m_scene.PhysicsScene.SupportsRayCast())
{
//m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback());
//SitRayCastAvatarPosition(part);
//return;
}
} }
else else
{ {
@ -1779,14 +1785,201 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
} }
if (m_scene.PhysicsScene.SupportsRayCast())
SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity);
}
/*
public void SitRayCastAvatarPosition(SceneObjectPart part)
{
Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
Vector3 StartRayCastPosition = AbsolutePosition;
Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse);
}
public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
{
SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
if (part != null)
{ {
//m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); if (hitYN)
{
if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
{
SitRaycastFindEdge(collisionPoint, normal);
m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal );
}
else
{
SitRayCastAvatarPositionCameraZ(part);
}
}
else
{
SitRayCastAvatarPositionCameraZ(part);
}
}
else
{
ControllingClient.SendAlertMessage("Sit position no longer exists");
m_requestedSitTargetUUID = UUID.Zero;
m_requestedSitTargetID = 0;
m_requestedSitOffset = Vector3.Zero;
} }
SendSitResponse(remoteClient, targetID, offset);
} }
public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part)
{
// Next, try to raycast from the camera Z position
Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z;
Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse);
}
public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
{
SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
if (part != null)
{
if (hitYN)
{
if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
{
SitRaycastFindEdge(collisionPoint, normal);
m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal);
}
else
{
SitRayCastCameraPosition(part);
}
}
else
{
SitRayCastCameraPosition(part);
}
}
else
{
ControllingClient.SendAlertMessage("Sit position no longer exists");
m_requestedSitTargetUUID = UUID.Zero;
m_requestedSitTargetID = 0;
m_requestedSitOffset = Vector3.Zero;
}
}
public void SitRayCastCameraPosition(SceneObjectPart part)
{
// Next, try to raycast from the camera position
Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
Vector3 StartRayCastPosition = CameraPosition;
Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse);
}
public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
{
SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
if (part != null)
{
if (hitYN)
{
if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
{
SitRaycastFindEdge(collisionPoint, normal);
m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
}
else
{
SitRayHorizontal(part);
}
}
else
{
SitRayHorizontal(part);
}
}
else
{
ControllingClient.SendAlertMessage("Sit position no longer exists");
m_requestedSitTargetUUID = UUID.Zero;
m_requestedSitTargetID = 0;
m_requestedSitOffset = Vector3.Zero;
}
}
public void SitRayHorizontal(SceneObjectPart part)
{
// Next, try to raycast from the avatar position to fwd
Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
Vector3 StartRayCastPosition = CameraPosition;
Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse);
}
public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
{
SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
if (part != null)
{
if (hitYN)
{
if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
{
SitRaycastFindEdge(collisionPoint, normal);
m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
// Next, try to raycast from the camera position
Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
Vector3 StartRayCastPosition = CameraPosition;
Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
//m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition);
}
else
{
ControllingClient.SendAlertMessage("Sit position not accessable.");
m_requestedSitTargetUUID = UUID.Zero;
m_requestedSitTargetID = 0;
m_requestedSitOffset = Vector3.Zero;
}
}
else
{
ControllingClient.SendAlertMessage("Sit position not accessable.");
m_requestedSitTargetUUID = UUID.Zero;
m_requestedSitTargetID = 0;
m_requestedSitOffset = Vector3.Zero;
}
}
else
{
ControllingClient.SendAlertMessage("Sit position no longer exists");
m_requestedSitTargetUUID = UUID.Zero;
m_requestedSitTargetID = 0;
m_requestedSitOffset = Vector3.Zero;
}
}
private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal)
{
int i = 0;
//throw new NotImplementedException();
//m_requestedSitTargetUUID = UUID.Zero;
//m_requestedSitTargetID = 0;
//m_requestedSitOffset = Vector3.Zero;
SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity);
}
*/
public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation)
{ {
if (m_parentID != 0) if (m_parentID != 0)
@ -1807,14 +2000,23 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null) if (part != null)
{ {
m_requestedSitTargetID = part.LocalId; m_requestedSitTargetID = part.LocalId;
//m_requestedSitOffset = offset; m_requestedSitOffset = offset;
m_requestedSitTargetUUID = targetID;
m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
if (m_scene.PhysicsScene.SupportsRayCast())
{
//SitRayCastAvatarPosition(part);
//return;
}
} }
else else
{ {
m_log.Warn("Sit requested on unknown object: " + targetID); m_log.Warn("Sit requested on unknown object: " + targetID);
} }
SendSitResponse(remoteClient, targetID, offset); SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity);
} }
public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)

View File

@ -106,13 +106,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (m_PendingRequests.Count > 0) if (m_PendingRequests.Count > 0)
{ {
ODERayCastRequest[] reqs = m_PendingRequests.ToArray();
for (int i = 0; i < reqs.Length; i++)
{
if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
RayCast(reqs[i]); // if there isn't anyone to send results
}
/*
foreach (ODERayCastRequest req in m_PendingRequests) foreach (ODERayCastRequest req in m_PendingRequests)
{ {
if (req.callbackMethod != null) // quick optimization here, don't raycast if (req.callbackMethod != null) // quick optimization here, don't raycast
RayCast(req); // if there isn't anyone to send results to RayCast(req); // if there isn't anyone to send results to
} }
*/
m_PendingRequests.Clear(); m_PendingRequests.Clear();
} }
} }