aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs645
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs8
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs60
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs189
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs123
5 files changed, 394 insertions, 631 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 0a4ebe4..3ed3b5a 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -163,6 +163,8 @@ namespace OpenSim.Region.Physics.OdePlugin
163 private bool m_isphysical; 163 private bool m_isphysical;
164 private bool m_isSelected; 164 private bool m_isSelected;
165 165
166 private bool m_NoColide; // for now only for internal use for bad meshs
167
166 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively 168 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
167 169
168 private bool m_throttleUpdates; 170 private bool m_throttleUpdates;
@@ -253,7 +255,7 @@ namespace OpenSim.Region.Physics.OdePlugin
253 private float m_verticalAttractionEfficiency = 1.0f; // damped 255 private float m_verticalAttractionEfficiency = 1.0f; // damped
254 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. 256 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
255 257
256 SerialControl m_taintserial = null; 258// SerialControl m_taintserial = null;
257 object m_taintvehicledata = null; 259 object m_taintvehicledata = null;
258 260
259 public void DoSetVehicle() 261 public void DoSetVehicle()
@@ -309,410 +311,6 @@ namespace OpenSim.Region.Physics.OdePlugin
309 m_taintvehicledata = vdata; 311 m_taintvehicledata = vdata;
310 _parent_scene.AddPhysicsActorTaint(this); 312 _parent_scene.AddPhysicsActorTaint(this);
311 } 313 }
312
313 public override byte[] Serialize(bool PhysIsRunning)
314 {
315 SerialControl sc = new SerialControl();
316
317 lock (sc.alock)
318 {
319 if (PhysIsRunning)
320 {
321 m_taintserial = sc;
322
323 if (!Monitor.Wait(sc.alock, 1000))
324 {
325 m_log.Error("[chOde] prim data serialization timed out");
326 m_taintserial = null;
327 return new byte[0];
328 }
329 }
330 else
331 DoSerialize(sc);
332 }
333
334 return sc.data;
335 }
336
337 public void DoSerialize(SerialControl sc)
338 {
339 wstreamer st = new wstreamer();
340 Vector3 vtmp;
341
342 ushort version = 2;
343 if (!BitConverter.IsLittleEndian)
344 version |= 1;
345 st.Wushort(version); //version lower bit codes endian type for future use
346
347 // compact booleans in a ushort
348 ushort flags = 0;
349
350 if (m_isphysical) // this should be true for now
351 flags |= 1;
352 if (m_isSelected)
353 flags |= 2;
354 if (m_isVolumeDetect)
355 flags |= 4;
356 if (m_disabled)
357 flags |= 8;
358 if (m_collidesWater)
359 flags |= 16;
360 if (m_collidesLand)
361 flags |= 32;
362 if (m_usePID)
363 flags |= 64;
364 if (m_useAPID)
365 flags |= 128;
366 if (m_useHoverPID)
367 flags |= 256;
368 if (m_throttleUpdates)
369 flags |= 512;
370
371 st.Wushort(flags);
372
373 st.Wvector3(_size);
374 st.Wint(m_material);
375 st.Wfloat(m_density);
376 st.Wfloat(0); // future gravity mod V3
377 st.Wfloat(0); // future friction V3
378 st.Wfloat(0); // future bounce V3
379
380// st.Wuint((uint)m_collisionCategories);
381// st.Wuint((uint)m_collisionFlags);
382
383 if (_parent == null)
384 {
385 st.Wvector3(_position); // ??
386 st.Wquat(_orientation);
387 }
388 else // for childs save offsets
389 {
390 Quaternion to;
391 Quaternion ipo = Quaternion.Inverse(_parent.Orientation);
392
393 if (m_isphysical && prim_geom != IntPtr.Zero)
394 {
395 d.Vector3 dvt;
396 d.GeomCopyPosition(prim_geom, out dvt);
397
398 vtmp.X = dvt.X;
399 vtmp.Y = dvt.Y;
400 vtmp.Z = dvt.Z;
401
402 d.Quaternion dqt;
403 d.GeomCopyQuaternion(prim_geom, out dqt);
404
405 to.X = dqt.X;
406 to.Y = dqt.Y;
407 to.Z = dqt.Z;
408 to.W = dqt.W; // rotation in world
409 }
410 else
411 {
412 vtmp = _position;
413 to = _orientation;
414 }
415
416 vtmp -= _parent.Position; // offset in world
417 vtmp *= ipo; // offset in local
418 st.Wvector3(vtmp);
419
420 ipo *= to; // own rotation
421 st.Wquat(ipo);
422 }
423
424 st.Wvector3(_velocity);
425 st.Wvector3(m_rotationalVelocity);
426 st.Wvector3(_acceleration);
427 st.Wvector3(m_rotateEnable);
428
429 vtmp = Vector3.Zero;
430 for (int i = 0; i < m_forcelist.Count; i++)
431 {
432
433 vtmp += (m_forcelist[i] * 100);
434 }
435
436 st.Wvector3(vtmp); // force acc
437
438 vtmp = Vector3.Zero;
439 for (int i = 0; i < m_angularforcelist.Count; i++)
440 {
441 vtmp += (m_angularforcelist[i] * 100);
442 }
443
444 st.Wvector3(vtmp); // angular force acc
445
446 st.Wvector3(m_PIDTarget);
447 st.Wfloat(m_PIDTau);
448 st.Wfloat(PID_D);
449 st.Wfloat(PID_G);
450 st.Wquat(m_APIDTarget);
451 st.Wfloat(m_APIDStrength);
452 st.Wfloat(m_APIDDamping);
453 st.Wfloat(m_APIDdamper);
454
455 st.Wint((int)m_PIDHoverType);
456 st.Wfloat(m_PIDHoverHeight);
457 st.Wfloat(m_PIDHoverTau);
458 st.Wfloat(m_targetHoverHeight);
459
460 st.Wfloat(m_groundHeight);
461 st.Wfloat(m_waterHeight);
462
463 st.Wfloat(m_buoyancy);
464
465 // this must be last since type none ends stream
466 if (m_type == Vehicle.TYPE_NONE)
467 st.Wint((int)Vehicle.TYPE_NONE);
468 else
469 {
470 st.Wint((int)m_type);
471
472 st.Wquat(Quaternion.Identity); //m_referenceFrame
473
474 st.Wint((int)m_flags);
475
476 st.Wvector3(m_linearMotorDirection);
477 st.Wfloat(
478 (float)Math.Sqrt(m_lLinMotorDVel.LengthSquared() / m_linearMotorDirection.LengthSquared()));
479
480 st.Wvector3(m_linearFrictionTimescale);
481 st.Wfloat(m_linearMotorDecayTimescale);
482 st.Wfloat(m_linearMotorTimescale);
483 st.Wvector3(new Vector3(0, 0, 0)); //m_linearMotorOffset);
484
485 st.Wvector3(m_angularMotorDirection);
486 st.Wfloat((float)Math.Sqrt(m_angularMotorDVel.LengthSquared() / m_angularMotorDirection.LengthSquared()));
487
488 st.Wvector3(m_angularFrictionTimescale);
489 st.Wfloat(m_angularMotorDecayTimescale);
490 st.Wfloat(m_angularMotorTimescale);
491
492 st.Wfloat(0); //m_linearDeflectionEfficiency);
493 st.Wfloat(1000); //m_linearDeflectionTimescale);
494
495 st.Wfloat(0); //m_angularDeflectionEfficiency);
496 st.Wfloat(120); //m_angularDeflectionTimescale);
497
498 st.Wfloat(0); // m_bankingEfficiency);
499 st.Wfloat(0); //m_bankingMix);
500 st.Wfloat(1000); //m_bankingTimescale);
501
502 st.Wfloat(m_VhoverHeight);
503 st.Wfloat(0.5f); //m_VhoverEfficiency);
504 st.Wfloat(m_VhoverTimescale);
505
506 st.Wfloat(m_VehicleBuoyancy);
507
508 st.Wfloat(m_verticalAttractionEfficiency);
509 st.Wfloat(m_verticalAttractionTimescale);
510 }
511 sc.data = st.close();
512 m_taintserial = null;
513 Monitor.PulseAll(sc.alock);
514 }
515
516 public bool DeSerialize(byte[] data)
517 {
518 rstreamer st = new rstreamer(data);
519
520 int version =st.Rushort(); //version
521
522 // merge booleans in a ushort
523 ushort flags = st.Rushort();
524 if ((flags & 1) != 0)
525 m_isphysical = true;
526 if ((flags & 2) != 0)
527 m_taintselected = true;
528 if ((flags & 4) != 0)
529 m_isVolumeDetect = true;
530 if ((flags & 8) != 0)
531 m_taintdisable = true;
532 if ((flags & 16) != 0)
533 m_taintCollidesWater = true;
534 if ((flags & 32) != 0)
535 m_collidesLand = true;
536 if ((flags & 64) != 0)
537 m_usePID = true;
538 if ((flags & 128) != 0)
539 m_useAPID = true;
540 if ((flags & 256) != 0)
541 m_useHoverPID = true;
542 if ((flags & 512) != 0)
543 m_throttleUpdates = true;
544
545 _size = st.Rvector3();
546 m_taintsize = _size;
547
548 m_material= st.Rint();
549 m_density = st.Rfloat();
550 st.Rfloat(); // future gravity mod V3
551 st.Rfloat(); // future friction V3
552 st.Rfloat(); // future bounce V3
553
554// m_collisionCategories = (CollisionCategories)st.Ruint();
555// m_collisionFlags = (CollisionCategories) st.Ruint();
556
557 if (m_taintparent == null)
558 {
559 st.Rvector3(); // ignore old position sop/sog as to tell the new one
560 m_taintrot = st.Rquat(); //
561 _orientation = m_taintrot;
562 }
563 else
564 {
565 m_taintrot = _parent.Orientation;
566 m_taintposition = st.Rvector3(); // ??
567 _position = m_taintposition;
568
569 m_taintposition *= m_taintrot;
570 m_taintposition += _parent.Position;
571
572 m_taintrot *= st.Rquat(); //
573 _orientation = m_taintrot;
574 }
575
576 m_taintVelocity = st.Rvector3();
577 m_rotationalVelocity = st.Rvector3();
578
579 _acceleration = st.Rvector3();
580 m_rotateEnableRequest = st.Rvector3();
581 m_rotateEnableUpdate = true;
582
583 Vector3 vtmp;
584
585 vtmp = st.Rvector3(); // forces acc
586 m_forcelist.Add(vtmp);
587 m_taintforce = true;
588
589 vtmp = st.Rvector3(); // angular forces acc
590 m_angularforcelist.Add(vtmp);
591 m_taintaddangularforce = true;
592
593 m_PIDTarget = st.Rvector3();
594 m_PIDTau = st.Rfloat();
595 PID_D = st.Rfloat();
596 PID_G = st.Rfloat();
597
598 m_APIDTarget = st.Rquat();
599 m_APIDStrength = st.Rfloat();
600 m_APIDDamping = st.Rfloat();
601 m_APIDdamper = st.Rfloat();
602
603 m_PIDHoverType = (PIDHoverType) st.Rint();
604 m_PIDHoverHeight = st.Rfloat();
605 m_PIDHoverTau = st.Rfloat();
606 m_targetHoverHeight = st.Rfloat();
607
608 m_groundHeight = st.Rfloat();
609 m_waterHeight = st.Rfloat();
610
611 m_buoyancy = st.Rfloat();
612
613
614 // this must be last since type none ends stream
615
616 m_type = (Vehicle) st.Rint();
617
618 if (m_type != Vehicle.TYPE_NONE)
619 {
620 float ftmp;
621
622 st.Rquat(); //m_referenceFrame
623
624 m_flags = (VehicleFlag) st.Rint();
625
626 m_linearMotorDirection = st.Rvector3();
627
628 ftmp = st.Rfloat();
629 m_lLinMotorDVel = m_linearMotorDirection * ftmp;
630
631 m_linearFrictionTimescale = st.Rvector3();
632 m_linearMotorDecayTimescale = st.Rfloat();
633 m_linearMotorTimescale = st.Rfloat();
634 st.Rvector3(); //m_linearMotorOffset);
635
636 m_angularMotorDirection = st.Rvector3();
637 ftmp = st.Rfloat();
638 m_angularMotorDVel = m_angularMotorDirection * ftmp;
639
640 m_angularFrictionTimescale = st.Rvector3();
641 m_angularMotorDecayTimescale = st.Rfloat();
642 m_angularMotorTimescale = st.Rfloat();
643
644 st.Rfloat(); //m_linearDeflectionEfficiency);
645 st.Rfloat(); //m_linearDeflectionTimescale);
646
647 st.Rfloat(); //m_angularDeflectionEfficiency);
648 st.Rfloat(); //m_angularDeflectionTimescale);
649
650 st.Rfloat(); // m_bankingEfficiency);
651 st.Rfloat(); //m_bankingMix);
652 st.Rfloat(); //m_bankingTimescale);
653
654 m_VhoverHeight = st.Rfloat();
655 st.Rfloat(); //m_VhoverEfficiency);
656 m_VhoverTimescale = st.Rfloat();
657
658 m_VehicleBuoyancy = st.Rfloat();
659
660 m_verticalAttractionEfficiency = st.Rfloat();
661 m_verticalAttractionTimescale = st.Rfloat();
662 }
663 st.close();
664 return true;
665 }
666
667 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, PhysicsActor parent,
668 PrimitiveBaseShape pbs, CollisionLocker dode, uint localid, byte[] sdata)
669 {
670 m_localID = localid;
671 ode = dode;
672
673 if (parent == null)
674 {
675 m_taintparent = null;
676
677 if (!pos.IsFinite())
678 {
679 pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
680 parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
681 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
682 }
683
684 _position = pos;
685 m_taintposition = pos;
686 }
687 else
688 m_taintparent = parent;
689
690 body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
691
692 prim_geom = IntPtr.Zero;
693
694 _mesh = null;
695 m_meshfailed = false;
696 _pbs = pbs;
697
698 _parent_scene = parent_scene;
699 m_targetSpace = (IntPtr)0;
700
701 if(sdata != null && sdata.Length > 1)
702 DeSerialize(sdata);
703
704 if (m_isphysical)
705 m_targetSpace = _parent_scene.space;
706
707 _triMeshData = IntPtr.Zero;
708
709 m_primName = primName;
710 m_taintserial = null;
711 m_taintadd = true;
712 _parent_scene.AddPhysicsActorTaint(this);
713 // don't do .add() here; old geoms get recycled with the same hash
714 }
715
716 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, 314 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
717 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, uint localid) 315 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, uint localid)
718 { 316 {
@@ -776,8 +374,9 @@ namespace OpenSim.Region.Physics.OdePlugin
776 } 374 }
777 375
778 _triMeshData = IntPtr.Zero; 376 _triMeshData = IntPtr.Zero;
377 m_NoColide = false;
779 378
780 m_taintserial = null; 379// m_taintserial = null;
781 m_primName = primName; 380 m_primName = primName;
782 m_taintadd = true; 381 m_taintadd = true;
783 _parent_scene.AddPhysicsActorTaint(this); 382 _parent_scene.AddPhysicsActorTaint(this);
@@ -814,7 +413,6 @@ namespace OpenSim.Region.Physics.OdePlugin
814 { 413 {
815 set 414 set
816 { 415 {
817
818 //Console.WriteLine("Sel {0} {1} {2}", m_primName, value, m_isphysical); 416 //Console.WriteLine("Sel {0} {1} {2}", m_primName, value, m_isphysical);
819 // This only makes the object not collidable if the object 417 // This only makes the object not collidable if the object
820 // is physical or the object is modified somehow *IN THE FUTURE* 418 // is physical or the object is modified somehow *IN THE FUTURE*
@@ -1077,7 +675,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1077 } 675 }
1078 } 676 }
1079 677
1080
1081 public override bool FloatOnWater 678 public override bool FloatOnWater
1082 { 679 {
1083 set 680 set
@@ -1270,7 +867,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1270 } 867 }
1271 } 868 }
1272 869
1273
1274 public void SetGeom(IntPtr geom) 870 public void SetGeom(IntPtr geom)
1275 { 871 {
1276 if (prim_geom != IntPtr.Zero) 872 if (prim_geom != IntPtr.Zero)
@@ -1290,9 +886,25 @@ namespace OpenSim.Region.Physics.OdePlugin
1290 { 886 {
1291 _parent_scene.geom_name_map[prim_geom] = this.m_primName; 887 _parent_scene.geom_name_map[prim_geom] = this.m_primName;
1292 _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; 888 _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
1293 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1294 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1295 //Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, this.m_primName); 889 //Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, this.m_primName);
890 if (m_NoColide)
891 {
892 d.GeomSetCategoryBits(prim_geom, 0);
893 if (m_isphysical)
894 {
895 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
896 }
897 else
898 {
899 d.GeomSetCollideBits(prim_geom, 0);
900 d.GeomDisable(prim_geom);
901 }
902 }
903 else
904 {
905 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
906 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
907 }
1296 } 908 }
1297 909
1298 if (childPrim) 910 if (childPrim)
@@ -1351,11 +963,20 @@ namespace OpenSim.Region.Physics.OdePlugin
1351 myrot.W = _orientation.W; 963 myrot.W = _orientation.W;
1352 d.BodySetQuaternion(Body, ref myrot); 964 d.BodySetQuaternion(Body, ref myrot);
1353 d.GeomSetBody(prim_geom, Body); 965 d.GeomSetBody(prim_geom, Body);
966
1354 m_collisionCategories |= CollisionCategories.Body; 967 m_collisionCategories |= CollisionCategories.Body;
1355 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 968 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1356 969
1357 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 970 if (m_NoColide)
1358 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 971 {
972 d.GeomSetCategoryBits(prim_geom, 0);
973 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
974 }
975 else
976 {
977 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
978 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
979 }
1359 980
1360 d.BodySetAutoDisableFlag(Body, true); 981 d.BodySetAutoDisableFlag(Body, true);
1361 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 982 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
@@ -1723,11 +1344,19 @@ namespace OpenSim.Region.Physics.OdePlugin
1723 1344
1724 if (prim_geom != IntPtr.Zero) 1345 if (prim_geom != IntPtr.Zero)
1725 { 1346 {
1726 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1347 if (m_NoColide)
1727 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1348 {
1349 d.GeomSetCategoryBits(prim_geom, 0);
1350 d.GeomSetCollideBits(prim_geom, 0);
1351 d.GeomDisable(prim_geom);
1352 }
1353 else
1354 {
1355 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1356 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1357 }
1728 } 1358 }
1729 1359
1730
1731 d.BodyDestroy(Body); 1360 d.BodyDestroy(Body);
1732 lock (childrenPrim) 1361 lock (childrenPrim)
1733 { 1362 {
@@ -1735,6 +1364,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1735 { 1364 {
1736 foreach (OdePrim prm in childrenPrim) 1365 foreach (OdePrim prm in childrenPrim)
1737 { 1366 {
1367 if (prm.m_NoColide && prm.prim_geom != IntPtr.Zero)
1368 {
1369 d.GeomSetCategoryBits(prm.prim_geom, 0);
1370 d.GeomSetCollideBits(prm.prim_geom, 0);
1371 d.GeomDisable(prm.prim_geom);
1372 }
1373
1738 _parent_scene.remActivePrim(prm); 1374 _parent_scene.remActivePrim(prm);
1739 prm.Body = IntPtr.Zero; 1375 prm.Body = IntPtr.Zero;
1740 } 1376 }
@@ -1752,8 +1388,18 @@ namespace OpenSim.Region.Physics.OdePlugin
1752 1388
1753 if (prim_geom != IntPtr.Zero) 1389 if (prim_geom != IntPtr.Zero)
1754 { 1390 {
1755 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1391 if (m_NoColide)
1756 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1392 {
1393 d.GeomSetCategoryBits(prim_geom, 0);
1394 d.GeomSetCollideBits(prim_geom, 0);
1395 d.GeomDisable(prim_geom);
1396 }
1397 else
1398 {
1399 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1400 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1401 }
1402
1757 } 1403 }
1758 1404
1759 1405
@@ -1768,11 +1414,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1768 1414
1769 public bool setMesh(OdeScene parent_scene, IMesh mesh) 1415 public bool setMesh(OdeScene parent_scene, IMesh mesh)
1770 { 1416 {
1771 // This sleeper is there to moderate how long it takes between
1772 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
1773
1774 //Thread.Sleep(10);
1775
1776 //Kill Body so that mesh can re-make the geom 1417 //Kill Body so that mesh can re-make the geom
1777 if (IsPhysical && Body != IntPtr.Zero) 1418 if (IsPhysical && Body != IntPtr.Zero)
1778 { 1419 {
@@ -1790,14 +1431,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1790 } 1431 }
1791 } 1432 }
1792 1433
1793// do it on caller instead
1794/*
1795 if (_triMeshData != IntPtr.Zero)
1796 {
1797 d.GeomTriMeshDataDestroy(_triMeshData);
1798 _triMeshData = IntPtr.Zero;
1799 }
1800*/
1801 IntPtr vertices, indices; 1434 IntPtr vertices, indices;
1802 int vertexCount, indexCount; 1435 int vertexCount, indexCount;
1803 int vertexStride, triStride; 1436 int vertexStride, triStride;
@@ -1809,38 +1442,20 @@ namespace OpenSim.Region.Physics.OdePlugin
1809 1442
1810 if (vertexCount == 0 || indexCount == 0) 1443 if (vertexCount == 0 || indexCount == 0)
1811 { 1444 {
1812 m_log.WarnFormat("[PHYSICS]: Got invalid mesh on prim {0} at <{1},{2},{3}>. It can be a sculp with alpha channel in map. Replacing it by a small box.", Name, _position.X, _position.Y, _position.Z); 1445 m_log.WarnFormat("[PHYSICS]: Got invalid mesh on prim {0} at <{1},{2},{3}>. mesh UUID {4}", Name, _position.X, _position.Y, _position.Z, _pbs.SculptTexture.ToString());
1813 _size.X = 0.05f;
1814 _size.Y = 0.05f;
1815 _size.Z = 0.05f;
1816 return false; 1446 return false;
1817 } 1447 }
1818 1448
1819/* 1449 IntPtr geo = IntPtr.Zero;
1820 if (m_MeshToTriMeshMap.ContainsKey(mesh)) 1450 try
1821 {
1822 _triMeshData = m_MeshToTriMeshMap[mesh];
1823 }
1824 else
1825*/
1826
1827
1828 { 1451 {
1829 _triMeshData = d.GeomTriMeshDataCreate(); 1452 _triMeshData = d.GeomTriMeshDataCreate();
1830
1831 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 1453 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
1832 d.GeomTriMeshDataPreprocess(_triMeshData); 1454 d.GeomTriMeshDataPreprocess(_triMeshData);
1833// m_MeshToTriMeshMap[mesh] = _triMeshData;
1834 }
1835 1455
1836 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1456 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1837 try 1457
1838 { 1458 geo = d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null);
1839 // if (prim_geom == IntPtr.Zero) // setGeom takes care of phys engine recreate and prim_geom pointer
1840 // {
1841 // SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
1842 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null));
1843 // }
1844 } 1459 }
1845 catch (Exception e) 1460 catch (Exception e)
1846 { 1461 {
@@ -1851,21 +1466,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1851 d.GeomTriMeshDataDestroy(_triMeshData); 1466 d.GeomTriMeshDataDestroy(_triMeshData);
1852 _triMeshData = IntPtr.Zero; 1467 _triMeshData = IntPtr.Zero;
1853 } 1468 }
1854 _size.X = 0.05f;
1855 _size.Y = 0.05f;
1856 _size.Z = 0.05f;
1857 return false; 1469 return false;
1858 } 1470 }
1859 1471
1472 SetGeom(geo);
1860 1473
1861 // if (IsPhysical && Body == (IntPtr) 0)
1862 // {
1863 // Recreate the body
1864 // m_interpenetrationcount = 0;
1865 // m_collisionscore = 0;
1866
1867 // enableBody();
1868 // }
1869 return true; 1474 return true;
1870 } 1475 }
1871 1476
@@ -1943,18 +1548,21 @@ namespace OpenSim.Region.Physics.OdePlugin
1943 if (m_taintvehicledata != null) 1548 if (m_taintvehicledata != null)
1944 DoSetVehicle(); 1549 DoSetVehicle();
1945 1550
1946 if (m_taintserial != null)
1947 DoSerialize(m_taintserial);
1948
1949 /* obsolete 1551 /* obsolete
1950 if (!m_angularLock.ApproxEquals(m_taintAngularLock,0f)) 1552 if (!m_angularLock.ApproxEquals(m_taintAngularLock,0f))
1951 changeAngularLock(timestep); 1553 changeAngularLock(timestep);
1952 */ 1554 */
1953 } 1555 }
1556
1954 else 1557 else
1955 { 1558 {
1956 m_log.Error("[PHYSICS]: The scene reused a disposed PhysActor! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)"); 1559 m_log.Error("[PHYSICS]: prim {0} at <{1},{2},{3}> as invalid geom");
1560
1561 // not sure this will not flame...
1562 m_taintremove = true;
1563 _parent_scene.AddPhysicsActorTaint(this);
1957 } 1564 }
1565
1958 } 1566 }
1959 1567
1960 /* obsolete 1568 /* obsolete
@@ -2058,7 +1666,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2058 } 1666 }
2059 foreach (OdePrim prm in childrenPrim) 1667 foreach (OdePrim prm in childrenPrim)
2060 { 1668 {
2061
2062 prm.m_collisionCategories |= CollisionCategories.Body; 1669 prm.m_collisionCategories |= CollisionCategories.Body;
2063 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1670 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
2064 1671
@@ -2067,9 +1674,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2067 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); 1674 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet");
2068 continue; 1675 continue;
2069 } 1676 }
2070 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
2071 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
2072 1677
1678 if (prm.m_NoColide)
1679 {
1680 d.GeomSetCategoryBits(prm.prim_geom, 0);
1681 d.GeomSetCollideBits(prm.prim_geom, (int)CollisionCategories.Land);
1682 }
1683 else
1684 {
1685 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
1686 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
1687 }
2073 1688
2074 d.Quaternion quat = new d.Quaternion(); 1689 d.Quaternion quat = new d.Quaternion();
2075 quat.W = prm._orientation.W; 1690 quat.W = prm._orientation.W;
@@ -2098,20 +1713,28 @@ namespace OpenSim.Region.Physics.OdePlugin
2098 m_log.Debug("[PHYSICS]:I ain't got no boooooooooddy, no body"); 1713 m_log.Debug("[PHYSICS]:I ain't got no boooooooooddy, no body");
2099 } 1714 }
2100 1715
2101
2102 prm.m_interpenetrationcount = 0; 1716 prm.m_interpenetrationcount = 0;
2103 prm.m_collisionscore = 0; 1717 prm.m_collisionscore = 0;
2104 prm.m_disabled = false; 1718 prm.m_disabled = false;
2105 1719
2106 prm.Body = Body; 1720 prm.Body = Body;
2107 _parent_scene.addActivePrim(prm); 1721
1722 _parent_scene.addActivePrim(prm);
2108 } 1723 }
1724
2109 m_collisionCategories |= CollisionCategories.Body; 1725 m_collisionCategories |= CollisionCategories.Body;
2110 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1726 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
2111 1727
2112 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1728 if (m_NoColide)
2113 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1729 {
2114 1730 d.GeomSetCategoryBits(prim_geom, 0);
1731 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
1732 }
1733 else
1734 {
1735 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1736 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1737 }
2115 1738
2116 d.Quaternion quat2 = new d.Quaternion(); 1739 d.Quaternion quat2 = new d.Quaternion();
2117 quat2.W = _orientation.W; 1740 quat2.W = _orientation.W;
@@ -2134,19 +1757,18 @@ namespace OpenSim.Region.Physics.OdePlugin
2134 d.BodySetAutoDisableFlag(Body, true); 1757 d.BodySetAutoDisableFlag(Body, true);
2135 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 1758 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
2136 1759
2137
2138 m_interpenetrationcount = 0; 1760 m_interpenetrationcount = 0;
2139 m_collisionscore = 0; 1761 m_collisionscore = 0;
2140 m_disabled = false; 1762 m_disabled = false;
2141 1763
2142 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); 1764 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
2143 if (m_type != Vehicle.TYPE_NONE) Enable(Body, _parent_scene); 1765 if (m_type != Vehicle.TYPE_NONE) Enable(Body, _parent_scene);
1766
2144 _parent_scene.addActivePrim(this); 1767 _parent_scene.addActivePrim(this);
2145 } 1768 }
2146 } 1769 }
2147 } 1770 }
2148 } 1771 }
2149
2150 } 1772 }
2151 1773
2152 private void ChildSetGeom(OdePrim odePrim) 1774 private void ChildSetGeom(OdePrim odePrim)
@@ -2258,6 +1880,8 @@ namespace OpenSim.Region.Physics.OdePlugin
2258 { 1880 {
2259 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1881 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
2260 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1882 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1883 if (m_NoColide)
1884 d.GeomDisable(prim_geom);
2261 } 1885 }
2262 1886
2263 if (m_isphysical) 1887 if (m_isphysical)
@@ -2275,22 +1899,35 @@ namespace OpenSim.Region.Physics.OdePlugin
2275 } 1899 }
2276 else 1900 else
2277 { 1901 {
2278 m_collisionCategories = CollisionCategories.Geom; 1902 m_collisionCategories = CollisionCategories.Geom;
2279 1903 if (m_isphysical)
2280 if (m_isphysical) 1904 m_collisionCategories |= CollisionCategories.Body;
2281 m_collisionCategories |= CollisionCategories.Body;
2282 1905
2283 m_collisionFlags = m_default_collisionFlags; 1906 m_collisionFlags = m_default_collisionFlags;
2284 1907
2285 if (m_collidesLand) 1908 if (m_collidesLand)
2286 m_collisionFlags |= CollisionCategories.Land; 1909 m_collisionFlags |= CollisionCategories.Land;
2287 if (m_collidesWater) 1910 if (m_collidesWater)
2288 m_collisionFlags |= CollisionCategories.Water; 1911 m_collisionFlags |= CollisionCategories.Water;
2289 1912
2290 if (prim_geom != IntPtr.Zero) 1913 if (prim_geom != IntPtr.Zero)
2291 { 1914 {
2292 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1915 if (m_NoColide)
2293 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1916 {
1917 d.GeomSetCategoryBits(prim_geom, 0);
1918 if (m_isphysical)
1919 d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land);
1920 else
1921 {
1922 d.GeomSetCollideBits(prim_geom, 0);
1923 d.GeomDisable(prim_geom);
1924 }
1925 }
1926 else
1927 {
1928 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1929 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1930 }
2294 } 1931 }
2295 if (Body != IntPtr.Zero) 1932 if (Body != IntPtr.Zero)
2296 { 1933 {
@@ -2330,19 +1967,29 @@ namespace OpenSim.Region.Physics.OdePlugin
2330 { 1967 {
2331 bool gottrimesh = false; 1968 bool gottrimesh = false;
2332 1969
1970 m_NoColide = false; // assume all will go well
1971
2333 if (_triMeshData != IntPtr.Zero) 1972 if (_triMeshData != IntPtr.Zero)
2334 { 1973 {
2335 d.GeomTriMeshDataDestroy(_triMeshData); 1974 d.GeomTriMeshDataDestroy(_triMeshData);
2336 _triMeshData = IntPtr.Zero; 1975 _triMeshData = IntPtr.Zero;
2337 } 1976 }
2338 1977
2339 if (_mesh != null) // Special - make mesh 1978 if (_mesh != null)
2340 { 1979 {
2341 gottrimesh = setMesh(_parent_scene, _mesh); 1980 gottrimesh = setMesh(_parent_scene, _mesh);
1981 if (!gottrimesh)
1982 {
1983 // getting a mesh failed,
1984 // lets go on having a basic box or sphere, with prim size but not coliding
1985 // physical colides with land, non with nothing
1986
1987 m_NoColide = true;
1988 }
2342 } 1989 }
2343 1990
2344 if (!gottrimesh) // not a mesh 1991 if (!gottrimesh)
2345 { 1992 { // we will have a basic box or sphere
2346 IntPtr geo = IntPtr.Zero; 1993 IntPtr geo = IntPtr.Zero;
2347 1994
2348 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1 1995 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1
@@ -2376,14 +2023,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2376 } 2023 }
2377 } 2024 }
2378 2025
2379 if (geo == IntPtr.Zero) 2026 if (geo == IntPtr.Zero) // if this happens it must be fixed
2380 { 2027 {
2028 // if it does lets stop what we can
2029 // not sure this will not flame...
2030
2381 m_taintremove = true; 2031 m_taintremove = true;
2382 _parent_scene.AddPhysicsActorTaint(this); 2032 _parent_scene.AddPhysicsActorTaint(this);
2383 return; 2033 return;
2384 } 2034 }
2385 2035
2386 SetGeom(geo); 2036 SetGeom(geo); // this processes the m_NoColide
2387 } 2037 }
2388 } 2038 }
2389 2039
@@ -2415,7 +2065,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2415 } 2065 }
2416 } 2066 }
2417 2067
2418
2419 lock (_parent_scene.OdeLock) 2068 lock (_parent_scene.OdeLock)
2420 { 2069 {
2421 CreateGeom(m_targetSpace, _mesh); 2070 CreateGeom(m_targetSpace, _mesh);
@@ -2518,8 +2167,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2518 m_taintposition = _position; 2167 m_taintposition = _position;
2519 } 2168 }
2520 2169
2521
2522
2523 public void rotate(float timestep) 2170 public void rotate(float timestep)
2524 { 2171 {
2525 d.Quaternion myrot = new d.Quaternion(); 2172 d.Quaternion myrot = new d.Quaternion();
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
index 7a1e671..5f5d547 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
@@ -1735,7 +1735,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1735 1735
1736 return newPrim; 1736 return newPrim;
1737 } 1737 }
1738 1738/*
1739 private PhysicsActor AddPrim(String name, Vector3 position, PhysicsActor parent, 1739 private PhysicsActor AddPrim(String name, Vector3 position, PhysicsActor parent,
1740 PrimitiveBaseShape pbs, uint localid, byte[] sdata) 1740 PrimitiveBaseShape pbs, uint localid, byte[] sdata)
1741 { 1741 {
@@ -1751,7 +1751,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1751 1751
1752 return newPrim; 1752 return newPrim;
1753 } 1753 }
1754 1754*/
1755 1755
1756 public void addActivePrim(OdePrim activatePrim) 1756 public void addActivePrim(OdePrim activatePrim)
1757 { 1757 {
@@ -1778,7 +1778,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1778 1778
1779 return result; 1779 return result;
1780 } 1780 }
1781 1781/*
1782 public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position, 1782 public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position,
1783 uint localid, byte[] sdata) 1783 uint localid, byte[] sdata)
1784 { 1784 {
@@ -1789,7 +1789,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1789 1789
1790 return result; 1790 return result;
1791 } 1791 }
1792 1792*/
1793 public override float TimeDilation 1793 public override float TimeDilation
1794 { 1794 {
1795 get { return m_timeDilation; } 1795 get { return m_timeDilation; }
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index c9d0909..4f82c24 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -38,7 +38,7 @@
38 * settings use. 38 * settings use.
39 */ 39 */
40 40
41// Ubit 2012 41// Extensive change Ubit 2012
42 42
43using System; 43using System;
44using System.Collections.Generic; 44using System.Collections.Generic;
@@ -614,6 +614,7 @@ namespace OpenSim.Region.Physics.OdePlugin
614 return vec; 614 return vec;
615 } 615 }
616 616
617 private const float pi = (float)Math.PI;
617 private const float halfpi = 0.5f * (float)Math.PI; 618 private const float halfpi = 0.5f * (float)Math.PI;
618 619
619 public static Vector3 ubitRot2Euler(Quaternion rot) 620 public static Vector3 ubitRot2Euler(Quaternion rot)
@@ -884,35 +885,64 @@ namespace OpenSim.Region.Physics.OdePlugin
884 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE; 885 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE;
885 float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE; 886 float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE;
886 887
887 if (Math.Abs(roll) > 0.01) // roll 888 if (roll > halfpi)
889 roll = pi - roll;
890 else if (roll < -halfpi)
891 roll = -pi - roll;
892
893 float effroll = pitch / halfpi;
894 effroll *= effroll;
895 effroll = 1 - effroll;
896 effroll *= roll;
897
898 if (Math.Abs(effroll) > 0.01) // roll
888 { 899 {
889 torque.X -= -roll * ftmp + curLocalAngVel.X * ftmp2; 900 torque.X -= -effroll * ftmp + curLocalAngVel.X * ftmp2;
890 } 901 }
891 902
892 if (Math.Abs(pitch) > 0.01 && ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)) // pitch 903 if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)
893 { 904 {
894 torque.Y -= -pitch * ftmp + curLocalAngVel.Y * ftmp2; 905 float effpitch = roll / halfpi;
906 effpitch *= effpitch;
907 effpitch = 1 - effpitch;
908 effpitch *= pitch;
909
910 if (Math.Abs(effpitch) > 0.01) // pitch
911 {
912 torque.Y -= -effpitch * ftmp + curLocalAngVel.Y * ftmp2;
913 }
895 } 914 }
896 915
897 if (m_bankingEfficiency != 0 && Math.Abs(roll) > 0.01) 916 if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
898 { 917 {
899 float broll = roll * m_bankingEfficiency; ; 918
919 float broll = effroll;
920/*
921 if (broll > halfpi)
922 broll = pi - broll;
923 else if (broll < -halfpi)
924 broll = -pi - broll;
925*/
926 broll *= m_bankingEfficiency;
900 if (m_bankingMix != 0) 927 if (m_bankingMix != 0)
901 { 928 {
902 float vfact = Math.Abs(curLocalVel.X) / 10.0f; 929 float vfact = Math.Abs(curLocalVel.X) / 10.0f;
903 if (vfact > 1.0f) vfact = 1.0f; 930 if (vfact > 1.0f) vfact = 1.0f;
931
904 if (curLocalVel.X >= 0) 932 if (curLocalVel.X >= 0)
905 broll *= ((1 - m_bankingMix) + vfact); 933 broll *= (1 + (vfact - 1) * m_bankingMix);
906 else 934 else
907 broll *= -((1 - m_bankingMix) + vfact); 935 broll *= -(1 + (vfact - 1) * m_bankingMix);
908 } 936 }
909 broll = (broll - curLocalAngVel.Z) / m_bankingTimescale;
910 // torque.Z += broll;
911
912 // make z rot be in world Z not local as seems to be in sl 937 // make z rot be in world Z not local as seems to be in sl
913 tmpV.X = 0; 938
914 tmpV.Y = 0; 939 broll = broll / m_bankingTimescale;
915 tmpV.Z = broll; 940
941 ftmp = -Math.Abs(m_bankingEfficiency) / m_bankingTimescale;
942
943 tmpV.X = ftmp * curAngVel.X;
944 tmpV.Y = ftmp * curAngVel.Y;
945 tmpV.Z = broll + ftmp * curAngVel.Z;
916 tmpV *= irotq; 946 tmpV *= irotq;
917 947
918 torque.X += tmpV.X; 948 torque.X += tmpV.X;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 0ccdbc0..17f38e8 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -155,6 +155,8 @@ namespace OpenSim.Region.Physics.OdePlugin
155 public float m_collisionscore; 155 public float m_collisionscore;
156 int m_colliderfilter = 0; 156 int m_colliderfilter = 0;
157 157
158 public IntPtr collide_geom; // for objects: geom if single prim space it linkset
159
158 private float m_density = 10.000006836f; // Aluminum g/cm3; 160 private float m_density = 10.000006836f; // Aluminum g/cm3;
159 161
160 public bool _zeroFlag; 162 public bool _zeroFlag;
@@ -453,8 +455,6 @@ namespace OpenSim.Region.Physics.OdePlugin
453 { 455 {
454 get 456 get
455 { 457 {
456 // Averate previous velocity with the new one so
457 // client object interpolation works a 'little' better
458 if (_zeroFlag) 458 if (_zeroFlag)
459 return Vector3.Zero; 459 return Vector3.Zero;
460 return _velocity; 460 return _velocity;
@@ -833,6 +833,7 @@ namespace OpenSim.Region.Physics.OdePlugin
833 body_autodisable_frames = parent_scene.bodyFramesAutoDisable; 833 body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
834 834
835 prim_geom = IntPtr.Zero; 835 prim_geom = IntPtr.Zero;
836 collide_geom = IntPtr.Zero;
836 Body = IntPtr.Zero; 837 Body = IntPtr.Zero;
837 838
838 if (!size.IsFinite()) 839 if (!size.IsFinite())
@@ -1367,7 +1368,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1367 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1368 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1368 m_collisionscore = 0; 1369 m_collisionscore = 0;
1369 1370
1370 if (m_targetSpace != _parent_scene.ActiveSpace) 1371// if (m_targetSpace != _parent_scene.ActiveSpace)
1371 { 1372 {
1372 if (m_targetSpace != IntPtr.Zero) 1373 if (m_targetSpace != IntPtr.Zero)
1373 { 1374 {
@@ -1376,9 +1377,26 @@ namespace OpenSim.Region.Physics.OdePlugin
1376 d.SpaceRemove(m_targetSpace, prim_geom); 1377 d.SpaceRemove(m_targetSpace, prim_geom);
1377 } 1378 }
1378 1379
1380// m_targetSpace = _parent_scene.ActiveSpace;
1381// d.SpaceAdd(m_targetSpace, prim_geom);
1382 }
1383
1384
1385 if (childrenPrim.Count == 0)
1386 {
1387 collide_geom = prim_geom;
1379 m_targetSpace = _parent_scene.ActiveSpace; 1388 m_targetSpace = _parent_scene.ActiveSpace;
1380 d.SpaceAdd(m_targetSpace, prim_geom); 1389 d.SpaceAdd(m_targetSpace, prim_geom);
1381 } 1390 }
1391 else
1392 {
1393 m_targetSpace = d.HashSpaceCreate(_parent_scene.ActiveSpace);
1394 d.HashSpaceSetLevels(m_targetSpace, -2, 8);
1395 d.SpaceSetSublevel(m_targetSpace, 3);
1396 d.SpaceSetCleanup(m_targetSpace, false);
1397 d.SpaceAdd(m_targetSpace, prim_geom);
1398 collide_geom = m_targetSpace;
1399 }
1382 1400
1383 lock (childrenPrim) 1401 lock (childrenPrim)
1384 { 1402 {
@@ -1396,15 +1414,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1396 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); 1414 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
1397 prm.m_collisionscore = 0; 1415 prm.m_collisionscore = 0;
1398 1416
1399 if (prm.m_targetSpace != _parent_scene.ActiveSpace) 1417 if (prm.m_targetSpace != m_targetSpace)
1400 { 1418 {
1401 if (prm.m_targetSpace != IntPtr.Zero) 1419 if (prm.m_targetSpace != IntPtr.Zero)
1402 { 1420 {
1403 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1421 _parent_scene.waitForSpaceUnlock(prm.m_targetSpace);
1404 if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) 1422 if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom))
1405 d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); 1423 d.SpaceRemove(prm.m_targetSpace, prm.prim_geom);
1406 } 1424 }
1407 prm.m_targetSpace = _parent_scene.ActiveSpace; 1425 prm.m_targetSpace = m_targetSpace;
1408 d.SpaceAdd(m_targetSpace, prm.prim_geom); 1426 d.SpaceAdd(m_targetSpace, prm.prim_geom);
1409 } 1427 }
1410 1428
@@ -1427,8 +1445,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1427 d.GeomDisable(prim_geom); 1445 d.GeomDisable(prim_geom);
1428 d.BodyDisable(Body); 1446 d.BodyDisable(Body);
1429 } 1447 }
1448 else
1449 {
1450 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
1451 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
1452 }
1430 1453
1431 _parent_scene.addActivePrim(this); 1454 _parent_scene.addActivePrim(this);
1455 _parent_scene.addActiveGroups(this);
1432 } 1456 }
1433 1457
1434 private void DestroyBody() 1458 private void DestroyBody()
@@ -1473,6 +1497,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1473 d.JointDestroy(Amotor); 1497 d.JointDestroy(Amotor);
1474 Amotor = IntPtr.Zero; 1498 Amotor = IntPtr.Zero;
1475 } 1499 }
1500 _parent_scene.remActiveGroup(this);
1476 d.BodyDestroy(Body); 1501 d.BodyDestroy(Body);
1477 } 1502 }
1478 Body = IntPtr.Zero; 1503 Body = IntPtr.Zero;
@@ -2390,8 +2415,8 @@ namespace OpenSim.Region.Physics.OdePlugin
2390 else 2415 else
2391 */ 2416 */
2392 DestroyBody(); 2417 DestroyBody();
2393 Stop();
2394 } 2418 }
2419 Stop();
2395 } 2420 }
2396 } 2421 }
2397 2422
@@ -2576,7 +2601,8 @@ namespace OpenSim.Region.Physics.OdePlugin
2576 if ((bool)newbuilding) 2601 if ((bool)newbuilding)
2577 { 2602 {
2578 m_building = true; 2603 m_building = true;
2579 DestroyBody(); 2604 if (!childPrim)
2605 DestroyBody();
2580 } 2606 }
2581 else 2607 else
2582 { 2608 {
@@ -2648,12 +2674,95 @@ namespace OpenSim.Region.Physics.OdePlugin
2648 public void Move() 2674 public void Move()
2649 { 2675 {
2650 if (!childPrim && m_isphysical && Body != IntPtr.Zero && 2676 if (!childPrim && m_isphysical && Body != IntPtr.Zero &&
2651 !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building) // KF: Only move root prims. 2677 !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building && !m_outbounds)
2678 // !m_disabled && !m_isSelected && !m_building && !m_outbounds)
2652 { 2679 {
2653 // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 2680// if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009
2654 2681
2655 float timestep = _parent_scene.ODE_STEPSIZE; 2682 float timestep = _parent_scene.ODE_STEPSIZE;
2656 2683
2684 // check outside region
2685 d.Vector3 lpos;
2686 d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator
2687
2688 if (lpos.Z < -100 || lpos.Z > 100000f)
2689 {
2690 m_outbounds = true;
2691
2692 lpos.Z = Util.Clip(lpos.Z, -100f, 100000f);
2693 _acceleration.X = 0;
2694 _acceleration.Y = 0;
2695 _acceleration.Z = 0;
2696
2697 _velocity.X = 0;
2698 _velocity.Y = 0;
2699 _velocity.Z = 0;
2700 m_rotationalVelocity.X = 0;
2701 m_rotationalVelocity.Y = 0;
2702 m_rotationalVelocity.Z = 0;
2703
2704 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
2705 d.BodySetAngularVel(Body, 0, 0, 0); // stop it
2706 d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere
2707 m_lastposition = _position;
2708 m_lastorientation = _orientation;
2709
2710 base.RequestPhysicsterseUpdate();
2711
2712 m_throttleUpdates = false;
2713 throttleCounter = 0;
2714 _zeroFlag = true;
2715
2716 disableBodySoft(); // disable it and colisions
2717 base.RaiseOutOfBounds(_position);
2718 return;
2719 }
2720
2721 if (lpos.X < 0f)
2722 {
2723 _position.X = Util.Clip(lpos.X, -2f, -0.1f);
2724 m_outbounds = true;
2725 }
2726 else if(lpos.X > _parent_scene.WorldExtents.X)
2727 {
2728 _position.X = Util.Clip(lpos.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f);
2729 m_outbounds = true;
2730 }
2731 if (lpos.Y < 0f)
2732 {
2733 _position.Y = Util.Clip(lpos.Y, -2f, -0.1f);
2734 m_outbounds = true;
2735 }
2736 else if(lpos.Y > _parent_scene.WorldExtents.Y)
2737 {
2738 _position.Y = Util.Clip(lpos.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f);
2739 m_outbounds = true;
2740 }
2741
2742 if(m_outbounds)
2743 {
2744 m_lastposition = _position;
2745 m_lastorientation = _orientation;
2746
2747 d.Vector3 dtmp = d.BodyGetAngularVel(Body);
2748 m_rotationalVelocity.X = dtmp.X;
2749 m_rotationalVelocity.Y = dtmp.Y;
2750 m_rotationalVelocity.Z = dtmp.Z;
2751
2752 dtmp = d.BodyGetLinearVel(Body);
2753 _velocity.X = dtmp.X;
2754 _velocity.Y = dtmp.Y;
2755 _velocity.Z = dtmp.Z;
2756
2757 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
2758 d.BodySetAngularVel(Body, 0, 0, 0);
2759 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2760 disableBodySoft(); // stop collisions
2761 base.RequestPhysicsterseUpdate();
2762 return;
2763 }
2764
2765
2657 float fx = 0; 2766 float fx = 0;
2658 float fy = 0; 2767 float fy = 0;
2659 float fz = 0; 2768 float fz = 0;
@@ -2862,7 +2971,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2862 public void UpdatePositionAndVelocity(float simulatedtime) 2971 public void UpdatePositionAndVelocity(float simulatedtime)
2863 { 2972 {
2864 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 2973 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
2865 if (_parent == null && !m_disabled && !m_building) 2974 if (_parent == null && !m_disabled && !m_building && !m_outbounds)
2866 { 2975 {
2867 if (Body != IntPtr.Zero) 2976 if (Body != IntPtr.Zero)
2868 { 2977 {
@@ -2872,64 +2981,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2872 d.Vector3 lpos; 2981 d.Vector3 lpos;
2873 d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator 2982 d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator
2874 2983
2875 // we need to use root position since that's all the rest of scene uses
2876 if (lpos.X < 0f || lpos.X > _parent_scene.WorldExtents.X
2877 || lpos.Y < 0f || lpos.Y > _parent_scene.WorldExtents.Y
2878 )
2879 {
2880 // we are outside current region
2881 // we can't let it keeping moving and having colisions
2882 // since it can be stucked between something like terrain and edge
2883 // so lets stop and disable it until something else kicks it
2884
2885 _position.X = Util.Clip(lpos.X, -0.2f, _parent_scene.WorldExtents.X + 0.2f);
2886 _position.Y = Util.Clip(lpos.Y, -0.2f, _parent_scene.WorldExtents.Y + 0.2f);
2887 _position.Z = Util.Clip(lpos.Z, -100f, 50000f);
2888
2889 m_lastposition = _position;
2890// m_lastorientation = _orientation;
2891
2892 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
2893// d.BodySetAngularVel(Body, 0, 0, 0);
2894 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2895 disableBodySoft(); // stop collisions
2896 m_outbounds = true;
2897 base.RequestPhysicsterseUpdate();
2898 return;
2899 }
2900
2901 if (lpos.Z < -100 || lpos.Z > 100000f)
2902 {
2903 lpos.Z = Util.Clip(lpos.Z, -100f, 50000f);
2904
2905 _acceleration.X = 0;
2906 _acceleration.Y = 0;
2907 _acceleration.Z = 0;
2908
2909 _velocity.X = 0;
2910 _velocity.Y = 0;
2911 _velocity.Z = 0;
2912 m_rotationalVelocity.X = 0;
2913 m_rotationalVelocity.Y = 0;
2914 m_rotationalVelocity.Z = 0;
2915
2916 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
2917 d.BodySetAngularVel(Body, 0, 0, 0); // stop it
2918 d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere
2919 m_lastposition = _position;
2920 m_lastorientation = _orientation;
2921
2922 base.RequestPhysicsterseUpdate();
2923
2924 m_throttleUpdates = false;
2925 throttleCounter = 0;
2926 _zeroFlag = true;
2927
2928 disableBodySoft(); // disable it and colisions
2929 base.RaiseOutOfBounds(_position);
2930
2931 return;
2932 }
2933 2984
2934 d.Quaternion ori; 2985 d.Quaternion ori;
2935 d.GeomCopyQuaternion(prim_geom, out ori); 2986 d.GeomCopyQuaternion(prim_geom, out ori);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 6e4c373..eb5c687 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -224,6 +224,7 @@ namespace OpenSim.Region.Physics.OdePlugin
224 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); 224 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
225 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 225 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
226 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 226 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
227 private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
227 228
228 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); 229 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>();
229 230
@@ -1013,15 +1014,24 @@ namespace OpenSim.Region.Physics.OdePlugin
1013 1014
1014 } 1015 }
1015 1016
1016 // collide active prims with static enviroment
1017 lock (_activeprims) 1017 lock (_activeprims)
1018 { 1018 {
1019 foreach (OdePrim aprim in _activeprims)
1020 {
1021 aprim.CollisionScore = 0;
1022 aprim.IsColliding = false;
1023 }
1024 }
1025
1026 // collide active prims with static enviroment
1027 lock (_activegroups)
1028 {
1019 try 1029 try
1020 { 1030 {
1021 foreach (OdePrim prm in _activeprims) 1031 foreach (OdePrim prm in _activegroups)
1022 { 1032 {
1023 if (d.BodyIsEnabled(prm.Body)) 1033 if (d.BodyIsEnabled(prm.Body) && !prm.m_outbounds)
1024 d.SpaceCollide2(StaticSpace, prm.prim_geom, IntPtr.Zero, nearCallback); 1034 d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback);
1025 } 1035 }
1026 } 1036 }
1027 catch (AccessViolationException) 1037 catch (AccessViolationException)
@@ -1029,7 +1039,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1029 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); 1039 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
1030 } 1040 }
1031 } 1041 }
1032
1033 // finally colide active things amoung them 1042 // finally colide active things amoung them
1034 try 1043 try
1035 { 1044 {
@@ -1039,7 +1048,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1039 { 1048 {
1040 m_log.Warn("[PHYSICS]: Unable to collide in Active space"); 1049 m_log.Warn("[PHYSICS]: Unable to collide in Active space");
1041 } 1050 }
1042
1043// _perloopContact.Clear(); 1051// _perloopContact.Clear();
1044 } 1052 }
1045 1053
@@ -1148,13 +1156,20 @@ namespace OpenSim.Region.Physics.OdePlugin
1148 1156
1149 public void addActivePrim(OdePrim activatePrim) 1157 public void addActivePrim(OdePrim activatePrim)
1150 { 1158 {
1151 // adds active prim.. (ones that should be iterated over in collisions_optimized 1159 // adds active prim..
1152 lock (_activeprims) 1160 lock (_activeprims)
1153 { 1161 {
1154 if (!_activeprims.Contains(activatePrim)) 1162 if (!_activeprims.Contains(activatePrim))
1155 _activeprims.Add(activatePrim); 1163 _activeprims.Add(activatePrim);
1156 //else 1164 }
1157 // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); 1165 }
1166
1167 public void addActiveGroups(OdePrim activatePrim)
1168 {
1169 lock (_activegroups)
1170 {
1171 if (!_activegroups.Contains(activatePrim))
1172 _activegroups.Add(activatePrim);
1158 } 1173 }
1159 } 1174 }
1160 1175
@@ -1186,6 +1201,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1186 _activeprims.Remove(deactivatePrim); 1201 _activeprims.Remove(deactivatePrim);
1187 } 1202 }
1188 } 1203 }
1204 public void remActiveGroup(OdePrim deactivatePrim)
1205 {
1206 lock (_activegroups)
1207 {
1208 _activegroups.Remove(deactivatePrim);
1209 }
1210 }
1189 1211
1190 public override void RemovePrim(PhysicsActor prim) 1212 public override void RemovePrim(PhysicsActor prim)
1191 { 1213 {
@@ -1258,6 +1280,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1258 { 1280 {
1259 waitForSpaceUnlock(currentspace); 1281 waitForSpaceUnlock(currentspace);
1260 d.SpaceRemove(currentspace, geom); 1282 d.SpaceRemove(currentspace, geom);
1283
1284 if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0)
1285 {
1286 d.SpaceDestroy(currentspace);
1287 }
1261 } 1288 }
1262 else 1289 else
1263 { 1290 {
@@ -1274,6 +1301,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1274 { 1301 {
1275 waitForSpaceUnlock(currentspace); 1302 waitForSpaceUnlock(currentspace);
1276 d.SpaceRemove(currentspace, geom); 1303 d.SpaceRemove(currentspace, geom);
1304
1305 if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0)
1306 {
1307 d.SpaceDestroy(currentspace);
1308 }
1309
1277 } 1310 }
1278 } 1311 }
1279 } 1312 }
@@ -1577,42 +1610,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1577 1610
1578 statchanges += Util.EnvironmentTickCountSubtract(statstart); 1611 statchanges += Util.EnvironmentTickCountSubtract(statstart);
1579 1612
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); 1613 statactmove += Util.EnvironmentTickCountSubtract(statstart);
1611 //if ((framecount % m_randomizeWater) == 0) 1614 //if ((framecount % m_randomizeWater) == 0)
1612 // randomizeWater(waterlevel); 1615 // randomizeWater(waterlevel);
1613 1616
1614 m_rayCastManager.ProcessQueuedRequests(); 1617 m_rayCastManager.ProcessQueuedRequests();
1615 1618
1619
1620
1616 statray += Util.EnvironmentTickCountSubtract(statstart); 1621 statray += Util.EnvironmentTickCountSubtract(statstart);
1617 collision_optimized(); 1622 collision_optimized();
1618 statcol += Util.EnvironmentTickCountSubtract(statstart); 1623 statcol += Util.EnvironmentTickCountSubtract(statstart);
@@ -1642,8 +1647,35 @@ namespace OpenSim.Region.Physics.OdePlugin
1642 1647
1643 d.WorldQuickStep(world, ODE_STEPSIZE); 1648 d.WorldQuickStep(world, ODE_STEPSIZE);
1644 statstep += Util.EnvironmentTickCountSubtract(statstart); 1649 statstep += Util.EnvironmentTickCountSubtract(statstart);
1645 d.JointGroupEmpty(contactgroup); 1650
1646 totjcontact += m_global_contactcount; 1651 // Move characters
1652 lock (_characters)
1653 {
1654 List<OdeCharacter> defects = new List<OdeCharacter>();
1655 foreach (OdeCharacter actor in _characters)
1656 {
1657 if (actor != null)
1658 actor.Move(ODE_STEPSIZE, defects);
1659 }
1660 if (defects.Count != 0)
1661 {
1662 foreach (OdeCharacter defect in defects)
1663 {
1664 RemoveCharacter(defect);
1665 }
1666 }
1667 }
1668 statchmove += Util.EnvironmentTickCountSubtract(statstart);
1669
1670 // Move other active objects
1671 lock (_activegroups)
1672 {
1673 foreach (OdePrim aprim in _activegroups)
1674 {
1675 aprim.Move();
1676 }
1677 }
1678
1647 //ode.dunlock(world); 1679 //ode.dunlock(world);
1648 } 1680 }
1649 catch (Exception e) 1681 catch (Exception e)
@@ -1652,6 +1684,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1652// ode.dunlock(world); 1684// ode.dunlock(world);
1653 } 1685 }
1654 1686
1687 d.JointGroupEmpty(contactgroup);
1688 totjcontact += m_global_contactcount;
1689
1655 step_time -= ODE_STEPSIZE; 1690 step_time -= ODE_STEPSIZE;
1656 nodeframes++; 1691 nodeframes++;
1657 } 1692 }
@@ -1686,10 +1721,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1686 } 1721 }
1687 statmovchar = Util.EnvironmentTickCountSubtract(statstart); 1722 statmovchar = Util.EnvironmentTickCountSubtract(statstart);
1688 1723
1689 lock (_activeprims) 1724 lock (_activegroups)
1690 { 1725 {
1691 { 1726 {
1692 foreach (OdePrim actor in _activeprims) 1727 foreach (OdePrim actor in _activegroups)
1693 { 1728 {
1694 if (actor.IsPhysical) 1729 if (actor.IsPhysical)
1695 { 1730 {
@@ -1966,7 +2001,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1966 2001
1967 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2002 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
1968 d.GeomSetRotation(GroundGeom, ref R); 2003 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); 2004 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
1970 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2005 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
1971// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); 2006// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
1972 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2007 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);