Program Listing for include/PxSoftBody.h

↰ Return to documentation for include/PxSoftBody.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_SOFT_BODY_H
#define PX_SOFT_BODY_H

#include "PxFEMParameter.h"
#include "PxActor.h"
#include "PxConeLimitedConstraint.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

#if PX_VC
#pragma warning(push)
#pragma warning(disable : 4435)
#endif

    class PxCudaContextManager;
    class PxBuffer;
    class PxTetrahedronMesh;
    class PxSoftBodyAuxData;
    class PxFEMCloth;
    class PxParticleBuffer;

    #define PX_MAX_TETID    0x000fffff

    struct PxSoftBodyData
    {
        enum Enum
        {
            eNONE = 0,

            ePOSITION_INVMASS = 1 << 0,
            eSIM_POSITION_INVMASS = 1 << 2,
            eSIM_VELOCITY = 1 << 3,
            eSIM_KINEMATIC_TARGET = 1 << 4,

            eALL = ePOSITION_INVMASS | eSIM_POSITION_INVMASS | eSIM_VELOCITY | eSIM_KINEMATIC_TARGET
        };
    };

    typedef PxFlags<PxSoftBodyData::Enum, PxU32> PxSoftBodyDataFlags;

    struct PxSoftBodyFlag
    {
        enum Enum
        {
            eDISABLE_SELF_COLLISION = 1 << 0,
            eCOMPUTE_STRESS_TENSOR = 1 << 1,
            eENABLE_CCD = 1 << 2,
            eDISPLAY_SIM_MESH = 1 << 3,
            eKINEMATIC = 1 << 4,
            ePARTIALLY_KINEMATIC = 1 << 5
        };
    };

    typedef PxFlags<PxSoftBodyFlag::Enum, PxU32> PxSoftBodyFlags;

    class PxSoftBody : public PxActor
    {
    public:

        virtual                         ~PxSoftBody() {}

        virtual     void                setSoftBodyFlag(PxSoftBodyFlag::Enum flag, bool val) = 0;

        virtual     void                setSoftBodyFlags(PxSoftBodyFlags flags) = 0;

        virtual     PxSoftBodyFlags     getSoftBodyFlag() const = 0;

        virtual void                    setParameter(const PxFEMParameters parameters) = 0;

        virtual PxFEMParameters         getParameter() const = 0;

        virtual     void                readData(PxSoftBodyData::Enum flags, PxBuffer& buffer, bool flush = false) = 0;

        virtual     void                readData(PxSoftBodyData::Enum flags, bool flush = false) = 0;

        virtual     void                writeData(PxSoftBodyData::Enum flags, PxBuffer& buffer, bool flush = false) = 0;

        virtual     void                writeData(PxSoftBodyData::Enum flags, bool flush = false) = 0;

        virtual     PxCudaContextManager*   getCudaContextManager() const = 0;

        virtual     void                setWakeCounter(PxReal wakeCounterValue) = 0;

        virtual     PxReal              getWakeCounter() const = 0;

        virtual     bool                isSleeping() const = 0;

        virtual     void                setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) = 0;

        virtual     void                getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const = 0;


        virtual     PxShape*            getShape() = 0;


        virtual PxTetrahedronMesh*      getCollisionMesh() = 0;

        virtual PxTetrahedronMesh*      getSimulationMesh() = 0;

        virtual PxSoftBodyAuxData* getSoftBodyAuxData() = 0;


        virtual     bool                attachShape(PxShape& shape) = 0;

        virtual     bool                attachSimulationMesh(PxTetrahedronMesh& simulationMesh, PxSoftBodyAuxData& softBodyAuxData) = 0;

        virtual     void                detachShape() = 0;

        virtual     void                detachSimulationMesh() = 0;

        virtual     void                release() = 0;

        virtual     void                addParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) = 0;

        virtual     void                removeParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) = 0;

        virtual     PxU32               addParticleAttachment(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId, const PxVec4& barycentric) = 0;


        virtual     void                removeParticleAttachment(PxPBDParticleSystem* particlesystem, PxU32 handle) = 0;

        virtual     void                addRigidFilter(PxRigidActor* actor, PxU32 vertId) = 0;

        virtual     void                removeRigidFilter(PxRigidActor* actor, PxU32 vertId) = 0;

        virtual     PxU32                   addRigidAttachment(PxRigidActor* actor, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint = NULL) = 0;

        virtual     void                    removeRigidAttachment(PxRigidActor* actor, PxU32 handle) = 0;

        virtual     void                    addTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) = 0;

        virtual     void                    removeTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) = 0;

        virtual     PxU32                   addTetRigidAttachment(PxRigidActor* actor, PxU32 tetIdx, const PxVec4& barycentric, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint = NULL) = 0;

        virtual     void                    addSoftBodyFilter(PxSoftBody* otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1) = 0;

        virtual     void                    removeSoftBodyFilter(PxSoftBody* otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1) = 0;

        virtual     void                    addSoftBodyFilters(PxSoftBody* otherSoftBody, PxU32* otherTetIndices, PxU32* tetIndices, PxU32 tetIndicesSize) = 0;

        virtual     void                    removeSoftBodyFilters(PxSoftBody* otherSoftBody, PxU32* otherTetIndices, PxU32* tetIndices, PxU32 tetIndicesSize) = 0;

        virtual     PxU32                   addSoftBodyAttachment(PxSoftBody* softbody0, PxU32 tetIdx0, const PxVec4& tetBarycentric0, PxU32 tetIdx1, const PxVec4& tetBarycentric1,
                                            PxConeLimitedConstraint* constraint = NULL) = 0;

        virtual     void                    removeSoftBodyAttachment(PxSoftBody* softbody0, PxU32 handle) = 0;

        virtual     void                    addClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) = 0;

        virtual     void                    removeClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) = 0;


        virtual     PxU32                   addClothAttachment(PxFEMCloth* cloth, PxU32 triIdx, const PxVec4& triBarycentric, PxU32 tetIdx, const PxVec4& tetBarycentric,
                                            PxConeLimitedConstraint* constraint = NULL) = 0;

        virtual     void                    removeClothAttachment(PxFEMCloth* cloth, PxU32 handle) = 0;

        virtual     PxBuffer*               getSimPositionInvMassCPU() = 0;

        virtual     PxBuffer*               getKinematicTargetCPU() = 0;
        virtual     PxBuffer*               getSimVelocityInvMassCPU() = 0;

        virtual     PxBuffer*               getPositionInvMassCPU() = 0;

        virtual     PxBuffer*               getRestPositionInvMassCPU() = 0;

        virtual     PxBounds3       getWorldBounds(float inflation = 1.01f) const = 0;

        virtual     PxU32           getGpuSoftBodyIndex() = 0;

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


    protected:
        PX_INLINE                   PxSoftBody(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
        PX_INLINE                   PxSoftBody(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
        virtual     bool            isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxSoftBody", name) || PxActor::isKindOf(name); }
    };

#if PX_VC
#pragma warning(pop)
#endif


#if !PX_DOXYGEN
} // namespace physx
#endif

#endif