mirror of https://github.com/zeldaret/botw.git
Havok: Add hkpMoppBvTreeShape
This commit is contained in:
parent
3f793b24d9
commit
bf09eea7a8
|
@ -104,6 +104,7 @@ add_library(hkStubs OBJECT
|
||||||
Havok/Physics2012/Collide/Shape/Compound/Collection/hkpShapeCollection.h
|
Havok/Physics2012/Collide/Shape/Compound/Collection/hkpShapeCollection.h
|
||||||
Havok/Physics2012/Collide/Shape/Compound/Collection/List/hkpListShape.h
|
Havok/Physics2012/Collide/Shape/Compound/Collection/List/hkpListShape.h
|
||||||
Havok/Physics2012/Collide/Shape/Compound/Tree/hkpBvTreeShape.h
|
Havok/Physics2012/Collide/Shape/Compound/Tree/hkpBvTreeShape.h
|
||||||
|
Havok/Physics2012/Collide/Shape/Compound/Tree/Mopp/hkpMoppBvTreeShape.h
|
||||||
Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h
|
Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h
|
||||||
Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h
|
Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h
|
||||||
Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h
|
Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h
|
||||||
|
@ -149,6 +150,8 @@ add_library(hkStubs OBJECT
|
||||||
Havok/Physics2012/Dynamics/World/Memory/Default/hkpDefaultWorldMemoryWatchDog.h
|
Havok/Physics2012/Dynamics/World/Memory/Default/hkpDefaultWorldMemoryWatchDog.h
|
||||||
Havok/Physics2012/Dynamics/World/Simulation/hkpSimulation.h
|
Havok/Physics2012/Dynamics/World/Simulation/hkpSimulation.h
|
||||||
|
|
||||||
|
Havok/Physics2012/Internal/Collide/Mopp/Code/hkpMoppCode.h
|
||||||
|
|
||||||
Havok/Physics2012/Utilities/Serialize/hkpPhysicsData.h
|
Havok/Physics2012/Utilities/Serialize/hkpPhysicsData.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Havok/Physics2012/Collide/Shape/Compound/Collection/hkpShapeCollection.h>
|
||||||
|
#include <Havok/Physics2012/Collide/Shape/Compound/Tree/hkpBvTreeShape.h>
|
||||||
|
#include <Havok/Physics2012/Collide/Shape/hkpShapeContainer.h>
|
||||||
|
#include <Havok/Physics2012/Internal/Collide/Mopp/Code/hkpMoppCode.h>
|
||||||
|
|
||||||
|
class hkMoppBvTreeShapeBase : public hkpBvTreeShape {
|
||||||
|
public:
|
||||||
|
HK_DECLARE_CLASS_ALLOCATOR(hkMoppBvTreeShapeBase)
|
||||||
|
HK_DECLARE_REFLECTION()
|
||||||
|
|
||||||
|
HK_FORCE_INLINE hkMoppBvTreeShapeBase() {}
|
||||||
|
|
||||||
|
hkMoppBvTreeShapeBase(ShapeType type, const hkpMoppCode* code);
|
||||||
|
explicit hkMoppBvTreeShapeBase(hkFinishLoadedObjectFlag flag);
|
||||||
|
~hkMoppBvTreeShapeBase() override;
|
||||||
|
|
||||||
|
virtual void queryObb(const hkTransform& obbToMopp, const hkVector4& extent, hkReal tolerance,
|
||||||
|
hkArray<hkpShapeKey>& hits) const;
|
||||||
|
|
||||||
|
void queryAabb(const hkAabb& aabb, hkArray<hkpShapeKey>& hits) const override;
|
||||||
|
hkUint32 queryAabbImpl(const hkAabb& aabb, hkpShapeKey* hits, int maxNumKeys) const override;
|
||||||
|
|
||||||
|
const hkpMoppCode* m_code;
|
||||||
|
const hkUint8* m_moppData;
|
||||||
|
hkUint32 m_moppDataSize;
|
||||||
|
hkVector4 m_codeInfoCopy;
|
||||||
|
};
|
||||||
|
|
||||||
|
class hkpMoppBvTreeShape : public hkMoppBvTreeShapeBase {
|
||||||
|
public:
|
||||||
|
HK_DECLARE_CLASS_ALLOCATOR(hkpMoppBvTreeShape)
|
||||||
|
HK_DECLARE_REFLECTION()
|
||||||
|
HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::MOPP)
|
||||||
|
|
||||||
|
HK_FORCE_INLINE hkpMoppBvTreeShape() {}
|
||||||
|
hkpMoppBvTreeShape(const hkpShapeCollection* collection, const hkpMoppCode* code);
|
||||||
|
HK_FORCE_INLINE explicit hkpMoppBvTreeShape(hkFinishLoadedObjectFlag flag);
|
||||||
|
~hkpMoppBvTreeShape() override;
|
||||||
|
|
||||||
|
void getAabb(const hkTransform& localToWorld, hkReal tolerance, hkAabb& out) const override;
|
||||||
|
|
||||||
|
hkBool castRay(const hkpShapeRayCastInput& input,
|
||||||
|
hkpShapeRayCastOutput& results) const override;
|
||||||
|
|
||||||
|
void castRayWithCollector(const hkpShapeRayCastInput& input, const hkpCdBody& cdBody,
|
||||||
|
hkpRayHitCollector& collector) const override;
|
||||||
|
|
||||||
|
hkVector4Comparison castRayBundle(const hkpShapeRayBundleCastInput& input,
|
||||||
|
hkpShapeRayBundleCastOutput& results,
|
||||||
|
hkVector4ComparisonParameter mask) const override;
|
||||||
|
|
||||||
|
inline const hkpMoppCode* getMoppCode() const;
|
||||||
|
inline void setMoppCode(const hkpMoppCode* code);
|
||||||
|
|
||||||
|
inline const hkpShapeCollection* getShapeCollection() const;
|
||||||
|
inline const hkpShapeContainer* getContainer() const override;
|
||||||
|
inline const hkpShape* getChild() const;
|
||||||
|
|
||||||
|
int calcSizeForSpu(const CalcSizeForSpuInput& input, int spuBufferSizeLeft) const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
hkpSingleShapeContainer m_child;
|
||||||
|
|
||||||
|
public:
|
||||||
|
mutable int m_childSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline hkMoppBvTreeShapeBase::hkMoppBvTreeShapeBase(hkFinishLoadedObjectFlag flag)
|
||||||
|
: hkpBvTreeShape(flag) {
|
||||||
|
if (flag.m_finishing) {
|
||||||
|
m_bvTreeType = BVTREE_MOPP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkMoppBvTreeShapeBase::~hkMoppBvTreeShapeBase() {
|
||||||
|
m_code->removeReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkpMoppBvTreeShape::hkpMoppBvTreeShape(hkFinishLoadedObjectFlag flag)
|
||||||
|
: hkMoppBvTreeShapeBase(flag), m_child(flag) {
|
||||||
|
if (flag.m_finishing == 1) {
|
||||||
|
setType(HKCD_SHAPE_TYPE_FROM_CLASS(hkpMoppBvTreeShape));
|
||||||
|
m_codeInfoCopy = m_code->m_info.m_offset;
|
||||||
|
m_moppData = m_code->m_data.begin();
|
||||||
|
m_moppDataSize = m_code->getCodeSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkpShapeCollection* hkpMoppBvTreeShape::getShapeCollection() const {
|
||||||
|
return static_cast<const hkpShapeCollection*>(m_child.getChild());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkpMoppCode* hkpMoppBvTreeShape::getMoppCode() const {
|
||||||
|
return m_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkpMoppBvTreeShape::setMoppCode(const hkpMoppCode* code) {
|
||||||
|
code->addReference();
|
||||||
|
m_code->removeReference();
|
||||||
|
m_code = code;
|
||||||
|
m_codeInfoCopy = code->m_info.m_offset;
|
||||||
|
m_moppData = code->m_data.begin();
|
||||||
|
m_moppDataSize = code->getCodeSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkpShapeContainer* hkpMoppBvTreeShape::getContainer() const {
|
||||||
|
return getShapeCollection()->getContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const hkpShape* hkpMoppBvTreeShape::getChild() const {
|
||||||
|
return m_child.getChild();
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ public:
|
||||||
BVTREE_MAX
|
BVTREE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HK_FORCE_INLINE hkpBvTreeShape() {}
|
||||||
|
|
||||||
inline hkpBvTreeShape(ShapeType type, BvTreeType bvType)
|
inline hkpBvTreeShape(ShapeType type, BvTreeType bvType)
|
||||||
: hkpShape(type), m_bvTreeType(bvType) {}
|
: hkpShape(type), m_bvTreeType(bvType) {}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
|
|
||||||
HK_DECLARE_CLASS_ALLOCATOR(hkpSingleShapeContainer)
|
HK_DECLARE_CLASS_ALLOCATOR(hkpSingleShapeContainer)
|
||||||
|
|
||||||
|
hkpSingleShapeContainer() {}
|
||||||
explicit hkpSingleShapeContainer(hkFinishLoadedObjectFlag) {}
|
explicit hkpSingleShapeContainer(hkFinishLoadedObjectFlag) {}
|
||||||
|
|
||||||
~hkpSingleShapeContainer() override {
|
~hkpSingleShapeContainer() override {
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Havok/Common/Base/hkBase.h>
|
||||||
|
|
||||||
|
class hkpMoppCode : public hkReferencedObject {
|
||||||
|
public:
|
||||||
|
HK_DECLARE_CLASS_ALLOCATOR(hkpMoppCode)
|
||||||
|
HK_DECLARE_REFLECTION()
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MIN_PROPERTY_VALUE = 0,
|
||||||
|
MAX_PROPERTY_VALUE = 0xffffffff,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MAX_PRIMITIVE_PROPERTIES = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum BuildType {
|
||||||
|
BUILT_WITH_CHUNK_SUBDIVISION,
|
||||||
|
BUILT_WITHOUT_CHUNK_SUBDIVISION,
|
||||||
|
BUILD_NOT_SET,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CodeInfo {
|
||||||
|
HK_DECLARE_CLASS_ALLOCATOR(CodeInfo)
|
||||||
|
HK_DECLARE_REFLECTION()
|
||||||
|
|
||||||
|
inline hkReal getScale() const;
|
||||||
|
inline void setScale(hkReal inVal);
|
||||||
|
|
||||||
|
hkVector4 m_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
hkpMoppCode() {
|
||||||
|
m_info.m_offset.setZero();
|
||||||
|
m_buildType = BUILD_NOT_SET;
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit hkpMoppCode(hkFinishLoadedObjectFlag f) : hkReferencedObject(f), m_data(f) {}
|
||||||
|
|
||||||
|
inline hkpMoppCode(const CodeInfo& info, const hkUint8* moppData, int moppBytes,
|
||||||
|
BuildType buildType);
|
||||||
|
|
||||||
|
~hkpMoppCode() override = default;
|
||||||
|
|
||||||
|
inline hkInt32 getCodeSize() const;
|
||||||
|
|
||||||
|
inline void initialize(const CodeInfo& info, const hkUint8* moppData, int moppBytes,
|
||||||
|
BuildType buildType = BUILD_NOT_SET);
|
||||||
|
|
||||||
|
CodeInfo m_info;
|
||||||
|
hkArray<hkUint8> m_data;
|
||||||
|
hkEnum<BuildType, hkInt8> m_buildType;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline hkpMoppCode::hkpMoppCode(const CodeInfo& info, const hkUint8* moppData, int moppBytes,
|
||||||
|
BuildType buildType)
|
||||||
|
: m_info(info), m_data(const_cast<hkUint8*>(moppData), moppBytes, moppBytes) {
|
||||||
|
m_buildType = buildType;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkInt32 hkpMoppCode::getCodeSize() const {
|
||||||
|
return m_data.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline hkReal hkpMoppCode::CodeInfo::getScale() const {
|
||||||
|
return m_offset(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void hkpMoppCode::CodeInfo::setScale(hkReal inVal) {
|
||||||
|
m_offset(3) = inVal;
|
||||||
|
}
|
Loading…
Reference in New Issue