HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUI_GroupData.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: GUI_GroupData.h (GUI Library)
7  *
8  * COMMENTS:
9  */
10 #ifndef __GUI_GroupData_h__
11 #define __GUI_GroupData_h__
12 
13 #include "GUI_API.h"
14 #include <GR/GR_Defines.h>
15 #include <GR/GR_TextureRef.h>
16 #include <GU/GU_Selection.h>
17 #include <GU/GU_SelectType.h>
18 #include <GA/GA_Types.h>
19 #include <RE/RE_RenderContext.h>
20 #include <RE/RE_Texture.h>
21 #include <UT/UT_IntrusivePtr.h>
22 
23 #ifdef USE_VULKAN
24 #include <RV/RV_TypePtrs.h>
25 #endif
26 
27 class RE_Render;
28 class RE_Geometry;
29 class RE_ShaderHandle;
30 class GUI_GeoRender;
32 class GU_Detail;
33 class UT_Color;
34 
35 class RV_VKImage;
36 class RV_VKBuffer;
37 class RV_ShaderProgram;
38 class RV_Geometry;
39 
40 /// Holds information sbout groups for display in the viewport.
41 class GUI_API GUI_GroupData : public UT_IntrusiveRefCounter<GUI_GroupData>
42 {
43 public:
45  GUI_GeoRender &owner,
46  const GR_CommonDispOption &options,
48  GU_SelectionHandle *selection = nullptr,
49  UT_StringHolder *name = nullptr);
50  ~GUI_GroupData();
51 
52  const UT_StringHolder &groupMask() const;
53  GA_GroupType groupType() const;
54  GR_TextureRef colorTexture() const;
55  bool hasColorTexture() const;
56 
57  // These values are used for drawing primitive groups.
58  RE_Texture *idTexture() const;
59  RV_VKBuffer *idBuffer() const;
60  int minId() const;
61  int maxId() const;
62 
63  // These values are used for drawing point and edge groups.
64  RE_ShaderHandle *shader(bool uv_viewport) const;
65  RE_Geometry *geometry() const;
66  RV_ShaderProgram *shader(RV_Render *r, bool uv_viewport) const;
67  RV_Geometry *geometryVK() const;
68 
69  // Returns true if the provided mask specifies an adhoc group
70  // (basically anything that isn't recognized as a connectivity
71  // specifier, attribute range, or group name mask.
72  static bool isAdhocGroupMask(const char *mask);
73 
74  // Returns a magic group name that is used to trigger the use of the
75  // cook selection group from the detail, rather than a named group or
76  // an ad-hoc group.
77  static UT_StringRef cookSelectionGroupMask();
78 
79 private:
80  void createIdTexture(RE_RenderContext r,
81  const int *id_data,
82  int numids);
83  void createColorTexture(RE_RenderContext r,
84  const UT_ValArray<uint8> &color_data);
85 
86  void createGeometry(RE_RenderContext r,
87  RE_PrimType prim_type,
88  const UT_Vector3FArray &pos,
89  const UT_Array<int32> &id_data,
90  const UT_Vector3FArray &ppos = UT_Vector3FArray(),
91  const UT_Vector3FArray &npos = UT_Vector3FArray(),
92  exint min_id = 0,
93  exint max_id = SYS_EXINT_MAX);
94 
95  void initializePackedPrimsFromPoints(RE_RenderContext r,
96  const GU_Detail &gdp,
97  const UT_Array<int32> &id_data);
98  void initializeFromConnectivity(RE_RenderContext r);
99  void initializeFromAttrib(RE_RenderContext r);
100  void initializeFromAdhocGroup(RE_RenderContext r);
101 
102  bool initializeFromGroup(
105  const GA_Group *group = nullptr,
106  const UT_StringRef *name = nullptr,
107  const UT_Color *override_color = nullptr);
108  void initializeFromPrimGroups(RE_RenderContext r,
109  const GA_PrimitiveGroup *group = nullptr,
110  const UT_StringRef *name = nullptr,
111  const UT_Color *override_color = nullptr);
112  void initializeFromPointGroups(RE_RenderContext r,
113  const GA_PointGroup *group = nullptr,
114  const UT_StringRef *name = nullptr,
115  const UT_Color *override_color = nullptr);
116  void initializeFromEdgeGroups(RE_RenderContext r,
117  const GA_EdgeGroup *group = nullptr,
118  const UT_StringRef *name = nullptr,
119  const UT_Color *override_color = nullptr);
120  void initializeFromVertexGroups(RE_RenderContext r,
121  const GA_VertexGroup *group = nullptr,
122  const UT_StringRef *name = nullptr,
123  const UT_Color *override_color = nullptr);
124 
125  GUI_GeoRender &myOwnerGeoRender;
126  UT_StringHolder myGroupMask;
127  GA_GroupType myGroupType;
128  UT_StringHolder myAttribName;
129  UT_StringHolder myAttribValueMask;
130  GA_AttributeOwner myAttribOwner;
131  GU_Connectivity myConnectivity;
132  RE_Texture *myColorTextureGL;
133 
134  RE_Texture *myIdTextureGL;
135  int myMinId;
136  int myMaxId;
137 
138  RE_Geometry *myGeometryGL;
139 
140 #ifdef USE_VULKAN
141  UT_UniquePtr<RV_VKImage> myColorTextureVK;
142  UT_UniquePtr<RV_VKBuffer> myIdBufferVK;
143  UT_UniquePtr<RV_Geometry> myGeometryVK;
144 #endif
145 };
146 
148 
149 #endif
GT_API const UT_StringHolder selection
UT_ValArray< UT_Vector3F > UT_Vector3FArray
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:52
int64 exint
Definition: SYS_Types.h:125
Object that represents drawable geometry. This object holds vertex, instancing and index buffers for ...
Definition: RV_Geometry.h:165
Holds information sbout groups for display in the viewport.
Definition: GUI_GroupData.h:41
#define SYS_EXINT_MAX
Definition: SYS_Types.h:181
A reference counter base class for use with UT_IntrusivePtr.
Temporary container for either a RV_Render and an RE_Render.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
UT_IntrusivePtr< const GUI_GroupData > GUI_GroupDataHandle
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
#define GUI_API
Definition: GUI_API.h:10
GU_Connectivity
Definition: GU_SelectType.h:66
GLint GLuint mask
Definition: glcorearb.h:124
GLuint const GLchar * name
Definition: glcorearb.h:786
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GLuint shader
Definition: glcorearb.h:785
GA_AttributeOwner
Definition: GA_Types.h:35
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:167
GLboolean r
Definition: glcorearb.h:1222
A vulkan buffer object.
Definition: RV_VKBuffer.h:75
RE_PrimType
Definition: RE_Types.h:199
Simple interface to building a shader from a .prog file.