diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 261 |
1 files changed, 146 insertions, 115 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 6e4c373..14516f9 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -155,7 +155,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
155 | private readonly ILog m_log; | 155 | private readonly ILog m_log; |
156 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); | 156 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); |
157 | 157 | ||
158 | private int threadid = 0; | 158 | // private int threadid = 0; |
159 | private Random fluidRandomizer = new Random(Environment.TickCount); | 159 | private Random fluidRandomizer = new Random(Environment.TickCount); |
160 | 160 | ||
161 | const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; | 161 | const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; |
@@ -163,12 +163,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
163 | const float comumSoftContactERP = 0.1f; | 163 | const float comumSoftContactERP = 0.1f; |
164 | const float comumContactCFM = 0.0001f; | 164 | const float comumContactCFM = 0.0001f; |
165 | 165 | ||
166 | float frictionScale = 1.0f; | ||
167 | |||
168 | float frictionMovementMult = 0.3f; | 166 | float frictionMovementMult = 0.3f; |
169 | 167 | ||
170 | float TerrainBounce = 0.1f; | 168 | float TerrainBounce = 0.1f; |
171 | float TerrainFriction = 0.1f; | 169 | float TerrainFriction = 0.3f; |
172 | 170 | ||
173 | public float AvatarBounce = 0.3f; | 171 | public float AvatarBounce = 0.3f; |
174 | public float AvatarFriction = 0;// 0.9f * 0.5f; | 172 | public float AvatarFriction = 0;// 0.9f * 0.5f; |
@@ -189,8 +187,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
189 | 187 | ||
190 | internal IntPtr WaterGeom; | 188 | internal IntPtr WaterGeom; |
191 | 189 | ||
192 | public float avPIDD = 3200f; // make it visible | 190 | public float avPIDD = 2200f; // make it visible |
193 | public float avPIDP = 1400f; // make it visible | 191 | public float avPIDP = 900f; // make it visible |
194 | private float avCapRadius = 0.37f; | 192 | private float avCapRadius = 0.37f; |
195 | private float avDensity = 3f; | 193 | private float avDensity = 3f; |
196 | private float avMovementDivisorWalk = 1.3f; | 194 | private float avMovementDivisorWalk = 1.3f; |
@@ -202,7 +200,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
202 | public bool forceSimplePrimMeshing = false; | 200 | public bool forceSimplePrimMeshing = false; |
203 | 201 | ||
204 | public float meshSculptLOD = 32; | 202 | public float meshSculptLOD = 32; |
205 | public float MeshSculptphysicalLOD = 16; | 203 | public float MeshSculptphysicalLOD = 32; |
206 | 204 | ||
207 | public float geomDefaultDensity = 10.000006836f; | 205 | public float geomDefaultDensity = 10.000006836f; |
208 | 206 | ||
@@ -212,18 +210,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
212 | public float bodyPIDD = 35f; | 210 | public float bodyPIDD = 35f; |
213 | public float bodyPIDG = 25; | 211 | public float bodyPIDG = 25; |
214 | 212 | ||
215 | public int geomCrossingFailuresBeforeOutofbounds = 6; | 213 | // public int geomCrossingFailuresBeforeOutofbounds = 6; |
216 | 214 | ||
217 | public int bodyFramesAutoDisable = 20; | 215 | public int bodyFramesAutoDisable = 20; |
218 | 216 | ||
219 | private float[] _watermap; | 217 | private float[] _watermap; |
220 | private bool m_filterCollisions = true; | ||
221 | 218 | ||
222 | private d.NearCallback nearCallback; | 219 | private d.NearCallback nearCallback; |
223 | 220 | ||
224 | private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); | 221 | private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); |
225 | private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); | 222 | private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); |
226 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); | 223 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); |
224 | private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>(); | ||
227 | 225 | ||
228 | public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); | 226 | public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); |
229 | 227 | ||
@@ -387,9 +385,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
387 | 385 | ||
388 | // Defaults | 386 | // Defaults |
389 | 387 | ||
390 | avPIDD = 2200.0f; | ||
391 | avPIDP = 900.0f; | ||
392 | |||
393 | int contactsPerCollision = 80; | 388 | int contactsPerCollision = 80; |
394 | 389 | ||
395 | if (m_config != null) | 390 | if (m_config != null) |
@@ -397,90 +392,86 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
397 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; | 392 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; |
398 | if (physicsconfig != null) | 393 | if (physicsconfig != null) |
399 | { | 394 | { |
400 | gravityx = physicsconfig.GetFloat("world_gravityx", 0f); | 395 | gravityx = physicsconfig.GetFloat("world_gravityx", gravityx); |
401 | gravityy = physicsconfig.GetFloat("world_gravityy", 0f); | 396 | gravityy = physicsconfig.GetFloat("world_gravityy", gravityy); |
402 | gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); | 397 | gravityz = physicsconfig.GetFloat("world_gravityz", gravityz); |
403 | 398 | ||
404 | metersInSpace = physicsconfig.GetFloat("meters_in_small_space", 29.9f); | 399 | metersInSpace = physicsconfig.GetFloat("meters_in_small_space", metersInSpace); |
405 | 400 | ||
406 | contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer); | 401 | contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer); |
407 | 402 | ||
408 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f); | 403 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE); |
409 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10); | 404 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", m_physicsiterations); |
410 | 405 | ||
411 | avDensity = physicsconfig.GetFloat("av_density", avDensity); | 406 | avDensity = physicsconfig.GetFloat("av_density", avDensity); |
412 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); | 407 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); |
413 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); | 408 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); |
414 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); | 409 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", avCapRadius); |
415 | 410 | ||
416 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); | 411 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); |
417 | 412 | ||
418 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); | 413 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); |
419 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); | 414 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); |
420 | geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); | 415 | // geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); |
421 | 416 | ||
422 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f); | 417 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); |
423 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20); | 418 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); |
424 | 419 | ||
425 | bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f); | 420 | bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", bodyPIDD); |
426 | bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f); | 421 | bodyPIDG = physicsconfig.GetFloat("body_pid_gain", bodyPIDG); |
427 | 422 | ||
428 | forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing); | 423 | forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing); |
429 | meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true); | 424 | meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", meshSculptedPrim); |
430 | meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f); | 425 | meshSculptLOD = physicsconfig.GetFloat("mesh_lod", meshSculptLOD); |
431 | MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f); | 426 | MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", MeshSculptphysicalLOD); |
432 | m_filterCollisions = physicsconfig.GetBoolean("filter_collisions", false); | ||
433 | 427 | ||
434 | if (Environment.OSVersion.Platform == PlatformID.Unix) | 428 | if (Environment.OSVersion.Platform == PlatformID.Unix) |
435 | { | 429 | { |
436 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f); | 430 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", avPIDD); |
437 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f); | 431 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", avPIDP); |
438 | } | 432 | } |
439 | else | 433 | else |
440 | { | 434 | { |
441 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); | 435 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", avPIDD); |
442 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); | 436 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", avPIDP); |
443 | } | 437 | } |
444 | 438 | ||
445 | physics_logging = physicsconfig.GetBoolean("physics_logging", false); | 439 | physics_logging = physicsconfig.GetBoolean("physics_logging", false); |
446 | physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); | 440 | physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); |
447 | physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); | 441 | physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); |
448 | 442 | ||
449 | minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); | 443 | minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", minimumGroundFlightOffset); |
450 | maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f); | 444 | maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", maximumMassObject); |
451 | } | 445 | } |
452 | } | 446 | } |
453 | 447 | ||
454 | ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); | 448 | ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); |
455 | GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); | 449 | GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); |
456 | 450 | ||
457 | m_materialContactsData[(int)Material.Stone].mu = frictionScale * 0.8f; | 451 | m_materialContactsData[(int)Material.Stone].mu = 0.8f; |
458 | m_materialContactsData[(int)Material.Stone].bounce = 0.4f; | 452 | m_materialContactsData[(int)Material.Stone].bounce = 0.4f; |
459 | 453 | ||
460 | m_materialContactsData[(int)Material.Metal].mu = frictionScale * 0.3f; | 454 | m_materialContactsData[(int)Material.Metal].mu = 0.3f; |
461 | m_materialContactsData[(int)Material.Metal].bounce = 0.4f; | 455 | m_materialContactsData[(int)Material.Metal].bounce = 0.4f; |
462 | 456 | ||
463 | m_materialContactsData[(int)Material.Glass].mu = frictionScale * 0.2f; | 457 | m_materialContactsData[(int)Material.Glass].mu = 0.2f; |
464 | m_materialContactsData[(int)Material.Glass].bounce = 0.7f; | 458 | m_materialContactsData[(int)Material.Glass].bounce = 0.7f; |
465 | 459 | ||
466 | m_materialContactsData[(int)Material.Wood].mu = frictionScale * 0.6f; | 460 | m_materialContactsData[(int)Material.Wood].mu = 0.6f; |
467 | m_materialContactsData[(int)Material.Wood].bounce = 0.5f; | 461 | m_materialContactsData[(int)Material.Wood].bounce = 0.5f; |
468 | 462 | ||
469 | m_materialContactsData[(int)Material.Flesh].mu = frictionScale * 0.9f; | 463 | m_materialContactsData[(int)Material.Flesh].mu = 0.9f; |
470 | m_materialContactsData[(int)Material.Flesh].bounce = 0.3f; | 464 | m_materialContactsData[(int)Material.Flesh].bounce = 0.3f; |
471 | 465 | ||
472 | m_materialContactsData[(int)Material.Plastic].mu = frictionScale * 0.4f; | 466 | m_materialContactsData[(int)Material.Plastic].mu = 0.4f; |
473 | m_materialContactsData[(int)Material.Plastic].bounce = 0.7f; | 467 | m_materialContactsData[(int)Material.Plastic].bounce = 0.7f; |
474 | 468 | ||
475 | m_materialContactsData[(int)Material.Rubber].mu = frictionScale * 0.9f; | 469 | m_materialContactsData[(int)Material.Rubber].mu = 0.9f; |
476 | m_materialContactsData[(int)Material.Rubber].bounce = 0.95f; | 470 | m_materialContactsData[(int)Material.Rubber].bounce = 0.95f; |
477 | 471 | ||
478 | m_materialContactsData[(int)Material.light].mu = 0.0f; | 472 | m_materialContactsData[(int)Material.light].mu = 0.0f; |
479 | m_materialContactsData[(int)Material.light].bounce = 0.0f; | 473 | m_materialContactsData[(int)Material.light].bounce = 0.0f; |
480 | 474 | ||
481 | TerrainFriction *= frictionScale; | ||
482 | // AvatarFriction *= frictionScale; | ||
483 | |||
484 | // Set the gravity,, don't disable things automatically (we set it explicitly on some things) | 475 | // Set the gravity,, don't disable things automatically (we set it explicitly on some things) |
485 | 476 | ||
486 | d.WorldSetGravity(world, gravityx, gravityy, gravityz); | 477 | d.WorldSetGravity(world, gravityx, gravityy, gravityz); |
@@ -566,13 +557,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
566 | } | 557 | } |
567 | 558 | ||
568 | 559 | ||
569 | /// <summary> | ||
570 | /// This is our near callback. A geometry is near a body | ||
571 | /// </summary> | ||
572 | /// <param name="space">The space that contains the geoms. Remember, spaces are also geoms</param> | ||
573 | /// <param name="g1">a geometry or space</param> | ||
574 | /// <param name="g2">another geometry or space</param> | ||
575 | /// | ||
576 | 560 | ||
577 | private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) | 561 | private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) |
578 | { | 562 | { |
@@ -584,7 +568,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
584 | return true; | 568 | return true; |
585 | } | 569 | } |
586 | 570 | ||
587 | 571 | /// <summary> | |
572 | /// This is our near callback. A geometry is near a body | ||
573 | /// </summary> | ||
574 | /// <param name="space">The space that contains the geoms. Remember, spaces are also geoms</param> | ||
575 | /// <param name="g1">a geometry or space</param> | ||
576 | /// <param name="g2">another geometry or space</param> | ||
577 | /// | ||
588 | 578 | ||
589 | private void near(IntPtr space, IntPtr g1, IntPtr g2) | 579 | private void near(IntPtr space, IntPtr g1, IntPtr g2) |
590 | { | 580 | { |
@@ -703,8 +693,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
703 | // big messy collision analises | 693 | // big messy collision analises |
704 | float mu = 0; | 694 | float mu = 0; |
705 | float bounce = 0; | 695 | float bounce = 0; |
706 | ContactData contactdata1; | 696 | ContactData contactdata1 = new ContactData(0, 0, false); |
707 | ContactData contactdata2; | 697 | ContactData contactdata2 = new ContactData(0, 0, false); |
708 | bool erpSoft = false; | 698 | bool erpSoft = false; |
709 | 699 | ||
710 | String name = null; | 700 | String name = null; |
@@ -718,8 +708,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
718 | switch (p2.PhysicsActorType) | 708 | switch (p2.PhysicsActorType) |
719 | { | 709 | { |
720 | case (int)ActorTypes.Agent: | 710 | case (int)ActorTypes.Agent: |
721 | contactdata1 = p1.ContactData; | 711 | p1.getContactData(ref contactdata1); |
722 | contactdata2 = p2.ContactData; | 712 | p2.getContactData(ref contactdata2); |
713 | |||
723 | bounce = contactdata1.bounce * contactdata2.bounce; | 714 | bounce = contactdata1.bounce * contactdata2.bounce; |
724 | 715 | ||
725 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | 716 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); |
@@ -727,12 +718,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
727 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | 718 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) |
728 | mu *= frictionMovementMult; | 719 | mu *= frictionMovementMult; |
729 | 720 | ||
721 | erpSoft = contactdata1.softcolide | contactdata2.softcolide; | ||
730 | p1.CollidingObj = true; | 722 | p1.CollidingObj = true; |
731 | p2.CollidingObj = true; | 723 | p2.CollidingObj = true; |
732 | break; | 724 | break; |
733 | case (int)ActorTypes.Prim: | 725 | case (int)ActorTypes.Prim: |
734 | contactdata1 = p1.ContactData; | 726 | p1.getContactData(ref contactdata1); |
735 | contactdata2 = p2.ContactData; | 727 | p2.getContactData(ref contactdata2); |
736 | bounce = contactdata1.bounce * contactdata2.bounce; | 728 | bounce = contactdata1.bounce * contactdata2.bounce; |
737 | 729 | ||
738 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | 730 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); |
@@ -741,6 +733,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
741 | mu *= frictionMovementMult; | 733 | mu *= frictionMovementMult; |
742 | if (p2.Velocity.LengthSquared() > 0.0f) | 734 | if (p2.Velocity.LengthSquared() > 0.0f) |
743 | p2.CollidingObj = true; | 735 | p2.CollidingObj = true; |
736 | |||
737 | erpSoft = contactdata1.softcolide | contactdata2.softcolide; | ||
738 | |||
744 | dop1foot = true; | 739 | dop1foot = true; |
745 | break; | 740 | break; |
746 | default: | 741 | default: |
@@ -753,8 +748,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
753 | switch (p2.PhysicsActorType) | 748 | switch (p2.PhysicsActorType) |
754 | { | 749 | { |
755 | case (int)ActorTypes.Agent: | 750 | case (int)ActorTypes.Agent: |
756 | contactdata1 = p1.ContactData; | 751 | p1.getContactData(ref contactdata1); |
757 | contactdata2 = p2.ContactData; | 752 | p2.getContactData(ref contactdata2); |
758 | bounce = contactdata1.bounce * contactdata2.bounce; | 753 | bounce = contactdata1.bounce * contactdata2.bounce; |
759 | 754 | ||
760 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | 755 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); |
@@ -762,6 +757,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
762 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | 757 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) |
763 | mu *= frictionMovementMult; | 758 | mu *= frictionMovementMult; |
764 | 759 | ||
760 | erpSoft = contactdata1.softcolide | contactdata2.softcolide; | ||
765 | dop2foot = true; | 761 | dop2foot = true; |
766 | if (p1.Velocity.LengthSquared() > 0.0f) | 762 | if (p1.Velocity.LengthSquared() > 0.0f) |
767 | p1.CollidingObj = true; | 763 | p1.CollidingObj = true; |
@@ -772,10 +768,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
772 | p1.CollidingObj = true; | 768 | p1.CollidingObj = true; |
773 | p2.CollidingObj = true; | 769 | p2.CollidingObj = true; |
774 | } | 770 | } |
775 | contactdata1 = p1.ContactData; | 771 | p1.getContactData(ref contactdata1); |
776 | contactdata2 = p2.ContactData; | 772 | p2.getContactData(ref contactdata2); |
777 | bounce = contactdata1.bounce * contactdata2.bounce; | 773 | bounce = contactdata1.bounce * contactdata2.bounce; |
778 | erpSoft = true; | 774 | erpSoft = contactdata1.softcolide | contactdata2.softcolide; |
779 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | 775 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); |
780 | 776 | ||
781 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | 777 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) |
@@ -787,12 +783,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
787 | { | 783 | { |
788 | if (name == "Terrain") | 784 | if (name == "Terrain") |
789 | { | 785 | { |
790 | erpSoft = true; | 786 | p1.getContactData(ref contactdata1); |
791 | contactdata1 = p1.ContactData; | ||
792 | bounce = contactdata1.bounce * TerrainBounce; | 787 | bounce = contactdata1.bounce * TerrainBounce; |
793 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); | 788 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); |
794 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) | 789 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) |
795 | mu *= frictionMovementMult; | 790 | mu *= frictionMovementMult; |
791 | erpSoft = contactdata1.softcolide; | ||
796 | p1.CollidingGround = true; | 792 | p1.CollidingGround = true; |
797 | } | 793 | } |
798 | else if (name == "Water") | 794 | else if (name == "Water") |
@@ -813,11 +809,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
813 | { | 809 | { |
814 | if (p2.PhysicsActorType == (int)ActorTypes.Prim) | 810 | if (p2.PhysicsActorType == (int)ActorTypes.Prim) |
815 | { | 811 | { |
816 | erpSoft = true; | ||
817 | p2.CollidingGround = true; | 812 | p2.CollidingGround = true; |
818 | contactdata2 = p2.ContactData; | 813 | p2.getContactData(ref contactdata2); |
819 | bounce = contactdata2.bounce * TerrainBounce; | 814 | bounce = contactdata2.bounce * TerrainBounce; |
820 | mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); | 815 | mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); |
816 | erpSoft = contactdata2.softcolide; | ||
821 | 817 | ||
822 | if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) | 818 | if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) |
823 | mu *= frictionMovementMult; | 819 | mu *= frictionMovementMult; |
@@ -1013,15 +1009,24 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1013 | 1009 | ||
1014 | } | 1010 | } |
1015 | 1011 | ||
1016 | // collide active prims with static enviroment | ||
1017 | lock (_activeprims) | 1012 | lock (_activeprims) |
1018 | { | 1013 | { |
1014 | foreach (OdePrim aprim in _activeprims) | ||
1015 | { | ||
1016 | aprim.CollisionScore = 0; | ||
1017 | aprim.IsColliding = false; | ||
1018 | } | ||
1019 | } | ||
1020 | |||
1021 | // collide active prims with static enviroment | ||
1022 | lock (_activegroups) | ||
1023 | { | ||
1019 | try | 1024 | try |
1020 | { | 1025 | { |
1021 | foreach (OdePrim prm in _activeprims) | 1026 | foreach (OdePrim prm in _activegroups) |
1022 | { | 1027 | { |
1023 | if (d.BodyIsEnabled(prm.Body)) | 1028 | if (d.BodyIsEnabled(prm.Body) && !prm.m_outbounds) |
1024 | d.SpaceCollide2(StaticSpace, prm.prim_geom, IntPtr.Zero, nearCallback); | 1029 | d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback); |
1025 | } | 1030 | } |
1026 | } | 1031 | } |
1027 | catch (AccessViolationException) | 1032 | catch (AccessViolationException) |
@@ -1029,7 +1034,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1029 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); | 1034 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); |
1030 | } | 1035 | } |
1031 | } | 1036 | } |
1032 | |||
1033 | // finally colide active things amoung them | 1037 | // finally colide active things amoung them |
1034 | try | 1038 | try |
1035 | { | 1039 | { |
@@ -1039,7 +1043,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1039 | { | 1043 | { |
1040 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); | 1044 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); |
1041 | } | 1045 | } |
1042 | |||
1043 | // _perloopContact.Clear(); | 1046 | // _perloopContact.Clear(); |
1044 | } | 1047 | } |
1045 | 1048 | ||
@@ -1148,13 +1151,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1148 | 1151 | ||
1149 | public void addActivePrim(OdePrim activatePrim) | 1152 | public void addActivePrim(OdePrim activatePrim) |
1150 | { | 1153 | { |
1151 | // adds active prim.. (ones that should be iterated over in collisions_optimized | 1154 | // adds active prim.. |
1152 | lock (_activeprims) | 1155 | lock (_activeprims) |
1153 | { | 1156 | { |
1154 | if (!_activeprims.Contains(activatePrim)) | 1157 | if (!_activeprims.Contains(activatePrim)) |
1155 | _activeprims.Add(activatePrim); | 1158 | _activeprims.Add(activatePrim); |
1156 | //else | 1159 | } |
1157 | // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); | 1160 | } |
1161 | |||
1162 | public void addActiveGroups(OdePrim activatePrim) | ||
1163 | { | ||
1164 | lock (_activegroups) | ||
1165 | { | ||
1166 | if (!_activegroups.Contains(activatePrim)) | ||
1167 | _activegroups.Add(activatePrim); | ||
1158 | } | 1168 | } |
1159 | } | 1169 | } |
1160 | 1170 | ||
@@ -1186,6 +1196,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1186 | _activeprims.Remove(deactivatePrim); | 1196 | _activeprims.Remove(deactivatePrim); |
1187 | } | 1197 | } |
1188 | } | 1198 | } |
1199 | public void remActiveGroup(OdePrim deactivatePrim) | ||
1200 | { | ||
1201 | lock (_activegroups) | ||
1202 | { | ||
1203 | _activegroups.Remove(deactivatePrim); | ||
1204 | } | ||
1205 | } | ||
1189 | 1206 | ||
1190 | public override void RemovePrim(PhysicsActor prim) | 1207 | public override void RemovePrim(PhysicsActor prim) |
1191 | { | 1208 | { |
@@ -1258,6 +1275,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1258 | { | 1275 | { |
1259 | waitForSpaceUnlock(currentspace); | 1276 | waitForSpaceUnlock(currentspace); |
1260 | d.SpaceRemove(currentspace, geom); | 1277 | d.SpaceRemove(currentspace, geom); |
1278 | |||
1279 | if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0) | ||
1280 | { | ||
1281 | d.SpaceDestroy(currentspace); | ||
1282 | } | ||
1261 | } | 1283 | } |
1262 | else | 1284 | else |
1263 | { | 1285 | { |
@@ -1274,6 +1296,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1274 | { | 1296 | { |
1275 | waitForSpaceUnlock(currentspace); | 1297 | waitForSpaceUnlock(currentspace); |
1276 | d.SpaceRemove(currentspace, geom); | 1298 | d.SpaceRemove(currentspace, geom); |
1299 | |||
1300 | if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0) | ||
1301 | { | ||
1302 | d.SpaceDestroy(currentspace); | ||
1303 | } | ||
1304 | |||
1277 | } | 1305 | } |
1278 | } | 1306 | } |
1279 | } | 1307 | } |
@@ -1577,42 +1605,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1577 | 1605 | ||
1578 | statchanges += Util.EnvironmentTickCountSubtract(statstart); | 1606 | statchanges += Util.EnvironmentTickCountSubtract(statstart); |
1579 | 1607 | ||
1580 | // Move characters | ||
1581 | lock (_characters) | ||
1582 | { | ||
1583 | List<OdeCharacter> defects = new List<OdeCharacter>(); | ||
1584 | foreach (OdeCharacter actor in _characters) | ||
1585 | { | ||
1586 | if (actor != null) | ||
1587 | actor.Move(ODE_STEPSIZE, defects); | ||
1588 | } | ||
1589 | if (defects.Count != 0) | ||
1590 | { | ||
1591 | foreach (OdeCharacter defect in defects) | ||
1592 | { | ||
1593 | RemoveCharacter(defect); | ||
1594 | } | ||
1595 | } | ||
1596 | } | ||
1597 | statchmove += Util.EnvironmentTickCountSubtract(statstart); | ||
1598 | |||
1599 | // Move other active objects | ||
1600 | lock (_activeprims) | ||
1601 | { | ||
1602 | foreach (OdePrim aprim in _activeprims) | ||
1603 | { | ||
1604 | aprim.CollisionScore = 0; | ||
1605 | aprim.IsColliding = false; | ||
1606 | aprim.Move(); | ||
1607 | } | ||
1608 | } | ||
1609 | |||
1610 | statactmove += Util.EnvironmentTickCountSubtract(statstart); | 1608 | statactmove += Util.EnvironmentTickCountSubtract(statstart); |
1611 | //if ((framecount % m_randomizeWater) == 0) | 1609 | //if ((framecount % m_randomizeWater) == 0) |
1612 | // randomizeWater(waterlevel); | 1610 | // randomizeWater(waterlevel); |
1613 | 1611 | ||
1614 | m_rayCastManager.ProcessQueuedRequests(); | 1612 | m_rayCastManager.ProcessQueuedRequests(); |
1615 | 1613 | ||
1614 | |||
1615 | |||
1616 | statray += Util.EnvironmentTickCountSubtract(statstart); | 1616 | statray += Util.EnvironmentTickCountSubtract(statstart); |
1617 | collision_optimized(); | 1617 | collision_optimized(); |
1618 | statcol += Util.EnvironmentTickCountSubtract(statstart); | 1618 | statcol += Util.EnvironmentTickCountSubtract(statstart); |
@@ -1642,8 +1642,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1642 | 1642 | ||
1643 | d.WorldQuickStep(world, ODE_STEPSIZE); | 1643 | d.WorldQuickStep(world, ODE_STEPSIZE); |
1644 | statstep += Util.EnvironmentTickCountSubtract(statstart); | 1644 | statstep += Util.EnvironmentTickCountSubtract(statstart); |
1645 | d.JointGroupEmpty(contactgroup); | 1645 | |
1646 | totjcontact += m_global_contactcount; | 1646 | // Move characters |
1647 | lock (_characters) | ||
1648 | { | ||
1649 | List<OdeCharacter> defects = new List<OdeCharacter>(); | ||
1650 | foreach (OdeCharacter actor in _characters) | ||
1651 | { | ||
1652 | if (actor != null) | ||
1653 | actor.Move(ODE_STEPSIZE, defects); | ||
1654 | } | ||
1655 | if (defects.Count != 0) | ||
1656 | { | ||
1657 | foreach (OdeCharacter defect in defects) | ||
1658 | { | ||
1659 | RemoveCharacter(defect); | ||
1660 | } | ||
1661 | } | ||
1662 | } | ||
1663 | statchmove += Util.EnvironmentTickCountSubtract(statstart); | ||
1664 | |||
1665 | // Move other active objects | ||
1666 | lock (_activegroups) | ||
1667 | { | ||
1668 | foreach (OdePrim aprim in _activegroups) | ||
1669 | { | ||
1670 | aprim.Move(); | ||
1671 | } | ||
1672 | } | ||
1673 | |||
1647 | //ode.dunlock(world); | 1674 | //ode.dunlock(world); |
1648 | } | 1675 | } |
1649 | catch (Exception e) | 1676 | catch (Exception e) |
@@ -1652,6 +1679,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1652 | // ode.dunlock(world); | 1679 | // ode.dunlock(world); |
1653 | } | 1680 | } |
1654 | 1681 | ||
1682 | d.JointGroupEmpty(contactgroup); | ||
1683 | totjcontact += m_global_contactcount; | ||
1684 | |||
1655 | step_time -= ODE_STEPSIZE; | 1685 | step_time -= ODE_STEPSIZE; |
1656 | nodeframes++; | 1686 | nodeframes++; |
1657 | } | 1687 | } |
@@ -1686,10 +1716,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1686 | } | 1716 | } |
1687 | statmovchar = Util.EnvironmentTickCountSubtract(statstart); | 1717 | statmovchar = Util.EnvironmentTickCountSubtract(statstart); |
1688 | 1718 | ||
1689 | lock (_activeprims) | 1719 | lock (_activegroups) |
1690 | { | 1720 | { |
1691 | { | 1721 | { |
1692 | foreach (OdePrim actor in _activeprims) | 1722 | foreach (OdePrim actor in _activegroups) |
1693 | { | 1723 | { |
1694 | if (actor.IsPhysical) | 1724 | if (actor.IsPhysical) |
1695 | { | 1725 | { |
@@ -1906,13 +1936,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1906 | yy += regionsize; | 1936 | yy += regionsize; |
1907 | 1937 | ||
1908 | val = heightMap[yy + xx]; | 1938 | val = heightMap[yy + xx]; |
1939 | if (val < 0.0f) | ||
1940 | val = 0.0f; // no neg terrain as in chode | ||
1909 | _heightmap[xt + y] = val; | 1941 | _heightmap[xt + y] = val; |
1910 | 1942 | ||
1911 | if (hfmin > val) | 1943 | if (hfmin > val) |
1912 | hfmin = val; | 1944 | hfmin = val; |
1913 | if (hfmax < val) | 1945 | if (hfmax < val) |
1914 | hfmax = val; | 1946 | hfmax = val; |
1915 | |||
1916 | } | 1947 | } |
1917 | xt += heightmapHeightSamples; | 1948 | xt += heightmapHeightSamples; |
1918 | } | 1949 | } |
@@ -1966,7 +1997,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1966 | 1997 | ||
1967 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 1998 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
1968 | d.GeomSetRotation(GroundGeom, ref R); | 1999 | d.GeomSetRotation(GroundGeom, ref R); |
1969 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f - 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f - 0.5f, 0); | 2000 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); |
1970 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); | 2001 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); |
1971 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); | 2002 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); |
1972 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2003 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |