aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs277
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs93
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs283
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs219
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs189
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs33
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs2
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs9
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs173
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs29
10 files changed, 601 insertions, 706 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index fcca1bc..4c43c10 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -11481,21 +11481,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11481 } 11481 }
11482 else 11482 else
11483 { 11483 {
11484// m_log.DebugFormat(
11485// "[CLIENT]: Processing block {0} type {1} for {2} {3}",
11486// i, block.Type, part.Name, part.LocalId);
11487
11488// // Do this once since fetch parts creates a new array.
11489// SceneObjectPart[] parts = part.ParentGroup.Parts;
11490// for (int j = 0; j < parts.Length; j++)
11491// {
11492// part.StoreUndoState();
11493// parts[j].IgnoreUndoUpdate = true;
11494// }
11495
11496// UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
11497// UpdateVector handlerUpdatePrimGroupScale;
11498
11499 ClientChangeObject updatehandler = onClientChangeObject; 11484 ClientChangeObject updatehandler = onClientChangeObject;
11500 11485
11501 if (updatehandler != null) 11486 if (updatehandler != null)
@@ -11536,7 +11521,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11536 11521
11537 udata.what = ObjectChangeWhat.primPR; 11522 udata.what = ObjectChangeWhat.primPR;
11538 updatehandler(localId, udata, this); 11523 updatehandler(localId, udata, this);
11539
11540 break; 11524 break;
11541 11525
11542 case 4: // scale sp 11526 case 4: // scale sp
@@ -11637,270 +11621,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11637 } 11621 }
11638 } 11622 }
11639 11623
11640/*
11641 switch (block.Type)
11642 {
11643 case 1: //change position sp
11644 apos = new Vector3(block.Data, 0);
11645
11646 UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
11647 if (handlerUpdatePrimSinglePosition != null)
11648 {
11649 part.StoreUndoState();
11650 part.IgnoreUndoUpdate = true;
11651
11652 // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
11653 handlerUpdatePrimSinglePosition(localId, apos, this);
11654
11655 part.IgnoreUndoUpdate = false;
11656 }
11657 break;
11658
11659 case 2: // rotation sp
11660 arot = new Quaternion(block.Data, 0, true);
11661
11662 UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
11663 if (handlerUpdatePrimSingleRotation != null)
11664 {
11665 part.StoreUndoState();
11666 part.IgnoreUndoUpdate = true;
11667
11668 handlerUpdatePrimSingleRotation(localId, arot, this);
11669
11670 part.IgnoreUndoUpdate = false;
11671 }
11672 break;
11673
11674 case 3: // position plus rotation
11675 apos = new Vector3(block.Data, 0);
11676 arot = new Quaternion(block.Data, 12, true);
11677
11678 UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
11679 if (handlerUpdatePrimSingleRotationPosition != null)
11680 {
11681 part.StoreUndoState();
11682 part.IgnoreUndoUpdate = true;
11683
11684 handlerUpdatePrimSingleRotationPosition(localId, arot, apos, this);
11685
11686 part.IgnoreUndoUpdate = false;
11687 }
11688 break;
11689
11690 case 4: // scale sp
11691 case 0x14: // uniform scale sp
11692 ascale = new Vector3(block.Data, 0);
11693
11694 UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
11695 if (handlerUpdatePrimScale != null)
11696 {
11697 part.StoreUndoState();
11698 part.IgnoreUndoUpdate = true;
11699
11700 handlerUpdatePrimScale(localId, ascale, this);
11701
11702 part.IgnoreUndoUpdate = false;
11703 }
11704 break;
11705
11706 case 5: // scale and position sp
11707 apos = new Vector3(block.Data, 0);
11708 ascale = new Vector3(block.Data, 12);
11709
11710
11711 handlerUpdatePrimScale = OnUpdatePrimScale;
11712 if (handlerUpdatePrimScale != null)
11713 {
11714 part.StoreUndoState();
11715 part.IgnoreUndoUpdate = true;
11716
11717 handlerUpdatePrimScale(localId, ascale, this);
11718
11719 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
11720
11721 if (handlerUpdatePrimSinglePosition != null)
11722 {
11723 handlerUpdatePrimSinglePosition(localId, apos, this);
11724 }
11725 part.IgnoreUndoUpdate = false;
11726 }
11727 break;
11728
11729 case 0x15: //uniform scale and position
11730 apos = new Vector3(block.Data, 0);
11731 ascale = new Vector3(block.Data, 12);
11732
11733
11734 handlerUpdatePrimScale = OnUpdatePrimScale;
11735 if (handlerUpdatePrimScale != null)
11736 {
11737 part.StoreUndoState(false);
11738 part.IgnoreUndoUpdate = true;
11739
11740 // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
11741 handlerUpdatePrimScale(localId, ascale, this);
11742 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
11743 if (handlerUpdatePrimSinglePosition != null)
11744 {
11745 handlerUpdatePrimSinglePosition(localId, apos, this);
11746 }
11747
11748 part.IgnoreUndoUpdate = false;
11749 }
11750 break;
11751
11752// now group related (bit 4)
11753 case 9: //( 8 + 1 )group position
11754 apos = new Vector3(block.Data, 0);
11755
11756 UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
11757
11758 if (handlerUpdateVector != null)
11759 {
11760 part.StoreUndoState(true);
11761 part.IgnoreUndoUpdate = true;
11762
11763 handlerUpdateVector(localId, apos, this);
11764
11765 part.IgnoreUndoUpdate = false;
11766 }
11767 break;
11768
11769 case 0x0A: // (8 + 2) group rotation
11770 arot = new Quaternion(block.Data, 0, true);
11771
11772 UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
11773 if (handlerUpdatePrimRotation != null)
11774 {
11775 // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
11776 part.StoreUndoState(true);
11777 part.IgnoreUndoUpdate = true;
11778
11779 handlerUpdatePrimRotation(localId, arot, this);
11780
11781 part.IgnoreUndoUpdate = false;
11782 }
11783 break;
11784
11785 case 0x0B: //( 8 + 2 + 1) group rotation and position
11786 apos = new Vector3(block.Data, 0);
11787 arot = new Quaternion(block.Data, 12, true);
11788
11789 handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
11790 if (handlerUpdatePrimGroupRotation != null)
11791 {
11792 // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
11793 // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
11794 part.StoreUndoState(true);
11795 part.IgnoreUndoUpdate = true;
11796
11797 handlerUpdatePrimGroupRotation(localId, apos, arot, this);
11798
11799 part.IgnoreUndoUpdate = false;
11800 }
11801 break;
11802
11803 case 0x0C: // (8 + 4) group scale
11804 // only afects root prim and only sent by viewer editor object tab scaling
11805 // mouse edition only allows uniform scaling
11806 // SL MAY CHANGE THIS in viewers
11807
11808 ascale = new Vector3(block.Data, 0);
11809
11810 handlerUpdatePrimScale = OnUpdatePrimScale;
11811 if (handlerUpdatePrimScale != null)
11812 {
11813 // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
11814 part.StoreUndoState(false); // <- SL Exception make it apply to root prim and not group
11815 part.IgnoreUndoUpdate = true;
11816
11817 handlerUpdatePrimScale(localId, ascale, this);
11818
11819 part.IgnoreUndoUpdate = false;
11820 }
11821 break;
11822
11823 case 0x0D: //(8 + 4 + 1) group scale and position
11824 // exception as above
11825
11826 apos = new Vector3(block.Data, 0);
11827 ascale = new Vector3(block.Data, 12);
11828
11829 handlerUpdatePrimScale = OnUpdatePrimScale;
11830 if (handlerUpdatePrimScale != null)
11831 {
11832 //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
11833 part.StoreUndoState(false); // <- make it apply to root prim and not group
11834 part.IgnoreUndoUpdate = true;
11835
11836 handlerUpdatePrimScale(localId, ascale, this);
11837
11838 // Change the position based on scale (for bug number 246)
11839 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
11840 // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
11841 if (handlerUpdatePrimSinglePosition != null)
11842 {
11843 handlerUpdatePrimSinglePosition(localId, apos, this);
11844 }
11845
11846 part.IgnoreUndoUpdate = false;
11847 }
11848 break;
11849
11850 case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM
11851 ascale = new Vector3(block.Data, 0);
11852
11853 handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
11854 if (handlerUpdatePrimGroupScale != null)
11855 {
11856 // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
11857 part.StoreUndoState(true);
11858 part.IgnoreUndoUpdate = true;
11859
11860 handlerUpdatePrimGroupScale(localId, ascale, this);
11861
11862 part.IgnoreUndoUpdate = false;
11863 }
11864 break;
11865
11866 case 0x1D: // (UNIFORM + GROUP + SCALE + POS)
11867 apos = new Vector3(block.Data, 0);
11868 ascale = new Vector3(block.Data, 12);
11869
11870
11871 handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
11872 if (handlerUpdatePrimGroupScale != null)
11873 {
11874 // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
11875 part.StoreUndoState(true);
11876 part.IgnoreUndoUpdate = true;
11877
11878 handlerUpdatePrimGroupScale(localId, ascale, this);
11879
11880 handlerUpdateVector = OnUpdatePrimGroupPosition;
11881
11882 if (handlerUpdateVector != null)
11883 {
11884 handlerUpdateVector(localId, apos, this);
11885 }
11886
11887 part.IgnoreUndoUpdate = false;
11888 }
11889
11890 break;
11891
11892 default:
11893 m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
11894 break;
11895 }
11896*/
11897// for (int j = 0; j < parts.Length; j++)
11898// parts[j].IgnoreUndoUpdate = false;
11899
11900 } 11624 }
11901 } 11625 }
11902 } 11626 }
11903
11904 return true; 11627 return true;
11905 } 11628 }
11906 11629
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 92f2d54..2654563 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1940,37 +1940,46 @@ namespace OpenSim.Region.Framework.Scenes
1940 { 1940 {
1941 newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); 1941 newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
1942 newPart.LinkNum = part.LinkNum; 1942 newPart.LinkNum = part.LinkNum;
1943 } 1943 if (userExposed)
1944 newPart.ParentID = dupe.m_rootPart.LocalId;
1945 }
1944 else 1946 else
1945 { 1947 {
1946 newPart = dupe.m_rootPart; 1948 newPart = dupe.m_rootPart;
1947 } 1949 }
1950/*
1951 bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0);
1952 bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0);
1948 1953
1949 // Need to duplicate the physics actor as well 1954 // Need to duplicate the physics actor as well
1950 if (part.PhysActor != null && userExposed) 1955 if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive))
1951 { 1956 {
1952 PrimitiveBaseShape pbs = newPart.Shape; 1957 PrimitiveBaseShape pbs = newPart.Shape;
1953
1954 newPart.PhysActor 1958 newPart.PhysActor
1955 = m_scene.PhysicsScene.AddPrimShape( 1959 = m_scene.PhysicsScene.AddPrimShape(
1956 string.Format("{0}/{1}", newPart.Name, newPart.UUID), 1960 string.Format("{0}/{1}", newPart.Name, newPart.UUID),
1957 pbs, 1961 pbs,
1958 newPart.AbsolutePosition, 1962 newPart.AbsolutePosition,
1959 newPart.Scale, 1963 newPart.Scale,
1960 //newPart.RotationOffset,
1961 newPart.GetWorldRotation(), 1964 newPart.GetWorldRotation(),
1962 part.PhysActor.IsPhysical, 1965 isphys,
1966 isphan,
1963 newPart.LocalId); 1967 newPart.LocalId);
1964 1968
1965 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); 1969 newPart.DoPhysicsPropertyUpdate(isphys, true);
1966 } 1970 */
1971 if (userExposed)
1972 newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true);
1973// }
1967 } 1974 }
1968 if (dupe.m_rootPart.PhysActor != null && userExposed)
1969 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building
1970 1975
1971 if (userExposed) 1976 if (userExposed)
1972 { 1977 {
1973 dupe.UpdateParentIDs(); 1978// done above dupe.UpdateParentIDs();
1979
1980 if (dupe.m_rootPart.PhysActor != null)
1981 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building
1982
1974 dupe.HasGroupChanged = true; 1983 dupe.HasGroupChanged = true;
1975 dupe.AttachToBackup(); 1984 dupe.AttachToBackup();
1976 1985
@@ -3498,9 +3507,18 @@ namespace OpenSim.Region.Framework.Scenes
3498 ScheduleGroupForFullUpdate(); 3507 ScheduleGroupForFullUpdate();
3499 } 3508 }
3500 3509
3510 private enum updatetype :int
3511 {
3512 none = 0,
3513 partterse = 1,
3514 partfull = 2,
3515 groupterse = 3,
3516 groupfull = 4
3517 }
3518
3501 public void doChangeObject(SceneObjectPart part, ObjectChangeData data) 3519 public void doChangeObject(SceneObjectPart part, ObjectChangeData data)
3502 { 3520 {
3503 // TODO this still as excessive ScheduleGroupForTerseUpdate()s 3521 // TODO this still as excessive *.Schedule*Update()s
3504 3522
3505 if (part != null && part.ParentGroup != null) 3523 if (part != null && part.ParentGroup != null)
3506 { 3524 {
@@ -3511,7 +3529,7 @@ namespace OpenSim.Region.Framework.Scenes
3511 SceneObjectGroup group = part.ParentGroup; 3529 SceneObjectGroup group = part.ParentGroup;
3512 PhysicsActor pha = group.RootPart.PhysActor; 3530 PhysicsActor pha = group.RootPart.PhysActor;
3513 3531
3514 bool needgrpUpdate = false; 3532 updatetype updateType = updatetype.none;
3515 3533
3516 if (togroup) 3534 if (togroup)
3517 { 3535 {
@@ -3519,15 +3537,21 @@ namespace OpenSim.Region.Framework.Scenes
3519 if ((what & ObjectChangeWhat.Position) != 0) 3537 if ((what & ObjectChangeWhat.Position) != 0)
3520 { 3538 {
3521 group.AbsolutePosition = data.position; 3539 group.AbsolutePosition = data.position;
3522 needgrpUpdate = true; 3540 updateType = updatetype.groupterse;
3523 } 3541 }
3524 if ((what & ObjectChangeWhat.Rotation) != 0) 3542 if ((what & ObjectChangeWhat.Rotation) != 0)
3543 {
3525 group.RootPart.UpdateRotation(data.rotation); 3544 group.RootPart.UpdateRotation(data.rotation);
3545 updateType = updatetype.none;
3546 }
3526 if ((what & ObjectChangeWhat.Scale) != 0) 3547 if ((what & ObjectChangeWhat.Scale) != 0)
3527 { 3548 {
3528 if (pha != null) 3549 if (pha != null)
3529 pha.Building = true; 3550 pha.Building = true;
3551
3530 group.GroupResize(data.scale); 3552 group.GroupResize(data.scale);
3553 updateType = updatetype.none;
3554
3531 if (pha != null) 3555 if (pha != null)
3532 pha.Building = false; 3556 pha.Building = false;
3533 } 3557 }
@@ -3538,8 +3562,8 @@ namespace OpenSim.Region.Framework.Scenes
3538 if (pha != null) 3562 if (pha != null)
3539 pha.Building = true; 3563 pha.Building = true;
3540 3564
3541 // must deal with root part specially for position and rotation 3565 // root part is special
3542 // so parts offset positions or rotations are fixed 3566 // parts offset positions or rotations need to change also
3543 3567
3544 if (part == group.RootPart) 3568 if (part == group.RootPart)
3545 { 3569 {
@@ -3547,30 +3571,53 @@ namespace OpenSim.Region.Framework.Scenes
3547 group.UpdateRootPosition(data.position); 3571 group.UpdateRootPosition(data.position);
3548 if ((what & ObjectChangeWhat.Rotation) != 0) 3572 if ((what & ObjectChangeWhat.Rotation) != 0)
3549 group.UpdateRootRotation(data.rotation); 3573 group.UpdateRootRotation(data.rotation);
3574 if ((what & ObjectChangeWhat.Scale) != 0)
3575 part.Resize(data.scale);
3550 } 3576 }
3551 else 3577 else
3552 { 3578 {
3553
3554 if ((what & ObjectChangeWhat.Position) != 0) 3579 if ((what & ObjectChangeWhat.Position) != 0)
3555 { 3580 {
3556 part.OffsetPosition = data.position; 3581 part.OffsetPosition = data.position;
3557 needgrpUpdate = true; 3582 updateType = updatetype.partterse;
3558 } 3583 }
3559 if ((what & ObjectChangeWhat.Rotation) != 0) 3584 if ((what & ObjectChangeWhat.Rotation) != 0)
3585 {
3560 part.UpdateRotation(data.rotation); 3586 part.UpdateRotation(data.rotation);
3587 updateType = updatetype.none;
3588 }
3589 if ((what & ObjectChangeWhat.Scale) != 0)
3590 {
3591 part.Resize(data.scale);
3592 updateType = updatetype.none;
3593 }
3561 } 3594 }
3562 3595
3563 if ((what & ObjectChangeWhat.Scale) != 0)
3564 part.Resize(data.scale);
3565
3566 if (pha != null) 3596 if (pha != null)
3567 pha.Building = false; 3597 pha.Building = false;
3568 } 3598 }
3569 3599
3570 if (needgrpUpdate) 3600 if (updateType != updatetype.none)
3571 { 3601 {
3572 HasGroupChanged = true; 3602 group.HasGroupChanged = true;
3573 ScheduleGroupForTerseUpdate(); 3603
3604 switch (updateType)
3605 {
3606 case updatetype.partterse:
3607 part.ScheduleTerseUpdate();
3608 break;
3609 case updatetype.partfull:
3610 part.ScheduleFullUpdate();
3611 break;
3612 case updatetype.groupterse:
3613 group.ScheduleGroupForTerseUpdate();
3614 break;
3615 case updatetype.groupfull:
3616 group.ScheduleGroupForFullUpdate();
3617 break;
3618 default:
3619 break;
3620 }
3574 } 3621 }
3575 } 3622 }
3576 } 3623 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f70b259..a17862e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1577,16 +1577,12 @@ namespace OpenSim.Region.Framework.Scenes
1577 /// </summary> 1577 /// </summary>
1578 /// <param name="rootObjectFlags"></param> 1578 /// <param name="rootObjectFlags"></param>
1579 /// <param name="VolumeDetectActive"></param> 1579 /// <param name="VolumeDetectActive"></param>
1580// public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) 1580
1581 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building) 1581 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building)
1582 { 1582 {
1583 if (!ParentGroup.Scene.CollidablePrims) 1583 if (!ParentGroup.Scene.CollidablePrims)
1584 return; 1584 return;
1585 1585
1586// m_log.DebugFormat(
1587// "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}",
1588// Name, LocalId, UUID, m_physicalPrim);
1589
1590 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; 1586 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0;
1591 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; 1587 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0;
1592 1588
@@ -1597,15 +1593,16 @@ namespace OpenSim.Region.Framework.Scenes
1597 else 1593 else
1598 { 1594 {
1599 // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored 1595 // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored
1600 if (VolumeDetectActive) 1596// if (VolumeDetectActive)
1601 isPhantom = false; 1597// isPhantom = false;
1602 1598
1603 // Added clarification.. since A rigid body is an object that you can kick around, etc. 1599 // Added clarification.. since A rigid body is an object that you can kick around, etc.
1604 bool RigidBody = isPhysical && !isPhantom; 1600// bool RigidBody = isPhysical && !isPhantom;
1605 1601
1606 // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition 1602 // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition
1607 // or flexible 1603 // or flexible
1608 if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) 1604 // if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1605 if ((!isPhantom || isPhysical || VolumeDetectActive) && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1609 { 1606 {
1610 Vector3 velocity = Velocity; 1607 Vector3 velocity = Velocity;
1611 Vector3 rotationalVelocity = AngularVelocity; 1608 Vector3 rotationalVelocity = AngularVelocity;
@@ -1616,9 +1613,9 @@ namespace OpenSim.Region.Framework.Scenes
1616 Shape, 1613 Shape,
1617 AbsolutePosition, 1614 AbsolutePosition,
1618 Scale, 1615 Scale,
1619// RotationOffset, 1616 GetWorldRotation(),
1620 GetWorldRotation(), // physics wants world rotation 1617 isPhysical,
1621 RigidBody, 1618 isPhantom,
1622 m_localId); 1619 m_localId);
1623 } 1620 }
1624 catch 1621 catch
@@ -1637,8 +1634,9 @@ namespace OpenSim.Region.Framework.Scenes
1637 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) 1634 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
1638 m_vehicle.SetVehicle(PhysActor); 1635 m_vehicle.SetVehicle(PhysActor);
1639 1636
1640 DoPhysicsPropertyUpdate(RigidBody, true); 1637 DoPhysicsPropertyUpdate(isPhysical, true);
1641 PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); 1638 if(VolumeDetectActive) // change if not the default only
1639 PhysActor.SetVolumeDetect(1);
1642 1640
1643 if (!building) 1641 if (!building)
1644 PhysActor.Building = false; 1642 PhysActor.Building = false;
@@ -1888,73 +1886,62 @@ namespace OpenSim.Region.Framework.Scenes
1888 { 1886 {
1889 if (UsePhysics != PhysActor.IsPhysical || isNew) 1887 if (UsePhysics != PhysActor.IsPhysical || isNew)
1890 { 1888 {
1891 if (PhysActor.IsPhysical) // implies UsePhysics==false for this block 1889 if (PhysActor.IsPhysical)
1892 { 1890 {
1893 if (!isNew) 1891 if (!isNew) // implies UsePhysics==false for this block
1892 {
1894 ParentGroup.Scene.RemovePhysicalPrim(1); 1893 ParentGroup.Scene.RemovePhysicalPrim(1);
1895 1894
1896 Velocity = new Vector3(0, 0, 0); 1895 Velocity = new Vector3(0, 0, 0);
1897 Acceleration = new Vector3(0, 0, 0); 1896 Acceleration = new Vector3(0, 0, 0);
1898 if (ParentGroup.RootPart == this) 1897 if (ParentGroup.RootPart == this)
1899 AngularVelocity = new Vector3(0, 0, 0); 1898 AngularVelocity = new Vector3(0, 0, 0);
1900 1899
1901 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 1900 if (PhysActor.Phantom)
1902 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; 1901 {
1903 PhysActor.delink(); 1902 RemoveFromPhysics();
1903 return;
1904 }
1904 1905
1905 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) 1906 PhysActor.IsPhysical = UsePhysics;
1906 { 1907 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
1907 // destroy all joints connected to this now deactivated body 1908 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
1908 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); 1909 PhysActor.delink();
1910 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
1911 {
1912 // destroy all joints connected to this now deactivated body
1913 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor);
1914 }
1909 } 1915 }
1910
1911 // stop client-side interpolation of all joint proxy objects that have just been deleted
1912 // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback,
1913 // which stops client-side interpolation of deactivated joint proxy objects.
1914 }
1915
1916 if (!UsePhysics && !isNew)
1917 {
1918 // reset velocity to 0 on physics switch-off. Without that, the client thinks the
1919 // prim still has velocity and continues to interpolate its position along the old
1920 // velocity-vector.
1921 Velocity = new Vector3(0, 0, 0);
1922 Acceleration = new Vector3(0, 0, 0);
1923 if (ParentGroup.RootPart == this)
1924 AngularVelocity = new Vector3(0, 0, 0);
1925 //RotationalVelocity = new Vector3(0, 0, 0);
1926 } 1916 }
1927 1917
1928 PhysActor.IsPhysical = UsePhysics; 1918 if (PhysActor.IsPhysical != UsePhysics)
1929 1919 PhysActor.IsPhysical = UsePhysics;
1930 // If we're not what we're supposed to be in the physics scene, recreate ourselves.
1931 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
1932 /// that's not wholesome. Had to make Scene public
1933 //PhysActor = null;
1934 1920
1935 if ((Flags & PrimFlags.Phantom) == 0) 1921 if (UsePhysics)
1936 { 1922 {
1937 if (UsePhysics) 1923 if (ParentGroup.RootPart.KeyframeMotion != null)
1938 { 1924 ParentGroup.RootPart.KeyframeMotion.Stop();
1939 if (ParentGroup.RootPart.KeyframeMotion != null) 1925 ParentGroup.RootPart.KeyframeMotion = null;
1940 ParentGroup.RootPart.KeyframeMotion.Stop(); 1926 ParentGroup.Scene.AddPhysicalPrim(1);
1941 ParentGroup.RootPart.KeyframeMotion = null;
1942 ParentGroup.Scene.AddPhysicalPrim(1);
1943 1927
1944 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 1928 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
1945 PhysActor.OnOutOfBounds += PhysicsOutOfBounds; 1929 PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
1946 1930
1947 if (ParentID != 0 && ParentID != LocalId) 1931 if (ParentID != 0 && ParentID != LocalId)
1932 {
1933 if (ParentGroup.RootPart.PhysActor != null)
1948 { 1934 {
1949 if (ParentGroup.RootPart.PhysActor != null) 1935 PhysActor.link(ParentGroup.RootPart.PhysActor);
1950 {
1951 PhysActor.link(ParentGroup.RootPart.PhysActor);
1952 }
1953 } 1936 }
1954 } 1937 }
1955 } 1938 }
1956 } 1939 }
1957 1940
1941 bool phan = ((Flags & PrimFlags.Phantom) != 0);
1942 if (PhysActor.Phantom != phan)
1943 PhysActor.Phantom = phan;
1944
1958 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the 1945 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the
1959 // mesh data. 1946 // mesh data.
1960 if (Shape.SculptEntry) 1947 if (Shape.SculptEntry)
@@ -4355,40 +4342,45 @@ namespace OpenSim.Region.Framework.Scenes
4355 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4342 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4356 bool wasVD = VolumeDetectActive; 4343 bool wasVD = VolumeDetectActive;
4357 4344
4358// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4359// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4360
4361 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4345 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4362 return; 4346 return;
4363 4347
4348 // do this first
4349 if (building && PhysActor != null && PhysActor.Building != building)
4350 PhysActor.Building = building;
4351
4364 // Special cases for VD. VD can only be called from a script 4352 // Special cases for VD. VD can only be called from a script
4365 // and can't be combined with changes to other states. So we can rely 4353 // and can't be combined with changes to other states. So we can rely
4366 // that... 4354 // that...
4367 // ... if VD is changed, all others are not. 4355 // ... if VD is changed, all others are not.
4368 // ... if one of the others is changed, VD is not. 4356 // ... if one of the others is changed, VD is not.
4369 // do this first 4357
4370 if (building && PhysActor != null && PhysActor.Building != building)
4371 PhysActor.Building = building;
4372 if (SetVD) // VD is active, special logic applies 4358 if (SetVD) // VD is active, special logic applies
4373 {
4374 // State machine logic for VolumeDetect
4375 // More logic below
4376 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
4377 4359
4378 if (phanReset) // Phantom changes from on to off switch VD off too 4360 /* volume detection is now independent of phantom in sl
4379 { 4361
4380 SetVD = false; // Switch it of for the course of this routine 4362 {
4381 VolumeDetectActive = false; // and also permanently 4363 // State machine logic for VolumeDetect
4382 if (PhysActor != null) 4364 // More logic below
4383 PhysActor.SetVolumeDetect(0); // Let physics know about it too 4365
4384 } 4366
4385 else 4367 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
4386 { 4368
4387 // If volumedetect is active we don't want phantom to be applied. 4369 if (phanReset) // Phantom changes from on to off switch VD off too
4388 // If this is a new call to VD out of the state "phantom" 4370 {
4389 // this will also cause the prim to be visible to physics 4371 SetVD = false; // Switch it of for the course of this routine
4372 VolumeDetectActive = false; // and also permanently
4373 if (PhysActor != null)
4374 PhysActor.SetVolumeDetect(0); // Let physics know about it too
4375 }
4376 else
4377 {
4378 // If volumedetect is active we don't want phantom to be applied.
4379 // If this is a new call to VD out of the state "phantom"
4380 // this will also cause the prim to be visible to physics
4381 */
4390 SetPhantom = false; 4382 SetPhantom = false;
4391 } 4383/* }
4392 } 4384 }
4393 else if (wasVD) 4385 else if (wasVD)
4394 { 4386 {
@@ -4400,10 +4392,11 @@ namespace OpenSim.Region.Framework.Scenes
4400 { 4392 {
4401 SetPhantom = true; 4393 SetPhantom = true;
4402 } 4394 }
4403 4395*/
4404 if (UsePhysics) 4396 if (UsePhysics)
4405 { 4397 {
4406 AddFlag(PrimFlags.Physics); 4398 AddFlag(PrimFlags.Physics);
4399/*
4407 if (!wasUsingPhysics) 4400 if (!wasUsingPhysics)
4408 { 4401 {
4409 DoPhysicsPropertyUpdate(UsePhysics, false); 4402 DoPhysicsPropertyUpdate(UsePhysics, false);
@@ -4416,84 +4409,99 @@ namespace OpenSim.Region.Framework.Scenes
4416 } 4409 }
4417 } 4410 }
4418 } 4411 }
4412 */
4419 } 4413 }
4420 else 4414 else
4421 { 4415 {
4422 RemFlag(PrimFlags.Physics); 4416 RemFlag(PrimFlags.Physics);
4417/*
4423 if (wasUsingPhysics) 4418 if (wasUsingPhysics)
4424 { 4419 {
4425 DoPhysicsPropertyUpdate(UsePhysics, false); 4420 DoPhysicsPropertyUpdate(UsePhysics, false);
4426 } 4421 }
4427 } 4422*/
4423 }
4428 4424
4429 if (SetPhantom 4425 if (SetPhantom)
4430 || ParentGroup.IsAttachment 4426 AddFlag(PrimFlags.Phantom);
4427 else
4428 RemFlag(PrimFlags.Phantom);
4429
4430 if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment
4431 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints 4431 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4432 { 4432 {
4433 AddFlag(PrimFlags.Phantom); 4433 AddFlag(PrimFlags.Phantom);
4434 4434
4435 Velocity = new Vector3(0, 0, 0);
4436 Acceleration = new Vector3(0, 0, 0);
4437 if (ParentGroup.RootPart == this)
4438 AngularVelocity = new Vector3(0, 0, 0);
4439
4435 if (PhysActor != null) 4440 if (PhysActor != null)
4441 {
4442 ParentGroup.Scene.RemovePhysicalPrim(1);
4436 RemoveFromPhysics(); 4443 RemoveFromPhysics();
4444 }
4437 } 4445 }
4438 else // Not phantom 4446 else
4439 { 4447 {
4440 RemFlag(PrimFlags.Phantom);
4441
4442 if (ParentGroup.Scene == null) 4448 if (ParentGroup.Scene == null)
4443 return; 4449 return;
4444 4450
4445 if (ParentGroup.Scene.CollidablePrims && PhysActor == null) 4451 if (ParentGroup.Scene.CollidablePrims)
4446 { 4452 {
4447 // It's not phantom anymore. So make sure the physics engine get's knowledge of it 4453 if (PhysActor == null)
4448 PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4454 {
4449 string.Format("{0}/{1}", Name, UUID), 4455 PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape(
4450 Shape, 4456 string.Format("{0}/{1}", Name, UUID),
4451 AbsolutePosition, 4457 Shape,
4452 Scale, 4458 AbsolutePosition,
4453// RotationOffset, 4459 Scale,
4454 GetWorldRotation(), //physics wants world rotation like all other functions send 4460 GetWorldRotation(), //physics wants world rotation like all other functions send
4455 UsePhysics, 4461 UsePhysics,
4456 m_localId); 4462 SetPhantom,
4463 m_localId);
4457 4464
4458 PhysActor.SetMaterial(Material); 4465 PhysActor.SetMaterial(Material);
4466
4467 // if root part apply vehicle
4468 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
4469 m_vehicle.SetVehicle(PhysActor);
4459 4470
4460 // if root part apply vehicle 4471 DoPhysicsPropertyUpdate(UsePhysics, true);
4461 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
4462 m_vehicle.SetVehicle(PhysActor);
4463 4472
4464 DoPhysicsPropertyUpdate(UsePhysics, true); 4473 if (!ParentGroup.IsDeleted)
4474 {
4475 if (LocalId == ParentGroup.RootPart.LocalId)
4476 {
4477 ParentGroup.CheckSculptAndLoad();
4478 }
4479 }
4465 4480
4466 if (!ParentGroup.IsDeleted) 4481 if (
4467 { 4482 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4468 if (LocalId == ParentGroup.RootPart.LocalId) 4483 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4484 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4485 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4486 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4487 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4488 (CollisionSound != UUID.Zero)
4489 )
4469 { 4490 {
4470 ParentGroup.CheckSculptAndLoad(); 4491 PhysActor.OnCollisionUpdate += PhysicsCollision;
4492 PhysActor.SubscribeEvents(1000);
4471 } 4493 }
4472 } 4494 }
4473 4495 else // it already has a physical representation
4474 if (
4475 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4476 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4477 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4478 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4479 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4480 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4481 (CollisionSound != UUID.Zero)
4482 )
4483 { 4496 {
4484 PhysActor.OnCollisionUpdate += PhysicsCollision; 4497 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4485 PhysActor.SubscribeEvents(1000);
4486 }
4487 }
4488 else // it already has a physical representation
4489 {
4490 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
4491 4498
4492 if (!ParentGroup.IsDeleted) 4499 if (!ParentGroup.IsDeleted)
4493 {
4494 if (LocalId == ParentGroup.RootPart.LocalId)
4495 { 4500 {
4496 ParentGroup.CheckSculptAndLoad(); 4501 if (LocalId == ParentGroup.RootPart.LocalId)
4502 {
4503 ParentGroup.CheckSculptAndLoad();
4504 }
4497 } 4505 }
4498 } 4506 }
4499 } 4507 }
@@ -4509,7 +4517,7 @@ namespace OpenSim.Region.Framework.Scenes
4509 if (this.PhysActor != null) 4517 if (this.PhysActor != null)
4510 { 4518 {
4511 PhysActor.SetVolumeDetect(1); 4519 PhysActor.SetVolumeDetect(1);
4512 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active 4520// AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4513 this.VolumeDetectActive = true; 4521 this.VolumeDetectActive = true;
4514 } 4522 }
4515 } 4523 }
@@ -4517,8 +4525,7 @@ namespace OpenSim.Region.Framework.Scenes
4517 { 4525 {
4518 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like 4526 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4519 // (mumbles, well, at least if you have infinte CPU powers :-)) 4527 // (mumbles, well, at least if you have infinte CPU powers :-))
4520 PhysicsActor pa = this.PhysActor; 4528 if (this.PhysActor != null)
4521 if (pa != null)
4522 { 4529 {
4523 PhysActor.SetVolumeDetect(0); 4530 PhysActor.SetVolumeDetect(0);
4524 } 4531 }
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 668b53b..fd90714 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -31,170 +31,9 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using System;
35 34
36namespace OpenSim.Region.Framework.Scenes 35namespace OpenSim.Region.Framework.Scenes
37{ 36{
38
39/*
40 [Flags]
41 public enum UndoType
42 {
43 STATE_PRIM_POSITION = 1,
44 STATE_PRIM_ROTATION = 2,
45 STATE_PRIM_SCALE = 4,
46 STATE_PRIM_ALL = 7,
47 STATE_GROUP_POSITION = 8,
48 STATE_GROUP_ROTATION = 16,
49 STATE_GROUP_SCALE = 32,
50 STATE_GROUP_ALL = 56,
51 STATE_ALL = 63
52 }
53
54
55 public class UndoState
56 {
57 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58
59 public Vector3 Position = Vector3.Zero;
60 public Vector3 Scale = Vector3.Zero;
61 public Quaternion Rotation = Quaternion.Identity;
62
63 /// <summary>
64 /// Is this undo state for an entire group?
65 /// </summary>
66 public bool ForGroup;
67
68 /// <summary>
69 /// Constructor.
70 /// </summary>
71 /// <param name="part"></param>
72 /// <param name="forGroup">True if the undo is for an entire group</param>
73 /// only for root parts ????
74 public UndoState(SceneObjectPart part, bool forGroup)
75 {
76 if (part.ParentID == 0)
77 {
78 ForGroup = forGroup;
79 Position = part.ParentGroup.AbsolutePosition;
80 Rotation = part.RotationOffset;
81 Scale = part.Shape.Scale;
82 }
83 else
84 {
85 ForGroup = false; // only root parts can undo grp
86 Position = part.OffsetPosition;
87 Rotation = part.RotationOffset;
88 Scale = part.Shape.Scale;
89 }
90 }
91
92 /// <summary>
93 /// Compare the relevant state in the given part to this state.
94 /// </summary>
95 /// <param name="part"></param>
96 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
97 public bool Compare(SceneObjectPart part, bool forgrp)
98 {
99 if (ForGroup != forgrp) // if diferent targets, then they are diferent
100 return false;
101
102 if (part != null)
103 {
104 if (part.ParentID == 0)
105 {
106 // root part
107 // grp position is same as part
108 if (Position != part.ParentGroup.AbsolutePosition)
109 return false;
110 if (Rotation != part.RotationOffset)
111 return false;
112 return Scale == part.Shape.Scale;
113 }
114 else
115 {
116 return (Position == part.OffsetPosition
117 && Rotation == part.RotationOffset
118 && Scale == part.Shape.Scale);
119 }
120 }
121
122 return false;
123 }
124
125 public void PlayState(SceneObjectPart part)
126 {
127 part.Undoing = true;
128 bool physbuilding = false;
129
130 if (part.ParentID == 0)
131 {
132 if (!ForGroup && part.PhysActor != null)
133 {
134 part.PhysActor.Building = true;
135 physbuilding = true;
136 }
137
138 if (Position != Vector3.Zero)
139 {
140 if (ForGroup)
141 part.ParentGroup.AbsolutePosition = Position;
142 else
143 part.ParentGroup.UpdateRootPosition(Position);
144 }
145
146 if (ForGroup)
147 part.UpdateRotation(Rotation);
148 else
149 part.ParentGroup.UpdateRootRotation(Rotation);
150
151 if (Scale != Vector3.Zero)
152 {
153 if (!physbuilding && part.PhysActor != null)
154 {
155 part.PhysActor.Building = true;
156 physbuilding = true;
157 }
158
159 if (ForGroup)
160 part.ParentGroup.GroupResize(Scale);
161 else
162 part.Resize(Scale);
163 }
164
165 if (physbuilding)
166 part.PhysActor.Building = false;
167
168 part.ParentGroup.ScheduleGroupForTerseUpdate();
169 }
170 else
171 {
172 if (ForGroup) // trap for group since seems parts can't do it
173 return;
174
175 // changing a part invalidates entire object physical rep
176 if (part.ParentGroup != null && part.ParentGroup.RootPart != null && part.ParentGroup.RootPart.PhysActor != null)
177 {
178 part.ParentGroup.RootPart.PhysActor.Building = true;
179 physbuilding = true;
180 }
181
182 // Note: Updating these properties on sop automatically schedules an update if needed
183 part.OffsetPosition = Position;
184 part.UpdateRotation(Rotation);
185 if (Scale != Vector3.Zero)
186 {
187 part.Resize(Scale);
188 }
189
190 if (physbuilding)
191 part.ParentGroup.RootPart.PhysActor.Building = false;
192 }
193
194 part.Undoing = false;
195 }
196 }
197*/
198 public class UndoState 37 public class UndoState
199 { 38 {
200 const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) 39 const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later)
@@ -205,8 +44,8 @@ namespace OpenSim.Region.Framework.Scenes
205 /// Constructor. 44 /// Constructor.
206 /// </summary> 45 /// </summary>
207 /// <param name="part"></param> 46 /// <param name="part"></param>
208 /// <param name="forGroup">True if the undo is for an entire group</param> 47 /// <param name="what">bit field with what is changed</param>
209 /// only for root parts ???? 48 ///
210 public UndoState(SceneObjectPart part, ObjectChangeWhat what) 49 public UndoState(SceneObjectPart part, ObjectChangeWhat what)
211 { 50 {
212 data = new ObjectChangeData(); 51 data = new ObjectChangeData();
@@ -232,6 +71,9 @@ namespace OpenSim.Region.Framework.Scenes
232 data.scale = part.Shape.Scale; 71 data.scale = part.Shape.Scale;
233 } 72 }
234 } 73 }
74 /// <summary>
75 /// check if undo or redo is too old
76 /// </summary>
235 77
236 public bool checkExpire() 78 public bool checkExpire()
237 { 79 {
@@ -241,6 +83,9 @@ namespace OpenSim.Region.Framework.Scenes
241 return false; 83 return false;
242 } 84 }
243 85
86 /// <summary>
87 /// updates undo or redo creation time to now
88 /// </summary>
244 public void updateExpire() 89 public void updateExpire()
245 { 90 {
246 creationtime = DateTime.UtcNow; 91 creationtime = DateTime.UtcNow;
@@ -250,7 +95,8 @@ namespace OpenSim.Region.Framework.Scenes
250 /// Compare the relevant state in the given part to this state. 95 /// Compare the relevant state in the given part to this state.
251 /// </summary> 96 /// </summary>
252 /// <param name="part"></param> 97 /// <param name="part"></param>
253 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> 98 /// <returns>true what fiels and related data are equal, False otherwise.</returns>
99 ///
254 public bool Compare(SceneObjectPart part, ObjectChangeWhat what) 100 public bool Compare(SceneObjectPart part, ObjectChangeWhat what)
255 { 101 {
256 if (data.what != what) // if diferent targets, then they are diferent 102 if (data.what != what) // if diferent targets, then they are diferent
@@ -279,6 +125,12 @@ namespace OpenSim.Region.Framework.Scenes
279 return false; 125 return false;
280 } 126 }
281 127
128 /// <summary>
129 /// executes the undo or redo to a part or its group
130 /// </summary>
131 /// <param name="part"></param>
132 ///
133
282 public void PlayState(SceneObjectPart part) 134 public void PlayState(SceneObjectPart part)
283 { 135 {
284 part.Undoing = true; 136 part.Undoing = true;
@@ -298,12 +150,21 @@ namespace OpenSim.Region.Framework.Scenes
298 int size; 150 int size;
299 public LinkedList<UndoState> m_redo = new LinkedList<UndoState>(); 151 public LinkedList<UndoState> m_redo = new LinkedList<UndoState>();
300 public LinkedList<UndoState> m_undo = new LinkedList<UndoState>(); 152 public LinkedList<UndoState> m_undo = new LinkedList<UndoState>();
301 153
154 /// <summary>
155 /// creates a new UndoRedoState with default states memory size
156 /// </summary>
157
302 public UndoRedoState() 158 public UndoRedoState()
303 { 159 {
304 size = 5; 160 size = 5;
305 } 161 }
306 162
163 /// <summary>
164 /// creates a new UndoRedoState with states memory having indicated size
165 /// </summary>
166 /// <param name="size"></param>
167
307 public UndoRedoState(int _size) 168 public UndoRedoState(int _size)
308 { 169 {
309 if (_size < 3) 170 if (_size < 3)
@@ -312,17 +173,31 @@ namespace OpenSim.Region.Framework.Scenes
312 size = _size; 173 size = _size;
313 } 174 }
314 175
176 /// <summary>
177 /// returns number of undo entries in memory
178 /// </summary>
179
315 public int Count 180 public int Count
316 { 181 {
317 get { return m_undo.Count; } 182 get { return m_undo.Count; }
318 } 183 }
319 184
185 /// <summary>
186 /// clears all undo and redo entries
187 /// </summary>
188
320 public void Clear() 189 public void Clear()
321 { 190 {
322 m_undo.Clear(); 191 m_undo.Clear();
323 m_redo.Clear(); 192 m_redo.Clear();
324 } 193 }
325 194
195 /// <summary>
196 /// adds a new state undo to part or its group, with changes indicated by what bits
197 /// </summary>
198 /// <param name="part"></param>
199 /// <param name="what">bit field with what is changed</param>
200
326 public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what) 201 public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what)
327 { 202 {
328 lock (m_undo) 203 lock (m_undo)
@@ -360,6 +235,12 @@ namespace OpenSim.Region.Framework.Scenes
360 } 235 }
361 } 236 }
362 237
238 /// <summary>
239 /// executes last state undo to part or its group
240 /// current state is pushed into redo
241 /// </summary>
242 /// <param name="part"></param>
243
363 public void Undo(SceneObjectPart part) 244 public void Undo(SceneObjectPart part)
364 { 245 {
365 lock (m_undo) 246 lock (m_undo)
@@ -401,6 +282,12 @@ namespace OpenSim.Region.Framework.Scenes
401 } 282 }
402 } 283 }
403 284
285 /// <summary>
286 /// executes last state redo to part or its group
287 /// current state is pushed into undo
288 /// </summary>
289 /// <param name="part"></param>
290
404 public void Redo(SceneObjectPart part) 291 public void Redo(SceneObjectPart part)
405 { 292 {
406 lock (m_undo) 293 lock (m_undo)
@@ -441,8 +328,6 @@ namespace OpenSim.Region.Framework.Scenes
441 } 328 }
442 } 329 }
443 } 330 }
444
445
446 } 331 }
447 332
448 public class LandUndoState 333 public class LandUndoState
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 3ed3b5a..f9548d2 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -131,6 +131,7 @@ namespace OpenSim.Region.Physics.OdePlugin
131 public bool m_disabled; 131 public bool m_disabled;
132 public bool m_taintadd; 132 public bool m_taintadd;
133 public bool m_taintselected; 133 public bool m_taintselected;
134 public bool m_taintphantom;
134 public bool m_taintCollidesWater; 135 public bool m_taintCollidesWater;
135 136
136 public uint m_localID; 137 public uint m_localID;
@@ -161,6 +162,7 @@ namespace OpenSim.Region.Physics.OdePlugin
161 162
162 private bool iscolliding; 163 private bool iscolliding;
163 private bool m_isphysical; 164 private bool m_isphysical;
165 private bool m_isphantom;
164 private bool m_isSelected; 166 private bool m_isSelected;
165 167
166 private bool m_NoColide; // for now only for internal use for bad meshs 168 private bool m_NoColide; // for now only for internal use for bad meshs
@@ -311,8 +313,9 @@ namespace OpenSim.Region.Physics.OdePlugin
311 m_taintvehicledata = vdata; 313 m_taintvehicledata = vdata;
312 _parent_scene.AddPhysicsActorTaint(this); 314 _parent_scene.AddPhysicsActorTaint(this);
313 } 315 }
316
314 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, 317 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
315 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, uint localid) 318 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical,bool pisPhantom, CollisionLocker dode, uint localid)
316 { 319 {
317 m_localID = localid; 320 m_localID = localid;
318 ode = dode; 321 ode = dode;
@@ -373,6 +376,9 @@ namespace OpenSim.Region.Physics.OdePlugin
373 m_targetSpace = _parent_scene.space; 376 m_targetSpace = _parent_scene.space;
374 } 377 }
375 378
379 m_isphantom = pisPhantom;
380 m_taintphantom = pisPhantom;
381
376 _triMeshData = IntPtr.Zero; 382 _triMeshData = IntPtr.Zero;
377 m_NoColide = false; 383 m_NoColide = false;
378 384
@@ -447,6 +453,15 @@ namespace OpenSim.Region.Physics.OdePlugin
447 } 453 }
448 } 454 }
449 455
456 public override bool Phantom
457 {
458 get { return m_isphantom; }
459 set
460 {
461 m_isphantom = value;
462 }
463 }
464
450 public void setPrimForRemoval() 465 public void setPrimForRemoval()
451 { 466 {
452 m_taintremove = true; 467 m_taintremove = true;
@@ -890,7 +905,7 @@ namespace OpenSim.Region.Physics.OdePlugin
890 if (m_NoColide) 905 if (m_NoColide)
891 { 906 {
892 d.GeomSetCategoryBits(prim_geom, 0); 907 d.GeomSetCategoryBits(prim_geom, 0);
893 if (m_isphysical) 908 if (m_isphysical && !m_isVolumeDetect)
894 { 909 {
895 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); 910 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
896 } 911 }
@@ -1399,10 +1414,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1399 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1414 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1400 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1415 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1401 } 1416 }
1402
1403 } 1417 }
1404 1418
1405
1406 Body = IntPtr.Zero; 1419 Body = IntPtr.Zero;
1407 } 1420 }
1408 } 1421 }
@@ -1410,7 +1423,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1410 m_collisionscore = 0; 1423 m_collisionscore = 0;
1411 } 1424 }
1412 1425
1413 private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>(); 1426// private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>();
1414 1427
1415 public bool setMesh(OdeScene parent_scene, IMesh mesh) 1428 public bool setMesh(OdeScene parent_scene, IMesh mesh)
1416 { 1429 {
@@ -1507,12 +1520,17 @@ namespace OpenSim.Region.Physics.OdePlugin
1507 } 1520 }
1508 } 1521 }
1509 // 1522 //
1523 if (m_taintphantom != m_isphantom )
1524 {
1525 changePhantomStatus();
1526 }//
1510 1527
1511 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) 1528 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent))
1512 { 1529 {
1513 changePhysicsStatus(timestep); 1530 changePhysicsStatus(timestep);
1514 }// 1531 }//
1515 1532
1533
1516 if (!_size.ApproxEquals(m_taintsize, 0f)) 1534 if (!_size.ApproxEquals(m_taintsize, 0f))
1517 changesize(timestep); 1535 changesize(timestep);
1518 // 1536 //
@@ -1534,7 +1552,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1534 changedisable(timestep); 1552 changedisable(timestep);
1535 1553
1536 if (m_taintselected != m_isSelected) 1554 if (m_taintselected != m_isSelected)
1537 changeSelectedStatus(timestep); 1555 changeSelectedStatus();
1538 1556
1539 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) 1557 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
1540 changevelocity(timestep); 1558 changevelocity(timestep);
@@ -1565,16 +1583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1565 1583
1566 } 1584 }
1567 1585
1568 /* obsolete
1569 private void changeAngularLock(float timestep)
1570 {
1571 if (_parent == null)
1572 {
1573 m_angularLock = m_taintAngularLock;
1574 m_angularLockSet = true;
1575 }
1576 }
1577 */
1578 private void changelink(float timestep) 1586 private void changelink(float timestep)
1579 { 1587 {
1580 // If the newly set parent is not null 1588 // If the newly set parent is not null
@@ -1584,18 +1592,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1584 if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) 1592 if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
1585 { 1593 {
1586 OdePrim obj = (OdePrim)m_taintparent; 1594 OdePrim obj = (OdePrim)m_taintparent;
1587 //obj.disableBody();
1588 obj.ParentPrim(this); 1595 obj.ParentPrim(this);
1589
1590 /*
1591 if (obj.Body != (IntPtr)0 && Body != (IntPtr)0 && obj.Body != Body)
1592 {
1593 _linkJointGroup = d.JointGroupCreate(0);
1594 m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
1595 d.JointAttach(m_linkJoint, obj.Body, Body);
1596 d.JointSetFixed(m_linkJoint);
1597 }
1598 */
1599 } 1596 }
1600 } 1597 }
1601 // If the newly set parent is null 1598 // If the newly set parent is null
@@ -1607,16 +1604,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1607 OdePrim obj = (OdePrim)_parent; 1604 OdePrim obj = (OdePrim)_parent;
1608 obj.ChildDelink(this); 1605 obj.ChildDelink(this);
1609 childPrim = false; 1606 childPrim = false;
1610 //_parent = null;
1611 } 1607 }
1612
1613 /*
1614 if (Body != (IntPtr)0 && _linkJointGroup != (IntPtr)0)
1615 d.JointGroupDestroy(_linkJointGroup);
1616
1617 _linkJointGroup = (IntPtr)0;
1618 m_linkJoint = (IntPtr)0;
1619 */
1620 } 1608 }
1621 1609
1622 _parent = m_taintparent; 1610 _parent = m_taintparent;
@@ -1666,9 +1654,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1666 } 1654 }
1667 foreach (OdePrim prm in childrenPrim) 1655 foreach (OdePrim prm in childrenPrim)
1668 { 1656 {
1669 prm.m_collisionCategories |= CollisionCategories.Body; 1657 if (m_isphantom && !prm.m_isVolumeDetect)
1670 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1658 {
1671 1659 prm.m_collisionCategories = 0;
1660 prm.m_collisionFlags = CollisionCategories.Land;
1661 }
1662 else
1663 {
1664 prm.m_collisionCategories |= CollisionCategories.Body;
1665 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1666 }
1672 if (prm.prim_geom == IntPtr.Zero) 1667 if (prm.prim_geom == IntPtr.Zero)
1673 { 1668 {
1674 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); 1669 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet");
@@ -1722,8 +1717,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1722 _parent_scene.addActivePrim(prm); 1717 _parent_scene.addActivePrim(prm);
1723 } 1718 }
1724 1719
1725 m_collisionCategories |= CollisionCategories.Body; 1720 if (m_isphantom && !m_isVolumeDetect)
1726 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1721 {
1722 m_collisionCategories = 0;
1723 m_collisionFlags = CollisionCategories.Land;
1724 }
1725 else
1726 {
1727 m_collisionCategories |= CollisionCategories.Body;
1728 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1729 }
1727 1730
1728 if (m_NoColide) 1731 if (m_NoColide)
1729 { 1732 {
@@ -1773,23 +1776,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1773 1776
1774 private void ChildSetGeom(OdePrim odePrim) 1777 private void ChildSetGeom(OdePrim odePrim)
1775 { 1778 {
1776 //if (m_isphysical && Body != IntPtr.Zero)
1777 lock (childrenPrim) 1779 lock (childrenPrim)
1778 { 1780 {
1779 foreach (OdePrim prm in childrenPrim) 1781 foreach (OdePrim prm in childrenPrim)
1780 { 1782 {
1781 //prm.childPrim = true;
1782 prm.disableBody(); 1783 prm.disableBody();
1783 //prm.m_taintparent = null;
1784 //prm._parent = null;
1785 //prm.m_taintPhysics = false;
1786 //prm.m_disabled = true;
1787 //prm.childPrim = false;
1788 } 1784 }
1789 } 1785 }
1790 disableBody(); 1786 disableBody();
1791 1787
1792
1793 if (Body != IntPtr.Zero) 1788 if (Body != IntPtr.Zero)
1794 { 1789 {
1795 _parent_scene.remActivePrim(this); 1790 _parent_scene.remActivePrim(this);
@@ -1802,7 +1797,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1802 ParentPrim(prm); 1797 ParentPrim(prm);
1803 } 1798 }
1804 } 1799 }
1805
1806 } 1800 }
1807 1801
1808 private void ChildDelink(OdePrim odePrim) 1802 private void ChildDelink(OdePrim odePrim)
@@ -1814,11 +1808,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1814 { 1808 {
1815 prm.childPrim = true; 1809 prm.childPrim = true;
1816 prm.disableBody(); 1810 prm.disableBody();
1817 //prm.m_taintparent = null;
1818 //prm._parent = null;
1819 //prm.m_taintPhysics = false;
1820 //prm.m_disabled = true;
1821 //prm.childPrim = false;
1822 } 1811 }
1823 } 1812 }
1824 disableBody(); 1813 disableBody();
@@ -1842,7 +1831,73 @@ namespace OpenSim.Region.Physics.OdePlugin
1842 } 1831 }
1843 } 1832 }
1844 1833
1845 private void changeSelectedStatus(float timestep) 1834 private void changePhantomStatus()
1835 {
1836 m_taintphantom = m_isphantom;
1837 changeSelectedStatus();
1838 }
1839
1840/* not in use
1841 private void SetCollider()
1842 {
1843 SetCollider(m_isSelected, m_isphysical, m_isphantom, m_isSelected);
1844 }
1845
1846 private void SetCollider(bool sel, bool phys, bool phan, bool vdtc)
1847 {
1848 if (sel)
1849 {
1850 m_collisionCategories = CollisionCategories.Selected;
1851 m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
1852 }
1853 else
1854 {
1855 if (phan && !vdtc)
1856 {
1857 m_collisionCategories = 0;
1858 if (phys)
1859 m_collisionFlags = CollisionCategories.Land;
1860 else
1861 m_collisionFlags = 0; // this case should not happen non physical phantoms should not have physics
1862 }
1863 else
1864 {
1865 m_collisionCategories = CollisionCategories.Geom;
1866 if (phys)
1867 m_collisionCategories |= CollisionCategories.Body;
1868
1869 m_collisionFlags = m_default_collisionFlags;
1870
1871 if (m_collidesLand)
1872 m_collisionFlags |= CollisionCategories.Land;
1873 if (m_collidesWater)
1874 m_collisionFlags |= CollisionCategories.Water;
1875 }
1876 }
1877
1878 if (prim_geom != IntPtr.Zero)
1879 {
1880 if (m_NoColide)
1881 {
1882 d.GeomSetCategoryBits(prim_geom, 0);
1883 if (phys)
1884 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
1885 else
1886 {
1887 d.GeomSetCollideBits(prim_geom, 0);
1888 d.GeomDisable(prim_geom);
1889 }
1890 }
1891 else
1892 {
1893 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1894 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1895 }
1896 }
1897 }
1898*/
1899
1900 private void changeSelectedStatus()
1846 { 1901 {
1847 if (m_taintselected) 1902 if (m_taintselected)
1848 { 1903 {
@@ -1895,10 +1950,19 @@ namespace OpenSim.Region.Physics.OdePlugin
1895 d.BodySetAngularVel(Body, 0.0f, 0.0f, 0.0f); 1950 d.BodySetAngularVel(Body, 0.0f, 0.0f, 0.0f);
1896 d.BodySetTorque(Body, 0.0f, 0.0f, 0.0f); 1951 d.BodySetTorque(Body, 0.0f, 0.0f, 0.0f);
1897 } 1952 }
1898
1899 } 1953 }
1900 else 1954 else
1901 { 1955 {
1956 if (m_isphantom && !m_isVolumeDetect)
1957 {
1958 m_collisionCategories = 0;
1959 if (m_isphysical)
1960 m_collisionFlags = CollisionCategories.Land;
1961 else
1962 m_collisionFlags = 0; // this case should not happen non physical phantoms should not have physics
1963 }
1964 else
1965 {
1902 m_collisionCategories = CollisionCategories.Geom; 1966 m_collisionCategories = CollisionCategories.Geom;
1903 if (m_isphysical) 1967 if (m_isphysical)
1904 m_collisionCategories |= CollisionCategories.Body; 1968 m_collisionCategories |= CollisionCategories.Body;
@@ -1909,6 +1973,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1909 m_collisionFlags |= CollisionCategories.Land; 1973 m_collisionFlags |= CollisionCategories.Land;
1910 if (m_collidesWater) 1974 if (m_collidesWater)
1911 m_collisionFlags |= CollisionCategories.Water; 1975 m_collisionFlags |= CollisionCategories.Water;
1976 }
1912 1977
1913 if (prim_geom != IntPtr.Zero) 1978 if (prim_geom != IntPtr.Zero)
1914 { 1979 {
@@ -2086,7 +2151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2086 } 2151 }
2087 } 2152 }
2088 2153
2089 changeSelectedStatus(timestep); 2154 changeSelectedStatus();
2090 2155
2091 m_taintadd = false; 2156 m_taintadd = false;
2092 } 2157 }
@@ -2161,7 +2226,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2161 } 2226 }
2162 } 2227 }
2163 2228
2164 changeSelectedStatus(timestep); 2229 changeSelectedStatus();
2165 2230
2166 resetCollisionAccounting(); 2231 resetCollisionAccounting();
2167 m_taintposition = _position; 2232 m_taintposition = _position;
@@ -2248,7 +2313,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2248 } 2313 }
2249 } 2314 }
2250 2315
2251 changeSelectedStatus(timestep); 2316 changeSelectedStatus();
2252 2317
2253 resetCollisionAccounting(); 2318 resetCollisionAccounting();
2254 m_taintPhysics = m_isphysical; 2319 m_taintPhysics = m_isphysical;
@@ -2342,7 +2407,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2342 2407
2343 _parent_scene.geom_name_map[prim_geom] = oldname; 2408 _parent_scene.geom_name_map[prim_geom] = oldname;
2344 2409
2345 changeSelectedStatus(timestamp); 2410 changeSelectedStatus();
2346 if (childPrim) 2411 if (childPrim)
2347 { 2412 {
2348 if (_parent is OdePrim) 2413 if (_parent is OdePrim)
@@ -2454,7 +2519,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2454 } 2519 }
2455 _parent_scene.geom_name_map[prim_geom] = oldname; 2520 _parent_scene.geom_name_map[prim_geom] = oldname;
2456 2521
2457 changeSelectedStatus(timestamp); 2522 changeSelectedStatus();
2458 if (childPrim) 2523 if (childPrim)
2459 { 2524 {
2460 if (_parent is OdePrim) 2525 if (_parent is OdePrim)
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
index 05f6fae..ea89d87 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
@@ -1730,7 +1730,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1730 OdePrim newPrim; 1730 OdePrim newPrim;
1731 lock (OdeLock) 1731 lock (OdeLock)
1732 { 1732 {
1733 newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, ode, localid); 1733 newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical,false, ode, localid);
1734 1734
1735 lock (_prims) 1735 lock (_prims)
1736 _prims.Add(newPrim); 1736 _prims.Add(newPrim);
@@ -1738,23 +1738,27 @@ namespace OpenSim.Region.Physics.OdePlugin
1738 1738
1739 return newPrim; 1739 return newPrim;
1740 } 1740 }
1741/* 1741
1742 private PhysicsActor AddPrim(String name, Vector3 position, PhysicsActor parent, 1742 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1743 PrimitiveBaseShape pbs, uint localid, byte[] sdata) 1743 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, bool isphantom, uint localid)
1744 { 1744 {
1745
1745 Vector3 pos = position; 1746 Vector3 pos = position;
1747 Vector3 siz = size;
1748 Quaternion rot = rotation;
1746 1749
1747 OdePrim newPrim; 1750 OdePrim newPrim;
1748 lock (OdeLock) 1751 lock (OdeLock)
1749 { 1752 {
1750 newPrim = new OdePrim(name, this, pos, parent, pbs, ode, localid, sdata); 1753 newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, isphantom, ode, localid);
1754
1751 lock (_prims) 1755 lock (_prims)
1752 _prims.Add(newPrim); 1756 _prims.Add(newPrim);
1753 } 1757 }
1754 1758
1755 return newPrim; 1759 return newPrim;
1756 } 1760 }
1757*/ 1761
1758 1762
1759 public void addActivePrim(OdePrim activatePrim) 1763 public void addActivePrim(OdePrim activatePrim)
1760 { 1764 {
@@ -1781,6 +1785,23 @@ namespace OpenSim.Region.Physics.OdePlugin
1781 1785
1782 return result; 1786 return result;
1783 } 1787 }
1788
1789 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1790 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid)
1791 {
1792 PhysicsActor result;
1793 IMesh mesh = null;
1794
1795 if (needsMeshing(pbs))
1796 mesh = mesher.CreateMesh(primName, pbs, size, (int)LevelOfDetail.High, true);
1797
1798 result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, isPhantom, localid);
1799
1800 return result;
1801 }
1802
1803
1804
1784/* 1805/*
1785 public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position, 1806 public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position,
1786 uint localid, byte[] sdata) 1807 uint localid, byte[] sdata)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 1a0c2a7..bd80fff 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -170,6 +170,8 @@ namespace OpenSim.Region.Physics.Manager
170 170
171 public abstract Vector3 Size { get; set; } 171 public abstract Vector3 Size { get; set; }
172 172
173 public virtual bool Phantom { get; set; }
174
173 public abstract PrimitiveBaseShape Shape { set; } 175 public abstract PrimitiveBaseShape Shape { set; }
174 176
175 uint m_baseLocalID; 177 uint m_baseLocalID;
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 0346d4e..eca6a0f 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -122,9 +122,6 @@ namespace OpenSim.Region.Physics.Manager
122 /// <param name="prim"></param> 122 /// <param name="prim"></param>
123 public abstract void RemovePrim(PhysicsActor prim); 123 public abstract void RemovePrim(PhysicsActor prim);
124 124
125 //public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
126 // Vector3 size, Quaternion rotation); //To be removed - Actually removed!
127
128 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 125 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
129 Vector3 size, Quaternion rotation, bool isPhysical, uint localid); 126 Vector3 size, Quaternion rotation, bool isPhysical, uint localid);
130 127
@@ -134,6 +131,12 @@ namespace OpenSim.Region.Physics.Manager
134 return null; 131 return null;
135 } 132 }
136 133
134 public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
135 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid)
136 {
137 return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid);
138 }
139
137 public virtual float TimeDilation 140 public virtual float TimeDilation
138 { 141 {
139 get { return 1.0f; } 142 get { return 1.0f; }
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 563d527..5d8f03c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -66,6 +66,8 @@ namespace OpenSim.Region.Physics.OdePlugin
66 66
67 private bool m_isphysical; 67 private bool m_isphysical;
68 private bool m_fakeisphysical; 68 private bool m_fakeisphysical;
69 private bool m_isphantom;
70 private bool m_fakeisphantom;
69 71
70 protected bool m_building; 72 protected bool m_building;
71 private Quaternion m_lastorientation = new Quaternion(); 73 private Quaternion m_lastorientation = new Quaternion();
@@ -211,6 +213,19 @@ namespace OpenSim.Region.Physics.OdePlugin
211 } 213 }
212 } 214 }
213 215
216 public override bool Phantom // this is not reliable for internal use
217 {
218 get { return m_fakeisphantom; }
219 set
220 {
221 m_fakeisphantom = value; // we show imediatly to outside that we changed physical
222 // and also to stop imediatly some updates
223 // but real change will only happen in taintprocessing
224
225 AddChange(changes.Phantom, value);
226 }
227 }
228
214 public override bool Building // this is not reliable for internal use 229 public override bool Building // this is not reliable for internal use
215 { 230 {
216 get { return m_building; } 231 get { return m_building; }
@@ -831,9 +846,10 @@ namespace OpenSim.Region.Physics.OdePlugin
831 846
832 847
833 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, 848 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
834 Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) 849 Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical,bool pisPhantom,uint plocalID)
835 { 850 {
836 Name = primName; 851 Name = primName;
852 LocalID = plocalID;
837 853
838 m_vehicle = null; 854 m_vehicle = null;
839 855
@@ -908,6 +924,9 @@ namespace OpenSim.Region.Physics.OdePlugin
908 m_isSelected = false; 924 m_isSelected = false;
909 m_delaySelect = false; 925 m_delaySelect = false;
910 926
927 m_isphantom = pisPhantom;
928 m_fakeisphantom = pisPhantom;
929
911 mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu; 930 mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu;
912 bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; 931 bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce;
913 932
@@ -1237,8 +1256,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1237 { 1256 {
1238 if (m_isphysical && Body != IntPtr.Zero) 1257 if (m_isphysical && Body != IntPtr.Zero)
1239 { 1258 {
1240 m_collisionCategories |= CollisionCategories.Body; 1259 if (m_isphantom && !m_isVolumeDetect)
1241 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1260 {
1261 m_collisionCategories = 0;
1262 m_collisionFlags = CollisionCategories.Land;
1263 }
1264 else
1265 {
1266 m_collisionCategories |= CollisionCategories.Body;
1267 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1268 }
1242 1269
1243 foreach (OdePrim prm in childrenPrim) 1270 foreach (OdePrim prm in childrenPrim)
1244 { 1271 {
@@ -1492,6 +1519,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1492 collide_geom = m_targetSpace; 1519 collide_geom = m_targetSpace;
1493 } 1520 }
1494 1521
1522 if (m_delaySelect)
1523 {
1524 m_isSelected = true;
1525 m_delaySelect = false;
1526 }
1527
1495 lock (childrenPrim) 1528 lock (childrenPrim)
1496 { 1529 {
1497 foreach (OdePrim prm in childrenPrim) 1530 foreach (OdePrim prm in childrenPrim)
@@ -1522,8 +1555,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1522 } 1555 }
1523 else 1556 else
1524 { 1557 {
1525 prm.m_collisionCategories |= CollisionCategories.Body; 1558 if (m_isphantom && !m_isVolumeDetect)
1526 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1559 {
1560 prm.m_collisionCategories = 0;
1561 prm.m_collisionFlags = CollisionCategories.Land;
1562 }
1563 else
1564 {
1565 prm.m_collisionCategories |= CollisionCategories.Body;
1566 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1567 }
1527 d.GeomEnable(prm.prim_geom); 1568 d.GeomEnable(prm.prim_geom);
1528 } 1569 }
1529 1570
@@ -1563,8 +1604,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1563 } 1604 }
1564 else 1605 else
1565 { 1606 {
1566 m_collisionCategories |= CollisionCategories.Body; 1607 if (m_isphantom && !m_isVolumeDetect)
1567 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1608 {
1609 m_collisionCategories = 0;
1610 m_collisionFlags = CollisionCategories.Land;
1611 }
1612 else
1613 {
1614 m_collisionCategories |= CollisionCategories.Body;
1615 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1616 }
1568 1617
1569 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); 1618 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
1570 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); 1619 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
@@ -2271,6 +2320,88 @@ namespace OpenSim.Region.Physics.OdePlugin
2271 } 2320 }
2272 } 2321 }
2273 2322
2323
2324 private void changePhantomStatus(bool newval)
2325 {
2326 m_isphantom = newval;
2327
2328 if (m_isSelected)
2329 {
2330 m_collisionCategories = CollisionCategories.Selected;
2331 m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
2332 }
2333 else
2334 {
2335 if (m_isphantom && !m_isVolumeDetect)
2336 {
2337 m_collisionCategories = 0;
2338 if (m_isphysical)
2339 m_collisionFlags = CollisionCategories.Land;
2340 else
2341 m_collisionFlags = 0; // should never happen
2342 }
2343
2344 else
2345 {
2346 m_collisionCategories = CollisionCategories.Geom;
2347 if (m_isphysical)
2348 m_collisionCategories |= CollisionCategories.Body;
2349
2350 m_collisionFlags = m_default_collisionFlags | CollisionCategories.Land;
2351
2352 if (m_collidesWater)
2353 m_collisionFlags |= CollisionCategories.Water;
2354 }
2355 }
2356
2357 if (!childPrim)
2358 {
2359 foreach (OdePrim prm in childrenPrim)
2360 {
2361 prm.m_collisionCategories = m_collisionCategories;
2362 prm.m_collisionFlags = m_collisionFlags;
2363
2364 if (!prm.m_disabled && prm.prim_geom != IntPtr.Zero)
2365 {
2366 if (prm.m_NoColide)
2367 {
2368 d.GeomSetCategoryBits(prm.prim_geom, 0);
2369 if (m_isphysical)
2370 d.GeomSetCollideBits(prm.prim_geom, (int)CollisionCategories.Land);
2371 else
2372 d.GeomSetCollideBits(prm.prim_geom, 0);
2373 }
2374 else
2375 {
2376 d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories);
2377 d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags);
2378 }
2379 if(!m_isSelected)
2380 d.GeomEnable(prm.prim_geom);
2381 }
2382 }
2383 }
2384
2385 if (!m_disabled && prim_geom != IntPtr.Zero)
2386 {
2387 if (m_NoColide)
2388 {
2389 d.GeomSetCategoryBits(prim_geom, 0);
2390 if (m_isphysical)
2391 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
2392 else
2393 d.GeomSetCollideBits(prim_geom, 0);
2394 }
2395 else
2396 {
2397 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
2398 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
2399 }
2400 if(!m_isSelected)
2401 d.GeomEnable(prim_geom);
2402 }
2403 }
2404
2274 private void changeSelectedStatus(bool newval) 2405 private void changeSelectedStatus(bool newval)
2275 { 2406 {
2276 if (m_lastdoneSelected == newval) 2407 if (m_lastdoneSelected == newval)
@@ -2346,7 +2477,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2346 2477
2347 m_delaySelect = false; 2478 m_delaySelect = false;
2348 } 2479 }
2349 else 2480 else if(!m_isphysical)
2350 { 2481 {
2351 m_delaySelect = true; 2482 m_delaySelect = true;
2352 } 2483 }
@@ -2613,30 +2744,12 @@ namespace OpenSim.Region.Physics.OdePlugin
2613 if (NewStatus) 2744 if (NewStatus)
2614 { 2745 {
2615 if (Body == IntPtr.Zero) 2746 if (Body == IntPtr.Zero)
2616 { 2747 MakeBody();
2617 /*
2618 if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
2619 {
2620 changeShape(_pbs);
2621 }
2622 else
2623 */
2624 {
2625 MakeBody();
2626 }
2627 }
2628 } 2748 }
2629 else 2749 else
2630 { 2750 {
2631 if (Body != IntPtr.Zero) 2751 if (Body != IntPtr.Zero)
2632 { 2752 {
2633 // UpdateChildsfromgeom();
2634 /* if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
2635 {
2636 changeShape(_pbs);
2637 }
2638 else
2639 */
2640 DestroyBody(); 2753 DestroyBody();
2641 } 2754 }
2642 Stop(); 2755 Stop();
@@ -2720,7 +2833,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2720 { 2833 {
2721 m_collidesWater = newval; 2834 m_collidesWater = newval;
2722 2835
2723 if (prim_geom != IntPtr.Zero) 2836 if (prim_geom != IntPtr.Zero && !m_isphantom)
2724 { 2837 {
2725 if (m_collidesWater) 2838 if (m_collidesWater)
2726 { 2839 {
@@ -3492,6 +3605,10 @@ namespace OpenSim.Region.Physics.OdePlugin
3492 changeVolumedetetion((bool)arg); 3605 changeVolumedetetion((bool)arg);
3493 break; 3606 break;
3494 3607
3608 case changes.Phantom:
3609 changePhantomStatus((bool)arg);
3610 break;
3611
3495 case changes.Physical: 3612 case changes.Physical:
3496 changePhysicsStatus((bool)arg); 3613 changePhysicsStatus((bool)arg);
3497 break; 3614 break;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 14516f9..612eafd 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -128,6 +128,7 @@ namespace OpenSim.Region.Physics.OdePlugin
128 VolumeDtc, 128 VolumeDtc,
129 129
130 Physical, 130 Physical,
131 Phantom,
131 Selected, 132 Selected,
132 disabled, 133 disabled,
133 building, 134 building,
@@ -1140,12 +1141,29 @@ namespace OpenSim.Region.Physics.OdePlugin
1140 OdePrim newPrim; 1141 OdePrim newPrim;
1141 lock (OdeLock) 1142 lock (OdeLock)
1142 { 1143 {
1143 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical); 1144 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical,false,localID);
1145
1146 lock (_prims)
1147 _prims.Add(newPrim);
1148 }
1149 return newPrim;
1150 }
1151
1152 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1153 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, uint localID)
1154 {
1155 Vector3 pos = position;
1156 Vector3 siz = size;
1157 Quaternion rot = rotation;
1158
1159 OdePrim newPrim;
1160 lock (OdeLock)
1161 {
1162 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical,isPhantom,localID);
1144 1163
1145 lock (_prims) 1164 lock (_prims)
1146 _prims.Add(newPrim); 1165 _prims.Add(newPrim);
1147 } 1166 }
1148 newPrim.LocalID = localID;
1149 return newPrim; 1167 return newPrim;
1150 } 1168 }
1151 1169
@@ -1169,6 +1187,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1169 } 1187 }
1170 1188
1171 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1189 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1190 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid)
1191 {
1192 return AddPrim(primName, position, size, rotation, pbs, isPhysical, isPhantom, localid);
1193 }
1194
1195
1196 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1172 Vector3 size, Quaternion rotation, bool isPhysical, uint localid) 1197 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
1173 { 1198 {
1174#if SPAM 1199#if SPAM