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