baseIntegrator.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file baseIntegrator.h
  10. * @author charles
  11. * @date 2000-08-11
  12. */
  13. #ifndef BASEINTEGRATOR_H
  14. #define BASEINTEGRATOR_H
  15. #include "pandabase.h"
  16. #include "pointerTo.h"
  17. #include "referenceCount.h"
  18. #include "luse.h"
  19. #include "linearForce.h"
  20. #include "angularForce.h"
  21. #include "pvector.h"
  22. #include "epvector.h"
  23. class Physical;
  24. /**
  25. * pure virtual integrator class that holds cached matrix information that
  26. * really should be common to any possible child implementation.
  27. */
  28. class EXPCL_PANDA_PHYSICS BaseIntegrator : public ReferenceCount {
  29. public:
  30. typedef epvector<LMatrix4> MatrixVector;
  31. typedef pvector<PT(LinearForce)> LinearForceVector;
  32. typedef pvector<PT(AngularForce)> AngularForceVector;
  33. virtual ~BaseIntegrator();
  34. PUBLISHED:
  35. virtual void output(std::ostream &out) const;
  36. virtual void write_precomputed_linear_matrices(std::ostream &out,
  37. int indent=0) const;
  38. virtual void write_precomputed_angular_matrices(std::ostream &out,
  39. int indent=0) const;
  40. virtual void write(std::ostream &out, int indent=0) const;
  41. protected:
  42. BaseIntegrator();
  43. INLINE const MatrixVector &get_precomputed_linear_matrices() const;
  44. INLINE const MatrixVector &get_precomputed_angular_matrices() const;
  45. void precompute_linear_matrices(Physical *physical,
  46. const LinearForceVector &forces);
  47. void precompute_angular_matrices(Physical *physical,
  48. const AngularForceVector &forces);
  49. private:
  50. // since the wrt for each physicsobject between its physicalnode and however
  51. // many forces will be the same among one physical, the transformation
  52. // matrices can be pulled out of the inner loop and precomputed.
  53. MatrixVector _precomputed_linear_matrices;
  54. MatrixVector _precomputed_angular_matrices;
  55. };
  56. #include "baseIntegrator.I"
  57. #endif // BASEINTEGRATOR_H