summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/System/physClosestPointQuery.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-03-06 22:50:15 +0100
committerLéo Lam <leo@leolam.fr>2022-03-07 12:44:38 +0100
commit62959cc554dae3bf2d18f3f7e55788edf343d8e8 (patch)
tree68b89c8ba299c8b9c849a5c9249a8d8135f09ba0 /src/KingSystem/Physics/System/physClosestPointQuery.cpp
parent6229e5d41adcf16a87dba7df9b12c5f91871273b (diff)
ksys/phys: Start adding ClosestPointQuery and iterator stuff
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