Havok: Add hkpConstraintInstance stub

This commit is contained in:
Léo Lam 2022-01-17 19:58:19 +01:00
parent adad4553d6
commit a2cde0f0de
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
5 changed files with 353 additions and 0 deletions

View File

@ -65,6 +65,11 @@ add_library(hkStubs OBJECT
Havok/Geometry/Collide/Shapes/hkcdShape.h
Havok/Physics/Constraint/hkpConstraintInstance.h
Havok/Physics/Constraint/Atom/hkpConstraintAtom.h
Havok/Physics/Constraint/Data/hkpConstraintData.h
Havok/Physics/Constraint/Data/hkpConstraintInfo.h
Havok/Physics2012/Collide/Agent/hkpCollisionInput.h
Havok/Physics2012/Collide/Agent/hkpCollisionQualityInfo.h
Havok/Physics2012/Collide/Agent/Collidable/hkpCdBody.h

View File

@ -0,0 +1,90 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
struct hkpConstraintAtom {
public:
enum AtomType {
TYPE_INVALID = 0,
TYPE_BRIDGE, // 1
TYPE_SET_LOCAL_TRANSFORMS, // 2
TYPE_SET_LOCAL_TRANSLATIONS, // 3
TYPE_SET_LOCAL_ROTATIONS, // 4
TYPE_BALL_SOCKET, // 5
TYPE_STIFF_SPRING, // 6
TYPE_LIN, // 7
TYPE_LIN_SOFT, // 8
TYPE_LIN_LIMIT, // 9
TYPE_LIN_FRICTION, // 10
TYPE_LIN_MOTOR, // 11
TYPE_2D_ANG, // 12
TYPE_ANG, // 13
TYPE_ANG_LIMIT, // 14
TYPE_TWIST_LIMIT, // 15
TYPE_CONE_LIMIT, // 16
TYPE_ANG_FRICTION, // 17
TYPE_ANG_MOTOR, // 18
TYPE_RAGDOLL_MOTOR, // 19
TYPE_PULLEY, // 20
TYPE_RACK_AND_PINION, // 21
TYPE_COG_WHEEL, // 22
TYPE_SETUP_STABILIZATION, // 23
TYPE_3D_ANG, // 24
TYPE_DEFORMABLE_3D_LIN, // 25
TYPE_DEFORMABLE_3D_ANG, // 26
TYPE_OVERWRITE_PIVOT,
TYPE_WHEEL_FRICTION, // 28
TYPE_CONTACT,
FIRST_MODIFIER_TYPE,
TYPE_MODIFIER_SOFT_CONTACT = FIRST_MODIFIER_TYPE,
TYPE_MODIFIER_MASS_CHANGER,
TYPE_MODIFIER_VISCOUS_SURFACE,
TYPE_MODIFIER_MOVING_SURFACE,
TYPE_MODIFIER_IGNORE_CONSTRAINT,
TYPE_MODIFIER_CENTER_OF_MASS_CHANGER,
LAST_MODIFIER_TYPE = TYPE_MODIFIER_CENTER_OF_MASS_CHANGER,
TYPE_MAX
};
enum CallbackRequest {
CALLBACK_REQUEST_NONE = 0,
CALLBACK_REQUEST_NEW_CONTACT_POINT = 1,
CALLBACK_REQUEST_SETUP_PPU_ONLY = 2,
CALLBACK_REQUEST_SETUP_CALLBACK = 4,
CALLBACK_REQUEST_CONTACT_POINT_CALLBACK = 8
};
enum SolvingMethod {
METHOD_STABILIZED = 0,
METHOD_OLD = 1,
};
HK_DECLARE_CLASS_ALLOCATOR(hkpConstraintAtom)
HK_DECLARE_REFLECTION()
hkpConstraintAtom() = delete;
explicit hkpConstraintAtom(hkFinishLoadedObjectFlag f) {}
HK_FORCE_INLINE AtomType getType() const { return m_type; }
HK_FORCE_INLINE int isModifierType() const { return m_type >= FIRST_MODIFIER_TYPE; }
protected:
hkpConstraintAtom(AtomType type) : m_type(type) {}
public:
hkEnum<AtomType, hkUint16> m_type;
};

View File

@ -0,0 +1,103 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics/Constraint/Atom/hkpConstraintAtom.h>
#include <Havok/Physics/Constraint/Data/hkpConstraintInfo.h>
class hkpConstraintQueryIn;
class hkpConstraintQueryOut;
struct hkpConstraintRuntime;
class hkpSolverResults;
class hkpConstraintData : public hkReferencedObject {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpConstraintData)
HK_DECLARE_REFLECTION()
enum ConstraintType {
CONSTRAINT_TYPE_BALLANDSOCKET = 0,
CONSTRAINT_TYPE_HINGE = 1,
CONSTRAINT_TYPE_LIMITEDHINGE = 2,
CONSTRAINT_TYPE_POINTTOPATH = 3,
CONSTRAINT_TYPE_PRISMATIC = 6,
CONSTRAINT_TYPE_RAGDOLL = 7,
CONSTRAINT_TYPE_STIFFSPRING = 8,
CONSTRAINT_TYPE_WHEEL = 9,
CONSTRAINT_TYPE_GENERIC = 10,
CONSTRAINT_TYPE_CONTACT = 11,
CONSTRAINT_TYPE_BREAKABLE = 12,
CONSTRAINT_TYPE_MALLEABLE = 13,
CONSTRAINT_TYPE_POINTTOPLANE = 14,
CONSTRAINT_TYPE_PULLEY = 15,
CONSTRAINT_TYPE_ROTATIONAL = 16,
CONSTRAINT_TYPE_HINGE_LIMITS = 18,
CONSTRAINT_TYPE_RAGDOLL_LIMITS = 19,
CONSTRAINT_TYPE_CUSTOM = 20,
CONSTRAINT_TYPE_RACK_AND_PINION = 21,
CONSTRAINT_TYPE_COG_WHEEL = 22,
CONSTRAINT_TYPE_FIXED = 23,
CONSTRAINT_TYPE_DEFORMABLE_FIXED = 24,
CONSTRAINT_TYPE_LINEAR_SLACK = 25,
BEGIN_CONSTRAINT_CHAIN_TYPES = 100,
CONSTRAINT_TYPE_STIFF_SPRING_CHAIN = 100,
CONSTRAINT_TYPE_BALL_SOCKET_CHAIN = 101,
CONSTRAINT_TYPE_POWERED_CHAIN = 102
};
struct ConstraintInfo : hkpConstraintInfo {
HK_DECLARE_CLASS_ALLOCATOR(ConstraintType)
HK_FORCE_INLINE ConstraintInfo() { m_extraSchemaSize = 0; }
hkpConstraintAtom* m_atoms;
hkUint32 m_sizeOfAllAtoms;
hkUint32 m_extraSchemaSize;
};
struct RuntimeInfo {
HK_DECLARE_CLASS_ALLOCATOR(RuntimeInfo)
int m_sizeOfExternalRuntime;
int m_numSolverResults;
};
HK_FORCE_INLINE hkpConstraintData();
explicit hkpConstraintData(hkFinishLoadedObjectFlag f);
HK_FORCE_INLINE ~hkpConstraintData() override;
virtual int getType() const = 0;
virtual void getConstraintInfo(ConstraintInfo& infoOut) const = 0;
virtual hkBool isValid() const = 0;
virtual void setMaximumLinearImpulse(hkReal maxLinearImpulse);
virtual void setMaximumAngularImpulse(hkReal maxAngularImpulse);
virtual void setBreachImpulse(hkReal breachImpulse);
virtual hkReal getMaximumLinearImpulse() const;
virtual hkReal getMaximumAngularImpulse() const;
virtual hkReal getBreachImpulse() const;
virtual void setBodyToNotify(int bodyIndex);
virtual hkUint8 getNotifiedBodyIndex() const;
virtual void setSolvingMethod(hkpConstraintAtom::SolvingMethod method);
virtual hkResult setInertiaStabilizationFactor(const hkReal inertiaStabilizationFactor);
virtual hkResult getInertiaStabilizationFactor(hkReal& inertiaStabilizationFactorOut) const;
virtual void getRuntimeInfo(hkBool wantRuntime, RuntimeInfo& infoOut) const = 0;
virtual hkpSolverResults* getSolverResults(hkpConstraintRuntime* runtime) const;
virtual void addInstance(hkpConstraintRuntime* runtime, int sizeOfRuntime) const;
virtual void buildJacobian(const hkpConstraintQueryIn& in, hkpConstraintQueryOut& out);
virtual hkBool isBuildJacobianCallbackRequired() const { return false; }
virtual void buildJacobianCallback(const hkpConstraintQueryIn& in,
const hkpConstraintQueryOut& out);
static void getConstraintInfoUtil(const hkpConstraintAtom* atoms, int sizeOfAllAtoms,
ConstraintInfo& infoOut);
hkUlong m_userData;
};
inline hkpConstraintData::hkpConstraintData() {
m_userData = 0;
}
inline hkpConstraintData::~hkpConstraintData() = default;

