From b70da6ac1955ada29e1cb4dbe9aeb915735ec686 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Wed, 30 Apr 2008 16:52:12 +0000
Subject: * 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
---
.../Environment/Scenes/Scene.PacketHandlers.cs | 4 +-
.../Scenes/SceneObjectGroup.Inventory.cs | 2 +-
.../Region/Environment/Scenes/SceneObjectGroup.cs | 107 +++------------------
.../Scenes/SceneObjectPart.Inventory.cs | 2 +-
.../Region/Environment/Scenes/SceneObjectPart.cs | 105 ++++++++++++++++++--
.../Region/Environment/Scenes/SceneXmlLoader.cs | 8 +-
6 files changed, 120 insertions(+), 108 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index 71b2716..dccc09a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -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);
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index 2d0c636..824a536 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Environment.Scenes
if (part != null)
{
part.StopScript(itemID);
- RemoveScriptEvents(itemID);
+ part.RemoveScriptEvents(itemID);
}
else
{
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index c28e66f..863146c 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -96,8 +96,6 @@ namespace OpenSim.Region.Environment.Scenes
private LLVector3 lastPhysGroupPos;
private LLQuaternion lastPhysGroupRot;
- private scriptEvents m_aggregateScriptEvents = scriptEvents.None;
-
///
/// The constituent parts of this group
///
@@ -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;
-
- 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;
- }
+ uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags();
- if ((m_aggregateScriptEvents & scriptEvents.money) != 0)
- {
- objectflagupdate |= (uint) LLObject.ObjectFlags.Money;
- }
- else
- {
- objectflagupdate &= ~(uint) LLObject.ObjectFlags.Money;
- }
+ scriptEvents aggregateScriptEvents=0;
- 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);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 42047ad..0215cec 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -170,7 +170,7 @@ namespace OpenSim.Region.Environment.Scenes
if (10 == item.Type)
{
StopScript(item.ItemID);
- m_parentGroup.RemoveScriptEvents(item.ItemID);
+ RemoveScriptEvents(item.ItemID);
}
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 6cfe3e9..8d05987 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -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 m_scriptEvents = new Dictionary();
+ [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();
+ }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 391d3f3..8390f64 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -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,
--
cgit v1.1