HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_SolverEnable.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  */
7 
8 #ifndef __SIM_SolverEnable_h__
9 #define __SIM_SolverEnable_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_Solver.h"
13 #include "SIM_Query.h"
14 #include "SIM_QueryCombine.h"
16 
17 /// This solver class passes the solve responsibility to one or more other
18 /// solvers. It searches for any SIM_Solver subdata attached to itself, and
19 /// and calls the one that matches the object's swithch value.
21 {
22 public:
23  SIM_SolverEnableParms &param() { return myParms; }
24  const SIM_SolverEnableParms &param() const { return myParms; }
25 
26  void clearCachedSubdata() const
27  { mySolverListCached = false; mySolverList.clear(); }
28 
29 protected:
30  /// Basic SIM_SolverEnable constructor.
31  explicit SIM_SolverEnable(const SIM_DataFactory *factory);
32  /// Basic SIM_SolverEnable destructor.
33  virtual ~SIM_SolverEnable();
34 
35  /// Creates a SIM_QueryArrays object to treat impact as a record
37  {
38  return new SIM_QueryCombine(BaseClass::createQueryObjectSubclass(), param().createQueryObject(this));
39  }
40  virtual void makeEqualSubclass(const SIM_Data *source)
41  {
42  BaseClass::makeEqualSubclass(source);
44  if (src)
45  {
46  param() = src->param();
47  }
48  }
49  virtual void saveSubclass(std::ostream &os) const
50  {
51  BaseClass::saveSubclass(os);
52  myParms.save(os);
53  }
54  virtual bool loadSubclass(UT_IStream &is)
55  {
56  if (!BaseClass::loadSubclass(is))
57  return false;
58  if (!myParms.load(is))
59  return false;
60  return true;
61  }
62  bool enableSolvers(const SIM_RootData *object) const;
63 
64  /// We are static if our switch is invalid or our input is.
65  virtual bool isStaticSubclass(const SIM_Object *obj) const;
66 
67  /// Override this function to pass this call along to our child solvers.
68  virtual SIM_Result solveObjectsSubclass(SIM_Engine &engine,
69  SIM_ObjectArray &objects,
70  SIM_ObjectArray &newobjects,
71  SIM_ObjectArray &feedbacktoobjects,
72  const SIM_Time &timestep);
73  virtual SIM_Result solveRelationshipSubclass(SIM_Engine &engine,
74  SIM_Relationship &relation,
75  const SIM_Time &timestep);
76  /// Override this function to get the requirements of our child solvers.
77  virtual int getRequestedCacheSubclass() const;
78  virtual void getImpulseMassMatrixSubclass(
79  const SIM_Object &object,
80  const UT_Vector3 &impulseworldpos,
81  UT_DMatrix3 &immatrix) const;
83  const SIM_Object &object,
84  int ptnum, UT_DMatrix3 &immatrix) const;
86  const SIM_Object &object) const;
87  virtual fpreal getPropertyAtPositionSubclass(const SIM_Object &object,
88  const UT_Vector3 &worldpos,
89  const SIM_Property &property) const;
90  virtual fpreal getPropertyAtPointSubclass(const SIM_Object &object,
91  int ptnum, const SIM_Property &property) const;
93  const SIM_Object &object,
94  UT_String &label) const;
95  virtual void getDefaultColliderSubclass(
96  const SIM_Object &object,
97  const UT_String &colliderlabel,
98  UT_String &collidertype,
99  bool &colliderreverseobjectroles) const;
100 
101 private:
102  static const SIM_DopDescription *getSolverEnableDopDescription();
103 
104  SIM_Solver *myCurrentSolver;
105  SIM_SolverEnableParms myParms;
106 
107  mutable bool mySolverListCached;
108  mutable SIM_SolverArray mySolverList;
109 
112  SIM_Solver,
113  "Enable Solver",
114  getSolverEnableDopDescription());
115 };
116 
117 #endif
118 
const SIM_SolverEnableParms & param() const
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
#define SIM_DATA_CASTCONST(Data, DataClass)
Definition: SIM_Utils.h:34
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
virtual void getDefaultColliderSubclass(const SIM_Object &object, const UT_String &colliderlabel, UT_String &collidertype, bool &colliderreverseobjectroles) const
virtual int getRequestedCacheSubclass() const
SIM_SolverEnableParms & param()
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
Holds pointers to a number of SIM_Object objects.
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
virtual void getImpulseMassMatrixSubclass(const SIM_Object &object, const UT_Vector3 &impulseworldpos, UT_DMatrix3 &immatrix) const
virtual SIM_PointImpulseMassMatrixResolver * getPointImpulseMassMatrixResolverSubclass(const SIM_Object &object) const
Builds a resolver for evaluating mass matrices swiftly.
virtual SIM_Result solveObjectsSubclass(SIM_Engine &engine, SIM_ObjectArray &objects, SIM_ObjectArray &newobjects, SIM_ObjectArray &feedbacktoobjects, const SIM_Time &timestep)=0
virtual void makeEqualSubclass(const SIM_Data *source)
virtual fpreal getPropertyAtPositionSubclass(const SIM_Object &object, const UT_Vector3 &worldpos, const SIM_Property &property) const
virtual void getDefaultColliderLabelSubclass(const SIM_Object &object, UT_String &label) const
Gets the default collider label for an object using this solver.
double fpreal
Definition: SYS_Types.h:263
GLenum GLfloat param
Definition: glcorearb.h:103
void clearCachedSubdata() const
virtual bool loadSubclass(UT_IStream &is)
#define SIM_API
Definition: SIM_API.h:10
virtual SIM_Query * createQueryObjectSubclass() const
Creates a SIM_QueryArrays object to treat impact as a record.
virtual SIM_Result solveRelationshipSubclass(SIM_Engine &engine, SIM_Relationship &relationship, const SIM_Time &timestep)
Definition: SIM_Solver.h:182
virtual void getPointImpulseMassMatrixSubclass(const SIM_Object &object, int ptnum, UT_DMatrix3 &immatrix) const
virtual bool isStaticSubclass(const SIM_Object *obj) const
Determines if this solver does nothing on the object.
Definition: SIM_Solver.h:159
virtual void saveSubclass(std::ostream &os) const
SIM_Property
virtual fpreal getPropertyAtPointSubclass(const SIM_Object &object, int ptnum, const SIM_Property &property) const
GLenum src
Definition: glcorearb.h:1792