aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs58
1 files changed, 38 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index c9c9c2c..758d92b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -279,9 +279,12 @@ public sealed class BSPrim : BSPhysObject
279 } 279 }
280 public override OMV.Vector3 Position { 280 public override OMV.Vector3 Position {
281 get { 281 get {
282 /* NOTE: this refetch is not necessary. The simulator knows about linkset children
283 * and does not fetch this position info for children. Thus this is commented out.
282 // child prims move around based on their parent. Need to get the latest location 284 // child prims move around based on their parent. Need to get the latest location
283 if (!Linkset.IsRoot(this)) 285 if (!Linkset.IsRoot(this))
284 _position = Linkset.Position(this); 286 _position = Linkset.PositionGet(this);
287 */
285 288
286 // don't do the GetObjectPosition for root elements because this function is called a zillion times. 289 // don't do the GetObjectPosition for root elements because this function is called a zillion times.
287 // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); 290 // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
@@ -289,21 +292,22 @@ public sealed class BSPrim : BSPhysObject
289 } 292 }
290 set { 293 set {
291 // If the position must be forced into the physics engine, use ForcePosition. 294 // If the position must be forced into the physics engine, use ForcePosition.
295 // All positions are given in world positions.
292 if (_position == value) 296 if (_position == value)
293 { 297 {
298 DetailLog("{0},BSPrim.setPosition,taint,positionNotChanging,pos={1},orient={2}", LocalID, _position, _orientation);
294 return; 299 return;
295 } 300 }
296 _position = value; 301 _position = value;
297 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
298 PositionSanityCheck(false); 302 PositionSanityCheck(false);
303
304 // A linkset might need to know if a component information changed.
305 Linkset.UpdateProperties(this, false);
306
299 PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() 307 PhysicsScene.TaintedObject("BSPrim.setPosition", delegate()
300 { 308 {
301 // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 309 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
302 if (PhysBody.HasPhysicalBody) 310 ForcePosition = _position;
303 {
304 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
305 ActivateIfPhysical(false);
306 }
307 }); 311 });
308 } 312 }
309 } 313 }
@@ -314,9 +318,11 @@ public sealed class BSPrim : BSPhysObject
314 } 318 }
315 set { 319 set {
316 _position = value; 320 _position = value;
317 // PositionSanityCheck(); // Don't do this! Causes a loop and caller should know better. 321 if (PhysBody.HasPhysicalBody)
318 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 322 {
319 ActivateIfPhysical(false); 323 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
324 ActivateIfPhysical(false);
325 }
320 } 326 }
321 } 327 }
322 328
@@ -327,6 +333,14 @@ public sealed class BSPrim : BSPhysObject
327 { 333 {
328 bool ret = false; 334 bool ret = false;
329 335
336 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(_position))
337 {
338 // The physical object is out of the known/simulated area.
339 // Upper levels of code will handle the transition to other areas so, for
340 // the time, we just ignore the position.
341 return ret;
342 }
343
330 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); 344 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
331 OMV.Vector3 upForce = OMV.Vector3.Zero; 345 OMV.Vector3 upForce = OMV.Vector3.Zero;
332 if (RawPosition.Z < terrainHeight) 346 if (RawPosition.Z < terrainHeight)
@@ -350,8 +364,6 @@ public sealed class BSPrim : BSPhysObject
350 } 364 }
351 } 365 }
352 366
353 // TODO: check for out of bounds
354
355 // The above code computes a force to apply to correct any out-of-bounds problems. Apply same. 367 // The above code computes a force to apply to correct any out-of-bounds problems. Apply same.
356 // TODO: This should be intergrated with a geneal physics action mechanism. 368 // TODO: This should be intergrated with a geneal physics action mechanism.
357 // TODO: This should be moderated with PID'ness. 369 // TODO: This should be moderated with PID'ness.
@@ -551,18 +563,24 @@ public sealed class BSPrim : BSPhysObject
551 } 563 }
552 public override OMV.Quaternion Orientation { 564 public override OMV.Quaternion Orientation {
553 get { 565 get {
566 /* NOTE: this refetch is not necessary. The simulator knows about linkset children
567 * and does not fetch this position info for children. Thus this is commented out.
554 // Children move around because tied to parent. Get a fresh value. 568 // Children move around because tied to parent. Get a fresh value.
555 if (!Linkset.IsRoot(this)) 569 if (!Linkset.IsRoot(this))
556 { 570 {
557 _orientation = Linkset.Orientation(this); 571 _orientation = Linkset.OrientationGet(this);
558 } 572 }
573 */
559 return _orientation; 574 return _orientation;
560 } 575 }
561 set { 576 set {
562 if (_orientation == value) 577 if (_orientation == value)
563 return; 578 return;
564 _orientation = value; 579 _orientation = value;
565 // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? 580
581 // A linkset might need to know if a component information changed.
582 Linkset.UpdateProperties(this, false);
583
566 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() 584 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
567 { 585 {
568 if (PhysBody.HasPhysicalBody) 586 if (PhysBody.HasPhysicalBody)
@@ -1427,14 +1445,14 @@ public sealed class BSPrim : BSPhysObject
1427 entprop.Velocity = _velocity; 1445 entprop.Velocity = _velocity;
1428 } 1446 }
1429 1447
1430 // remember the current and last set values
1431 LastEntityProperties = CurrentEntityProperties;
1432 CurrentEntityProperties = entprop;
1433
1434 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG 1448 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG
1435 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},dir={3},vel={4},rotVel={5}", 1449 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},dir={3},vel={4},rotVel={5}",
1436 LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity); 1450 LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity);
1437 1451
1452 // remember the current and last set values
1453 LastEntityProperties = CurrentEntityProperties;
1454 CurrentEntityProperties = entprop;
1455
1438 base.RequestPhysicsterseUpdate(); 1456 base.RequestPhysicsterseUpdate();
1439 } 1457 }
1440 /* 1458 /*
@@ -1448,7 +1466,7 @@ public sealed class BSPrim : BSPhysObject
1448 */ 1466 */
1449 1467
1450 // The linkset implimentation might want to know about this. 1468 // The linkset implimentation might want to know about this.
1451 Linkset.UpdateProperties(this); 1469 Linkset.UpdateProperties(this, true);
1452 } 1470 }
1453} 1471}
1454} 1472}