some cleanup ( well or not )

avinationmerge
UbitUmarov 2014-08-22 20:01:07 +01:00
parent 9a8d8d2130
commit 0295e6822d
5 changed files with 234 additions and 81 deletions

View File

@ -576,6 +576,16 @@ namespace OpenSim.Region.Framework.Scenes.Animation
m_scenePresence.SendAnimPack(animations, seqs, objectIDs);
}
public void GetArrays(out UUID[] animIDs, out int[] sequenceNums, out UUID[] objectIDs)
{
animIDs = null;
sequenceNums = null;
objectIDs = null;
if(m_animations != null)
m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
}
public void SendAnimPackToClient(IClientAPI client)
{
if (m_scenePresence.IsChildAgent)

View File

@ -3000,13 +3000,18 @@ namespace OpenSim.Region.Framework.Scenes
if (sp == null)
{
m_log.DebugFormat(
"[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
"[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}, tpflags: {4}",
client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos,
((TPFlags)aCircuit.teleportFlags).ToString());
m_clientManager.Add(client);
SubscribeToClientEvents(client);
sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
/* done in completMovement
InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
if (cof == null)
sp.COF = UUID.Zero;
@ -3014,9 +3019,9 @@ namespace OpenSim.Region.Framework.Scenes
sp.COF = cof.ID;
m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
*/
m_eventManager.TriggerOnNewPresence(sp);
sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
}
else
{

View File

@ -2718,14 +2718,14 @@ namespace OpenSim.Region.Framework.Scenes
}
}
RootPart.SendFullUpdateToAllClients();
RootPart.SendFullUpdateToAllClientsInternal();
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
if (part != RootPart)
part.SendFullUpdateToAllClients();
part.SendFullUpdateToAllClientsInternal();
}
}
@ -2740,16 +2740,6 @@ namespace OpenSim.Region.Framework.Scenes
if (IsDeleted)
return;
if (IsAttachment)
{
ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar);
if (sp != null)
{
sp.SendAttachmentUpdate(RootPart, UpdateRequired.TERSE);
return;
}
}
RootPart.SendTerseUpdateToAllClients();
}
@ -2781,7 +2771,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].SendTerseUpdateToAllClients();
parts[i].SendTerseUpdateToAllClientsInternal();
}
/// <summary>

View File

