HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PolySurfaceVK.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_PolySurfaceVK ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Line and ribbon primitive.
10  */
11 #ifndef GR_PolySurfaceVK_h
12 #define GR_PolySurfaceVK_h
13 
14 #include "GR_API.h"
15 #include "GR_GeoRenderVK.h"
16 #include <GT/GT_PrimPolygonMesh.h>
17 #include <RV/RV_Geometry.h>
18 #include <RE/RE_ShaderHandle.h>
19 #include <UT/UT_Map.h>
20 
21 class RV_Geometry;
22 class RV_Render;
23 class RV_ShaderProgram;
24 class GR_Material;
25 
27 {
28 public:
30  ~GR_PolySurfaceVK() override;
31 
32  const char *className() const override { return "GR_PolySurfaceVK"; }
33 
34  void getPickConnectGroup(unsigned int pick_mode,
35  GR_PickGeometry pick_geo,
36  int &out_connect_start,
37  int &out_connect_num) override;
38 
39  RV_Geometry *getVkPickGeometry(unsigned int pick_mode) override;
40 
42  PrimitiveType prim_type,
43  RV_PrimType render_prim,
44  RV_Geometry &geo,
45  int &out_connect_start,
46  int &out_connect_num) override;
47 
48  void update(RE_RenderContext rc,
49  const GT_PrimitiveHandle &primh,
50  const GR_UpdateParms &parms,
51  const char *cache_name) override;
52 
53  void draw(RE_RenderContext rc,
56  GR_DrawParms dp) override;
57 
58  exint getNumGLPrimitives() const override;
59  bool hasTransparency() const override
60  { return myHasAlpha || myHasBlendedMaterial; }
61 
62  static bool initShaders(RV_Instance* inst);
63  static void cleanupShaders();
64 
65  const GT_PrimitiveHandle &getMesh() const { return myFlattenedMesh; }
66  const GT_PrimitiveHandle &getConvexedMesh() const {return myConvexedMesh;}
67 private:
68 
69  void updateSurface(RV_Render *r,
70  GT_PrimPolygonMesh *pmesh,
71  const GR_UpdateParms &p,
72  bool needs_tangents,
73  GR_Material *material);
74 
75  void convexAndFlattenMesh(GT_PrimPolygonMesh *pmesh,
76  const GR_UpdateParms &parms,
77  bool needs_tangents,
78  GT_PrimPolygonMesh* &out_cmesh,
79  bool &out_flattened);
80 
81  void buildNormals(GT_PrimPolygonMesh *pmesh,
82  const GR_UpdateParms &parms,
83  bool needs_tangents,
84  GT_PrimPolygonMesh* &out_nmesh);
85 
86  void buildSurfaceConnectivity(const GT_PrimPolygonMesh *pmesh,
87  const GR_UpdateParms &parms,
88  UT_Int32Array &connect_indices);
89 
90  void buildVertexNumbers(const GT_PrimPolygonMesh *pmesh,
91  const GR_UpdateParms &parms,
92  GT_Int8Array &vert_num);
93 
94  void buildWireframeConnectivity(
95  const GT_PrimPolygonMesh *pmesh,
96  const GR_UpdateParms &parms,
97  UT_Int32Array &connect_indices,
98  UT_Int32Array &faces,
99  bool target_vert = false);
100 
101  void buildUVBoundaryConnectivity(
102  const GT_PrimPolygonMesh *pmesh,
103  const GR_UpdateParms &p,
104  UT_Int32Array &connect,
105  UT_Int32Array &face_list);
106 
107  void buildInstanceTransform(RV_Render *r,
108  GT_PrimitiveHandle primh,
109  const GR_UpdateParms &p);
110 
111  RV_ShaderProgram * fetchShader(RV_Render *r,
114  const GR_Material *mat,
115  const GR_DisplayOption *opts,
116  bool &uses_mat);
117 
118  bool updateBoneTransforms(RV_Render *r,
119  const GT_DataArrayHandle &a);
120 
121  void updateBlendShapes(RV_Render *r,
122  const GT_DataArrayHandle &a);
123 
124 
125  GT_PrimitiveHandle myNormalMesh; // with generated normals
126  GT_PrimitiveHandle myTangentMesh; // with generated tangents
127  GT_PrimitiveHandle myFlattenedMesh; // with only Point/Detail attribs
128 
129  GT_PrimitiveHandle myBaseMesh; // original
130  GT_PrimitiveHandle myConvexedMesh; // convexed
131 
132  GT_DataArrayHandle myGeneratedNormals;
133  GT_Owner myNormalsOwner;
134  GT_DataArrayHandle myGeneratedTangents;
135  GT_Owner myTangentsOwner;
136 
137  GT_DataArrayHandle myConvexUniformIndirect;
138  GT_DataArrayHandle myConvexVertexIndirect;
139  GT_DataArrayHandle myConvexVertexList;
140  GT_DataArrayHandle myConvexPrimInfo;
141  GT_DataArrayHandle myConvexVertInfo;
142 
143  UT_StringHolder myUVAttrib;
144  int64 myUVver;
145 
146  int myMaterialID = -1;
147  bool myHasTangents = false;
148  bool myWindingOrder = false;
149  bool myAutoGenNormal = false;
150  bool myIsFlattened = false;
151  bool myHasCd = false;
152  bool myHasAlpha = false;
153  bool myHasBlendedMaterial = false;
154  bool myHasNormalOffsets = false;
155  int myNumBlendShapes = 0;
156  int myBlendShapeVertexCount = 0;
157  int myNumBoneTransforms = 0;
158 
159  int64 myTopVersion = 0;
160  int64 myPointVer = 0;
161 
162  gr_SetCache myBoneBlendSet;
163  UT_UniquePtr<RV_ShaderBlock> myBoneTransforms;
164  UT_UniquePtr<RV_ShaderBlock> myBlendShapes;
165  UT_UniquePtr<RV_ShaderBlock> myBlendOffsets;
166  bool myIsMatXMaterial = false;
167  UT_UniquePtr<GT_GEOOffsetList> myVertexOffsets;
168 
169  static UT_Map<exint, RV_ShaderProgram *> theProgramMap;
170 };
171 
172 #endif
GLbitfield flags
Definition: glcorearb.h:1596
const char * className() const override
virtual void draw(RE_RenderContext r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms draw_parms)=0
Normal drawing method. Only issue rendering commands.
const GT_PrimitiveHandle & getMesh() const
A mesh of polygons.
virtual void getVkDecorGeometry(GR_DecorationRender::PrimitiveType prim_type, RV_PrimType render_prim, RV_Geometry &geo, int &out_connect_start, int &out_connect_num)
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
Temporary container for either a RV_Render and an RE_Render.
virtual RV_Geometry * getVkPickGeometry(unsigned int pick_mode)
Definition: GR_GeoRender.h:128
virtual exint getNumGLPrimitives() const =0
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:48
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
GR_RenderFlags
Definition: GR_Defines.h:86
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:38
const GT_PrimitiveHandle & getConvexedMesh() const
GLenum mode
Definition: glcorearb.h:99
GT_Owner
Definition: GT_Types.h:90
virtual void getPickConnectGroup(unsigned int pick_mode, GR_PickGeometry pick_geo, int &out_connect_start, int &out_connect_num)
Definition: GR_GeoRender.h:100
GR_PickGeometry
Definition: GR_PickRecord.h:60
RV_PrimType
Definition: RV_Type.h:367
bool hasTransparency() const override
returns true if this drawable renders some transparent elements
An array of numeric values (int32, int64, fpreal16, fpreal32, fpreal64)
Definition: GT_DANumeric.h:23
virtual void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p, const char *cache_name)=0
GLboolean r
Definition: glcorearb.h:1222