linearIntegrator.cxx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Filename: linearIntegrator.cxx
  2. // Created by: charles (02Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #include <get_rel_pos.h>
  19. #include "linearIntegrator.h"
  20. #include "config_physics.h"
  21. #include "physicalNode.h"
  22. #include "forceNode.h"
  23. ////////////////////////////////////////////////////////////////////
  24. // Function : BaseLinearIntegrator
  25. // Access : Protected
  26. // Description : constructor
  27. ////////////////////////////////////////////////////////////////////
  28. LinearIntegrator::
  29. LinearIntegrator(void) {
  30. }
  31. ////////////////////////////////////////////////////////////////////
  32. // Function : ~LinearIntegrator
  33. // Access : public, virtual
  34. // Description : destructor
  35. ////////////////////////////////////////////////////////////////////
  36. LinearIntegrator::
  37. ~LinearIntegrator(void) {
  38. }
  39. ////////////////////////////////////////////////////////////////////
  40. // Function : integrate
  41. // Access : public
  42. // Description : parent integration routine, hands off to child
  43. // virtual.
  44. ////////////////////////////////////////////////////////////////////
  45. void LinearIntegrator::
  46. integrate(Physical *physical, pvector< PT(LinearForce) > &forces,
  47. float dt) {
  48. /* <-- darren, 2000.10.06
  49. // cap dt so physics don't go flying off on lags
  50. if (dt > _max_linear_dt)
  51. dt = _max_linear_dt;
  52. */
  53. pvector< PT(PhysicsObject) >::const_iterator current_object_iter;
  54. current_object_iter = physical->get_object_vector().begin();
  55. for (; current_object_iter != physical->get_object_vector().end();
  56. current_object_iter++) {
  57. PhysicsObject *current_object = *current_object_iter;
  58. // bail out if this object doesn't exist or doesn't want to be
  59. // processed.
  60. if (current_object == (PhysicsObject *) NULL)
  61. continue;
  62. // set the object's last position to its current position before we move it
  63. current_object->set_last_position(current_object->get_position());
  64. }
  65. child_integrate(physical, forces, dt);
  66. }