BIG MESS. changed Iclient interface so only one event is used to inform scene about position scale or rotation change by client (others can be added). Its served at SceneGraph that does permition checks, undostore and sends down to SOG. changed values are stored in a class (ObjectChangeData) and what is changed as a enum (ObjectChangeWhat) with bit fields and 'macros' of this for better readability (at top of scenegraph.cs lasy to find better place for now) this can be extended for other things clients changes and need undo/redo. SOG process acording to what is changed. Changed UNDO/redo to use this also (warning is only storing what is changed, previus stored all, this must be checked for side efects. to save all PRS change commented line in scenegraph). Still have excessive calls to ScheduleGroupForTerseUpdate. **** UNTESTED ****

This commit is contained in:
UbitUmarov
2012-03-10 20:32:19 +00:00
parent 0e5e324a2c
commit 908abb1c3d
10 changed files with 543 additions and 139 deletions

View File

@@ -47,6 +47,57 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void ChangedBackupDelegate(SceneObjectGroup sog);
public enum ObjectChangeWhat : uint
{
// bits definitions
Position = 0x01,
Rotation = 0x02,
Scale = 0x04,
Group = 0x08,
UniformScale = 0x10,
// macros from above
// single prim
primP = 0x01,
primR = 0x02,
primPR = 0x03,
primS = 0x04,
primPS = 0x05,
primRS = 0x06,
primPSR = 0x07,
primUS = 0x14,
primPUS = 0x15,
primRUS = 0x16,
primPUSR = 0x17,
// group
groupP = 0x09,
groupR = 0x0A,
groupPR = 0x0B,
groupS = 0x0C,
groupPS = 0x0D,
groupRS = 0x0E,
groupPSR = 0x0F,
groupUS = 0x1C,
groupPUS = 0x1D,
groupRUS = 0x1E,
groupPUSR = 0x1F,
PRSmask = 0x07
}
public struct ObjectChangeData
{
public Quaternion rotation;
public Vector3 position;
public Vector3 scale;
public ObjectChangeWhat what;
}
/// <summary>
/// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components
/// should be migrated out over time.
@@ -1289,6 +1340,87 @@ namespace OpenSim.Region.Framework.Scenes
#region Client Event handlers
protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient)
{
SceneObjectPart part = GetSceneObjectPart(localID);
ObjectChangeData data = (ObjectChangeData)odata;
if (part != null)
{
SceneObjectGroup grp = part.ParentGroup;
if (grp != null)
{
if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId))
{
// part.StoreUndoState(data.what | ObjectChangeWhat.PRSmask); // for now save all to keep previus behavour ???
part.StoreUndoState(data.what); // lets test only saving what we changed
grp.doChangeObject(part, (ObjectChangeData)data);
}
}
}
}
/* moved to SOG
protected internal void doChangeObject(SceneObjectPart part, ObjectChangeData data)
{
if (part != null && part.ParentGroup != null)
{
ObjectChangeWhat what = data.what;
bool togroup = ((what & ObjectChangeWhat.Group) != 0);
// bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use
SceneObjectGroup group = part.ParentGroup;
PhysicsActor pha = group.RootPart.PhysActor;
if (togroup)
{
// related to group
if ((what & ObjectChangeWhat.Position) != 0)
group.AbsolutePosition = data.position;
if ((what & ObjectChangeWhat.Rotation) != 0)
group.RootPart.UpdateRotation(data.rotation);
if ((what & ObjectChangeWhat.Scale) != 0)
{
if (pha != null)
pha.Building = true;
group.GroupResize(data.scale);
if (pha != null)
pha.Building = false;
}
}
else
{
// related to single prim in a link-set ( ie group)
if (pha != null)
pha.Building = true;
// must deal with root part specially for position and rotation
// so parts offset positions or rotations are fixed
if (part == group.RootPart)
{
if ((what & ObjectChangeWhat.Position) != 0)
group.UpdateRootPosition(data.position);
if ((what & ObjectChangeWhat.Rotation) != 0)
group.UpdateRootRotation(data.rotation);
}
else
{
if ((what & ObjectChangeWhat.Position) != 0)
part.OffsetPosition = data.position;
if ((what & ObjectChangeWhat.Rotation) != 0)
part.UpdateRotation(data.rotation);
}
if ((what & ObjectChangeWhat.Scale) != 0)
part.Resize(data.scale);
if (pha != null)
pha.Building = false;
}
}
}
*/
/// <summary>
/// Update the scale of an individual prim.
/// </summary>
@@ -1303,7 +1435,17 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId))
{
bool physbuild = false;
if (part.ParentGroup.RootPart.PhysActor != null)
{
part.ParentGroup.RootPart.PhysActor.Building = true;
physbuild = true;
}
part.Resize(scale);
if (physbuild)
part.ParentGroup.RootPart.PhysActor.Building = false;
}
}
}
@@ -1315,7 +1457,17 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId))
{
bool physbuild = false;
if (group.RootPart.PhysActor != null)
{
group.RootPart.PhysActor.Building = true;
physbuild = true;
}
group.GroupResize(scale);
if (physbuild)
group.RootPart.PhysActor.Building = false;
}
}
}