Havok: Add hkpResponseModifier

This commit is contained in:
Léo Lam 2022-01-07 18:57:06 +01:00
parent d7d96a5434
commit 16ae321058
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
3 changed files with 67 additions and 1 deletions

View File

@ -95,6 +95,7 @@ add_library(hkStubs OBJECT
Havok/Physics2012/Collide/Shape/Query/hkpShapeRayCastInput.h
Havok/Physics2012/Collide/Util/Welding/hkpWeldingUtility.h
Havok/Physics2012/Dynamics/Collide/hkpResponseModifier.h
Havok/Physics2012/Dynamics/Common/hkpMaterial.h
Havok/Physics2012/Dynamics/Common/hkpProperty.h
Havok/Physics2012/Dynamics/Entity/hkpEntity.h

View File

@ -0,0 +1,64 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
class hkpConstraintInstance;
class hkpConstraintOwner;
class hkpDynamicsContactMgr;
class hkpRigidBody;
class hkpResponseModifier {
public:
enum Flags {
MASS_SCALING = 1,
CENTER_OF_MASS_DISPLACEMENT = 2,
SURFACE_VELOCITY = 4,
IMPULSE_SCALING = 8,
VISCOUS_SURFACE = 16,
ADDITIONAL_SIZE_MODIFIERS = MASS_SCALING | CENTER_OF_MASS_DISPLACEMENT | SURFACE_VELOCITY,
};
static void setInvMassScalingForContact(hkpDynamicsContactMgr* manager, hkpRigidBody* bodyA,
hkpRigidBody* bodyB,
hkpConstraintOwner& constraintOwner,
const hkVector4& factorA, const hkVector4& factorB);
static void setInvMassScalingForContact(hkpDynamicsContactMgr* manager, hkpRigidBody* body,
hkpConstraintOwner& constraintOwner,
const hkVector4& factor);
static void setCenterOfMassDisplacementForContact(hkpDynamicsContactMgr* manager,
hkpRigidBody* bodyA, hkpRigidBody* bodyB,
hkpConstraintOwner& constraintOwner,
const hkVector4& displacementA,
const hkVector4& displacementB);
static void setImpulseScalingForContact(hkpDynamicsContactMgr* manager, hkpRigidBody* bodyA,
hkpRigidBody* bodyB,
hkpConstraintOwner& constraintOwner,
hkReal usedImpulseFraction, hkReal maxAcceleration);
static void setSurfaceVelocity(hkpDynamicsContactMgr* manager, hkpRigidBody* body,
hkpConstraintOwner& constraintOwner, const hkVector4& velWorld);
static void clearSurfaceVelocity(hkpDynamicsContactMgr* manager,
hkpConstraintOwner& constraintOwner, hkpRigidBody* body);
static void setLowSurfaceViscosity(hkpDynamicsContactMgr* manager,
hkpConstraintOwner& constraintOwner);
static void disableConstraint(hkpConstraintInstance* instance,
hkpConstraintOwner& constraintOwner);
static void enableConstraint(hkpConstraintInstance* instance,
hkpConstraintOwner& constraintOwner);
HK_FORCE_INLINE static hkUint16 getAdditionalSchemaSize(hkUint8 flags);
static const hkUint16 tableOfAdditionalSchemaSizes[];
};
inline hkUint16 hkpResponseModifier::getAdditionalSchemaSize(hkUint8 flags) {
return tableOfAdditionalSchemaSizes[flags & ADDITIONAL_SIZE_MODIFIERS];
}

View File

@ -1,4 +1,5 @@
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
#include <Havok/Physics2012/Dynamics/Collide/hkpResponseModifier.h>
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
#include "KingSystem/Physics/System/physMemSystem.h"
@ -17,7 +18,7 @@ RigidBody::RigidBody(u32 a, u32 mass_scaling, hkpRigidBody* hk_body, const sead:
mHkBody->enableDeactivation(true);
mHkBody->getCollidableRw()->m_allowedPenetrationDepth = 0.1f;
if (mFlags.isOff(Flag1::MassScaling)) {
mHkBody->m_responseModifierFlags |= 1;
mHkBody->m_responseModifierFlags |= hkpResponseModifier::Flags::MASS_SCALING;
}
mFlags.change(Flag1::_80, _b4 == 5);