Skip to content

Commit e898be2

Browse files
committed
New ParticleField schema.
ParticleField base schema type combined with sets of different appliedAPI schema to compose functionality in to a concrete ParticleField instance. ParticleField_3DGaussianSplat is a concrete instance with pre-applied apiSchema to define the necessary attributes.
1 parent 8e994e0 commit e898be2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+6970
-1211
lines changed

pxr/usd/usdLightField/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ pxr_library(usdLightField
55
INCLUDE_SCHEMA_FILES
66

77
LIBRARIES
8-
plug
98
tf
109
sdf
1110
vt
1211
gf
12+
pcp
1313
usd
1414
usdGeom
15+
arch
16+
17+
CPPFILES
18+
# List non-schema cpp files
1519

1620
PUBLIC_HEADERS
1721
api.h
18-
22+
1923
PYMODULE_FILES
2024
__init__.py
2125
)

pxr/usd/usdLightField/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#
2-
# Copyright 2025 Pixar
2+
# Copyright 2024 Pixar
33
#
44
# Licensed under the terms set forth in the LICENSE.txt file available at
55
# https://openusd.org/license.
66
#
7+
78
from pxr import Tf
89
Tf.PreparePythonModule()
910
del Tf
10-
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
#include "pxr/usd/usdLightField/gaussianFalloffFunctionAPI.h"
8+
#include "pxr/usd/usd/schemaRegistry.h"
9+
#include "pxr/usd/usd/typed.h"
10+
11+
#include "pxr/usd/sdf/types.h"
12+
#include "pxr/usd/sdf/assetPath.h"
13+
14+
PXR_NAMESPACE_OPEN_SCOPE
15+
16+
// Register the schema with the TfType system.
17+
TF_REGISTRY_FUNCTION(TfType)
18+
{
19+
TfType::Define<UsdLightFieldGaussianFalloffFunctionAPI,
20+
TfType::Bases< UsdAPISchemaBase > >();
21+
22+
}
23+
24+
/* virtual */
25+
UsdLightFieldGaussianFalloffFunctionAPI::~UsdLightFieldGaussianFalloffFunctionAPI()
26+
{
27+
}
28+
29+
/* static */
30+
UsdLightFieldGaussianFalloffFunctionAPI
31+
UsdLightFieldGaussianFalloffFunctionAPI::Get(const UsdStagePtr &stage, const SdfPath &path)
32+
{
33+
if (!stage) {
34+
TF_CODING_ERROR("Invalid stage");
35+
return UsdLightFieldGaussianFalloffFunctionAPI();
36+
}
37+
return UsdLightFieldGaussianFalloffFunctionAPI(stage->GetPrimAtPath(path));
38+
}
39+
40+
41+
/* virtual */
42+
UsdSchemaKind UsdLightFieldGaussianFalloffFunctionAPI::_GetSchemaKind() const
43+
{
44+
return UsdLightFieldGaussianFalloffFunctionAPI::schemaKind;
45+
}
46+
47+
/* static */
48+
bool
49+
UsdLightFieldGaussianFalloffFunctionAPI::CanApply(
50+
const UsdPrim &prim, std::string *whyNot)
51+
{
52+
return prim.CanApplyAPI<UsdLightFieldGaussianFalloffFunctionAPI>(whyNot);
53+
}
54+
55+
/* static */
56+
UsdLightFieldGaussianFalloffFunctionAPI
57+
UsdLightFieldGaussianFalloffFunctionAPI::Apply(const UsdPrim &prim)
58+
{
59+
if (prim.ApplyAPI<UsdLightFieldGaussianFalloffFunctionAPI>()) {
60+
return UsdLightFieldGaussianFalloffFunctionAPI(prim);
61+
}
62+
return UsdLightFieldGaussianFalloffFunctionAPI();
63+
}
64+
65+
/* static */
66+
const TfType &
67+
UsdLightFieldGaussianFalloffFunctionAPI::_GetStaticTfType()
68+
{
69+
static TfType tfType = TfType::Find<UsdLightFieldGaussianFalloffFunctionAPI>();
70+
return tfType;
71+
}
72+
73+
/* static */
74+
bool
75+
UsdLightFieldGaussianFalloffFunctionAPI::_IsTypedSchema()
76+
{
77+
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
78+
return isTyped;
79+
}
80+
81+
/* virtual */
82+
const TfType &
83+
UsdLightFieldGaussianFalloffFunctionAPI::_GetTfType() const
84+
{
85+
return _GetStaticTfType();
86+
}
87+
88+
/*static*/
89+
const TfTokenVector&
90+
UsdLightFieldGaussianFalloffFunctionAPI::GetSchemaAttributeNames(bool includeInherited)
91+
{
92+
static TfTokenVector localNames;
93+
static TfTokenVector allNames =
94+
UsdAPISchemaBase::GetSchemaAttributeNames(true);
95+
96+
if (includeInherited)
97+
return allNames;
98+
else
99+
return localNames;
100+
}
101+
102+
PXR_NAMESPACE_CLOSE_SCOPE
103+
104+
// ===================================================================== //
105+
// Feel free to add custom code below this line. It will be preserved by
106+
// the code generator.
107+
//
108+
// Just remember to wrap code in the appropriate delimiters:
109+
// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'.
110+
// ===================================================================== //
111+
// --(BEGIN CUSTOM CODE)--
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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 USDLIGHTFIELD_GENERATED_GAUSSIANFALLOFFFUNCTIONAPI_H
8+
#define USDLIGHTFIELD_GENERATED_GAUSSIANFALLOFFFUNCTIONAPI_H
9+
10+
/// \file usdLightField/gaussianFalloffFunctionAPI.h
11+
12+
#include "pxr/pxr.h"
13+
#include "pxr/usd/usdLightField/api.h"
14+
#include "pxr/usd/usd/apiSchemaBase.h"
15+
#include "pxr/usd/usd/prim.h"
16+
#include "pxr/usd/usd/stage.h"
17+
18+
#include "pxr/base/vt/value.h"
19+
20+
#include "pxr/base/gf/vec3d.h"
21+
#include "pxr/base/gf/vec3f.h"
22+
#include "pxr/base/gf/matrix4d.h"
23+
24+
#include "pxr/base/tf/token.h"
25+
#include "pxr/base/tf/type.h"
26+
27+
PXR_NAMESPACE_OPEN_SCOPE
28+
29+
class SdfAssetPath;
30+
31+
// -------------------------------------------------------------------------- //
32+
// GAUSSIANFALLOFFFUNCTIONAPI //
33+
// -------------------------------------------------------------------------- //
34+
35+
/// \class UsdLightFieldGaussianFalloffFunctionAPI
36+
///
37+
/// Defines a Gaussian fall-off function. An opacity data source is
38+
/// required and it used to control the gaussian peak.
39+
///
40+
class UsdLightFieldGaussianFalloffFunctionAPI : public UsdAPISchemaBase
41+
{
42+
public:
43+
/// Compile time constant representing what kind of schema this class is.
44+
///
45+
/// \sa UsdSchemaKind
46+
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
47+
48+
/// Construct a UsdLightFieldGaussianFalloffFunctionAPI on UsdPrim \p prim .
49+
/// Equivalent to UsdLightFieldGaussianFalloffFunctionAPI::Get(prim.GetStage(), prim.GetPath())
50+
/// for a \em valid \p prim, but will not immediately throw an error for
51+
/// an invalid \p prim
52+
explicit UsdLightFieldGaussianFalloffFunctionAPI(const UsdPrim& prim=UsdPrim())
53+
: UsdAPISchemaBase(prim)
54+
{
55+
}
56+
57+
/// Construct a UsdLightFieldGaussianFalloffFunctionAPI on the prim held by \p schemaObj .
58+
/// Should be preferred over UsdLightFieldGaussianFalloffFunctionAPI(schemaObj.GetPrim()),
59+
/// as it preserves SchemaBase state.
60+
explicit UsdLightFieldGaussianFalloffFunctionAPI(const UsdSchemaBase& schemaObj)
61+
: UsdAPISchemaBase(schemaObj)
62+
{
63+
}
64+
65+
/// Destructor.
66+
USDLIGHTFIELD_API
67+
virtual ~UsdLightFieldGaussianFalloffFunctionAPI();
68+
69+
/// Return a vector of names of all pre-declared attributes for this schema
70+
/// class and all its ancestor classes. Does not include attributes that
71+
/// may be authored by custom/extended methods of the schemas involved.
72+
USDLIGHTFIELD_API
73+
static const TfTokenVector &
74+
GetSchemaAttributeNames(bool includeInherited=true);
75+
76+
/// Return a UsdLightFieldGaussianFalloffFunctionAPI holding the prim adhering to this
77+
/// schema at \p path on \p stage. If no prim exists at \p path on
78+
/// \p stage, or if the prim at that path does not adhere to this schema,
79+
/// return an invalid schema object. This is shorthand for the following:
80+
///
81+
/// \code
82+
/// UsdLightFieldGaussianFalloffFunctionAPI(stage->GetPrimAtPath(path));
83+
/// \endcode
84+
///
85+
USDLIGHTFIELD_API
86+
static UsdLightFieldGaussianFalloffFunctionAPI
87+
Get(const UsdStagePtr &stage, const SdfPath &path);
88+
89+
90+
/// Returns true if this <b>single-apply</b> API schema can be applied to
91+
/// the given \p prim. If this schema can not be a applied to the prim,
92+
/// this returns false and, if provided, populates \p whyNot with the
93+
/// reason it can not be applied.
94+
///
95+
/// Note that if CanApply returns false, that does not necessarily imply
96+
/// that calling Apply will fail. Callers are expected to call CanApply
97+
/// before calling Apply if they want to ensure that it is valid to
98+
/// apply a schema.
99+
///
100+
/// \sa UsdPrim::GetAppliedSchemas()
101+
/// \sa UsdPrim::HasAPI()
102+
/// \sa UsdPrim::CanApplyAPI()
103+
/// \sa UsdPrim::ApplyAPI()
104+
/// \sa UsdPrim::RemoveAPI()
105+
///
106+
USDLIGHTFIELD_API
107+
static bool
108+
CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
109+
110+
/// Applies this <b>single-apply</b> API schema to the given \p prim.
111+
/// This information is stored by adding "GaussianFalloffFunctionAPI" to the
112+
/// token-valued, listOp metadata \em apiSchemas on the prim.
113+
///
114+
/// \return A valid UsdLightFieldGaussianFalloffFunctionAPI object is returned upon success.
115+
/// An invalid (or empty) UsdLightFieldGaussianFalloffFunctionAPI object is returned upon
116+
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
117+
/// resulting in failure.
118+
///
119+
/// \sa UsdPrim::GetAppliedSchemas()
120+
/// \sa UsdPrim::HasAPI()
121+
/// \sa UsdPrim::CanApplyAPI()
122+
/// \sa UsdPrim::ApplyAPI()
123+
/// \sa UsdPrim::RemoveAPI()
124+
///
125+
USDLIGHTFIELD_API
126+
static UsdLightFieldGaussianFalloffFunctionAPI
127+
Apply(const UsdPrim &prim);
128+
129+
protected:
130+
/// Returns the kind of schema this class belongs to.
131+
///
132+
/// \sa UsdSchemaKind
133+
USDLIGHTFIELD_API
134+
UsdSchemaKind _GetSchemaKind() const override;
135+
136+
private:
137+
// needs to invoke _GetStaticTfType.
138+
friend class UsdSchemaRegistry;
139+
USDLIGHTFIELD_API
140+
static const TfType &_GetStaticTfType();
141+
142+
static bool _IsTypedSchema();
143+
144+
// override SchemaBase virtuals.
145+
USDLIGHTFIELD_API
146+
const TfType &_GetTfType() const override;
147+
148+
public:
149+
// ===================================================================== //
150+
// Feel free to add custom code below this line, it will be preserved by
151+
// the code generator.
152+
//
153+
// Just remember to:
154+
// - Close the class declaration with };
155+
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
156+
// - Close the include guard with #endif
157+
// ===================================================================== //
158+
// --(BEGIN CUSTOM CODE)--
159+
};
160+
161+
PXR_NAMESPACE_CLOSE_SCOPE
162+
163+
#endif

0 commit comments

Comments
 (0)