aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
authorUbitUmarov2012-10-09 00:18:39 +0100
committerUbitUmarov2012-10-09 00:18:39 +0100
commit3bf7201fd4d3e2b240f8139c20f88c916d338c31 (patch)
treef58ae6354071c182e487a72d9e5afad58c98d8a6 /OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
parent a few changes/fix (?) (diff)
downloadopensim-SC_OLD-3bf7201fd4d3e2b240f8139c20f88c916d338c31.zip
opensim-SC_OLD-3bf7201fd4d3e2b240f8139c20f88c916d338c31.tar.gz
opensim-SC_OLD-3bf7201fd4d3e2b240f8139c20f88c916d338c31.tar.bz2
opensim-SC_OLD-3bf7201fd4d3e2b240f8139c20f88c916d338c31.tar.xz
move terrain geom to own ode space. Limit range on raycast if includes
terrain until ode doesn't eat all stack. Add a pre-simulation method to do pending actors changes (except mesh assets still not ready to use), to be optionaly called before firing heartbeat. [UNTESTED]
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs128
1 files changed, 80 insertions, 48 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index c2c4384..535a4e2 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -1325,12 +1325,48 @@ namespace OpenSim.Region.Physics.OdePlugin
1325 } 1325 }
1326 } 1326 }
1327 1327
1328
1329 private void SetGeom(IntPtr geom)
1330 {
1331 prim_geom = geom;
1332 //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name);
1333 if (prim_geom != IntPtr.Zero)
1334 {
1335
1336 if (m_NoColide)
1337 {
1338 d.GeomSetCategoryBits(prim_geom, 0);
1339 if (m_isphysical)
1340 {
1341 d.GeomSetCollideBits(prim_geom, (uint)CollisionCategories.Land);
1342 }
1343 else
1344 {
1345 d.GeomSetCollideBits(prim_geom, 0);
1346 d.GeomDisable(prim_geom);
1347 }
1348 }
1349 else
1350 {
1351 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1352 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1353 }
1354
1355 UpdatePrimBodyData();
1356 _parent_scene.actor_name_map[prim_geom] = this;
1357
1358 }
1359 else
1360 m_log.Warn("Setting bad Geom");
1361 }
1362
1328 private bool GetMeshGeom() 1363 private bool GetMeshGeom()
1329 { 1364 {
1330 IntPtr vertices, indices; 1365 IntPtr vertices, indices;
1331 int vertexCount, indexCount; 1366 int vertexCount, indexCount;
1332 int vertexStride, triStride; 1367 int vertexStride, triStride;
1333 1368
1369
1334 IMesh mesh = m_mesh; 1370 IMesh mesh = m_mesh;
1335 1371
1336 if (mesh == null) 1372 if (mesh == null)
@@ -1356,6 +1392,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1356 m_mesh = null; 1392 m_mesh = null;
1357 return false; 1393 return false;
1358 } 1394 }
1395
1396 IntPtr geo = IntPtr.Zero;
1397
1359 try 1398 try
1360 { 1399 {
1361 _triMeshData = d.GeomTriMeshDataCreate(); 1400 _triMeshData = d.GeomTriMeshDataCreate();
@@ -1363,7 +1402,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1363 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 1402 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
1364 d.GeomTriMeshDataPreprocess(_triMeshData); 1403 d.GeomTriMeshDataPreprocess(_triMeshData);
1365 1404
1366 prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null); 1405 geo = d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null);
1367 } 1406 }
1368 1407
1369 catch (Exception e) 1408 catch (Exception e)
@@ -1380,15 +1419,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1380 } 1419 }
1381 } 1420 }
1382 _triMeshData = IntPtr.Zero; 1421 _triMeshData = IntPtr.Zero;
1383 prim_geom = IntPtr.Zero;
1384 1422
1385 m_hasOBB = false; 1423 m_hasOBB = false;
1386 m_OBBOffset = Vector3.Zero; 1424 m_OBBOffset = Vector3.Zero;
1387 m_OBB = _size * 0.5f; 1425 m_OBB = _size * 0.5f;
1388 m_physCost = 0.1f; 1426 m_physCost = 0.1f;
1389 m_streamCost = 1.0f; 1427 m_streamCost = 1.0f;
1428
1390 _parent_scene.mesher.ReleaseMesh(mesh); 1429 _parent_scene.mesher.ReleaseMesh(mesh);
1391 m_meshState = MeshState.AssetFailed; 1430 m_meshState = MeshState.MeshFailed;
1392 m_mesh = null; 1431 m_mesh = null;
1393 return false; 1432 return false;
1394 } 1433 }
@@ -1397,12 +1436,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1397 // todo 1436 // todo
1398 m_streamCost = 1.0f; 1437 m_streamCost = 1.0f;
1399 1438
1439 SetGeom(geo);
1440
1400 return true; 1441 return true;
1401 } 1442 }
1402 1443
1403 private void CreateGeom() 1444 private void CreateGeom()
1404 { 1445 {
1405 IntPtr geo = IntPtr.Zero;
1406 bool hasMesh = false; 1446 bool hasMesh = false;
1407 1447
1408 m_NoColide = false; 1448 m_NoColide = false;
@@ -1418,8 +1458,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1418 m_NoColide = true; 1458 m_NoColide = true;
1419 } 1459 }
1420 1460
1461
1421 if (!hasMesh) 1462 if (!hasMesh)
1422 { 1463 {
1464 IntPtr geo = IntPtr.Zero;
1465
1423 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1 1466 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1
1424 && _size.X == _size.Y && _size.Y == _size.Z) 1467 && _size.X == _size.Y && _size.Y == _size.Z)
1425 { // it's a sphere 1468 { // it's a sphere
@@ -1447,7 +1490,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1447 } 1490 }
1448 m_physCost = 0.1f; 1491 m_physCost = 0.1f;
1449 m_streamCost = 1.0f; 1492 m_streamCost = 1.0f;
1450 prim_geom = geo; 1493 SetGeom(geo);
1451 } 1494 }
1452 } 1495 }
1453 1496
@@ -2740,8 +2783,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2740 { 2783 {
2741 } 2784 }
2742 2785
2743
2744
2745 private void changeAddPhysRep(ODEPhysRepData repData) 2786 private void changeAddPhysRep(ODEPhysRepData repData)
2746 { 2787 {
2747 _size = repData.size; //?? 2788 _size = repData.size; //??
@@ -2763,10 +2804,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2763 2804
2764 if (prim_geom != IntPtr.Zero) 2805 if (prim_geom != IntPtr.Zero)
2765 { 2806 {
2766 UpdatePrimBodyData();
2767
2768 _parent_scene.actor_name_map[prim_geom] = this;
2769
2770 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 2807 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2771 d.Quaternion myrot = new d.Quaternion(); 2808 d.Quaternion myrot = new d.Quaternion();
2772 myrot.X = _orientation.X; 2809 myrot.X = _orientation.X;
@@ -2774,23 +2811,23 @@ namespace OpenSim.Region.Physics.OdePlugin
2774 myrot.Z = _orientation.Z; 2811 myrot.Z = _orientation.Z;
2775 myrot.W = _orientation.W; 2812 myrot.W = _orientation.W;
2776 d.GeomSetQuaternion(prim_geom, ref myrot); 2813 d.GeomSetQuaternion(prim_geom, ref myrot);
2814 }
2777 2815
2778 if (!m_isphysical) 2816 if (!m_isphysical)
2779 { 2817 {
2780 SetInStaticSpace(this); 2818 SetInStaticSpace(this);
2781 UpdateCollisionCatFlags(); 2819 UpdateCollisionCatFlags();
2782 ApplyCollisionCatFlags(); 2820 ApplyCollisionCatFlags();
2783 } 2821 }
2784 else 2822 else
2785 MakeBody(); 2823 MakeBody();
2786 2824
2787 if ((m_meshState & MeshState.NeedMask) != 0) 2825 if ((m_meshState & MeshState.NeedMask) != 0)
2788 { 2826 {
2789 repData.size = _size; 2827 repData.size = _size;
2790 repData.pbs = _pbs; 2828 repData.pbs = _pbs;
2791 repData.shapetype = m_shapetype; 2829 repData.shapetype = m_shapetype;
2792 _parent_scene.m_meshWorker.RequestMesh(repData); 2830 _parent_scene.m_meshWorker.RequestMesh(repData);
2793 }
2794 } 2831 }
2795 } 2832 }
2796 2833
@@ -2831,14 +2868,10 @@ namespace OpenSim.Region.Physics.OdePlugin
2831 2868
2832 primVolume = repData.volume; 2869 primVolume = repData.volume;
2833 2870
2834 CreateGeom(); 2871 CreateGeom();
2835 2872
2836 if (prim_geom != IntPtr.Zero) 2873 if (prim_geom != IntPtr.Zero)
2837 { 2874 {
2838 UpdatePrimBodyData();
2839
2840 _parent_scene.actor_name_map[prim_geom] = this;
2841
2842 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 2875 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2843 d.Quaternion myrot = new d.Quaternion(); 2876 d.Quaternion myrot = new d.Quaternion();
2844 myrot.X = _orientation.X; 2877 myrot.X = _orientation.X;
@@ -2846,29 +2879,28 @@ namespace OpenSim.Region.Physics.OdePlugin
2846 myrot.Z = _orientation.Z; 2879 myrot.Z = _orientation.Z;
2847 myrot.W = _orientation.W; 2880 myrot.W = _orientation.W;
2848 d.GeomSetQuaternion(prim_geom, ref myrot); 2881 d.GeomSetQuaternion(prim_geom, ref myrot);
2882 }
2849 2883
2850 if (m_isphysical) 2884 if (m_isphysical)
2885 {
2886 if (chp)
2851 { 2887 {
2852 if (chp) 2888 if (parent != null)
2853 { 2889 {
2854 if (parent != null) 2890 parent.MakeBody();
2855 {
2856 parent.MakeBody();
2857 }
2858 } 2891 }
2859 else
2860 MakeBody();
2861 } 2892 }
2862
2863 else 2893 else
2864 { 2894 MakeBody();
2865 SetInStaticSpace(this);
2866 UpdateCollisionCatFlags();
2867 ApplyCollisionCatFlags();
2868 }
2869
2870 resetCollisionAccounting();
2871 } 2895 }
2896 else
2897 {
2898 SetInStaticSpace(this);
2899 UpdateCollisionCatFlags();
2900 ApplyCollisionCatFlags();
2901 }
2902
2903 resetCollisionAccounting();
2872 2904
2873 if ((m_meshState & MeshState.NeedMask) != 0) 2905 if ((m_meshState & MeshState.NeedMask) != 0)
2874 { 2906 {