summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/System/physClosestPointQuery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/KingSystem/Physics/System/physClosestPointQuery.cpp')
-rw-r--r--src/KingSystem/Physics/System/physClosestPointQuery.cpp43
1 files changed, 43 insertions, 0 deletions
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