include/PxShape.h

File members: include/PxShape.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_SHAPE_H
#define PX_SHAPE_H

#include "PxPhysXConfig.h"
#include "common/PxBase.h"
#include "foundation/PxSimpleTypes.h"
#include "geometry/PxGeometry.h"
#include "geometry/PxGeometryHelpers.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

class PxBoxGeometry;
class PxSphereGeometry;
class PxCapsuleGeometry;
class PxPlaneGeometry;
class PxConvexMeshGeometry;
class PxTriangleMeshGeometry;
class PxTetrahedronMeshGeometry;
class PxHeightFieldGeometry;
class PxParticleSystemGeometry;
class PxHairSystemGeometry;
class PxRigidActor;
struct PxFilterData;
class PxBaseMaterial;
class PxMaterial;
class PxFEMSoftBodyMaterial;
class PxFEMClothMaterial;

struct PxShapeFlag
{
    enum Enum
    {
        eSIMULATION_SHAPE               = (1<<0),

        eSCENE_QUERY_SHAPE              = (1<<1),

        eTRIGGER_SHAPE                  = (1<<2),

        eVISUALIZATION                  = (1<<3)
    };
};

typedef PxFlags<PxShapeFlag::Enum,PxU8> PxShapeFlags;
PX_FLAGS_OPERATORS(PxShapeFlag::Enum,PxU8)

class PxShape : public PxRefCounted
{
public:
    virtual     void    release() = 0;

    virtual     void    setGeometry(const PxGeometry& geometry) = 0;

    virtual     const PxGeometry&   getGeometry() const = 0;

    virtual     PxRigidActor*   getActor() const = 0;

/************************************************************************************************/

//\{

    virtual     void    setLocalPose(const PxTransform& pose)       = 0;

    virtual     PxTransform getLocalPose()  const   = 0;

//\}
/************************************************************************************************/

//\{

    virtual     void    setSimulationFilterData(const PxFilterData& data)   = 0;

    virtual     PxFilterData    getSimulationFilterData()   const   = 0;

    virtual     void    setQueryFilterData(const PxFilterData& data)    = 0;

    virtual     PxFilterData    getQueryFilterData()    const   = 0;

//\}
/************************************************************************************************/

    virtual     void    setMaterials(PxMaterial*const* materials, PxU16 materialCount) = 0;

    virtual     void    setSoftBodyMaterials(PxFEMSoftBodyMaterial*const* materials, PxU16 materialCount) = 0;

    virtual     void    setClothMaterials(PxFEMClothMaterial*const* materials, PxU16 materialCount) = 0;

    virtual     PxU16   getNbMaterials()        const   = 0;

    virtual     PxU32   getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;

    virtual     PxU32   getSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;

    virtual     PxU32   getClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;

    virtual     PxBaseMaterial*     getMaterialFromInternalFaceIndex(PxU32 faceIndex) const = 0;

    virtual     void    setContactOffset(PxReal contactOffset)  = 0;

    virtual     PxReal  getContactOffset() const    = 0;

    virtual     void    setRestOffset(PxReal restOffset)    = 0;

    virtual     PxReal  getRestOffset() const   = 0;

    virtual     void    setDensityForFluid(PxReal densityForFluid)  = 0;

    virtual     PxReal  getDensityForFluid() const  = 0;

    virtual     void    setTorsionalPatchRadius(PxReal radius) = 0;

    virtual     PxReal  getTorsionalPatchRadius() const = 0;

    virtual     void    setMinTorsionalPatchRadius(PxReal radius) = 0;

    virtual     PxReal  getMinTorsionalPatchRadius() const = 0;

    virtual PX_DEPRECATED   PxU32   getInternalShapeIndex() const = 0;

    virtual PxShapeGPUIndex  getGPUIndex() const = 0;

/************************************************************************************************/

    virtual     void    setFlag(PxShapeFlag::Enum flag, bool value) = 0;

    virtual     void    setFlags(PxShapeFlags inFlags) = 0;

    virtual     PxShapeFlags    getFlags() const = 0;

    virtual     bool    isExclusive() const = 0;

    virtual     void    setName(const char* name)       = 0;

    virtual     const char* getName()           const   = 0;

    virtual     const char* getConcreteTypeName() const { return "PxShape"; }

/************************************************************************************************/

                void*       userData;

protected:
    PX_INLINE               PxShape(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
    PX_INLINE               PxShape(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags), userData(NULL) {}
    virtual                 ~PxShape() {}
    virtual     bool        isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxShape", PxRefCounted); }
};

#if !PX_DOXYGEN
} // namespace physx
#endif

#endif