HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_Primitive.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: GR_Primitive.h ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Base class for all primitives that Houdini is natively capable of
10  * rendering with OpenGL.
11  */
12 #ifndef GR_PRIMITIVE_H
13 #define GR_PRIMITIVE_H
14 
15 class GR_GeoRender;
16 class GR_DisplayOption;
18 class GT_Primitive;
19 
20 #include <SYS/SYS_AtomicInt.h>
21 #include <UT/UT_Array.h>
22 #include <UT/UT_IntrusivePtr.h>
23 #include <UT/UT_String.h>
24 #include <RE/RE_Types.h>
25 #include <RE/RE_RenderContext.h>
26 #include <GEO/GEO_PrimTypeCompat.h>
27 #include <GT/GT_Types.h>
28 #include <GT/GT_PrimitiveTypes.h>
29 #include <GT/GT_Handles.h>
30 #include <GT/GT_GEOPrimitive.h>
31 #include <GU/GU_Detail.h>
32 #include <GU/GU_OnionSkin.h>
33 #include "GR_Defines.h"
34 #include "GR_DecorationRender.h"
35 #include "GR_DrawParms.h"
36 #include "GR_ErrorManager.h"
37 #include "GR_PickSelection.h"
38 #include "GR_PickRender.h"
39 #include "GR_UpdateParms.h"
40 #include "GR_API.h"
41 
42 class GA_Primitive;
43 class GA_PointGroup;
44 class GA_EdgeGroup;
45 class GA_PrimitiveGroup;
46 class OP_Node;
47 class GT_RefineParms;
48 class GR_DisplayOption;
50 class GR_InstanceBuffer;
51 class GR_RenderInfo;
52 class GEO_Primitive;
53 
55 {
56 public:
57  /// Return a string version of this class's name
58  virtual const char *className() const = 0;
59 
60  /// The cache name is assigned to this primitive by the viewport. It can be
61  /// used as a base name for multiple objects by adding a suffix, but do not
62  /// change the base name. Returns true if the name changed.
63  bool setCacheName(const char *cache_name);
64 
65  /// returns true if the given GT primitive can be rendered by this primitive
66  /// if t==GT_GEO_PRIMITIVE, geo_type will be the geo type id and prim will
67  /// be non-NULL. If t is any other type, ph will be a valid GT primitive.
68  /// The primitives themselves can be used for more sophisticated matching.
69  virtual GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t,
70  int geo_type,
71  const GT_PrimitiveHandle &ph,
72  const GEO_Primitive *prim) = 0;
73 
74  /// This is called if this primitive is collecting multiple GEO or GT
75  /// primitives. It will be called just before the viewport starts iterating
76  /// through the primitives. The GR_Primitive should clear its list of
77  /// collected primitive IDs.
78  virtual void resetPrimitives() {}
79 
80  /// The base primitive type is usually NORMAL unless this is a packed type.
82  { return GR_BASE_PRIM_NORMAL; }
83 
84  /// Returns the contained instance prim. Will only be valid if
85  /// getBasePrimType() is not GR_BASE_PRIM_NORMAL.
87  { return GT_PrimitiveHandle(); }
88 
89  /// returns true if this primitive's type mask is part of "mask".
91  { return bool(mask & myGAPrimMask); }
92 
93  virtual void checkForDeferredDraw(RE_RenderContext r,
96  const GR_DrawParms &dp,
97  const UT_Matrix4D &proj_view,
98  const UT_Matrix4D &object,
99  const UT_Vector2F &min_proj_size,
100  bool &visible,
101  bool &defer);
102  // This function is implemented by GR_PrimPacked to track visibility of
103  // USD primitives based on purpose.
104  virtual bool isPrimVisible() const
105  { return true; }
106 
108  {
111  DISPLAY_VERSION_CHANGED
112  };
113 
114  /// Called when the geometry-related display options change, to determine if
115  /// an update is required. By default, no update is required. If the options
116  /// did change, return either DISPLAY_CHANGED, which will call update()
117  /// without bumping the display option version, or DISPLAY_VERSION_CHANGED,
118  /// which will bump the version.
119  GR_DispOptChange checkDisplayOptionChange(const GR_DisplayOption &opts);
120 
121 
122  /// If this primitive requires an update when the view changes, return true.
123  virtual bool updateOnViewChange(const GR_DisplayOption &) const
124  { return false; }
125 
126  /// called every time the metacount version is bumped on the GU_Detail.
127  void updatePrim(RE_RenderContext r,
128  const GT_PrimitiveHandle &primh,
129  const GR_UpdateParms &parms);
130 
131  /// If updateOnViewChange() returns true, this is called when the view
132  /// changes.
134  const GR_ViewUpdateParms &parms)
135  {}
136 
137  /// Update an array on the specified instance group. If instance group is
138  /// -1, array->getInstanceGroup() must specify a valid instance group.
139  /// If 'array' is null, it will be removed from the instances but
140  /// you must specify the instance_group and attrib_name.
141  virtual void updateInstanceGroup(const GR_InstanceBuffer *buffer,
142  int instance_group = -1);
143 
144  /// For primitives that may need updating if the GL state changes, this
145  /// hook allows you to perform a check if no update is otherwise required.
146  /// Return true to have checkGLState() called. Returning true from that
147  /// will trigger an update.
148  /// @{
149  virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const
150  { return false; }
152  const GR_DisplayOption &opts)
153  { return false; }
154  /// @}
155 
156  /// Main render call, which can be called several times in a redraw with
157  /// different render modes. Calls render to do the real work specialized
158  /// for each primitive type.
159  void draw(RE_RenderContext r,
160  GR_RenderMode render_mode,
161  GR_RenderFlags render_flags,
163 
164  /// Picking version of draw(). Calls renderPick to do the real work
165  /// specialized for each primitive type.
166  int drawPick(RE_RenderContext r,
167  const GR_DisplayOption *opt,
168  unsigned int pick_type,
169  GR_PickStyle pick_style,
170  bool has_pick_map);
171 
172  /// Called just before drawing our first decoration.
173  virtual void setupDrawDecorations(RE_RenderContext r);
174  /// Decoration version of draw(). Calls renderDecoration to do the real
175  /// work specialized for each primitive type.
176  void drawDecoration(RE_RenderContext r,
177  GR_Decoration decor,
178  const GR_DecorationParms &parms);
179 
180  /// called once per viewport draw, setup() before any renders are done, and
181  /// cleanup() after all are complete. There is a possibility that render()
182  /// may not be called at all.
183  /// @{
184  virtual bool setup(const GR_DisplayOption *)
185  { return true; }
186  virtual void cleanup(RE_RenderContext r) {}
187  /// @}
188 
189  /// Called just before ray tracing
190  void prepareForRayTrace(RE_RenderContext r,
191  int tag,
192  int light_id,
193  const UT_Matrix4F &obj_mat);
194 
195  /// return true if the primitive is in or overlaps the view frustum.
196  /// always returning true will effectively disable frustum culling.
197  /// bbox is an option bounding box which can be used for frustum testing.
198  virtual bool inViewFrustum(const UT_Matrix4D &objviewproj,
199  const UT_BoundingBoxD *bbox = nullptr)
200  { return true; }
201 
202  /// Similar to inViewFrustum, but also considers if the prim is too small
203  /// to render in the viewport. Also uses 32b FP precision for speed.
204  virtual bool isRasterizedInView(const UT_Matrix4F &objviewproj,
205  const UT_Vector2F &min_proj_size,
206  const UT_BoundingBoxF *bbox=nullptr);
207 
208  /// Return a bitfield of what decorations are supported by this primitive.
209  /// Set bit (1 << GR_Decoration) if that decoration is supported.
210  /// Not all primitives will support all decorations.
211  int64 supportedDecorations() { return myDecorMask; }
212 
213  /// Return true if this primitive supports drawing into a UV viewport.
214  virtual bool supportsRenderUV();
215 
216  /// Return true if this primitive requires an alpha pass.
217  virtual bool requiresAlphaPass() const { return false; }
218 
219  /// Return true if this should be drawn in the given alpha pass.
221  { return myAlphaPassMask & alpha; }
222 
223  /// Returns true if this should be drawn in the given onion skin pass.
224  bool drawInOnionSkinPass(bool is_onion_skin_pass) const
225  {
226  return myOnionSkinInfo.has_value()
227  == is_onion_skin_pass;
228  }
229 
230  /// Return true if this primitive renders in the specified alpha pass.
231  virtual bool renderInAlphaPass(GR_AlphaPass a);
232 
233  /// Returns the bounding box of this primitive if it can be determined.
234  virtual bool getBoundingBox(UT_BoundingBoxD &bbox) const
235  { return false; }
236 
237  /// There are assigned by `updatePrim()` and should not generally be
238  /// overriden.
239  /// @{
241  { myAlphaPassMask = mask; }
244  { myOnionSkinInfo = info; }
245  /// @}
246 
247  int getAlphaPassMask() const
248  { return myAlphaPassMask; }
251  { return myOnionSkinInfo; }
253  { return myLatestOnionSkinGroup; }
254  bool isOutlineOnionSkin() const
255  {
256  return myOnionSkinInfo &&
257  myOnionSkinInfo->myRenderMode ==
259  }
260 
261  /// Return the GA_Primitive corresponding to this primitive. Some
262  /// rendering primitives may be comprised of multiple GA/GU primitives.
263  /// The @c id parameter (corresponding to the @c __primitive_id attribute)
264  /// can be used to extract a specific primitive.
265  virtual const GA_Primitive *getGAPrimitive(const GU_Detail *gdp,
266  exint primitive_id) const;
267 
268  /// Find the vertex offset for a given vertex id. The integer returned
269  /// corresponds with the GA_Offset for the given vertex. If the vertex_id
270  /// is invalid, the method will return -1.
271  virtual exint getGAVertex(const GU_Detail *gdp,
272  exint vertex_id) const;
273 
274  /// Return the actual or estimated number of GL primitive that this
275  /// primitive will be rendering.
276  virtual exint getNumGLPrimitives(const GR_DisplayOption *);
277 
278  /// The GL render version to use for this primitive
279  GR_RenderVersion getRenderVersion() const;
280 
281  /// Returns whether this primitive can have it's render function called
282  /// from a thread other then the main thread
283  virtual bool supportsParallelDraw() const { return false; }
284 
285  /// Returns whether this primitive can have it's update function called
286  /// from a thread other then the main thread
287  virtual bool supportsParallelUpdate() const { return false; }
288 
289  /// whether to display component selections or not.
290  bool showSelections() const;
291 
292  /// Instancing matrix list and version (for the vertex array)
293  bool canDoInstancing() const;
294 
295  /// Returns true if the full object is selected at the scene level.
296  bool isObjectSelection() const;
297 
298  /// Returns true if the primitive supports packed prim culling when its
299  /// parent is a packed prim. On by default.
301  { return mySupportsDynamicCulling; }
303  { mySupportsDynamicCulling = dc; }
304 
305  /// Returns the current display option version for this primitive.
306  /// It will only be non-zero if the primitive responds to display option
307  /// changes and bumps the display option version.
309  { return myDispOptVersion; }
310 
312  {
313  myDispOptVersion++;
314  return myDispOptVersion;
315  }
316 
317  /// GT Primitive caching. This is handled by updatePrim()
318  /// @{
319  GT_PrimitiveHandle getCachedGTPrimitive() { return myCachedPrim; }
321  {
322  if(prim)
323  {
324  if(prim != myCachedPrim)
325  myCachedPrim = prim;
326  }
327  else
328  myCachedPrim = NULL;
329  }
330 
331  /// @}
332 
333  /// Called when a node is no longer actively displayed, but still cached
334  virtual void retirePrimitive();
335 
336  /// Only for the Scene Graph view: highlighted prims.
337  virtual bool isHighlighted() const { return false; }
338 
339  /// create a primitive for the given GT type, with appropriate cache name
340  /// and GL render level
341  static GR_Primitive *createPrimitive(GT_PrimitiveType ptype,
342  int geo_type,
343  const GR_RenderInfo *info,
344  const char *cache_name);
345 
346  void setPrimUsed(bool used) { myPrimUsed = used; }
347  bool isPrimUsed() const { return myPrimUsed; }
348 
349  /// set for those primitives that are within packed primitives
351  { myParentPrimType = type; }
353  { return myParentPrimType; }
354 
355  const GR_RenderInfo *getRenderInfo() const { return myInfo; }
356 
357  virtual void getGeoRenders(UT_Array<GR_GeoRender *> &renders) {}
359  { getGeoRenders(renders); }
360 
361  void addUpdateMessage(GR_ErrorManager::Source err_source,
362  GR_ErrorCode gr_code,
363  UT_StringHolder extra_text=UT_StringHolder(),
364  UT_StringHolder src_name=UT_StringHolder());
365  void addUpdateWarning(GR_ErrorManager::Source err_source,
366  GR_ErrorCode gr_code,
367  UT_StringHolder extra_text=UT_StringHolder(),
368  UT_StringHolder src_name=UT_StringHolder());
369  void addUpdateError (GR_ErrorManager::Source err_source,
370  GR_ErrorCode gr_code,
371  UT_StringHolder extra_text=UT_StringHolder(),
372  UT_StringHolder src_name=UT_StringHolder());
373  void addUpdateFatal (GR_ErrorManager::Source err_source,
374  GR_ErrorCode gr_code,
375  UT_StringHolder extra_text=UT_StringHolder(),
376  UT_StringHolder src_name=UT_StringHolder());
377 
378  void addRedrawMessage(GR_ErrorManager::Source err_source,
379  GR_ErrorCode gr_code,
380  UT_StringHolder extra_text=UT_StringHolder(),
381  UT_StringHolder src_name=UT_StringHolder());
382  void addRedrawWarning(GR_ErrorManager::Source err_source,
383  GR_ErrorCode gr_code,
384  UT_StringHolder extra_text=UT_StringHolder(),
385  UT_StringHolder src_name=UT_StringHolder());
386  void addRedrawError (GR_ErrorManager::Source err_source,
387  GR_ErrorCode gr_code,
388  UT_StringHolder extra_text=UT_StringHolder(),
389  UT_StringHolder src_name=UT_StringHolder());
390  void addRedrawFatal (GR_ErrorManager::Source err_source,
391  GR_ErrorCode gr_code,
392  UT_StringHolder extra_text=UT_StringHolder(),
393  UT_StringHolder src_name=UT_StringHolder());
394 
395  /// The base GL cache name assigned to this primitive.
396  const char * getCacheName() const { return myCacheName; }
397 
398  // For reference counted GR prims only
399  void incref() { myRef.add(1); }
400  void decref()
401  {
402  if( myRef.add(-1) == 0)
403  delete this;
404  }
405 
406  /// pass highlighted edge groups from GUI to GR
407  void setSelectedEdgeGroup(const GA_EdgeGroup* selected_edge)
408  { mySelectedEdges = selected_edge; }
409 
410 protected:
411  /// Primitive constructor. info and cache_name are assigned by the viewport.
412  /// GR_Primitive subclasses can assign a typemask which is used to determine
413  /// if the primitive is rendered in instances where only a subset of
414  /// primitive types is requested.
415  GR_Primitive(const GR_RenderInfo *info,
416  const char *cache_name,
417  GEO_PrimTypeCompat::TypeMask gaprimtype);
418 
419  virtual ~GR_Primitive();
420 
421 
422  /// Called when the geometry-related display options change, to determine if
423  /// an update is required. By default, no update is required. If the options
424  /// did change, return either DISPLAY_CHANGED, which will call update()
425  /// without bumping the display option version, or DISPLAY_VERSION_CHANGED,
426  /// which will bump the version.
427  /// If 'first_init' is true, this is being called to initialize any cached
428  /// display options. The return value will be ignored. This will happen
429  /// just after the primitive is created.
430  virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts,
431  bool first_init);
432 
433  /// Main update method, called when conditions change which may require the
434  /// geometry to be updated. These include geometry changes, selections,
435  /// volatile display options (level of detail), instancing updates,
436  /// and some GL state changes (if needsGLStateCheck returns true)
437  virtual void update(RE_RenderContext r,
438  const GT_PrimitiveHandle &primh,
439  const GR_UpdateParms &p) = 0;
440 
441  /// Main drawing method. update() will always be called before render(), but
442  /// render() may execute multiple times before the next update call. This
443  /// method should be fairly lightweight; do as much work in update() as
444  /// possible. There is no access to the GU_Detail from this method.
445  virtual void render(RE_RenderContext r,
446  GR_RenderMode render_mode,
448  GR_DrawParms dp) = 0;
449 
450  /// Render this primitive for picking, where pick_type is defined as one of
451  /// the pickable bits in GU_SelectType.h (like GR_PICK_GEOPOINT)
452  /// return the number of picks
453  virtual int renderPick(RE_RenderContext r,
454  const GR_DisplayOption *opt,
455  unsigned int pick_type,
456  GR_PickStyle pick_style,
457  bool has_pick_map) = 0;
458 
459  /// Render the attributes required for decoration 'decor' (like point
460  /// markers, uv text, normals, etc). 'overlay' should be set to true if
461  /// currently rendering in the overlay texture, false if in the main
462  /// viewport.
463  virtual void renderDecoration(RE_RenderContext r,
464  GR_Decoration decor,
465  const GR_DecorationParms &parms);
466 
467  /// Check if the builtin Houdini markers (point numbers, profile curves,
468  /// prim normals, etc) have changed since the last redraw, and return true
469  /// if at least one did. 'markers' is a list of markers to check that must
470  /// be terminated by GR_NO_DECORATION.
471  bool standardMarkersChanged(const GR_DisplayOption &opts,
472  const GR_Decoration *markers,
473  bool first_init);
474 
475  void updateDecoration(RE_RenderContext r,
477  const GR_UpdateParms &p,
478  const GT_PrimitiveHandle &prim,
479  RV_Geometry *geo);
480 
481  void updateDecorationList(RE_RenderContext r,
482  const GR_Decoration *pdecs,
483  const GR_UpdateParms &p,
484  const GT_PrimitiveHandle &prim,
485  GR_GeoRender *geo);
486 
487  /// Helper mother to draw a decoration on a given GR_GeoRender object.
488  /// Called from renderDecoration() or render().
489  void drawDecoration(RE_RenderContext r,
490  GR_GeoRender *geo,
492  const GR_DisplayOption *opts,
494  bool overlay,
495  bool override_vis,
496  int instance_group = -1,
497  GR_SelectMode *select_override = NULL,
500 
501  void drawVisualizer(RE_RenderContext r,
502  GR_GeoRender *geo,
503  const GR_VisualizerInfo *dec_info,
504  const GR_DisplayOption *opts,
508 
509 
510  /// Helper method to draw a decoration on a given RE_Geometry object.
511  /// Called from renderDeocration() or render().
512  void drawDecorationForGeo(RE_RenderContext r,
513  RV_Geometry *geo,
515  const GR_DisplayOption *opts,
517  bool overlay,
518  bool override_vis,
519  int instance_group,
520  GR_SelectMode smode,
523  RE_OverrideList *override_list = NULL);
524 
525  void drawVisualizerForGeo(RE_RenderContext r,
526  RV_Geometry *geo,
527  const GR_VisualizerInfo *dec_info,
528  const GR_DisplayOption *opts,
532 
533 
534  /// Helper method to draw a GR_GeoRender object. Called from render() or
535  /// renderDecoration().
536  void drawGeoRender(RE_RenderContext r,
537  GR_GeoRender *geo,
540  GR_DrawParms dp);
541  bool checkUserOptions(const GR_DisplayOption &opt) const;
542  void updateUserOptions(const GR_DisplayOption &opt);
543  const GR_UserOption *getUserDecoration(GR_Decoration dec) const;
544 
545  GR_DispOptChange checkColorOverride(const GR_DisplayOption &opts,
546  bool first_init);
547 
548  GT_Primitive *createUnitSphere(const GT_RefineParms &parms);
549 
550 
551 
552  /// Return a GEO_Primitive derivative (GeoPrim) from the GT handle. The
553  /// GT handle must be referencing a GT_GEOPrimitive.
554  template <class GeoPrim>
556  const GeoPrim *&prim)
557  {
558  const GT_GEOPrimitive *geo =
559  dynamic_cast<const GT_GEOPrimitive*>(primh.get());
560  prim = dynamic_cast<const GeoPrim *>(geo->getPrimitive(0));
561  }
562 
563  /// Do picking for point attribute on GeoRender `gr`
564  ///
565  /// Only uses parameters `geo`, `select_mode`, and `select_inst`
566  /// if `gr` is null, ignores them and uses values set from `gr`
567  int doPickPoints(RE_RenderContext r,
568  const GR_DisplayOption *opts,
569  GR_GeoRender* gr,
570  RV_Geometry* geo,
571  GR_SelectMode select_mode,
572  int select_inst,
573  GR_PickStyle pickstyle,
574  bool has_pick_map,
575  RE_PrimType real_prim_type,
576  int real_connect_start,
577  int real_connect_num);
578 
579  /// Do picking for point attribute on GeoRender `gr`
580  int doPickPoints(RE_RenderContext r,
581  const GR_DisplayOption *opts,
582  GR_GeoRender* gr,
583  GR_PickStyle pickstyle,
584  bool has_pick_map,
585  RE_PrimType real_prim_type,
586  int real_connect_start,
587  int real_connect_num);
588 
589  /// Create a pick buffer large enough to hold all picks from 'geo' with
590  /// 'picktype' selection style (GR_PICK_GEOPOINT, PRIMITIVE, etc)
591  /// The required vector size (1 or 2) will be returned in vsize (edges need
592  /// 2) and needs_2pass will be true if some picks require CPU support.
593  int getPickBufferSize(const GR_PickRender *geo,
594  unsigned int picktype,
595  int &vector_size,
596  bool &needs_2pass,
597  int start_group = 4,
598  int end_group = -1,
599  GR_PickStyle pickstyle
600  = GR_PICK_NONE) const;
601 
602  /// creates a ivec4 pick buffer with a pickID attribute with buffer_size
603  /// points. This primitive owns the buffer, and there is only one.
604  GR_PickBuffer *createPickBuffer(RE_RenderContext r, int buffer_size,
605  int vector_size = 1,
606  bool inconclusive_stream_too = false,
607  const GR_PickRender *geo = nullptr);
608 
609  /// creates a PickRender wrapping the passed in GeoRender,
610  /// also creates a pick buffer if needed
612  const GR_DisplayOption *opts,
613  GR_GeoRender* gr,
614  unsigned int picktype);
615 
616  /// accumulate picks into the myInfo.myPicks array so that it can be passed
617  /// up to higher level code. Some effort is made to remove duplicate pickIDs,
618  /// mostly from neighbouring picks. If 'pick_buffer' is NULL, myPickBuffer
619  /// is used.
620  int accumulatePickIDs(RE_RenderContext r, int npicks,
621  GR_PickBuffer *pick_buffer = NULL);
622 
623  GR_PickCompMode setupPrimPickMode(RE_RenderContext r,GR_GeoRender *geo) const;
624 
625 
627  { myGAPrimMask = m; }
628 
630  { myDecorMask = mask; }
631 
632  bool checkForRibbons(const GR_UpdateParms &p,
633  const GT_PrimitiveHandle &primh) const;
634 
639 
640  // For deferred rendering
645 
646  // Pointer to edge group containing selected edges to be passed to GR
647  const GA_EdgeGroup *mySelectedEdges = nullptr;
648 
649 private:
650  int pickPoints(RE_RenderContext r,
651  GR_PickRender* pr,
652  GR_SelectMode select_mode,
653  int select_inst,
654  GR_PickStyle pickstyle,
655  bool has_pick_map,
656  RE_PrimType real_prim_type,
657  int real_connect_start,
658  int real_connect_num);
659 
660  UT_String myCacheName;
661  UT_Int64Array myUserDispOptions;
662  int32 myDispOptVersion;
663  GEO_PrimTypeCompat::TypeMask myGAPrimMask;
664  UT_String myColorOverrideOpt;
665  unsigned myPrimUsed : 1,
666  myUserDecorationsProcessed : 1,
667  myDispOptInit : 1;
668  GR_BasePrimType myParentPrimType;
669 
670  // for cache access only; do not dereference.
671  GT_PrimitiveHandle myCachedPrim;
672 
673  int myMarkerState[GR_MAX_DECORATIONS];//0=off,1=on,-1=undef
674  int64 myDecorMask;
675  SYS_AtomicInt32 myRef;
676  int myAlphaPassMask;
677 
678  // uncached buffer for doing transform feedback picking
679  UT_UniquePtr<GR_PickBuffer> myPickBuffer;
680 
681  /// If this holds a value, then this primitive is meant to be drawn as an
682  /// onion skin using the options in the struct.
684  UT_Optional<int> myLatestOnionSkinGroup;
685 };
686 
688 static inline void intrusive_ptr_add_ref(GR_Primitive *pr) { pr->incref(); }
689 static inline void intrusive_ptr_release(GR_Primitive *pr) { pr->decref(); }
690 
693 {
694  GR_DispOptChange changed = displayOptionChange(opts, !myDispOptInit);
695 
696  myDispOptInit = true;
697 
698  return changed;
699 }
700 
701 inline void
703  const GT_PrimitiveHandle &primh,
704  const GR_UpdateParms &p)
705 {
707  myCachedPrim = primh;
709  rlock.isValid() ? rlock->findPointAttribute("N") != NULL : false;
710  myUserDecorationsProcessed = false;
711 
712  utZoneScopedFlag(VIEWPORT);
713  utZoneTextSH(myCacheName);
714 
715  if(!myDispOptInit)
716  {
717  displayOptionChange(p.dopts, true);
718  myDispOptInit = true;
719  }
720 
721  update(r, primh, p);
722 
724  myAlphaPassMask = GR_ALPHA_PASS_OPAQUE;
725  else
726  myAlphaPassMask = 0;
727 
729  myAlphaPassMask |= GR_ALPHA_PASS_NORMAL;
730 }
731 
732 inline void
734  GR_Decoration dec,
735  const GR_UpdateParms &p,
736  const GT_PrimitiveHandle &prim,
737  RV_Geometry *geo)
738 {
739  // Don't draw decorations for packed primitives
743  return;
744 
745  myDecorRender->updateDecoration(r, dec, *prim.get(), p, *geo);
746 }
747 
748 #endif
type
Definition: core.h:556
Base class for many of the GEO_Primitive objects.
virtual bool isPrimVisible() const
Definition: GR_Primitive.h:104
virtual bool inViewFrustum(const UT_Matrix4D &objviewproj, const UT_BoundingBoxD *bbox=nullptr)
Definition: GR_Primitive.h:198
virtual void getBeautyGeoRenders(UT_Array< GR_GeoRender * > &renders)
Definition: GR_Primitive.h:358
GLbitfield flags
Definition: glcorearb.h:1596
UT_Matrix4D myLocal
Definition: GR_Primitive.h:642
int int32
Definition: SYS_Types.h:39
virtual bool updateOnViewChange(const GR_DisplayOption &) const
If this primitive requires an update when the view changes, return true.
Definition: GR_Primitive.h:123
bool typeMask(GEO_PrimTypeCompat::TypeMask mask) const
returns true if this primitive's type mask is part of "mask".
Definition: GR_Primitive.h:90
int32 getDisplayOptionVersion() const
Definition: GR_Primitive.h:308
virtual bool requiresAlphaPass() const
Return true if this primitive requires an alpha pass.
Definition: GR_Primitive.h:217
GR_DecorRenderFlags
Definition: GR_Defines.h:235
GR_DecorationRender * myDecorRender
Definition: GR_Primitive.h:637
Set of parameters sent to GR_Primitive::viewUpdate().
GU_ConstDetailHandle geometry
GR_ErrorCode
Definition: GR_Error.h:16
GR_DispOptChange checkDisplayOptionChange(const GR_DisplayOption &opts)
Definition: GR_Primitive.h:692
virtual bool supportsParallelDraw() const
Definition: GR_Primitive.h:283
const GEO_Primitive * getPrimitive(int seg) const
virtual void resetPrimitives()
Definition: GR_Primitive.h:78
bool myHasDetailPointNormal
Definition: GR_Primitive.h:635
int64 exint
Definition: SYS_Types.h:125
GT_API const UT_StringHolder cache_name
Object that represents drawable geometry. This object holds vertex, instancing and index buffers for ...
Definition: RV_Geometry.h:165
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
void getGEOPrimFromGT(const GT_PrimitiveHandle &primh, const GeoPrim *&prim)
Definition: GR_Primitive.h:555
int32 bumpDisplayOptionVersion()
Definition: GR_Primitive.h:311
bool drawInAlphaPass(GR_AlphaPass alpha) const
Return true if this should be drawn in the given alpha pass.
Definition: GR_Primitive.h:220
GR_Decoration
Definition: GR_Defines.h:167
GR_AlphaPass
Definition: GR_Defines.h:125
GLuint buffer
Definition: glcorearb.h:660
Temporary container for either a RV_Render and an RE_Render.
OutGridT const XformOp bool bool
IFDmantra you can see code vm_image_mplay_direction endcode When SOHO starts a render
Definition: HDK_Image.dox:266
UT_Optional< int > getOnionSkinGroup() const
Definition: GR_Primitive.h:252
std::optional< T > UT_Optional
Definition: UT_Optional.h:26
virtual void getGeoRenders(UT_Array< GR_GeoRender * > &renders)
Definition: GR_Primitive.h:357
virtual void viewUpdate(RE_RenderContext r, const GR_ViewUpdateParms &parms)
Definition: GR_Primitive.h:133
void cacheGTPrimitive(const GT_PrimitiveHandle &prim)
Definition: GR_Primitive.h:320
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
const char * getCacheName() const
The base GL cache name assigned to this primitive.
Definition: GR_Primitive.h:396
set of parameters sent to GR_Primitive::update()
GR_BasePrimType getParentPrimType() const
Definition: GR_Primitive.h:352
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
#define utZoneTextSH(sh)
Definition: UT_Tracing.h:232
virtual bool isHighlighted() const
Only for the Scene Graph view: highlighted prims.
Definition: GR_Primitive.h:337
GR_RenderMode
Definition: GR_Defines.h:48
const GR_DisplayOption & dopts
GR_BasePrimType
Definition: GR_Defines.h:371
void updatePrim(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &parms)
called every time the metacount version is bumped on the GU_Detail.
Definition: GR_Primitive.h:702
virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const
Definition: GR_Primitive.h:149
void setSupportedDecorations(int64 mask)
Definition: GR_Primitive.h:629
virtual bool renderInAlphaPass(GR_AlphaPass a)
Return true if this primitive renders in the specified alpha pass.
GT_API const UT_StringHolder primitive_id
GLint GLuint mask
Definition: glcorearb.h:124
const GR_RenderInfo * getRenderInfo() const
Definition: GR_Primitive.h:355
#define GR_API
Definition: GR_API.h:10
virtual GT_PrimitiveHandle getInstancePrim() const
Definition: GR_Primitive.h:86
const GR_RenderInfo * myInfo
Definition: GR_Primitive.h:638
#define utZoneScopedFlag(F)
Definition: UT_Tracing.h:215
void setParentPrimType(GR_BasePrimType type)
set for those primitives that are within packed primitives
Definition: GR_Primitive.h:350
long long int64
Definition: SYS_Types.h:116
virtual bool getBoundingBox(UT_BoundingBoxD &bbox) const
Returns the bounding box of this primitive if it can be determined.
Definition: GR_Primitive.h:234
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:112
virtual void cleanup(RE_RenderContext r)
Definition: GR_Primitive.h:186
virtual bool setup(const GR_DisplayOption *)
Definition: GR_Primitive.h:184
GR_PrimAcceptResult
Definition: GR_Defines.h:364
GR_RenderFlags
Definition: GR_Defines.h:88
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
GT_PrimitiveHandle getCachedGTPrimitive()
Definition: GR_Primitive.h:319
GR_RenderVersion
Definition: GR_Defines.h:22
void setOnionSkinInfo(UT_Optional< GU_OnionSkinPrimRenderInfo > info)
Definition: GR_Primitive.h:242
GLdouble t
Definition: glad.h:2397
GLenum mode
Definition: glcorearb.h:99
GT_PrimitiveType
Contains transitional objects to provide some backward compatibility for code that references old GEO...
void setSelectedEdgeGroup(const GA_EdgeGroup *selected_edge)
pass highlighted edge groups from GUI to GR
Definition: GR_Primitive.h:407
GR_PickCompMode
Definition: GR_PickRecord.h:52
GA_API const UT_StringHolder parms
bool supportsDynamicCulling() const
Definition: GR_Primitive.h:300
UT_Optional< GU_OnionSkinPrimRenderInfo > getOnionSkinInfo() const
Definition: GR_Primitive.h:250
int getAlphaPassMask() const
Definition: GR_Primitive.h:247
virtual bool checkGLState(RE_RenderContext r, const GR_DisplayOption &opts)
Definition: GR_Primitive.h:151
bool updateDecoration(RE_Render *r, GR_Decoration dec, const GT_Primitive &prim, const GR_UpdateParms &p, RE_Geometry &geo)
bool isPrimUsed() const
Definition: GR_Primitive.h:347
int64 supportedDecorations()
Definition: GR_Primitive.h:211
bool isOutlineOnionSkin() const
Definition: GR_Primitive.h:254
void setPrimUsed(bool used)
Definition: GR_Primitive.h:346
UT_BoundingBoxF myBBox
Definition: GR_Primitive.h:641
void supportsDynamicCulling(bool dc)
Definition: GR_Primitive.h:302
virtual void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p)=0
bool drawInOnionSkinPass(bool is_onion_skin_pass) const
Returns true if this should be drawn in the given onion skin pass.
Definition: GR_Primitive.h:224
void updateDecoration(RE_RenderContext r, GR_Decoration dec, const GR_UpdateParms &p, const GT_PrimitiveHandle &prim, RV_Geometry *geo)
Definition: GR_Primitive.h:733
UT_IntrusivePtr< GT_Primitive > GT_PrimitiveHandle
Definition: GT_Handles.h:34
GLboolean r
Definition: glcorearb.h:1222
virtual bool supportsParallelUpdate() const
Definition: GR_Primitive.h:287
UT_IntrusivePtr< GR_Primitive > GR_PrimitivePtr
Definition: GR_Primitive.h:687
void setPrimTypeMask(GEO_PrimTypeCompat::TypeMask m)
Definition: GR_Primitive.h:626
SYS_FORCE_INLINE const GA_Attribute * findPointAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1057
GT_API const UT_StringHolder vertex_id
RE_PrimType
Definition: RE_Types.h:199
virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init)
bool mySupportsDynamicCulling
Definition: GR_Primitive.h:636
GR_SelectMode
Definition: GR_Defines.h:246
virtual GR_BasePrimType getBasePrimType() const
The base primitive type is usually NORMAL unless this is a packed type.
Definition: GR_Primitive.h:81
void setAlphaPassMask(int mask)
Definition: GR_Primitive.h:240
GR_PickStyle
Definition: GR_Defines.h:257