stop using a Vector3 to store 3bits

avinationmerge
UbitUmarov 2015-10-20 16:55:18 +01:00
parent dfd60d6f71
commit 52860a7d15
2 changed files with 58 additions and 23 deletions

View File

@ -110,6 +110,9 @@ namespace OpenSim.Region.Framework.Scenes
STATUS_ROTATE_X = 0x002, STATUS_ROTATE_X = 0x002,
STATUS_ROTATE_Y = 0x004, STATUS_ROTATE_Y = 0x004,
STATUS_ROTATE_Z = 0x008, 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 // 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 setY = ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0);
bool setZ = ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0); bool setZ = ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0);
float setval = (rotate10 > 0) ? 1f : 0f;
if (setX)
RootPart.RotationAxis.X = setval;
if (setY)
RootPart.RotationAxis.Y = setval;
if (setZ)
RootPart.RotationAxis.Z = setval;
if (setX || setY || setZ) if (setX || setY || setZ)
{
bool lockaxis = (rotate10 == 0); // zero means axis locked
byte locks = RootPart.RotationAxisLocks;
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 (setZ)
{
if(lockaxis)
locks |= (byte)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z;
else
locks &= (byte)SceneObjectGroup.axisSelect.NOT_STATUS_ROTATE_Z;
}
RootPart.RotationAxisLocks = locks;
RootPart.SetPhysicsAxisRotation(); RootPart.SetPhysicsAxisRotation();
}
} }
public int GetAxisRotation(int axis) public int GetAxisRotation(int axis)
{ {
Vector3 rotAxis = RootPart.RotationAxis; byte rotAxislocks = RootPart.RotationAxisLocks;
// if multiple return the one with higher id // if multiple return the one with higher id
if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) 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) 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) 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; return 0;
} }

View File

@ -254,11 +254,13 @@ namespace OpenSim.Region.Framework.Scenes
public Quaternion AttachRotation = Quaternion.Identity; public Quaternion AttachRotation = Quaternion.Identity;
[XmlIgnore] [XmlIgnore]
public int STATUS_ROTATE_X; 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_Y; [XmlIgnore]
public int STATUS_ROTATE_Z; // this should not be used
public int STATUS_ROTATE_Z;
private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>(); private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>();
@ -278,7 +280,10 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 AttachedPos; 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; public bool VolumeDetectActive;
@ -778,9 +783,6 @@ namespace OpenSim.Region.Framework.Scenes
set { m_damage = value; } set { m_damage = value; }
} }
public void setGroupPosition(Vector3 pos) public void setGroupPosition(Vector3 pos)
{ {
m_groupPosition = pos; m_groupPosition = pos;
@ -791,7 +793,6 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
/// ///
public Vector3 GroupPosition public Vector3 GroupPosition
{ {
get get
@ -3860,7 +3861,16 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
if (pa != null) 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); ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
} }
} }