aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs42
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs206
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs69
-rw-r--r--OpenSim/Region/Physics/Manager/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/Physics/Manager/IMesher.cs9
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs101
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs8
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs15
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs15
-rw-r--r--OpenSim/Region/Physics/Manager/ZeroMesher.cs9
-rw-r--r--OpenSim/Region/Physics/Meshing/Extruder.cs21
-rw-r--r--OpenSim/Region/Physics/Meshing/HelperTypes.cs10
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs42
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs74
-rw-r--r--OpenSim/Region/Physics/Meshing/SimpleHull.cs120
-rw-r--r--OpenSim/Region/Physics/Meshing/Simplex.cs49
-rw-r--r--OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs114
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs175
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs336
-rw-r--r--OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs84
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs124
26 files changed, 862 insertions, 773 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
index 919910c..b76fbbf 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("1.0.*")] 58[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 5ac651f..636cf1a 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -106,18 +106,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
106 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 106 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
107 PhysicsVector size, Quaternion rotation) 107 PhysicsVector size, Quaternion rotation)
108 { 108 {
109 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 109 return AddPrimShape(primName, pbs, position, size, rotation, false);
110 } 110 }
111 111
112 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 112 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
113 PhysicsVector size, Quaternion rotation, bool isPhysical) 113 PhysicsVector size, Quaternion rotation, bool isPhysical)
114 { 114 {
115 return null; 115 return null;
116 } 116 }
117
117 public override void AddPhysicsActorTaint(PhysicsActor prim) 118 public override void AddPhysicsActorTaint(PhysicsActor prim)
118 { 119 {
119
120 } 120 }
121
121 public override float Simulate(float timeStep) 122 public override float Simulate(float timeStep)
122 { 123 {
123 float fps = 0; 124 float fps = 0;
@@ -125,8 +126,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
125 { 126 {
126 BasicActor actor = _actors[i]; 127 BasicActor actor = _actors[i];
127 128
128 actor.Position.X += actor.Velocity.X * timeStep; 129 actor.Position.X += actor.Velocity.X*timeStep;
129 actor.Position.Y += actor.Velocity.Y * timeStep; 130 actor.Position.Y += actor.Velocity.Y*timeStep;
130 131
131 if (actor.Position.Y < 0) 132 if (actor.Position.Y < 0)
132 { 133 {
@@ -146,18 +147,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
146 actor.Position.X = 255.9F; 147 actor.Position.X = 255.9F;
147 } 148 }
148 149
149 float height = _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 1.0f; 150 float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f;
150 if (actor.Flying) 151 if (actor.Flying)
151 { 152 {
152 if (actor.Position.Z + (actor.Velocity.Z * timeStep) < 153 if (actor.Position.Z + (actor.Velocity.Z*timeStep) <
153 _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 2) 154 _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2)
154 { 155 {
155 actor.Position.Z = height; 156 actor.Position.Z = height;
156 actor.Velocity.Z = 0; 157 actor.Velocity.Z = 0;
157 } 158 }
158 else 159 else
159 { 160 {
160 actor.Position.Z += actor.Velocity.Z * timeStep; 161 actor.Position.Z += actor.Velocity.Z*timeStep;
161 } 162 }
162 } 163 }
163 else 164 else
@@ -204,31 +205,37 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
204 _position = new PhysicsVector(); 205 _position = new PhysicsVector();
205 _acceleration = new PhysicsVector(); 206 _acceleration = new PhysicsVector();
206 } 207 }
208
207 public override int PhysicsActorType 209 public override int PhysicsActorType
208 { 210 {
209 get { return (int)ActorTypes.Agent; } 211 get { return (int) ActorTypes.Agent; }
210 set { return; } 212 set { return; }
211 } 213 }
214
212 public override PhysicsVector RotationalVelocity 215 public override PhysicsVector RotationalVelocity
213 { 216 {
214 get { return m_rotationalVelocity; } 217 get { return m_rotationalVelocity; }
215 set { m_rotationalVelocity = value; } 218 set { m_rotationalVelocity = value; }
216 } 219 }
220
217 public override bool SetAlwaysRun 221 public override bool SetAlwaysRun
218 { 222 {
219 get { return false; } 223 get { return false; }
220 set { return; } 224 set { return; }
221 } 225 }
226
222 public override bool IsPhysical 227 public override bool IsPhysical
223 { 228 {
224 get { return false; } 229 get { return false; }
225 set { return; } 230 set { return; }
226 } 231 }
232
227 public override bool ThrottleUpdates 233 public override bool ThrottleUpdates
228 { 234 {
229 get { return false; } 235 get { return false; }
230 set { return; } 236 set { return; }
231 } 237 }
238
232 public override bool Flying 239 public override bool Flying
233 { 240 {
234 get { return flying; } 241 get { return flying; }
@@ -240,16 +247,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
240 get { return iscolliding; } 247 get { return iscolliding; }
241 set { iscolliding = value; } 248 set { iscolliding = value; }
242 } 249 }
250
243 public override bool CollidingGround 251 public override bool CollidingGround
244 { 252 {
245 get { return false; } 253 get { return false; }
246 set { return; } 254 set { return; }
247 } 255 }
256
248 public override bool CollidingObj 257 public override bool CollidingObj
249 { 258 {
250 get { return false; } 259 get { return false; }
251 set { return; } 260 set { return; }
252 } 261 }
262
253 public override PhysicsVector Position 263 public override PhysicsVector Position
254 { 264 {
255 get { return _position; } 265 get { return _position; }
@@ -264,27 +274,29 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
264 274
265 public override PrimitiveBaseShape Shape 275 public override PrimitiveBaseShape Shape
266 { 276 {
267 set 277 set { return; }
268 {
269 return;
270 }
271 } 278 }
279
272 public override float Mass 280 public override float Mass
273 { 281 {
274 get { return 0f; } 282 get { return 0f; }
275 } 283 }
284
276 public override PhysicsVector Force 285 public override PhysicsVector Force
277 { 286 {
278 get { return PhysicsVector.Zero; } 287 get { return PhysicsVector.Zero; }
279 } 288 }
289
280 public override PhysicsVector CenterOfMass 290 public override PhysicsVector CenterOfMass
281 { 291 {
282 get { return PhysicsVector.Zero; } 292 get { return PhysicsVector.Zero; }
283 } 293 }
294
284 public override PhysicsVector GeometricCenter 295 public override PhysicsVector GeometricCenter
285 { 296 {
286 get { return PhysicsVector.Zero; } 297 get { return PhysicsVector.Zero; }
287 } 298 }
299
288 public override PhysicsVector Velocity 300 public override PhysicsVector Velocity
289 { 301 {
290 get { return _velocity; } 302 get { return _velocity; }
@@ -321,4 +333,4 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
321 { 333 {
322 } 334 }
323 } 335 }
324} 336} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
index 06d4fe3..6b7ce82 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("1.0.0.0")] 58[assembly : AssemblyVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 5602301..a88299e 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -70,12 +70,11 @@ using XnaDevRu.BulletX;
70using XnaDevRu.BulletX.Dynamics; 70using XnaDevRu.BulletX.Dynamics;
71using AxiomQuaternion = Axiom.Math.Quaternion; 71using AxiomQuaternion = Axiom.Math.Quaternion;
72using BoxShape=XnaDevRu.BulletX.BoxShape; 72using BoxShape=XnaDevRu.BulletX.BoxShape;
73#endregion
74 73
74#endregion
75 75
76namespace OpenSim.Region.Physics.BulletXPlugin 76namespace OpenSim.Region.Physics.BulletXPlugin
77{ 77{
78
79 /// <summary> 78 /// <summary>
80 /// BulletXConversions are called now BulletXMaths 79 /// BulletXConversions are called now BulletXMaths
81 /// This Class converts objects and types for BulletX and give some operations 80 /// This Class converts objects and types for BulletX and give some operations
@@ -263,25 +262,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin
263 262
264 // Class to detect and debug collisions 263 // Class to detect and debug collisions
265 // Mainly used for debugging purposes 264 // Mainly used for debugging purposes
266 class CollisionDispatcherLocal : CollisionDispatcher 265 internal class CollisionDispatcherLocal : CollisionDispatcher
267 { 266 {
268 267 private BulletXScene relatedScene;
269 BulletXScene relatedScene;
270 268
271 public CollisionDispatcherLocal(BulletXScene s) 269 public CollisionDispatcherLocal(BulletXScene s)
272 : base() 270 : base()
273 { 271 {
274 relatedScene=s; 272 relatedScene = s;
275 } 273 }
276 274
277 public override bool NeedsCollision(CollisionObject bodyA, CollisionObject bodyB) 275 public override bool NeedsCollision(CollisionObject bodyA, CollisionObject bodyB)
278 { 276 {
279 RigidBody rb; 277 RigidBody rb;
280 BulletXCharacter bxcA=null; 278 BulletXCharacter bxcA = null;
281 BulletXPrim bxpA = null; 279 BulletXPrim bxpA = null;
282 Type t = bodyA.GetType(); 280 Type t = bodyA.GetType();
283 if (t==typeof(RigidBody)) { 281 if (t == typeof (RigidBody))
284 rb = (RigidBody)bodyA; 282 {
283 rb = (RigidBody) bodyA;
285 relatedScene._characters.TryGetValue(rb, out bxcA); 284 relatedScene._characters.TryGetValue(rb, out bxcA);
286 relatedScene._prims.TryGetValue(rb, out bxpA); 285 relatedScene._prims.TryGetValue(rb, out bxpA);
287 } 286 }
@@ -296,9 +295,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
296 BulletXCharacter bxcB = null; 295 BulletXCharacter bxcB = null;
297 BulletXPrim bxpB = null; 296 BulletXPrim bxpB = null;
298 t = bodyB.GetType(); 297 t = bodyB.GetType();
299 if (t == typeof(RigidBody)) 298 if (t == typeof (RigidBody))
300 { 299 {
301 rb = (RigidBody)bodyB; 300 rb = (RigidBody) bodyB;
302 relatedScene._characters.TryGetValue(rb, out bxcB); 301 relatedScene._characters.TryGetValue(rb, out bxcB);
303 relatedScene._prims.TryGetValue(rb, out bxpB); 302 relatedScene._prims.TryGetValue(rb, out bxpB);
304 } 303 }
@@ -310,15 +309,16 @@ namespace OpenSim.Region.Physics.BulletXPlugin
310 else 309 else
311 nameB = "null"; 310 nameB = "null";
312 311
313 bool needsCollision=base.NeedsCollision(bodyA, bodyB); 312 bool needsCollision = base.NeedsCollision(bodyA, bodyB);
314 313
315 MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB, needsCollision); 314 MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB,
315 needsCollision);
316 316
317 317
318 return needsCollision; 318 return needsCollision;
319 } 319 }
320 } 320 }
321 321
322 /// <summary> 322 /// <summary>
323 /// PhysicsScene Class for BulletX 323 /// PhysicsScene Class for BulletX
324 /// </summary> 324 /// </summary>
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
439 ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation; 439 ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation;
440 AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody); 440 AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody);
441 } 441 }
442 _characters.Remove(((BulletXCharacter)actor).RigidBody); 442 _characters.Remove(((BulletXCharacter) actor).RigidBody);
443 } 443 }
444 GC.Collect(); 444 GC.Collect();
445 } 445 }
@@ -448,8 +448,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
448 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 448 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
449 PhysicsVector size, AxiomQuaternion rotation) 449 PhysicsVector size, AxiomQuaternion rotation)
450 { 450 {
451 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 451 return AddPrimShape(primName, pbs, position, size, rotation, false);
452 } 452 }
453
453 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 454 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
454 PhysicsVector size, AxiomQuaternion rotation, bool isPhysical) 455 PhysicsVector size, AxiomQuaternion rotation, bool isPhysical)
455 { 456 {
@@ -514,7 +515,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin
514 515
515 public override void AddPhysicsActorTaint(PhysicsActor prim) 516 public override void AddPhysicsActorTaint(PhysicsActor prim)
516 { 517 {
517
518 } 518 }
519 519
520 public override float Simulate(float timeStep) 520 public override float Simulate(float timeStep)
@@ -526,10 +526,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
526 RemoveForgottenRigidBodies(); 526 RemoveForgottenRigidBodies();
527 //End of remove 527 //End of remove
528 MoveAllObjects(timeStep); 528 MoveAllObjects(timeStep);
529 529
530 530
531 fps = (timeStep * simulationSubSteps); 531 fps = (timeStep*simulationSubSteps);
532 532
533 ddWorld.StepSimulation(timeStep, simulationSubSteps, timeStep); 533 ddWorld.StepSimulation(timeStep, simulationSubSteps, timeStep);
534 //Extra Heightmap Validation: BulletX's HeightFieldTerrain somestimes doesn't work so fine. 534 //Extra Heightmap Validation: BulletX's HeightFieldTerrain somestimes doesn't work so fine.
535 ValidateHeightForAll(); 535 ValidateHeightForAll();
@@ -768,7 +768,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
768 public override PhysicsVector Size 768 public override PhysicsVector Size
769 { 769 {
770 get { return _size; } 770 get { return _size; }
771 set { lock (BulletXScene.BulletXLock) { _size = value; } } 771 set
772 {
773 lock (BulletXScene.BulletXLock)
774 {
775 _size = value;
776 }
777 }
772 } 778 }
773 779
774 public override PhysicsVector Force 780 public override PhysicsVector Force
@@ -788,10 +794,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
788 794
789 public override PrimitiveBaseShape Shape 795 public override PrimitiveBaseShape Shape
790 { 796 {
791 set 797 set { return; }
792 {
793 return;
794 }
795 } 798 }
796 799
797 public override bool SetAlwaysRun 800 public override bool SetAlwaysRun
@@ -818,9 +821,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
818 } 821 }
819 } 822 }
820 823
821 public override float Mass 824 public override float Mass
822 { 825 {
823 get { return ActorMass; } 826 get { return ActorMass; }
824 } 827 }
825 828
826 public virtual float ActorMass 829 public virtual float ActorMass
@@ -841,7 +844,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
841 844
842 public Vector3 RigidBodyPosition 845 public Vector3 RigidBodyPosition
843 { 846 {
844 get { return this.rigidBody.CenterOfMassPosition; } 847 get { return rigidBody.CenterOfMassPosition; }
845 } 848 }
846 849
847 public override bool IsPhysical 850 public override bool IsPhysical
@@ -855,6 +858,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
855 get { return flying; } 858 get { return flying; }
856 set { flying = value; } 859 set { flying = value; }
857 } 860 }
861
858 public override bool ThrottleUpdates 862 public override bool ThrottleUpdates
859 { 863 {
860 get { return false; } 864 get { return false; }
@@ -889,19 +893,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
889 893
890 public override bool Kinematic 894 public override bool Kinematic
891 { 895 {
892 get 896 get { return false; }
893 { 897 set { }
894 return false;
895 }
896 set
897 {
898
899 }
900 } 898 }
901 899
902 public override void AddForce(PhysicsVector force) 900 public override void AddForce(PhysicsVector force)
903 { 901 {
904
905 } 902 }
906 903
907 public override void SetMomentum(PhysicsVector momentum) 904 public override void SetMomentum(PhysicsVector momentum)
@@ -917,31 +914,37 @@ namespace OpenSim.Region.Physics.BulletXPlugin
917 } 914 }
918 915
919 #region Methods for updating values of RigidBody 916 #region Methods for updating values of RigidBody
920 internal protected void Translate() 917
918 protected internal void Translate()
921 { 919 {
922 Translate(this._position); 920 Translate(_position);
923 } 921 }
924 internal protected void Translate(PhysicsVector _newPos) 922
923 protected internal void Translate(PhysicsVector _newPos)
925 { 924 {
926 Vector3 _translation; 925 Vector3 _translation;
927 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; 926 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
928 rigidBody.Translate(_translation); 927 rigidBody.Translate(_translation);
929 } 928 }
930 internal protected void Speed() 929
930 protected internal void Speed()
931 { 931 {
932 Speed(this._velocity); 932 Speed(_velocity);
933 } 933 }
934 internal protected void Speed(PhysicsVector _newSpeed) 934
935 protected internal void Speed(PhysicsVector _newSpeed)
935 { 936 {
936 Vector3 _speed; 937 Vector3 _speed;
937 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); 938 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
938 rigidBody.LinearVelocity = _speed; 939 rigidBody.LinearVelocity = _speed;
939 } 940 }
940 internal protected void ReOrient() 941
942 protected internal void ReOrient()
941 { 943 {
942 ReOrient(this._orientation); 944 ReOrient(_orientation);
943 } 945 }
944 internal protected void ReOrient(AxiomQuaternion _newOrient) 946
947 protected internal void ReOrient(AxiomQuaternion _newOrient)
945 { 948 {
946 Quaternion _newOrientation; 949 Quaternion _newOrientation;
947 _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); 950 _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient);
@@ -949,17 +952,21 @@ namespace OpenSim.Region.Physics.BulletXPlugin
949 BulletXMaths.SetRotation(ref _comTransform, _newOrientation); 952 BulletXMaths.SetRotation(ref _comTransform, _newOrientation);
950 rigidBody.CenterOfMassTransform = _comTransform; 953 rigidBody.CenterOfMassTransform = _comTransform;
951 } 954 }
952 internal protected void ReSize() 955
956 protected internal void ReSize()
953 { 957 {
954 ReSize(this._size); 958 ReSize(_size);
955 } 959 }
956 internal protected virtual void ReSize(PhysicsVector _newSize) 960
961 protected internal virtual void ReSize(PhysicsVector _newSize)
957 { 962 {
958 } 963 }
964
959 public virtual void ScheduleTerseUpdate() 965 public virtual void ScheduleTerseUpdate()
960 { 966 {
961 base.RequestPhysicsterseUpdate(); 967 base.RequestPhysicsterseUpdate();
962 } 968 }
969
963 #endregion 970 #endregion
964 } 971 }
965 972
@@ -972,11 +979,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
972 : this("", parent_scene, pos) 979 : this("", parent_scene, pos)
973 { 980 {
974 } 981 }
982
975 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) 983 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos)
976 : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), 984 : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(),
977 AxiomQuaternion.Identity) 985 AxiomQuaternion.Identity)
978 { 986 {
979 } 987 }
988
980 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 989 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
981 PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation) 990 PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation)
982 : base(avName) 991 : base(avName)
@@ -1026,45 +1035,54 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1026 parent_scene.ddWorld.AddRigidBody(rigidBody); 1035 parent_scene.ddWorld.AddRigidBody(rigidBody);
1027 } 1036 }
1028 } 1037 }
1038
1029 public override int PhysicsActorType 1039 public override int PhysicsActorType
1030 { 1040 {
1031 get { return (int)ActorTypes.Agent; } 1041 get { return (int) ActorTypes.Agent; }
1032 set { return; } 1042 set { return; }
1033 } 1043 }
1044
1034 public override PhysicsVector Position 1045 public override PhysicsVector Position
1035 { 1046 {
1036 get { return base.Position; } 1047 get { return base.Position; }
1037 set { base.Position = value; } 1048 set { base.Position = value; }
1038 } 1049 }
1050
1039 public override PhysicsVector Velocity 1051 public override PhysicsVector Velocity
1040 { 1052 {
1041 get { return base.Velocity; } 1053 get { return base.Velocity; }
1042 set { base.Velocity = value; } 1054 set { base.Velocity = value; }
1043 } 1055 }
1056
1044 public override PhysicsVector Size 1057 public override PhysicsVector Size
1045 { 1058 {
1046 get { return base.Size; } 1059 get { return base.Size; }
1047 set { base.Size = value; } 1060 set { base.Size = value; }
1048 } 1061 }
1062
1049 public override PhysicsVector Acceleration 1063 public override PhysicsVector Acceleration
1050 { 1064 {
1051 get { return base.Acceleration; } 1065 get { return base.Acceleration; }
1052 } 1066 }
1067
1053 public override AxiomQuaternion Orientation 1068 public override AxiomQuaternion Orientation
1054 { 1069 {
1055 get { return base.Orientation; } 1070 get { return base.Orientation; }
1056 set { base.Orientation = value; } 1071 set { base.Orientation = value; }
1057 } 1072 }
1073
1058 public override bool Flying 1074 public override bool Flying
1059 { 1075 {
1060 get { return base.Flying; } 1076 get { return base.Flying; }
1061 set { base.Flying = value; } 1077 set { base.Flying = value; }
1062 } 1078 }
1079
1063 public override bool IsColliding 1080 public override bool IsColliding
1064 { 1081 {
1065 get { return base.IsColliding; } 1082 get { return base.IsColliding; }
1066 set { base.IsColliding = value; } 1083 set { base.IsColliding = value; }
1067 } 1084 }
1085
1068 public override bool Kinematic 1086 public override bool Kinematic
1069 { 1087 {
1070 get { return base.Kinematic; } 1088 get { return base.Kinematic; }
@@ -1075,10 +1093,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1075 { 1093 {
1076 base.SetAcceleration(accel); 1094 base.SetAcceleration(accel);
1077 } 1095 }
1096
1078 public override void AddForce(PhysicsVector force) 1097 public override void AddForce(PhysicsVector force)
1079 { 1098 {
1080 base.AddForce(force); 1099 base.AddForce(force);
1081 } 1100 }
1101
1082 public override void SetMomentum(PhysicsVector momentum) 1102 public override void SetMomentum(PhysicsVector momentum)
1083 { 1103 {
1084 base.SetMomentum(momentum); 1104 base.SetMomentum(momentum);
@@ -1117,6 +1137,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1117 } 1137 }
1118 rigidBody.LinearVelocity = vec; 1138 rigidBody.LinearVelocity = vec;
1119 } 1139 }
1140
1120 //This validation is very basic 1141 //This validation is very basic
1121 internal override void ValidateHeight(float heighmapPositionValue) 1142 internal override void ValidateHeight(float heighmapPositionValue)
1122 { 1143 {
@@ -1131,6 +1152,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1131 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1152 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1132 } 1153 }
1133 } 1154 }
1155
1134 internal override void UpdateKinetics() 1156 internal override void UpdateKinetics()
1135 { 1157 {
1136 _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); 1158 _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
@@ -1154,12 +1176,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1154 1176
1155 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, 1177 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size,
1156 AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) 1178 AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
1157 : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, isPhysical) 1179 : this(
1180 primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs,
1181 isPhysical)
1158 { 1182 {
1159 } 1183 }
1184
1160 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 1185 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
1161 PhysicsVector size, 1186 PhysicsVector size,
1162 PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, 1187 PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs,
1163 bool isPhysical) 1188 bool isPhysical)
1164 : base(primName) 1189 : base(primName)
1165 { 1190 {
@@ -1177,27 +1202,28 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1177 1202
1178 CreateRigidBody(parent_scene, mesh, pos, size); 1203 CreateRigidBody(parent_scene, mesh, pos, size);
1179 } 1204 }
1205
1180 public override int PhysicsActorType 1206 public override int PhysicsActorType
1181 { 1207 {
1182 get { return (int)ActorTypes.Prim; } 1208 get { return (int) ActorTypes.Prim; }
1183 set { return; } 1209 set { return; }
1184 } 1210 }
1211
1185 public override PhysicsVector Position 1212 public override PhysicsVector Position
1186 { 1213 {
1187 get { return base.Position; } 1214 get { return base.Position; }
1188 set { base.Position = value; } 1215 set { base.Position = value; }
1189 } 1216 }
1217
1190 public override PhysicsVector Velocity 1218 public override PhysicsVector Velocity
1191 { 1219 {
1192 get { return base.Velocity; } 1220 get { return base.Velocity; }
1193 set { base.Velocity = value; } 1221 set { base.Velocity = value; }
1194 } 1222 }
1223
1195 public override PhysicsVector Size 1224 public override PhysicsVector Size
1196 { 1225 {
1197 get 1226 get { return _size; }
1198 {
1199 return _size;
1200 }
1201 set 1227 set
1202 { 1228 {
1203 lock (BulletXScene.BulletXLock) 1229 lock (BulletXScene.BulletXLock)
@@ -1207,29 +1233,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1207 } 1233 }
1208 } 1234 }
1209 } 1235 }
1236
1210 public override PhysicsVector Acceleration 1237 public override PhysicsVector Acceleration
1211 { 1238 {
1212 get { return base.Acceleration; } 1239 get { return base.Acceleration; }
1213 } 1240 }
1241
1214 public override AxiomQuaternion Orientation 1242 public override AxiomQuaternion Orientation
1215 { 1243 {
1216 get { return base.Orientation; } 1244 get { return base.Orientation; }
1217 set { base.Orientation = value; } 1245 set { base.Orientation = value; }
1218 } 1246 }
1247
1219 public override float ActorMass 1248 public override float ActorMass
1220 { 1249 {
1221 get 1250 get
1222 { 1251 {
1223 //For now all prims are boxes 1252 //For now all prims are boxes
1224 return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z; 1253 return (_physical ? 1 : 0)*_density*_size.X*_size.Y*_size.Z;
1225 } 1254 }
1226 } 1255 }
1256
1227 public override bool IsPhysical 1257 public override bool IsPhysical
1228 { 1258 {
1229 get 1259 get { return base.IsPhysical; }
1230 {
1231 return base.IsPhysical;
1232 }
1233 set 1260 set
1234 { 1261 {
1235 base.IsPhysical = value; 1262 base.IsPhysical = value;
@@ -1238,27 +1265,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1238 //--- 1265 //---
1239 PhysicsPluginManager.PhysicsPluginMessage("Physical - Recreate", true); 1266 PhysicsPluginManager.PhysicsPluginMessage("Physical - Recreate", true);
1240 //--- 1267 //---
1241 ReCreateRigidBody(this._size); 1268 ReCreateRigidBody(_size);
1242 } 1269 }
1243 else 1270 else
1244 { 1271 {
1245 //--- 1272 //---
1246 PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true); 1273 PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true);
1247 //--- 1274 //---
1248 this.rigidBody.SetMassProps(Mass, new Vector3()); 1275 rigidBody.SetMassProps(Mass, new Vector3());
1249 } 1276 }
1250 } 1277 }
1251 } 1278 }
1279
1252 public override bool Flying 1280 public override bool Flying
1253 { 1281 {
1254 get { return base.Flying; } 1282 get { return base.Flying; }
1255 set { base.Flying = value; } 1283 set { base.Flying = value; }
1256 } 1284 }
1285
1257 public override bool IsColliding 1286 public override bool IsColliding
1258 { 1287 {
1259 get { return base.IsColliding; } 1288 get { return base.IsColliding; }
1260 set { base.IsColliding = value; } 1289 set { base.IsColliding = value; }
1261 } 1290 }
1291
1262 public override bool Kinematic 1292 public override bool Kinematic
1263 { 1293 {
1264 get { return base.Kinematic; } 1294 get { return base.Kinematic; }
@@ -1272,10 +1302,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1272 _acceleration = accel; 1302 _acceleration = accel;
1273 } 1303 }
1274 } 1304 }
1305
1275 public override void AddForce(PhysicsVector force) 1306 public override void AddForce(PhysicsVector force)
1276 { 1307 {
1277 base.AddForce(force); 1308 base.AddForce(force);
1278 } 1309 }
1310
1279 public override void SetMomentum(PhysicsVector momentum) 1311 public override void SetMomentum(PhysicsVector momentum)
1280 { 1312 {
1281 base.SetMomentum(momentum); 1313 base.SetMomentum(momentum);
@@ -1296,6 +1328,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1296 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1328 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1297 } 1329 }
1298 } 1330 }
1331
1299 internal override void UpdateKinetics() 1332 internal override void UpdateKinetics()
1300 { 1333 {
1301 if (_physical) //Updates properties. Prim updates its properties physically 1334 if (_physical) //Updates properties. Prim updates its properties physically
@@ -1320,7 +1353,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1320 { 1353 {
1321 m_lastUpdateSent = false; 1354 m_lastUpdateSent = false;
1322 base.ScheduleTerseUpdate(); 1355 base.ScheduleTerseUpdate();
1323
1324 } 1356 }
1325 m_prev_position = _position; 1357 m_prev_position = _position;
1326 } 1358 }
@@ -1333,7 +1365,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1333 } 1365 }
1334 1366
1335 #region Methods for updating values of RigidBody 1367 #region Methods for updating values of RigidBody
1336 internal protected void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, PhysicsVector size) 1368
1369 protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos,
1370 PhysicsVector size)
1337 { 1371 {
1338 //For RigidBody Constructor. The next values might change 1372 //For RigidBody Constructor. The next values might change
1339 float _linearDamping = 0.0f; 1373 float _linearDamping = 0.0f;
@@ -1349,27 +1383,31 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1349 CollisionShape _collisionShape; 1383 CollisionShape _collisionShape;
1350 if (mesh == null) 1384 if (mesh == null)
1351 { 1385 {
1352 _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f); 1386 _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size)/2.0f);
1353 } else { 1387 }
1388 else
1389 {
1354 int iVertexCount = mesh.getVertexList().Count; 1390 int iVertexCount = mesh.getVertexList().Count;
1355 int[] indices = mesh.getIndexListAsInt(); 1391 int[] indices = mesh.getIndexListAsInt();
1356 Vector3[] v3Vertices = new Vector3[iVertexCount]; 1392 Vector3[] v3Vertices = new Vector3[iVertexCount];
1357 for (int i = 0; i < iVertexCount; i++) 1393 for (int i = 0; i < iVertexCount; i++)
1358 { 1394 {
1359 PhysicsVector v=mesh.getVertexList()[i]; 1395 PhysicsVector v = mesh.getVertexList()[i];
1360 if (v != null) // Note, null has special meaning. See meshing code for details 1396 if (v != null) // Note, null has special meaning. See meshing code for details
1361 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); 1397 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
1362 else 1398 else
1363 v3Vertices[i] = MonoXnaCompactMaths.Vector3.Zero; 1399 v3Vertices[i] = Vector3.Zero;
1364 } 1400 }
1365 TriangleIndexVertexArray triMesh = new TriangleIndexVertexArray(indices, v3Vertices); 1401 TriangleIndexVertexArray triMesh = new TriangleIndexVertexArray(indices, v3Vertices);
1366 1402
1367 _collisionShape = new XnaDevRu.BulletX.TriangleMeshShape(triMesh); 1403 _collisionShape = new TriangleMeshShape(triMesh);
1368 } 1404 }
1369 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); 1405 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
1370 Vector3 _localInertia = new Vector3(); 1406 Vector3 _localInertia = new Vector3();
1371 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 1407 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1372 rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); 1408 rigidBody =
1409 new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping,
1410 _friction, _restitution);
1373 //rigidBody.ActivationState = ActivationState.DisableDeactivation; 1411 //rigidBody.ActivationState = ActivationState.DisableDeactivation;
1374 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition 1412 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
1375 Vector3 _vDebugTranslation; 1413 Vector3 _vDebugTranslation;
@@ -1379,30 +1417,34 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1379 parent_scene.ddWorld.AddRigidBody(rigidBody); 1417 parent_scene.ddWorld.AddRigidBody(rigidBody);
1380 } 1418 }
1381 } 1419 }
1382 internal protected void ReCreateRigidBody(PhysicsVector size) 1420
1421 protected internal void ReCreateRigidBody(PhysicsVector size)
1383 { 1422 {
1384 //There is a bug when trying to remove a rigidBody that is colliding with something.. 1423 //There is a bug when trying to remove a rigidBody that is colliding with something..
1385 try 1424 try
1386 { 1425 {
1387 this._parent_scene.ddWorld.RemoveRigidBody(rigidBody); 1426 _parent_scene.ddWorld.RemoveRigidBody(rigidBody);
1388 } 1427 }
1389 catch (Exception ex) 1428 catch (Exception ex)
1390 { 1429 {
1391 this._parent_scene.BulletXMessage(this._parent_scene.is_ex_message + ex.Message, true); 1430 _parent_scene.BulletXMessage(_parent_scene.is_ex_message + ex.Message, true);
1392 rigidBody.ActivationState = ActivationState.DisableSimulation; 1431 rigidBody.ActivationState = ActivationState.DisableSimulation;
1393 this._parent_scene.AddForgottenRigidBody(rigidBody); 1432 _parent_scene.AddForgottenRigidBody(rigidBody);
1394 } 1433 }
1395 CreateRigidBody(this._parent_scene, null, this._position, size); // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler 1434 CreateRigidBody(_parent_scene, null, _position, size);
1396 if (_physical) Speed();//Static objects don't have linear velocity 1435 // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler
1436 if (_physical) Speed(); //Static objects don't have linear velocity
1397 ReOrient(); 1437 ReOrient();
1398 GC.Collect(); 1438 GC.Collect();
1399 } 1439 }
1400 internal protected override void ReSize(PhysicsVector _newSize) 1440
1441 protected internal override void ReSize(PhysicsVector _newSize)
1401 { 1442 {
1402 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't 1443 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't
1403 //so i have to do it manually. That's recreating rigidbody 1444 //so i have to do it manually. That's recreating rigidbody
1404 ReCreateRigidBody(_newSize); 1445 ReCreateRigidBody(_newSize);
1405 } 1446 }
1447
1406 #endregion 1448 #endregion
1407 } 1449 }
1408 1450
@@ -1486,4 +1528,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1486 return height; 1528 return height;
1487 } 1529 }
1488 } 1530 }
1489} 1531} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs
index 4f63687..e73c953 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs
@@ -34,8 +34,8 @@
34 */ 34 */
35using System; 35using System;
36using System.Collections.Generic; 36using System.Collections.Generic;
37using System.Text;
38using MonoXnaCompactMaths; 37using MonoXnaCompactMaths;
38using XnaDevRu.BulletX;
39 39
40namespace OpenSim.Region.Physics.BulletXPlugin 40namespace OpenSim.Region.Physics.BulletXPlugin
41{ 41{
@@ -52,7 +52,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
52 private Vector3[] _vertexBase; 52 private Vector3[] _vertexBase;
53 private int _vertexStride; 53 private int _vertexStride;
54 54
55 public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) 55 public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices,
56 Vector3[] vertexBase, int vertexStride)
56 { 57 {
57 _numTriangles = numTriangleIndices; 58 _numTriangles = numTriangleIndices;
58 _triangleIndexBase = triangleIndexBase; 59 _triangleIndexBase = triangleIndexBase;
@@ -72,25 +73,57 @@ namespace OpenSim.Region.Physics.BulletXPlugin
72 _vertexStride = 24; 73 _vertexStride = 24;
73 } 74 }
74 75
75 public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } } 76 public int TriangleCount
76 public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } } 77 {
77 public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } } 78 get { return _numTriangles; }
78 public int VertexCount { get { return _numVertices; } set { _numVertices = value; } } 79 set { _numTriangles = value; }
79 public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } } 80 }
80 public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } } 81
82 public int[] TriangleIndexBase
83 {
84 get { return _triangleIndexBase; }
85 set { _triangleIndexBase = value; }
86 }
87
88 public int TriangleIndexStride
89 {
90 get { return _triangleIndexStride; }
91 set { _triangleIndexStride = value; }
92 }
93
94 public int VertexCount
95 {
96 get { return _numVertices; }
97 set { _numVertices = value; }
98 }
99
100 public Vector3[] VertexBase
101 {
102 get { return _vertexBase; }
103 set { _vertexBase = value; }
104 }
105
106 public int VertexStride
107 {
108 get { return _vertexStride; }
109 set { _vertexStride = value; }
110 }
81 } 111 }
82 112
83 /// <summary> 113 /// <summary>
84 /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. 114 /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays.
85 /// Additional meshes can be added using addIndexedMesh 115 /// Additional meshes can be added using addIndexedMesh
86 /// </summary> 116 /// </summary>
87 public class TriangleIndexVertexArray : XnaDevRu.BulletX.StridingMeshInterface 117 public class TriangleIndexVertexArray : StridingMeshInterface
88 { 118 {
89 List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); 119 private List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>();
90 120
91 public TriangleIndexVertexArray() { } 121 public TriangleIndexVertexArray()
122 {
123 }
92 124
93 public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) 125 public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride,
126 int numVertices, Vector3[] vertexBase, int vertexStride)
94 { 127 {
95 IndexedMesh mesh = new IndexedMesh(); 128 IndexedMesh mesh = new IndexedMesh();
96 mesh.TriangleCount = numTriangleIndices; 129 mesh.TriangleCount = numTriangleIndices;
@@ -104,19 +137,23 @@ namespace OpenSim.Region.Physics.BulletXPlugin
104 } 137 }
105 138
106 public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) 139 public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase)
107 : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { } 140 : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24)
141 {
142 }
108 143
109 public void AddIndexedMesh(IndexedMesh indexedMesh) 144 public void AddIndexedMesh(IndexedMesh indexedMesh)
110 { 145 {
111 _indexedMeshes.Add(indexedMesh); 146 _indexedMeshes.Add(indexedMesh);
112 } 147 }
113 148
114 public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) 149 public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces,
150 int subpart)
115 { 151 {
116 throw new Exception("The method or operation is not implemented."); 152 throw new Exception("The method or operation is not implemented.");
117 } 153 }
118 154
119 public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) 155 public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies,
156 out int numfaces, int subpart)
120 { 157 {
121 IndexedMesh m = _indexedMeshes[0]; 158 IndexedMesh m = _indexedMeshes[0];
122 Vector3[] vertexBase = m.VertexBase; 159 Vector3[] vertexBase = m.VertexBase;
@@ -158,4 +195,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin
158 throw new Exception("The method or operation is not implemented."); 195 throw new Exception("The method or operation is not implemented.");
159 } 196 }
160 } 197 }
161} 198} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
index 3d95d6d..983a2b9 100644
--- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("1.0.*")] 58[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs
index 1648a98..80b3320 100644
--- a/OpenSim/Region/Physics/Manager/IMesher.cs
+++ b/OpenSim/Region/Physics/Manager/IMesher.cs
@@ -28,8 +28,6 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32
33using OpenSim.Framework; 31using OpenSim.Framework;
34 32
35namespace OpenSim.Region.Physics.Manager 33namespace OpenSim.Region.Physics.Manager
@@ -39,7 +37,8 @@ namespace OpenSim.Region.Physics.Manager
39 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size); 37 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size);
40 } 38 }
41 39
42 public interface IVertex { 40 public interface IVertex
41 {
43 } 42 }
44 43
45 public interface IMesh 44 public interface IMesh
@@ -48,7 +47,5 @@ namespace OpenSim.Region.Physics.Manager
48 int[] getIndexListAsInt(); 47 int[] getIndexListAsInt();
49 int[] getIndexListAsIntLocked(); 48 int[] getIndexListAsIntLocked();
50 float[] getVertexListAsFloatLocked(); 49 float[] getVertexListAsFloatLocked();
51
52
53 } 50 }
54} 51} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 5894ab0..d393b62 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -25,10 +25,10 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using Axiom.Math;
29using OpenSim.Framework;
30using System; 28using System;
31using System.Collections.Generic; 29using System.Collections.Generic;
30using Axiom.Math;
31using OpenSim.Framework;
32 32
33namespace OpenSim.Region.Physics.Manager 33namespace OpenSim.Region.Physics.Manager
34{ 34{
@@ -37,14 +37,16 @@ namespace OpenSim.Region.Physics.Manager
37 public delegate void VelocityUpdate(PhysicsVector velocity); 37 public delegate void VelocityUpdate(PhysicsVector velocity);
38 38
39 public delegate void OrientationUpdate(Quaternion orientation); 39 public delegate void OrientationUpdate(Quaternion orientation);
40
40 public enum ActorTypes : int 41 public enum ActorTypes : int
41 { 42 {
42 Unknown = 0, 43 Unknown = 0,
43 Agent = 1, 44 Agent = 1,
44 Prim = 2, 45 Prim = 2,
45 Ground = 3 46 Ground = 3
46 } 47 }
47 public class CollisionEventUpdate : EventArgs 48
49 public class CollisionEventUpdate : EventArgs
48 { 50 {
49 // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. 51 // Raising the event on the object, so don't need to provide location.. further up the tree knows that info.
50 52
@@ -53,52 +55,53 @@ namespace OpenSim.Region.Physics.Manager
53 public bool m_startOrEnd; 55 public bool m_startOrEnd;
54 //public uint m_LocalID; 56 //public uint m_LocalID;
55 public List<uint> m_objCollisionList; 57 public List<uint> m_objCollisionList;
58
56 public CollisionEventUpdate(uint localID, int colliderType, bool startOrEnd, List<uint> objCollisionList) 59 public CollisionEventUpdate(uint localID, int colliderType, bool startOrEnd, List<uint> objCollisionList)
57 { 60 {
58 m_colliderType = colliderType; 61 m_colliderType = colliderType;
59 m_startOrEnd = startOrEnd; 62 m_startOrEnd = startOrEnd;
60 m_objCollisionList = objCollisionList; 63 m_objCollisionList = objCollisionList;
61
62 } 64 }
63 public CollisionEventUpdate(bool startOrEnd){ 65
64 m_colliderType = (int)ActorTypes.Unknown; 66 public CollisionEventUpdate(bool startOrEnd)
67 {
68 m_colliderType = (int) ActorTypes.Unknown;
65 m_startOrEnd = startOrEnd; 69 m_startOrEnd = startOrEnd;
66 m_objCollisionList = null; 70 m_objCollisionList = null;
67 } 71 }
68 public CollisionEventUpdate() { 72
69 m_colliderType = (int)ActorTypes.Unknown; 73 public CollisionEventUpdate()
74 {
75 m_colliderType = (int) ActorTypes.Unknown;
70 m_startOrEnd = false; 76 m_startOrEnd = false;
71 m_objCollisionList = null; 77 m_objCollisionList = null;
72 } 78 }
73 public int collidertype{ 79
74 get { 80 public int collidertype
75 return m_colliderType; 81 {
76 } 82 get { return m_colliderType; }
77 set { 83 set { m_colliderType = value; }
78 m_colliderType = value;
79 }
80 } 84 }
81 public bool startOrEnd { 85
82 get { 86 public bool startOrEnd
83 return m_startOrEnd; 87 {
84 } 88 get { return m_startOrEnd; }
85 set { 89 set { m_startOrEnd = value; }
86 m_startOrEnd = value;
87 }
88 } 90 }
89 public void addCollider(uint localID) { 91
92 public void addCollider(uint localID)
93 {
90 m_objCollisionList.Add(localID); 94 m_objCollisionList.Add(localID);
91 } 95 }
92 } 96 }
93
94
95 97
96
97 98
98 public abstract class PhysicsActor 99 public abstract class PhysicsActor
99 { 100 {
100 public delegate void RequestTerseUpdate(); 101 public delegate void RequestTerseUpdate();
102
101 public delegate void CollisionUpdate(EventArgs e); 103 public delegate void CollisionUpdate(EventArgs e);
104
102 public delegate void OutOfBounds(PhysicsVector pos); 105 public delegate void OutOfBounds(PhysicsVector pos);
103 106
104#pragma warning disable 67 107#pragma warning disable 67
@@ -117,10 +120,8 @@ namespace OpenSim.Region.Physics.Manager
117 120
118 public abstract PhysicsVector Size { get; set; } 121 public abstract PhysicsVector Size { get; set; }
119 122
120 public abstract PrimitiveBaseShape Shape 123 public abstract PrimitiveBaseShape Shape { set; }
121 { 124
122 set;
123 }
124 public virtual void RequestPhysicsterseUpdate() 125 public virtual void RequestPhysicsterseUpdate()
125 { 126 {
126 // Make a temporary copy of the event to avoid possibility of 127 // Make a temporary copy of the event to avoid possibility of
@@ -131,8 +132,8 @@ namespace OpenSim.Region.Physics.Manager
131 { 132 {
132 OnRequestTerseUpdate(); 133 OnRequestTerseUpdate();
133 } 134 }
134
135 } 135 }
136
136 public virtual void RaiseOutOfBounds(PhysicsVector pos) 137 public virtual void RaiseOutOfBounds(PhysicsVector pos)
137 { 138 {
138 // Make a temporary copy of the event to avoid possibility of 139 // Make a temporary copy of the event to avoid possibility of
@@ -143,8 +144,8 @@ namespace OpenSim.Region.Physics.Manager
143 { 144 {
144 OnOutOfBounds(pos); 145 OnOutOfBounds(pos);
145 } 146 }
146
147 } 147 }
148
148 public virtual void SendCollisionUpdate(EventArgs e) 149 public virtual void SendCollisionUpdate(EventArgs e)
149 { 150 {
150 CollisionUpdate handler = OnCollisionUpdate; 151 CollisionUpdate handler = OnCollisionUpdate;
@@ -159,7 +160,7 @@ namespace OpenSim.Region.Physics.Manager
159 160
160 public abstract float Mass { get; } 161 public abstract float Mass { get; }
161 162
162 public abstract PhysicsVector Force { get;} 163 public abstract PhysicsVector Force { get; }
163 164
164 public abstract PhysicsVector GeometricCenter { get; } 165 public abstract PhysicsVector GeometricCenter { get; }
165 166
@@ -172,7 +173,7 @@ namespace OpenSim.Region.Physics.Manager
172 public abstract Quaternion Orientation { get; set; } 173 public abstract Quaternion Orientation { get; set; }
173 public abstract int PhysicsActorType { get; set; } 174 public abstract int PhysicsActorType { get; set; }
174 175
175 public abstract bool IsPhysical {get; set;} 176 public abstract bool IsPhysical { get; set; }
176 177
177 public abstract bool Flying { get; set; } 178 public abstract bool Flying { get; set; }
178 public abstract bool SetAlwaysRun { get; set; } 179 public abstract bool SetAlwaysRun { get; set; }
@@ -198,48 +199,54 @@ namespace OpenSim.Region.Physics.Manager
198 get { return PhysicsVector.Zero; } 199 get { return PhysicsVector.Zero; }
199 set { return; } 200 set { return; }
200 } 201 }
202
201 public override bool SetAlwaysRun 203 public override bool SetAlwaysRun
202 { 204 {
203 get { return false; } 205 get { return false; }
204 set { return; } 206 set { return; }
205 } 207 }
208
206 public override bool CollidingGround 209 public override bool CollidingGround
207 { 210 {
208 get {return false;} 211 get { return false; }
209 set {return;} 212 set { return; }
210 } 213 }
211 public override bool CollidingObj 214
215 public override bool CollidingObj
212 { 216 {
213 get { return false; } 217 get { return false; }
214 set { return; } 218 set { return; }
215 } 219 }
220
216 public override PhysicsVector Size 221 public override PhysicsVector Size
217 { 222 {
218 get { return PhysicsVector.Zero; } 223 get { return PhysicsVector.Zero; }
219 set { return; } 224 set { return; }
220 } 225 }
226
221 public override float Mass 227 public override float Mass
222 { 228 {
223 get { return 0f; } 229 get { return 0f; }
224 } 230 }
231
225 public override PhysicsVector Force 232 public override PhysicsVector Force
226 { 233 {
227 get { return PhysicsVector.Zero; } 234 get { return PhysicsVector.Zero; }
228 } 235 }
236
229 public override PhysicsVector CenterOfMass 237 public override PhysicsVector CenterOfMass
230 { 238 {
231 get { return PhysicsVector.Zero; } 239 get { return PhysicsVector.Zero; }
232 } 240 }
241
233 public override PhysicsVector GeometricCenter 242 public override PhysicsVector GeometricCenter
234 { 243 {
235 get { return PhysicsVector.Zero; } 244 get { return PhysicsVector.Zero; }
236 } 245 }
246
237 public override PrimitiveBaseShape Shape 247 public override PrimitiveBaseShape Shape
238 { 248 {
239 set 249 set { return; }
240 {
241 return;
242 }
243 } 250 }
244 251
245 public override PhysicsVector Velocity 252 public override PhysicsVector Velocity
@@ -270,6 +277,7 @@ namespace OpenSim.Region.Physics.Manager
270 get { return false; } 277 get { return false; }
271 set { return; } 278 set { return; }
272 } 279 }
280
273 public override bool ThrottleUpdates 281 public override bool ThrottleUpdates
274 { 282 {
275 get { return false; } 283 get { return false; }
@@ -281,9 +289,10 @@ namespace OpenSim.Region.Physics.Manager
281 get { return false; } 289 get { return false; }
282 set { return; } 290 set { return; }
283 } 291 }
292
284 public override int PhysicsActorType 293 public override int PhysicsActorType
285 { 294 {
286 get { return (int)ActorTypes.Unknown; } 295 get { return (int) ActorTypes.Unknown; }
287 set { return; } 296 set { return; }
288 } 297 }
289 298
@@ -297,14 +306,16 @@ namespace OpenSim.Region.Physics.Manager
297 { 306 {
298 return; 307 return;
299 } 308 }
309
300 public override PhysicsVector RotationalVelocity 310 public override PhysicsVector RotationalVelocity
301 { 311 {
302 get { return PhysicsVector.Zero; } 312 get { return PhysicsVector.Zero; }
303 set { return; } 313 set { return; }
304 } 314 }
315
305 public override void SetMomentum(PhysicsVector momentum) 316 public override void SetMomentum(PhysicsVector momentum)
306 { 317 {
307 return; 318 return;
308 } 319 }
309 } 320 }
310} 321} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
index badcc04..a4ac54f 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
33using Nini.Config;
34 33
35namespace OpenSim.Region.Physics.Manager 34namespace OpenSim.Region.Physics.Manager
36{ 35{
@@ -91,7 +90,7 @@ namespace OpenSim.Region.Physics.Manager
91 plugHard = new ZeroMesherPlugin(); 90 plugHard = new ZeroMesherPlugin();
92 _MeshPlugins.Add(plugHard.GetName(), plugHard); 91 _MeshPlugins.Add(plugHard.GetName(), plugHard);
93 MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plugHard.GetName()); 92 MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plugHard.GetName());
94 93
95 // And now walk all assemblies (DLLs effectively) and see if they are home 94 // And now walk all assemblies (DLLs effectively) and see if they are home
96 // of a plugin that is of interest for us 95 // of a plugin that is of interest for us
97 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); 96 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics");
@@ -129,7 +128,7 @@ namespace OpenSim.Region.Physics.Manager
129 if (meshTypeInterface != null) 128 if (meshTypeInterface != null)
130 { 129 {
131 IMeshingPlugin plug = 130 IMeshingPlugin plug =
132 (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 131 (IMeshingPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
133 _MeshPlugins.Add(plug.GetName(), plug); 132 _MeshPlugins.Add(plug.GetName(), plug);
134 MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plug.GetName()); 133 MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plug.GetName());
135 } 134 }
@@ -155,6 +154,7 @@ namespace OpenSim.Region.Physics.Manager
155 MainLog.Instance.Verbose("PHYSICS", message); 154 MainLog.Instance.Verbose("PHYSICS", message);
156 } 155 }
157 } 156 }
157
158 //--- 158 //---
159 } 159 }
160 160
@@ -171,4 +171,4 @@ namespace OpenSim.Region.Physics.Manager
171 string GetName(); 171 string GetName();
172 IMesher GetMesher(); 172 IMesher GetMesher();
173 } 173 }
174} 174} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index c63a66d..37481f1 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -28,7 +28,6 @@
28using Axiom.Math; 28using Axiom.Math;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenSim.Framework.Console; 30using OpenSim.Framework.Console;
31using OpenSim.Region.Physics.Manager;
32 31
33namespace OpenSim.Region.Physics.Manager 32namespace OpenSim.Region.Physics.Manager
34{ 33{
@@ -45,6 +44,7 @@ namespace OpenSim.Region.Physics.Manager
45 { 44 {
46 get { return new NullPhysicsScene(); } 45 get { return new NullPhysicsScene(); }
47 } 46 }
47
48 public virtual void TriggerPhysicsBasedRestart() 48 public virtual void TriggerPhysicsBasedRestart()
49 { 49 {
50 physicsCrash handler = OnPhysicsCrash; 50 physicsCrash handler = OnPhysicsCrash;
@@ -52,9 +52,8 @@ namespace OpenSim.Region.Physics.Manager
52 { 52 {
53 OnPhysicsCrash(); 53 OnPhysicsCrash();
54 } 54 }
55
56 } 55 }
57 56
58 57
59 public abstract void Initialise(IMesher meshmerizer); 58 public abstract void Initialise(IMesher meshmerizer);
60 59
@@ -68,6 +67,7 @@ namespace OpenSim.Region.Physics.Manager
68 PhysicsVector size, Quaternion rotation); //To be removed 67 PhysicsVector size, Quaternion rotation); //To be removed
69 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 68 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
70 PhysicsVector size, Quaternion rotation, bool isPhysical); 69 PhysicsVector size, Quaternion rotation, bool isPhysical);
70
71 public abstract void AddPhysicsActorTaint(PhysicsActor prim); 71 public abstract void AddPhysicsActorTaint(PhysicsActor prim);
72 72
73 public abstract float Simulate(float timeStep); 73 public abstract float Simulate(float timeStep);
@@ -111,21 +111,24 @@ namespace OpenSim.Region.Physics.Manager
111 return PhysicsActor.Null; 111 return PhysicsActor.Null;
112 } 112 }
113*/ 113*/
114
114 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 115 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
115 PhysicsVector size, Quaternion rotation) //To be removed 116 PhysicsVector size, Quaternion rotation) //To be removed
116 { 117 {
117 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 118 return AddPrimShape(primName, pbs, position, size, rotation, false);
118 } 119 }
120
119 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 121 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
120 PhysicsVector size, Quaternion rotation, bool isPhysical) 122 PhysicsVector size, Quaternion rotation, bool isPhysical)
121 { 123 {
122 MainLog.Instance.Verbose("PHYSICS", "NullPhysicsScene : AddPrim({0},{1})", position, size); 124 MainLog.Instance.Verbose("PHYSICS", "NullPhysicsScene : AddPrim({0},{1})", position, size);
123 return PhysicsActor.Null; 125 return PhysicsActor.Null;
124 } 126 }
127
125 public override void AddPhysicsActorTaint(PhysicsActor prim) 128 public override void AddPhysicsActorTaint(PhysicsActor prim)
126 { 129 {
127
128 } 130 }
131
129 public override float Simulate(float timeStep) 132 public override float Simulate(float timeStep)
130 { 133 {
131 m_workIndicator = (m_workIndicator + 1)%10; 134 m_workIndicator = (m_workIndicator + 1)%10;
@@ -154,4 +157,4 @@ namespace OpenSim.Region.Physics.Manager
154 } 157 }
155 } 158 }
156 } 159 }
157} 160} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
index be82fca..1f5d0dc 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
@@ -28,7 +28,6 @@
28 28
29using System; 29using System;
30 30
31
32namespace OpenSim.Region.Physics.Manager 31namespace OpenSim.Region.Physics.Manager
33{ 32{
34 public class PhysicsVector 33 public class PhysicsVector
@@ -68,27 +67,27 @@ namespace OpenSim.Region.Physics.Manager
68 67
69 public static PhysicsVector cross(PhysicsVector a, PhysicsVector b) 68 public static PhysicsVector cross(PhysicsVector a, PhysicsVector b)
70 { 69 {
71 return new PhysicsVector(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); 70 return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X);
72 } 71 }
73 72
74 public float length() 73 public float length()
75 { 74 {
76 return (float)Math.Sqrt(X*X + Y*Y + Z*Z); 75 return (float) Math.Sqrt(X*X + Y*Y + Z*Z);
77 } 76 }
78 77
79 public static PhysicsVector operator / (PhysicsVector v, float f) 78 public static PhysicsVector operator /(PhysicsVector v, float f)
80 { 79 {
81 return new PhysicsVector(v.X / f, v.Y / f, v.Z / f); 80 return new PhysicsVector(v.X/f, v.Y/f, v.Z/f);
82 } 81 }
83 82
84 public static PhysicsVector operator *(PhysicsVector v, float f) 83 public static PhysicsVector operator *(PhysicsVector v, float f)
85 { 84 {
86 return new PhysicsVector(v.X * f, v.Y * f, v.Z * f); 85 return new PhysicsVector(v.X*f, v.Y*f, v.Z*f);
87 } 86 }
88 87
89 public static PhysicsVector operator *(float f, PhysicsVector v) 88 public static PhysicsVector operator *(float f, PhysicsVector v)
90 { 89 {
91 return v * f; 90 return v*f;
92 } 91 }
93 92
94 public virtual bool IsIdentical(PhysicsVector v, float tolerance) 93 public virtual bool IsIdentical(PhysicsVector v, float tolerance)
@@ -101,4 +100,4 @@ namespace OpenSim.Region.Physics.Manager
101 return false; 100 return false;
102 } 101 }
103 } 102 }
104} 103} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
index a88656e..7dae4ac 100644
--- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs
+++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
@@ -27,11 +27,8 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32using OpenSim.Framework; 30using OpenSim.Framework;
33 31
34
35/* 32/*
36 * This is the zero mesher. 33 * This is the zero mesher.
37 * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer. 34 * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer.
@@ -62,13 +59,11 @@ namespace OpenSim.Region.Physics.Manager
62 } 59 }
63 } 60 }
64 61
65 public class ZeroMesher: IMesher 62 public class ZeroMesher : IMesher
66 { 63 {
67
68 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) 64 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size)
69 { 65 {
70 return null; 66 return null;
71 } 67 }
72 } 68 }
73 69} \ No newline at end of file
74}
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs
index eecac5a..7ef5b5b 100644
--- a/OpenSim/Region/Physics/Meshing/Extruder.cs
+++ b/OpenSim/Region/Physics/Meshing/Extruder.cs
@@ -26,24 +26,22 @@
26* 26*
27*/ 27*/
28 28
29using System; 29using OpenSim.Region.Physics.Manager;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace OpenSim.Region.Physics.Meshing 31namespace OpenSim.Region.Physics.Meshing
34{ 32{
35 class Extruder 33 internal class Extruder
36 { 34 {
37 public float startParameter; 35 public float startParameter;
38 public float stopParameter; 36 public float stopParameter;
39 public Manager.PhysicsVector size; 37 public PhysicsVector size;
40 38
41 public Mesh Extrude(Mesh m) 39 public Mesh Extrude(Mesh m)
42 { 40 {
43 // Currently only works for iSteps=1; 41 // Currently only works for iSteps=1;
44 Mesh result = new Mesh(); 42 Mesh result = new Mesh();
45 43
46 Mesh workingPlus = m.Clone(); 44 Mesh workingPlus = m.Clone();
47 Mesh workingMinus = m.Clone(); 45 Mesh workingMinus = m.Clone();
48 46
49 foreach (Vertex v in workingPlus.vertices) 47 foreach (Vertex v in workingPlus.vertices)
@@ -80,14 +78,14 @@ namespace OpenSim.Region.Physics.Meshing
80 for (int i = 0; i < workingPlus.vertices.Count; i++) 78 for (int i = 0; i < workingPlus.vertices.Count; i++)
81 { 79 {
82 int iNext = (i + 1); 80 int iNext = (i + 1);
83 81
84 if (workingPlus.vertices[i] == null) // Can't make a simplex here 82 if (workingPlus.vertices[i] == null) // Can't make a simplex here
85 { 83 {
86 iLastNull = i+1; 84 iLastNull = i + 1;
87 continue; 85 continue;
88 } 86 }
89 87
90 if (i == workingPlus.vertices.Count-1) // End of list 88 if (i == workingPlus.vertices.Count - 1) // End of list
91 { 89 {
92 iNext = iLastNull; 90 iNext = iLastNull;
93 } 91 }
@@ -101,11 +99,12 @@ namespace OpenSim.Region.Physics.Meshing
101 tSide = new Triangle(workingPlus.vertices[i], workingMinus.vertices[i], workingPlus.vertices[iNext]); 99 tSide = new Triangle(workingPlus.vertices[i], workingMinus.vertices[i], workingPlus.vertices[iNext]);
102 result.Add(tSide); 100 result.Add(tSide);
103 101
104 tSide = new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]); 102 tSide =
103 new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]);
105 result.Add(tSide); 104 result.Add(tSide);
106 } 105 }
107 106
108 return result; 107 return result;
109 } 108 }
110 } 109 }
111} 110} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
index be82c32..ac06614 100644
--- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
@@ -30,9 +30,7 @@ using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Diagnostics; 31using System.Diagnostics;
32using System.Globalization; 32using System.Globalization;
33using OpenSim.Framework.Console;
34using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
35
36using OpenSim.Region.Physics.Meshing; 34using OpenSim.Region.Physics.Meshing;
37 35
38public class Vertex : PhysicsVector, IComparable<Vertex> 36public class Vertex : PhysicsVector, IComparable<Vertex>
@@ -54,7 +52,7 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
54 52
55 public static Vertex FromAngle(double angle) 53 public static Vertex FromAngle(double angle)
56 { 54 {
57 return new Vertex((float)Math.Cos(angle), (float)Math.Sin(angle), 0.0f); 55 return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f);
58 } 56 }
59 57
60 58
@@ -101,6 +99,7 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
101 { 99 {
102 return me.CompareTo(other) < 0; 100 return me.CompareTo(other) < 0;
103 } 101 }
102
104 public String ToRaw() 103 public String ToRaw()
105 { 104 {
106 // Why this stuff with the number formatter? 105 // Why this stuff with the number formatter?
@@ -117,7 +116,6 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
117 116
118 return s1; 117 return s1;
119 } 118 }
120
121} 119}
122 120
123public class Triangle 121public class Triangle
@@ -283,7 +281,7 @@ public class Triangle
283 float l = n.length(); 281 float l = n.length();
284 282
285 // Normalized "normal" 283 // Normalized "normal"
286 n = n / l; 284 n = n/l;
287 285
288 return n; 286 return n;
289 } 287 }
@@ -300,7 +298,7 @@ public class Triangle
300 // debugging purposes 298 // debugging purposes
301 public String ToStringRaw() 299 public String ToStringRaw()
302 { 300 {
303 String output = v1.ToRaw() + " " + v2.ToRaw() + " " +v3.ToRaw(); 301 String output = v1.ToRaw() + " " + v2.ToRaw() + " " + v3.ToRaw();
304 return output; 302 return output;
305 } 303 }
306} \ No newline at end of file 304} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index 2ebfa1c..9c2667e 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -26,14 +26,11 @@
26* 26*
27*/ 27*/
28 28
29
29using System; 30using System;
30using System.IO;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Text; 32using System.IO;
33
34using System.Runtime.InteropServices; 33using System.Runtime.InteropServices;
35
36
37using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.Physics.Manager;
38 35
39namespace OpenSim.Region.Physics.Meshing 36namespace OpenSim.Region.Physics.Meshing
@@ -66,9 +63,9 @@ namespace OpenSim.Region.Physics.Meshing
66 foreach (Triangle t in triangles) 63 foreach (Triangle t in triangles)
67 { 64 {
68 int iV1, iV2, iV3; 65 int iV1, iV2, iV3;
69 iV1 = this.vertices.IndexOf(t.v1); 66 iV1 = vertices.IndexOf(t.v1);
70 iV2 = this.vertices.IndexOf(t.v2); 67 iV2 = vertices.IndexOf(t.v2);
71 iV3 = this.vertices.IndexOf(t.v3); 68 iV3 = vertices.IndexOf(t.v3);
72 69
73 Triangle newT = new Triangle(result.vertices[iV1], result.vertices[iV2], result.vertices[iV3]); 70 Triangle newT = new Triangle(result.vertices[iV1], result.vertices[iV2], result.vertices[iV3]);
74 result.Add(newT); 71 result.Add(newT);
@@ -77,8 +74,7 @@ namespace OpenSim.Region.Physics.Meshing
77 return result; 74 return result;
78 } 75 }
79 76
80 77
81
82 public void Add(Triangle triangle) 78 public void Add(Triangle triangle)
83 { 79 {
84 int i; 80 int i;
@@ -160,15 +156,15 @@ namespace OpenSim.Region.Physics.Meshing
160 156
161 public float[] getVertexListAsFloatLocked() 157 public float[] getVertexListAsFloatLocked()
162 { 158 {
163 float[] result = new float[vertices.Count * 3]; 159 float[] result = new float[vertices.Count*3];
164 for (int i = 0; i < vertices.Count; i++) 160 for (int i = 0; i < vertices.Count; i++)
165 { 161 {
166 Vertex v = vertices[i]; 162 Vertex v = vertices[i];
167 if (v == null) 163 if (v == null)
168 continue; 164 continue;
169 result[3 * i + 0] = v.X; 165 result[3*i + 0] = v.X;
170 result[3 * i + 1] = v.Y; 166 result[3*i + 1] = v.Y;
171 result[3 * i + 2] = v.Z; 167 result[3*i + 2] = v.Z;
172 } 168 }
173 GCHandle.Alloc(result, GCHandleType.Pinned); 169 GCHandle.Alloc(result, GCHandleType.Pinned);
174 return result; 170 return result;
@@ -176,13 +172,13 @@ namespace OpenSim.Region.Physics.Meshing
176 172
177 public int[] getIndexListAsInt() 173 public int[] getIndexListAsInt()
178 { 174 {
179 int[] result = new int[triangles.Count * 3]; 175 int[] result = new int[triangles.Count*3];
180 for (int i = 0; i < triangles.Count; i++) 176 for (int i = 0; i < triangles.Count; i++)
181 { 177 {
182 Triangle t = triangles[i]; 178 Triangle t = triangles[i];
183 result[3 * i + 0] = vertices.IndexOf(t.v1); 179 result[3*i + 0] = vertices.IndexOf(t.v1);
184 result[3 * i + 1] = vertices.IndexOf(t.v2); 180 result[3*i + 1] = vertices.IndexOf(t.v2);
185 result[3 * i + 2] = vertices.IndexOf(t.v3); 181 result[3*i + 2] = vertices.IndexOf(t.v3);
186 } 182 }
187 return result; 183 return result;
188 } 184 }
@@ -202,7 +198,6 @@ namespace OpenSim.Region.Physics.Meshing
202 198
203 foreach (Triangle t in newMesh.triangles) 199 foreach (Triangle t in newMesh.triangles)
204 Add(t); 200 Add(t);
205
206 } 201 }
207 202
208 // Do a linear transformation of mesh. 203 // Do a linear transformation of mesh.
@@ -213,9 +208,9 @@ namespace OpenSim.Region.Physics.Meshing
213 if (v == null) 208 if (v == null)
214 continue; 209 continue;
215 float x, y, z; 210 float x, y, z;
216 x = v.X * matrix[0, 0] + v.Y * matrix[1, 0] + v.Z * matrix[2, 0]; 211 x = v.X*matrix[0, 0] + v.Y*matrix[1, 0] + v.Z*matrix[2, 0];
217 y = v.X * matrix[0, 1] + v.Y * matrix[1, 1] + v.Z * matrix[2, 1]; 212 y = v.X*matrix[0, 1] + v.Y*matrix[1, 1] + v.Z*matrix[2, 1];
218 z = v.X * matrix[0, 2] + v.Y * matrix[1, 2] + v.Z * matrix[2, 2]; 213 z = v.X*matrix[0, 2] + v.Y*matrix[1, 2] + v.Z*matrix[2, 2];
219 v.X = x + offset[0]; 214 v.X = x + offset[0];
220 v.Y = y + offset[1]; 215 v.Y = y + offset[1];
221 v.Z = z + offset[2]; 216 v.Z = z + offset[2];
@@ -237,5 +232,4 @@ namespace OpenSim.Region.Physics.Meshing
237 sw.Close(); 232 sw.Close();
238 } 233 }
239 } 234 }
240 235} \ No newline at end of file
241}
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 9c35f81..3217dd8 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -27,18 +27,13 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.IO;
31using System.Globalization;
32using System.Diagnostics;
33using System.Collections.Generic; 30using System.Collections.Generic;
34using System.Runtime.InteropServices;
35using OpenSim.Framework; 31using OpenSim.Framework;
36using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
37using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
38 34
39namespace OpenSim.Region.Physics.Meshing 35namespace OpenSim.Region.Physics.Meshing
40{ 36{
41
42 public class MeshmerizerPlugin : IMeshingPlugin 37 public class MeshmerizerPlugin : IMeshingPlugin
43 { 38 {
44 public MeshmerizerPlugin() 39 public MeshmerizerPlugin()
@@ -61,10 +56,11 @@ namespace OpenSim.Region.Physics.Meshing
61 // Setting baseDir to a path will enable the dumping of raw files 56 // Setting baseDir to a path will enable the dumping of raw files
62 // raw files can be imported by blender so a visual inspection of the results can be done 57 // raw files can be imported by blender so a visual inspection of the results can be done
63 // const string baseDir = "rawFiles"; 58 // const string baseDir = "rawFiles";
64 const string baseDir = null; 59 private const string baseDir = null;
65 60
66 static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2, ref float lambda, ref float mu) 61 private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2,
67 { 62 PhysicsVector r2, ref float lambda, ref float mu)
63 {
68 // p1, p2, points on the straight 64 // p1, p2, points on the straight
69 // r1, r2, directional vectors of the straight. Not necessarily of length 1! 65 // r1, r2, directional vectors of the straight. Not necessarily of length 1!
70 // note, that l, m can be scaled such, that the range 0..1 is mapped to the area between two points, 66 // note, that l, m can be scaled such, that the range 0..1 is mapped to the area between two points,
@@ -88,9 +84,8 @@ namespace OpenSim.Region.Physics.Meshing
88 float p1y = p1.Y; 84 float p1y = p1.Y;
89 float p2x = p2.X; 85 float p2x = p2.X;
90 float p2y = p2.Y; 86 float p2y = p2.Y;
91 lambda = (-p2x * r2y + p1x * r2y + (p2y - p1y) * r2x) / denom; 87 lambda = (-p2x*r2y + p1x*r2y + (p2y - p1y)*r2x)/denom;
92 mu = (-p2x * r1y + p1x * r1y + (p2y - p1y) * r1x) / denom; 88 mu = (-p2x*r1y + p1x*r1y + (p2y - p1y)*r1x)/denom;
93
94 } 89 }
95 90
96 private static List<Triangle> FindInfluencedTriangles(List<Triangle> triangles, Vertex v) 91 private static List<Triangle> FindInfluencedTriangles(List<Triangle> triangles, Vertex v)
@@ -105,8 +100,8 @@ namespace OpenSim.Region.Physics.Meshing
105 } 100 }
106 return influenced; 101 return influenced;
107 } 102 }
108 103
109 104
110 private static void InsertVertices(List<Vertex> vertices, int usedForSeed, List<Triangle> triangles) 105 private static void InsertVertices(List<Vertex> vertices, int usedForSeed, List<Triangle> triangles)
111 { 106 {
112 // This is a variant of the delaunay algorithm 107 // This is a variant of the delaunay algorithm
@@ -126,10 +121,10 @@ namespace OpenSim.Region.Physics.Meshing
126 // do not fulfill this condition with respect to the new triangle 121 // do not fulfill this condition with respect to the new triangle
127 122
128 // Find the triangles that are influenced by the new vertex 123 // Find the triangles that are influenced by the new vertex
129 Vertex v=vertices[iCurrentVertex]; 124 Vertex v = vertices[iCurrentVertex];
130 if (v == null) 125 if (v == null)
131 continue; // Null is polygon stop marker. Ignore it 126 continue; // Null is polygon stop marker. Ignore it
132 List<Triangle> influencedTriangles=FindInfluencedTriangles(triangles, v); 127 List<Triangle> influencedTriangles = FindInfluencedTriangles(triangles, v);
133 128
134 List<Simplex> simplices = new List<Simplex>(); 129 List<Simplex> simplices = new List<Simplex>();
135 130
@@ -177,12 +172,11 @@ namespace OpenSim.Region.Physics.Meshing
177 } 172 }
178 } 173 }
179 } 174 }
180
181 } 175 }
182 176
183 177
184 static Mesh CreateBoxMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) 178 private static Mesh CreateBoxMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size)
185 // Builds the z (+ and -) surfaces of a box shaped prim 179 // Builds the z (+ and -) surfaces of a box shaped prim
186 { 180 {
187 UInt16 hollowFactor = primShape.ProfileHollow; 181 UInt16 hollowFactor = primShape.ProfileHollow;
188 UInt16 profileBegin = primShape.ProfileBegin; 182 UInt16 profileBegin = primShape.ProfileBegin;
@@ -201,7 +195,7 @@ namespace OpenSim.Region.Physics.Meshing
201 Vertex MP = new Vertex(-0.5f, +0.5f, 0.0f); 195 Vertex MP = new Vertex(-0.5f, +0.5f, 0.0f);
202 Vertex PP = new Vertex(+0.5f, +0.5f, 0.0f); 196 Vertex PP = new Vertex(+0.5f, +0.5f, 0.0f);
203 197
204 Meshing.SimpleHull outerHull = new SimpleHull(); 198 SimpleHull outerHull = new SimpleHull();
205 outerHull.AddVertex(MM); 199 outerHull.AddVertex(MM);
206 outerHull.AddVertex(PM); 200 outerHull.AddVertex(PM);
207 outerHull.AddVertex(PP); 201 outerHull.AddVertex(PP);
@@ -210,9 +204,10 @@ namespace OpenSim.Region.Physics.Meshing
210 // Deal with cuts now 204 // Deal with cuts now
211 if ((profileBegin != 0) || (profileEnd != 0)) 205 if ((profileBegin != 0) || (profileEnd != 0))
212 { 206 {
213 double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; // In degree, for easier debugging and understanding 207 double fProfileBeginAngle = profileBegin/50000.0*360.0;
214 fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y 208 // In degree, for easier debugging and understanding
215 double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 209 fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y
210 double fProfileEndAngle = 360.0 - profileEnd/50000.0*360.0; // Pathend comes as complement to 1.0
216 fProfileEndAngle -= (90.0 + 45.0); 211 fProfileEndAngle -= (90.0 + 45.0);
217 if (fProfileBeginAngle < fProfileEndAngle) 212 if (fProfileBeginAngle < fProfileEndAngle)
218 fProfileEndAngle -= 360.0; 213 fProfileEndAngle -= 360.0;
@@ -222,20 +217,23 @@ namespace OpenSim.Region.Physics.Meshing
222 // and we approximate this arc by a polygon chain 217 // and we approximate this arc by a polygon chain
223 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space 218 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space
224 // So it can easily be subtracted from the outer hull 219 // So it can easily be subtracted from the outer hull
225 int iSteps = (int)(((fProfileBeginAngle - fProfileEndAngle) / 45.0) + .5); // how many steps do we need with approximately 45 degree 220 int iSteps = (int) (((fProfileBeginAngle - fProfileEndAngle)/45.0) + .5);
226 double dStepWidth=(fProfileBeginAngle-fProfileEndAngle)/iSteps; 221 // how many steps do we need with approximately 45 degree
222 double dStepWidth = (fProfileBeginAngle - fProfileEndAngle)/iSteps;
227 223
228 Vertex origin = new Vertex(0.0f, 0.0f, 0.0f); 224 Vertex origin = new Vertex(0.0f, 0.0f, 0.0f);
229 225
230 // Note the sequence of vertices here. It's important to have the other rotational sense than in outerHull 226 // Note the sequence of vertices here. It's important to have the other rotational sense than in outerHull
231 SimpleHull cutHull = new SimpleHull(); 227 SimpleHull cutHull = new SimpleHull();
232 cutHull.AddVertex(origin); 228 cutHull.AddVertex(origin);
233 for (int i=0; i<iSteps; i++) { 229 for (int i = 0; i < iSteps; i++)
234 double angle=fProfileBeginAngle-i*dStepWidth; // we count against the angle orientation!!!! 230 {
235 Vertex v = Vertex.FromAngle(angle * Math.PI / 180.0); 231 double angle = fProfileBeginAngle - i*dStepWidth; // we count against the angle orientation!!!!
232 Vertex v = Vertex.FromAngle(angle*Math.PI/180.0);
236 cutHull.AddVertex(v); 233 cutHull.AddVertex(v);
237 } 234 }
238 Vertex legEnd = Vertex.FromAngle(fProfileEndAngle * Math.PI / 180.0); // Calculated separately to avoid errors 235 Vertex legEnd = Vertex.FromAngle(fProfileEndAngle*Math.PI/180.0);
236 // Calculated separately to avoid errors
239 cutHull.AddVertex(legEnd); 237 cutHull.AddVertex(legEnd);
240 238
241 MainLog.Instance.Debug("Starting cutting of the hollow shape from the prim {1}", 0, primName); 239 MainLog.Instance.Debug("Starting cutting of the hollow shape from the prim {1}", 0, primName);
@@ -248,10 +246,10 @@ namespace OpenSim.Region.Physics.Meshing
248 if (hollowFactor > 0) 246 if (hollowFactor > 0)
249 { 247 {
250 float hollowFactorF = (float) hollowFactor/(float) 50000; 248 float hollowFactorF = (float) hollowFactor/(float) 50000;
251 Vertex IMM = new Vertex(-0.5f * hollowFactorF, -0.5f * hollowFactorF, 0.0f); 249 Vertex IMM = new Vertex(-0.5f*hollowFactorF, -0.5f*hollowFactorF, 0.0f);
252 Vertex IPM = new Vertex(+0.5f * hollowFactorF, -0.5f * hollowFactorF, 0.0f); 250 Vertex IPM = new Vertex(+0.5f*hollowFactorF, -0.5f*hollowFactorF, 0.0f);
253 Vertex IMP = new Vertex(-0.5f * hollowFactorF, +0.5f * hollowFactorF, 0.0f); 251 Vertex IMP = new Vertex(-0.5f*hollowFactorF, +0.5f*hollowFactorF, 0.0f);
254 Vertex IPP = new Vertex(+0.5f * hollowFactorF, +0.5f * hollowFactorF, 0.0f); 252 Vertex IPP = new Vertex(+0.5f*hollowFactorF, +0.5f*hollowFactorF, 0.0f);
255 253
256 SimpleHull holeHull = new SimpleHull(); 254 SimpleHull holeHull = new SimpleHull();
257 255
@@ -263,7 +261,6 @@ namespace OpenSim.Region.Physics.Meshing
263 SimpleHull hollowedHull = SimpleHull.SubtractHull(outerHull, holeHull); 261 SimpleHull hollowedHull = SimpleHull.SubtractHull(outerHull, holeHull);
264 262
265 outerHull = hollowedHull; 263 outerHull = hollowedHull;
266
267 } 264 }
268 265
269 Mesh m = new Mesh(); 266 Mesh m = new Mesh();
@@ -286,7 +283,7 @@ namespace OpenSim.Region.Physics.Meshing
286 m.Remove(Seed2); 283 m.Remove(Seed2);
287 m.Remove(Seed3); 284 m.Remove(Seed3);
288 m.DumpRaw(baseDir, primName, "Proto seeds removed"); 285 m.DumpRaw(baseDir, primName, "Proto seeds removed");
289 286
290 m.RemoveTrianglesOutside(outerHull); 287 m.RemoveTrianglesOutside(outerHull);
291 m.DumpRaw(baseDir, primName, "Proto outsides removed"); 288 m.DumpRaw(baseDir, primName, "Proto outsides removed");
292 289
@@ -374,7 +371,7 @@ namespace OpenSim.Region.Physics.Meshing
374 switch (primShape.ProfileShape) 371 switch (primShape.ProfileShape)
375 { 372 {
376 case ProfileShape.Square: 373 case ProfileShape.Square:
377 mesh=CreateBoxMesh(primName, primShape, size); 374 mesh = CreateBoxMesh(primName, primShape, size);
378 CalcNormals(mesh); 375 CalcNormals(mesh);
379 break; 376 break;
380 default: 377 default:
@@ -389,5 +386,4 @@ namespace OpenSim.Region.Physics.Meshing
389 return mesh; 386 return mesh;
390 } 387 }
391 } 388 }
392 389} \ No newline at end of file
393}
diff --git a/OpenSim/Region/Physics/Meshing/SimpleHull.cs b/OpenSim/Region/Physics/Meshing/SimpleHull.cs
index a769053..809f3d5 100644
--- a/OpenSim/Region/Physics/Meshing/SimpleHull.cs
+++ b/OpenSim/Region/Physics/Meshing/SimpleHull.cs
@@ -28,9 +28,8 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32
33using OpenSim.Framework.Console; 31using OpenSim.Framework.Console;
32using OpenSim.Region.Physics.Manager;
34 33
35namespace OpenSim.Region.Physics.Meshing 34namespace OpenSim.Region.Physics.Meshing
36{ 35{
@@ -43,17 +42,18 @@ namespace OpenSim.Region.Physics.Meshing
43 // is defined by the hull lies inside or outside the simplex chain 42 // is defined by the hull lies inside or outside the simplex chain
44 public class SimpleHull 43 public class SimpleHull
45 { 44 {
46 List<Vertex> vertices = new List<Vertex>(); 45 private List<Vertex> vertices = new List<Vertex>();
47 List<Vertex> holeVertices = new List<Vertex>(); // Only used, when the hull is hollow 46 private List<Vertex> holeVertices = new List<Vertex>(); // Only used, when the hull is hollow
48 47
49 // Adds a vertex to the end of the list 48 // Adds a vertex to the end of the list
50 public void AddVertex(Vertex v) { 49 public void AddVertex(Vertex v)
50 {
51 vertices.Add(v); 51 vertices.Add(v);
52 } 52 }
53 53
54 override public String ToString() 54 public override String ToString()
55 { 55 {
56 String result=""; 56 String result = "";
57 foreach (Vertex v in vertices) 57 foreach (Vertex v in vertices)
58 { 58 {
59 result += "b:" + v.ToString() + "\n"; 59 result += "b:" + v.ToString() + "\n";
@@ -63,7 +63,8 @@ namespace OpenSim.Region.Physics.Meshing
63 } 63 }
64 64
65 65
66 public List<Vertex> getVertices() { 66 public List<Vertex> getVertices()
67 {
67 List<Vertex> newVertices = new List<Vertex>(); 68 List<Vertex> newVertices = new List<Vertex>();
68 69
69 newVertices.AddRange(vertices); 70 newVertices.AddRange(vertices);
@@ -81,27 +82,27 @@ namespace OpenSim.Region.Physics.Meshing
81 result.AddVertex(v.Clone()); 82 result.AddVertex(v.Clone());
82 } 83 }
83 84
84 foreach (Vertex v in this.holeVertices) 85 foreach (Vertex v in holeVertices)
85 { 86 {
86 result.holeVertices.Add(v.Clone()); 87 result.holeVertices.Add(v.Clone());
87 } 88 }
88 89
89 return result; 90 return result;
90 } 91 }
91 92
92 public bool IsPointIn(Vertex v1) 93 public bool IsPointIn(Vertex v1)
93 { 94 {
94 int iCounter=0; 95 int iCounter = 0;
95 List<Simplex> simplices=buildSimplexList(); 96 List<Simplex> simplices = buildSimplexList();
96 foreach (Simplex s in simplices) 97 foreach (Simplex s in simplices)
97 { 98 {
98 // Send a ray along the positive X-Direction 99 // Send a ray along the positive X-Direction
99 // Note, that this direction must correlate with the "below" interpretation 100 // Note, that this direction must correlate with the "below" interpretation
100 // of handling for the special cases below 101 // of handling for the special cases below
101 Manager.PhysicsVector intersection = s.RayIntersect(v1, new Manager.PhysicsVector(1.0f, 0.0f, 0.0f), true); 102 PhysicsVector intersection = s.RayIntersect(v1, new PhysicsVector(1.0f, 0.0f, 0.0f), true);
102 103
103 if (intersection == null) 104 if (intersection == null)
104 continue; // No intersection. Done. More tests to follow otherwise 105 continue; // No intersection. Done. More tests to follow otherwise
105 106
106 // Did we hit the end of a simplex? 107 // Did we hit the end of a simplex?
107 // Then this can be one of two special cases: 108 // Then this can be one of two special cases:
@@ -111,19 +112,21 @@ namespace OpenSim.Region.Physics.Meshing
111 // Solution: If the other vertex is "below" the ray, we don't count it 112 // Solution: If the other vertex is "below" the ray, we don't count it
112 // Thus corners pointing down are counted twice, corners pointing up are not counted 113 // Thus corners pointing down are counted twice, corners pointing up are not counted
113 // borders are counted once 114 // borders are counted once
114 if (intersection.IsIdentical(s.v1, 0.001f)) { 115 if (intersection.IsIdentical(s.v1, 0.001f))
116 {
115 if (s.v2.Y < v1.Y) 117 if (s.v2.Y < v1.Y)
116 continue; 118 continue;
117 } 119 }
118 // Do this for the other vertex two 120 // Do this for the other vertex two
119 if (intersection.IsIdentical(s.v2, 0.001f)) { 121 if (intersection.IsIdentical(s.v2, 0.001f))
120 if (s.v1.Y<v1.Y) 122 {
123 if (s.v1.Y < v1.Y)
121 continue; 124 continue;
122 } 125 }
123 iCounter++; 126 iCounter++;
124 } 127 }
125 128
126 return iCounter % 2 == 1; // Point is inside if the number of intersections is odd 129 return iCounter%2 == 1; // Point is inside if the number of intersections is odd
127 } 130 }
128 131
129 public bool containsPointsFrom(SimpleHull otherHull) 132 public bool containsPointsFrom(SimpleHull otherHull)
@@ -138,19 +141,20 @@ namespace OpenSim.Region.Physics.Meshing
138 } 141 }
139 142
140 143
141 List<Simplex> buildSimplexList() { 144 private List<Simplex> buildSimplexList()
142 145 {
143 List<Simplex> result = new List<Simplex>(); 146 List<Simplex> result = new List<Simplex>();
144 147
145 // Not asserted but assumed: at least three vertices 148 // Not asserted but assumed: at least three vertices
146 for (int i=0; i<vertices.Count-1; i++) { 149 for (int i = 0; i < vertices.Count - 1; i++)
147 Simplex s=new Simplex(vertices[i], vertices[i+1]); 150 {
151 Simplex s = new Simplex(vertices[i], vertices[i + 1]);
148 result.Add(s); 152 result.Add(s);
149 } 153 }
150 Simplex s1=new Simplex(vertices[vertices.Count-1], vertices[0]); 154 Simplex s1 = new Simplex(vertices[vertices.Count - 1], vertices[0]);
151 result.Add(s1); 155 result.Add(s1);
152 156
153 if (holeVertices.Count==0) 157 if (holeVertices.Count == 0)
154 return result; 158 return result;
155 159
156 // Same here. At least three vertices in hole assumed 160 // Same here. At least three vertices in hole assumed
@@ -159,19 +163,19 @@ namespace OpenSim.Region.Physics.Meshing
159 Simplex s = new Simplex(holeVertices[i], holeVertices[i + 1]); 163 Simplex s = new Simplex(holeVertices[i], holeVertices[i + 1]);
160 result.Add(s); 164 result.Add(s);
161 } 165 }
162 166
163 s1 = new Simplex(holeVertices[holeVertices.Count - 1], holeVertices[0]); 167 s1 = new Simplex(holeVertices[holeVertices.Count - 1], holeVertices[0]);
164 result.Add(s1); 168 result.Add(s1);
165 return result; 169 return result;
166 } 170 }
167 171
168 bool InsertVertex(Vertex v, int iAfter) 172 private bool InsertVertex(Vertex v, int iAfter)
169 { 173 {
170 vertices.Insert(iAfter + 1, v); 174 vertices.Insert(iAfter + 1, v);
171 return true; 175 return true;
172 } 176 }
173 177
174 Vertex getNextVertex(Vertex currentVertex) 178 private Vertex getNextVertex(Vertex currentVertex)
175 { 179 {
176 int iCurrentIndex; 180 int iCurrentIndex;
177 iCurrentIndex = vertices.IndexOf(currentVertex); 181 iCurrentIndex = vertices.IndexOf(currentVertex);
@@ -185,8 +189,10 @@ namespace OpenSim.Region.Physics.Meshing
185 return vertices[iCurrentIndex]; 189 return vertices[iCurrentIndex];
186 } 190 }
187 191
188 public Vertex FindVertex(Vertex vBase, float tolerance) { 192 public Vertex FindVertex(Vertex vBase, float tolerance)
189 foreach (Vertex v in vertices) { 193 {
194 foreach (Vertex v in vertices)
195 {
190 if (v.IsIdentical(vBase, tolerance)) 196 if (v.IsIdentical(vBase, tolerance))
191 return v; 197 return v;
192 } 198 }
@@ -196,32 +202,31 @@ namespace OpenSim.Region.Physics.Meshing
196 202
197 public void FindIntersection(Simplex s, ref Vertex Intersection, ref Vertex nextVertex) 203 public void FindIntersection(Simplex s, ref Vertex Intersection, ref Vertex nextVertex)
198 { 204 {
199 Vertex bestIntersection=null; 205 Vertex bestIntersection = null;
200 float distToV1=Single.PositiveInfinity; 206 float distToV1 = Single.PositiveInfinity;
201 Simplex bestIntersectingSimplex=null; 207 Simplex bestIntersectingSimplex = null;
202 208
203 List<Simplex> simple = buildSimplexList(); 209 List<Simplex> simple = buildSimplexList();
204 foreach (Simplex sTest in simple) 210 foreach (Simplex sTest in simple)
205 { 211 {
206 Manager.PhysicsVector vvTemp = Simplex.Intersect(sTest, s, -.001f, -.001f, 0.999f, .999f); 212 PhysicsVector vvTemp = Simplex.Intersect(sTest, s, -.001f, -.001f, 0.999f, .999f);
207 213
208 Vertex vTemp=null; 214 Vertex vTemp = null;
209 if (vvTemp != null) 215 if (vvTemp != null)
210 vTemp = new Vertex(vvTemp); 216 vTemp = new Vertex(vvTemp);
211 217
212 if (vTemp!=null) { 218 if (vTemp != null)
213 219 {
214 Manager.PhysicsVector diff=(s.v1-vTemp); 220 PhysicsVector diff = (s.v1 - vTemp);
215 float distTemp=diff.length(); 221 float distTemp = diff.length();
216 222
217 if (bestIntersection==null || distTemp<distToV1) { 223 if (bestIntersection == null || distTemp < distToV1)
218 bestIntersection=vTemp; 224 {
219 distToV1=distTemp; 225 bestIntersection = vTemp;
226 distToV1 = distTemp;
220 bestIntersectingSimplex = sTest; 227 bestIntersectingSimplex = sTest;
221 } 228 }
222
223 } // end if vTemp 229 } // end if vTemp
224
225 } // end foreach 230 } // end foreach
226 231
227 Intersection = bestIntersection; 232 Intersection = bestIntersection;
@@ -234,7 +239,6 @@ namespace OpenSim.Region.Physics.Meshing
234 239
235 public static SimpleHull SubtractHull(SimpleHull baseHull, SimpleHull otherHull) 240 public static SimpleHull SubtractHull(SimpleHull baseHull, SimpleHull otherHull)
236 { 241 {
237
238 SimpleHull baseHullClone = baseHull.Clone(); 242 SimpleHull baseHullClone = baseHull.Clone();
239 SimpleHull otherHullClone = otherHull.Clone(); 243 SimpleHull otherHullClone = otherHull.Clone();
240 bool intersects = false; 244 bool intersects = false;
@@ -249,15 +253,16 @@ namespace OpenSim.Region.Physics.Meshing
249 // Insert into baseHull 253 // Insert into baseHull
250 for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++) 254 for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++)
251 { 255 {
252 int iBaseNext = (iBase + 1) % baseHullClone.vertices.Count; 256 int iBaseNext = (iBase + 1)%baseHullClone.vertices.Count;
253 Simplex sBase = new Simplex(baseHullClone.vertices[iBase], baseHullClone.vertices[iBaseNext]); 257 Simplex sBase = new Simplex(baseHullClone.vertices[iBase], baseHullClone.vertices[iBaseNext]);
254 258
255 for (iOther = 0; iOther < otherHullClone.vertices.Count; iOther++) 259 for (iOther = 0; iOther < otherHullClone.vertices.Count; iOther++)
256 { 260 {
257 int iOtherNext = (iOther + 1) % otherHullClone.vertices.Count; 261 int iOtherNext = (iOther + 1)%otherHullClone.vertices.Count;
258 Simplex sOther = new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]); 262 Simplex sOther =
263 new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]);
259 264
260 Manager.PhysicsVector intersect = Simplex.Intersect(sBase, sOther, 0.001f, -.001f, 0.999f, 1.001f); 265 PhysicsVector intersect = Simplex.Intersect(sBase, sOther, 0.001f, -.001f, 0.999f, 1.001f);
261 if (intersect != null) 266 if (intersect != null)
262 { 267 {
263 Vertex vIntersect = new Vertex(intersect); 268 Vertex vIntersect = new Vertex(intersect);
@@ -278,15 +283,15 @@ namespace OpenSim.Region.Physics.Meshing
278 // Insert into otherHull 283 // Insert into otherHull
279 for (iOther = 0; iOther < otherHullClone.vertices.Count; iOther++) 284 for (iOther = 0; iOther < otherHullClone.vertices.Count; iOther++)
280 { 285 {
281 int iOtherNext = (iOther + 1) % otherHullClone.vertices.Count; 286 int iOtherNext = (iOther + 1)%otherHullClone.vertices.Count;
282 Simplex sOther = new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]); 287 Simplex sOther = new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]);
283 288
284 for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++) 289 for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++)
285 { 290 {
286 int iBaseNext = (iBase + 1) % baseHullClone.vertices.Count; 291 int iBaseNext = (iBase + 1)%baseHullClone.vertices.Count;
287 Simplex sBase = new Simplex(baseHullClone.vertices[iBase], baseHullClone.vertices[iBaseNext]); 292 Simplex sBase = new Simplex(baseHullClone.vertices[iBase], baseHullClone.vertices[iBaseNext]);
288 293
289 Manager.PhysicsVector intersect = Simplex.Intersect(sBase, sOther, -.001f, 0.001f, 1.001f, 0.999f); 294 PhysicsVector intersect = Simplex.Intersect(sBase, sOther, -.001f, 0.001f, 1.001f, 0.999f);
290 if (intersect != null) 295 if (intersect != null)
291 { 296 {
292 Vertex vIntersect = new Vertex(intersect); 297 Vertex vIntersect = new Vertex(intersect);
@@ -321,8 +326,8 @@ namespace OpenSim.Region.Physics.Meshing
321 int iBase; 326 int iBase;
322 for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++) 327 for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++)
323 { 328 {
324 int iBaseNext = (iBase + 1) % baseHullClone.vertices.Count; 329 int iBaseNext = (iBase + 1)%baseHullClone.vertices.Count;
325 Vertex center = new Vertex((baseHullClone.vertices[iBase] + baseHullClone.vertices[iBaseNext]) / 2.0f); 330 Vertex center = new Vertex((baseHullClone.vertices[iBase] + baseHullClone.vertices[iBaseNext])/2.0f);
326 bool isOutside = !otherHullClone.IsPointIn(center); 331 bool isOutside = !otherHullClone.IsPointIn(center);
327 if (isOutside) 332 if (isOutside)
328 { 333 {
@@ -334,7 +339,7 @@ namespace OpenSim.Region.Physics.Meshing
334 339
335 340
336 if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition. 341 if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition.
337 // In otherwords, subtractHull completely embraces baseHull 342 // In otherwords, subtractHull completely embraces baseHull
338 { 343 {
339 return result; 344 return result;
340 } 345 }
@@ -369,7 +374,7 @@ namespace OpenSim.Region.Physics.Meshing
369 374
370 if (nextVertex != null) // A node that represents an intersection 375 if (nextVertex != null) // A node that represents an intersection
371 { 376 {
372 V1 = nextVertex; // Needed to find the next vertex on the other hull 377 V1 = nextVertex; // Needed to find the next vertex on the other hull
373 onBase = !onBase; 378 onBase = !onBase;
374 } 379 }
375 380
@@ -385,7 +390,6 @@ namespace OpenSim.Region.Physics.Meshing
385 MainLog.Instance.Debug("The resulting Hull is:\n{1}", 0, result.ToString()); 390 MainLog.Instance.Debug("The resulting Hull is:\n{1}", 0, result.ToString());
386 391
387 return result; 392 return result;
388
389 } 393 }
390 } 394 }
391} 395} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Meshing/Simplex.cs b/OpenSim/Region/Physics/Meshing/Simplex.cs
index 98e693a..8fba2bf 100644
--- a/OpenSim/Region/Physics/Meshing/Simplex.cs
+++ b/OpenSim/Region/Physics/Meshing/Simplex.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32using OpenSim.Region.Physics.Manager; 30using OpenSim.Region.Physics.Manager;
33 31
34namespace OpenSim.Region.Physics.Meshing 32namespace OpenSim.Region.Physics.Meshing
@@ -49,7 +47,6 @@ namespace OpenSim.Region.Physics.Meshing
49 47
50 public int CompareTo(Simplex other) 48 public int CompareTo(Simplex other)
51 { 49 {
52
53 Vertex lv1, lv2, ov1, ov2, temp; 50 Vertex lv1, lv2, ov1, ov2, temp;
54 51
55 lv1 = v1; 52 lv1 = v1;
@@ -92,8 +89,9 @@ namespace OpenSim.Region.Physics.Meshing
92 return 0; 89 return 0;
93 } 90 }
94 91
95 private static void intersectParameter(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2, ref float lambda, ref float mu) 92 private static void intersectParameter(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2,
96 { 93 ref float lambda, ref float mu)
94 {
97 // Intersects two straights 95 // Intersects two straights
98 // p1, p2, points on the straight 96 // p1, p2, points on the straight
99 // r1, r2, directional vectors of the straight. Not necessarily of length 1! 97 // r1, r2, directional vectors of the straight. Not necessarily of length 1!
@@ -112,27 +110,28 @@ namespace OpenSim.Region.Physics.Meshing
112 float p2x = p2.X; 110 float p2x = p2.X;
113 float p2y = p2.Y; 111 float p2y = p2.Y;
114 112
115 float z1=-p2x * r2y + p1x * r2y + (p2y - p1y) * r2x; 113 float z1 = -p2x*r2y + p1x*r2y + (p2y - p1y)*r2x;
116 float z2=-p2x * r1y + p1x * r1y + (p2y - p1y) * r1x; 114 float z2 = -p2x*r1y + p1x*r1y + (p2y - p1y)*r1x;
117 115
118 if (denom == 0.0f) // Means the straights are parallel. Either no intersection or an infinite number of them 116 if (denom == 0.0f) // Means the straights are parallel. Either no intersection or an infinite number of them
119 { 117 {
120 if (z1==0.0f) {// Means they are identical -> many, many intersections 118 if (z1 == 0.0f)
119 {
120// Means they are identical -> many, many intersections
121 lambda = Single.NaN; 121 lambda = Single.NaN;
122 mu = Single.NaN; 122 mu = Single.NaN;
123 } else { 123 }
124 else
125 {
124 lambda = Single.PositiveInfinity; 126 lambda = Single.PositiveInfinity;
125 mu = Single.PositiveInfinity; 127 mu = Single.PositiveInfinity;
126 } 128 }
127 return; 129 return;
128
129 } 130 }
130 131
131 132
132 133 lambda = z1/denom;
133 lambda = z1 / denom; 134 mu = z2/denom;
134 mu = z2 / denom;
135
136 } 135 }
137 136
138 137
@@ -145,12 +144,12 @@ namespace OpenSim.Region.Physics.Meshing
145 // upperBorder2 : 1.0 144 // upperBorder2 : 1.0
146 // Set these to values near the given parameters (e.g. 0.001 instead of 1 to exclude simplex starts safely, or to -0.001 to include them safely) 145 // Set these to values near the given parameters (e.g. 0.001 instead of 1 to exclude simplex starts safely, or to -0.001 to include them safely)
147 public static PhysicsVector Intersect( 146 public static PhysicsVector Intersect(
148 Simplex s1, 147 Simplex s1,
149 Simplex s2, 148 Simplex s2,
150 float lowerBorder1, 149 float lowerBorder1,
151 float lowerBorder2, 150 float lowerBorder2,
152 float upperBorder1, 151 float upperBorder1,
153 float upperBorder2) 152 float upperBorder2)
154 { 153 {
155 PhysicsVector firstSimplexDirection = s1.v2 - s1.v1; 154 PhysicsVector firstSimplexDirection = s1.v2 - s1.v1;
156 PhysicsVector secondSimplexDirection = s2.v2 - s2.v1; 155 PhysicsVector secondSimplexDirection = s2.v2 - s2.v1;
@@ -181,8 +180,7 @@ namespace OpenSim.Region.Physics.Meshing
181 if (mu > upperBorder2) // outside simplex 2 180 if (mu > upperBorder2) // outside simplex 2
182 return null; 181 return null;
183 182
184 return s1.v1 + lambda * firstSimplexDirection; 183 return s1.v1 + lambda*firstSimplexDirection;
185
186 } 184 }
187 185
188 // Intersects the simplex with a ray. The ray is defined as all p=origin + lambda*direction 186 // Intersects the simplex with a ray. The ray is defined as all p=origin + lambda*direction
@@ -212,15 +210,12 @@ namespace OpenSim.Region.Physics.Meshing
212 return null; 210 return null;
213 211
214 if (lambda == 1.0 && !bEndsIncluded) 212 if (lambda == 1.0 && !bEndsIncluded)
215 return null; // The end of the simplices are not included 213 return null; // The end of the simplices are not included
216 214
217 if (lambda < 0.0f) // we're before v1; 215 if (lambda < 0.0f) // we're before v1;
218 return null; 216 return null;
219 217
220 return this.v1 + lambda * simplexDirection; 218 return v1 + lambda*simplexDirection;
221
222 } 219 }
223
224
225 } 220 }
226} \ No newline at end of file 221} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
index 1e5713b..1ea5458 100644
--- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("1.0.*")] 58[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 9676db4..a118e7c 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -27,11 +27,9 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using Axiom.Math; 30using Axiom.Math;
32using Ode.NET; 31using Ode.NET;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
36 34
37namespace OpenSim.Region.Physics.OdePlugin 35namespace OpenSim.Region.Physics.OdePlugin
@@ -87,7 +85,9 @@ namespace OpenSim.Region.Physics.OdePlugin
87 _acceleration = new PhysicsVector(); 85 _acceleration = new PhysicsVector();
88 _parent_scene = parent_scene; 86 _parent_scene = parent_scene;
89 87
90 m_StandUpRotation = new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, -0.004689182f, 0.9998941f); 88 m_StandUpRotation =
89 new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f,
90 -0.004689182f, 0.9998941f);
91 91
92 for (int i = 0; i < 11; i++) 92 for (int i = 0; i < 11; i++)
93 { 93 {
@@ -105,12 +105,9 @@ namespace OpenSim.Region.Physics.OdePlugin
105 d.GeomSetBody(Shell, Body); 105 d.GeomSetBody(Shell, Body);
106 106
107 107
108
109
110 d.BodySetRotation(Body, ref m_StandUpRotation); 108 d.BodySetRotation(Body, ref m_StandUpRotation);
111 109
112 110
113
114 //Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero); 111 //Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero);
115 //d.JointAttach(Amotor, Body, IntPtr.Zero); 112 //d.JointAttach(Amotor, Body, IntPtr.Zero);
116 //d.JointSetAMotorMode(Amotor, dAMotorEuler); 113 //d.JointSetAMotorMode(Amotor, dAMotorEuler);
@@ -124,45 +121,47 @@ namespace OpenSim.Region.Physics.OdePlugin
124 //d.JointSetAMotorParam(Amotor, 0, -0); 121 //d.JointSetAMotorParam(Amotor, 0, -0);
125 //d.JointSetAMotorParam(Amotor, 0x200, -0); 122 //d.JointSetAMotorParam(Amotor, 0x200, -0);
126 //d.JointSetAMotorParam(Amotor, 0x100, -0); 123 //d.JointSetAMotorParam(Amotor, 0x100, -0);
127 // d.JointSetAMotorParam(Amotor, 0, 0); 124 // d.JointSetAMotorParam(Amotor, 0, 0);
128 // d.JointSetAMotorParam(Amotor, 3, 0); 125 // d.JointSetAMotorParam(Amotor, 3, 0);
129 // d.JointSetAMotorParam(Amotor, 2, 0); 126 // d.JointSetAMotorParam(Amotor, 2, 0);
130
131
132
133 } 127 }
134 m_name = avName; 128 m_name = avName;
135 parent_scene.geom_name_map[Shell] = avName; 129 parent_scene.geom_name_map[Shell] = avName;
136 parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 130 parent_scene.actor_name_map[Shell] = (PhysicsActor) this;
137 } 131 }
132
138 public override int PhysicsActorType 133 public override int PhysicsActorType
139 { 134 {
140 get { return (int)ActorTypes.Agent; } 135 get { return (int) ActorTypes.Agent; }
141 set { return; } 136 set { return; }
142 } 137 }
138
143 public override bool SetAlwaysRun 139 public override bool SetAlwaysRun
144 { 140 {
145 get { return m_alwaysRun; } 141 get { return m_alwaysRun; }
146 set { m_alwaysRun = value; } 142 set { m_alwaysRun = value; }
147 } 143 }
144
148 public override bool IsPhysical 145 public override bool IsPhysical
149 { 146 {
150 get { return false; } 147 get { return false; }
151 set { return; } 148 set { return; }
152 } 149 }
150
153 public override bool ThrottleUpdates 151 public override bool ThrottleUpdates
154 { 152 {
155 get { return false; } 153 get { return false; }
156 set { return; } 154 set { return; }
157 } 155 }
156
158 public override bool Flying 157 public override bool Flying
159 { 158 {
160 get { return flying; } 159 get { return flying; }
161 set { flying = value; } 160 set { flying = value; }
162 } 161 }
162
163 public override bool IsColliding 163 public override bool IsColliding
164 { 164 {
165
166 get { return m_iscolliding; } 165 get { return m_iscolliding; }
167 set 166 set
168 { 167 {
@@ -193,24 +192,22 @@ namespace OpenSim.Region.Physics.OdePlugin
193 192
194 // Equal truecounts and false counts means we're colliding with something. 193 // Equal truecounts and false counts means we're colliding with something.
195 194
196 if (falsecount > 1.2 * truecount) 195 if (falsecount > 1.2*truecount)
197 { 196 {
198 m_iscolliding = false; 197 m_iscolliding = false;
199 } 198 }
200 else 199 else
201 { 200 {
202 m_iscolliding = true; 201 m_iscolliding = true;
203
204
205 } 202 }
206 if (m_wascolliding != m_iscolliding) 203 if (m_wascolliding != m_iscolliding)
207 { 204 {
208 //base.SendCollisionUpdate(new CollisionEventUpdate()); 205 //base.SendCollisionUpdate(new CollisionEventUpdate());
209
210 } 206 }
211 m_wascolliding = m_iscolliding; 207 m_wascolliding = m_iscolliding;
212 } 208 }
213 } 209 }
210
214 public override bool CollidingGround 211 public override bool CollidingGround
215 { 212 {
216 get { return m_iscollidingGround; } 213 get { return m_iscollidingGround; }
@@ -243,7 +240,7 @@ namespace OpenSim.Region.Physics.OdePlugin
243 240
244 // Equal truecounts and false counts means we're colliding with something. 241 // Equal truecounts and false counts means we're colliding with something.
245 242
246 if (falsecount > 1.2 * truecount) 243 if (falsecount > 1.2*truecount)
247 { 244 {
248 m_iscollidingGround = false; 245 m_iscollidingGround = false;
249 } 246 }
@@ -258,10 +255,12 @@ namespace OpenSim.Region.Physics.OdePlugin
258 m_wascollidingGround = m_iscollidingGround; 255 m_wascollidingGround = m_iscollidingGround;
259 } 256 }
260 } 257 }
258
261 public override bool CollidingObj 259 public override bool CollidingObj
262 { 260 {
263 get { return m_iscollidingObj; } 261 get { return m_iscollidingObj; }
264 set { 262 set
263 {
265 m_iscollidingObj = value; 264 m_iscollidingObj = value;
266 if (value) 265 if (value)
267 m_pidControllerActive = false; 266 m_pidControllerActive = false;
@@ -269,10 +268,12 @@ namespace OpenSim.Region.Physics.OdePlugin
269 m_pidControllerActive = true; 268 m_pidControllerActive = true;
270 } 269 }
271 } 270 }
271
272 public void SetPidStatus(bool status) 272 public void SetPidStatus(bool status)
273 { 273 {
274 m_pidControllerActive = status; 274 m_pidControllerActive = status;
275 } 275 }
276
276 public override PhysicsVector Position 277 public override PhysicsVector Position
277 { 278 {
278 get { return _position; } 279 get { return _position; }
@@ -285,14 +286,16 @@ namespace OpenSim.Region.Physics.OdePlugin
285 } 286 }
286 } 287 }
287 } 288 }
289
288 public override PhysicsVector RotationalVelocity 290 public override PhysicsVector RotationalVelocity
289 { 291 {
290 get { return m_rotationalVelocity; } 292 get { return m_rotationalVelocity; }
291 set { m_rotationalVelocity = value; } 293 set { m_rotationalVelocity = value; }
292 } 294 }
295
293 public override PhysicsVector Size 296 public override PhysicsVector Size
294 { 297 {
295 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 298 get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); }
296 set 299 set
297 { 300 {
298 m_pidControllerActive = true; 301 m_pidControllerActive = true;
@@ -303,7 +306,7 @@ namespace OpenSim.Region.Physics.OdePlugin
303 float capsuleradius = CAPSULE_RADIUS; 306 float capsuleradius = CAPSULE_RADIUS;
304 capsuleradius = 0.2f; 307 capsuleradius = 0.2f;
305 308
306 CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z * 0.43f))); // subtract 43% of the size 309 CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.43f))); // subtract 43% of the size
307 d.BodyDestroy(Body); 310 d.BodyDestroy(Body);
308 d.GeomDestroy(Shell); 311 d.GeomDestroy(Shell);
309 //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH)); 312 //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH));
@@ -311,25 +314,27 @@ namespace OpenSim.Region.Physics.OdePlugin
311 d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); 314 d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
312 Body = d.BodyCreate(_parent_scene.world); 315 Body = d.BodyCreate(_parent_scene.world);
313 d.BodySetMass(Body, ref ShellMass); 316 d.BodySetMass(Body, ref ShellMass);
314 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); 317 d.BodySetPosition(Body, _position.X, _position.Y,
318 _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule));
315 d.GeomSetBody(Shell, Body); 319 d.GeomSetBody(Shell, Body);
316 } 320 }
317 _parent_scene.geom_name_map[Shell] = m_name; 321 _parent_scene.geom_name_map[Shell] = m_name;
318 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 322 _parent_scene.actor_name_map[Shell] = (PhysicsActor) this;
319 } 323 }
320 } 324 }
325
321 public override float Mass 326 public override float Mass
322 { 327 {
323 get { 328 get
324 329 {
325 float AVvolume = (float)(Math.PI * Math.Pow(CAPSULE_RADIUS, 2) * CAPSULE_LENGTH); 330 float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
326 return m_density * AVvolume; 331 return m_density*AVvolume;
327 } 332 }
328 } 333 }
329 334
330 public override PhysicsVector Force 335 public override PhysicsVector Force
331 { 336 {
332 get { return new PhysicsVector(_target_velocity.X,_target_velocity.Y,_target_velocity.Z); } 337 get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); }
333 } 338 }
334 339
335 public override PhysicsVector CenterOfMass 340 public override PhysicsVector CenterOfMass
@@ -344,18 +349,17 @@ namespace OpenSim.Region.Physics.OdePlugin
344 349
345 public override PrimitiveBaseShape Shape 350 public override PrimitiveBaseShape Shape
346 { 351 {
347 set 352 set { return; }
348 {
349 return;
350 }
351 } 353 }
352 354
353 public override PhysicsVector Velocity 355 public override PhysicsVector Velocity
354 { 356 {
355 get { return _velocity; } 357 get { return _velocity; }
356 set { 358 set
359 {
357 m_pidControllerActive = true; 360 m_pidControllerActive = true;
358 _target_velocity = value; } 361 _target_velocity = value;
362 }
359 } 363 }
360 364
361 public override bool Kinematic 365 public override bool Kinematic
@@ -390,6 +394,7 @@ namespace OpenSim.Region.Physics.OdePlugin
390 394
391 //m_lastUpdateSent = false; 395 //m_lastUpdateSent = false;
392 } 396 }
397
393 public void doForce(PhysicsVector force) 398 public void doForce(PhysicsVector force)
394 { 399 {
395 if (!collidelock) 400 if (!collidelock)
@@ -413,13 +418,11 @@ namespace OpenSim.Region.Physics.OdePlugin
413 //d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); 418 //d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f);
414 419
415 //m_lastUpdateSent = false; 420 //m_lastUpdateSent = false;
416
417 } 421 }
418
419 } 422 }
423
420 public override void SetMomentum(PhysicsVector momentum) 424 public override void SetMomentum(PhysicsVector momentum)
421 { 425 {
422
423 } 426 }
424 427
425 public void Move(float timeStep) 428 public void Move(float timeStep)
@@ -442,7 +445,6 @@ namespace OpenSim.Region.Physics.OdePlugin
442 else 445 else
443 { 446 {
444 movementdivisor = 0.8f; 447 movementdivisor = 0.8f;
445
446 } 448 }
447 449
448 // if velocity is zero, use position control; otherwise, velocity control 450 // if velocity is zero, use position control; otherwise, velocity control
@@ -457,11 +459,11 @@ namespace OpenSim.Region.Physics.OdePlugin
457 if (m_pidControllerActive) 459 if (m_pidControllerActive)
458 { 460 {
459 d.Vector3 pos = d.BodyGetPosition(Body); 461 d.Vector3 pos = d.BodyGetPosition(Body);
460 vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P; 462 vec.X = (_target_velocity.X - vel.X)*PID_D + (_zeroPosition.X - pos.X)*PID_P;
461 vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P; 463 vec.Y = (_target_velocity.Y - vel.Y)*PID_D + (_zeroPosition.Y - pos.Y)*PID_P;
462 if (flying) 464 if (flying)
463 { 465 {
464 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100) + (_zeroPosition.Z - pos.Z) * PID_P; 466 vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100) + (_zeroPosition.Z - pos.Z)*PID_P;
465 } 467 }
466 } 468 }
467 //PidStatus = true; 469 //PidStatus = true;
@@ -472,21 +474,20 @@ namespace OpenSim.Region.Physics.OdePlugin
472 _zeroFlag = false; 474 _zeroFlag = false;
473 if (m_iscolliding || flying) 475 if (m_iscolliding || flying)
474 { 476 {
475 477 vec.X = ((_target_velocity.X/movementdivisor) - vel.X)*PID_D;
476 vec.X = ((_target_velocity.X / movementdivisor) - vel.X) * PID_D; 478 vec.Y = ((_target_velocity.Y/movementdivisor) - vel.Y)*PID_D;
477 vec.Y = ((_target_velocity.Y / movementdivisor) - vel.Y) * PID_D;
478 } 479 }
479 if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) 480 if (m_iscolliding && !flying && _target_velocity.Z > 0.0f)
480 { 481 {
481 d.Vector3 pos = d.BodyGetPosition(Body); 482 d.Vector3 pos = d.BodyGetPosition(Body);
482 vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; 483 vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P;
483 if (_target_velocity.X > 0) 484 if (_target_velocity.X > 0)
484 { 485 {
485 vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; 486 vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D;
486 } 487 }
487 if (_target_velocity.Y > 0) 488 if (_target_velocity.Y > 0)
488 { 489 {
489 vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; 490 vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D;
490 } 491 }
491 } 492 }
492 else if (!m_iscolliding && !flying) 493 else if (!m_iscolliding && !flying)
@@ -494,19 +495,18 @@ namespace OpenSim.Region.Physics.OdePlugin
494 d.Vector3 pos = d.BodyGetPosition(Body); 495 d.Vector3 pos = d.BodyGetPosition(Body);
495 if (_target_velocity.X > 0) 496 if (_target_velocity.X > 0)
496 { 497 {
497 vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; 498 vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D;
498 } 499 }
499 if (_target_velocity.Y > 0) 500 if (_target_velocity.Y > 0)
500 { 501 {
501 vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; 502 vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D;
502 } 503 }
503
504 } 504 }
505 505
506 506
507 if (flying) 507 if (flying)
508 { 508 {
509 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100); 509 vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100);
510 } 510 }
511 } 511 }
512 if (flying) 512 if (flying)
@@ -546,13 +546,12 @@ namespace OpenSim.Region.Physics.OdePlugin
546 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 546 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
547 //if (primScenAvatarIn == "0") 547 //if (primScenAvatarIn == "0")
548 //{ 548 //{
549 //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); 549 //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
550 //} 550 //}
551 //else 551 //else
552 //{ 552 //{
553 // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); 553 // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
554 //} 554 //}
555
556 } 555 }
557 } 556 }
558 else 557 else
@@ -586,12 +585,11 @@ namespace OpenSim.Region.Physics.OdePlugin
586 { 585 {
587 lock (OdeScene.OdeLock) 586 lock (OdeScene.OdeLock)
588 { 587 {
589 // d.JointDestroy(Amotor); 588 // d.JointDestroy(Amotor);
590 d.GeomDestroy(Shell); 589 d.GeomDestroy(Shell);
591 _parent_scene.geom_name_map.Remove(Shell); 590 _parent_scene.geom_name_map.Remove(Shell);
592 d.BodyDestroy(Body); 591 d.BodyDestroy(Body);
593 } 592 }
594 } 593 }
595 } 594 }
596 595} \ No newline at end of file
597}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 35328b8..5fef47d 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -27,16 +27,13 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using Axiom.Math; 30using Axiom.Math;
32using Ode.NET; 31using Ode.NET;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
36 34
37namespace OpenSim.Region.Physics.OdePlugin 35namespace OpenSim.Region.Physics.OdePlugin
38{ 36{
39
40 public class OdePrim : PhysicsActor 37 public class OdePrim : PhysicsActor
41 { 38 {
42 public PhysicsVector _position; 39 public PhysicsVector _position;
@@ -57,7 +54,7 @@ namespace OpenSim.Region.Physics.OdePlugin
57 private IMesh _mesh; 54 private IMesh _mesh;
58 private PrimitiveBaseShape _pbs; 55 private PrimitiveBaseShape _pbs;
59 private OdeScene _parent_scene; 56 private OdeScene _parent_scene;
60 public IntPtr m_targetSpace = (IntPtr)0; 57 public IntPtr m_targetSpace = (IntPtr) 0;
61 public IntPtr prim_geom; 58 public IntPtr prim_geom;
62 public IntPtr _triMeshData; 59 public IntPtr _triMeshData;
63 private bool iscolliding = false; 60 private bool iscolliding = false;
@@ -65,18 +62,17 @@ namespace OpenSim.Region.Physics.OdePlugin
65 private bool m_throttleUpdates = false; 62 private bool m_throttleUpdates = false;
66 private int throttleCounter = 0; 63 private int throttleCounter = 0;
67 public bool outofBounds = false; 64 public bool outofBounds = false;
68 private float m_density = 10.000006836f;// Aluminum g/cm3; 65 private float m_density = 10.000006836f; // Aluminum g/cm3;
69 66
70
71 67
72 public bool _zeroFlag = false; 68 public bool _zeroFlag = false;
73 private bool m_lastUpdateSent = false; 69 private bool m_lastUpdateSent = false;
74 70
75 public IntPtr Body = (IntPtr)0; 71 public IntPtr Body = (IntPtr) 0;
76 private String m_primName; 72 private String m_primName;
77 private PhysicsVector _target_velocity; 73 private PhysicsVector _target_velocity;
78 public d.Mass pMass; 74 public d.Mass pMass;
79 75
80 private int debugcounter = 0; 76 private int debugcounter = 0;
81 77
82 public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size, 78 public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size,
@@ -123,7 +119,6 @@ namespace OpenSim.Region.Physics.OdePlugin
123 // linksets *should* be in a space together.. but are not currently 119 // linksets *should* be in a space together.. but are not currently
124 if (m_isphysical) 120 if (m_isphysical)
125 m_targetSpace = _parent_scene.space; 121 m_targetSpace = _parent_scene.space;
126
127 } 122 }
128 m_primName = primName; 123 m_primName = primName;
129 124
@@ -147,25 +142,28 @@ namespace OpenSim.Region.Physics.OdePlugin
147 d.GeomSetQuaternion(prim_geom, ref myrot); 142 d.GeomSetQuaternion(prim_geom, ref myrot);
148 143
149 144
150 if (m_isphysical && Body == (IntPtr)0) 145 if (m_isphysical && Body == (IntPtr) 0)
151 { 146 {
152 enableBody(); 147 enableBody();
153 } 148 }
154 parent_scene.geom_name_map[prim_geom] = primName; 149 parent_scene.geom_name_map[prim_geom] = primName;
155 parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; 150 parent_scene.actor_name_map[prim_geom] = (PhysicsActor) this;
156 // don't do .add() here; old geoms get recycled with the same hash 151 // don't do .add() here; old geoms get recycled with the same hash
157 } 152 }
158 } 153 }
154
159 public override int PhysicsActorType 155 public override int PhysicsActorType
160 { 156 {
161 get { return (int)ActorTypes.Prim; } 157 get { return (int) ActorTypes.Prim; }
162 set { return; } 158 set { return; }
163 } 159 }
160
164 public override bool SetAlwaysRun 161 public override bool SetAlwaysRun
165 { 162 {
166 get { return false; } 163 get { return false; }
167 set { return; } 164 set { return; }
168 } 165 }
166
169 public void enableBody() 167 public void enableBody()
170 { 168 {
171 // Sets the geom to a body 169 // Sets the geom to a body
@@ -185,13 +183,14 @@ namespace OpenSim.Region.Physics.OdePlugin
185 183
186 _parent_scene.addActivePrim(this); 184 _parent_scene.addActivePrim(this);
187 } 185 }
186
188 private float CalculateMass() 187 private float CalculateMass()
189 { 188 {
190 float volume = 0; 189 float volume = 0;
191 190
192 // No material is passed to the physics engines yet.. soo.. 191 // No material is passed to the physics engines yet.. soo..
193 // we're using the m_density constant in the class definition 192 // we're using the m_density constant in the class definition
194 193
195 194
196 float returnMass = 0; 195 float returnMass = 0;
197 196
@@ -199,17 +198,17 @@ namespace OpenSim.Region.Physics.OdePlugin
199 { 198 {
200 case ProfileShape.Square: 199 case ProfileShape.Square:
201 // Profile Volume 200 // Profile Volume
202 201
203 volume = _size.X * _size.Y * _size.Z; 202 volume = _size.X*_size.Y*_size.Z;
204 203
205 // If the user has 'hollowed out' 204 // If the user has 'hollowed out'
206 // ProfileHollow is one of those 0 to 50000 values :P 205 // ProfileHollow is one of those 0 to 50000 values :P
207 // we like percentages better.. so turning into a percentage 206 // we like percentages better.. so turning into a percentage
208 207
209 if (((float)_pbs.ProfileHollow / 50000f) > 0.0) 208 if (((float) _pbs.ProfileHollow/50000f) > 0.0)
210 { 209 {
211 float hollowAmount = (float)_pbs.ProfileHollow / 50000f; 210 float hollowAmount = (float) _pbs.ProfileHollow/50000f;
212 211
213 // calculate the hollow volume by it's shape compared to the prim shape 212 // calculate the hollow volume by it's shape compared to the prim shape
214 float hollowVolume = 0; 213 float hollowVolume = 0;
215 switch (_pbs.HollowShape) 214 switch (_pbs.HollowShape)
@@ -217,29 +216,29 @@ namespace OpenSim.Region.Physics.OdePlugin
217 case HollowShape.Square: 216 case HollowShape.Square:
218 case HollowShape.Same: 217 case HollowShape.Same:
219 // Cube Hollow volume calculation 218 // Cube Hollow volume calculation
220 float hollowsizex = _size.X * hollowAmount; 219 float hollowsizex = _size.X*hollowAmount;
221 float hollowsizey = _size.Y * hollowAmount; 220 float hollowsizey = _size.Y*hollowAmount;
222 float hollowsizez = _size.Z * hollowAmount; 221 float hollowsizez = _size.Z*hollowAmount;
223 hollowVolume = hollowsizex * hollowsizey * hollowsizez; 222 hollowVolume = hollowsizex*hollowsizey*hollowsizez;
224 break; 223 break;
225 224
226 case HollowShape.Circle: 225 case HollowShape.Circle:
227 // Hollow shape is a perfect cyllinder in respect to the cube's scale 226 // Hollow shape is a perfect cyllinder in respect to the cube's scale
228 // Cyllinder hollow volume calculation 227 // Cyllinder hollow volume calculation
229 float hRadius = _size.X / 2; 228 float hRadius = _size.X/2;
230 float hLength = _size.Z; 229 float hLength = _size.Z;
231 230
232 // pi * r2 * h 231 // pi * r2 * h
233 hollowVolume = ((float)(Math.PI * Math.Pow(hRadius, 2) * hLength) * hollowAmount); 232 hollowVolume = ((float) (Math.PI*Math.Pow(hRadius, 2)*hLength)*hollowAmount);
234 break; 233 break;
235 234
236 case HollowShape.Triangle: 235 case HollowShape.Triangle:
237 // Equilateral Triangular Prism volume hollow calculation 236 // Equilateral Triangular Prism volume hollow calculation
238 // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y 237 // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
239 238
240 float aLength = _size.Y; 239 float aLength = _size.Y;
241 // 1/2 abh 240 // 1/2 abh
242 hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount); 241 hollowVolume = (float) ((0.5*aLength*_size.X*_size.Z)*hollowAmount);
243 break; 242 break;
244 243
245 default: 244 default:
@@ -247,15 +246,14 @@ namespace OpenSim.Region.Physics.OdePlugin
247 break; 246 break;
248 } 247 }
249 volume = volume - hollowVolume; 248 volume = volume - hollowVolume;
250
251 } 249 }
252 250
253 break; 251 break;
254 252
255 default: 253 default:
256 // we don't have all of the volume formulas yet so 254 // we don't have all of the volume formulas yet so
257 // use the common volume formula for all 255 // use the common volume formula for all
258 volume = _size.X * _size.Y * _size.Z; 256 volume = _size.X*_size.Y*_size.Z;
259 break; 257 break;
260 } 258 }
261 259
@@ -273,70 +271,70 @@ namespace OpenSim.Region.Physics.OdePlugin
273 float PathCutStartAmount = _pbs.ProfileBegin; 271 float PathCutStartAmount = _pbs.ProfileBegin;
274 if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f) 272 if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f)
275 { 273 {
274 float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount)/50000f);
276 275
277 float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount) / 50000f);
278
279 // Check the return amount for sanity 276 // Check the return amount for sanity
280 if (pathCutAmount >= 0.99f) 277 if (pathCutAmount >= 0.99f)
281 pathCutAmount=0.99f; 278 pathCutAmount = 0.99f;
282 279
283 volume = volume - (volume * pathCutAmount); 280 volume = volume - (volume*pathCutAmount);
284 } 281 }
285 282
286 // Mass = density * volume 283 // Mass = density * volume
287 284
288 returnMass = m_density * volume; 285 returnMass = m_density*volume;
289 286
290 return returnMass; 287 return returnMass;
291 } 288 }
292 289
293 public void setMass() 290 public void setMass()
294 { 291 {
295 if (Body != (IntPtr)0) 292 if (Body != (IntPtr) 0)
296 { 293 {
297 d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z); 294 d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z);
298 d.BodySetMass(Body, ref pMass); 295 d.BodySetMass(Body, ref pMass);
299 } 296 }
300 } 297 }
301 298
302
303 299
304 public void disableBody() 300 public void disableBody()
305 { 301 {
306 //this kills the body so things like 'mesh' can re-create it. 302 //this kills the body so things like 'mesh' can re-create it.
307 if (Body != (IntPtr)0) 303 if (Body != (IntPtr) 0)
308 { 304 {
309 _parent_scene.remActivePrim(this); 305 _parent_scene.remActivePrim(this);
310 d.BodyDestroy(Body); 306 d.BodyDestroy(Body);
311 Body = (IntPtr)0; 307 Body = (IntPtr) 0;
312 } 308 }
313 } 309 }
310
314 public void setMesh(OdeScene parent_scene, IMesh mesh) 311 public void setMesh(OdeScene parent_scene, IMesh mesh)
315 { 312 {
316 //Kill Body so that mesh can re-make the geom 313 //Kill Body so that mesh can re-make the geom
317 if (IsPhysical && Body != (IntPtr)0) 314 if (IsPhysical && Body != (IntPtr) 0)
318 { 315 {
319 disableBody(); 316 disableBody();
320 } 317 }
321 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory 318 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
322 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage 319 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
323 int VertexCount = vertexList.GetLength(0) / 3; 320 int VertexCount = vertexList.GetLength(0)/3;
324 int IndexCount = indexList.GetLength(0); 321 int IndexCount = indexList.GetLength(0);
325 322
326 _triMeshData = d.GeomTriMeshDataCreate(); 323 _triMeshData = d.GeomTriMeshDataCreate();
327 324
328 d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, 325 d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3*sizeof (float), VertexCount, indexList, IndexCount,
329 3 * sizeof(int)); 326 3*sizeof (int));
330 d.GeomTriMeshDataPreprocess(_triMeshData); 327 d.GeomTriMeshDataPreprocess(_triMeshData);
331 328
332 prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); 329 prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null);
333 330
334 if (IsPhysical && Body == (IntPtr)0) 331 if (IsPhysical && Body == (IntPtr) 0)
335 { 332 {
336 // Recreate the body 333 // Recreate the body
337 enableBody(); 334 enableBody();
338 } 335 }
339 } 336 }
337
340 public void ProcessTaints(float timestep) 338 public void ProcessTaints(float timestep)
341 { 339 {
342 if (m_taintposition != _position) 340 if (m_taintposition != _position)
@@ -357,14 +355,14 @@ namespace OpenSim.Region.Physics.OdePlugin
357 if (m_taintshape) 355 if (m_taintshape)
358 changeshape(timestep); 356 changeshape(timestep);
359 // 357 //
360
361 } 358 }
359
362 public void Move(float timestep) 360 public void Move(float timestep)
363 { 361 {
364 if (m_isphysical) 362 if (m_isphysical)
365 { 363 {
366 // This is a fallback.. May no longer be necessary. 364 // This is a fallback.. May no longer be necessary.
367 if (Body == (IntPtr)0) 365 if (Body == (IntPtr) 0)
368 enableBody(); 366 enableBody();
369 //Prim auto disable after 20 frames, 367 //Prim auto disable after 20 frames,
370 ///if you move it, re-enable the prim manually. 368 ///if you move it, re-enable the prim manually.
@@ -382,35 +380,35 @@ namespace OpenSim.Region.Physics.OdePlugin
382 380
383 m_taintposition = _position; 381 m_taintposition = _position;
384 } 382 }
383
385 public void rotate(float timestep) 384 public void rotate(float timestep)
386 { 385 {
387
388 d.Quaternion myrot = new d.Quaternion(); 386 d.Quaternion myrot = new d.Quaternion();
389 myrot.W = _orientation.w; 387 myrot.W = _orientation.w;
390 myrot.X = _orientation.x; 388 myrot.X = _orientation.x;
391 myrot.Y = _orientation.y; 389 myrot.Y = _orientation.y;
392 myrot.Z = _orientation.z; 390 myrot.Z = _orientation.z;
393 d.GeomSetQuaternion(prim_geom, ref myrot); 391 d.GeomSetQuaternion(prim_geom, ref myrot);
394 if (m_isphysical && Body != (IntPtr)0) 392 if (m_isphysical && Body != (IntPtr) 0)
395 { 393 {
396 d.BodySetQuaternion(Body, ref myrot); 394 d.BodySetQuaternion(Body, ref myrot);
397 } 395 }
398 396
399 m_taintrot = _orientation; 397 m_taintrot = _orientation;
400 } 398 }
399
401 public void changePhysicsStatus(float timestap) 400 public void changePhysicsStatus(float timestap)
402 { 401 {
403 if (m_isphysical == true) 402 if (m_isphysical == true)
404 { 403 {
405 if (Body == (IntPtr)0) 404 if (Body == (IntPtr) 0)
406 { 405 {
407 enableBody(); 406 enableBody();
408 } 407 }
409
410 } 408 }
411 else 409 else
412 { 410 {
413 if (Body != (IntPtr)0) 411 if (Body != (IntPtr) 0)
414 { 412 {
415 disableBody(); 413 disableBody();
416 } 414 }
@@ -419,6 +417,7 @@ namespace OpenSim.Region.Physics.OdePlugin
419 417
420 m_taintPhysics = m_isphysical; 418 m_taintPhysics = m_isphysical;
421 } 419 }
420
422 public void changesize(float timestamp) 421 public void changesize(float timestamp)
423 { 422 {
424 string oldname = _parent_scene.geom_name_map[prim_geom]; 423 string oldname = _parent_scene.geom_name_map[prim_geom];
@@ -429,7 +428,7 @@ namespace OpenSim.Region.Physics.OdePlugin
429 // Cleanup meshing here 428 // Cleanup meshing here
430 } 429 }
431 //kill body to rebuild 430 //kill body to rebuild
432 if (IsPhysical && Body != (IntPtr)0) 431 if (IsPhysical && Body != (IntPtr) 0)
433 { 432 {
434 disableBody(); 433 disableBody();
435 } 434 }
@@ -442,10 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin
442 // we don't need to do space calculation because the client sends a position update also. 441 // we don't need to do space calculation because the client sends a position update also.
443 442
444 // Construction of new prim 443 // Construction of new prim
445 if (this._parent_scene.needsMeshing(_pbs)) 444 if (_parent_scene.needsMeshing(_pbs))
446 { 445 {
447
448
449 // Don't need to re-enable body.. it's done in SetMesh 446 // Don't need to re-enable body.. it's done in SetMesh
450 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); 447 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
451 // createmesh returns null when it's a shape that isn't a cube. 448 // createmesh returns null when it's a shape that isn't a cube.
@@ -463,8 +460,6 @@ namespace OpenSim.Region.Physics.OdePlugin
463 myrot.Y = _orientation.y; 460 myrot.Y = _orientation.y;
464 myrot.Z = _orientation.z; 461 myrot.Z = _orientation.z;
465 d.GeomSetQuaternion(prim_geom, ref myrot); 462 d.GeomSetQuaternion(prim_geom, ref myrot);
466
467
468 } 463 }
469 } 464 }
470 else 465 else
@@ -480,7 +475,7 @@ namespace OpenSim.Region.Physics.OdePlugin
480 475
481 476
482 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); 477 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
483 if (IsPhysical && Body == (IntPtr)0) 478 if (IsPhysical && Body == (IntPtr) 0)
484 { 479 {
485 // Re creates body on size. 480 // Re creates body on size.
486 // EnableBody also does setMass() 481 // EnableBody also does setMass()
@@ -493,12 +488,13 @@ namespace OpenSim.Region.Physics.OdePlugin
493 488
494 m_taintsize = _size; 489 m_taintsize = _size;
495 } 490 }
491
496 public void changeshape(float timestamp) 492 public void changeshape(float timestamp)
497 { 493 {
498 string oldname = _parent_scene.geom_name_map[prim_geom]; 494 string oldname = _parent_scene.geom_name_map[prim_geom];
499 495
500 // Cleanup of old prim geometry and Bodies 496 // Cleanup of old prim geometry and Bodies
501 if (IsPhysical && Body != (IntPtr)0) 497 if (IsPhysical && Body != (IntPtr) 0)
502 { 498 {
503 disableBody(); 499 disableBody();
504 } 500 }
@@ -509,7 +505,7 @@ namespace OpenSim.Region.Physics.OdePlugin
509 } 505 }
510 506
511 // Construction of new prim 507 // Construction of new prim
512 if (this._parent_scene.needsMeshing(_pbs)) 508 if (_parent_scene.needsMeshing(_pbs))
513 { 509 {
514 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); 510 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
515 if (mesh != null) 511 if (mesh != null)
@@ -525,7 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin
525 { 521 {
526 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); 522 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
527 } 523 }
528 if (IsPhysical && Body == (IntPtr)0) 524 if (IsPhysical && Body == (IntPtr) 0)
529 { 525 {
530 //re-create new body 526 //re-create new body
531 enableBody(); 527 enableBody();
@@ -544,11 +540,13 @@ namespace OpenSim.Region.Physics.OdePlugin
544 540
545 m_taintshape = false; 541 m_taintshape = false;
546 } 542 }
543
547 public override bool IsPhysical 544 public override bool IsPhysical
548 { 545 {
549 get { return m_isphysical; } 546 get { return m_isphysical; }
550 set { m_isphysical = value; } 547 set { m_isphysical = value; }
551 } 548 }
549
552 public void setPrimForRemoval() 550 public void setPrimForRemoval()
553 { 551 {
554 m_taintremove = true; 552 m_taintremove = true;
@@ -556,9 +554,7 @@ namespace OpenSim.Region.Physics.OdePlugin
556 554
557 public override bool Flying 555 public override bool Flying
558 { 556 {
559 get 557 get { return false; //no flying prims for you
560 {
561 return false; //no flying prims for you
562 } 558 }
563 set { } 559 set { }
564 } 560 }
@@ -568,16 +564,19 @@ namespace OpenSim.Region.Physics.OdePlugin
568 get { return iscolliding; } 564 get { return iscolliding; }
569 set { iscolliding = value; } 565 set { iscolliding = value; }
570 } 566 }
567
571 public override bool CollidingGround 568 public override bool CollidingGround
572 { 569 {
573 get { return false; } 570 get { return false; }
574 set { return; } 571 set { return; }
575 } 572 }
573
576 public override bool CollidingObj 574 public override bool CollidingObj
577 { 575 {
578 get { return false; } 576 get { return false; }
579 set { return; } 577 set { return; }
580 } 578 }
579
581 public override bool ThrottleUpdates 580 public override bool ThrottleUpdates
582 { 581 {
583 get { return m_throttleUpdates; } 582 get { return m_throttleUpdates; }
@@ -588,20 +587,13 @@ namespace OpenSim.Region.Physics.OdePlugin
588 { 587 {
589 get { return _position; } 588 get { return _position; }
590 589
591 set 590 set { _position = value; }
592 {
593 _position = value;
594
595 }
596 } 591 }
597 592
598 public override PhysicsVector Size 593 public override PhysicsVector Size
599 { 594 {
600 get { return _size; } 595 get { return _size; }
601 set 596 set { _size = value; }
602 {
603 _size = value;
604 }
605 } 597 }
606 598
607 public override float Mass 599 public override float Mass
@@ -626,10 +618,7 @@ namespace OpenSim.Region.Physics.OdePlugin
626 618
627 public override PrimitiveBaseShape Shape 619 public override PrimitiveBaseShape Shape
628 { 620 {
629 set 621 set { _pbs = value; }
630 {
631 _pbs = value;
632 }
633 } 622 }
634 623
635 public override PhysicsVector Velocity 624 public override PhysicsVector Velocity
@@ -639,9 +628,9 @@ namespace OpenSim.Region.Physics.OdePlugin
639 // Averate previous velocity with the new one so 628 // Averate previous velocity with the new one so
640 // client object interpolation works a 'little' better 629 // client object interpolation works a 'little' better
641 PhysicsVector returnVelocity = new PhysicsVector(); 630 PhysicsVector returnVelocity = new PhysicsVector();
642 returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; 631 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
643 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; 632 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2;
644 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; 633 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2;
645 return returnVelocity; 634 return returnVelocity;
646 } 635 }
647 set { _velocity = value; } 636 set { _velocity = value; }
@@ -656,11 +645,7 @@ namespace OpenSim.Region.Physics.OdePlugin
656 public override Quaternion Orientation 645 public override Quaternion Orientation
657 { 646 {
658 get { return _orientation; } 647 get { return _orientation; }
659 set 648 set { _orientation = value; }
660 {
661 _orientation = value;
662
663 }
664 } 649 }
665 650
666 public override PhysicsVector Acceleration 651 public override PhysicsVector Acceleration
@@ -688,7 +673,7 @@ namespace OpenSim.Region.Physics.OdePlugin
688 { 673 {
689 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 674 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
690 675
691 if (Body != (IntPtr)0) 676 if (Body != (IntPtr) 0)
692 { 677 {
693 d.Vector3 vec = d.BodyGetPosition(Body); 678 d.Vector3 vec = d.BodyGetPosition(Body);
694 d.Quaternion ori = d.BodyGetQuaternion(Body); 679 d.Quaternion ori = d.BodyGetQuaternion(Body);
@@ -715,8 +700,6 @@ namespace OpenSim.Region.Physics.OdePlugin
715 // It's a hack and will generate a console message if it fails. 700 // It's a hack and will generate a console message if it fails.
716 701
717 702
718
719
720 //IsPhysical = false; 703 //IsPhysical = false;
721 base.RaiseOutOfBounds(_position); 704 base.RaiseOutOfBounds(_position);
722 _velocity.X = 0; 705 _velocity.X = 0;
@@ -736,7 +719,6 @@ namespace OpenSim.Region.Physics.OdePlugin
736 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) 719 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
737 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)) 720 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02))
738 { 721 {
739
740 _zeroFlag = true; 722 _zeroFlag = true;
741 } 723 }
742 else 724 else
@@ -746,7 +728,6 @@ namespace OpenSim.Region.Physics.OdePlugin
746 } 728 }
747 729
748 730
749
750 if (_zeroFlag) 731 if (_zeroFlag)
751 { 732 {
752 // Supposedly this is supposed to tell SceneObjectGroup that 733 // Supposedly this is supposed to tell SceneObjectGroup that
@@ -811,10 +792,10 @@ namespace OpenSim.Region.Physics.OdePlugin
811 m_rotationalVelocity.Z = 0; 792 m_rotationalVelocity.Z = 0;
812 _zeroFlag = true; 793 _zeroFlag = true;
813 } 794 }
814
815 } 795 }
796
816 public override void SetMomentum(PhysicsVector momentum) 797 public override void SetMomentum(PhysicsVector momentum)
817 { 798 {
818 } 799 }
819 } 800 }
820} 801} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 8bb822e..f2c9b57 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -28,6 +28,7 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Runtime.InteropServices;
31using Axiom.Math; 32using Axiom.Math;
32using Ode.NET; 33using Ode.NET;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -99,17 +100,17 @@ namespace OpenSim.Region.Physics.OdePlugin
99 private d.Contact TerrainContact; 100 private d.Contact TerrainContact;
100 private d.Contact AvatarMovementprimContact; 101 private d.Contact AvatarMovementprimContact;
101 private d.Contact AvatarMovementTerrainContact; 102 private d.Contact AvatarMovementTerrainContact;
102 103
103 private int m_physicsiterations = 10; 104 private int m_physicsiterations = 10;
104 private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag 105 private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
105 private PhysicsActor PANull = new NullPhysicsActor(); 106 private PhysicsActor PANull = new NullPhysicsActor();
106 private float step_time = 0.0f; 107 private float step_time = 0.0f;
107 public IntPtr world; 108 public IntPtr world;
108 109
109 public IntPtr space; 110 public IntPtr space;
110 // split static geometry collision handling into spaces of 30 meters 111 // split static geometry collision handling into spaces of 30 meters
111 public IntPtr[,] staticPrimspace = new IntPtr[(int)(300/metersInSpace),(int)(300/metersInSpace)]; 112 public IntPtr[,] staticPrimspace = new IntPtr[(int) (300/metersInSpace),(int) (300/metersInSpace)];
112 113
113 public static Object OdeLock = new Object(); 114 public static Object OdeLock = new Object();
114 115
115 public IMesher mesher; 116 public IMesher mesher;
@@ -126,7 +127,7 @@ namespace OpenSim.Region.Physics.OdePlugin
126 contact.surface.soft_erp = 0.005f; 127 contact.surface.soft_erp = 0.005f;
127 contact.surface.soft_cfm = 0.00003f; 128 contact.surface.soft_cfm = 0.00003f;
128 */ 129 */
129 130
130 contact.surface.mu = 250.0f; 131 contact.surface.mu = 250.0f;
131 contact.surface.bounce = 0.2f; 132 contact.surface.bounce = 0.2f;
132 133
@@ -151,7 +152,7 @@ namespace OpenSim.Region.Physics.OdePlugin
151 contactgroup = d.JointGroupCreate(0); 152 contactgroup = d.JointGroupCreate(0);
152 //contactgroup 153 //contactgroup
153 154
154 155
155 d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); 156 d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f);
156 d.WorldSetAutoDisableFlag(world, false); 157 d.WorldSetAutoDisableFlag(world, false);
157 d.WorldSetContactSurfaceLayer(world, 0.001f); 158 d.WorldSetContactSurfaceLayer(world, 0.001f);
@@ -165,10 +166,9 @@ namespace OpenSim.Region.Physics.OdePlugin
165 { 166 {
166 for (int j = 0; j < staticPrimspace.GetLength(1); j++) 167 for (int j = 0; j < staticPrimspace.GetLength(1); j++)
167 { 168 {
168 staticPrimspace[i,j] = IntPtr.Zero; 169 staticPrimspace[i, j] = IntPtr.Zero;
169 } 170 }
170 } 171 }
171
172 } 172 }
173 173
174 public override void Initialise(IMesher meshmerizer) 174 public override void Initialise(IMesher meshmerizer)
@@ -184,25 +184,25 @@ namespace OpenSim.Region.Physics.OdePlugin
184 private void near(IntPtr space, IntPtr g1, IntPtr g2) 184 private void near(IntPtr space, IntPtr g1, IntPtr g2)
185 { 185 {
186 // no lock here! It's invoked from within Simulate(), which is thread-locked 186 // no lock here! It's invoked from within Simulate(), which is thread-locked
187 if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2) ) 187 if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
188 { 188 {
189 // Separating static prim geometry spaces. 189 // Separating static prim geometry spaces.
190 // We'll be calling near recursivly if one 190 // We'll be calling near recursivly if one
191 // of them is a space to find all of the 191 // of them is a space to find all of the
192 // contact points in the space 192 // contact points in the space
193 193
194 d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); 194 d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
195 //Colliding a space or a geom with a space or a geom. 195 //Colliding a space or a geom with a space or a geom.
196 196
197 //Collide all geoms in each space.. 197 //Collide all geoms in each space..
198 //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); 198 //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback);
199 //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); 199 //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback);
200 } 200 }
201 else 201 else
202 { 202 {
203 // Colliding Geom To Geom 203 // Colliding Geom To Geom
204 // This portion of the function 'was' blatantly ripped off from BoxStack.cs 204 // This portion of the function 'was' blatantly ripped off from BoxStack.cs
205 205
206 IntPtr b1 = d.GeomGetBody(g1); 206 IntPtr b1 = d.GeomGetBody(g1);
207 IntPtr b2 = d.GeomGetBody(g2); 207 IntPtr b2 = d.GeomGetBody(g2);
208 208
@@ -213,7 +213,7 @@ namespace OpenSim.Region.Physics.OdePlugin
213 return; 213 return;
214 214
215 d.GeomClassID id = d.GeomGetClass(g1); 215 d.GeomClassID id = d.GeomGetClass(g1);
216 216
217 String name1 = null; 217 String name1 = null;
218 String name2 = null; 218 String name2 = null;
219 219
@@ -228,21 +228,22 @@ namespace OpenSim.Region.Physics.OdePlugin
228 228
229 if (id == d.GeomClassID.TriMeshClass) 229 if (id == d.GeomClassID.TriMeshClass)
230 { 230 {
231 // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); 231 // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2);
232 //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); 232 //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2);
233 } 233 }
234 234
235 int count = 0; 235 int count = 0;
236 try 236 try
237 { 237 {
238 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); 238 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
239 } 239 }
240 catch (System.Runtime.InteropServices.SEHException) 240 catch (SEHException)
241 { 241 {
242 MainLog.Instance.Error("PHYSICS", "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); 242 MainLog.Instance.Error("PHYSICS",
243 "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
243 base.TriggerPhysicsBasedRestart(); 244 base.TriggerPhysicsBasedRestart();
244 } 245 }
245 246
246 for (int i = 0; i < count; i++) 247 for (int i = 0; i < count; i++)
247 { 248 {
248 IntPtr joint; 249 IntPtr joint;
@@ -263,17 +264,17 @@ namespace OpenSim.Region.Physics.OdePlugin
263 // We only need to test p2 for 'jump crouch purposes' 264 // We only need to test p2 for 'jump crouch purposes'
264 p2.IsColliding = true; 265 p2.IsColliding = true;
265 266
266
267 267
268 switch(p1.PhysicsActorType) { 268 switch (p1.PhysicsActorType)
269 case (int)ActorTypes.Agent: 269 {
270 case (int) ActorTypes.Agent:
270 p2.CollidingObj = true; 271 p2.CollidingObj = true;
271 break; 272 break;
272 case (int)ActorTypes.Prim: 273 case (int) ActorTypes.Prim:
273 if (p2.Velocity.X >0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) 274 if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0)
274 p2.CollidingObj = true; 275 p2.CollidingObj = true;
275 break; 276 break;
276 case (int)ActorTypes.Unknown: 277 case (int) ActorTypes.Unknown:
277 p2.CollidingGround = true; 278 p2.CollidingGround = true;
278 break; 279 break;
279 default: 280 default:
@@ -282,7 +283,9 @@ namespace OpenSim.Region.Physics.OdePlugin
282 } 283 }
283 284
284 // we don't want prim or avatar to explode 285 // we don't want prim or avatar to explode
286
285 #region InterPenetration Handling - Unintended physics explosions 287 #region InterPenetration Handling - Unintended physics explosions
288
286 if (contacts[i].depth >= 0.08f) 289 if (contacts[i].depth >= 0.08f)
287 { 290 {
288 if (contacts[i].depth >= 1.00f) 291 if (contacts[i].depth >= 1.00f)
@@ -290,30 +293,31 @@ namespace OpenSim.Region.Physics.OdePlugin
290 //MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString()); 293 //MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString());
291 } 294 }
292 // If you interpenetrate a prim with an agent 295 // If you interpenetrate a prim with an agent
293 if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Prim) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Prim)) 296 if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
297 p1.PhysicsActorType == (int) ActorTypes.Prim) ||
298 (p1.PhysicsActorType == (int) ActorTypes.Agent &&
299 p2.PhysicsActorType == (int) ActorTypes.Prim))
294 { 300 {
295 301 if (p2.PhysicsActorType == (int) ActorTypes.Agent)
296 if (p2.PhysicsActorType == (int)ActorTypes.Agent)
297 { 302 {
298 p2.CollidingObj = true; 303 p2.CollidingObj = true;
299 //contacts[i].depth = 0.003f; 304 //contacts[i].depth = 0.003f;
300 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); 305 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
301 OdeCharacter character = (OdeCharacter)p2; 306 OdeCharacter character = (OdeCharacter) p2;
302 character.SetPidStatus(true); 307 character.SetPidStatus(true);
303 //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); 308 //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2));
304
305 } 309 }
306 else 310 else
307 { 311 {
308 contacts[i].depth = 0.0000000f; 312 contacts[i].depth = 0.0000000f;
309 } 313 }
310 if (p1.PhysicsActorType == (int)ActorTypes.Agent) 314 if (p1.PhysicsActorType == (int) ActorTypes.Agent)
311 { 315 {
312 p1.CollidingObj = true; 316 p1.CollidingObj = true;
313 //contacts[i].depth = 0.003f; 317 //contacts[i].depth = 0.003f;
314 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); 318 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);
315 //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2)); 319 //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2));
316 OdeCharacter character = (OdeCharacter)p2; 320 OdeCharacter character = (OdeCharacter) p2;
317 character.SetPidStatus(true); 321 character.SetPidStatus(true);
318 } 322 }
319 else 323 else
@@ -322,39 +326,45 @@ namespace OpenSim.Region.Physics.OdePlugin
322 } 326 }
323 } 327 }
324 // If you interpenetrate a prim with another prim 328 // If you interpenetrate a prim with another prim
325 if (p1.PhysicsActorType == (int)ActorTypes.Prim && p2.PhysicsActorType == (int)ActorTypes.Prim) 329 if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim)
326 { 330 {
327 // Don't collide, one or both prim will explode. 331 // Don't collide, one or both prim will explode.
328 contacts[i].depth = -1f; 332 contacts[i].depth = -1f;
329 } 333 }
330 if (contacts[i].depth >= 1.00f) 334 if (contacts[i].depth >= 1.00f)
331 { 335 {
332 if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Unknown) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Unknown)) 336 if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
337 p1.PhysicsActorType == (int) ActorTypes.Unknown) ||
338 (p1.PhysicsActorType == (int) ActorTypes.Agent &&
339 p2.PhysicsActorType == (int) ActorTypes.Unknown))
333 { 340 {
334 341 if (p2.PhysicsActorType == (int) ActorTypes.Agent)
335 if (p2.PhysicsActorType == (int)ActorTypes.Agent)
336 { 342 {
337 OdeCharacter character = (OdeCharacter)p2; 343 OdeCharacter character = (OdeCharacter) p2;
338 344
339 //p2.CollidingObj = true; 345 //p2.CollidingObj = true;
340 contacts[i].depth = 0.003f; 346 contacts[i].depth = 0.003f;
341 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); 347 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f);
342 contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); 348 contacts[i].pos =
349 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
350 contacts[i].pos.Y + (p1.Size.Y/2),
351 contacts[i].pos.Z + (p1.Size.Z/2));
343 character.SetPidStatus(true); 352 character.SetPidStatus(true);
344
345 } 353 }
346 else 354 else
347 { 355 {
348
349 } 356 }
350 if (p1.PhysicsActorType == (int)ActorTypes.Agent) 357 if (p1.PhysicsActorType == (int) ActorTypes.Agent)
351 { 358 {
352 OdeCharacter character = (OdeCharacter)p2; 359 OdeCharacter character = (OdeCharacter) p2;
353 360
354 //p2.CollidingObj = true; 361 //p2.CollidingObj = true;
355 contacts[i].depth = 0.003f; 362 contacts[i].depth = 0.003f;
356 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); 363 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f);
357 contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); 364 contacts[i].pos =
365 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
366 contacts[i].pos.Y + (p1.Size.Y/2),
367 contacts[i].pos.Z + (p1.Size.Z/2));
358 character.SetPidStatus(true); 368 character.SetPidStatus(true);
359 } 369 }
360 else 370 else
@@ -364,18 +374,18 @@ namespace OpenSim.Region.Physics.OdePlugin
364 } 374 }
365 } 375 }
366 } 376 }
377
367 #endregion 378 #endregion
368 379
369 if (contacts[i].depth >= 0f) 380 if (contacts[i].depth >= 0f)
370 { 381 {
371 if (name1 == "Terrain" || name2 == "Terrain") 382 if (name1 == "Terrain" || name2 == "Terrain")
372 { 383 {
373 384 if ((p2.PhysicsActorType == (int) ActorTypes.Agent) &&
374 if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) 385 (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
375 { 386 {
376 AvatarMovementTerrainContact.geom = contacts[i]; 387 AvatarMovementTerrainContact.geom = contacts[i];
377 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); 388 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
378
379 } 389 }
380 else 390 else
381 { 391 {
@@ -385,11 +395,11 @@ namespace OpenSim.Region.Physics.OdePlugin
385 } 395 }
386 else 396 else
387 { 397 {
388 if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) 398 if ((p2.PhysicsActorType == (int) ActorTypes.Agent) &&
399 (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
389 { 400 {
390 AvatarMovementprimContact.geom = contacts[i]; 401 AvatarMovementprimContact.geom = contacts[i];
391 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); 402 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
392
393 } 403 }
394 else 404 else
395 { 405 {
@@ -399,7 +409,7 @@ namespace OpenSim.Region.Physics.OdePlugin
399 } 409 }
400 d.JointAttach(joint, b1, b2); 410 d.JointAttach(joint, b1, b2);
401 } 411 }
402 412
403 if (count > 3) 413 if (count > 3)
404 { 414 {
405 p2.ThrottleUpdates = true; 415 p2.ThrottleUpdates = true;
@@ -421,7 +431,7 @@ namespace OpenSim.Region.Physics.OdePlugin
421 } 431 }
422 // If the sim is running slow this frame, 432 // If the sim is running slow this frame,
423 // don't process collision for prim! 433 // don't process collision for prim!
424 if (timeStep < (m_SkipFramesAtms / 3)) 434 if (timeStep < (m_SkipFramesAtms/3))
425 { 435 {
426 foreach (OdePrim chr in _activeprims) 436 foreach (OdePrim chr in _activeprims)
427 { 437 {
@@ -432,16 +442,16 @@ namespace OpenSim.Region.Physics.OdePlugin
432 //foreach (OdePrim ch2 in _prims) 442 //foreach (OdePrim ch2 in _prims)
433 /// should be a separate space -- lots of avatars will be N**2 slow 443 /// should be a separate space -- lots of avatars will be N**2 slow
434 //{ 444 //{
435 //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body)) 445 //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body))
436 //{ 446 //{
437 // Only test prim that are 0.03 meters away in one direction. 447 // Only test prim that are 0.03 meters away in one direction.
438 // This should be Optimized! 448 // This should be Optimized!
439 449
440 //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)) 450 //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))
441 //{ 451 //{
442 //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback); 452 //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback);
443 //} 453 //}
444 //} 454 //}
445 //} 455 //}
446 } 456 }
447 } 457 }
@@ -456,7 +466,6 @@ namespace OpenSim.Region.Physics.OdePlugin
456 if (d.BodyIsEnabled(chr.Body)) 466 if (d.BodyIsEnabled(chr.Body))
457 { 467 {
458 d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback); 468 d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback);
459
460 } 469 }
461 } 470 }
462 } 471 }
@@ -492,7 +501,6 @@ namespace OpenSim.Region.Physics.OdePlugin
492 501
493 p.setPrimForRemoval(); 502 p.setPrimForRemoval();
494 AddPhysicsActorTaint(prim); 503 AddPhysicsActorTaint(prim);
495
496 } 504 }
497 } 505 }
498 } 506 }
@@ -519,13 +527,14 @@ namespace OpenSim.Region.Physics.OdePlugin
519 } 527 }
520 else 528 else
521 { 529 {
522 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString()); 530 MainLog.Instance.Verbose("Physics",
531 "Invalid Scene passed to 'removeprim from scene':" +
532 ((OdePrim) prim).m_targetSpace.ToString());
523 } 533 }
524 } 534 }
525 } 535 }
526 536
527 537
528
529 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 538 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
530 if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) 539 if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
531 { 540 {
@@ -541,17 +550,18 @@ namespace OpenSim.Region.Physics.OdePlugin
541 } 550 }
542 else 551 else
543 { 552 {
544 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString()); 553 MainLog.Instance.Verbose("Physics",
554 "Invalid Scene passed to 'removeprim from scene':" +
555 ((OdePrim) prim).m_targetSpace.ToString());
545 } 556 }
546 } 557 }
547 } 558 }
548 } 559 }
549 560
550 d.GeomDestroy(prim.prim_geom); 561 d.GeomDestroy(prim.prim_geom);
551 562
552 _prims.Remove(prim); 563 _prims.Remove(prim);
553 } 564 }
554
555 } 565 }
556 566
557 public void resetSpaceArrayItemToZero(IntPtr space) 567 public void resetSpaceArrayItemToZero(IntPtr space)
@@ -566,7 +576,7 @@ namespace OpenSim.Region.Physics.OdePlugin
566 } 576 }
567 } 577 }
568 578
569 public void resetSpaceArrayItemToZero(int arrayitemX,int arrayitemY) 579 public void resetSpaceArrayItemToZero(int arrayitemX, int arrayitemY)
570 { 580 {
571 staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero; 581 staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero;
572 } 582 }
@@ -582,16 +592,17 @@ namespace OpenSim.Region.Physics.OdePlugin
582 // never be called if the prim is physical(active) 592 // never be called if the prim is physical(active)
583 if (currentspace != space) 593 if (currentspace != space)
584 { 594 {
585 if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr)0) 595 if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr) 0)
586 { 596 {
587 if (d.GeomIsSpace(currentspace)) 597 if (d.GeomIsSpace(currentspace))
588 { 598 {
589
590 d.SpaceRemove(currentspace, geom); 599 d.SpaceRemove(currentspace, geom);
591 } 600 }
592 else 601 else
593 { 602 {
594 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); 603 MainLog.Instance.Verbose("Physics",
604 "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() +
605 " Geom:" + geom.ToString());
595 } 606 }
596 } 607 }
597 else 608 else
@@ -599,7 +610,7 @@ namespace OpenSim.Region.Physics.OdePlugin
599 IntPtr sGeomIsIn = d.GeomGetSpace(geom); 610 IntPtr sGeomIsIn = d.GeomGetSpace(geom);
600 if (!(sGeomIsIn.Equals(null))) 611 if (!(sGeomIsIn.Equals(null)))
601 { 612 {
602 if (sGeomIsIn != (IntPtr)0) 613 if (sGeomIsIn != (IntPtr) 0)
603 { 614 {
604 if (d.GeomIsSpace(currentspace)) 615 if (d.GeomIsSpace(currentspace))
605 { 616 {
@@ -607,7 +618,9 @@ namespace OpenSim.Region.Physics.OdePlugin
607 } 618 }
608 else 619 else
609 { 620 {
610 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); 621 MainLog.Instance.Verbose("Physics",
622 "Invalid Scene passed to 'recalculatespace':" +
623 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
611 } 624 }
612 } 625 }
613 } 626 }
@@ -617,7 +630,7 @@ namespace OpenSim.Region.Physics.OdePlugin
617 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 630 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
618 if (d.SpaceGetNumGeoms(currentspace) == 0) 631 if (d.SpaceGetNumGeoms(currentspace) == 0)
619 { 632 {
620 if (currentspace != (IntPtr)0) 633 if (currentspace != (IntPtr) 0)
621 { 634 {
622 if (d.GeomIsSpace(currentspace)) 635 if (d.GeomIsSpace(currentspace))
623 { 636 {
@@ -628,9 +641,10 @@ namespace OpenSim.Region.Physics.OdePlugin
628 } 641 }
629 else 642 else
630 { 643 {
631 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); 644 MainLog.Instance.Verbose("Physics",
645 "Invalid Scene passed to 'recalculatespace':" +
646 currentspace.ToString() + " Geom:" + geom.ToString());
632 } 647 }
633
634 } 648 }
635 } 649 }
636 } 650 }
@@ -639,15 +653,16 @@ namespace OpenSim.Region.Physics.OdePlugin
639 // this is a physical object that got disabled. ;.; 653 // this is a physical object that got disabled. ;.;
640 if (d.SpaceQuery(currentspace, geom)) 654 if (d.SpaceQuery(currentspace, geom))
641 { 655 {
642 if (currentspace != (IntPtr)0) 656 if (currentspace != (IntPtr) 0)
643 if (d.GeomIsSpace(currentspace)) 657 if (d.GeomIsSpace(currentspace))
644 { 658 {
645 d.SpaceRemove(currentspace, geom); 659 d.SpaceRemove(currentspace, geom);
646 } 660 }
647 else 661 else
648 { 662 {
649 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); 663 MainLog.Instance.Verbose("Physics",
650 664 "Invalid Scene passed to 'recalculatespace':" +
665 currentspace.ToString() + " Geom:" + geom.ToString());
651 } 666 }
652 } 667 }
653 else 668 else
@@ -655,7 +670,7 @@ namespace OpenSim.Region.Physics.OdePlugin
655 IntPtr sGeomIsIn = d.GeomGetSpace(geom); 670 IntPtr sGeomIsIn = d.GeomGetSpace(geom);
656 if (!(sGeomIsIn.Equals(null))) 671 if (!(sGeomIsIn.Equals(null)))
657 { 672 {
658 if (sGeomIsIn != (IntPtr)0) 673 if (sGeomIsIn != (IntPtr) 0)
659 { 674 {
660 if (d.GeomIsSpace(sGeomIsIn)) 675 if (d.GeomIsSpace(sGeomIsIn))
661 { 676 {
@@ -663,14 +678,16 @@ namespace OpenSim.Region.Physics.OdePlugin
663 } 678 }
664 else 679 else
665 { 680 {
666 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); 681 MainLog.Instance.Verbose("Physics",
682 "Invalid Scene passed to 'recalculatespace':" +
683 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
667 } 684 }
668 } 685 }
669 } 686 }
670 } 687 }
671 } 688 }
672 689
673 690
674 // The routines in the Position and Size sections do the 'inserting' into the space, 691 // The routines in the Position and Size sections do the 'inserting' into the space,
675 // so all we have to do is make sure that the space that we're putting the prim into 692 // so all we have to do is make sure that the space that we're putting the prim into
676 // is in the 'main' space. 693 // is in the 'main' space.
@@ -679,17 +696,18 @@ namespace OpenSim.Region.Physics.OdePlugin
679 696
680 if (newspace == IntPtr.Zero) 697 if (newspace == IntPtr.Zero)
681 { 698 {
682 newspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]); 699 newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]);
683 d.HashSpaceSetLevels(newspace, -4, 66); 700 d.HashSpaceSetLevels(newspace, -4, 66);
684 } 701 }
685 702
686 return newspace; 703 return newspace;
687 } 704 }
688 705
689 public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) { 706 public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY)
707 {
690 // creating a new space for prim and inserting it into main space. 708 // creating a new space for prim and inserting it into main space.
691 staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); 709 staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
692 d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX,iprimspaceArrItemY]); 710 d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]);
693 return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; 711 return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
694 } 712 }
695 713
@@ -697,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin
697 { 715 {
698 int[] xyspace = calculateSpaceArrayItemFromPos(pos); 716 int[] xyspace = calculateSpaceArrayItemFromPos(pos);
699 //MainLog.Instance.Verbose("Physics", "Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); 717 //MainLog.Instance.Verbose("Physics", "Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
700 IntPtr locationbasedspace = staticPrimspace[xyspace[0],xyspace[1]]; 718 IntPtr locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]];
701 719
702 //locationbasedspace = space; 720 //locationbasedspace = space;
703 return locationbasedspace; 721 return locationbasedspace;
@@ -706,17 +724,17 @@ namespace OpenSim.Region.Physics.OdePlugin
706 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) 724 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos)
707 { 725 {
708 int[] returnint = new int[2]; 726 int[] returnint = new int[2];
709 727
710 returnint[0] = (int)(pos.X / metersInSpace); 728 returnint[0] = (int) (pos.X/metersInSpace);
711 729
712 if (returnint[0] > ((int)(259f / metersInSpace))) 730 if (returnint[0] > ((int) (259f/metersInSpace)))
713 returnint[0] = ((int)(259f / metersInSpace)); 731 returnint[0] = ((int) (259f/metersInSpace));
714 if (returnint[0] < 0) 732 if (returnint[0] < 0)
715 returnint[0] = 0; 733 returnint[0] = 0;
716 734
717 returnint[1] = (int)(pos.Y / metersInSpace); 735 returnint[1] = (int) (pos.Y/metersInSpace);
718 if (returnint[0] > ((int)(259f / metersInSpace))) 736 if (returnint[0] > ((int) (259f/metersInSpace)))
719 returnint[0] = ((int)(259f / metersInSpace)); 737 returnint[0] = ((int) (259f/metersInSpace));
720 if (returnint[0] < 0) 738 if (returnint[0] < 0)
721 returnint[0] = 0; 739 returnint[0] = 0;
722 740
@@ -726,7 +744,6 @@ namespace OpenSim.Region.Physics.OdePlugin
726 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 744 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,
727 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 745 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
728 { 746 {
729
730 PhysicsVector pos = new PhysicsVector(); 747 PhysicsVector pos = new PhysicsVector();
731 pos.X = position.X; 748 pos.X = position.X;
732 pos.Y = position.Y; 749 pos.Y = position.Y;
@@ -741,21 +758,21 @@ namespace OpenSim.Region.Physics.OdePlugin
741 rot.y = rotation.y; 758 rot.y = rotation.y;
742 rot.z = rotation.z; 759 rot.z = rotation.z;
743 760
744 761
745 int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); 762 int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
746 IntPtr targetspace = calculateSpaceForGeom(pos); 763 IntPtr targetspace = calculateSpaceForGeom(pos);
747 764
748 if (targetspace == IntPtr.Zero) 765 if (targetspace == IntPtr.Zero)
749 targetspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]); 766 targetspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]);
750 767
751 OdePrim newPrim; 768 OdePrim newPrim;
752 lock (OdeLock) 769 lock (OdeLock)
753 { 770 {
754 newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical); 771 newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical);
755 772
756 _prims.Add(newPrim); 773 _prims.Add(newPrim);
757 } 774 }
758 775
759 return newPrim; 776 return newPrim;
760 } 777 }
761 778
@@ -763,16 +780,14 @@ namespace OpenSim.Region.Physics.OdePlugin
763 { 780 {
764 // adds active prim.. (ones that should be iterated over in collisions_optimized 781 // adds active prim.. (ones that should be iterated over in collisions_optimized
765 782
766 _activeprims.Add(activatePrim); 783 _activeprims.Add(activatePrim);
767
768 } 784 }
785
769 public void remActivePrim(OdePrim deactivatePrim) 786 public void remActivePrim(OdePrim deactivatePrim)
770 { 787 {
771 788 _activeprims.Remove(deactivatePrim);
772 _activeprims.Remove(deactivatePrim);
773
774
775 } 789 }
790
776 public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) 791 public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount)
777 { 792 {
778/* String name1 = null; 793/* String name1 = null;
@@ -818,7 +833,7 @@ namespace OpenSim.Region.Physics.OdePlugin
818 return 1; 833 return 1;
819 } 834 }
820 835
821 836
822 public bool needsMeshing(PrimitiveBaseShape pbs) 837 public bool needsMeshing(PrimitiveBaseShape pbs)
823 { 838 {
824 if (pbs.ProfileHollow != 0) 839 if (pbs.ProfileHollow != 0)
@@ -833,7 +848,7 @@ namespace OpenSim.Region.Physics.OdePlugin
833 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 848 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
834 PhysicsVector size, Quaternion rotation) //To be removed 849 PhysicsVector size, Quaternion rotation) //To be removed
835 { 850 {
836 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 851 return AddPrimShape(primName, pbs, position, size, rotation, false);
837 } 852 }
838 853
839 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 854 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
@@ -848,12 +863,12 @@ namespace OpenSim.Region.Physics.OdePlugin
848 /// support simple box & hollow box now; later, more shapes 863 /// support simple box & hollow box now; later, more shapes
849 if (needsMeshing(pbs)) 864 if (needsMeshing(pbs))
850 { 865 {
851 mesh = mesher.CreateMesh(primName, pbs, size); 866 mesh = mesher.CreateMesh(primName, pbs, size);
852 } 867 }
853 868
854 break; 869 break;
855 } 870 }
856 871
857 result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); 872 result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical);
858 873
859 874
@@ -864,10 +879,9 @@ namespace OpenSim.Region.Physics.OdePlugin
864 { 879 {
865 if (prim is OdePrim) 880 if (prim is OdePrim)
866 { 881 {
867 OdePrim taintedprim = ((OdePrim)prim); 882 OdePrim taintedprim = ((OdePrim) prim);
868 if (!(_taintedPrim.Contains(taintedprim))) 883 if (!(_taintedPrim.Contains(taintedprim)))
869 _taintedPrim.Add(taintedprim); 884 _taintedPrim.Add(taintedprim);
870
871 } 885 }
872 } 886 }
873 887
@@ -877,19 +891,18 @@ namespace OpenSim.Region.Physics.OdePlugin
877 891
878 step_time += timeStep; 892 step_time += timeStep;
879 893
880 894
881 // If We're loaded down by something else, 895 // If We're loaded down by something else,
882 // or debugging with the Visual Studio project on pause 896 // or debugging with the Visual Studio project on pause
883 // skip a few frames to catch up gracefully. 897 // skip a few frames to catch up gracefully.
884 // without shooting the physicsactors all over the place 898 // without shooting the physicsactors all over the place
885
886 899
887 900
888 if (step_time >= m_SkipFramesAtms) 901 if (step_time >= m_SkipFramesAtms)
889 { 902 {
890 // Instead of trying to catch up, it'll do one physics frame only 903 // Instead of trying to catch up, it'll do one physics frame only
891 step_time = ODE_STEPSIZE; 904 step_time = ODE_STEPSIZE;
892 this.m_physicsiterations = 5; 905 m_physicsiterations = 5;
893 } 906 }
894 else 907 else
895 { 908 {
@@ -897,35 +910,36 @@ namespace OpenSim.Region.Physics.OdePlugin
897 } 910 }
898 lock (OdeLock) 911 lock (OdeLock)
899 { 912 {
900 // Process 10 frames if the sim is running normal.. 913 // Process 10 frames if the sim is running normal..
901 // process 5 frames if the sim is running slow 914 // process 5 frames if the sim is running slow
902 try{ 915 try
916 {
903 d.WorldSetQuickStepNumIterations(world, m_physicsiterations); 917 d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
904 } 918 }
905 catch (System.StackOverflowException) 919 catch (StackOverflowException)
906 { 920 {
907 MainLog.Instance.Error("PHYSICS", "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); 921 MainLog.Instance.Error("PHYSICS",
922 "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
908 base.TriggerPhysicsBasedRestart(); 923 base.TriggerPhysicsBasedRestart();
909 } 924 }
910 925
911 int i = 0; 926 int i = 0;
912 927
913 928
914 // Figure out the Frames Per Second we're going at. 929 // Figure out the Frames Per Second we're going at.
915 930
916 fps = (((step_time / ODE_STEPSIZE * m_physicsiterations)*2)* 10); 931 fps = (((step_time/ODE_STEPSIZE*m_physicsiterations)*2)*10);
917 932
918 933
919 while (step_time > 0.0f) 934 while (step_time > 0.0f)
920 { 935 {
921
922 foreach (OdeCharacter actor in _characters) 936 foreach (OdeCharacter actor in _characters)
923 { 937 {
924 actor.Move(timeStep); 938 actor.Move(timeStep);
925 actor.collidelock = true; 939 actor.collidelock = true;
926 } 940 }
927 941
928 942
929 collision_optimized(timeStep); 943 collision_optimized(timeStep);
930 d.WorldQuickStep(world, ODE_STEPSIZE); 944 d.WorldQuickStep(world, ODE_STEPSIZE);
931 d.JointGroupEmpty(contactgroup); 945 d.JointGroupEmpty(contactgroup);
@@ -933,7 +947,7 @@ namespace OpenSim.Region.Physics.OdePlugin
933 { 947 {
934 actor.collidelock = false; 948 actor.collidelock = false;
935 } 949 }
936 950
937 step_time -= ODE_STEPSIZE; 951 step_time -= ODE_STEPSIZE;
938 i++; 952 i++;
939 } 953 }
@@ -941,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin
941 foreach (OdeCharacter actor in _characters) 955 foreach (OdeCharacter actor in _characters)
942 { 956 {
943 actor.UpdatePositionAndVelocity(); 957 actor.UpdatePositionAndVelocity();
944
945 } 958 }
946 bool processedtaints = false; 959 bool processedtaints = false;
947 foreach (OdePrim prim in _taintedPrim) 960 foreach (OdePrim prim in _taintedPrim)
@@ -963,7 +976,6 @@ namespace OpenSim.Region.Physics.OdePlugin
963 if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag)) 976 if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag))
964 { 977 {
965 actor.UpdatePositionAndVelocity(); 978 actor.UpdatePositionAndVelocity();
966
967 } 979 }
968 } 980 }
969 } 981 }
@@ -984,25 +996,25 @@ namespace OpenSim.Region.Physics.OdePlugin
984 public float[] ResizeTerrain512(float[] heightMap) 996 public float[] ResizeTerrain512(float[] heightMap)
985 { 997 {
986 float[] returnarr = new float[262144]; 998 float[] returnarr = new float[262144];
987 float[,] resultarr = new float[m_regionWidth, m_regionHeight]; 999 float[,] resultarr = new float[m_regionWidth,m_regionHeight];
988 1000
989 // Filling out the array into it's multi-dimentional components 1001 // Filling out the array into it's multi-dimentional components
990 for (int y = 0; y < m_regionHeight; y++) 1002 for (int y = 0; y < m_regionHeight; y++)
991 { 1003 {
992 for (int x = 0; x < m_regionWidth; x++) 1004 for (int x = 0; x < m_regionWidth; x++)
993 { 1005 {
994 resultarr[y,x] = heightMap[y * m_regionWidth + x]; 1006 resultarr[y, x] = heightMap[y*m_regionWidth + x];
995 } 1007 }
996 } 1008 }
997 1009
998 // Resize using interpolation 1010 // Resize using interpolation
999 1011
1000 // This particular way is quick but it only works on a multiple of the original 1012 // This particular way is quick but it only works on a multiple of the original
1001 1013
1002 // The idea behind this method can be described with the following diagrams 1014 // The idea behind this method can be described with the following diagrams
1003 // second pass and third pass happen in the same loop really.. just separated 1015 // second pass and third pass happen in the same loop really.. just separated
1004 // them to show what this does. 1016 // them to show what this does.
1005 1017
1006 // First Pass 1018 // First Pass
1007 // ResultArr: 1019 // ResultArr:
1008 // 1,1,1,1,1,1 1020 // 1,1,1,1,1,1
@@ -1054,12 +1066,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1054 // 4th # 1066 // 4th #
1055 // on single loop. 1067 // on single loop.
1056 1068
1057 float[,] resultarr2 = new float[512, 512]; 1069 float[,] resultarr2 = new float[512,512];
1058 for (int y = 0; y < m_regionHeight; y++) 1070 for (int y = 0; y < m_regionHeight; y++)
1059 { 1071 {
1060 for (int x = 0; x < m_regionWidth; x++) 1072 for (int x = 0; x < m_regionWidth; x++)
1061 { 1073 {
1062 resultarr2[y*2,x*2] = resultarr[y,x]; 1074 resultarr2[y*2, x*2] = resultarr[y, x];
1063 1075
1064 if (y < m_regionHeight) 1076 if (y < m_regionHeight)
1065 { 1077 {
@@ -1067,16 +1079,17 @@ namespace OpenSim.Region.Physics.OdePlugin
1067 { 1079 {
1068 if (x + 1 < m_regionWidth) 1080 if (x + 1 < m_regionWidth)
1069 { 1081 {
1070 resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x+1] + resultarr[y+1, x+1])/4); 1082 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] +
1083 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
1071 } 1084 }
1072 else 1085 else
1073 { 1086 {
1074 resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x]) / 2); 1087 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x])/2);
1075 } 1088 }
1076 } 1089 }
1077 else 1090 else
1078 { 1091 {
1079 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; 1092 resultarr2[(y*2) + 1, x*2] = resultarr[y, x];
1080 } 1093 }
1081 } 1094 }
1082 if (x < m_regionWidth) 1095 if (x < m_regionWidth)
@@ -1085,31 +1098,32 @@ namespace OpenSim.Region.Physics.OdePlugin
1085 { 1098 {
1086 if (y + 1 < m_regionHeight) 1099 if (y + 1 < m_regionHeight)
1087 { 1100 {
1088 resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); 1101 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
1102 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
1089 } 1103 }
1090 else 1104 else
1091 { 1105 {
1092 resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1]) / 2); 1106 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1])/2);
1093 } 1107 }
1094 } 1108 }
1095 else 1109 else
1096 { 1110 {
1097 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; 1111 resultarr2[y*2, (x*2) + 1] = resultarr[y, x];
1098 } 1112 }
1099 } 1113 }
1100 if (x < m_regionWidth && y < m_regionHeight) 1114 if (x < m_regionWidth && y < m_regionHeight)
1101 { 1115 {
1102 if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight)) 1116 if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight))
1103 { 1117 {
1104 resultarr2[(y * 2) + 1, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); 1118 resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
1119 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
1105 } 1120 }
1106 else 1121 else
1107 { 1122 {
1108 resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x]; 1123 resultarr2[(y*2) + 1, (x*2) + 1] = resultarr[y, x];
1109 } 1124 }
1110 } 1125 }
1111 } 1126 }
1112
1113 } 1127 }
1114 //Flatten out the array 1128 //Flatten out the array
1115 int i = 0; 1129 int i = 0;
@@ -1119,7 +1133,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1119 { 1133 {
1120 if (resultarr2[y, x] <= 0) 1134 if (resultarr2[y, x] <= 0)
1121 returnarr[i] = 0.0000001f; 1135 returnarr[i] = 0.0000001f;
1122 else 1136 else
1123 returnarr[i] = resultarr2[y, x]; 1137 returnarr[i] = resultarr2[y, x];
1124 1138
1125 i++; 1139 i++;
@@ -1127,8 +1141,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1127 } 1141 }
1128 1142
1129 return returnarr; 1143 return returnarr;
1130
1131 } 1144 }
1145
1132 public override void SetTerrain(float[] heightMap) 1146 public override void SetTerrain(float[] heightMap)
1133 { 1147 {
1134 // this._heightmap[i] = (double)heightMap[i]; 1148 // this._heightmap[i] = (double)heightMap[i];
@@ -1137,8 +1151,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1137 1151
1138 const uint heightmapWidth = m_regionWidth + 2; 1152 const uint heightmapWidth = m_regionWidth + 2;
1139 const uint heightmapHeight = m_regionHeight + 2; 1153 const uint heightmapHeight = m_regionHeight + 2;
1140 const uint heightmapWidthSamples = 2 * m_regionWidth + 2; 1154 const uint heightmapWidthSamples = 2*m_regionWidth + 2;
1141 const uint heightmapHeightSamples = 2 * m_regionHeight + 2; 1155 const uint heightmapHeightSamples = 2*m_regionHeight + 2;
1142 const float scale = 1.0f; 1156 const float scale = 1.0f;
1143 const float offset = 0.0f; 1157 const float offset = 0.0f;
1144 const float thickness = 2.0f; 1158 const float thickness = 2.0f;
@@ -1166,7 +1180,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1166 } 1180 }
1167 IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); 1181 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
1168 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, 1182 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight,
1169 (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, offset, thickness, wrap); 1183 (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale,
1184 offset, thickness, wrap);
1170 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); 1185 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
1171 LandGeom = d.CreateHeightfield(space, HeightmapData, 1); 1186 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
1172 geom_name_map[LandGeom] = "Terrain"; 1187 geom_name_map[LandGeom] = "Terrain";
@@ -1193,7 +1208,4 @@ namespace OpenSim.Region.Physics.OdePlugin
1193 { 1208 {
1194 } 1209 }
1195 } 1210 }
1196 1211} \ No newline at end of file
1197
1198
1199}
diff --git a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs
index da9f587..3bb71d4 100644
--- a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("1.0.*")] 58[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
index 26310f9..1bc3490 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
@@ -25,8 +25,8 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic;
29using System; 28using System;
29using System.Collections.Generic;
30using Axiom.Math; 30using Axiom.Math;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
@@ -114,10 +114,10 @@ namespace OpenSim.Region.Physics.POSPlugin
114 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 114 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
115 PhysicsVector size, Quaternion rotation) 115 PhysicsVector size, Quaternion rotation)
116 { 116 {
117 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 117 return AddPrimShape(primName, pbs, position, size, rotation, false);
118 } 118 }
119 119
120 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 120 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
121 PhysicsVector size, Quaternion rotation, bool isPhysical) 121 PhysicsVector size, Quaternion rotation, bool isPhysical)
122 { 122 {
123 POSPrim prim = new POSPrim(); 123 POSPrim prim = new POSPrim();
@@ -136,18 +136,20 @@ namespace OpenSim.Region.Physics.POSPlugin
136 " sizeX: " + p.Size.X * 0.5 + 0.5); 136 " sizeX: " + p.Size.X * 0.5 + 0.5);
137 */ 137 */
138 138
139 Vector3 rotatedPos = p.Orientation.Inverse() * new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y, c.Position.Z - p.Position.Z); 139 Vector3 rotatedPos = p.Orientation.Inverse()*
140 Vector3 avatarSize = p.Orientation.Inverse() * new Vector3(c.Size.X, c.Size.Y, c.Size.Z); 140 new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y,
141 c.Position.Z - p.Position.Z);
142 Vector3 avatarSize = p.Orientation.Inverse()*new Vector3(c.Size.X, c.Size.Y, c.Size.Z);
141 143
142 if (Math.Abs(rotatedPos.x) >= (p.Size.X * 0.5 + Math.Abs(avatarSize.x))) 144 if (Math.Abs(rotatedPos.x) >= (p.Size.X*0.5 + Math.Abs(avatarSize.x)))
143 { 145 {
144 return false; 146 return false;
145 } 147 }
146 if (Math.Abs(rotatedPos.y) >= (p.Size.Y * 0.5 + Math.Abs(avatarSize.y))) 148 if (Math.Abs(rotatedPos.y) >= (p.Size.Y*0.5 + Math.Abs(avatarSize.y)))
147 { 149 {
148 return false; 150 return false;
149 } 151 }
150 if (Math.Abs(rotatedPos.z) >= (p.Size.Z * 0.5 + Math.Abs(avatarSize.z))) 152 if (Math.Abs(rotatedPos.z) >= (p.Size.Z*0.5 + Math.Abs(avatarSize.z)))
151 { 153 {
152 return false; 154 return false;
153 } 155 }
@@ -182,12 +184,12 @@ namespace OpenSim.Region.Physics.POSPlugin
182 184
183 if (!character.Flying) 185 if (!character.Flying)
184 { 186 {
185 character._target_velocity.Z += gravity * timeStep; 187 character._target_velocity.Z += gravity*timeStep;
186 } 188 }
187 189
188 bool forcedZ = false; 190 bool forcedZ = false;
189 character.Position.X += character._target_velocity.X * timeStep; 191 character.Position.X += character._target_velocity.X*timeStep;
190 character.Position.Y += character._target_velocity.Y * timeStep; 192 character.Position.Y += character._target_velocity.Y*timeStep;
191 193
192 if (character.Position.Y < 0) 194 if (character.Position.Y < 0)
193 { 195 {
@@ -207,15 +209,15 @@ namespace OpenSim.Region.Physics.POSPlugin
207 character.Position.X = 255.9F; 209 character.Position.X = 255.9F;
208 } 210 }
209 211
210 float terrainheight = _heightMap[(int)character.Position.Y * 256 + (int)character.Position.X]; 212 float terrainheight = _heightMap[(int) character.Position.Y*256 + (int) character.Position.X];
211 if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) 213 if (character.Position.Z + (character._target_velocity.Z*timeStep) < terrainheight + 2)
212 { 214 {
213 character.Position.Z = terrainheight + 1.0f; 215 character.Position.Z = terrainheight + 1.0f;
214 forcedZ = true; 216 forcedZ = true;
215 } 217 }
216 else 218 else
217 { 219 {
218 character.Position.Z += character._target_velocity.Z * timeStep; 220 character.Position.Z += character._target_velocity.Z*timeStep;
219 } 221 }
220 222
221 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- 223 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen --
@@ -224,21 +226,21 @@ namespace OpenSim.Region.Physics.POSPlugin
224 226
225 if (check_all_prims(character)) 227 if (check_all_prims(character))
226 { 228 {
227 character.Position.Z = oldposZ; // first try Z axis 229 character.Position.Z = oldposZ; // first try Z axis
228 if (check_all_prims(character)) 230 if (check_all_prims(character))
229 { 231 {
230 character.Position.Z = oldposZ + 0.4f; // try harder 232 character.Position.Z = oldposZ + 0.4f; // try harder
231 if (check_all_prims(character)) 233 if (check_all_prims(character))
232 { 234 {
233 character.Position.X = oldposX; 235 character.Position.X = oldposX;
234 character.Position.Y = oldposY; 236 character.Position.Y = oldposY;
235 character.Position.Z = oldposZ; 237 character.Position.Z = oldposZ;
236 character.Position.X = character.Position.X + (character._target_velocity.X * timeStep); 238 character.Position.X = character.Position.X + (character._target_velocity.X*timeStep);
237 if (check_all_prims(character)) 239 if (check_all_prims(character))
238 { 240 {
239 character.Position.X = oldposX; 241 character.Position.X = oldposX;
240 } 242 }
241 character.Position.Y = character.Position.Y + (character._target_velocity.Y * timeStep); 243 character.Position.Y = character.Position.Y + (character._target_velocity.Y*timeStep);
242 if (check_all_prims(character)) 244 if (check_all_prims(character))
243 { 245 {
244 character.Position.Y = oldposY; 246 character.Position.Y = oldposY;
@@ -253,7 +255,7 @@ namespace OpenSim.Region.Physics.POSPlugin
253 { 255 {
254 forcedZ = true; 256 forcedZ = true;
255 } 257 }
256 } 258 }
257 259
258 if (character.Position.Y < 0) 260 if (character.Position.Y < 0)
259 { 261 {
@@ -273,8 +275,8 @@ namespace OpenSim.Region.Physics.POSPlugin
273 character.Position.X = 255.9F; 275 character.Position.X = 255.9F;
274 } 276 }
275 277
276 character._velocity.X = (character.Position.X - oldposX) / timeStep; 278 character._velocity.X = (character.Position.X - oldposX)/timeStep;
277 character._velocity.Y = (character.Position.Y - oldposY) / timeStep; 279 character._velocity.Y = (character.Position.Y - oldposY)/timeStep;
278 280
279 if (forcedZ) 281 if (forcedZ)
280 { 282 {
@@ -284,7 +286,7 @@ namespace OpenSim.Region.Physics.POSPlugin
284 } 286 }
285 else 287 else
286 { 288 {
287 character._velocity.Z = (character.Position.Z - oldposZ) / timeStep; 289 character._velocity.Z = (character.Position.Z - oldposZ)/timeStep;
288 } 290 }
289 } 291 }
290 return fps; 292 return fps;
@@ -326,31 +328,37 @@ namespace OpenSim.Region.Physics.POSPlugin
326 _position = new PhysicsVector(); 328 _position = new PhysicsVector();
327 _acceleration = new PhysicsVector(); 329 _acceleration = new PhysicsVector();
328 } 330 }
331
329 public override int PhysicsActorType 332 public override int PhysicsActorType
330 { 333 {
331 get { return (int)ActorTypes.Agent; } 334 get { return (int) ActorTypes.Agent; }
332 set { return; } 335 set { return; }
333 } 336 }
337
334 public override PhysicsVector RotationalVelocity 338 public override PhysicsVector RotationalVelocity
335 { 339 {
336 get { return m_rotationalVelocity; } 340 get { return m_rotationalVelocity; }
337 set { m_rotationalVelocity = value; } 341 set { m_rotationalVelocity = value; }
338 } 342 }
343
339 public override bool SetAlwaysRun 344 public override bool SetAlwaysRun
340 { 345 {
341 get { return false; } 346 get { return false; }
342 set { return; } 347 set { return; }
343 } 348 }
349
344 public override bool IsPhysical 350 public override bool IsPhysical
345 { 351 {
346 get { return false; } 352 get { return false; }
347 set { return; } 353 set { return; }
348 } 354 }
355
349 public override bool ThrottleUpdates 356 public override bool ThrottleUpdates
350 { 357 {
351 get { return false; } 358 get { return false; }
352 set { return; } 359 set { return; }
353 } 360 }
361
354 public override bool Flying 362 public override bool Flying
355 { 363 {
356 get { return flying; } 364 get { return flying; }
@@ -362,16 +370,19 @@ namespace OpenSim.Region.Physics.POSPlugin
362 get { return iscolliding; } 370 get { return iscolliding; }
363 set { iscolliding = value; } 371 set { iscolliding = value; }
364 } 372 }
373
365 public override bool CollidingGround 374 public override bool CollidingGround
366 { 375 {
367 get { return false; } 376 get { return false; }
368 set { return; } 377 set { return; }
369 } 378 }
379
370 public override bool CollidingObj 380 public override bool CollidingObj
371 { 381 {
372 get { return false; } 382 get { return false; }
373 set { return; } 383 set { return; }
374 } 384 }
385
375 public override PhysicsVector Position 386 public override PhysicsVector Position
376 { 387 {
377 get { return _position; } 388 get { return _position; }
@@ -383,18 +394,22 @@ namespace OpenSim.Region.Physics.POSPlugin
383 get { return new PhysicsVector(0.5f, 0.5f, 1.0f); } 394 get { return new PhysicsVector(0.5f, 0.5f, 1.0f); }
384 set { } 395 set { }
385 } 396 }
397
386 public override float Mass 398 public override float Mass
387 { 399 {
388 get { return 0f; } 400 get { return 0f; }
389 } 401 }
402
390 public override PhysicsVector Force 403 public override PhysicsVector Force
391 { 404 {
392 get { return PhysicsVector.Zero; } 405 get { return PhysicsVector.Zero; }
393 } 406 }
407
394 public override PhysicsVector CenterOfMass 408 public override PhysicsVector CenterOfMass
395 { 409 {
396 get { return PhysicsVector.Zero; } 410 get { return PhysicsVector.Zero; }
397 } 411 }
412
398 public override PhysicsVector GeometricCenter 413 public override PhysicsVector GeometricCenter
399 { 414 {
400 get { return PhysicsVector.Zero; } 415 get { return PhysicsVector.Zero; }
@@ -402,10 +417,7 @@ namespace OpenSim.Region.Physics.POSPlugin
402 417
403 public override PrimitiveBaseShape Shape 418 public override PrimitiveBaseShape Shape
404 { 419 {
405 set 420 set { return; }
406 {
407 return;
408 }
409 } 421 }
410 422
411 public override PhysicsVector Velocity 423 public override PhysicsVector Velocity
@@ -461,41 +473,49 @@ namespace OpenSim.Region.Physics.POSPlugin
461 _position = new PhysicsVector(); 473 _position = new PhysicsVector();
462 _acceleration = new PhysicsVector(); 474 _acceleration = new PhysicsVector();
463 } 475 }
476
464 public override int PhysicsActorType 477 public override int PhysicsActorType
465 { 478 {
466 get { return (int)ActorTypes.Prim; } 479 get { return (int) ActorTypes.Prim; }
467 set { return; } 480 set { return; }
468 } 481 }
482
469 public override PhysicsVector RotationalVelocity 483 public override PhysicsVector RotationalVelocity
470 { 484 {
471 get { return m_rotationalVelocity; } 485 get { return m_rotationalVelocity; }
472 set { m_rotationalVelocity = value; } 486 set { m_rotationalVelocity = value; }
473 } 487 }
488
474 public override bool IsPhysical 489 public override bool IsPhysical
475 { 490 {
476 get { return false; } 491 get { return false; }
477 set { return; } 492 set { return; }
478 } 493 }
494
479 public override bool ThrottleUpdates 495 public override bool ThrottleUpdates
480 { 496 {
481 get { return false; } 497 get { return false; }
482 set { return; } 498 set { return; }
483 } 499 }
500
484 public override bool IsColliding 501 public override bool IsColliding
485 { 502 {
486 get { return iscolliding; } 503 get { return iscolliding; }
487 set { iscolliding = value; } 504 set { iscolliding = value; }
488 } 505 }
506
489 public override bool CollidingGround 507 public override bool CollidingGround
490 { 508 {
491 get { return false; } 509 get { return false; }
492 set { return; } 510 set { return; }
493 } 511 }
512
494 public override bool CollidingObj 513 public override bool CollidingObj
495 { 514 {
496 get { return false; } 515 get { return false; }
497 set { return; } 516 set { return; }
498 } 517 }
518
499 public override PhysicsVector Position 519 public override PhysicsVector Position
500 { 520 {
501 get { return _position; } 521 get { return _position; }
@@ -530,10 +550,7 @@ namespace OpenSim.Region.Physics.POSPlugin
530 550
531 public override PrimitiveBaseShape Shape 551 public override PrimitiveBaseShape Shape
532 { 552 {
533 set 553 set { return; }
534 {
535 return;
536 }
537 } 554 }
538 555
539 public override PhysicsVector Velocity 556 public override PhysicsVector Velocity
@@ -571,6 +588,7 @@ namespace OpenSim.Region.Physics.POSPlugin
571 public override void SetMomentum(PhysicsVector momentum) 588 public override void SetMomentum(PhysicsVector momentum)
572 { 589 {
573 } 590 }
591
574 public override bool Flying 592 public override bool Flying
575 { 593 {
576 get { return false; } 594 get { return false; }
@@ -583,4 +601,4 @@ namespace OpenSim.Region.Physics.POSPlugin
583 set { return; } 601 set { return; }
584 } 602 }
585 } 603 }
586} 604} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
index 8e6d2a6..36cb952 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("1.0.*")] 58[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 8525e75..20bf358 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -128,17 +128,19 @@ namespace OpenSim.Region.Physics.PhysXPlugin
128 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 128 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
129 PhysicsVector size, Quaternion rotation) //To be removed 129 PhysicsVector size, Quaternion rotation) //To be removed
130 { 130 {
131 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 131 return AddPrimShape(primName, pbs, position, size, rotation, false);
132 } 132 }
133
133 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 134 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
134 PhysicsVector size, Quaternion rotation, bool isPhysical) 135 PhysicsVector size, Quaternion rotation, bool isPhysical)
135 { 136 {
136 return AddPrim(position, size, rotation); 137 return AddPrim(position, size, rotation);
137 } 138 }
139
138 public override void AddPhysicsActorTaint(PhysicsActor prim) 140 public override void AddPhysicsActorTaint(PhysicsActor prim)
139 { 141 {
140
141 } 142 }
143
142 public override float Simulate(float timeStep) 144 public override float Simulate(float timeStep)
143 { 145 {
144 float fps = 0f; 146 float fps = 0f;
@@ -209,51 +211,61 @@ namespace OpenSim.Region.Physics.PhysXPlugin
209 _acceleration = new PhysicsVector(); 211 _acceleration = new PhysicsVector();
210 _character = character; 212 _character = character;
211 } 213 }
214
212 public override int PhysicsActorType 215 public override int PhysicsActorType
213 { 216 {
214 get { return (int)ActorTypes.Agent; } 217 get { return (int) ActorTypes.Agent; }
215 set { return; } 218 set { return; }
216 } 219 }
220
217 public override bool SetAlwaysRun 221 public override bool SetAlwaysRun
218 { 222 {
219 get { return false; } 223 get { return false; }
220 set { return; } 224 set { return; }
221 } 225 }
226
222 public override bool IsPhysical 227 public override bool IsPhysical
223 { 228 {
224 get { return false; } 229 get { return false; }
225 set { return; } 230 set { return; }
226 } 231 }
232
227 public override bool ThrottleUpdates 233 public override bool ThrottleUpdates
228 { 234 {
229 get { return false; } 235 get { return false; }
230 set { return; } 236 set { return; }
231 } 237 }
238
232 public override bool Flying 239 public override bool Flying
233 { 240 {
234 get { return flying; } 241 get { return flying; }
235 set { flying = value; } 242 set { flying = value; }
236 } 243 }
244
237 public override bool IsColliding 245 public override bool IsColliding
238 { 246 {
239 get { return iscolliding; } 247 get { return iscolliding; }
240 set { iscolliding = value; } 248 set { iscolliding = value; }
241 } 249 }
250
242 public override bool CollidingGround 251 public override bool CollidingGround
243 { 252 {
244 get { return false; } 253 get { return false; }
245 set { return; } 254 set { return; }
246 } 255 }
256
247 public override bool CollidingObj 257 public override bool CollidingObj
248 { 258 {
249 get { return false; } 259 get { return false; }
250 set { return; } 260 set { return; }
251 } 261 }
262
252 public override PhysicsVector RotationalVelocity 263 public override PhysicsVector RotationalVelocity
253 { 264 {
254 get { return m_rotationalVelocity; } 265 get { return m_rotationalVelocity; }
255 set { m_rotationalVelocity = value; } 266 set { m_rotationalVelocity = value; }
256 } 267 }
268
257 public override PhysicsVector Position 269 public override PhysicsVector Position
258 { 270 {
259 get { return _position; } 271 get { return _position; }
@@ -273,22 +285,27 @@ namespace OpenSim.Region.Physics.PhysXPlugin
273 get { return PhysicsVector.Zero; } 285 get { return PhysicsVector.Zero; }
274 set { } 286 set { }
275 } 287 }
288
276 public override float Mass 289 public override float Mass
277 { 290 {
278 get { return 0f; } 291 get { return 0f; }
279 } 292 }
293
280 public override PhysicsVector Force 294 public override PhysicsVector Force
281 { 295 {
282 get { return PhysicsVector.Zero; } 296 get { return PhysicsVector.Zero; }
283 } 297 }
298
284 public override PhysicsVector CenterOfMass 299 public override PhysicsVector CenterOfMass
285 { 300 {
286 get { return PhysicsVector.Zero; } 301 get { return PhysicsVector.Zero; }
287 } 302 }
303
288 public override PhysicsVector GeometricCenter 304 public override PhysicsVector GeometricCenter
289 { 305 {
290 get { return PhysicsVector.Zero; } 306 get { return PhysicsVector.Zero; }
291 } 307 }
308
292 public override PhysicsVector Velocity 309 public override PhysicsVector Velocity
293 { 310 {
294 get { return _velocity; } 311 get { return _velocity; }
@@ -345,23 +362,21 @@ namespace OpenSim.Region.Physics.PhysXPlugin
345 gravityAccel = 0; 362 gravityAccel = 0;
346 } 363 }
347 } 364 }
365
348 public override PrimitiveBaseShape Shape 366 public override PrimitiveBaseShape Shape
349 { 367 {
350 set 368 set { return; }
351 { 369 }
352 return; 370
353 } 371 public void UpdatePosition()
372 {
373 Vec3 vec = _character.Position;
374 _position.X = vec.X;
375 _position.Y = vec.Y;
376 _position.Z = vec.Z;
354 } 377 }
355 378 }
356 public void UpdatePosition() 379
357 {
358 Vec3 vec = this._character.Position;
359 this._position.X = vec.X;
360 this._position.Y = vec.Y;
361 this._position.Z = vec.Z;
362 }
363 }
364
365 380
366 public class PhysXPrim : PhysicsActor 381 public class PhysXPrim : PhysicsActor
367 { 382 {
@@ -376,55 +391,62 @@ namespace OpenSim.Region.Physics.PhysXPlugin
376 _acceleration = new PhysicsVector(); 391 _acceleration = new PhysicsVector();
377 _prim = prim; 392 _prim = prim;
378 } 393 }
394
379 public override int PhysicsActorType 395 public override int PhysicsActorType
380 { 396 {
381 get { return (int)ActorTypes.Prim; } 397 get { return (int) ActorTypes.Prim; }
382 set { return; } 398 set { return; }
383 } 399 }
400
384 public override bool IsPhysical 401 public override bool IsPhysical
385 { 402 {
386 get { return false; } 403 get { return false; }
387 set { return; } 404 set { return; }
388 } 405 }
406
389 public override bool SetAlwaysRun 407 public override bool SetAlwaysRun
390 { 408 {
391 get { return false; } 409 get { return false; }
392 set { return; } 410 set { return; }
393 } 411 }
412
394 public override bool ThrottleUpdates 413 public override bool ThrottleUpdates
395 { 414 {
396 get { return false; } 415 get { return false; }
397 set { return; } 416 set { return; }
398 } 417 }
418
399 public override PhysicsVector RotationalVelocity 419 public override PhysicsVector RotationalVelocity
400 { 420 {
401 get { return m_rotationalVelocity; } 421 get { return m_rotationalVelocity; }
402 set { m_rotationalVelocity = value; } 422 set { m_rotationalVelocity = value; }
403 } 423 }
424
404 public override bool Flying 425 public override bool Flying
405 { 426 {
406 get { return false; //no flying prims for you 427 get { return false; //no flying prims for you
407 } 428 }
408 set { } 429 set { }
409 } 430 }
431
410 public override bool IsColliding 432 public override bool IsColliding
411 { 433 {
412 get 434 get { return false; }
413 {
414 return false;
415 }
416 set { } 435 set { }
417 } 436 }
437
418 public override bool CollidingGround 438 public override bool CollidingGround
419 { 439 {
420 get { return false; } 440 get { return false; }
421 set { return; } 441 set { return; }
422 } 442 }
443
423 public override bool CollidingObj 444 public override bool CollidingObj
424 { 445 {
425 get { return false; } 446 get { return false; }
426 set { return; } 447 set { return; }
427 } 448 }
449
428 public override PhysicsVector Position 450 public override PhysicsVector Position
429 { 451 {
430 get 452 get
@@ -449,75 +471,52 @@ namespace OpenSim.Region.Physics.PhysXPlugin
449 471
450 public override PrimitiveBaseShape Shape 472 public override PrimitiveBaseShape Shape
451 { 473 {
452 set 474 set { return; }
453 {
454 return;
455 }
456 } 475 }
457 476
458 public override PhysicsVector Velocity 477 public override PhysicsVector Velocity
459 { 478 {
460 get 479 get { return _velocity; }
461 { 480 set { _velocity = value; }
462 return _velocity;
463 }
464 set
465 {
466 _velocity = value;
467 }
468 } 481 }
469 482
470 public override bool Kinematic 483 public override bool Kinematic
471 { 484 {
472 get 485 get { return _prim.Kinematic; }
473 { 486 set { _prim.Kinematic = value; }
474 return this._prim.Kinematic;
475 }
476 set
477 {
478 this._prim.Kinematic = value;
479 }
480 } 487 }
481 488
482 public override Quaternion Orientation 489 public override Quaternion Orientation
483 { 490 {
484 get 491 get
485 { 492 {
486 Quaternion res = new Quaternion(); 493 Quaternion res = new Quaternion();
487 PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); 494 PhysXWrapper.Quaternion quat = _prim.GetOrientation();
488 res.w = quat.W; 495 res.w = quat.W;
489 res.x = quat.X; 496 res.x = quat.X;
490 res.y = quat.Y; 497 res.y = quat.Y;
491 res.z = quat.Z; 498 res.z = quat.Z;
492 return res; 499 return res;
493 } 500 }
494 set 501 set { }
495 {
496
497 }
498 } 502 }
499 503
500 public override PhysicsVector Acceleration 504 public override PhysicsVector Acceleration
501 { 505 {
502 get 506 get { return _acceleration; }
503 {
504 return _acceleration;
505 }
506
507 } 507 }
508 public void SetAcceleration (PhysicsVector accel) 508
509 public void SetAcceleration(PhysicsVector accel)
509 { 510 {
510 this._acceleration = accel; 511 _acceleration = accel;
511 } 512 }
512 513
513 public override void AddForce(PhysicsVector force) 514 public override void AddForce(PhysicsVector force)
514 { 515 {
515
516 } 516 }
517 517
518 public override void SetMomentum(PhysicsVector momentum) 518 public override void SetMomentum(PhysicsVector momentum)
519 { 519 {
520
521 } 520 }
522 521
523 public override PhysicsVector Size 522 public override PhysicsVector Size
@@ -545,6 +544,5 @@ namespace OpenSim.Region.Physics.PhysXPlugin
545 { 544 {
546 get { return PhysicsVector.Zero; } 545 get { return PhysicsVector.Zero; }
547 } 546 }
548
549 } 547 }
550} 548} \ No newline at end of file