Panda3D
|
00001 // Filename: baseIntegrator.h 00002 // Created by: charles (11Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef BASEINTEGRATOR_H 00016 #define BASEINTEGRATOR_H 00017 00018 #include "pandabase.h" 00019 #include "pointerTo.h" 00020 #include "referenceCount.h" 00021 #include "luse.h" 00022 00023 #include "linearForce.h" 00024 #include "angularForce.h" 00025 00026 #include "pvector.h" 00027 00028 class Physical; 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : BaseIntegrator 00032 // Description : pure virtual integrator class that holds cached 00033 // matrix information that really should be common to 00034 // any possible child implementation. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDAPHYSICS BaseIntegrator : public ReferenceCount { 00037 public: 00038 typedef epvector<LMatrix4> MatrixVector; 00039 typedef pvector<PT(LinearForce)> LinearForceVector; 00040 typedef pvector<PT(AngularForce)> AngularForceVector; 00041 00042 virtual ~BaseIntegrator(); 00043 00044 PUBLISHED: 00045 virtual void output(ostream &out) const; 00046 virtual void write_precomputed_linear_matrices(ostream &out, 00047 unsigned int indent=0) const; 00048 virtual void write_precomputed_angular_matrices(ostream &out, 00049 unsigned int indent=0) const; 00050 virtual void write(ostream &out, unsigned int indent=0) const; 00051 00052 protected: 00053 BaseIntegrator(); 00054 00055 INLINE const MatrixVector &get_precomputed_linear_matrices() const; 00056 INLINE const MatrixVector &get_precomputed_angular_matrices() const; 00057 00058 void precompute_linear_matrices(Physical *physical, 00059 const LinearForceVector &forces); 00060 void precompute_angular_matrices(Physical *physical, 00061 const AngularForceVector &forces); 00062 00063 private: 00064 // since the wrt for each physicsobject between its physicalnode 00065 // and however many forces will be the same among one physical, 00066 // the transformation matrices can be pulled out of the inner loop 00067 // and precomputed. 00068 MatrixVector _precomputed_linear_matrices; 00069 MatrixVector _precomputed_angular_matrices; 00070 }; 00071 00072 #include "baseIntegrator.I" 00073 00074 #endif // BASEINTEGRATOR_H