HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_GEOPackedAgent.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: GT_GEOPackedAgent.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_GEOPackedAgent__
12 #define __GT_GEOPackedAgent__
13 
14 #include "GT_GEOPrimCollect.h"
15 #include "GT_GEOSupport.h"
16 #include "GT_Primitive.h"
17 #include "GT_PrimitiveTypes.h"
18 #include "GT_AgentSupport.h"
19 
20 #include <UT/UT_ValArray.h>
21 #include <UT/UT_IntrusivePtr.h>
22 #include <UT/UT_NonCopyable.h>
23 #include <UT/UT_VectorTypes.h>
24 
25 #include <SYS/SYS_AtomicInt.h>
26 #include <SYS/SYS_Types.h>
27 
28 
29 class GU_PrimPacked;
30 class UT_StringRef;
31 
32 
33 /// Contains a list of agents which share the same rig.
35 {
36 public:
39  ~GT_GEOPackedAgent() override;
40 
41  /// Main interface
42 
43  /// Number of agents in this agent list
44  int getNumAgents() const { return myPrimOffsets.entries(); }
45 
46  /// Unique ID of the agents' rig.
47  exint getUniqueId() const;
48 
49  class RigElement
50  {
51  public:
52  RigElement(int idx, int pidx)
53  : bone_length(0.0), trans_idx(idx), parent_idx(pidx) {}
55  {
56  for(int i=0; i<children.entries(); i++)
57  delete children(i);
58  }
59 
61  int trans_idx;
64  };
65 
66  /// Return a list of bones corresponding to all the ones used by deforming
67  /// shapes. bone_transform_indices correspond to transforms in the rig and
68  /// bone_quats are the directions for the bone (assuming a source
69  /// orientation pointing in the -Z axis), and scaled to indicate the bone
70  /// length.
71  bool buildRig(UT_IntArray &bone_transform_indices,
72  UT_ValArray<UT_QuaternionF> &bone_quats,
73  UT_BoundingBox &rig_worst_case_bounds) const;
74 
75  /// Fetch bounding box of an agent, return false if bbox couldn't be
76  /// computed.
77  bool getBoundingBox(int agent_idx, UT_BoundingBox &box) const;
78 
79  /// Primitive IDs (GA_Index) of all agents in the agent list.
80  GT_DataArrayHandle getPrimIDs() const;
81 
82  /// Point IDs (GA_Index) of all agents in the agent list.
83  GT_DataArrayHandle getPointIDs() const;
84 
85  /// Point positions of all agents' points.
86  GT_DataArrayHandle getPointPos() const;
87 
88  /// Fetch a data array for the attribute named 'attrib_name'.
89  GT_DataArrayHandle fetchAttributeData(const UT_StringRef &attrib_name,
90  GT_Owner &attrib_list_owner) const;
91 
92  bool hasDataArray(const UT_StringRef &name,
93  GT_Owner owner_scope[],
94  int num_owners,
95  GT_Storage *storage = NULL,
96  GT_Size *tuple_size = NULL) const override;
97 
98  /// local transform for agent at idx. Returns false if no transform present
99  bool getTransform(int idx, UT_Matrix4D &mat) const;
100 
101  /// local transform for agent at idx.
102  bool getTransform(int idx, UT_Matrix4F &mat) const;
103 
104  /// computed main transforms for all visible agents
106  { return myAgentTransforms; }
107 
108  /// computed rig transforms for all visible agents
110  { return myAgentRigTransforms; }
111 
112  /// map GA index locations of agent prims to a flat list used by this rig
114  { return myAgentIndexMap; }
115 
116  /// list of selected agent primitives
117  GT_AgentSelectionHandle selection() const { return myAgentSelection; }
118 
119  /// list of agent primitive ids.
120  GT_AgentIDHandle primIDs() const { return myAgentPrimIDs; }
121 
122  /// List of agent colors;
123  GT_AgentColorsHandle colors() const { return myAgentColors; }
124 
125  /// Visibility information for agents.
126  GT_AgentVisibilityHandle visibility() const { return myVisibility; }
127 
128  const GT_GEOOffsetList &pointOffsets() const { return myPointOffsets; }
129  const GT_GEOOffsetList &primOffsets() const { return myPrimOffsets; }
130  const GT_GEOOffsetList &vtxOffsets() const { return myVertexOffsets; }
131 
132  void init();
133 
134  // GT Interface
135  const char *className() const override { return "GT_GEOPackedAgent"; }
136  int getPrimitiveType() const override { return GT_PRIM_AGENTS; }
137 
138  int getMotionSegments() const override { return 1; }
139  int64 getMemoryUsage() const override { return 0; }
140 
142  {return GT_PrimitiveHandle();}
143 
145  int nsegments) const override {}
146 
147  /// Refine to a collection of instanced primitives (for static shapes) and
148  /// unique meshes (for deforming shapes).
149  bool refine(GT_Refine &refiner,
150  const GT_RefineParms *parms = nullptr) const override;
151 
152  void append(const GU_PrimPacked *prim);
153 
154  const GU_PrimPacked *getPackedAgent(int agent_idx) const;
155  const GU_ConstDetailHandle &getDetail() const { return myParentDetail; }
156 
157  /// compute transform information for those agents that are visible.
158  /// 'initial_pass' indicates a topology change where incremental updates
159  /// cannot be done.
160  void computeTransforms(bool initial_pass) const;
161 
162  void bumpTransformSerial() const { myTransformSerial++; }
163  int getTransformSerial() const { return myTransformSerial; }
164 
165  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
166  const GT_RefineParms &parms) override;
167 
168 private:
169 
170  GU_ConstDetailHandle myParentDetail;
171  const GU_Detail *myParentGdp;
172  GT_GEOOffsetList myPrimOffsets;
173  GT_GEOOffsetList myPointOffsets;
174  GT_GEOOffsetList myVertexOffsets;
175  UT_BoundingBox myBoundingBox;
176 
177  mutable int myTransformSerial;
178 
179  GT_AgentVisibilityHandle myVisibility;
180  GT_AgentTransformsHandle myAgentTransforms;
181  GT_AgentRigTransformsHandle myAgentRigTransforms;
182  GT_AgentIndexMapHandle myAgentIndexMap;
183  GT_AgentSelectionHandle myAgentSelection;
184  GT_AgentIDHandle myAgentPrimIDs;
185  GT_AgentColorsHandle myAgentColors;
186 };
187 
189 
190 #endif
GT_Storage
Definition: GT_Types.h:19
virtual bool hasDataArray(const UT_StringRef &name, GT_Owner owner_scope[], int num_owners, GT_Storage *storage=NULL, GT_Size *tuple_size=NULL) const
virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl, const GT_RefineParms &parms)
update any cached data for geometry and its attributes
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
#define GT_API
Definition: GT_API.h:13
int64 exint
Definition: SYS_Types.h:125
int getPrimitiveType() const override
void bumpTransformSerial() const
GT_AgentIndexMapHandle indexMap() const
map GA index locations of agent prims to a flat list used by this rig
Contains a list of agents which share the same rig.
const GT_GEOOffsetList & pointOffsets() const
GT_AgentColorsHandle colors() const
List of agent colors;.
UT_Array< RigElement * > children
int64 getMemoryUsage() const override
GT_PrimitiveHandle doSoftCopy() const override
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
GT_Owner
Definition: GT_Types.h:90
const GT_GEOOffsetList & vtxOffsets() const
int64 GT_Size
Definition: GT_Types.h:128
GA_API const UT_StringHolder parms
GT_AgentRigTransformsHandle rigTransforms() const
computed rig transforms for all visible agents
const char * className() const override
fpreal64 fpreal
Definition: SYS_Types.h:278
int getTransformSerial() const
void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const override
int getMotionSegments() const override
GT_AgentVisibilityHandle visibility() const
Visibility information for agents.
const GU_ConstDetailHandle & getDetail() const
GT_AgentSelectionHandle selection() const
list of selected agent primitives
UT_IntrusivePtr< GT_Primitive > GT_PrimitiveHandle
Definition: GT_Handles.h:34
int getNumAgents() const
Main interface.
GT_AgentIDHandle primIDs() const
list of agent primitive ids.
GT_AgentTransformsHandle agentTransforms() const
computed main transforms for all visible agents
const GT_GEOOffsetList & primOffsets() const
GLenum src
Definition: glcorearb.h:1793