HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PrimAgentShape.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_PrimAgentShape.h (GR Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef GR_PrimAgentShape_h
11 #define GR_PrimAgentShape_h
12 
13 #include "GR_PrimPacked.h"
14 #include <UT/UT_NonCopyable.h>
15 #include <GT/GT_PrimAgentShape.h>
16 #include <GT/GT_AgentSupport.h>
17 
18 #ifdef USE_VULKAN
19 #include "GR_UtilsVK.h"
20 class RV_ShaderBlock;
21 class RV_ShaderVaraibleSet;
22 class GR_VulkanAgentData : public GT_VulkanAgentData
23 {
24 public:
25  GR_VulkanAgentData() {}
26 
27  UT_NON_COPYABLE(GR_VulkanAgentData);
28 
32  UT_Array<UT_UniquePtr<GR_InstanceBuffer>> InstanceTransforms;
36  UT_Array<RE_CacheVersion> SelVersion;
37 };
38 #endif
39 
40 
42 {
43 public:
44  GR_PrimAgentShape(const GR_RenderInfo *info,
45  const char *cache_name,
46  const GT_PrimitiveHandle &pack_prim,
47  const GT_PrimitiveHandle &shape_prim);
48  ~GR_PrimAgentShape() override;
49 
50  const char *className() const override { return "GR_PrimAgentShape"; }
51 
53  { return GR_BASE_PRIM_AGENT_SHAPE; }
54 
56  int geo_type,
57  const GT_PrimitiveHandle &ph,
58  const GEO_Primitive *prim) override;
59 
60  GR_DispOptChange displayOptionChange(const GR_DisplayOption &opt,
61  bool first_init) override;
62 
64  const GT_PrimitiveHandle &primh,
65  const GR_UpdateParms &p) override;
66 
68  GR_RenderMode render_mode,
70  GR_DrawParms dp) override;
71 
73  const GR_DisplayOption *opt,
74  unsigned int pick_type,
75  GR_PickStyle pick_style,
76  bool has_pick_map) override;
77 
79  const GR_DisplayOption &opt) const override
80  { return opt.shadingMode() >= GR_FLAT_SHADED; }
82  const GR_ViewUpdateParms &parms) override;
83 
85  const UT_Matrix4D &objviewprojj,
86  const UT_BoundingBoxD *bbox = nullptr) override
87  { return myVisibilityFlag; }
88 
89  bool requiresAlphaPass() const override { return false; }
90  bool getSingleTransform(UT_Matrix4D &mat) const override
91  { return false; }
92 
93 #ifdef USE_VULKAN
94  static bool initShaders(RV_Instance* inst);
95  static void cleanupShaders();
96 #endif
97 private:
98  const GT_PrimAgentShape &getShape() const
99  {
100  return *UTverify_cast<const GT_PrimAgentShape *>(myPackedPrim.get());
101  }
102 
103  void processVisibility(RE_RenderContext r,
104  const GR_DisplayOption &dopts);
105  void updateTransforms(RE_RenderContext r,
106  const GU_ConstDetailHandle &geo,
107  bool geo_changed);
108  void updateInstanceTransforms(RE_RenderContext r,
109  const GU_ConstDetailHandle &geo,
110  bool geo_changed);
111  void updateRigTransformsGL(RE_Render *r,
112  const GU_ConstDetailHandle &geo,
113  bool geo_changed);
114  void updateBlendWeightsGL(RE_Render *r,
115  const GU_ConstDetailHandle &geo,
116  bool geo_changed);
117 #ifdef USE_VULKAN
118  void updateRigTransforms(RV_Render *r,
119  const GU_ConstDetailHandle &geo,
120  bool geo_changed);
121  void updatePrimID(RV_Render *r, bool geo_changed);
122  void updateColor(RV_Render *r, bool geo_changed);
123  void processSelection(RV_Render *r,
124  const RE_CacheVersion &select_version);
125 #endif
126  void processSelectionGL(RE_RenderContext r,
127  const RE_CacheVersion &select_ver);
128  void freeVertexArrays();
129  void updatePrimIDGL(RE_Render *r, bool geo_changed);
130  void updateColorGL(RE_Render *r, bool geo_changed);
131 
132  int myLODLevel;
133  int myTotalAgents;
134  int64 myLastInstVersion;
135  int myTransformSerial;
136  int mySelectionSerial;
137  int myRigSerial;
138  GT_ShapeLODGroupHandle myShapeGroup;
139  UT_IntArray myTransformIndexMap;
140  GR_UpdateReason myDeferredReason;
141  bool myDeformingShape;
142  bool myVisibilityFlag;
143  bool myLastWire;
144  bool myLastLODEnable;
145  fpreal myLastLODBias;
146  int myLastLODBase;
147 
148  // Only the primary LOD holds any of these.
149  UT_Array<RE_VertexArray *> myTransformVA;
150  UT_Array<RE_VertexArray *> myRigTransformVA;
151  UT_Array<RE_VertexArray *> myBlendWeightVA;
152  UT_Array<RE_VertexArray *> myShapeSelectionVA;
153  UT_Array<RE_VertexArray *> myPrimIDVA;
155 
156 #ifdef USE_VULKAN
160 #endif
161 };
162 
163 
164 
165 #endif
bool inViewFrustum(const UT_Matrix4D &objviewprojj, const UT_BoundingBoxD *bbox=nullptr) override
GLbitfield flags
Definition: glcorearb.h:1596
int renderPick(RE_RenderContext r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map) override
RE_VertexArray * myColorVA
void render(RE_RenderContext r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp) override
Set of parameters sent to GR_Primitive::viewUpdate().
void shadingMode(GR_ShadingMode shading_mode)
void viewUpdate(RE_RenderContext r, const GR_ViewUpdateParms &parms) override
GT_API const UT_StringHolder cache_name
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:229
Temporary container for either a RV_Render and an RE_Render.
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:47
GR_BasePrimType
Definition: GR_Defines.h:352
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim) override
#define GR_API
Definition: GR_API.h:10
GR_UpdateReason
Definition: GR_Defines.h:300
long long int64
Definition: SYS_Types.h:116
bool updateOnViewChange(const GR_DisplayOption &opt) const override
If this primitive requires an update when the view changes, return true.
GR_PrimAcceptResult
Definition: GR_Defines.h:345
GR_RenderFlags
Definition: GR_Defines.h:85
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:36
GLdouble t
Definition: glad.h:2397
const char * className() const override
Return a string version of this class's name.
GT_PrimitiveType
GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init) override
fpreal64 fpreal
Definition: SYS_Types.h:277
A shape belonging to agents, instanced with material assignments.
void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p) override
GR_BasePrimType getBasePrimType() const override
The base primitive type is usually NORMAL unless this is a packed type.
bool requiresAlphaPass() const override
Return true if this primitive requires an alpha pass.
Simple class for a mutli-integer cache tag.
GLboolean r
Definition: glcorearb.h:1222
bool getSingleTransform(UT_Matrix4D &mat) const override
GR_PickStyle
Definition: GR_Defines.h:240