From 1ad591ed043e2da285e1a9e696b214ddc5200fbc Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Thu, 4 Nov 2021 03:55:32 +0700 Subject: [PATCH] HitBox added. acceleration of collision detection in 20 times. --- Source.cpp | 4 ++-- engine/physics/HitBox.h | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Source.cpp b/Source.cpp index 209e3f4..9c40cdf 100644 --- a/Source.cpp +++ b/Source.cpp @@ -10,10 +10,10 @@ using namespace std; int main() { Shooter game; - game.create(1280, 720, ShooterConsts::PROJECT_NAME); + //game.create(1280, 720, ShooterConsts::PROJECT_NAME); //game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen); - //game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false); + game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false); //game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen); return 0; diff --git a/engine/physics/HitBox.h b/engine/physics/HitBox.h index d7df40c..3afe05e 100644 --- a/engine/physics/HitBox.h +++ b/engine/physics/HitBox.h @@ -7,19 +7,22 @@ #include "../Mesh.h" -class HitBox { +class HitBox final { private: std::vector _hitBox; - void _addIfUnique(const Vec3D& point); + void _addIfUnique(const Vec3D &point); + public: HitBox() = default; - explicit HitBox(const Mesh& mesh); - std::vector::iterator begin() { return _hitBox.begin(); } - std::vector::iterator end() { return _hitBox.end(); } + explicit HitBox(const Mesh &mesh); - HitBox static Box(const Mesh& mesh); + [[nodiscard]] std::vector::iterator begin() { return _hitBox.begin(); } + + [[nodiscard]] std::vector::iterator end() { return _hitBox.end(); } + + HitBox static Box(const Mesh &mesh); };