Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005959opensim[REGION] Script Functionspublic2012-04-11 20:412012-05-06 01:38
ReporterStefan_Boom 
Assigned Tojustincc 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformUbuntu 11.10OSOS Version
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0005959: [PATCH] Fix llSensor in Child Prim has wrong position when root prim is rotated
DescriptionPosition of llSensor in a child (origin of the sensor sphere) is not following the rotation of the object (root prim)
Steps To ReproduceCreate a prim (will be root prim) (no rotation)
Create a 2nd prim (no rotation) 8 meter away, put a sensor in it with range 2m, step closer 2 meters so it detects your avatar. -working-

Link the sensor prim to the first prim (which will be the root prim)
-still working-

Now roatate the object (root prim) lets say 90 degrees around the z-axis
the child prim with sensor will also rotate away from your avatar position,
BUT .. the sensor will still detect your avatar. If your Avatar moves closer to the new child prim position the sensor will not detect your avatar.
Additional Information[PATCH] included fixing: llSensor in Child Prim has "wrong" position and rotation when root prim is rotated
by using SOP.GetWorldPosition() and SOP.GetWorldRotation() instead of SOP.AbosultePosition and SOP.RotationOfsset

Also behavior (In attachments, the sensor cone always orients with the avatar rotation.) is changed to (In attachments, rotate the sensor cone with the avatar rotation.) which make it possible to sense behind/over/under your avatar by rotating the attached llSensor-prim.

Sensor in child prim, attached to an avatar still will have wrong position.
Think of:
a) The Sensor is placed with the global avatar position/rotation, not the coordinates of the attachment point (your head is turning, your attached heairs will turn too, but the sensor inside your hair prim will stick to the avatar rotation.
b) Is it a wanted feature that an attached sensor is following the rotation of the attachment-point (like when attached to your eyes following any movement of your eyes and sensing in direction of avatars eye/head movement?

Further observation about SOP.GetWorld*() see note
TagsNo tags attached.
Git Revision or version numberall (up to 2c74e1b-r18682)
Run Mode Standalone (Multiple Regions)
Physics EngineODE
EnvironmentMono / Linux64
Mono Version2.10
ViewerImprudence
Attached Filespatch file icon 0001-Fixing-wrong-position-of-llSensor-SensePoint-wasnt-f.patch [^] (4,160 bytes) 2012-04-14 20:14 [Show Content]

- Relationships
has duplicate 0004574resolvedStefan_Boom Directional sensors in child prims don't scan in the right direction 

-  Notes
(0021225)
Stefan_Boom (reporter)
2012-04-11 22:04

Oki, never digged into the source code before, so whats following maybe not helping at all:
In
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs:
we have a Vector3 fromRegionPos = SensePoint.AbsolutePosition;
from
public Vector3 AbsolutePosition
        {
            get {
                if (IsAttachment)
                    return GroupPosition;

                return m_offsetPosition + m_groupPosition; }
        }
i havent found any rotation calculation for getting the absolute coordinates of a child prim (and SensePoint) .. that would explain my observation.. but as i said... first time digging into the code, so there is a 110% chance that i havent understood it at all :-)
(0021226)
Stefan_Boom (reporter)
2012-04-11 23:25

... trying out GetWorldPosition() ...
(0021227)
Stefan_Boom (reporter)
2012-04-12 00:11

Oki, the following change is solving the problem (with position of llSensor)
whats left is getting the right rotation....

diff OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs.dist OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs.new
311c311
< Vector3 fromRegionPos = SensePoint.AbsolutePosition;
---
> Vector3 fromRegionPos = SensePoint.GetWorldPosition();
442c442
< Vector3 fromRegionPos = SensePoint.AbsolutePosition;
---
> Vector3 fromRegionPos = SensePoint.GetWorldPosition();
(0021228)
Stefan_Boom (reporter)
2012-04-12 00:38

Here we go.. LLSensor with right position and rotatation
TODO: Testing. and TODO: (since it was my first journey into the code) Side effects? is GetWorldxxx doing something special/diffrent for Avatars/physical prims/normal prims? but so far its working for me.

