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