* Patch by Melanie. Implements proper objectflags on child objects. Thanks Melanie!

RE: 0001079: r4387. touch() event does not fire when touch script is in root prim and child prims are touched
0.6.0-stable
Teravus Ovares 2008-04-30 16:52:12 +00:00
parent eac3fd51f0
commit b70da6ac19
12 changed files with 139 additions and 134 deletions

View File

@ -152,7 +152,7 @@ namespace OpenSim.Data.MSSQL
{
foreach (SceneObjectPart prim in obj.Children.Values)
{
if ((prim.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0)
if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0)
{
m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
addPrim(prim, obj.UUID, regionUUID);

View File

@ -148,7 +148,7 @@ namespace OpenSim.Data.MySQL
{
foreach (SceneObjectPart prim in obj.Children.Values)
{
if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
if ((prim.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) == 0)
{
m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
addPrim(prim, obj.UUID, regionUUID);

View File

@ -182,7 +182,7 @@ namespace OpenSim.Data.SQLite
{
foreach (SceneObjectPart prim in obj.Children.Values)
{
if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
if ((prim.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) == 0)
{
m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID));

View File

@ -226,21 +226,14 @@ namespace OpenSim.Region.Environment
// Outside of this method, they should never be added to objectflags!
// -teravus
if (!m_scene.Entities.ContainsKey(objID))
{
return 0;
}
SceneObjectPart task=m_scene.GetSceneObjectPart(objID);
// this shouldn't ever happen.. return no permissions/objectflags.
if (task == null)
return (uint)0;
// If it's not an object, we cant edit it.
if (!(m_scene.Entities[objID] is SceneObjectGroup))
{
return 0;
}
SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID];
LLUUID objectOwner = task.OwnerID;
uint objflags = task.RootPart.ObjectFlags;
uint objflags = task.GetEffectiveObjectFlags();
LLUUID objectOwner = task.OwnerID;
// Remove any of the objectFlags that are temporary. These will get added back if appropriate
@ -257,14 +250,14 @@ namespace OpenSim.Region.Environment
// Creating the three ObjectFlags options for this method to choose from.
// Customize the OwnerMask
uint objectOwnerMask = ApplyObjectModifyMasks(task.RootPart.OwnerMask, objflags);
uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner;
// Customize the GroupMask
uint objectGroupMask = ApplyObjectModifyMasks(task.RootPart.GroupMask, objflags);
uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
// Customize the EveryoneMask
uint objectEveryoneMask = ApplyObjectModifyMasks(task.RootPart.EveryoneMask, objflags);
uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags);
// Hack to allow collaboration until Groups and Group Permissions are implemented

View File

@ -164,7 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
// If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ObjectFlags & (uint)LLObject.ObjectFlags.Touch) != 0)
if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
EventManager.TriggerObjectGrab(part.LocalId, part.OffsetPosition, remoteClient);
else
EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.OffsetPosition, remoteClient);
@ -195,7 +195,7 @@ namespace OpenSim.Region.Environment.Scenes
{
// If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ObjectFlags & (uint)LLObject.ObjectFlags.Touch) != 0)
if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
EventManager.TriggerObjectDeGrab(part.LocalId, remoteClient);
else
EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, remoteClient);

View File

@ -118,7 +118,7 @@ namespace OpenSim.Region.Environment.Scenes
if (part != null)
{
part.StopScript(itemID);
RemoveScriptEvents(itemID);
part.RemoveScriptEvents(itemID);
}
else
{

View File

@ -96,8 +96,6 @@ namespace OpenSim.Region.Environment.Scenes
private LLVector3 lastPhysGroupPos;
private LLQuaternion lastPhysGroupRot;
private scriptEvents m_aggregateScriptEvents = scriptEvents.None;
/// <summary>
/// The constituent parts of this group
/// </summary>
@ -716,7 +714,7 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.SetParentLocalId(0);
m_rootPart.SetAttachmentPoint((byte)0);
m_rootPart.m_IsAttachment = false;
m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim);
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
AttachToBackup();
m_rootPart.ScheduleFullUpdate();
m_rootPart.ClearUndoState();
@ -737,7 +735,7 @@ namespace OpenSim.Region.Environment.Scenes
//m_rootPart.SetAttachmentPoint((byte)0);
m_rootPart.m_IsAttachment = false;
AbsolutePosition = m_rootPart.m_attachedPos;
//m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim);
//m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
//AttachToBackup();
//m_rootPart.ScheduleFullUpdate();
@ -943,100 +941,25 @@ namespace OpenSim.Region.Environment.Scenes
d.AddActiveScripts(count);
}
public void RemoveScriptEvents(LLUUID scriptid)
{
lock (m_scriptEvents)
{
if (m_scriptEvents.ContainsKey(scriptid))
{
scriptEvents oldparts = scriptEvents.None;
oldparts = (scriptEvents) m_scriptEvents[scriptid];
// remove values from aggregated script events
m_aggregateScriptEvents &= ~oldparts;
m_scriptEvents.Remove(scriptid);
}
}
aggregateScriptEvents();
}
public void SetScriptEvents(LLUUID scriptid, int events)
{
scriptEvents oldparts;
lock (m_scriptEvents)
{
if (m_scriptEvents.ContainsKey(scriptid))
{
oldparts = m_scriptEvents[scriptid];
// remove values from aggregated script events
m_aggregateScriptEvents &= ~oldparts;
m_scriptEvents[scriptid] = (scriptEvents) events;
}
else
{
m_scriptEvents.Add(scriptid, (scriptEvents) events);
}
}
aggregateScriptEvents();
}
public void aggregateScriptEvents()
{
// Aggregate script events
lock (m_scriptEvents)
{
foreach (scriptEvents s in m_scriptEvents.Values)
{
m_aggregateScriptEvents |= s;
}
}
uint objectflagupdate = m_rootPart.ObjectFlags;
uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags();
if (
((m_aggregateScriptEvents & scriptEvents.touch) != 0) ||
((m_aggregateScriptEvents & scriptEvents.touch_end) != 0) ||
((m_aggregateScriptEvents & scriptEvents.touch_start) != 0)
)
{
objectflagupdate |= (uint) LLObject.ObjectFlags.Touch;
}
else
{
objectflagupdate &= ~(uint) LLObject.ObjectFlags.Touch;
}
scriptEvents aggregateScriptEvents=0;
if ((m_aggregateScriptEvents & scriptEvents.money) != 0)
{
objectflagupdate |= (uint) LLObject.ObjectFlags.Money;
}
else
{
objectflagupdate &= ~(uint) LLObject.ObjectFlags.Money;
}
if (
((m_aggregateScriptEvents & scriptEvents.collision) != 0) ||
((m_aggregateScriptEvents & scriptEvents.collision_end) != 0) ||
((m_aggregateScriptEvents & scriptEvents.collision_start) != 0)
)
{
// subscribe to physics updates.
}
else
{
// unsubscribe to physics updates.
}
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
part.ObjectFlags = objectflagupdate;
if(part == null)
continue;
if(part != RootPart)
part.ObjectFlags = objectflagupdate;
aggregateScriptEvents |= part.m_aggregateScriptEvents;
}
}
if ((m_aggregateScriptEvents & scriptEvents.at_target) != 0)
if ((aggregateScriptEvents & scriptEvents.at_target) != 0)
{
m_scriptListens_atTarget = true;
}
@ -1045,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes
m_scriptListens_atTarget = false;
}
if ((m_aggregateScriptEvents & scriptEvents.not_at_target) != 0)
if ((aggregateScriptEvents & scriptEvents.not_at_target) != 0)
{
m_scriptListens_notAtTarget = true;
}
@ -1082,12 +1005,12 @@ namespace OpenSim.Region.Environment.Scenes
{
if (m_parts.Count > 1)
{
m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_physicalPrim);
foreach (SceneObjectPart part in m_parts.Values)
{
if (part.LocalId != m_rootPart.LocalId)
{
part.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_physicalPrim);
}
// Hack to get the physics scene geometries in the right spot
ResetChildPrimPhysicsPositions();
@ -1095,7 +1018,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_physicalPrim);
}
}
}
@ -1333,7 +1256,7 @@ namespace OpenSim.Region.Environment.Scenes
else
{
part.RemFlag(LLObject.ObjectFlags.Phantom);
if ((part.ObjectFlags & (int) LLObject.ObjectFlags.Physics) != 0)
if ((part.GetEffectiveObjectFlags() & (int) LLObject.ObjectFlags.Physics) != 0)
{
part.DoPhysicsPropertyUpdate(true, false);
}

View File

@ -170,7 +170,7 @@ namespace OpenSim.Region.Environment.Scenes
if (10 == item.Type)
{
StopScript(item.ItemID);
m_parentGroup.RemoveScriptEvents(item.ItemID);
RemoveScriptEvents(item.ItemID);
}
}
}

