Program Listing for include/PxConstraint.h

↰ Return to documentation for include/PxConstraint.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-2022 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_CONSTRAINT_H
#define PX_CONSTRAINT_H

#include "PxPhysXConfig.h"
#include "PxConstraintDesc.h"
#include "common/PxBase.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

class PxRigidActor;
class PxScene;
class PxConstraintConnector;

struct PxConstraintFlag
{
    enum Enum
    {
        eBROKEN                     = 1<<0,
        ePROJECT_TO_ACTOR0          = 1<<1,
        ePROJECT_TO_ACTOR1          = 1<<2,
        ePROJECTION                 = ePROJECT_TO_ACTOR0 | ePROJECT_TO_ACTOR1,
        eCOLLISION_ENABLED          = 1<<3,
        eVISUALIZATION              = 1<<4,
        eDRIVE_LIMITS_ARE_FORCES    = 1<<5,
        eIMPROVED_SLERP             = 1<<7,
        eDISABLE_PREPROCESSING      = 1<<8,
        eENABLE_EXTENDED_LIMITS     = 1<<9,
        eGPU_COMPATIBLE             = 1<<10,
        eALWAYS_UPDATE              = 1<<11,
        eDISABLE_CONSTRAINT         = 1<<12
    };
};

typedef PxFlags<PxConstraintFlag::Enum, PxU16> PxConstraintFlags;
PX_FLAGS_OPERATORS(PxConstraintFlag::Enum, PxU16)


struct PxConstraintShaderTable
{
    PxConstraintSolverPrep  solverPrep;
    PxConstraintProject     project;
    PxConstraintVisualize   visualize;
    PxConstraintFlag::Enum  flag;
};

class PxConstraint : public PxBase
{
public:

    virtual void                release()                                                       = 0;

    virtual PxScene*            getScene()                                              const   = 0;

    virtual void                getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const   = 0;

    virtual void                setActors(PxRigidActor* actor0, PxRigidActor* actor1)           = 0;

    virtual void                markDirty()                                                     = 0;

    virtual PxConstraintFlags   getFlags()                                              const   = 0;

    virtual void                setFlags(PxConstraintFlags flags)                               = 0;

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

    virtual void                getForce(PxVec3& linear, PxVec3& angular)               const   = 0;

    virtual bool                isValid() const                                                 = 0;

    virtual void                setBreakForce(PxReal linear, PxReal angular)                = 0;

    virtual void                getBreakForce(PxReal& linear, PxReal& angular)      const   = 0;

    virtual void                setMinResponseThreshold(PxReal threshold)                   = 0;

    virtual PxReal              getMinResponseThreshold()                           const   = 0;

    virtual void*               getExternalReference(PxU32& typeID)                         = 0;

    virtual void                setConstraintFunctions(PxConstraintConnector& connector, const PxConstraintShaderTable& shaders)    = 0;

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

            void*               userData;

protected:
    PX_INLINE                   PxConstraint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
    PX_INLINE                   PxConstraint(PxBaseFlags baseFlags) : PxBase(baseFlags), userData(NULL) {}
    virtual                     ~PxConstraint() {}
    virtual bool                isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxConstraint", name) || PxBase::isKindOf(name); }
};

#if !PX_DOXYGEN
} // namespace physx
#endif

#endif