aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs143
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs16
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs14
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs99
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs6
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs394
7 files changed, 277 insertions, 397 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b038876..bd11cde 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4964,7 +4964,7 @@ namespace OpenSim.Region.Framework.Scenes
4964 4964
4965 pa.OnCollisionUpdate -= PhysicsCollision; 4965 pa.OnCollisionUpdate -= PhysicsCollision;
4966 4966
4967 bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); 4967 bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0));
4968 4968
4969 scriptEvents CombinedEvents = AggregateScriptEvents; 4969 scriptEvents CombinedEvents = AggregateScriptEvents;
4970 4970
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index aaeae86..a2c72c3 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -43,7 +43,8 @@ namespace OpenSim.Region.Physics.Manager
43 Unknown = 0, 43 Unknown = 0,
44 Agent = 1, 44 Agent = 1,
45 Prim = 2, 45 Prim = 2,
46 Ground = 3 46 Ground = 3,
47 Water = 4
47 } 48 }
48 49
49 public enum PIDHoverType 50 public enum PIDHoverType
@@ -114,7 +115,7 @@ namespace OpenSim.Region.Physics.Manager
114 m_objCollisionList.Add(localID, contact); 115 m_objCollisionList.Add(localID, contact);
115 } 116 }
116 else 117 else
117 { 118 {
118 if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) 119 if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth)
119 m_objCollisionList[localID] = contact; 120 m_objCollisionList[localID] = contact;
120 } 121 }
@@ -202,7 +203,7 @@ namespace OpenSim.Region.Physics.Manager
202 /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or 203 /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or
203 /// water. This is not a problem due to the formatting of names given by prims and avatars. 204 /// water. This is not a problem due to the formatting of names given by prims and avatars.
204 /// </remarks> 205 /// </remarks>
205 public string Name { get; protected set; } 206 public string Name { get; set; }
206 207
207 /// <summary> 208 /// <summary>
208 /// This is being used by ODE joint code. 209 /// This is being used by ODE joint code.
@@ -230,11 +231,6 @@ namespace OpenSim.Region.Physics.Manager
230 } 231 }
231 } 232 }
232 233
233 public virtual byte[] Serialize(bool PhysIsRunning)
234 {
235 return new byte[0];
236 }
237
238 public virtual void RaiseOutOfBounds(Vector3 pos) 234 public virtual void RaiseOutOfBounds(Vector3 pos)
239 { 235 {
240 // Make a temporary copy of the event to avoid possibility of 236 // Make a temporary copy of the event to avoid possibility of
@@ -258,10 +254,7 @@ namespace OpenSim.Region.Physics.Manager
258 handler(e); 254 handler(e);
259 } 255 }
260 256
261 public virtual void SetMaterial (int material) 257 public virtual void SetMaterial (int material) { }
262 {
263 }
264
265 public virtual float Density { get; set; } 258 public virtual float Density { get; set; }
266 public virtual float GravModifier { get; set; } 259 public virtual float GravModifier { get; set; }
267 public virtual float Friction { get; set; } 260 public virtual float Friction { get; set; }
@@ -373,13 +366,21 @@ namespace OpenSim.Region.Physics.Manager
373 public abstract void SubscribeEvents(int ms); 366 public abstract void SubscribeEvents(int ms);
374 public abstract void UnSubscribeEvents(); 367 public abstract void UnSubscribeEvents();
375 public abstract bool SubscribedEvents(); 368 public abstract bool SubscribedEvents();
369
370 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { }
371
372 // Warning in a parent part it returns itself, not null
373 public virtual PhysicsActor ParentActor { get { return this; } }
374
376 } 375 }
377 376
378 public class NullPhysicsActor : PhysicsActor 377 public class NullPhysicsActor : PhysicsActor
379 { 378 {
379 private ActorTypes m_actorType = ActorTypes.Unknown;
380
380 public override bool Stopped 381 public override bool Stopped
381 { 382 {
382 get{ return false; } 383 get{ return true; }
383 } 384 }
384 385
385 public override Vector3 Position 386 public override Vector3 Position
@@ -396,6 +397,7 @@ namespace OpenSim.Region.Physics.Manager
396 397
397 public override uint LocalID 398 public override uint LocalID
398 { 399 {
400 get { return 0; }
399 set { return; } 401 set { return; }
400 } 402 }
401 403
@@ -455,49 +457,17 @@ namespace OpenSim.Region.Physics.Manager
455 set { return; } 457 set { return; }
456 } 458 }
457 459
458 public override void VehicleFloatParam(int param, float value) 460 public override void VehicleFloatParam(int param, float value) {}
459 { 461 public override void VehicleVectorParam(int param, Vector3 value) { }
460 } 462 public override void VehicleRotationParam(int param, Quaternion rotation) { }
461 463 public override void VehicleFlags(int param, bool remove) { }
462 public override void VehicleVectorParam(int param, Vector3 value) 464 public override void SetVolumeDetect(int param) {}
463 { 465 public override void SetMaterial(int material) {}
464 466 public override Vector3 CenterOfMass { get { return Vector3.Zero; }}
465 }
466
467 public override void VehicleRotationParam(int param, Quaternion rotation)
468 {
469
470 }
471
472 public override void VehicleFlags(int param, bool remove)
473 {
474
475 }
476
477 public override void SetVolumeDetect(int param)
478 {
479
480 }
481
482 public override void SetMaterial(int material)
483 {
484
485 }
486
487 public override Vector3 CenterOfMass
488 {
489 get { return Vector3.Zero; }
490 }
491 467
492 public override Vector3 GeometricCenter 468 public override Vector3 GeometricCenter { get { return Vector3.Zero; }}
493 {
494 get { return Vector3.Zero; }
495 }
496 469
497 public override PrimitiveBaseShape Shape 470 public override PrimitiveBaseShape Shape { set { return; }}
498 {
499 set { return; }
500 }
501 471
502 public override Vector3 Velocity 472 public override Vector3 Velocity
503 { 473 {
@@ -517,9 +487,7 @@ namespace OpenSim.Region.Physics.Manager
517 set { } 487 set { }
518 } 488 }
519 489
520 public override void CrossingFailure() 490 public override void CrossingFailure() {}
521 {
522 }
523 491
524 public override Quaternion Orientation 492 public override Quaternion Orientation
525 { 493 {
@@ -559,8 +527,20 @@ namespace OpenSim.Region.Physics.Manager
559 527
560 public override int PhysicsActorType 528 public override int PhysicsActorType
561 { 529 {
562 get { return (int) ActorTypes.Unknown; } 530 get { return (int)m_actorType; }
563 set { return; } 531 set {
532 ActorTypes type = (ActorTypes)value;
533 switch (type)
534 {
535 case ActorTypes.Ground:
536 case ActorTypes.Water:
537 m_actorType = type;
538 break;
539 default:
540 m_actorType = ActorTypes.Unknown;
541 break;
542 }
543 }
564 } 544 }
565 545
566 public override bool Kinematic 546 public override bool Kinematic
@@ -569,26 +549,11 @@ namespace OpenSim.Region.Physics.Manager
569 set { return; } 549 set { return; }
570 } 550 }
571 551
572 public override void link(PhysicsActor obj) 552 public override void link(PhysicsActor obj) { }
573 { 553 public override void delink() { }
574 } 554 public override void LockAngularMotion(Vector3 axis) { }
575 555 public override void AddForce(Vector3 force, bool pushforce) { }
576 public override void delink() 556 public override void AddAngularForce(Vector3 force, bool pushforce) { }
577 {
578 }
579
580 public override void LockAngularMotion(Vector3 axis)
581 {
582 }
583
584 public override void AddForce(Vector3 force, bool pushforce)
585 {
586 }
587
588 public override void AddAngularForce(Vector3 force, bool pushforce)
589 {
590
591 }
592 557
593 public override Vector3 RotationalVelocity 558 public override Vector3 RotationalVelocity
594 { 559 {
@@ -610,22 +575,10 @@ namespace OpenSim.Region.Physics.Manager
610 public override float APIDStrength { set { return; } } 575 public override float APIDStrength { set { return; } }
611 public override float APIDDamping { set { return; } } 576 public override float APIDDamping { set { return; } }
612 577
613 public override void SetMomentum(Vector3 momentum) 578 public override void SetMomentum(Vector3 momentum) { }
614 {
615 }
616
617 public override void SubscribeEvents(int ms)
618 {
619
620 }
621 public override void UnSubscribeEvents()
622 {
623
624 }
625 public override bool SubscribedEvents()
626 {
627 return false;
628 }
629 579
580 public override void SubscribeEvents(int ms) { }
581 public override void UnSubscribeEvents() { }
582 public override bool SubscribedEvents() { return false; }
630 } 583 }
631} 584}
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b506b1c..c363310 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.OdePlugin
106 private bool m_freemove = false; 106 private bool m_freemove = false;
107 // private CollisionLocker ode; 107 // private CollisionLocker ode;
108 108
109 private string m_name = String.Empty; 109// private string m_name = String.Empty;
110 // other filter control 110 // other filter control
111 int m_colliderfilter = 0; 111 int m_colliderfilter = 0;
112 int m_colliderGroundfilter = 0; 112 int m_colliderGroundfilter = 0;
@@ -183,7 +183,7 @@ namespace OpenSim.Region.Physics.OdePlugin
183 183
184 m_isPhysical = false; // current status: no ODE information exists 184 m_isPhysical = false; // current status: no ODE information exists
185 185
186 m_name = avName; 186 Name = avName;
187 187
188 AddChange(changes.Add, null); 188 AddChange(changes.Add, null);
189 } 189 }
@@ -218,6 +218,11 @@ namespace OpenSim.Region.Physics.OdePlugin
218 set { m_localID = value; } 218 set { m_localID = value; }
219 } 219 }
220 220
221 public override PhysicsActor ParentActor
222 {
223 get { return (PhysicsActor)this; }
224 }
225
221 public override bool Grabbed 226 public override bool Grabbed
222 { 227 {
223 set { return; } 228 set { return; }
@@ -740,7 +745,7 @@ namespace OpenSim.Region.Physics.OdePlugin
740 //kill the Geometry 745 //kill the Geometry
741 if (Shell != IntPtr.Zero) 746 if (Shell != IntPtr.Zero)
742 { 747 {
743 _parent_scene.geom_name_map.Remove(Shell); 748// _parent_scene.geom_name_map.Remove(Shell);
744 _parent_scene.actor_name_map.Remove(Shell); 749 _parent_scene.actor_name_map.Remove(Shell);
745 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 750 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
746 d.GeomDestroy(Shell); 751 d.GeomDestroy(Shell);
@@ -1115,7 +1120,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1115 m_eventsubscription = 0; 1120 m_eventsubscription = 0;
1116 } 1121 }
1117 1122
1118 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1123 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
1119 { 1124 {
1120 if (CollisionEventsThisFrame == null) 1125 if (CollisionEventsThisFrame == null)
1121 CollisionEventsThisFrame = new CollisionEventUpdate(); 1126 CollisionEventsThisFrame = new CollisionEventUpdate();
@@ -1184,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1184 } 1189 }
1185 1190
1186 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); 1191 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
1187 _parent_scene.geom_name_map[Shell] = m_name; 1192
1188 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1193 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
1189 _parent_scene.AddCharacter(this); 1194 _parent_scene.AddCharacter(this);
1190 } 1195 }
@@ -1236,7 +1241,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1236 1241
1237 Velocity = Vector3.Zero; 1242 Velocity = Vector3.Zero;
1238 1243
1239 _parent_scene.geom_name_map[Shell] = m_name;
1240 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1244 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
1241 } 1245 }
1242 else 1246 else
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 6d322e2..6bf5be1 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -176,7 +176,7 @@ namespace OpenSim.Region.Physics.OdePlugin
176 private bool m_lastUpdateSent; 176 private bool m_lastUpdateSent;
177 177
178 public IntPtr Body = IntPtr.Zero; 178 public IntPtr Body = IntPtr.Zero;
179 public String Name { get; private set; } 179// public String Name { get; private set; }
180 private Vector3 _target_velocity; 180 private Vector3 _target_velocity;
181 181
182 public Vector3 primOOBsize; // prim real dimensions from mesh 182 public Vector3 primOOBsize; // prim real dimensions from mesh
@@ -295,14 +295,14 @@ namespace OpenSim.Region.Physics.OdePlugin
295 set { m_localID = value; } 295 set { m_localID = value; }
296 } 296 }
297 297
298 public OdePrim Parent 298 public override PhysicsActor ParentActor
299 { 299 {
300 get 300 get
301 { 301 {
302 if (childPrim) 302 if (childPrim)
303 return (OdePrim)_parent; 303 return _parent;
304 else 304 else
305 return this; 305 return (PhysicsActor)this;
306 } 306 }
307 } 307 }
308 308
@@ -950,7 +950,7 @@ namespace OpenSim.Region.Physics.OdePlugin
950 _parent_scene.RemoveCollisionEventReporting(this); 950 _parent_scene.RemoveCollisionEventReporting(this);
951 } 951 }
952 952
953 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 953 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
954 { 954 {
955 if (CollisionEventsThisFrame == null) 955 if (CollisionEventsThisFrame == null)
956 CollisionEventsThisFrame = new CollisionEventUpdate(); 956 CollisionEventsThisFrame = new CollisionEventUpdate();
@@ -1431,6 +1431,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1431 //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); 1431 //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name);
1432 if (prim_geom != IntPtr.Zero) 1432 if (prim_geom != IntPtr.Zero)
1433 { 1433 {
1434
1434 if (m_NoColide) 1435 if (m_NoColide)
1435 { 1436 {
1436 d.GeomSetCategoryBits(prim_geom, 0); 1437 d.GeomSetCategoryBits(prim_geom, 0);
@@ -1452,7 +1453,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1452 1453
1453 CalcPrimBodyData(); 1454 CalcPrimBodyData();
1454 1455
1455 _parent_scene.geom_name_map[prim_geom] = Name;
1456 _parent_scene.actor_name_map[prim_geom] = this; 1456 _parent_scene.actor_name_map[prim_geom] = this;
1457 1457
1458 } 1458 }
@@ -1526,7 +1526,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1526 { 1526 {
1527 if (prim_geom != IntPtr.Zero) 1527 if (prim_geom != IntPtr.Zero)
1528 { 1528 {
1529 _parent_scene.geom_name_map.Remove(prim_geom); 1529// _parent_scene.geom_name_map.Remove(prim_geom);
1530 _parent_scene.actor_name_map.Remove(prim_geom); 1530 _parent_scene.actor_name_map.Remove(prim_geom);
1531 try 1531 try
1532 { 1532 {
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
index 3d108f8..21fe9c0 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
@@ -470,56 +470,77 @@ namespace OpenSim.Region.Physics.OdePlugin
470 470
471 if (p2 == null) 471 if (p2 == null)
472 { 472 {
473 string name; 473 /*
474 474 string name;
475 if (!m_scene.geom_name_map.TryGetValue(g2, out name)) 475
476 return; 476 if (!m_scene.geom_name_map.TryGetValue(g2, out name))
477 477 return;
478 if (name == "Terrain") 478
479 { 479 if (name == "Terrain")
480 // land colision 480 {
481 if ((CurrentRayFilter & RayFilterFlags.land) == 0) 481 // land colision
482 return; 482 if ((CurrentRayFilter & RayFilterFlags.land) == 0)
483 } 483 return;
484 else if (name == "Water") 484 }
485 { 485 else if (name == "Water")
486 if ((CurrentRayFilter & RayFilterFlags.water) == 0) 486 {
487 return; 487 if ((CurrentRayFilter & RayFilterFlags.water) == 0)
488 } 488 return;
489 else 489 }
490 return; 490 else
491 return;
492 */
493 return;
491 } 494 }
492 else 495 else
493 { 496 {
494 if (p2 is OdePrim) 497 switch (p2.PhysicsActorType)
495 { 498 {
496 RayFilterFlags thisFlags; 499 case (int)ActorTypes.Prim:
497 500
498 if (p2.IsPhysical) 501 RayFilterFlags thisFlags;
499 thisFlags = RayFilterFlags.physical;
500 else
501 thisFlags = RayFilterFlags.nonphysical;
502 502
503 if (p2.Phantom) 503 if (p2.IsPhysical)
504 thisFlags |= RayFilterFlags.phantom; 504 thisFlags = RayFilterFlags.physical;
505 else
506 thisFlags = RayFilterFlags.nonphysical;
505 507
506 if (p2.IsVolumeDtc) 508 if (p2.Phantom)
507 thisFlags |= RayFilterFlags.volumedtc; 509 thisFlags |= RayFilterFlags.phantom;
508 510
509 if ((thisFlags & CurrentRayFilter) == 0) 511 if (p2.IsVolumeDtc)
510 return; 512 thisFlags |= RayFilterFlags.volumedtc;
511 513
512 ID = ((OdePrim)p2).LocalID; 514 if ((thisFlags & CurrentRayFilter) == 0)
513 } 515 return;
514 else if (p2 is OdeCharacter) 516
515 { 517 ID = ((OdePrim)p2).LocalID;
516 if ((CurrentRayFilter & RayFilterFlags.agent) == 0) 518 break;
519
520 case (int)ActorTypes.Agent:
521
522 if ((CurrentRayFilter & RayFilterFlags.agent) == 0)
523 return;
524 else
525 ID = ((OdeCharacter)p2).LocalID;
526 break;
527
528 case (int)ActorTypes.Ground:
529
530 if ((CurrentRayFilter & RayFilterFlags.land) == 0)
531 return;
532 break;
533
534 case (int)ActorTypes.Water:
535
536 if ((CurrentRayFilter & RayFilterFlags.water) == 0)
537 return;
538 break;
539
540 default:
517 return; 541 return;
518 else 542 break;
519 ID = ((OdeCharacter)p2).LocalID;
520 } 543 }
521 else //??
522 return;
523 } 544 }
524 545
525 d.ContactGeom curcontact = new d.ContactGeom(); 546 d.ContactGeom curcontact = new d.ContactGeom();
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
index ee48db5..403a4ce 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
@@ -903,7 +903,7 @@ namespace OdeAPI
903 public static extern GeomClassID GeomGetClass(IntPtr geom); 903 public static extern GeomClassID GeomGetClass(IntPtr geom);
904 904
905 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetData"), SuppressUnmanagedCodeSecurity] 905 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetData"), SuppressUnmanagedCodeSecurity]
906 public static extern IntPtr GeomGetData(IntPtr geom); 906 public static extern IntPtr GeomGetData(IntPtr geom);
907 907
908 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetOffsetPosition"), SuppressUnmanagedCodeSecurity] 908 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetOffsetPosition"), SuppressUnmanagedCodeSecurity]
909 public extern unsafe static Vector3* GeomGetOffsetPositionUnsafe(IntPtr geom); 909 public extern unsafe static Vector3* GeomGetOffsetPositionUnsafe(IntPtr geom);
@@ -1096,8 +1096,8 @@ namespace OdeAPI
1096 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetConvex"), SuppressUnmanagedCodeSecurity] 1096 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetConvex"), SuppressUnmanagedCodeSecurity]
1097 public static extern IntPtr GeomSetConvex(IntPtr geom, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons); 1097 public static extern IntPtr GeomSetConvex(IntPtr geom, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons);
1098 1098
1099 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetData"), SuppressUnmanagedCodeSecurity] 1099 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetData"), SuppressUnmanagedCodeSecurity]
1100 public static extern void GeomSetData(IntPtr geom, IntPtr data); 1100 public static extern void GeomSetData(IntPtr geom, IntPtr data);
1101 1101
1102 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetOffsetPosition"), SuppressUnmanagedCodeSecurity] 1102 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetOffsetPosition"), SuppressUnmanagedCodeSecurity]
1103 public static extern void GeomSetOffsetPosition(IntPtr geom, dReal x, dReal y, dReal z); 1103 public static extern void GeomSetOffsetPosition(IntPtr geom, dReal x, dReal y, dReal z);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 2928257..a554897 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -203,9 +203,9 @@ namespace OpenSim.Region.Physics.OdePlugin
203 private float waterlevel = 0f; 203 private float waterlevel = 0f;
204 private int framecount = 0; 204 private int framecount = 0;
205 205
206 private IntPtr WaterGeom = IntPtr.Zero; 206// private IntPtr WaterGeom = IntPtr.Zero;
207 private IntPtr WaterHeightmapData = IntPtr.Zero; 207// private IntPtr WaterHeightmapData = IntPtr.Zero;
208 private GCHandle WaterMapHandler = new GCHandle(); 208// private GCHandle WaterMapHandler = new GCHandle();
209 209
210 public float avPIDD = 2200f; // make it visible 210 public float avPIDD = 2200f; // make it visible
211 public float avPIDP = 900f; // make it visible 211 public float avPIDP = 900f; // make it visible
@@ -251,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin
251 private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); 251 private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
252 252
253 private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 253 private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
254 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 254// public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
256 256
257 private float contactsurfacelayer = 0.002f; 257 private float contactsurfacelayer = 0.002f;
@@ -274,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin
274 274
275 private int m_physicsiterations = 10; 275 private int m_physicsiterations = 10;
276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag 276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
277 private PhysicsActor PANull = new NullPhysicsActor(); 277// private PhysicsActor PANull = new NullPhysicsActor();
278 private float step_time = 0.0f; 278 private float step_time = 0.0f;
279 279
280 public IntPtr world; 280 public IntPtr world;
@@ -713,6 +713,7 @@ namespace OpenSim.Region.Physics.OdePlugin
713 713
714 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 714 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
715 return; 715 return;
716
716 if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || 717 if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
717 d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) 718 d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc)
718 { 719 {
@@ -738,7 +739,7 @@ namespace OpenSim.Region.Physics.OdePlugin
738 return; 739 return;
739 } 740 }
740 741
741 // id contacts done 742 // contacts done
742 if (count == 0) 743 if (count == 0)
743 return; 744 return;
744 745
@@ -748,12 +749,14 @@ namespace OpenSim.Region.Physics.OdePlugin
748 749
749 if (!actor_name_map.TryGetValue(g1, out p1)) 750 if (!actor_name_map.TryGetValue(g1, out p1))
750 { 751 {
751 p1 = PANull; 752 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 1");
753 return;
752 } 754 }
753 755
754 if (!actor_name_map.TryGetValue(g2, out p2)) 756 if (!actor_name_map.TryGetValue(g2, out p2))
755 { 757 {
756 p2 = PANull; 758 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2");
759 return;
757 } 760 }
758 761
759 // update actors collision score 762 // update actors collision score
@@ -765,7 +768,6 @@ namespace OpenSim.Region.Physics.OdePlugin
765 p2.CollisionScore = 0; 768 p2.CollisionScore = 0;
766 p2.CollisionScore += count; 769 p2.CollisionScore += count;
767 770
768
769 // get first contact 771 // get first contact
770 d.ContactGeom curContact = new d.ContactGeom(); 772 d.ContactGeom curContact = new d.ContactGeom();
771 if (!GetCurContactGeom(0, ref curContact)) 773 if (!GetCurContactGeom(0, ref curContact))
@@ -798,7 +800,6 @@ namespace OpenSim.Region.Physics.OdePlugin
798 ContactData contactdata1 = new ContactData(0, 0, false); 800 ContactData contactdata1 = new ContactData(0, 0, false);
799 ContactData contactdata2 = new ContactData(0, 0, false); 801 ContactData contactdata2 = new ContactData(0, 0, false);
800 802
801 String name = null;
802 bool dop1foot = false; 803 bool dop1foot = false;
803 bool dop2foot = false; 804 bool dop2foot = false;
804 bool ignore = false; 805 bool ignore = false;
@@ -830,34 +831,16 @@ namespace OpenSim.Region.Physics.OdePlugin
830 switch (p2.PhysicsActorType) 831 switch (p2.PhysicsActorType)
831 { 832 {
832 case (int)ActorTypes.Agent: 833 case (int)ActorTypes.Agent:
833/*
834 p1.getContactData(ref contactdata1);
835 p2.getContactData(ref contactdata2);
836
837 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
838
839 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
840 mu *= frictionMovementMult;
841*/
842 p1.CollidingObj = true; 834 p1.CollidingObj = true;
843 p2.CollidingObj = true; 835 p2.CollidingObj = true;
844 break; 836 break;
845 case (int)ActorTypes.Prim:
846/*
847 p1.getContactData(ref contactdata1);
848 p2.getContactData(ref contactdata2);
849 837
850 838 case (int)ActorTypes.Prim:
851 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
852
853 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
854 mu *= frictionMovementMult;
855 */
856 if (p2.Velocity.LengthSquared() > 0.0f) 839 if (p2.Velocity.LengthSquared() > 0.0f)
857 p2.CollidingObj = true; 840 p2.CollidingObj = true;
858
859 dop1foot = true; 841 dop1foot = true;
860 break; 842 break;
843
861 default: 844 default:
862 ignore = true; // avatar to terrain and water ignored 845 ignore = true; // avatar to terrain and water ignored
863 break; 846 break;
@@ -869,9 +852,6 @@ namespace OpenSim.Region.Physics.OdePlugin
869 switch (p2.PhysicsActorType) 852 switch (p2.PhysicsActorType)
870 { 853 {
871 case (int)ActorTypes.Agent: 854 case (int)ActorTypes.Agent:
872 // p1.getContactData(ref contactdata1);
873 // p2.getContactData(ref contactdata2);
874
875 AvanormOverride = true; 855 AvanormOverride = true;
876 856
877 Vector3 tmp = p2.Position - p1.Position; 857 Vector3 tmp = p2.Position - p1.Position;
@@ -894,16 +874,12 @@ namespace OpenSim.Region.Physics.OdePlugin
894 bounce = 0; 874 bounce = 0;
895 mu = 0; 875 mu = 0;
896 cfm = 0.0001f; 876 cfm = 0.0001f;
897 /*
898 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
899 877
900 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
901 mu *= frictionMovementMult;
902 */
903 dop2foot = true; 878 dop2foot = true;
904 if (p1.Velocity.LengthSquared() > 0.0f) 879 if (p1.Velocity.LengthSquared() > 0.0f)
905 p1.CollidingObj = true; 880 p1.CollidingObj = true;
906 break; 881 break;
882
907 case (int)ActorTypes.Prim: 883 case (int)ActorTypes.Prim:
908 if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f) 884 if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f)
909 { 885 {
@@ -933,95 +909,77 @@ namespace OpenSim.Region.Physics.OdePlugin
933 mu *= frictionMovementMult; 909 mu *= frictionMovementMult;
934 910
935 break; 911 break;
936 default:
937 if (geom_name_map.TryGetValue(g2, out name))
938 {
939 if (name == "Terrain")
940 {
941 p1.getContactData(ref contactdata1);
942 bounce = contactdata1.bounce * TerrainBounce;
943 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
944 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
945 mu *= frictionMovementMult;
946 p1.CollidingGround = true;
947
948 cfm = p1.Mass;
949 dscale = 10 / cfm;
950 dscale = (float)Math.Sqrt(dscale);
951 if (dscale > 1.0f)
952 dscale = 1.0f;
953 erpscale = cfm * 0.01f;
954 cfm = 0.0001f / cfm;
955 if (cfm > 0.01f)
956 cfm = 0.01f;
957 else if (cfm < 0.00001f)
958 cfm = 0.00001f;
959
960 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
961 {
962 if (curContact.side1 > 0)
963 IgnoreNegSides = true;
964 }
965
966 }
967 else if (name == "Water")
968 {
969 ignore = true;
970 }
971 }
972 else
973 ignore = true;
974 break;
975 }
976 break;
977
978 default:
979 if (geom_name_map.TryGetValue(g1, out name))
980 {
981 if (name == "Terrain")
982 {
983 if (p2.PhysicsActorType == (int)ActorTypes.Prim)
984 {
985 p2.CollidingGround = true;
986 p2.getContactData(ref contactdata2);
987 bounce = contactdata2.bounce * TerrainBounce;
988 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
989 912
990 cfm = p2.Mass; 913 case (int)ActorTypes.Ground:
991 dscale = 10 / cfm; 914 p1.getContactData(ref contactdata1);
992 dscale = (float)Math.Sqrt(dscale); 915 bounce = contactdata1.bounce * TerrainBounce;
993 916 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
994 if (dscale > 1.0f) 917 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
995 dscale = 1.0f; 918 mu *= frictionMovementMult;
919 p1.CollidingGround = true;
996 920
997 erpscale = cfm * 0.01f; 921 cfm = p1.Mass;
998 cfm = 0.0001f / cfm; 922 dscale = 10 / cfm;
999 if (cfm > 0.01f) 923 dscale = (float)Math.Sqrt(dscale);
1000 cfm = 0.01f; 924 if (dscale > 1.0f)
1001 else if (cfm < 0.00001f) 925 dscale = 1.0f;
1002 cfm = 0.00001f; 926 erpscale = cfm * 0.01f;
927 cfm = 0.0001f / cfm;
928 if (cfm > 0.01f)
929 cfm = 0.01f;
930 else if (cfm < 0.00001f)
931 cfm = 0.00001f;
1003 932
1004 if (curContact.side1 > 0) // should be 2 ? 933 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
934 {
935 if (curContact.side1 > 0)
1005 IgnoreNegSides = true; 936 IgnoreNegSides = true;
1006
1007 if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
1008 mu *= frictionMovementMult;
1009 } 937 }
1010 else 938 break;
1011 ignore = true;
1012 939
1013 } 940 case (int)ActorTypes.Water:
1014 else if (name == "Water" && 941 default:
1015 (p2.PhysicsActorType == (int)ActorTypes.Prim || p2.PhysicsActorType == (int)ActorTypes.Agent))
1016 {
1017 ignore = true; 942 ignore = true;
1018 } 943 break;
944 }
945 break;
946
947 case (int)ActorTypes.Ground:
948 if (p2.PhysicsActorType == (int)ActorTypes.Prim)
949 {
950 p2.CollidingGround = true;
951 p2.getContactData(ref contactdata2);
952 bounce = contactdata2.bounce * TerrainBounce;
953 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
954
955 cfm = p2.Mass;
956 dscale = 10 / cfm;
957 dscale = (float)Math.Sqrt(dscale);
958
959 if (dscale > 1.0f)
960 dscale = 1.0f;
961
962 erpscale = cfm * 0.01f;
963 cfm = 0.0001f / cfm;
964 if (cfm > 0.01f)
965 cfm = 0.01f;
966 else if (cfm < 0.00001f)
967 cfm = 0.00001f;
968
969 if (curContact.side1 > 0) // should be 2 ?
970 IgnoreNegSides = true;
971
972 if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
973 mu *= frictionMovementMult;
1019 } 974 }
1020 else 975 else
1021 ignore = true; 976 ignore = true;
1022 break; 977 break;
1023 }
1024 978
979 case (int)ActorTypes.Water:
980 default:
981 break;
982 }
1025 if (ignore) 983 if (ignore)
1026 return; 984 return;
1027 985
@@ -1162,36 +1120,23 @@ namespace OpenSim.Region.Physics.OdePlugin
1162 1120
1163 } 1121 }
1164 */ 1122 */
1165 } 1123 }
1166 1124
1167 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1125 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
1168 { 1126 {
1169
1170 OdeCharacter cc1;
1171 OdePrim cp1;
1172 OdeCharacter cc2;
1173 OdePrim cp2;
1174 OdePrim cp1Parent;
1175 OdePrim cp2Parent;
1176
1177 uint obj2LocalID = 0; 1127 uint obj2LocalID = 0;
1128
1178 bool p1events = p1.SubscribedEvents(); 1129 bool p1events = p1.SubscribedEvents();
1179 bool p2events = p2.SubscribedEvents(); 1130 bool p2events = p2.SubscribedEvents();
1180 1131
1181 if (p1.IsVolumeDtc) 1132 if (p1.IsVolumeDtc)
1182 p2events = false; 1133 p2events = false;
1183 if (p2.IsVolumeDtc) 1134 if (p2.IsVolumeDtc)
1184 p1events = false; 1135 p1events = false;
1185 1136
1186 if (!(p2events || p1events)) 1137 if (!p2events && !p1events)
1187 return; 1138 return;
1188 1139
1189 if (p1events)
1190 AddCollisionEventReporting(p1);
1191
1192 if (p2events)
1193 AddCollisionEventReporting(p2);
1194
1195 Vector3 vel = Vector3.Zero; 1140 Vector3 vel = Vector3.Zero;
1196 if (p2 != null && p2.IsPhysical) 1141 if (p2 != null && p2.IsPhysical)
1197 vel = p2.Velocity; 1142 vel = p2.Velocity;
@@ -1200,71 +1145,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1200 vel -= p1.Velocity; 1145 vel -= p1.Velocity;
1201 1146
1202 contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); 1147 contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal);
1203 1148
1204 switch ((ActorTypes)p1.PhysicsActorType) 1149 switch ((ActorTypes)p1.PhysicsActorType)
1205 { 1150 {
1206 case ActorTypes.Agent: 1151 case ActorTypes.Agent:
1207 cc1 = (OdeCharacter)p1;
1208 switch ((ActorTypes)p2.PhysicsActorType)
1209 {
1210 case ActorTypes.Agent:
1211 cc2 = (OdeCharacter)p2;
1212 obj2LocalID = cc2.LocalID;
1213 if (p2events)
1214 cc2.AddCollisionEvent(cc1.LocalID, contact);
1215 break;
1216
1217 case ActorTypes.Prim:
1218 if (p2 is OdePrim)
1219 {
1220 cp2 = (OdePrim)p2;
1221 if (p2events)
1222 cp2.AddCollisionEvent(cc1.LocalID, contact);
1223 cp2 = cp2.Parent;
1224 obj2LocalID = cp2.LocalID;
1225 }
1226 break;
1227
1228 case ActorTypes.Ground:
1229 case ActorTypes.Unknown:
1230 default:
1231 obj2LocalID = 0;
1232 break;
1233 }
1234 if (p1events)
1235 {
1236 contact.SurfaceNormal = -contact.SurfaceNormal;
1237 cc1.AddCollisionEvent(obj2LocalID, contact);
1238 }
1239 break;
1240
1241 case ActorTypes.Prim: 1152 case ActorTypes.Prim:
1242 1153 {
1243 if (p1 is OdePrim)
1244 {
1245 cp1 = (OdePrim)p1;
1246 cp1Parent = cp1.Parent;
1247 switch ((ActorTypes)p2.PhysicsActorType) 1154 switch ((ActorTypes)p2.PhysicsActorType)
1248 { 1155 {
1249 case ActorTypes.Agent: 1156 case ActorTypes.Agent:
1250 if (p2 is OdeCharacter)
1251 {
1252 cc2 = (OdeCharacter)p2;
1253 obj2LocalID = cc2.LocalID;
1254 if (p2events)
1255 cc2.AddCollisionEvent(cp1Parent.LocalID, contact);
1256 }
1257 break;
1258 case ActorTypes.Prim: 1157 case ActorTypes.Prim:
1259 1158 if (p2events)
1260 if (p2 is OdePrim) 1159 {
1261 { 1160 AddCollisionEventReporting(p2);
1262 cp2 = (OdePrim)p2; 1161 p2.AddCollisionEvent(p1.ParentActor.LocalID, contact);
1263 if (p2events) 1162 }
1264 cp2.AddCollisionEvent(cp1Parent.LocalID, contact); 1163 obj2LocalID = p2.ParentActor.LocalID;
1265 cp2 = cp2.Parent;
1266 obj2LocalID = cp2.LocalID;
1267 }
1268 break; 1164 break;
1269 1165
1270 case ActorTypes.Ground: 1166 case ActorTypes.Ground:
@@ -1272,41 +1168,28 @@ namespace OpenSim.Region.Physics.OdePlugin
1272 default: 1168 default:
1273 obj2LocalID = 0; 1169 obj2LocalID = 0;
1274 break; 1170 break;
1275 } 1171 }
1276 if (p1events) 1172 if (p1events)
1277 { 1173 {
1278 contact.SurfaceNormal = -contact.SurfaceNormal; 1174 contact.SurfaceNormal = -contact.SurfaceNormal;
1279 cp1.AddCollisionEvent(obj2LocalID, contact); 1175 AddCollisionEventReporting(p1);
1280 } 1176 p1.AddCollisionEvent(obj2LocalID, contact);
1281 } 1177 }
1282 break; 1178 break;
1179 }
1283 case ActorTypes.Ground: 1180 case ActorTypes.Ground:
1284 case ActorTypes.Unknown: 1181 case ActorTypes.Unknown:
1285 default: 1182 default:
1286 switch ((ActorTypes)p2.PhysicsActorType) 1183 {
1184 if (p2events && !p2.IsVolumeDtc)
1287 { 1185 {
1288 case ActorTypes.Agent: 1186 AddCollisionEventReporting(p2);
1289 if (p2 is OdeCharacter) 1187 p2.AddCollisionEvent(0, contact);
1290 {
1291 cc2 = (OdeCharacter)p2;
1292 obj2LocalID = cc2.LocalID;
1293 if (p2events)
1294 cc2.AddCollisionEvent(0, contact);
1295 }
1296 break;
1297 case ActorTypes.Prim:
1298 if (p2 is OdePrim)
1299 {
1300 cp2 = (OdePrim)p2;
1301 obj2LocalID = cp2.LocalID;
1302 if (p2events)
1303 cp2.AddCollisionEvent(0, contact);
1304 }
1305 break;
1306 } 1188 }
1307 break; 1189 break;
1308 } 1190 }
1309 } 1191 }
1192 }
1310 1193
1311 /// <summary> 1194 /// <summary>
1312 /// This is our collision testing routine in ODE 1195 /// This is our collision testing routine in ODE
@@ -2369,6 +2252,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2369 RegionTerrain.Remove(pOffset); 2252 RegionTerrain.Remove(pOffset);
2370 if (GroundGeom != IntPtr.Zero) 2253 if (GroundGeom != IntPtr.Zero)
2371 { 2254 {
2255 actor_name_map.Remove(GroundGeom);
2372 d.GeomDestroy(GroundGeom); 2256 d.GeomDestroy(GroundGeom);
2373 2257
2374 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) 2258 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
@@ -2394,27 +2278,32 @@ namespace OpenSim.Region.Physics.OdePlugin
2394 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); 2278 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land));
2395 d.GeomSetCollideBits(GroundGeom, 0); 2279 d.GeomSetCollideBits(GroundGeom, 0);
2396 2280
2397 } 2281 PhysicsActor pa = new NullPhysicsActor();
2398 geom_name_map[GroundGeom] = "Terrain"; 2282 pa.Name = "Terrain";
2283 pa.PhysicsActorType = (int)ActorTypes.Ground;
2284 actor_name_map[GroundGeom] = pa;
2399 2285
2400 d.Matrix3 R = new d.Matrix3(); 2286// geom_name_map[GroundGeom] = "Terrain";
2401 2287
2402 Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); 2288 d.Matrix3 R = new d.Matrix3();
2403 Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f);
2404
2405 2289
2406 q1 = q1 * q2; 2290 Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f);
2407 2291 Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f);
2408 Vector3 v3; 2292
2409 float angle; 2293
2410 q1.GetAxisAngle(out v3, out angle); 2294 q1 = q1 * q2;
2411 2295
2412 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2296 Vector3 v3;
2413 d.GeomSetRotation(GroundGeom, ref R); 2297 float angle;
2414 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2298 q1.GetAxisAngle(out v3, out angle);
2415 RegionTerrain.Add(pOffset, GroundGeom); 2299
2416 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2300 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
2417 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2301 d.GeomSetRotation(GroundGeom, ref R);
2302 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2303 RegionTerrain.Add(pOffset, GroundGeom);
2304 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2305 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2306 }
2418 } 2307 }
2419 } 2308 }
2420 2309
@@ -2478,6 +2367,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2478 RegionTerrain.Remove(pOffset); 2367 RegionTerrain.Remove(pOffset);
2479 if (GroundGeom != IntPtr.Zero) 2368 if (GroundGeom != IntPtr.Zero)
2480 { 2369 {
2370 actor_name_map.Remove(GroundGeom);
2481 d.GeomDestroy(GroundGeom); 2371 d.GeomDestroy(GroundGeom);
2482 2372
2483 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) 2373 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
@@ -2509,13 +2399,18 @@ namespace OpenSim.Region.Physics.OdePlugin
2509 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); 2399 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land));
2510 d.GeomSetCollideBits(GroundGeom, 0); 2400 d.GeomSetCollideBits(GroundGeom, 0);
2511 2401
2512 } 2402 PhysicsActor pa = new NullPhysicsActor();
2513 geom_name_map[GroundGeom] = "Terrain"; 2403 pa.Name = "Terrain";
2404 pa.PhysicsActorType = (int)ActorTypes.Ground;
2405 actor_name_map[GroundGeom] = pa;
2406
2407// geom_name_map[GroundGeom] = "Terrain";
2514 2408
2515 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2409 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2516 RegionTerrain.Add(pOffset, GroundGeom); 2410 RegionTerrain.Add(pOffset, GroundGeom);
2517 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2411 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2518 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2412 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2413 }
2519 } 2414 }
2520 } 2415 }
2521 2416
@@ -2596,9 +2491,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2596 public override void SetWaterLevel(float baseheight) 2491 public override void SetWaterLevel(float baseheight)
2597 { 2492 {
2598 waterlevel = baseheight; 2493 waterlevel = baseheight;
2599 randomizeWater(waterlevel); 2494// randomizeWater(waterlevel);
2600 } 2495 }
2601 2496/*
2602 public void randomizeWater(float baseheight) 2497 public void randomizeWater(float baseheight)
2603 { 2498 {
2604 const uint heightmapWidth = Constants.RegionSize + 2; 2499 const uint heightmapWidth = Constants.RegionSize + 2;
@@ -2632,6 +2527,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2632 { 2527 {
2633 if (WaterGeom != IntPtr.Zero) 2528 if (WaterGeom != IntPtr.Zero)
2634 { 2529 {
2530 actor_name_map.Remove(WaterGeom);
2635 d.GeomDestroy(WaterGeom); 2531 d.GeomDestroy(WaterGeom);
2636 d.GeomHeightfieldDataDestroy(WaterHeightmapData); 2532 d.GeomHeightfieldDataDestroy(WaterHeightmapData);
2637 WaterGeom = IntPtr.Zero; 2533 WaterGeom = IntPtr.Zero;
@@ -2654,7 +2550,13 @@ namespace OpenSim.Region.Physics.OdePlugin
2654 d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water)); 2550 d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water));
2655 d.GeomSetCollideBits(WaterGeom, 0); 2551 d.GeomSetCollideBits(WaterGeom, 0);
2656 2552
2657 geom_name_map[WaterGeom] = "Water"; 2553
2554 PhysicsActor pa = new NullPhysicsActor();
2555 pa.Name = "Water";
2556 pa.PhysicsActorType = (int)ActorTypes.Water;
2557
2558 actor_name_map[WaterGeom] = pa;
2559// geom_name_map[WaterGeom] = "Water";
2658 2560
2659 d.Matrix3 R = new d.Matrix3(); 2561 d.Matrix3 R = new d.Matrix3();
2660 2562
@@ -2672,7 +2574,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2672 } 2574 }
2673 } 2575 }
2674 } 2576 }
2675 2577*/
2676 public override void Dispose() 2578 public override void Dispose()
2677 { 2579 {
2678 lock (OdeLock) 2580 lock (OdeLock)
@@ -2722,7 +2624,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2722 2624
2723 TerrainHeightFieldHeightsHandlers.Clear(); 2625 TerrainHeightFieldHeightsHandlers.Clear();
2724 TerrainHeightFieldHeights.Clear(); 2626 TerrainHeightFieldHeights.Clear();
2725 2627/*
2726 if (WaterGeom != IntPtr.Zero) 2628 if (WaterGeom != IntPtr.Zero)
2727 { 2629 {
2728 d.GeomDestroy(WaterGeom); 2630 d.GeomDestroy(WaterGeom);
@@ -2734,7 +2636,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2734 if (WaterMapHandler.IsAllocated) 2636 if (WaterMapHandler.IsAllocated)
2735 WaterMapHandler.Free(); 2637 WaterMapHandler.Free();
2736 } 2638 }
2737 2639*/
2738 if (ContactgeomsArray != IntPtr.Zero) 2640 if (ContactgeomsArray != IntPtr.Zero)
2739 Marshal.FreeHGlobal(ContactgeomsArray); 2641 Marshal.FreeHGlobal(ContactgeomsArray);
2740 if (GlobalContactsArray != IntPtr.Zero) 2642 if (GlobalContactsArray != IntPtr.Zero)