include/PxDirectGPUAPI.h

File members: include/PxDirectGPUAPI.h

// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of NVIDIA CORPORATION nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2024 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.

#ifndef PX_DIRECT_GPU_API_H
#define PX_DIRECT_GPU_API_H

#include "cudamanager/PxCudaTypes.h"
#include "foundation/PxVec4.h"
#include "foundation/PxSimpleTypes.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

class PxRigidDynamicGPUAPIReadType
{
public:
    enum Enum
    {
        eGLOBAL_POSE = 0,
        eLINEAR_VELOCITY,
        eANGULAR_VELOCITY,
        // eLINEAR_ACCELERATION and eANGULAR_ACCELERATION are only available if PxSceneFlag::eENABLE_BODY_ACCELERATIONS is enabled.
        eLINEAR_ACCELERATION,
        eANGULAR_ACCELERATION
    };
};

class PxRigidDynamicGPUAPIWriteType
{
public:
    enum Enum
    {
        eGLOBAL_POSE = 0,
        eLINEAR_VELOCITY,
        eANGULAR_VELOCITY,
        eFORCE,
        eTORQUE
    };
};

class PxArticulationGPUAPIReadType
{
  public:
    enum Enum
    {
        eJOINT_POSITION = 0,
        eJOINT_VELOCITY,
        eJOINT_ACCELERATION,
        eJOINT_FORCE,
        eJOINT_TARGET_VELOCITY,
        eJOINT_TARGET_POSITION,
        eROOT_GLOBAL_POSE,
        eROOT_LINEAR_VELOCITY,
        eROOT_ANGULAR_VELOCITY,
        eLINK_GLOBAL_POSE,
        eLINK_LINEAR_VELOCITY,
        eLINK_ANGULAR_VELOCITY,
        eLINK_LINEAR_ACCELERATION,
        eLINK_ANGULAR_ACCELERATION,
        eLINK_INCOMING_JOINT_FORCE
    };
};

class PxArticulationGPUAPIWriteType
{
public:
    enum Enum
    {
        eJOINT_POSITION = 0,
        eJOINT_VELOCITY,
        eJOINT_FORCE,
        eJOINT_TARGET_VELOCITY,
        eJOINT_TARGET_POSITION,
        eROOT_GLOBAL_POSE,
        eROOT_LINEAR_VELOCITY,
        eROOT_ANGULAR_VELOCITY,
        eLINK_FORCE,
        eLINK_TORQUE,
        eFIXED_TENDON,
        eFIXED_TENDON_JOINT,
        eSPATIAL_TENDON,
        eSPATIAL_TENDON_ATTACHMENT
    };
};

class PxArticulationGPUAPIComputeType
{
public:
    enum Enum
    {
        eUPDATE_KINEMATIC = 0,
        eDENSE_JACOBIANS,
        eGENERALIZED_MASS_MATRICES,
        eGENERALIZED_GRAVITY_FORCES,
        eCORIOLIS_AND_CENTRIFUGAL_FORCES
    };
};

struct PxArticulationGPUAPIMaxCounts
{
    PxU32 maxDofs;
    PxU32 maxLinks;
    PxU32 maxFixedTendons;
    PxU32 maxFixedTendonJoints;
    PxU32 maxSpatialTendons;
    PxU32 maxSpatialTendonAttachments;

    PxArticulationGPUAPIMaxCounts() :
        maxDofs(0),
        maxLinks(0),
        maxFixedTendons(0),
        maxFixedTendonJoints(0),
        maxSpatialTendons(0),
        maxSpatialTendonAttachments(0)
    {   }
};

class PxDirectGPUAPI
{
protected:
                PxDirectGPUAPI()  {}
    virtual     ~PxDirectGPUAPI() {}

public:

    virtual bool getRigidDynamicData(void* data, const PxRigidDynamicGPUIndex* gpuIndices, PxRigidDynamicGPUAPIReadType::Enum dataType, PxU32 nbElements, CUevent startEvent = NULL, CUevent finishEvent = NULL) const = 0;

    virtual bool setRigidDynamicData(const void* data, const PxRigidDynamicGPUIndex* gpuIndices, PxRigidDynamicGPUAPIWriteType::Enum dataType, PxU32 nbElements, CUevent startEvent = NULL, CUevent finishEvent = NULL) = 0;

    virtual bool getArticulationData(void* data, const PxArticulationGPUIndex* gpuIndices, PxArticulationGPUAPIReadType::Enum dataType, PxU32 nbElements, CUevent startEvent = NULL, CUevent finishEvent = NULL) const = 0;

    virtual bool setArticulationData(const void* data, const PxArticulationGPUIndex* gpuIndices, PxArticulationGPUAPIWriteType::Enum dataType, PxU32 nbElements, CUevent startEvent = NULL, CUevent finishEvent = NULL) = 0;

    virtual bool computeArticulationData(void* data, const PxArticulationGPUIndex* gpuIndices, PxArticulationGPUAPIComputeType::Enum operation, PxU32 nbElements, CUevent startEvent = NULL, CUevent finishEvent = NULL) = 0;

    virtual bool copyContactData(void* data, PxU32* nbContactPairs, PxU32 maxPairs, CUevent startEvent = NULL, CUevent finishEvent = NULL) const = 0;

    virtual bool evaluateSDFDistances(PxVec4* localGradientAndSDFConcatenated, const PxShapeGPUIndex* shapeIndices, const PxVec4* localSamplePointsConcatenated, const PxU32* samplePointCountPerShape, PxU32 nbElements, PxU32 maxPointCount, CUevent startEvent = NULL, CUevent finishEvent = NULL) const = 0;

    virtual PxArticulationGPUAPIMaxCounts getArticulationGPUAPIMaxCounts()  const = 0;
};

#if !PX_DOXYGEN
} // namespace physx
#endif

#endif