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 #include <UT/UT_StringHolder.h>
18 #include <UT/UT_UniquePtr.h>
19 
20 class SIM_SolverEnableTestCache;
22 
23 /// This solver class passes the solve responsibility to one or more other
24 /// solvers. It searches for any SIM_Solver subdata attached to itself, and
25 /// and calls the one that matches the object's swithch value.
27 {
28 public:
29  SIM_SolverEnableParms &param() { return myParms; }
30  const SIM_SolverEnableParms &param() const { return myParms; }
31 
32  OP_VERSION versionParms() const { return myVersion; }
33  void setVersionParms(OP_VERSION version) { myVersion = version; }
34 
35  void clearCachedSubdata() const
36  { mySolverListCached = false; mySolverList.clear(); }
37 
38 protected:
39 
40  class TestCache
41  {
42  public:
43  void update(const SIM_SolverEnableParms &parms);
44  bool test(const SIM_SolverEnableParms &parms, const SIM_RootData *object);
45  protected:
50 
56  };
57 
58  /// Basic SIM_SolverEnable constructor.
59  explicit SIM_SolverEnable(const SIM_DataFactory *factory);
60  /// Basic SIM_SolverEnable destructor.
61  ~SIM_SolverEnable() override;
62 
63  /// Creates a SIM_QueryArrays object to treat impact as a record
65  {
66  return new SIM_QueryCombine(BaseClass::createQueryObjectSubclass(), param().createQueryObject(this));
67  }
68  void makeEqualSubclass(const SIM_Data *source) override
69  {
70  BaseClass::makeEqualSubclass(source);
72  if (src)
73  {
74  param() = src->param();
75  setVersionParms(src->versionParms());
76  }
77  }
78  void saveSubclass(std::ostream &os) const override
79  {
80  BaseClass::saveSubclass(os);
81  myParms.save(os);
82  }
83  bool loadSubclass(UT_IStream &is) override
84  {
85  if (!BaseClass::loadSubclass(is))
86  return false;
87  if (!myParms.load(is))
88  return false;
89  return true;
90  }
91  bool enableSolvers(const SIM_RootData *object) const;
92 
93  /// We are static if our switch is invalid or our input is.
94  bool isStaticSubclass(const SIM_Object *obj) const override;
95 
96  /// Override this function to pass this call along to our child solvers.
97  SIM_Result solveObjectsSubclass(
98  SIM_Engine &engine,
99  SIM_ObjectArray &objects,
100  SIM_ObjectArray &newobjects,
101  SIM_ObjectArray &feedbacktoobjects,
102  const SIM_Time &timestep) override;
103  SIM_Result solveRelationshipSubclass(
104  SIM_Engine &engine,
105  SIM_Relationship &relation,
106  const SIM_Time &timestep) override;
107  /// Override this function to get the requirements of our child solvers.
108  int getRequestedCacheSubclass() const override;
110  const SIM_Object &object,
111  const UT_Vector3 &impulseworldpos,
112  UT_DMatrix3 &immatrix) const override;
114  const SIM_Object &object,
115  int ptnum, UT_DMatrix3 &immatrix) const override;
118  const SIM_Object &object) const override;
120  const SIM_Object &object,
121  const UT_Vector3 &worldpos,
122  const SIM_Property &property) const override;
124  const SIM_Object &object,
125  int ptnum,
126  const SIM_Property &property) const override;
128  const SIM_Object &object,
129  UT_String &label) const override;
131  const SIM_Object &object,
132  const UT_String &colliderlabel,
133  UT_String &collidertype,
134  bool &colliderreverseobjectroles) const override;
135 
136 private:
137  static const SIM_DopDescription *getSolverEnableDopDescription();
138 
139  SIM_Solver *myCurrentSolver;
140  SIM_SolverEnableParms myParms;
141  OP_VERSION myVersion;
142 
143  mutable bool mySolverListCached;
144  mutable SIM_SolverArray mySolverList;
145  mutable TestCache myTestCache;
146 
149  SIM_Solver,
150  "Enable Solver",
151  getSolverEnableDopDescription());
152 };
153 
154 #endif
155 
UT_StringHolder myObjectPatternCache
const SIM_SolverEnableParms & param() const
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#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:2545
UT_StringHolder myDataNamesCache
uint64 OP_VERSION
Definition: OP_Version.h:6
virtual void getDefaultColliderSubclass(const SIM_Object &object, const UT_String &colliderlabel, UT_String &collidertype, bool &colliderreverseobjectroles) const
virtual int getRequestedCacheSubclass() const
SIM_SolverEnableParms & param()
UT_StringHolder myAttribNamesCache
bool loadSubclass(UT_IStream &is) override
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
SIM_Query * createQueryObjectSubclass() const override
Creates a SIM_QueryArrays object to treat impact as a record.
void makeEqualSubclass(const SIM_Data *source) override
Holds pointers to a number of SIM_Object objects.
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
virtual void getImpulseMassMatrixSubclass(const SIM_Object &object, const UT_Vector3 &impulseworldpos, UT_DMatrix3 &immatrix) const
void setVersionParms(OP_VERSION version)
virtual SIM_PointImpulseMassMatrixResolver * getPointImpulseMassMatrixResolverSubclass(const SIM_Object &object) const
Builds a resolver for evaluating mass matrices swiftly.
OP_VERSION versionParms() const
virtual SIM_Result solveObjectsSubclass(SIM_Engine &engine, SIM_ObjectArray &objects, SIM_ObjectArray &newobjects, SIM_ObjectArray &feedbacktoobjects, const SIM_Time &timestep)=0
virtual fpreal getPropertyAtPositionSubclass(const SIM_Object &object, const UT_Vector3 &worldpos, const SIM_Property &property) const
GT_API const UT_StringHolder version
virtual void getDefaultColliderLabelSubclass(const SIM_Object &object, UT_String &label) const
Gets the default collider label for an object using this solver.
GLenum GLfloat param
Definition: glcorearb.h:104
void clearCachedSubdata() const
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_UniquePtr< SIM_DataFilterRootData > myObjectFilter
void saveSubclass(std::ostream &os) const override
#define SIM_API
Definition: SIM_API.h:12
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
UT_StringHolder myFieldNamesCache
SIM_Property
virtual fpreal getPropertyAtPointSubclass(const SIM_Object &object, int ptnum, const SIM_Property &property) const
GLenum src
Definition: glcorearb.h:1793