diff options
author | Kitto Flora | 2010-07-13 20:37:13 +0000 |
---|---|---|
committer | Kitto Flora | 2010-07-13 20:37:13 +0000 |
commit | 7ab103c96f3e82cac592f20d61358e1928da8e27 (patch) | |
tree | 0dd397de0b82b9eb2109847122d61bd86134b65e /OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | |
parent | Removed the CHANGED_COLOR event post from the Color accessor in SOP. This is ... (diff) | |
download | opensim-SC_OLD-7ab103c96f3e82cac592f20d61358e1928da8e27.zip opensim-SC_OLD-7ab103c96f3e82cac592f20d61358e1928da8e27.tar.gz opensim-SC_OLD-7ab103c96f3e82cac592f20d61358e1928da8e27.tar.bz2 opensim-SC_OLD-7ab103c96f3e82cac592f20d61358e1928da8e27.tar.xz |
Rewrite collision dictionary handling, cleans up deleted obects/avs. Fixes occasional collision event failure. ChOde only.
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 7ce01dc..6b17ce7 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | |||
@@ -142,7 +142,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
142 | private OdeScene _parent_scene; | 142 | private OdeScene _parent_scene; |
143 | public IntPtr m_targetSpace = IntPtr.Zero; | 143 | public IntPtr m_targetSpace = IntPtr.Zero; |
144 | public IntPtr prim_geom; | 144 | public IntPtr prim_geom; |
145 | public IntPtr prev_geom; | 145 | // public IntPtr prev_geom; |
146 | public IntPtr _triMeshData; | 146 | public IntPtr _triMeshData; |
147 | 147 | ||
148 | private IntPtr _linkJointGroup = IntPtr.Zero; | 148 | private IntPtr _linkJointGroup = IntPtr.Zero; |
@@ -274,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
274 | 274 | ||
275 | 275 | ||
276 | prim_geom = IntPtr.Zero; | 276 | prim_geom = IntPtr.Zero; |
277 | prev_geom = IntPtr.Zero; | 277 | // prev_geom = IntPtr.Zero; |
278 | 278 | ||
279 | if (!pos.IsFinite()) | 279 | if (!pos.IsFinite()) |
280 | { | 280 | { |
@@ -776,13 +776,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
776 | 776 | ||
777 | public void SetGeom(IntPtr geom) | 777 | public void SetGeom(IntPtr geom) |
778 | { | 778 | { |
779 | prev_geom = prim_geom; | 779 | if(prim_geom != IntPtr.Zero) |
780 | { | ||
781 | // Remove any old entries | ||
782 | //string tPA; | ||
783 | //_parent_scene.geom_name_map.TryGetValue(prim_geom, out tPA); | ||
784 | //Console.WriteLine("**** Remove {0}", tPA); | ||
785 | if(_parent_scene.geom_name_map.ContainsKey(prim_geom)) _parent_scene.geom_name_map.Remove(prim_geom); | ||
786 | if(_parent_scene.actor_name_map.ContainsKey(prim_geom)) _parent_scene.actor_name_map.Remove(prim_geom); | ||
787 | d.GeomDestroy(prim_geom); | ||
788 | } | ||
789 | |||
780 | prim_geom = geom; | 790 | prim_geom = geom; |
781 | //Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName); | 791 | //Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName); |
782 | if (prim_geom != IntPtr.Zero) | 792 | if (prim_geom != IntPtr.Zero) |
783 | { | 793 | { |
794 | _parent_scene.geom_name_map[prim_geom] = this.m_primName; | ||
795 | _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; | ||
784 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | 796 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
785 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 797 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
798 | //Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, this.m_primName); | ||
786 | } | 799 | } |
787 | 800 | ||
788 | if (childPrim) | 801 | if (childPrim) |
@@ -1774,17 +1787,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1774 | public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) | 1787 | public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) |
1775 | { | 1788 | { |
1776 | //Console.WriteLine("CreateGeom:"); | 1789 | //Console.WriteLine("CreateGeom:"); |
1777 | if (_mesh != null) | 1790 | if (_mesh != null) // Special - make mesh |
1778 | { | 1791 | { |
1779 | setMesh(_parent_scene, _mesh); | 1792 | setMesh(_parent_scene, _mesh); |
1780 | } | 1793 | } |
1781 | else | 1794 | else // not a mesh |
1782 | { | 1795 | { |
1783 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | 1796 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) // special profile?? |
1784 | { | 1797 | { |
1785 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | 1798 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) // Equi-size |
1786 | { | 1799 | { |
1787 | if (((_size.X / 2f) > 0f)) | 1800 | if (((_size.X / 2f) > 0f)) // Has size |
1788 | { | 1801 | { |
1789 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1802 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
1790 | try | 1803 | try |
@@ -1815,7 +1828,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1815 | } | 1828 | } |
1816 | } | 1829 | } |
1817 | } | 1830 | } |
1818 | else | 1831 | else // not equi-size |
1819 | { | 1832 | { |
1820 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1833 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
1821 | try | 1834 | try |
@@ -1832,7 +1845,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1832 | } | 1845 | } |
1833 | } | 1846 | } |
1834 | 1847 | ||
1835 | else | 1848 | else // not special profile |
1836 | { | 1849 | { |
1837 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1850 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
1838 | try | 1851 | try |
@@ -1894,9 +1907,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1894 | } | 1907 | } |
1895 | } | 1908 | } |
1896 | 1909 | ||
1897 | _parent_scene.geom_name_map[prim_geom] = this.m_primName; | ||
1898 | _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; | ||
1899 | |||
1900 | changeSelectedStatus(timestep); | 1910 | changeSelectedStatus(timestep); |
1901 | 1911 | ||
1902 | m_taintadd = false; | 1912 | m_taintadd = false; |
@@ -2045,22 +2055,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2045 | { | 2055 | { |
2046 | if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) | 2056 | if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) |
2047 | { | 2057 | { |
2048 | 2058 | _mesh = null; | |
2049 | |||
2050 | if (prim_geom != IntPtr.Zero) | ||
2051 | { | ||
2052 | try | ||
2053 | { | ||
2054 | d.GeomDestroy(prim_geom); | ||
2055 | prim_geom = IntPtr.Zero; | ||
2056 | _mesh = null; | ||
2057 | } | ||
2058 | catch (System.AccessViolationException) | ||
2059 | { | ||
2060 | prim_geom = IntPtr.Zero; | ||
2061 | m_log.Error("[PHYSICS]: PrimGeom dead"); | ||
2062 | } | ||
2063 | } | ||
2064 | //Console.WriteLine("changePhysicsStatus for " + m_primName ); | 2059 | //Console.WriteLine("changePhysicsStatus for " + m_primName ); |
2065 | changeadd(2f); | 2060 | changeadd(2f); |
2066 | } | 2061 | } |
@@ -2120,8 +2115,6 @@ Console.WriteLine(" JointCreateFixed"); | |||
2120 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 2115 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
2121 | d.SpaceRemove(m_targetSpace, prim_geom); | 2116 | d.SpaceRemove(m_targetSpace, prim_geom); |
2122 | } | 2117 | } |
2123 | d.GeomDestroy(prim_geom); | ||
2124 | prim_geom = IntPtr.Zero; | ||
2125 | // we don't need to do space calculation because the client sends a position update also. | 2118 | // we don't need to do space calculation because the client sends a position update also. |
2126 | 2119 | ||
2127 | // Construction of new prim | 2120 | // Construction of new prim |
@@ -2223,16 +2216,8 @@ Console.WriteLine(" JointCreateFixed"); | |||
2223 | disableBody(); | 2216 | disableBody(); |
2224 | } | 2217 | } |
2225 | } | 2218 | } |
2226 | try | 2219 | |
2227 | { | 2220 | |
2228 | d.GeomDestroy(prim_geom); | ||
2229 | } | ||
2230 | catch (System.AccessViolationException) | ||
2231 | { | ||
2232 | prim_geom = IntPtr.Zero; | ||
2233 | m_log.Error("[PHYSICS]: PrimGeom dead"); | ||
2234 | } | ||
2235 | prim_geom = IntPtr.Zero; | ||
2236 | // we don't need to do space calculation because the client sends a position update also. | 2221 | // we don't need to do space calculation because the client sends a position update also. |
2237 | if (_size.X <= 0) _size.X = 0.01f; | 2222 | if (_size.X <= 0) _size.X = 0.01f; |
2238 | if (_size.Y <= 0) _size.Y = 0.01f; | 2223 | if (_size.Y <= 0) _size.Y = 0.01f; |