Skip to content

Commit

Permalink
Merge pull request #1424 from AlesBorovicka/physics-schema
Browse files Browse the repository at this point in the history
UsdPhysics schema

(Internal change: 2174307)
  • Loading branch information
pixar-oss committed Jun 25, 2021
2 parents e8d4dde + 8f5d21c commit c4d5d78
Show file tree
Hide file tree
Showing 77 changed files with 15,392 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/doxygen/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ EXCLUDE_PATTERNS =

EXCLUDE_SYMBOLS = Usd_* \
UsdGeom_* \
UsdPhysics_* \
UsdRi_* \
UsdShade_* \
UsdHydra_* \
Expand Down
6 changes: 6 additions & 0 deletions docs/doxygen/externalOverview.dox
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ modules that layer on top of the core. In low-to-high order, the modules are:
of the schema classes are produced entirely via the \em usdGenSchema code
generator included with the core.

- \ref usdPhysics_page_front : The primary physics-supporting schema module,
UsdPhysics provides physics description of the USD prims (rigid bodies,
joints, scenes, collisions, etc.). Physics schema also defines physics
related metrics like the mass units, kilogramsPerUnit (\ref
UsdPhysicsTokensType::kilogramsPerUnit).

- \ref usdShade_page_front Schema module that defines Looks, Shaders,
connectible Parameters, with API for building shading networks and
user-facing "Look Interfaces" that allow shading networks to be shared (via
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(DIRS
usdSkel
usdUI
usdUtils
usdPhysics
plugin
)

Expand Down
89 changes: 89 additions & 0 deletions pxr/usd/usdPhysics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
set(PXR_PREFIX pxr/usd)
set(PXR_PACKAGE usdPhysics)

pxr_library(usdPhysics
LIBRARIES
js
tf
plug
vt
sdf
trace
usd
usdGeom
work
${Boost_PYTHON_LIBRARY}
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${TBB_INCLUDE_DIRS}

PUBLIC_CLASSES
articulationRootAPI
collisionAPI
collisionGroup
distanceJoint
driveAPI
filteredPairsAPI
fixedJoint
joint
limitAPI
massAPI
materialAPI
meshCollisionAPI
metrics
prismaticJoint
revoluteJoint
rigidBodyAPI
scene
sphericalJoint
tokens

PUBLIC_HEADERS
api.h

PYTHON_CPPFILES
moduleDeps.cpp

PYMODULE_CPPFILES
module.cpp
wrapArticulationRootAPI.cpp
wrapCollisionAPI.cpp
wrapCollisionGroup.cpp
wrapDistanceJoint.cpp
wrapDriveAPI.cpp
wrapFilteredPairsAPI.cpp
wrapFixedJoint.cpp
wrapJoint.cpp
wrapLimitAPI.cpp
wrapMassAPI.cpp
wrapMaterialAPI.cpp
wrapMeshCollisionAPI.cpp
wrapMetrics.cpp
wrapPrismaticJoint.cpp
wrapRevoluteJoint.cpp
wrapRigidBodyAPI.cpp
wrapScene.cpp
wrapSphericalJoint.cpp
wrapTokens.cpp

PYMODULE_FILES
__init__.py

RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdPhysics/schema.usda

DOXYGEN_FILES
overview.dox
examples/usdPhysicsBoxOnBox.usda
examples/usdPhysicsBoxOnQuad.usda
examples/usdPhysicsDistanceJoint.usda
examples/usdPhysicsGroupFiltering.usda
examples/usdPhysicsJoints.usda
examples/usdPhysicsPairFiltering.usda
examples/usdPhysicsSpheresWithMaterial.usda
)

46 changes: 46 additions & 0 deletions pxr/usd/usdPhysics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
#====
# Copyright (c) 2018, NVIDIA CORPORATION
#======
#

#
# Copyright 2016 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.
#
from . import _usdPhysics
from pxr import Tf
Tf.PrepareModule(_usdPhysics, locals())
del Tf

try:
import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
try:
import __tmpDoc
__tmpDoc.Execute(locals())
del __tmpDoc
except:
pass

47 changes: 47 additions & 0 deletions pxr/usd/usdPhysics/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Copyright 2017 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.
//
#ifndef USDPHYSICS_API_H
#define USDPHYSICS_API_H

#include "pxr/base/arch/export.h"

#if defined(PXR_STATIC)
# define USDPHYSICS_API
# define USDPHYSICS_API_TEMPLATE_CLASS(...)
# define USDPHYSICS_API_TEMPLATE_STRUCT(...)
# define USDPHYSICS_LOCAL
#else
# if defined(USDPHYSICS_EXPORTS)
# define USDPHYSICS_API ARCH_EXPORT
# define USDPHYSICS_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
# define USDPHYSICS_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
# else
# define USDPHYSICS_API ARCH_IMPORT
# define USDPHYSICS_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
# define USDPHYSICS_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
# endif
# define USDPHYSICS_LOCAL ARCH_HIDDEN
#endif

#endif
134 changes: 134 additions & 0 deletions pxr/usd/usdPhysics/articulationRootAPI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//
// Copyright 2016 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.
//
#include "pxr/usd/usdPhysics/articulationRootAPI.h"
#include "pxr/usd/usd/schemaRegistry.h"
#include "pxr/usd/usd/typed.h"
#include "pxr/usd/usd/tokens.h"

#include "pxr/usd/sdf/types.h"
#include "pxr/usd/sdf/assetPath.h"

PXR_NAMESPACE_OPEN_SCOPE

// Register the schema with the TfType system.
TF_REGISTRY_FUNCTION(TfType)
{
TfType::Define<UsdPhysicsArticulationRootAPI,
TfType::Bases< UsdAPISchemaBase > >();

}

TF_DEFINE_PRIVATE_TOKENS(
_schemaTokens,
(PhysicsArticulationRootAPI)
);

/* virtual */
UsdPhysicsArticulationRootAPI::~UsdPhysicsArticulationRootAPI()
{
}

/* static */
UsdPhysicsArticulationRootAPI
UsdPhysicsArticulationRootAPI::Get(const UsdStagePtr &stage, const SdfPath &path)
{
if (!stage) {
TF_CODING_ERROR("Invalid stage");
return UsdPhysicsArticulationRootAPI();
}
return UsdPhysicsArticulationRootAPI(stage->GetPrimAtPath(path));
}


/* virtual */
UsdSchemaKind UsdPhysicsArticulationRootAPI::_GetSchemaKind() const
{
return UsdPhysicsArticulationRootAPI::schemaKind;
}

/* static */
bool
UsdPhysicsArticulationRootAPI::CanApply(
const UsdPrim &prim, std::string *whyNot)
{
return prim.CanApplyAPI<UsdPhysicsArticulationRootAPI>(whyNot);
}

/* static */
UsdPhysicsArticulationRootAPI
UsdPhysicsArticulationRootAPI::Apply(const UsdPrim &prim)
{
if (prim.ApplyAPI<UsdPhysicsArticulationRootAPI>()) {
return UsdPhysicsArticulationRootAPI(prim);
}
return UsdPhysicsArticulationRootAPI();
}

/* static */
const TfType &
UsdPhysicsArticulationRootAPI::_GetStaticTfType()
{
static TfType tfType = TfType::Find<UsdPhysicsArticulationRootAPI>();
return tfType;
}

/* static */
bool
UsdPhysicsArticulationRootAPI::_IsTypedSchema()
{
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
return isTyped;
}

/* virtual */
const TfType &
UsdPhysicsArticulationRootAPI::_GetTfType() const
{
return _GetStaticTfType();
}

/*static*/
const TfTokenVector&
UsdPhysicsArticulationRootAPI::GetSchemaAttributeNames(bool includeInherited)
{
static TfTokenVector localNames;
static TfTokenVector allNames =
UsdAPISchemaBase::GetSchemaAttributeNames(true);

if (includeInherited)
return allNames;
else
return localNames;
}

PXR_NAMESPACE_CLOSE_SCOPE

// ===================================================================== //
// Feel free to add custom code below this line. It will be preserved by
// the code generator.
//
// Just remember to wrap code in the appropriate delimiters:
// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'.
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
Loading

0 comments on commit c4d5d78

Please sign in to comment.