@ -862,7 +862,8 @@ namespace OpenSim.Region.Framework.Scenes
{
Vector3 offset = (m_offsetPosition - oldpos);
av.AbsolutePosition += offset;
av.SendAvatarDataToAllAgents();
// av.SendAvatarDataToAllAgents();
av.SendTerseUpdateToAllClients();
}
}
}
@ -3257,7 +3258,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary>
/// Send a full update for this part to all clients.
/// </summary>
public void SendFullUpdateToAllClients()
public void SendFullUpdateToAllClientsInternal()
{
if (ParentGroup == null)
return;
@ -3276,6 +3277,36 @@ namespace OpenSim.Region.Framework.Scenes
});
}
public void SendFullUpdateToAllClients()
{
if (ParentGroup == null)
return;
// Update the "last" values
m_lastPosition = OffsetPosition;
m_lastRotation = RotationOffset;
m_lastVelocity = Velocity;
m_lastAcceleration = Acceleration;
m_lastAngularVelocity = AngularVelocity;
m_lastUpdateSentTime = Environment.TickCount;
if (ParentGroup.IsAttachment)
{
ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
if (sp != null)
{
sp.SendAttachmentUpdate(this, UpdateRequired.FULL);
}
}
else
{
ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
SendFullUpdate(avatar.ControllingClient);
});
}
}
/// <summary>
/// Sends a full update to the client
/// </summary>
@ -3345,24 +3376,24 @@ namespace OpenSim.Region.Framework.Scenes
!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE)
{
SendTerseUpdateToAllClients();
SendTerseUpdateToAllClientsInternal();
}
break;
}
case UpdateRequired.FULL:
{
ClearUpdateSchedule();
SendFullUpdateToAllClients();
SendFullUpdateToAllClientsInternal();
break;
}
}
}
/// <summary>
/// Send a terse update to all clients
/// </summary>
public void SendTerseUpdateToAllClients()
public void SendTerseUpdateToAllClientsInternal()
{
if (ParentGroup == null || ParentGroup.Scene == null)
return;
@ -3381,6 +3412,36 @@ namespace OpenSim.Region.Framework.Scenes
});
}
public void SendTerseUpdateToAllClients()
{
if (ParentGroup == null || ParentGroup.Scene == null)
return;
// Update the "last" values
m_lastPosition = OffsetPosition;
m_lastRotation = RotationOffset;
m_lastVelocity = Velocity;
m_lastAcceleration = Acceleration;
m_lastAngularVelocity = AngularVelocity;
m_lastUpdateSentTime = Environment.TickCount;
if (ParentGroup.IsAttachment)
{
ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
if (sp != null)
{
sp.SendAttachmentUpdate(this, UpdateRequired.TERSE);
}
}
else
{
ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
{
SendTerseUpdateToClient(client);
});
}
}
public void SetAxisRotation(int axis, int rotate)
{
ParentGroup.SetAxisRotation(axis, rotate);

View File

@ -1341,6 +1341,11 @@ namespace OpenSim.Region.Framework.Scenes
RemoveFromPhysicalScene();
ParentID = 0; // Child agents can't be sitting
// we dont have land information for child
m_previusParcelHide = false;
m_previusParcelUUID = UUID.Zero;
m_currentParcelHide = false;
m_currentParcelUUID = UUID.Zero;
// FIXME: Set RegionHandle to the region handle of the scene this agent is moving into
m_scene.EventManager.TriggerOnMakeChildAgent(this);
@ -1753,13 +1758,6 @@ namespace OpenSim.Region.Framework.Scenes
// Tell the client that we're totally ready
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
// Remember in HandleUseCircuitCode, we delayed this to here
// this prims etc, moved down
// if (m_teleportFlags > 0)
// SendInitialDataToMe();
// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
if (!string.IsNullOrEmpty(m_callbackURI))
@ -1805,17 +1803,80 @@ namespace OpenSim.Region.Framework.Scenes
if (!IsChildAgent)
{
ValidateAndSendAppearanceAndAgentData();
// ValidateAndSendAppearanceAndAgentData();
// do it here in line
// so sequence is clear
// verify baked textures and cache
bool cachedbaked = false;
if (m_scene.AvatarFactory != null)
cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
// not sure we need this
if (!cachedbaked)
{
if (m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(UUID);
}
List<ScenePresence> allpresences = m_scene.GetScenePresences();
// send avatar object to all presences including us, so they cross it into region
// then hide if necessary
SendInitialAvatarDataToAllAgents(allpresences);
// send this look
SendAppearanceToAgent(this);
// send this animations
UUID[] animIDs = null;
int[] animseqs = null;
UUID[] animsobjs = null;
if (Animator != null)
Animator.GetArrays(out animIDs, out animseqs, out animsobjs);
bool haveAnims = (animIDs != null && animseqs != null && animsobjs != null);
if(haveAnims)
SendAnimPackToAgent(this, animIDs, animseqs, animsobjs);
// we should be able to receive updates, etc
// so release them
m_inTransit = false;
// send look and animations to others
// if not cached we send greys
// uncomented if will wait till avatar does baking
//if (cachedbaked)
{
foreach (ScenePresence p in allpresences)
{
if (p == this)
continue;
if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
continue;
SendAppearanceToAgentNF(p);
if (haveAnims)
SendAnimPackToAgentNF(p, animIDs, animseqs, animsobjs);
}
} // greys if
m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts));
// attachments
if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
{
if (Scene.AttachmentsModule != null)
// Util.FireAndForget(
// o =>
// {
// Util.FireAndForget(
// o =>
// {
Scene.AttachmentsModule.RezAttachments(this);
// });
}
@ -1829,23 +1890,23 @@ namespace OpenSim.Region.Framework.Scenes
// Resume scripts this possible should also be moved down after sending the avatar to viewer ?
foreach (SceneObjectGroup sog in m_attachments)
{
sog.SendFullUpdateToClient(ControllingClient);
SendFullUpdateToClient(ControllingClient);
sog.SendFullUpdateToClient(ControllingClient);
if (!sog.HasPrivateAttachmentPoint)
{
// sog.ScheduleGroupForFullUpdate();
m_scene.ForEachScenePresence(delegate(ScenePresence p)
foreach(ScenePresence p in allpresences)
{
if (p == this)
return;
continue;
if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
return;
continue;
sog.SendFullUpdateToClient(p.ControllingClient);
SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
});
sog.SendFullUpdateToClient(p.ControllingClient);
};
}
sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
sog.ResumeScripts();
@ -1872,25 +1933,14 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts));
if (!IsChildAgent)
{
// moved from makeroot missing in sendInitialDataToMe
// its already there
/*
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
{
if (presence != this)
presence.Animator.SendAnimPackToClient(ControllingClient);
});
*/
if (openChildAgents)
if (!IsChildAgent && openChildAgents)
{
IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
if (friendsModule != null)
friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts));
}
}
}
finally
@ -3481,6 +3531,8 @@ namespace OpenSim.Region.Framework.Scenes
/// Do everything required once a client completes its movement into a region and becomes
/// a root agent.
/// </summary>
///
/* only called from on place, do done inline there
private void ValidateAndSendAppearanceAndAgentData()
{
//m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
@ -3502,11 +3554,13 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.AvatarFactory.QueueAppearanceSave(UUID);
}
// send avatar object to all viewers so they cross it into region
bool newhide = m_currentParcelHide;
m_currentParcelHide = false;
SendAvatarDataToAllAgents();
// now hide
if (newhide)
{
ParcelLoginCheck(m_currentParcelUUID);
@ -3522,7 +3576,7 @@ namespace OpenSim.Region.Framework.Scenes
if(Animator!= null)
Animator.SendAnimPack();
}
*/
/// <summary>
/// Send avatar full data appearance and animations for all other root agents to this agent, this agent
/// can be either a child or root
@ -3530,15 +3584,18 @@ namespace OpenSim.Region.Framework.Scenes
public void SendOtherAgentsAvatarFullToMe()
{
int count = 0;
m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
m_scene.ForEachRootScenePresence(delegate(ScenePresence p)
{
// only send information about other root agents
if (scenePresence.UUID == UUID)
if (p.UUID == UUID)
return;
scenePresence.SendAvatarDataToAgent(this);
scenePresence.SendAppearanceToAgent(this);
scenePresence.SendAnimPackToAgent(this);
if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodLevel < 200)
return;
p.SendAvatarDataToAgentNF(this);
p.SendAppearanceToAgentNF(this);
p.SendAnimPackToAgentNF(this);
// for now attachments are sent with all SOG
count++;
});
@ -3559,7 +3616,6 @@ namespace OpenSim.Region.Framework.Scenes
m_log.WarnFormat(
"[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}",
Name, Scene.RegionInfo.RegionName);
return;
}
@ -3575,6 +3631,26 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.StatsReporter.AddAgentUpdates(count);
}
// sends avatar object to all clients so they cross it into region
// then sends kills to hide
public void SendInitialAvatarDataToAllAgents(List<ScenePresence> presences)
{
m_lastSize = Appearance.AvatarSize;
int count = 0;
foreach (ScenePresence p in presences)
{
p.ControllingClient.SendAvatarDataImmediate(this);
if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
// either just kill the object
// p.ControllingClient.SendKillObject(new List<uint> {LocalId});
// or also attachments viewer may still know about
SendKillTo(p);
count++;
}
m_scene.StatsReporter.AddAgentUpdates(count);
}
/// <summary>
/// Send avatar data to an agent.
/// </summary>
@ -3637,6 +3713,12 @@ namespace OpenSim.Region.Framework.Scenes
UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
}
public void SendAppearanceToAgentNF(ScenePresence avatar)
{
avatar.ControllingClient.SendAppearance(
UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
}
public void SendAnimPackToAgent(ScenePresence p)
{
if (IsChildAgent || Animator == null)
@ -3648,6 +3730,29 @@ namespace OpenSim.Region.Framework.Scenes
Animator.SendAnimPackToClient(p.ControllingClient);
}
public void SendAnimPackToAgent(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs)
{
if (IsChildAgent)
return;
if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
return;
p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
}
public void SendAnimPackToAgentNF(ScenePresence p)
{
if (IsChildAgent || Animator == null)
return;
Animator.SendAnimPackToClient(p.ControllingClient);
}
public void SendAnimPackToAgentNF(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs)
{
p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
}
public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs)
{
if (IsChildAgent)
@ -5634,22 +5739,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
private void ParcelLoginCheck(UUID currentParcelID)
{
List<ScenePresence> allpresences = m_scene.GetScenePresences();
foreach (ScenePresence p in allpresences)
{
if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
continue;
if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200)
{
SendKillTo(p);
}
}
}
public void parcelRegionCross()
{
if (!ParcelHideThisAvatar || GodLevel >= 200)
@ -5817,8 +5906,6 @@ namespace OpenSim.Region.Framework.Scenes
if (killsToSendme.Count > 0)
{
m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString());
foreach (ScenePresence p in killsToSendme)
{
m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname);