aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
authorUbitUmarov2012-10-07 01:20:52 +0100
committerUbitUmarov2012-10-07 01:20:52 +0100
commit78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100 (patch)
treed73921adb6a2e7f9c518a50a65c843ef7d95b539 /OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
parentMerge branch 'avination' into ubitwork (diff)
downloadopensim-SC-78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100.zip
opensim-SC-78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100.tar.gz
opensim-SC-78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100.tar.bz2
opensim-SC-78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100.tar.xz
[DANGER UNTESTED] ODE mesh assets. Other plugins will not do meshs/sculpts
now
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs187
1 files changed, 64 insertions, 123 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index d758c85..5e4c2a5 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -60,29 +60,6 @@ namespace OpenSim.Region.Physics.OdePlugin
60 public int lastframe; 60 public int lastframe;
61 } 61 }
62 62
63 public class ODEPhysRepData
64 {
65 public PhysicsActor actor;
66 public IntPtr geo = IntPtr.Zero;
67 public IntPtr triMeshData = IntPtr.Zero;
68 public IMesh mesh;
69 public IntPtr curSpace = IntPtr.Zero;
70 public PrimitiveBaseShape pbs;
71
72 public Vector3 size = Vector3.Zero;
73 public Vector3 OBB = Vector3.Zero;
74 public Vector3 OBBOffset = Vector3.Zero;
75
76 public float volume;
77
78 public float physCost = 0.0f;
79 public float streamCost = 0;
80 public MeshWorkerChange changed;
81 public byte shapetype = 0;
82 public bool NoColide = false;
83 public bool hasOBB = false;
84 public bool hasMeshVolume = false;
85 }
86 63
87 // colision flags of things others can colide with 64 // colision flags of things others can colide with
88 // rays, sensors, probes removed since can't be colided with 65 // rays, sensors, probes removed since can't be colided with
@@ -133,13 +110,16 @@ namespace OpenSim.Region.Physics.OdePlugin
133 110
134 light = 7 // compatibility with old viewers 111 light = 7 // compatibility with old viewers
135 } 112 }
136 [Flags] 113
137 public enum MeshWorkerChange : uint 114 public enum AssetState : byte
138 { 115 {
139 none = 0, 116 noNeedAsset = 0,
140 size = 1, 117 needAsset = 1,
141 shape = 2, 118 loadingAsset = 2,
142 shapetype = 3, 119 procAsset = 3,
120 AssetOK = 4,
121
122 AssetFailed = 0xff
143 } 123 }
144 124
145 public enum changes : int 125 public enum changes : int
@@ -180,6 +160,7 @@ namespace OpenSim.Region.Physics.OdePlugin
180 Size, 160 Size,
181 Shape, 161 Shape,
182 PhysRepData, 162 PhysRepData,
163 AddPhysRep,
183 164
184 CollidesWater, 165 CollidesWater,
185 VolumeDtc, 166 VolumeDtc,
@@ -330,7 +311,6 @@ namespace OpenSim.Region.Physics.OdePlugin
330 public IntPtr TopSpace; // the global space 311 public IntPtr TopSpace; // the global space
331 public IntPtr ActiveSpace; // space for active prims 312 public IntPtr ActiveSpace; // space for active prims
332 public IntPtr StaticSpace; // space for the static things around 313 public IntPtr StaticSpace; // space for the static things around
333 public IntPtr WorkSpace; // no collisions work space
334 314
335 // some speedup variables 315 // some speedup variables
336 private int spaceGridMaxX; 316 private int spaceGridMaxX;
@@ -342,7 +322,7 @@ namespace OpenSim.Region.Physics.OdePlugin
342 private IntPtr[] staticPrimspaceOffRegion; 322 private IntPtr[] staticPrimspaceOffRegion;
343 323
344 public Object OdeLock; 324 public Object OdeLock;
345 private static Object SimulationLock; 325 public static Object SimulationLock;
346 326
347 public IMesher mesher; 327 public IMesher mesher;
348 328
@@ -403,7 +383,6 @@ namespace OpenSim.Region.Physics.OdePlugin
403 // now the major subspaces 383 // now the major subspaces
404 ActiveSpace = d.HashSpaceCreate(TopSpace); 384 ActiveSpace = d.HashSpaceCreate(TopSpace);
405 StaticSpace = d.HashSpaceCreate(TopSpace); 385 StaticSpace = d.HashSpaceCreate(TopSpace);
406 WorkSpace = d.HashSpaceCreate(TopSpace);
407 } 386 }
408 catch 387 catch
409 { 388 {
@@ -413,12 +392,10 @@ namespace OpenSim.Region.Physics.OdePlugin
413 d.HashSpaceSetLevels(TopSpace, -2, 8); 392 d.HashSpaceSetLevels(TopSpace, -2, 8);
414 d.HashSpaceSetLevels(ActiveSpace, -2, 8); 393 d.HashSpaceSetLevels(ActiveSpace, -2, 8);
415 d.HashSpaceSetLevels(StaticSpace, -2, 8); 394 d.HashSpaceSetLevels(StaticSpace, -2, 8);
416 d.HashSpaceSetLevels(WorkSpace, -2, 8);
417 395
418 // demote to second level 396 // demote to second level
419 d.SpaceSetSublevel(ActiveSpace, 1); 397 d.SpaceSetSublevel(ActiveSpace, 1);
420 d.SpaceSetSublevel(StaticSpace, 1); 398 d.SpaceSetSublevel(StaticSpace, 1);
421 d.SpaceSetSublevel(WorkSpace, 1);
422 399
423 d.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space | 400 d.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space |
424 CollisionCategories.Geom | 401 CollisionCategories.Geom |
@@ -436,8 +413,6 @@ namespace OpenSim.Region.Physics.OdePlugin
436 )); 413 ));
437 d.GeomSetCollideBits(StaticSpace, 0); 414 d.GeomSetCollideBits(StaticSpace, 0);
438 415
439 d.GeomSetCategoryBits(WorkSpace, 0);
440 d.GeomSetCollideBits(WorkSpace, 0);
441 416
442 contactgroup = d.JointGroupCreate(0); 417 contactgroup = d.JointGroupCreate(0);
443 //contactgroup 418 //contactgroup
@@ -518,7 +493,7 @@ namespace OpenSim.Region.Physics.OdePlugin
518 } 493 }
519 } 494 }
520 495
521 m_meshWorker = new ODEMeshWorker(this, m_log, meshmerizer, WorkSpace, physicsconfig); 496 m_meshWorker = new ODEMeshWorker(this, m_log, meshmerizer, physicsconfig);
522 497
523 HalfOdeStep = ODE_STEPSIZE * 0.5f; 498 HalfOdeStep = ODE_STEPSIZE * 0.5f;
524 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); 499 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f);
@@ -1316,6 +1291,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1316 _collisionEventPrimRemove.Add(obj); 1291 _collisionEventPrimRemove.Add(obj);
1317 } 1292 }
1318 1293
1294 public override float TimeDilation
1295 {
1296 get { return m_timeDilation; }
1297 }
1298
1299 public override bool SupportsNINJAJoints
1300 {
1301 get { return false; }
1302 }
1319 1303
1320 #region Add/Remove Entities 1304 #region Add/Remove Entities
1321 1305
@@ -1371,117 +1355,59 @@ namespace OpenSim.Region.Physics.OdePlugin
1371 ((OdeCharacter) actor).Destroy(); 1355 ((OdeCharacter) actor).Destroy();
1372 } 1356 }
1373 1357
1374 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1375 PrimitiveBaseShape pbs, bool isphysical, uint localID)
1376 {
1377 Vector3 pos = position;
1378 Vector3 siz = size;
1379 Quaternion rot = rotation;
1380 1358
1381 OdePrim newPrim; 1359 public void addActivePrim(OdePrim activatePrim)
1382 lock (OdeLock) 1360 {
1361 // adds active prim..
1362 lock (_activeprims)
1383 { 1363 {
1384 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical,false,0,localID); 1364 if (!_activeprims.Contains(activatePrim))
1385 1365 _activeprims.Add(activatePrim);
1386 lock (_prims)
1387 _prims.Add(newPrim);
1388 } 1366 }
1389 return newPrim;
1390 } 1367 }
1391 1368
1392 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1369 public void addActiveGroups(OdePrim activatePrim)
1393 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, uint localID)
1394 { 1370 {
1395 Vector3 pos = position; 1371 lock (_activegroups)
1396 Vector3 siz = size;
1397 Quaternion rot = rotation;
1398
1399 OdePrim newPrim;
1400 lock (OdeLock)
1401 { 1372 {
1402 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical, isPhantom, 0, localID); 1373 if (!_activegroups.Contains(activatePrim))
1403 1374 _activegroups.Add(activatePrim);
1404 lock (_prims)
1405 _prims.Add(newPrim);
1406 } 1375 }
1407 return newPrim;
1408 } 1376 }
1409 1377
1410 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1378 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1411 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, byte shapeType, uint localID) 1379 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, byte shapeType, uint localID)
1412 { 1380 {
1413 Vector3 pos = position;
1414 Vector3 siz = size;
1415 Quaternion rot = rotation;
1416
1417 OdePrim newPrim; 1381 OdePrim newPrim;
1418 lock (OdeLock) 1382 lock (OdeLock)
1419 { 1383 {
1420 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical, isPhantom, shapeType, localID); 1384 newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID);
1421
1422 lock (_prims) 1385 lock (_prims)
1423 _prims.Add(newPrim); 1386 _prims.Add(newPrim);
1424 } 1387 }
1425 return newPrim; 1388 return newPrim;
1426 } 1389 }
1427 1390
1428 public void addActivePrim(OdePrim activatePrim)
1429 {
1430 // adds active prim..
1431 lock (_activeprims)
1432 {
1433 if (!_activeprims.Contains(activatePrim))
1434 _activeprims.Add(activatePrim);
1435 }
1436 }
1437
1438 public void addActiveGroups(OdePrim activatePrim)
1439 {
1440 lock (_activegroups)
1441 {
1442 if (!_activegroups.Contains(activatePrim))
1443 _activegroups.Add(activatePrim);
1444 }
1445 }
1446
1447 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1391 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1448 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid) 1392 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid)
1449 { 1393 {
1450 return AddPrim(primName, position, size, rotation, pbs, isPhysical, isPhantom, localid); 1394 return AddPrim(primName, position, size, rotation, pbs, isPhysical, isPhantom, 0 , localid);
1451 } 1395 }
1452 1396
1453 1397
1454 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1398 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1455 Vector3 size, Quaternion rotation, bool isPhysical, uint localid) 1399 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
1456 { 1400 {
1457#if SPAM 1401 return AddPrim(primName, position, size, rotation, pbs, isPhysical,false, 0, localid);
1458 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName);
1459#endif
1460
1461 return AddPrim(primName, position, size, rotation, pbs, isPhysical, localid);
1462 } 1402 }
1463 1403
1464 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1404 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1465 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapeType, uint localid) 1405 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapeType, uint localid)
1466 { 1406 {
1467#if SPAM
1468 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName);
1469#endif
1470 1407
1471 return AddPrim(primName, position, size, rotation, pbs, isPhysical,isPhantom, shapeType, localid); 1408 return AddPrim(primName, position, size, rotation, pbs, isPhysical,isPhantom, shapeType, localid);
1472 } 1409 }
1473 1410
1474 public override float TimeDilation
1475 {
1476 get { return m_timeDilation; }
1477 }
1478
1479 public override bool SupportsNINJAJoints
1480 {
1481 get { return false; }
1482 }
1483
1484
1485 public void remActivePrim(OdePrim deactivatePrim) 1411 public void remActivePrim(OdePrim deactivatePrim)
1486 { 1412 {
1487 lock (_activeprims) 1413 lock (_activeprims)
@@ -1534,6 +1460,28 @@ namespace OpenSim.Region.Physics.OdePlugin
1534 } 1460 }
1535 1461
1536 } 1462 }
1463
1464 public bool havePrim(OdePrim prm)
1465 {
1466 lock (_prims)
1467 return _prims.Contains(prm);
1468 }
1469
1470 public bool haveActor(PhysicsActor actor)
1471 {
1472 if (actor is OdePrim)
1473 {
1474 lock (_prims)
1475 return _prims.Contains((OdePrim)actor);
1476 }
1477 else if (actor is OdeCharacter)
1478 {
1479 lock (_characters)
1480 return _characters.Contains((OdeCharacter)actor);
1481 }
1482 return false;
1483 }
1484
1537 #endregion 1485 #endregion
1538 1486
1539 #region Space Separation Calculation 1487 #region Space Separation Calculation
@@ -1706,20 +1654,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1706 { 1654 {
1707 if (world == IntPtr.Zero) 1655 if (world == IntPtr.Zero)
1708 return 0; 1656 return 0;
1657
1658 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1709 1659
1710 // adjust number of iterations per step
1711
1712// try
1713// {
1714 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1715/* }
1716 catch (StackOverflowException)
1717 {
1718 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
1719// ode.drelease(world);
1720 base.TriggerPhysicsBasedRestart();
1721 }
1722*/
1723 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever 1660 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
1724 { 1661 {
1725 try 1662 try
@@ -1747,8 +1684,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1747 } 1684 }
1748 catch 1685 catch
1749 { 1686 {
1750 m_log.Warn("[PHYSICS]: doChange failed for a actor"); 1687 m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}",
1751 }; 1688 item.actor.Name, item.what.ToString());
1689 }
1752 } 1690 }
1753 ttmp = Util.EnvironmentTickCountSubtract(ttmpstart); 1691 ttmp = Util.EnvironmentTickCountSubtract(ttmpstart);
1754 if (ttmp > 20) 1692 if (ttmp > 20)
@@ -2491,6 +2429,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2491*/ 2429*/
2492 public override void Dispose() 2430 public override void Dispose()
2493 { 2431 {
2432 if (m_meshWorker != null)
2433 m_meshWorker.Stop();
2434
2494 lock (OdeLock) 2435 lock (OdeLock)
2495 { 2436 {
2496 m_rayCastManager.Dispose(); 2437 m_rayCastManager.Dispose();