// 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 <OgnTutorialTupleDataDatabase.h>
#include <algorithm>
#include <iostream>

// This class exercises access to the DataModel through the generated database class for supported data types
// with element counts greater than 1.

class OgnTutorialTupleData
{
public:
    static bool compute(OgnTutorialTupleDataDatabase& db)
    {
        // For each piece of data apply a transforming operation so that compute does something testable.
        // The transformation adds 1 to the input to compute the matching output. Notice how the recognized
        // USD types can make use of the built-in manipulation functions while the generic types have to
        // manually apply the algorithm.
        db.outputs.a_double2() = db.inputs.a_double2() + GfVec2d(1.0, 1.0);
        db.outputs.a_double3() = db.inputs.a_double3() + GfVec3d(1.0, 1.0, 1.0);
        db.outputs.a_float2() = db.inputs.a_float2() + GfVec2f(1.0f, 1.0f);
        db.outputs.a_half2() = db.inputs.a_half2() + GfVec2h(1.0, 1.0);
        db.outputs.a_int2() = db.inputs.a_int2() + GfVec2i(1, 1);

        // If you have your own data types which are memory-layout-compatible with the defaults provided
        // you can use a simple cast operation to force a specific data type. Be careful not to cast away
        // the "const" on inputs or your data could get out of sync.
        const carb::Float3& inFloat3 = reinterpret_cast<const carb::Float3&>(db.inputs.a_float3());
        carb::Float3& outFloat3 = reinterpret_cast<carb::Float3&>(db.outputs.a_float3());
        outFloat3.x = inFloat3.x + 1.0f;
        outFloat3.y = inFloat3.y + 1.0f;
        outFloat3.z = inFloat3.z + 1.0f;

        return true;
    }
};

REGISTER_OGN_NODE()
