aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs78
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs4
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs3
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs3
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs4
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs661
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs3
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs3
11 files changed, 425 insertions, 352 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index bc0ccb3..3c8dc0a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -491,7 +491,7 @@ namespace OpenSim.Region.Environment.Scenes
491 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 491 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
492 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 492 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
493 493
494 rootPart.doPhysicsPropertyUpdate(UsePhysics); 494 rootPart.doPhysicsPropertyUpdate(UsePhysics, true);
495 495
496 } 496 }
497 rootPart.ScheduleFullUpdate(); 497 rootPart.ScheduleFullUpdate();
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index dcba9bd..405f2e3 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -604,7 +604,7 @@ namespace OpenSim.Region.Environment.Scenes
604 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 604 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
605 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 605 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
606 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 606 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
607 rootPart.doPhysicsPropertyUpdate(UsePhysics); 607 rootPart.doPhysicsPropertyUpdate(UsePhysics, true);
608 } 608 }
609 MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 609 MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
610 } 610 }
@@ -657,7 +657,7 @@ namespace OpenSim.Region.Environment.Scenes
657 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), 657 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
658 new Quaternion(), UsePhysics); 658 new Quaternion(), UsePhysics);
659 // subscribe to physics events. 659 // subscribe to physics events.
660 rootPart.doPhysicsPropertyUpdate(UsePhysics); 660 rootPart.doPhysicsPropertyUpdate(UsePhysics, true);
661 661
662 } 662 }
663 } 663 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 38962c1..efee81b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -150,6 +150,7 @@ namespace OpenSim.Region.Environment.Scenes
150 m_rootPart.PhysActor.Position = 150 m_rootPart.PhysActor.Position =
151 new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y, 151 new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y,
152 m_rootPart.GroupPosition.Z); 152 m_rootPart.GroupPosition.Z);
153 m_scene.PhysScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
153 } 154 }
154 } 155 }
155 } 156 }
@@ -480,7 +481,7 @@ namespace OpenSim.Region.Environment.Scenes
480 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, 481 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X,
481 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z), 482 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z),
482 dupe.RootPart.PhysActor.IsPhysical); 483 dupe.RootPart.PhysActor.IsPhysical);
483 dupe.RootPart.doPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical); 484 dupe.RootPart.doPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true);
484 485
485 } 486 }
486 // Now we've made a copy that replaces this one, we need to 487 // Now we've made a copy that replaces this one, we need to
@@ -784,6 +785,7 @@ namespace OpenSim.Region.Environment.Scenes
784 if (linkPart.PhysActor != null) 785 if (linkPart.PhysActor != null)
785 { 786 {
786 m_scene.PhysScene.RemovePrim(linkPart.PhysActor); 787 m_scene.PhysScene.RemovePrim(linkPart.PhysActor);
788
787 linkPart.PhysActor = null; 789 linkPart.PhysActor = null;
788 } 790 }
789 791
@@ -861,7 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
861 new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, 863 new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X,
862 linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), 864 linkPart.RotationOffset.Y, linkPart.RotationOffset.Z),
863 m_rootPart.PhysActor.IsPhysical); 865 m_rootPart.PhysActor.IsPhysical);
864 m_rootPart.doPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical); 866 m_rootPart.doPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true);
865 867
866 } 868 }
867 869
@@ -1170,7 +1172,7 @@ namespace OpenSim.Region.Environment.Scenes
1170 m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z), 1172 m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z),
1171 m_rootPart.PhysActor.IsPhysical); 1173 m_rootPart.PhysActor.IsPhysical);
1172 bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 1174 bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
1173 m_rootPart.doPhysicsPropertyUpdate(UsePhysics); 1175 m_rootPart.doPhysicsPropertyUpdate(UsePhysics, true);
1174 1176
1175 } 1177 }
1176 } 1178 }
@@ -1196,6 +1198,7 @@ namespace OpenSim.Region.Environment.Scenes
1196 { 1198 {
1197 m_rootPart.PhysActor.Size = 1199 m_rootPart.PhysActor.Size =
1198 new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z); 1200 new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
1201 m_scene.PhysScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
1199 } 1202 }
1200 } 1203 }
1201 } 1204 }
@@ -1286,6 +1289,7 @@ namespace OpenSim.Region.Environment.Scenes
1286 m_rootPart.PhysActor.Orientation = 1289 m_rootPart.PhysActor.Orientation =
1287 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, 1290 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
1288 m_rootPart.RotationOffset.Z); 1291 m_rootPart.RotationOffset.Z);
1292 m_scene.PhysScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
1289 } 1293 }
1290 ScheduleGroupForTerseUpdate(); 1294 ScheduleGroupForTerseUpdate();
1291 } 1295 }
@@ -1303,6 +1307,7 @@ namespace OpenSim.Region.Environment.Scenes
1303 m_rootPart.PhysActor.Orientation = 1307 m_rootPart.PhysActor.Orientation =
1304 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, 1308 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
1305 m_rootPart.RotationOffset.Z); 1309 m_rootPart.RotationOffset.Z);
1310 m_scene.PhysScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
1306 } 1311 }
1307 AbsolutePosition = pos; 1312 AbsolutePosition = pos;
1308 ScheduleGroupForTerseUpdate(); 1313 ScheduleGroupForTerseUpdate();
@@ -1346,6 +1351,7 @@ namespace OpenSim.Region.Environment.Scenes
1346 m_rootPart.PhysActor.Orientation = 1351 m_rootPart.PhysActor.Orientation =
1347 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, 1352 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
1348 m_rootPart.RotationOffset.Z); 1353 m_rootPart.RotationOffset.Z);
1354 m_scene.PhysScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
1349 } 1355 }
1350 1356
1351 foreach (SceneObjectPart prim in m_parts.Values) 1357 foreach (SceneObjectPart prim in m_parts.Values)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 76fe4b6..7bab3b6 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -170,9 +170,10 @@ namespace OpenSim.Region.Environment.Scenes
170 { 170 {
171 try 171 try
172 { 172 {
173 //lock (m_scene.SyncRoot) 173 //lock (m_parentGroup.m_scene.SyncRoot)
174 //{ 174 //{
175 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 175 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
176 m_parentGroup.m_scene.PhysScene.AddPhysicsActorTaint(PhysActor);
176 //} 177 //}
177 } 178 }
178 catch (Exception e) 179 catch (Exception e)
@@ -225,6 +226,7 @@ namespace OpenSim.Region.Environment.Scenes
225 //lock (m_scene.SyncRoot) 226 //lock (m_scene.SyncRoot)
226 //{ 227 //{
227 PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z); 228 PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z);
229 m_parentGroup.m_scene.PhysScene.AddPhysicsActorTaint(PhysActor);
228 //} 230 //}
229 } 231 }
230 catch (Exception ex) 232 catch (Exception ex)
@@ -502,7 +504,7 @@ namespace OpenSim.Region.Environment.Scenes
502 RotationOffset = rotation; 504 RotationOffset = rotation;
503 ObjectFlags = flags; 505 ObjectFlags = flags;
504 bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 506 bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
505 doPhysicsPropertyUpdate(UsePhysics); 507 doPhysicsPropertyUpdate(UsePhysics, true);
506 ScheduleFullUpdate(); 508 ScheduleFullUpdate();
507 } 509 }
508 510
@@ -518,7 +520,7 @@ namespace OpenSim.Region.Environment.Scenes
518 XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); 520 XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
519 SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); 521 SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader);
520 bool UsePhysics = ((newobject.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 522 bool UsePhysics = ((newobject.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
521 newobject.doPhysicsPropertyUpdate(UsePhysics); 523 newobject.doPhysicsPropertyUpdate(UsePhysics, true);
522 524
523 return newobject; 525 return newobject;
524 } 526 }
@@ -586,7 +588,7 @@ namespace OpenSim.Region.Environment.Scenes
586 Array.Copy(Shape.ExtraParams, extraP, extraP.Length); 588 Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
587 dupe.Shape.ExtraParams = extraP; 589 dupe.Shape.ExtraParams = extraP;
588 bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 590 bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
589 dupe.doPhysicsPropertyUpdate(UsePhysics); 591 dupe.doPhysicsPropertyUpdate(UsePhysics, true);
590 592
591 return dupe; 593 return dupe;
592 } 594 }
@@ -852,7 +854,7 @@ namespace OpenSim.Region.Environment.Scenes
852 AddFlag(LLObject.ObjectFlags.Physics); 854 AddFlag(LLObject.ObjectFlags.Physics);
853 if (!wasUsingPhysics) 855 if (!wasUsingPhysics)
854 { 856 {
855 doPhysicsPropertyUpdate(UsePhysics); 857 doPhysicsPropertyUpdate(UsePhysics,false);
856 } 858 }
857 859
858 } 860 }
@@ -861,7 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
861 RemFlag(LLObject.ObjectFlags.Physics); 863 RemFlag(LLObject.ObjectFlags.Physics);
862 if (wasUsingPhysics) 864 if (wasUsingPhysics)
863 { 865 {
864 doPhysicsPropertyUpdate(UsePhysics); 866 doPhysicsPropertyUpdate(UsePhysics, false);
865 } 867 }
866 } 868 }
867 869
@@ -892,12 +894,12 @@ namespace OpenSim.Region.Environment.Scenes
892 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 894 new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
893 new Quaternion(RotationOffset.W, RotationOffset.X, 895 new Quaternion(RotationOffset.W, RotationOffset.X,
894 RotationOffset.Y, RotationOffset.Z), UsePhysics); 896 RotationOffset.Y, RotationOffset.Z), UsePhysics);
895 doPhysicsPropertyUpdate(UsePhysics); 897 doPhysicsPropertyUpdate(UsePhysics, true);
896 } 898 }
897 else 899 else
898 { 900 {
899 PhysActor.IsPhysical = UsePhysics; 901 PhysActor.IsPhysical = UsePhysics;
900 doPhysicsPropertyUpdate(UsePhysics); 902 doPhysicsPropertyUpdate(UsePhysics,false);
901 } 903 }
902 } 904 }
903 905
@@ -912,36 +914,45 @@ namespace OpenSim.Region.Environment.Scenes
912// System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 914// System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
913 ScheduleFullUpdate(); 915 ScheduleFullUpdate();
914 } 916 }
915 public void doPhysicsPropertyUpdate(bool UsePhysics) 917 public void doPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
916 { 918 {
917 919
918 if (PhysActor != null) 920 if (PhysActor != null)
919 { 921 {
920 if (PhysActor.IsPhysical) 922 if (UsePhysics != PhysActor.IsPhysical || isNew)
921 { 923 {
922 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 924
923 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; 925 if (PhysActor.IsPhysical)
924 } 926 {
925 m_parentGroup.m_scene.PhysScene.RemovePrim(PhysActor); 927 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
926 /// that's not wholesome. Had to make m_scene public 928 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
927 PhysActor = null; 929 }
928 930
929 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 931 PhysActor.IsPhysical = UsePhysics;
930 { 932 // If we're not what we're supposed to be in the physics scene, recreate ourselves.
931 PhysActor = m_parentGroup.m_scene.PhysScene.AddPrimShape( 933 //m_parentGroup.m_scene.PhysScene.RemovePrim(PhysActor);
932 Name, 934 /// that's not wholesome. Had to make m_scene public
933 Shape, 935 //PhysActor = null;
934 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, 936
935 AbsolutePosition.Z), 937
936 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 938 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
937 new Quaternion(RotationOffset.W, RotationOffset.X,
938 RotationOffset.Y, RotationOffset.Z), UsePhysics);
939 if (UsePhysics)
940 { 939 {
941 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 940 //PhysActor = m_parentGroup.m_scene.PhysScene.AddPrimShape(
942 PhysActor.OnOutOfBounds += PhysicsOutOfBounds; 941 //Name,
942 //Shape,
943 //new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
944 //AbsolutePosition.Z),
945 //new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
946 //new Quaternion(RotationOffset.W, RotationOffset.X,
947 //RotationOffset.Y, RotationOffset.Z), UsePhysics);
948 if (UsePhysics)
949 {
950 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
951 PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
952 }
943 } 953 }
944 } 954 }
955 m_parentGroup.m_scene.PhysScene.AddPhysicsActorTaint(PhysActor);
945 } 956 }
946 } 957 }
947 958
@@ -1195,8 +1206,11 @@ namespace OpenSim.Region.Environment.Scenes
1195 public void PhysicsOutOfBounds(PhysicsVector pos) 1206 public void PhysicsOutOfBounds(PhysicsVector pos)
1196 { 1207 {
1197 OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Physical Object went out of bounds."); 1208 OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Physical Object went out of bounds.");
1198 doPhysicsPropertyUpdate(false); 1209 RemFlag(LLObject.ObjectFlags.Physics);
1199 ScheduleFullUpdate(); 1210 doPhysicsPropertyUpdate(false,true);
1211 m_parentGroup.m_scene.PhysScene.AddPhysicsActorTaint(PhysActor);
1212
1213
1200 } 1214 }
1201 1215
1202 1216
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 3b5fc57..5c460be 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes
55 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 55 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
56 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 56 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
57 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 57 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
58 rootPart.doPhysicsPropertyUpdate(UsePhysics); 58 rootPart.doPhysicsPropertyUpdate(UsePhysics, true);
59 59
60 } 60 }
61 primCount++; 61 primCount++;
@@ -125,7 +125,7 @@ namespace OpenSim.Region.Environment.Scenes
125 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 125 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
126 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 126 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
127 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 127 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
128 rootPart.doPhysicsPropertyUpdate(UsePhysics); 128 rootPart.doPhysicsPropertyUpdate(UsePhysics, true);
129 } 129 }
130 } 130 }
131 131
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 2582097..a7f7877 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -114,7 +114,10 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
114 { 114 {
115 return null; 115 return null;
116 } 116 }
117 public override void AddPhysicsActorTaint(PhysicsActor prim)
118 {
117 119
120 }
118 public override void Simulate(float timeStep) 121 public override void Simulate(float timeStep)
119 { 122 {
120 foreach (BasicActor actor in _actors) 123 foreach (BasicActor actor in _actors)
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index f78e99e..8890f97 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -511,7 +511,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
511 GC.Collect(); 511 GC.Collect();
512 } 512 }
513 } 513 }
514 public override void AddPhysicsActorTaint(PhysicsActor prim)
515 {
514 516
517 }
515 public override void Simulate(float timeStep) 518 public override void Simulate(float timeStep)
516 { 519 {
517 lock (BulletXLock) 520 lock (BulletXLock)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 6f19e72..651992c 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Region.Physics.Manager
51 PhysicsVector size, Quaternion rotation); //To be removed 51 PhysicsVector size, Quaternion rotation); //To be removed
52 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 52 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
53 PhysicsVector size, Quaternion rotation, bool isPhysical); 53 PhysicsVector size, Quaternion rotation, bool isPhysical);
54 public abstract void AddPhysicsActorTaint(PhysicsActor prim);
54 55
55 public abstract void Simulate(float timeStep); 56 public abstract void Simulate(float timeStep);
56 57
@@ -104,7 +105,10 @@ namespace OpenSim.Region.Physics.Manager
104 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size); 105 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size);
105 return PhysicsActor.Null; 106 return PhysicsActor.Null;
106 } 107 }
108 public override void AddPhysicsActorTaint(PhysicsActor prim)
109 {
107 110
111 }
108 public override void Simulate(float timeStep) 112 public override void Simulate(float timeStep)
109 { 113 {
110 m_workIndicator = (m_workIndicator + 1)%10; 114 m_workIndicator = (m_workIndicator + 1)%10;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index e1dc9f8..84ff60c 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -85,6 +85,7 @@ namespace OpenSim.Region.Physics.OdePlugin
85 private List<OdeCharacter> _characters = new List<OdeCharacter>(); 85 private List<OdeCharacter> _characters = new List<OdeCharacter>();
86 private List<OdePrim> _prims = new List<OdePrim>(); 86 private List<OdePrim> _prims = new List<OdePrim>();
87 private List<OdePrim> _activeprims = new List<OdePrim>(); 87 private List<OdePrim> _activeprims = new List<OdePrim>();
88 private List<OdePrim> _taintedPrim = new List<OdePrim>();
88 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 89 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
89 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 90 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
90 private d.ContactGeom[] contacts = new d.ContactGeom[30]; 91 private d.ContactGeom[] contacts = new d.ContactGeom[30];
@@ -326,13 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin
326 chr.CollidingGround = false; 327 chr.CollidingGround = false;
327 chr.CollidingObj = false; 328 chr.CollidingObj = false;
328 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); 329 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
329 foreach (OdeCharacter ch2 in _characters) 330
330 /// should be a separate space -- lots of avatars will be N**2 slow
331 {
332
333
334 //d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback);
335 }
336 331
337 } 332 }
338 // If the sim is running slow this frame, 333 // If the sim is running slow this frame,
@@ -345,20 +340,20 @@ namespace OpenSim.Region.Physics.OdePlugin
345 if (d.BodyIsEnabled(chr.Body)) 340 if (d.BodyIsEnabled(chr.Body))
346 { 341 {
347 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback); 342 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
348 foreach (OdePrim ch2 in _prims) 343 //foreach (OdePrim ch2 in _prims)
349 /// should be a separate space -- lots of avatars will be N**2 slow 344 /// should be a separate space -- lots of avatars will be N**2 slow
350 { 345 //{
351 if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body)) 346 //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body))
352 { 347 //{
353 // Only test prim that are 0.03 meters away in one direction. 348 // Only test prim that are 0.03 meters away in one direction.
354 // This should be Optimized! 349 // This should be Optimized!
355 350
356 if ((Math.Abs(ch2.Position.X - chr.Position.X) < 0.03) || (Math.Abs(ch2.Position.Y - chr.Position.Y) < 0.03) || (Math.Abs(ch2.Position.X - chr.Position.X) < 0.03)) 351 //if ((Math.Abs(ch2.Position.X - chr.Position.X) < 0.03) || (Math.Abs(ch2.Position.Y - chr.Position.Y) < 0.03) || (Math.Abs(ch2.Position.X - chr.Position.X) < 0.03))
357 { 352 //{
358 d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback); 353 //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback);
359 } 354 //}
360 } 355 //}
361 } 356 //}
362 } 357 }
363 } 358 }
364 } 359 }
@@ -404,60 +399,70 @@ namespace OpenSim.Region.Physics.OdePlugin
404 { 399 {
405 lock (OdeLock) 400 lock (OdeLock)
406 { 401 {
407 if (prim.IsPhysical) 402 OdePrim p = (OdePrim) prim;
408 { 403
409 OdePrim p; 404 p.setPrimForRemoval();
410 p = (OdePrim) prim; 405 AddPhysicsActorTaint(prim);
411 p.disableBody(); 406
412 } 407 }
413 // we don't want to remove the main space 408 }
414 if (((OdePrim)prim).m_targetSpace != space && ((OdePrim)prim).IsPhysical == false) 409 }
410 public void RemovePrimThreadLocked(OdePrim prim)
411 {
412 lock (OdeLock)
413 {
414
415 if (prim.IsPhysical)
416 {
417 prim.disableBody();
418 }
419 // we don't want to remove the main space
420 if (prim.m_targetSpace != space && prim.IsPhysical == false)
421 {
422 // If the geometry is in the targetspace, remove it from the target space
423 if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
415 { 424 {
416 // If the geometry is in the targetspace, remove it from the target space 425 if (!(prim.m_targetSpace.Equals(null)))
417 if (d.SpaceQuery(((OdePrim)prim).m_targetSpace, ((OdePrim)prim).prim_geom))
418 { 426 {
419 if (!(((OdePrim)prim).m_targetSpace.Equals(null))) 427 if (d.GeomIsSpace(prim.m_targetSpace))
428 {
429 d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
430 }
431 else
420 { 432 {
421 if (d.GeomIsSpace(((OdePrim)prim).m_targetSpace)) 433 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString());
422 {
423 d.SpaceRemove(((OdePrim)prim).m_targetSpace, ((OdePrim)prim).prim_geom);
424 }
425 else
426 {
427 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString());
428 }
429 } 434 }
430 } 435 }
436 }
437
431 438
432
433 439
434 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 440 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
435 if (d.SpaceGetNumGeoms(((OdePrim)prim).m_targetSpace) == 0) 441 if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
442 {
443 if (!(prim.m_targetSpace.Equals(null)))
436 { 444 {
437 if (!(((OdePrim)prim).m_targetSpace.Equals(null))) 445 if (d.GeomIsSpace(prim.m_targetSpace))
438 { 446 {
439 if (d.GeomIsSpace(((OdePrim)prim).m_targetSpace)) 447 d.SpaceRemove(space, prim.m_targetSpace);
440 { 448 // free up memory used by the space.
441 d.SpaceRemove(space, ((OdePrim)prim).m_targetSpace); 449 d.SpaceDestroy(prim.m_targetSpace);
442 // free up memory used by the space. 450 int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
443 d.SpaceDestroy(((OdePrim)prim).m_targetSpace); 451 resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
444 int[] xyspace = calculateSpaceArrayItemFromPos(((OdePrim)prim).Position); 452 }
445 resetSpaceArrayItemToZero(xyspace[0],xyspace[1]); 453 else
446 } 454 {
447 else 455 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString());
448 {
449 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString());
450 }
451 } 456 }
452 } 457 }
453 } 458 }
454
455 d.GeomDestroy(((OdePrim)prim).prim_geom);
456
457 _prims.Remove((OdePrim)prim);
458
459 } 459 }
460
461 d.GeomDestroy(prim.prim_geom);
462
463 _prims.Remove(prim);
460 } 464 }
465
461 } 466 }
462 public void resetSpaceArrayItemToZero(IntPtr space) 467 public void resetSpaceArrayItemToZero(IntPtr space)
463 { 468 {
@@ -654,8 +659,9 @@ namespace OpenSim.Region.Physics.OdePlugin
654 lock (OdeLock) 659 lock (OdeLock)
655 { 660 {
656 newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical); 661 newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical);
662
663 _prims.Add(newPrim);
657 } 664 }
658 _prims.Add(newPrim);
659 665
660 return newPrim; 666 return newPrim;
661 } 667 }
@@ -761,20 +767,23 @@ namespace OpenSim.Region.Physics.OdePlugin
761 return result; 767 return result;
762 } 768 }
763 769
770 public override void AddPhysicsActorTaint(PhysicsActor prim)
771 {
772 if (prim is OdePrim)
773 {
774 OdePrim taintedprim = ((OdePrim)prim);
775 if (!(_taintedPrim.Contains(taintedprim)))
776 _taintedPrim.Add(taintedprim);
777
778 }
779 }
764 780
765 public override void Simulate(float timeStep) 781 public override void Simulate(float timeStep)
766 { 782 {
767 783
768 step_time += timeStep; 784 step_time += timeStep;
769 lock (OdeLock)
770 {
771 if (_characters.Count > 0 && RENDER_FLAG)
772 {
773 Console.WriteLine("RENDER: frame");
774 }
775
776
777 785
786
778 // If We're loaded down by something else, 787 // If We're loaded down by something else,
779 // or debugging with the Visual Studio project on pause 788 // or debugging with the Visual Studio project on pause
780 // skip a few frames to catch up gracefully. 789 // skip a few frames to catch up gracefully.
@@ -792,7 +801,8 @@ namespace OpenSim.Region.Physics.OdePlugin
792 { 801 {
793 m_physicsiterations = 10; 802 m_physicsiterations = 10;
794 } 803 }
795 804 lock (OdeLock)
805 {
796 // Process 10 frames if the sim is running normal.. 806 // Process 10 frames if the sim is running normal..
797 // process 5 frames if the sim is running slow 807 // process 5 frames if the sim is running slow
798 d.WorldSetQuickStepNumIterations(world, m_physicsiterations); 808 d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
@@ -823,38 +833,23 @@ namespace OpenSim.Region.Physics.OdePlugin
823 foreach (OdeCharacter actor in _characters) 833 foreach (OdeCharacter actor in _characters)
824 { 834 {
825 actor.UpdatePositionAndVelocity(); 835 actor.UpdatePositionAndVelocity();
826 if (RENDER_FLAG) 836
837 }
838 bool processedtaints = false;
839 foreach (OdePrim prim in _taintedPrim)
840 {
841 prim.ProcessTaints(timeStep);
842 if (prim.m_taintremove)
827 { 843 {
828 /// debugging code 844 RemovePrimThreadLocked(prim);
829 float Zoff = -33.0f;
830 d.Matrix3 temp = d.BodyGetRotation(actor.Body);
831 //Console.WriteLine("RENDER: cylinder; " + // shape
832 //OdeCharacter.CAPSULE_RADIUS + ", " + OdeCharacter.CAPSULE_LENGTH + //size
833 //"; 0, 1, 0; " + // color
834 //(actor.Position.X - 128.0f) + ", " + (actor.Position.Y - 128.0f) + ", " +
835 //(actor.Position.Z + Zoff) + "; " + // position
836 //temp.M00 + "," + temp.M10 + "," + temp.M20 + ", " + // rotation
837 //temp.M01 + "," + temp.M11 + "," + temp.M21 + ", " +
838 //temp.M02 + "," + temp.M12 + "," + temp.M22);
839 d.Vector3 caphead;
840 //d.BodyGetRelPointPos(actor.Body, 0, 0, OdeCharacter.CAPSULE_LENGTH*.5f, out caphead);
841 d.Vector3 capfoot;
842 //d.BodyGetRelPointPos(actor.Body, 0, 0, -OdeCharacter.CAPSULE_LENGTH*.5f, out capfoot);
843 //Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size
844 //"; 1, 0, 1; " + //color
845 //(caphead.X - 128.0f) + ", " + (caphead.Y - 128.0f) + ", " + (caphead.Z + Zoff) +
846 //"; " + // position
847 ///"1,0,0, 0,1,0, 0,0,1"); // rotation
848 // Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size
849 //"; 1, 0, 0; " + //color
850 //(capfoot.X - 128.0f) + ", " + (capfoot.Y - 128.0f) + ", " + (capfoot.Z + Zoff) +
851 //"; " + // position
852 //"1,0,0, 0,1,0, 0,0,1"); // rotation
853 } 845 }
846 processedtaints = true;
854 } 847 }
848 if (processedtaints)
849 _taintedPrim = new List<OdePrim>();
850
855 if (timeStep < 0.2f) 851 if (timeStep < 0.2f)
856 { 852 {
857 OdePrim outofBoundsPrim = null;
858 foreach (OdePrim actor in _activeprims) 853 foreach (OdePrim actor in _activeprims)
859 { 854 {
860 if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag)) 855 if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag))
@@ -1410,6 +1405,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1410 private PhysicsVector _size; 1405 private PhysicsVector _size;
1411 private PhysicsVector _acceleration; 1406 private PhysicsVector _acceleration;
1412 private Quaternion _orientation; 1407 private Quaternion _orientation;
1408 private PhysicsVector m_taintposition;
1409 private PhysicsVector m_taintsize;
1410 private Quaternion m_taintrot;
1411 private bool m_taintshape = false;
1412 private bool m_taintPhysics = false;
1413 public bool m_taintremove = false;
1413 1414
1414 private IMesh _mesh; 1415 private IMesh _mesh;
1415 private PrimitiveBaseShape _pbs; 1416 private PrimitiveBaseShape _pbs;
@@ -1441,30 +1442,33 @@ namespace OpenSim.Region.Physics.OdePlugin
1441 1442
1442 _velocity = new PhysicsVector(); 1443 _velocity = new PhysicsVector();
1443 _position = pos; 1444 _position = pos;
1444 1445 m_taintposition = pos;
1445 //if (_position.X > 257) 1446 if (_position.X > 257)
1446 //{ 1447 {
1447 // _position.X = 257; 1448 _position.X = 257;
1448 //} 1449 }
1449 //if (_position.X < 0) 1450 if (_position.X < 0)
1450 //{ 1451 {
1451 // _position.X = 0; 1452 _position.X = 0;
1452 //} 1453 }
1453 //if (_position.Y > 257) 1454 if (_position.Y > 257)
1454 //{ 1455 {
1455 // _position.Y = 257; 1456 _position.Y = 257;
1456 // } 1457 }
1457 //if (_position.Y < 0) 1458 if (_position.Y < 0)
1458 //{ 1459 {
1459 // _position.Y = 0; 1460 _position.Y = 0;
1460 //} 1461 }
1461 1462
1462 _size = size; 1463 _size = size;
1464 m_taintsize = _size;
1463 _acceleration = new PhysicsVector(); 1465 _acceleration = new PhysicsVector();
1464 m_rotationalVelocity = PhysicsVector.Zero; 1466 m_rotationalVelocity = PhysicsVector.Zero;
1465 _orientation = rotation; 1467 _orientation = rotation;
1468 m_taintrot = _orientation;
1466 _mesh = mesh; 1469 _mesh = mesh;
1467 _pbs = pbs; 1470 _pbs = pbs;
1471
1468 _parent_scene = parent_scene; 1472 _parent_scene = parent_scene;
1469 m_targetSpace = targetSpace; 1473 m_targetSpace = targetSpace;
1470 1474
@@ -1585,39 +1589,237 @@ namespace OpenSim.Region.Physics.OdePlugin
1585 enableBody(); 1589 enableBody();
1586 } 1590 }
1587 } 1591 }
1592 public void ProcessTaints(float timestep)
1593 {
1594 if (m_taintposition != _position)
1595 Move(timestep);
1588 1596
1589 public override bool IsPhysical 1597 if (m_taintrot != _orientation)
1598 rotate(timestep);
1599 //
1600
1601 if (m_taintPhysics != m_isphysical)
1602 changePhysicsStatus(timestep);
1603 //
1604
1605 if (m_taintsize != _size)
1606 changesize(timestep);
1607 //
1608
1609 if (m_taintshape)
1610 changeshape(timestep);
1611 //
1612
1613 }
1614 public void Move(float timestep)
1590 { 1615 {
1591 get { return m_isphysical; } 1616 if (m_isphysical)
1592 set { 1617 {
1593 1618 // This is a fallback.. May no longer be necessary.
1594 lock (OdeScene.OdeLock) 1619 if (Body == (IntPtr)0)
1620 enableBody();
1621 //Prim auto disable after 20 frames,
1622 ///if you move it, re-enable the prim manually.
1623 d.BodyEnable(Body);
1624 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
1625 }
1626 else
1627 {
1628 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1629 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1630 if (primScenAvatarIn == "0")
1595 { 1631 {
1596 if (m_isphysical == value) 1632 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in space with no prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + " . Arr:': " + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1597 { 1633 }
1598 // If the object is already what the user checked 1634 else
1599 1635 {
1600 return; 1636 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in Prim space with prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1601 } 1637 }
1602 if (value == true) 1638 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
1603 { 1639 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1604 if (Body == (IntPtr)0) 1640 d.SpaceAdd(m_targetSpace, prim_geom);
1605 { 1641 }
1606 enableBody();
1607 }
1608 1642
1609 } 1643 m_taintposition = _position;
1610 else if (value == false) 1644 }
1611 { 1645 public void rotate(float timestep)
1612 if (Body != (IntPtr)0) 1646 {
1613 { 1647
1614 disableBody(); 1648 d.Quaternion myrot = new d.Quaternion();
1615 } 1649 myrot.W = _orientation.w;
1616 } 1650 myrot.X = _orientation.x;
1617 m_isphysical = value; 1651 myrot.Y = _orientation.y;
1652 myrot.Z = _orientation.z;
1653 d.GeomSetQuaternion(prim_geom, ref myrot);
1654 if (m_isphysical && Body != (IntPtr)0)
1655 {
1656 d.BodySetQuaternion(Body, ref myrot);
1657 }
1658
1659 m_taintrot = _orientation;
1660 }
1661 public void changePhysicsStatus(float timestap)
1662 {
1663 if (m_isphysical == true)
1664 {
1665 if (Body == (IntPtr)0)
1666 {
1667 enableBody();
1618 } 1668 }
1619 1669
1620 } 1670 }
1671 else
1672 {
1673 if (Body != (IntPtr)0)
1674 {
1675 disableBody();
1676 }
1677 }
1678
1679
1680 m_taintPhysics = m_isphysical;
1681 }
1682 public void changesize(float timestamp)
1683 {
1684 string oldname = _parent_scene.geom_name_map[prim_geom];
1685
1686 // Cleanup of old prim geometry
1687 if (_mesh != null)
1688 {
1689 // Cleanup meshing here
1690 }
1691 //kill body to rebuild
1692 if (IsPhysical && Body != (IntPtr)0)
1693 {
1694 disableBody();
1695 }
1696 if (d.SpaceQuery(m_targetSpace, prim_geom))
1697 {
1698 d.SpaceRemove(m_targetSpace, prim_geom);
1699 }
1700 d.GeomDestroy(prim_geom);
1701
1702 // we don't need to do space calculation because the client sends a position update also.
1703
1704 // Construction of new prim
1705 if (this._parent_scene.needsMeshing(_pbs))
1706 {
1707
1708
1709 // Don't need to re-enable body.. it's done in SetMesh
1710 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
1711 // createmesh returns null when it's a shape that isn't a cube.
1712 if (mesh != null)
1713 {
1714 setMesh(_parent_scene, mesh);
1715 }
1716 else
1717 {
1718 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1719 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1720 d.Quaternion myrot = new d.Quaternion();
1721 myrot.W = _orientation.w;
1722 myrot.X = _orientation.x;
1723 myrot.Y = _orientation.y;
1724 myrot.Z = _orientation.z;
1725 d.GeomSetQuaternion(prim_geom, ref myrot);
1726
1727
1728 }
1729 }
1730 else
1731 {
1732 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1733 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1734 d.Quaternion myrot = new d.Quaternion();
1735 myrot.W = _orientation.w;
1736 myrot.X = _orientation.x;
1737 myrot.Y = _orientation.y;
1738 myrot.Z = _orientation.z;
1739 d.GeomSetQuaternion(prim_geom, ref myrot);
1740
1741
1742 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1743 if (IsPhysical && Body == (IntPtr)0)
1744 {
1745 // Re creates body on size.
1746 // EnableBody also does setMass()
1747 enableBody();
1748 d.BodyEnable(Body);
1749 }
1750
1751 }
1752
1753
1754 _parent_scene.geom_name_map[prim_geom] = oldname;
1755
1756
1757 m_taintsize = _size;
1758 }
1759 public void changeshape(float timestamp)
1760 {
1761 string oldname = _parent_scene.geom_name_map[prim_geom];
1762
1763 // Cleanup of old prim geometry and Bodies
1764 if (IsPhysical && Body != (IntPtr)0)
1765 {
1766 disableBody();
1767 }
1768 d.GeomDestroy(prim_geom);
1769 if (_mesh != null)
1770 {
1771
1772 d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1773
1774 }
1775
1776 // Construction of new prim
1777 if (this._parent_scene.needsMeshing(_pbs))
1778 {
1779 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
1780 if (mesh != null)
1781 {
1782 setMesh(_parent_scene, mesh);
1783 }
1784 else
1785 {
1786 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1787 }
1788 }
1789 else
1790 {
1791 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1792 }
1793 if (IsPhysical && Body == (IntPtr)0)
1794 {
1795 //re-create new body
1796 enableBody();
1797 }
1798 else
1799 {
1800 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1801 d.Quaternion myrot = new d.Quaternion();
1802 myrot.W = _orientation.w;
1803 myrot.X = _orientation.x;
1804 myrot.Y = _orientation.y;
1805 myrot.Z = _orientation.z;
1806 d.GeomSetQuaternion(prim_geom, ref myrot);
1807 }
1808 _parent_scene.geom_name_map[prim_geom] = oldname;
1809
1810
1811
1812
1813 m_taintshape = false;
1814 }
1815 public override bool IsPhysical
1816 {
1817 get { return m_isphysical; }
1818 set{ m_isphysical = value;}
1819 }
1820 public void setPrimForRemoval()
1821 {
1822 m_taintremove = true;
1621 } 1823 }
1622 1824
1623 public override bool Flying 1825 public override bool Flying
@@ -1656,36 +1858,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1656 set 1858 set
1657 { 1859 {
1658 _position = value; 1860 _position = value;
1659 lock (OdeScene.OdeLock) 1861
1660 {
1661 if (m_isphysical)
1662 {
1663 // This is a fallback.. May no longer be necessary.
1664 if (Body == (IntPtr)0)
1665 enableBody();
1666 //Prim auto disable after 20 frames,
1667 ///if you move it, re-enable the prim manually.
1668 d.BodyEnable(Body);
1669 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
1670 }
1671 else
1672 {
1673 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1674 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1675 if (primScenAvatarIn == "0")
1676 {
1677 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in space with no prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + " . Arr:': " + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1678 }
1679 else
1680 {
1681 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in Prim space with prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1682 }
1683 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
1684 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1685 d.SpaceAdd(m_targetSpace, prim_geom);
1686 }
1687
1688 }
1689 } 1862 }
1690 } 1863 }
1691 1864
@@ -1695,78 +1868,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1695 set 1868 set
1696 { 1869 {
1697 _size = value; 1870 _size = value;
1698 lock (OdeScene.OdeLock) 1871
1699 {
1700 string oldname = _parent_scene.geom_name_map[prim_geom];
1701
1702 // Cleanup of old prim geometry
1703 if (_mesh != null)
1704 {
1705 // Cleanup meshing here
1706 }
1707 //kill body to rebuild
1708 if (IsPhysical && Body != (IntPtr)0)
1709 {
1710 disableBody();
1711 }
1712 if (d.SpaceQuery(m_targetSpace,prim_geom)) {
1713 d.SpaceRemove(m_targetSpace,prim_geom);
1714 }
1715 d.GeomDestroy(prim_geom);
1716
1717 // we don't need to do space calculation because the client sends a position update also.
1718
1719 // Construction of new prim
1720 if (this._parent_scene.needsMeshing(_pbs))
1721 {
1722
1723
1724 // Don't need to re-enable body.. it's done in SetMesh
1725 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
1726 // createmesh returns null when it's a shape that isn't a cube.
1727 if (mesh != null)
1728 {
1729 setMesh(_parent_scene, mesh);
1730 }
1731 else
1732 {
1733 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1734 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1735 d.Quaternion myrot = new d.Quaternion();
1736 myrot.W = _orientation.w;
1737 myrot.X = _orientation.x;
1738 myrot.Y = _orientation.y;
1739 myrot.Z = _orientation.z;
1740 d.GeomSetQuaternion(prim_geom, ref myrot);
1741
1742
1743 }
1744 } else {
1745 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1746 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1747 d.Quaternion myrot = new d.Quaternion();
1748 myrot.W = _orientation.w;
1749 myrot.X = _orientation.x;
1750 myrot.Y = _orientation.y;
1751 myrot.Z = _orientation.z;
1752 d.GeomSetQuaternion(prim_geom, ref myrot);
1753
1754
1755 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1756 if (IsPhysical && Body == (IntPtr)0)
1757 {
1758 // Re creates body on size.
1759 // EnableBody also does setMass()
1760 enableBody();
1761 d.BodyEnable(Body);
1762 }
1763
1764 }
1765
1766
1767 _parent_scene.geom_name_map[prim_geom] = oldname;
1768
1769 }
1770 } 1872 }
1771 } 1873 }
1772 1874
@@ -1775,58 +1877,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1775 set 1877 set
1776 { 1878 {
1777 _pbs = value; 1879 _pbs = value;
1778 lock (OdeScene.OdeLock) 1880
1779 {
1780 string oldname = _parent_scene.geom_name_map[prim_geom];
1781
1782 // Cleanup of old prim geometry and Bodies
1783 if (IsPhysical && Body != (IntPtr)0)
1784 {
1785 disableBody();
1786 }
1787 d.GeomDestroy(prim_geom);
1788 if (_mesh != null)
1789 {
1790
1791 d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1792
1793 }
1794
1795 // Construction of new prim
1796 if (this._parent_scene.needsMeshing(_pbs))
1797 {
1798 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
1799 if (mesh != null)
1800 {
1801 setMesh(_parent_scene, mesh);
1802 }
1803 else
1804 {
1805 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1806 }
1807 } else {
1808 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1809 }
1810 if (IsPhysical && Body == (IntPtr)0)
1811 {
1812 //re-create new body
1813 enableBody();
1814 }
1815 else
1816 {
1817 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1818 d.Quaternion myrot = new d.Quaternion();
1819 myrot.W = _orientation.w;
1820 myrot.X = _orientation.x;
1821 myrot.Y = _orientation.y;
1822 myrot.Z = _orientation.z;
1823 d.GeomSetQuaternion(prim_geom, ref myrot);
1824 }
1825 _parent_scene.geom_name_map[prim_geom] = oldname;
1826
1827
1828
1829 }
1830 } 1881 }
1831 } 1882 }
1832 1883
@@ -1856,19 +1907,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1856 set 1907 set
1857 { 1908 {
1858 _orientation = value; 1909 _orientation = value;
1859 lock (OdeScene.OdeLock) 1910
1860 {
1861 d.Quaternion myrot = new d.Quaternion();
1862 myrot.W = _orientation.w;
1863 myrot.X = _orientation.x;
1864 myrot.Y = _orientation.y;
1865 myrot.Z = _orientation.z;
1866 d.GeomSetQuaternion(prim_geom, ref myrot);
1867 if (m_isphysical && Body != (IntPtr)0)
1868 {
1869 d.BodySetQuaternion(Body, ref myrot);
1870 }
1871 }
1872 } 1911 }
1873 } 1912 }
1874 1913
@@ -1886,10 +1925,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1886 public override void AddForce(PhysicsVector force) 1925 public override void AddForce(PhysicsVector force)
1887 { 1926 {
1888 } 1927 }
1889 public void Move(float timestep) 1928
1890 {
1891
1892 }
1893 public override PhysicsVector RotationalVelocity 1929 public override PhysicsVector RotationalVelocity
1894 { 1930 {
1895 get{ return m_rotationalVelocity;} 1931 get{ return m_rotationalVelocity;}
@@ -1928,18 +1964,19 @@ namespace OpenSim.Region.Physics.OdePlugin
1928 1964
1929 1965
1930 1966
1931 IsPhysical = false; 1967 //IsPhysical = false;
1968 base.RaiseOutOfBounds(_position);
1932 _velocity.X = 0; 1969 _velocity.X = 0;
1933 _velocity.Y = 0; 1970 _velocity.Y = 0;
1934 _velocity.Z = 0; 1971 _velocity.Z = 0;
1935 m_rotationalVelocity.X = 0; 1972 m_rotationalVelocity.X = 0;
1936 m_rotationalVelocity.Y = 0; 1973 m_rotationalVelocity.Y = 0;
1937 m_rotationalVelocity.Z = 0; 1974 m_rotationalVelocity.Z = 0;
1938 //base.RequestPhysicsterseUpdate(); 1975 base.RequestPhysicsterseUpdate();
1939 m_throttleUpdates = false; 1976 m_throttleUpdates = false;
1940 throttleCounter = 0; 1977 throttleCounter = 0;
1941 _zeroFlag = true; 1978 _zeroFlag = true;
1942 outofBounds = true; 1979 //outofBounds = true;
1943 } 1980 }
1944 1981
1945 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) 1982 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
index cc1d16b..15b3415 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
@@ -163,7 +163,10 @@ namespace OpenSim.Region.Physics.POSPlugin
163 } 163 }
164 return false; 164 return false;
165 } 165 }
166 public override void AddPhysicsActorTaint(PhysicsActor prim)
167 {
166 168
169 }
167 public override void Simulate(float timeStep) 170 public override void Simulate(float timeStep)
168 { 171 {
169 foreach (POSCharacter character in _characters) 172 foreach (POSCharacter character in _characters)
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 8956f1a..799a7d4 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -135,7 +135,10 @@ namespace OpenSim.Region.Physics.PhysXPlugin
135 { 135 {
136 return AddPrim(position, size, rotation); 136 return AddPrim(position, size, rotation);
137 } 137 }
138 public override void AddPhysicsActorTaint(PhysicsActor prim)
139 {
138 140
141 }
139 public override void Simulate(float timeStep) 142 public override void Simulate(float timeStep)
140 { 143 {
141 try 144 try