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  int getInstancedBoundingBox3D(UT_BoundingBox &bbox,
154  const UT_Matrix3R *rot,
155  const UT_DMatrix4 &detail_xform) const;
156 
157  // set the view * projection matrix
158  static void setWorldToScreen(const UT_Matrix4R &xform);
159 
160  // instanced transforms for the object, when point instancing
161  void setIsInstancedGeo(bool instanced);
162  bool addInstanceTransform(const UT_DMatrix4 &xform,
163  int geo_index);
164  void clearInstanceTransforms();
165  void setInstanceVersion(int64 version);
166  int64 getInstanceVersion() const;
167 
168  // setup() called before any update or drawing is done, and cleanup() is
169  // called when all rendering is complete for the current redraw.
170  virtual GUI_SetupResult setup(const GUI_DisplayOption &disp_opt,
171  GUI_DisplaySetType state,
172  bool show_selection,
173  GR_DecorationOverride selmask_dec,
174  GR_DecorationOverride &select_dec,
175  bool &needs_alpha,
176  bool is_current);
177 
178  // minimal setup for multiple viewports (such as a quad config). One
179  // viewport is called with setup(), the others fastSetup().
180  virtual bool fastSetup(const GUI_DisplayOption &disp_opt);
181 
182  virtual void update(RE_Render *r,
183  GR_DisplayOption *opt,
184  GUI_SetupResult setup_reason,
185  GR_DecorationOverride selmask_dec,
186  const char *view_name,
187  bool &needs_alpha,
188  const GR_FrustumList &view_frustums);
189  virtual void cleanup(RE_Render *r);
190 
191  bool isSetup() const { return mySetupFlag; }
192  bool needsAlphaPass() const { return myNeedsAlphaPassFlag; }
193  void needsAlphaPass(bool need) { myNeedsAlphaPassFlag=need;}
194 
195  // called when this look is no longer displayed and placed in a short cache
196  // in case it is displayed again.
197  void retire();
198 
199  // Called when an object isn't displayed anymore, aka retire()-lite.
200  void hide();
201 
202  // Return true if gl_lit is set on the contained detail.
203  bool isLit() const { return myLitFlag; }
204 
205  // return true if this geo has guide rendering
206  bool hasGuideParts() const { return myHasGuideParts; }
207 
208  // Return if gl_wireframe is set to a positive value.
209  bool forceWireframe() const { return myWireframeFlag; }
210 
211  // Return if gl_wireframe is set to a negative value.
212  bool forceShaded() const { return myForceShadedFlag; }
213 
214  // The post-pass ID is used to setup and render post-render passes
215  void setPostPassID(int id) { myPostPassID = id ; }
216  int getPostPassID() const { return myPostPassID; }
217 
218  // An additional deferred pass is required (not a post pass).
219  bool needsDeferredPass() const { return myNeedsDeferredPass;}
220 
221  void setDeferredPass(bool dpass) { myIsDeferPass = dpass; }
222 
223  // Returns the time in seconds of various operations
224  fpreal getSetupTime() const { return fpreal(mySetupTime)*1e-9;}
225  fpreal getDrawTime() const { return fpreal(myDrawTime)*1e-9;}
226 
227  virtual bool isObjectRender() const { return false; }
228 
230  { return myMaterialHasReflection; }
231 
232  void setGhosted(bool ghost)
233  { myInfo.myObjectGhosted = ghost; }
234  void setObjectSelection(int obj_selection)
235  { myInfo.myObjectSelection = obj_selection; }
236 
237  bool getComponentSelection(
238  const GR_DisplayOption *opt,
239  GR_SelectionAdapter &adapter) const;
240 
241  // DRAWING --------------------------------------------------------------
242 
243  // wire representation of all objects.
244  virtual void wireframeRender(RE_Render *r,
245  GUI_DisplayOption &disp_opt,
247  GR_RenderFlags render_flags);
248 
249  // Beauty pass shaded render.
250  virtual GUI_RenderPassFlags
251  beautyRender(RE_Render *r,
252  GUI_DisplayOption &disp_opt,
253  GR_ShadingPass shade_pass,
254  GR_AlphaPass alphapass,
256  GR_RenderFlags render_flags);
257 
258  static void setupRender(RE_Render *r, GR_RenderMode mode);
259  static void cleanupRender(RE_Render *r, GR_RenderMode mode);
260 
261  void setupGhosting(RE_Render *r,
262  GUI_DisplayOption &disp_opt,
263  UT_Vector4F &ghost_color,
264  fpreal ghost_amount = 0.5);
265  void cleanupGhosting(RE_Render *r);
266 
267  // Various simple rendering, such as matte or depth.
268  virtual void utilityRender(RE_Render *r,
269  GUI_DisplayOption &disp_opt,
271  GR_RenderFlags rflags);
272 
273  // rendering for post-render passes that primitives request.
274  virtual void postPassRender(RE_Render *r,
275  GUI_DisplayOption &disp_opt,
276  GR_AlphaPass apass);
277 
278  // Object bounding box render
279  virtual void bboxRender(RE_Render *r,
280  GUI_DisplayOption &disp_opt,
281  GR_RenderMode render_mode);
282 
283  // Render any highlights required
284  void renderMatteHighlights(RE_Render *r,
285  GUI_DisplayOption &disp_opt,
286  GR_RenderFlags render_flags);
287  // Render onion skins
288  void onionSkinRender(RE_Render *r,
289  GUI_DisplayOption &disp_opt);
290 
291  virtual int64 getPrimDecorationMask() const
292  { return myPrimDecorMask; }
293 
294  // Modelling aids, like normals or uv coord display.
295  // This function is called before any specific decorations are rendered.
296  virtual void setupDecorationsRender(RE_Render *r);
297  // This functions renders one type of decoration.
298  virtual void decorationRender(RE_Render *r,
299  GUI_DisplayOption &disp_opt,
300  GR_Decoration dec,
301  GR_DecorVisibility vis,
302  bool override_dispopt,
303  GR_DecorRenderFlags render_flags);
304 
305  virtual void customDecorationRender(RE_Render *r,
306  GUI_DisplayOption &disp_opts,
307  const GR_VisualizerInfo *dec,
309 
310  // PICKING --------------------------------------------------------------
311 
312  // Return true if this object can be selected, and if 'node' isn't null,
313  // assign to it the node that should be selected when this object is picked
314  bool canBeSelected(OP_Node *op,
315  GUI_DisplayOption &disp_opt,
316  bool pick_template,
317  bool pick_non_sel,
318  bool pick_ghost,
319  OBJ_Node **node = nullptr) const;
320 
321  // A version of canBeSelected() used when every displayed detail is treated
322  // as an "object".
323  bool canBeSelectedWhenNotUsingOps(
324  GUI_DisplayOption &disp_opt,
325  bool pick_template,
326  bool pick_non_sel,
327  bool pick_ghost) const;
328 
329  // Full object pick - all or nothing.
330  virtual void objectPick(RE_Render *r,
331  GUI_DisplayOption &opts,
332  GR_RenderFlags render_flags,
333  const GR_ObjectPickFlags &pick_flags,
334  bool force_wire);
335 
336  // Component pick, component type based on display option.
337  virtual int componentPick(RE_Render *r,
338  GUI_DisplayOption &opts,
339  unsigned int primmask,
341  GR_PickStyle pickstyle,
342  bool has_pick_map,
343  UT_Array<GR_PickRecord> *pick_records);
344 
345  GUI_DetailLook &look() const { return *myLook; }
346  const char *name() const { return myCacheName; }
347 
348  // LIGHTING ------------------------------------------------------------
349 
350  void setupLighting(RE_LightList *list, bool headlight);
351  void cleanupLighting();
352 
353  static void resetStats();
354  static void getStats(int &num_objs,
355  int &num_polys,
356  int &num_vertices);
357 
358  static const RE_MaterialPtr &getDefaultMaterial(bool lit);
359 
360  static void setDefaultMaterialParms(UT_Color diff,
361  UT_Color spec,
362  UT_Color amb,
363  UT_Color emit);
364 
365  void bumpObjectMaterial() { myObjectMaterialDirty=true; }
366 
367  void useObjectMaterials(bool use_obj_mat);
368  bool getAssignedMaterials(UT_Array<OP_Node *> &nodes) const;
369 
370  int getObjectMaterialID() const { return myObjMaterialID; }
371 
372  void adoptAtlas(const RE_MaterialAtlas &from_atlas);
373 
374  bool isBboxShadingMode(const GR_DisplayOption *opt) const
375  {
376  return opt->shadingMode()==GR_BOUNDING_BOX_WIRE
378  }
379 
381  {
382  return isBboxShadingMode(getDisplayOptionSet(opt));
383  }
384 
385  // Reflection map support, for this object
386  bool prepReflectionMap(RE_Render *r,
387  GUI_DisplayOption &opt,
388  int64 version,
389  fpreal time);
390  void startReflectionPass(RE_Render *r, RE_TextureCubeFace f);
391  void endReflectionPass(RE_Render *r);
392  void finishReflectionMap(RE_Render *r,
393  GUI_DisplayOption &opt);
394  RE_Texture *getReflectionMap() const;
395 
396  // VISUALIZERS -----------------------------------------------------------
397 
399  { return myVisUpdateTime; }
400 
402  { return myVisRefineTime; }
403 
405  { myVisUpdateTime =
407 
409  { myVisRefineTime = myVisUpdateTime =
411 
412  bool hasUpdateVisualizer(int vis_id) const
413  { return myUpdateVisualizers.find(vis_id) >= 0; }
414 
415  bool hasRefineVisualizer(int vis_id) const
416  { return myRefineVisualizers.find(vis_id) >= 0; }
417 
419  { return look().getActiveVisualizers(); }
420 
422  { return myUpdateVisualizers; }
423 
425  { return myRefineVisualizers; }
426 
428  { myUpdateVisualizers = getActiveVisualizers(); }
429 
431  { myUpdateVisualizers.clear(); }
432 
434  { myRefineVisualizers = getActiveVisualizers(); }
435 
437  { myRefineVisualizers.clear(); }
438 
439  void runCreatorVisualizers(int &listcount,
441 
442  GUI_VisFlags getActiveVisFlags(int prim_idx,
443  GUI_VisContext context) const;
444 
445  // Look for an attribute in the given owner class (or all of them for
446  // GT_OWNER_INVALID) in all cached GT_Primitives in the detail
447  // (those used for updating GR_Primitives in the last update, which,
448  // in particular, have been filtered by visualizes) and return
449  // the first matching attribute if any.
450 
451  const
452  GT_DataArrayHandle findCachedAttribute(const char *attrib_name,
453  GT_Owner owner = GT_OWNER_INVALID) const;
454 
455  // Cached data used for display. Tied to the underlying GU_Detail.
456  virtual const GEO_DetachedHedgeInterface *getHedgeInterface(
457  bool use_hidden_grp);
458  virtual const GEO_PrimClassifier *getPrimClassifier(GU_Connectivity con);
459  virtual const GA_EdgeGroup *getHiddenEdgeGroup();
460  virtual const GA_ElementGroup *getVisibleElementGroup(GA_GroupType t);
461 
462  static int getPolygonMeshLimit();
463  static int getPointMeshLimit();
464 
465  static void handleMaterialChange(OP_Node *src, void *dest,
466  OP_EventType type, void *data);
467 
468  bool isMSSEnabled() const { return myMSSEnable; }
469  bool isMSSPackedEnabled() const { return myMSSPackedGeo; }
470  bool isMSSPerPrimEnabled() const { return myMSSPerPrim; }
471  bool areOverridesEnabled() const
472  { return myMaterialUseOverrides; }
473  int getMaterialLimit() const { return myMaterialLimit; }
475  { myMaterialLimitExceeded = e; }
476 
477  // clear all primitives and associated caching information
478  void invalidateGeo();
479 
480 protected:
481  virtual void updateGLSpecific(RE_Render *r,
482  GR_DisplayOption *opts,
483  GUI_SetupResult setup_reason,
484  GR_DecorationOverride selmask_dec,
485  const char *view_name,
486  const GU_Detail *dtl)
487  {}
488 
489  virtual void cleanupMaterials() {}
490  virtual bool shouldRender(const GU_Detail *geo) const;
491 
492  int getNumPrimitives() const
493  { return myPrimitives.entries(); }
494  GR_Primitive *getPrimitive(int index) const;
495 
497  { return &disp_opt[ look().getDisplaySetType() ]; }
498 
500  const GUI_DisplayOption &disp_opt) const
501  { return &disp_opt[ look().getDisplaySetType() ]; }
502 
503  // Required Render functions -------------------------------------------
504 
505  // Wireframe only.
506  virtual void wireRender(RE_Render *r,
507  GUI_DisplayOption &disp_opt,
508  const GU_Detail *geo,
511 
512  // Solid polygon render
513  virtual void solidRender(RE_Render *r,
514  GUI_DisplayOption &disp_opt,
515  const GU_Detail *geo,
518  GR_AlphaPass pass) {};
519 
520  virtual void simpleRender(RE_Render *r,
521  GUI_DisplayOption &opt,
522  const GU_Detail *geo,
524  GR_RenderFlags flags) {};
525 
526  virtual void simpleBboxRender(RE_Render *r,
527  GUI_DisplayOption &opt,
528  RE_Shader *shader=0,
529  bool fill=true,
530  bool outline=true) {};
531 
532  // Utility functions ---------------------------------------------------
533 
534  // Returns the decorations required for the selection types on this detail
535  GR_DecorationOverride getSelectionDecorations(
536  const GR_DisplayOption *opt) const;
537 
538  // Returns true if the geometry has a selection which requires a closure
539  // color.
540  bool isClosureSelection(GU_SelectionHandle sel,
541  bool &has_edges) const;
542  bool isClosureSelection(GR_SelectionAdapter &sel,
543  bool &has_edges) const;
544 
545  // returns true if the buffer was filled because the attribute existed in
546  // the detail, or false if a constant attribute was created (which must be
547  // filled in)
549  {
554  FETCH_ERROR
555  };
556 
557  // returns true if all materials were loaded (textures included).
558  // can return false if timeout > 0 and it took too long.
559  bool prepMaterials(RE_Render *r,
560  const GR_DisplayOption *opts,
561  bool &needs_alpha_pass);
562 
563  // Setup wire selection uniforms on 'r', and modify 'flags' to include
564  // GR_RENDER_FLAG_WIRE_OVER if needed.
565  void setupWireSelectParms(RE_Render *r,
566  GUI_DisplayOption &disp_opts,
567  bool is_wireframe,
569  void cleanupWireSelectParms(RE_Render *r);
570 
571  // Sets the object matrix uniform based on our instancer transform,
572  // detail transform, etc.
573  void setObjectMatrixUniform(RE_Render *r);
574 
575  void updatePrimitives(RE_Render *r,
576  GR_DisplayOption *opts,
578  GT_RefineParms &refine_opts,
579  GR_UpdateReason reason,
580  GR_DecorationOverride req_dec,
581  const char *view_name,
582  const GR_FrustumList &view_frustums);
583  void processPrimitives(const GU_ConstDetailHandle &geo,
584  GT_PrimitiveHandle &ph,
585  GT_RefineParms &refparms,
586  int &listcount,
587  const GR_DisplayOption &dispopt,
588  GR_UpdateReason reason,
589  const char *cache_name,
591  bool processPrim(const GU_ConstDetailHandle &geo,
592  GT_PrimitiveHandle &ph,
593  GT_RefineParms &refparms,
594  int &listcount,
595  const GR_DisplayOption &dispopt,
596  GR_UpdateReason reason,
597  const char *cache_name,
599  bool apply_filter_vis,
600  int &packed_index);
601 
602  void processAlembicArchive(GT_PrimitiveHandle &ph,
603  const GU_ConstDetailHandle &gdh,
604  GT_RefineParms &refparms,
605  int &listcount,
606  const GR_DisplayOption &dispopt,
607  GR_UpdateReason reason,
608  const char *cache_name,
610  exint mat_id);
611  void clearUnusedAlembicArchives();
612 
613  void renderMatteGroupColors(RE_Render *r,
614  GUI_GroupDataHandle group_data,
615  GR_DisplayOption *opt,
616  GR_RenderFlags render_flags);
617 
618  // Lower level render function used by beautyRender, wireRender, etc.
619  void renderPrims(RE_Render *r,
620  GR_DisplayOption *opt,
623  GR_AlphaPass alphapass,
624  bool use_materials);
625 
626  bool createOrReuseRefinedPrim(GT_PrimitiveHandle &ph,
627  const GU_ConstDetailHandle &gdh,
628  const GEO_Primitive *geo_prim,
629  int &listcount,
630  const GR_DisplayOption &disp,
631  GR_UpdateReason reason,
632  const GT_RefineParms &ref_parms,
633  const char *cache_name,
635  bool processing_geo_prims,
636  bool apply_filter_vis,
637  int packed_index,
638  int64 mat_id);
639  GR_PrimAcceptResult checkForExistingPrim(GT_PrimitiveHandle &ph,
640  GR_Primitive *prim,
641  int pindex,
642  GR_UpdateReason reason,
643  const GT_RefineParms &ref_parms,
644  const GU_ConstDetailHandle &gdh,
645  const GEO_Primitive *geo_prim,
646  int &listcount,
648  bool processing_geo_prims,
649  int packed_index);
650  void accumulateTime(RE_Render *r);
651 
652  void buildEdgeHighlight(RE_Render *r,
653  const GU_Detail *geo,
654  GR_UpdateReason reason,
655  const GR_DisplayOption *opt,
656  const char *view_name);
657 
658  bool buildInstanceSelection(bool has_sel_overrides);
659  fpreal getPointInstanceFraction(GR_DisplayOption *opts) const;
660  UT_Matrix4DArray *getPointInstanceTransforms(GR_DisplayOption *opts);
661 
662  RE_CacheVersion getGeoVersion(const GU_Detail *geo,
663  const GR_DisplayOption *opt);
664  RE_CacheVersion getSelectionVersion(const GU_Detail *geo,
665  const GR_DisplayOption *opt);
666  RE_CacheVersion getEdgeHighlightVersion(const GU_Detail *geo,
667  const GR_DisplayOption *opt,
668  bool include_selection);
669 
671  { mySelectionId = id; mySelectionRevision = version; }
672 
673  GR_PrimAcceptResult processHookPrimitive(GT_PrimitiveHandle &gt_prim,
674  const GEO_Primitive *geo_prim,
675  const GU_ConstDetailHandle &gdh,
676  GR_UpdateReason reason,
677  const GT_RefineParms &ref_parms,
678  const char *cache_name,
679  GR_Primitive *&created,
680  int &list_index,
681  int &hook_priority,
682  bool &filtered_prim,
683  gui_RenderHookEntry *&prev,
685  bool processing_geo_prims,
686  int packed_index);
687 
688  void processFilterHooks(GT_PrimitiveHandle &gt_prim,
689  const GEO_Primitive *geo_prim);
690 
691  void restartCollectionPrimitives();
692  void removeUnusedCollectionPrimitives();
693 
694  void find3DBoundaries(const GU_Detail *geo,
695  const GA_PrimitiveGroup *within_prims,
696  GA_EdgeGroup *boundary_group);
697  void findUVBoundaries(const GU_Detail *geo,
698  const GA_PrimitiveGroup *within_prims,
699  GA_EdgeGroup * uv_boundary_group,
700  const GA_ROHandleV2 &uv,
701  bool vert_uvs);
702 
704  {
705  public:
706  gui_BoundaryData() : myUsed(false), myAttribVersion(-1) {}
707 
714  bool myUsed;
715  };
716 
717  bool matchesVersion(gui_BoundaryData &bdata,
718  const UT_StringHolder &attrib_name,
719  const RE_CacheVersion &ver,
720  bool view_3d, bool vert_uv);
721  void createEdgeGeo(RE_Render *r,
722  gui_BoundaryData &bdata,
723  const GA_EdgeGroup *edges,
724  bool is_3d,
725  bool is_vertex,
726  const UT_StringHolder &attrib_name,
727  const UT_StringHolder &cache_suffix,
728  const GU_Detail *geo,
729  const RE_CacheVersion &ev,
730  GA_ROHandleV2 *uvhandle = nullptr);
731 
733  { return myInfo; }
734 
735  void getRefineParms(RE_Render *r,
736  const GR_DisplayOption *opts,
737  GT_RefineParms &p) const;
738 
739  void resizePrimArray(exint nprims, bool clear = false);
740  void assignPrim(exint index,
741  GR_Primitive *prim,
742  const GT_PrimitiveHandle &gtprim);
743  void updateWorldTransform();
744 
746  static RE_MaterialPtr theDefaultMaterial[2];
747 
748  static int theNumObjects;
749  static int theNumPolys;
750  static int theNumVertices;
751 
754  GUI_ObjectMaterialCache *myObjectMaterialCache;
756 
759 
766 
770  int myViewID;
771 
775 
776 private:
777  bool shouldUVRender(const GU_Detail *geo,
778  const GUI_DisplayOption &disp,
779  bool is_vertex) const;
780  bool shouldRender(const GU_Detail *geo,
781  const GUI_DisplayOption &disp,
782  GR_RenderFlags render_flags) const;
783  bool shouldRender(const GU_Detail *geo,
784  const GUI_DisplayOption &disp,
785  GR_DecorRenderFlags decor_flags) const;
786  bool shouldRender(const GU_Detail *geo,
787  const GUI_DisplayOption &disp,
788  GR_PickStyle pick_style) const;
789 
790  bool requiresStateChange(const GUI_DisplayOption &disp_opt,
791  GUI_DisplaySetType newset,
792  GUI_DisplaySetType oldset) const;
793 
794  GR_UpdateReason checkForShaderUpdates(const GU_Detail *geo);
795  bool prepObjectMaterial(RE_Render *r,
796  const GR_DisplayOption &opts);
797  bool checkAutoVertexNormal(const GU_Detail *dtl,
798  const GR_CommonDispOption &opts);
799 
800  bool inPackedPrim() const
801  { return myPackedPrimLevel > 0; }
802  bool inInstancePrim() const
803  { return myInstancePrim.entries() > 0; }
804  void updateInstanceEntry(gr_PrimEntry *entry,
805  int prim_index);
806 
807  bool processInstancedPrims(const GT_PrimitiveHandle &ph,
808  int &listcount,
810  int64 geo_id, int64 geo_count,
811  int packed_index,
812  int64 mat_id);
813 
814  // instancing
815  void buildPointInstanceArray(RE_Render *r,
816  GR_DisplayOption *dopts,
817  const GU_Detail *dtl,
818  bool use_fraction_parm);
819  void pointInstanceGuideRender(RE_Render *r,
820  GUI_DisplayOption &disp_opt);
821  void renderEdgeHighlight(RE_Render *r,
822  const GR_DisplayOption *op,
823  GR_RenderFlags render_flags);
824  void renderBBox(RE_Render *r,
825  GUI_DisplayOption &opt,
826  RE_Shader *shader=0,
827  bool fill=true,
828  bool outline=true);
829  OP_Node * getObjectMaterial(fpreal t) const;
830  void clearMaterialInterests();
831 
832  UT_Array<gr_PrimEntry *> myPrimitives;
833  UT_IntArray myPrimitiveIndex;
834 
835  GUI_GroupDataHandle myGroupData;
836 
837  UT_Array<gui_HookedPrims *> myHookedGEOPrims;
838 
839  bool myObjectMaterialDirty;
840  OBJ_Node *myTopObject;
841  int myNodeID;
842  bool myUseObjectMaterial;
843 
844  GR_RenderInfo myInfo;
845  GUI_DetailLook *myLook;
846  int myGeoIndex;
847  int myNameIndex;
848  UT_String myCacheName;
849  bool mySetupFlag;
850  bool myHasGLStateCheckPrims;
851  bool myLitFlag;
852  bool myHasGuideParts;
853  bool myHasPackedPrims;
854  bool myHasPackedFragments;
855  bool myHasPackedInstances;
856  bool myWireframeFlag;
857  bool myForceShadedFlag;
858  bool myRecordingTime;
859  bool myIsDisplayed;
860 
861  bool myHasAgentPrims;
862  bool myAgentLastLODEnable;
863  int myAgentLastMinPoints;
864  int myAgentLastMaxLOD;
865 
866 
869  int myDrawTimeWaiting;
870  int64 myDrawTime;
871  int64 mySetupTime;
872 
873  int myDetailID;
874  int64 myVersion;
875  int64 myTopologyVersion;
876  int myCachedShowSelect;
877  int64 myPrimitiveVersion;
878  int64 myPosVersion;
879  exint mySelectionId;
880  exint mySelectionRevision;
881  int myPostPassID;
882  bool myNeedsDeferredPass;
883 
884  UT_String myDopnetPath;
885 
886  // For determining if a display option which affects geometry has changed.
887  int64 myDispOptID;
888  int myDispOptSerial;
889  fpreal myLOD;
890  bool myPolygonConvexQuality;
891  bool myVertexNormalEnable;
892  fpreal myVertexNormalCuspAngle;
893  GR_DecorationOverride myRequiredDecorations;
894  bool myShowAllPoints;
895  fpreal myDetailLOD;
896 
897  GUI_RenderMask myRenderMask;
898  GUI_DisplaySetType myObjectState;
899  GEO_ViewportLOD myObjectLOD;
900  bool myObjectDisplayAsSubdiv;
901 
902  GU_ConstDetailHandle myDetailHandle;
903  UT_Matrix4DArray myDetailTransforms;
904  UT_Matrix4DArray myDetailInvTransforms;
905  UT_Matrix4DArray myReducedDetailTransforms;
906  bool myDetailTransformIdentity;
907  UT_Matrix4D myInstancerTransform;
908  UT_Matrix4D myDetailFullTransform;
909  bool myInstancerIdentityFlag;
910  UT_IntArray myDetailGeoIndex;
911  UT_BoundingBox myLocalBBox;
912  int64 myCachedInstanceVersion;
913  int myRefineVersion;
914  bool myCheckUpdateViewFlag;
915  bool myObjectTransformDirty;
916  bool myNeedsAlphaPassFlag;
917  bool myPrimAlphaPassFlag;
918  bool myIsDeferPass;
919  bool myRefineOnLODChange;
920  int mySelectionInstance;
921  fpreal myLimitedInstanceFraction;
922  bool myShowMaterials;
923 
924  RE_CacheVersion myInstanceSelectVersion;
925  UT_BitArray myInstanceSelection;
926  bool myHasInstanceSelection;
927 
928  // for GT_PrimInstance types, this holds the array of instance transforms
929  // while its geometry is being refined.
930  class gui_Instance
931  {
932  public:
933  gui_Instance() { myBBox.makeInvalid(); }
934 
935  UT_Matrix4DArray myTransforms;
936  GU_ConstDetailHandle myDetail;
937  GT_PrimitiveHandle myPrim;
938  UT_BoundingBox myBBox;
939  };
940  UT_Array<gui_Instance> myInstancePrim;
941  GT_AttributeListHandle myInstancePrimAttribs;
942  GT_AttributeListHandle myInstancePointAttribs;
943 
944  class gui_DiskFile
945  {
946  public:
947  gui_DiskFile() : myPrimIndex(0) {}
948  UT_StringHolder myDiskFile;
949  int myPrimIndex;
950  };
951  UT_Array<gui_DiskFile> myPackedDiskStack;
952 
953  int myPackedPrimLevel;
954  GT_PrimitiveHandle myPackedPrim;
955  mutable bool myCachedUseSampleMask;
956  mutable int myCachedSampleMask;
957  mutable bool myCachedMultisample;
958  mutable bool myCachedSampleCoverage;
959 
960  RE_Geometry *myPointGeo;
961  RE_Geometry *myCubeGeo;
962  RE_VertexArray *myCubeInstance;
963  fpreal myCubeInstanceFraction;
964 
965  RE_ReflectMap *myReflectMap;
966 
967  // last update and refinement time in visualization clock (counter)
968  exint myVisUpdateTime;
969  exint myVisRefineTime;
970 
971  UT_IntArray myUpdateVisualizers;
972  UT_IntArray myRefineVisualizers;
973 
974  // if set to true in setup, updates are upgraded to full refinements.
975  bool myRefineOnUpdate;
976  unsigned myMaterialTextureFlag :1,
977  myMaterialHasDisplaceMap :1,
978  myMaterialHasReflection :1,
979  myMaterialUseOverrides :1,
980  myMSSEnable :1,
981  myMSSPackedGeo :1,
982  myMSSPerPrim :1;
983  GUI_DisplayOption::gui_MatAssignMode myMatAssignMode;
984  int myMaterialLimit;
985  bool myMaterialLimitExceeded;
986  int myObjMaterialID;
987 
988  GT_DataArrayHandle myBaseMaterialAssignments;
989  GT_DataArrayHandle myBaseMaterialRemap;
990  int64 myBaseMaterialPrevID;
991  int64 myBaseMaterialRemapPrevID;
992  bool myDefaultMaterialLazyMode;
993  bool myForceMaterialUpdate;
994  bool myMaterialAllowUpdates;
995 
996  class gui_DetailAttribLists
997  {
998  public:
999  bool checkForAttribListChanges(const GU_Detail &dtl);
1000 
1001  UT_StringMap<bool> myPoint;
1002  UT_StringMap<bool> myVertex;
1003  UT_StringMap<bool> myPrim;
1004  UT_StringMap<bool> myDetail;
1005 
1006  UT_StringMap<bool> myVisAttribs;
1007  };
1008 
1009  gui_DetailAttribLists myDetailAttribLists;
1010  struct
1011  {
1016  } myHedgeInterface[2];
1017 
1018  UT_UniquePtr<GEO_PrimClassifier> myPrimClassifier;
1019  int myPrimClassifierDetailId;
1020  int64 myPrimClassifierCacheVersion;
1021  int64 myPrimClassifierTopVersion;
1022  int64 myPrimClassifierSelectId;
1023  int64 myPrimClassifierSelectRevision;
1024  GU_Connectivity myPrimClassifierConnectivity;
1025 
1026  UT_UniquePtr<GA_Group> myCachedGroup;
1027  GA_GroupType myCachedGroupType;
1028  int myCachedGroupDetailId;
1029  int64 myCachedGroupCacheVersion;
1030  int64 myCachedGroupTopVersion;
1031 
1032  static RE_ShaderHandle theBboxShader;
1033  static RE_ShaderHandle theObjectPickShader;
1034  static RE_ShaderHandle theEdgeHighlightShader;
1035  static RE_ShaderHandle theEdgeHighlightUVShader;
1036 
1037  UT_StringMap<GT_PrimitiveHandle> myAlembicArchives;
1038  UT_StringMap<int> myUsedAlembicArchives;
1039 
1040  UT_StringHolder myUVDisplay;
1041 public:
1042  // treat as private. For DM_RenderTable only.
1043  static bool registerHook(GUI_PrimitiveHook *hook,
1044  GT_PrimitiveType gt_type,
1045  int geo_type,
1046  int priority,
1048 
1049  friend class gr_PrimEntry;
1050 };
1051 
1052 inline void
1054 {
1056 }
1057 
1058 inline int64
1060 {
1061  return myInstanceVersion;
1062 }
1063 
1064 inline const UT_DMatrix4 &
1066 {
1067  return myDetailTransforms(index);
1068 }
1069 
1070 inline const UT_DMatrix4 &
1072 {
1073  return myDetailInvTransforms(index);
1074 }
1075 
1076 #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()
GLuint id
Definition: glew.h:1679
GLenum src
Definition: glew.h:2410
RE_LightList * myLightList
GLuint const GLchar * name
Definition: glew.h:1814
RE_TextureCubeFace
GR_DecorRenderFlags
Definition: GR_Defines.h:209
UT_StringMap< gui_BoundaryData > myUVBoundary
bool isDisplayed() const
GR_DecorationOverride
Definition: GR_Defines.h:198
GLenum mode
Definition: glew.h:2163
void refreshVisRefineTime()
int64 myPrimDecorMask
gui_BoundaryData myEdgeSelection
GA_API const UT_StringHolder uv
GT_API const UT_StringHolder time
GLuint index
Definition: glew.h:1814
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)
ImageBuf OIIO_API fill(cspan< float > values, ROI roi, int nthreads=0)
void shadingMode(GR_ShadingMode shading_mode)
void setNameIndex(int idx)
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
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)
const UT_DMatrix4 & getDetailTransform(int index) const
bool forceWireframe() const
bool hasUpdateVisualizer(int vis_id) const
static UT_Lock theShaderLock
GLuint shader
Definition: glew.h:1813
GR_Decoration
Definition: GR_Defines.h:141
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
bool needsDeferredPass() const
int64 myEdgePrimsVersion
void refreshUpdateVisualizers()
void setSelection(int64 id, int64 version)
long long int64
Definition: SYS_Types.h:111
void setLocalBBox(const UT_BoundingBox &bbox, int)
virtual exint bumpClock()=0
UT_SharedPtr< GA_EdgeGroup > myEdges
void setDisplayed(bool is_disp)
UT_SharedPtr< RE_Geometry > my2DGeo
bool isBboxShadingMode(const GR_DisplayOption *opt) const
GR_DecorVisibility
Definition: GR_Defines.h:171
GR_ShadingPass
Definition: GR_Defines.h:118
GR_RenderMode
Definition: GR_Defines.h:44
std::pair< GA_PrimitiveTypeId, GT_PrimitiveType > GUI_PrimTypeKey
Definition: GUI_GeoRender.h:75
GLclampf f
Definition: glew.h:3499
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:120
UT_SharedPtr< RE_Geometry > my2DGeoV
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
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:288
GUI_RenderPassFlags
int isIdentity() const
Definition: UT_Matrix4.h:1046
GUI_SetupResult
void clearRefineVisualizers()
GR_PrimAcceptResult
Definition: GR_Defines.h:331
void setInstancerTransform(const UT_DMatrix4 &xform)
static int theNumPolys
GR_RenderFlags
Definition: GR_Defines.h:80
const UT_DMatrix4 & getDetailInvTransform(int index) const
bool needsAlphaPass() const
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
void setInstancerTransformIdentity()
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GUI_DetailLook & look() const
void setDeferredPass(bool dpass)
const UT_DMatrix4 & getDetailFullTransform() const
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:76
GT_PrimitiveType
void refreshRefineVisualizers()
GUI_DisplaySetType getDisplaySetType() const
GLfloat GLfloat p
Definition: glew.h:16321
bool isMSSPerPrimEnabled() const
bool isSetup() const
double fpreal
Definition: SYS_Types.h:276
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:157
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
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
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
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
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
GR_API void setupGhosting(RE_Render *r, int opaque_data[3], fpreal transparency=0.25f)
const char * getCacheName() const
Definition: GUI_GeoRender.h:98
GUI_PrimitiveHookFlags
GR_API void cleanupGhosting(RE_Render *r, int opaque_data[3])
virtual bool isLopRender() const
Definition: GUI_GeoRender.h:88
GLdouble GLdouble t
Definition: glew.h:1398
void needsAlphaPass(bool need)
void setGeoIndex(int idx)
static GUI_VisInterface * getHandler()
Simple interface to building a shader from a .prog file.
bool areOverridesEnabled() const
UT_UniquePtr< GEO_DetachedHedgeInterface > interface
GR_PickStyle
Definition: GR_Defines.h:230
const GR_DisplayOption * getDisplayOptionSet(const GUI_DisplayOption &disp_opt) const