aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTom2011-09-04 07:38:25 -0700
committerTom2011-09-04 07:38:25 -0700
commit9ab951a954ff85371dc3dd92563d7c8cdefb7c20 (patch)
treec7e533bee1f871cdf391919c817779e942fe758c
parentResolve merge commits, stage 1 (diff)
downloadopensim-SC_OLD-9ab951a954ff85371dc3dd92563d7c8cdefb7c20.zip
opensim-SC_OLD-9ab951a954ff85371dc3dd92563d7c8cdefb7c20.tar.gz
opensim-SC_OLD-9ab951a954ff85371dc3dd92563d7c8cdefb7c20.tar.bz2
opensim-SC_OLD-9ab951a954ff85371dc3dd92563d7c8cdefb7c20.tar.xz
I fucked up the merge for SOG, so reverting back to OpenSim Core's version...
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs1260
1 files changed, 255 insertions, 1005 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index b1b76dd..5762717 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -24,12 +24,11 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.IO; 31using System.IO;
32using System.Diagnostics;
33using System.Linq; 32using System.Linq;
34using System.Threading; 33using System.Threading;
35using System.Xml; 34using System.Xml;
@@ -106,29 +105,8 @@ namespace OpenSim.Region.Framework.Scenes
106 /// since the group's last persistent backup 105 /// since the group's last persistent backup
107 /// </summary> 106 /// </summary>
108 private bool m_hasGroupChanged = false; 107 private bool m_hasGroupChanged = false;
109 private long timeFirstChanged = 0; 108 private long timeFirstChanged;
110 private long timeLastChanged = 0; 109 private long timeLastChanged;
111 private long m_maxPersistTime = 0;
112 private long m_minPersistTime = 0;
113 private Random m_rand;
114 private bool m_suspendUpdates;
115 private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>();
116
117 public bool areUpdatesSuspended
118 {
119 get
120 {
121 return m_suspendUpdates;
122 }
123 set
124 {
125 m_suspendUpdates = value;
126 if (!value)
127 {
128 QueueForUpdateCheck();
129 }
130 }
131 }
132 110
133 public bool HasGroupChanged 111 public bool HasGroupChanged
134 { 112 {
@@ -136,54 +114,24 @@ namespace OpenSim.Region.Framework.Scenes
136 { 114 {
137 if (value) 115 if (value)
138 { 116 {
139 if (m_isBackedUp)
140 {
141 m_scene.SceneGraph.FireChangeBackup(this);
142 }
143 timeLastChanged = DateTime.Now.Ticks; 117 timeLastChanged = DateTime.Now.Ticks;
144 if (!m_hasGroupChanged) 118 if (!m_hasGroupChanged)
145 timeFirstChanged = DateTime.Now.Ticks; 119 timeFirstChanged = DateTime.Now.Ticks;
146 if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null)
147 {
148 if (m_rand == null)
149 {
150 byte[] val = new byte[16];
151 m_rootPart.UUID.ToBytes(val, 0);
152 m_rand = new Random(BitConverter.ToInt32(val, 0));
153 }
154
155 if (m_scene.GetRootAgentCount() == 0)
156 {
157 //If the region is empty, this change has been made by an automated process
158 //and thus we delay the persist time by a random amount between 1.5 and 2.5.
159
160 float factor = 1.5f + (float)(m_rand.NextDouble());
161 m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor);
162 m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor);
163 }
164 else
165 {
166 //If the region is not empty, we want to obey the minimum and maximum persist times
167 //but add a random factor so we stagger the object persistance a little
168 m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5
169 m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0
170 }
171 }
172 } 120 }
173 m_hasGroupChanged = value; 121 m_hasGroupChanged = value;
174 122
175// m_log.DebugFormat( 123 // m_log.DebugFormat(
176// "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId); 124 // "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId);
177 } 125 }
178 126
179 get { return m_hasGroupChanged; } 127 get { return m_hasGroupChanged; }
180 } 128 }
181 129
182 /// <summary> 130 /// <summary>
183 /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since 131 /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since
184 /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. 132 /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation.
185 /// </summary> 133 /// </summary>
186 public bool HasGroupChangedDueToDelink { get; set; } 134 public bool HasGroupChangedDueToDelink { get; private set; }
187 135
188 private bool isTimeToPersist() 136 private bool isTimeToPersist()
189 { 137 {
@@ -193,19 +141,8 @@ namespace OpenSim.Region.Framework.Scenes
193 return false; 141 return false;
194 if (m_scene.ShuttingDown) 142 if (m_scene.ShuttingDown)
195 return true; 143 return true;
196
197 if (m_minPersistTime == 0 || m_maxPersistTime == 0)
198 {
199 m_maxPersistTime = m_scene.m_persistAfter;
200 m_minPersistTime = m_scene.m_dontPersistBefore;
201 }
202
203 long currentTime = DateTime.Now.Ticks; 144 long currentTime = DateTime.Now.Ticks;
204 145 if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter)
205 if (timeLastChanged == 0) timeLastChanged = currentTime;
206 if (timeFirstChanged == 0) timeFirstChanged = currentTime;
207
208 if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime)
209 return true; 146 return true;
210 return false; 147 return false;
211 } 148 }
@@ -310,10 +247,10 @@ namespace OpenSim.Region.Framework.Scenes
310 247
311 private bool m_scriptListens_atTarget; 248 private bool m_scriptListens_atTarget;
312 private bool m_scriptListens_notAtTarget; 249 private bool m_scriptListens_notAtTarget;
250
313 private bool m_scriptListens_atRotTarget; 251 private bool m_scriptListens_atRotTarget;
314 private bool m_scriptListens_notAtRotTarget; 252 private bool m_scriptListens_notAtRotTarget;
315 253
316 public bool m_dupeInProgress = false;
317 internal Dictionary<UUID, string> m_savedScriptState; 254 internal Dictionary<UUID, string> m_savedScriptState;
318 255
319 #region Properties 256 #region Properties
@@ -349,13 +286,7 @@ namespace OpenSim.Region.Framework.Scenes
349 public virtual Quaternion Rotation 286 public virtual Quaternion Rotation
350 { 287 {
351 get { return m_rotation; } 288 get { return m_rotation; }
352 set { 289 set { m_rotation = value; }
353 foreach(SceneObjectPart p in m_parts.GetArray())
354 {
355 p.StoreUndoState(UndoType.STATE_GROUP_ROTATION);
356 }
357 m_rotation = value;
358 }
359 } 290 }
360 291
361 public Quaternion GroupRotation 292 public Quaternion GroupRotation
@@ -370,27 +301,27 @@ namespace OpenSim.Region.Framework.Scenes
370 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); 301 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
371 Vector3 maxScale = Vector3.Zero; 302 Vector3 maxScale = Vector3.Zero;
372 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); 303 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
373 304
374 SceneObjectPart[] parts = m_parts.GetArray(); 305 SceneObjectPart[] parts = m_parts.GetArray();
375 for (int i = 0; i < parts.Length; i++) 306 for (int i = 0; i < parts.Length; i++)
376 { 307 {
377 SceneObjectPart part = parts[i]; 308 SceneObjectPart part = parts[i];
378 Vector3 partscale = part.Scale; 309 Vector3 partscale = part.Scale;
379 Vector3 partoffset = part.OffsetPosition; 310 Vector3 partoffset = part.OffsetPosition;
380 311
381 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X; 312 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
382 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y; 313 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
383 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z; 314 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
384 315
385 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; 316 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
386 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; 317 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
387 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; 318 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
388 } 319 }
389 320
390 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; 321 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
391 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; 322 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
392 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; 323 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
393 324
394 return finalScale; 325 return finalScale;
395 } 326 }
396 } 327 }
@@ -446,7 +377,7 @@ namespace OpenSim.Region.Framework.Scenes
446 { 377 {
447 return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); 378 return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0));
448 } 379 }
449 380
450 /// <summary> 381 /// <summary>
451 /// The absolute position of this scene object in the scene 382 /// The absolute position of this scene object in the scene
452 /// </summary> 383 /// </summary>
@@ -460,55 +391,30 @@ namespace OpenSim.Region.Framework.Scenes
460 if (Scene != null) 391 if (Scene != null)
461 { 392 {
462 if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 393 if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
463 || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 394 || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
464 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 395 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
465 { 396 {
466 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 397 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
467 } 398 }
468 } 399 }
469 400
470 foreach (SceneObjectPart part in m_parts.GetArray())
471 {
472 part.IgnoreUndoUpdate = true;
473 }
474 if (RootPart.GetStatusSandbox()) 401 if (RootPart.GetStatusSandbox())
475 { 402 {
476 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) 403 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
477 { 404 {
478 RootPart.ScriptSetPhysicsStatus(false); 405 RootPart.ScriptSetPhysicsStatus(false);
479 406
480 if (Scene != null) 407 if (Scene != null)
481 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), 408 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
482 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); 409 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
483 410
484 return; 411 return;
485 } 412 }
486 } 413 }
414
487 SceneObjectPart[] parts = m_parts.GetArray(); 415 SceneObjectPart[] parts = m_parts.GetArray();
488 foreach (SceneObjectPart part in parts) 416 for (int i = 0; i < parts.Length; i++)
489 { 417 parts[i].GroupPosition = val;
490 part.IgnoreUndoUpdate = false;
491 part.StoreUndoState(UndoType.STATE_GROUP_POSITION);
492 part.GroupPosition = val;
493 if (!m_dupeInProgress)
494 {
495 part.TriggerScriptChangedEvent(Changed.POSITION);
496 }
497 }
498 if (!m_dupeInProgress)
499 {
500 foreach (ScenePresence av in m_linkedAvatars)
501 {
502 SceneObjectPart p;
503 if (m_parts.TryGetValue(av.LinkedPrim, out p))
504 {
505 Vector3 offset = p.GetWorldPosition() - av.ParentPosition;
506 av.AbsolutePosition += offset;
507 av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition
508 av.SendAvatarDataToAllAgents();
509 }
510 }
511 }
512 418
513 //if (m_rootPart.PhysActor != null) 419 //if (m_rootPart.PhysActor != null)
514 //{ 420 //{
@@ -517,7 +423,7 @@ namespace OpenSim.Region.Framework.Scenes
517 //m_rootPart.GroupPosition.Z); 423 //m_rootPart.GroupPosition.Z);
518 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 424 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
519 //} 425 //}
520 426
521 if (Scene != null) 427 if (Scene != null)
522 Scene.EventManager.TriggerParcelPrimCountTainted(); 428 Scene.EventManager.TriggerParcelPrimCountTainted();
523 } 429 }
@@ -532,7 +438,7 @@ namespace OpenSim.Region.Framework.Scenes
532 public override UUID UUID 438 public override UUID UUID
533 { 439 {
534 get { return m_rootPart.UUID; } 440 get { return m_rootPart.UUID; }
535 set 441 set
536 { 442 {
537 lock (m_parts.SyncRoot) 443 lock (m_parts.SyncRoot)
538 { 444 {
@@ -563,9 +469,10 @@ namespace OpenSim.Region.Framework.Scenes
563 469
564 public string Text 470 public string Text
565 { 471 {
566 get { 472 get
473 {
567 string returnstr = m_rootPart.Text; 474 string returnstr = m_rootPart.Text;
568 if (returnstr.Length > 255) 475 if (returnstr.Length > 255)
569 { 476 {
570 returnstr = returnstr.Substring(0, 255); 477 returnstr = returnstr.Substring(0, 255);
571 } 478 }
@@ -578,7 +485,7 @@ namespace OpenSim.Region.Framework.Scenes
578 { 485 {
579 get { return true; } 486 get { return true; }
580 } 487 }
581 488
582 private bool m_passCollision; 489 private bool m_passCollision;
583 public bool PassCollision 490 public bool PassCollision
584 { 491 {
@@ -655,10 +562,10 @@ namespace OpenSim.Region.Framework.Scenes
655 562
656 #endregion 563 #endregion
657 564
658// ~SceneObjectGroup() 565 // ~SceneObjectGroup()
659// { 566 // {
660// m_log.DebugFormat("[SCENE OBJECT GROUP]: Destructor called for {0}, local id {1}", Name, LocalId); 567 // m_log.DebugFormat("[SCENE OBJECT GROUP]: Destructor called for {0}, local id {1}", Name, LocalId);
661// } 568 // }
662 569
663 #region Constructors 570 #region Constructors
664 571
@@ -667,7 +574,6 @@ namespace OpenSim.Region.Framework.Scenes
667 /// </summary> 574 /// </summary>
668 public SceneObjectGroup() 575 public SceneObjectGroup()
669 { 576 {
670
671 } 577 }
672 578
673 /// <summary> 579 /// <summary>
@@ -711,7 +617,7 @@ namespace OpenSim.Region.Framework.Scenes
711 if (itemid != UUID.Zero) 617 if (itemid != UUID.Zero)
712 m_savedScriptState[itemid] = node.InnerXml; 618 m_savedScriptState[itemid] = node.InnerXml;
713 } 619 }
714 } 620 }
715 } 621 }
716 } 622 }
717 623
@@ -732,9 +638,6 @@ namespace OpenSim.Region.Framework.Scenes
732 /// </summary> 638 /// </summary>
733 public virtual void AttachToBackup() 639 public virtual void AttachToBackup()
734 { 640 {
735 if (IsAttachment) return;
736 m_scene.SceneGraph.FireAttachToBackup(this);
737
738 if (InSceneBackup) 641 if (InSceneBackup)
739 { 642 {
740 //m_log.DebugFormat( 643 //m_log.DebugFormat(
@@ -742,11 +645,11 @@ namespace OpenSim.Region.Framework.Scenes
742 645
743 if (!m_isBackedUp) 646 if (!m_isBackedUp)
744 m_scene.EventManager.OnBackup += ProcessBackup; 647 m_scene.EventManager.OnBackup += ProcessBackup;
745 648
746 m_isBackedUp = true; 649 m_isBackedUp = true;
747 } 650 }
748 } 651 }
749 652
750 /// <summary> 653 /// <summary>
751 /// Attach this object to a scene. It will also now appear to agents. 654 /// Attach this object to a scene. It will also now appear to agents.
752 /// </summary> 655 /// </summary>
@@ -777,9 +680,6 @@ namespace OpenSim.Region.Framework.Scenes
777 680
778 ApplyPhysics(m_scene.m_physicalPrim); 681 ApplyPhysics(m_scene.m_physicalPrim);
779 682
780 if (RootPart.PhysActor != null)
781 RootPart.Buoyancy = RootPart.Buoyancy;
782
783 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled 683 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
784 // for the same object with very different properties. The caller must schedule the update. 684 // for the same object with very different properties. The caller must schedule the update.
785 //ScheduleGroupForFullUpdate(); 685 //ScheduleGroupForFullUpdate();
@@ -825,9 +725,9 @@ namespace OpenSim.Region.Framework.Scenes
825 result.normal = inter.normal; 725 result.normal = inter.normal;
826 result.distance = inter.distance; 726 result.distance = inter.distance;
827 } 727 }
828
829 } 728 }
830 } 729 }
730
831 return result; 731 return result;
832 } 732 }
833 733
@@ -847,19 +747,17 @@ namespace OpenSim.Region.Framework.Scenes
847 minZ = 8192f; 747 minZ = 8192f;
848 748
849 SceneObjectPart[] parts = m_parts.GetArray(); 749 SceneObjectPart[] parts = m_parts.GetArray();
850 foreach (SceneObjectPart part in parts) 750 for (int i = 0; i < parts.Length; i++)
851 { 751 {
752 SceneObjectPart part = parts[i];
753
852 Vector3 worldPos = part.GetWorldPosition(); 754 Vector3 worldPos = part.GetWorldPosition();
853 Vector3 offset = worldPos - AbsolutePosition; 755 Vector3 offset = worldPos - AbsolutePosition;
854 Quaternion worldRot; 756 Quaternion worldRot;
855 if (part.ParentID == 0) 757 if (part.ParentID == 0)
856 {
857 worldRot = part.RotationOffset; 758 worldRot = part.RotationOffset;
858 }
859 else 759 else
860 {
861 worldRot = part.GetWorldRotation(); 760 worldRot = part.GetWorldRotation();
862 }
863 761
864 Vector3 frontTopLeft; 762 Vector3 frontTopLeft;
865 Vector3 frontTopRight; 763 Vector3 frontTopRight;
@@ -871,8 +769,6 @@ namespace OpenSim.Region.Framework.Scenes
871 Vector3 backBottomLeft; 769 Vector3 backBottomLeft;
872 Vector3 backBottomRight; 770 Vector3 backBottomRight;
873 771
874 // Vector3[] corners = new Vector3[8];
875
876 Vector3 orig = Vector3.Zero; 772 Vector3 orig = Vector3.Zero;
877 773
878 frontTopLeft.X = orig.X - (part.Scale.X / 2); 774 frontTopLeft.X = orig.X - (part.Scale.X / 2);
@@ -907,38 +803,6 @@ namespace OpenSim.Region.Framework.Scenes
907 backBottomRight.Y = orig.Y + (part.Scale.Y / 2); 803 backBottomRight.Y = orig.Y + (part.Scale.Y / 2);
908 backBottomRight.Z = orig.Z - (part.Scale.Z / 2); 804 backBottomRight.Z = orig.Z - (part.Scale.Z / 2);
909 805
910
911
912 //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z);
913 //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z);
914 //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z);
915 //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z);
916 //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z);
917 //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z);
918 //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z);
919 //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z);
920
921 //for (int i = 0; i < 8; i++)
922 //{
923 // corners[i] = corners[i] * worldRot;
924 // corners[i] += offset;
925
926 // if (corners[i].X > maxX)
927 // maxX = corners[i].X;
928 // if (corners[i].X < minX)
929 // minX = corners[i].X;
930
931 // if (corners[i].Y > maxY)
932 // maxY = corners[i].Y;
933 // if (corners[i].Y < minY)
934 // minY = corners[i].Y;
935
936 // if (corners[i].Z > maxZ)
937 // maxZ = corners[i].Y;
938 // if (corners[i].Z < minZ)
939 // minZ = corners[i].Z;
940 //}
941
942 frontTopLeft = frontTopLeft * worldRot; 806 frontTopLeft = frontTopLeft * worldRot;
943 frontTopRight = frontTopRight * worldRot; 807 frontTopRight = frontTopRight * worldRot;
944 frontBottomLeft = frontBottomLeft * worldRot; 808 frontBottomLeft = frontBottomLeft * worldRot;
@@ -960,15 +824,6 @@ namespace OpenSim.Region.Framework.Scenes
960 backTopLeft += offset; 824 backTopLeft += offset;
961 backTopRight += offset; 825 backTopRight += offset;
962 826
963 //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z);
964 //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z);
965 //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z);
966 //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z);
967 //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z);
968 //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z);
969 //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z);
970 //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z);
971
972 if (frontTopRight.X > maxX) 827 if (frontTopRight.X > maxX)
973 maxX = frontTopRight.X; 828 maxX = frontTopRight.X;
974 if (frontTopLeft.X > maxX) 829 if (frontTopLeft.X > maxX)
@@ -1106,7 +961,7 @@ namespace OpenSim.Region.Framework.Scenes
1106 offsetHeight *= -1; 961 offsetHeight *= -1;
1107 } 962 }
1108 963
1109 // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); 964 // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z);
1110 return boundingBox; 965 return boundingBox;
1111 } 966 }
1112 967
@@ -1114,20 +969,15 @@ namespace OpenSim.Region.Framework.Scenes
1114 969
1115 public void SaveScriptedState(XmlTextWriter writer) 970 public void SaveScriptedState(XmlTextWriter writer)
1116 { 971 {
1117 SaveScriptedState(writer, false);
1118 }
1119
1120 public void SaveScriptedState(XmlTextWriter writer, bool oldIDs)
1121 {
1122 XmlDocument doc = new XmlDocument(); 972 XmlDocument doc = new XmlDocument();
1123 Dictionary<UUID,string> states = new Dictionary<UUID,string>(); 973 Dictionary<UUID, string> states = new Dictionary<UUID, string>();
1124 974
1125 SceneObjectPart[] parts = m_parts.GetArray(); 975 SceneObjectPart[] parts = m_parts.GetArray();
1126 for (int i = 0; i < parts.Length; i++) 976 for (int i = 0; i < parts.Length; i++)
1127 { 977 {
1128 Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); 978 Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates();
1129 foreach (KeyValuePair<UUID, string> kvp in pstates) 979 foreach (KeyValuePair<UUID, string> kvp in pstates)
1130 states[kvp.Key] = kvp.Value; 980 states.Add(kvp.Key, kvp.Value);
1131 } 981 }
1132 982
1133 if (states.Count > 0) 983 if (states.Count > 0)
@@ -1146,190 +996,6 @@ namespace OpenSim.Region.Framework.Scenes
1146 } 996 }
1147 } 997 }
1148 998
1149<<<<<<< HEAD
1150 /// <summary>
1151 /// Add the avatar to this linkset (avatar is sat).
1152 /// </summary>
1153 /// <param name="agentID"></param>
1154 public void AddAvatar(UUID agentID)
1155 {
1156 ScenePresence presence;
1157 if (m_scene.TryGetScenePresence(agentID, out presence))
1158 {
1159 if (!m_linkedAvatars.Contains(presence))
1160 {
1161 m_linkedAvatars.Add(presence);
1162 }
1163 }
1164 }
1165
1166 /// <summary>
1167 /// Delete the avatar from this linkset (avatar is unsat).
1168 /// </summary>
1169 /// <param name="agentID"></param>
1170 public void DeleteAvatar(UUID agentID)
1171 {
1172 ScenePresence presence;
1173 if (m_scene.TryGetScenePresence(agentID, out presence))
1174 {
1175 if (m_linkedAvatars.Contains(presence))
1176 {
1177 m_linkedAvatars.Remove(presence);
1178 }
1179 }
1180 }
1181
1182 /// <summary>
1183 /// Returns the list of linked presences (avatars sat on this group)
1184 /// </summary>
1185 /// <param name="agentID"></param>
1186 public List<ScenePresence> GetLinkedAvatars()
1187 {
1188 return m_linkedAvatars;
1189 }
1190
1191 /// <summary>
1192 /// Attach this scene object to the given avatar.
1193 /// </summary>
1194 /// <param name="agentID"></param>
1195 /// <param name="attachmentpoint"></param>
1196 /// <param name="AttachOffset"></param>
1197 public void AttachToAgent(UUID agentID, uint attachmentpoint, Vector3 AttachOffset, bool silent)
1198 {
1199 ScenePresence avatar = m_scene.GetScenePresence(agentID);
1200 if (avatar != null)
1201 {
1202 // don't attach attachments to child agents
1203 if (avatar.IsChildAgent) return;
1204
1205// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
1206
1207 DetachFromBackup();
1208
1209 // Remove from database and parcel prim count
1210 m_scene.DeleteFromStorage(UUID);
1211 m_scene.EventManager.TriggerParcelPrimCountTainted();
1212
1213 m_rootPart.AttachedAvatar = agentID;
1214
1215 //Anakin Lohner bug #3839
1216 lock (m_parts)
1217 {
1218 foreach (SceneObjectPart p in m_parts.GetArray())
1219 {
1220 p.AttachedAvatar = agentID;
1221 }
1222 }
1223
1224 if (m_rootPart.PhysActor != null)
1225 {
1226 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
1227 m_rootPart.PhysActor = null;
1228 }
1229
1230 AbsolutePosition = AttachOffset;
1231 m_rootPart.AttachedPos = AttachOffset;
1232 m_rootPart.IsAttachment = true;
1233
1234 m_rootPart.SetParentLocalId(avatar.LocalId);
1235 SetAttachmentPoint(Convert.ToByte(attachmentpoint));
1236
1237 avatar.AddAttachment(this);
1238
1239 if (!silent)
1240 {
1241 // Killing it here will cause the client to deselect it
1242 // It then reappears on the avatar, deselected
1243 // through the full update below
1244 //
1245 if (IsSelected)
1246 {
1247 m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId });
1248 }
1249
1250 IsSelected = false; // fudge....
1251 ScheduleGroupForFullUpdate();
1252 }
1253 }
1254 else
1255 {
1256 m_log.WarnFormat(
1257 "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
1258 UUID, agentID, Scene.RegionInfo.RegionName);
1259 }
1260 }
1261
1262 public byte GetAttachmentPoint()
1263 {
1264 return m_rootPart.Shape.State;
1265 }
1266
1267 public void ClearPartAttachmentData()
1268 {
1269 SetAttachmentPoint((Byte)0);
1270 }
1271
1272 public void DetachToGround()
1273 {
1274 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
1275 if (avatar == null)
1276 return;
1277
1278 avatar.RemoveAttachment(this);
1279
1280 Vector3 detachedpos = new Vector3(127f,127f,127f);
1281 if (avatar == null)
1282 return;
1283
1284 detachedpos = avatar.AbsolutePosition;
1285 RootPart.FromItemID = UUID.Zero;
1286
1287 AbsolutePosition = detachedpos;
1288 m_rootPart.AttachedAvatar = UUID.Zero;
1289
1290 SceneObjectPart[] parts = m_parts.GetArray();
1291 for (int i = 0; i < parts.Length; i++)
1292 parts[i].AttachedAvatar = UUID.Zero;
1293
1294 m_rootPart.SetParentLocalId(0);
1295 SetAttachmentPoint((byte)0);
1296 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
1297 HasGroupChanged = true;
1298 RootPart.Rezzed = DateTime.Now;
1299 RootPart.RemFlag(PrimFlags.TemporaryOnRez);
1300 AttachToBackup();
1301 m_scene.EventManager.TriggerParcelPrimCountTainted();
1302 m_rootPart.ScheduleFullUpdate();
1303 m_rootPart.ClearUndoState();
1304 }
1305
1306 public void DetachToInventoryPrep()
1307 {
1308 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
1309 //Vector3 detachedpos = new Vector3(127f, 127f, 127f);
1310 if (avatar != null)
1311 {
1312 //detachedpos = avatar.AbsolutePosition;
1313 avatar.RemoveAttachment(this);
1314 }
1315
1316 m_rootPart.AttachedAvatar = UUID.Zero;
1317
1318 SceneObjectPart[] parts = m_parts.GetArray();
1319 for (int i = 0; i < parts.Length; i++)
1320 parts[i].AttachedAvatar = UUID.Zero;
1321
1322 m_rootPart.SetParentLocalId(0);
1323 //m_rootPart.SetAttachmentPoint((byte)0);
1324 m_rootPart.IsAttachment = false;
1325 AbsolutePosition = m_rootPart.AttachedPos;
1326 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
1327 //AttachToBackup();
1328 //m_rootPart.ScheduleFullUpdate();
1329 }
1330
1331=======
1332>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1333 /// <summary> 999 /// <summary>
1334 /// 1000 ///
1335 /// </summary> 1001 /// </summary>
@@ -1361,7 +1027,7 @@ namespace OpenSim.Region.Framework.Scenes
1361 { 1027 {
1362 m_scene = scene; 1028 m_scene = scene;
1363 } 1029 }
1364 1030
1365 /// <summary> 1031 /// <summary>
1366 /// Set a part to act as the root part for this scene object 1032 /// Set a part to act as the root part for this scene object
1367 /// </summary> 1033 /// </summary>
@@ -1376,7 +1042,7 @@ namespace OpenSim.Region.Framework.Scenes
1376 if (!IsAttachment) 1042 if (!IsAttachment)
1377 part.ParentID = 0; 1043 part.ParentID = 0;
1378 part.LinkNum = 0; 1044 part.LinkNum = 0;
1379 1045
1380 m_parts.Add(m_rootPart.UUID, m_rootPart); 1046 m_parts.Add(m_rootPart.UUID, m_rootPart);
1381 } 1047 }
1382 1048
@@ -1387,16 +1053,8 @@ namespace OpenSim.Region.Framework.Scenes
1387 public void AddPart(SceneObjectPart part) 1053 public void AddPart(SceneObjectPart part)
1388 { 1054 {
1389 part.SetParent(this); 1055 part.SetParent(this);
1390<<<<<<< HEAD
1391 m_parts.Add(part.UUID, part);
1392
1393 part.LinkNum = m_parts.Count;
1394
1395 if (part.LinkNum == 2 && RootPart != null)
1396=======
1397 part.LinkNum = m_parts.Add(part.UUID, part); 1056 part.LinkNum = m_parts.Add(part.UUID, part);
1398 if (part.LinkNum == 2) 1057 if (part.LinkNum == 2)
1399>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1400 RootPart.LinkNum = 1; 1058 RootPart.LinkNum = 1;
1401 } 1059 }
1402 1060
@@ -1432,19 +1090,19 @@ namespace OpenSim.Region.Framework.Scenes
1432 // justincc: I don't believe this hack is needed any longer, especially since the physics 1090 // justincc: I don't believe this hack is needed any longer, especially since the physics
1433 // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false 1091 // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false
1434 // this method was preventing proper reload of scene objects. 1092 // this method was preventing proper reload of scene objects.
1435 1093
1436 // dahlia: I had to uncomment it, without it meshing was failing on some prims and objects 1094 // dahlia: I had to uncomment it, without it meshing was failing on some prims and objects
1437 // at region startup 1095 // at region startup
1438 1096
1439 // teravus: After this was removed from the linking algorithm, Linked prims no longer collided 1097 // teravus: After this was removed from the linking algorithm, Linked prims no longer collided
1440 // properly when non-physical if they havn't been moved. This breaks ALL builds. 1098 // properly when non-physical if they havn't been moved. This breaks ALL builds.
1441 // see: http://opensimulator.org/mantis/view.php?id=3108 1099 // see: http://opensimulator.org/mantis/view.php?id=3108
1442 1100
1443 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the 1101 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
1444 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and 1102 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and
1445 // unmoved prims! As soon as you move a Prim/group, it will collide properly because Absolute 1103 // unmoved prims! As soon as you move a Prim/group, it will collide properly because Absolute
1446 // Position has been set! 1104 // Position has been set!
1447 1105
1448 public void ResetChildPrimPhysicsPositions() 1106 public void ResetChildPrimPhysicsPositions()
1449 { 1107 {
1450 AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? 1108 AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works?
@@ -1479,15 +1137,11 @@ namespace OpenSim.Region.Framework.Scenes
1479 1137
1480 public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) 1138 public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient)
1481 { 1139 {
1482<<<<<<< HEAD 1140 // m_log.DebugFormat(
1483 part.StoreUndoState(UndoType.STATE_PRIM_ALL); 1141 // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}",
1484======= 1142 // remoteClient.Name, part.Name, part.LocalId, offsetPos);
1485// m_log.DebugFormat(
1486// "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}",
1487// remoteClient.Name, part.Name, part.LocalId, offsetPos);
1488 1143
1489 part.StoreUndoState(); 1144 part.StoreUndoState();
1490>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1491 part.OnGrab(offsetPos, remoteClient); 1145 part.OnGrab(offsetPos, remoteClient);
1492 } 1146 }
1493 1147
@@ -1507,11 +1161,6 @@ namespace OpenSim.Region.Framework.Scenes
1507 /// <param name="silent">If true then deletion is not broadcast to clients</param> 1161 /// <param name="silent">If true then deletion is not broadcast to clients</param>
1508 public void DeleteGroupFromScene(bool silent) 1162 public void DeleteGroupFromScene(bool silent)
1509 { 1163 {
1510 // We need to keep track of this state in case this group is still queued for backup.
1511 m_isDeleted = true;
1512
1513 DetachFromBackup();
1514
1515 SceneObjectPart[] parts = m_parts.GetArray(); 1164 SceneObjectPart[] parts = m_parts.GetArray();
1516 for (int i = 0; i < parts.Length; i++) 1165 for (int i = 0; i < parts.Length; i++)
1517 { 1166 {
@@ -1523,11 +1172,13 @@ namespace OpenSim.Region.Framework.Scenes
1523 avatar.StandUp(); 1172 avatar.StandUp();
1524 1173
1525 if (!silent) 1174 if (!silent)
1175 {
1526 part.UpdateFlag = 0; 1176 part.UpdateFlag = 0;
1177 if (part == m_rootPart)
1178 avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
1179 }
1527 }); 1180 });
1528 } 1181 }
1529
1530
1531 } 1182 }
1532 1183
1533 public void AddScriptLPS(int count) 1184 public void AddScriptLPS(int count)
@@ -1587,10 +1238,10 @@ namespace OpenSim.Region.Framework.Scenes
1587 1238
1588 public void SetText(string text, Vector3 color, double alpha) 1239 public void SetText(string text, Vector3 color, double alpha)
1589 { 1240 {
1590 Color = Color.FromArgb(0xff - (int) (alpha * 0xff), 1241 Color = Color.FromArgb(0xff - (int)(alpha * 0xff),
1591 (int) (color.X * 0xff), 1242 (int)(color.X * 0xff),
1592 (int) (color.Y * 0xff), 1243 (int)(color.Y * 0xff),
1593 (int) (color.Z * 0xff)); 1244 (int)(color.Z * 0xff));
1594 Text = text; 1245 Text = text;
1595 1246
1596 HasGroupChanged = true; 1247 HasGroupChanged = true;
@@ -1605,7 +1256,7 @@ namespace OpenSim.Region.Framework.Scenes
1605 { 1256 {
1606 // Apply physics to the root prim 1257 // Apply physics to the root prim
1607 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); 1258 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
1608 1259
1609 // Apply physics to child prims 1260 // Apply physics to child prims
1610 SceneObjectPart[] parts = m_parts.GetArray(); 1261 SceneObjectPart[] parts = m_parts.GetArray();
1611 if (parts.Length > 1) 1262 if (parts.Length > 1)
@@ -1624,12 +1275,7 @@ namespace OpenSim.Region.Framework.Scenes
1624 1275
1625 public void SetOwnerId(UUID userId) 1276 public void SetOwnerId(UUID userId)
1626 { 1277 {
1627 ForEachPart(delegate(SceneObjectPart part) 1278 ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; });
1628 {
1629
1630 part.OwnerID = userId;
1631
1632 });
1633 } 1279 }
1634 1280
1635 public void ForEachPart(Action<SceneObjectPart> whatToDo) 1281 public void ForEachPart(Action<SceneObjectPart> whatToDo)
@@ -1649,29 +1295,23 @@ namespace OpenSim.Region.Framework.Scenes
1649 { 1295 {
1650 if (!m_isBackedUp) 1296 if (!m_isBackedUp)
1651 { 1297 {
1652// m_log.DebugFormat( 1298 // m_log.DebugFormat(
1653// "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID); 1299 // "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID);
1654 return; 1300 return;
1655 } 1301 }
1656 1302
1657 if (IsDeleted || UUID == UUID.Zero) 1303 if (IsDeleted || UUID == UUID.Zero)
1658 { 1304 {
1659// m_log.DebugFormat( 1305 // m_log.DebugFormat(
1660// "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); 1306 // "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID);
1661 return; 1307 return;
1662 } 1308 }
1663 1309
1664 if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
1665 return;
1666
1667 // Since this is the top of the section of call stack for backing up a particular scene object, don't let 1310 // Since this is the top of the section of call stack for backing up a particular scene object, don't let
1668 // any exception propogate upwards. 1311 // any exception propogate upwards.
1669 try 1312 try
1670 { 1313 {
1671 if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart 1314 if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart
1672 m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things
1673 m_scene.LoadingPrims) // Land may not be valid yet
1674
1675 { 1315 {
1676 ILandObject parcel = m_scene.LandChannel.GetLandObject( 1316 ILandObject parcel = m_scene.LandChannel.GetLandObject(
1677 m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); 1317 m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y);
@@ -1688,7 +1328,7 @@ namespace OpenSim.Region.Framework.Scenes
1688 { 1328 {
1689 DetachFromBackup(); 1329 DetachFromBackup();
1690 m_log.DebugFormat( 1330 m_log.DebugFormat(
1691 "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", 1331 "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn",
1692 RootPart.UUID); 1332 RootPart.UUID);
1693 m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn"); 1333 m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn");
1694 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, 1334 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
@@ -1698,7 +1338,6 @@ namespace OpenSim.Region.Framework.Scenes
1698 } 1338 }
1699 } 1339 }
1700 } 1340 }
1701
1702 } 1341 }
1703 1342
1704 if (m_scene.UseBackup && HasGroupChanged) 1343 if (m_scene.UseBackup && HasGroupChanged)
@@ -1706,23 +1345,9 @@ namespace OpenSim.Region.Framework.Scenes
1706 // don't backup while it's selected or you're asking for changes mid stream. 1345 // don't backup while it's selected or you're asking for changes mid stream.
1707 if (isTimeToPersist() || forcedBackup) 1346 if (isTimeToPersist() || forcedBackup)
1708 { 1347 {
1709 if (m_rootPart.PhysActor != null && 1348 // m_log.DebugFormat(
1710 (!m_rootPart.PhysActor.IsPhysical)) 1349 // "[SCENE]: Storing {0}, {1} in {2}",
1711 { 1350 // Name, UUID, m_scene.RegionInfo.RegionName);
1712 // Possible ghost prim
1713 if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition)
1714 {
1715 foreach (SceneObjectPart part in m_parts.GetArray())
1716 {
1717 // Re-set physics actor positions and
1718 // orientations
1719 part.GroupPosition = m_rootPart.GroupPosition;
1720 }
1721 }
1722 }
1723// m_log.DebugFormat(
1724// "[SCENE]: Storing {0}, {1} in {2}",
1725// Name, UUID, m_scene.RegionInfo.RegionName);
1726 1351
1727 SceneObjectGroup backup_group = Copy(false); 1352 SceneObjectGroup backup_group = Copy(false);
1728 backup_group.RootPart.Velocity = RootPart.Velocity; 1353 backup_group.RootPart.Velocity = RootPart.Velocity;
@@ -1735,25 +1360,25 @@ namespace OpenSim.Region.Framework.Scenes
1735 m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); 1360 m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this);
1736 datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); 1361 datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);
1737 1362
1738 backup_group.ForEachPart(delegate(SceneObjectPart part) 1363 backup_group.ForEachPart(delegate(SceneObjectPart part)
1739 { 1364 {
1740 part.Inventory.ProcessInventoryBackup(datastore); 1365 part.Inventory.ProcessInventoryBackup(datastore);
1741 }); 1366 });
1742 1367
1743 backup_group = null; 1368 backup_group = null;
1744 } 1369 }
1745// else 1370 // else
1746// { 1371 // {
1747// m_log.DebugFormat( 1372 // m_log.DebugFormat(
1748// "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}", 1373 // "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}",
1749// Name, UUID, IsSelected); 1374 // Name, UUID, IsSelected);
1750// } 1375 // }
1751 } 1376 }
1752 } 1377 }
1753 catch (Exception e) 1378 catch (Exception e)
1754 { 1379 {
1755 m_log.ErrorFormat( 1380 m_log.ErrorFormat(
1756 "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", 1381 "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}",
1757 Name, UUID, m_scene.RegionInfo.RegionName, e.Message, e.StackTrace); 1382 Name, UUID, m_scene.RegionInfo.RegionName, e.Message, e.StackTrace);
1758 } 1383 }
1759 } 1384 }
@@ -1783,106 +1408,63 @@ namespace OpenSim.Region.Framework.Scenes
1783 /// <returns></returns> 1408 /// <returns></returns>
1784 public SceneObjectGroup Copy(bool userExposed) 1409 public SceneObjectGroup Copy(bool userExposed)
1785 { 1410 {
1786 SceneObjectGroup dupe; 1411 SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone();
1787 try 1412 dupe.m_isBackedUp = false;
1788 { 1413 dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>();
1789 m_dupeInProgress = true; 1414
1790 dupe = (SceneObjectGroup)MemberwiseClone(); 1415 // Warning, The following code related to previousAttachmentStatus is needed so that clones of
1791 dupe.m_isBackedUp = false; 1416 // attachments do not bordercross while they're being duplicated. This is hacktastic!
1792 dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); 1417 // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
1793 1418 // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state
1794<<<<<<< HEAD 1419 // (which should be false anyway) set it as an Attachment and then set it's Absolute Position,
1795 // Warning, The following code related to previousAttachmentStatus is needed so that clones of 1420 // then restore it's attachment state
1796 // attachments do not bordercross while they're being duplicated. This is hacktastic! 1421
1797 // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! 1422 // This is only necessary when userExposed is false!
1798 // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state 1423
1799 // (which should be false anyway) set it as an Attachment and then set it's Absolute Position,
1800 // then restore it's attachment state
1801=======
1802 bool previousAttachmentStatus = dupe.IsAttachment; 1424 bool previousAttachmentStatus = dupe.IsAttachment;
1803 1425
1804 if (!userExposed) 1426 if (!userExposed)
1805 dupe.IsAttachment = true; 1427 dupe.IsAttachment = true;
1806>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1807 1428
1808 // This is only necessary when userExposed is false! 1429 dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
1809 1430
1810<<<<<<< HEAD
1811 bool previousAttachmentStatus = dupe.RootPart.IsAttachment;
1812=======
1813 if (!userExposed) 1431 if (!userExposed)
1814 { 1432 {
1815 dupe.IsAttachment = previousAttachmentStatus; 1433 dupe.IsAttachment = previousAttachmentStatus;
1816 } 1434 }
1817>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1818
1819 if (!userExposed)
1820 dupe.RootPart.IsAttachment = true;
1821
1822 dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
1823
1824 if (!userExposed)
1825 {
1826 dupe.RootPart.IsAttachment = previousAttachmentStatus;
1827 }
1828 1435
1829 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); 1436 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
1830 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; 1437 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
1831 1438
1832 if (userExposed) 1439 if (userExposed)
1833 dupe.m_rootPart.TrimPermissions(); 1440 dupe.m_rootPart.TrimPermissions();
1834 1441
1835 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); 1442 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray());
1836 1443
1837 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) 1444 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
1838 { 1445 {
1839 return p1.LinkNum.CompareTo(p2.LinkNum); 1446 return p1.LinkNum.CompareTo(p2.LinkNum);
1840 } 1447 }
1841 ); 1448 );
1842 1449
1843 foreach (SceneObjectPart part in partList) 1450 foreach (SceneObjectPart part in partList)
1451 {
1452 SceneObjectPart newPart;
1453 if (part.UUID != m_rootPart.UUID)
1844 { 1454 {
1845 if (part.UUID != m_rootPart.UUID) 1455 newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
1846 { 1456 newPart.LinkNum = part.LinkNum;
1847 SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
1848
1849 newPart.LinkNum = part.LinkNum;
1850 }
1851
1852 // Need to duplicate the physics actor as well
1853 if (part.PhysActor != null && userExposed)
1854 {
1855 PrimitiveBaseShape pbs = part.Shape;
1856
1857 part.PhysActor
1858 = m_scene.PhysicsScene.AddPrimShape(
1859 string.Format("{0}/{1}", part.Name, part.UUID),
1860 pbs,
1861 part.AbsolutePosition,
1862 part.Scale,
1863 part.RotationOffset,
1864 part.PhysActor.IsPhysical,
1865 m_localId);
1866 part.PhysActor.SetMaterial((int)part.Material);
1867
1868 part.PhysActor.LocalID = part.LocalId;
1869 part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
1870 }
1871 } 1457 }
1872 if (userExposed) 1458 else
1873 { 1459 {
1874 dupe.UpdateParentIDs(); 1460 newPart = dupe.m_rootPart;
1875 dupe.HasGroupChanged = true; 1461 }
1876 dupe.AttachToBackup();
1877 1462
1878<<<<<<< HEAD
1879 ScheduleGroupForFullUpdate();
1880=======
1881 // Need to duplicate the physics actor as well 1463 // Need to duplicate the physics actor as well
1882 if (part.PhysActor != null && userExposed) 1464 if (part.PhysActor != null && userExposed)
1883 { 1465 {
1884 PrimitiveBaseShape pbs = newPart.Shape; 1466 PrimitiveBaseShape pbs = newPart.Shape;
1885 1467
1886 newPart.PhysActor 1468 newPart.PhysActor
1887 = m_scene.PhysicsScene.AddPrimShape( 1469 = m_scene.PhysicsScene.AddPrimShape(
1888 string.Format("{0}/{1}", newPart.Name, newPart.UUID), 1470 string.Format("{0}/{1}", newPart.Name, newPart.UUID),
@@ -1892,15 +1474,20 @@ namespace OpenSim.Region.Framework.Scenes
1892 newPart.RotationOffset, 1474 newPart.RotationOffset,
1893 part.PhysActor.IsPhysical, 1475 part.PhysActor.IsPhysical,
1894 newPart.LocalId); 1476 newPart.LocalId);
1895 1477
1896 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); 1478 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
1897>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1898 } 1479 }
1899 } 1480 }
1900 finally 1481
1482 if (userExposed)
1901 { 1483 {
1902 m_dupeInProgress = false; 1484 dupe.UpdateParentIDs();
1485 dupe.HasGroupChanged = true;
1486 dupe.AttachToBackup();
1487
1488 ScheduleGroupForFullUpdate();
1903 } 1489 }
1490
1904 return dupe; 1491 return dupe;
1905 } 1492 }
1906 1493
@@ -2006,7 +1593,6 @@ namespace OpenSim.Region.Framework.Scenes
2006 return Vector3.Zero; 1593 return Vector3.Zero;
2007 } 1594 }
2008 1595
2009 // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object
2010 public void moveToTarget(Vector3 target, float tau) 1596 public void moveToTarget(Vector3 target, float tau)
2011 { 1597 {
2012 if (IsAttachment) 1598 if (IsAttachment)
@@ -2030,72 +1616,14 @@ namespace OpenSim.Region.Framework.Scenes
2030 1616
2031 public void stopMoveToTarget() 1617 public void stopMoveToTarget()
2032 { 1618 {
2033<<<<<<< HEAD
2034 SceneObjectPart rootpart = m_rootPart;
2035 if (rootpart != null)
2036 {
2037 if (IsAttachment)
2038 {
2039 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
2040 if (avatar != null) avatar.StopMoveToPosition();
2041 }
2042 else
2043 {
2044 if (rootpart.PhysActor != null)
2045 {
2046 rootpart.PhysActor.PIDActive = false;
2047 }
2048 }
2049 }
2050=======
2051 if (RootPart.PhysActor != null) 1619 if (RootPart.PhysActor != null)
2052 RootPart.PhysActor.PIDActive = false; 1620 RootPart.PhysActor.PIDActive = false;
2053>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2054 }
2055
2056 public void rotLookAt(Quaternion target, float strength, float damping)
2057 {
2058 SceneObjectPart rootpart = m_rootPart;
2059 if (rootpart != null)
2060 {
2061 if (IsAttachment)
2062 {
2063 /*
2064 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
2065 if (avatar != null)
2066 {
2067 Rotate the Av?
2068 } */
2069 }
2070 else
2071 {
2072 if (rootpart.PhysActor != null)
2073 { // APID must be implemented in your physics system for this to function.
2074 rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W);
2075 rootpart.PhysActor.APIDStrength = strength;
2076 rootpart.PhysActor.APIDDamping = damping;
2077 rootpart.PhysActor.APIDActive = true;
2078 }
2079 }
2080 }
2081 } 1621 }
2082 1622
2083 public void stopLookAt() 1623 public void stopLookAt()
2084 { 1624 {
2085<<<<<<< HEAD
2086 SceneObjectPart rootpart = m_rootPart;
2087 if (rootpart != null)
2088 {
2089 if (rootpart.PhysActor != null)
2090 { // APID must be implemented in your physics system for this to function.
2091 rootpart.PhysActor.APIDActive = false;
2092 }
2093 }
2094
2095=======
2096 if (RootPart.PhysActor != null) 1625 if (RootPart.PhysActor != null)
2097 RootPart.PhysActor.APIDActive = false; 1626 RootPart.PhysActor.APIDActive = false;
2098>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2099 } 1627 }
2100 1628
2101 /// <summary> 1629 /// <summary>
@@ -2153,8 +1681,6 @@ namespace OpenSim.Region.Framework.Scenes
2153 public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) 1681 public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
2154 { 1682 {
2155 SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); 1683 SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed);
2156 newPart.SetParent(this);
2157
2158 AddPart(newPart); 1684 AddPart(newPart);
2159 1685
2160 SetPartAsNonRoot(newPart); 1686 SetPartAsNonRoot(newPart);
@@ -2188,11 +1714,11 @@ namespace OpenSim.Region.Framework.Scenes
2188 public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags) 1714 public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags)
2189 { 1715 {
2190 remoteClient.SendObjectPropertiesFamilyData(RootPart, RequestFlags); 1716 remoteClient.SendObjectPropertiesFamilyData(RootPart, RequestFlags);
2191 1717
2192// remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask, 1718 // remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask,
2193// RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, 1719 // RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask,
2194// RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, 1720 // RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category,
2195// RootPart.CreatorID, RootPart.Name, RootPart.Description); 1721 // RootPart.CreatorID, RootPart.Name, RootPart.Description);
2196 } 1722 }
2197 1723
2198 public void SetPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID) 1724 public void SetPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID)
@@ -2245,8 +1771,8 @@ namespace OpenSim.Region.Framework.Scenes
2245 1771
2246 public void ScheduleFullUpdateToAvatar(ScenePresence presence) 1772 public void ScheduleFullUpdateToAvatar(ScenePresence presence)
2247 { 1773 {
2248// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); 1774 // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
2249 1775
2250 RootPart.AddFullUpdateToAvatar(presence); 1776 RootPart.AddFullUpdateToAvatar(presence);
2251 1777
2252 SceneObjectPart[] parts = m_parts.GetArray(); 1778 SceneObjectPart[] parts = m_parts.GetArray();
@@ -2260,7 +1786,7 @@ namespace OpenSim.Region.Framework.Scenes
2260 1786
2261 public void ScheduleTerseUpdateToAvatar(ScenePresence presence) 1787 public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
2262 { 1788 {
2263// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); 1789 // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
2264 1790
2265 SceneObjectPart[] parts = m_parts.GetArray(); 1791 SceneObjectPart[] parts = m_parts.GetArray();
2266 for (int i = 0; i < parts.Length; i++) 1792 for (int i = 0; i < parts.Length; i++)
@@ -2272,9 +1798,9 @@ namespace OpenSim.Region.Framework.Scenes
2272 /// </summary> 1798 /// </summary>
2273 public void ScheduleGroupForFullUpdate() 1799 public void ScheduleGroupForFullUpdate()
2274 { 1800 {
2275// if (IsAttachment) 1801 // if (IsAttachment)
2276// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); 1802 // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId);
2277 1803
2278 checkAtTargets(); 1804 checkAtTargets();
2279 RootPart.ScheduleFullUpdate(); 1805 RootPart.ScheduleFullUpdate();
2280 1806
@@ -2292,7 +1818,7 @@ namespace OpenSim.Region.Framework.Scenes
2292 /// </summary> 1818 /// </summary>
2293 public void ScheduleGroupForTerseUpdate() 1819 public void ScheduleGroupForTerseUpdate()
2294 { 1820 {
2295// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); 1821 // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
2296 1822
2297 SceneObjectPart[] parts = m_parts.GetArray(); 1823 SceneObjectPart[] parts = m_parts.GetArray();
2298 for (int i = 0; i < parts.Length; i++) 1824 for (int i = 0; i < parts.Length; i++)
@@ -2303,12 +1829,12 @@ namespace OpenSim.Region.Framework.Scenes
2303 /// Immediately send a full update for this scene object. 1829 /// Immediately send a full update for this scene object.
2304 /// </summary> 1830 /// </summary>
2305 public void SendGroupFullUpdate() 1831 public void SendGroupFullUpdate()
2306 { 1832 {
2307 if (IsDeleted) 1833 if (IsDeleted)
2308 return; 1834 return;
2309 1835
2310// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); 1836 // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID);
2311 1837
2312 RootPart.SendFullUpdateToAllClients(); 1838 RootPart.SendFullUpdateToAllClients();
2313 1839
2314 SceneObjectPart[] parts = m_parts.GetArray(); 1840 SceneObjectPart[] parts = m_parts.GetArray();
@@ -2338,7 +1864,7 @@ namespace OpenSim.Region.Framework.Scenes
2338 { 1864 {
2339 if (m_scene == null) // Need to check here as it's null during object creation 1865 if (m_scene == null) // Need to check here as it's null during object creation
2340 return; 1866 return;
2341 1867
2342 m_scene.SceneGraph.AddToUpdateList(this); 1868 m_scene.SceneGraph.AddToUpdateList(this);
2343 } 1869 }
2344 1870
@@ -2454,9 +1980,9 @@ namespace OpenSim.Region.Framework.Scenes
2454 // objectGroup.RootPart.SendScheduledUpdates(); 1980 // objectGroup.RootPart.SendScheduledUpdates();
2455 //} 1981 //}
2456 1982
2457// m_log.DebugFormat( 1983 // m_log.DebugFormat(
2458// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", 1984 // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
2459// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); 1985 // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
2460 1986
2461 SceneObjectPart linkPart = objectGroup.m_rootPart; 1987 SceneObjectPart linkPart = objectGroup.m_rootPart;
2462 1988
@@ -2496,15 +2022,12 @@ namespace OpenSim.Region.Framework.Scenes
2496 part.LinkNum += objectGroup.PrimCount; 2022 part.LinkNum += objectGroup.PrimCount;
2497 } 2023 }
2498 } 2024 }
2499 }
2500 2025
2501 linkPart.LinkNum = 2; 2026 linkPart.LinkNum = 2;
2502 2027
2503 linkPart.SetParent(this); 2028 linkPart.SetParent(this);
2504 linkPart.CreateSelected = true; 2029 linkPart.CreateSelected = true;
2505 2030
2506 lock (m_parts.SyncRoot)
2507 {
2508 //if (linkPart.PhysActor != null) 2031 //if (linkPart.PhysActor != null)
2509 //{ 2032 //{
2510 // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); 2033 // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
@@ -2528,9 +2051,9 @@ namespace OpenSim.Region.Framework.Scenes
2528 objectGroup.IsDeleted = true; 2051 objectGroup.IsDeleted = true;
2529 2052
2530 objectGroup.m_parts.Clear(); 2053 objectGroup.m_parts.Clear();
2531 2054
2532 // Can't do this yet since backup still makes use of the root part without any synchronization 2055 // Can't do this yet since backup still makes use of the root part without any synchronization
2533// objectGroup.m_rootPart = null; 2056 // objectGroup.m_rootPart = null;
2534 2057
2535 AttachToBackup(); 2058 AttachToBackup();
2536 2059
@@ -2588,10 +2111,10 @@ namespace OpenSim.Region.Framework.Scenes
2588 /// <returns>The object group of the newly delinked prim.</returns> 2111 /// <returns>The object group of the newly delinked prim.</returns>
2589 public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) 2112 public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents)
2590 { 2113 {
2591// m_log.DebugFormat( 2114 // m_log.DebugFormat(
2592// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", 2115 // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
2593// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); 2116 // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
2594 2117
2595 linkPart.ClearUndoState(); 2118 linkPart.ClearUndoState();
2596 2119
2597 Quaternion worldRot = linkPart.GetWorldRotation(); 2120 Quaternion worldRot = linkPart.GetWorldRotation();
@@ -2662,15 +2185,9 @@ namespace OpenSim.Region.Framework.Scenes
2662 /// <param name="objectGroup"></param> 2185 /// <param name="objectGroup"></param>
2663 public virtual void DetachFromBackup() 2186 public virtual void DetachFromBackup()
2664 { 2187 {
2665<<<<<<< HEAD
2666 m_scene.SceneGraph.FireDetachFromBackup(this);
2667
2668 if (m_isBackedUp)
2669=======
2670 if (m_isBackedUp && Scene != null) 2188 if (m_isBackedUp && Scene != null)
2671>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2672 m_scene.EventManager.OnBackup -= ProcessBackup; 2189 m_scene.EventManager.OnBackup -= ProcessBackup;
2673 2190
2674 m_isBackedUp = false; 2191 m_isBackedUp = false;
2675 } 2192 }
2676 2193
@@ -2686,8 +2203,7 @@ namespace OpenSim.Region.Framework.Scenes
2686 2203
2687 axPos *= parentRot; 2204 axPos *= parentRot;
2688 part.OffsetPosition = axPos; 2205 part.OffsetPosition = axPos;
2689 Vector3 newPos = oldGroupPosition + part.OffsetPosition; 2206 part.GroupPosition = oldGroupPosition + part.OffsetPosition;
2690 part.GroupPosition = newPos;
2691 part.OffsetPosition = Vector3.Zero; 2207 part.OffsetPosition = Vector3.Zero;
2692 part.RotationOffset = worldRot; 2208 part.RotationOffset = worldRot;
2693 2209
@@ -2698,7 +2214,7 @@ namespace OpenSim.Region.Framework.Scenes
2698 2214
2699 part.LinkNum = linkNum; 2215 part.LinkNum = linkNum;
2700 2216
2701 part.OffsetPosition = newPos - AbsolutePosition; 2217 part.OffsetPosition = part.GroupPosition - AbsolutePosition;
2702 2218
2703 Quaternion rootRotation = m_rootPart.RotationOffset; 2219 Quaternion rootRotation = m_rootPart.RotationOffset;
2704 2220
@@ -2708,7 +2224,7 @@ namespace OpenSim.Region.Framework.Scenes
2708 2224
2709 parentRot = m_rootPart.RotationOffset; 2225 parentRot = m_rootPart.RotationOffset;
2710 oldRot = part.RotationOffset; 2226 oldRot = part.RotationOffset;
2711 Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; 2227 Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
2712 part.RotationOffset = newRot; 2228 part.RotationOffset = newRot;
2713 } 2229 }
2714 2230
@@ -2806,7 +2322,7 @@ namespace OpenSim.Region.Framework.Scenes
2806 // but it will result in over-shoot or under-shoot of the target orientation. 2322 // but it will result in over-shoot or under-shoot of the target orientation.
2807 // For the end user, this means that ctrl+shift+drag can be used for relative, 2323 // For the end user, this means that ctrl+shift+drag can be used for relative,
2808 // but not absolute, adjustments of orientation for physical prims. 2324 // but not absolute, adjustments of orientation for physical prims.
2809 2325
2810 if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) 2326 if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation))
2811 { 2327 {
2812 if (m_rootPart.PhysActor != null) 2328 if (m_rootPart.PhysActor != null)
@@ -2821,25 +2337,25 @@ namespace OpenSim.Region.Framework.Scenes
2821 } 2337 }
2822 else 2338 else
2823 { 2339 {
2824 // save and update old orientation 2340 // save and update old orientation
2825 Quaternion old = m_rootPart.SpinOldOrientation; 2341 Quaternion old = m_rootPart.SpinOldOrientation;
2826 m_rootPart.SpinOldOrientation = newOrientation; 2342 m_rootPart.SpinOldOrientation = newOrientation;
2827 //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); 2343 //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
2828 //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); 2344 //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
2829 2345
2830 // compute difference between previous old rotation and new incoming rotation 2346 // compute difference between previous old rotation and new incoming rotation
2831 Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; 2347 Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation;
2832 2348
2833 float rotationAngle; 2349 float rotationAngle;
2834 Vector3 rotationAxis; 2350 Vector3 rotationAxis;
2835 minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); 2351 minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle);
2836 rotationAxis.Normalize(); 2352 rotationAxis.Normalize();
2837 2353
2838 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); 2354 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
2839 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); 2355 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
2840 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor 2356 spinforce = (spinforce / 8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor
2841 m_rootPart.PhysActor.AddAngularForce(spinforce,true); 2357 m_rootPart.PhysActor.AddAngularForce(spinforce, true);
2842 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2358 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
2843 } 2359 }
2844 } 2360 }
2845 else 2361 else
@@ -2948,14 +2464,14 @@ namespace OpenSim.Region.Framework.Scenes
2948 if (selectionPart != null) 2464 if (selectionPart != null)
2949 { 2465 {
2950 SceneObjectPart[] parts = m_parts.GetArray(); 2466 SceneObjectPart[] parts = m_parts.GetArray();
2951 2467
2952 if (Scene != null) 2468 if (Scene != null)
2953 { 2469 {
2954 for (int i = 0; i < parts.Length; i++) 2470 for (int i = 0; i < parts.Length; i++)
2955 { 2471 {
2956 SceneObjectPart part = parts[i]; 2472 SceneObjectPart part = parts[i];
2957 if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || 2473 if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax ||
2958 part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || 2474 part.Scale.Y > m_scene.RegionInfo.PhysPrimMax ||
2959 part.Scale.Z > m_scene.RegionInfo.PhysPrimMax) 2475 part.Scale.Z > m_scene.RegionInfo.PhysPrimMax)
2960 { 2476 {
2961 UsePhysics = false; // Reset physics 2477 UsePhysics = false; // Reset physics
@@ -2964,16 +2480,8 @@ namespace OpenSim.Region.Framework.Scenes
2964 } 2480 }
2965 } 2481 }
2966 2482
2967 RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2968 for (int i = 0; i < parts.Length; i++) 2483 for (int i = 0; i < parts.Length; i++)
2969<<<<<<< HEAD
2970 {
2971 if (parts[i] != RootPart)
2972 parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2973 }
2974=======
2975 parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); 2484 parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect);
2976>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2977 } 2485 }
2978 } 2486 }
2979 2487
@@ -2986,17 +2494,6 @@ namespace OpenSim.Region.Framework.Scenes
2986 } 2494 }
2987 } 2495 }
2988 2496
2989
2990
2991 /// <summary>
2992 /// Gets the number of parts
2993 /// </summary>
2994 /// <returns></returns>
2995 public int GetPartCount()
2996 {
2997 return Parts.Count();
2998 }
2999
3000 /// <summary> 2497 /// <summary>
3001 /// Update the texture entry for this part 2498 /// Update the texture entry for this part
3002 /// </summary> 2499 /// </summary>
@@ -3051,37 +2548,10 @@ namespace OpenSim.Region.Framework.Scenes
3051 /// <param name="scale"></param> 2548 /// <param name="scale"></param>
3052 public void GroupResize(Vector3 scale) 2549 public void GroupResize(Vector3 scale)
3053 { 2550 {
3054<<<<<<< HEAD 2551 // m_log.DebugFormat(
3055 if (scale.X > m_scene.m_maxNonphys) 2552 // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
3056 scale.X = m_scene.m_maxNonphys;
3057 if (scale.Y > m_scene.m_maxNonphys)
3058 scale.Y = m_scene.m_maxNonphys;
3059 if (scale.Z > m_scene.m_maxNonphys)
3060 scale.Z = m_scene.m_maxNonphys;
3061 SceneObjectPart part = GetChildPart(localID);
3062 if (part != null)
3063 {
3064 if (part.PhysActor != null)
3065 {
3066 if (part.PhysActor.IsPhysical)
3067 {
3068 if (scale.X > m_scene.m_maxPhys)
3069 scale.X = m_scene.m_maxPhys;
3070 if (scale.Y > m_scene.m_maxPhys)
3071 scale.Y = m_scene.m_maxPhys;
3072 if (scale.Z > m_scene.m_maxPhys)
3073 scale.Z = m_scene.m_maxPhys;
3074 }
3075 part.PhysActor.Size = scale;
3076 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
3077 }
3078 part.Resize(scale);
3079=======
3080// m_log.DebugFormat(
3081// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
3082 2553
3083 RootPart.StoreUndoState(true); 2554 RootPart.StoreUndoState(true);
3084>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3085 2555
3086 scale.X = Math.Min(scale.X, Scene.m_maxNonphys); 2556 scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
3087 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); 2557 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
@@ -3094,35 +2564,9 @@ namespace OpenSim.Region.Framework.Scenes
3094 scale.Z = Math.Min(scale.Z, Scene.m_maxPhys); 2564 scale.Z = Math.Min(scale.Z, Scene.m_maxPhys);
3095 } 2565 }
3096 2566
3097<<<<<<< HEAD
3098 public void GroupResize(Vector3 scale, uint localID)
3099 {
3100 SceneObjectPart part = GetChildPart(localID);
3101 if (part != null)
3102 {
3103 if (scale.X > m_scene.m_maxNonphys)
3104 scale.X = m_scene.m_maxNonphys;
3105 if (scale.Y > m_scene.m_maxNonphys)
3106 scale.Y = m_scene.m_maxNonphys;
3107 if (scale.Z > m_scene.m_maxNonphys)
3108 scale.Z = m_scene.m_maxNonphys;
3109 if (part.PhysActor != null && part.PhysActor.IsPhysical)
3110 {
3111 if (scale.X > m_scene.m_maxPhys)
3112 scale.X = m_scene.m_maxPhys;
3113 if (scale.Y > m_scene.m_maxPhys)
3114 scale.Y = m_scene.m_maxPhys;
3115 if (scale.Z > m_scene.m_maxPhys)
3116 scale.Z = m_scene.m_maxPhys;
3117 }
3118 float x = (scale.X / part.Scale.X);
3119 float y = (scale.Y / part.Scale.Y);
3120 float z = (scale.Z / part.Scale.Z);
3121=======
3122 float x = (scale.X / RootPart.Scale.X); 2567 float x = (scale.X / RootPart.Scale.X);
3123 float y = (scale.Y / RootPart.Scale.Y); 2568 float y = (scale.Y / RootPart.Scale.Y);
3124 float z = (scale.Z / RootPart.Scale.Z); 2569 float z = (scale.Z / RootPart.Scale.Z);
3125>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3126 2570
3127 SceneObjectPart[] parts; 2571 SceneObjectPart[] parts;
3128 if (x > 1.0f || y > 1.0f || z > 1.0f) 2572 if (x > 1.0f || y > 1.0f || z > 1.0f)
@@ -3133,7 +2577,7 @@ namespace OpenSim.Region.Framework.Scenes
3133 SceneObjectPart obPart = parts[i]; 2577 SceneObjectPart obPart = parts[i];
3134 if (obPart.UUID != m_rootPart.UUID) 2578 if (obPart.UUID != m_rootPart.UUID)
3135 { 2579 {
3136// obPart.IgnoreUndoUpdate = true; 2580 // obPart.IgnoreUndoUpdate = true;
3137 Vector3 oldSize = new Vector3(obPart.Scale); 2581 Vector3 oldSize = new Vector3(obPart.Scale);
3138 2582
3139 float f = 1.0f; 2583 float f = 1.0f;
@@ -3161,72 +2605,17 @@ namespace OpenSim.Region.Framework.Scenes
3161 2605
3162 if (oldSize.Z * z > m_scene.m_maxPhys) 2606 if (oldSize.Z * z > m_scene.m_maxPhys)
3163 { 2607 {
3164<<<<<<< HEAD
3165 if (oldSize.X*x > m_scene.m_maxPhys)
3166 {
3167 f = m_scene.m_maxPhys / oldSize.X;
3168 a = f / x;
3169 x *= a;
3170 y *= a;
3171 z *= a;
3172 }
3173 if (oldSize.Y*y > m_scene.m_maxPhys)
3174 {
3175 f = m_scene.m_maxPhys / oldSize.Y;
3176 a = f / y;
3177 x *= a;
3178 y *= a;
3179 z *= a;
3180 }
3181 if (oldSize.Z*z > m_scene.m_maxPhys)
3182 {
3183 f = m_scene.m_maxPhys / oldSize.Z;
3184 a = f / z;
3185 x *= a;
3186 y *= a;
3187 z *= a;
3188 }
3189=======
3190 f = m_scene.m_maxPhys / oldSize.Z; 2608 f = m_scene.m_maxPhys / oldSize.Z;
3191 a = f / z; 2609 a = f / z;
3192 x *= a; 2610 x *= a;
3193 y *= a; 2611 y *= a;
3194 z *= a; 2612 z *= a;
3195>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3196 } 2613 }
3197 } 2614 }
3198 else 2615 else
3199 { 2616 {
3200 if (oldSize.X * x > m_scene.m_maxNonphys) 2617 if (oldSize.X * x > m_scene.m_maxNonphys)
3201 { 2618 {
3202<<<<<<< HEAD
3203 if (oldSize.X*x > m_scene.m_maxNonphys)
3204 {
3205 f = m_scene.m_maxNonphys / oldSize.X;
3206 a = f / x;
3207 x *= a;
3208 y *= a;
3209 z *= a;
3210 }
3211 if (oldSize.Y*y > m_scene.m_maxNonphys)
3212 {
3213 f = m_scene.m_maxNonphys / oldSize.Y;
3214 a = f / y;
3215 x *= a;
3216 y *= a;
3217 z *= a;
3218 }
3219 if (oldSize.Z*z > m_scene.m_maxNonphys)
3220 {
3221 f = m_scene.m_maxNonphys / oldSize.Z;
3222 a = f / z;
3223 x *= a;
3224 y *= a;
3225 z *= a;
3226 }
3227 }
3228 obPart.IgnoreUndoUpdate = false;
3229=======
3230 f = m_scene.m_maxNonphys / oldSize.X; 2619 f = m_scene.m_maxNonphys / oldSize.X;
3231 a = f / x; 2620 a = f / x;
3232 x *= a; 2621 x *= a;
@@ -3251,35 +2640,21 @@ namespace OpenSim.Region.Framework.Scenes
3251 y *= a; 2640 y *= a;
3252 z *= a; 2641 z *= a;
3253 } 2642 }
3254>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3255 } 2643 }
3256 2644
3257// obPart.IgnoreUndoUpdate = false; 2645 // obPart.IgnoreUndoUpdate = false;
3258 } 2646 }
3259 } 2647 }
3260 } 2648 }
3261 2649
3262<<<<<<< HEAD
3263 Vector3 prevScale = part.Scale;
3264 prevScale.X *= x;
3265 prevScale.Y *= y;
3266 prevScale.Z *= z;;
3267
3268 part.IgnoreUndoUpdate = false;
3269 part.StoreUndoState(UndoType.STATE_GROUP_SCALE);
3270 part.IgnoreUndoUpdate = true;
3271 part.Resize(prevScale);
3272 part.IgnoreUndoUpdate = false;
3273=======
3274 Vector3 prevScale = RootPart.Scale; 2650 Vector3 prevScale = RootPart.Scale;
3275 prevScale.X *= x; 2651 prevScale.X *= x;
3276 prevScale.Y *= y; 2652 prevScale.Y *= y;
3277 prevScale.Z *= z; 2653 prevScale.Z *= z;
3278>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3279 2654
3280// RootPart.IgnoreUndoUpdate = true; 2655 // RootPart.IgnoreUndoUpdate = true;
3281 RootPart.Resize(prevScale); 2656 RootPart.Resize(prevScale);
3282// RootPart.IgnoreUndoUpdate = false; 2657 // RootPart.IgnoreUndoUpdate = false;
3283 2658
3284 parts = m_parts.GetArray(); 2659 parts = m_parts.GetArray();
3285 for (int i = 0; i < parts.Length; i++) 2660 for (int i = 0; i < parts.Length; i++)
@@ -3289,32 +2664,6 @@ namespace OpenSim.Region.Framework.Scenes
3289 if (obPart.UUID != m_rootPart.UUID) 2664 if (obPart.UUID != m_rootPart.UUID)
3290 { 2665 {
3291 obPart.IgnoreUndoUpdate = true; 2666 obPart.IgnoreUndoUpdate = true;
3292<<<<<<< HEAD
3293 if (obPart.UUID != m_rootPart.UUID)
3294 {
3295 if (obPart.UUID != m_rootPart.UUID)
3296 {
3297 obPart.IgnoreUndoUpdate = false;
3298 obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE);
3299 obPart.IgnoreUndoUpdate = true;
3300
3301 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
3302 currentpos.X *= x;
3303 currentpos.Y *= y;
3304 currentpos.Z *= z;
3305 Vector3 newSize = new Vector3(obPart.Scale);
3306 newSize.X *= x;
3307 newSize.Y *= y;
3308 newSize.Z *= z;
3309 obPart.Resize(newSize);
3310 obPart.UpdateOffSet(currentpos);
3311 }
3312 obPart.IgnoreUndoUpdate = false;
3313 }
3314 obPart.IgnoreUndoUpdate = false;
3315 }
3316=======
3317>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3318 2667
3319 Vector3 currentpos = new Vector3(obPart.OffsetPosition); 2668 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
3320 currentpos.X *= x; 2669 currentpos.X *= x;
@@ -3329,22 +2678,15 @@ namespace OpenSim.Region.Framework.Scenes
3329 obPart.Resize(newSize); 2678 obPart.Resize(newSize);
3330 obPart.UpdateOffSet(currentpos); 2679 obPart.UpdateOffSet(currentpos);
3331 2680
3332 obPart.IgnoreUndoUpdate = false; 2681 obPart.IgnoreUndoUpdate = false;
3333 } 2682 }
3334 2683
3335<<<<<<< HEAD 2684 // obPart.IgnoreUndoUpdate = false;
3336 part.IgnoreUndoUpdate = false; 2685 // obPart.StoreUndoState();
3337 HasGroupChanged = true;
3338 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE);
3339 ScheduleGroupForTerseUpdate();
3340=======
3341// obPart.IgnoreUndoUpdate = false;
3342// obPart.StoreUndoState();
3343>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3344 } 2686 }
3345 2687
3346// m_log.DebugFormat( 2688 // m_log.DebugFormat(
3347// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); 2689 // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale);
3348 } 2690 }
3349 2691
3350 #endregion 2692 #endregion
@@ -3357,22 +2699,18 @@ namespace OpenSim.Region.Framework.Scenes
3357 /// <param name="pos"></param> 2699 /// <param name="pos"></param>
3358 public void UpdateGroupPosition(Vector3 pos) 2700 public void UpdateGroupPosition(Vector3 pos)
3359 { 2701 {
3360<<<<<<< HEAD 2702 // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
3361=======
3362// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
3363 2703
3364 RootPart.StoreUndoState(true); 2704 RootPart.StoreUndoState(true);
3365 2705
3366// SceneObjectPart[] parts = m_parts.GetArray(); 2706 // SceneObjectPart[] parts = m_parts.GetArray();
3367// for (int i = 0; i < parts.Length; i++) 2707 // for (int i = 0; i < parts.Length; i++)
3368// parts[i].StoreUndoState(); 2708 // parts[i].StoreUndoState();
3369 2709
3370>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3371 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 2710 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
3372 { 2711 {
3373 if (IsAttachment) 2712 if (IsAttachment)
3374 { 2713 {
3375 m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION);
3376 m_rootPart.AttachedPos = pos; 2714 m_rootPart.AttachedPos = pos;
3377 } 2715 }
3378 if (RootPart.GetStatusSandbox()) 2716 if (RootPart.GetStatusSandbox())
@@ -3404,20 +2742,14 @@ namespace OpenSim.Region.Framework.Scenes
3404 { 2742 {
3405 SceneObjectPart part = GetChildPart(localID); 2743 SceneObjectPart part = GetChildPart(localID);
3406 2744
3407<<<<<<< HEAD 2745 // SceneObjectPart[] parts = m_parts.GetArray();
3408 SceneObjectPart[] parts = m_parts.GetArray(); 2746 // for (int i = 0; i < parts.Length; i++)
3409 for (int i = 0; i < parts.Length; i++) 2747 // parts[i].StoreUndoState();
3410 parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION);
3411=======
3412// SceneObjectPart[] parts = m_parts.GetArray();
3413// for (int i = 0; i < parts.Length; i++)
3414// parts[i].StoreUndoState();
3415>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3416 2748
3417 if (part != null) 2749 if (part != null)
3418 { 2750 {
3419// m_log.DebugFormat( 2751 // m_log.DebugFormat(
3420// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); 2752 // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
3421 2753
3422 part.StoreUndoState(false); 2754 part.StoreUndoState(false);
3423 part.IgnoreUndoUpdate = true; 2755 part.IgnoreUndoUpdate = true;
@@ -3442,18 +2774,12 @@ namespace OpenSim.Region.Framework.Scenes
3442 /// <param name="pos"></param> 2774 /// <param name="pos"></param>
3443 public void UpdateRootPosition(Vector3 pos) 2775 public void UpdateRootPosition(Vector3 pos)
3444 { 2776 {
3445<<<<<<< HEAD 2777 // m_log.DebugFormat(
3446 SceneObjectPart[] parts = m_parts.GetArray(); 2778 // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
3447 for (int i = 0; i < parts.Length; i++)
3448 parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION);
3449=======
3450// m_log.DebugFormat(
3451// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
3452 2779
3453// SceneObjectPart[] parts = m_parts.GetArray(); 2780 // SceneObjectPart[] parts = m_parts.GetArray();
3454// for (int i = 0; i < parts.Length; i++) 2781 // for (int i = 0; i < parts.Length; i++)
3455// parts[i].StoreUndoState(); 2782 // parts[i].StoreUndoState();
3456>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3457 2783
3458 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 2784 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
3459 Vector3 oldPos = 2785 Vector3 oldPos =
@@ -3474,27 +2800,10 @@ namespace OpenSim.Region.Framework.Scenes
3474 obPart.OffsetPosition = obPart.OffsetPosition + diff; 2800 obPart.OffsetPosition = obPart.OffsetPosition + diff;
3475 } 2801 }
3476 2802
3477 //We have to set undoing here because otherwise an undo state will be saved 2803 AbsolutePosition = newPos;
3478 if (!m_rootPart.Undoing)
3479 {
3480 m_rootPart.Undoing = true;
3481 AbsolutePosition = newPos;
3482 m_rootPart.Undoing = false;
3483 }
3484 else
3485 {
3486 AbsolutePosition = newPos;
3487 }
3488 2804
3489 HasGroupChanged = true; 2805 HasGroupChanged = true;
3490 if (m_rootPart.Undoing) 2806 ScheduleGroupForTerseUpdate();
3491 {
3492 ScheduleGroupForFullUpdate();
3493 }
3494 else
3495 {
3496 ScheduleGroupForTerseUpdate();
3497 }
3498 } 2807 }
3499 2808
3500 public void OffsetForNewRegion(Vector3 offset) 2809 public void OffsetForNewRegion(Vector3 offset)
@@ -3512,20 +2821,14 @@ namespace OpenSim.Region.Framework.Scenes
3512 /// <param name="rot"></param> 2821 /// <param name="rot"></param>
3513 public void UpdateGroupRotationR(Quaternion rot) 2822 public void UpdateGroupRotationR(Quaternion rot)
3514 { 2823 {
3515<<<<<<< HEAD 2824 // m_log.DebugFormat(
3516 SceneObjectPart[] parts = m_parts.GetArray(); 2825 // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
3517 for (int i = 0; i < parts.Length; i++)
3518 parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION);
3519=======
3520// m_log.DebugFormat(
3521// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
3522 2826
3523// SceneObjectPart[] parts = m_parts.GetArray(); 2827 // SceneObjectPart[] parts = m_parts.GetArray();
3524// for (int i = 0; i < parts.Length; i++) 2828 // for (int i = 0; i < parts.Length; i++)
3525// parts[i].StoreUndoState(); 2829 // parts[i].StoreUndoState();
3526 2830
3527 m_rootPart.StoreUndoState(true); 2831 m_rootPart.StoreUndoState(true);
3528>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3529 2832
3530 m_rootPart.UpdateRotation(rot); 2833 m_rootPart.UpdateRotation(rot);
3531 2834
@@ -3547,21 +2850,15 @@ namespace OpenSim.Region.Framework.Scenes
3547 /// <param name="rot"></param> 2850 /// <param name="rot"></param>
3548 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) 2851 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
3549 { 2852 {
3550<<<<<<< HEAD 2853 // m_log.DebugFormat(
3551 SceneObjectPart[] parts = m_parts.GetArray(); 2854 // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
3552 for (int i = 0; i < parts.Length; i++)
3553 parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION);
3554=======
3555// m_log.DebugFormat(
3556// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
3557 2855
3558// SceneObjectPart[] parts = m_parts.GetArray(); 2856 // SceneObjectPart[] parts = m_parts.GetArray();
3559// for (int i = 0; i < parts.Length; i++) 2857 // for (int i = 0; i < parts.Length; i++)
3560// parts[i].StoreUndoState(); 2858 // parts[i].StoreUndoState();
3561 2859
3562 RootPart.StoreUndoState(true); 2860 RootPart.StoreUndoState(true);
3563 RootPart.IgnoreUndoUpdate = true; 2861 RootPart.IgnoreUndoUpdate = true;
3564>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3565 2862
3566 m_rootPart.UpdateRotation(rot); 2863 m_rootPart.UpdateRotation(rot);
3567 2864
@@ -3588,14 +2885,15 @@ namespace OpenSim.Region.Framework.Scenes
3588 public void UpdateSingleRotation(Quaternion rot, uint localID) 2885 public void UpdateSingleRotation(Quaternion rot, uint localID)
3589 { 2886 {
3590 SceneObjectPart part = GetChildPart(localID); 2887 SceneObjectPart part = GetChildPart(localID);
2888
3591 SceneObjectPart[] parts = m_parts.GetArray(); 2889 SceneObjectPart[] parts = m_parts.GetArray();
3592 for (int i = 0; i < parts.Length; i++) 2890 for (int i = 0; i < parts.Length; i++)
3593 parts[i].StoreUndoState(UndoType.STATE_PRIM_ROTATION); 2891 parts[i].StoreUndoState();
3594 2892
3595 if (part != null) 2893 if (part != null)
3596 { 2894 {
3597// m_log.DebugFormat( 2895 // m_log.DebugFormat(
3598// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); 2896 // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot);
3599 2897
3600 if (part.UUID == m_rootPart.UUID) 2898 if (part.UUID == m_rootPart.UUID)
3601 { 2899 {
@@ -3618,9 +2916,9 @@ namespace OpenSim.Region.Framework.Scenes
3618 SceneObjectPart part = GetChildPart(localID); 2916 SceneObjectPart part = GetChildPart(localID);
3619 if (part != null) 2917 if (part != null)
3620 { 2918 {
3621// m_log.DebugFormat( 2919 // m_log.DebugFormat(
3622// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", 2920 // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}",
3623// part.Name, part.LocalId, rot); 2921 // part.Name, part.LocalId, rot);
3624 2922
3625 part.StoreUndoState(); 2923 part.StoreUndoState();
3626 part.IgnoreUndoUpdate = true; 2924 part.IgnoreUndoUpdate = true;
@@ -3628,29 +2926,12 @@ namespace OpenSim.Region.Framework.Scenes
3628 if (part.UUID == m_rootPart.UUID) 2926 if (part.UUID == m_rootPart.UUID)
3629 { 2927 {
3630 UpdateRootRotation(rot); 2928 UpdateRootRotation(rot);
3631 if (!m_rootPart.Undoing) 2929 AbsolutePosition = pos;
3632 {
3633 m_rootPart.Undoing = true;
3634 AbsolutePosition = pos;
3635 m_rootPart.Undoing = false;
3636 }
3637 else
3638 {
3639 AbsolutePosition = pos;
3640 }
3641 } 2930 }
3642 else 2931 else
3643 { 2932 {
3644<<<<<<< HEAD
3645 part.StoreUndoState(UndoType.STATE_PRIM_ROTATION);
3646 part.IgnoreUndoUpdate = true;
3647 part.UpdateRotation(rot);
3648 part.OffsetPosition = pos;
3649 part.IgnoreUndoUpdate = false;
3650=======
3651 part.UpdateRotation(rot); 2933 part.UpdateRotation(rot);
3652 part.OffsetPosition = pos; 2934 part.OffsetPosition = pos;
3653>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3654 } 2935 }
3655 2936
3656 part.IgnoreUndoUpdate = false; 2937 part.IgnoreUndoUpdate = false;
@@ -3663,23 +2944,15 @@ namespace OpenSim.Region.Framework.Scenes
3663 /// <param name="rot"></param> 2944 /// <param name="rot"></param>
3664 public void UpdateRootRotation(Quaternion rot) 2945 public void UpdateRootRotation(Quaternion rot)
3665 { 2946 {
3666// m_log.DebugFormat( 2947 // m_log.DebugFormat(
3667// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", 2948 // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
3668// Name, LocalId, rot); 2949 // Name, LocalId, rot);
3669 2950
3670 Quaternion axRot = rot; 2951 Quaternion axRot = rot;
3671 Quaternion oldParentRot = m_rootPart.RotationOffset; 2952 Quaternion oldParentRot = m_rootPart.RotationOffset;
3672 2953
3673 m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); 2954 m_rootPart.StoreUndoState();
3674 bool cancelUndo = false; 2955 m_rootPart.UpdateRotation(rot);
3675 if (!m_rootPart.Undoing)
3676 {
3677 m_rootPart.Undoing = true;
3678 cancelUndo = true;
3679 }
3680
3681 //Don't use UpdateRotation because it schedules an update prematurely
3682 m_rootPart.RotationOffset = rot;
3683 if (m_rootPart.PhysActor != null) 2956 if (m_rootPart.PhysActor != null)
3684 { 2957 {
3685 m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; 2958 m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset;
@@ -3694,24 +2967,9 @@ namespace OpenSim.Region.Framework.Scenes
3694 { 2967 {
3695 prim.IgnoreUndoUpdate = true; 2968 prim.IgnoreUndoUpdate = true;
3696 Vector3 axPos = prim.OffsetPosition; 2969 Vector3 axPos = prim.OffsetPosition;
3697
3698 axPos *= oldParentRot; 2970 axPos *= oldParentRot;
3699 axPos *= Quaternion.Inverse(axRot); 2971 axPos *= Quaternion.Inverse(axRot);
3700 prim.OffsetPosition = axPos; 2972 prim.OffsetPosition = axPos;
3701<<<<<<< HEAD
3702
3703 prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset);
3704
3705 prim.IgnoreUndoUpdate = false;
3706 }
3707 }
3708 if (cancelUndo == true)
3709 {
3710 m_rootPart.Undoing = false;
3711 }
3712 HasGroupChanged = true;
3713 ScheduleGroupForFullUpdate();
3714=======
3715 Quaternion primsRot = prim.RotationOffset; 2973 Quaternion primsRot = prim.RotationOffset;
3716 Quaternion newRot = primsRot * oldParentRot; 2974 Quaternion newRot = primsRot * oldParentRot;
3717 newRot *= Quaternion.Inverse(axRot); 2975 newRot *= Quaternion.Inverse(axRot);
@@ -3721,22 +2979,21 @@ namespace OpenSim.Region.Framework.Scenes
3721 } 2979 }
3722 } 2980 }
3723 2981
3724// for (int i = 0; i < parts.Length; i++) 2982 // for (int i = 0; i < parts.Length; i++)
3725// { 2983 // {
3726// SceneObjectPart childpart = parts[i]; 2984 // SceneObjectPart childpart = parts[i];
3727// if (childpart != m_rootPart) 2985 // if (childpart != m_rootPart)
3728// { 2986 // {
3729//// childpart.IgnoreUndoUpdate = false; 2987 //// childpart.IgnoreUndoUpdate = false;
3730//// childpart.StoreUndoState(); 2988 //// childpart.StoreUndoState();
3731// } 2989 // }
3732// } 2990 // }
3733 2991
3734 m_rootPart.ScheduleTerseUpdate(); 2992 m_rootPart.ScheduleTerseUpdate();
3735 2993
3736// m_log.DebugFormat( 2994 // m_log.DebugFormat(
3737// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", 2995 // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}",
3738// Name, LocalId, rot); 2996 // Name, LocalId, rot);
3739>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3740 } 2997 }
3741 2998
3742 #endregion 2999 #endregion
@@ -3807,7 +3064,7 @@ namespace OpenSim.Region.Framework.Scenes
3807 m_scene.AddGroupTarget(this); 3064 m_scene.AddGroupTarget(this);
3808 return (int)handle; 3065 return (int)handle;
3809 } 3066 }
3810 3067
3811 public void unregisterTargetWaypoint(int handle) 3068 public void unregisterTargetWaypoint(int handle)
3812 { 3069 {
3813 lock (m_targets) 3070 lock (m_targets)
@@ -3848,14 +3105,14 @@ namespace OpenSim.Region.Framework.Scenes
3848 } 3105 }
3849 } 3106 }
3850 } 3107 }
3851 3108
3852 if (atTargets.Count > 0) 3109 if (atTargets.Count > 0)
3853 { 3110 {
3854 SceneObjectPart[] parts = m_parts.GetArray(); 3111 SceneObjectPart[] parts = m_parts.GetArray();
3855 uint[] localids = new uint[parts.Length]; 3112 uint[] localids = new uint[parts.Length];
3856 for (int i = 0; i < parts.Length; i++) 3113 for (int i = 0; i < parts.Length; i++)
3857 localids[i] = parts[i].LocalId; 3114 localids[i] = parts[i].LocalId;
3858 3115
3859 for (int ctr = 0; ctr < localids.Length; ctr++) 3116 for (int ctr = 0; ctr < localids.Length; ctr++)
3860 { 3117 {
3861 foreach (uint target in atTargets.Keys) 3118 foreach (uint target in atTargets.Keys)
@@ -3865,10 +3122,10 @@ namespace OpenSim.Region.Framework.Scenes
3865 localids[ctr], att.handle, att.targetPos, m_rootPart.GroupPosition); 3122 localids[ctr], att.handle, att.targetPos, m_rootPart.GroupPosition);
3866 } 3123 }
3867 } 3124 }
3868 3125
3869 return; 3126 return;
3870 } 3127 }
3871 3128
3872 if (m_scriptListens_notAtTarget && !at_target) 3129 if (m_scriptListens_notAtTarget && !at_target)
3873 { 3130 {
3874 //trigger not_at_target 3131 //trigger not_at_target
@@ -3876,7 +3133,7 @@ namespace OpenSim.Region.Framework.Scenes
3876 uint[] localids = new uint[parts.Length]; 3133 uint[] localids = new uint[parts.Length];
3877 for (int i = 0; i < parts.Length; i++) 3134 for (int i = 0; i < parts.Length; i++)
3878 localids[i] = parts[i].LocalId; 3135 localids[i] = parts[i].LocalId;
3879 3136
3880 for (int ctr = 0; ctr < localids.Length; ctr++) 3137 for (int ctr = 0; ctr < localids.Length; ctr++)
3881 { 3138 {
3882 m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); 3139 m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]);
@@ -3956,10 +3213,11 @@ namespace OpenSim.Region.Framework.Scenes
3956 } 3213 }
3957 } 3214 }
3958 } 3215 }
3959 3216
3960 public float GetMass() 3217 public float GetMass()
3961 { 3218 {
3962 float retmass = 0f; 3219 float retmass = 0f;
3220
3963 SceneObjectPart[] parts = m_parts.GetArray(); 3221 SceneObjectPart[] parts = m_parts.GetArray();
3964 for (int i = 0; i < parts.Length; i++) 3222 for (int i = 0; i < parts.Length; i++)
3965 retmass += parts[i].GetMass(); 3223 retmass += parts[i].GetMass();
@@ -3982,7 +3240,7 @@ namespace OpenSim.Region.Framework.Scenes
3982 if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) 3240 if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0)
3983 return; 3241 return;
3984 3242
3985// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); 3243 // m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
3986 3244
3987 SceneObjectPart[] parts = m_parts.GetArray(); 3245 SceneObjectPart[] parts = m_parts.GetArray();
3988 3246
@@ -4016,14 +3274,14 @@ namespace OpenSim.Region.Framework.Scenes
4016 for (int i = 0; i < parts.Length; i++) 3274 for (int i = 0; i < parts.Length; i++)
4017 parts[i].TriggerScriptChangedEvent(val); 3275 parts[i].TriggerScriptChangedEvent(val);
4018 } 3276 }
4019 3277
4020 public override string ToString() 3278 public override string ToString()
4021 { 3279 {
4022 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 3280 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
4023 } 3281 }
4024 3282
4025 #region ISceneObject 3283 #region ISceneObject
4026 3284
4027 public virtual ISceneObject CloneForNewScene() 3285 public virtual ISceneObject CloneForNewScene()
4028 { 3286 {
4029 SceneObjectGroup sog = Copy(false); 3287 SceneObjectGroup sog = Copy(false);
@@ -4053,14 +3311,6 @@ namespace OpenSim.Region.Framework.Scenes
4053 SetFromItemID(uuid); 3311 SetFromItemID(uuid);
4054 } 3312 }
4055 3313
4056 public void ResetOwnerChangeFlag()
4057 {
4058 ForEachPart(delegate(SceneObjectPart part)
4059 {
4060 part.ResetOwnerChangeFlag();
4061 });
4062 }
4063
4064 #endregion 3314 #endregion
4065 } 3315 }
4066} 3316} \ No newline at end of file