From b6f6c94133d75e31605c1c9387f0b00afe320922 Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Sat, 5 Mar 2022 17:40:25 +0700 Subject: [PATCH] small refactoring --- engine/physics/HitBox.cpp | 4 ++-- engine/physics/RigidBody.cpp | 4 ---- engine/physics/RigidBody.h | 2 -- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/engine/physics/HitBox.cpp b/engine/physics/HitBox.cpp index 924f91c..cc9cc47 100644 --- a/engine/physics/HitBox.cpp +++ b/engine/physics/HitBox.cpp @@ -38,7 +38,7 @@ void HitBox::generateSimple(const Mesh &mesh) { for(const auto& t : mesh.triangles()) { for(int i = 0; i < 3; i++) { - auto point = mesh.model()*Vec3D(t[i]); + auto point = Vec3D(t[i]); if(point.x() > maxX) { maxX = point.x(); } @@ -78,7 +78,7 @@ void HitBox::generateDetailed(const Mesh &mesh) { for (const auto& t : mesh.triangles()) for (int i = 0; i < 3; i++) - points.insert(mesh.model()*Vec3D(t[i])); + points.insert(Vec3D(t[i])); _hitBox.reserve(points.size()); for (const auto& it : points) diff --git a/engine/physics/RigidBody.cpp b/engine/physics/RigidBody.cpp index 01b12f1..1c9cbae 100644 --- a/engine/physics/RigidBody.cpp +++ b/engine/physics/RigidBody.cpp @@ -18,10 +18,6 @@ RigidBody::RigidBody(ObjectNameTag nameTag, const std::string &filename, const V RigidBody::RigidBody(const Mesh &mesh, bool useSimpleBox) : Mesh(mesh), _hitBox(mesh, useSimpleBox) { } -void RigidBody::recalculateHitBox(bool useSimpleBox) { - _hitBox = HitBox(*this, useSimpleBox); -} - Vec3D RigidBody::_findFurthestPoint(const Vec3D &direction) { Vec3D maxPoint{0, 0, 0}; diff --git a/engine/physics/RigidBody.h b/engine/physics/RigidBody.h index e1e8919..b53fc11 100644 --- a/engine/physics/RigidBody.h +++ b/engine/physics/RigidBody.h @@ -70,8 +70,6 @@ public: [[nodiscard]] CollisionPoint EPA(const Simplex &simplex, std::shared_ptr obj); void solveCollision(const CollisionPoint &collision); - void recalculateHitBox(bool useSimpleBox = true); - [[nodiscard]] Vec3D collisionNormal() const { return _collisionNormal; } [[nodiscard]] bool hasCollision() const { return _hasCollision; } [[nodiscard]] bool inCollision() const { return _inCollision; }