HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 class SIM_SolverEnableTestCache;
18 
19 /// This solver class passes the solve responsibility to one or more other
20 /// solvers. It searches for any SIM_Solver subdata attached to itself, and
21 /// and calls the one that matches the object's swithch value.
23 {
24 public:
25  SIM_SolverEnableParms &param() { return myParms; }
26  const SIM_SolverEnableParms &param() const { return myParms; }
27 
28  void clearCachedSubdata() const
29  { mySolverListCached = false; mySolverList.clear(); }
30 
31 protected:
32 
33  class TestCache
34  {
35  public:
36  void update(const SIM_SolverEnableParms &parms);
37  bool test(const SIM_SolverEnableParms &parms, const SIM_RootData *object);
38  protected:
39  UT_StringHolder myDataNamesCache, myAttribNamesCache;
40  UT_StringArray myParsedData, myParsedAttrib;
42  };
43 
44  /// Basic SIM_SolverEnable constructor.
45  explicit SIM_SolverEnable(const SIM_DataFactory *factory);
46  /// Basic SIM_SolverEnable destructor.
47  virtual ~SIM_SolverEnable();
48 
49  /// Creates a SIM_QueryArrays object to treat impact as a record
51  {
52  return new SIM_QueryCombine(BaseClass::createQueryObjectSubclass(), param().createQueryObject(this));
53  }
54  virtual void makeEqualSubclass(const SIM_Data *source)
55  {
56  BaseClass::makeEqualSubclass(source);
58  if (src)
59  {
60  param() = src->param();
61  }
62  }
63  virtual void saveSubclass(std::ostream &os) const
64  {
65  BaseClass::saveSubclass(os);
66  myParms.save(os);
67  }
68  virtual bool loadSubclass(UT_IStream &is)
69  {
70  if (!BaseClass::loadSubclass(is))
71  return false;
72  if (!myParms.load(is))
73  return false;
74  return true;
75  }
76  bool enableSolvers(const SIM_RootData *object) const;
77 
78  /// We are static if our switch is invalid or our input is.
79  virtual bool isStaticSubclass(const SIM_Object *obj) const;
80 
81  /// Override this function to pass this call along to our child solvers.
82  virtual SIM_Result solveObjectsSubclass(SIM_Engine &engine,
83  SIM_ObjectArray &objects,
84  SIM_ObjectArray &newobjects,
85  SIM_ObjectArray &feedbacktoobjects,
86  const SIM_Time &timestep);
87  virtual SIM_Result solveRelationshipSubclass(SIM_Engine &engine,
88  SIM_Relationship &relation,
89  const SIM_Time &timestep);
90  /// Override this function to get the requirements of our child solvers.
91  virtual int getRequestedCacheSubclass() const;
92  virtual void getImpulseMassMatrixSubclass(
93  const SIM_Object &object,
94  const UT_Vector3 &impulseworldpos,
95  UT_DMatrix3 &immatrix) const;
97  const SIM_Object &object,
98  int ptnum, UT_DMatrix3 &immatrix) const;
100  const SIM_Object &object) const;
101  virtual fpreal getPropertyAtPositionSubclass(const SIM_Object &object,
102  const UT_Vector3 &worldpos,
103  const SIM_Property &property) const;
104  virtual fpreal getPropertyAtPointSubclass(const SIM_Object &object,
105  int ptnum, const SIM_Property &property) const;
106  virtual void getDefaultColliderLabelSubclass(
107  const SIM_Object &object,
108  UT_String &label) const;
109  virtual void getDefaultColliderSubclass(
110  const SIM_Object &object,
111  const UT_String &colliderlabel,
112  UT_String &collidertype,
113  bool &colliderreverseobjectroles) const;
114 
115 private:
116  static const SIM_DopDescription *getSolverEnableDopDescription();
117 
118  SIM_Solver *myCurrentSolver;
119  SIM_SolverEnableParms myParms;
120 
121  mutable bool mySolverListCached;
122  mutable SIM_SolverArray mySolverList;
123  mutable TestCache myTestCache;
124 
127  SIM_Solver,
128  "Enable Solver",
129  getSolverEnableDopDescription());
130 };
131 
132 #endif
133 
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
cvex test(vector P=0;int unbound=3;export float s=0;export vector Cf=0;)
Definition: test.vfl:11
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
UT_StringHolder myDataNamesCache
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:270
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