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