HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GR_PrimPacked.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_PrimPacked.h (GR Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef __GR_PrimPacked__
11 #define __GR_PrimPacked__
12 
13 #include "GR_Primitive.h"
14 #include "GR_MaterialGroups.h"
15 
16 #include <RE/RE_VertexArray.h>
17 
19 {
20 public:
21  GR_PrimPacked(const GR_RenderInfo *info,
22  const char *cache_name,
23  const GT_PrimitiveHandle &packed_prim,
24  const GT_PrimitiveHandle &instanced_prim,
25  const GU_ConstDetailHandle &instanced_gdp,
26  int prim_index = -1);
27 
28  virtual ~GR_PrimPacked();
29 
30  virtual const char *className() const { return "GR_PrimPacked"; }
31 
33  { return GR_BASE_PRIM_PACKED; }
35  { return myInstancedPrim; }
36 
37  const GT_PrimitiveHandle &instancePrim() const { return myInstancedPrim; }
38 
39  void setPackedPrim(const GT_PrimitiveHandle &packed_prim);
40  void setInstancedPrim(const GT_PrimitiveHandle &instance,
41  const GU_ConstDetailHandle &instance_gdp)
42  {
43  myInstancedPrim = instance;
44  myInstancedDetail = instance_gdp;
45  }
46  void setPrimIndex(int pindex)
47  { myPrimIndex = pindex; }
48 
50  int geo_type,
51  const GT_PrimitiveHandle &ph,
52  const GEO_Primitive *prim);
53 
54  virtual void update(RE_Render *r,
55  const GT_PrimitiveHandle &primh,
56  const GR_UpdateParms &p);
57 
58  virtual void checkForDeferredDraw(const RE_Render *r,
61  const GR_DrawParms &dp,
62  const UT_Matrix4D &proj_view,
63  const UT_Matrix4D &object,
64  bool &visible,
65  bool &defer);
66 
67  virtual void render(RE_Render *r,
68  GR_RenderMode render_mode,
70  GR_DrawParms dp);
71 
72  virtual void renderDecoration(RE_Render *r,
73  GR_Decoration decor,
74  const GR_DecorationParms &parms);
75  virtual int renderPick(RE_Render *r,
76  const GR_DisplayOption *opt,
77  unsigned int pick_type,
78  GR_PickStyle pick_style,
79  bool has_pick_map);
80 
81  bool checkForTransformChange();
82 
83  // Delegate these to the child prim.
84  virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts,
85  bool first_init);
86  virtual bool updateOnViewChange(const GR_DisplayOption &) const;
87  virtual void viewUpdate(RE_Render *r,
88  const GR_ViewUpdateParms &parms);
89  virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const;
90  virtual bool checkGLState(RE_Render *r,const GR_DisplayOption &opt);
91  virtual bool setup(const GR_DisplayOption *);
92  virtual void cleanup(RE_Render *r);
93 
94  virtual bool requiresAlphaPass() const;
95  virtual const GA_Primitive *getGAPrimitive(const GU_Detail *gdp,
96  exint primitive_id) const;
97  virtual exint getGAVertex(const GU_Detail *gdp,
98  exint vertex_id) const;
100  virtual bool renderInAlphaPass(GR_AlphaPass a);
101  virtual bool inViewFrustum(const UT_Matrix4D &objviewproj);
102  virtual bool getBoundingBox(UT_BoundingBoxD &bbox) const;
103 
104  virtual exint getNumGLPrimitives(const GR_DisplayOption *);
105  virtual void retirePrimitive();
106 
107  GR_SelectMode getSelectionMode(const GU_Detail &gdp,
108  GU_SelectionHandle &selection) const;
109 
110  void setPickID(GA_Index prim_id, GA_Index point_id);
111 
112  void setInstanceHookPrim(GR_Primitive *prim);
113 protected:
114  virtual bool isFragment() const { return false; }
115  virtual bool getSingleTransform(UT_Matrix4D &mat) const
116  { mat = myInstancePrimTransform; return true; }
117 
118  bool updateCacheName(const GT_PrimitiveHandle &iph);
119  void updateInstanceGeometry(RE_Render *r,
120  const GT_PrimitiveHandle &container_prim,
121  const GR_UpdateParms &p,
122  bool build_anchors);
123 
124  virtual void buildAnchorsGL3(RE_Render *r,
125  const GR_UpdateParms &p,
126  const GT_PrimitiveHandle &xforms);
127 
128  // Given the packed geometry handle and the update reason for the packed
129  // primitive, determine the update reason for the packed geometry.
130  GR_UpdateReason checkForPackedGeoChanges(const GT_PrimitiveHandle &ph,
131  GR_UpdateReason reason);
132 
133 
134  // Packed primitive
139 
140  // Instanced (contained) primitive
150 
158 
161 
168 
171 
173 
175 
176  // For GR_PrimPacked only
178 
181 };
182 
184 {
185 public:
187  const char *cache_name,
188  const GT_PrimitiveHandle &packed_prim,
189  const GT_PrimitiveHandle &instanced_prim,
190  const GU_ConstDetailHandle &instanced_gdp)
191  : GR_PrimPacked(info, cache_name,packed_prim,instanced_prim,instanced_gdp)
192  {}
193 
194 
195  virtual const char *className() const { return "GR_PrimPackedMesh"; }
196 
198  { return GR_BASE_PRIM_PACKED_MESH; }
199 };
200 
201 
204  bool first_init)
205 {
206  if(myInstance)
207  return myInstance->checkDisplayOptionChange(opts);
208  return DISPLAY_UNCHANGED;
209 }
210 
211 inline bool
213 {
214  if(myInstance)
215  return myInstance->updateOnViewChange(opt);
216  return false;
217 }
218 
219 inline void
221 {
222  if(myInstance)
223  myInstance->viewUpdate(r, parms);
224 }
225 
226 inline bool
228 {
229  if(myInstance)
230  return myInstance->needsGLStateCheck(opts);
231  return false;
232 }
233 
234 inline bool
236 {
237  if(myInstance)
238  return myInstance->checkGLState(r,opts);
239  return false;
240 }
241 
242 inline bool
244 {
245  if(myInstance)
246  return myInstance->setup(d);
247  return false;
248 }
249 
250 inline void
252 {
253  if(myInstance)
254  myInstance->cleanup(r);
255 }
256 
257 
258 inline bool
260 {
261  if(myInstance)
262  return myInstance->requiresAlphaPass();
263  return false;
264 }
265 
266 inline const GA_Primitive *
268  exint primitive_id) const
269 {
270  if(myInstance)
271  return myInstance->getGAPrimitive(gdp, primitive_id);
272  return NULL;
273 }
274 
275 inline exint
277  exint vertex_id) const
278 {
279  if(myInstance)
280  return myInstance->getGAVertex(gdp, vertex_id);
281  return exint(-1);
282 }
283 
284 inline RE_Geometry *
286 {
287  return NULL;
288 }
289 
290 inline bool
292 {
293  if(myInstance)
294  return myInstance->renderInAlphaPass(a);
295  return true;
296 }
297 
298 inline bool
300 {
301  if(myInstance)
302  return myInstance->inViewFrustum(objviewproj);
303  // if no instance, no point in rendering nothing, so cull
304  return false;
305 }
306 
307 inline bool
309 {
310  return myInstance ? myInstance->getBoundingBox(bbox) : false;
311 }
312 
313 inline exint
315 {
316  return myInstance ? myInstance->getNumGLPrimitives(opt) : 0;
317 }
318 
319 #endif
320 
virtual bool checkGLState(RE_Render *r, const GR_DisplayOption &opt)
virtual bool renderInAlphaPass(GR_AlphaPass a)
Return true if this primitive renders in the specified alpha pass.
virtual bool getSingleTransform(UT_Matrix4D &mat) const
virtual bool updateOnViewChange(const GR_DisplayOption &) const
If this primitive requires an update when the view changes, return true.
Definition: GR_Primitive.h:118
virtual exint getNumGLPrimitives(const GR_DisplayOption *)
virtual bool requiresAlphaPass() const
Return true if this primitive requires an alpha pass.
Definition: GR_Primitive.h:201
virtual GR_BasePrimType getBasePrimType() const
The base primitive type is usually NORMAL unless this is a packed type.
RE_VertexArray * myColorVA
int64 myInstancedDetailID
int64 myInstancedDetailCacheCount
Set of parameters sent to GR_Primitive::viewUpdate().
virtual const char * className() const
Return a string version of this class's name.
Definition: GR_PrimPacked.h:30
GR_DispOptChange checkDisplayOptionChange(const GR_DisplayOption &opts)
Definition: GR_Primitive.h:553
GT_DataArrayHandle myPointIDs
GA_Index myPrimID
RE_VertexArrayRef myCenterPointP
virtual void cleanup(RE_Render *r)
Definition: GR_Primitive.h:183
virtual const GA_Primitive * getGAPrimitive(const GU_Detail *gdp, exint primitive_id) const
virtual bool inViewFrustum(const UT_Matrix4D &objviewproj)
GT_PrimitiveHandle myPackedPrim
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:53
UT_Vector3F myInstancePoint
virtual void viewUpdate(RE_Render *r, const GR_ViewUpdateParms &parms)
GR_SelectMode myPointSelectMode
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
GLbitfield flags
Definition: glcorearb.h:1595
virtual GR_BasePrimType getBasePrimType() const
The base primitive type is usually NORMAL unless this is a packed type.
Definition: GR_PrimPacked.h:32
virtual bool checkGLState(RE_Render *r, const GR_DisplayOption &opts)
Definition: GR_Primitive.h:149
GR_Decoration
Definition: GR_Defines.h:137
GR_PrimPackedMesh(const GR_RenderInfo *info, const char *cache_name, const GT_PrimitiveHandle &packed_prim, const GT_PrimitiveHandle &instanced_prim, const GU_ConstDetailHandle &instanced_gdp)
GR_AlphaPass
Definition: GR_Defines.h:107
A class that manages material assignments to different groups of primitives.
virtual int renderPick(RE_Render *r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map)=0
RE_CacheVersion myCenterPointCacheVersion
virtual bool getBoundingBox(UT_BoundingBoxD &bbox) const
Returns the bounding box of this primitive if it can be determined.
virtual void render(RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp)=0
set of parameters sent to GR_Primitive::update()
GT_DataArrayHandle myPrimIDs
long long int64
Definition: SYS_Types.h:100
virtual const GA_Primitive * getGAPrimitive(const GU_Detail *gdp, exint primitive_id) const
GR_RenderMode
Definition: GR_Defines.h:42
GR_BasePrimType
Definition: GR_Defines.h:327
RE_VertexArrayRef myCenterPrimP
RE_VertexArrayRef myCenterPrimInstMat
virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const
Definition: GR_Primitive.h:147
virtual bool renderInAlphaPass(GR_AlphaPass a)
Return true if this primitive renders in the specified alpha pass.
int64 exint
Definition: SYS_Types.h:109
virtual void retirePrimitive()
Called when a node is no longer actively displayed, but still cached.
RE_Geometry * myCenterPrims
virtual RE_Geometry * getDecorationGeometry()
Definition: GR_Primitive.h:275
bool myPrimSwappedFlag
void setInstancedPrim(const GT_PrimitiveHandle &instance, const GU_ConstDetailHandle &instance_gdp)
Definition: GR_PrimPacked.h:40
virtual exint getNumGLPrimitives(const GR_DisplayOption *)
#define GR_API
Definition: GR_API.h:10
GR_UpdateReason
Definition: GR_Defines.h:278
virtual bool getBoundingBox(UT_BoundingBoxD &bbox) const
Returns the bounding box of this primitive if it can be determined.
Definition: GR_Primitive.h:210
GA_Index myOverridePrimID
UT_Matrix4D myInstancePrimTransform
virtual bool setup(const GR_DisplayOption *)
Definition: GR_Primitive.h:181
GR_PrimAcceptResult
Definition: GR_Defines.h:320
virtual void viewUpdate(RE_Render *r, const GR_ViewUpdateParms &parms)
Definition: GR_Primitive.h:128
GR_RenderFlags
Definition: GR_Defines.h:77
RE_VertexArrayRef myCenterPointInstMat
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
virtual bool needsGLStateCheck(const GR_DisplayOption &opts) const
GA_Index myOverridePointID
GT_PrimitiveType myInstancedPrimType
virtual const char * className() const
Return a string version of this class's name.
GU_ConstDetailHandle myInstancedDetail
GLenum mode
Definition: glcorearb.h:98
GR_Primitive * myInstance
GT_PrimitiveType
virtual GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim)=0
virtual bool requiresAlphaPass() const
Return true if this primitive requires an alpha pass.
virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init)
virtual exint getGAVertex(const GU_Detail *gdp, exint vertex_id) const
virtual bool inViewFrustum(const UT_Matrix4D &objviewproj)
Definition: GR_Primitive.h:189
virtual RE_Geometry * getDecorationGeometry()
virtual bool isFragment() const
virtual void update(RE_Render *r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p)=0
const GT_PrimitiveHandle & instancePrim() const
Definition: GR_PrimPacked.h:37
GR_SelectMode mySelectMode
Simple class for a mutli-integer cache tag.
int64 myPackedPVersion
virtual void checkForDeferredDraw(const RE_Render *r, GR_RenderMode mode, GR_RenderFlags flags, const GR_DrawParms &dp, const UT_Matrix4D &proj_view, const UT_Matrix4D &object, bool &visible, bool &defer)
GLboolean r
Definition: glcorearb.h:1221
GT_PrimitiveHandle myInstancedPrim
virtual void cleanup(RE_Render *r)
virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init)
virtual GT_PrimitiveHandle getInstancePrim() const
Definition: GR_PrimPacked.h:34
int64 myPrimUniqueID
GR_MaterialGroups myMatGroups
int64 myAlembicVersion
void setPrimIndex(int pindex)
Definition: GR_PrimPacked.h:46
virtual void renderDecoration(RE_Render *r, GR_Decoration decor, const GR_DecorationParms &parms)
RE_Geometry * myCenterPoints
GR_SelectMode
Definition: GR_Defines.h:215
virtual exint getGAVertex(const GU_Detail *gdp, exint vertex_id) const
virtual bool updateOnViewChange(const GR_DisplayOption &) const
If this primitive requires an update when the view changes, return true.
virtual bool setup(const GR_DisplayOption *)
GR_PickStyle
Definition: GR_Defines.h:226