From 62959cc554dae3bf2d18f3f7e55788edf343d8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 6 Mar 2022 22:50:15 +0100 Subject: ksys/phys: Start adding ClosestPointQuery and iterator stuff --- .../Physics/System/physClosestPointQuery.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/KingSystem/Physics/System/physClosestPointQuery.cpp (limited to 'src/KingSystem/Physics/System/physClosestPointQuery.cpp') diff --git a/src/KingSystem/Physics/System/physClosestPointQuery.cpp b/src/KingSystem/Physics/System/physClosestPointQuery.cpp new file mode 100644 index 00000000..c27220a0 --- /dev/null +++ b/src/KingSystem/Physics/System/physClosestPointQuery.cpp @@ -0,0 +1,43 @@ +#include "KingSystem/Physics/System/physClosestPointQuery.h" +#include "KingSystem/Physics/RigidBody/physRigidBody.h" +#include "KingSystem/Physics/System/physQueryContactPointInfo.h" +#include "KingSystem/Physics/physDefines.h" +#include "KingSystem/Physics/physLayerMaskBuilder.h" + +namespace ksys::phys { + +ClosestPointQuery::ClosestPointQuery(RigidBody* body, QueryContactPointInfo* contact_point_info) + : mBody(body), mContactPointInfo(contact_point_info) { + reset(); +} + +ClosestPointQuery::~ClosestPointQuery() = default; + +void ClosestPointQuery::reset() { + mIsSuccess = false; + _18 = 0; +} + +void ClosestPointQuery::setLayerMasks(const LayerMaskBuilder& builder) { + auto* info = mContactPointInfo; + for (int i = 0; i < NumContactLayerTypes; ++i) { + info->mSubscribedLayers[i] = builder.getMasks()[i].layers; + info->mLayerMask2[i] = builder.getMasks()[i].layers2; + } +} + +bool ClosestPointQuery::isSuccess() const { + return mIsSuccess; +} + +void ClosestPointQuery::setLayerMasksAndBodyCollisionFilterInfo(const LayerMaskBuilder& builder) { + EntityCollisionMask mask; + mask.data.query_custom_receiver_layer_mask = + builder.getMasks()[int(ContactLayerType::Entity)].layers; + mask.data.layer = ContactLayer::EntityQueryCustomReceiver; + mBody->setCollisionFilterInfo(mask.raw); + + setLayerMasks(builder); +} + +} // namespace ksys::phys -- cgit v1.2.3