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,
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 #ifdef USE_VULKAN
201  /// Called just before ray tracing
202  void prepareForRayTrace(RE_RenderContext r,
203  int tag,
204  int light_id,
205  const UT_Matrix4F &obj_mat);
206 #endif
207 
208  /// return true if the primitive is in or overlaps the view frustum.
209  /// always returning true will effectively disable frustum culling.
210  /// bbox is an option bounding box which can be used for frustum testing.
211  virtual bool inViewFrustum(const UT_Matrix4D &objviewproj,
212  const UT_BoundingBoxD *bbox = nullptr)
213  { return true; }
214 
215  /// Similar to inViewFrustum, but also considers if the prim is too small
216  /// to render in the viewport. Also uses 32b FP precision for speed.
217  virtual bool isRasterizedInView(const UT_Matrix4F &objviewproj,
218  const UT_Vector2F &min_proj_size,
219  const UT_BoundingBoxF *bbox=nullptr);
220 
221  /// Return a bitfield of what decorations are supported by this primitive.
222  /// Set bit (1 << GR_Decoration) if that decoration is supported.
223  /// Not all primitives will support all decorations.
224  int64 supportedDecorations() { return myDecorMask; }
225 
226  /// Return true if this primitive supports drawing into a UV viewport.
227  virtual bool supportsRenderUV();
228 
229  /// Return true if this primitive requires an alpha pass.
230  virtual bool requiresAlphaPass() const { return false; }
231 
232  /// Return true if this should be drawn in the given alpha pass.
234  { return myAlphaPassMask & alpha; }
235 
236  /// Return true if this primitive renders in the specified alpha pass.
237  virtual bool renderInAlphaPass(GR_AlphaPass a);
238 
239  /// Returns the bounding box of this primitive if it can be determined.
240  virtual bool getBoundingBox(UT_BoundingBoxD &bbox) const
241  { return false; }
242 
243  // this is assigned by updatePrim() and should not generally be overriden.
245  { myAlphaPassMask = mask; }
246  int getAlphaPassMask() const
247  { return myAlphaPassMask; }
248 
249  /// Return the GA_Primitive corresponding to this primitive. Some
250  /// rendering primitives may be comprised of multiple GA/GU primitives.
251  /// The @c id parameter (corresponding to the @c __primitive_id attribute)
252  /// can be used to extract a specific primitive.
253  virtual const GA_Primitive *getGAPrimitive(const GU_Detail *gdp,
254  exint primitive_id) const;
255 
256  /// Find the vertex offset for a given vertex id. The integer returned
257  /// corresponds with the GA_Offset for the given vertex. If the vertex_id
258  /// is invalid, the method will return -1.
259  virtual exint getGAVertex(const GU_Detail *gdp,
260  exint vertex_id) const;
261 
262  /// Return the actual or estimated number of GL primitive that this
263  /// primitive will be rendering.
264  virtual exint getNumGLPrimitives(const GR_DisplayOption *);
265 
266  /// The GL render version to use for this primitive
267  GR_RenderVersion getRenderVersion() const;
268 
269  /// Returns whether this primitive can have it's render function called
270  /// from a thread other then the main thread
271  virtual bool supportsParallelDraw() const { return false; }
272 
273  /// Returns whether this primitive can have it's update function called
274  /// from a thread other then the main thread
275  virtual bool supportsParallelUpdate() const { return false; }
276 
277  /// whether to display component selections or not.
278  bool showSelections() const;
279 
280  /// Instancing matrix list and version (for the vertex array)
281  bool canDoInstancing() const;
282 
283  /// Returns true if the full object is selected at the scene level.
284  bool isObjectSelection() const;
285 
286  /// Returns true if the primitive supports packed prim culling when its
287  /// parent is a packed prim. On by default.
289  { return mySupportsDynamicCulling; }
291  { mySupportsDynamicCulling = dc; }
292 
293  /// Returns the current display option version for this primitive.
294  /// It will only be non-zero if the primitive responds to display option
295  /// changes and bumps the display option version.
297  { return myDispOptVersion; }
298 
300  {
301  myDispOptVersion++;
302  return myDispOptVersion;
303  }
304 
305  /// GT Primitive caching. This is handled by updatePrim()
306  /// @{
307  GT_PrimitiveHandle getCachedGTPrimitive() { return myCachedPrim; }
309  {
310  if(prim)
311  {
312  if(prim != myCachedPrim)
313  myCachedPrim = prim;
314  }
315  else
316  myCachedPrim = NULL;
317  }
318 
319  /// @}
320 
321  /// Called when a node is no longer actively displayed, but still cached
322  virtual void retirePrimitive();
323 
324  /// return the RE_Geometry containing the geometry to be decorated by user
325  /// display options. May return NULL if no user decorations are to be shown.
326  virtual RE_Geometry *getDecorationGeometry() { return NULL; }
327 
328  /// Only for the Scene Graph view: highlighted prims.
329  virtual bool isHighlighted() const { return false; }
330 
331  /// create a primitive for the given GT type, with appropriate cache name
332  /// and GL render level
333  static GR_Primitive *createPrimitive(GT_PrimitiveType ptype,
334  int geo_type,
335  const GR_RenderInfo *info,
336  const char *cache_name);
337 
338  void setPrimUsed(bool used) { myPrimUsed = used; }
339  bool isPrimUsed() const { return myPrimUsed; }
340 
341  /// set for those primitives that are within packed primitives
343  { myParentPrimType = type; }
345  { return myParentPrimType; }
346 
347  const GR_RenderInfo *getRenderInfo() const { return myInfo; }
348 
349  virtual void getGeoRenders(UT_Array<GR_GeoRender *> &renders) {}
351  { getGeoRenders(renders); }
352 
353  void addUpdateMessage(GR_ErrorManager::Source err_source,
354  GR_ErrorCode gr_code,
355  UT_StringHolder extra_text=UT_StringHolder(),
356  UT_StringHolder src_name=UT_StringHolder());
357  void addUpdateWarning(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 addUpdateError (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 addUpdateFatal (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 
370  void addRedrawMessage(GR_ErrorManager::Source err_source,
371  GR_ErrorCode gr_code,
372  UT_StringHolder extra_text=UT_StringHolder(),
373  UT_StringHolder src_name=UT_StringHolder());
374  void addRedrawWarning(GR_ErrorManager::Source err_source,
375  GR_ErrorCode gr_code,
376  UT_StringHolder extra_text=UT_StringHolder(),
377  UT_StringHolder src_name=UT_StringHolder());
378  void addRedrawError (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 addRedrawFatal (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 
387  /// The base GL cache name assigned to this primitive.
388  const char * getCacheName() const { return myCacheName; }
389 
390  // For reference counted GR prims only
391  void incref() { myRef.add(1); }
392  void decref()
393  {
394  if( myRef.add(-1) == 0)
395  delete this;
396  }
397 
398 protected:
399  /// Primitive constructor. info and cache_name are assigned by the viewport.
400  /// GR_Primitive subclasses can assign a typemask which is used to determine
401  /// if the primitive is rendered in instances where only a subset of
402  /// primitive types is requested.
403  GR_Primitive(const GR_RenderInfo *info,
404  const char *cache_name,
405  GEO_PrimTypeCompat::TypeMask gaprimtype);
406 
407  virtual ~GR_Primitive();
408 
409 
410  /// Called when the geometry-related display options change, to determine if
411  /// an update is required. By default, no update is required. If the options
412  /// did change, return either DISPLAY_CHANGED, which will call update()
413  /// without bumping the display option version, or DISPLAY_VERSION_CHANGED,
414  /// which will bump the version.
415  /// If 'first_init' is true, this is being called to initialize any cached
416  /// display options. The return value will be ignored. This will happen
417  /// just after the primitive is created.
418  virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts,
419  bool first_init);
420 
421  /// Main update method, called when conditions change which may require the
422  /// geometry to be updated. These include geometry changes, selections,
423  /// volatile display options (level of detail), instancing updates,
424  /// and some GL state changes (if needsGLStateCheck returns true)
425  virtual void update(RE_RenderContext r,
426  const GT_PrimitiveHandle &primh,
427  const GR_UpdateParms &p) = 0;
428 
429  /// Main drawing method. update() will always be called before render(), but
430  /// render() may execute multiple times before the next update call. This
431  /// method should be fairly lightweight; do as much work in update() as
432  /// possible. There is no access to the GU_Detail from this method.
433  virtual void render(RE_RenderContext r,
434  GR_RenderMode render_mode,
436  GR_DrawParms dp) = 0;
437 
438  /// Render this primitive for picking, where pick_type is defined as one of
439  /// the pickable bits in GU_SelectType.h (like GR_PICK_GEOPOINT)
440  /// return the number of picks
441  virtual int renderPick(RE_RenderContext r,
442  const GR_DisplayOption *opt,
443  unsigned int pick_type,
444  GR_PickStyle pick_style,
445  bool has_pick_map) = 0;
446 
447  /// Render the attributes required for decoration 'decor' (like point
448  /// markers, uv text, normals, etc). 'overlay' should be set to true if
449  /// currently rendering in the overlay texture, false if in the main
450  /// viewport.
451  virtual void renderDecoration(RE_RenderContext r,
452  GR_Decoration decor,
453  const GR_DecorationParms &parms);
454 
455  /// Check if the builtin Houdini markers (point numbers, profile curves,
456  /// prim normals, etc) have changed since the last redraw, and return true
457  /// if at least one did. 'markers' is a list of markers to check that must
458  /// be terminated by GR_NO_DECORATION.
459  bool standardMarkersChanged(const GR_DisplayOption &opts,
460  const GR_Decoration *markers,
461  bool first_init);
462 
463  /// Updates a decoration for the pass RE_Geometry object. Called from
464  /// update().
465  void updateDecoration(RE_RenderContext r,
467  const GR_UpdateParms &p,
468  const GT_PrimitiveHandle &prim,
469  RE_Geometry *geo);
470 
471  void updateDecoration(RE_RenderContext r,
473  const GR_UpdateParms &p,
474  const GT_PrimitiveHandle &prim,
475  RV_Geometry *geo);
476 
477  void updateDecorationList(RE_RenderContext r,
478  const GR_Decoration *pdecs,
479  const GR_UpdateParms &p,
480  const GT_PrimitiveHandle &prim,
481  GR_GeoRender *geo);
482 
483  /// Helper mother to draw a decoration on a given GR_GeoRender object.
484  /// Called from renderDecoration() or render().
485  void drawDecoration(RE_RenderContext r,
486  GR_GeoRender *geo,
488  const GR_DisplayOption *opts,
490  bool overlay,
491  bool override_vis,
492  int instance_group = -1,
493  GR_SelectMode *select_override = NULL,
496 
497  void drawVisualizer(RE_RenderContext r,
498  GR_GeoRender *geo,
499  const GR_VisualizerInfo *dec_info,
500  const GR_DisplayOption *opts,
504 
505 
506  /// Helper method to draw a decoration on a given RE_Geometry object.
507  /// Called from renderDeocration() or render().
508  void drawDecorationForGeo(RE_RenderContext r,
509  RE_Geometry *geo,
511  const GR_DisplayOption *opts,
513  bool overlay,
514  bool override_vis,
515  int instance_group,
516  GR_SelectMode smode,
519  RE_OverrideList *override_list = NULL);
520 
521  void drawVisualizerForGeo(RE_RenderContext r,
522  RE_Geometry *geo,
523  const GR_VisualizerInfo *dec_info,
524  const GR_DisplayOption *opts,
528 
529  /// Helper method to draw a decoration on a given RE_Geometry object.
530  /// Called from renderDeocration() or render().
531  void drawDecorationForGeo(RE_RenderContext r,
532  RV_Geometry *geo,
534  const GR_DisplayOption *opts,
536  bool overlay,
537  bool override_vis,
538  int instance_group,
539  GR_SelectMode smode,
542  RE_OverrideList *override_list = NULL);
543 
544  void drawVisualizerForGeo(RE_RenderContext r,
545  RV_Geometry *geo,
546  const GR_VisualizerInfo *dec_info,
547  const GR_DisplayOption *opts,
551 
552 
553  /// Helper method to draw a GR_GeoRender object. Called from render() or
554  /// renderDecoration().
555  void drawGeoRender(RE_RenderContext r,
556  GR_GeoRender *geo,
559  GR_DrawParms dp);
560  bool checkUserOptions(const GR_DisplayOption &opt) const;
561  void updateUserOptions(const GR_DisplayOption &opt);
562  const GR_UserOption *getUserDecoration(GR_Decoration dec) const;
563  void updateUserDecorations(RE_RenderContext r,
564  const GT_PrimitiveHandle &primh,
565  const GR_UpdateParms &p,
566  RE_Geometry *for_geo = NULL);
567 
568  GR_DispOptChange checkColorOverride(const GR_DisplayOption &opts,
569  bool first_init);
570 
571  GT_Primitive *createUnitSphere(const GT_RefineParms &parms);
572 
573 
574 
575  /// Return a GEO_Primitive derivative (GeoPrim) from the GT handle. The
576  /// GT handle must be referencing a GT_GEOPrimitive.
577  template <class GeoPrim>
579  const GeoPrim *&prim)
580  {
581  const GT_GEOPrimitive *geo =
582  dynamic_cast<const GT_GEOPrimitive*>(primh.get());
583  prim = dynamic_cast<const GeoPrim *>(geo->getPrimitive(0));
584  }
585 
586  /// Do picking for point attribute on GeoRender `gr`
587  ///
588  /// Only uses parameters `geo`, `select_mode`, and `select_inst`
589  /// if `gr` is null, ignores them and uses values set from `gr`
590  int doPickPoints(RE_RenderContext r,
591  const GR_DisplayOption *opts,
592  GR_GeoRender* gr,
593  RE_Geometry* geo,
594  GR_SelectMode select_mode,
595  int select_inst,
596  GR_PickStyle pickstyle,
597  bool has_pick_map,
598  RE_PrimType real_prim_type,
599  int real_connect_start,
600  int real_connect_num);
601 
602  int doPickPoints(RE_RenderContext r,
603  const GR_DisplayOption *opts,
604  GR_GeoRender* gr,
605  RV_Geometry* geo,
606  GR_SelectMode select_mode,
607  int select_inst,
608  GR_PickStyle pickstyle,
609  bool has_pick_map,
610  RE_PrimType real_prim_type,
611  int real_connect_start,
612  int real_connect_num);
613 
614  /// Do picking for point attribute on GeoRender `gr`
615  int doPickPoints(RE_RenderContext r,
616  const GR_DisplayOption *opts,
617  GR_GeoRender* gr,
618  GR_PickStyle pickstyle,
619  bool has_pick_map,
620  RE_PrimType real_prim_type,
621  int real_connect_start,
622  int real_connect_num);
623 
624  /// Create a pick buffer large enough to hold all picks from 'geo' with
625  /// 'picktype' selection style (GR_PICK_GEOPOINT, PRIMITIVE, etc)
626  /// The required vector size (1 or 2) will be returned in vsize (edges need
627  /// 2) and needs_2pass will be true if some picks require CPU support.
628  int getPickBufferSize(RE_Geometry *geo,
629  unsigned int picktype,
630  int &vector_size,
631  bool &needs_2pass,
632  int start_group = 4,
633  int end_group = -1,
634  GR_PickStyle pickstyle
635  = GR_PICK_NONE) const;
636 
637 
638  /// Create a pick buffer large enough to hold all picks from 'geo' with
639  /// 'picktype' selection style (GR_PICK_GEOPOINT, PRIMITIVE, etc)
640  /// The required vector size (1 or 2) will be returned in vsize (edges need
641  /// 2) and needs_2pass will be true if some picks require CPU support.
642  int getPickBufferSize(const GR_PickRender *geo,
643  unsigned int picktype,
644  int &vector_size,
645  bool &needs_2pass,
646  int start_group = 4,
647  int end_group = -1,
648  GR_PickStyle pickstyle
649  = GR_PICK_NONE) const;
650 
651  /// creates a ivec4 pick buffer with a pickID attribute with buffer_size
652  /// points. This primitive owns the buffer, and there is only one.
653  GR_PickBuffer *createPickBuffer(RE_RenderContext r, int buffer_size,
654  int vector_size = 1,
655  bool inconclusive_stream_too = false,
656  const GR_PickRender *geo = nullptr);
657 
658  /// creates a PickRender wrapping the passed in GeoRender,
659  /// also creates a pick buffer if needed
661  const GR_DisplayOption *opts,
662  GR_GeoRender* gr,
663  unsigned int picktype);
664 
665  /// accumulate picks into the myInfo.myPicks array so that it can be passed
666  /// up to higher level code. Some effort is made to remove duplicate pickIDs,
667  /// mostly from neighbouring picks. If 'pick_buffer' is NULL, myPickBuffer
668  /// is used.
669  int accumulatePickIDs(RE_RenderContext r, int npicks,
670  GR_PickBuffer *pick_buffer = NULL);
671 
672  GR_PickCompMode setupPrimPickMode(RE_RenderContext r,GR_GeoRender *geo) const;
673 
674 
676  { myGAPrimMask = m; }
677 
679  { myDecorMask = mask; }
680 
681  bool checkForRibbons(const GR_UpdateParms &p,
682  const GT_PrimitiveHandle &primh) const;
683 
688 
689  // For deferred rendering
694 
695 private:
696  int pickPoints(RE_RenderContext r,
697  GR_PickRender* pr,
698  GR_SelectMode select_mode,
699  int select_inst,
700  GR_PickStyle pickstyle,
701  bool has_pick_map,
702  RE_PrimType real_prim_type,
703  int real_connect_start,
704  int real_connect_num);
705 
706  UT_String myCacheName;
707  UT_Int64Array myUserDispOptions;
708  int32 myDispOptVersion;
709  GEO_PrimTypeCompat::TypeMask myGAPrimMask;
710  UT_String myColorOverrideOpt;
711  unsigned myPrimUsed : 1,
712  myUserDecorationsProcessed : 1,
713  myDispOptInit : 1;
714  GR_BasePrimType myParentPrimType;
715 
716  // for cache access only; do not dereference.
717  GT_PrimitiveHandle myCachedPrim;
718 
719  int myMarkerState[GR_MAX_DECORATIONS];//0=off,1=on,-1=undef
720  int64 myDecorMask;
721  SYS_AtomicInt32 myRef;
722  int myAlphaPassMask;
723 
724  // uncached buffer for doing transform feedback picking
725  UT_UniquePtr<GR_PickBuffer> myPickBuffer;
726 };
727 
729 static inline void intrusive_ptr_add_ref(GR_Primitive *pr) { pr->incref(); }
730 static inline void intrusive_ptr_release(GR_Primitive *pr) { pr->decref(); }
731 
734 {
735  GR_DispOptChange changed = displayOptionChange(opts, !myDispOptInit);
736 
737  myDispOptInit = true;
738 
739  return changed;
740 }
741 
742 inline void
744  const GT_PrimitiveHandle &primh,
745  const GR_UpdateParms &p)
746 {
748  myCachedPrim = primh;
750  rlock.isValid() ? rlock->findPointAttribute("N") != NULL : false;
751  myUserDecorationsProcessed = false;
752 
753  if(!myDispOptInit)
754  {
755  displayOptionChange(p.dopts, true);
756  myDispOptInit = true;
757  }
758 
759  update(r, primh, p);
760 
762  myAlphaPassMask = GR_ALPHA_PASS_OPAQUE;
763  else
764  myAlphaPassMask = 0;
765 
767  myAlphaPassMask |= GR_ALPHA_PASS_NORMAL;
768 
769  updateUserDecorations(r, primh, p);
770 }
771 
772 inline void
774  GR_Decoration dec,
775  const GR_UpdateParms &p,
776  const GT_PrimitiveHandle &prim,
777  RE_Geometry *geo)
778 {
779  // Don't draw decorations for packed primitives
783  return;
784 
785  myDecorRender->updateDecoration(r, dec, *prim.get(), p, *geo);
786 }
787 
788 inline void
790  GR_Decoration dec,
791  const GR_UpdateParms &p,
792  const GT_PrimitiveHandle &prim,
793  RV_Geometry *geo)
794 {
795  // Don't draw decorations for packed primitives
799  return;
800 
801  myDecorRender->updateDecoration(r, dec, *prim.get(), p, *geo);
802 }
803 
804 #endif
type
Definition: core.h:556
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:211
virtual void getBeautyGeoRenders(UT_Array< GR_GeoRender * > &renders)
Definition: GR_Primitive.h:350
GLbitfield flags
Definition: glcorearb.h:1596
UT_Matrix4D myLocal
Definition: GR_Primitive.h:691
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:296
virtual bool requiresAlphaPass() const
Return true if this primitive requires an alpha pass.
Definition: GR_Primitive.h:230
GR_DecorRenderFlags
Definition: GR_Defines.h:232
void updateDecoration(RE_RenderContext r, GR_Decoration dec, const GR_UpdateParms &p, const GT_PrimitiveHandle &prim, RE_Geometry *geo)
Definition: GR_Primitive.h:773
GR_DecorationRender * myDecorRender
Definition: GR_Primitive.h:686
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:733
virtual bool supportsParallelDraw() const
Definition: GR_Primitive.h:271
const GEO_Primitive * getPrimitive(int seg) const
virtual void resetPrimitives()
Definition: GR_Primitive.h:79
bool myHasDetailPointNormal
Definition: GR_Primitive.h:684
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:52
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:578
int32 bumpDisplayOptionVersion()
Definition: GR_Primitive.h:299
bool drawInAlphaPass(GR_AlphaPass alpha) const
Return true if this should be drawn in the given alpha pass.
Definition: GR_Primitive.h:233
GR_Decoration
Definition: GR_Defines.h:164
GR_AlphaPass
Definition: GR_Defines.h:123
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
virtual void getGeoRenders(UT_Array< GR_GeoRender * > &renders)
Definition: GR_Primitive.h:349
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:308
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:388
set of parameters sent to GR_Primitive::update()
RE_GenericAttribID
Definition: RE_Types.h:355
GR_BasePrimType getParentPrimType() const
Definition: GR_Primitive.h:344
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
virtual bool isHighlighted() const
Only for the Scene Graph view: highlighted prims.
Definition: GR_Primitive.h:329
GR_RenderMode
Definition: GR_Defines.h:48
const GR_DisplayOption & dopts
GR_BasePrimType
Definition: GR_Defines.h:368
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:743
virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const
Definition: GR_Primitive.h:160
void setSupportedDecorations(int64 mask)
Definition: GR_Primitive.h:678
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:326
const GR_RenderInfo * getRenderInfo() const
Definition: GR_Primitive.h:347
#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:687
void setParentPrimType(GR_BasePrimType type)
set for those primitives that are within packed primitives
Definition: GR_Primitive.h:342
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:240
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:361
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:307
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
GA_API const UT_StringHolder parms
bool supportsDynamicCulling() const
Definition: GR_Primitive.h:288
int getAlphaPassMask() const
Definition: GR_Primitive.h:246
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:339
int64 supportedDecorations()
Definition: GR_Primitive.h:224
void setPrimUsed(bool used)
Definition: GR_Primitive.h:338
UT_BoundingBoxF myBBox
Definition: GR_Primitive.h:690
void supportsDynamicCulling(bool dc)
Definition: GR_Primitive.h:290
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
virtual bool supportsParallelUpdate() const
Definition: GR_Primitive.h:275
UT_IntrusivePtr< GR_Primitive > GR_PrimitivePtr
Definition: GR_Primitive.h:728
void setPrimTypeMask(GEO_PrimTypeCompat::TypeMask m)
Definition: GR_Primitive.h:675
SYS_FORCE_INLINE const GA_Attribute * findPointAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1048
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:685
GR_SelectMode
Definition: GR_Defines.h:243
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:244
GR_PickStyle
Definition: GR_Defines.h:254