HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
collisionGroup.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef USDPHYSICS_GENERATED_COLLISIONGROUP_H
8 #define USDPHYSICS_GENERATED_COLLISIONGROUP_H
9 
10 /// \file usdPhysics/collisionGroup.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdPhysics/api.h"
14 #include "pxr/usd/usd/typed.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
18 
20 
21 #include "pxr/base/vt/value.h"
22 
23 #include "pxr/base/gf/vec3d.h"
24 #include "pxr/base/gf/vec3f.h"
25 #include "pxr/base/gf/matrix4d.h"
26 
27 #include "pxr/base/tf/token.h"
28 #include "pxr/base/tf/type.h"
29 
31 
32 class SdfAssetPath;
33 
34 // -------------------------------------------------------------------------- //
35 // PHYSICSCOLLISIONGROUP //
36 // -------------------------------------------------------------------------- //
37 
38 /// \class UsdPhysicsCollisionGroup
39 ///
40 /// Defines a collision group for coarse filtering. When a collision
41 /// occurs between two objects that have a PhysicsCollisionGroup assigned,
42 /// they will collide with each other unless this PhysicsCollisionGroup pair
43 /// is filtered. See filteredGroups attribute.
44 ///
45 /// A CollectionAPI:colliders maintains a list of PhysicsCollisionAPI rel-s that
46 /// defines the members of this Collisiongroup.
47 ///
48 ///
50 {
51 public:
52  /// Compile time constant representing what kind of schema this class is.
53  ///
54  /// \sa UsdSchemaKind
56 
57  /// Construct a UsdPhysicsCollisionGroup on UsdPrim \p prim .
58  /// Equivalent to UsdPhysicsCollisionGroup::Get(prim.GetStage(), prim.GetPath())
59  /// for a \em valid \p prim, but will not immediately throw an error for
60  /// an invalid \p prim
61  explicit UsdPhysicsCollisionGroup(const UsdPrim& prim=UsdPrim())
62  : UsdTyped(prim)
63  {
64  }
65 
66  /// Construct a UsdPhysicsCollisionGroup on the prim held by \p schemaObj .
67  /// Should be preferred over UsdPhysicsCollisionGroup(schemaObj.GetPrim()),
68  /// as it preserves SchemaBase state.
69  explicit UsdPhysicsCollisionGroup(const UsdSchemaBase& schemaObj)
70  : UsdTyped(schemaObj)
71  {
72  }
73 
74  /// Destructor.
76  virtual ~UsdPhysicsCollisionGroup();
77 
78  /// Return a vector of names of all pre-declared attributes for this schema
79  /// class and all its ancestor classes. Does not include attributes that
80  /// may be authored by custom/extended methods of the schemas involved.
82  static const TfTokenVector &
83  GetSchemaAttributeNames(bool includeInherited=true);
84 
85  /// Return a UsdPhysicsCollisionGroup holding the prim adhering to this
86  /// schema at \p path on \p stage. If no prim exists at \p path on
87  /// \p stage, or if the prim at that path does not adhere to this schema,
88  /// return an invalid schema object. This is shorthand for the following:
89  ///
90  /// \code
91  /// UsdPhysicsCollisionGroup(stage->GetPrimAtPath(path));
92  /// \endcode
93  ///
96  Get(const UsdStagePtr &stage, const SdfPath &path);
97 
98  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
99  /// is defined (according to UsdPrim::IsDefined()) on this stage.
100  ///
101  /// If a prim adhering to this schema at \p path is already defined on this
102  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
103  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
104  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
105  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
106  /// current EditTarget for any nonexistent, or existing but not \a Defined
107  /// ancestors.
108  ///
109  /// The given \a path must be an absolute prim path that does not contain
110  /// any variant selections.
111  ///
112  /// If it is impossible to author any of the necessary PrimSpecs, (for
113  /// example, in case \a path cannot map to the current UsdEditTarget's
114  /// namespace) issue an error and return an invalid \a UsdPrim.
115  ///
116  /// Note that this method may return a defined prim whose typeName does not
117  /// specify this schema class, in case a stronger typeName opinion overrides
118  /// the opinion at the current EditTarget.
119  ///
122  Define(const UsdStagePtr &stage, const SdfPath &path);
123 
124 protected:
125  /// Returns the kind of schema this class belongs to.
126  ///
127  /// \sa UsdSchemaKind
129  UsdSchemaKind _GetSchemaKind() const override;
130 
131 private:
132  // needs to invoke _GetStaticTfType.
133  friend class UsdSchemaRegistry;
135  static const TfType &_GetStaticTfType();
136 
137  static bool _IsTypedSchema();
138 
139  // override SchemaBase virtuals.
141  const TfType &_GetTfType() const override;
142 
143 public:
144  // --------------------------------------------------------------------- //
145  // MERGEGROUPNAME
146  // --------------------------------------------------------------------- //
147  /// If non-empty, any collision groups in a stage with a matching
148  /// mergeGroup should be considered to refer to the same collection. Matching
149  /// collision groups should behave as if there were a single group containing
150  /// referenced colliders and filter groups from both collections.
151  ///
152  /// | ||
153  /// | -- | -- |
154  /// | Declaration | `string physics:mergeGroup` |
155  /// | C++ Type | std::string |
156  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
159 
160  /// See GetMergeGroupNameAttr(), and also
161  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
162  /// If specified, author \p defaultValue as the attribute's default,
163  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
164  /// the default for \p writeSparsely is \c false.
166  UsdAttribute CreateMergeGroupNameAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
167 
168 public:
169  // --------------------------------------------------------------------- //
170  // INVERTFILTEREDGROUPS
171  // --------------------------------------------------------------------- //
172  /// Normally, the filter will disable collisions against the selected
173  /// filter groups. However, if this option is set, the filter will disable
174  /// collisions against all colliders except for those in the selected filter
175  /// groups.
176  ///
177  /// | ||
178  /// | -- | -- |
179  /// | Declaration | `bool physics:invertFilteredGroups` |
180  /// | C++ Type | bool |
181  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
184 
185  /// See GetInvertFilteredGroupsAttr(), and also
186  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
187  /// If specified, author \p defaultValue as the attribute's default,
188  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
189  /// the default for \p writeSparsely is \c false.
191  UsdAttribute CreateInvertFilteredGroupsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
192 
193 public:
194  // --------------------------------------------------------------------- //
195  // FILTEREDGROUPS
196  // --------------------------------------------------------------------- //
197  /// References a list of PhysicsCollisionGroups with which
198  /// collisions should be ignored.
199  ///
202 
203  /// See GetFilteredGroupsRel(), and also
204  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
207 
208 public:
209  // ===================================================================== //
210  // Feel free to add custom code below this line, it will be preserved by
211  // the code generator.
212  //
213  // Just remember to:
214  // - Close the class declaration with };
215  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
216  // - Close the include guard with #endif
217  // ===================================================================== //
218  // --(BEGIN CUSTOM CODE)--
219 
220  /// Return the UsdCollectionAPI interface used for defining
221  /// what colliders belong to the CollisionGroup.
224 
225  /// Utility structure generated by ComputeCollisionGroupTable(); contains a
226  /// table describing which pairs of collision groups have collisions
227  /// enabled/disabled by the filtering rules.
229  {
230  /// Return the set of all UsdPhysicsCollisionGroup which this table
231  /// contains
233  const SdfPathVector& GetCollisionGroups() const;
234 
235  /// Return true if the groups at indices \a idxA and \a idxB collide
237  bool IsCollisionEnabled(const unsigned int idxA,
238  const unsigned int idxB) const;
239 
240  /// Return true if the groups \a primA and \a primB collide
242  bool IsCollisionEnabled(const SdfPath& primA,
243  const SdfPath& primB) const;
244 
245  protected:
247  // < All collision groups known to this table
249  // < 2D table, with one element per collision-group-pair. Entry is false
250  // if collision is disabled by a filtering rule.
251  std::vector<bool> _enabled;
252  };
253 
254  /// Compute a table encoding all the collision groups filter rules for a
255  /// stage. This can be used as a reference to validate an implementation of
256  /// the collision groups filters. The returned table is diagonally
257  /// symmetric.
258  static USDPHYSICS_API
260 };
261 
263 
264 #endif
static USDPHYSICS_API UsdPhysicsCollisionGroup Get(const UsdStagePtr &stage, const SdfPath &path)
USDPHYSICS_API UsdRelationship GetFilteredGroupsRel() const
USDPHYSICS_API UsdAttribute CreateMergeGroupNameAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDPHYSICS_API UsdCollectionAPI GetCollidersCollectionAPI() const
UsdPhysicsCollisionGroup(const UsdPrim &prim=UsdPrim())
Represents a concrete typed schema.
std::vector< class SdfPath > SdfPathVector
USDPHYSICS_API UsdRelationship CreateFilteredGroupsRel() const
USDPHYSICS_API bool IsCollisionEnabled(const unsigned int idxA, const unsigned int idxB) const
Return true if the groups at indices idxA and idxB collide.
static const UsdSchemaKind schemaKind
Definition: prim.h:116
Definition: typed.h:44
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
static USDPHYSICS_API UsdPhysicsCollisionGroup Define(const UsdStagePtr &stage, const SdfPath &path)
USDPHYSICS_API UsdAttribute GetInvertFilteredGroupsAttr() const
Definition: path.h:273
USDPHYSICS_API UsdAttribute GetMergeGroupNameAttr() const
#define USDPHYSICS_API
Definition: api.h:23
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDPHYSICS_API const SdfPathVector & GetCollisionGroups() const
static USDPHYSICS_API CollisionGroupTable ComputeCollisionGroupTable(const UsdStage &stage)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
Definition: type.h:47
UsdPhysicsCollisionGroup(const UsdSchemaBase &schemaObj)
virtual USDPHYSICS_API ~UsdPhysicsCollisionGroup()
Destructor.
USDPHYSICS_API UsdAttribute CreateInvertFilteredGroupsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDPHYSICS_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: value.h:146