Skip to content

Commit

Permalink
Update UsdImagingCoordSysAPIAdapter
Browse files Browse the repository at this point in the history
- Adds coordSys:<instanceName> coordSys hydra prim
    - This provides info for coordSys hydra prim, which can be queried for:
        - name (instanceName of the corresponding applied UsdShadeCoordSysAPI)
        - xform values
    - Updated stageSceneIndexContext test usda and baseline

Following updates were done for the above:
- Implemented GetImagingSubprims and GetImagingSubprimType methods for UsdImagingCoordSysAPIAdapter
- Implement UsdImagingDataSourceCoordsysPrim which is a data source representing the subprim and is responsible for providing coordSys prim's name and xform.
- Adds a new HdCoordSysSchema which also provides "name" member field and its builder interface(s).

(Internal change: 2263106)
  • Loading branch information
tallytalwar authored and pixar-oss committed Feb 16, 2023
1 parent c20bc87 commit 3609cfc
Show file tree
Hide file tree
Showing 6 changed files with 382 additions and 22 deletions.
1 change: 1 addition & 0 deletions pxr/imaging/hd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pxr_library(hd
coneSchema
containerDataSourceEditor
coordSys
coordSysSchema
coordSysBindingSchema
cubeSchema
cylinderSchema
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hd/coordSysBindingSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ class HdCoordSysBindingSchema : public HdSchema

PXR_NAMESPACE_CLOSE_SCOPE

#endif
#endif
107 changes: 107 additions & 0 deletions pxr/imaging/hd/coordSysSchema.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//
// Copyright 2022 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
////////////////////////////////////////////////////////////////////////

/* ************************************************************************** */
/* ** This file is generated by a script. Do not edit directly. Edit ** */
/* ** defs.py or the (*)Schema.template.cpp files to make changes. ** */
/* ************************************************************************** */

#include "pxr/imaging/hd/coordSysSchema.h"
#include "pxr/imaging/hd/retainedDataSource.h"

#include "pxr/base/trace/trace.h"


PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_PUBLIC_TOKENS(HdCoordSysSchemaTokens,
HDCOORDSYS_SCHEMA_TOKENS);



HdTokenDataSourceHandle
HdCoordSysSchema::GetName()
{
return _GetTypedDataSource<HdTokenDataSource>(
HdCoordSysSchemaTokens->name);
}

/*static*/
HdContainerDataSourceHandle
HdCoordSysSchema::BuildRetained(
const HdTokenDataSourceHandle &name
)
{
TfToken names[1];
HdDataSourceBaseHandle values[1];

size_t count = 0;
if (name) {
names[count] = HdCoordSysSchemaTokens->name;
values[count++] = name;
}

return HdRetainedContainerDataSource::New(count, names, values);
}

/*static*/
HdCoordSysSchema
HdCoordSysSchema::GetFromParent(
const HdContainerDataSourceHandle &fromParentContainer)
{
return HdCoordSysSchema(
fromParentContainer
? HdContainerDataSource::Cast(fromParentContainer->Get(
HdCoordSysSchemaTokens->coordSys))
: nullptr);
}

/*static*/
const HdDataSourceLocator &
HdCoordSysSchema::GetDefaultLocator()
{
static const HdDataSourceLocator locator(
HdCoordSysSchemaTokens->coordSys
);
return locator;
}
HdCoordSysSchema::Builder &
HdCoordSysSchema::Builder::SetName(
const HdTokenDataSourceHandle &name)
{
_name = name;
return *this;
}

HdContainerDataSourceHandle
HdCoordSysSchema::Builder::Build()
{
return HdCoordSysSchema::BuildRetained(
_name
);
}


PXR_NAMESPACE_CLOSE_SCOPE
114 changes: 114 additions & 0 deletions pxr/imaging/hd/coordSysSchema.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// Copyright 2022 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
////////////////////////////////////////////////////////////////////////

/* ************************************************************************** */
/* ** This file is generated by a script. Do not edit directly. Edit ** */
/* ** defs.py or the (*)Schema.template.h files to make changes. ** */
/* ************************************************************************** */

#ifndef PXR_IMAGING_HD_COORD_SYS_SCHEMA_H
#define PXR_IMAGING_HD_COORD_SYS_SCHEMA_H

#include "pxr/imaging/hd/api.h"

#include "pxr/imaging/hd/schema.h"

PXR_NAMESPACE_OPEN_SCOPE

//-----------------------------------------------------------------------------

#define HDCOORDSYS_SCHEMA_TOKENS \
(coordSys) \
(name) \

TF_DECLARE_PUBLIC_TOKENS(HdCoordSysSchemaTokens, HD_API,
HDCOORDSYS_SCHEMA_TOKENS);

//-----------------------------------------------------------------------------

class HdCoordSysSchema : public HdSchema
{
public:
HdCoordSysSchema(HdContainerDataSourceHandle container)
: HdSchema(container) {}

//ACCESSORS

HD_API
HdTokenDataSourceHandle GetName();

// RETRIEVING AND CONSTRUCTING

/// Builds a container data source which includes the provided child data
/// sources. Parameters with nullptr values are excluded. This is a
/// low-level interface. For cases in which it's desired to define
/// the container with a sparse set of child fields, the Builder class
/// is often more convenient and readable.
HD_API
static HdContainerDataSourceHandle
BuildRetained(
const HdTokenDataSourceHandle &name
);

/// \class HdCoordSysSchema::Builder
///
/// Utility class for setting sparse sets of child data source fields to be
/// filled as arguments into BuildRetained. Because all setter methods
/// return a reference to the instance, this can be used in the "builder
/// pattern" form.
class Builder
{
public:
HD_API
Builder &SetName(
const HdTokenDataSourceHandle &name);

/// Returns a container data source containing the members set thus far.
HD_API
HdContainerDataSourceHandle Build();

private:
HdTokenDataSourceHandle _name;
};

/// Retrieves a container data source with the schema's default name token
/// "coordSys" from the parent container and constructs a
/// HdCoordSysSchema instance.
/// Because the requested container data source may not exist, the result
/// should be checked with IsDefined() or a bool comparison before use.
HD_API
static HdCoordSysSchema GetFromParent(
const HdContainerDataSourceHandle &fromParentContainer);

/// Returns an HdDataSourceLocator (relative to the prim-level data source)
/// where the container representing this schema is found by default.
HD_API
static const HdDataSourceLocator &GetDefaultLocator();

};

PXR_NAMESPACE_CLOSE_SCOPE

#endif
Loading

0 comments on commit 3609cfc

Please sign in to comment.