touch and world chat working

dsg
Robert Adams 2010-10-19 14:06:59 -07:00
parent 62fbd2ef08
commit 3b9a6a565f
7 changed files with 309 additions and 9 deletions

View File

@ -32,6 +32,7 @@ using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
@ -311,6 +312,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private string m_firstName;
private string m_lastName;
private Vector3 m_startPos;
private RegionSyncClientView m_clientView;
/*
// Throw away duplicate or insignificant updates
@ -326,6 +328,21 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_firstName = first;
m_lastName = last;
m_startPos = startPos;
m_clientView = null;
m_log.Debug("[REGION SYNC AVATAR] instance");
//m_scene.EventManager.OnFrame += Update;
}
public RegionSyncAvatar(Scene scene, UUID agentID, string first, string last, Vector3 startPos, RegionSyncClientView view)
{
m_scene = scene;
m_agentID = agentID;
m_firstName = first;
m_lastName = last;
m_startPos = startPos;
m_clientView = view;
m_log.Debug("[REGION SYNC AVATAR] instance");
@ -476,6 +493,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
{
m_log.Debug("[REGION SYNC AVATAR] SendAnimations");
}
public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
@ -753,6 +771,21 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
{
m_log.Debug("[REGION SYNC AVATAR] SendSitResponse");
if (m_clientView != null)
{
OSDMap data = new OSDMap();
data["agentID"] = OSD.FromUUID(m_agentID);
data["targetID"] = OSD.FromUUID(TargetID);
data["offsetPos"] = OSD.FromVector3(OffsetPos);
data["sitOrientation"] = OSD.FromQuaternion(SitOrientation);
data["autoPilot"] = OSD.FromBoolean(autopilot);
data["cameraAtOffset"] = OSD.FromVector3(CameraAtOffset);
data["cameraEyeOffset"] = OSD.FromVector3(CameraEyeOffset);
data["forceMouseLook"] = OSD.FromBoolean(ForceMouseLook);
RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.SitResponse, OSDParser.SerializeJsonString(data));
m_clientView.Send(rsm);
}
}
public void SendAdminResponse(UUID Token, uint AdminLevel)

View File

@ -295,6 +295,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return;
}
/*
m_log.DebugFormat("{0} NewObject '{1}'", LogHeader, sog.Name);
sog.ForEachPart(delegate(SceneObjectPart part)
{
m_log.DebugFormat("{0} Part {1}, lf={2} f={3}", LogHeader, part.Name,
part.LocalFlags.ToString(), part.Flags.ToString());
});
*/
if (m_scene.AddNewSceneObject(sog, true));
//RegionSyncMessage.HandleSuccess(LogHeader, msg, String.Format("Object \"{0}\" ({1}) ({1}) updated.", sog.Name, sog.UUID.ToString(), sog.LocalId.ToString()));
//else
@ -596,6 +604,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
args.Position = data["pos"].AsVector3();
args.From = data["name"].AsString();
UUID id = data["id"].AsUUID();
// m_log.DebugFormat("{0} chat. chan={1}, from='{2}', msg='{3}'", LogHeader, args.Channel, args.From, args.Message);
args.Scene = m_scene;
args.Type = ChatTypeEnum.Say;
ScenePresence sp;
@ -606,6 +615,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
args.SenderUUID = id;
m_scene.EventManager.TriggerOnChatBroadcast(sp.ControllingClient, args);
}
else {
args.Sender = null;
args.SenderUUID = id;
m_scene.EventManager.TriggerOnChatFromWorld(null, args);
}
//RegionSyncMessage.HandlerDebug(LogHeader, msg, String.Format("Received chat from \"{0}\"", args.From));
RegionSyncMessage.HandleSuccess(LogHeader, msg, String.Format("Received chat from \"{0}\"", args.From));
@ -663,6 +677,37 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
RegionSyncMessage.HandleWarning(LogHeader, msg, String.Format("Agent {0} not found in the scene.", agentID));
}
//m_log.WarnFormat("{0} END of AvatarAppearance handler", LogHeader);
return;
}
case RegionSyncMessage.MsgType.SitResponse:
{
OSDMap data = DeserializeMessage(msg);
if (data == null)
{
RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data.");
return;
}
UUID agentID = data["agentID"].AsUUID();
m_log.DebugFormat("{0} SitResponse for {1}", LogHeader, agentID);
UUID targetID = data["targetID"].AsUUID();
Vector3 offsetPos = data["offsetPos"].AsVector3();
Quaternion sitOrientation = data["sitOrientation"].AsQuaternion();
Boolean autopilot = data["autoPilot"].AsBoolean();
Vector3 cameraAtOffset = data["cameraAtOffset"].AsVector3();
Vector3 cameraEyeOffset = data["cameraEyeOffset"].AsVector3();
Boolean forceMouseLook = data["forceMouseLook"].AsBoolean();
ScenePresence presence;
if (m_scene.TryGetScenePresence(agentID, out presence))
{
presence.ControllingClient.SendSitResponse(targetID, offsetPos, sitOrientation, autopilot,
cameraAtOffset, cameraEyeOffset, forceMouseLook);
}
else
{
RegionSyncMessage.HandleWarning(LogHeader, msg,
String.Format("Agent {0} not found in the scene for SitResponse.", agentID));
}
return;
}
case RegionSyncMessage.MsgType.BalanceClientLoad:
@ -768,6 +813,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
client.OnAgentUpdateRaw += HandleAgentUpdateRaw;
client.OnSetAppearanceRaw += HandleSetAppearanceRaw;
client.OnChatFromClientRaw += HandleChatFromClientRaw;
client.OnAgentRequestSit += HandleAgentRequestSit;
client.OnAgentSit += HandleAgentSit;
client.OnGrabObject += HandleGrabObject;
client.OnGrabUpdate += HandleGrabUpdate;
client.OnDeGrabObject += HandleDeGrabObject;
}
public void EventManager_OnMakeChildAgent(ScenePresence scenep)
@ -867,6 +917,80 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
}
public void HandleAgentRequestSit(object sender, UUID agentID, UUID targetID, Vector3 offset)
{
m_log.DebugFormat("[REGION SYNC CLIENT] HandleAgentRequestSit for {0}", agentID.ToString());
OSDMap data = new OSDMap(3);
data["agentID"] = OSD.FromUUID(agentID);
data["targetID"] = OSD.FromUUID(targetID);
data["offset"] = OSD.FromVector3(offset);
Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentRequestSit, OSDParser.SerializeJsonString(data)));
}
public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
{
m_log.DebugFormat("[REGION SYNC CLIENT] HandleAgentSit for {0}", agentID.ToString());
OSDMap data = new OSDMap(1);
data["agentID"] = OSD.FromUUID(agentID);
Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentSit, OSDParser.SerializeJsonString(data)));
}
public void HandleGrabObject(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{
m_log.DebugFormat("[REGION SYNC CLIENT] HandleGrabObject for {0}", remoteClient.AgentId.ToString());
OSDMap data = new OSDMap(4);
data["agentID"] = OSD.FromUUID(remoteClient.AgentId);
data["localID"] = OSD.FromUInteger(localID);
data["offsetPos"] = OSD.FromVector3(offsetPos);
data["surfaceArgs"] = MakeSurfaceArgsArray(surfaceArgs);
Send(new RegionSyncMessage(RegionSyncMessage.MsgType.GrabObject, OSDParser.SerializeJsonString(data)));
}
public void HandleGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{
m_log.DebugFormat("[REGION SYNC CLIENT] HandleGrabUpdate for {0}", remoteClient.AgentId.ToString());
OSDMap data = new OSDMap(5);
data["agentID"] = OSD.FromUUID(remoteClient.AgentId);
data["objectID"] = OSD.FromUUID(objectID);
data["offset"] = OSD.FromVector3(offset);
data["pos"] = OSD.FromVector3(pos);
data["surfaceArgs"] = MakeSurfaceArgsArray(surfaceArgs);
Send(new RegionSyncMessage(RegionSyncMessage.MsgType.GrabUpdate, OSDParser.SerializeJsonString(data)));
}
public void HandleDeGrabObject(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{
m_log.DebugFormat("[REGION SYNC CLIENT] HandleDeGrabObject for {0}", remoteClient.AgentId.ToString());
OSDMap data = new OSDMap(3);
data["agentID"] = OSD.FromUUID(remoteClient.AgentId);
data["localID"] = OSD.FromUInteger(localID);
data["surfaceArgs"] = MakeSurfaceArgsArray(surfaceArgs);
Send(new RegionSyncMessage(RegionSyncMessage.MsgType.DeGrabObject, OSDParser.SerializeJsonString(data)));
}
/// <summary>
/// Convert a list of SurfaceTouchEventArgs into an OSDArray for transmission.
/// Return an array of maps which each are a list entry.
/// </summary>
/// <param name="surfaceArgs"></param>
/// <returns></returns>
private OSDArray MakeSurfaceArgsArray(List<SurfaceTouchEventArgs> surfaceArgs)
{
OSDArray surfaceList = new OSDArray();
for (int ii = 0; ii < surfaceArgs.Count; ii++)
{
OSDMap surfaceData = new OSDMap(6);
surfaceData["binormal"] = OSD.FromVector3(surfaceArgs[ii].Binormal);
surfaceData["faceIndex"] = OSD.FromInteger(surfaceArgs[ii].FaceIndex);
surfaceData["normal"] = OSD.FromVector3(surfaceArgs[ii].Normal);
surfaceData["position"] = OSD.FromVector3(surfaceArgs[ii].Position);
surfaceData["stCoord"] = OSD.FromVector3(surfaceArgs[ii].STCoord);
surfaceData["uvCoord"] = OSD.FromVector3(surfaceArgs[ii].UVCoord);
surfaceList.Add(surfaceData);
}
return surfaceList;
}
public void HandleChatFromClientRaw(object sender, byte[] chatData)
{
if (chatData != null && sender is IClientAPI)

View File

@ -180,6 +180,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private void ReceiveLoop()
{
m_scene.EventManager.OnChatFromClient += new EventManager.ChatFromClientEvent(EventManager_OnChatFromClient);
m_scene.EventManager.OnChatFromWorld += new EventManager.ChatFromWorldEvent(EventManager_OnChatFromClient);
// Reset stats and time
lastStatTime = DateTime.Now;
@ -349,7 +351,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
if (agentID != null && first != null && last != null && startPos != null)
{
RegionSyncAvatar av = new RegionSyncAvatar(m_scene, agentID, first, last, startPos);
RegionSyncAvatar av = new RegionSyncAvatar(m_scene, agentID, first, last, startPos, this);
lock (m_syncRoot)
{
if (m_syncedAvatars.ContainsKey(agentID))
@ -535,6 +537,119 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_log.WarnFormat("{0} END of AvatarAppearance handler <{1}>", LogHeader, msgID);
return;
}
case RegionSyncMessage.MsgType.AgentRequestSit:
{
OSDMap data = DeserializeMessage(msg);
if (data == null)
{
RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data.");
return;
}
UUID agentID = data["agentID"].AsUUID();
UUID targetID = data["targetID"].AsUUID();
Vector3 offset = data["offset"].AsVector3();
m_log.DebugFormat("{0} AgentRequestSit for {1}", LogHeader, agentID.ToString());
ScenePresence sp;
m_scene.TryGetScenePresence(agentID, out sp);
if (sp != null)
{
sp.HandleAgentRequestSit(sp.ControllingClient, agentID, targetID, offset);
}
return;
}
case RegionSyncMessage.MsgType.AgentSit:
{
OSDMap data = DeserializeMessage(msg);
if (data == null)
{
RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data.");
return;
}
UUID agentID = data["agentID"].AsUUID();
m_log.DebugFormat("{0} AgentSit for {1}", LogHeader, agentID.ToString());
ScenePresence sp;
m_scene.TryGetScenePresence(agentID, out sp);
if (sp != null)
{
sp.HandleAgentSit(sp.ControllingClient, agentID);
}
return;
}
case RegionSyncMessage.MsgType.GrabObject:
{
OSDMap data = DeserializeMessage(msg);
if (data == null)
{
RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data.");
return;
}
UUID agentID = data["agentID"].AsUUID();
uint localID = data["localID"].AsUInteger();
m_log.DebugFormat("{0} GrabObject for {1}. object={2}",
LogHeader, agentID.ToString(), localID);
Vector3 offsetPos = data["offsetPos"].AsVector3();
OSDArray surfaceArray = (OSDArray)data["surfaceArgs"];
List<SurfaceTouchEventArgs> surfaceArgs = ExtractSurfaceArgList(surfaceArray);
ScenePresence sp;
m_scene.TryGetScenePresence(agentID, out sp);
if (sp != null)
{
m_scene.ProcessObjectGrab(localID, offsetPos, sp.ControllingClient, surfaceArgs);
}
return;
}
case RegionSyncMessage.MsgType.GrabUpdate:
{
OSDMap data = DeserializeMessage(msg);
if (data == null)
{
RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data.");
return;
}
UUID agentID = data["agentID"].AsUUID();
UUID objectID = data["objectID"].AsUUID();
m_log.DebugFormat("{0} GrabUpdate for {1}. ObjectID={2}",
LogHeader, agentID.ToString(), objectID.ToString());
Vector3 offset = data["offset"].AsVector3();
Vector3 pos = data["pos"].AsVector3();
OSDArray surfaceArray = (OSDArray)data["surfaceArgs"];
List<SurfaceTouchEventArgs> surfaceArgs = ExtractSurfaceArgList(surfaceArray);
ScenePresence sp;
m_scene.TryGetScenePresence(agentID, out sp);
if (sp != null)
{
m_scene.ProcessObjectGrabUpdate(objectID, offset, pos, sp.ControllingClient, surfaceArgs);
}
return;
}
case RegionSyncMessage.MsgType.DeGrabObject:
{
OSDMap data = DeserializeMessage(msg);
if (data == null)
{
RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data.");
return;
}
UUID agentID = data["agentID"].AsUUID();
m_log.DebugFormat("{0} DeGrabUpdate for {1}", LogHeader, agentID.ToString());
uint localID = data["objectID"].AsUInteger();
OSDArray surfaceArray = (OSDArray)data["surfaceArgs"];
List<SurfaceTouchEventArgs> surfaceArgs = ExtractSurfaceArgList(surfaceArray);
ScenePresence sp;
m_scene.TryGetScenePresence(agentID, out sp);
if (sp != null)
{
m_scene.ProcessObjectDeGrab(localID, sp.ControllingClient, surfaceArgs);
}
return;
}
case RegionSyncMessage.MsgType.ChatFromClient:
{
// Get the data from message and error check
@ -649,6 +764,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
}
private List<SurfaceTouchEventArgs> ExtractSurfaceArgList(OSDArray args)
{
List<SurfaceTouchEventArgs> surfaceArgs = new List<SurfaceTouchEventArgs>();
for (int ii = 0; ii < args.Count; ii++)
{
SurfaceTouchEventArgs stea = new SurfaceTouchEventArgs();
OSDMap entry = (OSDMap)args[ii];
stea.Binormal = entry["binormal"].AsVector3();
stea.FaceIndex = entry["faceIndex"].AsInteger();
stea.Normal = entry["normal"].AsVector3();
stea.Position = entry["position"].AsVector3();
stea.STCoord = entry["stCoord"].AsVector3();
stea.UVCoord = entry["uvCoord"].AsVector3();
surfaceArgs.Add(stea);
}
return surfaceArgs;
}
private bool HandlerDebug(RegionSyncMessage msg, string handlerMessage)
{
m_log.WarnFormat("{0} DBG ({1}): {2}", LogHeader, msg.ToString(), handlerMessage);

View File

@ -42,6 +42,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
AgentAdd,
AgentUpdate,
AgentRemove,
AgentRequestSit,
AgentSit,
GrabObject,
GrabUpdate,
DeGrabObject,
GetTerrain,
GetObjects,
SubscribeObjects,
@ -62,6 +67,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
RemovedAvatar, // avatars
BalanceClientLoad, // Tells CM a client load target and a place to teleport the extras
ChatFromSim,
SitResponse,
// BIDIR
EchoRequest,
EchoResponse,

View File

@ -3117,9 +3117,12 @@ namespace OpenSim.Region.Framework.Scenes
client.OnUpdatePrimFlags += m_sceneGraph.UpdatePrimFlags;
client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily;
client.OnObjectPermissions += HandleObjectPermissionsUpdate;
client.OnGrabObject += ProcessObjectGrab;
client.OnGrabUpdate += ProcessObjectGrabUpdate;
client.OnDeGrabObject += ProcessObjectDeGrab;
if (IsSyncedServer())
{
client.OnGrabObject += ProcessObjectGrab;
client.OnGrabUpdate += ProcessObjectGrabUpdate;
client.OnDeGrabObject += ProcessObjectDeGrab;
}
client.OnUndo += m_sceneGraph.HandleUndo;
client.OnRedo += m_sceneGraph.HandleRedo;
client.OnObjectDescription += m_sceneGraph.PrimDescription;

View File

@ -259,7 +259,6 @@ namespace OpenSim.Region.Framework.Scenes
[XmlIgnore]
public bool IgnoreUndoUpdate = false;
[XmlIgnore]
private PrimFlags LocalFlags;
[XmlIgnore]
private float m_damage = -1.0f;

View File

@ -768,20 +768,22 @@ namespace OpenSim.Region.Framework.Scenes
public void RegisterToEvents()
{
// REGION SYNC
if (m_scene.IsSyncedServer() || m_scene.RegionSyncEnabled == false)
// if (m_scene.IsSyncedServer() || m_scene.RegionSyncEnabled == false)
if (m_scene.IsSyncedServer())
{
// These client messages will not be handled by client managers but instead
// they are caught by the RegionSyncClient module and passed up to the auth sim
m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
m_controllingClient.OnSetAppearance += SetAppearance;
m_log.DebugFormat("[SCENE PRESENCE]: Setting local handler for HandleAgentRequestSit"); //RA
m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit;
m_controllingClient.OnAgentSit += HandleAgentSit;
}
m_controllingClient.OnRequestWearables += SendWearables;
m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
//m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit;
m_controllingClient.OnAgentSit += HandleAgentSit;
m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
m_controllingClient.OnStartAnim += HandleStartAnim;
m_controllingClient.OnStopAnim += HandleStopAnim;