View File

@ -99,6 +99,9 @@ namespace OpenSim.Region.Environment.Scenes
// TODO: This needs to be persisted in next XML version update!
[XmlIgnore] public int[] PayPrice = {-2,-2,-2,-2,-2};
[XmlIgnore] private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>();
[XmlIgnore] public scriptEvents m_aggregateScriptEvents=0;
[XmlIgnore] private LLObject.ObjectFlags LocalFlags = LLObject.ObjectFlags.None;
[XmlIgnore] public bool m_IsAttachment = false;
@ -187,7 +190,10 @@ namespace OpenSim.Region.Environment.Scenes
set { m_name = value; }
}
public scriptEvents ScriptEvents
{
get { return m_aggregateScriptEvents; }
}
protected LLObject.MaterialType m_material = 0;
@ -205,6 +211,15 @@ namespace OpenSim.Region.Environment.Scenes
set { m_regionHandle = value; }
}
public uint GetEffectiveObjectFlags()
{
LLObject.ObjectFlags f=Flags;
if(m_parentGroup == null || m_parentGroup.RootPart == this)
f &= ~(LLObject.ObjectFlags.Touch | LLObject.ObjectFlags.Money);
return (uint)Flags | (uint)LocalFlags;
}
//unkown if this will be kept, added as a way of removing the group position from the group class
protected LLVector3 m_groupPosition;
@ -2434,13 +2449,6 @@ namespace OpenSim.Region.Environment.Scenes
SetText( text );
}
public void setScriptEvents(LLUUID scriptID, int events)
{
if (m_parentGroup != null)
{
m_parentGroup.SetScriptEvents(scriptID, events);
}
}
public int registerTargetWaypoint(LLVector3 target, float tolerance)
{
if (m_parentGroup != null)
@ -2581,5 +2589,86 @@ namespace OpenSim.Region.Environment.Scenes
goback.PlaybackState(this);
}
}
public void SetScriptEvents(LLUUID scriptid, int events)
{
scriptEvents oldparts;
lock (m_scriptEvents)
{
if (m_scriptEvents.ContainsKey(scriptid))
{
oldparts = m_scriptEvents[scriptid];
// remove values from aggregated script events
m_scriptEvents[scriptid] = (scriptEvents) events;
}
else
{
m_scriptEvents.Add(scriptid, (scriptEvents) events);
}
}
aggregateScriptEvents();
}
public void RemoveScriptEvents(LLUUID scriptid)
{
lock (m_scriptEvents)
{
if (m_scriptEvents.ContainsKey(scriptid))
{
scriptEvents oldparts = scriptEvents.None;
oldparts = (scriptEvents) m_scriptEvents[scriptid];
// remove values from aggregated script events
m_aggregateScriptEvents &= ~oldparts;
m_scriptEvents.Remove(scriptid);
}
}
aggregateScriptEvents();
}
public void aggregateScriptEvents()
{
// Aggregate script events
lock (m_scriptEvents)
{
foreach (scriptEvents s in m_scriptEvents.Values)
{
m_aggregateScriptEvents |= s;
}
}
uint objectflagupdate = 0;
if (
((m_aggregateScriptEvents & scriptEvents.touch) != 0) ||
((m_aggregateScriptEvents & scriptEvents.touch_end) != 0) ||
((m_aggregateScriptEvents & scriptEvents.touch_start) != 0)
)
{
objectflagupdate |= (uint) LLObject.ObjectFlags.Touch;
}
if ((m_aggregateScriptEvents & scriptEvents.money) != 0)
{
objectflagupdate |= (uint) LLObject.ObjectFlags.Money;
}
if (
((m_aggregateScriptEvents & scriptEvents.collision) != 0) ||
((m_aggregateScriptEvents & scriptEvents.collision_end) != 0) ||
((m_aggregateScriptEvents & scriptEvents.collision_start) != 0)
)
{
// subscribe to physics updates.
}
LocalFlags=(LLObject.ObjectFlags)objectflagupdate;
if(m_parentGroup != null && m_parentGroup.RootPart == this)
m_parentGroup.aggregateScriptEvents();
else
ScheduleFullUpdate();
}
}
}

