From b35a1d56818386fc70a4a71e3cd8f6dd6d0e2193 Mon Sep 17 00:00:00 2001 From: Stefan_Boom Date: Sat, 14 Apr 2012 22:05:16 +0200 Subject: Fixing wrong position of llSensor, SensePoint wasnt following the rotation of the root prim. --- .../Api/Implementation/Plugins/SensorRepeat.cs | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 1c272f8..57f741c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } SceneObjectPart SensePoint = ts.host; - Vector3 fromRegionPos = SensePoint.AbsolutePosition; + Vector3 fromRegionPos = SensePoint.GetWorldPosition(); // pre define some things to avoid repeated definitions in the loop body Vector3 toRegionPos; @@ -319,14 +319,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins float dy; float dz; - Quaternion q = SensePoint.RotationOffset; + Quaternion q = SensePoint.GetWorldRotation(); if (SensePoint.ParentGroup.IsAttachment) { - // In attachments, the sensor cone always orients with the + // In attachments, rotate the sensor cone with the // avatar rotation. This may include a nonzero elevation if // in mouselook. + // This will not include the rotation and position of the + // attachment point (e.g. your head when a sensor is in your + // hair attached to your scull. Your hair will turn with + // your head but the sensor will stay with your (global) + // avatar rotation and position. + // Position of a sensor in a child prim attached to an avatar + // will be still wrong. ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); - q = avatar.Rotation; + q = avatar.Rotation*q; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); @@ -439,16 +446,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins return sensedEntities; SceneObjectPart SensePoint = ts.host; - Vector3 fromRegionPos = SensePoint.AbsolutePosition; + Vector3 fromRegionPos = SensePoint.GetWorldPosition(); - Quaternion q = SensePoint.RotationOffset; + Quaternion q = SensePoint.GetWorldRotation(); if (SensePoint.ParentGroup.IsAttachment) { - // In attachments, the sensor cone always orients with the + // In attachments, rotate the sensor cone with the // avatar rotation. This may include a nonzero elevation if // in mouselook. + // This will not include the rotation and position of the + // attachment point (e.g. your head when a sensor is in your + // hair attached to your scull. Your hair will turn with + // your head but the sensor will stay with your (global) + // avatar rotation and position. + // Position of a sensor in a child prim attached to an avatar + // will be still wrong. ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); - q = avatar.Rotation; + q = avatar.Rotation*q; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); -- cgit v1.1 From e39e4f6bfb9d28317c2547094f5fe79969f4ede9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Apr 2012 19:40:19 +0100 Subject: minor: style adjustments in SensorRepeat, mainly related to patch from stoehr --- .../ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 57f741c..3844753 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -222,7 +222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // Is the sensor type is AGENT and not SCRIPTED then include agents if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) { - sensedEntities.AddRange(doAgentSensor(ts)); + sensedEntities.AddRange(doAgentSensor(ts)); } // If SCRIPTED or PASSIVE or ACTIVE check objects @@ -333,8 +333,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // Position of a sensor in a child prim attached to an avatar // will be still wrong. ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); - q = avatar.Rotation*q; + q = avatar.Rotation * q; } + LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); @@ -462,7 +463,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // Position of a sensor in a child prim attached to an avatar // will be still wrong. ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); - q = avatar.Rotation*q; + q = avatar.Rotation * q; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); -- cgit v1.1