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  bool use_hidden_grp);
443  virtual const GEO_PrimClassifier *getPrimClassifier(GU_Connectivity con);
444  virtual const GA_EdgeGroup *getHiddenEdgeGroup();
445  virtual const GA_ElementGroup *getVisibleElementGroup(GA_GroupType t);
446 
447  static int getPolygonMeshLimit();
448  static int getPointMeshLimit();
449 
450  static void handleMaterialChange(OP_Node *src, void *dest,
451  OP_EventType type, void *data);
452 
453  bool isMSSEnabled() const { return myMSSEnable; }
454  bool isMSSPackedEnabled() const { return myMSSPackedGeo; }
455  bool isMSSPerPrimEnabled() const { return myMSSPerPrim; }
456  bool areOverridesEnabled() const
457  { return myMaterialUseOverrides; }
458  int getMaterialLimit() const { return myMaterialLimit; }
460  { myMaterialLimitExceeded = e; }
461 
462  // clear all primitives and associated caching information
463  void invalidateGeo();
464 
465 protected:
466  virtual void updateGLSpecific(RE_Render *r,
467  GR_DisplayOption *opts,
468  GUI_SetupResult setup_reason,
469  GR_DecorationOverride selmask_dec,
470  const char *view_name,
471  const GU_Detail *dtl)
472  {}
473 
474  virtual void cleanupMaterials() {}
475 
476  GR_Primitive *getPrimitive(int index);
477 
479  { return &disp_opt[ look().getDisplaySetType() ]; }
480 
482  const GUI_DisplayOption &disp_opt) const
483  { return &disp_opt[ look().getDisplaySetType() ]; }
484 
485  // Required Render functions -------------------------------------------
486 
487  // Wireframe only.
488  virtual void wireRender(RE_Render *r,
489  GUI_DisplayOption &disp_opt,
490  const GU_Detail *geo,
493 
494  // Solid polygon render
495  virtual void solidRender(RE_Render *r,
496  GUI_DisplayOption &disp_opt,
497  const GU_Detail *geo,
500  GR_AlphaPass pass) {};
501 
502  virtual void simpleRender(RE_Render *r,
503  GUI_DisplayOption &opt,
504  const GU_Detail *geo,
506  GR_RenderFlags flags) {};
507 
508  virtual void simpleBboxRender(RE_Render *r,
509  GUI_DisplayOption &opt,
510  RE_Shader *shader=0,
511  bool fill=true,
512  bool outline=true) {};
513 
514  // Utility functions ---------------------------------------------------
515 
516  // Returns the decorations required for the selection types on this detail
517  GR_DecorationOverride getSelectionDecorations(
518  const GR_DisplayOption *opt) const;
519 
520  // Returns true if the geometry has a selection which requires a closure
521  // color.
522  bool isClosureSelection(GU_SelectionHandle sel,
523  bool &has_edges) const;
524  bool isClosureSelection(GR_SelectionAdapter &sel,
525  bool &has_edges) const;
526 
527  // returns true if the buffer was filled because the attribute existed in
528  // the detail, or false if a constant attribute was created (which must be
529  // filled in)
531  {
536  FETCH_ERROR
537  };
538 
539  void prepMaterials(RE_Render *r,
540  const GR_DisplayOption *opts);
541 
542  // Setup wire selection uniforms on 'r', and modify 'flags' to include
543  // GR_RENDER_FLAG_WIRE_OVER if needed.
544  void setupWireSelectParms(RE_Render *r,
545  GUI_DisplayOption &disp_opts,
546  bool is_wireframe,
548  void cleanupWireSelectParms(RE_Render *r);
549 
550  // Sets the object matrix uniform based on our instancer transform,
551  // detail transform, etc.
552  void setObjectMatrixUniform(RE_Render *r);
553 
554  void updatePrimitives(RE_Render *r,
555  GR_DisplayOption *opts,
557  GT_RefineParms &refine_opts,
558  GR_UpdateReason reason,
559  GR_DecorationOverride req_dec,
560  const char *view_name,
561  const GR_FrustumList &view_frustums);
562  void processPrimitives(const GU_ConstDetailHandle &geo,
563  GT_PrimitiveHandle &ph,
564  GT_RefineParms &refparms,
565  int &listcount,
566  const GR_DisplayOption &dispopt,
567  GR_UpdateReason reason,
568  const char *cache_name,
570  bool processPrim(const GU_ConstDetailHandle &geo,
571  GT_PrimitiveHandle &ph,
572  GT_RefineParms &refparms,
573  int &listcount,
574  const GR_DisplayOption &dispopt,
575  GR_UpdateReason reason,
576  const char *cache_name,
578  bool apply_filter_vis,
579  int &packed_index);
580 
581  void processAlembicArchive(GT_PrimitiveHandle &ph,
582  const GU_ConstDetailHandle &gdh,
583  GT_RefineParms &refparms,
584  int &listcount,
585  const GR_DisplayOption &dispopt,
586  GR_UpdateReason reason,
587  const char *cache_name,
589  exint mat_id);
590  void clearUnusedAlembicArchives();
591 
592  void renderMatteGroupColors(RE_Render *r,
593  GUI_GroupDataHandle group_data,
594  GR_DisplayOption *opt,
595  GR_RenderFlags render_flags);
596 
597  // Lower level render function used by beautyRender, wireRender, etc.
598  void renderPrims(RE_Render *r,
599  GR_DisplayOption *opt,
602  GR_AlphaPass alphapass,
603  bool use_materials);
604 
605  bool createOrReuseRefinedPrim(GT_PrimitiveHandle &ph,
606  const GU_ConstDetailHandle &gdh,
607  const GEO_Primitive *geo_prim,
608  int &listcount,
609  const GR_DisplayOption &disp,
610  GR_UpdateReason reason,
611  const GT_RefineParms &ref_parms,
612  const char *cache_name,
614  bool processing_geo_prims,
615  bool apply_filter_vis,
616  int packed_index,
617  int64 mat_id);
618  GR_PrimAcceptResult checkForExistingPrim(GT_PrimitiveHandle &ph,
619  GR_Primitive *prim,
620  int pindex,
621  GR_UpdateReason reason,
622  const GT_RefineParms &ref_parms,
623  const GU_ConstDetailHandle &gdh,
624  const GEO_Primitive *geo_prim,
625  int &listcount,
627  bool processing_geo_prims,
628  int packed_index);
629  void accumulateTime(RE_Render *r);
630 
631  void buildEdgeHighlight(RE_Render *r,
632  const GU_Detail *geo,
633  GR_UpdateReason reason,
634  const GR_DisplayOption *opt,
635  GUI_DisplaySetType draw_state,
636  const char *view_name);
637 
638  bool buildInstanceSelection(bool has_sel_overrides);
639  fpreal getPointInstanceFraction(GR_DisplayOption *opts) const;
640  UT_Matrix4DArray *getPointInstanceTransforms(GR_DisplayOption *opts);
641 
642  RE_CacheVersion getGeoVersion(const GU_Detail *geo,
643  const GR_DisplayOption *opt);
644  RE_CacheVersion getSelectionVersion(const GU_Detail *geo,
645  const GR_DisplayOption *opt);
646  RE_CacheVersion getEdgeHighlightVersion(const GU_Detail *geo,
647  const GR_DisplayOption *opt,
648  bool include_selection);
649 
650  GR_PrimAcceptResult processHookPrimitive(GT_PrimitiveHandle &gt_prim,
651  const GEO_Primitive *geo_prim,
652  const GU_ConstDetailHandle &gdh,
653  GR_UpdateReason reason,
654  const GT_RefineParms &ref_parms,
655  const char *cache_name,
656  GR_Primitive *&created,
657  int &list_index,
658  int &hook_priority,
659  bool &filtered_prim,
660  gui_RenderHookEntry *&prev,
662  bool processing_geo_prims,
663  int packed_index);
664 
665  void processFilterHooks(GT_PrimitiveHandle &gt_prim,
666  const GEO_Primitive *geo_prim);
667 
668  void restartCollectionPrimitives();
669  void removeUnusedCollectionPrimitives();
670 
671  void find3DBoundaries(const GU_Detail *geo,
672  const GA_PrimitiveGroup *within_prims,
673  GA_EdgeGroup *boundary_group);
674  void findUVBoundaries(const GU_Detail *geo,
675  const GA_PrimitiveGroup *within_prims,
676  GA_EdgeGroup * uv_boundary_group,
677  const GA_ROHandleV2 &uv,
678  bool vert_uvs);
679 
681  {
682  public:
683  gui_BoundaryData() : myUsed(false), myAttribVersion(-1) {}
684 
691  bool myUsed;
692  };
693 
694  bool matchesVersion(gui_BoundaryData &bdata,
695  const UT_StringHolder &attrib_name,
696  const RE_CacheVersion &ver,
697  bool view_3d, bool vert_uv);
698  void createEdgeGeo(RE_Render *r,
699  gui_BoundaryData &bdata,
700  const GA_EdgeGroup *edges,
701  bool is_3d,
702  bool is_vertex,
703  const UT_StringHolder &attrib_name,
704  const UT_StringHolder &cache_suffix,
705  const GU_Detail *geo,
706  const RE_CacheVersion &ev,
707  GA_ROHandleV2 *uvhandle = nullptr);
708 
710  { return myInfo; }
711 
713  static RE_MaterialPtr theDefaultMaterial[2];
714 
715  static int theNumObjects;
716  static int theNumPolys;
717  static int theNumVertices;
718 
721  GUI_ObjectMaterialCache *myObjectMaterialCache;
723 
726 
733 
736 
740 
741 private:
742  bool shouldRender(const GU_Detail *geo) const;
743  bool shouldUVRender(const GU_Detail *geo,
744  const GUI_DisplayOption &disp,
745  bool is_vertex) const;
746  bool shouldRender(const GU_Detail *geo,
747  const GUI_DisplayOption &disp,
748  GR_RenderFlags render_flags) const;
749  bool shouldRender(const GU_Detail *geo,
750  const GUI_DisplayOption &disp,
751  GR_DecorRenderFlags decor_flags) const;
752  bool shouldRender(const GU_Detail *geo,
753  const GUI_DisplayOption &disp,
754  GR_PickStyle pick_style) const;
755 
756  bool requiresStateChange(const GUI_DisplayOption &disp_opt,
757  GUI_DisplaySetType newset,
758  GUI_DisplaySetType oldset) const;
759 
760  GR_UpdateReason checkForShaderUpdates(const GU_Detail *geo);
761  bool prepObjectMaterial(RE_Render *r,
762  const GR_DisplayOption &opts);
763  bool checkAutoVertexNormal(const GU_Detail *dtl,
764  const GR_CommonDispOption &opts);
765 
766  void getRefineParms(RE_Render *r,
767  const GR_DisplayOption *opts,
768  GT_RefineParms &p) const;
769 
770  bool inPackedPrim() const
771  { return myPackedPrimLevel > 0; }
772  bool inInstancePrim() const
773  { return myInstancePrim.entries() > 0; }
774  void updateInstanceEntry(gr_PrimEntry *entry,
775  int prim_index);
776 
777  bool processInstancedPrims(const GT_PrimitiveHandle &ph,
778  int &listcount,
780  int64 geo_id, int64 geo_count,
781  int packed_index,
782  int64 mat_id);
783 
784  // instancing
785  void buildPointInstanceArray(RE_Render *r,
786  GR_DisplayOption *dopts,
787  const GU_Detail *dtl,
788  bool use_fraction_parm);
789  void pointInstanceGuideRender(RE_Render *r,
790  GUI_DisplayOption &disp_opt);
791  void renderEdgeHighlight(RE_Render *r,
792  const GR_DisplayOption *op,
793  GR_RenderFlags render_flags);
794  void renderBBox(RE_Render *r,
795  GUI_DisplayOption &opt,
796  RE_Shader *shader=0,
797  bool fill=true,
798  bool outline=true);
799  OP_Node * getObjectMaterial(fpreal t) const;
800  void clearMaterialInterests();
801 
802  UT_Array<gr_PrimEntry *> myPrimitives;
803  UT_IntArray myPrimitiveIndex;
804 
806  GUI_GroupDataHandle myGroupData;
807 
808  UT_Array<gui_HookedPrims *> myHookedGEOPrims;
809 
810  bool myObjectMaterialDirty;
811  OBJ_Node *myTopObject;
812  int myNodeID;
813  bool myUseObjectMaterial;
814 
815  GR_RenderInfo myInfo;
816  GUI_DetailLook *myLook;
817  int myGeoIndex;
818  int myNameIndex;
819  UT_String myCacheName;
820  bool mySetupFlag;
821  bool myHasGLStateCheckPrims;
822  bool myLitFlag;
823  bool myHasGuideParts;
824  bool myHasPackedPrims;
825  bool myHasPackedFragments;
826  bool myHasPackedInstances;
827  bool myWireframeFlag;
828  bool myForceShadedFlag;
829  bool myRecordingTime;
830  bool myIsDisplayed;
831 
832  bool myHasAgentPrims;
833  bool myAgentLastLODEnable;
834  int myAgentLastMinPoints;
835  int myAgentLastMaxLOD;
836 
837 
840  int myDrawTimeWaiting;
841  int64 myDrawTime;
842  int64 mySetupTime;
843 
844  int myDetailID;
845  int64 myVersion;
846  int64 myTopologyVersion;
847  int myCachedShowSelect;
848  int64 myPrimitiveVersion;
849  int64 myPosVersion;
850  exint mySelectionId;
851  exint mySelectionRevision;
852  int myPostPassID;
853  bool myNeedsDeferredPass;
854 
855  UT_String myDopnetPath;
856 
857  // For determining if a display option which affects geometry has changed.
858  int64 myDispOptID;
859  int myDispOptSerial;
860  fpreal myLOD;
861  bool myPolygonConvexQuality;
862  bool myVertexNormalEnable;
863  fpreal myVertexNormalCuspAngle;
864  GR_DecorationOverride myRequiredDecorations;
865  bool myShowAllPoints;
866  fpreal myDetailLOD;
867 
868  GUI_RenderMask myRenderMask;
869  GUI_DisplaySetType myObjectState;
870  GEO_ViewportLOD myObjectLOD;
871  bool myObjectDisplayAsSubdiv;
872 
873  GU_ConstDetailHandle myDetailHandle;
874  UT_Matrix4DArray myDetailTransforms;
875  UT_Matrix4DArray myDetailInvTransforms;
876  UT_Matrix4DArray myReducedDetailTransforms;
877  bool myDetailTransformIdentity;
878  UT_Matrix4D myInstancerTransform;
879  UT_Matrix4D myDetailFullTransform;
880  bool myInstancerIdentityFlag;
881  UT_IntArray myDetailGeoIndex;
882  UT_BoundingBox myLocalBBox;
883  int64 myCachedInstanceVersion;
884  int myViewSerial;
885  int myViewID;
886  int myRefineVersion;
887  bool myCheckUpdateViewFlag;
888  bool myObjectTransformDirty;
889  bool myNeedsAlphaPassFlag;
890  bool myPrimAlphaPassFlag;
891  bool myIsDeferPass;
892  bool myRefineOnLODChange;
893  int mySelectionInstance;
894  fpreal myLimitedInstanceFraction;
895  bool myShowMaterials;
896 
897  RE_CacheVersion myInstanceSelectVersion;
898  UT_BitArray myInstanceSelection;
899  bool myHasInstanceSelection;
900 
901  // for GT_PrimInstance types, this holds the array of instance transforms
902  // while its geometry is being refined.
903  class gui_Instance
904  {
905  public:
906  gui_Instance() { myBBox.makeInvalid(); }
907 
908  UT_Matrix4DArray myTransforms;
909  GU_ConstDetailHandle myDetail;
910  GT_PrimitiveHandle myPrim;
911  UT_BoundingBox myBBox;
912  };
913  UT_Array<gui_Instance> myInstancePrim;
914  GT_AttributeListHandle myInstancePrimAttribs;
915  GT_AttributeListHandle myInstancePointAttribs;
916 
917  class gui_DiskFile
918  {
919  public:
920  gui_DiskFile() : myPrimIndex(0) {}
921  UT_StringHolder myDiskFile;
922  int myPrimIndex;
923  };
924  UT_Array<gui_DiskFile> myPackedDiskStack;
925 
926  int myPackedPrimLevel;
927  GT_PrimitiveHandle myPackedPrim;
928  mutable bool myCachedUseSampleMask;
929  mutable int myCachedSampleMask;
930  mutable bool myCachedMultisample;
931  mutable bool myCachedSampleCoverage;
932 
933  RE_Geometry *myPointGeo;
934  RE_Geometry *myCubeGeo;
935  RE_VertexArray *myCubeInstance;
936  fpreal myCubeInstanceFraction;
937 
938  RE_ReflectMap *myReflectMap;
939 
940  // last update and refinement time in visualization clock (counter)
941  exint myVisUpdateTime;
942  exint myVisRefineTime;
943 
944  UT_IntArray myUpdateVisualizers;
945  UT_IntArray myRefineVisualizers;
946 
947  // if set to true in setup, updates are upgraded to full refinements.
948  bool myRefineOnUpdate;
949  unsigned myMaterialTextureFlag :1,
950  myMaterialHasDisplaceMap :1,
951  myMaterialHasReflection :1,
952  myMaterialUseOverrides :1,
953  myMSSEnable :1,
954  myMSSPackedGeo :1,
955  myMSSPerPrim :1;
956  GUI_DisplayOption::gui_MatAssignMode myMatAssignMode;
957  int myMaterialLimit;
958  bool myMaterialLimitExceeded;
959  int myObjMaterialID;
960 
961  GT_DataArrayHandle myBaseMaterialAssignments;
962  GT_DataArrayHandle myBaseMaterialRemap;
963  int64 myBaseMaterialPrevID;
964  int64 myBaseMaterialRemapPrevID;
965  bool myDefaultMaterialLazyMode;
966  bool myForceMaterialUpdate;
967  bool myMaterialAllowUpdates;
968 
969  class gui_DetailAttribLists
970  {
971  public:
972  bool checkForAttribListChanges(const GU_Detail &dtl);
973 
974  UT_StringMap<bool> myPoint;
975  UT_StringMap<bool> myVertex;
976  UT_StringMap<bool> myPrim;
977  UT_StringMap<bool> myDetail;
978  };
979 
980  gui_DetailAttribLists myDetailAttribLists;
981  struct
982  {
987  } myHedgeInterface[2];
988 
989  UT_UniquePtr<GEO_PrimClassifier> myPrimClassifier;
990  int myPrimClassifierDetailId;
991  int64 myPrimClassifierCacheVersion;
992  int64 myPrimClassifierTopVersion;
993  int64 myPrimClassifierSelectId;
994  int64 myPrimClassifierSelectRevision;
995  GU_Connectivity myPrimClassifierConnectivity;
996 
997  UT_UniquePtr<GA_Group> myCachedGroup;
998  GA_GroupType myCachedGroupType;
999  int myCachedGroupDetailId;
1000  int64 myCachedGroupCacheVersion;
1001  int64 myCachedGroupTopVersion;
1002 
1003  static RE_ShaderHandle theBboxShader;
1004  static RE_ShaderHandle theObjectPickShader;
1005  static RE_ShaderHandle theEdgeHighlightShader;
1006  static RE_ShaderHandle theEdgeHighlightUVShader;
1007 
1008  UT_StringMap<GT_PrimitiveHandle> myAlembicArchives;
1009  UT_StringMap<int> myUsedAlembicArchives;
1010 
1011  UT_StringHolder myUVDisplay;
1012 public:
1013  // treat as private. For DM_RenderTable only.
1014  static bool registerHook(GUI_PrimitiveHook *hook,
1015  GT_PrimitiveType gt_type,
1016  int geo_type,
1017  int priority,
1019 
1020  friend class gr_PrimEntry;
1021 };
1022 
1023 inline void
1025 {
1026  myInstanceVersion = version;
1027 }
1028 
1029 inline int64
1031 {
1032  return myInstanceVersion;
1033 }
1034 
1035 inline const UT_DMatrix4 &
1037 {
1038  return myDetailTransforms(index);
1039 }
1040 
1041 inline const UT_DMatrix4 &
1043 {
1044  return myDetailInvTransforms(index);
1045 }
1046 
1047 #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
UT_SharedPtr< RE_Geometry > my2DGeo
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
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: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
UT_UniquePtr< GEO_DetachedHedgeInterface > interface
GR_PickStyle
Definition: GR_Defines.h:226
const GR_DisplayOption * getDisplayOptionSet(const GUI_DisplayOption &disp_opt) const