Harmonizing SP with Avination

iar_mods
Melanie 2011-12-22 16:48:52 +00:00
parent 219ec7ef20
commit 2347593dac
1 changed files with 57 additions and 43 deletions

View File

@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes
/// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is
/// necessary. /// necessary.
/// </remarks> /// </remarks>
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
public Object AttachmentsSyncLock { get; private set; } public Object AttachmentsSyncLock { get; private set; }
@ -550,8 +550,12 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
m_pos = value; // Don't update while sitting
ParentPosition = Vector3.Zero; if (ParentID == 0)
{
m_pos = value;
ParentPosition = Vector3.Zero;
}
//m_log.DebugFormat( //m_log.DebugFormat(
// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
@ -566,6 +570,13 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 OffsetPosition public Vector3 OffsetPosition
{ {
get { return m_pos; } get { return m_pos; }
set
{
// There is no offset position when not seated
if (ParentID == 0)
return;
m_pos = value;
}
} }
/// <summary> /// <summary>
@ -2740,8 +2751,10 @@ namespace OpenSim.Region.Framework.Scenes
if (IsChildAgent) if (IsChildAgent)
return; return;
// We only do this if we have a physics actor or we're sitting on something if (ParentID != 0)
if (ParentID == 0 && PhysicsActor != null || ParentID != 0) return;
if (!IsInTransit)
{ {
Vector3 pos2 = AbsolutePosition; Vector3 pos2 = AbsolutePosition;
Vector3 vel = Velocity; Vector3 vel = Velocity;
@ -3100,30 +3113,28 @@ namespace OpenSim.Region.Framework.Scenes
catch { } catch { }
// Attachment objects // Attachment objects
lock (m_attachments) List<SceneObjectGroup> attachments = GetAttachments();
if (attachments.Count > 0)
{ {
if (m_attachments.Count > 0) cAgent.AttachmentObjects = new List<ISceneObject>();
{ cAgent.AttachmentObjectStates = new List<string>();
cAgent.AttachmentObjects = new List<ISceneObject>(); // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
cAgent.AttachmentObjectStates = new List<string>(); InTransitScriptStates.Clear();
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
InTransitScriptStates.Clear();
foreach (SceneObjectGroup sog in m_attachments) foreach (SceneObjectGroup sog in attachments)
{ {
// We need to make a copy and pass that copy // We need to make a copy and pass that copy
// because of transfers withn the same sim // because of transfers withn the same sim
ISceneObject clone = sog.CloneForNewScene(); ISceneObject clone = sog.CloneForNewScene();
// Attachment module assumes that GroupPosition holds the offsets...! // Attachment module assumes that GroupPosition holds the offsets...!
((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
((SceneObjectGroup)clone).IsAttachment = false; ((SceneObjectGroup)clone).IsAttachment = false;
cAgent.AttachmentObjects.Add(clone); cAgent.AttachmentObjects.Add(clone);
string state = sog.GetStateSnapshot(); string state = sog.GetStateSnapshot();
cAgent.AttachmentObjectStates.Add(state); cAgent.AttachmentObjectStates.Add(state);
InTransitScriptStates.Add(state); InTransitScriptStates.Add(state);
// Let's remove the scripts of the original object here // Let's remove the scripts of the original object here
sog.RemoveScriptInstances(true); sog.RemoveScriptInstances(true);
}
} }
} }
} }
@ -3531,26 +3542,29 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="args">The arguments for the event</param> /// <param name="args">The arguments for the event</param>
public void SendScriptEventToAttachments(string eventName, Object[] args) public void SendScriptEventToAttachments(string eventName, Object[] args)
{ {
if (m_scriptEngines.Length == 0) Util.FireAndForget(delegate(object x)
return;
lock (m_attachments)
{ {
foreach (SceneObjectGroup grp in m_attachments) if (m_scriptEngines.Length == 0)
{ return;
// 16384 is CHANGED_ANIMATION
//
// Send this to all attachment root prims
//
foreach (IScriptModule m in m_scriptEngines)
{
if (m == null) // No script engine loaded
continue;
m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); lock (m_attachments)
{
foreach (SceneObjectGroup grp in m_attachments)
{
// 16384 is CHANGED_ANIMATION
//
// Send this to all attachment root prims
//
foreach (IScriptModule m in m_scriptEngines)
{
if (m == null) // No script engine loaded
continue;
m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION });
}
} }
} }
} });
} }
internal void PushForce(Vector3 impulse) internal void PushForce(Vector3 impulse)