HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
meshCollisionAPI.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_MESHCOLLISIONAPI_H
8 #define USDPHYSICS_GENERATED_MESHCOLLISIONAPI_H
9 
10 /// \file usdPhysics/meshCollisionAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdPhysics/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // PHYSICSMESHCOLLISIONAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdPhysicsMeshCollisionAPI
37 ///
38 /// Attributes to control how a Mesh is made into a collider.
39 /// Can be applied to only a USDGeomMesh in addition to its
40 /// PhysicsCollisionAPI.
41 ///
42 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
43 /// that are text/tokens, the actual token is published and defined in \ref UsdPhysicsTokens.
44 /// So to set an attribute to the value "rightHanded", use UsdPhysicsTokens->rightHanded
45 /// as the value.
46 ///
48 {
49 public:
50  /// Compile time constant representing what kind of schema this class is.
51  ///
52  /// \sa UsdSchemaKind
54 
55  /// Construct a UsdPhysicsMeshCollisionAPI on UsdPrim \p prim .
56  /// Equivalent to UsdPhysicsMeshCollisionAPI::Get(prim.GetStage(), prim.GetPath())
57  /// for a \em valid \p prim, but will not immediately throw an error for
58  /// an invalid \p prim
59  explicit UsdPhysicsMeshCollisionAPI(const UsdPrim& prim=UsdPrim())
60  : UsdAPISchemaBase(prim)
61  {
62  }
63 
64  /// Construct a UsdPhysicsMeshCollisionAPI on the prim held by \p schemaObj .
65  /// Should be preferred over UsdPhysicsMeshCollisionAPI(schemaObj.GetPrim()),
66  /// as it preserves SchemaBase state.
67  explicit UsdPhysicsMeshCollisionAPI(const UsdSchemaBase& schemaObj)
68  : UsdAPISchemaBase(schemaObj)
69  {
70  }
71 
72  /// Destructor.
75 
76  /// Return a vector of names of all pre-declared attributes for this schema
77  /// class and all its ancestor classes. Does not include attributes that
78  /// may be authored by custom/extended methods of the schemas involved.
80  static const TfTokenVector &
81  GetSchemaAttributeNames(bool includeInherited=true);
82 
83  /// Return a UsdPhysicsMeshCollisionAPI holding the prim adhering to this
84  /// schema at \p path on \p stage. If no prim exists at \p path on
85  /// \p stage, or if the prim at that path does not adhere to this schema,
86  /// return an invalid schema object. This is shorthand for the following:
87  ///
88  /// \code
89  /// UsdPhysicsMeshCollisionAPI(stage->GetPrimAtPath(path));
90  /// \endcode
91  ///
94  Get(const UsdStagePtr &stage, const SdfPath &path);
95 
96 
97  /// Returns true if this <b>single-apply</b> API schema can be applied to
98  /// the given \p prim. If this schema can not be a applied to the prim,
99  /// this returns false and, if provided, populates \p whyNot with the
100  /// reason it can not be applied.
101  ///
102  /// Note that if CanApply returns false, that does not necessarily imply
103  /// that calling Apply will fail. Callers are expected to call CanApply
104  /// before calling Apply if they want to ensure that it is valid to
105  /// apply a schema.
106  ///
107  /// \sa UsdPrim::GetAppliedSchemas()
108  /// \sa UsdPrim::HasAPI()
109  /// \sa UsdPrim::CanApplyAPI()
110  /// \sa UsdPrim::ApplyAPI()
111  /// \sa UsdPrim::RemoveAPI()
112  ///
114  static bool
115  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
116 
117  /// Applies this <b>single-apply</b> API schema to the given \p prim.
118  /// This information is stored by adding "PhysicsMeshCollisionAPI" to the
119  /// token-valued, listOp metadata \em apiSchemas on the prim.
120  ///
121  /// \return A valid UsdPhysicsMeshCollisionAPI object is returned upon success.
122  /// An invalid (or empty) UsdPhysicsMeshCollisionAPI object is returned upon
123  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
124  /// resulting in failure.
125  ///
126  /// \sa UsdPrim::GetAppliedSchemas()
127  /// \sa UsdPrim::HasAPI()
128  /// \sa UsdPrim::CanApplyAPI()
129  /// \sa UsdPrim::ApplyAPI()
130  /// \sa UsdPrim::RemoveAPI()
131  ///
134  Apply(const UsdPrim &prim);
135 
136 protected:
137  /// Returns the kind of schema this class belongs to.
138  ///
139  /// \sa UsdSchemaKind
141  UsdSchemaKind _GetSchemaKind() const override;
142 
143 private:
144  // needs to invoke _GetStaticTfType.
145  friend class UsdSchemaRegistry;
147  static const TfType &_GetStaticTfType();
148 
149  static bool _IsTypedSchema();
150 
151  // override SchemaBase virtuals.
153  const TfType &_GetTfType() const override;
154 
155 public:
156  // --------------------------------------------------------------------- //
157  // APPROXIMATION
158  // --------------------------------------------------------------------- //
159  /// Determines the mesh's collision approximation:
160  /// "none" - The mesh geometry is used directly as a collider without any
161  /// approximation.
162  /// "convexDecomposition" - A convex mesh decomposition is performed. This
163  /// results in a set of convex mesh colliders.
164  /// "convexHull" - A convex hull of the mesh is generated and used as the
165  /// collider.
166  /// "boundingSphere" - A bounding sphere is computed around the mesh and used
167  /// as a collider.
168  /// "boundingCube" - An optimally fitting box collider is computed around the
169  /// mesh.
170  /// "meshSimplification" - A mesh simplification step is performed, resulting
171  /// in a simplified triangle mesh collider.
172  ///
173  /// | ||
174  /// | -- | -- |
175  /// | Declaration | `uniform token physics:approximation = "none"` |
176  /// | C++ Type | TfToken |
177  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
178  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
179  /// | \ref UsdPhysicsTokens "Allowed Values" | none, convexDecomposition, convexHull, boundingSphere, boundingCube, meshSimplification |
182 
183  /// See GetApproximationAttr(), and also
184  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
185  /// If specified, author \p defaultValue as the attribute's default,
186  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
187  /// the default for \p writeSparsely is \c false.
189  UsdAttribute CreateApproximationAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
190 
191 public:
192  // ===================================================================== //
193  // Feel free to add custom code below this line, it will be preserved by
194  // the code generator.
195  //
196  // Just remember to:
197  // - Close the class declaration with };
198  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
199  // - Close the include guard with #endif
200  // ===================================================================== //
201  // --(BEGIN CUSTOM CODE)--
202 };
203 
205 
206 #endif
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
static USDPHYSICS_API UsdPhysicsMeshCollisionAPI Get(const UsdStagePtr &stage, const SdfPath &path)
UsdPhysicsMeshCollisionAPI(const UsdPrim &prim=UsdPrim())
Single Apply API schema.
virtual USDPHYSICS_API ~UsdPhysicsMeshCollisionAPI()
Destructor.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdPhysicsMeshCollisionAPI(const UsdSchemaBase &schemaObj)
static USDPHYSICS_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
static USDPHYSICS_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
static const UsdSchemaKind schemaKind
USDPHYSICS_API UsdAttribute CreateApproximationAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
#define USDPHYSICS_API
Definition: api.h:23
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
static USDPHYSICS_API UsdPhysicsMeshCollisionAPI Apply(const UsdPrim &prim)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDPHYSICS_API UsdAttribute GetApproximationAttr() const
Definition: value.h:146