From 52860a7d154a17c5035702d9a390b219e1aaba03 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 20 Oct 2015 16:55:18 +0100 Subject: stop using a Vector3 to store 3bits --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 49 ++++++++++++++++------ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 30 ++++++++----- 2 files changed, 57 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 48fce3d..329ea11 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -110,6 +110,9 @@ namespace OpenSim.Region.Framework.Scenes STATUS_ROTATE_X = 0x002, STATUS_ROTATE_Y = 0x004, STATUS_ROTATE_Z = 0x008, + NOT_STATUS_ROTATE_X = 0xFD, + NOT_STATUS_ROTATE_Y = 0xFB, + NOT_STATUS_ROTATE_Z = 0xF7 } // This flag has the same purpose as InventoryItemFlags.ObjectSlamPerm @@ -4367,30 +4370,52 @@ namespace OpenSim.Region.Framework.Scenes bool setY = ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0); bool setZ = ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0); - float setval = (rotate10 > 0) ? 1f : 0f; + if (setX || setY || setZ) + { + bool lockaxis = (rotate10 == 0); // zero means axis locked + + byte locks = RootPart.RotationAxisLocks; - if (setX) - RootPart.RotationAxis.X = setval; - if (setY) - RootPart.RotationAxis.Y = setval; - if (setZ) - RootPart.RotationAxis.Z = setval; + if (setX) + { + if(lockaxis) + locks |= (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_X; + else + locks &= (byte)SceneObjectGroup.axisSelect.NOT_STATUS_ROTATE_X; + } + + if (setY) + { + if(lockaxis) + locks |= (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y; + else + locks &= (byte)SceneObjectGroup.axisSelect.NOT_STATUS_ROTATE_Y; + } - if (setX || setY || setZ) + if (setZ) + { + if(lockaxis) + locks |= (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z; + else + locks &= (byte)SceneObjectGroup.axisSelect.NOT_STATUS_ROTATE_Z; + } + + RootPart.RotationAxisLocks = locks; RootPart.SetPhysicsAxisRotation(); + } } public int GetAxisRotation(int axis) { - Vector3 rotAxis = RootPart.RotationAxis; + byte rotAxislocks = RootPart.RotationAxisLocks; // if multiple return the one with higher id if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) - return (int)rotAxis.Z; + return (rotAxislocks & (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) == 0 ? 1:0; if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) - return (int)rotAxis.Y; + return (rotAxislocks & (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) == 0 ? 1:0; if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) - return (int)rotAxis.X; + return (rotAxislocks & (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) == 0 ? 1:0; return 0; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0ea4ab8..6e7b568 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -254,11 +254,13 @@ namespace OpenSim.Region.Framework.Scenes public Quaternion AttachRotation = Quaternion.Identity; [XmlIgnore] - public int STATUS_ROTATE_X; - - public int STATUS_ROTATE_Y; + public int STATUS_ROTATE_X; // this should not be used + + [XmlIgnore] + public int STATUS_ROTATE_Y; // this should not be used - public int STATUS_ROTATE_Z; + [XmlIgnore] + public int STATUS_ROTATE_Z; // this should not be used private Dictionary m_CollisionFilter = new Dictionary(); @@ -278,7 +280,10 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 AttachedPos; - public Vector3 RotationAxis = Vector3.One; + // rotation locks on local X,Y and or Z axis bit flags + // bits are as in llSetStatus defined in SceneObjectGroup.axisSelect enum + // but reversed logic: bit cleared means free to rotate + public byte RotationAxisLocks = 0; public bool VolumeDetectActive; @@ -778,9 +783,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_damage = value; } } - - - public void setGroupPosition(Vector3 pos) { m_groupPosition = pos; @@ -791,7 +793,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// - public Vector3 GroupPosition { get @@ -3860,7 +3861,16 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter if (pa != null) { - pa.LockAngularMotion(RotationAxis); + // physics should also get a byte and not a Vector3 TODO + Vector3 lrRotationAxis = Vector3.One; + if((RotationAxisLocks & (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) != 0 ) + lrRotationAxis.X = 0f; + if((RotationAxisLocks & (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0 ) + lrRotationAxis.Y = 0f; + if((RotationAxisLocks & (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0 ) + lrRotationAxis.Z = 0f; + + pa.LockAngularMotion(lrRotationAxis); ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); } } -- cgit v1.1