mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
Merge branch 'master' into varregion
Add new region crossing code to varregion Conflicts: OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs
This commit is contained in:
@@ -35,8 +35,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
|
||||
public interface IAvatarFactoryModule
|
||||
{
|
||||
void SetAppearance(IScenePresence sp, AvatarAppearance appearance);
|
||||
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
|
||||
void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems);
|
||||
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems);
|
||||
|
||||
/// <summary>
|
||||
/// Send the appearance of an avatar to others in the scene.
|
||||
@@ -52,6 +52,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns>
|
||||
Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId);
|
||||
|
||||
|
||||
WearableCacheItem[] GetCachedItems(UUID agentId);
|
||||
/// <summary>
|
||||
/// Save the baked textures for the given agent permanently in the asset database.
|
||||
/// </summary>
|
||||
|
||||
40
OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs
Normal file
40
OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Services.Interfaces
|
||||
{
|
||||
public interface IBakedTextureModule
|
||||
{
|
||||
WearableCacheItem[] Get(UUID id);
|
||||
void Store(UUID id, WearableCacheItem[] data);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,8 @@ using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version);
|
||||
|
||||
public interface IEntityTransferModule
|
||||
{
|
||||
/// <summary>
|
||||
@@ -50,30 +52,11 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <param name='teleportFlags'></param>
|
||||
void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags);
|
||||
|
||||
/// <summary>
|
||||
/// Teleport an agent directly to a given region without checking whether the region should be subsituted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Please use Teleport() instead unless you know exactly what you're doing.
|
||||
/// Do not use for same region teleports.
|
||||
/// </remarks>
|
||||
/// <param name='sp'></param>
|
||||
/// <param name='reg'></param>
|
||||
/// <param name='finalDestination'>/param>
|
||||
/// <param name='position'></param>
|
||||
/// <param name='lookAt'></param>
|
||||
/// <param name='teleportFlags'></param>
|
||||
void DoTeleport(
|
||||
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
||||
Vector3 position, Vector3 lookAt, uint teleportFlags);
|
||||
|
||||
/// <summary>
|
||||
/// Teleports the agent for the given client to their home destination.
|
||||
/// </summary>
|
||||
/// <param name='id'></param>
|
||||
/// <param name='client'></param>
|
||||
bool TeleportHome(UUID id, IClientAPI client);
|
||||
|
||||
void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
||||
Vector3 position, Vector3 lookAt, uint teleportFlags);
|
||||
|
||||
/// <summary>
|
||||
/// Show whether the given agent is being teleported.
|
||||
/// </summary>
|
||||
@@ -89,7 +72,12 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
|
||||
void EnableChildAgent(ScenePresence agent, GridRegion region);
|
||||
|
||||
GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos);
|
||||
|
||||
void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
|
||||
|
||||
ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version);
|
||||
|
||||
}
|
||||
|
||||
public interface IUserAgentVerificationModule
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private bool m_hasGroupChanged = false;
|
||||
private long timeFirstChanged;
|
||||
private long timeLastChanged;
|
||||
private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>();
|
||||
|
||||
/// <summary>
|
||||
/// This indicates whether the object has changed such that it needs to be repersisted to permenant storage
|
||||
@@ -428,6 +429,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0));
|
||||
}
|
||||
|
||||
private struct avtocrossInfo
|
||||
{
|
||||
public ScenePresence av;
|
||||
public uint ParentID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The absolute position of this scene object in the scene
|
||||
/// </summary>
|
||||
@@ -455,13 +462,122 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|| Scene.TestBorderCross(val, Cardinals.S))
|
||||
&& !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
|
||||
{
|
||||
IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
|
||||
string version = String.Empty;
|
||||
Vector3 newpos = Vector3.Zero;
|
||||
OpenSim.Services.Interfaces.GridRegion destination = null;
|
||||
|
||||
if (m_rootPart.KeyframeMotion != null)
|
||||
m_rootPart.KeyframeMotion.StartCrossingCheck();
|
||||
|
||||
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
|
||||
bool canCross = true;
|
||||
foreach (ScenePresence av in m_linkedAvatars)
|
||||
{
|
||||
// We need to cross these agents. First, let's find
|
||||
// out if any of them can't cross for some reason.
|
||||
// We have to deny the crossing entirely if any
|
||||
// of them are banned. Alternatively, we could
|
||||
// unsit banned agents....
|
||||
|
||||
|
||||
// We set the avatar position as being the object
|
||||
// position to get the region to send to
|
||||
if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out version, out newpos)) == null)
|
||||
{
|
||||
canCross = false;
|
||||
break;
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
|
||||
}
|
||||
|
||||
if (canCross)
|
||||
{
|
||||
// We unparent the SP quietly so that it won't
|
||||
// be made to stand up
|
||||
|
||||
List<avtocrossInfo> avsToCross = new List<avtocrossInfo>();
|
||||
|
||||
foreach (ScenePresence av in m_linkedAvatars)
|
||||
{
|
||||
avtocrossInfo avinfo = new avtocrossInfo();
|
||||
SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID);
|
||||
if (parentPart != null)
|
||||
av.ParentUUID = parentPart.UUID;
|
||||
|
||||
avinfo.av = av;
|
||||
avinfo.ParentID = av.ParentID;
|
||||
avsToCross.Add(avinfo);
|
||||
|
||||
av.PrevSitOffset = av.OffsetPosition;
|
||||
av.ParentID = 0;
|
||||
}
|
||||
|
||||
// m_linkedAvatars.Clear();
|
||||
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
|
||||
|
||||
// Normalize
|
||||
if (val.X >= Constants.RegionSize)
|
||||
val.X -= Constants.RegionSize;
|
||||
if (val.Y >= Constants.RegionSize)
|
||||
val.Y -= Constants.RegionSize;
|
||||
if (val.X < 0)
|
||||
val.X += Constants.RegionSize;
|
||||
if (val.Y < 0)
|
||||
val.Y += Constants.RegionSize;
|
||||
|
||||
// If it's deleted, crossing was successful
|
||||
if (IsDeleted)
|
||||
{
|
||||
// foreach (ScenePresence av in m_linkedAvatars)
|
||||
foreach (avtocrossInfo avinfo in avsToCross)
|
||||
{
|
||||
ScenePresence av = avinfo.av;
|
||||
if (!av.IsInTransit) // just in case...
|
||||
{
|
||||
m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);
|
||||
|
||||
av.IsInTransit = true;
|
||||
|
||||
CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync;
|
||||
d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d);
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val);
|
||||
}
|
||||
avsToCross.Clear();
|
||||
return;
|
||||
}
|
||||
else // cross failed, put avas back ??
|
||||
{
|
||||
foreach (avtocrossInfo avinfo in avsToCross)
|
||||
{
|
||||
ScenePresence av = avinfo.av;
|
||||
av.ParentUUID = UUID.Zero;
|
||||
av.ParentID = avinfo.ParentID;
|
||||
// m_linkedAvatars.Add(av);
|
||||
}
|
||||
}
|
||||
avsToCross.Clear();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_rootPart.KeyframeMotion != null)
|
||||
m_rootPart.KeyframeMotion.CrossingFailure();
|
||||
|
||||
if (RootPart.PhysActor != null)
|
||||
{
|
||||
RootPart.PhysActor.CrossingFailure();
|
||||
}
|
||||
}
|
||||
Vector3 oldp = AbsolutePosition;
|
||||
val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f);
|
||||
val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
|
||||
val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (RootPart.GetStatusSandbox())
|
||||
{
|
||||
if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
|
||||
@@ -495,6 +611,39 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector3 Velocity
|
||||
{
|
||||
get { return RootPart.Velocity; }
|
||||
set { RootPart.Velocity = value; }
|
||||
}
|
||||
|
||||
private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
|
||||
{
|
||||
CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
|
||||
ScenePresence agent = icon.EndInvoke(iar);
|
||||
|
||||
//// If the cross was successful, this agent is a child agent
|
||||
if (agent.IsChildAgent)
|
||||
{
|
||||
if (agent.ParentUUID != UUID.Zero)
|
||||
{
|
||||
agent.ParentPart = null;
|
||||
// agent.ParentPosition = Vector3.Zero;
|
||||
// agent.ParentUUID = UUID.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
agent.ParentUUID = UUID.Zero;
|
||||
// agent.Reset();
|
||||
// else // Not successful
|
||||
// agent.RestoreInCurrentScene();
|
||||
|
||||
// In any case
|
||||
agent.IsInTransit = false;
|
||||
|
||||
m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
|
||||
}
|
||||
|
||||
public override uint LocalId
|
||||
{
|
||||
get { return m_rootPart.LocalId; }
|
||||
@@ -1096,6 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -1105,6 +1255,46 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
part.ParentID = m_rootPart.LocalId;
|
||||
part.ClearUndoState();
|
||||
}
|
||||
/// <summary>
|
||||
/// Add the avatar to this linkset (avatar is sat).
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public void AddAvatar(UUID agentID)
|
||||
{
|
||||
ScenePresence presence;
|
||||
if (m_scene.TryGetScenePresence(agentID, out presence))
|
||||
{
|
||||
if (!m_linkedAvatars.Contains(presence))
|
||||
{
|
||||
m_linkedAvatars.Add(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the avatar from this linkset (avatar is unsat).
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public void DeleteAvatar(UUID agentID)
|
||||
{
|
||||
ScenePresence presence;
|
||||
if (m_scene.TryGetScenePresence(agentID, out presence))
|
||||
{
|
||||
if (m_linkedAvatars.Contains(presence))
|
||||
{
|
||||
m_linkedAvatars.Remove(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the list of linked presences (avatars sat on this group)
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public List<ScenePresence> GetLinkedAvatars()
|
||||
{
|
||||
return m_linkedAvatars;
|
||||
}
|
||||
|
||||
public ushort GetTimeDilation()
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -111,15 +111,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
|
||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
|
||||
|
||||
// We need to preserve this here because phys actor is removed by the sit.
|
||||
Vector3 spPhysActorSize = m_sp.PhysicsActor.Size;
|
||||
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
|
||||
|
||||
// FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
|
||||
// default avatar.
|
||||
// Curiously, Vector3.ToString() will not display the last two places of the float. For example,
|
||||
// printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337>
|
||||
Assert.That(
|
||||
m_sp.AbsolutePosition,
|
||||
Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f)));
|
||||
Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2)));
|
||||
|
||||
m_sp.StandUp();
|
||||
|
||||
@@ -147,9 +145,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
|
||||
Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID));
|
||||
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
|
||||
Assert.That(
|
||||
m_sp.AbsolutePosition,
|
||||
Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
|
||||
// Assert.That(
|
||||
// m_sp.AbsolutePosition,
|
||||
// Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
|
||||
Assert.That(m_sp.PhysicsActor, Is.Null);
|
||||
|
||||
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
|
||||
|
||||
@@ -181,9 +181,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (part.ParticleSystem.Length > 0)
|
||||
{
|
||||
Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
|
||||
if (ps.Texture != UUID.Zero)
|
||||
assetUuids[ps.Texture] = AssetType.Texture;
|
||||
try
|
||||
{
|
||||
Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
|
||||
if (ps.Texture != UUID.Zero)
|
||||
assetUuids[ps.Texture] = AssetType.Texture;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt. Continuing.",
|
||||
part.Name, part.UUID, sceneObject.Name, sceneObject.UUID);
|
||||
}
|
||||
}
|
||||
|
||||
TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
|
||||
|
||||
Reference in New Issue
Block a user