View File

@ -76,9 +76,9 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
// Apply loadOffsets for load/import and move combinations
rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
m_parentScene.m_physicalPrim);
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
{
rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
rootPart.Name,
@ -186,9 +186,9 @@ namespace OpenSim.Region.Environment.Scenes
m_innerScene.AddEntityFromStorage(obj);
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
m_parentScene.m_physicalPrim);
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
{
rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
rootPart.Name,

View File

@ -863,23 +863,23 @@ namespace OpenSim.Region.ScriptEngine.Common
public int llGetStatus(int status)
{
m_host.AddScriptLPS(1);
Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.ObjectFlags.ToString());
Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString());
switch (status)
{
case BuiltIn_Commands_BaseClass.STATUS_PHYSICS:
if ((m_host.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics)
if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics)
{
return 1;
}
return 0;
case BuiltIn_Commands_BaseClass.STATUS_PHANTOM:
if ((m_host.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom)
if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom)
{
return 1;
}
return 0;
case BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS:
if ((m_host.ObjectFlags & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows)
if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows)
{
return 1;
}
@ -2154,7 +2154,7 @@ namespace OpenSim.Region.ScriptEngine.Common
bool attachment=false; // Attachments not implemented yet. TODO: reflect real attachemnt state
if(attachment && agent == m_host.OwnerID)
if(m_host.ParentGroup.RootPart.m_IsAttachment && agent == m_host.ParentGroup.RootPart.m_attachedAvatar)
{
// When attached, certain permissions are implicit if requested from owner
int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS |

View File

@ -528,7 +528,7 @@ namespace OpenSim.Region.ScriptEngine.Common
public void osSetStateEvents(int events)
{
m_host.setScriptEvents(m_itemID, events);
m_host.SetScriptEvents(m_itemID, events);
}
}