HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GAS_GeometryVex.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  * NAME: GAS_GeometryVex.h ( GAS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GAS_GeometryVex__
12 #define __GAS_GeometryVex__
13 
14 #include "SIMZ_API.h"
15 
16 #include <UT/UT_WeakPtr.h>
17 #include <UT/UT_SharedPtr.h>
18 
19 #include <GU/GU_Detail.h>
20 
21 #include <SIM/SIM_RawField.h>
22 #include <SIM/SIM_RawIndexField.h>
23 #include <SIM/SIM_PhysicalParms.h>
24 
25 #include <VEX/VEX_GeoCommand.h>
26 #include <VEX/VEX_VexResolver.h>
27 
28 #include <CVEX/CVEX_Context.h>
29 #include <CVEX/CVEX_Value.h>
30 
31 #include <GVEX/GVEX_Execute.h>
32 
33 #include <GAS/GAS_SubSolver.h>
34 
35 #include <SIM/SIM_Query.h>
36 #include <SIM/SIM_QueryCombine.h>
38 
39 class SIM_GeometryCopy;
40 
41 class GVEX_GeoBlockData;
42 class GU_VexGeoInputs;
43 class GA_ElementGroup;
44 
45 class OP_Caller;
46 
47 class gas_SimpleGroupCache;
48 
50 {
51 public:
53  {
54  myScriptParsed = false;
55  myGroupParsed = false;
56  mySimpleGroupCache.clear();
57  myCurrentNodeId = -1;
58  myVexNodeTimestamp = -1;
59  myVexNodeId = -1;
60  myDontRecomputeNormals = false;
61  myComputeNormals = false;
62  }
64  void clearBlocks();
65 
67 
69 
70  // We have to hold the script
74 
75  // Parsed group.
80 
81  // Our cached bindings. Provided our new detail
82  // has a matching set of attributes we assume our
83  // bindings will match.
86 
89 
92 
93  // Tracks if we have an implicit normal that needs
94  // recomputing every time.
96  // Tracks if we potentially need to recompute normals due
97  // to deforming P, but have determined we shouldn't.
99 };
100 
101 
103 {
104 public:
105  GA_AttributeOwner targetClass() const { return (GA_AttributeOwner) param().getAttribClass(); }
106 
107  GAS_GeometryVexParms &param() { return myParms; }
108  const GAS_GeometryVexParms &param() const { return myParms; }
109 
110 protected:
111  explicit GAS_GeometryVex(const SIM_DataFactory *factory);
112  virtual ~GAS_GeometryVex();
113 
114  /// Creates a SIM_QueryArrays object to treat impact as a record
116  {
117  return new SIM_QueryCombine(BaseClass::createQueryObjectSubclass(), param().createQueryObject(this));
118  }
119  virtual void makeEqualSubclass(const SIM_Data *source)
120  {
121  BaseClass::makeEqualSubclass(source);
123  if (src)
124  {
125  param() = src->param();
126 
127  // We steal forward in time any caches.
128  if (myCache) delete myCache;
129  myCache = src->myCache;
130  SYSconst_cast(src)->myCache = 0;
131  }
132  }
133  virtual void saveSubclass(std::ostream &os) const
134  {
135  BaseClass::saveSubclass(os);
136  myParms.save(os);
137  }
138  virtual bool loadSubclass(UT_IStream &is)
139  {
140  if (!BaseClass::loadSubclass(is))
141  return false;
142  if (!myParms.load(is))
143  return false;
144  return true;
145  }
146 
147  bool shouldMultiThread(SIM_RawField *field) const
148  { return field->field()->numTiles() > 1; }
149 
150  virtual bool solveGasSubclass(SIM_Engine &engine,
151  SIM_Object *obj,
152  SIM_Time time,
153  SIM_Time timestep);
154 
155  bool runVexOnGeometry(SIM_Engine &engine, SIM_Object *obj, SIM_GeometryCopy *geo, const char *geoname);
156 
157  void executeVex(SIM_Object *obj, GU_Detail *gdp,
158  int argc, const char *const *argv,
159  OP_Caller &caller,
160  GU_VexGeoInputs *geoinputs,
161  const UT_Array<UT_Matrix4D> *inputxform,
162  const UT_IntArray *inputxformid) const;
163 
164  THREADED_METHOD1_CONST(GAS_GeometryVex, parms.multithread, processVexGeometry,
165  GVEX_GeometryParms &, parms)
166  void processVexGeometryPartial(GVEX_GeometryParms &parms,
168 
169  bool processVexBlock(
170  const GU_Detail *gdp,
171  GVEX_GeoBlockData &data,
172  CVEX_Context &context,
173  int argc, const char *const*argv,
174  const UT_Array<GVEX_GeometryMap> &geomap,
175  int num, GA_Offset *elementoffsets,
176  bool triviallist,
177  fpreal t,
178  const UT_JobInfo &info) const;
179 
180  void addInputName(CVEX_Context &context, int idx, CVEX_StringArray &inputnames) const;
181 private:
182  static const SIM_DopDescription *getDopDescription();
183 
184  fpreal myTime, mySopTime, myTimeInc;
185  fpreal mySimTime, mySimFrame;
186 
187  GAS_GeometryVexParms myParms;
188  gas_GeometryVexCache *myCache;
189 
193  "Gas Geometry Vex",
194  getDopDescription());
195 };
196 
197 #endif
GAS_GeometryVexParms myParam
const GAS_GeometryVexParms & param() const
#define SIMZ_API
Definition: SIMZ_API.h:10
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
#define SIM_DATA_CASTCONST(Data, DataClass)
Definition: SIM_Utils.h:34
virtual void makeEqualSubclass(const SIM_Data *source)
virtual void saveSubclass(std::ostream &os) const
UT_WorkArgs myScriptArgs
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:126
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
Call VEX from C++.
Definition: CVEX_Context.h:147
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GA_Size GA_Offset
Definition: GA_Types.h:617
int numTiles() const
GA_AttributeOwner targetClass() const
UT_UniquePtr< GVEX_AttribHash > myDetailAttribHash
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
GLboolean * data
Definition: glcorearb.h:130
UT_UniquePtr< GVEX_AttribHash > myAttribHash
#define THREADED_METHOD1_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1)
GA_AttributeOwner
Definition: GA_Types.h:33
double fpreal
Definition: SYS_Types.h:269
GLenum GLfloat param
Definition: glcorearb.h:103
UT_StringArray myGroupNames
UT_WeakPtr< gas_SimpleGroupCache > mySimpleGroupCache
UT_Array< GVEX_GeoBlockData * > myBlocks
virtual bool loadSubclass(UT_IStream &is)
GAS_GeometryVexParms & param()
png_infop png_uint_32 int num
Definition: png.h:2158
bool shouldMultiThread(SIM_RawField *field) const
#define const
Definition: zconf.h:214
virtual SIM_Query * createQueryObjectSubclass() const
Creates a SIM_QueryArrays object to treat impact as a record.
UT_VoxelArrayF UT_VoxelArrayF & field
UT_Array< GVEX_GeometryMap > myGeoMap
GLenum src
Definition: glcorearb.h:1792
This implements a SIM_Geometry that copies the source geometry.