file_path
stringlengths
32
153
content
stringlengths
0
3.14M
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/usd/OgnReadStageSelection.ogn
{ "ReadStageSelection": { "version": 1, "description": [ "Outputs the current stage selection as a list of paths" ], "uiName": "Read Stage Selection", "categories": ["sceneGraph"], "scheduling": ["usd-read"], "inputs": { }, "outputs": { "selectedPrims": { "type": "token[]", "description": "The currently selected path(s)" } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/usd/OgnReadStageSelection.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // // clang-format off #include "UsdPCH.h" // clang-format on #include <omni/usd/Selection.h> #include <omni/usd/UsdContext.h> #include <OgnReadStageSelectionDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnReadStageSelection { public: static bool compute(OgnReadStageSelectionDatabase& db) { omni::usd::UsdContext* usdContext = omni::usd::UsdContext::getContext(); PXR_NS::SdfPathVector selectedPaths = usdContext->getSelection()->getSelectedPrimPathsV2(); ogn::array<NameToken>& selectedPrims = db.outputs.selectedPrims(); selectedPrims.resize(selectedPaths.size()); std::transform(selectedPaths.begin(), selectedPaths.end(), selectedPrims.begin(), [&db](PXR_NS::SdfPath const& path) { std::string const& s = path.GetString(); auto tokenC = db.abi_context().iToken->getHandle(s.c_str()); return tokenC; }); return true; } }; REGISTER_OGN_NODE() } // nodes } // graph } // omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/usd/OgnIsPrimSelected.ogn
{ "IsPrimSelected": { "version": 1, "description": [ "Checks if the prim at the given path is currently selected" ], "uiName": "Is Prim Selected", "categories": ["sceneGraph"], "scheduling": ["usd-read"], "inputs": { "primPath": { "type": "token", "description": "The prim path to check" } }, "outputs": { "isSelected": { "type": "bool", "description": "True if the given path is in the current stage selection" } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord2f.ogn
{ "ConstantTexCoord2f": { "description": [ "Holds a 2D uv texture coordinate." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "texcoordf[2]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord3f.ogn
{ "ConstantTexCoord3f": { "description": [ "Holds a 3D uvw texture coordinate." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "texcoordf[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord3h.ogn
{ "ConstantTexCoord3h": { "description": [ "Holds a 3D uvw texture coordinate." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "texcoordh[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt64.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantInt64Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantInt64 { public: static size_t computeVectorized(OgnConstantInt64Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf4.ogn
{ "ConstantHalf4": { "description": [ "Holds a 4-component half constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "half[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble3.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantDouble3Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantDouble3 { public: static size_t computeVectorized(OgnConstantDouble3Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord3f.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantTexCoord3fDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantTexCoord3f { public: static size_t computeVectorized(OgnConstantTexCoord3fDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat.ogn
{ "ConstantFloat": { "description": "Holds a 32 bit floating point value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "float", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantBool.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantBoolDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantBool { public: static size_t computeVectorized(OgnConstantBoolDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt2.ogn
{ "ConstantInt2": { "description": [ "Holds a 2-component int constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "int[2]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf3.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantHalf3Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantHalf3 { public: static size_t computeVectorized(OgnConstantHalf3Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantToken.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantTokenDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantToken { public: static size_t computeVectorized(OgnConstantTokenDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantColor4f.ogn
{ "ConstantColor4f": { "description": [ "Holds a 4-component color constant, which is energy-linear RGBA, not pre-alpha multiplied" ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "colorf[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPath.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantPathDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantPath { public: static size_t computeVectorized(OgnConstantPathDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantDoubleDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantDouble { public: static size_t computeVectorized(OgnConstantDoubleDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantHalfDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantHalf { public: static size_t computeVectorized(OgnConstantHalfDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantUInt64.ogn
{ "ConstantUInt64": { "description": "Holds a 64 bit signed integer value", "version": 1, "categories": ["constants"], "uiName": "Constant UInt64", "scheduling": ["pure"], "inputs": { "value": { "type": "uint64", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble4.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantDouble4Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantDouble4 { public: static size_t computeVectorized(OgnConstantDouble4Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantQuatf.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantQuatfDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantQuatf { public: static size_t computeVectorized(OgnConstantQuatfDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantToken.ogn
{ "ConstantToken": { "description": "Holds a token value, which is a 64-bit value representing an interned string", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "token", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPi.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantPiDatabase.h> #include <omni/math/linalg/math.h> namespace omni { namespace graph { namespace nodes { class OgnConstantPi { public: static size_t computeVectorized(OgnConstantPiDatabase& db, size_t count) { auto ptr = db.outputs.value.vectorized(count); auto pFactor = db.inputs.factor.vectorized(count); for (size_t i =0 ; i < count; ++i) ptr[i] = pFactor[i] * M_PI; return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantBool.ogn
{ "ConstantBool": { "description": "Holds a boolean value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "bool", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble2.ogn
{ "ConstantDouble2": { "description": [ "Holds a 2-component double constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "double[2]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPoint3f.ogn
{ "ConstantPoint3f": { "description": [ "Holds a 3-component float constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "pointf[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantUInt.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantUIntDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantUInt { public: static size_t computeVectorized(OgnConstantUIntDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat2.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantFloat2Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantFloat2 { public: static size_t computeVectorized(OgnConstantFloat2Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPoint3d.ogn
{ "ConstantPoint3d": { "description": [ "Holds a 3-component double constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "pointd[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble2.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantDouble2Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantDouble2 { public: static size_t computeVectorized(OgnConstantDouble2Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantColor3f.ogn
{ "ConstantColor3f": { "description": [ "Holds a 3-component color constant, which is energy-linear RGB" ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "colorf[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt64.ogn
{ "ConstantInt64": { "description": "Holds a 64 bit signed integer constant value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "int64", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantQuatd.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantQuatdDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantQuatd { public: static size_t computeVectorized(OgnConstantQuatdDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantUInt.ogn
{ "ConstantUInt": { "description": "Holds a 32 bit unsigned integer value", "version": 1, "categories": ["constants"], "uiName": "Constant UInt", "scheduling": ["pure"], "inputs": { "value": { "type": "uint", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf3.ogn
{ "ConstantHalf3": { "description": [ "Holds a 3-component half-precision constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "half[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPi.ogn
{ "ConstantPi": { "description": "Holds a 64-bit floating point constant value that is a multiple of Pi", "version": 1, "categories": ["constants"], "scheduling": ["threadsafe"], "inputs": { "factor": { "type": "double", "description": "Multiply this by Pi to get the result", "uiName": "Factor", "default": 1 } }, "outputs": { "value": { "type": "double", "description": "Pi multiplied by the input factor", "uiName": "Value" } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord2h.ogn
{ "ConstantTexCoord2h": { "description": [ "Holds a 2D uv texture coordinate." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "texcoordh[2]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord3h.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantTexCoord3hDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantTexCoord3h { public: static size_t computeVectorized(OgnConstantTexCoord3hDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantFloatDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantFloat { public: static size_t computeVectorized(OgnConstantFloatDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt.ogn
{ "ConstantInt": { "description": "Holds a 32 bit signed integer constant value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "int", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantQuatf.ogn
{ "ConstantQuatf": { "description": [ "Holds a single-precision quaternion constant: A real coefficient and three imaginary coefficients." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "quatf[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt4.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantInt4Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantInt4 { public: static size_t computeVectorized(OgnConstantInt4Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat3.ogn
{ "ConstantFloat3": { "description": [ "Holds a 3-component float constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "float[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantString.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantStringDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantString { public: static size_t computeVectorized(OgnConstantStringDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat2.ogn
{ "ConstantFloat2": { "description": [ "Holds a 2-component float constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "float[2]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble3.ogn
{ "ConstantDouble3": { "description": [ "Holds a 3-component double constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "double[3]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord2h.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantTexCoord2hDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantTexCoord2h { public: static size_t computeVectorized(OgnConstantTexCoord2hDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf2.ogn
{ "ConstantHalf2": { "description": [ "Holds a 2-component half constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "half[2]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf4.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantHalf4Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantHalf4 { public: static size_t computeVectorized(OgnConstantHalf4Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantColor4f.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantColor4fDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantColor4f { public: static size_t computeVectorized(OgnConstantColor4fDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantTexCoord2f.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantTexCoord2fDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantTexCoord2f { public: static size_t computeVectorized(OgnConstantTexCoord2fDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf2.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantHalf2Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantHalf2 { public: static size_t computeVectorized(OgnConstantHalf2Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantUChar.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantUCharDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantUChar { public: static size_t computeVectorized(OgnConstantUCharDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantUChar.ogn
{ "ConstantUChar": { "description": "Holds an 8-bit unsigned character value", "version": 1, "categories": ["constants"], "uiName": "Constant UChar", "scheduling": ["pure"], "inputs": { "value": { "type": "uchar", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantHalf.ogn
{ "ConstantHalf": { "description": "Holds a 16-bit floating point value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "half", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantUInt64.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantUInt64Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantUInt64 { public: static size_t computeVectorized(OgnConstantUInt64Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantQuatd.ogn
{ "ConstantQuatd": { "description": [ "Holds a double-precision quaternion constant: A real coefficient and three imaginary coefficients" ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "quatd[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble.ogn
{ "ConstantDouble": { "description": "Holds a 64 bit floating point value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "double", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantString.ogn
{ "ConstantString": { "description": "Holds a string constant value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "string", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt4.ogn
{ "ConstantInt4": { "description": [ "Holds a 4-component int constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "int[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPoint3d.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantPoint3dDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantPoint3d { public: static size_t computeVectorized(OgnConstantPoint3dDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt2.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantInt2Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantInt2 { public: static size_t computeVectorized(OgnConstantInt2Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat4.ogn
{ "ConstantFloat4": { "description": [ "Holds a 4-component float constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "float[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantColor3f.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantColor3fDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantColor3f { public: static size_t computeVectorized(OgnConstantColor3fDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat4.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantFloat4Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantFloat4 { public: static size_t computeVectorized(OgnConstantFloat4Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPath.ogn
{ "ConstantPath": { "description": "Holds a path constant value", "version": 1, "categories": ["constants"], "scheduling": ["pure"], "inputs": { "value": { "type": "path", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantDouble4.ogn
{ "ConstantDouble4": { "description": [ "Holds a 4-component double constant." ], "categories": ["constants"], "scheduling": ["pure"], "version": 1, "inputs": { "value": { "type": "double[4]", "description": "The constant value", "uiName": "Value", "metadata": { "outputOnly": "1" } } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantPoint3f.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantPoint3fDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantPoint3f { public: static size_t computeVectorized(OgnConstantPoint3fDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantFloat3.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantFloat3Database.h> namespace omni { namespace graph { namespace nodes { class OgnConstantFloat3 { public: static size_t computeVectorized(OgnConstantFloat3Database&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/constants/OgnConstantInt.cpp
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantIntDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantInt { public: static size_t computeVectorized(OgnConstantIntDatabase&, size_t count) { return count; } }; REGISTER_OGN_NODE() } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnMakeVector3.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnMakeVector3Database.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/UsdTypes.h> #include <fstream> #include <iomanip> namespace omni { namespace graph { namespace nodes { namespace { template <typename Type> bool tryMakeVector(OgnMakeVector3Database& db, size_t count = 1) { const auto x = db.inputs.x().template get<Type>(); const auto y = db.inputs.y().template get<Type>(); const auto z = db.inputs.z().template get<Type>(); const auto vector = db.outputs.tuple().template get<Type[3]>(); if (x && y && z && vector) { const auto px = x.vectorized(count); const auto py = y.vectorized(count); const auto pz = z.vectorized(count); const auto pvector = vector.vectorized(count); if (not(pvector.empty() || px.empty() || py.empty() || pz.empty())) { for (size_t i = 0; i < count; i++) { pvector[i][0] = px[i]; pvector[i][1] = py[i]; pvector[i][2] = pz[i]; } return true; } return false; } for(size_t i = 0; i < count ; ++i) { const auto xArray = db.inputs.x(i).template get<Type[]>(); const auto yArray = db.inputs.y(i).template get<Type[]>(); const auto zArray = db.inputs.z(i).template get<Type[]>(); auto vectorArray = db.outputs.tuple(i).template get<Type[][3]>(); if (!vectorArray || !xArray || !yArray || !zArray){ return false; } if (xArray->size() != yArray->size() || xArray->size() != zArray->size()) { throw ogn::compute::InputError("Input arrays of different lengths x:" + std::to_string(xArray->size()) + ", y:" + std::to_string(yArray->size()) + ", z:" + std::to_string(zArray->size())); } vectorArray->resize(xArray->size()); for (size_t i = 0; i < vectorArray->size(); i++) { (*vectorArray)[i][0] = (*xArray)[i]; (*vectorArray)[i][1] = (*yArray)[i]; (*vectorArray)[i][2] = (*zArray)[i]; } } return true; } } // namespace // Node to merge 3 scalers together to make 3-vector class OgnMakeVector3 { public: static size_t computeVectorized(OgnMakeVector3Database& db, size_t count) { // Compute the components, if the types are all resolved. try { if (tryMakeVector<double>(db, count)) return count; else if (tryMakeVector<float>(db, count)) return count; else if (tryMakeVector<pxr::GfHalf>(db, count)) return count; else if (tryMakeVector<int32_t>(db, count)) return count; else { db.logError("Failed to resolve input types"); return 0; } } catch (const std::exception& e) { db.logError("Vector could not be made: %s", e.what()); return 0; } return 0; } static void onConnectionTypeResolve(const NodeObj& nodeObj) { auto x = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::x.token()); auto y = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::y.token()); auto z = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::z.token()); auto vector = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::tuple.token()); auto xType = vector.iAttribute->getResolvedType(x); auto yType = vector.iAttribute->getResolvedType(y); auto zType = vector.iAttribute->getResolvedType(z); // If one of the inputs is resolved we can resolve the other because they should match std::array<AttributeObj, 3> attrs { x, y, z }; if (nodeObj.iNode->resolveCoupledAttributes(nodeObj, attrs.data(), attrs.size())) { xType = vector.iAttribute->getResolvedType(x); yType = vector.iAttribute->getResolvedType(y); zType = vector.iAttribute->getResolvedType(z); } // Require inputs to be resolved before determining outputs' type if (xType.baseType != BaseDataType::eUnknown && yType.baseType != BaseDataType::eUnknown && zType.baseType != BaseDataType::eUnknown ) { std::array<AttributeObj, 4> attrs{ x, y, z, vector }; std::array<uint8_t, 4> tuples{ 1, 1, 1, 3 }; std::array<uint8_t, 4> arrays{ xType.arrayDepth, yType.arrayDepth, zType.arrayDepth, xType.arrayDepth, }; std::array<AttributeRole, 4> roles{ xType.role, yType.role, zType.role, AttributeRole::eNone }; nodeObj.iNode->resolvePartiallyCoupledAttributes( nodeObj, attrs.data(), tuples.data(), arrays.data(), roles.data(), attrs.size()); } } }; REGISTER_OGN_NODE(); } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnConstantPrims.cpp
// Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstantPrimsDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnConstantPrims { public: static size_t computeVectorized(OgnConstantPrimsDatabase& db, size_t count) { return count; } }; REGISTER_OGN_NODE(); } // nodes } // graph } // omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnGetParentPrims.ogn
{ "GetParentPrims": { "version": 1, "description": ["Generates parent paths from one or more targeted paths (ex. /World/Cube -> /World)"], "uiName": "Get Parent Prims", "categories": ["sceneGraph"], "scheduling": [ "threadsafe" ], "inputs": { "prims": { "type": "target", "description": "Input prim paths (ex. /World/Cube)", "metadata": { "allowMultiInputs": "1" } } }, "outputs": { "parentPrims": { "type": "target", "description": "Computed parent paths (ex. /World)" } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnConstructArray.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnConstructArrayDatabase.h> #include <carb/logging/Log.h> #include <omni/graph/core/Type.h> #include <omni/graph/core/StringUtils.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <array> #include <unordered_map> #include <vector> namespace omni { namespace graph { namespace nodes { // unnamed namespace to avoid multiple declaration when linking namespace { static constexpr size_t kMaxAttrNameLen{ 32 }; void formatAttrName(size_t n, std::array<char, kMaxAttrNameLen>& outName) { snprintf(outName.data(), kMaxAttrNameLen, "inputs:input%zu", n); } template<typename BaseType> bool tryComputeAssumingType(OgnConstructArrayDatabase& db) { NodeObj nodeObj = db.abi_node(); auto iNode = nodeObj.iNode; GraphObj graphObj = iNode->getGraph(nodeObj); GraphContextObj context = graphObj.iGraph->getDefaultGraphContext(graphObj); auto const outputArrayAttr = iNode->getAttributeByToken(nodeObj, outputs::array.token()); auto const outputArrayType = outputArrayAttr.iAttribute->getResolvedType(outputArrayAttr); if (outputArrayType.baseType == BaseDataType::eUnknown) { return false; } auto outputArray = db.outputs.array().template get<BaseType[]>(); if (!outputArray) return false; size_t const arraySize = static_cast<size_t>(std::max(0, db.inputs.arraySize())); (*outputArray).resize(arraySize); memset(outputArray->data(), 0, sizeof(BaseType) * arraySize); // read dynamic inputs size_t i = 0; std::array<char, kMaxAttrNameLen> outName; formatAttrName(i, outName); while (iNode->getAttributeExists(nodeObj, outName.data()) && i < arraySize) { auto inAttrib = iNode->getAttribute(nodeObj, outName.data()); auto inputAttribType = inAttrib.iAttribute->getResolvedType(inAttrib); if (inputAttribType.baseType != BaseDataType::eUnknown) { ConstAttributeDataHandle handle = inAttrib.iAttribute->getConstAttributeDataHandle(inAttrib, db.getInstanceIndex()); auto const dataPtr = getDataR<BaseType>(context, handle); if (dataPtr) (*outputArray)[i] = *dataPtr; } ++i; formatAttrName(i, outName); } // fill the rest of the array using the last input value if necessary if (0 < i && i < arraySize) { for (size_t j = i; j < arraySize; ++j) { (*outputArray)[j] = (*outputArray)[i - 1]; } } return true; } template<typename BaseType, size_t TupleSize> bool tryComputeAssumingType(OgnConstructArrayDatabase& db) { NodeObj nodeObj = db.abi_node(); auto iNode = nodeObj.iNode; GraphObj graphObj = iNode->getGraph(nodeObj); GraphContextObj context = graphObj.iGraph->getDefaultGraphContext(graphObj); auto const outputArrayAttr = iNode->getAttributeByToken(nodeObj, outputs::array.token()); auto const outputArrayType = outputArrayAttr.iAttribute->getResolvedType(outputArrayAttr); if (outputArrayType.baseType == BaseDataType::eUnknown) { return false; } auto outputArray = db.outputs.array().template get<BaseType[][TupleSize]>(); if (!outputArray) return false; size_t const arraySize = static_cast<size_t>(std::max(0, db.inputs.arraySize())); (*outputArray).resize(arraySize); memset(outputArray->data(), 0, sizeof(BaseType) * arraySize * TupleSize); // read dynamic inputs size_t i = 0; std::array<char, kMaxAttrNameLen> outName; formatAttrName(i, outName); while (iNode->getAttributeExists(nodeObj, outName.data()) && i < arraySize) { auto inAttrib = iNode->getAttribute(nodeObj, outName.data()); auto inputAttribType = inAttrib.iAttribute->getResolvedType(inAttrib); if (inputAttribType.baseType != BaseDataType::eUnknown) { ConstAttributeDataHandle handle = inAttrib.iAttribute->getConstAttributeDataHandle(inAttrib, db.getInstanceIndex()); auto const dataPtr = getDataR<BaseType[TupleSize]>(context, handle); if (dataPtr) memcpy(&((*outputArray)[i]), dataPtr, sizeof(BaseType) * TupleSize); } ++i; formatAttrName(i, outName); } // fill the rest of the array using the last input value if necessary if (0 < i && i < arraySize) { for (size_t j = i; j < arraySize; ++j) { memcpy(&((*outputArray)[j]), &((*outputArray)[i - 1]), sizeof(BaseType) * TupleSize); } } return true; } } // namespace class OgnConstructArray { static void tryResolveAttribute(omni::graph::core::NodeObj const& nodeObj, omni::graph::core::AttributeObj attrib, omni::graph::core::Type attribType) { Type valueType{ attrib.iAttribute->getResolvedType(attrib) }; bool attribIsValid = (attribType.baseType != BaseDataType::eUnknown); if (valueType.baseType != BaseDataType::eUnknown) { // Resolved // Case 1: We didn't find a valid source attribute => unresolve // Case 2: We found an attribute but it is not compatible with our current resolution => unresolve // Else: All good if (!attribIsValid or (attribType != valueType)) { // Not compatible! Request that the attribute be un-resolved. Note that this could fail if there are // connections that result in a contradiction during type propagation attrib.iAttribute->setResolvedType(attrib, Type(BaseDataType::eUnknown)); } } // If it's unresolved (and we have a valid attribute) we can request a resolution if (attribIsValid and (attrib.iAttribute->getResolvedType(attrib).baseType == BaseDataType::eUnknown)) { attrib.iAttribute->setResolvedType(attrib, attribType); } } static void tryResolveArrayAttributes(omni::graph::core::NodeObj const& nodeObj, bool reconnectInputs) { auto& state = OgnConstructArrayDatabase::sInternalState<OgnConstructArray>(nodeObj); // Get the input attributes std::vector<AttributeObj> inputAttributes; size_t i = 0; std::array<char, kMaxAttrNameLen> outName; formatAttrName(i, outName); while (nodeObj.iNode->getAttributeExists(nodeObj, outName.data())) { inputAttributes.push_back(nodeObj.iNode->getAttribute(nodeObj, outName.data())); ++i; formatAttrName(i, outName); } // Determine the output array type from the specified array type and connected inputs Type outputType = state.m_inputArrayType; // Initialize to the specified array type ('eUnknown' if unspecified, i.e. 'inputs:arrayType' is set to 'auto') for (auto const& inAttrib : inputAttributes) { // Check if input is an array if (inAttrib.iAttribute->getResolvedType(inAttrib).arrayDepth != 0) { OgnConstructArrayDatabase::logError(nodeObj, "Nested arrays not supported: The input array element at attribute '%s' is an array", inAttrib.iAttribute->getName(inAttrib)); // Unresolve output and return auto outputArrayAttrib = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::array.token()); tryResolveAttribute(nodeObj, outputArrayAttrib, Type(BaseDataType::eUnknown)); return; } // Skip unconnected inputs size_t upstreamConnectionCount = inAttrib.iAttribute->getUpstreamConnectionCount(inAttrib); if (upstreamConnectionCount != 1) continue; // Get the type of the current input from the upstream connection ConnectionInfo upstreamConnection; inAttrib.iAttribute->getUpstreamConnectionsInfo(inAttrib, &upstreamConnection, 1); Type const upstreamType = upstreamConnection.attrObj.iAttribute->getResolvedType(upstreamConnection.attrObj); // The array type is not specified, so infer from the first connected and resolved input if (upstreamType.baseType != BaseDataType::eUnknown) { if (outputType.baseType == BaseDataType::eUnknown) { outputType = upstreamType; } else { // Check if the specified or inferred array type matches the type of the current input if (!outputType.compatibleRawData(upstreamType)) { OgnConstructArrayDatabase::logError( nodeObj, "Mismatched array element type on input attribute '%s': expected '%s', got '%s'", inAttrib.iAttribute->getName(inAttrib), getOgnTypeName(outputType).c_str(), getOgnTypeName(upstreamType).c_str()); outputType = Type(BaseDataType::eUnknown); break; } } } } // Resolve inputs for (auto& inAttrib : inputAttributes) { size_t upstreamConnectionCount = inAttrib.iAttribute->getUpstreamConnectionCount(inAttrib); if (upstreamConnectionCount == 0) { // Resolve unconnected inputs to the specified array type, or the inferred array type if the array type is unspecified if (state.m_inputArrayType.baseType != BaseDataType::eUnknown) { if (inAttrib.iAttribute->getResolvedType(inAttrib) != state.m_inputArrayType) { // Case: The current input is disconnected and the array type is specified // Action: Resolve the current input to the specified array type tryResolveAttribute(nodeObj, inAttrib, state.m_inputArrayType); } } else { if (inAttrib.iAttribute->getResolvedType(inAttrib) != outputType) { // Case: The current input is disconnected and the array type is unspecified (auto) // Action: Resolve the current input to the inferred array type if any input is connected. // If no inputs are connected, then outputType will be 'eUnknown', unresolving the current input. tryResolveAttribute(nodeObj, inAttrib, outputType); } } } else if (upstreamConnectionCount == 1 && reconnectInputs) // reconnectInputs avoids an infinite loop { // Resolve connected inputs to the specified array type, or their upstream types if the array type is unspecified if (state.m_inputArrayType.baseType != BaseDataType::eUnknown) { // Check if already resolved to the specified array type if (inAttrib.iAttribute->getResolvedType(inAttrib) != state.m_inputArrayType) { // Disconnect before re-resolving ConnectionInfo upstreamConnection; inAttrib.iAttribute->getUpstreamConnectionsInfo(inAttrib, &upstreamConnection, 1); inAttrib.iAttribute->disconnectAttrs(upstreamConnection.attrObj, inAttrib, true); // Case: The current input is connected and the array type is specified // Action: Resolve the current input to the specified array type tryResolveAttribute(nodeObj, inAttrib, state.m_inputArrayType); // Reconnect ConnectionInfo destConnection {inAttrib, upstreamConnection.connectionType}; inAttrib.iAttribute->connectAttrsEx(upstreamConnection.attrObj, destConnection, true); } } else { ConnectionInfo upstreamConnection; inAttrib.iAttribute->getUpstreamConnectionsInfo(inAttrib, &upstreamConnection, 1); Type const upstreamType = upstreamConnection.attrObj.iAttribute->getResolvedType(upstreamConnection.attrObj); // Check if already resolved to the upstream type if (inAttrib.iAttribute->getResolvedType(inAttrib) != upstreamType) { // Disconnect before re-resolving inAttrib.iAttribute->disconnectAttrs(upstreamConnection.attrObj, inAttrib, true); // Case: The current input is connected and the array type is unspecified (auto) // Action: Resolve the current input to its upstream type (not the inferred array type 'outputType', // which could be a different but compatible type or 'eUnknown') tryResolveAttribute(nodeObj, inAttrib, Type(BaseDataType::eUnknown)); // Must be resolved to 'eUnknown', not 'upstreamType' // Reconnect ConnectionInfo destConnection {inAttrib, upstreamConnection.connectionType}; inAttrib.iAttribute->connectAttrsEx(upstreamConnection.attrObj, destConnection, true); } } } } // Resolve the output // If there is a type mismatch (regardless of whether the array type was specified), then 'outputType' gets set to 'eUnknown', so 'outputs:array' gets unresolved. // If the array type is unspecified (auto) and no inputs are connected (i.e. no type is inferred), then 'outputType' gets set to 'eUnknown' as well (but the node does not error). // Otherwise, 'outputs:array' gets resolved to the specified or inferred array type 'outputType'. outputType.arrayDepth = 1; auto outputArrayAttrib = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::array.token()); tryResolveAttribute(nodeObj, outputArrayAttrib, outputType); } static void onValueChanged(AttributeObj const& attrObj, void const* userData) { NodeObj nodeObj{ attrObj.iAttribute->getNode(attrObj) }; if (nodeObj.nodeHandle == kInvalidNodeHandle) return; GraphObj graphObj{ nodeObj.iNode->getGraph(nodeObj) }; if (graphObj.graphHandle == kInvalidGraphHandle) return; GraphContextObj context{ graphObj.iGraph->getDefaultGraphContext(graphObj) }; if (context.contextHandle == kInvalidGraphContextHandle) return; ConstAttributeDataHandle handle = attrObj.iAttribute->getConstAttributeDataHandle(attrObj, kAccordingToContextIndex); auto const dataPtr = getDataR<NameToken>(context, handle); if (dataPtr) { auto& state = OgnConstructArrayDatabase::sInternalState<OgnConstructArray>(nodeObj); state.m_inputArrayType = state.m_arrayTypes[*dataPtr]; } tryResolveArrayAttributes(nodeObj, true); } static void onConnected(AttributeObj const& otherAttrib, AttributeObj const& inAttrib, void* userData) { NodeObj nodeObj{ inAttrib.iAttribute->getNode(inAttrib) }; if (nodeObj.nodeHandle == kInvalidNodeHandle) return; NodeObj* thisNodeObj = reinterpret_cast<NodeObj*>(userData); if (nodeObj.nodeHandle != thisNodeObj->nodeHandle) return; auto& state = OgnConstructArrayDatabase::sInternalState<OgnConstructArray>(nodeObj); // Deregister onConnected callback to avoid infinite loop struct ConnectionCallback connectedCallback = {onConnected, &state.m_nodeObj}; nodeObj.iNode->deregisterConnectedCallback(nodeObj, connectedCallback); tryResolveArrayAttributes(nodeObj, true); // Re-register onConnected callback nodeObj.iNode->registerConnectedCallback(nodeObj, connectedCallback); } public: omni::graph::core::NodeObj m_nodeObj; std::unordered_map<NameToken, omni::graph::core::Type> m_arrayTypes; omni::graph::core::Type m_inputArrayType; static void initialize(GraphContextObj const& context, NodeObj const& nodeObj) { auto& state = OgnConstructArrayDatabase::sInternalState<OgnConstructArray>(nodeObj); state.m_nodeObj = nodeObj; state.m_arrayTypes = { {OgnConstructArrayDatabase::tokens.Bool, Type(BaseDataType::eBool)}, {OgnConstructArrayDatabase::tokens.Double, Type(BaseDataType::eDouble)}, {OgnConstructArrayDatabase::tokens.Float, Type(BaseDataType::eFloat)}, {OgnConstructArrayDatabase::tokens.Half, Type(BaseDataType::eHalf)}, {OgnConstructArrayDatabase::tokens.Int, Type(BaseDataType::eInt)}, {OgnConstructArrayDatabase::tokens.Int64, Type(BaseDataType::eInt64)}, {OgnConstructArrayDatabase::tokens.Token, Type(BaseDataType::eToken)}, {OgnConstructArrayDatabase::tokens.UChar, Type(BaseDataType::eUChar)}, {OgnConstructArrayDatabase::tokens.UInt, Type(BaseDataType::eUInt)}, {OgnConstructArrayDatabase::tokens.UInt64, Type(BaseDataType::eUInt64)}, {OgnConstructArrayDatabase::tokens.Double_2, Type(BaseDataType::eDouble, 2)}, {OgnConstructArrayDatabase::tokens.Double_3, Type(BaseDataType::eDouble, 3)}, {OgnConstructArrayDatabase::tokens.Double_4, Type(BaseDataType::eDouble, 4)}, {OgnConstructArrayDatabase::tokens.Double_9, Type(BaseDataType::eDouble, 9, 0, AttributeRole::eMatrix)}, {OgnConstructArrayDatabase::tokens.Double_16, Type(BaseDataType::eDouble, 16, 0, AttributeRole::eMatrix)}, {OgnConstructArrayDatabase::tokens.Float_2, Type(BaseDataType::eFloat, 2)}, {OgnConstructArrayDatabase::tokens.Float_3, Type(BaseDataType::eFloat, 3)}, {OgnConstructArrayDatabase::tokens.Float_4, Type(BaseDataType::eFloat, 4)}, {OgnConstructArrayDatabase::tokens.Half_2, Type(BaseDataType::eHalf, 2)}, {OgnConstructArrayDatabase::tokens.Half_3, Type(BaseDataType::eHalf, 3)}, {OgnConstructArrayDatabase::tokens.Half_4, Type(BaseDataType::eHalf, 4)}, {OgnConstructArrayDatabase::tokens.Int_2, Type(BaseDataType::eInt, 2)}, {OgnConstructArrayDatabase::tokens.Int_3, Type(BaseDataType::eInt, 3)}, {OgnConstructArrayDatabase::tokens.Int_4, Type(BaseDataType::eInt, 4)}, }; AttributeObj arrayTypeAttrib = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::arrayType.m_token); arrayTypeAttrib.iAttribute->registerValueChangedCallback(arrayTypeAttrib, onValueChanged, true); struct ConnectionCallback connectedCallback = {onConnected, &state.m_nodeObj}; nodeObj.iNode->registerConnectedCallback(nodeObj, connectedCallback); onValueChanged(arrayTypeAttrib, nullptr); } static bool compute(OgnConstructArrayDatabase& db) { NodeObj nodeObj = db.abi_node(); auto const outputArrayAttr = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::array.token()); auto const outputArrayType = outputArrayAttr.iAttribute->getResolvedType(outputArrayAttr); try { switch (outputArrayType.baseType) { case BaseDataType::eBool: if (outputArrayType.componentCount == 1) if (tryComputeAssumingType<bool>(db)) return true; break; case BaseDataType::eDouble: switch (outputArrayType.componentCount) { case 1: if (tryComputeAssumingType<double>(db)) return true; break; case 2: if (tryComputeAssumingType<double, 2>(db)) return true; break; case 3: if (tryComputeAssumingType<double, 3>(db)) return true; break; case 4: if (tryComputeAssumingType<double, 4>(db)) return true; break; case 9: if (tryComputeAssumingType<double, 9>(db)) return true; break; case 16: if (tryComputeAssumingType<double, 16>(db)) return true; break; } break; case BaseDataType::eFloat: switch (outputArrayType.componentCount) { case 1: if (tryComputeAssumingType<float>(db)) return true; break; case 2: if (tryComputeAssumingType<float, 2>(db)) return true; break; case 3: if (tryComputeAssumingType<float, 3>(db)) return true; break; case 4: if (tryComputeAssumingType<float, 4>(db)) return true; break; } break; case BaseDataType::eHalf: switch (outputArrayType.componentCount) { case 1: if (tryComputeAssumingType<pxr::GfHalf>(db)) return true; break; case 2: if (tryComputeAssumingType<pxr::GfHalf, 2>(db)) return true; break; case 3: if (tryComputeAssumingType<pxr::GfHalf, 3>(db)) return true; break; case 4: if (tryComputeAssumingType<pxr::GfHalf, 4>(db)) return true; break; } break; case BaseDataType::eInt: switch (outputArrayType.componentCount) { case 1: if (tryComputeAssumingType<int32_t>(db)) return true; break; case 2: if (tryComputeAssumingType<int32_t, 2>(db)) return true; break; case 3: if (tryComputeAssumingType<int32_t, 3>(db)) return true; break; case 4: if (tryComputeAssumingType<int32_t, 4>(db)) return true; break; } break; case BaseDataType::eInt64: if (outputArrayType.componentCount == 1) if (tryComputeAssumingType<int64_t>(db)) return true; break; case BaseDataType::eToken: if (outputArrayType.componentCount == 1) if (tryComputeAssumingType<OgnToken>(db)) return true; break; case BaseDataType::eUChar: if (outputArrayType.componentCount == 1) if (tryComputeAssumingType<uint8_t>(db)) return true; break; case BaseDataType::eUInt: if (outputArrayType.componentCount == 1) if (tryComputeAssumingType<uint32_t>(db)) return true; break; case BaseDataType::eUInt64: if (outputArrayType.componentCount == 1) if (tryComputeAssumingType<uint64_t>(db)) return true; break; default: break; } db.logError("Failed to resolve input types"); } catch (ogn::compute::InputError const &error) { db.logError(error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& nodeObj) { tryResolveArrayAttributes(nodeObj, false); } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnAppendString.cpp
// Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnAppendStringDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnAppendString { public: static bool compute(OgnAppendStringDatabase& db) { auto const& suffix = db.inputs.suffix(); if (suffix.type().baseType == BaseDataType::eToken) return computeForToken(db); return computeForString(db); } static bool computeForString(OgnAppendStringDatabase& db) { auto const inputValue = db.inputs.value(); auto const suffixIn = db.inputs.suffix(); auto const suffixData = suffixIn.get<uint8_t[]>(); auto& outValue = db.outputs.value(); // No suffix? Just copy in to out if (suffixData->empty()) { db.outputs.value().copyData(inputValue); return true; } auto const inputValueData = inputValue.get<uint8_t[]>(); std::string outVal; outVal.reserve(inputValueData.size() + suffixData.size()); outVal.append(reinterpret_cast<char const*>(inputValueData->data()), inputValueData.size()); outVal.append(reinterpret_cast<char const*>(suffixData->data()), suffixData.size()); auto outData = outValue.get<uint8_t[]>(); size_t outBufferSize = outVal.size(); outData->resize(outBufferSize); memcpy(outData->data(), reinterpret_cast<uint8_t const*>(outVal.data()), outBufferSize); return true; } static bool computeForToken(OgnAppendStringDatabase& db) { auto const& inputValue = db.inputs.value(); auto const& suffix = db.inputs.suffix(); std::vector<char const*> suffixes; if (suffix.type().arrayDepth == 0) { NameToken suffixToken = *suffix.get<OgnToken>(); if (suffixToken != omni::fabric::kUninitializedToken) suffixes.push_back(db.tokenToString(suffixToken)); } else { const auto suffixTokens = *suffix.get<OgnToken[]>(); suffixes.resize(suffixTokens.size()); std::transform(suffixTokens.begin(), suffixTokens.end(), suffixes.begin(), [&db](auto t) { return db.tokenToString(t); }); } // No suffix? Just copy in to out if (suffixes.empty()) { db.outputs.value().copyData(inputValue); return true; } if (inputValue.type().arrayDepth > 0) { const auto inputValueArray = *inputValue.get<OgnToken[]>(); auto outputPathArray = *db.outputs.value().get<OgnToken[]>(); outputPathArray.resize(inputValueArray.size()); if (suffixes.size() == 1) { const char* suffixStr = suffixes[0]; std::transform(inputValueArray.begin(), inputValueArray.end(), outputPathArray.begin(), [&](const auto& p) { std::string s = db.tokenToString(p); s += suffixStr; return db.stringToToken(s.c_str()); }); } else { if (inputValueArray.size() != suffixes.size()) { CARB_LOG_ERROR("inputs:value and inputs:suffix arrays are not the same size (%zu and %zu)", inputValueArray.size(), suffixes.size()); return false; } for (size_t i = 0; i < inputValueArray.size(); ++i) { std::string s = db.tokenToString(inputValueArray[i]); s += suffixes[i]; outputPathArray[i] = db.stringToToken(s.c_str()); } } return true; } else { NameToken inValue = *inputValue.get<OgnToken>(); std::string s; if (inValue != omni::fabric::kUninitializedToken) { s = db.tokenToString(inValue); } s += suffixes[0]; *db.outputs.value().get<OgnToken>() = db.stringToToken(s.c_str()); } return true; } static void onConnectionTypeResolve(const NodeObj& node) { auto inputVal = node.iNode->getAttributeByToken(node, OgnAppendStringAttributes::inputs::value.m_token); auto outputVal = node.iNode->getAttributeByToken(node, OgnAppendStringAttributes::outputs::value.m_token); auto suffixVal = node.iNode->getAttributeByToken(node, OgnAppendStringAttributes::inputs::suffix.m_token); //in type auto type = inputVal.iAttribute->getResolvedType(inputVal); //if input is an array of token, suffix is allowed to be either a simple or an array of token(s) if (type.baseType == BaseDataType::eToken && type.arrayDepth != 0) { // both in and out needs to be the same std::array<AttributeObj, 2> attrs{ inputVal, outputVal }; node.iNode->resolveCoupledAttributes(node, attrs.data(), attrs.size()); //change suffix if necessary auto suffixType = suffixVal.iAttribute->getResolvedType(suffixVal); if (suffixType.baseType == BaseDataType::eUChar)//string not compatible with tokens suffixVal.iAttribute->setResolvedType(suffixVal, type); } else { // else, the 3 needs to have the same type std::array<AttributeObj, 3> attrs{ inputVal, suffixVal, outputVal }; node.iNode->resolveCoupledAttributes(node, attrs.data(), attrs.size()); } } }; REGISTER_OGN_NODE(); } // nodes } // graph } // omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnToHalf.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnToHalfDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/UsdTypes.h> namespace omni { namespace graph { namespace nodes { namespace { template<typename T> bool tryComputeAssumingType(OgnToHalfDatabase& db, size_t count) { auto functor = [](auto const& value, auto& converted) { converted = pxr::GfHalf(float(value)); }; return ogn::compute::tryComputeWithArrayBroadcasting<T, pxr::GfHalf>(db.inputs.value(), db.outputs.converted(), functor, count); } template<typename T, size_t tupleSize> bool tryComputeAssumingType(OgnToHalfDatabase& db, size_t count) { auto functor = [](auto const& value, auto& converted) { converted = pxr::GfHalf(float(value)); }; return ogn::compute::tryComputeWithTupleBroadcasting<tupleSize, T, pxr::GfHalf>( db.inputs.value(), db.outputs.converted(), functor, count); } } // namespace class OgnToHalf { public: // Node to convert numeric inputs to halfs static bool computeVectorized(OgnToHalfDatabase& db, size_t count) { const auto& inputsValue = db.inputs.value(); auto& type = inputsValue.type(); bool result = false; switch (type.baseType) { case BaseDataType::eBool: { result = tryComputeAssumingType<bool>(db, count); break; } case BaseDataType::eDouble: { switch (type.componentCount) { case 1: result = tryComputeAssumingType<double>(db, count); break; case 2: result = tryComputeAssumingType<double, 2>(db, count); break; case 3: result = tryComputeAssumingType<double, 3>(db, count); break; case 4: result = tryComputeAssumingType<double, 4>(db, count); break; case 9: result = tryComputeAssumingType<double, 9>(db, count); break; case 16: result = tryComputeAssumingType<double, 16>(db, count); break; default: result = false; } break; } case BaseDataType::eFloat: { switch (type.componentCount) { case 1: result = tryComputeAssumingType<float>(db, count); break; case 2: result = tryComputeAssumingType<float, 2>(db, count); break; case 3: result = tryComputeAssumingType<float, 3>(db, count); break; case 4: result = tryComputeAssumingType<float, 4>(db, count); break; default: result = false; } break; } case BaseDataType::eHalf: { switch (type.componentCount) { case 1: result = tryComputeAssumingType<pxr::GfHalf>(db, count); break; case 2: result = tryComputeAssumingType<pxr::GfHalf, 2>(db, count); break; case 3: result = tryComputeAssumingType<pxr::GfHalf, 3>(db, count); break; case 4: result = tryComputeAssumingType<pxr::GfHalf, 4>(db, count); break; default: result = false; } break; } case BaseDataType::eInt: { switch (type.componentCount) { case 1: result = tryComputeAssumingType<int32_t>(db, count); break; case 2: result = tryComputeAssumingType<int32_t, 2>(db, count); break; case 3: result = tryComputeAssumingType<int32_t, 3>(db, count); break; case 4: result = tryComputeAssumingType<int32_t, 4>(db, count); break; default: result = false; } break; } case BaseDataType::eInt64: { result = tryComputeAssumingType<int64_t>(db, count); break; } case BaseDataType::eUChar: { result = tryComputeAssumingType<unsigned char>(db, count); break; } case BaseDataType::eUInt: { result = tryComputeAssumingType<uint32_t>(db, count); break; } case BaseDataType::eUInt64: { result = tryComputeAssumingType<uint64_t>(db, count); break; } default: { result = false; } } if (!result) { db.logError("Input could not be converted to half"); return false; } return true; } static void onConnectionTypeResolve(const NodeObj& nodeObj) { auto valueAttr = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::value.token()); auto outAttr = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::converted.token()); auto valueType = valueAttr.iAttribute->getResolvedType(valueAttr); // The output shape must match the input shape and visa-versa, however we can't say anything // about the input base type until it's connected if (valueType.baseType != BaseDataType::eUnknown) { Type resultType(BaseDataType::eHalf, valueType.componentCount, valueType.arrayDepth); outAttr.iAttribute->setResolvedType(outAttr, resultType); } } }; REGISTER_OGN_NODE(); } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnArrayIndex.ogn
{ "ArrayIndex": { "version": 1, "description": [ "Copies an element of an input array into an output" ], "uiName": "Array Index", "categories": ["math:array"], "scheduling": ["threadsafe"], "inputs": { "array": { "type": ["arrays", "bool[]"], "description": "The array to be indexed", "uiName": "Array" }, "index": { "type": "int", "description": "The index into the array, a negative value indexes from the end of the array", "uiName": "Index" } }, "outputs": { "value": { "type": ["array_elements", "bool"], "description": "The value from the array" } }, "tests": [ { "inputs:array": {"type": "int[]", "value": [42]}, "inputs:index": 0, "outputs:value": {"type": "int", "value":42} }, { "inputs:array": {"type": "float[2][]", "value":[[1.0, 2.0]]}, "inputs:index": 0, "outputs:value": {"type": "float[2]", "value":[1.0, 2.0]} }, { "inputs:array": {"type": "int[]", "value": [1, 2, 3]}, "inputs:index": 1, "outputs:value": {"type": "int", "value":2} }, { "inputs:array": {"type": "int[]", "value": [1, 2, 3]}, "inputs:index": -1, "outputs:value": {"type": "int", "value":3} }, { "inputs:array": {"type": "int[]", "value": [1, 2, 3]}, "inputs:index": -2, "outputs:value": {"type": "int", "value":2} }, { "inputs:array": {"type": "int[]", "value": [1, 2, 3]}, "inputs:index": 2, "outputs:value": {"type": "int", "value":3} }, { "inputs:array": {"type": "token[]", "value": ["foo", "bar"]}, "inputs:index": 1, "outputs:value": {"type": "token", "value":"bar"} }, { "inputs:array": {"type": "bool[]", "value": [true, false, false]}, "inputs:index": 1, "outputs:value": {"type": "bool", "value":false} }, { "inputs:array": {"type": "pointd[3][]", "value": [[1,2,3],[4,5,6]]}, "inputs:index": 1, "outputs:value": {"type": "pointd[3]", "value":[4,5,6]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnGetPrimsAtPath.ogn
{ "GetPrimsAtPath": { "version": 1, "description": ["This node computes a prim path from either a single or an array of pth tokens."], "uiName": "Get Prims At Path", "categories": ["sceneGraph"], "scheduling": [ "threadsafe" ], "inputs": { "path": { "type": ["token", "token[]"], "description": "A token or token array to compute representing a path." } }, "outputs": { "prims": { "type": "target", "description": "The output prim paths" } }, "state": { "path": { "type": "token", "description": "Snapshot of previously seen path" } } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnMakeArray.ogn
{ "MakeArray": { "version": 1, "description": [ "Makes an output array attribute from input values, in the order of the inputs. If ", "'arraySize' is less than 5, the top 'arraySize' elements will be taken. If 'arraySize' is greater than 5", "element e will be repeated to fill the remaining space" ], "language": "Python", "categories": ["math:array"], "uiName": "Make Array", "metadata": {"hidden": "true"}, "inputs": { "a": { "type": ["array_elements"], "description": "Element 1" }, "b": { "type": ["array_elements"], "description": "Element 2" }, "c": { "type": ["array_elements"], "description": "Element 3" }, "d": { "type": ["array_elements"], "description": "Element 4" }, "e": { "type": ["array_elements"], "description": "Element 5" }, "arraySize": { "type": "int", "description": "The size of the array to create", "minimum": 0 } }, "outputs": { "array": { "type": ["arrays"], "description": "The array of copied values of inputs in the given order" } }, "tests": [ { "inputs:a": {"type": "float", "value": 1}, "inputs:b": {"type": "float", "value": 1}, "inputs:c": {"type": "float", "value": 1}, "inputs:d": {"type": "float", "value": 1}, "inputs:e": {"type": "float", "value": 1}, "inputs:arraySize": 1, "outputs:array": {"type": "float[]", "value":[1]} }, { "inputs:a": {"type": "float[2]", "value": [1,2]}, "inputs:b": {"type": "float[2]", "value": [1,3]}, "inputs:c": {"type": "float[2]", "value": [1,4]}, "inputs:d": {"type": "float[2]", "value": [1,5]}, "inputs:e": {"type": "float[2]", "value": [1,6]}, "inputs:arraySize": 5, "outputs:array": {"type": "float[2][]", "value":[ [1,2], [1,3], [1,4], [1,5], [1,6] ]} }, { "inputs:a": {"type": "token", "value": "foo"}, "inputs:b": {"type": "token", "value": "foo"}, "inputs:c": {"type": "token", "value": "foo"}, "inputs:d": {"type": "token", "value": "foo"}, "inputs:e": {"type": "token", "value": "foo"}, "inputs:arraySize": 5, "outputs:array": {"type": "token[]", "value":["foo","foo","foo","foo","foo"]} }, { "inputs:a": {"type": "uchar", "value": 42}, "inputs:b": {"type": "uchar", "value": 42}, "inputs:c": {"type": "uchar", "value": 42}, "inputs:d": {"type": "uchar", "value": 42}, "inputs:e": {"type": "uchar", "value": 42}, "inputs:arraySize": 5, "outputs:array": {"type": "uchar[]", "value":[42,42,42,42,42]} }, { "inputs:a": {"type": "double[4]", "value": [1, 2, 3, 4]}, "inputs:b": {"type": "double[4]", "value": [1, 2, 3, 4]}, "inputs:c": {"type": "double[4]", "value": [1, 2, 3, 4]}, "inputs:d": {"type": "double[4]", "value": [1, 2, 3, 4]}, "inputs:e": {"type": "double[4]", "value": [1, 2, 3, 5]}, "inputs:arraySize": 6, "outputs:array": {"type": "double[4][]", "value":[ [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 3, 5] ]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnIsEmpty.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnIsEmptyDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/Types.h> #include <string> #include "PrimCommon.h" namespace omni { namespace graph { namespace nodes { class OgnIsEmpty { public: static bool compute(OgnIsEmptyDatabase& db) { const auto& variable = db.inputs.input(); auto& type = variable.type(); switch (type.baseType) { case BaseDataType::eBool: case BaseDataType::eUChar: case BaseDataType::eInt: case BaseDataType::eUInt: case BaseDataType::eInt64: case BaseDataType::eUInt64: case BaseDataType::eHalf: case BaseDataType::eFloat: case BaseDataType::eDouble: { db.outputs.isEmpty() = variable.size() == 0; return true; } case BaseDataType::eToken: { std::string converted = tryConvertToString<ogn::Token>(db, variable); db.outputs.isEmpty() = converted.length() == 0; return true; } default: { db.logError("Type %s not supported", getOgnTypeName(type).c_str()); } } return false; } }; REGISTER_OGN_NODE() } // nodes } // graph } // omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnToToken.cpp
// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnToTokenDatabase.h> #include <omni/graph/core/ogn/UsdTypes.h> #include <fstream> #include <iomanip> #include <sstream> #include "PrimCommon.h" namespace omni { namespace graph { namespace nodes { namespace { template <typename T> bool tryComputeAssumingType(OgnToTokenDatabase& db) { std::string converted = tryConvertToString<T>(db, db.inputs.value()); if (converted.empty()) { return false; } db.outputs.converted() = db.stringToToken(converted.c_str()); return true; } template <typename T, size_t tupleSize> bool tryComputeAssumingType(OgnToTokenDatabase& db) { std::string converted = tryConvertToString<T, tupleSize>(db, db.inputs.value()); if (converted.empty()) { return false; } db.outputs.converted() = db.stringToToken(converted.c_str()); return true; } } // namespace class OgnToToken { public: // Node to convert any input to a token static bool compute(OgnToTokenDatabase& db) { NodeObj nodeObj = db.abi_node(); const AttributeObj attr = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::value.token()); const Type attrType = attr.iAttribute->getResolvedType(attr); auto value = db.inputs.value(); if (attrType.baseType == BaseDataType::eUnknown) { db.logError("Unknown input data type"); return false; } // Compute the components, if the types are all resolved. // This handles char and string case (get<ogn::string>() will return invalid result) if (attrType.baseType == BaseDataType::eUChar) { if ((attrType.arrayDepth == 1) && ((attrType.role == AttributeRole::eText) || (attrType.role == AttributeRole::ePath))) { auto val = db.inputs.value().template get<uint8_t[]>(); if (!val) { db.logError("Unable to resolve input type"); return false; } auto charData = val->data(); std::string str(charData, charData + val->size()); db.outputs.converted() = db.stringToToken(str.c_str()); return true; } else if (attrType.arrayDepth == 0) { uchar val = *db.inputs.value().template get<uchar>(); db.outputs.converted() = db.stringToToken(std::string(1, static_cast<char>(val)).c_str()); } return true; } try { auto& inputType = db.inputs.value().type(); switch (inputType.baseType) { case BaseDataType::eToken: return tryComputeAssumingType<ogn::Token>(db); case BaseDataType::eBool: return tryComputeAssumingType<bool>(db); case BaseDataType::eDouble: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<double>(db); case 2: return tryComputeAssumingType<double, 2>(db); case 3: return tryComputeAssumingType<double, 3>(db); case 4: return tryComputeAssumingType<double, 4>(db); case 9: return tryComputeAssumingType<double, 9>(db); case 16: return tryComputeAssumingType<double, 16>(db); default: break; } case BaseDataType::eFloat: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<float>(db); case 2: return tryComputeAssumingType<float, 2>(db); case 3: return tryComputeAssumingType<float, 3>(db); case 4: return tryComputeAssumingType<float, 4>(db); default: break; } case BaseDataType::eHalf: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<pxr::GfHalf>(db); case 2: return tryComputeAssumingType<pxr::GfHalf, 2>(db); case 3: return tryComputeAssumingType<pxr::GfHalf, 3>(db); case 4: return tryComputeAssumingType<pxr::GfHalf, 4>(db); default: break; } case BaseDataType::eInt: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<int32_t>(db); case 2: return tryComputeAssumingType<int32_t, 2>(db); case 3: return tryComputeAssumingType<int32_t, 3>(db); case 4: return tryComputeAssumingType<int32_t, 4>(db); default: break; } ; case BaseDataType::eInt64: return tryComputeAssumingType<int64_t>(db); case BaseDataType::eUInt: return tryComputeAssumingType<uint32_t>(db); case BaseDataType::eUInt64: return tryComputeAssumingType<uint64_t>(db); default: break; } db.logWarning("Failed to resolve input types"); } catch (const std::exception& e) { db.logError("Input could not be converted to a token: %s", e.what()); return false; } return true; } }; REGISTER_OGN_NODE(); } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnArrayFindValue.ogn
{ "ArrayFindValue": { "version": 1, "description": [ "Searches for a value in an array, returns the index of the first occurrence of the value, or -1 if not found." ], "uiName": "Array Find Value", "categories": ["math:array"], "scheduling": ["threadsafe"], "inputs": { "array": { "type": ["arrays", "bool[]"], "description": "The array to be searched", "uiName": "Array" }, "value": { "type": ["array_elements", "bool"], "description": "The value to be found" } }, "outputs": { "index": { "type": "int", "description": "The index of the first occurrence of value, or -1 if not found", "uiName": "Index" } }, "tests": [ { "inputs:array": {"type": "int[]", "value": [41, 42]}, "outputs:index": 1, "inputs:value": {"type": "int", "value": 42} }, { "inputs:array": {"type": "token[]", "value": ["FOOD", "BARFOOD", "BAZ"]}, "outputs:index": -1, "inputs:value": {"type": "token", "value":"FOO"} }, { "inputs:array": {"type": "token[]", "value": ["FOOD", "BARFOOD", "BAZ"]}, "outputs:index": 0, "inputs:value": {"type": "token", "value":"FOOD"} }, { "inputs:array": {"type": "int64[]", "value": [41, 42]}, "outputs:index": 0, "inputs:value": {"type": "int64", "value":41} }, { "inputs:array": {"type": "uchar[]", "value": [41, 42]}, "outputs:index": 0, "inputs:value": {"type": "uchar", "value":41} }, { "inputs:array": {"type": "uint[]", "value": [41, 42]}, "outputs:index": 1, "inputs:value": {"type": "uint", "value":42} }, { "inputs:array": {"type": "uint64[]", "value": [41, 42]}, "outputs:index": 1, "inputs:value": {"type": "uint64", "value":42} }, { "inputs:array": {"type": "bool[]", "value": [false, true]}, "outputs:index": 0, "inputs:value": {"type": "bool", "value":false} }, { "inputs:array": {"type": "half[2][]", "value": [[1, 2], [3, 4]]}, "outputs:index": 0, "inputs:value": {"type": "half[2]", "value":[1, 2]} }, { "inputs:array": {"type": "double[2][]", "value": [[1, 2], [3, 4]]}, "outputs:index": 0, "inputs:value": {"type": "double[2]", "value":[1, 2]} }, { "inputs:array": {"type": "double[3][]", "value": [[1.1, 2.1, 1.0], [3, 4, 5]]}, "outputs:index": 1, "inputs:value": {"type": "double[3]", "value":[3, 4, 5]} }, { "inputs:array": {"type": "int[4][]", "value": [[1, 2, 3, 4], [3, 4, 5, 6]]}, "outputs:index": 0, "inputs:value": {"type": "int[4]", "value":[1, 2, 3, 4]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnCompare.ogn
{ "Compare": { "version": 1, "description": ["Outputs the truth value of a comparison operation. Tuples are compared in lexicographic order.", "If one input is an array and the other is a scaler, the scaler will ", "be broadcast to the size of the array"], "uiName": "Compare", "categories": ["math:condition"], "scheduling": ["threadsafe"], "inputs": { "a": { "type": "any", "description": "Input A" }, "b": { "type": "any", "description": "Input B" }, "operation": { "type": "token", "description": "The comparison operation to perform (>,<,>=,<=,==,!=))", "uiName": "Operation", "default": ">", "metadata": { "allowedTokens": { "gt": ">", "lt": "<", "ge": ">=", "le": "<=", "eq": "==", "ne": "!=" } } } }, "outputs": { "result": { "type": ["bool","bool[]"], "description": "The result of the comparison operation", "uiName": "Result" } }, "tests" : [ { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "float", "value": 1.0}, "inputs:operation": ">", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "float", "value": 1.0}, "inputs:operation": "<=", "outputs:result": {"type": "bool", "value": false} }, { "inputs:a": {"type": "int64", "value": 9223372036854775807}, "inputs:b": {"type": "int64", "value": 9223372036854775807}, "inputs:operation": "==", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "float[]", "value": [1.0, 2.0]}, "inputs:b": {"type": "float[]", "value": [1.0, 2.01]}, "inputs:operation": "==", "outputs:result": {"type": "bool[]", "value": [true, false]} }, { "inputs:a": {"type": "double[]", "value": [2.0, 3.0]}, "inputs:b": {"type": "double[]", "value": [2.0, 3.1]}, "inputs:operation": "<=", "outputs:result": {"type": "bool[]", "value": [true, true]} }, { "inputs:a": {"type": "double[3][]", "value": [[2.0, 3.0, 1.0], [1.0, 2.0, 5.0]]}, "inputs:b": {"type": "double[3][]", "value": [[2.0, 1.0, 4.0], [2.0, 2.0, 2.0]]}, "inputs:operation": "<=", "outputs:result": {"type": "bool[]", "value": [false, true]} }, { "inputs:a": {"type": "token", "value": ""}, "inputs:b": {"type": "token", "value": ""}, "inputs:operation": "==", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "token", "value": "abc"}, "inputs:b": {"type": "token", "value": "abc"}, "inputs:operation": "!=", "outputs:result": {"type": "bool", "value": false} }, { "inputs:a": {"type": "token", "value": "abc"}, "inputs:b": {"type": "token", "value": "d"}, "inputs:operation": "==", "outputs:result": {"type": "bool", "value": false} }, { "inputs:a": {"type": "token", "value": "abc"}, "inputs:b": {"type": "token", "value": ""}, "inputs:operation": "!=", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "string", "value": ""}, "inputs:b": {"type": "string", "value": ""}, "inputs:operation": "==", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "string", "value": "abc"}, "inputs:operation": "!=", "outputs:result": {"type": "bool", "value": false} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "string", "value": "d"}, "inputs:operation": "==", "outputs:result": {"type": "bool", "value": false} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "string", "value": ""}, "inputs:operation": "!=", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "string", "value": ""}, "inputs:b": {"type": "string", "value": ""}, "inputs:operation": "<", "outputs:result": {"type": "bool", "value": false} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "string", "value": "ad"}, "inputs:operation": "<=", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "string", "value": ""}, "inputs:operation": ">", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "string", "value": "abc"}, "inputs:operation": ">=", "outputs:result": {"type": "bool", "value": true} }, { "inputs:a": {"type": "uchar[]", "value": []}, "inputs:b": {"type": "uchar[]", "value": []}, "inputs:operation": "==", "outputs:result": {"type": "bool[]", "value": []} }, { "inputs:a": {"type": "string", "value": "abc"}, "inputs:b": {"type": "uchar[]", "value": [97, 98, 99]}, "inputs:operation": "!=", "outputs:result": {"type": "bool[]", "value": [false, false, false]} }, { "inputs:a": {"type": "uchar[]", "value": [97, 98, 99]}, "inputs:b": {"type": "uchar", "value": 98}, "inputs:operation": ">", "outputs:result": {"type": "bool[]", "value": [false, false, true]} }, { "inputs:a": {"type": "uchar", "value": 98}, "inputs:b": {"type": "string", "value": "abc"}, "inputs:operation": "<=", "outputs:result": {"type": "bool[]", "value": [false, true, true]} }, { "inputs:a": {"type": "token[]", "value": ["abcd", "a", "foo"]}, "inputs:b": {"type": "token[]", "value": ["abc", "a", "food"]}, "inputs:operation": "!=", "outputs:result": {"type": "bool[]", "value": [true, false, true]} }, { "inputs:a": {"type": "token", "value": ""}, "inputs:b": {"type": "token[]", "value": ["abc", "a", ""]}, "inputs:operation": "==", "outputs:result": {"type": "bool[]", "value": [false, false, true]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnArrayRotate.ogn
{ "ArrayRotate": { "version": 1, "description": [ "Shifts the elements of an array by the specified number of steps to the right and wraps elements", "from one end to the other. A negative step will shift to the left." ], "uiName": "Array Rotate", "categories": ["math:array"], "scheduling": ["threadsafe"], "inputs": { "array": { "type": ["arrays", "bool[]"], "description": "The array to be modified" }, "steps": { "type": "int", "description": "The number of steps to shift, negative means shift left instead of right" } }, "outputs": { "array": { "type": ["arrays", "bool[]"], "description": "The modified array" } }, "tests": [ { "inputs:array": {"type": "int[]", "value": [41, 42]}, "inputs:steps": 0, "outputs:array": {"type": "int[]", "value": [41, 42]} }, { "inputs:array": {"type": "int[]", "value": [41, 42, 43]}, "inputs:steps": 1, "outputs:array": {"type": "int[]", "value": [43, 41, 42]} }, { "inputs:array": {"type": "float[2][]", "value": [[1,2],[3,4],[5,6]]}, "inputs:steps": 1, "outputs:array": {"type": "float[2][]", "value": [[5,6],[1,2],[3,4]]} }, { "inputs:array": {"type": "int[]", "value": [41, 42, 43]}, "inputs:steps": -1, "outputs:array": {"type": "int[]", "value": [42, 43, 41]} }, { "inputs:array": {"type": "bool[]", "value": [true, false, true]}, "inputs:steps": -1, "outputs:array": {"type": "bool[]", "value": [false, true, true]} }, { "inputs:array": {"type": "int[]", "value": [41, 42, 43]}, "inputs:steps": -2, "outputs:array": {"type": "int[]", "value": [43, 41, 42]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnBreakVector2.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnBreakVector2Database.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/UsdTypes.h> #include <fstream> #include <iomanip> namespace omni { namespace graph { namespace nodes { namespace { template <typename Type> bool tryBreakVector(OgnBreakVector2Database& db) { const auto vector = db.inputs.tuple().template get<Type[2]>(); auto x = db.outputs.x().template get<Type>(); auto y = db.outputs.y().template get<Type>(); if (!vector || !x || !y){ return false; } *x = (*vector)[0]; *y = (*vector)[1]; return true; } } // namespace // Node to break a 2-vector into it's component scalers class OgnBreakVector2 { public: static bool compute(OgnBreakVector2Database& db) { // Compute the components, if the types are all resolved. try { if (tryBreakVector<double>(db)) return true; else if (tryBreakVector<float>(db)) return true; else if (tryBreakVector<pxr::GfHalf>(db)) return true; else if (tryBreakVector<int32_t>(db)) return true; else { db.logWarning("Failed to resolve input types"); } } catch (const std::exception& e) { db.logError("Vector could not be broken: %s", e.what()); return false; } return true; } static void onConnectionTypeResolve(const NodeObj& nodeObj) { auto vector = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::tuple.token()); auto x = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::x.token()); auto y = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::y.token()); auto vectorType = vector.iAttribute->getResolvedType(vector); // Require inputs to be resolved before determining outputs' type if (vectorType.baseType != BaseDataType::eUnknown) { std::array<AttributeObj, 3> attrs{ vector, x, y }; std::array<uint8_t, 3> tuples{ 2, 1, 1 }; std::array<uint8_t, 3> arrays{ 0, 0, 0 }; std::array<AttributeRole, 3> roles{ vectorType.role, AttributeRole::eNone, AttributeRole::eNone }; nodeObj.iNode->resolvePartiallyCoupledAttributes(nodeObj, attrs.data(), tuples.data(), arrays.data(), roles.data(), attrs.size()); } } }; REGISTER_OGN_NODE(); } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnToFloat.cpp
// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnToFloatDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/UsdTypes.h> namespace omni { namespace graph { namespace nodes { namespace { template<typename T> bool tryComputeAssumingType(OgnToFloatDatabase& db, size_t count) { auto functor = [](auto const& value, auto& converted) { converted = static_cast<float>(value); }; return ogn::compute::tryComputeWithArrayBroadcasting<T, float>(db.inputs.value(), db.outputs.converted(), functor, count); } template<typename T, size_t tupleSize> bool tryComputeAssumingType(OgnToFloatDatabase& db, size_t count) { auto functor = [](auto const& value, auto& converted) { converted = static_cast<float>(value); }; return ogn::compute::tryComputeWithTupleBroadcasting<tupleSize, T, float>( db.inputs.value(), db.outputs.converted(), functor, count); } } // namespace class OgnToFloat { public: // Node to convert numeric inputs to floats static bool computeVectorized(OgnToFloatDatabase& db, size_t count) { auto& inputType = db.inputs.value().type(); // Compute the components, if the types are all resolved. try { switch (inputType.baseType) { case BaseDataType::eBool: return tryComputeAssumingType<bool>(db, count); case BaseDataType::eDouble: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<double>(db, count); case 2: return tryComputeAssumingType<double, 2>(db, count); case 3: return tryComputeAssumingType<double, 3>(db, count); case 4: return tryComputeAssumingType<double, 4>(db, count); case 9: return tryComputeAssumingType<double, 9>(db, count); case 16: return tryComputeAssumingType<double, 16>(db, count); default: break; } case BaseDataType::eFloat: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<float>(db, count); case 2: return tryComputeAssumingType<float, 2>(db, count); case 3: return tryComputeAssumingType<float, 3>(db, count); case 4: return tryComputeAssumingType<float, 4>(db, count); default: break; } case BaseDataType::eHalf: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<pxr::GfHalf>(db, count); case 2: return tryComputeAssumingType<pxr::GfHalf, 2>(db, count); case 3: return tryComputeAssumingType<pxr::GfHalf, 3>(db, count); case 4: return tryComputeAssumingType<pxr::GfHalf, 4>(db, count); default: break; } case BaseDataType::eInt: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<int32_t>(db, count); case 2: return tryComputeAssumingType<int32_t, 2>(db, count); case 3: return tryComputeAssumingType<int32_t, 3>(db, count); case 4: return tryComputeAssumingType<int32_t, 4>(db, count); default: break; } ; case BaseDataType::eInt64: return tryComputeAssumingType<int64_t>(db, count); case BaseDataType::eUChar: return tryComputeAssumingType<unsigned char>(db, count); case BaseDataType::eUInt: return tryComputeAssumingType<uint32_t>(db, count); case BaseDataType::eUInt64: return tryComputeAssumingType<uint64_t>(db, count); default: break; } db.logWarning("Failed to resolve input types"); } catch (const std::exception& e) { db.logError("Input could not be converted to float: %s", e.what()); return false; } return true; } static void onConnectionTypeResolve(const NodeObj& nodeObj) { auto valueAttr = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::value.token()); auto outAttr = nodeObj.iNode->getAttributeByToken(nodeObj, outputs::converted.token()); auto valueType = valueAttr.iAttribute->getResolvedType(valueAttr); // The output shape must match the input shape and visa-versa, however we can't say anything // about the input base type until it's connected if (valueType.baseType != BaseDataType::eUnknown) { Type resultType(BaseDataType::eFloat, valueType.componentCount, valueType.arrayDepth); outAttr.iAttribute->setResolvedType(outAttr, resultType); } } }; REGISTER_OGN_NODE(); } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnArrayRotate.cpp
// Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnArrayRotateDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/string.h> #include <omni/graph/core/ogn/Types.h> #include <algorithm> namespace omni { namespace graph { namespace nodes { namespace { // Custom implementation of std::rotate. // Using std::rotate fails to build on Linux when the underlying type is a tuple (eg int[3]) template<class ForwardIt> constexpr ForwardIt rotateArray(ForwardIt first, ForwardIt n_first, ForwardIt last) { if(first == n_first) return last; if(n_first == last) return first; ForwardIt read = n_first; ForwardIt write = first; ForwardIt next_read = first; // read position for when "read" hits "last" while(read != last) { if(write == next_read) next_read = read; // track where "first" went std::iter_swap(write++, read++); } // rotate the remaining sequence into place (rotateArray)(write, next_read, last); return write; } template<typename T> bool tryComputeAssumingType(OgnArrayRotateDatabase& db) { const auto& steps = db.inputs.steps(); if (auto array = db.inputs.array().template get<T[]>()) { if (auto result = db.outputs.array().template get<T[]>()) { *result = *array; if (!result->empty()) { if (steps < 0) { rotateArray(result->begin(), result->begin() - steps, result->end()); } else if (steps > 0) { rotateArray(result->rbegin(), result->rbegin() + steps, result->rend()); } } return true; } } return false; } } // namespace class OgnArrayRotate { public: static bool compute(OgnArrayRotateDatabase& db) { auto& inputType = db.inputs.array().type(); try { switch (inputType.baseType) { case BaseDataType::eBool: return tryComputeAssumingType<bool>(db); case BaseDataType::eToken: return tryComputeAssumingType<ogn::Token>(db); case BaseDataType::eDouble: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<double>(db); case 2: return tryComputeAssumingType<double[2]>(db); case 3: return tryComputeAssumingType<double[3]>(db); case 4: return tryComputeAssumingType<double[4]>(db); case 9: return tryComputeAssumingType<double[9]>(db); case 16: return tryComputeAssumingType<double[16]>(db); default: break; } case BaseDataType::eFloat: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<float>(db); case 2: return tryComputeAssumingType<float[2]>(db); case 3: return tryComputeAssumingType<float[3]>(db); case 4: return tryComputeAssumingType<float[4]>(db); default: break; } case BaseDataType::eHalf: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<pxr::GfHalf>(db); case 2: return tryComputeAssumingType<pxr::GfHalf[2]>(db); case 3: return tryComputeAssumingType<pxr::GfHalf[3]>(db); case 4: return tryComputeAssumingType<pxr::GfHalf[4]>(db); default: break; } case BaseDataType::eInt: switch (inputType.componentCount) { case 1: return tryComputeAssumingType<int32_t>(db); case 2: return tryComputeAssumingType<int32_t[2]>(db); case 3: return tryComputeAssumingType<int32_t[3]>(db); case 4: return tryComputeAssumingType<int32_t[4]>(db); default: break; } ; case BaseDataType::eInt64: return tryComputeAssumingType<int64_t>(db); case BaseDataType::eUChar: return tryComputeAssumingType<unsigned char>(db); case BaseDataType::eUInt: return tryComputeAssumingType<uint32_t>(db); case BaseDataType::eUInt64: return tryComputeAssumingType<uint64_t>(db); default: break; } db.logWarning("Failed to resolve input types"); } catch (ogn::compute::InputError &error) { db.logWarning("OgnArrayRotate: %s", error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node){ std::array<AttributeObj, 2> attrs { node.iNode->getAttributeByToken(node, inputs::array.token()), node.iNode->getAttributeByToken(node, outputs::array.token()) }; node.iNode->resolveCoupledAttributes(node, attrs.data(), attrs.size()); } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnArraySetIndex.ogn
{ "ArraySetIndex": { "version": 1, "description": [ "Sets an element of an array. If the given index is negative it will be an offset from the end of the array." ], "uiName": "Array Set Index", "categories": ["math:array"], "scheduling": ["threadsafe"], "inputs": { "array": { "type": ["arrays", "bool[]"], "description": "The array to be modified", "uiName": "Array" }, "index": { "type": "int", "description": "The index into the array, a negative value indexes from the end of the array", "uiName": "Index" }, "resizeToFit": { "type": "bool", "description": ["When true, and the given positive index is larger than the highest index in the array", "resize the output array to length 1 + index, and fill the new spaces with zeros"] }, "value": { "type": ["array_elements", "bool"], "description": "The value to set at the given index" } }, "outputs": { "array": { "type": ["arrays", "bool[]"], "description": "The modified array", "uiName": "Array" } }, "tests": [ { "inputs:array": {"type": "int[]", "value": [41, 42]}, "inputs:index": 0, "inputs:value": {"type": "int", "value":0}, "outputs:array": {"type": "int[]", "value": [0, 42]} }, { "inputs:array": {"type": "int64[]", "value": [41, 42]}, "inputs:index": 0, "inputs:value": {"type": "int64", "value":0}, "outputs:array": {"type": "int64[]", "value": [0, 42]} }, { "inputs:array": {"type": "uchar[]", "value": [41, 42]}, "inputs:index": 0, "inputs:value": {"type": "uchar", "value":0}, "outputs:array": {"type": "uchar[]", "value": [0, 42]} }, { "inputs:array": {"type": "uint[]", "value": [41, 42]}, "inputs:index": 0, "inputs:value": {"type": "uint", "value":0}, "outputs:array": {"type": "uint[]", "value": [0, 42]} }, { "inputs:array": {"type": "uint64[]", "value": [41, 42]}, "inputs:index": 0, "inputs:value": {"type": "uint64", "value":0}, "outputs:array": {"type": "uint64[]", "value": [0, 42]} }, { "inputs:array": {"type": "bool[]", "value": [true, true]}, "inputs:index": 0, "inputs:value": {"type": "bool", "value":false}, "outputs:array": {"type": "bool[]", "value": [false, true]} }, { "inputs:array": {"type": "token[]", "value": ["41", "42"]}, "inputs:index": -1, "inputs:value": {"type": "token", "value":""}, "outputs:array": {"type": "token[]", "value": ["41", ""]} }, { "inputs:array": {"type": "half[2][]", "value": [[1.0, 2.0], [3.0, 4.0]]}, "inputs:index": 3, "inputs:resizeToFit": true, "inputs:value": {"type": "half[2]", "value":[5.0, 6.0]}, "outputs:array": {"type": "half[2][]", "value": [[1.0, 2.0], [3.0, 4.0], [0.0, 0.0], [5.0, 6.0]]} }, { "inputs:array": {"type": "float[2][]", "value": [[1.0, 2.0], [3.0, 4.0]]}, "inputs:index": 3, "inputs:resizeToFit": true, "inputs:value": {"type": "float[2]", "value":[5.0, 6.0]}, "outputs:array": {"type": "float[2][]", "value": [[1.0, 2.0], [3.0, 4.0], [0.0, 0.0], [5.0, 6.0]]} }, { "inputs:array": {"type": "double[3][]", "value": [[1.0, 2.0, 3.0], [3.0, 4.0, 5.0]]}, "inputs:index": 3, "inputs:resizeToFit": true, "inputs:value": {"type": "double[3]", "value":[5.0, 6.0, 7.0]}, "outputs:array": {"type": "double[3][]", "value": [[1.0, 2.0, 3.0], [3.0, 4.0, 5.0], [0.0, 0.0, 0.0], [5.0, 6.0, 7.0]]} }, { "inputs:array": {"type": "int[4][]", "value": [[1, 2, 3, 4], [3, 4, 5, 6]]}, "inputs:index": 3, "inputs:resizeToFit": true, "inputs:value": {"type": "int[4]", "value":[5, 6, 7, 8]}, "outputs:array": {"type": "int[4][]", "value": [[1, 2, 3, 4], [3, 4, 5, 6], [0, 0, 0, 0], [5, 6, 7, 8]]} }, { "inputs:array": {"type": "token[]", "value": ["41", "42"]}, "inputs:index": 3, "inputs:resizeToFit": true, "inputs:value": {"type": "token", "value":"43"}, "outputs:array": {"type": "token[]", "value": ["41", "42", "", "43"]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnAppendPath.ogn
{ "AppendPath": { "version": 1, "description": [ "Generates a path token by appending the given relative path token to the given root or prim path token" ], "uiName": "Append Path", "tags": [ "paths" ], "categories": [ "sceneGraph" ], "scheduling": [ "threadsafe" ], "inputs": { "path": { "type": [ "token", "token[]" ], "description": "The path token(s) to be appended to. Must be a base or prim path (ex. /World)" }, "suffix": { "type": "token", "description": "The prim or prim-property path to append (ex. Cube or Cube.attr)" } }, "outputs": { "path": { "type": [ "token", "token[]" ], "description": "The new path token(s) (ex. /World/Cube or /World/Cube.attr)" } }, "state": { "path": { "type": "token", "description": "Snapshot of previously seen path" }, "suffix": { "type": "token", "description": "Snapshot of previously seen suffix" } }, "tests": [ { "inputs:path": { "type": "token", "value": "/" }, "inputs:suffix": "foo", "outputs:path": { "type": "token", "value": "/foo" } }, { "inputs:path": { "type": "token", "value": "/World" }, "inputs:suffix": "foo", "outputs:path": { "type": "token", "value": "/World/foo" } }, { "inputs:path": { "type": "token", "value": "/World" }, "inputs:suffix": "foo/bar", "outputs:path": { "type": "token", "value": "/World/foo/bar" } }, { "inputs:path": { "type": "token", "value": "/World" }, "inputs:suffix": "foo/bar.attrib", "outputs:path": { "type": "token", "value": "/World/foo/bar.attrib" } }, { "inputs:path": { "type": "token[]", "value": [ "/World", "/World2" ] }, "inputs:suffix": "foo", "outputs:path": { "type": "token[]", "value": [ "/World/foo", "/World2/foo" ] } } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnStartsWith.ogn
{ "StartsWith": { "version": 1, "description": [ "Determines if a string starts with a given string value" ], "uiName": "Starts With", "categories": ["function"], "scheduling": ["threadsafe"], "inputs": { "prefix": { "type": "string", "description": "The prefix to test" }, "value": { "type": "string", "description": "The string to check" } }, "outputs": { "isPrefix": { "type": "bool", "description": "True if 'value' starts with 'prefix'" } }, "tests": [ { "inputs:value": "", "inputs:prefix": "", "outputs:isPrefix": true }, { "inputs:value": "a", "inputs:prefix": "", "outputs:isPrefix": true }, { "inputs:value": "", "inputs:prefix": "a", "outputs:isPrefix": false }, { "inputs:value": "aa", "inputs:prefix": "a", "outputs:isPrefix": true }, { "inputs:value": "aa", "inputs:prefix": "aa", "outputs:isPrefix": true }, { "inputs:value": "aa", "inputs:prefix": "aaa", "outputs:isPrefix": false }, { "inputs:value": "aaa", "inputs:prefix": "aa", "outputs:isPrefix": true } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnIsEmpty.ogn
{ "IsEmpty": { "version": 1, "description": [ "Checks if the given input is empty.", "An input is considered empty if there is no data.", "A string or array of size 0 is considered empty whereas a blank string ' ' is not empty.", "A float with value 0.0 and int[2] with value [0, 0] are not empty." ], "uiName": "Is Empty", "categories": ["function"], "scheduling": ["threadsafe"], "inputs": { "input": { "type": "any", "uiName": "Input", "description": "The input to check if empty" } }, "outputs": { "isEmpty": { "type": "bool", "uiName": "Is Empty", "description": "True if the input is empty, false otherwise" } }, "tests": [ { "inputs:input": { "type": "bool", "value": false }, "outputs:isEmpty": false }, { "inputs:input": { "type": "int", "value": 0 }, "outputs:isEmpty": false }, { "inputs:input": { "type": "double", "value": 0.0 }, "outputs:isEmpty": false }, { "inputs:input": { "type": "uchar", "value": 0 }, "outputs:isEmpty": false }, { "inputs:input": { "type": "float[2]", "value": [0.0, 0.0] }, "outputs:isEmpty": false }, { "inputs:input": { "type": "float[]", "value": [0.0] }, "outputs:isEmpty": false }, { "inputs:input": { "type": "float[]", "value": [] }, "outputs:isEmpty": true }, { "inputs:input": { "type": "int[]", "value": [] }, "outputs:isEmpty": true }, { "inputs:input": { "type": "float[2][]", "value": [] }, "outputs:isEmpty": true }, { "inputs:input": { "type": "token", "value": "hello" }, "outputs:isEmpty": false }, { "inputs:input": { "type": "string", "value": "hello" }, "outputs:isEmpty": false }, { "inputs:input": { "type": "token", "value": " " }, "outputs:isEmpty": false }, { "inputs:input": { "type": "string", "value": " " }, "outputs:isEmpty": false }, { "inputs:input": { "type": "string", "value": "" }, "outputs:isEmpty": true }, { "inputs:input": { "type": "token", "value": "" }, "outputs:isEmpty": true } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnSelectIf.cpp
// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnSelectIfDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/string.h> #include <omni/graph/core/ogn/Types.h> #include <carb/logging/Log.h> namespace omni { namespace graph { namespace nodes { namespace { template<typename T> bool tryComputeAssumingType(OgnSelectIfDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto const& condition, auto& result) { result = condition ? a : b; }; return ogn::compute::tryComputeWithArrayBroadcasting<T, T, bool, T>( db.inputs.ifTrue(), db.inputs.ifFalse(), db.inputs.condition(), db.outputs.result(), functor, count); } template<typename T, size_t N> bool tryComputeAssumingType(OgnSelectIfDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto const& condition, auto& result) { if (condition) { memcpy(result, a, sizeof(T) * N); } else { memcpy(result, b, sizeof(T) * N); } }; return ogn::compute::tryComputeWithArrayBroadcasting<T[N], T[N], bool, T[N]>( db.inputs.ifTrue(), db.inputs.ifFalse(), db.inputs.condition(), db.outputs.result(), functor, count); } } // namespace class OgnSelectIf { public: static bool computeVectorized(OgnSelectIfDatabase& db, size_t count) { NodeObj nodeObj = db.abi_node(); const AttributeObj ifTrueAttr = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::ifTrue.token()); const Type ifTrueType = ifTrueAttr.iAttribute->getResolvedType(ifTrueAttr); const AttributeObj ifFalseAttr = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::ifFalse.token()); const Type ifFalseType = ifFalseAttr.iAttribute->getResolvedType(ifFalseAttr); const AttributeObj conditionAttr = nodeObj.iNode->getAttributeByToken(nodeObj, inputs::condition.token()); const Type conditionType = conditionAttr.iAttribute->getResolvedType(conditionAttr); // This handles string case (arrays of strings are not supported) if (ifTrueType.baseType == BaseDataType::eUChar && ifTrueType.arrayDepth == 1 && ifFalseType.baseType == BaseDataType::eUChar && ifFalseType.arrayDepth == 1 && conditionType.arrayDepth == 0) { for (size_t idx = 0; idx < count; ++idx) { const bool condition = *db.inputs.condition(idx).template get<bool>(); auto ifTrue = db.inputs.ifTrue(idx).template get<uint8_t[]>(); auto ifFalse = db.inputs.ifFalse(idx).template get<uint8_t[]>(); auto result = db.outputs.result(idx).template get<uint8_t[]>(); if (condition) { result->resize(ifTrue->size()); memcpy(&((*result)[0]), &((*ifTrue)[0]), result->size()); } else { result->resize(ifFalse->size()); memcpy(&((*result)[0]), &((*ifFalse)[0]), result->size()); } } return true; } try { switch (ifTrueType.baseType) { case BaseDataType::eBool: return tryComputeAssumingType<bool>(db, count); case BaseDataType::eToken: return tryComputeAssumingType<ogn::Token>(db, count); case BaseDataType::eDouble: switch (ifTrueType.componentCount) { case 1: return tryComputeAssumingType<double>(db, count); case 2: return tryComputeAssumingType<double, 2>(db, count); case 3: return tryComputeAssumingType<double, 3>(db, count); case 4: return tryComputeAssumingType<double, 4>(db, count); case 9: return tryComputeAssumingType<double, 9>(db, count); case 16: return tryComputeAssumingType<double, 16>(db, count); default: break; } case BaseDataType::eFloat: switch (ifTrueType.componentCount) { case 1: return tryComputeAssumingType<float>(db, count); case 2: return tryComputeAssumingType<float, 2>(db, count); case 3: return tryComputeAssumingType<float, 3>(db, count); case 4: return tryComputeAssumingType<float, 4>(db, count); default: break; } case BaseDataType::eHalf: switch (ifTrueType.componentCount) { case 1: return tryComputeAssumingType<pxr::GfHalf>(db, count); case 2: return tryComputeAssumingType<pxr::GfHalf, 2>(db, count); case 3: return tryComputeAssumingType<pxr::GfHalf, 3>(db, count); case 4: return tryComputeAssumingType<pxr::GfHalf, 4>(db, count); default: break; } case BaseDataType::eInt: switch (ifTrueType.componentCount) { case 1: return tryComputeAssumingType<int32_t>(db, count); case 2: return tryComputeAssumingType<int32_t, 2>(db, count); case 3: return tryComputeAssumingType<int32_t, 3>(db, count); case 4: return tryComputeAssumingType<int32_t, 4>(db, count); default: break; } ; case BaseDataType::eInt64: return tryComputeAssumingType<int64_t>(db, count); case BaseDataType::eUChar: return tryComputeAssumingType<unsigned char>(db, count); case BaseDataType::eUInt: return tryComputeAssumingType<uint32_t>(db, count); case BaseDataType::eUInt64: return tryComputeAssumingType<uint64_t>(db, count); default: break; } db.logWarning("Failed to resolve input types"); } catch (ogn::compute::InputError &error) { db.logError(error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node){ auto ifTrue = node.iNode->getAttributeByToken(node, inputs::ifTrue.token()); auto ifFalse = node.iNode->getAttributeByToken(node, inputs::ifFalse.token()); auto condition = node.iNode->getAttributeByToken(node, inputs::condition.token()); auto result = node.iNode->getAttributeByToken(node, outputs::result.token()); auto ifTrueType = ifTrue.iAttribute->getResolvedType(ifTrue); auto ifFalseType = ifFalse.iAttribute->getResolvedType(ifFalse); auto conditionType = condition.iAttribute->getResolvedType(condition); // Require ifTrue, ifFalse, and condition to be resolved before determining result's type if (ifTrueType.baseType != BaseDataType::eUnknown && ifFalseType.baseType != BaseDataType::eUnknown && conditionType.baseType != BaseDataType::eUnknown) { std::array<AttributeObj, 3> attrs { ifTrue, ifFalse, result }; std::array<uint8_t, 3> tupleCounts { ifTrueType.componentCount, ifFalseType.componentCount, std::max(ifTrueType.componentCount, ifFalseType.componentCount) }; std::array<uint8_t, 3> arrayDepths { ifTrueType.arrayDepth, ifFalseType.arrayDepth, std::max(conditionType.arrayDepth, std::max(ifTrueType.arrayDepth, ifFalseType.arrayDepth)) }; const bool isStringInput = (ifTrueType.baseType == BaseDataType::eUChar && ifTrueType.arrayDepth == 1 && ifFalseType.baseType == BaseDataType::eUChar && ifFalseType.arrayDepth == 1 && conditionType.arrayDepth == 0 && ifTrueType.role == AttributeRole::eText && ifFalseType.role == AttributeRole::eText); std::array<AttributeRole, 3> rolesBuf { ifTrueType.role, ifFalseType.role, isStringInput ? AttributeRole::eText : AttributeRole::eUnknown }; node.iNode->resolvePartiallyCoupledAttributes(node, attrs.data(), tupleCounts.data(), arrayDepths.data(), rolesBuf.data(), attrs.size()); } } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnArrayGetSize.cpp
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnArrayGetSizeDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <omni/graph/core/ogn/string.h> #include <omni/graph/core/ogn/Types.h> #include <algorithm> namespace omni { namespace graph { namespace nodes { class OgnArrayGetSize { public: static bool compute(OgnArrayGetSizeDatabase& db) { try { db.outputs.size() = int(db.inputs.array().size()); return true; } catch (ogn::compute::InputError const &error) { db.logError(error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node){ auto const inputArray = node.iNode->getAttributeByToken(node, inputs::array.token()); auto const inputArrayType = inputArray.iAttribute->getResolvedType(inputArray); if (inputArrayType.baseType != BaseDataType::eUnknown) { std::array<AttributeObj, 1> attrs { inputArray }; // all should have the same tuple count std::array<uint8_t, 1> tupleCounts { inputArrayType.componentCount }; // value type can not be an array because we don't support arrays-of-arrays std::array<uint8_t, 1> arrayDepths { 1 }; std::array<AttributeRole, 1> rolesBuf { inputArrayType.role }; node.iNode->resolvePartiallyCoupledAttributes(node, attrs.data(), tupleCounts.data(), arrayDepths.data(), rolesBuf.data(), attrs.size()); } } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnEndsWith.ogn
{ "EndsWith": { "version": 1, "description": [ "Determines if a string ends with a given string value" ], "uiName": "Ends With", "categories": ["function"], "scheduling": ["threadsafe"], "inputs": { "suffix": { "type": "string", "description": "The suffix to test" }, "value": { "type": "string", "description": "The string to check" } }, "outputs": { "isSuffix": { "type": "bool", "description": "True if 'value' ends with 'suffix'" } }, "tests": [ { "inputs:value": "", "inputs:suffix": "", "outputs:isSuffix": true }, { "inputs:value": "a", "inputs:suffix": "", "outputs:isSuffix": true }, { "inputs:value": "", "inputs:suffix": "a", "outputs:isSuffix": false }, { "inputs:value": "aa", "inputs:suffix": "a", "outputs:isSuffix": true }, { "inputs:value": "ab", "inputs:suffix": "ab", "outputs:isSuffix": true }, { "inputs:value": "aa", "inputs:suffix": "aaa", "outputs:isSuffix": false }, { "inputs:value": "aba", "inputs:suffix": "ba", "outputs:isSuffix": true } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnMakeVector2.ogn
{ "MakeVector2": { "version": 1, "description": [ "Merge 2 input values into a single output vector.", "If the inputs are arrays, the output will be an array of vectors." ], "uiName": "Make 2-Vector", "categories": ["math:conversion"], "tags": ["compose", "combine", "join"], "scheduling": ["threadsafe"], "inputs": { "x": { "type": ["double", "float", "half", "int", "double[]", "float[]", "half[]", "int[]"], "uiName": "X", "description": "The first component of the vector" }, "y": { "type": ["double", "float", "half", "int", "double[]", "float[]", "half[]", "int[]"], "uiName": "Y", "description": "The second component of the vector" } }, "outputs": { "tuple": { "type": ["double[2]", "float[2]", "half[2]", "int[2]", "double[2][]", "float[2][]", "half[2][]", "int[2][]"], "uiName": "Vector", "description": "Output vector(s)" } }, "tests" : [ { "inputs:x": {"type": "float", "value": 42.0}, "inputs:y": {"type": "float", "value": 1.0}, "outputs:tuple": {"type": "float[2]", "value": [42.0, 1.0]} }, { "inputs:x": {"type": "float", "value": 42.0}, "outputs:tuple": {"type": "float[2]", "value": [42.0, 0.0]} }, { "inputs:x": {"type": "float[]", "value": [42,1,0]}, "inputs:y": {"type": "float[]", "value": [0,1,2]}, "outputs:tuple": {"type": "float[2][]", "value": [[42,0],[1,1],[0,2]]} }, { "inputs:x": {"type": "int", "value": 42}, "inputs:y": {"type": "int", "value": -42}, "outputs:tuple": {"type": "int[2]", "value": [42, -42]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnToToken.ogn
{ "ToToken": { "version": 1, "description": [ "Converts the given input to a string equivalent and provides the Token value" ], "uiName": "To Token", "categories": ["function"], "scheduling": ["threadsafe"], "inputs": { "value": { "type": "any", "uiName": "value", "description": "The value to be converted to a token" } }, "outputs": { "converted": { "type": "token", "uiName": "Token", "description": "Stringified output as a Token" } }, "tests" : [ { "inputs:value": {"type": "bool", "value": true}, "outputs:converted": "True" }, { "inputs:value": {"type": "double", "value": 2.1}, "outputs:converted": "2.1" }, { "inputs:value": {"type": "int", "value": 42}, "outputs:converted": "42" }, { "inputs:value": {"type": "double[3]", "value": [1.8, 2.2, 3] }, "outputs:converted": "[1.8, 2.2, 3]" }, { "inputs:value": {"type": "half[3]", "value": [2, 3, 4.5] }, "outputs:converted": "[2, 3, 4.5]" }, { "inputs:value": {"type": "int[2][]", "value": [[1, 2],[3, 4]] }, "outputs:converted": "[[1, 2], [3, 4]]" }, { "inputs:value": {"type": "uint64", "value": 42 }, "outputs:converted": "42" }, { "inputs:value": {"type": "token", "value": "Foo" }, "outputs:converted": "Foo" }, { "inputs:value": {"type": "string", "value": "Foo" }, "outputs:converted": "Foo" } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnBuildString.cpp
// Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved. // // NVIDIA CORPORATION and its licensors retain all intellectual property // and proprietary rights in and to this software, related documentation // and any modifications thereto. Any use, reproduction, disclosure or // distribution of this software and related documentation without an express // license agreement from NVIDIA CORPORATION is strictly prohibited. // #include <OgnBuildStringDatabase.h> namespace omni { namespace graph { namespace nodes { class OgnBuildString { public: static bool compute(OgnBuildStringDatabase& db) { auto const& inputValue = db.inputs.a(); auto const& suffixIn = db.inputs.b(); auto& outValue = db.outputs.value(); bool result = true; if (inputValue.type().baseType == BaseDataType::eToken) result = result && computeForToken(db, inputValue, suffixIn, outValue); else result = result && computeForString(db, inputValue, suffixIn, outValue); auto const& dynamicInputs = db.getDynamicInputs(); if (!result || dynamicInputs.empty()) return result; auto accumulatingValue = omni::graph::core::ogn::constructInputFromOutput(db, db.outputs.value(), outputs::value.token()); for (auto const& input : dynamicInputs) { if (input().type().baseType == BaseDataType::eToken) result = result && computeForToken(db, accumulatingValue, input(), outValue); else result = result && computeForString(db, accumulatingValue, input(), outValue); } return result; } static bool computeForString(OgnBuildStringDatabase& db, ogn::RuntimeAttribute<ogn::kOgnInput, ogn::kCpu> const& inputValue, ogn::RuntimeAttribute<ogn::kOgnInput, ogn::kCpu> const& suffixIn, ogn::RuntimeAttribute<ogn::kOgnOutput, ogn::kCpu>& outValue) { auto const suffixData = suffixIn.get<uint8_t[]>(); // No suffix? Just copy in to out if (suffixData->empty()) { // the inputValue may be an alias for the outValue if (inputValue.name() != outValue.name()) db.outputs.value().copyData(inputValue); return true; } auto const inputValueData = inputValue.get<uint8_t[]>(); std::string outVal; outVal.reserve(inputValueData.size() + suffixData.size()); outVal.append(reinterpret_cast<char const*>(inputValueData->data()), inputValueData.size()); outVal.append(reinterpret_cast<char const*>(suffixData->data()), suffixData.size()); auto outData = outValue.get<uint8_t[]>(); size_t outBufferSize = outVal.size(); outData->resize(outBufferSize); memcpy(outData->data(), reinterpret_cast<uint8_t const*>(outVal.data()), outBufferSize); return true; } static bool computeForToken(OgnBuildStringDatabase& db, ogn::RuntimeAttribute<ogn::kOgnInput, ogn::kCpu> const& inputValue, ogn::RuntimeAttribute<ogn::kOgnInput, ogn::kCpu> const& suffix, ogn::RuntimeAttribute<ogn::kOgnOutput, ogn::kCpu>& outValue) { std::vector<char const*> suffixes; if (suffix.type().arrayDepth == 0) { NameToken suffixToken = *suffix.get<OgnToken>(); if (suffixToken != omni::fabric::kUninitializedToken) suffixes.push_back(db.tokenToString(suffixToken)); } else { const auto suffixTokens = *suffix.get<OgnToken[]>(); suffixes.resize(suffixTokens.size()); std::transform(suffixTokens.begin(), suffixTokens.end(), suffixes.begin(), [&db](auto t) { return db.tokenToString(t); }); } // No suffix? Just copy in to out if (suffixes.empty()) { // the input value may be an alias for the output value if (inputValue.name() != outValue.name()) db.outputs.value().copyData(inputValue); return true; } if (inputValue.type().arrayDepth > 0) { const auto inputValueArray = *inputValue.get<OgnToken[]>(); auto outputPathArray = *db.outputs.value().get<OgnToken[]>(); outputPathArray.resize(inputValueArray.size()); if (suffixes.size() == 1) { const char* suffixStr = suffixes[0]; std::transform(inputValueArray.begin(), inputValueArray.end(), outputPathArray.begin(), [&](const auto& p) { std::string s = db.tokenToString(p); s += suffixStr; return db.stringToToken(s.c_str()); }); } else { if (inputValueArray.size() != suffixes.size()) { CARB_LOG_ERROR("inputs:value and inputs:suffix arrays are not the same size (%zu and %zu)", inputValueArray.size(), suffixes.size()); return false; } for (size_t i = 0; i < inputValueArray.size(); ++i) { std::string s = db.tokenToString(inputValueArray[i]); s += suffixes[i]; outputPathArray[i] = db.stringToToken(s.c_str()); } } return true; } else { NameToken inValue = *inputValue.get<OgnToken>(); std::string s; if (inValue != omni::fabric::kUninitializedToken) { s = db.tokenToString(inValue); } s += suffixes[0]; *db.outputs.value().get<OgnToken>() = db.stringToToken(s.c_str()); } return true; } static void onConnectionTypeResolve(const NodeObj& node) { auto inputVal = node.iNode->getAttributeByToken(node, OgnBuildStringAttributes::inputs::a.m_token); auto outputVal = node.iNode->getAttributeByToken(node, OgnBuildStringAttributes::outputs::value.m_token); // in and out needs to be the same std::array<AttributeObj, 2> io{ inputVal, outputVal }; node.iNode->resolveCoupledAttributes(node, io.data(), io.size()); //retrieve all other input attributes auto totalCount = node.iNode->getAttributeCount(node); std::vector<AttributeObj> attrs(totalCount); node.iNode->getAttributes(node, attrs.data(), totalCount); size_t idx = 0; size_t count = totalCount; while (idx != count) { if (attrs[idx].iAttribute->getPortType(attrs[idx]) != AttributePortType::kAttributePortType_Input || attrs[idx].attributeHandle == inputVal.attributeHandle) { count--; std::swap(attrs[idx], attrs[count]); } else { idx++; } } auto type = inputVal.iAttribute->getResolvedType(inputVal); // if input is an array of token, suffixes are allowed to be either a simple or an array of token(s) if (type.baseType == BaseDataType::eToken && type.arrayDepth != 0) { for (auto const& attr : attrs) { auto suffixType = attr.iAttribute->getResolvedType(attr); if (suffixType.baseType == BaseDataType::eUChar) // string not compatible with tokens attr.iAttribute->setResolvedType(attr, type); } } else if (type.baseType != BaseDataType::eUnknown) { // else, they all needs to have the same type for (auto const& attr : attrs) attr.iAttribute->setResolvedType(attr, type); } } }; REGISTER_OGN_NODE(); } // nodes } // graph } // omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnBreakVector3.ogn
{ "BreakVector3": { "version": 1, "description": ["Split vector into 3 component values."], "uiName": "Break 3-Vector", "categories": ["math:conversion"], "tags": ["decompose", "separate", "isolate"], "scheduling": ["threadsafe"], "inputs": { "tuple": { "type": ["double[3]", "float[3]", "half[3]", "int[3]"], "uiName": "Vector", "description": "3-vector to be broken" } }, "outputs": { "x": { "type": ["double", "float", "half", "int"], "uiName": "X", "description": "The first component of the vector" }, "y": { "type": ["double", "float", "half", "int"], "uiName": "Y", "description": "The second component of the vector" }, "z": { "type": ["double", "float", "half", "int"], "uiName": "Z", "description": "The third component of the vector" } }, "tests" : [ { "inputs:tuple": {"type": "float[3]", "value": [42.0, 1.0, 0.0]}, "outputs:x": {"type": "float", "value": 42.0}, "outputs:y": {"type": "float", "value": 1.0}, "outputs:z": {"type": "float", "value": 0.0} }, { "inputs:tuple": {"type": "int[3]", "value": [42, -42, 5]}, "outputs:x": {"type": "int", "value": 42}, "outputs:y": {"type": "int", "value": -42}, "outputs:z": {"type": "int", "value": 5} }, { "inputs:tuple": {"type": "colorf[3]", "value": [42.0, 1.0, 0.0]}, "outputs:x": {"type": "float", "value": 42.0}, "outputs:y": {"type": "float", "value": 1.0}, "outputs:z": {"type": "float", "value": 0.0} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/utility/OgnGetPrimRelationship.ogn
{ "GetPrimRelationship": { "version": 3, "description": ["DEPRECATED - Use ReadPrimRelationship!"], "uiName": "Get Prim Relationship", "categories": ["sceneGraph"], "scheduling": ["usd-read", "threadsafe"], "inputs": { "prim": { "type": "target", "description": "The prim with the relationship", "optional": true }, "name": { "type": "token", "description": "Name of the relationship property", "uiName": "Relationship Name" }, "usePath": { "type": "bool", "default": false, "description": "When true, the 'path' attribute is used, otherwise it will read the connection at the 'prim' attribute.", "deprecated": "Use prim input with a GetPrimsAtPath node instead" }, "path": { "type": "token", "description": "Path of the prim with the relationship property", "uiName": "Prim Path", "optional": true, "deprecated": "Use prim input with a GetPrimsAtPath node instead" } }, "outputs": { "paths": { "type": "token[]", "description": "The prim paths for the given relationship", "uiName": "Paths" } } } }