// 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 <OgnRandomPointsGpuDatabase.h>
#include <cstdlib>

// This is the implementation of the OGN node defined in OgnRandomPointsGpu.ogn

namespace omni {
namespace graph {
namespace test {

extern "C"
void generateGpu(
    outputs::points_t outputPoints,
    inputs::minimum_t minimum,
    inputs::maximum_t maximum,
    size_t numberOfPoints);

class OgnRandomPointsGpu
{
public:
    // Create an array of "pointCount" points at random locations within the bounding cube,
    // delineated by the corner points "minimum" and "maximum".
    static bool compute(OgnRandomPointsGpuDatabase& db)
    {
        // No points mean nothing to generate
        const auto& pointCount = db.inputs.pointCount();
        if (pointCount == 0)
        {
            return true;
        }

        CARB_PROFILE_ZONE(carb::profiler::kCaptureMaskDefault, "Generating Data");
        db.outputs.points.resize(pointCount);
        generateGpu(db.outputs.points(), db.inputs.minimum(), db.inputs.maximum(), pointCount);

        return true;
    }
};

REGISTER_OGN_NODE()

} // test
} // namespace graph
} // namespace omni