diff OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs.dist OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs.new
311c311
< Vector3 fromRegionPos = SensePoint.AbsolutePosition;
---
> Vector3 fromRegionPos = SensePoint.GetWorldPosition();
322c322
< Quaternion q = SensePoint.RotationOffset;
---
> Quaternion q = SensePoint.GetWorldRotation();
442c442
< Vector3 fromRegionPos = SensePoint.AbsolutePosition;
---
> Vector3 fromRegionPos = SensePoint.GetWorldPosition();
444c444
< Quaternion q = SensePoint.RotationOffset;
---
> Quaternion q = SensePoint.GetWorldRotation();
(0021229)
Stefan_Boom (reporter)
2012-04-12 00:38

see last note :-)
(0021240)
justincc (administrator)
2012-04-14 00:17
edited on: 2012-04-14 00:22

I think you're on the right track, nice work Stefan. You can assume that GetWorld* methods do not have side effects - they are not implemented for ScenePresence anyway.

To be honest, the more I look at it, the more I'm sure that SOP.AbsolutePosition should be returning GetWorldPosition() rather than m_offsetPosition + m_groupPosition, as the latter is not the absolute position.

However, this is the kind of thing I would want to look at after your patch, so using GetWorldPosition() is absolutely fine.

If you could submit a patch with line numbers in that would be much better. Even better would be a patch generated by git.

Are you intending to do more testing yourself on this?

(0021241)
Stefan_Boom (reporter)
2012-04-14 00:24

Sure, i will finish testing and will make a git-patch...
(0021246)
Stefan_Boom (reporter)
2012-04-14 20:13
edited on: 2012-04-14 20:18

[PATCH] uploaded

Observation while digging into it:
SOP.AbsolutePosition is not calculating any rotation so it cant be used for child prim position.
SOP.GetWorldPosition() is returning Avatar center position for attached root prim and not calculting avatar rotation for attached child prims.
SOP.GetWorldRoatation() returns root/child rotatation with no avatar rotation added.

Should SOP.GetWorld*() cover the "object" is attached to an avatar and give correct absolute positions and rotation?

(0021318)
justincc (administrator)
2012-04-27 18:44

Patch commited in git master b35a1d5. Thanks a lot, Stefan!

I think you're right on all three counts about AbsolutePosition, GetWorldPosition and GetWorldRotation(). I suspect these need to be changed down the road but it requires some careful analysis of existing code to make sure it isn't relying on wrong assumptions in these methods (especially AbsolutePosition).

- Issue History
Date Modified Username Field Change
2012-04-11 20:41 Stefan_Boom New Issue
2012-04-11 22:04 Stefan_Boom Note Added: 0021225
2012-04-11 23:25 Stefan_Boom Note Added: 0021226
2012-04-12 00:11 Stefan_Boom Note Added: 0021227
2012-04-12 00:38 Stefan_Boom Note Added: 0021228
2012-04-12 00:38 Stefan_Boom Note Added: 0021229
2012-04-12 00:38 Stefan_Boom Status new => patch included
2012-04-14 00:17 justincc Note Added: 0021240
2012-04-14 00:22 nebadon Note Edited: 0021240 View Revisions
2012-04-14 00:24 Stefan_Boom Note Added: 0021241
2012-04-14 20:13 Stefan_Boom Git Revision 0.7.3 Post Fix Diva Distro => all (up to 2c74e1b-r18682)
2012-04-14 20:13 Stefan_Boom Note Added: 0021246
2012-04-14 20:13 Stefan_Boom Summary llSensor in Child Prim has "wrong" position when root prim is rotated - Opensim 0.7.3 Postfix (Diva Distro) => [PATCH] Fix llSensor in Child Prim has wrong position when root prim is rotated
2012-04-14 20:13 Stefan_Boom Additional Information Updated View Revisions
2012-04-14 20:14 Stefan_Boom File Added: 0001-Fixing-wrong-position-of-llSensor-SensePoint-wasnt-f.patch
2012-04-14 20:18 Stefan_Boom Note Edited: 0021246 View Revisions
2012-04-27 18:44 justincc Note Added: 0021318
2012-04-27 18:44 justincc Status patch included => resolved
2012-04-27 18:44 justincc Resolution open => fixed
2012-04-27 18:44 justincc Assigned To => justincc
2012-05-06 01:38 Stefan_Boom Relationship added has duplicate 0004574


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker