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