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