diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 149 |
1 files changed, 124 insertions, 25 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index f2f4725..7650571 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -104,9 +104,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
104 | private float m_PIDTau; | 104 | private float m_PIDTau; |
105 | private bool m_usePID; | 105 | private bool m_usePID; |
106 | 106 | ||
107 | // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), | ||
108 | // and are for non-VEHICLES only. | ||
109 | |||
110 | private float m_PIDHoverHeight; | 107 | private float m_PIDHoverHeight; |
111 | private float m_PIDHoverTau; | 108 | private float m_PIDHoverTau; |
112 | private bool m_useHoverPID; | 109 | private bool m_useHoverPID; |
@@ -395,6 +392,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
395 | if (value.IsFinite()) | 392 | if (value.IsFinite()) |
396 | { | 393 | { |
397 | AddChange(changes.Size, value); | 394 | AddChange(changes.Size, value); |
395 | |||
396 | // _parent_scene.m_meshWorker.ChangeActorPhysRep(this, _pbs, value, m_shapetype, MeshWorkerChange.size); | ||
398 | } | 397 | } |
399 | else | 398 | else |
400 | { | 399 | { |
@@ -529,6 +528,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
529 | set | 528 | set |
530 | { | 529 | { |
531 | AddChange(changes.Shape, value); | 530 | AddChange(changes.Shape, value); |
531 | // _parent_scene.m_meshWorker.ChangeActorPhysRep(this, value, _size, m_shapetype, MeshWorkerChange.shape); | ||
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
@@ -542,10 +542,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
542 | { | 542 | { |
543 | m_shapetype = value; | 543 | m_shapetype = value; |
544 | AddChange(changes.Shape, null); | 544 | AddChange(changes.Shape, null); |
545 | // _parent_scene.m_meshWorker.ChangeActorPhysRep(this, _pbs, _size, value, MeshWorkerChange.shapetype); | ||
545 | } | 546 | } |
546 | } | 547 | } |
547 | 548 | ||
548 | |||
549 | public override Vector3 Velocity | 549 | public override Vector3 Velocity |
550 | { | 550 | { |
551 | get | 551 | get |
@@ -1080,7 +1080,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1080 | bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; | 1080 | bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; |
1081 | 1081 | ||
1082 | CalcPrimBodyData(); | 1082 | CalcPrimBodyData(); |
1083 | 1083 | /* | |
1084 | m_mesh = null; | 1084 | m_mesh = null; |
1085 | if (_parent_scene.needsMeshing(pbs) && (pbs.SculptData.Length > 0)) | 1085 | if (_parent_scene.needsMeshing(pbs) && (pbs.SculptData.Length > 0)) |
1086 | { | 1086 | { |
@@ -1096,6 +1096,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1096 | } | 1096 | } |
1097 | m_mesh = _parent_scene.mesher.CreateMesh(Name, _pbs, _size, clod, true, convex); | 1097 | m_mesh = _parent_scene.mesher.CreateMesh(Name, _pbs, _size, clod, true, convex); |
1098 | } | 1098 | } |
1099 | */ | ||
1100 | m_mesh = _parent_scene.m_meshWorker.getMesh(this, pbs, _size, m_shapetype); | ||
1099 | 1101 | ||
1100 | m_building = true; // control must set this to false when done | 1102 | m_building = true; // control must set this to false when done |
1101 | 1103 | ||
@@ -1351,6 +1353,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1351 | { | 1353 | { |
1352 | if (m_mesh == null) | 1354 | if (m_mesh == null) |
1353 | { | 1355 | { |
1356 | /* | ||
1354 | bool convex; | 1357 | bool convex; |
1355 | int clod = (int)LevelOfDetail.High; | 1358 | int clod = (int)LevelOfDetail.High; |
1356 | 1359 | ||
@@ -1364,6 +1367,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1364 | } | 1367 | } |
1365 | 1368 | ||
1366 | mesh = _parent_scene.mesher.CreateMesh(Name, _pbs, _size, clod, true, convex); | 1369 | mesh = _parent_scene.mesher.CreateMesh(Name, _pbs, _size, clod, true, convex); |
1370 | */ | ||
1371 | mesh = _parent_scene.m_meshWorker.getMesh(this, _pbs, _size, m_shapetype); | ||
1367 | } | 1372 | } |
1368 | else | 1373 | else |
1369 | { | 1374 | { |
@@ -1476,7 +1481,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1476 | hasOOBoffsetFromMesh = false; | 1481 | hasOOBoffsetFromMesh = false; |
1477 | m_NoColide = false; | 1482 | m_NoColide = false; |
1478 | 1483 | ||
1479 | if (_parent_scene.needsMeshing(_pbs)) | 1484 | if (_parent_scene.m_meshWorker.needsMeshing(_pbs)) |
1480 | { | 1485 | { |
1481 | haveMesh = setMesh(_parent_scene); // this will give a mesh to non trivial known prims | 1486 | haveMesh = setMesh(_parent_scene); // this will give a mesh to non trivial known prims |
1482 | if (!haveMesh) | 1487 | if (!haveMesh) |
@@ -1524,7 +1529,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1524 | { | 1529 | { |
1525 | if (prim_geom != IntPtr.Zero) | 1530 | if (prim_geom != IntPtr.Zero) |
1526 | { | 1531 | { |
1527 | // _parent_scene.geom_name_map.Remove(prim_geom); | ||
1528 | _parent_scene.actor_name_map.Remove(prim_geom); | 1532 | _parent_scene.actor_name_map.Remove(prim_geom); |
1529 | try | 1533 | try |
1530 | { | 1534 | { |
@@ -1534,11 +1538,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1534 | d.GeomTriMeshDataDestroy(_triMeshData); | 1538 | d.GeomTriMeshDataDestroy(_triMeshData); |
1535 | _triMeshData = IntPtr.Zero; | 1539 | _triMeshData = IntPtr.Zero; |
1536 | } | 1540 | } |
1537 | |||
1538 | } | 1541 | } |
1539 | |||
1540 | |||
1541 | // catch (System.AccessViolationException) | ||
1542 | catch (Exception e) | 1542 | catch (Exception e) |
1543 | { | 1543 | { |
1544 | m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name, e); | 1544 | m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name, e); |
@@ -1552,23 +1552,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1552 | m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction BAD {0}", Name); | 1552 | m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction BAD {0}", Name); |
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | if (m_mesh != null) | 1555 | lock (m_meshlock) |
1556 | { | 1556 | { |
1557 | _parent_scene.mesher.ReleaseMesh(m_mesh); | 1557 | if (m_mesh != null) |
1558 | m_mesh = null; | 1558 | { |
1559 | _parent_scene.mesher.ReleaseMesh(m_mesh); | ||
1560 | m_mesh = null; | ||
1561 | } | ||
1559 | } | 1562 | } |
1560 | 1563 | ||
1561 | Body = IntPtr.Zero; | 1564 | Body = IntPtr.Zero; |
1562 | hasOOBoffsetFromMesh = false; | 1565 | hasOOBoffsetFromMesh = false; |
1563 | } | 1566 | } |
1564 | /* | 1567 | |
1565 | private void ChildSetGeom(OdePrim odePrim) | ||
1566 | { | ||
1567 | // well.. | ||
1568 | DestroyBody(); | ||
1569 | MakeBody(); | ||
1570 | } | ||
1571 | */ | ||
1572 | //sets non physical prim m_targetSpace to right space in spaces grid for static prims | 1568 | //sets non physical prim m_targetSpace to right space in spaces grid for static prims |
1573 | // should only be called for non physical prims unless they are becoming non physical | 1569 | // should only be called for non physical prims unless they are becoming non physical |
1574 | private void SetInStaticSpace(OdePrim prim) | 1570 | private void SetInStaticSpace(OdePrim prim) |
@@ -1631,9 +1627,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1631 | 1627 | ||
1632 | if (Body != IntPtr.Zero) | 1628 | if (Body != IntPtr.Zero) |
1633 | { | 1629 | { |
1634 | // d.BodyDestroy(Body); | ||
1635 | // Body = IntPtr.Zero; | ||
1636 | // do a more complet destruction | ||
1637 | DestroyBody(); | 1630 | DestroyBody(); |
1638 | m_log.Warn("[PHYSICS]: MakeBody called having a body"); | 1631 | m_log.Warn("[PHYSICS]: MakeBody called having a body"); |
1639 | } | 1632 | } |
@@ -2495,6 +2488,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2495 | primOOBradiusSQ = primOOBsize.LengthSquared(); | 2488 | primOOBradiusSQ = primOOBsize.LengthSquared(); |
2496 | } | 2489 | } |
2497 | 2490 | ||
2491 | private void UpdatePrimBodyData() | ||
2492 | { | ||
2493 | primMass = m_density * primVolume; | ||
2494 | |||
2495 | if (primMass <= 0) | ||
2496 | primMass = 0.0001f;//ckrinke: Mass must be greater then zero. | ||
2497 | if (primMass > _parent_scene.maximumMassObject) | ||
2498 | primMass = _parent_scene.maximumMassObject; | ||
2499 | |||
2500 | _mass = primMass; // just in case | ||
2501 | |||
2502 | d.MassSetBoxTotal(out primdMass, primMass, primOOBsize.X, primOOBsize.Y, primOOBsize.Z); | ||
2503 | |||
2504 | d.MassTranslate(ref primdMass, | ||
2505 | primOOBoffset.X, | ||
2506 | primOOBoffset.Y, | ||
2507 | primOOBoffset.Z); | ||
2508 | |||
2509 | primOOBradiusSQ = primOOBsize.LengthSquared(); | ||
2510 | } | ||
2498 | 2511 | ||
2499 | #endregion | 2512 | #endregion |
2500 | 2513 | ||
@@ -3227,6 +3240,86 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3227 | changeprimsizeshape(); | 3240 | changeprimsizeshape(); |
3228 | } | 3241 | } |
3229 | 3242 | ||
3243 | |||
3244 | private void changePhysRepData(ODEPhysRepData repData) | ||
3245 | { | ||
3246 | CheckDelaySelect(); | ||
3247 | |||
3248 | OdePrim parent = (OdePrim)_parent; | ||
3249 | |||
3250 | bool chp = childPrim; | ||
3251 | |||
3252 | if (chp) | ||
3253 | { | ||
3254 | if (parent != null) | ||
3255 | { | ||
3256 | parent.DestroyBody(); | ||
3257 | } | ||
3258 | } | ||
3259 | else | ||
3260 | { | ||
3261 | DestroyBody(); | ||
3262 | } | ||
3263 | |||
3264 | RemoveGeom(); | ||
3265 | |||
3266 | prim_geom = repData.geo; | ||
3267 | _triMeshData = repData.triMeshData; | ||
3268 | _size = repData.size; | ||
3269 | _pbs = repData.pbs; | ||
3270 | m_mesh = repData.mesh; | ||
3271 | m_shapetype = repData.shapetype; | ||
3272 | |||
3273 | hasOOBoffsetFromMesh = repData.hasOBB; | ||
3274 | primOOBoffset = repData.OBBOffset; | ||
3275 | primOOBsize = repData.OBB; | ||
3276 | |||
3277 | m_NoColide = repData.NoColide; | ||
3278 | // m_physCost = repData.physCost; | ||
3279 | // m_streamCost = repData.streamCost; | ||
3280 | |||
3281 | primVolume = repData.volume; | ||
3282 | m_targetSpace = repData.curSpace; | ||
3283 | |||
3284 | UpdatePrimBodyData(); | ||
3285 | |||
3286 | _parent_scene.actor_name_map[prim_geom] = this; | ||
3287 | |||
3288 | if (prim_geom != IntPtr.Zero) | ||
3289 | { | ||
3290 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
3291 | d.Quaternion myrot = new d.Quaternion(); | ||
3292 | myrot.X = _orientation.X; | ||
3293 | myrot.Y = _orientation.Y; | ||
3294 | myrot.Z = _orientation.Z; | ||
3295 | myrot.W = _orientation.W; | ||
3296 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
3297 | } | ||
3298 | |||
3299 | if (m_isphysical) | ||
3300 | { | ||
3301 | if (chp) | ||
3302 | { | ||
3303 | if (parent != null) | ||
3304 | { | ||
3305 | parent.MakeBody(); | ||
3306 | } | ||
3307 | } | ||
3308 | else | ||
3309 | MakeBody(); | ||
3310 | } | ||
3311 | |||
3312 | else | ||
3313 | { | ||
3314 | SetInStaticSpace(this); | ||
3315 | UpdateCollisionCatFlags(); | ||
3316 | ApplyCollisionCatFlags(); | ||
3317 | } | ||
3318 | |||
3319 | resetCollisionAccounting(); | ||
3320 | } | ||
3321 | |||
3322 | |||
3230 | private void changeFloatOnWater(bool newval) | 3323 | private void changeFloatOnWater(bool newval) |
3231 | { | 3324 | { |
3232 | m_collidesWater = newval; | 3325 | m_collidesWater = newval; |
@@ -3984,6 +4077,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3984 | changeShape((PrimitiveBaseShape)arg); | 4077 | changeShape((PrimitiveBaseShape)arg); |
3985 | break; | 4078 | break; |
3986 | 4079 | ||
4080 | case changes.PhysRepData: | ||
4081 | changePhysRepData((ODEPhysRepData) arg); | ||
4082 | break; | ||
4083 | |||
3987 | case changes.CollidesWater: | 4084 | case changes.CollidesWater: |
3988 | changeFloatOnWater((bool)arg); | 4085 | changeFloatOnWater((bool)arg); |
3989 | break; | 4086 | break; |
@@ -4072,6 +4169,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4072 | donullchange(); | 4169 | donullchange(); |
4073 | break; | 4170 | break; |
4074 | 4171 | ||
4172 | |||
4173 | |||
4075 | default: | 4174 | default: |
4076 | donullchange(); | 4175 | donullchange(); |
4077 | break; | 4176 | break; |