include/PxConstraintDesc.h
File members: include/PxConstraintDesc.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_CONSTRAINT_DESC_H
#define PX_CONSTRAINT_DESC_H
#include "PxPhysXConfig.h"
#include "foundation/PxFlags.h"
#include "foundation/PxVec3.h"
#include "foundation/PxTransform.h"
#include "common/PxBase.h"
#if !PX_DOXYGEN
namespace physx { namespace pvdsdk {
#endif
class PvdDataStream;
#if !PX_DOXYGEN
}}
#endif
#if !PX_DOXYGEN
namespace physx
{
#endif
struct Px1DConstraintFlag
{
PX_CUDA_CALLABLE Px1DConstraintFlag(){}
enum Type
{
eSPRING = 1<<0,
eACCELERATION_SPRING = 1<<1,
eRESTITUTION = 1<<2,
eKEEPBIAS = 1<<3,
eOUTPUT_FORCE = 1<<4,
eHAS_DRIVE_LIMIT = 1<<5,
eANGULAR_CONSTRAINT = 1<<6,
eDEPRECATED_DRIVE_ROW = 1<<7
};
};
typedef PxFlags<Px1DConstraintFlag::Type, PxU16> Px1DConstraintFlags;
PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16)
struct PxConstraintSolveHint
{
enum Enum
{
eNONE = 0,
eACCELERATION1 = 256,
eSLERP_SPRING = 258,
eACCELERATION2 = 512,
eACCELERATION3 = 768,
eROTATIONAL_EQUALITY = 1024,
eROTATIONAL_INEQUALITY = 1025,
eEQUALITY = 2048,
eINEQUALITY = 2049
};
};
PX_ALIGN_PREFIX(16)
struct Px1DConstraint
{
PxVec3 linear0;
PxReal geometricError;
PxVec3 angular0;
PxReal velocityTarget;
PxVec3 linear1;
PxReal minImpulse;
PxVec3 angular1;
PxReal maxImpulse;
union
{
struct SpringModifiers
{
PxReal stiffness;
PxReal damping;
} spring;
struct RestitutionModifiers
{
PxReal restitution;
PxReal velocityThreshold;
} bounce;
} mods;
PxU16 flags;
PxU16 solveHint;
PxU32 pad; // for padding only
}
PX_ALIGN_SUFFIX(16);
struct PxConstraintVisualizationFlag
{
enum Enum
{
eLOCAL_FRAMES = 1,
eLIMITS = 2
};
};
PX_ALIGN_PREFIX(16)
struct PxConstraintInvMassScale
{
PxReal linear0;
PxReal angular0;
PxReal linear1;
PxReal angular1;
PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(){}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(PxReal lin0, PxReal ang0, PxReal lin1, PxReal ang1) : linear0(lin0), angular0(ang0), linear1(lin1), angular1(ang1){}
}
PX_ALIGN_SUFFIX(16);
typedef PxU32 (*PxConstraintSolverPrep)(Px1DConstraint* constraints,
PxVec3p& bodyAWorldOffset,
PxU32 maxConstraints,
PxConstraintInvMassScale& invMassScale,
const void* constantBlock,
const PxTransform& bodyAToWorld,
const PxTransform& bodyBToWorld,
bool useExtendedLimits,
PxVec3p& cAtW,
PxVec3p& cBtW);
class PxConstraintVisualizer
{
protected:
virtual ~PxConstraintVisualizer(){}
public:
virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, PxReal value) = 0;
virtual void visualizeAngularLimit(const PxTransform& t0, PxReal lower, PxReal upper) = 0;
virtual void visualizeLimitCone(const PxTransform& t, PxReal tanQSwingY, PxReal tanQSwingZ) = 0;
virtual void visualizeDoubleCone(const PxTransform& t, PxReal angle) = 0;
virtual void visualizeLine(const PxVec3& p0, const PxVec3& p1, PxU32 color) = 0;
};
typedef void (*PxConstraintVisualize)(PxConstraintVisualizer& visualizer,
const void* constantBlock,
const PxTransform& body0Transform,
const PxTransform& body1Transform,
PxU32 flags);
struct PxPvdUpdateType
{
enum Enum
{
CREATE_INSTANCE,
RELEASE_INSTANCE,
UPDATE_ALL_PROPERTIES,
UPDATE_SIM_PROPERTIES
};
};
class PxConstraintConnector
{
public:
virtual void* prepareData() = 0;
virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection,
const PxConstraint* c,
PxPvdUpdateType::Enum updateType) const = 0;
virtual void updateOmniPvdProperties() const = 0;
virtual void onConstraintRelease() = 0;
virtual void onComShift(PxU32 actor) = 0;
virtual void onOriginShift(const PxVec3& shift) = 0;
virtual void* getExternalReference(PxU32& typeID) = 0;
virtual PxBase* getSerializable() = 0;
virtual PxConstraintSolverPrep getPrep() const = 0;
virtual const void* getConstantBlock() const = 0;
virtual void connectToConstraint(PxConstraint*) {}
virtual ~PxConstraintConnector() {}
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif