Merge commit 'eac29396d98a4864923a69e0eb73cecdd8a225b3' into bigmerge

avinationmerge
Melanie 2011-10-25 03:17:11 +01:00
commit d1028b3647
5 changed files with 318 additions and 318 deletions

View File

@ -105,143 +105,143 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
client.OnAvatarNowWearing += Client_OnAvatarNowWearing; client.OnAvatarNowWearing += Client_OnAvatarNowWearing;
} }
#endregion #endregion
#region IAvatarFactoryModule #region IAvatarFactoryModule
/// <summary> /// <summary>
/// Set appearance data (texture asset IDs and slider settings) /// Set appearance data (texture asset IDs and slider settings)
/// </summary> /// </summary>
/// <param name="sp"></param> /// <param name="sp"></param>
/// <param name="texture"></param> /// <param name="texture"></param>
/// <param name="visualParam"></param> /// <param name="visualParam"></param>
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams)
{ {
// m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId); // m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId);
// TODO: This is probably not necessary any longer, just assume the // TODO: This is probably not necessary any longer, just assume the
// textureEntry set implies that the appearance transaction is complete // textureEntry set implies that the appearance transaction is complete
bool changed = false; bool changed = false;
// Process the texture entry transactionally, this doesn't guarantee that Appearance is // Process the texture entry transactionally, this doesn't guarantee that Appearance is
// going to be handled correctly but it does serialize the updates to the appearance // going to be handled correctly but it does serialize the updates to the appearance
lock (m_setAppearanceLock) lock (m_setAppearanceLock)
{ {
// Process the visual params, this may change height as well // Process the visual params, this may change height as well
if (visualParams != null) if (visualParams != null)
{ {
// string[] visualParamsStrings = new string[visualParams.Length]; // string[] visualParamsStrings = new string[visualParams.Length];
// for (int i = 0; i < visualParams.Length; i++) // for (int i = 0; i < visualParams.Length; i++)
// visualParamsStrings[i] = visualParams[i].ToString(); // visualParamsStrings[i] = visualParams[i].ToString();
// m_log.DebugFormat( // m_log.DebugFormat(
// "[AVFACTORY]: Setting visual params for {0} to {1}", // "[AVFACTORY]: Setting visual params for {0} to {1}",
// client.Name, string.Join(", ", visualParamsStrings)); // client.Name, string.Join(", ", visualParamsStrings));
float oldHeight = sp.Appearance.AvatarHeight; float oldHeight = sp.Appearance.AvatarHeight;
changed = sp.Appearance.SetVisualParams(visualParams); changed = sp.Appearance.SetVisualParams(visualParams);
if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
} }
// Process the baked texture array // Process the baked texture array
if (textureEntry != null) if (textureEntry != null)
{ {
changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID); m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID);
Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(sp, false); }); Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(sp, false); });
// This appears to be set only in the final stage of the appearance // This appears to be set only in the final stage of the appearance
// update transaction. In theory, we should be able to do an immediate // update transaction. In theory, we should be able to do an immediate
// appearance send and save here. // appearance send and save here.
} }
// save only if there were changes, send no matter what (doesn't hurt to send twice) // save only if there were changes, send no matter what (doesn't hurt to send twice)
if (changed) if (changed)
QueueAppearanceSave(sp.ControllingClient.AgentId); QueueAppearanceSave(sp.ControllingClient.AgentId);
QueueAppearanceSend(sp.ControllingClient.AgentId); QueueAppearanceSend(sp.ControllingClient.AgentId);
} }
// m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
} }
public bool SendAppearance(UUID agentId) public bool SendAppearance(UUID agentId)
{ {
ScenePresence sp = m_scene.GetScenePresence(agentId); ScenePresence sp = m_scene.GetScenePresence(agentId);
if (sp == null) if (sp == null)
{ {
m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId);
return false; return false;
} }
// Send the appearance to everyone in the scene // Send the appearance to everyone in the scene
sp.SendAppearanceToAllOtherAgents(); sp.SendAppearanceToAllOtherAgents();
// Send animations back to the avatar as well // Send animations back to the avatar as well
sp.Animator.SendAnimPack(); sp.Animator.SendAnimPack();
return true; return true;
} }
public Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId) public Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId)
{ {
ScenePresence sp = m_scene.GetScenePresence(agentId); ScenePresence sp = m_scene.GetScenePresence(agentId);
if (sp == null) if (sp == null)
return new Dictionary<BakeType, Primitive.TextureEntryFace>(); return new Dictionary<BakeType, Primitive.TextureEntryFace>();
return GetBakedTextureFaces(sp); return GetBakedTextureFaces(sp);
} }
public bool SaveBakedTextures(UUID agentId) public bool SaveBakedTextures(UUID agentId)
{ {
ScenePresence sp = m_scene.GetScenePresence(agentId); ScenePresence sp = m_scene.GetScenePresence(agentId);
if (sp == null) if (sp == null)
return false; return false;
m_log.DebugFormat( m_log.DebugFormat(
"[AV FACTORY]: Permanently saving baked textures for {0} in {1}", "[AV FACTORY]: Permanently saving baked textures for {0} in {1}",
sp.Name, m_scene.RegionInfo.RegionName); sp.Name, m_scene.RegionInfo.RegionName);
Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp); Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp);
if (bakedTextures.Count == 0) if (bakedTextures.Count == 0)
return false; return false;
foreach (BakeType bakeType in bakedTextures.Keys) foreach (BakeType bakeType in bakedTextures.Keys)
{ {
Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType]; Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType];
if (bakedTextureFace == null) if (bakedTextureFace == null)
{ {
m_log.WarnFormat( m_log.WarnFormat(
"[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently",
bakeType, sp.Name, m_scene.RegionInfo.RegionName); bakeType, sp.Name, m_scene.RegionInfo.RegionName);
continue; continue;
} }
AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString()); AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString());
if (asset != null) if (asset != null)
{ {
asset.Temporary = false; asset.Temporary = false;
asset.Local = false; asset.Local = false;
m_scene.AssetService.Store(asset); m_scene.AssetService.Store(asset);
} }
else else
{ {
m_log.WarnFormat( m_log.WarnFormat(
"[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently", "[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently",
bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName); bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName);
} }
} }
return true; return true;
} }
/// <summary> /// <summary>
/// Check for the existence of the baked texture assets. /// Check for the existence of the baked texture assets.
/// </summary> /// </summary>
@ -249,42 +249,42 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
public bool ValidateBakedTextureCache(IScenePresence sp) public bool ValidateBakedTextureCache(IScenePresence sp)
{ {
return ValidateBakedTextureCache(sp, true); return ValidateBakedTextureCache(sp, true);
} }
/// <summary> /// <summary>
/// Queue up a request to send appearance, makes it possible to /// Queue up a request to send appearance, makes it possible to
/// accumulate changes without sending out each one separately. /// accumulate changes without sending out each one separately.
/// </summary> /// </summary>
public void QueueAppearanceSend(UUID agentid) public void QueueAppearanceSend(UUID agentid)
{ {
// m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid);
// 10000 ticks per millisecond, 1000 milliseconds per second // 10000 ticks per millisecond, 1000 milliseconds per second
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000);
lock (m_sendqueue) lock (m_sendqueue)
{ {
m_sendqueue[agentid] = timestamp; m_sendqueue[agentid] = timestamp;
m_updateTimer.Start(); m_updateTimer.Start();
} }
} }
public void QueueAppearanceSave(UUID agentid) public void QueueAppearanceSave(UUID agentid)
{ {
// m_log.WarnFormat("[AVFACTORY]: Queue appearance save for {0}", agentid); // m_log.WarnFormat("[AVFACTORY]: Queue appearance save for {0}", agentid);
// 10000 ticks per millisecond, 1000 milliseconds per second // 10000 ticks per millisecond, 1000 milliseconds per second
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000);
lock (m_savequeue) lock (m_savequeue)
{ {
m_savequeue[agentid] = timestamp; m_savequeue[agentid] = timestamp;
m_updateTimer.Start(); m_updateTimer.Start();
} }
} }
#endregion #endregion
#region AvatarFactoryModule private methods #region AvatarFactoryModule private methods
/// <summary> /// <summary>
/// Check for the existence of the baked texture assets. Request a rebake /// Check for the existence of the baked texture assets. Request a rebake
/// unless checkonly is true. /// unless checkonly is true.
@ -416,105 +416,105 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (m_savequeue.Count == 0 && m_sendqueue.Count == 0) if (m_savequeue.Count == 0 && m_sendqueue.Count == 0)
m_updateTimer.Stop(); m_updateTimer.Stop();
} }
private void SaveAppearance(UUID agentid) private void SaveAppearance(UUID agentid)
{ {
// We must set appearance parameters in the en_US culture in order to avoid issues where values are saved // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved
// in a culture where decimal points are commas and then reloaded in a culture which just treats them as // in a culture where decimal points are commas and then reloaded in a culture which just treats them as
// number seperators. // number seperators.
Culture.SetCurrentCulture(); Culture.SetCurrentCulture();
ScenePresence sp = m_scene.GetScenePresence(agentid); ScenePresence sp = m_scene.GetScenePresence(agentid);
if (sp == null) if (sp == null)
{ {
m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid);
return; return;
} }
// m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid); // m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid);
// This could take awhile since it needs to pull inventory // This could take awhile since it needs to pull inventory
// We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape
// assets and item asset id changes to complete. // assets and item asset id changes to complete.
// I don't think we need to worry about doing this within m_setAppearanceLock since the queueing avoids // I don't think we need to worry about doing this within m_setAppearanceLock since the queueing avoids
// multiple save requests. // multiple save requests.
SetAppearanceAssets(sp.UUID, sp.Appearance); SetAppearanceAssets(sp.UUID, sp.Appearance);
m_scene.AvatarService.SetAppearance(agentid, sp.Appearance); m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
} }
private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance)
{ {
IInventoryService invService = m_scene.InventoryService; IInventoryService invService = m_scene.InventoryService;
if (invService.GetRootFolder(userID) != null) if (invService.GetRootFolder(userID) != null)
{ {
for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
{ {
for (int j = 0; j < appearance.Wearables[j].Count; j++) for (int j = 0; j < appearance.Wearables[j].Count; j++)
{ {
if (appearance.Wearables[i][j].ItemID == UUID.Zero) if (appearance.Wearables[i][j].ItemID == UUID.Zero)
continue; continue;
// Ignore ruth's assets // Ignore ruth's assets
if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID)
continue; continue;
InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID);
baseItem = invService.GetItem(baseItem); baseItem = invService.GetItem(baseItem);
if (baseItem != null) if (baseItem != null)
{ {
appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID);
} }
else else
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
appearance.Wearables[i][j].ItemID, (WearableType)i); appearance.Wearables[i][j].ItemID, (WearableType)i);
appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID);
} }
} }
} }
} }
else else
{ {
m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
} }
} }
#endregion #endregion
#region Client Event Handlers #region Client Event Handlers
/// <summary> /// <summary>
/// Tell the client for this scene presence what items it should be wearing now /// Tell the client for this scene presence what items it should be wearing now
/// </summary> /// </summary>
/// <param name="client"></param> /// <param name="client"></param>
private void Client_OnRequestWearables(IClientAPI client) private void Client_OnRequestWearables(IClientAPI client)
{ {
// m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId);
ScenePresence sp = m_scene.GetScenePresence(client.AgentId); ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp != null) if (sp != null)
client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++);
else else
m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId);
} }
/// <summary> /// <summary>
/// Set appearance data (texture asset IDs and slider settings) received from a client /// Set appearance data (texture asset IDs and slider settings) received from a client
/// </summary> /// </summary>
/// <param name="client"></param> /// <param name="client"></param>
/// <param name="texture"></param> /// <param name="texture"></param>
/// <param name="visualParam"></param> /// <param name="visualParam"></param>
private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
{ {
// m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId);
ScenePresence sp = m_scene.GetScenePresence(client.AgentId); ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp != null) if (sp != null)
SetAppearance(sp, textureEntry, visualParams); SetAppearance(sp, textureEntry, visualParams);
else else
m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId);
} }
/// <summary> /// <summary>
@ -523,7 +523,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="client"></param> /// <param name="client"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Client_OnAvatarNowWearing(IClientAPI client, AvatarWearingArgs e) private void Client_OnAvatarNowWearing(IClientAPI client, AvatarWearingArgs e)
{ {
// m_log.WarnFormat("[AVFACTORY]: Client_OnAvatarNowWearing called for {0} ({1})", client.Name, client.AgentId); // m_log.WarnFormat("[AVFACTORY]: Client_OnAvatarNowWearing called for {0} ({1})", client.Name, client.AgentId);
ScenePresence sp = m_scene.GetScenePresence(client.AgentId); ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null) if (sp == null)
@ -558,8 +558,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// of visual param and baked texture changes. When those complete, the new appearance will be sent // of visual param and baked texture changes. When those complete, the new appearance will be sent
QueueAppearanceSave(client.AgentId); QueueAppearanceSave(client.AgentId);
} }
} }
#endregion #endregion
} }
} }

View File

@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
AvatarFactoryModule afm = new AvatarFactoryModule(); AvatarFactoryModule afm = new AvatarFactoryModule();
TestScene scene = SceneHelpers.SetupScene(assetCache); TestScene scene = SceneHelpers.SetupScene(assetCache);
SceneHelpers.SetupSceneModules(scene, afm); SceneHelpers.SetupSceneModules(scene, afm);
ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
// TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules

View File

@ -32,8 +32,8 @@ using OpenSim.Framework;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
{ {
public interface IAvatarFactoryModule public interface IAvatarFactoryModule
{ {
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
/// <summary> /// <summary>

View File

@ -987,6 +987,46 @@ namespace OpenSim.Region.Framework.Scenes
return found; return found;
} }
/// <summary>
/// Checks whether this region has a neighbour in the given direction.
/// </summary>
/// <param name="car"></param>
/// <param name="fix"></param>
/// <returns>
/// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
/// Returns a positive integer if there is a region in that direction, a negative integer if not.
/// </returns>
public int HaveNeighbor(Cardinals car, ref int[] fix)
{
uint neighbourx = RegionInfo.RegionLocX;
uint neighboury = RegionInfo.RegionLocY;
int dir = (int)car;
if (dir > 1 && dir < 5) //Heading East
neighbourx++;
else if (dir > 5) // Heading West
neighbourx--;
if (dir < 3 || dir == 8) // Heading North
neighboury++;
else if (dir > 3 && dir < 7) // Heading Sout
neighboury--;
int x = (int)(neighbourx * Constants.RegionSize);
int y = (int)(neighboury * Constants.RegionSize);
GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y);
if (neighbourRegion == null)
{
fix[0] = (int)(RegionInfo.RegionLocX - neighbourx);
fix[1] = (int)(RegionInfo.RegionLocY - neighboury);
return dir * (-1);
}
else
return dir;
}
// Alias IncomingHelloNeighbour OtherRegionUp, for now // Alias IncomingHelloNeighbour OtherRegionUp, for now
public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
{ {

View File

@ -3134,17 +3134,17 @@ namespace OpenSim.Region.Framework.Scenes
if (m_scene.TestBorderCross(pos2, Cardinals.S)) if (m_scene.TestBorderCross(pos2, Cardinals.S))
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.SW, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix);
} }
else if (m_scene.TestBorderCross(pos2, Cardinals.N)) else if (m_scene.TestBorderCross(pos2, Cardinals.N))
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.NW, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix);
} }
else else
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.W, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix);
} }
} }
else if (m_scene.TestBorderCross(pos2, Cardinals.E)) else if (m_scene.TestBorderCross(pos2, Cardinals.E))
@ -3152,28 +3152,28 @@ namespace OpenSim.Region.Framework.Scenes
if (m_scene.TestBorderCross(pos2, Cardinals.S)) if (m_scene.TestBorderCross(pos2, Cardinals.S))
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.SE, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix);
} }
else if (m_scene.TestBorderCross(pos2, Cardinals.N)) else if (m_scene.TestBorderCross(pos2, Cardinals.N))
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.NE, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix);
} }
else else
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.E, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix);
} }
} }
else if (m_scene.TestBorderCross(pos2, Cardinals.S)) else if (m_scene.TestBorderCross(pos2, Cardinals.S))
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.S, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix);
} }
else if (m_scene.TestBorderCross(pos2, Cardinals.N)) else if (m_scene.TestBorderCross(pos2, Cardinals.N))
{ {
needsTransit = true; needsTransit = true;
neighbor = HaveNeighbor(Cardinals.N, ref fix); neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix);
} }
// Makes sure avatar does not end up outside region // Makes sure avatar does not end up outside region
@ -3248,46 +3248,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Checks whether this region has a neighbour in the given direction.
/// </summary>
/// <param name="car"></param>
/// <param name="fix"></param>
/// <returns>
/// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
/// Returns a positive integer if there is a region in that direction, a negative integer if not.
/// </returns>
protected int HaveNeighbor(Cardinals car, ref int[] fix)
{
uint neighbourx = m_scene.RegionInfo.RegionLocX;
uint neighboury = m_scene.RegionInfo.RegionLocY;
int dir = (int)car;
if (dir > 1 && dir < 5) //Heading East
neighbourx++;
else if (dir > 5) // Heading West
neighbourx--;
if (dir < 3 || dir == 8) // Heading North
neighboury++;
else if (dir > 3 && dir < 7) // Heading Sout
neighboury--;
int x = (int)(neighbourx * Constants.RegionSize);
int y = (int)(neighboury * Constants.RegionSize);
GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
if (neighbourRegion == null)
{
fix[0] = (int)(m_scene.RegionInfo.RegionLocX - neighbourx);
fix[1] = (int)(m_scene.RegionInfo.RegionLocY - neighboury);
return dir * (-1);
}
else
return dir;
}
/// <summary> /// <summary>
/// Moves the agent outside the region bounds /// Moves the agent outside the region bounds
/// Tells neighbor region that we're crossing to it /// Tells neighbor region that we're crossing to it