View File

@ -0,0 +1,12 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
struct hkpConstraintInfo {
HK_DECLARE_CLASS_ALLOCATOR(hkpConstraintInfo)
int m_maxSizeOfSchema;
int m_sizeOfSchemas;
int m_numSolverResults;
int m_numSolverElemTemps;
};

View File

@ -0,0 +1,143 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
class hkpConstraintData;
class hkpConstraintListener;
class hkpConstraintOwner;
struct hkpConstraintRuntime;
class hkpEntity;
class hkpRigidBody;
class hkpSimulationIsland;
class hkpWorld;
class hkpConstraintInstance : public hkReferencedObject {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpConstraintInstance)
HK_DECLARE_REFLECTION()
enum ConstraintPriority {
PRIORITY_INVALID,
PRIORITY_PSI,
PRIORITY_SIMPLIFIED_TOI_UNUSED,
PRIORITY_TOI,
PRIORITY_TOI_HIGHER,
PRIORITY_TOI_FORCED,
NUM_PRIORITIES
};
enum InstanceType { TYPE_NORMAL = 0, TYPE_CHAIN = 1, TYPE_DISABLE_SPU = 2 };
enum AddReferences {
DO_NOT_ADD_REFERENCES,
DO_ADD_REFERENCES,
};
enum CloningMode {
CLONE_SHALLOW_IF_NOT_CONSTRAINED_TO_WORLD,
CLONE_DATAS_WITH_MOTORS,
CLONE_FORCE_SHALLOW
};
enum OnDestructionRemapInfo {
ON_DESTRUCTION_REMAP = 0,
ON_DESTRUCTION_REMOVE = 1,
ON_DESTRUCTION_RESET_REMOVE = 2,
};
hkpConstraintInstance(hkpEntity* entityA, hkpEntity* entityB, hkpConstraintData* data,
ConstraintPriority priority = PRIORITY_PSI);
explicit hkpConstraintInstance(hkFinishLoadedObjectFlag f)
: hkReferencedObject(f), m_name(f), m_uid(0xfffffff0) {}
~hkpConstraintInstance() override;
hkpConstraintInstance* clone(hkpEntity* newEntityA, hkpEntity* newEntityB,
CloningMode mode) const;
inline hkpEntity* getEntityA() const;
inline hkpEntity* getEntity(int index) const;
void replaceEntity(hkpEntity* oldEntity, hkpEntity* newEntity);
inline hkpEntity* getEntityB() const;
inline hkpRigidBody* getRigidBodyA() const;
inline hkpRigidBody* getRigidBodyB() const;
hkBool isConstrainedToWorld() const;
inline hkpEntity* getOtherEntity(const hkpEntity* entity) const;
hkpSimulationIsland* getSimulationIsland();
inline const hkpConstraintData* getData() const;
inline hkpConstraintData* getDataRw() const;
void getPivotsInWorld(hkVector4& pivotAinW, hkVector4& pivotBinW) const;
void addConstraintListener(hkpConstraintListener* listener);
void removeConstraintListener(hkpConstraintListener* listener);
void transform(const hkTransform& transformation);
inline struct hkpModifierConstraintAtom* getConstraintModifiers() const;
inline hkpConstraintRuntime* getRuntime() const;
inline void setWantRuntime(hkBool b);
inline hkBool getWantRuntime() const;
inline hkUlong getUserData() const;
inline void setUserData(hkUlong data);
inline ConstraintPriority getPriority() const;
void setPriority(ConstraintPriority priority);
inline const char* getName() const;
inline void setName(const char* name);
void setVirtualMassInverse(const hkVector4& invMassA, const hkVector4& invMassB);
void disable(void);
void enable(void);
void setEnabled(hkBool state);
hkBool isEnabled(void);
inline hkpConstraintOwner* getOwner() const;
inline hkpEntity* getMasterEntity() const;
inline hkpEntity* getSlaveEntity() const;
virtual void entityAddedCallback(hkpEntity* entity);
virtual void entityRemovedCallback(hkpEntity* entity);
virtual void entityDeletedCallback(hkpEntity* entity);
inline void setOwner(hkpConstraintOwner* island);
inline struct hkConstraintInternal* getInternal();
void pointNullsToFixedRigidBody();
void setFixedRigidBodyPointersToZero(hkpWorld* world);
virtual InstanceType getType() const { return TYPE_NORMAL; }
private:
friend class hkpWorldConstraintUtil;
friend class hkpSimpleConstraintContactMgr;
friend class hkpSaveContactPointsUtil;
hkpConstraintInstance() {}
protected:
explicit hkpConstraintInstance(ConstraintPriority priority);
friend class hkpSimpleContactConstraintData;
friend class hkpSimulationIsland;
hkpConstraintOwner* m_owner;
hkpConstraintData* m_data;
struct hkpModifierConstraintAtom* m_constraintModifiers;
hkpEntity* m_entities[2];
public:
hkEnum<ConstraintPriority, hkUint8> m_priority;
protected:
hkBool m_wantRuntime;
public:
hkEnum<OnDestructionRemapInfo, hkUint8> m_destructionRemapInfo;
hkSmallArray<hkpConstraintListener*> m_listeners;
hkStringPtr m_name;
hkUlong m_userData;
struct hkConstraintInternal* m_internal;
hkUint32 m_uid;
};