diff options
| author | ConorB <11508137+ConorBobbleHat@users.noreply.github.com> | 2022-04-13 22:35:04 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-14 00:35:04 +0200 |
| commit | 6ca1c6fd5ae79d3d074bca2e86eb8772f7193b30 (patch) | |
| tree | 182438de853cf5745eda08e7fa2538bcd799de87 /lib | |
| parent | 0127ac20640a01121a4accb5b214eb1d915272a4 (diff) | |
ksys/phys: Implement `SphereShape` and `SphereRigidBody` (#92)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hkStubs/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexTranslate/hkpConvexTranslateShape.h | 69 |
2 files changed, 70 insertions, 0 deletions
diff --git a/lib/hkStubs/CMakeLists.txt b/lib/hkStubs/CMakeLists.txt index b1303f0a..44473760 100644 --- a/lib/hkStubs/CMakeLists.txt +++ b/lib/hkStubs/CMakeLists.txt @@ -150,6 +150,7 @@ add_library(hkStubs OBJECT Havok/Physics2012/Collide/Shape/Convex/Box/hkpBoxShape.h Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h Havok/Physics2012/Collide/Shape/Convex/ConvexTransform/hkpConvexTransformShape.h + Havok/Physics2012/Collide/Shape/Convex/ConvexTranslate/hkpConvexTranslateShape.h Havok/Physics2012/Collide/Shape/Convex/ConvexVertices/hkpConvexVerticesShape.h Havok/Physics2012/Collide/Shape/Convex/Cylinder/hkpCylinderShape.h Havok/Physics2012/Collide/Shape/Convex/Sphere/hkpSphereShape.h diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexTranslate/hkpConvexTranslateShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexTranslate/hkpConvexTranslateShape.h new file mode 100644 index 00000000..07f70c63 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexTranslate/hkpConvexTranslateShape.h @@ -0,0 +1,69 @@ +#pragma once + +#include <Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h> + +class hkpConvexTranslateShape : public hkpConvexTransformShapeBase { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpConvexTranslateShape) + HK_DECLARE_REFLECTION() + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::CONVEX_TRANSLATE) + + HK_FORCE_INLINE hkpConvexTranslateShape() {} + HK_FORCE_INLINE hkpConvexTranslateShape( + const hkpConvexShape* childShape, const hkVector4& translation, + hkpShapeContainer::ReferencePolicy ref = hkpShapeContainer::REFERENCE_POLICY_INCREMENT); + + void getSupportingVertex(hkVector4Parameter direction, + hkcdVertex& supportingVertexOut) const override; + void convertVertexIdsToVertices(const hkpVertexId* ids, int numIds, + hkcdVertex* verticesOut) const override; + void getCentre(hkVector4& centreOut) const override; + HK_FORCE_INLINE int getNumCollisionSpheres() const override; + const hkSphere* getCollisionSpheres(hkSphere* sphereBuffer) const 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; + void getFirstVertex(hkVector4& v) const override; + hkReal getMaximumProjection(const hkVector4& direction) const override; + const hkpShapeContainer* getContainer() const override; + int calcSizeForSpu(const CalcSizeForSpuInput& input, int spuBufferSizeLeft) const override; + + inline const hkpConvexShape* getChildShape() const; + inline hkVector4& getTranslation(); + inline const hkVector4& getTranslation() const; + + hkpConvexTranslateShape(class hkFinishLoadedObjectFlag flag); + +protected: + hkVector4 m_translation; +}; + +HK_FORCE_INLINE +hkpConvexTranslateShape::hkpConvexTranslateShape(const hkpConvexShape* childShape, + const hkVector4& translation, + hkpShapeContainer::ReferencePolicy ref) + : hkpConvexTransformShapeBase(HKCD_SHAPE_TYPE_FROM_CLASS(hkpConvexTranslateShape), + childShape->getRadius(), childShape, ref) { + hkVector4 t = translation; + t.setW(0); + m_translation = t; + m_childShapeSizeForSpu = 0; +} + +inline const hkpConvexShape* hkpConvexTranslateShape::getChildShape() const { + return static_cast<const hkpConvexShape*>(m_childShape.getChild()); +} + +inline const hkVector4& hkpConvexTranslateShape::getTranslation() const { + return m_translation; +} + +inline hkVector4& hkpConvexTranslateShape::getTranslation() { + return m_translation; +} + +HK_FORCE_INLINE int hkpConvexTranslateShape::getNumCollisionSpheres() const { + return getChildShape()->getNumCollisionSpheres(); +}
\ No newline at end of file |
