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