Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

This commit is contained in:
Diva Canto
2010-11-29 09:58:20 -08:00
16 changed files with 356 additions and 239 deletions

View File

@@ -2324,16 +2324,14 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
return false;
}
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2);
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
newObject.ResumeScripts();
// Do this as late as possible so that listeners have full access to the incoming object
EventManager.TriggerOnIncomingSceneObject(newObject);
TriggerChangedTeleport(newObject);
return true;
}
@@ -2441,7 +2439,7 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
private void TriggerChangedTeleport(SceneObjectGroup sog)
private int GetStateSource(SceneObjectGroup sog)
{
ScenePresence sp = GetScenePresence(sog.OwnerID);
@@ -2452,13 +2450,12 @@ namespace OpenSim.Region.Framework.Scenes
if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
{
// This will get your attention
//m_log.Error("[XXX] Triggering ");
//m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
// Trigger CHANGED_TELEPORT
sp.Scene.EventManager.TriggerOnScriptChangedEvent(sog.LocalId, (uint)Changed.TELEPORT);
return 5; // StateSource.Teleporting
}
}
return 2; // StateSource.PrimCrossing
}
#endregion

View File

@@ -445,8 +445,36 @@ namespace OpenSim.Region.Framework.Scenes
PhysicsActor actor = m_physicsActor;
if (actor != null)
m_pos = actor.Position;
else
{
// Obtain the correct position of a seated avatar.
// In addition to providing the correct position while
// the avatar is seated, this value will also
// be used as the location to unsit to.
//
// If m_parentID is not 0, assume we are a seated avatar
// and we should return the position based on the sittarget
// offset and rotation of the prim we are seated on.
//
// Generally, m_pos will contain the position of the avatar
// in the sim unless the avatar is on a sit target. While
// on a sit target, m_pos will contain the desired offset
// without the parent rotation applied.
if (m_parentID != 0)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
if (part != null)
{
return m_parentPosition + (m_pos * part.GetWorldRotation());
}
else
{
return m_parentPosition + m_pos;
}
}
}
return m_parentPosition + m_pos;
return m_pos;
}
set
{
@@ -703,7 +731,9 @@ namespace OpenSim.Region.Framework.Scenes
// Note: This won't send data *to* other clients in that region (children don't send)
// MIC: This gets called again in CompleteMovement
SendInitialFullUpdateToAllClients();
// SendInitialFullUpdateToAllClients();
SendOtherAgentsAvatarDataToMe();
SendOtherAgentsAppearanceToMe();
RegisterToEvents();
SetDirectionVectors();
@@ -1613,7 +1643,7 @@ namespace OpenSim.Region.Framework.Scenes
{
AbsolutePosition = part.AbsolutePosition;
Velocity = Vector3.Zero;
SendFullUpdateToAllClients();
SendAvatarDataToAllAgents();
//HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
}
@@ -1688,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes
m_parentPosition = Vector3.Zero;
m_parentID = 0;
SendFullUpdateToAllClients();
SendAvatarDataToAllAgents();
m_requestedSitTargetID = 0;
if (m_physicsActor != null && m_appearance != null)
{
@@ -2154,7 +2184,7 @@ namespace OpenSim.Region.Framework.Scenes
RemoveFromPhysicalScene();
Animator.TrySetMovementAnimation(sitAnimation);
SendFullUpdateToAllClients();
SendAvatarDataToAllAgents();
// This may seem stupid, but Our Full updates don't send avatar rotation :P
// So we're also sending a terse update (which has avatar rotation)
// [Update] We do now.
@@ -2379,165 +2409,169 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar)
/// Do everything required once a client completes its movement into a region and becomes
/// a root agent.
/// </summary>
/// <param name="remoteAvatar"></param>
public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
{
// 2 stage check is needed.
if (remoteAvatar == null)
return;
IClientAPI cl = remoteAvatar.ControllingClient;
if (cl == null)
return;
if (m_appearance.Texture == null)
return;
// MT: This is needed for sit. It's legal to send it to oneself, and the name
// of the method is a misnomer
//
// if (LocalId == remoteAvatar.LocalId)
// {
// m_log.WarnFormat("[SCENEPRESENCE]: An agent is attempting to send avatar data to itself; {0}", UUID);
// return;
// }
if (IsChildAgent)
{
m_log.WarnFormat("[SCENEPRESENCE]: A child agent is attempting to send out avatar data; {0}", UUID);
return;
}
remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
m_scene.StatsReporter.AddAgentUpdates(1);
}
/// <summary>
/// Tell *ALL* agents about this agent
/// </summary>
public void SendInitialFullUpdateToAllClients()
{
m_perfMonMS = Util.EnvironmentTickCount();
int avUpdates = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
++avUpdates;
// Don't update ourselves
if (avatar.LocalId == LocalId)
return;
// If this is a root agent, then get info about the avatar
if (!IsChildAgent)
{
SendFullUpdateToOtherClient(avatar);
}
// If the other avatar is a root
if (!avatar.IsChildAgent)
{
avatar.SendFullUpdateToOtherClient(this);
avatar.SendAppearanceToOtherAgent(this);
avatar.Animator.SendAnimPackToClient(ControllingClient);
}
});
m_scene.StatsReporter.AddAgentUpdates(avUpdates);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
//Animator.SendAnimPack();
}
public void SendFullUpdateToAllClients()
{
m_perfMonMS = Util.EnvironmentTickCount();
// only send update from root agents to other clients; children are only "listening posts"
if (IsChildAgent)
{
m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
return;
}
int count = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
if (sp.IsChildAgent)
return;
SendFullUpdateToOtherClient(sp);
++count;
});
m_scene.StatsReporter.AddAgentUpdates(count);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
Animator.SendAnimPack();
}
/// <summary>
/// Do everything required once a client completes its movement into a region
/// </summary>
public void SendInitialData()
private void SendInitialData()
{
// Moved this into CompleteMovement to ensure that m_appearance is initialized before
// the inventory arrives
// m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
m_controllingClient.SendAvatarDataImmediate(this);
// This agent just became root. We are going to tell everyone about it. The process of
// getting other avatars information was initiated in the constructor... don't do it
// again here...
SendAvatarDataToAllAgents();
// We have an appearance but we may not have the baked textures. Check the asset cache
// to see if all the baked textures are already here.
if (m_scene.AvatarFactory != null)
{
if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient))
{
// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
m_controllingClient.SendAppearance(
m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes());
SendAppearanceToAgent(this);
// If the avatars baked textures are all in the cache, then we have a
// complete appearance... send it out, if not, then we'll send it when
// the avatar finishes updating its appearance
SendAppearanceToAllOtherAgents();
}
}
else
{
m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name);
}
SendInitialFullUpdateToAllClients();
}
/// <summary>
///
/// Send this agent's avatar data to all other root and child agents in the scene
/// This agent must be root. This avatar will receive its own update.
/// </summary>
public void SendAppearanceToAllOtherAgents()
public void SendAvatarDataToAllAgents()
{
// DEBUG ON
// m_log.WarnFormat("[SCENEPRESENCE]: Send appearance from {0} to all other agents", m_uuid);
// DEBUG OFF
// only send update from root agents to other clients; children are only "listening posts"
if (IsChildAgent)
{
m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
return;
}
m_perfMonMS = Util.EnvironmentTickCount();
int count = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
{
if (scenePresence.UUID != UUID)
{
SendAppearanceToOtherAgent(scenePresence);
}
SendAvatarDataToAgent(scenePresence);
count++;
});
m_scene.StatsReporter.AddAgentUpdates(count);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
}
/// <summary>
/// Send appearance data to an agent that isn't this one.
/// Send avatar data for all other root agents to this agent, this agent
/// can be either a child or root
/// </summary>
public void SendOtherAgentsAvatarDataToMe()
{
m_perfMonMS = Util.EnvironmentTickCount();
int count = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
{
// only send information about root agents
if (scenePresence.IsChildAgent)
return;
// only send information about other root agents
if (scenePresence.UUID == UUID)
return;
scenePresence.SendAvatarDataToAgent(this);
count++;
});
m_scene.StatsReporter.AddAgentUpdates(count);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
}
/// <summary>
/// Send avatar data to an agent.
/// </summary>
/// <param name="avatar"></param>
public void SendAppearanceToOtherAgent(ScenePresence avatar)
private void SendAvatarDataToAgent(ScenePresence avatar)
{
if (LocalId == avatar.LocalId)
// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
avatar.ControllingClient.SendAvatarDataImmediate(this);
Animator.SendAnimPackToClient(avatar.ControllingClient);
}
/// <summary>
/// Send this agent's appearance to all other root and child agents in the scene
/// This agent must be root.
/// </summary>
public void SendAppearanceToAllOtherAgents()
{
// only send update from root agents to other clients; children are only "listening posts"
if (IsChildAgent)
{
m_log.WarnFormat("[SCENE PRESENCE]: An agent is attempting to send appearance data to itself; {0}", UUID);
m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
return;
}
m_perfMonMS = Util.EnvironmentTickCount();
// DEBUG ON
int count = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
{
if (scenePresence.UUID == UUID)
return;
SendAppearanceToAgent(scenePresence);
count++;
});
m_scene.StatsReporter.AddAgentUpdates(count);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
}
/// <summary>
/// Send appearance from all other root agents to this agent. this agent
/// can be either root or child
/// </summary>
public void SendOtherAgentsAppearanceToMe()
{
m_perfMonMS = Util.EnvironmentTickCount();
int count = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
{
// only send information about root agents
if (scenePresence.IsChildAgent)
return;
// only send information about other root agents
if (scenePresence.UUID == UUID)
return;
scenePresence.SendAppearanceToAgent(this);
count++;
});
m_scene.StatsReporter.AddAgentUpdates(count);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
}
/// <summary>
/// Send appearance data to an agent.
/// </summary>
/// <param name="avatar"></param>
private void SendAppearanceToAgent(ScenePresence avatar)
{
// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
// DEBUG OFF
avatar.ControllingClient.SendAppearance(
m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
@@ -3050,9 +3084,6 @@ namespace OpenSim.Region.Framework.Scenes
public void CopyFrom(AgentData cAgent)
{
// DEBUG ON
m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
// DEBUG OFF
m_originRegionID = cAgent.RegionID;
m_callbackURI = cAgent.CallbackURI;

View File

@@ -86,23 +86,33 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="assetUuids">The assets gathered</param>
public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
{
assetUuids[assetUuid] = assetType;
if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
{
GetWearableAssetUuids(assetUuid, assetUuids);
try
{
assetUuids[assetUuid] = assetType;
if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
{
GetWearableAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.Gesture == assetType)
{
GetGestureAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.LSLText == assetType)
{
GetScriptAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.Object == assetType)
{
GetSceneObjectAssetUuids(assetUuid, assetUuids);
}
}
else if (AssetType.Gesture == assetType)
catch (Exception)
{
GetGestureAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.LSLText == assetType)
{
GetScriptAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.Object == assetType)
{
GetSceneObjectAssetUuids(assetUuid, assetUuids);
m_log.ErrorFormat(
"[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}",
assetUuid, assetType);
throw;
}
}