HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PrimAgents.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_PrimAgents ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Rendering class for agent decorations, bounding boxes
10  */
11 #ifndef GR_PrimAgents_h
12 #define GR_PrimAgents_h
13 
14 #include "GR_Primitive.h"
15 
16 #include <UT/UT_ValArray.h>
17 #include <UT/UT_BoundingBox.h>
18 #include <UT/UT_VectorTypes.h>
19 #include <GT/GT_GEOPackedAgent.h>
20 #include <UT/UT_UniquePtr.h>
21 
22 class RE_Geometry;
23 class RE_VertexArray;
24 class RV_Geometry;
25 class RV_Instance;
26 class GR_InstanceBuffer;
27 
29 {
30 public:
31  GR_PrimAgents(const GR_RenderInfo *info,
32  const char *cache_name);
33  ~GR_PrimAgents() override;
34 
35 
36  const char *className() const override { return "GR_PrimAgents"; }
37 
39  const GT_PrimitiveHandle &,
40  const GEO_Primitive *) override;
41 
42  GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts,
43  bool first_init) override;
44 
45  bool supportsParallelUpdate() const override;
46 
48  const GT_PrimitiveHandle &primh,
49  const GR_UpdateParms &p) override;
50 
51  // update the visibility info.
53  const GR_DisplayOption &) const override
54  { return true; }
56  const GR_ViewUpdateParms &parms) override;
57 
59  GR_RenderMode render_mode,
60  GR_RenderFlags render_flags,
61  GR_DrawParms dp) override;
62 
64  const GR_DisplayOption *opts,
65  unsigned int pickmask,
66  GR_PickStyle pickstyle,
67  bool has_pick_map) override;
68 
69  void renderDecoration(
71  GR_Decoration decor,
72  const GR_DecorationParms &parms) override;
73 
74  static bool initShaders(RV_Instance *inst);
75  static void cleanupShaders();
76 private:
77 
78  void updateVisibility(RE_RenderContext r,
79  const GR_FrustumList &view_frustums);
80  void buildSkeleton(RE_RenderContext r, const GT_GEOPackedAgent *agents);
81  void updateBones(RE_RenderContext r, const GT_GEOPackedAgent *agent,
82  bool geo_changed);
83  void updateAgentColor(RE_RenderContext r, const GT_GEOPackedAgent *agent,
84  const RE_CacheVersion &version);
85  void updateSelection(RE_RenderContext r,
86  const GT_GEOPackedAgent *agent,
87  const GR_UpdateParms &p);
88 
89  GT_PrimitiveHandle myAgent;
90  GT_AgentVisibilityHandle myVisibility;
91  UT_BoundingBox myWorstCaseBounds;
92  UT_Array<UT_BoundingBox> myBounds;
93  UT_Vector3FArray myPos;
94  UT_IntArray myPrimID;
95 
96  UT_Matrix4FArray myMats;
97  UT_IntArray myBoneTransformIndices;
98  UT_ValArray<UT_QuaternionF> myBoneQuats;
99 
100  // GL
101  RE_Geometry *myPoints;
102  RE_Geometry *myPrimAnchors;
103  RE_Geometry *myBBoxes;
104  RE_Geometry *myBaseDisc;
105  RE_Geometry *myBones;
106 
107 #ifdef USE_VULKAN
108  // Vulkan
109  UT_UniquePtr<RV_Geometry> myPointsGeo;
110  UT_UniquePtr<RV_Geometry> myPrimAnchorsGeo;
111  UT_UniquePtr<RV_Geometry> myBBoxesGeo;
112  UT_UniquePtr<RV_Geometry> myBaseDiscGeo;
113  UT_UniquePtr<RV_Geometry> myBonesGeo;
114 
116  UT_UniquePtr<GR_InstanceBuffer> myInstSelection;
117 
118  UT_UniquePtr<RV_ShaderBlock> myObjUniforms;
120 #endif
121 
122  RE_VertexArray *myBoneTransformsVA;
123  int myLastTransformSerial;
124 
125  unsigned myLastHullDisplay : 1,
126  myLastWireOver:1,
127  myLastWire:1,
128  myBoneRigDirty:1,
129  myBonesVisible:1,
130  myObjectSelected:1,
131  myDiscsDirty:1,
132  myBBoxDirty:1;
133 
134  RE_VertexArray *myColorVA;
135  RE_VertexArray *mySelectionVA;
136  RE_VertexArray *myPointSelectionVA;
137 
138  GR_SelectMode mySelectMode;
139  GR_AgentWireMode myAgentWireMode;
140  UT_IntArray myBoneSerialCounts;
141  int myBoneSerial;
142  int64 myBoneVisibleHash;
143  UT_Matrix4FArray myBoneMatrixBuffer;
144 };
145 
146 #endif
virtual void render(RE_RenderContext r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp)=0
Set of parameters sent to GR_Primitive::viewUpdate().
SIM_API const UT_StringHolder agent
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:52
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
GR_AgentWireMode
Definition: GR_Defines.h:389
GR_Decoration
Definition: GR_Defines.h:164
Contains a list of agents which share the same rig.
Temporary container for either a RV_Render and an RE_Render.
virtual void viewUpdate(RE_RenderContext r, const GR_ViewUpdateParms &parms)
Definition: GR_Primitive.h:134
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()
virtual int renderPick(RE_RenderContext r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map)=0
GR_RenderMode
Definition: GR_Defines.h:48
RV_API void cleanupShaders()
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
virtual void renderDecoration(RE_RenderContext r, GR_Decoration decor, const GR_DecorationParms &parms)
GR_PrimAcceptResult
Definition: GR_Defines.h:361
GR_RenderFlags
Definition: GR_Defines.h:88
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:44
GLdouble t
Definition: glad.h:2397
GT_API const UT_StringHolder version
GT_PrimitiveType
RV_API bool initShaders(RV_Instance *inst)
virtual GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim)=0
GA_API const UT_StringHolder parms
const char * className() const override
Return a string version of this class's name.
Definition: GR_PrimAgents.h:36
bool updateOnViewChange(const GR_DisplayOption &) const override
If this primitive requires an update when the view changes, return true.
Definition: GR_PrimAgents.h:52
virtual void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p)=0
Simple class for a mutli-integer cache tag.
GLboolean r
Definition: glcorearb.h:1222
virtual bool supportsParallelUpdate() const
Definition: GR_Primitive.h:275
virtual GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init)
GR_SelectMode
Definition: GR_Defines.h:243
GR_PickStyle
Definition: GR_Defines.h:254