HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_RefineParms.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: GT_RefineParms.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_RefineParms__
12 #define __GT_RefineParms__
13 
14 #include "GT_API.h"
15 #include <GEO/GEO_Normal.h>
16 #include <GEO/GEO_PackedTypes.h>
17 #include <UT/UT_VectorTypes.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_Options.h>
20 #include "GT_Handles.h"
21 #include "GT_DataArray.h"
22 
24 
26 {
27 public:
29  ~GT_RefineParms();
30 
31  /// Hash function
32  unsigned hash() const;
33 
34  /// Comparison test
35  bool isEqual(const GT_RefineParms &src) const;
36 
37  /// @{
38  /// Equivalence operators
39  bool operator==(const GT_RefineParms &src) const
40  { return isEqual(src); }
41  bool operator!=(const GT_RefineParms &src) const
42  { return !isEqual(src); }
43  /// @}
44 
45  /// @{
46  /// Import parameters/options.
47  void set(const UT_StringHolder &name, bool v)
48  { myOptions.setOptionB(name, v); }
49  void set(const UT_StringHolder &name, exint v)
50  { myOptions.setOptionI(name, v); }
52  { myOptions.setOptionF(name, v); }
53  void set(const UT_StringHolder &name, const char *v)
54  { myOptions.setOptionS(name, v); }
56  { myOptions.setOptionIArray(name, v); }
58  { myOptions.setOptionFArray(name, v); }
59  /// @}
60 
61 
62  /// @{
63  /// Import parameters/options.
64  bool import(const UT_StringRef &name, bool &v) const
65  { return importOption(name, v); }
66  bool import(const UT_StringRef &name, int32 &v) const
67  { return importOption(name, v); }
68  bool import(const UT_StringRef &name, int64 &v) const
69  { return importOption(name, v); }
70  bool import(const UT_StringRef &name, fpreal32 &v) const
71  { return importOption(name, v); }
72  bool import(const UT_StringRef &name, fpreal64 &v) const
73  { return importOption(name, v); }
74  bool import(const UT_StringRef &name, UT_String &v) const
75  { return importOption(name, v); }
76  bool import(const UT_StringRef &name, UT_StringHolder &v) const
77  { return importOption(name, v); }
78  bool import(const UT_StringRef &name, UT_Int64Array &v) const
79  { return importOption(name, v); }
80  bool import(const UT_StringRef &name, UT_Fpreal64Array &v) const
81  { return importOption(name, v); }
82  /// @}
83 
84  /// @{
85  /// Get a defaulted value
86  bool get(const UT_StringRef &name, bool def) const
87  {
88  bool val;
89  return import(name, val) ? val : def;
90  }
91  exint get(const UT_StringRef &name, exint def) const
92  {
93  exint val;
94  return import(name, val) ? val : def;
95  }
96  fpreal get(const UT_StringRef &name, fpreal def) const
97  {
98  fpreal val;
99  return import(name, val) ? val : def;
100  }
101  const char *get(const UT_StringRef &name, const char *def,
102  UT_String &storage) const
103  {
104  return import(name, storage) ? (const char *)storage : def;
105  }
106  /// @}
107 
108  /// @{
109  /// Static methods to get a defaulted parameter, with possibly a NULL
110  /// parameter pointer.
111  static bool getBool(const GT_RefineParms *parms,
112  const UT_StringRef &name, bool def)
113  {
114  return parms ? parms->get(name, def) : def;
115  }
117  const UT_StringRef &name, exint def)
118  {
119  return parms ? parms->get(name, def) : def;
120  }
122  const UT_StringRef &name, fpreal def)
123  {
124  return parms ? parms->get(name, def) : def;
125  }
126  static const char *getString(const GT_RefineParms *parms,
127  const UT_StringRef &name, const char *def,
129  {
130  return parms
131  ? parms->get(name, def, storage)
132  : def;
133  }
134  /// @}
135 
136  /// @{
137  /// Common parameters
138 
139  /// @def Define get/set method for bool, int, float types
140 #define GT_GETSET(METHOD, NAME, TYPE, DEF) \
141  private: \
142  static inline const UT_StringHolder &get##METHOD##Name() \
143  { \
144  static constexpr UT_StringLit theName(NAME); \
145  return theName.asHolder(); \
146  } \
147  public: \
148  void set##METHOD(TYPE v) { set(get##METHOD##Name(), v); } \
149  TYPE get##METHOD() const { return get(get##METHOD##Name(), (TYPE)DEF); } \
150  static TYPE get##METHOD(const GT_RefineParms *parms) \
151  { return parms ? parms->get(get##METHOD##Name(),(TYPE)DEF) : (TYPE)DEF; }
152 
153  /// @def Define get/set method for string types
154 #define GT_GETSET_STR(METHOD, NAME, DEF) \
155  void set##METHOD(const char *v) { set(NAME, v); } \
156  const char *get##METHOD(UT_String &storage) const \
157  { return get(NAME, DEF, storage); } \
158  static const char *get##METHOD(const GT_RefineParms *parms, \
159  UT_String &storage) \
160  { return parms ? parms->get(NAME,DEF,storage) : DEF; }
161 
162 #define GT_GETSET_BIT(METHOD, MEMBER, DEF) \
163  void set##METHOD(bool v) { MEMBER = v; } \
164  bool get##METHOD() const { return MEMBER; } \
165  static bool get##METHOD(const GT_RefineParms *parms) \
166  { return parms ? parms->get##METHOD() : DEF; }
167 
168 #define GT_GETSET_INT(METHOD, MEMBER, DEF) \
169  void set##METHOD(exint v) { MEMBER = v; } \
170  exint get##METHOD() const { return MEMBER; } \
171  static exint get##METHOD(const GT_RefineParms *parms) \
172  { return parms ? parms->get##METHOD() : DEF; }
173 
174  /// Render a geometry as a point mesh
175  GT_GETSET (GeoPointMesh, "geo:pointmesh", bool, false)
176 
177  /// Render dangling (unreferenced) points as a point mesh
178  GT_GETSET (ShowUnusedPoints, "geo:unusedpoints", bool, true)
179  /// Render all points, even if not dangled. Requires unusedpoints
180  /// already be set!
181  GT_GETSET (ShowAllPoints, "geo:allpoints", bool, false)
182 
183  /// Use polygon mesh primitives
184  GT_GETSET (GeoPolygonMesh, "geo:polygonmesh", bool, true)
185 
186  /// Refine only a specific group of primitives
187  GT_GETSET_STR(GeoRefineGroup, "geo:refinegroup", NULL)
188 
189  /// Global level of detail
190  GT_GETSET (LOD, "lod", fpreal, 1.0)
191 
192  /// Parametric u level of detail
193  GT_GETSET (ULOD, "ulod", fpreal, 1.0)
194  GT_GETSET (VLOD, "vlod", fpreal, 1.0)
195 
196  /// Quadric parameters
197  GT_GETSET (QuadricDivs, "quadricdivs", fpreal, 20.0)
198 
199  /// Metaball parameters
200  GT_GETSET (MetaMaxDivs, "metamaxdivs", exint, 4096)
201  GT_GETSET (MetaDensity, "metadensity", fpreal, 30.0)
202 
203  /// Parametric u/v range
204  GT_GETSET (URange0, "urange_min", fpreal, 0.0)
205  GT_GETSET (URange1, "urange_max", fpreal, 1.0)
206  GT_GETSET (VRange0, "vrange_min", fpreal, 0.0)
207  GT_GETSET (VRange1, "vrange_max", fpreal, 1.0)
208 
209  /// Whether to respect the packed primitive viewport LOD. This is set for
210  /// viewport rendering, but not for mantra.
211  GT_GETSET_BIT(PackedViewportLOD, myPackedViewLOD, false)
212 
213  /// Override the viewport LOD for packed primitives. The value should be
214  /// set to one of the enum values in $GEO/GEO_PackedTypes.h
215  GT_GETSET_INT(OverridePackedViewportLOD, myOverridePackedLOD, -1);
216 
217  /// The maximum number of LOD levels for agents.
218  GT_GETSET (ViewportAgentMaxLOD, "agent:maxlod", exint, 4)
219 
220  /// The minimum number of polygons for an LOD level; will halt the LOD.
221  GT_GETSET (ViewportAgentPointLimit, "agent:pointlimit", exint, 1000)
222 
223  /// Whether to enable the viewport specific code when refining agents.
224  GT_GETSET (RefineAgentsForViewport, "agent:refineviewport", bool, false)
225 
226  /// Whether to refine the collision layer (if available) for agents instead
227  /// of their current layer.
228  GT_GETSET (UseAgentCollisionLayer, "agent:collisionlayer", bool, false)
229 
230  /// Whether to enable GPU deformation for KineFX characters.
231  GT_GETSET (UseGPUCharacterDeformation, "character:gpudeform", bool, false)
232 
233  /// @{
234  /// When loading Alembic for the viewport, (i.e. when PackedViewportLOD is
235  /// true), we check the following settings to determine whether to load
236  /// face sets and arbitrary attributes.
237  GT_GETSET_BIT(ViewportAlembicFaceSets, myAlembicFaceSets, false)
238  GT_GETSET_BIT(ViewportAlembicArbGeometry, myAlembicArbGeo, true)
239  /// @}
240  GT_GETSET_BIT(AlembicHoudiniAttribs, myAlembicHoudiniAttribs, true)
241  GT_GETSET_BIT(AlembicInstancing, myAlembicInstancing, false)
242  GT_GETSET_BIT(AlembicGLOptimize, myAlembicGLOptimize, false)
243  GT_GETSET_BIT(PointInstanceEnable, myPointInstanceEnable, false)
244 
245 
246  /// When unpacking Alembic, prune geometry that isn't visible. If this is
247  /// false, empty geometry will be created.
248  GT_GETSET_BIT(AlembicSkipInvisible, myAlembicSkipInvisible, true)
249 
250  /// Whether to include primitive/vertex id's when converting to geo
251  GT_GETSET (ConvertIncludeIds, "gconvert:include_ids", bool, false)
252  /// Convert point clouds into a particle primitive (instead of unconnected
253  /// points).
254  GT_GETSET (ConvertParticlePrim, "gconvert:particleprim", bool, false)
255  /// When converting from GT to GU, create packed geometry containing the
256  /// converted GU details.
257  GT_GETSET (ConvertPack, "gconvert:pack", bool, false)
258  /// Convert to Polygon Soup primitives if possible
259  GT_GETSET (AllowPolySoup, "gconvert:allow_polysoup", bool, true)
260  /// When converting from GU_Detail to GT primitives, create a subdivivision
261  /// surface for polygons (instead of a GT_PrimPolygonMesh).
262  GT_GETSET_BIT(PolysAsSubdivision, mySubdivPolys, false)
263  /// Allow display of GT_PrimSubdivisionMeshes as subd surfaces. This won't
264  /// create subd surfaces for regular polygons meshes like the above option.
265  GT_GETSET_BIT(AllowSubdivision, myAllowSubdivPolys, false)
266 
267  /// Whether to coalesce fragments into a single mesh. In most cases, the
268  /// fragment geometry is constant over time, while only the transform
269  /// changes. Some applications prefer getting a large chunk of geometry
270  /// rather than lots of little pieces. Others prefer to use the fact that
271  /// only the transform is animated.
272  GT_GETSET (CoalesceFragments, "coalescefragments", bool, true);
273 
274  /// Whether to coalesce volumes into a single GT_Primitive. Mantra and
275  /// probably most uses of GT require this to be true but at least HAPI
276  /// likes to have volumes be kept as separate GT_Primitives.
277  GT_GETSET (CoalesceVolumes, "coalescevolumes", bool, true);
278 
279  enum
280  {
281  FACESET_NONE = 0, // Don't create facesets
282  FACESET_NON_EMPTY, // Create face sets for non-empty groups
283  FACESET_ALL_GROUPS, // Create face sets for all groups
284  };
285  /// When building polygon/curve meshes from geometry, optionally build a
286  /// "face set" to store group information in the meshes.
287  GT_GETSET (FaceSetMode, "facesetmode", exint, FACESET_NONE)
288 
289  /// When collecting polygons, there are some simple/fast heuristics to
290  /// check whether point attributes need to be compacted. However, this
291  /// doesn't always catch cases if there are stray points (unconnected
292  /// points) in the geometry. If you want precise polygonal meshes, you can
293  /// disable fast detection.
294  GT_GETSET (FastPolyCompacting, "fastpolycompacting", bool, true);
295 
296  /// When collecting polygons, if there are no point or vertex normals
297  /// on the incoming geometry, this indicates whether to compute and add
298  /// vertex normals to the GT_PrimPolygonMesh.
299  GT_GETSET (AddVertexNormals, "addvertexnormals", bool, false);
300 
301  /// When adding vertex normals, this is the cusp angle to use.
302  /// If the dihedral angle of an edge is larger than this, it will be cusped.
303  GT_GETSET (CuspAngle, "cuspangle", float,GEO_DEFAULT_ADJUSTED_CUSP_ANGLE);
304 
305  /// Generate MikkT tangents on polymeshes (vertex attribs)
306  GT_GETSET (AddMikkT, "addmikkt", bool, false);
307 
308  /// Maximum number of points in a point mesh. This is used when refining a
309  /// GEO_Detail.
310  GT_GETSET (MaxPointMeshSize, "maxpointmeshsize", exint, -1)
311 
312  /// Maximum number of points in a polygon mesh. This is used when refining a
313  /// GEO_Detail.
314  GT_GETSET (MaxPolyMeshSize, "maxpolymeshsize", exint, -1)
315 
316  /// Maximum number of points in a curve mesh. This is used when refining a
317  /// GEO_Detail.
318  GT_GETSET (MaxPolyCurveSize, "maxpolycurvesize", exint, -1)
319 
320  /// Number of sub-frame timesteps used when unpacking sequence packed
321  /// primitives. Each sub-step requires a blended detail. A value of -1
322  /// indicated no quantization, 0 will use only keyframe values, 1 will have
323  /// one sub-frame (i.e. 0.5), etc.
324  GT_GETSET (SequenceSubsteps, "sequencesubsteps", exint, -1)
325 
326  /// When creating instances during refining, rather than creating an
327  /// instance with multiple transforms for the geometry, create separate
328  /// instances, but still with a single shared GT_Primitive. This helps
329  /// create aligned instances when trying to match segments for motion blur.
330  GT_GETSET (SeparateInstances, "separateinstance", bool, false)
331 
332  /// When refining Houdini curves (NURBs/Bezier), generate Bezier curve
333  /// meshes along with NURBS curve meshes where appropriate. Otherwise,
334  /// only NURBS curves will be generated.
335  GT_GETSET (FullBezierSupport, "fullBezierSupport", bool, true);
336  /// If full Beziers aren't supported, still refine cubic Bezier curves to a
337  /// pure Bezier curve mesh.
338  GT_GETSET (CubicBezierSupport, "cubicBezierSupport", bool, true);
339 
340  /// Whether to refine capture regions to curves (e.g. as required by the
341  /// viewport) or to polygons.
342  GT_GETSET (RefineCRegionsToCurves, "refinecregionstocurves", bool, false)
343 
344  /// Prune geometry that is hidden.
345  GT_GETSET_BIT(SkipHidden, mySkipHidden, true)
346 
347  /// After height field volumes are coalesced, refine them into
348  /// GT_PrimPolygonMesh (or GT_PrimSubdivisionMesh if PolysAsSubdivision
349  /// option is enabled) instead of GT_PrimVolume(s).
350  GT_GETSET (HeightFieldConvert, "heightfieldconvert", bool, false);
351 
352  /// The refinement is for a viewer vulkan renderer.
353  GT_GETSET (ForVulkan, "forvulkan", bool, false);
354 
355 #undef GT_IMPLEMENT_GETSET
356 #undef GT_IMPLEMENT_GETSET_STR
357 
359  { return myViewportMaterialAttrib; }
361  { return myViewportMaterialRemapAttrib; }
363  const GT_DataArrayHandle &rh)
364  { myViewportMaterialAttrib = mh;
365  myViewportMaterialRemapAttrib = rh; }
366 
368  { myAttribFilter = af; }
370  { return myAttribFilter; }
371 
372  /// Load from UT_Options
373  bool load(const UT_Options &opts);
374 
375  /// @{
376  /// Debugging methods to dump the non-default parameters. Dump to either
377  /// stdout or a string buffer.
378  void dump() const;
379  bool dump(UT_WorkBuffer &buf) const;
380  /// @}
381 
382 public:
383  /// @{
384  /// For memory tracking, we override the new/delete operators
385  static void *operator new(size_t size);
386  static void *operator new(size_t size, void *p);
387  static void operator delete(void *p, size_t size);
388  /// @}
389 
390 protected:
391  template <typename T> bool
393  {
394  return myOptions.importOption(name, value);
395  }
396 private:
397  UT_Options myOptions;
398  int myAlembicArbGeo : 1,
399  myAlembicFaceSets : 1,
400  myAlembicHoudiniAttribs : 1,
401  myAlembicInstancing : 1,
402  myAlembicGLOptimize : 1,
403  myAlembicSkipInvisible : 1,
404  myPackedViewLOD : 1,
405  mySubdivPolys : 1,
406  myAllowSubdivPolys : 1,
407  myPointInstanceEnable : 1,
408  myOverridePackedLOD : 5,
409  mySkipHidden : 1;
410  GT_DataArrayHandle myViewportMaterialAttrib;
411  GT_DataArrayHandle myViewportMaterialRemapAttrib;
412  const GT_GEOAttributeFilter *myAttribFilter;
413 };
414 
415 #endif
void setViewportMaterialAttrib(const GT_DataArrayHandle &mh, const GT_DataArrayHandle &rh)
void set(const UT_StringHolder &name, UT_Int64Array &v)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
static fpreal getFloat(const GT_RefineParms *parms, const UT_StringRef &name, fpreal def)
#define GT_GETSET_BIT(METHOD, MEMBER, DEF)
GT_DataArrayHandle getViewportMaterialRemapAttrib() const
int int32
Definition: SYS_Types.h:39
void set(const UT_StringHolder &name, const char *v)
#define GT_GETSET_INT(METHOD, MEMBER, DEF)
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
const GLdouble * v
Definition: glcorearb.h:837
SIM_API const UT_StringHolder agent
GLsizei const GLfloat * value
Definition: glcorearb.h:824
bool get(const UT_StringRef &name, bool def) const
void set(const UT_StringHolder &name, fpreal v)
Class to filter attributes when building GT_AttributeLists.
#define GT_API
Definition: GT_API.h:13
int64 exint
Definition: SYS_Types.h:125
#define GT_GETSET(METHOD, NAME, TYPE, DEF)
float fpreal32
Definition: SYS_Types.h:200
void set(const UT_StringHolder &name, exint v)
double fpreal64
Definition: SYS_Types.h:201
#define GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
Definition: GEO_Normal.h:28
bool operator!=(const GT_RefineParms &src) const
GT_DataArrayHandle getViewportMaterialAttrib() const
long long int64
Definition: SYS_Types.h:116
bool importOption(const UT_StringRef &name, T &value) const
GLuint const GLchar * name
Definition: glcorearb.h:786
#define GT_GETSET_STR(METHOD, NAME, DEF)
void set(const UT_StringHolder &name, bool v)
void setAttributeFilter(const GT_GEOAttributeFilter *af)
static const char * getString(const GT_RefineParms *parms, const UT_StringRef &name, const char *def, UT_String &storage)
const GT_GEOAttributeFilter * getAttributeFilter() const
GLsizeiptr size
Definition: glcorearb.h:664
A map of string to various well defined value types.
Definition: UT_Options.h:84
GA_API const UT_StringHolder parms
fpreal64 fpreal
Definition: SYS_Types.h:278
void set(const UT_StringHolder &name, UT_Fpreal64Array &v)
GLuint GLfloat * val
Definition: glcorearb.h:1608
static bool getBool(const GT_RefineParms *parms, const UT_StringRef &name, bool def)
static exint getInt(const GT_RefineParms *parms, const UT_StringRef &name, exint def)
GLint lod
Definition: glcorearb.h:2765
bool operator==(const GT_RefineParms &src) const
GLenum src
Definition: glcorearb.h:1793