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
149 
157 
160 
167 
170 
172 
174 
175  // For GR_PrimPacked only
177 
180 };
181 
183 {
184 public:
186  const char *cache_name,
187  const GT_PrimitiveHandle &packed_prim,
188  const GT_PrimitiveHandle &instanced_prim,
189  const GU_ConstDetailHandle &instanced_gdp)
190  : GR_PrimPacked(info, cache_name,packed_prim,instanced_prim,instanced_gdp)
191  {}
192 
193 
194  virtual const char *className() const { return "GR_PrimPackedMesh"; }
195 
197  { return GR_BASE_PRIM_PACKED_MESH; }
198 };
199 
200 
203  bool first_init)
204 {
205  if(myInstance)
206  return myInstance->checkDisplayOptionChange(opts);
207  return DISPLAY_UNCHANGED;
208 }
209 
210 inline bool
212 {
213  if(myInstance)
214  return myInstance->updateOnViewChange(opt);
215  return false;
216 }
217 
218 inline void
220 {
221  if(myInstance)
222  myInstance->viewUpdate(r, parms);
223 }
224 
225 inline bool
227 {
228  if(myInstance)
229  return myInstance->needsGLStateCheck(opts);
230  return false;
231 }
232 
233 inline bool
235 {
236  if(myInstance)
237  return myInstance->checkGLState(r,opts);
238  return false;
239 }
240 
241 inline bool
243 {
244  if(myInstance)
245  return myInstance->setup(d);
246  return false;
247 }
248 
249 inline void
251 {
252  if(myInstance)
253  myInstance->cleanup(r);
254 }
255 
256 
257 inline bool
259 {
260  if(myInstance)
261  return myInstance->requiresAlphaPass();
262  return false;
263 }
264 
265 inline const GA_Primitive *
267  exint primitive_id) const
268 {
269  if(myInstance)
270  return myInstance->getGAPrimitive(gdp, primitive_id);
271  return NULL;
272 }
273 
274 inline exint
276  exint vertex_id) const
277 {
278  if(myInstance)
279  return myInstance->getGAVertex(gdp, vertex_id);
280  return exint(-1);
281 }
282 
283 inline RE_Geometry *
285 {
286  return NULL;
287 }
288 
289 inline bool
291 {
292  if(myInstance)
293  return myInstance->renderInAlphaPass(a);
294  return true;
295 }
296 
297 inline bool
299 {
300  if(myInstance)
301  return myInstance->inViewFrustum(objviewproj);
302  // if no instance, no point in rendering nothing, so cull
303  return false;
304 }
305 
306 inline bool
308 {
309  return myInstance ? myInstance->getBoundingBox(bbox) : false;
310 }
311 
312 inline exint
314 {
315  return myInstance ? myInstance->getNumGLPrimitives(opt) : 0;
316 }
317 
318 #endif
319 
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.
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