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