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 to display component selections or not.
263  bool showSelections() const;
264 
265  /// Instancing matrix list and version (for the vertex array)
266  bool canDoInstancing() const;
267 
268  /// Returns true if the full object is selected at the scene level.
269  bool isObjectSelection() const;
270 
271  /// Returns true if the primitive supports packed prim culling when its
272  /// parent is a packed prim. On by default.
274  { return mySupportsDynamicCulling; }
276  { mySupportsDynamicCulling = dc; }
277 
278  /// Returns the current display option version for this primitive.
279  /// It will only be non-zero if the primitive responds to display option
280  /// changes and bumps the display option version.
282  { return myDispOptVersion; }
283 
285  {
286  myDispOptVersion++;
287  return myDispOptVersion;
288  }
289 
290  /// GT Primitive caching. This is handled by updatePrim()
291  /// @{
292  GT_PrimitiveHandle getCachedGTPrimitive() { return myCachedPrim; }
294  {
295  if(prim)
296  {
297  if(prim != myCachedPrim)
298  myCachedPrim = prim;
299  }
300  else
301  myCachedPrim = NULL;
302  }
303 
304  /// @}
305 
306  /// Called when a node is no longer actively displayed, but still cached
307  virtual void retirePrimitive();
308 
309  /// return the RE_Geometry containing the geometry to be decorated by user
310  /// display options. May return NULL if no user decorations are to be shown.
311  virtual RE_Geometry *getDecorationGeometry() { return NULL; }
312 
313  /// Only for the Scene Graph view: highlighted prims.
314  virtual bool isHighlighted() const { return false; }
315 
316  /// create a primitive for the given GT type, with appropriate cache name
317  /// and GL render level
318  static GR_Primitive *createPrimitive(GT_PrimitiveType ptype,
319  int geo_type,
320  const GR_RenderInfo *info,
321  const char *cache_name);
322 
323  void setPrimUsed(bool used) { myPrimUsed = used; }
324  bool isPrimUsed() const { return myPrimUsed; }
325 
326  /// set for those primitives that are within packed primitives
328  { myParentPrimType = type; }
330  { return myParentPrimType; }
331 
332  const GR_RenderInfo *getRenderInfo() const { return myInfo; }
333 
334  virtual void getGeoRenders(UT_Array<GR_GeoRender *> &renders) {}
335 
336  void addUpdateMessage(GR_ErrorManager::Source err_source,
337  GR_ErrorCode gr_code,
338  UT_StringHolder extra_text=UT_StringHolder(),
339  UT_StringHolder src_name=UT_StringHolder());
340  void addUpdateWarning(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 addUpdateError (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 addUpdateFatal (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 
353  void addRedrawMessage(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 addRedrawWarning(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 addRedrawError (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 addRedrawFatal (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  /// The base GL cache name assigned to this primitive.
371  const char * getCacheName() const { return myCacheName; }
372 
373  // For reference counted GR prims only
374  void incref() { myRef.add(1); }
375  void decref()
376  {
377  if( myRef.add(-1) == 0)
378  delete this;
379  }
380 
381 protected:
382  /// Primitive constructor. info and cache_name are assigned by the viewport.
383  /// GR_Primitive subclasses can assign a typemask which is used to determine
384  /// if the primitive is rendered in instances where only a subset of
385  /// primitive types is requested.
386  GR_Primitive(const GR_RenderInfo *info,
387  const char *cache_name,
388  GEO_PrimTypeCompat::TypeMask gaprimtype);
389 
390  virtual ~GR_Primitive();
391 
392 
393  /// Called when the geometry-related display options change, to determine if
394  /// an update is required. By default, no update is required. If the options
395  /// did change, return either DISPLAY_CHANGED, which will call update()
396  /// without bumping the display option version, or DISPLAY_VERSION_CHANGED,
397  /// which will bump the version.
398  /// If 'first_init' is true, this is being called to initialize any cached
399  /// display options. The return value will be ignored. This will happen
400  /// just after the primitive is created.
401  virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts,
402  bool first_init);
403 
404  /// Main update method, called when conditions change which may require the
405  /// geometry to be updated. These include geometry changes, selections,
406  /// volatile display options (level of detail), instancing updates,
407  /// and some GL state changes (if needsGLStateCheck returns true)
408  virtual void update(RE_RenderContext r,
409  const GT_PrimitiveHandle &primh,
410  const GR_UpdateParms &p) = 0;
411 
412  /// Main drawing method. update() will always be called before render(), but
413  /// render() may execute multiple times before the next update call. This
414  /// method should be fairly lightweight; do as much work in update() as
415  /// possible. There is no access to the GU_Detail from this method.
416  virtual void render(RE_RenderContext r,
417  GR_RenderMode render_mode,
419  GR_DrawParms dp) = 0;
420 
421  /// Render this primitive for picking, where pick_type is defined as one of
422  /// the pickable bits in GU_SelectType.h (like GR_PICK_GEOPOINT)
423  /// return the number of picks
424  virtual int renderPick(RE_RenderContext r,
425  const GR_DisplayOption *opt,
426  unsigned int pick_type,
427  GR_PickStyle pick_style,
428  bool has_pick_map) = 0;
429 
430  /// Render the attributes required for decoration 'decor' (like point
431  /// markers, uv text, normals, etc). 'overlay' should be set to true if
432  /// currently rendering in the overlay texture, false if in the main
433  /// viewport.
434  virtual void renderDecoration(RE_RenderContext r,
435  GR_Decoration decor,
436  const GR_DecorationParms &parms);
437 
438  /// Check if the builtin Houdini markers (point numbers, profile curves,
439  /// prim normals, etc) have changed since the last redraw, and return true
440  /// if at least one did. 'markers' is a list of markers to check that must
441  /// be terminated by GR_NO_DECORATION.
442  bool standardMarkersChanged(const GR_DisplayOption &opts,
443  const GR_Decoration *markers,
444  bool first_init);
445 
446  /// Updates a decoration for the pass RE_Geometry object. Called from
447  /// update().
448  void updateDecoration(RE_RenderContext r,
449  GR_Decoration dec,
450  const GR_UpdateParms &p,
451  const GT_PrimitiveHandle &prim,
452  RE_Geometry *geo);
453 
454  void updateDecoration(RE_RenderContext r,
455  GR_Decoration dec,
456  const GR_UpdateParms &p,
457  const GT_PrimitiveHandle &prim,
458  RV_Geometry *geo);
459 
460  void updateDecorationList(RE_RenderContext r,
461  const GR_Decoration *pdecs,
462  const GR_UpdateParms &p,
463  const GT_PrimitiveHandle &prim,
464  GR_GeoRender *geo);
465 
466  /// Helper mother to draw a decoration on a given GR_GeoRender object.
467  /// Called from renderDecoration() or render().
468  void drawDecoration(RE_RenderContext r,
469  GR_GeoRender *geo,
470  GR_Decoration dec,
471  const GR_DisplayOption *opts,
473  bool overlay,
474  bool override_vis,
475  int instance_group = -1,
476  GR_SelectMode *select_override = NULL,
479 
480  void drawVisualizer(RE_RenderContext r,
481  GR_GeoRender *geo,
482  const GR_VisualizerInfo *dec_info,
483  const GR_DisplayOption *opts,
487 
488 
489  /// Helper method to draw a decoration on a given RE_Geometry object.
490  /// Called from renderDeocration() or render().
491  void drawDecorationForGeo(RE_RenderContext r,
492  RE_Geometry *geo,
493  GR_Decoration dec,
494  const GR_DisplayOption *opts,
496  bool overlay,
497  bool override_vis,
498  int instance_group,
499  GR_SelectMode smode,
502  RE_OverrideList *override_list = NULL);
503 
504  void drawVisualizerForGeo(RE_RenderContext r,
505  RE_Geometry *geo,
506  const GR_VisualizerInfo *dec_info,
507  const GR_DisplayOption *opts,
511 
512  /// Helper method to draw a decoration on a given RE_Geometry object.
513  /// Called from renderDeocration() or render().
514  void drawDecorationForGeo(RE_RenderContext r,
515  RV_Geometry *geo,
516  GR_Decoration dec,
517  const GR_DisplayOption *opts,
519  bool overlay,
520  bool override_vis,
521  int instance_group,
522  GR_SelectMode smode,
525  RE_OverrideList *override_list = NULL);
526 
527  void drawVisualizerForGeo(RE_RenderContext r,
528  RV_Geometry *geo,
529  const GR_VisualizerInfo *dec_info,
530  const GR_DisplayOption *opts,
534 
535 
536  /// Helper method to draw a GR_GeoRender object. Called from render() or
537  /// renderDecoration().
538  void drawGeoRender(RE_RenderContext r,
539  GR_GeoRender *geo,
542  GR_DrawParms dp);
543  bool checkUserOptions(const GR_DisplayOption &opt) const;
544  void updateUserOptions(const GR_DisplayOption &opt);
545  const GR_UserOption *getUserDecoration(GR_Decoration dec) const;
546  void updateUserDecorations(RE_RenderContext r,
547  const GT_PrimitiveHandle &primh,
548  const GR_UpdateParms &p,
549  RE_Geometry *for_geo = NULL);
550 
551  GR_DispOptChange checkColorOverride(const GR_DisplayOption &opts,
552  bool first_init);
553 
554  GT_Primitive *createUnitSphere(const GT_RefineParms &parms);
555 
556 
557 
558  /// Return a GEO_Primitive derivative (GeoPrim) from the GT handle. The
559  /// GT handle must be referencing a GT_GEOPrimitive.
560  template <class GeoPrim>
562  const GeoPrim *&prim)
563  {
564  const GT_GEOPrimitive *geo =
565  dynamic_cast<const GT_GEOPrimitive*>(primh.get());
566  prim = dynamic_cast<const GeoPrim *>(geo->getPrimitive(0));
567  }
568 
569  /// Do picking for point attribute on GeoRender `gr`
570  ///
571  /// Only uses parameters `geo`, `select_mode`, and `select_inst`
572  /// if `gr` is null, ignores them and uses values set from `gr`
573  int doPickPoints(RE_RenderContext r,
574  const GR_DisplayOption *opts,
575  GR_GeoRender* gr,
576  RE_Geometry* geo,
577  GR_SelectMode select_mode,
578  int select_inst,
579  GR_PickStyle pickstyle,
580  bool has_pick_map,
581  RE_PrimType real_prim_type,
582  int real_connect_start,
583  int real_connect_num);
584 
585  int doPickPoints(RE_RenderContext r,
586  const GR_DisplayOption *opts,
587  GR_GeoRender* gr,
588  RV_Geometry* geo,
589  GR_SelectMode select_mode,
590  int select_inst,
591  GR_PickStyle pickstyle,
592  bool has_pick_map,
593  RE_PrimType real_prim_type,
594  int real_connect_start,
595  int real_connect_num);
596 
597  /// Do picking for point attribute on GeoRender `gr`
598  int doPickPoints(RE_RenderContext r,
599  const GR_DisplayOption *opts,
600  GR_GeoRender* gr,
601  GR_PickStyle pickstyle,
602  bool has_pick_map,
603  RE_PrimType real_prim_type,
604  int real_connect_start,
605  int real_connect_num);
606 
607  /// Create a pick buffer large enough to hold all picks from 'geo' with
608  /// 'picktype' selection style (GR_PICK_GEOPOINT, PRIMITIVE, etc)
609  /// The required vector size (1 or 2) will be returned in vsize (edges need
610  /// 2) and needs_2pass will be true if some picks require CPU support.
611  int getPickBufferSize(RE_Geometry *geo,
612  unsigned int picktype,
613  int &vector_size,
614  bool &needs_2pass,
615  int start_group = 4,
616  int end_group = -1,
617  GR_PickStyle pickstyle
618  = GR_PICK_NONE) const;
619 
620 
621  /// Create a pick buffer large enough to hold all picks from 'geo' with
622  /// 'picktype' selection style (GR_PICK_GEOPOINT, PRIMITIVE, etc)
623  /// The required vector size (1 or 2) will be returned in vsize (edges need
624  /// 2) and needs_2pass will be true if some picks require CPU support.
625  int getPickBufferSize(const GR_PickRender *geo,
626  unsigned int picktype,
627  int &vector_size,
628  bool &needs_2pass,
629  int start_group = 4,
630  int end_group = -1,
631  GR_PickStyle pickstyle
632  = GR_PICK_NONE) const;
633 
634  /// creates a ivec4 pick buffer with a pickID attribute with buffer_size
635  /// points. This primitive owns the buffer, and there is only one.
636  GR_PickBuffer *createPickBuffer(RE_RenderContext r, int buffer_size,
637  int vector_size = 1,
638  bool inconclusive_stream_too = false,
639  const GR_PickRender *geo = nullptr);
640 
641  /// creates a PickRender wrapping the passed in GeoRender,
642  /// also creates a pick buffer if needed
644  const GR_DisplayOption *opts,
645  GR_GeoRender* gr,
646  unsigned int picktype);
647 
648  /// accumulate picks into the myInfo.myPicks array so that it can be passed
649  /// up to higher level code. Some effort is made to remove duplicate pickIDs,
650  /// mostly from neighbouring picks. If 'pick_buffer' is NULL, myPickBuffer
651  /// is used.
652  int accumulatePickIDs(RE_RenderContext r, int npicks,
653  GR_PickBuffer *pick_buffer = NULL);
654 
655  GR_PickCompMode setupPrimPickMode(RE_RenderContext r,GR_GeoRender *geo) const;
656 
657 
659  { myGAPrimMask = m; }
660 
662  { myDecorMask = mask; }
663 
668 
669  // For deferred rendering
674 
675 private:
676  int pickPoints(RE_RenderContext r,
677  GR_PickRender* pr,
678  GR_SelectMode select_mode,
679  int select_inst,
680  GR_PickStyle pickstyle,
681  bool has_pick_map,
682  RE_PrimType real_prim_type,
683  int real_connect_start,
684  int real_connect_num);
685 
686  UT_String myCacheName;
687  UT_Int64Array myUserDispOptions;
688  int32 myDispOptVersion;
689  GEO_PrimTypeCompat::TypeMask myGAPrimMask;
690  UT_String myColorOverrideOpt;
691  unsigned myPrimUsed : 1,
692  myUserDecorationsProcessed : 1,
693  myDispOptInit : 1;
694  GR_BasePrimType myParentPrimType;
695 
696  // for cache access only; do not dereference.
697  GT_PrimitiveHandle myCachedPrim;
698 
699  int myMarkerState[GR_MAX_DECORATIONS];//0=off,1=on,-1=undef
700  int64 myDecorMask;
701  SYS_AtomicInt32 myRef;
702  int myAlphaPassMask;
703 
704  // uncached buffer for doing transform feedback picking
705  UT_UniquePtr<GR_PickBuffer> myPickBuffer;
706 };
707 
709 static inline void intrusive_ptr_add_ref(GR_Primitive *pr) { pr->incref(); }
710 static inline void intrusive_ptr_release(GR_Primitive *pr) { pr->decref(); }
711 
714 {
715  GR_DispOptChange changed = displayOptionChange(opts, !myDispOptInit);
716 
717  myDispOptInit = true;
718 
719  return changed;
720 }
721 
722 inline void
724  const GT_PrimitiveHandle &primh,
725  const GR_UpdateParms &p)
726 {
728  myCachedPrim = primh;
730  rlock.isValid() ? rlock->findPointAttribute("N") != NULL : false;
731  myUserDecorationsProcessed = false;
732 
733  if(!myDispOptInit)
734  {
735  displayOptionChange(p.dopts, true);
736  myDispOptInit = true;
737  }
738 
739  update(r, primh, p);
740 
742  myAlphaPassMask = GR_ALPHA_PASS_OPAQUE;
743  else
744  myAlphaPassMask = 0;
745 
747  myAlphaPassMask |= GR_ALPHA_PASS_NORMAL;
748 
749  updateUserDecorations(r, primh, p);
750 }
751 
752 inline void
754  GR_Decoration dec,
755  const GR_UpdateParms &p,
756  const GT_PrimitiveHandle &prim,
757  RE_Geometry *geo)
758 {
759  // Don't draw decorations for packed primitives
763  return;
764 
765  myDecorRender->updateDecoration(r, dec, *prim.get(), p, *geo);
766 }
767 
768 inline void
770  GR_Decoration dec,
771  const GR_UpdateParms &p,
772  const GT_PrimitiveHandle &prim,
773  RV_Geometry *geo)
774 {
775  // Don't draw decorations for packed primitives
779  return;
780 
781  myDecorRender->updateDecoration(r, dec, *prim.get(), p, *geo);
782 }
783 
784 #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:671
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:281
virtual bool requiresAlphaPass() const
Return true if this primitive requires an alpha pass.
Definition: GR_Primitive.h:223
GR_DecorRenderFlags
Definition: GR_Defines.h:219
void updateDecoration(RE_RenderContext r, GR_Decoration dec, const GR_UpdateParms &p, const GT_PrimitiveHandle &prim, RE_Geometry *geo)
Definition: GR_Primitive.h:753
GR_DecorationRender * myDecorRender
Definition: GR_Primitive.h:666
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:713
const GEO_Primitive * getPrimitive(int seg) const
virtual void resetPrimitives()
Definition: GR_Primitive.h:79
bool myHasDetailPointNormal
Definition: GR_Primitive.h:664
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:164
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
void getGEOPrimFromGT(const GT_PrimitiveHandle &primh, const GeoPrim *&prim)
Definition: GR_Primitive.h:561
int32 bumpDisplayOptionVersion()
Definition: GR_Primitive.h:284
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:151
GR_AlphaPass
Definition: GR_Defines.h:117
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:334
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:293
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:371
set of parameters sent to GR_Primitive::update()
RE_GenericAttribID
Definition: RE_Types.h:348
GR_BasePrimType getParentPrimType() const
Definition: GR_Primitive.h:329
Definition: core.h:760
virtual bool isHighlighted() const
Only for the Scene Graph view: highlighted prims.
Definition: GR_Primitive.h:314
GR_RenderMode
Definition: GR_Defines.h:47
const GR_DisplayOption & dopts
GR_BasePrimType
Definition: GR_Defines.h:352
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:723
virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const
Definition: GR_Primitive.h:160
void setSupportedDecorations(int64 mask)
Definition: GR_Primitive.h:661
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:311
const GR_RenderInfo * getRenderInfo() const
Definition: GR_Primitive.h:332
#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:667
void setParentPrimType(GR_BasePrimType type)
set for those primitives that are within packed primitives
Definition: GR_Primitive.h:327
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:345
GR_RenderFlags
Definition: GR_Defines.h:85
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
GT_PrimitiveHandle getCachedGTPrimitive()
Definition: GR_Primitive.h:292
GR_RenderVersion
Definition: GR_Defines.h:21
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:273
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:324
int64 supportedDecorations()
Definition: GR_Primitive.h:217
void setPrimUsed(bool used)
Definition: GR_Primitive.h:323
UT_BoundingBoxF myBBox
Definition: GR_Primitive.h:670
void supportsDynamicCulling(bool dc)
Definition: GR_Primitive.h:275
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:33
GLboolean r
Definition: glcorearb.h:1222
UT_IntrusivePtr< GR_Primitive > GR_PrimitivePtr
Definition: GR_Primitive.h:708
void setPrimTypeMask(GEO_PrimTypeCompat::TypeMask m)
Definition: GR_Primitive.h:658
SYS_FORCE_INLINE const GA_Attribute * findPointAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1034
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:665
GR_SelectMode
Definition: GR_Defines.h:229
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:240