HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUI_GeoRender.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: GUI_GeoRender.h ( GUI Library, C++)
7  *
8  * COMMENTS:
9  * General rendering class for a GU_Detail.
10  */
11 #ifndef GUI_GeoRender_h
12 #define GUI_GeoRender_h
13 
14 #include <UT/UT_BoundingBox.h>
15 #include <UT/UT_Lock.h>
16 #include <UT/UT_Rect.h>
17 #include <UT/UT_String.h>
18 #include <UT/UT_StringMap.h>
19 #include <UT/UT_Matrix4.h>
20 #include <UT/UT_ValArray.h>
21 #include <UT/UT_UniquePtr.h>
22 #include <UT/UT_Array.h>
23 #include <DEP/DEP_MicroNode.h>
24 #include <RE/RE_Types.h>
25 #include <RE/RE_Texture.h>
26 #include <RE/RE_TimerQuery.h>
28 #include <GA/GA_Attribute.h>
29 #include <GR/GR_Defines.h>
30 #include <GR/GR_RenderInfo.h>
31 #include <GT/GT_Primitive.h>
32 #include <GU/GU_DetailHandle.h>
33 #include <GU/GU_SelectType.h>
34 #include "GUI_GroupData.h"
35 #include "GUI_RenderCommon.h"
36 #include "GUI_DisplayOption.h"
37 #include "GUI_DetailLook.h"
38 #include "GUI_PrimitiveHook.h"
39 #include "GUI_RenderCommon.h"
40 #include "GUI_API.h"
41 
42 class GA_EdgeGroup;
43 class GA_ElementGroup;
44 class GU_Detail;
45 class GEO_PrimClassifier;
47 class RE_Render;
48 class RE_Geometry;
49 class RE_LightList;
50 class RE_ReflectMap;
51 class RE_Shader;
52 class RE_VertexArray;
53 class RE_ElementArray;
54 class GUI_DetailLook;
55 class GA_ROAttributeRef;
56 class GA_PointGroup;
57 class GA_EdgeGroup;
58 class GA_PrimitiveGroup;
60 class GEO_Primitive;
61 class GR_DisplayOption;
63 class gui_AttribInfo;
64 class gui_CollectionPrim;
65 class GR_Primitive;
67 class GT_RefineParms;
68 class OBJ_Node;
69 class gui_HookedPrims;
70 class gr_PrimEntry;
71 class GR_VisualizerInfo;
72 class gui_RenderHookEntry;
73 class GUI_ObjectMaterialCache;
74 
75 using GUI_PrimTypeKey = std::pair<GA_PrimitiveTypeId, GT_PrimitiveType>;
76 
78 {
79 public:
81  const char *name,
82  int geo_index,
83  int name_index);
84  virtual ~GUI_GeoRender();
85 
86  virtual const char *className() const { return "GUI_GeoRender"; }
87 
88  virtual bool isLopRender() const { return false; }
89 
90  void setGeometry(OP_Node *node);
91  OP_Node *getGeometry() const;
92 
93  // set the base geometry name for the cache name.
94  void setGeoName(const char *name);
95  // set the cache name to exactly 'name'. Only used for instancing.
96  void setInstanceName(const char *name);
97 
98  const char *getCacheName() const { return myCacheName; }
99 
100  // the index of the detail within the GUI_DetailLook.
101  void setGeoIndex(int idx) { myGeoIndex = idx; }
102  int getGeoIndex() const { return myGeoIndex; }
103  void setNameIndex(int idx) { myNameIndex = idx; }
104  int getNameIndex() const { return myNameIndex; }
105 
106  // If this represents a node, this will return its node id.
107  int getNodeID() const { return myNodeID; }
108 
109  // The geometry this object will be rendering.
110  void setDetailHandle(const GU_ConstDetailHandle &handle);
111  virtual GU_ConstDetailHandle &getDetailHandle() { return myDetailHandle; }
112 
113  // control the display of the GUI_GeoRender object. Those not displayed
114  // cannot be rendered or picked.
115  void setDisplayed(bool is_disp) { myIsDisplayed = is_disp; }
116  bool isDisplayed() const { return myIsDisplayed; }
117 
118  // local transform of the object
119  bool setDetailTransform(const UT_DMatrix4 &xform);
120  const UT_DMatrix4 &getDetailTransform(int index) const;
121  const UT_DMatrix4 &getDetailInvTransform(int index) const;
123  { return myDetailTransforms.entries(); }
125  { myDetailFullTransform = xform; }
127  { return myDetailFullTransform; }
128 
129  // For an instance object, this is the instance object's transform. The
130  // detail transforms are the individual point transforms.
132  { myInstancerTransform = xform;
133  myInstancerIdentityFlag = xform.isIdentity(); }
135  { myInstancerTransform.identity();
136  myInstancerIdentityFlag = true; }
138  { return myInstancerTransform; }
139 
140  // set the local bounding box of this object
141  void setLocalBBox(const UT_BoundingBox &bbox,
142  int )
143  { myLocalBBox = bbox; }
144  const UT_BoundingBox& localBBox();
145 
146  // bounding box of this object
147  virtual int getBoundingBox2D(UT_BoundingBox &bbox,
148  const char *name,
149  int use_vertex) const;
150  virtual int getBoundingBox3D(UT_BoundingBox &bbox,
151  const UT_Matrix3R *rot) const;
152 
153  // set the view * projection matrix
154  static void setWorldToScreen(const UT_Matrix4R &xform);
155 
156  // instanced transforms for the object, when point instancing
157  void setIsInstancedGeo(bool instanced);
158  bool addInstanceTransform(const UT_DMatrix4 &xform,
159  int geo_index);
160  void clearInstanceTransforms();
161  void setInstanceVersion(int64 version);
162  int64 getInstanceVersion() const;
163 
164  // setup() called before any update or drawing is done, and cleanup() is
165  // called when all rendering is complete for the current redraw.
166  virtual GUI_SetupResult setup(const GUI_DisplayOption &disp_opt,
167  GUI_DisplaySetType state,
168  bool show_selection,
169  GR_DecorationOverride selmask_dec,
170  GR_DecorationOverride &select_dec,
171  bool &needs_alpha,
172  bool is_current);
173 
174  // minimal setup for multiple viewports (such as a quad config). One
175  // viewport is called with setup(), the others fastSetup().
176  virtual bool fastSetup(const GUI_DisplayOption &disp_opt);
177 
178  virtual void update(RE_Render *r,
179  GR_DisplayOption *opt,
180  GUI_SetupResult setup_reason,
181  GR_DecorationOverride selmask_dec,
182  const char *view_name,
183  bool &needs_alpha,
184  const GR_FrustumList &view_frustums);
185  virtual void cleanup(RE_Render *r);
186 
187  bool isSetup() const { return mySetupFlag; }
188  bool needsAlphaPass() const { return myNeedsAlphaPassFlag; }
189 
190  // called when this look is no longer displayed and placed in a short cache
191  // in case it is displayed again.
192  void retire();
193 
194  // Called when an object isn't displayed anymore, aka retire()-lite.
195  void hide();
196 
197  // Return true if gl_lit is set on the contained detail.
198  bool isLit() const { return myLitFlag; }
199 
200  // return true if this geo has guide rendering
201  bool hasGuideParts() const { return myHasGuideParts; }
202 
203  // Return if gl_wireframe is set to a positive value.
204  bool forceWireframe() const { return myWireframeFlag; }
205 
206  // Return if gl_wireframe is set to a negative value.
207  bool forceShaded() const { return myForceShadedFlag; }
208 
209  // The post-pass ID is used to setup and render post-render passes
210  void setPostPassID(int id) { myPostPassID = id ; }
211  int getPostPassID() const { return myPostPassID; }
212 
213  // An additional deferred pass is required (not a post pass).
214  bool needsDeferredPass() const { return myNeedsDeferredPass;}
215 
216  void setDeferredPass(bool dpass) { myIsDeferPass = dpass; }
217 
218  // Returns the time in seconds of various operations
219  fpreal getSetupTime() const { return fpreal(mySetupTime)*1e-9;}
220  fpreal getDrawTime() const { return fpreal(myDrawTime)*1e-9;}
221 
222  virtual bool isObjectRender() const { return false; }
223 
225  { return myMaterialHasReflection; }
226 
227  void setGhosted(bool ghost)
228  { myInfo.myObjectGhosted = ghost; }
229  void setObjectSelection(int obj_selection)
230  { myInfo.myObjectSelection = obj_selection; }
231 
232  bool getComponentSelection(
233  const GR_DisplayOption *opt,
234  GR_SelectionAdapter &adapter) const;
235 
236  // DRAWING --------------------------------------------------------------
237 
238  // wire representation of all objects.
239  virtual void wireframeRender(RE_Render *r,
240  GUI_DisplayOption &disp_opt,
242  GR_RenderFlags render_flags);
243 
244  // Beauty pass shaded render.
245  virtual GUI_RenderPassFlags
246  beautyRender(RE_Render *r,
247  GUI_DisplayOption &disp_opt,
248  GR_ShadingPass shade_pass,
249  GR_AlphaPass alphapass,
251  GR_RenderFlags render_flags);
252 
253  static void setupRender(RE_Render *r, GR_RenderMode mode);
254  static void cleanupRender(RE_Render *r, GR_RenderMode mode);
255 
256  // Various simple rendering, such as matte or depth.
257  virtual void utilityRender(RE_Render *r,
258  GUI_DisplayOption &disp_opt,
260  GR_RenderFlags rflags);
261 
262  // rendering for post-render passes that primitives request.
263  virtual void postPassRender(RE_Render *r,
264  GUI_DisplayOption &disp_opt,
265  GR_AlphaPass apass);
266 
267  // Object bounding box render
268  virtual void bboxRender(RE_Render *r,
269  GUI_DisplayOption &disp_opt,
270  GR_RenderMode render_mode);
271 
272  // Render any highlights required
273  void renderMatteHighlights(RE_Render *r,
274  GUI_DisplayOption &disp_opt,
275  GR_RenderFlags render_flags);
276  // Render onion skins
277  void onionSkinRender(RE_Render *r,
278  GUI_DisplayOption &disp_opt);
279 
280  virtual int64 getPrimDecorationMask() const
281  { return myPrimDecorMask; }
282 
283  // Modelling aids, like normals or uv coord display.
284  // This function is called before any specific decorations are rendered.
285  virtual void setupDecorationsRender(RE_Render *r);
286  // This functions renders one type of decoration.
287  virtual void decorationRender(RE_Render *r,
288  GUI_DisplayOption &disp_opt,
289  GR_Decoration dec,
290  GR_DecorVisibility vis,
291  bool override_dispopt,
292  GR_DecorRenderFlags render_flags);
293 
294  virtual void customDecorationRender(RE_Render *r,
295  GUI_DisplayOption &disp_opts,
296  const GR_VisualizerInfo *dec,
298 
299  // PICKING --------------------------------------------------------------
300 
301  // Return true if this object can be selected, and if 'node' isn't null,
302  // assign to it the node that should be selected when this object is picked
303  bool canBeSelected(OP_Node *op,
304  GUI_DisplayOption &disp_opt,
305  bool pick_template,
306  bool pick_non_sel,
307  bool pick_ghost,
308  OBJ_Node **node = nullptr) const;
309 
310  // A version of canBeSelected() used when every displayed detail is treated
311  // as an "object".
312  bool canBeSelectedWhenNotUsingOps(
313  GUI_DisplayOption &disp_opt,
314  bool pick_template,
315  bool pick_non_sel,
316  bool pick_ghost) const;
317 
318  // Full object pick - all or nothing.
319  virtual void objectPick(RE_Render *r,
320  GUI_DisplayOption &opts,
321  GR_RenderFlags render_flags,
322  const GR_ObjectPickFlags &pick_flags,
323  bool force_wire);
324 
325  // Component pick, component type based on display option.
326  virtual int componentPick(RE_Render *r,
327  GUI_DisplayOption &opts,
328  unsigned int primmask,
330  GR_PickStyle pickstyle,
331  bool has_pick_map,
332  UT_Array<GR_PickRecord> *pick_records);
333 
334  GUI_DetailLook &look() const { return *myLook; }
335  const char *name() const { return myCacheName; }
336 
337  // LIGHTING ------------------------------------------------------------
338 
339  void setupLighting(RE_LightList *list, bool headlight);
340  void cleanupLighting();
341 
342  static void resetStats();
343  static void getStats(int &num_objs,
344  int &num_polys,
345  int &num_vertices);
346 
347  static const RE_MaterialPtr &getDefaultMaterial(bool lit);
348 
349  static void setDefaultMaterialParms(UT_Color diff,
350  UT_Color spec,
351  UT_Color amb,
352  UT_Color emit);
353 
354  void bumpObjectMaterial() { myObjectMaterialDirty=true; }
355 
356  void useObjectMaterials(bool use_obj_mat);
357  bool getAssignedMaterials(UT_Array<OP_Node *> &nodes) const;
358 
359  int getObjectMaterialID() const { return myObjMaterialID; }
360 
361  void adoptAtlas(const RE_MaterialAtlas &from_atlas);
362 
363  bool isBboxShadingMode(const GR_DisplayOption *opt) const
364  {
365  return opt->shadingMode()==GR_BOUNDING_BOX_WIRE
367  }
368 
370  {
371  return isBboxShadingMode(getDisplayOptionSet(opt));
372  }
373 
374  // Reflection map support, for this object
375  bool prepReflectionMap(RE_Render *r,
376  GUI_DisplayOption &opt,
377  int64 version,
378  fpreal time);
379  void startReflectionPass(RE_Render *r, RE_TextureCubeFace f);
380  void endReflectionPass(RE_Render *r);
381  void finishReflectionMap(RE_Render *r,
382  GUI_DisplayOption &opt);
383  RE_Texture *getReflectionMap() const;
384 
385  // VISUALIZERS -----------------------------------------------------------
386 
388  { return myVisUpdateTime; }
389 
391  { return myVisRefineTime; }
392 
394  { myVisUpdateTime =
396 
398  { myVisRefineTime = myVisUpdateTime =
400 
401  bool hasUpdateVisualizer(int vis_id) const
402  { return myUpdateVisualizers.find(vis_id) >= 0; }
403 
404  bool hasRefineVisualizer(int vis_id) const
405  { return myRefineVisualizers.find(vis_id) >= 0; }
406 
408  { return look().getActiveVisualizers(); }
409 
411  { return myUpdateVisualizers; }
412 
414  { return myRefineVisualizers; }
415 
417  { myUpdateVisualizers = getActiveVisualizers(); }
418 
420  { myUpdateVisualizers.clear(); }
421 
423  { myRefineVisualizers = getActiveVisualizers(); }
424 
426  { myRefineVisualizers.clear(); }
427 
428  void runCreatorVisualizers(int &listcount,
430 
431  GUI_VisFlags getActiveVisFlags(int prim_idx,
432  GUI_VisContext context) const;
433 
434  // Look for an attribute in the given owner class (or all of them for
435  // GT_OWNER_INVALID) in all cached GT_Primitives in the detail
436  // (those used for updating GR_Primitives in the last update, which,
437  // in particular, have been filtered by visualizes) and return
438  // the first matching attribute if any.
439 
440  const
441  GT_DataArrayHandle findCachedAttribute(const char *attrib_name,
442  GT_Owner owner = GT_OWNER_INVALID) const;
443 
444  // Cached data used for display. Tied to the underlying GU_Detail.
445  virtual const GEO_DetachedHedgeInterface *getHedgeInterface(
446  bool use_hidden_grp);
447  virtual const GEO_PrimClassifier *getPrimClassifier(GU_Connectivity con);
448  virtual const GA_EdgeGroup *getHiddenEdgeGroup();
449  virtual const GA_ElementGroup *getVisibleElementGroup(GA_GroupType t);
450 
451  static int getPolygonMeshLimit();
452  static int getPointMeshLimit();
453 
454  static void handleMaterialChange(OP_Node *src, void *dest,
455  OP_EventType type, void *data);
456 
457  bool isMSSEnabled() const { return myMSSEnable; }
458  bool isMSSPackedEnabled() const { return myMSSPackedGeo; }
459  bool isMSSPerPrimEnabled() const { return myMSSPerPrim; }
460  bool areOverridesEnabled() const
461  { return myMaterialUseOverrides; }
462  int getMaterialLimit() const { return myMaterialLimit; }
464  { myMaterialLimitExceeded = e; }
465 
466  // clear all primitives and associated caching information
467  void invalidateGeo();
468 
469 protected:
470  virtual void updateGLSpecific(RE_Render *r,
471  GR_DisplayOption *opts,
472  GUI_SetupResult setup_reason,
473  GR_DecorationOverride selmask_dec,
474  const char *view_name,
475  const GU_Detail *dtl)
476  {}
477 
478  virtual void cleanupMaterials() {}
479  virtual bool shouldRender(const GU_Detail *geo) const;
480 
481  int getNumPrimitives() const
482  { return myPrimitives.entries(); }
483  GR_Primitive *getPrimitive(int index) const;
484 
486  { return &disp_opt[ look().getDisplaySetType() ]; }
487 
489  const GUI_DisplayOption &disp_opt) const
490  { return &disp_opt[ look().getDisplaySetType() ]; }
491 
492  // Required Render functions -------------------------------------------
493 
494  // Wireframe only.
495  virtual void wireRender(RE_Render *r,
496  GUI_DisplayOption &disp_opt,
497  const GU_Detail *geo,
500 
501  // Solid polygon render
502  virtual void solidRender(RE_Render *r,
503  GUI_DisplayOption &disp_opt,
504  const GU_Detail *geo,
507  GR_AlphaPass pass) {};
508 
509  virtual void simpleRender(RE_Render *r,
510  GUI_DisplayOption &opt,
511  const GU_Detail *geo,
513  GR_RenderFlags flags) {};
514 
515  virtual void simpleBboxRender(RE_Render *r,
516  GUI_DisplayOption &opt,
517  RE_Shader *shader=0,
518  bool fill=true,
519  bool outline=true) {};
520 
521  // Utility functions ---------------------------------------------------
522 
523  // Returns the decorations required for the selection types on this detail
524  GR_DecorationOverride getSelectionDecorations(
525  const GR_DisplayOption *opt) const;
526 
527  // Returns true if the geometry has a selection which requires a closure
528  // color.
529  bool isClosureSelection(GU_SelectionHandle sel,
530  bool &has_edges) const;
531  bool isClosureSelection(GR_SelectionAdapter &sel,
532  bool &has_edges) const;
533 
534  // returns true if the buffer was filled because the attribute existed in
535  // the detail, or false if a constant attribute was created (which must be
536  // filled in)
538  {
543  FETCH_ERROR
544  };
545 
546  void prepMaterials(RE_Render *r,
547  const GR_DisplayOption *opts);
548 
549  // Setup wire selection uniforms on 'r', and modify 'flags' to include
550  // GR_RENDER_FLAG_WIRE_OVER if needed.
551  void setupWireSelectParms(RE_Render *r,
552  GUI_DisplayOption &disp_opts,
553  bool is_wireframe,
555  void cleanupWireSelectParms(RE_Render *r);
556 
557  // Sets the object matrix uniform based on our instancer transform,
558  // detail transform, etc.
559  void setObjectMatrixUniform(RE_Render *r);
560 
561  void updatePrimitives(RE_Render *r,
562  GR_DisplayOption *opts,
564  GT_RefineParms &refine_opts,
565  GR_UpdateReason reason,
566  GR_DecorationOverride req_dec,
567  const char *view_name,
568  const GR_FrustumList &view_frustums);
569  void processPrimitives(const GU_ConstDetailHandle &geo,
570  GT_PrimitiveHandle &ph,
571  GT_RefineParms &refparms,
572  int &listcount,
573  const GR_DisplayOption &dispopt,
574  GR_UpdateReason reason,
575  const char *cache_name,
577  bool processPrim(const GU_ConstDetailHandle &geo,
578  GT_PrimitiveHandle &ph,
579  GT_RefineParms &refparms,
580  int &listcount,
581  const GR_DisplayOption &dispopt,
582  GR_UpdateReason reason,
583  const char *cache_name,
585  bool apply_filter_vis,
586  int &packed_index);
587 
588  void processAlembicArchive(GT_PrimitiveHandle &ph,
589  const GU_ConstDetailHandle &gdh,
590  GT_RefineParms &refparms,
591  int &listcount,
592  const GR_DisplayOption &dispopt,
593  GR_UpdateReason reason,
594  const char *cache_name,
596  exint mat_id);
597  void clearUnusedAlembicArchives();
598 
599  void renderMatteGroupColors(RE_Render *r,
600  GUI_GroupDataHandle group_data,
601  GR_DisplayOption *opt,
602  GR_RenderFlags render_flags);
603 
604  // Lower level render function used by beautyRender, wireRender, etc.
605  void renderPrims(RE_Render *r,
606  GR_DisplayOption *opt,
609  GR_AlphaPass alphapass,
610  bool use_materials);
611 
612  bool createOrReuseRefinedPrim(GT_PrimitiveHandle &ph,
613  const GU_ConstDetailHandle &gdh,
614  const GEO_Primitive *geo_prim,
615  int &listcount,
616  const GR_DisplayOption &disp,
617  GR_UpdateReason reason,
618  const GT_RefineParms &ref_parms,
619  const char *cache_name,
621  bool processing_geo_prims,
622  bool apply_filter_vis,
623  int packed_index,
624  int64 mat_id);
625  GR_PrimAcceptResult checkForExistingPrim(GT_PrimitiveHandle &ph,
626  GR_Primitive *prim,
627  int pindex,
628  GR_UpdateReason reason,
629  const GT_RefineParms &ref_parms,
630  const GU_ConstDetailHandle &gdh,
631  const GEO_Primitive *geo_prim,
632  int &listcount,
634  bool processing_geo_prims,
635  int packed_index);
636  void accumulateTime(RE_Render *r);
637 
638  void buildEdgeHighlight(RE_Render *r,
639  const GU_Detail *geo,
640  GR_UpdateReason reason,
641  const GR_DisplayOption *opt,
642  const char *view_name);
643 
644  bool buildInstanceSelection(bool has_sel_overrides);
645  fpreal getPointInstanceFraction(GR_DisplayOption *opts) const;
646  UT_Matrix4DArray *getPointInstanceTransforms(GR_DisplayOption *opts);
647 
648  RE_CacheVersion getGeoVersion(const GU_Detail *geo,
649  const GR_DisplayOption *opt);
650  RE_CacheVersion getSelectionVersion(const GU_Detail *geo,
651  const GR_DisplayOption *opt);
652  RE_CacheVersion getEdgeHighlightVersion(const GU_Detail *geo,
653  const GR_DisplayOption *opt,
654  bool include_selection);
655 
657  { mySelectionId = id; mySelectionRevision = version; }
658 
659  GR_PrimAcceptResult processHookPrimitive(GT_PrimitiveHandle &gt_prim,
660  const GEO_Primitive *geo_prim,
661  const GU_ConstDetailHandle &gdh,
662  GR_UpdateReason reason,
663  const GT_RefineParms &ref_parms,
664  const char *cache_name,
665  GR_Primitive *&created,
666  int &list_index,
667  int &hook_priority,
668  bool &filtered_prim,
669  gui_RenderHookEntry *&prev,
671  bool processing_geo_prims,
672  int packed_index);
673 
674  void processFilterHooks(GT_PrimitiveHandle &gt_prim,
675  const GEO_Primitive *geo_prim);
676 
677  void restartCollectionPrimitives();
678  void removeUnusedCollectionPrimitives();
679 
680  void find3DBoundaries(const GU_Detail *geo,
681  const GA_PrimitiveGroup *within_prims,
682  GA_EdgeGroup *boundary_group);
683  void findUVBoundaries(const GU_Detail *geo,
684  const GA_PrimitiveGroup *within_prims,
685  GA_EdgeGroup * uv_boundary_group,
686  const GA_ROHandleV2 &uv,
687  bool vert_uvs);
688 
690  {
691  public:
692  gui_BoundaryData() : myUsed(false), myAttribVersion(-1) {}
693 
700  bool myUsed;
701  };
702 
703  bool matchesVersion(gui_BoundaryData &bdata,
704  const UT_StringHolder &attrib_name,
705  const RE_CacheVersion &ver,
706  bool view_3d, bool vert_uv);
707  void createEdgeGeo(RE_Render *r,
708  gui_BoundaryData &bdata,
709  const GA_EdgeGroup *edges,
710  bool is_3d,
711  bool is_vertex,
712  const UT_StringHolder &attrib_name,
713  const UT_StringHolder &cache_suffix,
714  const GU_Detail *geo,
715  const RE_CacheVersion &ev,
716  GA_ROHandleV2 *uvhandle = nullptr);
717 
719  { return myInfo; }
720 
721  void getRefineParms(RE_Render *r,
722  const GR_DisplayOption *opts,
723  GT_RefineParms &p) const;
724 
725  void resizePrimArray(exint nprims, bool clear = false);
726  void assignPrim(exint index,
727  GR_Primitive *prim,
728  const GT_PrimitiveHandle &gtprim);
729  void updateWorldTransform();
730 
732  static RE_MaterialPtr theDefaultMaterial[2];
733 
734  static int theNumObjects;
735  static int theNumPolys;
736  static int theNumVertices;
737 
740  GUI_ObjectMaterialCache *myObjectMaterialCache;
742 
745 
752 
756  int myViewID;
757 
761 
762 private:
763  bool shouldUVRender(const GU_Detail *geo,
764  const GUI_DisplayOption &disp,
765  bool is_vertex) const;
766  bool shouldRender(const GU_Detail *geo,
767  const GUI_DisplayOption &disp,
768  GR_RenderFlags render_flags) const;
769  bool shouldRender(const GU_Detail *geo,
770  const GUI_DisplayOption &disp,
771  GR_DecorRenderFlags decor_flags) const;
772  bool shouldRender(const GU_Detail *geo,
773  const GUI_DisplayOption &disp,
774  GR_PickStyle pick_style) const;
775 
776  bool requiresStateChange(const GUI_DisplayOption &disp_opt,
777  GUI_DisplaySetType newset,
778  GUI_DisplaySetType oldset) const;
779 
780  GR_UpdateReason checkForShaderUpdates(const GU_Detail *geo);
781  bool prepObjectMaterial(RE_Render *r,
782  const GR_DisplayOption &opts);
783  bool checkAutoVertexNormal(const GU_Detail *dtl,
784  const GR_CommonDispOption &opts);
785 
786  bool inPackedPrim() const
787  { return myPackedPrimLevel > 0; }
788  bool inInstancePrim() const
789  { return myInstancePrim.entries() > 0; }
790  void updateInstanceEntry(gr_PrimEntry *entry,
791  int prim_index);
792 
793  bool processInstancedPrims(const GT_PrimitiveHandle &ph,
794  int &listcount,
796  int64 geo_id, int64 geo_count,
797  int packed_index,
798  int64 mat_id);
799 
800  // instancing
801  void buildPointInstanceArray(RE_Render *r,
802  GR_DisplayOption *dopts,
803  const GU_Detail *dtl,
804  bool use_fraction_parm);
805  void pointInstanceGuideRender(RE_Render *r,
806  GUI_DisplayOption &disp_opt);
807  void renderEdgeHighlight(RE_Render *r,
808  const GR_DisplayOption *op,
809  GR_RenderFlags render_flags);
810  void renderBBox(RE_Render *r,
811  GUI_DisplayOption &opt,
812  RE_Shader *shader=0,
813  bool fill=true,
814  bool outline=true);
815  OP_Node * getObjectMaterial(fpreal t) const;
816  void clearMaterialInterests();
817 
818  UT_Array<gr_PrimEntry *> myPrimitives;
819  UT_IntArray myPrimitiveIndex;
820 
821  GUI_GroupDataHandle myGroupData;
822 
823  UT_Array<gui_HookedPrims *> myHookedGEOPrims;
824 
825  bool myObjectMaterialDirty;
826  OBJ_Node *myTopObject;
827  int myNodeID;
828  bool myUseObjectMaterial;
829 
830  GR_RenderInfo myInfo;
831  GUI_DetailLook *myLook;
832  int myGeoIndex;
833  int myNameIndex;
834  UT_String myCacheName;
835  bool mySetupFlag;
836  bool myHasGLStateCheckPrims;
837  bool myLitFlag;
838  bool myHasGuideParts;
839  bool myHasPackedPrims;
840  bool myHasPackedFragments;
841  bool myHasPackedInstances;
842  bool myWireframeFlag;
843  bool myForceShadedFlag;
844  bool myRecordingTime;
845  bool myIsDisplayed;
846 
847  bool myHasAgentPrims;
848  bool myAgentLastLODEnable;
849  int myAgentLastMinPoints;
850  int myAgentLastMaxLOD;
851 
852 
855  int myDrawTimeWaiting;
856  int64 myDrawTime;
857  int64 mySetupTime;
858 
859  int myDetailID;
860  int64 myVersion;
861  int64 myTopologyVersion;
862  int myCachedShowSelect;
863  int64 myPrimitiveVersion;
864  int64 myPosVersion;
865  exint mySelectionId;
866  exint mySelectionRevision;
867  int myPostPassID;
868  bool myNeedsDeferredPass;
869 
870  UT_String myDopnetPath;
871 
872  // For determining if a display option which affects geometry has changed.
873  int64 myDispOptID;
874  int myDispOptSerial;
875  fpreal myLOD;
876  bool myPolygonConvexQuality;
877  bool myVertexNormalEnable;
878  fpreal myVertexNormalCuspAngle;
879  GR_DecorationOverride myRequiredDecorations;
880  bool myShowAllPoints;
881  fpreal myDetailLOD;
882 
883  GUI_RenderMask myRenderMask;
884  GUI_DisplaySetType myObjectState;
885  GEO_ViewportLOD myObjectLOD;
886  bool myObjectDisplayAsSubdiv;
887 
888  GU_ConstDetailHandle myDetailHandle;
889  UT_Matrix4DArray myDetailTransforms;
890  UT_Matrix4DArray myDetailInvTransforms;
891  UT_Matrix4DArray myReducedDetailTransforms;
892  bool myDetailTransformIdentity;
893  UT_Matrix4D myInstancerTransform;
894  UT_Matrix4D myDetailFullTransform;
895  bool myInstancerIdentityFlag;
896  UT_IntArray myDetailGeoIndex;
897  UT_BoundingBox myLocalBBox;
898  int64 myCachedInstanceVersion;
899  int myRefineVersion;
900  bool myCheckUpdateViewFlag;
901  bool myObjectTransformDirty;
902  bool myNeedsAlphaPassFlag;
903  bool myPrimAlphaPassFlag;
904  bool myIsDeferPass;
905  bool myRefineOnLODChange;
906  int mySelectionInstance;
907  fpreal myLimitedInstanceFraction;
908  bool myShowMaterials;
909 
910  RE_CacheVersion myInstanceSelectVersion;
911  UT_BitArray myInstanceSelection;
912  bool myHasInstanceSelection;
913 
914  // for GT_PrimInstance types, this holds the array of instance transforms
915  // while its geometry is being refined.
916  class gui_Instance
917  {
918  public:
919  gui_Instance() { myBBox.makeInvalid(); }
920 
921  UT_Matrix4DArray myTransforms;
922  GU_ConstDetailHandle myDetail;
923  GT_PrimitiveHandle myPrim;
924  UT_BoundingBox myBBox;
925  };
926  UT_Array<gui_Instance> myInstancePrim;
927  GT_AttributeListHandle myInstancePrimAttribs;
928  GT_AttributeListHandle myInstancePointAttribs;
929 
930  class gui_DiskFile
931  {
932  public:
933  gui_DiskFile() : myPrimIndex(0) {}
934  UT_StringHolder myDiskFile;
935  int myPrimIndex;
936  };
937  UT_Array<gui_DiskFile> myPackedDiskStack;
938 
939  int myPackedPrimLevel;
940  GT_PrimitiveHandle myPackedPrim;
941  mutable bool myCachedUseSampleMask;
942  mutable int myCachedSampleMask;
943  mutable bool myCachedMultisample;
944  mutable bool myCachedSampleCoverage;
945 
946  RE_Geometry *myPointGeo;
947  RE_Geometry *myCubeGeo;
948  RE_VertexArray *myCubeInstance;
949  fpreal myCubeInstanceFraction;
950 
951  RE_ReflectMap *myReflectMap;
952 
953  // last update and refinement time in visualization clock (counter)
954  exint myVisUpdateTime;
955  exint myVisRefineTime;
956 
957  UT_IntArray myUpdateVisualizers;
958  UT_IntArray myRefineVisualizers;
959 
960  // if set to true in setup, updates are upgraded to full refinements.
961  bool myRefineOnUpdate;
962  unsigned myMaterialTextureFlag :1,
963  myMaterialHasDisplaceMap :1,
964  myMaterialHasReflection :1,
965  myMaterialUseOverrides :1,
966  myMSSEnable :1,
967  myMSSPackedGeo :1,
968  myMSSPerPrim :1;
969  GUI_DisplayOption::gui_MatAssignMode myMatAssignMode;
970  int myMaterialLimit;
971  bool myMaterialLimitExceeded;
972  int myObjMaterialID;
973 
974  GT_DataArrayHandle myBaseMaterialAssignments;
975  GT_DataArrayHandle myBaseMaterialRemap;
976  int64 myBaseMaterialPrevID;
977  int64 myBaseMaterialRemapPrevID;
978  bool myDefaultMaterialLazyMode;
979  bool myForceMaterialUpdate;
980  bool myMaterialAllowUpdates;
981 
982  class gui_DetailAttribLists
983  {
984  public:
985  bool checkForAttribListChanges(const GU_Detail &dtl);
986 
987  UT_StringMap<bool> myPoint;
988  UT_StringMap<bool> myVertex;
989  UT_StringMap<bool> myPrim;
990  UT_StringMap<bool> myDetail;
991 
992  UT_StringMap<bool> myVisAttribs;
993  };
994 
995  gui_DetailAttribLists myDetailAttribLists;
996  struct
997  {
1002  } myHedgeInterface[2];
1003 
1004  UT_UniquePtr<GEO_PrimClassifier> myPrimClassifier;
1005  int myPrimClassifierDetailId;
1006  int64 myPrimClassifierCacheVersion;
1007  int64 myPrimClassifierTopVersion;
1008  int64 myPrimClassifierSelectId;
1009  int64 myPrimClassifierSelectRevision;
1010  GU_Connectivity myPrimClassifierConnectivity;
1011 
1012  UT_UniquePtr<GA_Group> myCachedGroup;
1013  GA_GroupType myCachedGroupType;
1014  int myCachedGroupDetailId;
1015  int64 myCachedGroupCacheVersion;
1016  int64 myCachedGroupTopVersion;
1017 
1018  static RE_ShaderHandle theBboxShader;
1019  static RE_ShaderHandle theObjectPickShader;
1020  static RE_ShaderHandle theEdgeHighlightShader;
1021  static RE_ShaderHandle theEdgeHighlightUVShader;
1022 
1023  UT_StringMap<GT_PrimitiveHandle> myAlembicArchives;
1024  UT_StringMap<int> myUsedAlembicArchives;
1025 
1026  UT_StringHolder myUVDisplay;
1027 public:
1028  // treat as private. For DM_RenderTable only.
1029  static bool registerHook(GUI_PrimitiveHook *hook,
1030  GT_PrimitiveType gt_type,
1031  int geo_type,
1032  int priority,
1034 
1035  friend class gr_PrimEntry;
1036 };
1037 
1038 inline void
1040 {
1042 }
1043 
1044 inline int64
1046 {
1047  return myInstanceVersion;
1048 }
1049 
1050 inline const UT_DMatrix4 &
1052 {
1053  return myDetailTransforms(index);
1054 }
1055 
1056 inline const UT_DMatrix4 &
1058 {
1059  return myDetailInvTransforms(index);
1060 }
1061 
1062 #endif
virtual void simpleBboxRender(RE_Render *r, GUI_DisplayOption &opt, RE_Shader *shader=0, bool fill=true, bool outline=true)
void setPostPassID(int id)
void setDetailFullTransform(const UT_DMatrix4 &xform)
int getNumPrimitives() const
bool forceShaded() const
gui_BoundaryData my3DBoundary
void clearUpdateVisualizers()
RE_LightList * myLightList
RE_TextureCubeFace
GR_DecorRenderFlags
Definition: GR_Defines.h:207
UT_StringMap< gui_BoundaryData > myUVBoundary
bool isDisplayed() const
GR_DecorationOverride
Definition: GR_Defines.h:196
void refreshVisRefineTime()
int64 myPrimDecorMask
gui_BoundaryData myEdgeSelection
GA_API const UT_StringHolder uv
GT_API const UT_StringHolder time
static int theNumObjects
virtual void solidRender(RE_Render *r, GUI_DisplayOption &disp_opt, const GU_Detail *geo, GR_RenderMode mode, GR_RenderFlags flags, GR_AlphaPass pass)
void shadingMode(GR_ShadingMode shading_mode)
void setNameIndex(int idx)
GA_API const UT_StringHolder rot
int getObjectMaterialID() const
int64 myInstanceVersion
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:53
GUI_VisFlags
fpreal getSetupTime() const
GT_API const UT_StringHolder cache_name
int getNodeID() const
void setGhosted(bool ghost)
GLbitfield flags
Definition: glcorearb.h:1595
const UT_DMatrix4 & getDetailTransform(int index) const
bool forceWireframe() const
bool hasUpdateVisualizer(int vis_id) const
static UT_Lock theShaderLock
GR_Decoration
Definition: GR_Defines.h:139
GR_AlphaPass
Definition: GR_Defines.h:109
int getNameIndex() const
GUI_DisplaySetType
Context specific display options for geometry states.
virtual void simpleRender(RE_Render *r, GUI_DisplayOption &opt, const GU_Detail *geo, GR_RenderMode mode, GR_RenderFlags flags)
int getNumDetailTransforms() const
const GU_Detail * myLockedDetail
const UT_IntArray & getUpdateVisualizers() const
const UT_IntArray & getRefineVisualizers() const
GLuint id
Definition: glcorearb.h:654
bool needsDeferredPass() const
int64 myEdgePrimsVersion
void refreshUpdateVisualizers()
void setSelection(int64 id, int64 version)
long long int64
Definition: SYS_Types.h:107
void setLocalBBox(const UT_BoundingBox &bbox, int)
virtual exint bumpClock()=0
UT_SharedPtr< GA_EdgeGroup > myEdges
void setDisplayed(bool is_disp)
GLfloat f
Definition: glcorearb.h:1925
UT_SharedPtr< RE_Geometry > my2DGeo
bool isBboxShadingMode(const GR_DisplayOption *opt) const
GR_DecorVisibility
Definition: GR_Defines.h:169
GR_ShadingPass
Definition: GR_Defines.h:117
GR_RenderMode
Definition: GR_Defines.h:44
std::pair< GA_PrimitiveTypeId, GT_PrimitiveType > GUI_PrimTypeKey
Definition: GUI_GeoRender.h:75
RE_MaterialAtlas myMaterialAtlas
void bumpObjectMaterial()
virtual int64 getPrimDecorationMask() const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
#define GUI_API
Definition: GUI_API.h:10
This class provides a way to manage a reference to an attribute permitting Read-Only access...
int64 exint
Definition: SYS_Types.h:116
UT_SharedPtr< RE_Geometry > my2DGeoV
GUI_ObjectMaterialCache * myObjectMaterialCache
UT_SharedPtr< RE_Geometry > myGeoV
GU_Connectivity
Definition: GU_SelectType.h:66
UT_SharedPtr< GA_PrimitiveGroup > myEdgePrims
GR_UpdateReason
Definition: GR_Defines.h:286
GUI_RenderPassFlags
int isIdentity() const
Definition: UT_Matrix4.h:1022
GUI_SetupResult
GLboolean * data
Definition: glcorearb.h:130
void clearRefineVisualizers()
GR_PrimAcceptResult
Definition: GR_Defines.h:328
void setInstancerTransform(const UT_DMatrix4 &xform)
GLuint const GLchar * name
Definition: glcorearb.h:785
static int theNumPolys
GR_RenderFlags
Definition: GR_Defines.h:79
const UT_DMatrix4 & getDetailInvTransform(int index) const
bool needsAlphaPass() const
void setInstancerTransformIdentity()
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GUI_DetailLook & look() const
void setDeferredPass(bool dpass)
const UT_DMatrix4 & getDetailFullTransform() const
GLenum mode
Definition: glcorearb.h:98
bool isMSSEnabled() const
GT_API const UT_StringHolder version
virtual const char * className() const
Definition: GUI_GeoRender.h:86
void setInstanceVersion(int64 version)
bool hasGuideParts() const
GT_Owner
Definition: GT_Types.h:75
GT_PrimitiveType
void refreshRefineVisualizers()
GUI_DisplaySetType getDisplaySetType() const
GLuint shader
Definition: glcorearb.h:784
bool isMSSPerPrimEnabled() const
bool isSetup() const
double fpreal
Definition: SYS_Types.h:270
int getMaterialLimit() const
int64 myUVAttribSerial
GR_DisplayOption * getDisplayOptionSet(GUI_DisplayOption &disp_opt)
void refreshVisUpdateTime()
bool isBboxShadingMode(GUI_DisplayOption &opt) const
int getPostPassID() const
GEO_ViewportLOD
int getGeoIndex() const
int64 myLimitInstanceVersion
bool myHasEdgeSelection
bool hasMaterialReflection() const
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:138
GLuint index
Definition: glcorearb.h:785
UT_SharedPtr< RE_Geometry > myGeo
GUI_RenderMask
void setMaterialLimitExceeded(bool e)
A specialization of GA_AIFStringTuple to access "shared strings".
void setObjectSelection(int obj_selection)
exint getVisUpdateTime() const
int64 getInstanceVersion() const
const char * name() const
OP_EventType
Definition: OP_Value.h:22
bool hasRefineVisualizer(int vis_id) const
virtual GU_ConstDetailHandle & getDetailHandle()
GR_RenderInfo & getRenderInfo()
exint getVisRefineTime() const
UT_Map< UT_StringRef, int > myAttributes
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
const UT_DMatrix4 & getInstancerTransform() const
bool isMSSPackedEnabled() const
fpreal getDrawTime() const
Simple class for a mutli-integer cache tag.
virtual bool isObjectRender() const
virtual void cleanupMaterials()
const UT_IntArray & getActiveVisualizers() const
GLboolean r
Definition: glcorearb.h:1221
virtual void updateGLSpecific(RE_Render *r, GR_DisplayOption *opts, GUI_SetupResult setup_reason, GR_DecorationOverride selmask_dec, const char *view_name, const GU_Detail *dtl)
UT_StringMap< bool > myUVAttribIsVertex
static int theNumVertices
const UT_IntArray & getActiveVisualizers() const
bool isLit() const
const char * getCacheName() const
Definition: GUI_GeoRender.h:98
GUI_PrimitiveHookFlags
virtual bool isLopRender() const
Definition: GUI_GeoRender.h:88
void setGeoIndex(int idx)
static GUI_VisInterface * getHandler()
Simple interface to building a shader from a .prog file.
bool areOverridesEnabled() const
GLenum src
Definition: glcorearb.h:1792
UT_UniquePtr< GEO_DetachedHedgeInterface > interface
GR_PickStyle
Definition: GR_Defines.h:228
const GR_DisplayOption * getDisplayOptionSet(const GUI_DisplayOption &disp_opt) const