aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
authorUbitUmarov2012-03-10 20:32:19 +0000
committerUbitUmarov2012-03-10 20:32:19 +0000
commit908abb1c3dded307e769abac71f660b835875975 (patch)
tree755d4e532a94346fe1960e3870f07767fbcfdd4a /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
parentubitOde bug (diff)
downloadopensim-SC_OLD-908abb1c3dded307e769abac71f660b835875975.zip
opensim-SC_OLD-908abb1c3dded307e769abac71f660b835875975.tar.gz
opensim-SC_OLD-908abb1c3dded307e769abac71f660b835875975.tar.bz2
opensim-SC_OLD-908abb1c3dded307e769abac71f660b835875975.tar.xz
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 ****
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs204
1 files changed, 83 insertions, 121 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5818798..92f2d54 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3124,10 +3124,6 @@ namespace OpenSim.Region.Framework.Scenes
3124 /// <param name="scale"></param> 3124 /// <param name="scale"></param>
3125 public void GroupResize(Vector3 scale) 3125 public void GroupResize(Vector3 scale)
3126 { 3126 {
3127// m_log.DebugFormat(
3128// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
3129// RootPart.StoreUndoState(true);
3130
3131 scale.X = Math.Min(scale.X, Scene.m_maxNonphys); 3127 scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
3132 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); 3128 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
3133 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); 3129 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
@@ -3152,7 +3148,6 @@ namespace OpenSim.Region.Framework.Scenes
3152 SceneObjectPart obPart = parts[i]; 3148 SceneObjectPart obPart = parts[i];
3153 if (obPart.UUID != m_rootPart.UUID) 3149 if (obPart.UUID != m_rootPart.UUID)
3154 { 3150 {
3155// obPart.IgnoreUndoUpdate = true;
3156 Vector3 oldSize = new Vector3(obPart.Scale); 3151 Vector3 oldSize = new Vector3(obPart.Scale);
3157 3152
3158 float f = 1.0f; 3153 float f = 1.0f;
@@ -3216,8 +3211,6 @@ namespace OpenSim.Region.Framework.Scenes
3216 z *= a; 3211 z *= a;
3217 } 3212 }
3218 } 3213 }
3219
3220// obPart.IgnoreUndoUpdate = false;
3221 } 3214 }
3222 } 3215 }
3223 } 3216 }
@@ -3226,9 +3219,8 @@ namespace OpenSim.Region.Framework.Scenes
3226 prevScale.X *= x; 3219 prevScale.X *= x;
3227 prevScale.Y *= y; 3220 prevScale.Y *= y;
3228 prevScale.Z *= z; 3221 prevScale.Z *= z;
3229// RootPart.IgnoreUndoUpdate = true; 3222
3230 RootPart.Resize(prevScale); 3223 RootPart.Resize(prevScale);
3231// RootPart.IgnoreUndoUpdate = false;
3232 3224
3233 parts = m_parts.GetArray(); 3225 parts = m_parts.GetArray();
3234 for (int i = 0; i < parts.Length; i++) 3226 for (int i = 0; i < parts.Length; i++)
@@ -3237,8 +3229,6 @@ namespace OpenSim.Region.Framework.Scenes
3237 3229
3238 if (obPart.UUID != m_rootPart.UUID) 3230 if (obPart.UUID != m_rootPart.UUID)
3239 { 3231 {
3240// obPart.IgnoreUndoUpdate = true;
3241
3242 Vector3 currentpos = new Vector3(obPart.OffsetPosition); 3232 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
3243 currentpos.X *= x; 3233 currentpos.X *= x;
3244 currentpos.Y *= y; 3234 currentpos.Y *= y;
@@ -3251,18 +3241,12 @@ namespace OpenSim.Region.Framework.Scenes
3251 3241
3252 obPart.Resize(newSize); 3242 obPart.Resize(newSize);
3253 obPart.UpdateOffSet(currentpos); 3243 obPart.UpdateOffSet(currentpos);
3254
3255// obPart.IgnoreUndoUpdate = false;
3256 } 3244 }
3257 3245
3258// obPart.IgnoreUndoUpdate = false;
3259 HasGroupChanged = true; 3246 HasGroupChanged = true;
3260 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); 3247 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE);
3261 ScheduleGroupForTerseUpdate(); 3248 ScheduleGroupForTerseUpdate();
3262 } 3249 }
3263
3264// m_log.DebugFormat(
3265// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale);
3266 } 3250 }
3267 3251
3268 #endregion 3252 #endregion
@@ -3275,14 +3259,6 @@ namespace OpenSim.Region.Framework.Scenes
3275 /// <param name="pos"></param> 3259 /// <param name="pos"></param>
3276 public void UpdateGroupPosition(Vector3 pos) 3260 public void UpdateGroupPosition(Vector3 pos)
3277 { 3261 {
3278// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
3279
3280// RootPart.StoreUndoState(true);
3281
3282// SceneObjectPart[] parts = m_parts.GetArray();
3283// for (int i = 0; i < parts.Length; i++)
3284// parts[i].StoreUndoState();
3285
3286 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 3262 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
3287 { 3263 {
3288 if (IsAttachment) 3264 if (IsAttachment)
@@ -3314,22 +3290,14 @@ namespace OpenSim.Region.Framework.Scenes
3314 /// </summary> 3290 /// </summary>
3315 /// <param name="pos"></param> 3291 /// <param name="pos"></param>
3316 /// <param name="localID"></param> 3292 /// <param name="localID"></param>
3293 ///
3294
3317 public void UpdateSinglePosition(Vector3 pos, uint localID) 3295 public void UpdateSinglePosition(Vector3 pos, uint localID)
3318 { 3296 {
3319 SceneObjectPart part = GetChildPart(localID); 3297 SceneObjectPart part = GetChildPart(localID);
3320 3298
3321// SceneObjectPart[] parts = m_parts.GetArray();
3322// for (int i = 0; i < parts.Length; i++)
3323// parts[i].StoreUndoState();
3324
3325 if (part != null) 3299 if (part != null)
3326 { 3300 {
3327// m_log.DebugFormat(
3328// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
3329
3330// part.StoreUndoState(false);
3331// part.IgnoreUndoUpdate = true;
3332
3333// unlock parts position change 3301// unlock parts position change
3334 if (m_rootPart.PhysActor != null) 3302 if (m_rootPart.PhysActor != null)
3335 m_rootPart.PhysActor.Building = true; 3303 m_rootPart.PhysActor.Building = true;
@@ -3347,7 +3315,6 @@ namespace OpenSim.Region.Framework.Scenes
3347 m_rootPart.PhysActor.Building = false; 3315 m_rootPart.PhysActor.Building = false;
3348 3316
3349 HasGroupChanged = true; 3317 HasGroupChanged = true;
3350// part.IgnoreUndoUpdate = false;
3351 } 3318 }
3352 } 3319 }
3353 3320
@@ -3357,13 +3324,7 @@ namespace OpenSim.Region.Framework.Scenes
3357 /// <param name="pos"></param> 3324 /// <param name="pos"></param>
3358 public void UpdateRootPosition(Vector3 pos) 3325 public void UpdateRootPosition(Vector3 pos)
3359 { 3326 {
3360// m_log.DebugFormat( 3327 // needs to be called with phys building true
3361// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
3362
3363// SceneObjectPart[] parts = m_parts.GetArray();
3364// for (int i = 0; i < parts.Length; i++)
3365// parts[i].StoreUndoState();
3366
3367 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 3328 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
3368 Vector3 oldPos = 3329 Vector3 oldPos =
3369 new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, 3330 new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X,
@@ -3383,17 +3344,7 @@ namespace OpenSim.Region.Framework.Scenes
3383 obPart.OffsetPosition = obPart.OffsetPosition + diff; 3344 obPart.OffsetPosition = obPart.OffsetPosition + diff;
3384 } 3345 }
3385 3346
3386 //We have to set undoing here because otherwise an undo state will be saved 3347 AbsolutePosition = newPos;
3387// if (!m_rootPart.Undoing)
3388// {
3389// m_rootPart.Undoing = true;
3390 AbsolutePosition = newPos;
3391// m_rootPart.Undoing = false;
3392// }
3393// else
3394// {
3395// AbsolutePosition = newPos;
3396// }
3397 3348
3398 HasGroupChanged = true; 3349 HasGroupChanged = true;
3399 if (m_rootPart.Undoing) 3350 if (m_rootPart.Undoing)
@@ -3416,17 +3367,6 @@ namespace OpenSim.Region.Framework.Scenes
3416 /// <param name="rot"></param> 3367 /// <param name="rot"></param>
3417 public void UpdateGroupRotationR(Quaternion rot) 3368 public void UpdateGroupRotationR(Quaternion rot)
3418 { 3369 {
3419// m_log.DebugFormat(
3420// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
3421
3422// SceneObjectPart[] parts = m_parts.GetArray();
3423// for (int i = 0; i < parts.Length; i++)
3424// parts[i].StoreUndoState();
3425
3426// m_rootPart.StoreUndoState(true);
3427
3428// m_rootPart.UpdateRotation(rot);
3429
3430 PhysicsActor actor = m_rootPart.PhysActor; 3370 PhysicsActor actor = m_rootPart.PhysActor;
3431 if (actor != null) 3371 if (actor != null)
3432 { 3372 {
@@ -3445,16 +3385,6 @@ namespace OpenSim.Region.Framework.Scenes
3445 /// <param name="rot"></param> 3385 /// <param name="rot"></param>
3446 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) 3386 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
3447 { 3387 {
3448// m_log.DebugFormat(
3449// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
3450
3451// SceneObjectPart[] parts = m_parts.GetArray();
3452// for (int i = 0; i < parts.Length; i++)
3453// parts[i].StoreUndoState();
3454
3455// RootPart.StoreUndoState(true);
3456// RootPart.IgnoreUndoUpdate = true;
3457
3458 m_rootPart.UpdateRotation(rot); 3388 m_rootPart.UpdateRotation(rot);
3459 3389
3460 PhysicsActor actor = m_rootPart.PhysActor; 3390 PhysicsActor actor = m_rootPart.PhysActor;
@@ -3468,8 +3398,6 @@ namespace OpenSim.Region.Framework.Scenes
3468 3398
3469 HasGroupChanged = true; 3399 HasGroupChanged = true;
3470 ScheduleGroupForTerseUpdate(); 3400 ScheduleGroupForTerseUpdate();
3471
3472// RootPart.IgnoreUndoUpdate = false;
3473 } 3401 }
3474 3402
3475 /// <summary> 3403 /// <summary>
@@ -3484,9 +3412,6 @@ namespace OpenSim.Region.Framework.Scenes
3484 3412
3485 if (part != null) 3413 if (part != null)
3486 { 3414 {
3487// m_log.DebugFormat(
3488// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot);
3489
3490 if (m_rootPart.PhysActor != null) 3415 if (m_rootPart.PhysActor != null)
3491 m_rootPart.PhysActor.Building = true; 3416 m_rootPart.PhysActor.Building = true;
3492 3417
@@ -3514,30 +3439,13 @@ namespace OpenSim.Region.Framework.Scenes
3514 SceneObjectPart part = GetChildPart(localID); 3439 SceneObjectPart part = GetChildPart(localID);
3515 if (part != null) 3440 if (part != null)
3516 { 3441 {
3517// m_log.DebugFormat(
3518// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}",
3519// part.Name, part.LocalId, rot);
3520
3521// part.StoreUndoState();
3522// part.IgnoreUndoUpdate = true;
3523
3524 if (m_rootPart.PhysActor != null) 3442 if (m_rootPart.PhysActor != null)
3525 m_rootPart.PhysActor.Building = true; 3443 m_rootPart.PhysActor.Building = true;
3526 3444
3527 if (part.UUID == m_rootPart.UUID) 3445 if (part.UUID == m_rootPart.UUID)
3528 { 3446 {
3529 UpdateRootRotation(rot); 3447 UpdateRootRotation(rot);
3530/* if (!m_rootPart.Undoing) 3448 AbsolutePosition = pos;
3531 {
3532 m_rootPart.Undoing = true;
3533 AbsolutePosition = pos;
3534 m_rootPart.Undoing = false;
3535 }
3536 else
3537 {
3538 */
3539 AbsolutePosition = pos;
3540// }
3541 } 3449 }
3542 else 3450 else
3543 { 3451 {
@@ -3547,8 +3455,6 @@ namespace OpenSim.Region.Framework.Scenes
3547 3455
3548 if (m_rootPart.PhysActor != null) 3456 if (m_rootPart.PhysActor != null)
3549 m_rootPart.PhysActor.Building = false; 3457 m_rootPart.PhysActor.Building = false;
3550
3551// part.IgnoreUndoUpdate = false;
3552 } 3458 }
3553 } 3459 }
3554 3460
@@ -3558,13 +3464,9 @@ namespace OpenSim.Region.Framework.Scenes
3558 /// <param name="rot"></param> 3464 /// <param name="rot"></param>
3559 public void UpdateRootRotation(Quaternion rot) 3465 public void UpdateRootRotation(Quaternion rot)
3560 { 3466 {
3561// m_log.DebugFormat( 3467 // needs to be called with phys building true
3562// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
3563// Name, LocalId, rot);
3564
3565 Quaternion axRot = rot; 3468 Quaternion axRot = rot;
3566 Quaternion oldParentRot = m_rootPart.RotationOffset; 3469 Quaternion oldParentRot = m_rootPart.RotationOffset;
3567// m_rootPart.StoreUndoState();
3568 3470
3569 //Don't use UpdateRotation because it schedules an update prematurely 3471 //Don't use UpdateRotation because it schedules an update prematurely
3570 m_rootPart.RotationOffset = rot; 3472 m_rootPart.RotationOffset = rot;
@@ -3580,8 +3482,6 @@ namespace OpenSim.Region.Framework.Scenes
3580 SceneObjectPart prim = parts[i]; 3482 SceneObjectPart prim = parts[i];
3581 if (prim.UUID != m_rootPart.UUID) 3483 if (prim.UUID != m_rootPart.UUID)
3582 { 3484 {
3583// prim.IgnoreUndoUpdate = true;
3584
3585 Quaternion NewRot = oldParentRot * prim.RotationOffset; 3485 Quaternion NewRot = oldParentRot * prim.RotationOffset;
3586 NewRot = Quaternion.Inverse(axRot) * NewRot; 3486 NewRot = Quaternion.Inverse(axRot) * NewRot;
3587 prim.RotationOffset = NewRot; 3487 prim.RotationOffset = NewRot;
@@ -3591,26 +3491,88 @@ namespace OpenSim.Region.Framework.Scenes
3591 axPos *= oldParentRot; 3491 axPos *= oldParentRot;
3592 axPos *= Quaternion.Inverse(axRot); 3492 axPos *= Quaternion.Inverse(axRot);
3593 prim.OffsetPosition = axPos; 3493 prim.OffsetPosition = axPos;
3594
3595// prim.IgnoreUndoUpdate = false;
3596 } 3494 }
3597 } 3495 }
3598 3496
3599// for (int i = 0; i < parts.Length; i++)
3600// {
3601// SceneObjectPart childpart = parts[i];
3602// if (childpart != m_rootPart)
3603// {
3604//// childpart.IgnoreUndoUpdate = false;
3605//// childpart.StoreUndoState();
3606// }
3607// }
3608 HasGroupChanged = true; 3497 HasGroupChanged = true;
3609 ScheduleGroupForFullUpdate(); 3498 ScheduleGroupForFullUpdate();
3499 }
3610 3500
3611// m_log.DebugFormat( 3501 public void doChangeObject(SceneObjectPart part, ObjectChangeData data)
3612// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", 3502 {
3613// Name, LocalId, rot); 3503 // TODO this still as excessive ScheduleGroupForTerseUpdate()s
3504
3505 if (part != null && part.ParentGroup != null)
3506 {
3507 ObjectChangeWhat what = data.what;
3508 bool togroup = ((what & ObjectChangeWhat.Group) != 0);
3509 // bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use
3510
3511 SceneObjectGroup group = part.ParentGroup;
3512 PhysicsActor pha = group.RootPart.PhysActor;
3513
3514 bool needgrpUpdate = false;
3515
3516 if (togroup)
3517 {
3518 // related to group
3519 if ((what & ObjectChangeWhat.Position) != 0)
3520 {
3521 group.AbsolutePosition = data.position;
3522 needgrpUpdate = true;
3523 }
3524 if ((what & ObjectChangeWhat.Rotation) != 0)
3525 group.RootPart.UpdateRotation(data.rotation);
3526 if ((what & ObjectChangeWhat.Scale) != 0)
3527 {
3528 if (pha != null)
3529 pha.Building = true;
3530 group.GroupResize(data.scale);
3531 if (pha != null)
3532 pha.Building = false;
3533 }
3534 }
3535 else
3536 {
3537 // related to single prim in a link-set ( ie group)
3538 if (pha != null)
3539 pha.Building = true;
3540
3541 // must deal with root part specially for position and rotation
3542 // so parts offset positions or rotations are fixed
3543
3544 if (part == group.RootPart)
3545 {
3546 if ((what & ObjectChangeWhat.Position) != 0)
3547 group.UpdateRootPosition(data.position);
3548 if ((what & ObjectChangeWhat.Rotation) != 0)
3549 group.UpdateRootRotation(data.rotation);
3550 }
3551 else
3552 {
3553
3554 if ((what & ObjectChangeWhat.Position) != 0)
3555 {
3556 part.OffsetPosition = data.position;
3557 needgrpUpdate = true;
3558 }
3559 if ((what & ObjectChangeWhat.Rotation) != 0)
3560 part.UpdateRotation(data.rotation);
3561 }
3562
3563 if ((what & ObjectChangeWhat.Scale) != 0)
3564 part.Resize(data.scale);
3565
3566 if (pha != null)
3567 pha.Building = false;
3568 }
3569
3570 if (needgrpUpdate)
3571 {
3572 HasGroupChanged = true;
3573 ScheduleGroupForTerseUpdate();
3574 }
3575 }
3614 } 3576 }
3615 3577
3616 #endregion 3578 #endregion