diff options
author | UbitUmarov | 2012-04-29 08:24:41 +0100 |
---|---|---|
committer | UbitUmarov | 2012-04-29 08:24:41 +0100 |
commit | be176b1e4948059e041d06be2caea1eb10b5ee68 (patch) | |
tree | 7bc5ce209d67fa67bb95f813f9ff96f53a0bd30c /OpenSim/Region/Physics | |
parent | llGetGeometricCenter... (diff) | |
download | opensim-SC_OLD-be176b1e4948059e041d06be2caea1eb10b5ee68.zip opensim-SC_OLD-be176b1e4948059e041d06be2caea1eb10b5ee68.tar.gz opensim-SC_OLD-be176b1e4948059e041d06be2caea1eb10b5ee68.tar.bz2 opensim-SC_OLD-be176b1e4948059e041d06be2caea1eb10b5ee68.tar.xz |
ubitode fix inertia for same cases. Added a nasty lock on llGetCenterOfMass and simulate
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 178 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 10 |
2 files changed, 91 insertions, 97 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index c9a453d..2bcce31 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -449,54 +449,57 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
449 | { | 449 | { |
450 | get | 450 | get |
451 | { | 451 | { |
452 | d.Vector3 dtmp; | 452 | lock (_parent_scene.OdeLock) |
453 | if (!childPrim && Body != IntPtr.Zero) | ||
454 | { | ||
455 | dtmp = d.BodyGetPosition(Body); | ||
456 | return new Vector3(dtmp.X, dtmp.Y, dtmp.Z); | ||
457 | } | ||
458 | else if (prim_geom != IntPtr.Zero) | ||
459 | { | 453 | { |
460 | d.Quaternion dq; | 454 | d.Vector3 dtmp; |
461 | d.GeomCopyQuaternion(prim_geom, out dq); | 455 | if (!childPrim && Body != IntPtr.Zero) |
462 | Quaternion q; | ||
463 | q.X = dq.X; | ||
464 | q.Y = dq.Y; | ||
465 | q.Z = dq.Z; | ||
466 | q.W = dq.W; | ||
467 | |||
468 | Vector3 Ptot = primOOBoffset * q; | ||
469 | dtmp = d.GeomGetPosition(prim_geom); | ||
470 | Ptot.X += dtmp.X; | ||
471 | Ptot.Y += dtmp.Y; | ||
472 | Ptot.Z += dtmp.Z; | ||
473 | |||
474 | // if(childPrim) we only know about physical linksets | ||
475 | return Ptot; | ||
476 | /* | ||
477 | float tmass = _mass; | ||
478 | Ptot *= tmass; | ||
479 | |||
480 | float m; | ||
481 | |||
482 | foreach (OdePrim prm in childrenPrim) | ||
483 | { | 456 | { |
484 | m = prm._mass; | 457 | dtmp = d.BodyGetPosition(Body); |
485 | Ptot += prm.CenterOfMass * m; | 458 | return new Vector3(dtmp.X, dtmp.Y, dtmp.Z); |
486 | tmass += m; | 459 | } |
460 | else if (prim_geom != IntPtr.Zero) | ||
461 | { | ||
462 | d.Quaternion dq; | ||
463 | d.GeomCopyQuaternion(prim_geom, out dq); | ||
464 | Quaternion q; | ||
465 | q.X = dq.X; | ||
466 | q.Y = dq.Y; | ||
467 | q.Z = dq.Z; | ||
468 | q.W = dq.W; | ||
469 | |||
470 | Vector3 Ptot = primOOBoffset * q; | ||
471 | dtmp = d.GeomGetPosition(prim_geom); | ||
472 | Ptot.X += dtmp.X; | ||
473 | Ptot.Y += dtmp.Y; | ||
474 | Ptot.Z += dtmp.Z; | ||
475 | |||
476 | // if(childPrim) we only know about physical linksets | ||
477 | return Ptot; | ||
478 | /* | ||
479 | float tmass = _mass; | ||
480 | Ptot *= tmass; | ||
481 | |||
482 | float m; | ||
483 | |||
484 | foreach (OdePrim prm in childrenPrim) | ||
485 | { | ||
486 | m = prm._mass; | ||
487 | Ptot += prm.CenterOfMass * m; | ||
488 | tmass += m; | ||
489 | } | ||
490 | |||
491 | if (tmass == 0) | ||
492 | tmass = 0; | ||
493 | else | ||
494 | tmass = 1.0f / tmass; | ||
495 | |||
496 | Ptot *= tmass; | ||
497 | return Ptot; | ||
498 | */ | ||
487 | } | 499 | } |
488 | |||
489 | if (tmass == 0) | ||
490 | tmass = 0; | ||
491 | else | 500 | else |
492 | tmass = 1.0f / tmass; | 501 | return _position; |
493 | |||
494 | Ptot *= tmass; | ||
495 | return Ptot; | ||
496 | */ | ||
497 | } | 502 | } |
498 | else | ||
499 | return _position; | ||
500 | } | 503 | } |
501 | } | 504 | } |
502 | /* | 505 | /* |
@@ -1511,7 +1514,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1511 | } | 1514 | } |
1512 | Body = IntPtr.Zero; | 1515 | Body = IntPtr.Zero; |
1513 | hasOOBoffsetFromMesh = false; | 1516 | hasOOBoffsetFromMesh = false; |
1514 | CalcPrimBodyData(); | ||
1515 | } | 1517 | } |
1516 | /* | 1518 | /* |
1517 | private void ChildSetGeom(OdePrim odePrim) | 1519 | private void ChildSetGeom(OdePrim odePrim) |
@@ -1601,7 +1603,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1601 | 1603 | ||
1602 | Body = d.BodyCreate(_parent_scene.world); | 1604 | Body = d.BodyCreate(_parent_scene.world); |
1603 | 1605 | ||
1604 | DMassDup(ref primdMass, out objdmass); | 1606 | objdmass = primdMass; |
1605 | 1607 | ||
1606 | // rotate inertia | 1608 | // rotate inertia |
1607 | myrot.X = _orientation.X; | 1609 | myrot.X = _orientation.X; |
@@ -1623,9 +1625,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1623 | d.Mass tmpdmass = new d.Mass { }; | 1625 | d.Mass tmpdmass = new d.Mass { }; |
1624 | Vector3 rcm; | 1626 | Vector3 rcm; |
1625 | 1627 | ||
1626 | rcm.X = _position.X + objdmass.c.X; | 1628 | rcm.X = _position.X; |
1627 | rcm.Y = _position.Y + objdmass.c.Y; | 1629 | rcm.Y = _position.Y; |
1628 | rcm.Z = _position.Z + objdmass.c.Z; | 1630 | rcm.Z = _position.Z; |
1629 | 1631 | ||
1630 | lock (childrenPrim) | 1632 | lock (childrenPrim) |
1631 | { | 1633 | { |
@@ -1637,7 +1639,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1637 | continue; | 1639 | continue; |
1638 | } | 1640 | } |
1639 | 1641 | ||
1640 | DMassCopy(ref prm.primdMass, ref tmpdmass); | 1642 | tmpdmass = prm.primdMass; |
1641 | 1643 | ||
1642 | // apply prim current rotation to inertia | 1644 | // apply prim current rotation to inertia |
1643 | quat.X = prm._orientation.X; | 1645 | quat.X = prm._orientation.X; |
@@ -1648,10 +1650,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1648 | d.MassRotate(ref tmpdmass, ref mat); | 1650 | d.MassRotate(ref tmpdmass, ref mat); |
1649 | 1651 | ||
1650 | Vector3 ppos = prm._position; | 1652 | Vector3 ppos = prm._position; |
1651 | ppos.X += tmpdmass.c.X - rcm.X; | 1653 | ppos.X -= rcm.X; |
1652 | ppos.Y += tmpdmass.c.Y - rcm.Y; | 1654 | ppos.Y -= rcm.Y; |
1653 | ppos.Z += tmpdmass.c.Z - rcm.Z; | 1655 | ppos.Z -= rcm.Z; |
1654 | |||
1655 | // refer inertia to root prim center of mass position | 1656 | // refer inertia to root prim center of mass position |
1656 | d.MassTranslate(ref tmpdmass, | 1657 | d.MassTranslate(ref tmpdmass, |
1657 | ppos.X, | 1658 | ppos.X, |
@@ -1683,9 +1684,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1683 | d.GeomSetOffsetWorldPosition(prim_geom, _position.X, _position.Y, _position.Z); | 1684 | d.GeomSetOffsetWorldPosition(prim_geom, _position.X, _position.Y, _position.Z); |
1684 | 1685 | ||
1685 | d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body | 1686 | d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z); // ode wants inertia at center of body |
1686 | myrot.W = -myrot.W; | 1687 | myrot.X = -myrot.X; |
1688 | myrot.Y = -myrot.Y; | ||
1689 | myrot.Z = -myrot.Z; | ||
1690 | |||
1687 | d.RfromQ(out mymat, ref myrot); | 1691 | d.RfromQ(out mymat, ref myrot); |
1688 | d.MassRotate(ref objdmass, ref mymat); | 1692 | d.MassRotate(ref objdmass, ref mymat); |
1693 | |||
1689 | d.BodySetMass(Body, ref objdmass); | 1694 | d.BodySetMass(Body, ref objdmass); |
1690 | _mass = objdmass.mass; | 1695 | _mass = objdmass.mass; |
1691 | 1696 | ||
@@ -2237,7 +2242,33 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2237 | case ProfileShape.HalfCircle: | 2242 | case ProfileShape.HalfCircle: |
2238 | if (_pbs.PathCurve == (byte)Extrusion.Curve1) | 2243 | if (_pbs.PathCurve == (byte)Extrusion.Curve1) |
2239 | { | 2244 | { |
2240 | volume *= 0.52359877559829887307710723054658f; | 2245 | volume *= 0.5236f; |
2246 | |||
2247 | if (hollowAmount > 0.0) | ||
2248 | { | ||
2249 | hollowVolume *= hollowAmount; | ||
2250 | |||
2251 | switch (_pbs.HollowShape) | ||
2252 | { | ||
2253 | case HollowShape.Circle: | ||
2254 | case HollowShape.Triangle: // diference in sl is minor and odd | ||
2255 | case HollowShape.Same: | ||
2256 | break; | ||
2257 | |||
2258 | case HollowShape.Square: | ||
2259 | hollowVolume *= 0.909f; | ||
2260 | break; | ||
2261 | |||
2262 | // case HollowShape.Triangle: | ||
2263 | // hollowVolume *= .827f; | ||
2264 | // break; | ||
2265 | default: | ||
2266 | hollowVolume = 0; | ||
2267 | break; | ||
2268 | } | ||
2269 | volume *= (1.0f - hollowVolume); | ||
2270 | } | ||
2271 | |||
2241 | } | 2272 | } |
2242 | break; | 2273 | break; |
2243 | 2274 | ||
@@ -3704,24 +3735,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3704 | return true; | 3735 | return true; |
3705 | } | 3736 | } |
3706 | 3737 | ||
3707 | internal static void DMassCopy(ref d.Mass src, ref d.Mass dst) | ||
3708 | { | ||
3709 | dst.c.W = src.c.W; | ||
3710 | dst.c.X = src.c.X; | ||
3711 | dst.c.Y = src.c.Y; | ||
3712 | dst.c.Z = src.c.Z; | ||
3713 | dst.mass = src.mass; | ||
3714 | dst.I.M00 = src.I.M00; | ||
3715 | dst.I.M01 = src.I.M01; | ||
3716 | dst.I.M02 = src.I.M02; | ||
3717 | dst.I.M10 = src.I.M10; | ||
3718 | dst.I.M11 = src.I.M11; | ||
3719 | dst.I.M12 = src.I.M12; | ||
3720 | dst.I.M20 = src.I.M20; | ||
3721 | dst.I.M21 = src.I.M21; | ||
3722 | dst.I.M22 = src.I.M22; | ||
3723 | } | ||
3724 | |||
3725 | internal static void DMassSubPartFromObj(ref d.Mass part, ref d.Mass theobj) | 3738 | internal static void DMassSubPartFromObj(ref d.Mass part, ref d.Mass theobj) |
3726 | { | 3739 | { |
3727 | // assumes object center of mass is zero | 3740 | // assumes object center of mass is zero |
@@ -3745,25 +3758,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3745 | theobj.I.M22 -= part.I.M22; | 3758 | theobj.I.M22 -= part.I.M22; |
3746 | } | 3759 | } |
3747 | 3760 | ||
3748 | private static void DMassDup(ref d.Mass src, out d.Mass dst) | ||
3749 | { | ||
3750 | dst = new d.Mass { }; | ||
3751 | |||
3752 | dst.c.W = src.c.W; | ||
3753 | dst.c.X = src.c.X; | ||
3754 | dst.c.Y = src.c.Y; | ||
3755 | dst.c.Z = src.c.Z; | ||
3756 | dst.mass = src.mass; | ||
3757 | dst.I.M00 = src.I.M00; | ||
3758 | dst.I.M01 = src.I.M01; | ||
3759 | dst.I.M02 = src.I.M02; | ||
3760 | dst.I.M10 = src.I.M10; | ||
3761 | dst.I.M11 = src.I.M11; | ||
3762 | dst.I.M12 = src.I.M12; | ||
3763 | dst.I.M20 = src.I.M20; | ||
3764 | dst.I.M21 = src.I.M21; | ||
3765 | dst.I.M22 = src.I.M22; | ||
3766 | } | ||
3767 | private void donullchange() | 3761 | private void donullchange() |
3768 | { | 3762 | { |
3769 | } | 3763 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index fa3d33e..84195d3 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -301,7 +301,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
301 | // split static geometry collision into a grid as before | 301 | // split static geometry collision into a grid as before |
302 | private IntPtr[,] staticPrimspace; | 302 | private IntPtr[,] staticPrimspace; |
303 | 303 | ||
304 | private Object OdeLock; | 304 | public Object OdeLock; |
305 | private static Object SimulationLock; | 305 | private static Object SimulationLock; |
306 | 306 | ||
307 | public IMesher mesher; | 307 | public IMesher mesher; |
@@ -746,8 +746,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
746 | ); | 746 | ); |
747 | // do volume detection case | 747 | // do volume detection case |
748 | if ( | 748 | if ( |
749 | (p1 is OdePrim) && (((OdePrim)p1).m_isVolumeDetect) || | 749 | (p1.IsVolumeDtc || p2.IsVolumeDtc)) |
750 | (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect)) | ||
751 | { | 750 | { |
752 | collision_accounting_events(p1, p2, maxDepthContact); | 751 | collision_accounting_events(p1, p2, maxDepthContact); |
753 | return; | 752 | return; |
@@ -1024,9 +1023,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1024 | bool p1events = p1.SubscribedEvents(); | 1023 | bool p1events = p1.SubscribedEvents(); |
1025 | bool p2events = p2.SubscribedEvents(); | 1024 | bool p2events = p2.SubscribedEvents(); |
1026 | 1025 | ||
1027 | if (p1 is OdePrim && p1.IsVolumeDtc) | 1026 | if (p1.IsVolumeDtc) |
1028 | p2events = false; | 1027 | p2events = false; |
1029 | if (p2 is OdePrim && p2.IsVolumeDtc) | 1028 | if (p2.IsVolumeDtc) |
1030 | p1events = false; | 1029 | p1events = false; |
1031 | 1030 | ||
1032 | if (!(p2events || p1events)) | 1031 | if (!(p2events || p1events)) |
@@ -1725,6 +1724,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1725 | // checkThread(); | 1724 | // checkThread(); |
1726 | 1725 | ||
1727 | lock (SimulationLock) | 1726 | lock (SimulationLock) |
1727 | lock(OdeLock) | ||
1728 | { | 1728 | { |
1729 | // adjust number of iterations per step | 1729 | // adjust number of iterations per step |
1730 | try | 1730 | try |