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;
45  const GT_PrimitiveHandle &primh,
46  const GR_UpdateParms &p) override;
47 
48  // update the visibility info.
50  const GR_DisplayOption &) const override
51  { return true; }
53  const GR_ViewUpdateParms &parms) override;
54 
56  GR_RenderMode render_mode,
57  GR_RenderFlags render_flags,
58  GR_DrawParms dp) override;
59 
61  const GR_DisplayOption *opts,
62  unsigned int pickmask,
63  GR_PickStyle pickstyle,
64  bool has_pick_map) override;
65 
66  void renderDecoration(
68  GR_Decoration decor,
69  const GR_DecorationParms &parms) override;
70 
71  static bool initShaders(RV_Instance *inst);
72  static void cleanupShaders();
73 private:
74 
75  void updateVisibility(RE_RenderContext r,
76  const GR_FrustumList &view_frustums);
77  void buildSkeleton(RE_RenderContext r, const GT_GEOPackedAgent *agents);
78  void updateBones(RE_RenderContext r, const GT_GEOPackedAgent *agent,
79  bool geo_changed);
80  void updateAgentColor(RE_RenderContext r, const GT_GEOPackedAgent *agent,
81  const RE_CacheVersion &version);
82  void updateSelection(RE_RenderContext r,
83  const GT_GEOPackedAgent *agent,
84  const GR_UpdateParms &p);
85 
86  GT_PrimitiveHandle myAgent;
87  GT_AgentVisibilityHandle myVisibility;
88  UT_BoundingBox myWorstCaseBounds;
89  UT_Array<UT_BoundingBox> myBounds;
90  UT_Vector3FArray myPos;
91  UT_IntArray myPrimID;
92 
93  UT_Matrix4FArray myMats;
94  UT_IntArray myBoneTransformIndices;
95  UT_ValArray<UT_QuaternionF> myBoneQuats;
96 
97  // GL
98  RE_Geometry *myPoints;
99  RE_Geometry *myPrimAnchors;
100  RE_Geometry *myBBoxes;
101  RE_Geometry *myBaseDisc;
102  RE_Geometry *myBones;
103 
104 #ifdef USE_VULKAN
105  // Vulkan
106  UT_UniquePtr<RV_Geometry> myPointsGeo;
107  UT_UniquePtr<RV_Geometry> myPrimAnchorsGeo;
108  UT_UniquePtr<RV_Geometry> myBBoxesGeo;
109  UT_UniquePtr<RV_Geometry> myBaseDiscGeo;
110  UT_UniquePtr<RV_Geometry> myBonesGeo;
111 
113  UT_UniquePtr<GR_InstanceBuffer> myInstSelection;
114 
115  UT_UniquePtr<RV_ShaderBlock> myObjUniforms;
117 #endif
118 
119  RE_VertexArray *myBoneTransformsVA;
120  int myLastTransformSerial;
121 
122  unsigned myLastHullDisplay : 1,
123  myLastWireOver:1,
124  myLastWire:1,
125  myBoneRigDirty:1,
126  myBonesVisible:1,
127  myObjectSelected:1,
128  myDiscsDirty:1,
129  myBBoxDirty:1;
130 
131  RE_VertexArray *myColorVA;
132  RE_VertexArray *mySelectionVA;
133  RE_VertexArray *myPointSelectionVA;
134 
135  GR_SelectMode mySelectMode;
136  GR_AgentWireMode myAgentWireMode;
137  UT_IntArray myBoneSerialCounts;
138  int myBoneSerial;
139  int64 myBoneVisibleHash;
140  UT_Matrix4FArray myBoneMatrixBuffer;
141 };
142 
143 #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:53
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
GR_AgentWireMode
Definition: GR_Defines.h:373
GR_Decoration
Definition: GR_Defines.h:151
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:47
#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: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
GT_API const UT_StringHolder version
GT_PrimitiveType
virtual GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim)=0
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:49
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 GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init)
GR_SelectMode
Definition: GR_Defines.h:229
GR_PickStyle
Definition: GR_Defines.h:240