diff options
author | UbitUmarov | 2012-03-11 07:44:34 +0000 |
---|---|---|
committer | UbitUmarov | 2012-03-11 07:44:34 +0000 |
commit | 43dc0ee02066a38b46383412b15a69b847975a79 (patch) | |
tree | 8ed2e8d64809070ac7bca6b6ed218eda64682fbc /OpenSim/Region/Physics/ChOdePlugin | |
parent | initial steps to support physical phantoms (diff) | |
download | opensim-SC_OLD-43dc0ee02066a38b46383412b15a69b847975a79.zip opensim-SC_OLD-43dc0ee02066a38b46383412b15a69b847975a79.tar.gz opensim-SC_OLD-43dc0ee02066a38b46383412b15a69b847975a79.tar.bz2 opensim-SC_OLD-43dc0ee02066a38b46383412b15a69b847975a79.tar.xz |
more phantom physics ( chODE and a fix in manager physicsactor
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 181 |
1 files changed, 120 insertions, 61 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 42a408e..f9548d2 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | |||
@@ -453,6 +453,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | public override bool Phantom | ||
457 | { | ||
458 | get { return m_isphantom; } | ||
459 | set | ||
460 | { | ||
461 | m_isphantom = value; | ||
462 | } | ||
463 | } | ||
464 | |||
456 | public void setPrimForRemoval() | 465 | public void setPrimForRemoval() |
457 | { | 466 | { |
458 | m_taintremove = true; | 467 | m_taintremove = true; |
@@ -896,7 +905,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
896 | if (m_NoColide) | 905 | if (m_NoColide) |
897 | { | 906 | { |
898 | d.GeomSetCategoryBits(prim_geom, 0); | 907 | d.GeomSetCategoryBits(prim_geom, 0); |
899 | if (m_isphysical) | 908 | if (m_isphysical && !m_isVolumeDetect) |
900 | { | 909 | { |
901 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); | 910 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); |
902 | } | 911 | } |
@@ -1405,10 +1414,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1405 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | 1414 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
1406 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 1415 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
1407 | } | 1416 | } |
1408 | |||
1409 | } | 1417 | } |
1410 | 1418 | ||
1411 | |||
1412 | Body = IntPtr.Zero; | 1419 | Body = IntPtr.Zero; |
1413 | } | 1420 | } |
1414 | } | 1421 | } |
@@ -1416,7 +1423,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1416 | m_collisionscore = 0; | 1423 | m_collisionscore = 0; |
1417 | } | 1424 | } |
1418 | 1425 | ||
1419 | private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>(); | 1426 | // private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>(); |
1420 | 1427 | ||
1421 | public bool setMesh(OdeScene parent_scene, IMesh mesh) | 1428 | public bool setMesh(OdeScene parent_scene, IMesh mesh) |
1422 | { | 1429 | { |
@@ -1513,12 +1520,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1513 | } | 1520 | } |
1514 | } | 1521 | } |
1515 | // | 1522 | // |
1523 | if (m_taintphantom != m_isphantom ) | ||
1524 | { | ||
1525 | changePhantomStatus(); | ||
1526 | }// | ||
1516 | 1527 | ||
1517 | if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) | 1528 | if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) |
1518 | { | 1529 | { |
1519 | changePhysicsStatus(timestep); | 1530 | changePhysicsStatus(timestep); |
1520 | }// | 1531 | }// |
1521 | 1532 | ||
1533 | |||
1522 | if (!_size.ApproxEquals(m_taintsize, 0f)) | 1534 | if (!_size.ApproxEquals(m_taintsize, 0f)) |
1523 | changesize(timestep); | 1535 | changesize(timestep); |
1524 | // | 1536 | // |
@@ -1540,7 +1552,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1540 | changedisable(timestep); | 1552 | changedisable(timestep); |
1541 | 1553 | ||
1542 | if (m_taintselected != m_isSelected) | 1554 | if (m_taintselected != m_isSelected) |
1543 | changeSelectedStatus(timestep); | 1555 | changeSelectedStatus(); |
1544 | 1556 | ||
1545 | if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) | 1557 | if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) |
1546 | changevelocity(timestep); | 1558 | changevelocity(timestep); |
@@ -1571,16 +1583,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1571 | 1583 | ||
1572 | } | 1584 | } |
1573 | 1585 | ||
1574 | /* obsolete | ||
1575 | private void changeAngularLock(float timestep) | ||
1576 | { | ||
1577 | if (_parent == null) | ||
1578 | { | ||
1579 | m_angularLock = m_taintAngularLock; | ||
1580 | m_angularLockSet = true; | ||
1581 | } | ||
1582 | } | ||
1583 | */ | ||
1584 | private void changelink(float timestep) | 1586 | private void changelink(float timestep) |
1585 | { | 1587 | { |
1586 | // If the newly set parent is not null | 1588 | // If the newly set parent is not null |
@@ -1590,18 +1592,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1590 | if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) | 1592 | if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) |
1591 | { | 1593 | { |
1592 | OdePrim obj = (OdePrim)m_taintparent; | 1594 | OdePrim obj = (OdePrim)m_taintparent; |
1593 | //obj.disableBody(); | ||
1594 | obj.ParentPrim(this); | 1595 | obj.ParentPrim(this); |
1595 | |||
1596 | /* | ||
1597 | if (obj.Body != (IntPtr)0 && Body != (IntPtr)0 && obj.Body != Body) | ||
1598 | { | ||
1599 | _linkJointGroup = d.JointGroupCreate(0); | ||
1600 | m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup); | ||
1601 | d.JointAttach(m_linkJoint, obj.Body, Body); | ||
1602 | d.JointSetFixed(m_linkJoint); | ||
1603 | } | ||
1604 | */ | ||
1605 | } | 1596 | } |
1606 | } | 1597 | } |
1607 | // If the newly set parent is null | 1598 | // If the newly set parent is null |
@@ -1613,16 +1604,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1613 | OdePrim obj = (OdePrim)_parent; | 1604 | OdePrim obj = (OdePrim)_parent; |
1614 | obj.ChildDelink(this); | 1605 | obj.ChildDelink(this); |
1615 | childPrim = false; | 1606 | childPrim = false; |
1616 | //_parent = null; | ||
1617 | } | 1607 | } |
1618 | |||
1619 | /* | ||
1620 | if (Body != (IntPtr)0 && _linkJointGroup != (IntPtr)0) | ||
1621 | d.JointGroupDestroy(_linkJointGroup); | ||
1622 | |||
1623 | _linkJointGroup = (IntPtr)0; | ||
1624 | m_linkJoint = (IntPtr)0; | ||
1625 | */ | ||
1626 | } | 1608 | } |
1627 | 1609 | ||
1628 | _parent = m_taintparent; | 1610 | _parent = m_taintparent; |
@@ -1672,9 +1654,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1672 | } | 1654 | } |
1673 | foreach (OdePrim prm in childrenPrim) | 1655 | foreach (OdePrim prm in childrenPrim) |
1674 | { | 1656 | { |
1675 | prm.m_collisionCategories |= CollisionCategories.Body; | 1657 | if (m_isphantom && !prm.m_isVolumeDetect) |
1676 | prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | 1658 | { |
1677 | 1659 | prm.m_collisionCategories = 0; | |
1660 | prm.m_collisionFlags = CollisionCategories.Land; | ||
1661 | } | ||
1662 | else | ||
1663 | { | ||
1664 | prm.m_collisionCategories |= CollisionCategories.Body; | ||
1665 | prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1666 | } | ||
1678 | if (prm.prim_geom == IntPtr.Zero) | 1667 | if (prm.prim_geom == IntPtr.Zero) |
1679 | { | 1668 | { |
1680 | m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); | 1669 | m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); |
@@ -1728,8 +1717,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1728 | _parent_scene.addActivePrim(prm); | 1717 | _parent_scene.addActivePrim(prm); |
1729 | } | 1718 | } |
1730 | 1719 | ||
1731 | m_collisionCategories |= CollisionCategories.Body; | 1720 | if (m_isphantom && !m_isVolumeDetect) |
1732 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | 1721 | { |
1722 | m_collisionCategories = 0; | ||
1723 | m_collisionFlags = CollisionCategories.Land; | ||
1724 | } | ||
1725 | else | ||
1726 | { | ||
1727 | m_collisionCategories |= CollisionCategories.Body; | ||
1728 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1729 | } | ||
1733 | 1730 | ||
1734 | if (m_NoColide) | 1731 | if (m_NoColide) |
1735 | { | 1732 | { |
@@ -1779,23 +1776,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1779 | 1776 | ||
1780 | private void ChildSetGeom(OdePrim odePrim) | 1777 | private void ChildSetGeom(OdePrim odePrim) |
1781 | { | 1778 | { |
1782 | //if (m_isphysical && Body != IntPtr.Zero) | ||
1783 | lock (childrenPrim) | 1779 | lock (childrenPrim) |
1784 | { | 1780 | { |
1785 | foreach (OdePrim prm in childrenPrim) | 1781 | foreach (OdePrim prm in childrenPrim) |
1786 | { | 1782 | { |
1787 | //prm.childPrim = true; | ||
1788 | prm.disableBody(); | 1783 | prm.disableBody(); |
1789 | //prm.m_taintparent = null; | ||
1790 | //prm._parent = null; | ||
1791 | //prm.m_taintPhysics = false; | ||
1792 | //prm.m_disabled = true; | ||
1793 | //prm.childPrim = false; | ||
1794 | } | 1784 | } |
1795 | } | 1785 | } |
1796 | disableBody(); | 1786 | disableBody(); |
1797 | 1787 | ||
1798 | |||
1799 | if (Body != IntPtr.Zero) | 1788 | if (Body != IntPtr.Zero) |
1800 | { | 1789 | { |
1801 | _parent_scene.remActivePrim(this); | 1790 | _parent_scene.remActivePrim(this); |
@@ -1808,7 +1797,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1808 | ParentPrim(prm); | 1797 | ParentPrim(prm); |
1809 | } | 1798 | } |
1810 | } | 1799 | } |
1811 | |||
1812 | } | 1800 | } |
1813 | 1801 | ||
1814 | private void ChildDelink(OdePrim odePrim) | 1802 | private void ChildDelink(OdePrim odePrim) |
@@ -1820,11 +1808,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1820 | { | 1808 | { |
1821 | prm.childPrim = true; | 1809 | prm.childPrim = true; |
1822 | prm.disableBody(); | 1810 | prm.disableBody(); |
1823 | //prm.m_taintparent = null; | ||
1824 | //prm._parent = null; | ||
1825 | //prm.m_taintPhysics = false; | ||
1826 | //prm.m_disabled = true; | ||
1827 | //prm.childPrim = false; | ||
1828 | } | 1811 | } |
1829 | } | 1812 | } |
1830 | disableBody(); | 1813 | disableBody(); |
@@ -1848,7 +1831,73 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1848 | } | 1831 | } |
1849 | } | 1832 | } |
1850 | 1833 | ||
1851 | private void changeSelectedStatus(float timestep) | 1834 | private void changePhantomStatus() |
1835 | { | ||
1836 | m_taintphantom = m_isphantom; | ||
1837 | changeSelectedStatus(); | ||
1838 | } | ||
1839 | |||
1840 | /* not in use | ||
1841 | private void SetCollider() | ||
1842 | { | ||
1843 | SetCollider(m_isSelected, m_isphysical, m_isphantom, m_isSelected); | ||
1844 | } | ||
1845 | |||
1846 | private void SetCollider(bool sel, bool phys, bool phan, bool vdtc) | ||
1847 | { | ||
1848 | if (sel) | ||
1849 | { | ||
1850 | m_collisionCategories = CollisionCategories.Selected; | ||
1851 | m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space); | ||
1852 | } | ||
1853 | else | ||
1854 | { | ||
1855 | if (phan && !vdtc) | ||
1856 | { | ||
1857 | m_collisionCategories = 0; | ||
1858 | if (phys) | ||
1859 | m_collisionFlags = CollisionCategories.Land; | ||
1860 | else | ||
1861 | m_collisionFlags = 0; // this case should not happen non physical phantoms should not have physics | ||
1862 | } | ||
1863 | else | ||
1864 | { | ||
1865 | m_collisionCategories = CollisionCategories.Geom; | ||
1866 | if (phys) | ||
1867 | m_collisionCategories |= CollisionCategories.Body; | ||
1868 | |||
1869 | m_collisionFlags = m_default_collisionFlags; | ||
1870 | |||
1871 | if (m_collidesLand) | ||
1872 | m_collisionFlags |= CollisionCategories.Land; | ||
1873 | if (m_collidesWater) | ||
1874 | m_collisionFlags |= CollisionCategories.Water; | ||
1875 | } | ||
1876 | } | ||
1877 | |||
1878 | if (prim_geom != IntPtr.Zero) | ||
1879 | { | ||
1880 | if (m_NoColide) | ||
1881 | { | ||
1882 | d.GeomSetCategoryBits(prim_geom, 0); | ||
1883 | if (phys) | ||
1884 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); | ||
1885 | else | ||
1886 | { | ||
1887 | d.GeomSetCollideBits(prim_geom, 0); | ||
1888 | d.GeomDisable(prim_geom); | ||
1889 | } | ||
1890 | } | ||
1891 | else | ||
1892 | { | ||
1893 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1894 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1895 | } | ||
1896 | } | ||
1897 | } | ||
1898 | */ | ||
1899 | |||
1900 | private void changeSelectedStatus() | ||
1852 | { | 1901 | { |
1853 | if (m_taintselected) | 1902 | if (m_taintselected) |
1854 | { | 1903 | { |
@@ -1901,10 +1950,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1901 | d.BodySetAngularVel(Body, 0.0f, 0.0f, 0.0f); | 1950 | d.BodySetAngularVel(Body, 0.0f, 0.0f, 0.0f); |
1902 | d.BodySetTorque(Body, 0.0f, 0.0f, 0.0f); | 1951 | d.BodySetTorque(Body, 0.0f, 0.0f, 0.0f); |
1903 | } | 1952 | } |
1904 | |||
1905 | } | 1953 | } |
1906 | else | 1954 | else |
1907 | { | 1955 | { |
1956 | if (m_isphantom && !m_isVolumeDetect) | ||
1957 | { | ||
1958 | m_collisionCategories = 0; | ||
1959 | if (m_isphysical) | ||
1960 | m_collisionFlags = CollisionCategories.Land; | ||
1961 | else | ||
1962 | m_collisionFlags = 0; // this case should not happen non physical phantoms should not have physics | ||
1963 | } | ||
1964 | else | ||
1965 | { | ||
1908 | m_collisionCategories = CollisionCategories.Geom; | 1966 | m_collisionCategories = CollisionCategories.Geom; |
1909 | if (m_isphysical) | 1967 | if (m_isphysical) |
1910 | m_collisionCategories |= CollisionCategories.Body; | 1968 | m_collisionCategories |= CollisionCategories.Body; |
@@ -1915,6 +1973,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1915 | m_collisionFlags |= CollisionCategories.Land; | 1973 | m_collisionFlags |= CollisionCategories.Land; |
1916 | if (m_collidesWater) | 1974 | if (m_collidesWater) |
1917 | m_collisionFlags |= CollisionCategories.Water; | 1975 | m_collisionFlags |= CollisionCategories.Water; |
1976 | } | ||
1918 | 1977 | ||
1919 | if (prim_geom != IntPtr.Zero) | 1978 | if (prim_geom != IntPtr.Zero) |
1920 | { | 1979 | { |
@@ -2092,7 +2151,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2092 | } | 2151 | } |
2093 | } | 2152 | } |
2094 | 2153 | ||
2095 | changeSelectedStatus(timestep); | 2154 | changeSelectedStatus(); |
2096 | 2155 | ||
2097 | m_taintadd = false; | 2156 | m_taintadd = false; |
2098 | } | 2157 | } |
@@ -2167,7 +2226,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2167 | } | 2226 | } |
2168 | } | 2227 | } |
2169 | 2228 | ||
2170 | changeSelectedStatus(timestep); | 2229 | changeSelectedStatus(); |
2171 | 2230 | ||
2172 | resetCollisionAccounting(); | 2231 | resetCollisionAccounting(); |
2173 | m_taintposition = _position; | 2232 | m_taintposition = _position; |
@@ -2254,7 +2313,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2254 | } | 2313 | } |
2255 | } | 2314 | } |
2256 | 2315 | ||
2257 | changeSelectedStatus(timestep); | 2316 | changeSelectedStatus(); |
2258 | 2317 | ||
2259 | resetCollisionAccounting(); | 2318 | resetCollisionAccounting(); |
2260 | m_taintPhysics = m_isphysical; | 2319 | m_taintPhysics = m_isphysical; |
@@ -2348,7 +2407,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2348 | 2407 | ||
2349 | _parent_scene.geom_name_map[prim_geom] = oldname; | 2408 | _parent_scene.geom_name_map[prim_geom] = oldname; |
2350 | 2409 | ||
2351 | changeSelectedStatus(timestamp); | 2410 | changeSelectedStatus(); |
2352 | if (childPrim) | 2411 | if (childPrim) |
2353 | { | 2412 | { |
2354 | if (_parent is OdePrim) | 2413 | if (_parent is OdePrim) |
@@ -2460,7 +2519,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2460 | } | 2519 | } |
2461 | _parent_scene.geom_name_map[prim_geom] = oldname; | 2520 | _parent_scene.geom_name_map[prim_geom] = oldname; |
2462 | 2521 | ||
2463 | changeSelectedStatus(timestamp); | 2522 | changeSelectedStatus(); |
2464 | if (childPrim) | 2523 | if (childPrim) |
2465 | { | 2524 | { |
2466 | if (_parent is OdePrim) | 2525 | if (_parent is OdePrim) |