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_Set.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_StringMap.h>
20 #include <UT/UT_StopWatch.h>
21 #include <UT/UT_Matrix4.h>
22 #include <UT/UT_ValArray.h>
23 #include <UT/UT_UniquePtr.h>
24 #include <UT/UT_Array.h>
25 #include <DEP/DEP_MicroNode.h>
26 #include <RE/RE_Types.h>
27 #include <RE/RE_Texture.h>
28 #include <RE/RE_TimerQuery.h>
30 #include <RE/RE_RenderContext.h>
31 #include <GA/GA_Attribute.h>
32 #include <GR/GR_Defines.h>
33 #include <GR/GR_Material.h>
34 #include <GR/GR_RenderInfo.h>
35 #include <GT/GT_Primitive.h>
36 #include <GU/GU_DetailHandle.h>
37 #include <GU/GU_SelectType.h>
38 #include "GUI_GroupData.h"
39 #include "GUI_RenderCommon.h"
40 #include "GUI_DisplayOption.h"
41 #include "GUI_DetailLook.h"
42 #include "GUI_PrimitiveHook.h"
43 #include "GUI_RenderCommon.h"
44 #include "GUI_API.h"
45 
46 class GA_EdgeGroup;
47 class GA_ElementGroup;
48 class GU_Detail;
49 class GEO_PrimClassifier;
51 class RE_Render;
52 class RE_Geometry;
53 class GR_LightList;
54 class RE_ReflectMap;
55 class RE_Shader;
56 class RE_VertexArray;
57 class RE_ElementArray;
58 class GUI_DetailLook;
59 class GA_ROAttributeRef;
60 class GA_PointGroup;
61 class GA_EdgeGroup;
62 class GA_PrimitiveGroup;
64 class GEO_Primitive;
65 class GR_DisplayOption;
67 class gui_AttribInfo;
68 class gui_CollectionPrim;
69 class GR_Primitive;
71 class GT_RefineParms;
72 class OBJ_Node;
73 class gui_HookedPrims;
74 class gr_PrimEntry;
75 class GR_VisualizerInfo;
76 class gui_RenderHookEntry;
77 class GUI_ObjectMaterialCache;
78 class GR_Uniforms;
79 
80 using GUI_PrimTypeKey = std::pair<GA_PrimitiveTypeId, GT_PrimitiveType>;
81 
83 {
84 public:
86  const char *name,
87  int geo_index,
88  int name_index);
89  virtual ~GUI_GeoRender();
90 
91  virtual const char *className() const { return "GUI_GeoRender"; }
92 
93  virtual bool isLopRender() const { return false; }
94 
95  void setGeometry(OP_Node *node);
96  OP_Node *getGeometry() const;
97 
98  // set the base geometry name for the cache name.
99  void setGeoName(const char *name);
100  // set the cache name to exactly 'name'. Only used for instancing.
101  void setInstanceName(const char *name);
102 
103  const char *getCacheName() const { return myCacheName; }
104 
105  // the index of the detail within the GUI_DetailLook.
106  void setGeoIndex(int idx) { myGeoIndex = idx; }
107  int getGeoIndex() const { return myGeoIndex; }
108  void setNameIndex(int idx) { myNameIndex = idx; }
109  int getNameIndex() const { return myNameIndex; }
110 
111  // If this represents a node, this will return its node id.
112  int getNodeID() const { return myNodeID; }
113 
114  // If this represents some guide geometry, the index within a list of
115  // guides is tracked through these methods.
116  void setGuideID(int id) { myGuideID = id; }
117  int getGuideID() const { return myGuideID; }
118 
119  // The geometry this object will be rendering.
120  void setDetailHandle(const GU_ConstDetailHandle &handle);
121  virtual GU_ConstDetailHandle &getDetailHandle() { return myDetailHandle; }
122 
123  // control the display of the GUI_GeoRender object. Those not displayed
124  // cannot be rendered or picked.
125  void setDisplayed(bool is_disp) { myIsDisplayed = is_disp; }
126  bool isDisplayed() const { return myIsDisplayed; }
127 
128  // local transform of the object
129  bool setDetailTransform(const UT_DMatrix4 &xform);
130  const UT_DMatrix4 &getDetailTransform(int index) const;
131  const UT_DMatrix4 &getDetailInvTransform(int index) const;
133  { return myDetailTransforms.entries(); }
135  { myDetailFullTransform = xform; }
137  { return myDetailFullTransform; }
138 
139  // For an instance object, this is the instance object's transform. The
140  // detail transforms are the individual point transforms.
142  { myInstancerTransform = xform;
143  myInstancerIdentityFlag = xform.isIdentity(); }
145  { myInstancerTransform.identity();
146  myInstancerIdentityFlag = true; }
148  { return myInstancerTransform; }
149 
150  const UT_BoundingBox &localBBox();
151  const UT_BoundingBox &worldBBox();
152 
153  void updateBBox();
154 
155 
156  // bounding box of this object
157  virtual int getBoundingBox2D(UT_BoundingBox &bbox,
158  const char *name,
159  int use_vertex) const;
160  virtual int getBoundingBox3D(UT_BoundingBox &bbox,
161  const UT_Matrix3R *rot) const;
162 
163  int getInstancedBoundingBox3D(UT_BoundingBox &bbox,
164  const UT_Matrix3R *rot,
165  const UT_DMatrix4 &detail_xform) const;
166 
167  // set the view * projection matrix
168  static void setWorldToScreen(const UT_Matrix4R &xform);
169 
170  // instanced transforms for the object, when point instancing
171  void setIsInstancedGeo(bool instanced);
172  bool addInstanceTransform(const UT_DMatrix4 &xform,
173  int geo_index);
174  void clearInstanceTransforms();
175  void setInstanceVersion(int64 version);
176  int64 getInstanceVersion() const;
177 
178  // setup() called before any update or drawing is done, and cleanup() is
179  // called when all rendering is complete for the current redraw.
180  virtual GUI_SetupResult setup(const GUI_DisplayOption &disp_opt,
181  GUI_DisplaySetType state,
182  bool show_selection,
183  GR_DecorationOverride selmask_dec,
184  GR_DecorationOverride &select_dec,
185  bool &needs_alpha,
186  bool is_current);
187 
188  // minimal setup for multiple viewports (such as a quad config). One
189  // viewport is called with setup(), the others fastSetup().
190  virtual bool fastSetup(const GUI_DisplayOption &disp_opt);
191 
192  virtual void update(RE_RenderContext r,
193  GR_DisplayOption *opt,
194  GUI_SetupResult setup_reason,
195  GR_DecorationOverride selmask_dec,
196  const char *view_name,
197  bool &needs_alpha,
198  const GR_FrustumList &view_frustums);
199 
200  void updateRenderVersion(RE_RenderContext r);
201 
202  virtual void cleanup(RE_RenderContext r);
203 
204  bool isSetup() const { return mySetupFlag; }
205  bool needsAlphaPass() const { return myNeedsAlphaPassFlag; }
206  void needsAlphaPass(bool need) { myNeedsAlphaPassFlag=need;}
207 
209  { return myMaterialTexturePending; }
210 
211  void addMaterialReference(OP_Node *mat_node);
212  void clearMaterialReferences();
213 
214  // called when this look is no longer displayed and placed in a short cache
215  // in case it is displayed again.
216  void retire();
217 
218  // Called when an object isn't displayed anymore, aka retire()-lite.
219  void hide();
220 
221  // Return true if gl_lit is set on the contained detail.
222  bool isLit() const { return myLitFlag; }
223 
224  // return true if this geo has guide rendering
225  bool hasGuideParts() const { return myHasGuideParts; }
226 
227  // Return if gl_wireframe is set to a positive value.
228  bool forceWireframe() const { return myWireframeFlag; }
229 
230  // Return if gl_wireframe is set to a negative value.
231  bool forceShaded() const { return myForceShadedFlag; }
232 
233  // Return if gl_xray is set to a positive value.
234  bool forceXRay() const { return myXRayFlag; }
235 
236  // Return true if should be drawn shaded in the beauty pass
237  // with current settings, false if it should be drawn wireframe
238  bool shouldDrawShaded(GUI_DisplayOption &disp_opt) const;
239 
240  // The post-pass ID is used to setup and render post-render passes
241  void setPostPassID(int id) { myPostPassID = id ; }
242  int getPostPassID() const { return myPostPassID; }
243 
244  // An additional deferred pass is required (not a post pass).
245  bool needsDeferredPass() const { return myNeedsDeferredPass;}
246  void setNeedsDeferredPass(bool need)
247  { myNeedsDeferredPass = need;}
248  void setDeferredPass(bool dpass) { myIsDeferPass = dpass; }
249  bool isDeferredPass() const { return myIsDeferPass; }
250 
251  // Returns the time in seconds of various operations
252  fpreal getSetupTime() const { return fpreal(mySetupTime)*1e-9;}
253  fpreal getDrawTime() const { return fpreal(myDrawTime)*1e-9;}
254 
255  virtual bool isObjectRender() const { return false; }
256 
258  { return myMaterialHasReflection; }
259 
260  void setGhosted(bool ghost)
261  { myInfo.myObjectGhosted = ghost; }
262  void setObjectSelection(int obj_selection)
263  { myInfo.myObjectSelection = obj_selection; }
264  void setCanRenderUV(int uv_render)
265  { myInfo.myCanRenderUV = uv_render; }
266  bool canRenderUV() const
267  {
268  return myInfo.myCanRenderUV;
269  }
270 
271  bool getComponentSelection(
272  const GR_DisplayOption *opt,
273  GR_SelectionAdapter &adapter) const;
274 
275  // DRAWING --------------------------------------------------------------
276 
277  // wire representation of all objects.
278  virtual void wireframeRender(RE_RenderContext r,
279  GUI_DisplayOption &disp_opt,
281  GR_RenderFlags render_flags);
282 
283  // Beauty pass shaded render.
284  virtual GUI_RenderPassFlags
285  beautyRender(RE_RenderContext r,
286  GUI_DisplayOption &disp_opt,
287  GR_ShadingPass shade_pass,
288  GR_AlphaPass alphapass,
290  GR_RenderFlags render_flags);
291 
292  static void setupRender(RE_RenderContext r, GR_RenderMode mode);
293  static void cleanupRender(RE_RenderContext r, GR_RenderMode mode);
294 
296  GUI_DisplayOption &disp_opt,
297  UT_Vector4F &ghost_color,
298  fpreal ghost_amount = 0.5);
300 
301  // Various simple rendering, such as matte or depth.
302  virtual void utilityRender(RE_RenderContext r,
303  GUI_DisplayOption &disp_opt,
305  GR_RenderFlags rflags);
306 
307  // rendering for post-render passes that primitives request.
308  virtual void postPassRender(RE_RenderContext r,
309  GUI_DisplayOption &disp_opt,
310  GR_AlphaPass apass);
311 
312  // Object bounding box render
313  virtual void bboxRender(RE_RenderContext r,
314  GUI_DisplayOption &disp_opt,
315  GR_RenderMode render_mode);
316 
317  // Render any highlights required
318  void renderMatteHighlights(RE_RenderContext r,
319  GUI_DisplayOption &disp_opt,
320  GR_RenderFlags render_flags);
321  // Render onion skins
322  void onionSkinRender(RE_RenderContext r,
323  GUI_DisplayOption &disp_opt);
324 
325  virtual int64 getPrimDecorationMask() const
326  { return myPrimDecorMask; }
327 
328  // Modelling aids, like normals or uv coord display.
329  // This function is called before any specific decorations are rendered.
330  virtual void setupDecorationsRender(RE_RenderContext r);
331  // This functions renders one type of decoration.
332  virtual void decorationRender(
334  GUI_DisplayOption &disp_opt,
335  GR_Decoration dec,
336  GR_DecorVisibility vis,
337  bool override_dispopt,
338  GR_DecorRenderFlags render_flags);
339 
340  virtual void customDecorationRender(RE_RenderContext r,
341  GUI_DisplayOption &disp_opts,
342  const GR_VisualizerInfo *dec,
344 
345  // PICKING --------------------------------------------------------------
346 
347  // Return true if this object can be selected, and if 'node' isn't null,
348  // assign to it the node that should be selected when this object is picked
349  bool canBeSelected(OP_Node *op,
350  GUI_DisplayOption &disp_opt,
351  bool pick_template,
352  bool pick_non_sel,
353  bool pick_ghost,
354  OBJ_Node **node = nullptr) const;
355 
356  // A version of canBeSelected() used when every displayed detail is treated
357  // as an "object".
358  bool canBeSelectedWhenNotUsingOps(
359  GUI_DisplayOption &disp_opt,
360  bool pick_template,
361  bool pick_non_sel,
362  bool pick_ghost) const;
363 
364  // Full object pick - all or nothing.
365  virtual void objectPick(RE_RenderContext r,
366  GUI_DisplayOption &opts,
367  GR_RenderFlags render_flags,
368  const GR_ObjectPickFlags &pick_flags,
369  bool force_wire);
370 
371  // Component pick, component type based on display option.
372  virtual int componentPick(RE_RenderContext r,
373  GUI_DisplayOption &opts,
374  unsigned int primmask,
376  GR_PickStyle pickstyle,
377  bool has_pick_map,
378  UT_Array<GR_PickRecord> *pick_records);
379 
380  GUI_DetailLook &look() const { return *myLook; }
381  const char *name() const { return myCacheName; }
382 
383  // LIGHTING ------------------------------------------------------------
384 
385  void setupLighting(GR_LightList *list, bool headlight);
386  void cleanupLighting();
387 
388  static void resetStats();
389  static void getStats(int &num_objs,
390  int &num_polys,
391  int &num_vertices);
392 
393  void bumpObjectMaterial() { myObjectMaterialDirty=true; }
394 
395  void useObjectMaterials(bool use_obj_mat);
396  bool getAssignedMaterials(UT_Array<OP_Node *> &nodes) const;
397 
398  int getObjectMaterialID() const { return myObjMaterialID; }
399 
400  void adoptAtlas(const RE_MaterialAtlas &gl_atlas,
401  const GR_MaterialAtlas &vk_atlas);
402 
403  bool isBBoxShadingMode(const GR_DisplayOption *opt) const
404  {
405  return opt->shadingMode()==GR_BOUNDING_BOX_WIRE
407  }
408 
410  {
411  return isBBoxShadingMode(getDisplayOptionSet(opt));
412  }
413 
414  // Reflection map support, for this object
415  bool prepReflectionMap(RE_RenderContext r,
416  GUI_DisplayOption &opt,
417  int64 version,
418  fpreal time);
419  void startReflectionPass(RE_RenderContext r,
421  void endReflectionPass(RE_RenderContext r);
422  void finishReflectionMap(RE_RenderContext r,
423  GUI_DisplayOption &opt);
424  RE_Texture *getReflectionMap() const;
425 
426  // VISUALIZERS -----------------------------------------------------------
427 
429  { return myVisUpdateTime; }
430 
432  { return myVisRefineTime; }
433 
435  { myVisUpdateTime =
437 
439  { myVisRefineTime = myVisUpdateTime =
441 
442  bool hasUpdateVisualizer(int vis_id) const
443  { return myUpdateVisualizers.find(vis_id) >= 0; }
444 
445  bool hasRefineVisualizer(int vis_id) const
446  { return myRefineVisualizers.find(vis_id) >= 0; }
447 
449  { return look().getActiveVisualizers(); }
450 
452  { return myUpdateVisualizers; }
453 
455  { return myRefineVisualizers; }
456 
458  { myUpdateVisualizers = getActiveVisualizers(); }
459 
461  { myUpdateVisualizers.clear(); }
462 
464  { myRefineVisualizers = getActiveVisualizers(); }
465 
467  { myRefineVisualizers.clear(); }
468 
469  void runCreatorVisualizers(int &listcount,
471 
472  GUI_VisFlags getActiveVisFlags(int prim_idx,
473  GUI_VisContext context) const;
474 
475  // Look for an attribute in the given owner class (or all of them for
476  // GT_OWNER_INVALID) in all cached GT_Primitives in the detail
477  // (those used for updating GR_Primitives in the last update, which,
478  // in particular, have been filtered by visualizes) and return
479  // the first matching attribute if any.
480 
481  const
482  GT_DataArrayHandle findCachedAttribute(const char *attrib_name,
483  GT_Owner owner = GT_OWNER_INVALID) const;
484 
485  // Cached data used for display. Tied to the underlying GU_Detail.
486  virtual const GEO_DetachedHedgeInterface *getHedgeInterface(
487  bool use_hidden_grp);
488  virtual const GEO_PrimClassifier *getPrimClassifier(GU_Connectivity con);
489  virtual const GA_EdgeGroup *getHiddenEdgeGroup();
490  virtual const GA_ElementGroup *getVisibleElementGroup(GA_GroupType t);
491 
492  static int getPolygonMeshLimit();
493  static int getPointMeshLimit();
494 
495  static void handleMaterialChange(OP_Node *src, void *dest,
496  OP_EventType type, void *data);
497 
498  bool isMSSEnabled() const { return myMSSEnable; }
499  bool isMSSPackedEnabled() const { return myMSSPackedGeo; }
500  bool isMSSPerPrimEnabled() const { return myMSSPerPrim; }
501  bool areOverridesEnabled() const
502  { return myMaterialUseOverrides; }
503  int getMaterialLimit() const { return myMaterialLimit; }
505  { myMaterialLimitExceeded = e; }
506 
507  // clear all primitives and associated caching information
508  void invalidateGeo();
509 
510  // clear the cached data ids used to enable GR_PACK_TRANSORM_CHANGED
511  // faster code path
513  { myDataIds.clear(); }
514 
515 #ifdef USE_VULKAN
516  static bool initShaders(RV_Instance* inst);
517  static void cleanupShaders();
518 #endif
519 
520 protected:
521 
522  virtual void cleanupMaterials() {}
523 
525  {
526  myLocalBBox.makeInvalid();
527  myWorldBBox.makeInvalid();
528  myLook->invalidateBBox();
529  }
530  virtual void doUpdateBBox(UT_BoundingBox &world_bbox,
531  UT_BoundingBox &local_bbox);
532 
533  void setShowMaterials(bool show) { myShowMaterials = show; }
534  bool showMaterials() const { return myShowMaterials; }
535  virtual bool shouldRender(const GU_Detail *geo) const;
536 
537  int getNumPrimitives() const
538  { return myPrimitives.entries(); }
539  GR_Primitive *getPrimitive(int index) const;
540 
542  { return &disp_opt[ look().getDisplaySetType() ]; }
543 
545  const GUI_DisplayOption &disp_opt) const
546  { return &disp_opt[ look().getDisplaySetType() ]; }
547 
548  // Required Render functions -------------------------------------------
549 
550  // Wireframe only.
551  virtual void wireRender(RE_RenderContext r,
552  GUI_DisplayOption &disp_opt,
553  const GU_Detail *geo,
556 
557  // Solid polygon render
559  GUI_DisplayOption &disp_opt,
560  const GU_Detail *geo,
563  GR_AlphaPass pass) {};
564 
566  GUI_DisplayOption &opt,
567  const GU_Detail *geo,
569  GR_RenderFlags flags) {};
570 
572  GUI_DisplayOption &opt,
573  RE_Shader *shader=0,
574  bool fill=true,
575  bool outline=true) {};
576 
577  // Utility functions ---------------------------------------------------
578 
579  // Returns the decorations required for the selection types on this detail
580  GR_DecorationOverride getSelectionDecorations(
581  const GR_DisplayOption *opt) const;
582 
583  // Returns true if the geometry has a selection which requires a closure
584  // color.
585  bool isClosureSelection(GU_SelectionHandle sel,
586  bool &has_edges) const;
587  bool isClosureSelection(GR_SelectionAdapter &sel,
588  bool &has_edges) const;
589 
590  // returns true if the buffer was filled because the attribute existed in
591  // the detail, or false if a constant attribute was created (which must be
592  // filled in)
594  {
599  FETCH_ERROR
600  };
601 
602  // returns true if all materials were loaded (textures included).
603  // can return false if timeout > 0 and it took too long.
604  bool prepMaterials(RE_RenderContext r,
605  const GR_DisplayOption *opts,
606  bool &needs_alpha_pass);
607  bool prepVulkanMaterials(RV_Render *r,
608  const GR_DisplayOption *disp,
609  bool &needs_alpha);
610 
611  // Setup wire selection uniforms on 'r', and modify 'flags' to include
612  // GR_RENDER_FLAG_WIRE_OVER if needed.
613  void setupWireSelectParms(RE_RenderContext r,
614  GUI_DisplayOption &disp_opts,
615  bool is_wireframe,
617  void cleanupWireSelectParms(RE_RenderContext r);
618 
619  // Sets the object matrix uniform based on our instancer transform,
620  // detail transform, etc.
621  void setObjectMatrixUniform(RE_RenderContext r);
622 
623  void updatePrimitives(RE_RenderContext r,
624  GR_DisplayOption *opts,
626  GT_RefineParms &refine_opts,
627  GR_UpdateReason reason,
628  GR_DecorationOverride req_dec,
629  const char *view_name,
630  const GR_FrustumList &view_frustums);
631  void processPrimitives(const GU_ConstDetailHandle &geo,
632  GT_PrimitiveHandle &ph,
633  GT_RefineParms &refparms,
634  int &listcount,
635  const GR_DisplayOption &dispopt,
636  GR_UpdateReason reason,
637  const char *cache_name,
639  bool processPrim(const GU_ConstDetailHandle &geo,
640  GT_PrimitiveHandle &ph,
641  GT_RefineParms &refparms,
642  int &listcount,
643  const GR_DisplayOption &dispopt,
644  GR_UpdateReason reason,
645  const char *cache_name,
647  bool apply_filter_vis,
648  int &packed_index);
649 
650  void processAlembicArchive(GT_PrimitiveHandle &ph,
651  const GU_ConstDetailHandle &gdh,
652  GT_RefineParms &refparms,
653  int &listcount,
654  const GR_DisplayOption &dispopt,
655  GR_UpdateReason reason,
656  const char *cache_name,
658  exint mat_id);
659  void clearUnusedAlembicArchives();
660 
661  void renderMatteGroupColors(RE_RenderContext r,
662  GUI_GroupDataHandle group_data,
663  GR_DisplayOption *opt,
664  GR_RenderFlags render_flags);
665 
666  // Lower level render function used by beautyRender, wireRender, etc.
667  void renderPrims(RE_RenderContext r,
668  GR_DisplayOption *opt,
671  GR_AlphaPass alphapass,
672  bool use_materials);
673 
674  bool createOrReuseRefinedPrim(GT_PrimitiveHandle &ph,
675  const GU_ConstDetailHandle &gdh,
676  const GEO_Primitive *geo_prim,
677  int &listcount,
678  const GR_DisplayOption &disp,
679  GR_UpdateReason reason,
680  const GT_RefineParms &ref_parms,
681  const char *cache_name,
683  bool processing_geo_prims,
684  bool apply_filter_vis,
685  int packed_index,
686  int64 mat_id);
687  GR_PrimAcceptResult checkForExistingPrim(GT_PrimitiveHandle &ph,
688  GR_Primitive *prim,
689  int pindex,
690  GR_UpdateReason reason,
691  const GT_RefineParms &ref_parms,
692  const GU_ConstDetailHandle &gdh,
693  const GEO_Primitive *geo_prim,
694  int &listcount,
696  bool processing_geo_prims,
697  int packed_index);
698 
699  void classifyPrim(const GT_Primitive *prim);
700  void resetPrimClassify();
701 
702  void accumulateTime(RE_RenderContext r);
703 
704  void buildEdgeHighlight(RE_RenderContext r,
705  const GU_Detail *geo,
706  GR_UpdateReason reason,
707  const GR_DisplayOption *opt,
708  const char *view_name);
709 
710  bool buildInstanceSelection(bool has_sel_overrides);
711  fpreal getPointInstanceFraction(GR_DisplayOption *opts) const;
712  UT_Matrix4DArray *getPointInstanceTransforms(GR_DisplayOption *opts);
713 
714  RE_CacheVersion getGeoVersion(const GU_Detail *geo,
715  const GR_DisplayOption *opt);
716  RE_CacheVersion getSelectionVersion(const GU_Detail *geo,
717  const GR_DisplayOption *opt);
718  RE_CacheVersion getEdgeHighlightVersion(const GU_Detail *geo,
719  const GR_DisplayOption *opt,
720  bool include_selection);
721 
723  { mySelectionId = id; mySelectionRevision = version; }
724 
725  GR_PrimAcceptResult processHookPrimitive(GT_PrimitiveHandle &gt_prim,
726  const GEO_Primitive *geo_prim,
727  const GU_ConstDetailHandle &gdh,
728  GR_UpdateReason reason,
729  const GT_RefineParms &ref_parms,
730  const char *cache_name,
731  GR_Primitive *&created,
732  int &list_index,
733  int &hook_priority,
734  bool &filtered_prim,
735  gui_RenderHookEntry *&prev,
737  bool processing_geo_prims,
738  int packed_index);
739 
740  void processFilterHooks(GT_PrimitiveHandle &gt_prim,
741  const GEO_Primitive *geo_prim);
742 
743  void restartCollectionPrimitives();
744  void removeUnusedCollectionPrimitives();
745 
746  void find3DBoundaries(const GU_Detail *geo,
747  const GA_PrimitiveGroup *within_prims,
748  GA_EdgeGroup *boundary_group);
749  void findUVBoundaries(const GU_Detail *geo,
750  const GA_PrimitiveGroup *within_prims,
751  GA_EdgeGroup * uv_boundary_group,
752  const GA_ROHandleV2 &uv,
753  bool vert_uvs);
754 
756  {
757  public:
758  gui_BoundaryData() : myUsed(false), myAttribVersion(-1) {}
759 
766  bool myUsed;
767  };
768 
769  bool matchesVersion(gui_BoundaryData &bdata,
770  const UT_StringHolder &attrib_name,
771  const RE_CacheVersion &ver,
772  bool view_3d, bool vert_uv);
773  void createEdgeGeo(RE_RenderContext r,
774  gui_BoundaryData &bdata,
775  const GA_EdgeGroup *edges,
776  bool is_3d,
777  bool is_vertex,
778  const UT_StringHolder &attrib_name,
779  const UT_StringHolder &cache_suffix,
780  const GU_Detail *geo,
781  const RE_CacheVersion &ev,
782  GA_ROHandleV2 *uvhandle = nullptr);
783 
785  { return myInfo; }
786 
787  void getRefineParms(RE_RenderContext r,
788  const GR_DisplayOption *opts,
789  GT_RefineParms &p) const;
790 
791  void resizePrimArray(exint nprims, bool clear = false);
792  void assignPrim(exint index,
793  GR_Primitive *prim,
794  const GT_PrimitiveHandle &gtprim);
795  void updateWorldTransform();
796 
798 
799  static int theNumObjects;
800  static int theNumPolys;
801  static int theNumVertices;
802 
806  GUI_ObjectMaterialCache *myObjectMaterialCache;
808 
811 
818 
822  int myViewID;
824 
828 
829 private:
830  bool shouldUVRender(const GU_Detail *geo,
831  const GUI_DisplayOption &disp,
832  bool is_vertex) const;
833  bool shouldRender(const GU_Detail *geo,
834  const GUI_DisplayOption &disp,
835  GR_RenderFlags render_flags) const;
836  bool shouldRender(const GU_Detail *geo,
837  const GUI_DisplayOption &disp,
838  GR_DecorRenderFlags decor_flags) const;
839  bool shouldRender(const GU_Detail *geo,
840  const GUI_DisplayOption &disp,
841  GR_PickStyle pick_style) const;
842 
843  bool requiresStateChange(const GUI_DisplayOption &disp_opt,
844  GUI_DisplaySetType newset,
845  GUI_DisplaySetType oldset) const;
846 
847  GR_UpdateReason checkForShaderUpdates(const GU_Detail *geo,
848  const GUI_DisplayOption &disp);
849  bool prepObjectMaterial(RE_RenderContext r,
850  const GR_DisplayOption &opts);
851  bool checkAutoVertexNormal(const GU_Detail *dtl,
852  const GR_CommonDispOption &opts);
853 
854  bool inPackedPrim() const
855  { return myPackedPrimLevel > 0; }
856  bool inInstancePrim() const
857  { return myInstancePrim.entries() > 0; }
858  void updateInstanceEntry(gr_PrimEntry *entry,
859  int prim_index);
860 
861  bool processInstancedPrims(const GT_PrimitiveHandle &ph,
862  int &listcount,
864  int64 geo_id, int64 geo_count,
865  int packed_index,
866  int64 mat_id);
867 
868  // instancing
869  void buildPointInstanceArray(RE_RenderContext r,
870  GR_DisplayOption *dopts,
871  const GU_Detail *dtl,
872  bool use_fraction_parm);
873  void pointInstanceGuideRender(RE_RenderContext r,
874  GUI_DisplayOption &disp_opt);
875  void renderEdgeHighlight(RE_RenderContext r,
876  const GR_DisplayOption *op,
877  GR_RenderFlags render_flags);
878  void renderBBox(RE_RenderContext r,
879  GUI_DisplayOption &opt,
880  RE_Shader *shader=0,
881  bool fill=true,
882  bool outline=true);
883  OP_Node * getObjectMaterial(fpreal t);
884  void clearMaterialInterests();
885 
886  UT_Array<gr_PrimEntry *> myPrimitives;
887  UT_IntArray myPrimitiveIndex;
888 
889  GUI_GroupDataHandle myGroupData;
890 
891  UT_Array<gui_HookedPrims *> myHookedGEOPrims;
892 
893  bool myObjectMaterialDirty;
894  int myTopObjectID;
895  int myShaderNodeID;
896  UT_StopWatch myShaderRetryTimer;
897  int myNodeID;
898  int myGuideID;
899  bool myUseObjectMaterial;
900 
901  GR_RenderInfo myInfo;
902  GUI_DetailLook *myLook;
903  int myGeoIndex;
904  int myNameIndex;
905  UT_String myCacheName;
906  bool mySetupFlag;
907  bool myHasGLStateCheckPrims;
908  bool myLitFlag;
909  bool myHasGuideParts;
910  bool myHasPackedPrims;
911  bool myHasPackedFragments;
912  bool myHasPackedInstances;
913  bool myWireframeFlag;
914  bool myForceShadedFlag;
915  bool myXRayFlag;
916  bool myRecordingTime;
917  bool myIsDisplayed;
918 
919  bool myHasAgentPrims;
920  bool myAgentLastLODEnable;
921  int myAgentLastMinPoints;
922  int myAgentLastMaxLOD;
923 
924  bool myCharcterLastDeform;
925 
926  bool myHasPolygons;
927  bool myHasCurves;
928  bool myHasPoints;
929 
932  int myDrawTimeWaiting;
933  int64 myDrawTime;
934  int64 mySetupTime;
935 
936  int myDetailID;
937  int64 myVersion;
938  int64 myTopologyVersion;
939  int myCachedShowSelect;
940  int64 myPrimitiveVersion;
941  int64 myPosVersion;
942  exint mySelectionId;
943  exint mySelectionRevision;
944  int myPostPassID;
945  bool myNeedsDeferredPass;
946 
947  // Accumulate a Count and a Sum of attribute data ids to know
948  // if something changed.
949  class DataIdsCache
950  {
951  public:
952  DataIdsCache()
953  : myDataIdsCount(0)
954  , myDataIdsSum(0)
955  {}
956 
957  bool operator==(const DataIdsCache &rhs) const
958  {
959  return myDataIdsCount==rhs.myDataIdsCount &&
960  myDataIdsSum==rhs.myDataIdsSum;
961  }
962 
963  void clear()
964  {
965  myDataIdsCount = 0;
966  myDataIdsSum = 0;
967  }
968 
969  void append(GA_DataId id)
970  {
971  myDataIdsCount++;
972  myDataIdsSum += (exint)id;
973  }
974 
975  void getDataIdsExcept_p_transform(const GA_Detail *gdp);
976 
977  private:
978  exint myDataIdsCount;
979  exint myDataIdsSum;
980  };
981  DataIdsCache myDataIds;
982  DataIdsCache myDataIdsCache;
983 
984  UT_String myDopnetPath;
985 
986  // For determining if a display option which affects geometry has changed.
987  int64 myDispOptID;
988  int myDispOptSerial;
989  fpreal myLOD;
990  bool myPolygonConvexQuality;
991  bool myVertexNormalEnable;
992  fpreal myVertexNormalCuspAngle;
993  GR_DecorationOverride myRequiredDecorations;
994  bool myShowAllPoints;
995  fpreal myDetailLOD;
996 
997  GUI_RenderMask myRenderMask;
998  GUI_DisplaySetType myObjectState;
999  GEO_ViewportLOD myObjectLOD;
1000  bool myObjectDisplayAsSubdiv;
1001 
1002  GU_ConstDetailHandle myDetailHandle;
1003  UT_Matrix4DArray myDetailTransforms;
1004  UT_Matrix4DArray myDetailInvTransforms;
1005  UT_Matrix4DArray myReducedDetailTransforms;
1006  bool myDetailTransformIdentity;
1007  UT_Matrix4D myInstancerTransform;
1008  UT_Matrix4D myDetailFullTransform;
1009  bool myInstancerIdentityFlag;
1010  UT_IntArray myDetailGeoIndex;
1011  UT_BoundingBox myLocalBBox;
1012  UT_BoundingBox myWorldBBox;
1013  int64 myCachedInstanceVersion;
1014  int myRefineVersion;
1015  bool myCheckUpdateViewFlag;
1016  bool myObjectTransformDirty;
1017  bool myNeedsAlphaPassFlag;
1018  bool myPrimAlphaPassFlag;
1019  bool myIsDeferPass;
1020  bool myRefineOnLODChange;
1021  int mySelectionInstance;
1022  fpreal myLimitedInstanceFraction;
1023  bool myShowMaterials;
1024 
1025  RE_CacheVersion myInstanceSelectVersion;
1026  UT_BitArray myInstanceSelection;
1027  bool myHasInstanceSelection;
1028 
1029  // for GT_PrimInstance types, this holds the array of instance transforms
1030  // while its geometry is being refined.
1031  class gui_Instance
1032  {
1033  public:
1034  gui_Instance() { myBBox.makeInvalid(); }
1035 
1036  UT_Matrix4DArray myTransforms;
1037  GU_ConstDetailHandle myDetail;
1038  GT_PrimitiveHandle myPrim;
1039  UT_BoundingBox myBBox;
1040  };
1041  UT_Array<gui_Instance> myInstancePrim;
1042  GT_AttributeListHandle myInstancePrimAttribs;
1043  GT_AttributeListHandle myInstancePointAttribs;
1044 
1045  class gui_DiskFile
1046  {
1047  public:
1048  gui_DiskFile() : myPrimIndex(0) {}
1049  UT_StringHolder myDiskFile;
1050  int myPrimIndex;
1051  };
1052  UT_Array<gui_DiskFile> myPackedDiskStack;
1053 
1054  int myPackedPrimLevel;
1055  GT_PrimitiveHandle myPackedPrim;
1056  mutable bool myCachedUseSampleMask;
1057  mutable int myCachedSampleMask;
1058  mutable bool myCachedMultisample;
1059  mutable bool myCachedSampleCoverage;
1060 
1061  RE_Geometry *myPointGeo;
1062  RE_Geometry *myCubeGeo;
1063  RE_VertexArray *myCubeInstance;
1064  fpreal myCubeInstanceFraction;
1065 
1066  RE_ReflectMap *myReflectMap;
1067 
1068  // last update and refinement time in visualization clock (counter)
1069  exint myVisUpdateTime;
1070  exint myVisRefineTime;
1071 
1072  UT_IntArray myUpdateVisualizers;
1073  UT_IntArray myRefineVisualizers;
1074 
1075  // if set to true in setup, updates are upgraded to full refinements.
1076  bool myRefineOnUpdate;
1077  unsigned myMaterialTextureFlag :1,
1078  myMaterialTexturePending :1,
1079  myMaterialHasDisplaceMap :1,
1080  myMaterialHasReflection :1,
1081  myMaterialUseOverrides :1,
1082  myMSSEnable :1,
1083  myMSSPackedGeo :1,
1084  myMSSPerPrim :1,
1085  myMatCapDefault:1,
1086  myMatDrawUVMap:1;
1087  GUI_DisplayOption::gui_MatAssignMode myMatAssignMode;
1088  int myMaterialLimit;
1089  bool myMaterialLimitExceeded;
1090  int myObjMaterialID;
1091  int myDefaultMatSerial;
1092  DEP_MicroNode myObjMaterialParm;
1093  UT_Set<int> myMaterialReferences;
1094 
1095  GT_DataArrayHandle myBaseMaterialAssignments;
1096  GT_DataArrayHandle myBaseMaterialRemap;
1097  int64 myBaseMaterialPrevID;
1098  int64 myBaseMaterialRemapPrevID;
1099  bool myForceMaterialUpdate;
1100  bool myMaterialAllowUpdates;
1101 
1102  class gui_DetailAttribLists
1103  {
1104  public:
1105  bool checkForAttribListChanges(const GU_Detail &dtl);
1106 
1107  UT_StringMap<bool> myPoint;
1108  UT_StringMap<bool> myVertex;
1109  UT_StringMap<bool> myPrim;
1110  UT_StringMap<bool> myDetail;
1111 
1112  UT_StringMap<bool> myVisAttribs;
1113  };
1114 
1115  gui_DetailAttribLists myDetailAttribLists;
1116  struct
1117  {
1122  } myHedgeInterface[2];
1123 
1124  UT_UniquePtr<GEO_PrimClassifier> myPrimClassifier;
1125  int myPrimClassifierDetailId;
1126  int64 myPrimClassifierCacheVersion;
1127  int64 myPrimClassifierTopVersion;
1128  int64 myPrimClassifierSelectId;
1129  int64 myPrimClassifierSelectRevision;
1130  GU_Connectivity myPrimClassifierConnectivity;
1131 
1132  GA_GroupUPtr myCachedGroup;
1133  GA_GroupType myCachedGroupType;
1134  int myCachedGroupDetailId;
1135  int64 myCachedGroupCacheVersion;
1136  int64 myCachedGroupTopVersion;
1137 
1138  int64 myCachedHidden3DVersion;
1139 
1140  static RE_ShaderHandle theBBoxShader;
1141  static RE_ShaderHandle theObjectPickShader;
1142  static RE_ShaderHandle theEdgeHighlightShader;
1143  static RE_ShaderHandle theEdgeHighlightUVShader;
1144 
1145  UT_StringMap<GT_PrimitiveHandle> myAlembicArchives;
1146  UT_StringMap<int> myUsedAlembicArchives;
1147 
1148  UT_StringHolder myUVDisplay;
1149 public:
1150  // treat as private. For DM_RenderTable only.
1151  static bool registerHook(GUI_PrimitiveHook *hook,
1152  GT_PrimitiveType gt_type,
1153  int geo_type,
1154  int priority,
1156 
1157  friend class gr_PrimEntry;
1158 };
1159 
1160 inline void
1162 {
1164 }
1165 
1166 inline int64
1168 {
1169  return myInstanceVersion;
1170 }
1171 
1172 inline const UT_DMatrix4 &
1174 {
1175  return myDetailTransforms(index);
1176 }
1177 
1178 inline const UT_DMatrix4 &
1180 {
1181  return myDetailInvTransforms(index);
1182 }
1183 
1184 #endif
void setPostPassID(int id)
GR_MaterialAtlas myVulkanMaterials
void setDetailFullTransform(const UT_DMatrix4 &xform)
GLbitfield flags
Definition: glcorearb.h:1596
int getNumPrimitives() const
bool forceShaded() const
gui_BoundaryData my3DBoundary
void clearUpdateVisualizers()
RE_TextureCubeFace
GR_DecorRenderFlags
Definition: GR_Defines.h:219
UT_StringMap< gui_BoundaryData > myUVBoundary
bool isDisplayed() const
virtual void simpleBBoxRender(RE_RenderContext r, GUI_DisplayOption &opt, RE_Shader *shader=0, bool fill=true, bool outline=true)
GR_DecorationOverride
Definition: GR_Defines.h:208
void refreshVisRefineTime()
int64 myPrimDecorMask
gui_BoundaryData myEdgeSelection
GA_API const UT_StringHolder uv
GT_API const UT_StringHolder time
int64 GA_DataId
Definition: GA_Types.h:687
static int theNumObjects
void shadingMode(GR_ShadingMode shading_mode)
void setNameIndex(int idx)
GA_API const UT_StringHolder rot
int getObjectMaterialID() const
bool isIdentity() const
Definition: UT_Matrix4.h:1132
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)
void clearDataIds()
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:151
bool isBBoxShadingMode(GUI_DisplayOption &opt) const
GR_AlphaPass
Definition: GR_Defines.h:117
bool isDeferredPass() const
int getNameIndex() const
GUI_DisplaySetType
Context specific display options for geometry states.
Temporary container for either a RV_Render and an RE_Render.
FMT_NOINLINE FMT_CONSTEXPR auto fill(OutputIt it, size_t n, const fill_t< Char > &fill) -> OutputIt
Definition: format.h:1262
int getNumDetailTransforms() const
const GU_Detail * myLockedDetail
void invalidateBounds()
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:39
const UT_IntArray & getRefineVisualizers() const
bool needsDeferredPass() const
int64 myEdgePrimsVersion
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void setNeedsDeferredPass(bool need)
void refreshUpdateVisualizers()
void setSelection(int64 id, int64 version)
virtual exint bumpClock()=0
UT_SharedPtr< GA_EdgeGroup > myEdges
void setDisplayed(bool is_disp)
GLfloat f
Definition: glcorearb.h:1926
UT_SharedPtr< RE_Geometry > my2DGeo
GR_DecorVisibility
Definition: GR_Defines.h:181
GR_ShadingPass
Definition: GR_Defines.h:126
GR_RenderMode
Definition: GR_Defines.h:47
std::pair< GA_PrimitiveTypeId, GT_PrimitiveType > GUI_PrimTypeKey
Definition: GUI_GeoRender.h:80
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:36
#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
GUI_ObjectMaterialCache * myObjectMaterialCache
UT_SharedPtr< RE_Geometry > myGeoV
GU_Connectivity
Definition: GU_SelectType.h:66
UT_SharedPtr< GA_PrimitiveGroup > myEdgePrims
GR_LightList * myLightList
GR_UpdateReason
Definition: GR_Defines.h:300
GUI_RenderPassFlags
long long int64
Definition: SYS_Types.h:116
bool isBBoxShadingMode(const GR_DisplayOption *opt) const
GUI_SetupResult
GLuint id
Definition: glcorearb.h:655
GLuint const GLchar * name
Definition: glcorearb.h:786
void clearRefineVisualizers()
GR_PrimAcceptResult
Definition: GR_Defines.h:345
void setInstancerTransform(const UT_DMatrix4 &xform)
static int theNumPolys
GR_RenderFlags
Definition: GR_Defines.h:85
const UT_DMatrix4 & getDetailInvTransform(int index) const
virtual void simpleRender(RE_RenderContext r, GUI_DisplayOption &opt, const GU_Detail *geo, GR_RenderMode mode, GR_RenderFlags flags)
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
bool needsAlphaPass() const
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:36
void setInstancerTransformIdentity()
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GUI_DetailLook & look() const
void setShowMaterials(bool show)
void setDeferredPass(bool dpass)
GLdouble t
Definition: glad.h:2397
const UT_DMatrix4 & getDetailFullTransform() const
GLenum mode
Definition: glcorearb.h:99
bool isMSSEnabled() const
GT_API const UT_StringHolder version
virtual const char * className() const
Definition: GUI_GeoRender.h:91
void setInstanceVersion(int64 version)
bool hasGuideParts() const
GT_Owner
Definition: GT_Types.h:90
GT_PrimitiveType
bool showMaterials() const
void refreshRefineVisualizers()
GUI_DisplaySetType getDisplaySetType() const
GLuint shader
Definition: glcorearb.h:785
bool isMSSPerPrimEnabled() const
bool isSetup() const
int getMaterialLimit() const
int64 myUVAttribSerial
GR_DisplayOption * getDisplayOptionSet(GUI_DisplayOption &disp_opt)
void refreshVisUpdateTime()
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:160
GLuint index
Definition: glcorearb.h:786
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
GR_API void setupGhosting(RE_RenderContext r, int opaque_data[3], fpreal transparency=0.25f)
bool hasRefineVisualizer(int vis_id) const
void setGuideID(int id)
virtual GU_ConstDetailHandle & getDetailHandle()
bool forceXRay() const
GR_RenderInfo & getRenderInfo()
exint getVisRefineTime() const
UT_Map< UT_StringRef, int > myAttributes
const UT_DMatrix4 & getInstancerTransform() const
GR_API void cleanupGhosting(RE_RenderContext r, int opaque_data[3])
virtual void solidRender(RE_RenderContext r, GUI_DisplayOption &disp_opt, const GU_Detail *geo, GR_RenderMode mode, GR_RenderFlags flags, GR_AlphaPass pass)
Container class for all geometry.
Definition: GA_Detail.h:96
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
GLboolean r
Definition: glcorearb.h:1222
int getGuideID() const
UT_StringMap< bool > myUVAttribIsVertex
static int theNumVertices
const UT_IntArray & getActiveVisualizers() const
bool isLit() const
type
Definition: core.h:1059
const char * getCacheName() const
GUI_PrimitiveHookFlags
virtual bool isLopRender() const
Definition: GUI_GeoRender.h:93
void needsAlphaPass(bool need)
Definition: format.h:895
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:1793
UT_UniquePtr< GEO_DetachedHedgeInterface > interface
bool hasPendingMaterialTextures() const
GR_PickStyle
Definition: GR_Defines.h:240
const GR_DisplayOption * getDisplayOptionSet(const GUI_DisplayOption &disp_opt) const