include/PxRigidBody.h

File members: include/PxRigidBody.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-2023 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_RIGID_BODY_H
#define PX_RIGID_BODY_H
#include "PxRigidActor.h"
#include "PxForceMode.h"
#include "PxNodeIndex.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

struct PxRigidBodyFlag
{
    enum Enum
    {
        eKINEMATIC  = (1<<0),

        eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES = (1<<1),

        eENABLE_CCD = (1<<2),

        eENABLE_CCD_FRICTION    = (1<<3),

        eENABLE_SPECULATIVE_CCD = (1<<4),

        eENABLE_POSE_INTEGRATION_PREVIEW    = (1<<5),

        eENABLE_CCD_MAX_CONTACT_IMPULSE = (1<<6),

        eRETAIN_ACCELERATIONS = (1<<7),

        eFORCE_KINE_KINE_NOTIFICATIONS = (1<<8),

        eFORCE_STATIC_KINE_NOTIFICATIONS = (1<<9),

        eENABLE_GYROSCOPIC_FORCES = (1<<10),

        eRESERVED = (1<<15)
    };
};

typedef PxFlags<PxRigidBodyFlag::Enum,PxU16> PxRigidBodyFlags;
PX_FLAGS_OPERATORS(PxRigidBodyFlag::Enum,PxU16)

class PxRigidBody : public PxRigidActor
{
public:
    // Runtime modifications

/************************************************************************************************/
    virtual     void    setCMassLocalPose(const PxTransform& pose) = 0;

    virtual     PxTransform     getCMassLocalPose() const = 0;

    virtual     void    setMass(PxReal mass) = 0;

    virtual     PxReal  getMass() const = 0;

    virtual     PxReal  getInvMass() const = 0;

    virtual     void    setMassSpaceInertiaTensor(const PxVec3& m) = 0;

    virtual     PxVec3  getMassSpaceInertiaTensor()         const = 0;

    virtual     PxVec3  getMassSpaceInvInertiaTensor()          const = 0;

    /************************************************************************************************/
    virtual     void    setLinearDamping(PxReal linDamp) = 0;

    virtual     PxReal  getLinearDamping() const = 0;

    virtual     void    setAngularDamping(PxReal angDamp) = 0;

    virtual     PxReal  getAngularDamping() const = 0;

/************************************************************************************************/
    virtual     PxVec3  getLinearVelocity()     const = 0;

    virtual     PxVec3  getAngularVelocity()    const = 0;

    virtual     void    setMaxLinearVelocity(PxReal maxLinVel) = 0;

    virtual     PxReal  getMaxLinearVelocity()  const = 0;

    virtual     void    setMaxAngularVelocity(PxReal maxAngVel) = 0;

    virtual     PxReal  getMaxAngularVelocity() const = 0;

/************************************************************************************************/
    virtual     void    addForce(const PxVec3& force, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true) = 0;

    virtual     void    addTorque(const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true) = 0;

    virtual     void    clearForce(PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;

    virtual     void    clearTorque(PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;

    virtual     void    setForceAndTorque(const PxVec3& force, const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;

    virtual     void    setRigidBodyFlag(PxRigidBodyFlag::Enum flag, bool value) = 0;
    virtual     void    setRigidBodyFlags(PxRigidBodyFlags inFlags) = 0;

    virtual     PxRigidBodyFlags    getRigidBodyFlags() const = 0;

    virtual void setMinCCDAdvanceCoefficient(PxReal advanceCoefficient) = 0;

    virtual PxReal getMinCCDAdvanceCoefficient() const = 0;

    virtual void setMaxDepenetrationVelocity(PxReal biasClamp) = 0;

    virtual PxReal getMaxDepenetrationVelocity() const = 0;

    virtual void setMaxContactImpulse(PxReal maxImpulse) = 0;

    virtual PxReal getMaxContactImpulse() const = 0;

    virtual void setContactSlopCoefficient(PxReal slopCoefficient) = 0;

    virtual PxReal getContactSlopCoefficient() const = 0;

    virtual PxNodeIndex getInternalIslandNodeIndex() const = 0;

protected:
    PX_INLINE           PxRigidBody(PxType concreteType, PxBaseFlags baseFlags) : PxRigidActor(concreteType, baseFlags) {}
    PX_INLINE           PxRigidBody(PxBaseFlags baseFlags) : PxRigidActor(baseFlags) {}
    virtual             ~PxRigidBody()  {}
    virtual     bool    isKindOf(const char* name)  const   { PX_IS_KIND_OF(name, "PxRigidBody", PxRigidActor); }
};

#if !PX_DOXYGEN
} // namespace physx
#endif

#endif