mirror of https://github.com/zeldaret/botw.git
Havok: Add more ragdoll header stubs
This commit is contained in:
parent
f85ac9793d
commit
a6f37367d2
|
@ -8,7 +8,9 @@ add_library(hkStubs OBJECT
|
||||||
Havok/Animation/Animation/Mapper/hkaSkeletonMapperData.h
|
Havok/Animation/Animation/Mapper/hkaSkeletonMapperData.h
|
||||||
Havok/Animation/Animation/Motion/hkaAnimatedReferenceFrame.h
|
Havok/Animation/Animation/Motion/hkaAnimatedReferenceFrame.h
|
||||||
Havok/Animation/Animation/Rig/hkaBone.h
|
Havok/Animation/Animation/Rig/hkaBone.h
|
||||||
|
Havok/Animation/Animation/Rig/hkaBoneAttachment.h
|
||||||
Havok/Animation/Animation/Rig/hkaSkeleton.h
|
Havok/Animation/Animation/Rig/hkaSkeleton.h
|
||||||
|
Havok/Animation/Animation/Rig/hkaPose.h
|
||||||
Havok/Animation/Physics2012Bridge/Instance/hkaRagdollInstance.h
|
Havok/Animation/Physics2012Bridge/Instance/hkaRagdollInstance.h
|
||||||
|
|
||||||
Havok/Common/Base/hkBase.h
|
Havok/Common/Base/hkBase.h
|
||||||
|
@ -27,6 +29,8 @@ add_library(hkStubs OBJECT
|
||||||
Havok/Common/Base/Math/Matrix/hkMatrix3.h
|
Havok/Common/Base/Math/Matrix/hkMatrix3.h
|
||||||
Havok/Common/Base/Math/Matrix/hkMatrix3f.h
|
Havok/Common/Base/Math/Matrix/hkMatrix3f.h
|
||||||
Havok/Common/Base/Math/Matrix/hkMatrix3f.inl
|
Havok/Common/Base/Math/Matrix/hkMatrix3f.inl
|
||||||
|
Havok/Common/Base/Math/Matrix/hkMatrix4.h
|
||||||
|
Havok/Common/Base/Math/Matrix/hkMatrix4f.h
|
||||||
Havok/Common/Base/Math/Matrix/hkRotation.h
|
Havok/Common/Base/Math/Matrix/hkRotation.h
|
||||||
Havok/Common/Base/Math/Matrix/hkRotationf.h
|
Havok/Common/Base/Math/Matrix/hkRotationf.h
|
||||||
Havok/Common/Base/Math/Matrix/hkTransform.h
|
Havok/Common/Base/Math/Matrix/hkTransform.h
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Havok/Common/Base/hkBase.h>
|
||||||
|
|
||||||
|
class hkaBoneAttachment : public hkReferencedObject {
|
||||||
|
public:
|
||||||
|
HK_DECLARE_CLASS_ALLOCATOR(hkaBoneAttachment)
|
||||||
|
HK_DECLARE_REFLECTION()
|
||||||
|
|
||||||
|
inline hkaBoneAttachment() : m_originalSkeletonName(nullptr), m_boneIndex(-1) {}
|
||||||
|
|
||||||
|
HK_FORCE_INLINE explicit hkaBoneAttachment(hkFinishLoadedObjectFlag f)
|
||||||
|
: hkReferencedObject(f), m_originalSkeletonName(f), m_attachment(f), m_name(f) {}
|
||||||
|
|
||||||
|
// Optional.
|
||||||
|
hkStringPtr m_originalSkeletonName;
|
||||||
|
hkMatrix4 m_boneFromAttachment;
|
||||||
|
hkRefVariant m_attachment;
|
||||||
|
hkStringPtr m_name;
|
||||||
|
hkInt16 m_boneIndex;
|
||||||
|
};
|
|
@ -0,0 +1,319 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Havok/Animation/Animation/Rig/hkaSkeleton.h>
|
||||||
|
#include <Havok/Common/Base/hkBase.h>
|
||||||
|
|
||||||
|
class hkaPose {
|
||||||
|
public:
|
||||||
|
HK_DECLARE_CLASS_ALLOCATOR(hkaPose)
|
||||||
|
|
||||||
|
enum PoseSpace { MODEL_SPACE, LOCAL_SPACE };
|
||||||
|
|
||||||
|
HK_FORCE_INLINE explicit hkaPose(const hkaSkeleton* skeleton);
|
||||||
|
HK_FORCE_INLINE hkaPose(const hkaSkeleton* skeleton, void* preallocatedMemory);
|
||||||
|
|
||||||
|
HK_FORCE_INLINE static int getRequiredMemorySize(const hkaSkeleton* skeleton);
|
||||||
|
|
||||||
|
hkaPose(PoseSpace space, const hkaSkeleton* skeleton, const hkArrayBase<hkQsTransform>& pose);
|
||||||
|
hkaPose(PoseSpace space, const hkaSkeleton* skeleton, const hkQsTransform* pose, int numBones);
|
||||||
|
|
||||||
|
enum PropagateOrNot { DONT_PROPAGATE = 0, PROPAGATE = 1 };
|
||||||
|
|
||||||
|
HK_FORCE_INLINE const hkaSkeleton* getSkeleton() const;
|
||||||
|
|
||||||
|
const hkArray<hkQsTransform>& getSyncedPoseLocalSpace() const;
|
||||||
|
const hkArray<hkQsTransform>& getSyncedPoseModelSpace() const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE const hkArray<hkReal>& getFloatSlotValues() const;
|
||||||
|
|
||||||
|
void setPoseLocalSpace(const hkArrayBase<hkQsTransform>& poseLocal);
|
||||||
|
void setPoseModelSpace(const hkArrayBase<hkQsTransform>& poseModel);
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void setFloatSlotValues(const hkArrayBase<hkReal>& floatSlotValues);
|
||||||
|
|
||||||
|
HK_FORCE_INLINE const hkQsTransform& getBoneLocalSpace(int boneIdx) const;
|
||||||
|
HK_FORCE_INLINE const hkQsTransform& getBoneModelSpace(int boneIdx) const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE hkReal getFloatSlotValue(int floatSlotIdx) const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void setBoneLocalSpace(int boneIdx, const hkQsTransform& boneLocal);
|
||||||
|
HK_FORCE_INLINE void setBoneModelSpace(int boneIdx, const hkQsTransform& boneModel,
|
||||||
|
PropagateOrNot propagateOrNot);
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void setFloatSlotValue(int floatSlotIdx, hkReal value);
|
||||||
|
|
||||||
|
void syncLocalSpace() const;
|
||||||
|
void syncModelSpace() const;
|
||||||
|
inline void syncAll() const;
|
||||||
|
|
||||||
|
hkQsTransform& accessBoneLocalSpace(int boneIdx);
|
||||||
|
hkQsTransform& accessBoneModelSpace(int boneIdx,
|
||||||
|
PropagateOrNot propagateOrNot = DONT_PROPAGATE);
|
||||||
|
|
||||||
|
hkArray<hkQsTransform>& accessSyncedPoseLocalSpace();
|
||||||
|
hkArray<hkQsTransform>& accessSyncedPoseModelSpace();
|
||||||
|
|
||||||
|
hkArray<hkQsTransform>& accessUnsyncedPoseLocalSpace();
|
||||||
|
hkArray<hkQsTransform>& accessUnsyncedPoseModelSpace();
|
||||||
|
|
||||||
|
HK_FORCE_INLINE hkArray<hkReal>& getFloatSlotValues();
|
||||||
|
|
||||||
|
void setToReferencePose();
|
||||||
|
|
||||||
|
void enforceSkeletonConstraintsLocalSpace();
|
||||||
|
void enforceSkeletonConstraintsModelSpace();
|
||||||
|
|
||||||
|
void getModelSpaceAabb(class hkAabb& aabbOut) const;
|
||||||
|
|
||||||
|
inline hkaPose& operator=(const hkaPose& other);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init(PoseSpace space, const hkaSkeleton* skeleton, const hkArrayBase<hkQsTransform>& pose);
|
||||||
|
|
||||||
|
using hkaPoseFlag = hkUint32;
|
||||||
|
|
||||||
|
const hkaSkeleton* m_skeleton;
|
||||||
|
|
||||||
|
mutable hkArray<hkQsTransform> m_localPose;
|
||||||
|
mutable hkArray<hkQsTransform> m_modelPose;
|
||||||
|
mutable hkArray<hkaPoseFlag> m_boneFlags;
|
||||||
|
|
||||||
|
mutable hkBool m_modelInSync;
|
||||||
|
mutable hkBool m_localInSync;
|
||||||
|
|
||||||
|
hkArray<hkReal> m_floatSlotValues;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
F_BONE_LOCAL_DIRTY = 0x1,
|
||||||
|
F_BONE_MODEL_DIRTY = 0x2,
|
||||||
|
F_BONE_INTERNAL_FLAG1 = 0x4,
|
||||||
|
F_BONE_INTERNAL_FLAG2 = 0x8,
|
||||||
|
F_BONE_INTERNAL_FLAG3 = 0x10,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
M_BONE_INTERNAL_FLAGS =
|
||||||
|
F_BONE_INTERNAL_FLAG1 | F_BONE_INTERNAL_FLAG2 | F_BONE_INTERNAL_FLAG3
|
||||||
|
};
|
||||||
|
|
||||||
|
HK_FORCE_INLINE int isFlagOn(int boneIdx, hkaPoseFlag enumToCheck) const;
|
||||||
|
HK_FORCE_INLINE void setFlag(int boneIdx, hkaPoseFlag enumToCheck) const;
|
||||||
|
HK_FORCE_INLINE void clearFlag(int boneIdx, hkaPoseFlag enumToCheck) const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE int isFlagOnExplicit(hkaPoseFlag flag, hkaPoseFlag enumToCheck) const;
|
||||||
|
HK_FORCE_INLINE void setFlagExplicit(hkaPoseFlag& flag, hkaPoseFlag enumToCheck) const;
|
||||||
|
HK_FORCE_INLINE void clearFlagExplicit(hkaPoseFlag& flag, hkaPoseFlag enumToCheck) const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void clearInternalFlags() const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void makeAllChildrenLocalSpace(int boneIdx) const;
|
||||||
|
HK_FORCE_INLINE void makeFirstChildrenModelSpace(int boneIdx) const;
|
||||||
|
|
||||||
|
const hkQsTransform& calculateBoneModelSpace(int boneIdx) const;
|
||||||
|
|
||||||
|
void setNonInitializedFlags();
|
||||||
|
hkBool checkInternalFlagIsClear(hkaPoseFlag flag) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
hkBool checkPoseValidity() const;
|
||||||
|
hkBool checkPoseTransformsValidity() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline hkaPose::hkaPose(const hkaSkeleton* skeleton)
|
||||||
|
: m_skeleton(skeleton), m_modelInSync(false), m_localInSync(false) {
|
||||||
|
const int numBones = m_skeleton->m_bones.getSize();
|
||||||
|
const int numBonesRoundedUp = HK_NEXT_MULTIPLE_OF(4, numBones);
|
||||||
|
|
||||||
|
m_modelPose.reserveExactly(numBonesRoundedUp);
|
||||||
|
m_localPose.reserveExactly(numBonesRoundedUp);
|
||||||
|
m_boneFlags.reserveExactly(numBonesRoundedUp);
|
||||||
|
m_modelPose.setSize(numBones);
|
||||||
|
m_localPose.setSize(numBones);
|
||||||
|
m_boneFlags.setSize(numBones);
|
||||||
|
|
||||||
|
const int numSlots = m_skeleton->m_floatSlots.getSize();
|
||||||
|
const int numSlotsRoundedUp = HK_NEXT_MULTIPLE_OF(4, numSlots);
|
||||||
|
m_floatSlotValues.reserveExactly(numSlotsRoundedUp);
|
||||||
|
m_floatSlotValues.setSize(numSlots, hkReal(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkaPose::hkaPose(const hkaSkeleton* skeleton, void* preallocatedMemory)
|
||||||
|
: m_skeleton(skeleton), m_localPose(reinterpret_cast<hkQsTransform*>(preallocatedMemory),
|
||||||
|
skeleton->m_bones.getSize(), skeleton->m_bones.getSize()),
|
||||||
|
m_modelPose(m_localPose.begin() + skeleton->m_bones.getSize(), skeleton->m_bones.getSize(),
|
||||||
|
skeleton->m_bones.getSize()),
|
||||||
|
m_boneFlags(reinterpret_cast<hkaPoseFlag*>(m_modelPose.begin() + skeleton->m_bones.getSize()),
|
||||||
|
skeleton->m_bones.getSize(), skeleton->m_bones.getSize()),
|
||||||
|
m_modelInSync(false), m_localInSync(false),
|
||||||
|
m_floatSlotValues(
|
||||||
|
reinterpret_cast<hkReal*>(m_boneFlags.begin() + skeleton->m_bones.getSize()),
|
||||||
|
skeleton->m_floatSlots.getSize(),
|
||||||
|
HK_NEXT_MULTIPLE_OF(4, skeleton->m_floatSlots.getSize())) {}
|
||||||
|
|
||||||
|
inline int hkaPose::getRequiredMemorySize(const hkaSkeleton* skeleton) {
|
||||||
|
const int numBonesRoundedUp = HK_NEXT_MULTIPLE_OF(4, skeleton->m_bones.getSize());
|
||||||
|
|
||||||
|
const int floatSizeRoundedUp = HK_NEXT_MULTIPLE_OF(4, skeleton->m_floatSlots.getSize());
|
||||||
|
|
||||||
|
const int totalSize =
|
||||||
|
numBonesRoundedUp * (2 * hkSizeOf(hkQsTransform) + hkSizeOf(hkaPoseFlag)) +
|
||||||
|
floatSizeRoundedUp * hkSizeOf(hkReal);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkaSkeleton* hkaPose::getSkeleton() const {
|
||||||
|
return m_skeleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkArray<hkReal>& hkaPose::getFloatSlotValues() const {
|
||||||
|
return m_floatSlotValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::setFloatSlotValues(const hkArrayBase<hkReal>& floatSlotValues) {
|
||||||
|
m_floatSlotValues = floatSlotValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkQsTransform& hkaPose::getBoneLocalSpace(int boneIdx) const {
|
||||||
|
if (!isFlagOn(boneIdx, F_BONE_LOCAL_DIRTY))
|
||||||
|
return m_localPose[boneIdx];
|
||||||
|
|
||||||
|
const hkQsTransform& modelFromBone = m_modelPose[boneIdx];
|
||||||
|
|
||||||
|
const hkInt16 parentIdx = m_skeleton->m_parentIndices[boneIdx];
|
||||||
|
|
||||||
|
if (parentIdx != -1) {
|
||||||
|
const hkQsTransform& modelFromParent = getBoneModelSpace(parentIdx);
|
||||||
|
m_localPose[boneIdx].setMulInverseMul(modelFromParent, modelFromBone);
|
||||||
|
} else {
|
||||||
|
m_localPose[boneIdx] = modelFromBone;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearFlag(boneIdx, F_BONE_LOCAL_DIRTY);
|
||||||
|
|
||||||
|
return m_localPose[boneIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkQsTransform& hkaPose::getBoneModelSpace(int boneIdx) const {
|
||||||
|
if (isFlagOn(boneIdx, F_BONE_MODEL_DIRTY))
|
||||||
|
return calculateBoneModelSpace(boneIdx);
|
||||||
|
return m_modelPose[boneIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkReal hkaPose::getFloatSlotValue(int floatSlotIdx) const {
|
||||||
|
return m_floatSlotValues[floatSlotIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::setBoneLocalSpace(int boneIdx, const hkQsTransform& boneLocal) {
|
||||||
|
makeAllChildrenLocalSpace(boneIdx);
|
||||||
|
m_localPose[boneIdx] = boneLocal;
|
||||||
|
m_boneFlags[boneIdx] = F_BONE_MODEL_DIRTY;
|
||||||
|
m_modelInSync = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::setBoneModelSpace(int boneIdx, const hkQsTransform& boneModel,
|
||||||
|
hkaPose::PropagateOrNot propagateOrNot) {
|
||||||
|
if (propagateOrNot)
|
||||||
|
makeAllChildrenLocalSpace(boneIdx);
|
||||||
|
else
|
||||||
|
makeFirstChildrenModelSpace(boneIdx);
|
||||||
|
|
||||||
|
m_modelPose[boneIdx] = boneModel;
|
||||||
|
m_boneFlags[boneIdx] = F_BONE_LOCAL_DIRTY;
|
||||||
|
m_localInSync = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::setFloatSlotValue(int floatSlotIdx, hkReal value) {
|
||||||
|
m_floatSlotValues[floatSlotIdx] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::syncAll() const {
|
||||||
|
syncLocalSpace();
|
||||||
|
syncModelSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkArray<hkReal>& hkaPose::getFloatSlotValues() {
|
||||||
|
return m_floatSlotValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkaPose& hkaPose::operator=(const hkaPose& other) {
|
||||||
|
m_skeleton = other.m_skeleton;
|
||||||
|
m_localPose = other.m_localPose;
|
||||||
|
m_modelPose = other.m_modelPose;
|
||||||
|
m_boneFlags = other.m_boneFlags;
|
||||||
|
m_modelInSync = other.m_modelInSync;
|
||||||
|
m_localInSync = other.m_localInSync;
|
||||||
|
m_floatSlotValues = other.m_floatSlotValues;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int hkaPose::isFlagOn(int boneIdx, hkaPose::hkaPoseFlag enumToCheck) const {
|
||||||
|
return m_boneFlags[boneIdx] & enumToCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::setFlag(int boneIdx, hkaPose::hkaPoseFlag enumToCheck) const {
|
||||||
|
m_boneFlags[boneIdx] |= enumToCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::clearFlag(int boneIdx, hkaPose::hkaPoseFlag enumToCheck) const {
|
||||||
|
m_boneFlags[boneIdx] &= static_cast<hkaPoseFlag>(~enumToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int hkaPose::isFlagOnExplicit(hkaPose::hkaPoseFlag flag,
|
||||||
|
hkaPose::hkaPoseFlag enumToCheck) const {
|
||||||
|
return int(flag & enumToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::setFlagExplicit(hkaPose::hkaPoseFlag& flag,
|
||||||
|
hkaPose::hkaPoseFlag enumToCheck) const {
|
||||||
|
flag |= enumToCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::clearFlagExplicit(hkaPose::hkaPoseFlag& flag,
|
||||||
|
hkaPose::hkaPoseFlag enumToCheck) const {
|
||||||
|
flag &= static_cast<hkaPoseFlag>(~enumToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::clearInternalFlags() const {
|
||||||
|
const int numBones = m_boneFlags.getSize();
|
||||||
|
for (int i = 0; i < numBones; ++i)
|
||||||
|
m_boneFlags[i] &= (~M_BONE_INTERNAL_FLAGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::makeAllChildrenLocalSpace(int boneIdx) const {
|
||||||
|
const int numBones = m_skeleton->m_bones.getSize();
|
||||||
|
|
||||||
|
setFlag(boneIdx, F_BONE_INTERNAL_FLAG1);
|
||||||
|
|
||||||
|
for (int i = boneIdx + 1; i < numBones; ++i) {
|
||||||
|
const hkInt16 parentId = m_skeleton->m_parentIndices[i];
|
||||||
|
if (parentId != -1 && isFlagOn(parentId, F_BONE_INTERNAL_FLAG1)) {
|
||||||
|
getBoneLocalSpace(i);
|
||||||
|
setFlag(i, F_BONE_INTERNAL_FLAG1);
|
||||||
|
m_modelInSync = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = boneIdx + 1; i < numBones; ++i) {
|
||||||
|
hkaPoseFlag f = m_boneFlags[i];
|
||||||
|
if (isFlagOnExplicit(f, F_BONE_INTERNAL_FLAG1)) {
|
||||||
|
setFlagExplicit(f, F_BONE_MODEL_DIRTY);
|
||||||
|
clearFlagExplicit(f, F_BONE_INTERNAL_FLAG1);
|
||||||
|
m_boneFlags[i] = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkaPose::makeFirstChildrenModelSpace(int boneIdx) const {
|
||||||
|
const int numBones = m_skeleton->m_bones.getSize();
|
||||||
|
|
||||||
|
for (int i = boneIdx + 1; i < numBones; ++i) {
|
||||||
|
const hkInt16 parentId = m_skeleton->m_parentIndices[i];
|
||||||
|
if (parentId == boneIdx) {
|
||||||
|
getBoneModelSpace(i); // sync model
|
||||||
|
m_boneFlags[i] = F_BONE_LOCAL_DIRTY;
|
||||||
|
m_localInSync = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -122,6 +122,8 @@ public:
|
||||||
|
|
||||||
HK_FORCE_INLINE void clearAndDeallocate();
|
HK_FORCE_INLINE void clearAndDeallocate();
|
||||||
HK_FORCE_INLINE void pushBack(const T& e);
|
HK_FORCE_INLINE void pushBack(const T& e);
|
||||||
|
HK_FORCE_INLINE hkResult reserve(int size);
|
||||||
|
HK_FORCE_INLINE hkResult reserveExactly(int size);
|
||||||
HK_FORCE_INLINE void setSize(int size);
|
HK_FORCE_INLINE void setSize(int size);
|
||||||
HK_FORCE_INLINE void setSize(int size, const T& fill);
|
HK_FORCE_INLINE void setSize(int size, const T& fill);
|
||||||
|
|
||||||
|
@ -425,6 +427,16 @@ inline void hkArray<T, Allocator>::setSize(int size, const T& fill) {
|
||||||
this->_setSize(AllocatorType().get(), size, fill);
|
this->_setSize(AllocatorType().get(), size, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename Allocator>
|
||||||
|
inline hkResult hkArray<T, Allocator>::reserve(int size) {
|
||||||
|
return this->_reserve(AllocatorType().get(), size);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename Allocator>
|
||||||
|
inline hkResult hkArray<T, Allocator>::reserveExactly(int size) {
|
||||||
|
return this->_reserveExactly(AllocatorType().get(), size);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, unsigned N, typename Allocator>
|
template <typename T, unsigned N, typename Allocator>
|
||||||
inline hkInplaceArray<T, N, Allocator>::hkInplaceArray(int size)
|
inline hkInplaceArray<T, N, Allocator>::hkInplaceArray(int size)
|
||||||
: hkArray<T, Allocator>(m_storage, size, N) {}
|
: hkArray<T, Allocator>(m_storage, size, N) {}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Havok/Common/Base/Math/Matrix/hkMatrix4f.h>
|
||||||
|
|
||||||
|
using hkMatrix4 = hkMatrix4f;
|
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class hkMatrix4f {
|
||||||
|
public:
|
||||||
|
hkVector4f m_col0;
|
||||||
|
hkVector4f m_col1;
|
||||||
|
hkVector4f m_col2;
|
||||||
|
hkVector4f m_col3;
|
||||||
|
};
|
|
@ -36,6 +36,21 @@ public:
|
||||||
void setFromTransform(const hkQTransformf& qt);
|
void setFromTransform(const hkQTransformf& qt);
|
||||||
void copyToTransform(hkTransformf& transformOut) const;
|
void copyToTransform(hkTransformf& transformOut) const;
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void setInverse(const hkQsTransformf& t);
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void setMul(const hkQsTransformf& t1, const hkQsTransformf& t2);
|
||||||
|
|
||||||
|
HK_FORCE_INLINE void setMulScaled(const hkQsTransformf& t1, const hkQsTransformf& t2);
|
||||||
|
|
||||||
|
/// this = t1^-1 * t2
|
||||||
|
HK_FORCE_INLINE void setMulInverseMul(const hkQsTransformf& t1, const hkQsTransformf& t2);
|
||||||
|
|
||||||
|
/// this = t1 * t2^-1
|
||||||
|
HK_FORCE_INLINE void setMulMulInverse(const hkQsTransformf& t1, const hkQsTransformf& t2);
|
||||||
|
|
||||||
|
/// this *= b
|
||||||
|
HK_FORCE_INLINE void setMulEq(const hkQsTransformf& b);
|
||||||
|
|
||||||
hkVector4f m_translation;
|
hkVector4f m_translation;
|
||||||
hkQuaternionf m_rotation;
|
hkQuaternionf m_rotation;
|
||||||
hkVector4f m_scale;
|
hkVector4f m_scale;
|
||||||
|
|
|
@ -47,3 +47,38 @@ inline void hkQsTransformf::setZero() {
|
||||||
m_rotation.m_vec.setZero();
|
m_rotation.m_vec.setZero();
|
||||||
m_scale.setZero();
|
m_scale.setZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void hkQsTransformf::setInverse(const hkQsTransformf& t) {
|
||||||
|
m_translation.setRotatedInverseDir(t.m_rotation, t.m_translation);
|
||||||
|
m_translation.setNeg<4>(m_translation);
|
||||||
|
m_rotation.setInverse(t.m_rotation);
|
||||||
|
|
||||||
|
m_scale.setReciprocal(t.m_scale);
|
||||||
|
|
||||||
|
m_scale.zeroComponent<3>();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkQsTransformf::setMul(const hkQsTransformf& t1, const hkQsTransformf& t2) {
|
||||||
|
hkVector4f extraTrans;
|
||||||
|
extraTrans._setRotatedDir(t1.m_rotation, t2.m_translation);
|
||||||
|
m_translation.setAdd(t1.m_translation, extraTrans);
|
||||||
|
m_rotation.setMul(t1.m_rotation, t2.m_rotation);
|
||||||
|
|
||||||
|
m_scale.setMul(t1.m_scale, t2.m_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkQsTransformf::setMulInverseMul(const hkQsTransformf& t1, const hkQsTransformf& t2) {
|
||||||
|
hkQsTransformf inv;
|
||||||
|
inv.setInverse(t1);
|
||||||
|
setMul(inv, t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkQsTransformf::setMulMulInverse(const hkQsTransformf& t1, const hkQsTransformf& t2) {
|
||||||
|
hkQsTransformf inv;
|
||||||
|
inv.setInverse(t2);
|
||||||
|
setMul(t1, inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkQsTransformf::setMulEq(const hkQsTransformf& b) {
|
||||||
|
setMul(*this, b);
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@ public:
|
||||||
HK_FORCE_INLINE void setAll(hkFloat32 x);
|
HK_FORCE_INLINE void setAll(hkFloat32 x);
|
||||||
HK_FORCE_INLINE void setAll(hkSimdFloat32Parameter x);
|
HK_FORCE_INLINE void setAll(hkSimdFloat32Parameter x);
|
||||||
HK_FORCE_INLINE void setZero();
|
HK_FORCE_INLINE void setZero();
|
||||||
|
template <int I>
|
||||||
|
HK_FORCE_INLINE void zeroComponent();
|
||||||
|
HK_FORCE_INLINE void zeroComponent(int i);
|
||||||
|
|
||||||
// ========== Vector operations
|
// ========== Vector operations
|
||||||
|
|
||||||
|
@ -116,7 +119,17 @@ public:
|
||||||
// ========== Matrix operations (out-of-line)
|
// ========== Matrix operations (out-of-line)
|
||||||
|
|
||||||
void setRotatedDir(const hkMatrix3f& a, hkVector4fParameter b);
|
void setRotatedDir(const hkMatrix3f& a, hkVector4fParameter b);
|
||||||
|
void setRotatedInverseDir(const hkMatrix3f& a, hkVector4fParameter b);
|
||||||
void setTransformedPos(const hkTransformf& a, const hkVector4f& pos);
|
void setTransformedPos(const hkTransformf& a, const hkVector4f& pos);
|
||||||
|
void setTransformedInversePos(const hkTransformf& a, hkVector4fParameter b);
|
||||||
|
|
||||||
|
void setRotatedDir(hkQuaternionfParameter quat, hkVector4fParameter direction);
|
||||||
|
void setRotatedInverseDir(hkQuaternionfParameter quat, hkVector4fParameter direction);
|
||||||
|
void setTransformedPos(const hkQsTransformf& a, hkVector4fParameter b);
|
||||||
|
void setTransformedInversePos(const hkQsTransformf& a, hkVector4fParameter b);
|
||||||
|
|
||||||
|
void setTransformedPos(const hkQTransformf& a, hkVector4fParameter b);
|
||||||
|
void setTransformedInversePos(const hkQTransformf& a, hkVector4fParameter b);
|
||||||
|
|
||||||
// ========== Matrix operations (inline)
|
// ========== Matrix operations (inline)
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,15 @@ inline void hkVector4f::setZero() {
|
||||||
setAll(0);
|
setAll(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <int I>
|
||||||
|
inline void hkVector4f::zeroComponent() {
|
||||||
|
v[I] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkVector4f::zeroComponent(int i) {
|
||||||
|
v[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
inline void hkVector4f::add(hkVector4fParameter a) {
|
inline void hkVector4f::add(hkVector4fParameter a) {
|
||||||
setAdd(*this, a);
|
setAdd(*this, a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class hkRotationf;
|
||||||
class hkTransformf;
|
class hkTransformf;
|
||||||
class hkQTransformf;
|
class hkQTransformf;
|
||||||
class hkQsTransformf;
|
class hkQsTransformf;
|
||||||
|
class hkMatrix4f;
|
||||||
|
|
||||||
// Type aliases
|
// Type aliases
|
||||||
using hkVector4fParameter = const hkVector4f&;
|
using hkVector4fParameter = const hkVector4f&;
|
||||||
|
@ -34,6 +35,7 @@ using hkQuaternionfParameter = const hkQuaternionf&;
|
||||||
#include <Havok/Common/Base/Math/Matrix/hkRotation.h>
|
#include <Havok/Common/Base/Math/Matrix/hkRotation.h>
|
||||||
#include <Havok/Common/Base/Math/Matrix/hkTransform.h>
|
#include <Havok/Common/Base/Math/Matrix/hkTransform.h>
|
||||||
#include <Havok/Common/Base/Math/QsTransform/hkQsTransform.h>
|
#include <Havok/Common/Base/Math/QsTransform/hkQsTransform.h>
|
||||||
|
#include <Havok/Common/Base/Math/Matrix/hkMatrix4.h>
|
||||||
|
|
||||||
// Implementations
|
// Implementations
|
||||||
#include <Havok/Common/Base/Math/Vector/hkVector4f.inl>
|
#include <Havok/Common/Base/Math/Vector/hkVector4f.inl>
|
||||||
|
|
|
@ -9,3 +9,6 @@
|
||||||
#define HK_RESTRICT __restrict
|
#define HK_RESTRICT __restrict
|
||||||
|
|
||||||
#define HK_MAX_NUM_THREADS 12
|
#define HK_MAX_NUM_THREADS 12
|
||||||
|
|
||||||
|
#define HK_NEXT_MULTIPLE_OF(ALIGNMENT, VALUE) \
|
||||||
|
(((VALUE) + ((ALIGNMENT)-1)) & (~((ALIGNMENT) + (VALUE)*0 - 1)))
|
||||||
|
|
|
@ -212,6 +212,8 @@ public:
|
||||||
int m_finishing = 0;
|
int m_finishing = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define hkSizeOf(A) int(sizeof(A))
|
||||||
|
|
||||||
HK_FORCE_INLINE hkLong hkGetByteOffset(const void* base, const void* pntr) {
|
HK_FORCE_INLINE hkLong hkGetByteOffset(const void* base, const void* pntr) {
|
||||||
return hkLong(pntr) - hkLong(base);
|
return hkLong(pntr) - hkLong(base);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue