diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 168 |
1 files changed, 136 insertions, 32 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 5911897..71a4303 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -148,6 +148,7 @@ public sealed class BSPrim : PhysicsActor | |||
148 | public void Destroy() | 148 | public void Destroy() |
149 | { | 149 | { |
150 | // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); | 150 | // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); |
151 | // DetailLog("{0},Destroy", LocalID); | ||
151 | // Undo any vehicle properties | 152 | // Undo any vehicle properties |
152 | _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); | 153 | _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); |
153 | _scene.RemoveVehiclePrim(this); // just to make sure | 154 | _scene.RemoveVehiclePrim(this); // just to make sure |
@@ -215,6 +216,7 @@ public sealed class BSPrim : PhysicsActor | |||
215 | public override void link(PhysicsActor obj) { | 216 | public override void link(PhysicsActor obj) { |
216 | BSPrim parent = obj as BSPrim; | 217 | BSPrim parent = obj as BSPrim; |
217 | DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); | 218 | DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); |
219 | DetailLog("{0},link,parent={1}", LocalID, obj.LocalID); | ||
218 | // TODO: decide if this parent checking needs to happen at taint time | 220 | // TODO: decide if this parent checking needs to happen at taint time |
219 | if (_parentPrim == null) | 221 | if (_parentPrim == null) |
220 | { | 222 | { |
@@ -250,6 +252,7 @@ public sealed class BSPrim : PhysicsActor | |||
250 | // Race condition here: if link() and delink() in same simulation tick, the delink will not happen | 252 | // Race condition here: if link() and delink() in same simulation tick, the delink will not happen |
251 | DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, | 253 | DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, |
252 | (_parentPrim==null ? "NULL" : _parentPrim._avName+"/"+_parentPrim.LocalID.ToString())); | 254 | (_parentPrim==null ? "NULL" : _parentPrim._avName+"/"+_parentPrim.LocalID.ToString())); |
255 | DetailLog("{0},delink,parent={1}", LocalID, (_parentPrim==null ? "NULL" : _parentPrim.LocalID.ToString())); | ||
253 | if (_parentPrim != null) | 256 | if (_parentPrim != null) |
254 | { | 257 | { |
255 | _parentPrim.RemoveChildFromLinkset(this); | 258 | _parentPrim.RemoveChildFromLinkset(this); |
@@ -266,6 +269,7 @@ public sealed class BSPrim : PhysicsActor | |||
266 | if (!_childrenPrims.Contains(child)) | 269 | if (!_childrenPrims.Contains(child)) |
267 | { | 270 | { |
268 | DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, this.LocalID); | 271 | DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, this.LocalID); |
272 | DetailLog("{0},AddChildToLinkset,child={1}", LocalID, pchild.LocalID); | ||
269 | _childrenPrims.Add(child); | 273 | _childrenPrims.Add(child); |
270 | child._parentPrim = this; // the child has gained a parent | 274 | child._parentPrim = this; // the child has gained a parent |
271 | RecreateGeomAndObject(); // rebuild my shape with the new child added | 275 | RecreateGeomAndObject(); // rebuild my shape with the new child added |
@@ -284,6 +288,7 @@ public sealed class BSPrim : PhysicsActor | |||
284 | if (_childrenPrims.Contains(child)) | 288 | if (_childrenPrims.Contains(child)) |
285 | { | 289 | { |
286 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); | 290 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); |
291 | DetailLog("{0},RemoveChildToLinkset,child={1}", LocalID, pchild.LocalID); | ||
287 | if (!BulletSimAPI.RemoveConstraintByID(_scene.WorldID, child.LocalID)) | 292 | if (!BulletSimAPI.RemoveConstraintByID(_scene.WorldID, child.LocalID)) |
288 | { | 293 | { |
289 | m_log.ErrorFormat("{0}: RemoveChildFromLinkset: Failed remove constraint for {1}", LogHeader, child.LocalID); | 294 | m_log.ErrorFormat("{0}: RemoveChildFromLinkset: Failed remove constraint for {1}", LogHeader, child.LocalID); |
@@ -317,20 +322,28 @@ public sealed class BSPrim : PhysicsActor | |||
317 | base.RequestPhysicsterseUpdate(); | 322 | base.RequestPhysicsterseUpdate(); |
318 | } | 323 | } |
319 | 324 | ||
320 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } | 325 | public override void LockAngularMotion(OMV.Vector3 axis) |
326 | { | ||
327 | DetailLog("{0},LockAngularMotion,call,axis={1}", LocalID, axis); | ||
328 | return; | ||
329 | } | ||
321 | 330 | ||
322 | public override OMV.Vector3 Position { | 331 | public override OMV.Vector3 Position { |
323 | get { | 332 | get { |
324 | // don't do the following GetObjectPosition because this function is called a zillion times | 333 | // child prims move around based on their parent. Need to get the latest location |
334 | if (_parentPrim != null) | ||
335 | _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); | ||
336 | // don't do the GetObjectPosition for root elements because this function is called a zillion times | ||
325 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); | 337 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); |
326 | return _position; | 338 | return _position; |
327 | } | 339 | } |
328 | set { | 340 | set { |
329 | _position = value; | 341 | _position = value; |
342 | // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? | ||
330 | _scene.TaintedObject(delegate() | 343 | _scene.TaintedObject(delegate() |
331 | { | 344 | { |
345 | DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | ||
332 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); | 346 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); |
333 | // m_log.DebugFormat("{0}: setPosition: id={1}, position={2}", LogHeader, _localID, _position); | ||
334 | }); | 347 | }); |
335 | } | 348 | } |
336 | } | 349 | } |
@@ -343,6 +356,7 @@ public sealed class BSPrim : PhysicsActor | |||
343 | _force = value; | 356 | _force = value; |
344 | _scene.TaintedObject(delegate() | 357 | _scene.TaintedObject(delegate() |
345 | { | 358 | { |
359 | DetailLog("{0},SetForce,taint,force={1}", LocalID, _force); | ||
346 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); | 360 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); |
347 | }); | 361 | }); |
348 | } | 362 | } |
@@ -354,15 +368,23 @@ public sealed class BSPrim : PhysicsActor | |||
354 | } | 368 | } |
355 | set { | 369 | set { |
356 | Vehicle type = (Vehicle)value; | 370 | Vehicle type = (Vehicle)value; |
357 | _vehicle.ProcessTypeChange(type); | ||
358 | _scene.TaintedObject(delegate() | 371 | _scene.TaintedObject(delegate() |
359 | { | 372 | { |
373 | DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type); | ||
374 | _vehicle.ProcessTypeChange(type); | ||
360 | if (type == Vehicle.TYPE_NONE) | 375 | if (type == Vehicle.TYPE_NONE) |
361 | { | 376 | { |
362 | _scene.RemoveVehiclePrim(this); | 377 | _scene.RemoveVehiclePrim(this); |
363 | } | 378 | } |
364 | else | 379 | else |
365 | { | 380 | { |
381 | _scene.TaintedObject(delegate() | ||
382 | { | ||
383 | // Tell the physics engine to clear state | ||
384 | IntPtr obj = BulletSimAPI.GetBodyHandleWorldID2(_scene.WorldID, LocalID); | ||
385 | BulletSimAPI.ClearForces2(obj); | ||
386 | }); | ||
387 | |||
366 | // make it so the scene will call us each tick to do vehicle things | 388 | // make it so the scene will call us each tick to do vehicle things |
367 | _scene.AddVehiclePrim(this); | 389 | _scene.AddVehiclePrim(this); |
368 | } | 390 | } |
@@ -372,21 +394,39 @@ public sealed class BSPrim : PhysicsActor | |||
372 | } | 394 | } |
373 | public override void VehicleFloatParam(int param, float value) | 395 | public override void VehicleFloatParam(int param, float value) |
374 | { | 396 | { |
375 | _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); | 397 | m_log.DebugFormat("{0} VehicleFloatParam. {1} <= {2}", LogHeader, param, value); |
398 | _scene.TaintedObject(delegate() | ||
399 | { | ||
400 | _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); | ||
401 | }); | ||
376 | } | 402 | } |
377 | public override void VehicleVectorParam(int param, OMV.Vector3 value) | 403 | public override void VehicleVectorParam(int param, OMV.Vector3 value) |
378 | { | 404 | { |
379 | _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); | 405 | m_log.DebugFormat("{0} VehicleVectorParam. {1} <= {2}", LogHeader, param, value); |
406 | _scene.TaintedObject(delegate() | ||
407 | { | ||
408 | _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); | ||
409 | }); | ||
380 | } | 410 | } |
381 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) | 411 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) |
382 | { | 412 | { |
383 | _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); | 413 | m_log.DebugFormat("{0} VehicleRotationParam. {1} <= {2}", LogHeader, param, rotation); |
414 | _scene.TaintedObject(delegate() | ||
415 | { | ||
416 | _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); | ||
417 | }); | ||
384 | } | 418 | } |
385 | public override void VehicleFlags(int param, bool remove) | 419 | public override void VehicleFlags(int param, bool remove) |
386 | { | 420 | { |
387 | _vehicle.ProcessVehicleFlags(param, remove); | 421 | m_log.DebugFormat("{0} VehicleFlags. {1}. Remove={2}", LogHeader, param, remove); |
422 | _scene.TaintedObject(delegate() | ||
423 | { | ||
424 | _vehicle.ProcessVehicleFlags(param, remove); | ||
425 | }); | ||
388 | } | 426 | } |
389 | // Called each simulation step to advance vehicle characteristics | 427 | |
428 | // Called each simulation step to advance vehicle characteristics. | ||
429 | // Called from Scene when doing simulation step so we're in taint processing time. | ||
390 | public void StepVehicle(float timeStep) | 430 | public void StepVehicle(float timeStep) |
391 | { | 431 | { |
392 | _vehicle.Step(timeStep); | 432 | _vehicle.Step(timeStep); |
@@ -395,14 +435,11 @@ public sealed class BSPrim : PhysicsActor | |||
395 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 435 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
396 | public override void SetVolumeDetect(int param) { | 436 | public override void SetVolumeDetect(int param) { |
397 | bool newValue = (param != 0); | 437 | bool newValue = (param != 0); |
398 | if (_isVolumeDetect != newValue) | 438 | _isVolumeDetect = newValue; |
439 | _scene.TaintedObject(delegate() | ||
399 | { | 440 | { |
400 | _isVolumeDetect = newValue; | 441 | SetObjectDynamic(); |
401 | _scene.TaintedObject(delegate() | 442 | }); |
402 | { | ||
403 | SetObjectDynamic(); | ||
404 | }); | ||
405 | } | ||
406 | return; | 443 | return; |
407 | } | 444 | } |
408 | 445 | ||
@@ -410,9 +447,11 @@ public sealed class BSPrim : PhysicsActor | |||
410 | public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } | 447 | public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } |
411 | public override OMV.Vector3 Velocity { | 448 | public override OMV.Vector3 Velocity { |
412 | get { return _velocity; } | 449 | get { return _velocity; } |
413 | set { _velocity = value; | 450 | set { |
451 | _velocity = value; | ||
414 | _scene.TaintedObject(delegate() | 452 | _scene.TaintedObject(delegate() |
415 | { | 453 | { |
454 | DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity); | ||
416 | BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); | 455 | BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); |
417 | }); | 456 | }); |
418 | } | 457 | } |
@@ -420,6 +459,7 @@ public sealed class BSPrim : PhysicsActor | |||
420 | public override OMV.Vector3 Torque { | 459 | public override OMV.Vector3 Torque { |
421 | get { return _torque; } | 460 | get { return _torque; } |
422 | set { _torque = value; | 461 | set { _torque = value; |
462 | DetailLog("{0},SetTorque,call,torque={1}", LocalID, _torque); | ||
423 | } | 463 | } |
424 | } | 464 | } |
425 | public override float CollisionScore { | 465 | public override float CollisionScore { |
@@ -432,13 +472,21 @@ public sealed class BSPrim : PhysicsActor | |||
432 | set { _acceleration = value; } | 472 | set { _acceleration = value; } |
433 | } | 473 | } |
434 | public override OMV.Quaternion Orientation { | 474 | public override OMV.Quaternion Orientation { |
435 | get { return _orientation; } | 475 | get { |
476 | if (_parentPrim != null) | ||
477 | { | ||
478 | // children move around because tied to parent. Get a fresh value. | ||
479 | _orientation = BulletSimAPI.GetObjectOrientation(_scene.WorldID, LocalID); | ||
480 | } | ||
481 | return _orientation; | ||
482 | } | ||
436 | set { | 483 | set { |
437 | _orientation = value; | 484 | _orientation = value; |
438 | // m_log.DebugFormat("{0}: set orientation: id={1}, ori={2}", LogHeader, LocalID, _orientation); | 485 | // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? |
439 | _scene.TaintedObject(delegate() | 486 | _scene.TaintedObject(delegate() |
440 | { | 487 | { |
441 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); | 488 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); |
489 | DetailLog("{0},SetOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | ||
442 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); | 490 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); |
443 | }); | 491 | }); |
444 | } | 492 | } |
@@ -471,8 +519,9 @@ public sealed class BSPrim : PhysicsActor | |||
471 | get { return !IsPhantom && !_isVolumeDetect; } | 519 | get { return !IsPhantom && !_isVolumeDetect; } |
472 | } | 520 | } |
473 | 521 | ||
474 | // make gravity work if the object is physical and not selected | 522 | // Make gravity work if the object is physical and not selected |
475 | // no locking here because only called when it is safe | 523 | // No locking here because only called when it is safe |
524 | // Only called at taint time so it is save to call into Bullet. | ||
476 | private void SetObjectDynamic() | 525 | private void SetObjectDynamic() |
477 | { | 526 | { |
478 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); | 527 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); |
@@ -489,6 +538,7 @@ public sealed class BSPrim : PhysicsActor | |||
489 | RecreateGeomAndObject(); | 538 | RecreateGeomAndObject(); |
490 | 539 | ||
491 | } | 540 | } |
541 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, _mass); | ||
492 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); | 542 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); |
493 | } | 543 | } |
494 | 544 | ||
@@ -529,11 +579,24 @@ public sealed class BSPrim : PhysicsActor | |||
529 | set { _floatOnWater = value; } | 579 | set { _floatOnWater = value; } |
530 | } | 580 | } |
531 | public override OMV.Vector3 RotationalVelocity { | 581 | public override OMV.Vector3 RotationalVelocity { |
532 | get { return _rotationalVelocity; } | 582 | get { |
533 | set { _rotationalVelocity = value; | 583 | /* |
584 | OMV.Vector3 pv = OMV.Vector3.Zero; | ||
585 | // if close to zero, report zero | ||
586 | // This is copied from ODE but I'm not sure why it returns zero but doesn't | ||
587 | // zero the property in the physics engine. | ||
588 | if (_rotationalVelocity.ApproxEquals(pv, 0.2f)) | ||
589 | return pv; | ||
590 | */ | ||
591 | |||
592 | return _rotationalVelocity; | ||
593 | } | ||
594 | set { | ||
595 | _rotationalVelocity = value; | ||
534 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); | 596 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); |
535 | _scene.TaintedObject(delegate() | 597 | _scene.TaintedObject(delegate() |
536 | { | 598 | { |
599 | DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | ||
537 | BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); | 600 | BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); |
538 | }); | 601 | }); |
539 | } | 602 | } |
@@ -546,11 +609,13 @@ public sealed class BSPrim : PhysicsActor | |||
546 | } | 609 | } |
547 | public override float Buoyancy { | 610 | public override float Buoyancy { |
548 | get { return _buoyancy; } | 611 | get { return _buoyancy; } |
549 | set { _buoyancy = value; | 612 | set { |
550 | _scene.TaintedObject(delegate() | 613 | _buoyancy = value; |
551 | { | 614 | _scene.TaintedObject(delegate() |
552 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); | 615 | { |
553 | }); | 616 | DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); |
617 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); | ||
618 | }); | ||
554 | } | 619 | } |
555 | } | 620 | } |
556 | 621 | ||
@@ -586,27 +651,45 @@ public sealed class BSPrim : PhysicsActor | |||
586 | public override float APIDStrength { set { return; } } | 651 | public override float APIDStrength { set { return; } } |
587 | public override float APIDDamping { set { return; } } | 652 | public override float APIDDamping { set { return; } } |
588 | 653 | ||
654 | private List<OMV.Vector3> m_accumulatedForces = new List<OMV.Vector3>(); | ||
589 | public override void AddForce(OMV.Vector3 force, bool pushforce) { | 655 | public override void AddForce(OMV.Vector3 force, bool pushforce) { |
590 | if (force.IsFinite()) | 656 | if (force.IsFinite()) |
591 | { | 657 | { |
592 | _force.X += force.X; | 658 | // _force += force; |
593 | _force.Y += force.Y; | 659 | lock (m_accumulatedForces) |
594 | _force.Z += force.Z; | 660 | m_accumulatedForces.Add(new OMV.Vector3(force)); |
595 | } | 661 | } |
596 | else | 662 | else |
597 | { | 663 | { |
598 | m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); | 664 | m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); |
665 | return; | ||
599 | } | 666 | } |
600 | _scene.TaintedObject(delegate() | 667 | _scene.TaintedObject(delegate() |
601 | { | 668 | { |
602 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); | 669 | lock (m_accumulatedForces) |
670 | { | ||
671 | if (m_accumulatedForces.Count > 0) | ||
672 | { | ||
673 | OMV.Vector3 fSum = OMV.Vector3.Zero; | ||
674 | foreach (OMV.Vector3 v in m_accumulatedForces) | ||
675 | { | ||
676 | fSum += v; | ||
677 | } | ||
678 | m_accumulatedForces.Clear(); | ||
679 | |||
680 | DetailLog("{0},SetObjectForce,taint,force={1}", LocalID, fSum); | ||
681 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, fSum); | ||
682 | } | ||
683 | } | ||
603 | }); | 684 | }); |
604 | } | 685 | } |
605 | 686 | ||
606 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { | 687 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { |
688 | DetailLog("{0},AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); | ||
607 | // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); | 689 | // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); |
608 | } | 690 | } |
609 | public override void SetMomentum(OMV.Vector3 momentum) { | 691 | public override void SetMomentum(OMV.Vector3 momentum) { |
692 | DetailLog("{0},SetMomentum,call,mom={1}", LocalID, momentum); | ||
610 | } | 693 | } |
611 | public override void SubscribeEvents(int ms) { | 694 | public override void SubscribeEvents(int ms) { |
612 | _subscribedEventsMs = ms; | 695 | _subscribedEventsMs = ms; |
@@ -931,6 +1014,7 @@ public sealed class BSPrim : PhysicsActor | |||
931 | { | 1014 | { |
932 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); | 1015 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); |
933 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; | 1016 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; |
1017 | DetailLog("{0},CreateGeom,sphere", LocalID); | ||
934 | // Bullet native objects are scaled by the Bullet engine so pass the size in | 1018 | // Bullet native objects are scaled by the Bullet engine so pass the size in |
935 | _scale = _size; | 1019 | _scale = _size; |
936 | } | 1020 | } |
@@ -938,6 +1022,7 @@ public sealed class BSPrim : PhysicsActor | |||
938 | else | 1022 | else |
939 | { | 1023 | { |
940 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, size={2}", LogHeader, LocalID, _size); | 1024 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, size={2}", LogHeader, LocalID, _size); |
1025 | DetailLog("{0},CreateGeom,box", LocalID); | ||
941 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; | 1026 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; |
942 | _scale = _size; | 1027 | _scale = _size; |
943 | } | 1028 | } |
@@ -974,10 +1059,12 @@ public sealed class BSPrim : PhysicsActor | |||
974 | // if this new shape is the same as last time, don't recreate the mesh | 1059 | // if this new shape is the same as last time, don't recreate the mesh |
975 | if (_meshKey == newMeshKey) return; | 1060 | if (_meshKey == newMeshKey) return; |
976 | 1061 | ||
1062 | DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, _meshKey); | ||
977 | // Since we're recreating new, get rid of any previously generated shape | 1063 | // Since we're recreating new, get rid of any previously generated shape |
978 | if (_meshKey != 0) | 1064 | if (_meshKey != 0) |
979 | { | 1065 | { |
980 | // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); | 1066 | // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); |
1067 | DetailLog("{0},CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); | ||
981 | BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); | 1068 | BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); |
982 | _mesh = null; | 1069 | _mesh = null; |
983 | _meshKey = 0; | 1070 | _meshKey = 0; |
@@ -1007,6 +1094,7 @@ public sealed class BSPrim : PhysicsActor | |||
1007 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH; | 1094 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH; |
1008 | // meshes are already scaled by the meshmerizer | 1095 | // meshes are already scaled by the meshmerizer |
1009 | _scale = new OMV.Vector3(1f, 1f, 1f); | 1096 | _scale = new OMV.Vector3(1f, 1f, 1f); |
1097 | DetailLog("{0},CreateGeomMesh,done", LocalID); | ||
1010 | return; | 1098 | return; |
1011 | } | 1099 | } |
1012 | 1100 | ||
@@ -1020,13 +1108,17 @@ public sealed class BSPrim : PhysicsActor | |||
1020 | // if the hull hasn't changed, don't rebuild it | 1108 | // if the hull hasn't changed, don't rebuild it |
1021 | if (newHullKey == _hullKey) return; | 1109 | if (newHullKey == _hullKey) return; |
1022 | 1110 | ||
1111 | DetailLog("{0},CreateGeomHull,create,key={1}", LocalID, _meshKey); | ||
1112 | |||
1023 | // Since we're recreating new, get rid of any previously generated shape | 1113 | // Since we're recreating new, get rid of any previously generated shape |
1024 | if (_hullKey != 0) | 1114 | if (_hullKey != 0) |
1025 | { | 1115 | { |
1026 | // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); | 1116 | // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); |
1117 | DetailLog("{0},CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey); | ||
1027 | BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); | 1118 | BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); |
1028 | _hullKey = 0; | 1119 | _hullKey = 0; |
1029 | _hulls.Clear(); | 1120 | _hulls.Clear(); |
1121 | DetailLog("{0},CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey); | ||
1030 | BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); | 1122 | BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); |
1031 | _mesh = null; // the mesh cannot match either | 1123 | _mesh = null; // the mesh cannot match either |
1032 | _meshKey = 0; | 1124 | _meshKey = 0; |
@@ -1123,6 +1215,7 @@ public sealed class BSPrim : PhysicsActor | |||
1123 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL; | 1215 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL; |
1124 | // meshes are already scaled by the meshmerizer | 1216 | // meshes are already scaled by the meshmerizer |
1125 | _scale = new OMV.Vector3(1f, 1f, 1f); | 1217 | _scale = new OMV.Vector3(1f, 1f, 1f); |
1218 | DetailLog("{0},CreateGeomHull,done", LocalID); | ||
1126 | return; | 1219 | return; |
1127 | } | 1220 | } |
1128 | 1221 | ||
@@ -1310,6 +1403,7 @@ public sealed class BSPrim : PhysicsActor | |||
1310 | */ | 1403 | */ |
1311 | 1404 | ||
1312 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. | 1405 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. |
1406 | |||
1313 | // Updates only for individual prims and for the root object of a linkset. | 1407 | // Updates only for individual prims and for the root object of a linkset. |
1314 | if (this._parentPrim == null) | 1408 | if (this._parentPrim == null) |
1315 | { | 1409 | { |
@@ -1319,8 +1413,12 @@ public sealed class BSPrim : PhysicsActor | |||
1319 | _velocity = entprop.Velocity; | 1413 | _velocity = entprop.Velocity; |
1320 | _acceleration = entprop.Acceleration; | 1414 | _acceleration = entprop.Acceleration; |
1321 | _rotationalVelocity = entprop.RotationalVelocity; | 1415 | _rotationalVelocity = entprop.RotationalVelocity; |
1416 | |||
1322 | // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", | 1417 | // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", |
1323 | // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); | 1418 | // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); |
1419 | DetailLog("{0},UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | ||
1420 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); | ||
1421 | |||
1324 | base.RequestPhysicsterseUpdate(); | 1422 | base.RequestPhysicsterseUpdate(); |
1325 | } | 1423 | } |
1326 | } | 1424 | } |
@@ -1361,5 +1459,11 @@ public sealed class BSPrim : PhysicsActor | |||
1361 | collisionCollection.Clear(); | 1459 | collisionCollection.Clear(); |
1362 | } | 1460 | } |
1363 | } | 1461 | } |
1462 | |||
1463 | // Invoke the detailed logger and output something if it's enabled. | ||
1464 | private void DetailLog(string msg, params Object[] args) | ||
1465 | { | ||
1466 | Scene.PhysicsLogging.Write(msg, args); | ||
1467 | } | ||
1364 | } | 1468 | } |
1365 | } | 1469 | } |