diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1350 |
1 files changed, 1129 insertions, 221 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 20d7a01..46a7e3d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -24,11 +24,12 @@ | |||
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Diagnostics; | ||
32 | using System.Linq; | 33 | using System.Linq; |
33 | using System.Threading; | 34 | using System.Threading; |
34 | using System.Xml; | 35 | using System.Xml; |
@@ -42,6 +43,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.Framework.Scenes | 44 | namespace OpenSim.Region.Framework.Scenes |
44 | { | 45 | { |
46 | |||
45 | [Flags] | 47 | [Flags] |
46 | public enum scriptEvents | 48 | public enum scriptEvents |
47 | { | 49 | { |
@@ -105,8 +107,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
105 | /// since the group's last persistent backup | 107 | /// since the group's last persistent backup |
106 | /// </summary> | 108 | /// </summary> |
107 | private bool m_hasGroupChanged = false; | 109 | private bool m_hasGroupChanged = false; |
108 | private long timeFirstChanged; | 110 | private long timeFirstChanged = 0; |
109 | private long timeLastChanged; | 111 | private long timeLastChanged = 0; |
112 | private long m_maxPersistTime = 0; | ||
113 | private long m_minPersistTime = 0; | ||
114 | private Random m_rand; | ||
115 | private bool m_suspendUpdates; | ||
116 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
117 | |||
118 | public bool areUpdatesSuspended | ||
119 | { | ||
120 | get | ||
121 | { | ||
122 | return m_suspendUpdates; | ||
123 | } | ||
124 | set | ||
125 | { | ||
126 | m_suspendUpdates = value; | ||
127 | if (!value) | ||
128 | { | ||
129 | QueueForUpdateCheck(); | ||
130 | } | ||
131 | } | ||
132 | } | ||
110 | 133 | ||
111 | public bool HasGroupChanged | 134 | public bool HasGroupChanged |
112 | { | 135 | { |
@@ -114,9 +137,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
114 | { | 137 | { |
115 | if (value) | 138 | if (value) |
116 | { | 139 | { |
140 | if (m_isBackedUp) | ||
141 | { | ||
142 | m_scene.SceneGraph.FireChangeBackup(this); | ||
143 | } | ||
117 | timeLastChanged = DateTime.Now.Ticks; | 144 | timeLastChanged = DateTime.Now.Ticks; |
118 | if (!m_hasGroupChanged) | 145 | if (!m_hasGroupChanged) |
119 | timeFirstChanged = DateTime.Now.Ticks; | 146 | timeFirstChanged = DateTime.Now.Ticks; |
147 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
148 | { | ||
149 | if (m_rand == null) | ||
150 | { | ||
151 | byte[] val = new byte[16]; | ||
152 | m_rootPart.UUID.ToBytes(val, 0); | ||
153 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
154 | } | ||
155 | |||
156 | if (m_scene.GetRootAgentCount() == 0) | ||
157 | { | ||
158 | //If the region is empty, this change has been made by an automated process | ||
159 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
160 | |||
161 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
162 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
163 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
168 | //but add a random factor so we stagger the object persistance a little | ||
169 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
170 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
171 | } | ||
172 | } | ||
120 | } | 173 | } |
121 | m_hasGroupChanged = value; | 174 | m_hasGroupChanged = value; |
122 | 175 | ||
@@ -131,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since | 184 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since |
132 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. | 185 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. |
133 | /// </summary> | 186 | /// </summary> |
134 | public bool HasGroupChangedDueToDelink { get; private set; } | 187 | public bool HasGroupChangedDueToDelink { get; set; } |
135 | 188 | ||
136 | private bool isTimeToPersist() | 189 | private bool isTimeToPersist() |
137 | { | 190 | { |
@@ -141,8 +194,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | return false; | 194 | return false; |
142 | if (m_scene.ShuttingDown) | 195 | if (m_scene.ShuttingDown) |
143 | return true; | 196 | return true; |
197 | |||
198 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
199 | { | ||
200 | m_maxPersistTime = m_scene.m_persistAfter; | ||
201 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
202 | } | ||
203 | |||
144 | long currentTime = DateTime.Now.Ticks; | 204 | long currentTime = DateTime.Now.Ticks; |
145 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 205 | |
206 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
207 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
208 | |||
209 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
146 | return true; | 210 | return true; |
147 | return false; | 211 | return false; |
148 | } | 212 | } |
@@ -245,10 +309,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
245 | 309 | ||
246 | private bool m_scriptListens_atTarget; | 310 | private bool m_scriptListens_atTarget; |
247 | private bool m_scriptListens_notAtTarget; | 311 | private bool m_scriptListens_notAtTarget; |
248 | |||
249 | private bool m_scriptListens_atRotTarget; | 312 | private bool m_scriptListens_atRotTarget; |
250 | private bool m_scriptListens_notAtRotTarget; | 313 | private bool m_scriptListens_notAtRotTarget; |
251 | 314 | ||
315 | public bool m_dupeInProgress = false; | ||
252 | internal Dictionary<UUID, string> m_savedScriptState; | 316 | internal Dictionary<UUID, string> m_savedScriptState; |
253 | 317 | ||
254 | #region Properties | 318 | #region Properties |
@@ -285,6 +349,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
285 | get { return m_parts.Count; } | 349 | get { return m_parts.Count; } |
286 | } | 350 | } |
287 | 351 | ||
352 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
353 | // | ||
354 | // public virtual Quaternion Rotation | ||
355 | // { | ||
356 | // get { return m_rotation; } | ||
357 | // set { | ||
358 | // m_rotation = value; | ||
359 | // } | ||
360 | // } | ||
361 | |||
288 | public Quaternion GroupRotation | 362 | public Quaternion GroupRotation |
289 | { | 363 | { |
290 | get { return m_rootPart.RotationOffset; } | 364 | get { return m_rootPart.RotationOffset; } |
@@ -391,7 +465,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
391 | { | 465 | { |
392 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 466 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); |
393 | } | 467 | } |
394 | 468 | ||
469 | |||
470 | |||
471 | private struct avtocrossInfo | ||
472 | { | ||
473 | public ScenePresence av; | ||
474 | public uint ParentID; | ||
475 | } | ||
476 | |||
395 | /// <summary> | 477 | /// <summary> |
396 | /// The absolute position of this scene object in the scene | 478 | /// The absolute position of this scene object in the scene |
397 | /// </summary> | 479 | /// </summary> |
@@ -404,14 +486,128 @@ namespace OpenSim.Region.Framework.Scenes | |||
404 | 486 | ||
405 | if (Scene != null) | 487 | if (Scene != null) |
406 | { | 488 | { |
407 | if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) | 489 | // if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) |
408 | || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) | 490 | // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) |
491 | // && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | ||
492 | if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) | ||
493 | || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) | ||
409 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | 494 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) |
410 | { | 495 | { |
411 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 496 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
497 | uint x = 0; | ||
498 | uint y = 0; | ||
499 | string version = String.Empty; | ||
500 | Vector3 newpos = Vector3.Zero; | ||
501 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
502 | |||
503 | bool canCross = true; | ||
504 | foreach (ScenePresence av in m_linkedAvatars) | ||
505 | { | ||
506 | // We need to cross these agents. First, let's find | ||
507 | // out if any of them can't cross for some reason. | ||
508 | // We have to deny the crossing entirely if any | ||
509 | // of them are banned. Alternatively, we could | ||
510 | // unsit banned agents.... | ||
511 | |||
512 | |||
513 | // We set the avatar position as being the object | ||
514 | // position to get the region to send to | ||
515 | if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) | ||
516 | { | ||
517 | canCross = false; | ||
518 | break; | ||
519 | } | ||
520 | |||
521 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
522 | } | ||
523 | |||
524 | if (canCross) | ||
525 | { | ||
526 | // We unparent the SP quietly so that it won't | ||
527 | // be made to stand up | ||
528 | |||
529 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
530 | |||
531 | foreach (ScenePresence av in m_linkedAvatars) | ||
532 | { | ||
533 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
534 | SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); | ||
535 | if (parentPart != null) | ||
536 | av.ParentUUID = parentPart.UUID; | ||
537 | |||
538 | avinfo.av = av; | ||
539 | avinfo.ParentID = av.ParentID; | ||
540 | avsToCross.Add(avinfo); | ||
541 | |||
542 | av.ParentID = 0; | ||
543 | } | ||
544 | |||
545 | // m_linkedAvatars.Clear(); | ||
546 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | ||
547 | |||
548 | // Normalize | ||
549 | if (val.X >= Constants.RegionSize) | ||
550 | val.X -= Constants.RegionSize; | ||
551 | if (val.Y >= Constants.RegionSize) | ||
552 | val.Y -= Constants.RegionSize; | ||
553 | if (val.X < 0) | ||
554 | val.X += Constants.RegionSize; | ||
555 | if (val.Y < 0) | ||
556 | val.Y += Constants.RegionSize; | ||
557 | |||
558 | // If it's deleted, crossing was successful | ||
559 | if (IsDeleted) | ||
560 | { | ||
561 | // foreach (ScenePresence av in m_linkedAvatars) | ||
562 | foreach (avtocrossInfo avinfo in avsToCross) | ||
563 | { | ||
564 | ScenePresence av = avinfo.av; | ||
565 | if (!av.IsInTransit) // just in case... | ||
566 | { | ||
567 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
568 | |||
569 | av.IsInTransit = true; | ||
570 | |||
571 | CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
572 | d.BeginInvoke(av, val, x, y, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
573 | } | ||
574 | else | ||
575 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); | ||
576 | } | ||
577 | avsToCross.Clear(); | ||
578 | return; | ||
579 | } | ||
580 | else // cross failed, put avas back ?? | ||
581 | { | ||
582 | foreach (avtocrossInfo avinfo in avsToCross) | ||
583 | { | ||
584 | ScenePresence av = avinfo.av; | ||
585 | av.ParentUUID = UUID.Zero; | ||
586 | av.ParentID = avinfo.ParentID; | ||
587 | // m_linkedAvatars.Add(av); | ||
588 | } | ||
589 | } | ||
590 | avsToCross.Clear(); | ||
591 | |||
592 | } | ||
593 | else if (RootPart.PhysActor != null) | ||
594 | { | ||
595 | RootPart.PhysActor.CrossingFailure(); | ||
596 | } | ||
597 | |||
598 | Vector3 oldp = AbsolutePosition; | ||
599 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
600 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
601 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); | ||
412 | } | 602 | } |
413 | } | 603 | } |
414 | 604 | ||
605 | /* don't see the need but worse don't see where is restored to false if things stay in | ||
606 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
607 | { | ||
608 | part.IgnoreUndoUpdate = true; | ||
609 | } | ||
610 | */ | ||
415 | if (RootPart.GetStatusSandbox()) | 611 | if (RootPart.GetStatusSandbox()) |
416 | { | 612 | { |
417 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 613 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -425,10 +621,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
425 | return; | 621 | return; |
426 | } | 622 | } |
427 | } | 623 | } |
428 | |||
429 | SceneObjectPart[] parts = m_parts.GetArray(); | 624 | SceneObjectPart[] parts = m_parts.GetArray(); |
430 | for (int i = 0; i < parts.Length; i++) | 625 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
431 | parts[i].GroupPosition = val; | 626 | if (m_dupeInProgress) |
627 | triggerScriptEvent = false; | ||
628 | foreach (SceneObjectPart part in parts) | ||
629 | { | ||
630 | part.GroupPosition = val; | ||
631 | if (triggerScriptEvent) | ||
632 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
633 | } | ||
634 | if (!m_dupeInProgress) | ||
635 | { | ||
636 | foreach (ScenePresence av in m_linkedAvatars) | ||
637 | { | ||
638 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
639 | if (p != null && m_parts.TryGetValue(p.UUID, out p)) | ||
640 | { | ||
641 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
642 | av.AbsolutePosition += offset; | ||
643 | av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
644 | av.SendAvatarDataToAllAgents(); | ||
645 | } | ||
646 | } | ||
647 | } | ||
432 | 648 | ||
433 | //if (m_rootPart.PhysActor != null) | 649 | //if (m_rootPart.PhysActor != null) |
434 | //{ | 650 | //{ |
@@ -443,6 +659,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | } | 659 | } |
444 | } | 660 | } |
445 | 661 | ||
662 | public override Vector3 Velocity | ||
663 | { | ||
664 | get { return RootPart.Velocity; } | ||
665 | set { RootPart.Velocity = value; } | ||
666 | } | ||
667 | |||
668 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
669 | { | ||
670 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
671 | ScenePresence agent = icon.EndInvoke(iar); | ||
672 | |||
673 | //// If the cross was successful, this agent is a child agent | ||
674 | if (agent.IsChildAgent) | ||
675 | { | ||
676 | if (agent.ParentUUID != UUID.Zero) | ||
677 | { | ||
678 | agent.ParentPart = null; | ||
679 | agent.ParentPosition = Vector3.Zero; | ||
680 | // agent.ParentUUID = UUID.Zero; | ||
681 | } | ||
682 | } | ||
683 | |||
684 | agent.ParentUUID = UUID.Zero; | ||
685 | |||
686 | // agent.Reset(); | ||
687 | // else // Not successful | ||
688 | // agent.RestoreInCurrentScene(); | ||
689 | |||
690 | // In any case | ||
691 | agent.IsInTransit = false; | ||
692 | |||
693 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
694 | } | ||
695 | |||
446 | public override uint LocalId | 696 | public override uint LocalId |
447 | { | 697 | { |
448 | get { return m_rootPart.LocalId; } | 698 | get { return m_rootPart.LocalId; } |
@@ -513,6 +763,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
513 | m_isSelected = value; | 763 | m_isSelected = value; |
514 | // Tell physics engine that group is selected | 764 | // Tell physics engine that group is selected |
515 | 765 | ||
766 | // this is not right | ||
767 | // but ode engines should only really need to know about root part | ||
768 | // so they can put entire object simulation on hold and not colliding | ||
769 | // keep as was for now | ||
770 | |||
516 | PhysicsActor pa = m_rootPart.PhysActor; | 771 | PhysicsActor pa = m_rootPart.PhysActor; |
517 | if (pa != null) | 772 | if (pa != null) |
518 | { | 773 | { |
@@ -529,6 +784,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
529 | childPa.Selected = value; | 784 | childPa.Selected = value; |
530 | } | 785 | } |
531 | } | 786 | } |
787 | if (RootPart.KeyframeMotion != null) | ||
788 | RootPart.KeyframeMotion.Selected = value; | ||
789 | } | ||
790 | } | ||
791 | |||
792 | public void PartSelectChanged(bool partSelect) | ||
793 | { | ||
794 | // any part selected makes group selected | ||
795 | if (m_isSelected == partSelect) | ||
796 | return; | ||
797 | |||
798 | if (partSelect) | ||
799 | { | ||
800 | IsSelected = partSelect; | ||
801 | // if (!IsAttachment) | ||
802 | // ScheduleGroupForFullUpdate(); | ||
803 | } | ||
804 | else | ||
805 | { | ||
806 | // bad bad bad 2 heavy for large linksets | ||
807 | // since viewer does send lot of (un)selects | ||
808 | // this needs to be replaced by a specific list or count ? | ||
809 | // but that will require extra code in several places | ||
810 | |||
811 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
812 | for (int i = 0; i < parts.Length; i++) | ||
813 | { | ||
814 | SceneObjectPart part = parts[i]; | ||
815 | if (part.IsSelected) | ||
816 | return; | ||
817 | } | ||
818 | IsSelected = partSelect; | ||
819 | if (!IsAttachment) | ||
820 | { | ||
821 | ScheduleGroupForFullUpdate(); | ||
822 | } | ||
532 | } | 823 | } |
533 | } | 824 | } |
534 | 825 | ||
@@ -606,6 +897,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
606 | /// </summary> | 897 | /// </summary> |
607 | public SceneObjectGroup() | 898 | public SceneObjectGroup() |
608 | { | 899 | { |
900 | |||
609 | } | 901 | } |
610 | 902 | ||
611 | /// <summary> | 903 | /// <summary> |
@@ -622,7 +914,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
622 | /// Constructor. This object is added to the scene later via AttachToScene() | 914 | /// Constructor. This object is added to the scene later via AttachToScene() |
623 | /// </summary> | 915 | /// </summary> |
624 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 916 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
625 | { | 917 | { |
626 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 918 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
627 | } | 919 | } |
628 | 920 | ||
@@ -658,6 +950,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
658 | /// </summary> | 950 | /// </summary> |
659 | public virtual void AttachToBackup() | 951 | public virtual void AttachToBackup() |
660 | { | 952 | { |
953 | if (IsAttachment) return; | ||
954 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
955 | |||
661 | if (InSceneBackup) | 956 | if (InSceneBackup) |
662 | { | 957 | { |
663 | //m_log.DebugFormat( | 958 | //m_log.DebugFormat( |
@@ -700,6 +995,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | 995 | ||
701 | ApplyPhysics(); | 996 | ApplyPhysics(); |
702 | 997 | ||
998 | if (RootPart.PhysActor != null) | ||
999 | RootPart.Force = RootPart.Force; | ||
1000 | if (RootPart.PhysActor != null) | ||
1001 | RootPart.Torque = RootPart.Torque; | ||
1002 | if (RootPart.PhysActor != null) | ||
1003 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1004 | |||
703 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1005 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
704 | // for the same object with very different properties. The caller must schedule the update. | 1006 | // for the same object with very different properties. The caller must schedule the update. |
705 | //ScheduleGroupForFullUpdate(); | 1007 | //ScheduleGroupForFullUpdate(); |
@@ -715,6 +1017,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
715 | EntityIntersection result = new EntityIntersection(); | 1017 | EntityIntersection result = new EntityIntersection(); |
716 | 1018 | ||
717 | SceneObjectPart[] parts = m_parts.GetArray(); | 1019 | SceneObjectPart[] parts = m_parts.GetArray(); |
1020 | |||
1021 | // Find closest hit here | ||
1022 | float idist = float.MaxValue; | ||
1023 | |||
718 | for (int i = 0; i < parts.Length; i++) | 1024 | for (int i = 0; i < parts.Length; i++) |
719 | { | 1025 | { |
720 | SceneObjectPart part = parts[i]; | 1026 | SceneObjectPart part = parts[i]; |
@@ -729,11 +1035,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
729 | 1035 | ||
730 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1036 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
731 | 1037 | ||
732 | // This may need to be updated to the maximum draw distance possible.. | ||
733 | // We might (and probably will) be checking for prim creation from other sims | ||
734 | // when the camera crosses the border. | ||
735 | float idist = Constants.RegionSize; | ||
736 | |||
737 | if (inter.HitTF) | 1038 | if (inter.HitTF) |
738 | { | 1039 | { |
739 | // We need to find the closest prim to return to the testcaller along the ray | 1040 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -744,10 +1045,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
744 | result.obj = part; | 1045 | result.obj = part; |
745 | result.normal = inter.normal; | 1046 | result.normal = inter.normal; |
746 | result.distance = inter.distance; | 1047 | result.distance = inter.distance; |
1048 | |||
1049 | idist = inter.distance; | ||
747 | } | 1050 | } |
748 | } | 1051 | } |
749 | } | 1052 | } |
750 | |||
751 | return result; | 1053 | return result; |
752 | } | 1054 | } |
753 | 1055 | ||
@@ -759,25 +1061,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
759 | /// <returns></returns> | 1061 | /// <returns></returns> |
760 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1062 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
761 | { | 1063 | { |
762 | maxX = -256f; | 1064 | maxX = float.MinValue; |
763 | maxY = -256f; | 1065 | maxY = float.MinValue; |
764 | maxZ = -256f; | 1066 | maxZ = float.MinValue; |
765 | minX = 256f; | 1067 | minX = float.MaxValue; |
766 | minY = 256f; | 1068 | minY = float.MaxValue; |
767 | minZ = 8192f; | 1069 | minZ = float.MaxValue; |
768 | 1070 | ||
769 | SceneObjectPart[] parts = m_parts.GetArray(); | 1071 | SceneObjectPart[] parts = m_parts.GetArray(); |
770 | for (int i = 0; i < parts.Length; i++) | 1072 | foreach (SceneObjectPart part in parts) |
771 | { | 1073 | { |
772 | SceneObjectPart part = parts[i]; | ||
773 | |||
774 | Vector3 worldPos = part.GetWorldPosition(); | 1074 | Vector3 worldPos = part.GetWorldPosition(); |
775 | Vector3 offset = worldPos - AbsolutePosition; | 1075 | Vector3 offset = worldPos - AbsolutePosition; |
776 | Quaternion worldRot; | 1076 | Quaternion worldRot; |
777 | if (part.ParentID == 0) | 1077 | if (part.ParentID == 0) |
1078 | { | ||
778 | worldRot = part.RotationOffset; | 1079 | worldRot = part.RotationOffset; |
1080 | } | ||
779 | else | 1081 | else |
1082 | { | ||
780 | worldRot = part.GetWorldRotation(); | 1083 | worldRot = part.GetWorldRotation(); |
1084 | } | ||
781 | 1085 | ||
782 | Vector3 frontTopLeft; | 1086 | Vector3 frontTopLeft; |
783 | Vector3 frontTopRight; | 1087 | Vector3 frontTopRight; |
@@ -789,6 +1093,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
789 | Vector3 backBottomLeft; | 1093 | Vector3 backBottomLeft; |
790 | Vector3 backBottomRight; | 1094 | Vector3 backBottomRight; |
791 | 1095 | ||
1096 | // Vector3[] corners = new Vector3[8]; | ||
1097 | |||
792 | Vector3 orig = Vector3.Zero; | 1098 | Vector3 orig = Vector3.Zero; |
793 | 1099 | ||
794 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1100 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -823,6 +1129,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
823 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1129 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
824 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1130 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
825 | 1131 | ||
1132 | |||
1133 | |||
1134 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1135 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1136 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1137 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1138 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1139 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1140 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1141 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1142 | |||
1143 | //for (int i = 0; i < 8; i++) | ||
1144 | //{ | ||
1145 | // corners[i] = corners[i] * worldRot; | ||
1146 | // corners[i] += offset; | ||
1147 | |||
1148 | // if (corners[i].X > maxX) | ||
1149 | // maxX = corners[i].X; | ||
1150 | // if (corners[i].X < minX) | ||
1151 | // minX = corners[i].X; | ||
1152 | |||
1153 | // if (corners[i].Y > maxY) | ||
1154 | // maxY = corners[i].Y; | ||
1155 | // if (corners[i].Y < minY) | ||
1156 | // minY = corners[i].Y; | ||
1157 | |||
1158 | // if (corners[i].Z > maxZ) | ||
1159 | // maxZ = corners[i].Y; | ||
1160 | // if (corners[i].Z < minZ) | ||
1161 | // minZ = corners[i].Z; | ||
1162 | //} | ||
1163 | |||
826 | frontTopLeft = frontTopLeft * worldRot; | 1164 | frontTopLeft = frontTopLeft * worldRot; |
827 | frontTopRight = frontTopRight * worldRot; | 1165 | frontTopRight = frontTopRight * worldRot; |
828 | frontBottomLeft = frontBottomLeft * worldRot; | 1166 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -844,6 +1182,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
844 | backTopLeft += offset; | 1182 | backTopLeft += offset; |
845 | backTopRight += offset; | 1183 | backTopRight += offset; |
846 | 1184 | ||
1185 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1186 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1187 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1188 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1189 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1190 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1191 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1192 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1193 | |||
847 | if (frontTopRight.X > maxX) | 1194 | if (frontTopRight.X > maxX) |
848 | maxX = frontTopRight.X; | 1195 | maxX = frontTopRight.X; |
849 | if (frontTopLeft.X > maxX) | 1196 | if (frontTopLeft.X > maxX) |
@@ -987,17 +1334,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
987 | 1334 | ||
988 | #endregion | 1335 | #endregion |
989 | 1336 | ||
1337 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1338 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1339 | { | ||
1340 | // this information may need to be cached | ||
1341 | |||
1342 | float cost; | ||
1343 | float tmpcost; | ||
1344 | |||
1345 | bool ComplexCost = false; | ||
1346 | |||
1347 | SceneObjectPart p; | ||
1348 | SceneObjectPart[] parts; | ||
1349 | |||
1350 | lock (m_parts) | ||
1351 | { | ||
1352 | parts = m_parts.GetArray(); | ||
1353 | } | ||
1354 | |||
1355 | int nparts = parts.Length; | ||
1356 | |||
1357 | |||
1358 | for (int i = 0; i < nparts; i++) | ||
1359 | { | ||
1360 | p = parts[i]; | ||
1361 | |||
1362 | if (p.UsesComplexCost) | ||
1363 | { | ||
1364 | ComplexCost = true; | ||
1365 | break; | ||
1366 | } | ||
1367 | } | ||
1368 | |||
1369 | if (ComplexCost) | ||
1370 | { | ||
1371 | linksetResCost = 0; | ||
1372 | linksetPhysCost = 0; | ||
1373 | partCost = 0; | ||
1374 | partPhysCost = 0; | ||
1375 | |||
1376 | for (int i = 0; i < nparts; i++) | ||
1377 | { | ||
1378 | p = parts[i]; | ||
1379 | |||
1380 | cost = p.StreamingCost; | ||
1381 | tmpcost = p.SimulationCost; | ||
1382 | if (tmpcost > cost) | ||
1383 | cost = tmpcost; | ||
1384 | tmpcost = p.PhysicsCost; | ||
1385 | if (tmpcost > cost) | ||
1386 | cost = tmpcost; | ||
1387 | |||
1388 | linksetPhysCost += tmpcost; | ||
1389 | linksetResCost += cost; | ||
1390 | |||
1391 | if (p == apart) | ||
1392 | { | ||
1393 | partCost = cost; | ||
1394 | partPhysCost = tmpcost; | ||
1395 | } | ||
1396 | } | ||
1397 | } | ||
1398 | else | ||
1399 | { | ||
1400 | partPhysCost = 1.0f; | ||
1401 | partCost = 1.0f; | ||
1402 | linksetResCost = (float)nparts; | ||
1403 | linksetPhysCost = linksetResCost; | ||
1404 | } | ||
1405 | } | ||
1406 | |||
1407 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1408 | { | ||
1409 | SceneObjectPart p; | ||
1410 | SceneObjectPart[] parts; | ||
1411 | |||
1412 | lock (m_parts) | ||
1413 | { | ||
1414 | parts = m_parts.GetArray(); | ||
1415 | } | ||
1416 | |||
1417 | int nparts = parts.Length; | ||
1418 | |||
1419 | PhysCost = 0; | ||
1420 | StreamCost = 0; | ||
1421 | SimulCost = 0; | ||
1422 | |||
1423 | for (int i = 0; i < nparts; i++) | ||
1424 | { | ||
1425 | p = parts[i]; | ||
1426 | |||
1427 | StreamCost += p.StreamingCost; | ||
1428 | SimulCost += p.SimulationCost; | ||
1429 | PhysCost += p.PhysicsCost; | ||
1430 | } | ||
1431 | } | ||
1432 | |||
990 | public void SaveScriptedState(XmlTextWriter writer) | 1433 | public void SaveScriptedState(XmlTextWriter writer) |
991 | { | 1434 | { |
1435 | SaveScriptedState(writer, false); | ||
1436 | } | ||
1437 | |||
1438 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1439 | { | ||
992 | XmlDocument doc = new XmlDocument(); | 1440 | XmlDocument doc = new XmlDocument(); |
993 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1441 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
994 | 1442 | ||
995 | SceneObjectPart[] parts = m_parts.GetArray(); | 1443 | SceneObjectPart[] parts = m_parts.GetArray(); |
996 | for (int i = 0; i < parts.Length; i++) | 1444 | for (int i = 0; i < parts.Length; i++) |
997 | { | 1445 | { |
998 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1446 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
999 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1447 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1000 | states.Add(kvp.Key, kvp.Value); | 1448 | states[kvp.Key] = kvp.Value; |
1001 | } | 1449 | } |
1002 | 1450 | ||
1003 | if (states.Count > 0) | 1451 | if (states.Count > 0) |
@@ -1017,6 +1465,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
1017 | } | 1465 | } |
1018 | 1466 | ||
1019 | /// <summary> | 1467 | /// <summary> |
1468 | /// Add the avatar to this linkset (avatar is sat). | ||
1469 | /// </summary> | ||
1470 | /// <param name="agentID"></param> | ||
1471 | public void AddAvatar(UUID agentID) | ||
1472 | { | ||
1473 | ScenePresence presence; | ||
1474 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1475 | { | ||
1476 | if (!m_linkedAvatars.Contains(presence)) | ||
1477 | { | ||
1478 | m_linkedAvatars.Add(presence); | ||
1479 | } | ||
1480 | } | ||
1481 | } | ||
1482 | |||
1483 | /// <summary> | ||
1484 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1485 | /// </summary> | ||
1486 | /// <param name="agentID"></param> | ||
1487 | public void DeleteAvatar(UUID agentID) | ||
1488 | { | ||
1489 | ScenePresence presence; | ||
1490 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1491 | { | ||
1492 | if (m_linkedAvatars.Contains(presence)) | ||
1493 | { | ||
1494 | m_linkedAvatars.Remove(presence); | ||
1495 | } | ||
1496 | } | ||
1497 | } | ||
1498 | |||
1499 | /// <summary> | ||
1500 | /// Returns the list of linked presences (avatars sat on this group) | ||
1501 | /// </summary> | ||
1502 | /// <param name="agentID"></param> | ||
1503 | public List<ScenePresence> GetLinkedAvatars() | ||
1504 | { | ||
1505 | return m_linkedAvatars; | ||
1506 | } | ||
1507 | |||
1508 | /// <summary> | ||
1509 | /// Attach this scene object to the given avatar. | ||
1510 | /// </summary> | ||
1511 | /// <param name="agentID"></param> | ||
1512 | /// <param name="attachmentpoint"></param> | ||
1513 | /// <param name="AttachOffset"></param> | ||
1514 | private void AttachToAgent( | ||
1515 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1516 | { | ||
1517 | if (avatar != null) | ||
1518 | { | ||
1519 | // don't attach attachments to child agents | ||
1520 | if (avatar.IsChildAgent) return; | ||
1521 | |||
1522 | // Remove from database and parcel prim count | ||
1523 | m_scene.DeleteFromStorage(so.UUID); | ||
1524 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1525 | |||
1526 | so.AttachedAvatar = avatar.UUID; | ||
1527 | |||
1528 | if (so.RootPart.PhysActor != null) | ||
1529 | { | ||
1530 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1531 | so.RootPart.PhysActor = null; | ||
1532 | } | ||
1533 | |||
1534 | so.AbsolutePosition = attachOffset; | ||
1535 | so.RootPart.AttachedPos = attachOffset; | ||
1536 | so.IsAttachment = true; | ||
1537 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1538 | so.AttachmentPoint = attachmentpoint; | ||
1539 | |||
1540 | avatar.AddAttachment(this); | ||
1541 | |||
1542 | if (!silent) | ||
1543 | { | ||
1544 | // Killing it here will cause the client to deselect it | ||
1545 | // It then reappears on the avatar, deselected | ||
1546 | // through the full update below | ||
1547 | // | ||
1548 | if (IsSelected) | ||
1549 | { | ||
1550 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1551 | } | ||
1552 | |||
1553 | IsSelected = false; // fudge.... | ||
1554 | ScheduleGroupForFullUpdate(); | ||
1555 | } | ||
1556 | } | ||
1557 | else | ||
1558 | { | ||
1559 | m_log.WarnFormat( | ||
1560 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1561 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1562 | } | ||
1563 | } | ||
1564 | |||
1565 | public byte GetAttachmentPoint() | ||
1566 | { | ||
1567 | return m_rootPart.Shape.State; | ||
1568 | } | ||
1569 | |||
1570 | public void DetachToGround() | ||
1571 | { | ||
1572 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1573 | if (avatar == null) | ||
1574 | return; | ||
1575 | |||
1576 | avatar.RemoveAttachment(this); | ||
1577 | |||
1578 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1579 | if (avatar == null) | ||
1580 | return; | ||
1581 | |||
1582 | detachedpos = avatar.AbsolutePosition; | ||
1583 | FromItemID = UUID.Zero; | ||
1584 | |||
1585 | AbsolutePosition = detachedpos; | ||
1586 | AttachedAvatar = UUID.Zero; | ||
1587 | |||
1588 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1589 | //for (int i = 0; i < parts.Length; i++) | ||
1590 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1591 | |||
1592 | m_rootPart.SetParentLocalId(0); | ||
1593 | AttachmentPoint = (byte)0; | ||
1594 | // must check if buildind should be true or false here | ||
1595 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1596 | HasGroupChanged = true; | ||
1597 | RootPart.Rezzed = DateTime.Now; | ||
1598 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1599 | AttachToBackup(); | ||
1600 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1601 | m_rootPart.ScheduleFullUpdate(); | ||
1602 | m_rootPart.ClearUndoState(); | ||
1603 | } | ||
1604 | |||
1605 | public void DetachToInventoryPrep() | ||
1606 | { | ||
1607 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1608 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1609 | if (avatar != null) | ||
1610 | { | ||
1611 | //detachedpos = avatar.AbsolutePosition; | ||
1612 | avatar.RemoveAttachment(this); | ||
1613 | } | ||
1614 | |||
1615 | AttachedAvatar = UUID.Zero; | ||
1616 | |||
1617 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1618 | for (int i = 0; i < parts.Length; i++) | ||
1619 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1620 | |||
1621 | m_rootPart.SetParentLocalId(0); | ||
1622 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1623 | IsAttachment = false; | ||
1624 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1625 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1626 | //AttachToBackup(); | ||
1627 | //m_rootPart.ScheduleFullUpdate(); | ||
1628 | } | ||
1629 | |||
1630 | /// <summary> | ||
1020 | /// | 1631 | /// |
1021 | /// </summary> | 1632 | /// </summary> |
1022 | /// <param name="part"></param> | 1633 | /// <param name="part"></param> |
@@ -1066,7 +1677,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1066 | public void AddPart(SceneObjectPart part) | 1677 | public void AddPart(SceneObjectPart part) |
1067 | { | 1678 | { |
1068 | part.SetParent(this); | 1679 | part.SetParent(this); |
1069 | part.LinkNum = m_parts.Add(part.UUID, part); | 1680 | m_parts.Add(part.UUID, part); |
1681 | |||
1682 | part.LinkNum = m_parts.Count; | ||
1683 | |||
1070 | if (part.LinkNum == 2) | 1684 | if (part.LinkNum == 2) |
1071 | RootPart.LinkNum = 1; | 1685 | RootPart.LinkNum = 1; |
1072 | } | 1686 | } |
@@ -1154,7 +1768,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1154 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 1768 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1155 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 1769 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1156 | 1770 | ||
1157 | part.StoreUndoState(); | 1771 | // part.StoreUndoState(); |
1158 | part.OnGrab(offsetPos, remoteClient); | 1772 | part.OnGrab(offsetPos, remoteClient); |
1159 | } | 1773 | } |
1160 | 1774 | ||
@@ -1174,6 +1788,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1174 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1788 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1175 | public void DeleteGroupFromScene(bool silent) | 1789 | public void DeleteGroupFromScene(bool silent) |
1176 | { | 1790 | { |
1791 | // We need to keep track of this state in case this group is still queued for backup. | ||
1792 | IsDeleted = true; | ||
1793 | |||
1794 | DetachFromBackup(); | ||
1795 | |||
1177 | SceneObjectPart[] parts = m_parts.GetArray(); | 1796 | SceneObjectPart[] parts = m_parts.GetArray(); |
1178 | for (int i = 0; i < parts.Length; i++) | 1797 | for (int i = 0; i < parts.Length; i++) |
1179 | { | 1798 | { |
@@ -1189,13 +1808,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1189 | part.ClearUpdateSchedule(); | 1808 | part.ClearUpdateSchedule(); |
1190 | if (part == m_rootPart) | 1809 | if (part == m_rootPart) |
1191 | { | 1810 | { |
1192 | if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || | 1811 | if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || |
1193 | (AttachmentPoint < 31) || (AttachmentPoint > 38)) | 1812 | (AttachmentPoint < 31) || (AttachmentPoint > 38)) |
1194 | avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint> { part.LocalId }); | 1813 | avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint> { part.LocalId }); |
1195 | } | 1814 | } |
1196 | } | 1815 | } |
1197 | }); | 1816 | }); |
1198 | } | 1817 | } |
1818 | |||
1199 | } | 1819 | } |
1200 | 1820 | ||
1201 | public void AddScriptLPS(int count) | 1821 | public void AddScriptLPS(int count) |
@@ -1265,28 +1885,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1265 | /// </summary> | 1885 | /// </summary> |
1266 | public void ApplyPhysics() | 1886 | public void ApplyPhysics() |
1267 | { | 1887 | { |
1268 | // Apply physics to the root prim | ||
1269 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1270 | |||
1271 | // Apply physics to child prims | ||
1272 | SceneObjectPart[] parts = m_parts.GetArray(); | 1888 | SceneObjectPart[] parts = m_parts.GetArray(); |
1273 | if (parts.Length > 1) | 1889 | if (parts.Length > 1) |
1274 | { | 1890 | { |
1891 | ResetChildPrimPhysicsPositions(); | ||
1892 | |||
1893 | // Apply physics to the root prim | ||
1894 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1895 | |||
1896 | |||
1275 | for (int i = 0; i < parts.Length; i++) | 1897 | for (int i = 0; i < parts.Length; i++) |
1276 | { | 1898 | { |
1277 | SceneObjectPart part = parts[i]; | 1899 | SceneObjectPart part = parts[i]; |
1278 | if (part.LocalId != m_rootPart.LocalId) | 1900 | if (part.LocalId != m_rootPart.LocalId) |
1279 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1901 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1280 | } | 1902 | } |
1281 | |||
1282 | // Hack to get the physics scene geometries in the right spot | 1903 | // Hack to get the physics scene geometries in the right spot |
1283 | ResetChildPrimPhysicsPositions(); | 1904 | // ResetChildPrimPhysicsPositions(); |
1905 | if (m_rootPart.PhysActor != null) | ||
1906 | { | ||
1907 | m_rootPart.PhysActor.Building = false; | ||
1908 | } | ||
1909 | } | ||
1910 | else | ||
1911 | { | ||
1912 | // Apply physics to the root prim | ||
1913 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1284 | } | 1914 | } |
1285 | } | 1915 | } |
1286 | 1916 | ||
1287 | public void SetOwnerId(UUID userId) | 1917 | public void SetOwnerId(UUID userId) |
1288 | { | 1918 | { |
1289 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 1919 | ForEachPart(delegate(SceneObjectPart part) |
1920 | { | ||
1921 | |||
1922 | part.OwnerID = userId; | ||
1923 | |||
1924 | }); | ||
1290 | } | 1925 | } |
1291 | 1926 | ||
1292 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 1927 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1318,11 +1953,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1318 | return; | 1953 | return; |
1319 | } | 1954 | } |
1320 | 1955 | ||
1956 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
1957 | return; | ||
1958 | |||
1321 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 1959 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1322 | // any exception propogate upwards. | 1960 | // any exception propogate upwards. |
1323 | try | 1961 | try |
1324 | { | 1962 | { |
1325 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 1963 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
1964 | m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things | ||
1965 | m_scene.LoadingPrims) // Land may not be valid yet | ||
1966 | |||
1326 | { | 1967 | { |
1327 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 1968 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1328 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 1969 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1349,6 +1990,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1349 | } | 1990 | } |
1350 | } | 1991 | } |
1351 | } | 1992 | } |
1993 | |||
1352 | } | 1994 | } |
1353 | 1995 | ||
1354 | if (m_scene.UseBackup && HasGroupChanged) | 1996 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1356,10 +1998,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1356 | // don't backup while it's selected or you're asking for changes mid stream. | 1998 | // don't backup while it's selected or you're asking for changes mid stream. |
1357 | if (isTimeToPersist() || forcedBackup) | 1999 | if (isTimeToPersist() || forcedBackup) |
1358 | { | 2000 | { |
2001 | if (m_rootPart.PhysActor != null && | ||
2002 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2003 | { | ||
2004 | // Possible ghost prim | ||
2005 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2006 | { | ||
2007 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2008 | { | ||
2009 | // Re-set physics actor positions and | ||
2010 | // orientations | ||
2011 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2012 | } | ||
2013 | } | ||
2014 | } | ||
1359 | // m_log.DebugFormat( | 2015 | // m_log.DebugFormat( |
1360 | // "[SCENE]: Storing {0}, {1} in {2}", | 2016 | // "[SCENE]: Storing {0}, {1} in {2}", |
1361 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2017 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1362 | 2018 | ||
2019 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2020 | { | ||
2021 | RootPart.Shape.State = 0; | ||
2022 | ScheduleGroupForFullUpdate(); | ||
2023 | } | ||
2024 | |||
1363 | SceneObjectGroup backup_group = Copy(false); | 2025 | SceneObjectGroup backup_group = Copy(false); |
1364 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2026 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1365 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2027 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1373,6 +2035,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | 2035 | ||
1374 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2036 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
1375 | { | 2037 | { |
2038 | if (part.KeyframeMotion != null) | ||
2039 | { | ||
2040 | part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); | ||
2041 | part.KeyframeMotion.UpdateSceneObject(this); | ||
2042 | } | ||
1376 | part.Inventory.ProcessInventoryBackup(datastore); | 2043 | part.Inventory.ProcessInventoryBackup(datastore); |
1377 | }); | 2044 | }); |
1378 | 2045 | ||
@@ -1425,10 +2092,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1425 | /// <returns></returns> | 2092 | /// <returns></returns> |
1426 | public SceneObjectGroup Copy(bool userExposed) | 2093 | public SceneObjectGroup Copy(bool userExposed) |
1427 | { | 2094 | { |
2095 | m_dupeInProgress = true; | ||
1428 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 2096 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1429 | dupe.m_isBackedUp = false; | 2097 | dupe.m_isBackedUp = false; |
1430 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2098 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1431 | 2099 | ||
2100 | // new group as no sitting avatars | ||
2101 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2102 | |||
1432 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 2103 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1433 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 2104 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1434 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 2105 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
@@ -1439,7 +2110,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1439 | // This is only necessary when userExposed is false! | 2110 | // This is only necessary when userExposed is false! |
1440 | 2111 | ||
1441 | bool previousAttachmentStatus = dupe.IsAttachment; | 2112 | bool previousAttachmentStatus = dupe.IsAttachment; |
1442 | 2113 | ||
1443 | if (!userExposed) | 2114 | if (!userExposed) |
1444 | dupe.IsAttachment = true; | 2115 | dupe.IsAttachment = true; |
1445 | 2116 | ||
@@ -1457,11 +2128,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1457 | dupe.m_rootPart.TrimPermissions(); | 2128 | dupe.m_rootPart.TrimPermissions(); |
1458 | 2129 | ||
1459 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2130 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1460 | 2131 | ||
1461 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2132 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1462 | { | 2133 | { |
1463 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2134 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1464 | } | 2135 | } |
1465 | ); | 2136 | ); |
1466 | 2137 | ||
1467 | foreach (SceneObjectPart part in partList) | 2138 | foreach (SceneObjectPart part in partList) |
@@ -1471,41 +2142,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
1471 | { | 2142 | { |
1472 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2143 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1473 | newPart.LinkNum = part.LinkNum; | 2144 | newPart.LinkNum = part.LinkNum; |
1474 | } | 2145 | if (userExposed) |
2146 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2147 | } | ||
1475 | else | 2148 | else |
1476 | { | 2149 | { |
1477 | newPart = dupe.m_rootPart; | 2150 | newPart = dupe.m_rootPart; |
1478 | } | 2151 | } |
2152 | /* | ||
2153 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2154 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1479 | 2155 | ||
1480 | // Need to duplicate the physics actor as well | 2156 | // Need to duplicate the physics actor as well |
1481 | PhysicsActor originalPartPa = part.PhysActor; | 2157 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1482 | if (originalPartPa != null && userExposed) | ||
1483 | { | 2158 | { |
1484 | PrimitiveBaseShape pbs = newPart.Shape; | 2159 | PrimitiveBaseShape pbs = newPart.Shape; |
1485 | |||
1486 | newPart.PhysActor | 2160 | newPart.PhysActor |
1487 | = m_scene.PhysicsScene.AddPrimShape( | 2161 | = m_scene.PhysicsScene.AddPrimShape( |
1488 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2162 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1489 | pbs, | 2163 | pbs, |
1490 | newPart.AbsolutePosition, | 2164 | newPart.AbsolutePosition, |
1491 | newPart.Scale, | 2165 | newPart.Scale, |
1492 | newPart.RotationOffset, | 2166 | newPart.GetWorldRotation(), |
1493 | originalPartPa.IsPhysical, | 2167 | isphys, |
2168 | isphan, | ||
1494 | newPart.LocalId); | 2169 | newPart.LocalId); |
1495 | 2170 | ||
1496 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2171 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1497 | } | 2172 | */ |
2173 | if (userExposed) | ||
2174 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2175 | // } | ||
1498 | } | 2176 | } |
1499 | 2177 | ||
1500 | if (userExposed) | 2178 | if (userExposed) |
1501 | { | 2179 | { |
1502 | dupe.UpdateParentIDs(); | 2180 | // done above dupe.UpdateParentIDs(); |
2181 | |||
2182 | if (dupe.m_rootPart.PhysActor != null) | ||
2183 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2184 | |||
1503 | dupe.HasGroupChanged = true; | 2185 | dupe.HasGroupChanged = true; |
1504 | dupe.AttachToBackup(); | 2186 | dupe.AttachToBackup(); |
1505 | 2187 | ||
1506 | ScheduleGroupForFullUpdate(); | 2188 | ScheduleGroupForFullUpdate(); |
1507 | } | 2189 | } |
1508 | 2190 | ||
2191 | m_dupeInProgress = false; | ||
1509 | return dupe; | 2192 | return dupe; |
1510 | } | 2193 | } |
1511 | 2194 | ||
@@ -1517,11 +2200,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1517 | /// <param name="cGroupID"></param> | 2200 | /// <param name="cGroupID"></param> |
1518 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2201 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1519 | { | 2202 | { |
1520 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2203 | // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); |
2204 | // give newpart a new local ID lettng old part keep same | ||
2205 | SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2206 | newpart.LocalId = m_scene.AllocateLocalId(); | ||
2207 | |||
2208 | SetRootPart(newpart); | ||
2209 | if (userExposed) | ||
2210 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1521 | } | 2211 | } |
1522 | 2212 | ||
1523 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2213 | public void ScriptSetPhysicsStatus(bool usePhysics) |
1524 | { | 2214 | { |
2215 | if (usePhysics) | ||
2216 | { | ||
2217 | if (RootPart.KeyframeMotion != null) | ||
2218 | RootPart.KeyframeMotion.Stop(); | ||
2219 | RootPart.KeyframeMotion = null; | ||
2220 | } | ||
1525 | UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 2221 | UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); |
1526 | } | 2222 | } |
1527 | 2223 | ||
@@ -1569,13 +2265,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1569 | 2265 | ||
1570 | if (pa != null) | 2266 | if (pa != null) |
1571 | { | 2267 | { |
1572 | pa.AddForce(impulse, true); | 2268 | // false to be applied as a impulse |
2269 | pa.AddForce(impulse, false); | ||
1573 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2270 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1574 | } | 2271 | } |
1575 | } | 2272 | } |
1576 | } | 2273 | } |
1577 | 2274 | ||
1578 | public void applyAngularImpulse(Vector3 impulse) | 2275 | public void ApplyAngularImpulse(Vector3 impulse) |
1579 | { | 2276 | { |
1580 | PhysicsActor pa = RootPart.PhysActor; | 2277 | PhysicsActor pa = RootPart.PhysActor; |
1581 | 2278 | ||
@@ -1583,21 +2280,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1583 | { | 2280 | { |
1584 | if (!IsAttachment) | 2281 | if (!IsAttachment) |
1585 | { | 2282 | { |
1586 | pa.AddAngularForce(impulse, true); | 2283 | // false to be applied as a impulse |
1587 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2284 | pa.AddAngularForce(impulse, false); |
1588 | } | ||
1589 | } | ||
1590 | } | ||
1591 | |||
1592 | public void setAngularImpulse(Vector3 impulse) | ||
1593 | { | ||
1594 | PhysicsActor pa = RootPart.PhysActor; | ||
1595 | |||
1596 | if (pa != null) | ||
1597 | { | ||
1598 | if (!IsAttachment) | ||
1599 | { | ||
1600 | pa.Torque = impulse; | ||
1601 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2285 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1602 | } | 2286 | } |
1603 | } | 2287 | } |
@@ -1605,20 +2289,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1605 | 2289 | ||
1606 | public Vector3 GetTorque() | 2290 | public Vector3 GetTorque() |
1607 | { | 2291 | { |
1608 | PhysicsActor pa = RootPart.PhysActor; | 2292 | return RootPart.Torque; |
1609 | |||
1610 | if (pa != null) | ||
1611 | { | ||
1612 | if (!IsAttachment) | ||
1613 | { | ||
1614 | Vector3 torque = pa.Torque; | ||
1615 | return torque; | ||
1616 | } | ||
1617 | } | ||
1618 | |||
1619 | return Vector3.Zero; | ||
1620 | } | 2293 | } |
1621 | 2294 | ||
2295 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1622 | public void moveToTarget(Vector3 target, float tau) | 2296 | public void moveToTarget(Vector3 target, float tau) |
1623 | { | 2297 | { |
1624 | if (IsAttachment) | 2298 | if (IsAttachment) |
@@ -1650,6 +2324,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
1650 | pa.PIDActive = false; | 2324 | pa.PIDActive = false; |
1651 | } | 2325 | } |
1652 | 2326 | ||
2327 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2328 | { | ||
2329 | SceneObjectPart rootpart = m_rootPart; | ||
2330 | if (rootpart != null) | ||
2331 | { | ||
2332 | if (IsAttachment) | ||
2333 | { | ||
2334 | /* | ||
2335 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2336 | if (avatar != null) | ||
2337 | { | ||
2338 | Rotate the Av? | ||
2339 | } */ | ||
2340 | } | ||
2341 | else | ||
2342 | { | ||
2343 | if (rootpart.PhysActor != null) | ||
2344 | { // APID must be implemented in your physics system for this to function. | ||
2345 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2346 | rootpart.PhysActor.APIDStrength = strength; | ||
2347 | rootpart.PhysActor.APIDDamping = damping; | ||
2348 | rootpart.PhysActor.APIDActive = true; | ||
2349 | } | ||
2350 | } | ||
2351 | } | ||
2352 | } | ||
2353 | |||
2354 | public void stopLookAt() | ||
2355 | { | ||
2356 | SceneObjectPart rootpart = m_rootPart; | ||
2357 | if (rootpart != null) | ||
2358 | { | ||
2359 | if (rootpart.PhysActor != null) | ||
2360 | { // APID must be implemented in your physics system for this to function. | ||
2361 | rootpart.PhysActor.APIDActive = false; | ||
2362 | } | ||
2363 | } | ||
2364 | |||
2365 | } | ||
2366 | |||
1653 | /// <summary> | 2367 | /// <summary> |
1654 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2368 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1655 | /// </summary> | 2369 | /// </summary> |
@@ -1666,7 +2380,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1666 | { | 2380 | { |
1667 | pa.PIDHoverHeight = height; | 2381 | pa.PIDHoverHeight = height; |
1668 | pa.PIDHoverType = hoverType; | 2382 | pa.PIDHoverType = hoverType; |
1669 | pa.PIDTau = tau; | 2383 | pa.PIDHoverTau = tau; |
1670 | pa.PIDHoverActive = true; | 2384 | pa.PIDHoverActive = true; |
1671 | } | 2385 | } |
1672 | else | 2386 | else |
@@ -1706,7 +2420,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1706 | /// <param name="cGroupID"></param> | 2420 | /// <param name="cGroupID"></param> |
1707 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2421 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1708 | { | 2422 | { |
1709 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2423 | // give new ID to the new part, letting old keep original |
2424 | // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | ||
2425 | SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2426 | newPart.LocalId = m_scene.AllocateLocalId(); | ||
2427 | newPart.SetParent(this); | ||
2428 | |||
1710 | AddPart(newPart); | 2429 | AddPart(newPart); |
1711 | 2430 | ||
1712 | SetPartAsNonRoot(newPart); | 2431 | SetPartAsNonRoot(newPart); |
@@ -1835,11 +2554,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1835 | /// Immediately send a full update for this scene object. | 2554 | /// Immediately send a full update for this scene object. |
1836 | /// </summary> | 2555 | /// </summary> |
1837 | public void SendGroupFullUpdate() | 2556 | public void SendGroupFullUpdate() |
1838 | { | 2557 | { |
1839 | if (IsDeleted) | 2558 | if (IsDeleted) |
1840 | return; | 2559 | return; |
1841 | 2560 | ||
1842 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2561 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
1843 | 2562 | ||
1844 | RootPart.SendFullUpdateToAllClients(); | 2563 | RootPart.SendFullUpdateToAllClients(); |
1845 | 2564 | ||
@@ -1973,6 +2692,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1973 | 2692 | ||
1974 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2693 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
1975 | 2694 | ||
2695 | if (m_rootPart.PhysActor != null) | ||
2696 | m_rootPart.PhysActor.Building = true; | ||
2697 | if (linkPart.PhysActor != null) | ||
2698 | linkPart.PhysActor.Building = true; | ||
2699 | |||
1976 | // physics flags from group to be applied to linked parts | 2700 | // physics flags from group to be applied to linked parts |
1977 | bool grpusephys = UsesPhysics; | 2701 | bool grpusephys = UsesPhysics; |
1978 | bool grptemporary = IsTemporary; | 2702 | bool grptemporary = IsTemporary; |
@@ -1981,19 +2705,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1981 | Quaternion oldRootRotation = linkPart.RotationOffset; | 2705 | Quaternion oldRootRotation = linkPart.RotationOffset; |
1982 | 2706 | ||
1983 | linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; | 2707 | linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; |
2708 | |||
1984 | linkPart.ParentID = m_rootPart.LocalId; | 2709 | linkPart.ParentID = m_rootPart.LocalId; |
1985 | linkPart.GroupPosition = AbsolutePosition; | 2710 | |
1986 | Vector3 axPos = linkPart.OffsetPosition; | 2711 | linkPart.GroupPosition = AbsolutePosition; |
1987 | 2712 | ||
2713 | Vector3 axPos = linkPart.OffsetPosition; | ||
1988 | Quaternion parentRot = m_rootPart.RotationOffset; | 2714 | Quaternion parentRot = m_rootPart.RotationOffset; |
1989 | axPos *= Quaternion.Inverse(parentRot); | 2715 | axPos *= Quaternion.Conjugate(parentRot); |
1990 | |||
1991 | linkPart.OffsetPosition = axPos; | 2716 | linkPart.OffsetPosition = axPos; |
2717 | |||
1992 | Quaternion oldRot = linkPart.RotationOffset; | 2718 | Quaternion oldRot = linkPart.RotationOffset; |
1993 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2719 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
1994 | linkPart.RotationOffset = newRot; | 2720 | linkPart.RotationOffset = newRot; |
1995 | 2721 | ||
1996 | linkPart.ParentID = m_rootPart.LocalId; | 2722 | // linkPart.ParentID = m_rootPart.LocalId; done above |
1997 | 2723 | ||
1998 | if (m_rootPart.LinkNum == 0) | 2724 | if (m_rootPart.LinkNum == 0) |
1999 | m_rootPart.LinkNum = 1; | 2725 | m_rootPart.LinkNum = 1; |
@@ -2021,7 +2747,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2021 | linkPart.CreateSelected = true; | 2747 | linkPart.CreateSelected = true; |
2022 | 2748 | ||
2023 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2749 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2024 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 2750 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2025 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2751 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
2026 | { | 2752 | { |
2027 | linkPart.PhysActor.link(m_rootPart.PhysActor); | 2753 | linkPart.PhysActor.link(m_rootPart.PhysActor); |
@@ -2029,6 +2755,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2029 | } | 2755 | } |
2030 | 2756 | ||
2031 | linkPart.LinkNum = linkNum++; | 2757 | linkPart.LinkNum = linkNum++; |
2758 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2032 | 2759 | ||
2033 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2760 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2034 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2761 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
@@ -2043,7 +2770,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2043 | { | 2770 | { |
2044 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); | 2771 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); |
2045 | // let physics know | 2772 | // let physics know |
2046 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 2773 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2047 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2774 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
2048 | { | 2775 | { |
2049 | part.PhysActor.link(m_rootPart.PhysActor); | 2776 | part.PhysActor.link(m_rootPart.PhysActor); |
@@ -2058,7 +2785,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2058 | objectGroup.IsDeleted = true; | 2785 | objectGroup.IsDeleted = true; |
2059 | 2786 | ||
2060 | objectGroup.m_parts.Clear(); | 2787 | objectGroup.m_parts.Clear(); |
2061 | 2788 | ||
2062 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2789 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2063 | // objectGroup.m_rootPart = null; | 2790 | // objectGroup.m_rootPart = null; |
2064 | 2791 | ||
@@ -2069,6 +2796,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2069 | // unmoved prims! | 2796 | // unmoved prims! |
2070 | ResetChildPrimPhysicsPositions(); | 2797 | ResetChildPrimPhysicsPositions(); |
2071 | 2798 | ||
2799 | if (m_rootPart.PhysActor != null) | ||
2800 | m_rootPart.PhysActor.Building = false; | ||
2801 | |||
2072 | //HasGroupChanged = true; | 2802 | //HasGroupChanged = true; |
2073 | //ScheduleGroupForFullUpdate(); | 2803 | //ScheduleGroupForFullUpdate(); |
2074 | } | 2804 | } |
@@ -2136,7 +2866,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2136 | // m_log.DebugFormat( | 2866 | // m_log.DebugFormat( |
2137 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 2867 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2138 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 2868 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2139 | 2869 | ||
2870 | if (m_rootPart.PhysActor != null) | ||
2871 | m_rootPart.PhysActor.Building = true; | ||
2872 | |||
2140 | linkPart.ClearUndoState(); | 2873 | linkPart.ClearUndoState(); |
2141 | 2874 | ||
2142 | Quaternion worldRot = linkPart.GetWorldRotation(); | 2875 | Quaternion worldRot = linkPart.GetWorldRotation(); |
@@ -2196,6 +2929,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2196 | 2929 | ||
2197 | // When we delete a group, we currently have to force persist to the database if the object id has changed | 2930 | // When we delete a group, we currently have to force persist to the database if the object id has changed |
2198 | // (since delete works by deleting all rows which have a given object id) | 2931 | // (since delete works by deleting all rows which have a given object id) |
2932 | |||
2933 | // this is as it seems to be in sl now | ||
2934 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
2935 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
2936 | |||
2937 | if (m_rootPart.PhysActor != null) | ||
2938 | m_rootPart.PhysActor.Building = false; | ||
2939 | |||
2199 | objectGroup.HasGroupChangedDueToDelink = true; | 2940 | objectGroup.HasGroupChangedDueToDelink = true; |
2200 | 2941 | ||
2201 | return objectGroup; | 2942 | return objectGroup; |
@@ -2207,6 +2948,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2207 | /// <param name="objectGroup"></param> | 2948 | /// <param name="objectGroup"></param> |
2208 | public virtual void DetachFromBackup() | 2949 | public virtual void DetachFromBackup() |
2209 | { | 2950 | { |
2951 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2210 | if (m_isBackedUp && Scene != null) | 2952 | if (m_isBackedUp && Scene != null) |
2211 | m_scene.EventManager.OnBackup -= ProcessBackup; | 2953 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2212 | 2954 | ||
@@ -2225,7 +2967,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2225 | 2967 | ||
2226 | axPos *= parentRot; | 2968 | axPos *= parentRot; |
2227 | part.OffsetPosition = axPos; | 2969 | part.OffsetPosition = axPos; |
2228 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 2970 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
2971 | part.GroupPosition = newPos; | ||
2229 | part.OffsetPosition = Vector3.Zero; | 2972 | part.OffsetPosition = Vector3.Zero; |
2230 | part.RotationOffset = worldRot; | 2973 | part.RotationOffset = worldRot; |
2231 | 2974 | ||
@@ -2236,20 +2979,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2236 | 2979 | ||
2237 | part.LinkNum = linkNum; | 2980 | part.LinkNum = linkNum; |
2238 | 2981 | ||
2239 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 2982 | part.OffsetPosition = newPos - AbsolutePosition; |
2240 | 2983 | ||
2241 | Quaternion rootRotation = m_rootPart.RotationOffset; | 2984 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2242 | 2985 | ||
2243 | Vector3 pos = part.OffsetPosition; | 2986 | Vector3 pos = part.OffsetPosition; |
2244 | pos *= Quaternion.Inverse(rootRotation); | 2987 | pos *= Quaternion.Conjugate(rootRotation); |
2245 | part.OffsetPosition = pos; | 2988 | part.OffsetPosition = pos; |
2246 | 2989 | ||
2247 | parentRot = m_rootPart.RotationOffset; | 2990 | parentRot = m_rootPart.RotationOffset; |
2248 | oldRot = part.RotationOffset; | 2991 | oldRot = part.RotationOffset; |
2249 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2992 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2250 | part.RotationOffset = newRot; | 2993 | part.RotationOffset = newRot; |
2251 | 2994 | ||
2252 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 2995 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); |
2253 | } | 2996 | } |
2254 | 2997 | ||
2255 | /// <summary> | 2998 | /// <summary> |
@@ -2500,8 +3243,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2500 | } | 3243 | } |
2501 | } | 3244 | } |
2502 | 3245 | ||
2503 | for (int i = 0; i < parts.Length; i++) | 3246 | if (parts.Length > 1) |
2504 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3247 | { |
3248 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3249 | |||
3250 | for (int i = 0; i < parts.Length; i++) | ||
3251 | { | ||
3252 | |||
3253 | if (parts[i].UUID != m_rootPart.UUID) | ||
3254 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3255 | } | ||
3256 | |||
3257 | if (m_rootPart.PhysActor != null) | ||
3258 | m_rootPart.PhysActor.Building = false; | ||
3259 | } | ||
3260 | else | ||
3261 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2505 | } | 3262 | } |
2506 | } | 3263 | } |
2507 | 3264 | ||
@@ -2514,6 +3271,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2514 | } | 3271 | } |
2515 | } | 3272 | } |
2516 | 3273 | ||
3274 | |||
3275 | |||
3276 | /// <summary> | ||
3277 | /// Gets the number of parts | ||
3278 | /// </summary> | ||
3279 | /// <returns></returns> | ||
3280 | public int GetPartCount() | ||
3281 | { | ||
3282 | return Parts.Count(); | ||
3283 | } | ||
3284 | |||
2517 | /// <summary> | 3285 | /// <summary> |
2518 | /// Update the texture entry for this part | 3286 | /// Update the texture entry for this part |
2519 | /// </summary> | 3287 | /// </summary> |
@@ -2575,11 +3343,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2575 | /// <param name="scale"></param> | 3343 | /// <param name="scale"></param> |
2576 | public void GroupResize(Vector3 scale) | 3344 | public void GroupResize(Vector3 scale) |
2577 | { | 3345 | { |
2578 | // m_log.DebugFormat( | ||
2579 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); | ||
2580 | |||
2581 | RootPart.StoreUndoState(true); | ||
2582 | |||
2583 | scale.X = Math.Min(scale.X, Scene.m_maxNonphys); | 3346 | scale.X = Math.Min(scale.X, Scene.m_maxNonphys); |
2584 | scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); | 3347 | scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); |
2585 | scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); | 3348 | scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); |
@@ -2606,7 +3369,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2606 | SceneObjectPart obPart = parts[i]; | 3369 | SceneObjectPart obPart = parts[i]; |
2607 | if (obPart.UUID != m_rootPart.UUID) | 3370 | if (obPart.UUID != m_rootPart.UUID) |
2608 | { | 3371 | { |
2609 | // obPart.IgnoreUndoUpdate = true; | ||
2610 | Vector3 oldSize = new Vector3(obPart.Scale); | 3372 | Vector3 oldSize = new Vector3(obPart.Scale); |
2611 | 3373 | ||
2612 | float f = 1.0f; | 3374 | float f = 1.0f; |
@@ -2670,8 +3432,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2670 | z *= a; | 3432 | z *= a; |
2671 | } | 3433 | } |
2672 | } | 3434 | } |
2673 | |||
2674 | // obPart.IgnoreUndoUpdate = false; | ||
2675 | } | 3435 | } |
2676 | } | 3436 | } |
2677 | } | 3437 | } |
@@ -2681,9 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2681 | prevScale.Y *= y; | 3441 | prevScale.Y *= y; |
2682 | prevScale.Z *= z; | 3442 | prevScale.Z *= z; |
2683 | 3443 | ||
2684 | // RootPart.IgnoreUndoUpdate = true; | ||
2685 | RootPart.Resize(prevScale); | 3444 | RootPart.Resize(prevScale); |
2686 | // RootPart.IgnoreUndoUpdate = false; | ||
2687 | 3445 | ||
2688 | parts = m_parts.GetArray(); | 3446 | parts = m_parts.GetArray(); |
2689 | for (int i = 0; i < parts.Length; i++) | 3447 | for (int i = 0; i < parts.Length; i++) |
@@ -2692,8 +3450,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2692 | 3450 | ||
2693 | if (obPart.UUID != m_rootPart.UUID) | 3451 | if (obPart.UUID != m_rootPart.UUID) |
2694 | { | 3452 | { |
2695 | obPart.IgnoreUndoUpdate = true; | ||
2696 | |||
2697 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3453 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2698 | currentpos.X *= x; | 3454 | currentpos.X *= x; |
2699 | currentpos.Y *= y; | 3455 | currentpos.Y *= y; |
@@ -2706,16 +3462,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2706 | 3462 | ||
2707 | obPart.Resize(newSize); | 3463 | obPart.Resize(newSize); |
2708 | obPart.UpdateOffSet(currentpos); | 3464 | obPart.UpdateOffSet(currentpos); |
2709 | |||
2710 | obPart.IgnoreUndoUpdate = false; | ||
2711 | } | 3465 | } |
2712 | 3466 | ||
2713 | // obPart.IgnoreUndoUpdate = false; | 3467 | HasGroupChanged = true; |
2714 | // obPart.StoreUndoState(); | 3468 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
3469 | ScheduleGroupForTerseUpdate(); | ||
2715 | } | 3470 | } |
2716 | |||
2717 | // m_log.DebugFormat( | ||
2718 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
2719 | } | 3471 | } |
2720 | 3472 | ||
2721 | #endregion | 3473 | #endregion |
@@ -2728,14 +3480,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2728 | /// <param name="pos"></param> | 3480 | /// <param name="pos"></param> |
2729 | public void UpdateGroupPosition(Vector3 pos) | 3481 | public void UpdateGroupPosition(Vector3 pos) |
2730 | { | 3482 | { |
2731 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
2732 | |||
2733 | RootPart.StoreUndoState(true); | ||
2734 | |||
2735 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2736 | // for (int i = 0; i < parts.Length; i++) | ||
2737 | // parts[i].StoreUndoState(); | ||
2738 | |||
2739 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3483 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2740 | { | 3484 | { |
2741 | if (IsAttachment) | 3485 | if (IsAttachment) |
@@ -2768,21 +3512,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2768 | /// </summary> | 3512 | /// </summary> |
2769 | /// <param name="pos"></param> | 3513 | /// <param name="pos"></param> |
2770 | /// <param name="localID"></param> | 3514 | /// <param name="localID"></param> |
3515 | /// | ||
3516 | |||
2771 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 3517 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
2772 | { | 3518 | { |
2773 | SceneObjectPart part = GetPart(localID); | 3519 | SceneObjectPart part = GetPart(localID); |
2774 | 3520 | ||
2775 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2776 | // for (int i = 0; i < parts.Length; i++) | ||
2777 | // parts[i].StoreUndoState(); | ||
2778 | |||
2779 | if (part != null) | 3521 | if (part != null) |
2780 | { | 3522 | { |
2781 | // m_log.DebugFormat( | 3523 | // unlock parts position change |
2782 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 3524 | if (m_rootPart.PhysActor != null) |
2783 | 3525 | m_rootPart.PhysActor.Building = true; | |
2784 | part.StoreUndoState(false); | ||
2785 | part.IgnoreUndoUpdate = true; | ||
2786 | 3526 | ||
2787 | if (part.UUID == m_rootPart.UUID) | 3527 | if (part.UUID == m_rootPart.UUID) |
2788 | { | 3528 | { |
@@ -2793,8 +3533,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2793 | part.UpdateOffSet(pos); | 3533 | part.UpdateOffSet(pos); |
2794 | } | 3534 | } |
2795 | 3535 | ||
3536 | if (m_rootPart.PhysActor != null) | ||
3537 | m_rootPart.PhysActor.Building = false; | ||
3538 | |||
2796 | HasGroupChanged = true; | 3539 | HasGroupChanged = true; |
2797 | part.IgnoreUndoUpdate = false; | ||
2798 | } | 3540 | } |
2799 | } | 3541 | } |
2800 | 3542 | ||
@@ -2804,13 +3546,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2804 | /// <param name="pos"></param> | 3546 | /// <param name="pos"></param> |
2805 | public void UpdateRootPosition(Vector3 pos) | 3547 | public void UpdateRootPosition(Vector3 pos) |
2806 | { | 3548 | { |
2807 | // m_log.DebugFormat( | 3549 | // needs to be called with phys building true |
2808 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
2809 | |||
2810 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2811 | // for (int i = 0; i < parts.Length; i++) | ||
2812 | // parts[i].StoreUndoState(); | ||
2813 | |||
2814 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3550 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
2815 | Vector3 oldPos = | 3551 | Vector3 oldPos = |
2816 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, | 3552 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, |
@@ -2833,7 +3569,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2833 | AbsolutePosition = newPos; | 3569 | AbsolutePosition = newPos; |
2834 | 3570 | ||
2835 | HasGroupChanged = true; | 3571 | HasGroupChanged = true; |
2836 | ScheduleGroupForTerseUpdate(); | 3572 | if (m_rootPart.Undoing) |
3573 | { | ||
3574 | ScheduleGroupForFullUpdate(); | ||
3575 | } | ||
3576 | else | ||
3577 | { | ||
3578 | ScheduleGroupForTerseUpdate(); | ||
3579 | } | ||
2837 | } | 3580 | } |
2838 | 3581 | ||
2839 | #endregion | 3582 | #endregion |
@@ -2846,24 +3589,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2846 | /// <param name="rot"></param> | 3589 | /// <param name="rot"></param> |
2847 | public void UpdateGroupRotationR(Quaternion rot) | 3590 | public void UpdateGroupRotationR(Quaternion rot) |
2848 | { | 3591 | { |
2849 | // m_log.DebugFormat( | ||
2850 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
2851 | |||
2852 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2853 | // for (int i = 0; i < parts.Length; i++) | ||
2854 | // parts[i].StoreUndoState(); | ||
2855 | |||
2856 | m_rootPart.StoreUndoState(true); | ||
2857 | |||
2858 | m_rootPart.UpdateRotation(rot); | 3592 | m_rootPart.UpdateRotation(rot); |
2859 | 3593 | ||
3594 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
2860 | PhysicsActor actor = m_rootPart.PhysActor; | 3595 | PhysicsActor actor = m_rootPart.PhysActor; |
2861 | if (actor != null) | 3596 | if (actor != null) |
2862 | { | 3597 | { |
2863 | actor.Orientation = m_rootPart.RotationOffset; | 3598 | actor.Orientation = m_rootPart.RotationOffset; |
2864 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3599 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
2865 | } | 3600 | } |
2866 | 3601 | */ | |
2867 | HasGroupChanged = true; | 3602 | HasGroupChanged = true; |
2868 | ScheduleGroupForTerseUpdate(); | 3603 | ScheduleGroupForTerseUpdate(); |
2869 | } | 3604 | } |
@@ -2875,16 +3610,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2875 | /// <param name="rot"></param> | 3610 | /// <param name="rot"></param> |
2876 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3611 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
2877 | { | 3612 | { |
2878 | // m_log.DebugFormat( | ||
2879 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
2880 | |||
2881 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2882 | // for (int i = 0; i < parts.Length; i++) | ||
2883 | // parts[i].StoreUndoState(); | ||
2884 | |||
2885 | RootPart.StoreUndoState(true); | ||
2886 | RootPart.IgnoreUndoUpdate = true; | ||
2887 | |||
2888 | m_rootPart.UpdateRotation(rot); | 3613 | m_rootPart.UpdateRotation(rot); |
2889 | 3614 | ||
2890 | PhysicsActor actor = m_rootPart.PhysActor; | 3615 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -2898,8 +3623,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2898 | 3623 | ||
2899 | HasGroupChanged = true; | 3624 | HasGroupChanged = true; |
2900 | ScheduleGroupForTerseUpdate(); | 3625 | ScheduleGroupForTerseUpdate(); |
2901 | |||
2902 | RootPart.IgnoreUndoUpdate = false; | ||
2903 | } | 3626 | } |
2904 | 3627 | ||
2905 | /// <summary> | 3628 | /// <summary> |
@@ -2912,13 +3635,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2912 | SceneObjectPart part = GetPart(localID); | 3635 | SceneObjectPart part = GetPart(localID); |
2913 | 3636 | ||
2914 | SceneObjectPart[] parts = m_parts.GetArray(); | 3637 | SceneObjectPart[] parts = m_parts.GetArray(); |
2915 | for (int i = 0; i < parts.Length; i++) | ||
2916 | parts[i].StoreUndoState(); | ||
2917 | 3638 | ||
2918 | if (part != null) | 3639 | if (part != null) |
2919 | { | 3640 | { |
2920 | // m_log.DebugFormat( | 3641 | if (m_rootPart.PhysActor != null) |
2921 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 3642 | m_rootPart.PhysActor.Building = true; |
2922 | 3643 | ||
2923 | if (part.UUID == m_rootPart.UUID) | 3644 | if (part.UUID == m_rootPart.UUID) |
2924 | { | 3645 | { |
@@ -2928,6 +3649,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2928 | { | 3649 | { |
2929 | part.UpdateRotation(rot); | 3650 | part.UpdateRotation(rot); |
2930 | } | 3651 | } |
3652 | |||
3653 | if (m_rootPart.PhysActor != null) | ||
3654 | m_rootPart.PhysActor.Building = false; | ||
2931 | } | 3655 | } |
2932 | } | 3656 | } |
2933 | 3657 | ||
@@ -2941,12 +3665,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2941 | SceneObjectPart part = GetPart(localID); | 3665 | SceneObjectPart part = GetPart(localID); |
2942 | if (part != null) | 3666 | if (part != null) |
2943 | { | 3667 | { |
2944 | // m_log.DebugFormat( | 3668 | if (m_rootPart.PhysActor != null) |
2945 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 3669 | m_rootPart.PhysActor.Building = true; |
2946 | // part.Name, part.LocalId, rot); | ||
2947 | |||
2948 | part.StoreUndoState(); | ||
2949 | part.IgnoreUndoUpdate = true; | ||
2950 | 3670 | ||
2951 | if (part.UUID == m_rootPart.UUID) | 3671 | if (part.UUID == m_rootPart.UUID) |
2952 | { | 3672 | { |
@@ -2959,7 +3679,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2959 | part.OffsetPosition = pos; | 3679 | part.OffsetPosition = pos; |
2960 | } | 3680 | } |
2961 | 3681 | ||
2962 | part.IgnoreUndoUpdate = false; | 3682 | if (m_rootPart.PhysActor != null) |
3683 | m_rootPart.PhysActor.Building = false; | ||
2963 | } | 3684 | } |
2964 | } | 3685 | } |
2965 | 3686 | ||
@@ -2969,15 +3690,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2969 | /// <param name="rot"></param> | 3690 | /// <param name="rot"></param> |
2970 | public void UpdateRootRotation(Quaternion rot) | 3691 | public void UpdateRootRotation(Quaternion rot) |
2971 | { | 3692 | { |
2972 | // m_log.DebugFormat( | 3693 | // needs to be called with phys building true |
2973 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
2974 | // Name, LocalId, rot); | ||
2975 | |||
2976 | Quaternion axRot = rot; | 3694 | Quaternion axRot = rot; |
2977 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3695 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
2978 | 3696 | ||
2979 | m_rootPart.StoreUndoState(); | 3697 | //Don't use UpdateRotation because it schedules an update prematurely |
2980 | m_rootPart.UpdateRotation(rot); | 3698 | m_rootPart.RotationOffset = rot; |
2981 | 3699 | ||
2982 | PhysicsActor pa = m_rootPart.PhysActor; | 3700 | PhysicsActor pa = m_rootPart.PhysActor; |
2983 | 3701 | ||
@@ -2993,35 +3711,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
2993 | SceneObjectPart prim = parts[i]; | 3711 | SceneObjectPart prim = parts[i]; |
2994 | if (prim.UUID != m_rootPart.UUID) | 3712 | if (prim.UUID != m_rootPart.UUID) |
2995 | { | 3713 | { |
2996 | prim.IgnoreUndoUpdate = true; | 3714 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
3715 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3716 | prim.RotationOffset = NewRot; | ||
3717 | |||
2997 | Vector3 axPos = prim.OffsetPosition; | 3718 | Vector3 axPos = prim.OffsetPosition; |
3719 | |||
2998 | axPos *= oldParentRot; | 3720 | axPos *= oldParentRot; |
2999 | axPos *= Quaternion.Inverse(axRot); | 3721 | axPos *= Quaternion.Inverse(axRot); |
3000 | prim.OffsetPosition = axPos; | 3722 | prim.OffsetPosition = axPos; |
3001 | Quaternion primsRot = prim.RotationOffset; | 3723 | } |
3002 | Quaternion newRot = oldParentRot * primsRot; | 3724 | } |
3003 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
3004 | prim.RotationOffset = newRot; | ||
3005 | prim.ScheduleTerseUpdate(); | ||
3006 | prim.IgnoreUndoUpdate = false; | ||
3007 | } | ||
3008 | } | ||
3009 | |||
3010 | // for (int i = 0; i < parts.Length; i++) | ||
3011 | // { | ||
3012 | // SceneObjectPart childpart = parts[i]; | ||
3013 | // if (childpart != m_rootPart) | ||
3014 | // { | ||
3015 | //// childpart.IgnoreUndoUpdate = false; | ||
3016 | //// childpart.StoreUndoState(); | ||
3017 | // } | ||
3018 | // } | ||
3019 | 3725 | ||
3020 | m_rootPart.ScheduleTerseUpdate(); | 3726 | HasGroupChanged = true; |
3727 | ScheduleGroupForFullUpdate(); | ||
3728 | } | ||
3021 | 3729 | ||
3022 | // m_log.DebugFormat( | 3730 | private enum updatetype :int |
3023 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 3731 | { |
3024 | // Name, LocalId, rot); | 3732 | none = 0, |
3733 | partterse = 1, | ||
3734 | partfull = 2, | ||
3735 | groupterse = 3, | ||
3736 | groupfull = 4 | ||
3737 | } | ||
3738 | |||
3739 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) | ||
3740 | { | ||
3741 | // TODO this still as excessive *.Schedule*Update()s | ||
3742 | |||
3743 | if (part != null && part.ParentGroup != null) | ||
3744 | { | ||
3745 | ObjectChangeType change = data.change; | ||
3746 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
3747 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
3748 | |||
3749 | SceneObjectGroup group = part.ParentGroup; | ||
3750 | PhysicsActor pha = group.RootPart.PhysActor; | ||
3751 | |||
3752 | updatetype updateType = updatetype.none; | ||
3753 | |||
3754 | if (togroup) | ||
3755 | { | ||
3756 | // related to group | ||
3757 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
3758 | { | ||
3759 | if ((change & ObjectChangeType.Rotation) != 0) | ||
3760 | { | ||
3761 | group.RootPart.UpdateRotation(data.rotation); | ||
3762 | updateType = updatetype.none; | ||
3763 | } | ||
3764 | if ((change & ObjectChangeType.Position) != 0) | ||
3765 | { | ||
3766 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
3767 | UpdateGroupPosition(data.position); | ||
3768 | updateType = updatetype.groupterse; | ||
3769 | } | ||
3770 | else | ||
3771 | // ugly rotation update of all parts | ||
3772 | { | ||
3773 | group.AbsolutePosition = AbsolutePosition; | ||
3774 | } | ||
3775 | |||
3776 | } | ||
3777 | if ((change & ObjectChangeType.Scale) != 0) | ||
3778 | { | ||
3779 | if (pha != null) | ||
3780 | pha.Building = true; | ||
3781 | |||
3782 | group.GroupResize(data.scale); | ||
3783 | updateType = updatetype.none; | ||
3784 | |||
3785 | if (pha != null) | ||
3786 | pha.Building = false; | ||
3787 | } | ||
3788 | } | ||
3789 | else | ||
3790 | { | ||
3791 | // related to single prim in a link-set ( ie group) | ||
3792 | if (pha != null) | ||
3793 | pha.Building = true; | ||
3794 | |||
3795 | // root part is special | ||
3796 | // parts offset positions or rotations need to change also | ||
3797 | |||
3798 | if (part == group.RootPart) | ||
3799 | { | ||
3800 | if ((change & ObjectChangeType.Rotation) != 0) | ||
3801 | group.UpdateRootRotation(data.rotation); | ||
3802 | if ((change & ObjectChangeType.Position) != 0) | ||
3803 | group.UpdateRootPosition(data.position); | ||
3804 | if ((change & ObjectChangeType.Scale) != 0) | ||
3805 | part.Resize(data.scale); | ||
3806 | } | ||
3807 | else | ||
3808 | { | ||
3809 | if ((change & ObjectChangeType.Position) != 0) | ||
3810 | { | ||
3811 | part.OffsetPosition = data.position; | ||
3812 | updateType = updatetype.partterse; | ||
3813 | } | ||
3814 | if ((change & ObjectChangeType.Rotation) != 0) | ||
3815 | { | ||
3816 | part.UpdateRotation(data.rotation); | ||
3817 | updateType = updatetype.none; | ||
3818 | } | ||
3819 | if ((change & ObjectChangeType.Scale) != 0) | ||
3820 | { | ||
3821 | part.Resize(data.scale); | ||
3822 | updateType = updatetype.none; | ||
3823 | } | ||
3824 | } | ||
3825 | |||
3826 | if (pha != null) | ||
3827 | pha.Building = false; | ||
3828 | } | ||
3829 | |||
3830 | if (updateType != updatetype.none) | ||
3831 | { | ||
3832 | group.HasGroupChanged = true; | ||
3833 | |||
3834 | switch (updateType) | ||
3835 | { | ||
3836 | case updatetype.partterse: | ||
3837 | part.ScheduleTerseUpdate(); | ||
3838 | break; | ||
3839 | case updatetype.partfull: | ||
3840 | part.ScheduleFullUpdate(); | ||
3841 | break; | ||
3842 | case updatetype.groupterse: | ||
3843 | group.ScheduleGroupForTerseUpdate(); | ||
3844 | break; | ||
3845 | case updatetype.groupfull: | ||
3846 | group.ScheduleGroupForFullUpdate(); | ||
3847 | break; | ||
3848 | default: | ||
3849 | break; | ||
3850 | } | ||
3851 | } | ||
3852 | } | ||
3025 | } | 3853 | } |
3026 | 3854 | ||
3027 | #endregion | 3855 | #endregion |
@@ -3241,11 +4069,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3241 | } | 4069 | } |
3242 | } | 4070 | } |
3243 | } | 4071 | } |
3244 | 4072 | ||
4073 | public Vector3 GetGeometricCenter() | ||
4074 | { | ||
4075 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4076 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4077 | // ignoring tortured prims details since sl also seems to ignore | ||
4078 | // so no real use in doing it on physics | ||
4079 | |||
4080 | Vector3 gc = Vector3.Zero; | ||
4081 | |||
4082 | int nparts = m_parts.Count; | ||
4083 | if (nparts <= 1) | ||
4084 | return gc; | ||
4085 | |||
4086 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4087 | nparts = parts.Length; // just in case it changed | ||
4088 | if (nparts <= 1) | ||
4089 | return gc; | ||
4090 | |||
4091 | Quaternion parentRot = RootPart.RotationOffset; | ||
4092 | Vector3 pPos; | ||
4093 | |||
4094 | // average all parts positions | ||
4095 | for (int i = 0; i < nparts; i++) | ||
4096 | { | ||
4097 | // do it directly | ||
4098 | // gc += parts[i].GetWorldPosition(); | ||
4099 | if (parts[i] != RootPart) | ||
4100 | { | ||
4101 | pPos = parts[i].OffsetPosition; | ||
4102 | gc += pPos; | ||
4103 | } | ||
4104 | |||
4105 | } | ||
4106 | gc /= nparts; | ||
4107 | |||
4108 | // relative to root: | ||
4109 | // gc -= AbsolutePosition; | ||
4110 | return gc; | ||
4111 | } | ||
4112 | |||
3245 | public float GetMass() | 4113 | public float GetMass() |
3246 | { | 4114 | { |
3247 | float retmass = 0f; | 4115 | float retmass = 0f; |
3248 | |||
3249 | SceneObjectPart[] parts = m_parts.GetArray(); | 4116 | SceneObjectPart[] parts = m_parts.GetArray(); |
3250 | for (int i = 0; i < parts.Length; i++) | 4117 | for (int i = 0; i < parts.Length; i++) |
3251 | retmass += parts[i].GetMass(); | 4118 | retmass += parts[i].GetMass(); |
@@ -3253,6 +4120,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3253 | return retmass; | 4120 | return retmass; |
3254 | } | 4121 | } |
3255 | 4122 | ||
4123 | // center of mass of full object | ||
4124 | public Vector3 GetCenterOfMass() | ||
4125 | { | ||
4126 | PhysicsActor pa = RootPart.PhysActor; | ||
4127 | |||
4128 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4129 | { | ||
4130 | // physics knows better about center of mass of physical prims | ||
4131 | Vector3 tmp = pa.CenterOfMass; | ||
4132 | return tmp; | ||
4133 | } | ||
4134 | |||
4135 | Vector3 Ptot = Vector3.Zero; | ||
4136 | float totmass = 0f; | ||
4137 | float m; | ||
4138 | |||
4139 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4140 | for (int i = 0; i < parts.Length; i++) | ||
4141 | { | ||
4142 | m = parts[i].GetMass(); | ||
4143 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4144 | totmass += m; | ||
4145 | } | ||
4146 | |||
4147 | if (totmass == 0) | ||
4148 | totmass = 0; | ||
4149 | else | ||
4150 | totmass = 1 / totmass; | ||
4151 | Ptot *= totmass; | ||
4152 | |||
4153 | return Ptot; | ||
4154 | } | ||
4155 | |||
3256 | /// <summary> | 4156 | /// <summary> |
3257 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4157 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3258 | /// the physics engine can use it. | 4158 | /// the physics engine can use it. |
@@ -3406,6 +4306,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3406 | FromItemID = uuid; | 4306 | FromItemID = uuid; |
3407 | } | 4307 | } |
3408 | 4308 | ||
4309 | public void ResetOwnerChangeFlag() | ||
4310 | { | ||
4311 | ForEachPart(delegate(SceneObjectPart part) | ||
4312 | { | ||
4313 | part.ResetOwnerChangeFlag(); | ||
4314 | }); | ||
4315 | } | ||
4316 | |||
3409 | #endregion | 4317 | #endregion |
3410 | } | 4318 | } |
3411 | } | 4319 | } |