aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs117
1 files changed, 50 insertions, 67 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index c0c33da..d63b9a4 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -1804,22 +1804,18 @@ namespace OpenSim.Region.Physics.OdePlugin
1804 mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap 1804 mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap
1805 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage 1805 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
1806 1806
1807 // warning this destroys the mesh for eventual future use. Only pinned float arrays stay valid
1808 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
1809
1807 if (vertexCount == 0 || indexCount == 0) 1810 if (vertexCount == 0 || indexCount == 0)
1808 { 1811 {
1809 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); 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);
1810 _size.X = 0.01f; 1813 _size.X = 0.01f;
1811 _size.Y = 0.01f; 1814 _size.Y = 0.01f;
1812 _size.Z = 0.01f; 1815 _size.Z = 0.01f;
1813 mesh.releaseSourceMeshData(); 1816 return false;
1814 // Temporarily hacking this to true which causes the object
1815 // to get no physical representation, effectively making it
1816 // phantom
1817 return true;
1818 } 1817 }
1819 1818
1820
1821 // warning this destroys the mesh for eventual future use. Only pinned float arrays stay valid
1822 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
1823/* 1819/*
1824 if (m_MeshToTriMeshMap.ContainsKey(mesh)) 1820 if (m_MeshToTriMeshMap.ContainsKey(mesh))
1825 { 1821 {
@@ -1846,16 +1842,18 @@ namespace OpenSim.Region.Physics.OdePlugin
1846 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null)); 1842 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null));
1847 // } 1843 // }
1848 } 1844 }
1849 catch (AccessViolationException) 1845 catch (Exception e)
1850 { 1846 {
1851 m_log.Error("[PHYSICS]: MESH LOCKED"); 1847 m_log.ErrorFormat("[PHYSICS]: Create trimesh failed on prim {0} : {1}",Name,e.Message);
1852 1848
1853 if (_triMeshData != IntPtr.Zero) 1849 if (_triMeshData != IntPtr.Zero)
1854 { 1850 {
1855 d.GeomTriMeshDataDestroy(_triMeshData); 1851 d.GeomTriMeshDataDestroy(_triMeshData);
1856 _triMeshData = IntPtr.Zero; 1852 _triMeshData = IntPtr.Zero;
1857 } 1853 }
1858 1854 _size.X = 0.01f;
1855 _size.Y = 0.01f;
1856 _size.Z = 0.01f;
1859 return false; 1857 return false;
1860 } 1858 }
1861 1859
@@ -1878,6 +1876,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1878 changeadd(timestep); 1876 changeadd(timestep);
1879 } 1877 }
1880 1878
1879 if (m_taintremove)
1880 return;
1881
1881 if (prim_geom != IntPtr.Zero) 1882 if (prim_geom != IntPtr.Zero)
1882 { 1883 {
1883 if (!_position.ApproxEquals(m_taintposition, 0f)) 1884 if (!_position.ApproxEquals(m_taintposition, 0f))
@@ -2340,71 +2341,49 @@ namespace OpenSim.Region.Physics.OdePlugin
2340 gottrimesh = setMesh(_parent_scene, _mesh); 2341 gottrimesh = setMesh(_parent_scene, _mesh);
2341 } 2342 }
2342 2343
2343 if(!gottrimesh) // not a mesh 2344 if (!gottrimesh) // not a mesh
2344 { 2345 {
2345 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) // special profile?? 2346 IntPtr geo = IntPtr.Zero;
2347
2348 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1
2349 && _size.X == _size.Y && _size.X == _size.Z)
2346 { 2350 {
2347 if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) // Equi-size 2351 // its a sphere
2352 _parent_scene.waitForSpaceUnlock(m_targetSpace);
2353 try
2348 { 2354 {
2349 if (((_size.X / 2f) > 0f)) // Has size 2355 geo = d.CreateSphere(m_targetSpace, _size.X * 0.5f);
2350 {
2351 _parent_scene.waitForSpaceUnlock(m_targetSpace);
2352 try
2353 {
2354 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2));
2355 }
2356 catch (AccessViolationException)
2357 {
2358 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
2359 ode.dunlock(_parent_scene.world);
2360 return;
2361 }
2362 }
2363 else
2364 {
2365 _parent_scene.waitForSpaceUnlock(m_targetSpace);
2366 try
2367 {
2368 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
2369 }
2370 catch (AccessViolationException)
2371 {
2372 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
2373 ode.dunlock(_parent_scene.world);
2374 return;
2375 }
2376 }
2377 } 2356 }
2378 else // not equi-size 2357 catch (Exception e)
2379 { 2358 {
2380 _parent_scene.waitForSpaceUnlock(m_targetSpace); 2359 m_log.WarnFormat("[PHYSICS]: Unable to create basic sphere for object {0}", e.Message);
2381 try 2360 geo = IntPtr.Zero;
2382 { 2361 ode.dunlock(_parent_scene.world);
2383 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
2384 }
2385 catch (AccessViolationException)
2386 {
2387 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
2388 ode.dunlock(_parent_scene.world);
2389 return;
2390 }
2391 } 2362 }
2392 } 2363 }
2393 2364 else // make it a box
2394 else // not special profile
2395 { 2365 {
2396 _parent_scene.waitForSpaceUnlock(m_targetSpace); 2366 _parent_scene.waitForSpaceUnlock(m_targetSpace);
2397 try 2367 try
2398 { 2368 {
2399 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 2369 geo = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
2400 } 2370 }
2401 catch (AccessViolationException) 2371 catch (Exception e)
2402 { 2372 {
2403 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); 2373 m_log.WarnFormat("[PHYSICS]: Unable to create basic sphere for object {0}", e.Message);
2374 geo = IntPtr.Zero;
2404 ode.dunlock(_parent_scene.world); 2375 ode.dunlock(_parent_scene.world);
2405 return;
2406 } 2376 }
2407 } 2377 }
2378
2379 if (geo == IntPtr.Zero)
2380 {
2381 m_taintremove = true;
2382 _parent_scene.AddPhysicsActorTaint(this);
2383 return;
2384 }
2385
2386 SetGeom(geo);
2408 } 2387 }
2409 } 2388 }
2410 2389
@@ -2422,7 +2401,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2422 { 2401 {
2423 if (_parent_scene.needsMeshing(_pbs)) 2402 if (_parent_scene.needsMeshing(_pbs))
2424 { 2403 {
2425 // Don't need to re-enable body.. it's done in SetMesh
2426 try 2404 try
2427 { 2405 {
2428 _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, (int)LevelOfDetail.High, true); 2406 _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, (int)LevelOfDetail.High, true);
@@ -2431,9 +2409,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2431 { 2409 {
2432 //Don't continuously try to mesh prims when meshing has failed 2410 //Don't continuously try to mesh prims when meshing has failed
2433 m_meshfailed = true; 2411 m_meshfailed = true;
2412 _mesh = null;
2413 m_log.WarnFormat("[PHYSICS]: changeAdd CreateMesh fail on prim {0} at <{1},{2},{3}>", Name, _position.X, _position.Y, _position.Z);
2434 } 2414 }
2435 // createmesh returns null when it's a shape that isn't a cube.
2436 // m_log.Debug(m_localID);
2437 } 2415 }
2438 } 2416 }
2439 2417
@@ -2685,12 +2663,12 @@ namespace OpenSim.Region.Physics.OdePlugin
2685 catch 2663 catch
2686 { 2664 {
2687 m_meshfailed = true; 2665 m_meshfailed = true;
2666 mesh = null;
2667 m_log.WarnFormat("[PHYSICS]: changeSize CreateMesh fail on prim {0} at <{1},{2},{3}>", Name, _position.X, _position.Y, _position.Z);
2688 } 2668 }
2689 2669
2690 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 2670 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
2691 CreateGeom(m_targetSpace, mesh); 2671 CreateGeom(m_targetSpace, mesh);
2692
2693
2694 } 2672 }
2695 else 2673 else
2696 { 2674 {
@@ -2782,18 +2760,23 @@ namespace OpenSim.Region.Physics.OdePlugin
2782 { 2760 {
2783 // Don't need to re-enable body.. it's done in SetMesh 2761 // Don't need to re-enable body.. it's done in SetMesh
2784 float meshlod = _parent_scene.meshSculptLOD; 2762 float meshlod = _parent_scene.meshSculptLOD;
2763 IMesh mesh;
2785 2764
2786 if (IsPhysical) 2765 if (IsPhysical)
2787 meshlod = _parent_scene.MeshSculptphysicalLOD; 2766 meshlod = _parent_scene.MeshSculptphysicalLOD;
2788 try 2767 try
2789 { 2768 {
2790 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true); 2769 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true);
2791 CreateGeom(m_targetSpace, mesh);
2792 } 2770 }
2793 catch 2771 catch
2794 { 2772 {
2773 mesh = null;
2795 m_meshfailed = true; 2774 m_meshfailed = true;
2775 m_log.WarnFormat("[PHYSICS]: changeAdd CreateMesh fail on prim {0} at <{1},{2},{3}>", Name, _position.X, _position.Y, _position.Z);
2796 } 2776 }
2777
2778 CreateGeom(m_targetSpace, mesh);
2779
2797 // createmesh returns null when it doesn't mesh. 2780 // createmesh returns null when it doesn't mesh.
2798 } 2781 }
2799 else 2782 else