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 &getConvexedMesh() const {return myConvexedMesh;}
66 private:
67 
68  void updateSurface(RV_Render *r,
69  GT_PrimPolygonMesh *pmesh,
70  const GR_UpdateParms &p,
71  bool needs_tangents);
72 
73  void convexAndFlattenMesh(GT_PrimPolygonMesh *pmesh,
74  const GR_UpdateParms &parms,
75  bool needs_tangents,
76  GT_PrimPolygonMesh* &out_cmesh,
77  bool &out_flattened);
78 
79  void buildNormals(GT_PrimPolygonMesh *pmesh,
80  const GR_UpdateParms &parms,
81  bool needs_tangents,
82  GT_PrimPolygonMesh* &out_nmesh);
83 
84  void buildSurfaceConnectivity(const GT_PrimPolygonMesh *pmesh,
85  const GR_UpdateParms &parms,
86  UT_Int32Array &connect_indices);
87 
88  void buildVertexNumbers(const GT_PrimPolygonMesh *pmesh,
89  const GR_UpdateParms &parms,
90  GT_Int8Array &vert_num);
91 
92  void buildWireframeConnectivity(
93  const GT_PrimPolygonMesh *pmesh,
94  const GR_UpdateParms &parms,
95  UT_Int32Array &connect_indices,
96  UT_Int32Array &faces,
97  bool target_vert = false);
98 
99  void buildUVBoundaryConnectivity(
100  const GT_PrimPolygonMesh *pmesh,
101  const GR_UpdateParms &p,
102  UT_Int32Array &connect,
103  UT_Int32Array &face_list);
104 
105  RV_ShaderProgram * fetchShader(GR_RenderMode mode,
107  const GR_Material *mat,
108  const GR_DisplayOption *opts,
109  bool &uses_mat);
110 
111  bool updateBoneTransforms(RV_Render *r,
112  const GT_DataArrayHandle &a);
113 
114  void updateBlendShapes(RV_Render *r,
115  const GT_DataArrayHandle &a);
116 
117 
118  GT_PrimitiveHandle myNormalMesh; // with generated normals
119  GT_PrimitiveHandle myTangentMesh; // with generated tangents
120  GT_PrimitiveHandle myFlattenedMesh; // with only Point/Detail attribs
121 
122  GT_PrimitiveHandle myBaseMesh; // original
123  GT_PrimitiveHandle myConvexedMesh; // convexed
124 
125  GT_DataArrayHandle myGeneratedNormals;
126  GT_Owner myNormalsOwner;
127  GT_DataArrayHandle myGeneratedTangents;
128  GT_Owner myTangentsOwner;
129 
130  GT_DataArrayHandle myConvexUniformIndirect;
131  GT_DataArrayHandle myConvexVertexIndirect;
132  GT_DataArrayHandle myConvexVertexList;
133  GT_DataArrayHandle myConvexPrimInfo;
134  GT_DataArrayHandle myConvexVertInfo;
135 
136  int myMaterialID = -1;
137  bool myHasTangents = false;
138  bool myWindingOrder = false;
139  bool myAutoGenNormal = false;
140  bool myIsFlattened = false;
141  bool myHasCd = false;
142  bool myHasAlpha = false;
143  bool myHasBlendedMaterial = false;
144  bool myHasNormalOffsets = false;
145  int myNumBlendShapes = 0;
146  int myBlendShapeVertexCount = 0;
147  int myNumBoneTransforms = 0;
148 
149  int64 myTopVersion = 0;
150  int64 myPointVer = 0;
151 
152  gr_SetCache myBoneBlendSet;
153  UT_UniquePtr<RV_ShaderBlock> myBoneTransforms;
154  UT_UniquePtr<RV_ShaderBlock> myBlendShapes;
155  UT_UniquePtr<RV_ShaderBlock> myBlendOffsets;
156 
157  static UT_Map<exint, RV_ShaderProgram *> theProgramMap;
158 };
159 
160 #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.
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:164
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:47
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
GR_RenderFlags
Definition: GR_Defines.h:85
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:36
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:345
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