HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUI_DetailLook.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_DetailLook.h ( GUI Library, C++)
7  *
8  * COMMENTS:
9  * A detail look encapsulates all of the data necessary to render a
10  * geometry in a viewport.
11  *
12  * The name is a holdover from when it was derived from UI_Rectangle.
13  */
14 
15 #ifndef __GUI_DetailLook__
16 #define __GUI_DetailLook__
17 
18 #include "GUI_API.h"
19 #include <UT/UT_Assert.h>
20 #include <UT/UT_BoundingBox.h>
21 #include <UT/UT_BoundingSphere.h>
22 #include <UT/UT_Color.h>
23 #include <UT/UT_IntrusivePtr.h>
24 #include <UT/UT_Map.h>
25 #include <UT/UT_Matrix4.h>
26 #include <UT/UT_PerfMonAutoEvent.h>
27 #include <UT/UT_PerfMonTypes.h>
28 #include <UT/UT_String.h>
29 #include <UT/UT_StringHolder.h>
30 #include <UT/UT_UniquePtr.h>
31 #include <UI/UI_Value.h>
32 #include <GEO/GEO_PackedTypes.h>
33 #include <GU/GU_Detail.h>
34 #include <GU/GU_DetailHandle.h>
35 #include <OP/OP_Network.h>
36 #include <GR/GR_DisplayOption.h>
37 #include <BM/BM_State.h>
38 #include "GUI_DisplayOption.h"
39 #include "GUI_RenderCommon.h"
40 #include "GUI_VisInterface.h"
41 #include "GUI_GroupData.h"
43 
44 #include <utility>
45 
46 class RE_Render;
47 class RE_Light;
48 class RE_Material;
49 class RE_Geometry;
50 class PXL_Raster;
51 class SIM_Data;
52 class SIM_RootData;
53 class GUI_GeoRender;
54 class GU_Detail;
56 class gui_Instance;
57 class gui_GeoInstanceInfo;
59 
61 
63 {
64 public:
65  // This determines if the detail passed to setDetailHandle() is refenced or
66  // copied to a new detail within this look.
68  {
70  REFERENCE_DETAIL
71  };
72 
74  const char *detail_name = NULL,
75  SetDetailMode mode = REFERENCE_DETAIL);
76 
77  void incref()
78  {
79  myRefCount.add(1);
80  }
81  void decref()
82  {
83  myRefCount.add(-1);
84  UT_ASSERT(myRefCount.relaxedLoad() >= 0);
85  if (myRefCount.relaxedLoad() == 0)
86  delete this;
87  }
88 
89  virtual const char *className() const;
90 
91  virtual bool isObjectList() const { return false; }
92  virtual bool isDopGuide() const { return false; }
93  virtual bool needsOverlayRender() { return false; }
94 
95  const char *getName() const { return myDetailName; }
96  void setName(const char *name);
97 
98  void setInitialized() { myInitializedFlag = true; }
99  bool isInitialized() const { return myInitializedFlag; }
100 
101  // Find out which node our gdp represents, if any:
102  OP_Node *getObject() const; // inline, below
103  OP_Node *getSop() const; // inline, below
104  OP_Node *getShopsRelativeTo() const; // inline, below
105  int getVisualizedNodeId() const; // inline, below
106 
107  // Set to new object/sop pair. returns true if the object or sop was
108  // actually changed.
109  bool setObject(OP_Node *node);
110  bool setSop(OP_Node *node);
111 
112  // New Viewport codepaths
113 
114  // setupForRender() can be called in parallel. setup() methods are expected
115  // to do non-GL work, such as convexing, surfacing, point normal computation
116  virtual GUI_SetupResult setupForRender(
117  const GUI_DisplayOption &opts,
118  bool show_selections,
119  GR_DecorationOverride selmask_dec,
120  GR_DecorationOverride &sel_dec);
121 
122  // This is a stripped down version of setupForRender() when the viewer is
123  // showing more than 1 viewport. The first viewport rendered does a full
124  // setupForRender(), and subsequent viewports do fastSetupForRender(), since
125  // many things do not change.
126  bool fastSetupForRender(GUI_DisplayOption &opts);
127 
128  // updateForRender() is called in serial. It does all the GL updating based
129  // on the precomputed results in setup().
130  void updateForRender(
131  RE_Render *r,
132  GUI_DisplayOption &opts,
133  RE_LightList *lights,
134  GR_DecorationOverride selmask_dec,
135  const char *view_name,
136  const GR_FrustumList &view_frustums,
137  bool &needs_alpha,
138  bool normal_update,
139  GR_UpdateReason additional_reasons);
140 
141  virtual void cleanupAfterRender(RE_Render *r);
142 
143  // An update is still pending on this look's geoemtry.
144  void updatePending(bool up) { myUpdatePending = up; }
145  bool isUpdatePending() const { return myUpdatePending; }
146 
147  // Materials still need updating on this look (textures).
149  { myMatUpdatePending = up; }
151  { return myMatUpdatePending; }
152 
153  // called when this look is no longer displayed, but kept around for a short
154  // time in case it might be displayed in the future
155  void retire();
156  bool isRetired() const { return myRetiredFlag; };
157  void reactivateRetired();
158 
159  // called when temporarily hidden, such as as display flag off.
160  void hide();
161 
162  // appends the contained geometry objects to 'geos'.
163  void getGeometryRenders(
166  int geo_index = -1);
167  void setSingleGeometryRender(OP_Node *node);
168  void resetGeometryRender();
169 
170  // Set selection data to be displayed with this geometry.
171  const UT_Array<GUI_GroupDataHandle> &getSelectData(int geo_index) const;
172  void addSelectData(GUI_GroupDataHandle select_data,
173  int geo_index);
174  void clearSelectData();
175  bool hasSelectData() const;
176 
177  // This method determines whether this detail look should be rendered
178  // for picking. It only checks if it is potentially pickable, but does
179  // not check if it currently being drawn. This only refers to the component
180  // level picking present in SOPs. For object picking, check the isPickable()
181  // flag on the getObject() node.
182  virtual bool isPickable() const;
183 
184  // Allows for custom pick priorities. 0 is normal, <0 low, >0 higher.
185  virtual bool hasPickPriority() const { return false; }
186  virtual bool getPickPriority(const GR_PickRecord &pick,
187  int & /*priority*/) const { return false; }
188 
189  // This method checks if this detail look is even rendered given the
190  // specified display options.
191  virtual bool isVisible(const GUI_DisplayOption &dopt) const;
192 
193  // Returns true if any of the contained details are lit.
194  bool areAnyLit() const
195  { return drawLit() && !isWireframeOnly(); }
196 
197  // returns true if any of the contained details are unlit.
198  bool areAnyUnlit() const { return myHasUnlitGeometry; }
199 
200  // returns true if any of the contained details have transparency.
201  bool hasTransparency() const;
202 
203  // returns true if any of the materials are reflective.
204  bool hasReflectiveMaterial() const;
205 
206  // returns a bitfield of decorations supported by all the GR_Primitives in
207  // this look.
208  int64 getPrimDecorMask() const { return myDecorMask; }
209 
210  // This look will not free the detail, it is up to the user
211  int setDetailHandle(GU_DetailHandle handle);
212  virtual int getNumDetailHandles() const; // inlined below
213  virtual GU_DetailHandle getDetailHandle(int i) const;
214  virtual UT_Matrix4D getDetailXform(int i) const;
215  virtual void appendDOPDataName(UT_String &str, int i,
216  bool descriptive) const;
217  virtual const SIM_Data *getDOPData(int i) const;
218  virtual const SIM_RootData *getDOPRootData(int i) const;
219  virtual bool getIsDetailTempSelected(int i) const;
220  // Get world space position
221  virtual UT_Vector4F getDetailPosition(int i) const;
222  virtual void getDetailName(UT_String &name, int i) const;
223  virtual void getDetailPath(UT_String &path, int i) const;
224  virtual void getDetailDescriptiveName(UT_String &name,
225  int i) const;
226  virtual void getDetailDescriptivePath(UT_String &path,
227  int i) const;
228  void signalNodeSelectionChanged(int i) const;
229 
230  virtual void setTempComponentSelection(
232  virtual GU_SelectionHandle getTempComponentSelection(int i) const;
233 
234  virtual void releaseAllTempComponentSelections();
235 
237  { myEnableDOPDisplay = enable; }
238  bool getEnableDOPDisplay() const
239  { return myEnableDOPDisplay; }
240  void setIsChosenDopnet(bool ischosen)
241  { myIsChosenDopnet = ischosen; }
242  bool getIsChosenDopnet() const
243  { return myIsChosenDopnet; }
244 
245  bool hasUserSelection() const;
246 
247  void setLightArray(RE_Light *lights[], int nLights = 0);
248 
249  void setGlobalLightArray(const UT_ValArray<RE_Light *> &lts,
250  bool headlight);
251  void enableAllLights();
252 
253  int getNumLights() const { return myLights.entries(); }
254  RE_Light *getLight(int i) const { return myLights(i); }
255  const UT_ValArray<RE_Light *> &getLights() const { return myLights; }
257  { return myEnabledLights; }
258 
259  static RE_Light *getGlobalHeadlight();
260 
261  void setUseWireColor(int c);
262  void setWireColor(const UT_Color &clr);
263 
264  // The id passed in here may be either a node id or a "guide" id set by
265  // the OP3D_GuideList on each piece of guide geometry.
266  virtual UT_Color getWireColor(int id) const
267  { return myWireColor; }
268 
269  // Methods to manage the view matrix, the user may use any of the
270  // UT_Matrix4 methods to transform the matrix.
271  void setXform(const UT_Matrix4D &mat)
272  { myXform = mat; myXformDirty = true; }
274  { return myXform; }
276  { myPivot = pivot; }
277 
278  void setAllowShadingOpenCurves(bool val);
279  bool shadeOpenCurves() const
280  { return myFlag.shade_open_curves; }
281 
282  void setDisplayAsSubdiv(bool val);
283 
284  // Methods to handle the look of the detail drawn.
285  void copyFlagsFrom(const GUI_DetailLookPtr &look);
286 
287  virtual void setDetailDisplay(bool display)
288  {
289  if(!myFlag.overrideDisplay)
290  {
291  if(myFlag.display != display)
292  myDisplaySetDirty= true;
293  myFlag.display = display;
294  }
295  }
296 
297  void setGeometry(bool enable) { myFlag.isGeometry = enable; }
298  void setShowAxes(bool show_axes) { myFlag.showAxes = show_axes; }
299  void setPicking(bool picking)
300  { myFlag.shouldPick = picking; }
301 
302  void setRender(bool render) { myFlag.render = render; }
303  void setTemplate(bool templated)
304  {
305  if(myFlag.templated!=templated)
306  myDisplaySetDirty=true;
307  myFlag.templated = templated;
308  }
309  void setFootprint(bool footprint)
310  { if(myFlag.footprinted!=footprint)
311  myDisplaySetDirty=true;
312  myFlag.footprinted = footprint; }
313  void setHighlight(bool highlight)
314  { myDisplaySetDirty |= (myFlag.highlighted != highlight);
315  myFlag.highlighted = highlight; }
316  void setXray(bool xray)
317  { myFlag.xray = xray; }
318  void setTargetOutput(bool target_output)
319  { if(myFlag.targetoutput !=target_output)
320  myDisplaySetDirty=true;
321  myFlag.targetoutput = target_output; }
322  void setCurrentOutput(bool current_output);
323  void setDrawLit(int onoff); // it's a bit more complicated now
324  void setDrawCookComponentSelection(bool enable);
325  void setSnappable(int onoff) { myFlag.snappable = onoff; }
326  void setSecondarySelection(int onoff);
327  void setObjSelection(bool obj_sel);
328  void setObjCurrent(bool obj_current);
329  void setObjSelectionHint(bool obj_sel_hint);
330  virtual void setObjGhost(bool obj_ghost, OP_Node *for_node);
331  void setWireframeOnly(bool wireframe_only)
332  { myFlag.wireframeOnly = wireframe_only; }
333  void setActiveModel(bool active_model)
334  {
335  if(myFlag.active_model != active_model)
336  {
337  myDisplaySetDirty = true;
338  myFlag.active_model = active_model;
339  }
340  }
341  // Is a DM_Drawable look
342  void setIsDrawableLook(bool dr) { myDrawableFlag = dr; }
343  bool isDrawableLook() const { return myDrawableFlag; }
344 
345  static void setUVObject(OP_Node *object);
346  bool isUVObject() const;
347 
348  void setOnionSkinning(int onion_skin_state);
349  bool isOnionSkinning() const { return myFlag.onion_skin; }
350  bool isOnionSkinDeformation() const { return myFlag.onion_skin_deform;}
351 
352  void onionSkinRender(RE_Render *r, GUI_DisplayOption &disp_opt,
353  int nsamples);
354 
355 
356  // Frustum culling is enabled by default.
357  void useFrustumCulling(bool frust_cull)
358  { myFlag.use_frustum_culling = frust_cull; }
359  bool usesFrustumCulling() const
360  { return myFlag.use_frustum_culling && !myFlag.onion_skin
361  && !myLastPointInstanceState &&
362  getUsesGeoRenderInstancing(); }
363 
364  virtual void applyBundleToDisplayedObjects( OP_Bundle *bdl, int object_vis_change_count);
365 
366  // The following methods allow the user to set the display flag while
367  // caching the old value, and resetting it back later.
368  virtual void setDisplaySavingPrevValue(int onoff)
369  {
370  myFlag.prevDisplay = myFlag.display;
371  myFlag.display = onoff;
372  myFlag.overrideDisplay = true;
373  }
374 
376  {
377  myFlag.display = myFlag.prevDisplay;
378  myFlag.overrideDisplay = false;
379  }
380 
381  // this is not the underlying node's display flag state.
382  bool isDetailDisplayOn() const; // inlined below
383 
384  bool getShowAxes() const { return myFlag.showAxes; }
385  bool isGeometry() const { return myFlag.isGeometry; }
386  bool isSymbolicGeometry() const { return myFlag.isSymGeo; }
387  bool isPickingOn() const { return myFlag.shouldPick; }
388  bool isRenderOn() const { return myFlag.render; }
389  bool isTemplated() const { return myFlag.templated; }
390  bool isFootprinted() const { return myFlag.footprinted; }
391  bool isHighlighted() const { return myFlag.highlighted; }
392  virtual bool isXray() const { return myFlag.xray || myFlag.geoxray || myIsXRay; }
393  bool isTargetOutput() const { return myFlag.targetoutput; }
394  bool isCurrentOutput() const { return myFlag.currentoutput; }
395  virtual bool isGuide() const { return false; }
396  virtual bool useWireColor(int node_id) const { return myFlag.usewireclr; }
397  bool drawLit() const { return myFlag.drawLit; }
398  bool displayAsSubdiv() { return myFlag.displayAsSubdiv; }
400  { return myFlag.drawCookComponentSelection; }
401  bool isSnappable() const { return myFlag.snappable; }
402  bool isSecondarySelection() const { return myFlag.secondarySelection; }
403  bool isObjSelection() const { return myFlag.objSelection; }
404  bool isObjCurrent() const { return myFlag.objCurrent; }
405  bool isObjSelectionHint() const { return myFlag.objSelectionHint; }
406  bool isObjGhost() const { return myFlag.objGhost; }
407  bool isWireframeOnly() const { return myFlag.wireframeOnly; }
408  bool isActiveModel() const { return myFlag.active_model; }
409  bool isPointInstanced() const { return myHasPointInstancing; }
410  bool hasInstanceFile() const { return myHasInstanceFile; }
412  { return myInstanceUseTransform; }
413 
414  bool needsAlphaPass() const
415  { return myFlag.needsAlphaPass; }
416  void setNeedsAlphaPass(bool e)
417  { myFlag.needsAlphaPass = e; }
418 
419  // Flag as a deleted look, so that it can be deleted rather than cached.
420  void setIsDeleted() { myFlag.being_deleted = true; }
421  bool isDeleted() { return myFlag.being_deleted; }
422 
423  // Weak flag that affects only GUI_DetailLook::isVisible()
424  bool forceHidden() const { return myFlag.forceHidden; }
425  void setForceHidden(bool on)
426  {
427  if(myFlag.forceHidden != on)
428  {
429  myDisplaySetDirty= true;
430  myFlag.forceHidden = on;
431  }
432  }
433 
434  // If true, this flag forces GUI_DetailLook to be a UVObject.
435  bool forceAsUVObject() const
436  {
437  return myFlag.forceAsUVObject;
438  }
439  void setForceAsUVObject(bool on)
440  {
441  myFlag.forceAsUVObject = on;
442  }
443 
444  bool castShadows() const { return myFlag.castShadows; }
445  void setCastShadows(bool on)
446  {
447  if(myFlag.castShadows != on)
448  {
449  myDisplaySetDirty= true;
450  myFlag.castShadows = on;
451  }
452  }
453 
454  // Set information about which geometry groups to color.
455  const UT_StringHolder &showGroupMask() const;
456  void setShowGroupMask(const UT_StringHolder &mask);
457  GA_GroupType showGroupType() const;
458  void setShowGroupType(GA_GroupType group_type);
459  int showGroupColorVersion() const;
460  void setShowGroupColorVersion(int version);
461 
462  int getBoundingBox2D(UT_BoundingBox &bbox,
463  const char *name,
464  int use_vertex) const;
465  int getBoundingBox3D(UT_BoundingBox &bbox,
466  const UT_Matrix3R *rot) const;
467 
468  void updateBBox();
469  void invalidateBBox();
470  const UT_BoundingBox &worldBBox();
471 
472  // Viewport type mask (PERSP, TOP, UV, etc)
473  void setViewportMask(unsigned mask)
474  { myViewportMask = mask; }
475  unsigned int getViewportMask() const
476  { return myViewportMask; }
477 
478  // Per-Viewport display. ID is the viewport's unique ID.
479  bool shownInViewport(int viewport_id) const;
480  void showInViewport(int viewport_id);
481  void showInAllViewports();
482 
484  int serial, int serial2, int id)
485  {
486  disp.common().setViewSerialNum(serial, serial2, id);
487  }
488 
489  // return the display set that this object belongs to.
491  {
492  if(!myDisplaySetDirty)
493  return myDisplaySet;
494  return privGetDisplaySetType();
495  }
496 
498  { return privGetDisplaySetType(); }
499 
500 
501  void renderObjectName(RE_Render *r,
502  GUI_DisplayOption *dispopt);
503  virtual void renderOrQueueObjectAxes(UT_Vector3FArray &axes,
504  UT_Vector3FArray &pivots);
505  static void renderQueuedObjectAxes(RE_Render *r,
506  GUI_DisplayOption *dispopt,
507  const UT_Vector3FArray &axes,
508  const UT_Vector3FArray &pivots);
509 
510  // The global chosen dopnet is set to filter out the drawing of geometry
511  // flagged as originating from this dopnet.
512  static void setGlobalChosenDopnet(OP_Node *dopnet)
513  {
514  if( dopnet )
515  {
516  dopnet->getFullPath(ourChosenDopnetPath);
517  ourChosenDopnetPathLen = ourChosenDopnetPath.length();
518  }
519  else
520  {
521  ourChosenDopnetPath = 0;
522  ourChosenDopnetPathLen = 0;
523  }
524  }
525  static const char *getGlobalChosenDopnetPath()
526  {
527  return (const char *) ourChosenDopnetPath;
528  }
529 
530  static bool matchesChosenDopnetPath(const char *path)
531  {
532  if( ourChosenDopnetPathLen > 0 &&
533  !strncmp(ourChosenDopnetPath, path, ourChosenDopnetPathLen) &&
534  (path[ourChosenDopnetPathLen] == ':' ||
535  path[ourChosenDopnetPathLen] == '\0') )
536  return true;
537  return false;
538  }
539 
540  // Used to assign a temporary ID to the look.
541  void setLookID(int id) { myID = id; }
542  int getLookID() const { return myID; }
543 
544  // Get/Set the object's viewport LOD
545  GEO_ViewportLOD getObjectLOD() const { return myObjectLOD; }
547  { myObjectLOD = lod; }
548 
549  void useObjectMaterials(bool use_obj_mat);
550  bool getAssignedMaterials(UT_Array<OP_Node *> &nodes) const;
551 
552  void setShowMaterials(bool show)
553  { myFlag.showMaterials = show; }
554  bool showMaterials() const
555  { return myFlag.showMaterials; }
556 
557  virtual bool isTimeDependent(fpreal t);
558  bool areInstancesTimeDependent(fpreal t);
559  virtual int64 getVersion();
560  void bumpVersion() { myLookVersion++; }
561 
562  // The name of the actively rendering or updating viewport
563  static void setActiveViewport(const char *name, int id);
564  // viewname (persp1)
565  static const char *getActiveViewport();
566  // viepwort unique id
567  static int getActiveViewportId();
568  // viewname/Material setup
569  static const char *getActiveViewportMatString();
570 
571 
572  static void visibleViewportTypes(bool view_3d, bool view_2d);
573  static bool hasVisible3D();
574  static bool hasVisibleUV();
575 
576  static void visibleUVAttribs(UT_StringArray &attribs);
577  static const UT_StringArray &visibleUVAttribs();
578  static int64 visibleUVAttribSerial();
579 
580  enum { VIEW_3D = 0x1, VIEW_2D = 0x2 }; // for the masks
581  static void visibleViewportBoundaries(
582  bool bound_3d,
583  UT_StringArray &bound_3d_uvs,
584  UT_Array<std::pair<UT_StringHolder,int> > &uvs);
585  static bool hasVisibleBoundaries();
586  static bool visible3DBoundary();
587  static const UT_StringArray &visible3DBoundariesInUV();
588  // uv name, view mask
590  &visibleUVBoundaries();
591 
593  { return myActiveVisualizers; }
595  { return myActiveVisualizers.entries(); }
596  void appendActiveVisualizer(int vis_id)
597  { myActiveVisualizers.append(vis_id);
598  myCollectVisPrimitives.append(0); }
600  {
601  myActiveVisualizers.clear();
602  myCollectVisPrimitives.clear();
603  }
605  { return myCollectVisPrimitives(i); }
607  { myCollectVisPrimitives(i) = prim; }
608 
609  void requireErrorCheck() { myFlag.errorsChecked = false; }
610  void checkForErrors();
611  int64 getNodeErrorID() const { return myOpErrorPosted; }
612 
613  void setRedrawValue(UI_Value *redraw)
614  { myRedrawValue = redraw; }
616  { if(myRedrawValue) myRedrawValue->changed(NULL); }
617 
619  {
620  myFlag.visualizerCheck = true;
621  myFlag.needVisualizerSetup = false;
622  }
623  void needVisualizerSetup(bool setup)
624  {
625  myFlag.visualizerCheck = false;
626  myFlag.needVisualizerSetup = setup;
627  }
628  bool runVisualizerSetup() const
629  {
630  return (myFlag.needVisualizerSetup ||
631  myFlag.visualizerCheck);
632  }
633 
634  virtual const PXL_Raster *getImage(RE_Render *) { return nullptr; }
635 
636  // Wrapper class to avoid sprintf's when not recording
638  {
639  public:
641  {
642  // Early exit if we're not recording
644  bool record_viewport = perf->isRecordingViewportStats();
645  bool record_memory = perf->isRecordingMemoryStats();
646  if (!record_viewport && !record_memory)
647  return;
648 
649  const char *
651  const char *
652  look_name = look.getName();
653 
654  if (record_viewport)
655  {
656  setTimedEventId_(
658  viewport_name, look_name, UT_PERFMON_3D_VIEWPORT));
659  }
660 
661  if (record_memory)
662  {
663  setMemoryEventId_(
665  viewport_name, look_name, UT_PERFMON_3D_VIEWPORT));
666  }
667  }
668  };
669 
670 protected:
671  virtual ~GUI_DetailLook();
672 
673  void cacheNodePtrs();
674 
675  // Multi-object instancing
676  void initInstanceTable();
677  GUI_GeoRender *addInstance(GU_ConstDetailHandle cgdh,
678  const char *name,
679  const UT_Matrix4D &xform,
680  int64 version,
681  int instance_index,
682  int object_id,
683  int inst_object_id,
684  bool is_guide,
685  bool time_dep);
686  void finalizeInstanceTable();
687 
688  using gui_CachedInstGeo = std::pair<GUI_GeoRender *, bool>;
689 
690  bool createObjectInstance(const char *instance_path,
691  int64 base_version,
692  fpreal t,
693  gui_Instance &instance,
694  OBJ_Node *instancer,
696  bool rel_to_sop);
697  void markGeoForRemoval(GUI_GeoRender *gr);
698  void removeDeletedGeos();
699  int64 computeInstanceVersion(const GU_Detail *dtl);
700 
701  // Indicates whether instancing should be implemented using the
702  // GUI_GeoRender instancing capabilities. If false, GUI_GeoRenderShared
703  // objects are used to instance the geometry without true OGL instancing.
704  virtual bool getUsesGeoRenderInstancing() const
705  { return true; }
706 
707  // End multi-object instancing
708  GUI_SetupResult setupAllGeos(const GUI_DisplayOption &disp_opt,
709  bool show_selections,
710  GR_DecorationOverride selmask_dec,
711  GR_DecorationOverride &sel_dec);
712 
713  virtual GUI_GeoRender *getOrCreateGeometryRender(int index);
714 
715  void setXRayOverride(bool xray) { myIsXRay = xray; }
716 
721 
724 
725 private:
726 
727  void generateObjectName(RE_Render *r,
728  GUI_DisplayOption *dispopt,
729  UT_String name,
730  int geo_index,
731  GR_DecorFontSize fontsize,
732  RE_Geometry &geo);
733  bool setupPointInstancing(bool show_selections,
734  GR_DecorationOverride selmask_dec,
735  GR_DecorationOverride &select_dec,
736  fpreal instance_fract,
737  int limit);
738  GUI_DisplaySetType privGetDisplaySetType() const;
739 
740  void updateInstancingStatus();
741  GUI_GeoRender * createGeoRender(int index,const char *opt_suffix=NULL);
742 
743  GUI_GeoRender *checkForDetailCaching(GUI_GeoRender *geo);
744  void freeCachedDetails();
745  void freeDeletedCachedDetails();
746 
747  int getNumOnionSkins() const;
748  const GU_DetailHandle &getOnionSkinDetail(int index) const;
749  GUI_SetupResult processSkins(const GUI_DisplayOption &dopt);
750  void addOnionSkin(OBJ_Node *obj, SOP_Node *sop,
751  fpreal skin_t, fpreal geo_t,
752  bool deforming,
753  bool is_pre_frame);
754  void clearOnionSkins();
755 
756  class GUI_DetailLookFlags
757  {
758  public:
759  GUI_DetailLookFlags()
760  {
761  showAxes = false;
762  render = true;
763  isGeometry = true;
764  isSymGeo = false;
765  shouldPick = true;
766  display = true;
767  templated = false;
768  footprinted = false;
769  highlighted = false;
770  xray = false;
771  geoxray = false;
772  targetoutput = false;
773  currentoutput = false;
774  usewireclr = false;
775  drawLit = true;
776  drawCookComponentSelection = true;
777  needsAlphaPass = false;
778  snappable = true;
779  secondarySelection = false;
780  objSelection = false;
781  objCurrent = false;
782  objSelectionHint = false;
783  objGhost = false;
784  wireframeOnly = false;
785  prevDisplay = true;
786  prevShouldPick = true;
787  overrideDisplay = false;
788  displayAsSubdiv = false;
789  shaders_used = false;
790  active_model = false;
791  being_deleted = false;
792  shade_open_curves = false;
793  onion_skin = false;
794  onion_skin_deform = false;
795  use_frustum_culling = true;
796  errorsChecked = false;
797  visualizerCheck = false;
798  needVisualizerSetup = true;
799  forceHidden = false;
800  forceAsUVObject = false;
801  showMaterials = true;
802  castShadows = true;
803  }
804 
805  bool showAxes:1, // draw the axes of the detail
806  isGeometry:1, // renderable
807  isSymGeo:1, // symbolic geo only (no materials)
808  render:1, // render the detail
809  shouldPick:1,
810  display:1, // display the detail
811  templated:1,
812  footprinted:1,
813  highlighted:1, // Node has the highlight flag set
814  xray:1, // display wireframe within other geo
815  geoxray:1, // Xray drawing enabled by an attribute on the geometry.
816  targetoutput:1, // display sop when in view current
817  // mode
818  currentoutput:1, // current sop when in view current
819  // mode and the display flag is on a
820  // different sop.
821  usewireclr:1, // Override default wire color
822  drawLit:1, // In shaded mode, draw shaded
823 drawCookComponentSelection:1, // Draw the GU cook component selection
824  needsAlphaPass:1, // requires a second pass
825  snappable:1, // is the detail snappable
826  secondarySelection:1, // Draw a secondary selection
827  objSelection:1, // object selection
828  objCurrent:1, // object current flag
829  objSelectionHint:1, // hint that object makes good selection
830  objGhost:1, // ghosted object
831  wireframeOnly:1, // draw in wireframe only
832  prevDisplay:1, // cached value of the previous value of the display flag.
833  prevShouldPick:1, // cached value of the previous value of the pick flag.
834  overrideDisplay:1, // don't allow changes to the display
835  displayAsSubdiv:1, // draw as subdivision.
836  shaders_used:1, // Shaders have been used on the object
837  active_model:1, // Use SOP-level display sets
838  being_deleted:1, // We are in the process of deletion
839  shade_open_curves:1, // Open curves are light-shaded
840  onion_skin:1, // Draw faded images before/after
841  onion_skin_deform:1, // Use deformation onion skinning
842  use_frustum_culling:1, // Frustum culling is allowed
843  errorsChecked:1, // Errors checked after cook
844  visualizerCheck:1, // Check for visualizer setup
845  needVisualizerSetup:1, // Requires visualizer setup
846  forceHidden:1, // Force Hidden flag
847  forceAsUVObject:1, // Force the look to be a uv object.
848  showMaterials:1, // Display look with materials
849  castShadows:1; // The look can cast shadows
850  };
851  GUI_DetailLookFlags myFlag;
852 
853  UT_StringHolder myShowGroupMask;
854  GA_GroupType myShowGroupType;
855  int myShowGroupColorVersion;
856  GU_DetailHandle myDetailHandle;
857  UT_Vector4I myDetailVersion;
858  GUI_GUSelectionProxyHandle myTempComponentSelection;
859  UT_Array<GU_DetailHandle> myOnionSkinDetails;
860 
861  // Override the wireframe display color.
862  UT_Color myWireColor;
863 
864  int myObjectID;
865  int mySopID;
866  OP_Node *myCachedObject;
867  OP_Node *myCachedSop;
868  UT_String myDetailName;
869  int myID;
870  GEO_ViewportLOD myObjectLOD;
871  bool myIsXRay;
872  bool myIsOnionSkin;
873  UT_String myInstanceObjectRef;
874 
875  UT_ValArray<RE_Light *> myLights;
876  UT_ValArray<RE_Light *> myEnabledLights;
877 
878  unsigned int myViewportMask;
879  bool myEnableDOPDisplay;
880  bool myIsChosenDopnet;
881  bool myNullDetailFlag;
882  bool myRetiredFlag;
883  bool myInitializedFlag;
884  bool myCopyDetailFlag;
885  bool myDrawableFlag;
886 
887  mutable bool myDisplaySetDirty;
888  mutable GUI_DisplaySetType myDisplaySet;
889 
890  fpreal myPrevInstanceFract;
891  int myPrevInstanceLimit;
892  int myInstanceFractSerial;
893  int64 myPointInstanceVersion;
894  int myInstanceXformVersion;
895  fpreal myInstanceTime;
896  int myInstanceObjectID;
897  bool myHasInstancing;
898  bool myHasPointInstancing;
899  bool myInstanceUseTransform;
900  bool myHasTransparentPrimitives;
901  bool myLastPointInstanceState;
902  bool myHasInstanceFile;
903  bool myXformDirty;
904  bool myDetailDirty;
905  UT_Matrix4D myXform;
906  UT_Vector3F myPivot;
907  int64 myOpErrorPosted;
908  int64 myLookVersion;
909 
910  // Variable geometry Instancing
912  int myGeoCountId;
913  const GU_Detail *myTempLastDetail;
914  GUI_GeoRender *myTempLastGeo;
915 
916  // Cached details for cached playback (ie cache SOP)
917  UT_Map<exint, GUI_GeoRender *> myCachedDetailTable;
918  bool myCachingDetails;
919  int64 myCacheSopID;
920  int64 myCacheSopSerial;
921 
922  bool myHasUnlitGeometry;
923  int64 myDecorMask;
924  bool myUpdatePending;
925  bool myMatUpdatePending;
926 
927  exint myVisUpdateTime; // last visualization-triggered
928  // update time (visualization
929  // clock measurement)
930  exint myVisUpdateVersion; // version at the time of last
931  // visualization-triggered
932  // update
933 
934  UT_IntArray myActiveVisualizers; // unique ids of visualizers
935  // currently active for look
936 
938  myCollectVisPrimitives;
939 
940  UT_Array<GUI_GeoRender *> myGeosToRemove;
941 
942  UT_BoundingBox myWorldBBox;
943  UT_UniquePtr<UT_Set<int> > myViewportVisibility;
944 
945  class gui_OnionSkinDetail
946  {
947  public:
948  gui_OnionSkinDetail(const GU_DetailHandle &dh)
949  : myDetail(dh), myRender(NULL), myUsedFlag(true)
950  {
951  myDetail.addPreserveRequest();
952  }
953  ~gui_OnionSkinDetail();
954 
955  GU_DetailHandle myDetail;
956  GUI_GeoRender *myRender;
957  bool myUsedFlag;
958  };
959  typedef std::pair<exint,int64> gui_OnionSkinId;
960  typedef UT_Map<gui_OnionSkinId, gui_OnionSkinDetail *> gui_OnionSkins;
961  gui_OnionSkins myOnionSkins;
962 
963  class gui_OnionSkinLayer
964  {
965  public:
966  gui_OnionSkinLayer(gui_OnionSkinId id, fpreal t, const UT_Matrix4D &mat, bool pre)
967  : myDetailID(id), myTime(t), myRender(NULL),
968  myTransform(mat), myIsPreFrame(pre) {}
969 
970  gui_OnionSkinId myDetailID;
971  fpreal myTime;
972  GUI_GeoRender *myRender;
973  UT_Matrix4D myTransform;
974  bool myIsPreFrame;
975  };
976  UT_Array<gui_OnionSkinLayer *> myOnionSkinLayers;
977 
978  class CachedDetailPos {
979  public:
980  CachedDetailPos()
981  : myPos(0,0,0,1)
982  , myCacheCount(-1)
983  , myUniqueId(-1)
984  {}
985 
986  CachedDetailPos(const GU_Detail *detail)
987  {
988  myCacheCount = detail ? detail->getMetaCacheCount() : -1;
989  myUniqueId = detail ? detail->getUniqueId() : -1;
990  }
991 
992  void computePosition(const GU_Detail *detail)
993  {
994  if(detail)
995  {
996  UT_BoundingBox bbox;
997  detail->getBBox(bbox, UT_Matrix4R::getIdentityMatrix());
998 
999  UT_Vector3 point3 = bbox.center();
1000  myPos = UT_Vector4F(point3.x(), point3.y(), point3.z(), 1.0);
1001  }
1002  }
1003 
1004  bool operator==(const CachedDetailPos& p)
1005  {
1006  return myCacheCount == p.myCacheCount
1007  && myUniqueId == p.myUniqueId;
1008  }
1009 
1010  const UT_Vector4F& position() { return myPos; }
1011 
1012  private:
1013  UT_Vector4F myPos;
1014  int myCacheCount;
1015  int myUniqueId;
1016  };
1017  // mutable because these are cached positions
1018  mutable UT_ValArray<CachedDetailPos> myDetailPositions;
1019 
1020  static RE_Light *theHeadlight;
1021 
1022  static UT_String ourChosenDopnetPath;
1023  static int ourChosenDopnetPathLen;
1024  static bool ourPickDisplayListUsedFlag;
1025 
1026  UI_Value *myRedrawValue;
1027  SYS_AtomicInt32 myRefCount;
1028 };
1029 
1030 static inline void intrusive_ptr_add_ref(GUI_DetailLook *d) { d->incref(); }
1031 static inline void intrusive_ptr_release(GUI_DetailLook *d) { d->decref(); }
1032 
1033 inline int
1035 {
1036  return myNullDetailFlag ? 0 : 1;
1037 }
1038 
1039 inline OP_Node *
1041 {
1042  if(myCachedObject)
1043  return myCachedObject;
1044  if(myObjectID != OP_INVALID_NODE_ID)
1045  return OP_Node::lookupNode(myObjectID);
1046  return NULL;
1047 }
1048 
1049 inline OP_Node *
1051 {
1052  if(myCachedSop)
1053  return myCachedSop;
1054  if(mySopID != OP_INVALID_NODE_ID)
1055  return OP_Node::lookupNode(mySopID);
1056  return NULL;
1057 }
1058 
1059 inline OP_Node *
1061 {
1062  OP_Node *node = getObject();
1063  if(!node)
1064  {
1065  node = getSop();
1066  if(node)
1067  return node->getCreator();
1068  }
1069  return node;
1070 }
1071 
1072 inline int
1074 {
1076  return mySopID;
1077  else
1078  return myObjectID;
1079 }
1080 
1081 inline bool
1083 {
1084  if(myFlag.display)
1085  {
1086 #if UT_ASSERT_LEVEL > 2
1087  if((myObjectID == OP_INVALID_NODE_ID || OP_Node::lookupNode(myObjectID))
1088  && (mySopID == OP_INVALID_NODE_ID || OP_Node::lookupNode(mySopID)))
1089  return true;
1090  UT_ASSERT_MSG(!"Stale GUI_DetailLook: ", myDetailName);
1091 #else
1092  return true;
1093 #endif
1094  }
1095  return false;
1096 }
1097 
1098 
1099 // UTformat support.
1100 GUI_API size_t format(char *buffer, size_t buffer_size, const GUI_DetailLook &v);
1101 
1102 
1103 #endif
static const char * getActiveViewportMatString()
static bool matchesChosenDopnetPath(const char *path)
virtual bool getUsesGeoRenderInstancing() const
int64 getNodeErrorID() const
void setTemplate(bool templated)
void setXray(bool xray)
virtual const PXL_Raster * getImage(RE_Render *)
const UT_ValArray< RE_Light * > & getLights() const
void setPivot(const UT_Vector3F &pivot)
bool usesFrustumCulling() const
void materialUpdatePending(bool up)
bool areAnyLit() const
GLboolean enable
Definition: glew.h:2750
OP_Node * getObject() const
int getVersion(int version)
Definition: ImfVersion.h:86
bool castShadows() const
void setForceAsUVObject(bool on)
virtual bool isObjectList() const
bool getIsChosenDopnet() const
Unsorted map container.
Definition: UT_Map.h:107
bool isTemplated() const
void setNeedsAlphaPass(bool e)
void setCollectVisPrimitive(int i, GR_Primitive *prim)
UT_API UT_Performance * UTgetPerformance(bool create=true)
GR_DecorationOverride
Definition: GR_Defines.h:203
int numActiveVisualizers() const
void setSnappable(int onoff)
bool getBBox(UT_BoundingBox *bbox, const GA_PrimitiveGroup *g=nullptr) const
UT_SharedPtr< GUI_GUSelectionProxy > GUI_GUSelectionProxyHandle
void setShowMaterials(bool show)
bool hasInstanceFile() const
bool useInstancerObjTransform() const
void setXform(const UT_Matrix4D &mat)
bool isPointInstanced() const
bool forceAsUVObject() const
void setFootprint(bool footprint)
bool isDetailDisplayOn() const
bool drawLit() const
bool isSymbolicGeometry() const
const GLfloat * c
Definition: glew.h:16631
UT_IntrusivePtr< GUI_DetailLook > GUI_DetailLookPtr
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GA_API const UT_StringHolder rot
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:53
void setRedrawValue(UI_Value *redraw)
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:657
int64 exint
Definition: SYS_Types.h:125
void setViewSerialNum(int num, int num_2d, int id)
void setForceHidden(bool on)
int startTimedViewportDrawEvent(const char *viewport_name, const char *draw_event_name, UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)
bool isInitialized() const
bool isFootprinted() const
bool isObjCurrent() const
bool isDrawableLook() const
bool displayAsSubdiv()
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual bool needsOverlayRender()
#define OP_INVALID_NODE_ID
Definition: OP_ItemId.h:24
OP_Network * getCreator() const
void requireErrorCheck()
GLdouble GLdouble t
Definition: glew.h:1403
bool isWireframeOnly() const
GUI_DisplaySetType
Context specific display options for geometry states.
int getVisualizedNodeId() const
void needVisualizerSetup(bool setup)
bool isRecordingMemoryStats() const
Return true if Houdini is recording memory stats.
virtual void setDisplaySavingPrevValue(int onoff)
virtual bool useWireColor(int node_id) const
IFDmantra you can see code vm_image_mplay_direction endcode When SOHO starts a render
Definition: HDK_Image.dox:266
bool isSnappable() const
void setHighlight(bool highlight)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
void setIsDrawableLook(bool dr)
void setLookID(int id)
bool getEnableDOPDisplay() const
void setViewportMask(unsigned mask)
#define UT_ASSERT_MSG(ZZ,...)
Definition: UT_Assert.h:156
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
UT_Matrix4D getXform() const
bool getShowAxes() const
const char * getFullPath(UT_String &str) const
Definition: PRM_ParmOwner.h:46
void setPicking(bool picking)
virtual bool isGuide() const
bool isRecordingViewportStats() const
Return true if Houdini is recording viewport draw stats.
OP_Node * getSop() const
Definition: core.h:760
void setGeometry(bool enable)
UT_Array< GUI_GeoRender * > myStashedGeoRenderShared
int getLookID() const
bool isSecondarySelection() const
void setCastShadows(bool on)
const GLint * attribs
Definition: glew.h:14698
GLint limit
Definition: glew.h:13230
bool isObjGhost() const
UT_Vector3T< T > center() const
bool showMaterials() const
#define GUI_API
Definition: GUI_API.h:10
bool isUpdatePending() const
GLint GLuint mask
Definition: glcorearb.h:124
const GR_CommonDispOption & common() const
static const UT_Matrix4T< fpreal > & getIdentityMatrix()
const GLdouble * v
Definition: glcorearb.h:837
bool isMaterialUpdatePending() const
void setObjectLOD(GEO_ViewportLOD lod)
virtual bool isDopGuide() const
UT_Array< GUI_SetupResult > myOnionSkinSetupResults
void setRender(bool render)
GLhandleARB obj
Definition: glew.h:6266
RE_Light * getLight(int i) const
GR_DecorFontSize
Definition: GR_Defines.h:184
bool isHighlighted() const
virtual void resetOverrideUsingSavedValue()
GR_UpdateReason
Definition: GR_Defines.h:295
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
GUI_SetupResult
virtual bool hasPickPriority() const
GLuint id
Definition: glcorearb.h:655
virtual UT_Color getWireColor(int id) const
bool isOnionSkinning() const
virtual int getNumDetailHandles() const
bool isPickingOn() const
void setTargetOutput(bool target_output)
bool isRenderOn() const
UT_Map< int, UT_Array< GUI_GroupDataHandle > > mySelectData
bool isGeometry() const
UT_SharedPtr< GU_Selection > GU_SelectionHandle
void setEnableDOPDisplay(bool enable)
bool isActiveModel() const
exint getUniqueId() const
Definition: GA_Detail.h:116
GLenum mode
Definition: glcorearb.h:99
GT_API const UT_StringHolder version
virtual bool isXray() const
GUI_DisplaySetType getDisplaySetType() const
UT_Array< GUI_GeoRender * > myGeoRender
GLuint GLfloat * val
Definition: glcorearb.h:1608
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
static void setGlobalViewSerial(GUI_DisplayOption &disp, int serial, int serial2, int id)
GR_Primitive * getCollectVisPrimitive(int i)
bool isRetired() const
virtual void setDetailDisplay(bool display)
unsigned int getViewportMask() const
void setActiveModel(bool active_model)
OP_Node * getShopsRelativeTo() const
UT_Vector4T< fpreal32 > UT_Vector4F
GEO_ViewportLOD
void clearActiveVisualizers()
GA_API const UT_StringHolder up
fpreal64 fpreal
Definition: SYS_Types.h:277
bool needsAlphaPass() const
GEO_ViewportLOD getObjectLOD() const
GUI_API size_t format(char *buffer, size_t buffer_size, const GUI_DetailLook &v)
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:159
GLuint index
Definition: glcorearb.h:786
bool isTargetOutput() const
void setXRayOverride(bool xray)
bool isObjSelectionHint() const
GR_LightingPass
Definition: GR_Defines.h:130
int64 getMetaCacheCount() const
Definition: GA_Detail.h:2343
int64 getPrimDecorMask() const
void resetVisualizerCheck()
GA_API const UT_StringHolder pivot
const UT_ValArray< RE_Light * > & getEnabledLights() const
void setInitialized()
bool drawCookComponentSelection() const
void updatePending(bool up)
static OP_Node * lookupNode(int unique_id, bool include_proxy=false)
Definition: OP_Node.h:698
void setIsChosenDopnet(bool ischosen)
bool runVisualizerSetup() const
static void setGlobalChosenDopnet(OP_Node *dopnet)
void useFrustumCulling(bool frust_cull)
bool forceHidden() const
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:153
std::pair< GUI_GeoRender *, bool > gui_CachedInstGeo
bool isOnionSkinDeformation() const
const UT_IntArray & getActiveVisualizers() const
bool areAnyUnlit() const
const char * getName() const
PerfMonAutoMatEvent(const GUI_DetailLook &look)
UT_Array< GUI_GeoRender * > myOnionSkinRenders
bool isObjSelection() const
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:655
GLboolean r
Definition: glcorearb.h:1222
static const char * getGlobalChosenDopnetPath()
void setWireframeOnly(bool wireframe_only)
virtual bool getPickPriority(const GR_PickRecord &pick, int &) const
void setShowAxes(bool show_axes)
bool isCurrentOutput() const
GLint lod
Definition: glcorearb.h:2765
UT_Array< GUI_SetupResult > mySetupResults
int getNumLights() const
void appendActiveVisualizer(int vis_id)
GUI_DisplaySetType updateDisplaySetType()
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:653
int startMemoryViewportDrawEvent(const char *viewport_name, const char *draw_event_name, UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)
bool shadeOpenCurves() const