diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 111 |
1 files changed, 108 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 17dfb85..53a9441 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3168,10 +3168,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3168 | if (insert) | 3168 | if (insert) |
3169 | { | 3169 | { |
3170 | linkNum = 2; | 3170 | linkNum = 2; |
3171 | int insertSize = objectGroup.PrimCount; | ||
3171 | foreach (SceneObjectPart part in Parts) | 3172 | foreach (SceneObjectPart part in Parts) |
3172 | { | 3173 | { |
3173 | if (part.LinkNum > 1) | 3174 | if (part.LinkNum > 1) |
3174 | part.LinkNum++; | 3175 | part.LinkNum += insertSize; |
3175 | } | 3176 | } |
3176 | } | 3177 | } |
3177 | else | 3178 | else |
@@ -3200,14 +3201,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3200 | linkPart.LinkNum = linkNum++; | 3201 | linkPart.LinkNum = linkNum++; |
3201 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | 3202 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); |
3202 | 3203 | ||
3203 | // Get a list of the SOP's in the old group in order of their linknum's. | 3204 | // Get a list of the SOP's in the source group in order of their linknum's. |
3204 | SceneObjectPart[] ogParts = objectGroup.Parts; | 3205 | SceneObjectPart[] ogParts = objectGroup.Parts; |
3205 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 3206 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
3206 | { | 3207 | { |
3207 | return a.LinkNum - b.LinkNum; | 3208 | return a.LinkNum - b.LinkNum; |
3208 | }); | 3209 | }); |
3209 | 3210 | ||
3210 | // Add each of the SOP's from the old linkset to our linkset | 3211 | // Add each of the SOP's from the source linkset to our linkset |
3211 | for (int i = 0; i < ogParts.Length; i++) | 3212 | for (int i = 0; i < ogParts.Length; i++) |
3212 | { | 3213 | { |
3213 | SceneObjectPart part = ogParts[i]; | 3214 | SceneObjectPart part = ogParts[i]; |
@@ -3415,6 +3416,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
3415 | return objectGroup; | 3416 | return objectGroup; |
3416 | } | 3417 | } |
3417 | 3418 | ||
3419 | /* working on it | ||
3420 | public void DelinkFromGroup(List<SceneObjectPart> linkParts, bool sendEvents) | ||
3421 | { | ||
3422 | // m_log.DebugFormat( | ||
3423 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | ||
3424 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | ||
3425 | |||
3426 | if(PrimCount == 1) | ||
3427 | return; | ||
3428 | |||
3429 | if (m_rootPart.PhysActor != null) | ||
3430 | m_rootPart.PhysActor.Building = true; | ||
3431 | |||
3432 | bool unlinkroot = false; | ||
3433 | foreach(SceneObjectPart linkPart in linkParts) | ||
3434 | { | ||
3435 | // first we only remove child parts | ||
3436 | if(linkPart.LocalId == m_rootPart.LocalId) | ||
3437 | { | ||
3438 | unlinkroot = true; | ||
3439 | continue; | ||
3440 | } | ||
3441 | |||
3442 | lock (m_parts.SyncRoot) | ||
3443 | if(!m_parts.Remove(linkPart.UUID)) | ||
3444 | continue; | ||
3445 | |||
3446 | linkPart.ClearUndoState(); | ||
3447 | |||
3448 | Vector3 worldPos = linkPart.GetWorldPosition(); | ||
3449 | Quaternion worldRot = linkPart.GetWorldRotation(); | ||
3450 | |||
3451 | linkPart.ParentID = 0; | ||
3452 | linkPart.LinkNum = 0; | ||
3453 | |||
3454 | PhysicsActor linkPartPa = linkPart.PhysActor; | ||
3455 | |||
3456 | // Remove the SOP from the physical scene. | ||
3457 | // If the new SOG is physical, it is re-created later. | ||
3458 | // (There is a problem here in that we have not yet told the physics | ||
3459 | // engine about the delink. Someday, linksets should be made first | ||
3460 | // class objects in the physics engine interface). | ||
3461 | if (linkPartPa != null) | ||
3462 | { | ||
3463 | m_scene.PhysicsScene.RemovePrim(linkPartPa); | ||
3464 | linkPart.PhysActor = null; | ||
3465 | } | ||
3466 | |||
3467 | linkPart.setGroupPosition(worldPos); | ||
3468 | linkPart.setOffsetPosition(Vector3.Zero); | ||
3469 | linkPart.setRotationOffset(worldRot); | ||
3470 | |||
3471 | // Create a new SOG to go around this unlinked and unattached SOP | ||
3472 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); | ||
3473 | |||
3474 | m_scene.AddNewSceneObject(objectGroup, true); | ||
3475 | |||
3476 | linkPart.Rezzed = RootPart.Rezzed; | ||
3477 | |||
3478 | // this is as it seems to be in sl now | ||
3479 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3480 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3481 | |||
3482 | objectGroup.HasGroupChangedDueToDelink = true; | ||
3483 | if (sendEvents) | ||
3484 | linkPart.TriggerScriptChangedEvent(Changed.LINK); | ||
3485 | } | ||
3486 | |||
3487 | if(unlinkroot) | ||
3488 | { | ||
3489 | //TODO | ||
3490 | } | ||
3491 | |||
3492 | lock (m_parts.SyncRoot) | ||
3493 | { | ||
3494 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
3495 | if (parts.Length == 1) | ||
3496 | { | ||
3497 | // Single prim left | ||
3498 | m_rootPart.LinkNum = 0; | ||
3499 | } | ||
3500 | else | ||
3501 | { | ||
3502 | m_rootPart.LinkNum = 1; | ||
3503 | int linknum = 2; | ||
3504 | for (int i = 1; i < parts.Length; i++) | ||
3505 | parts[i].LinkNum = linknum++; | ||
3506 | } | ||
3507 | } | ||
3508 | |||
3509 | InvalidBoundsRadius(); | ||
3510 | |||
3511 | if (m_rootPart.PhysActor != null) | ||
3512 | m_rootPart.PhysActor.Building = false; | ||
3513 | |||
3514 | // When we delete a group, we currently have to force persist to the database if the object id has changed | ||
3515 | // (since delete works by deleting all rows which have a given object id) | ||
3516 | |||
3517 | Scene.SimulationDataService.RemoveObject(UUID, Scene.RegionInfo.RegionID); | ||
3518 | HasGroupChangedDueToDelink = true; | ||
3519 | TriggerScriptChangedEvent(Changed.LINK); | ||
3520 | return; | ||
3521 | } | ||
3522 | */ | ||
3418 | /// <summary> | 3523 | /// <summary> |
3419 | /// Stop this object from being persisted over server restarts. | 3524 | /// Stop this object from being persisted over server restarts. |
3420 | /// </summary> | 3525 | /// </summary> |