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  class RigElement
47  {
48  public:
49  RigElement(int idx, int pidx)
50  : bone_length(0.0), trans_idx(idx), parent_idx(pidx) {}
52  {
53  for(int i=0; i<children.entries(); i++)
54  delete children(i);
55  }
56 
58  int trans_idx;
61  };
62 
63  /// Return a list of bones corresponding to all the ones used by deforming
64  /// shapes. bone_transform_indices correspond to transforms in the rig and
65  /// bone_quats are the directions for the bone (assuming a source
66  /// orientation pointing in the -Z axis), and scaled to indicate the bone
67  /// length.
68  bool buildRig(UT_IntArray &bone_transform_indices,
69  UT_ValArray<UT_QuaternionF> &bone_quats,
70  UT_BoundingBox &rig_worst_case_bounds) const;
71 
72  /// Fetch bounding box of an agent, return false if bbox couldn't be
73  /// computed.
74  bool getBoundingBox(int agent_idx, UT_BoundingBox &box) const;
75 
76  /// Primitive IDs (GA_Index) of all agents in the agent list.
77  GT_DataArrayHandle getPrimIDs() const;
78 
79  /// Point IDs (GA_Index) of all agents in the agent list.
80  GT_DataArrayHandle getPointIDs() const;
81 
82  /// Point positions of all agents' points.
83  GT_DataArrayHandle getPointPos() const;
84 
85  /// Fetch a data array for the attribute named 'attrib_name'.
86  GT_DataArrayHandle fetchAttributeData(const UT_StringRef &attrib_name,
87  GT_Owner &attrib_list_owner) const;
88 
89  bool hasDataArray(const UT_StringRef &name,
90  GT_Owner owner_scope[],
91  int num_owners,
92  GT_Storage *storage = NULL,
93  GT_Size *tuple_size = NULL) const override;
94 
95  /// local transform for agent at idx. Returns false if no transform present
96  bool getTransform(int idx, UT_Matrix4D &mat) const;
97 
98  /// local transform for agent at idx.
99  bool getTransform(int idx, UT_Matrix4F &mat) const;
100 
101  /// computed main transforms for all visible agents
103  { return myAgentTransforms; }
104 
105  /// computed rig transforms for all visible agents
107  { return myAgentRigTransforms; }
108 
109  /// map GA index locations of agent prims to a flat list used by this rig
111  { return myAgentIndexMap; }
112 
113  /// list of selected agent primitives
114  GT_AgentSelectionHandle selection() const { return myAgentSelection; }
115 
116  /// list of agent primitive ids.
117  GT_AgentIDHandle primIDs() const { return myAgentPrimIDs; }
118 
119  /// List of agent colors;
120  GT_AgentColorsHandle colors() const { return myAgentColors; }
121 
122  /// Visibility information for agents.
123  GT_AgentVisibilityHandle visibility() const { return myVisibility; }
124 
125  const GT_GEOOffsetList &pointOffsets() const { return myPointOffsets; }
126  const GT_GEOOffsetList &primOffsets() const { return myPrimOffsets; }
127  const GT_GEOOffsetList &vtxOffsets() const { return myVertexOffsets; }
128 
129  void init();
130 
131  // GT Interface
132  const char *className() const override { return "GT_GEOPackedAgent"; }
133  int getPrimitiveType() const override { return GT_PRIM_AGENTS; }
134 
135  int getMotionSegments() const override { return 1; }
136  int64 getMemoryUsage() const override { return 0; }
137 
139  {return GT_PrimitiveHandle();}
140 
142  int nsegments) const override {}
143 
144  /// Refine to a collection of instanced primitives (for static shapes) and
145  /// unique meshes (for deforming shapes).
146  bool refine(GT_Refine &refiner,
147  const GT_RefineParms *parms = nullptr) const override;
148 
149  void append(const GU_PrimPacked *prim);
150 
151  const GU_PrimPacked *getPackedAgent(int agent_idx) const;
152  const GU_ConstDetailHandle &getDetail() const { return myParentDetail; }
153 
154  /// compute transform information for those agents that are visible.
155  /// 'initial_pass' indicates a topology change where incremental updates
156  /// cannot be done.
157  void computeTransforms(bool initial_pass) const;
158 
159  void bumpTransformSerial() const { myTransformSerial++; }
160  int getTransformSerial() const { return myTransformSerial; }
161 
162  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
163  const GT_RefineParms &parms) override;
164 
165 private:
166 
167  GU_ConstDetailHandle myParentDetail;
168  const GU_Detail *myParentGdp;
169  GT_GEOOffsetList myPrimOffsets;
170  GT_GEOOffsetList myPointOffsets;
171  GT_GEOOffsetList myVertexOffsets;
172  UT_BoundingBox myBoundingBox;
173 
174  mutable int myTransformSerial;
175 
176  GT_AgentVisibilityHandle myVisibility;
177  GT_AgentTransformsHandle myAgentTransforms;
178  GT_AgentRigTransformsHandle myAgentRigTransforms;
179  GT_AgentIndexMapHandle myAgentIndexMap;
180  GT_AgentSelectionHandle myAgentSelection;
181  GT_AgentIDHandle myAgentPrimIDs;
182  GT_AgentColorsHandle myAgentColors;
183 };
184 
186 
187 #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
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
GT_AgentRigTransformsHandle rigTransforms() const
computed rig transforms for all visible agents
const char * className() const override
fpreal64 fpreal
Definition: SYS_Types.h:277
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