HitBox added. acceleration of collision detection in 20 times.

master
Vectozavr 2021-11-04 03:55:32 +07:00
parent e347215f11
commit 1ad591ed04
2 changed files with 11 additions and 8 deletions

View File

@ -10,10 +10,10 @@ using namespace std;
int main() { int main() {
Shooter game; 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(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); //game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
return 0; return 0;

View File

@ -7,17 +7,20 @@
#include "../Mesh.h" #include "../Mesh.h"
class HitBox { class HitBox final {
private: private:
std::vector<Vec3D> _hitBox; std::vector<Vec3D> _hitBox;
void _addIfUnique(const Vec3D &point); void _addIfUnique(const Vec3D &point);
public: public:
HitBox() = default; HitBox() = default;
explicit HitBox(const Mesh &mesh); explicit HitBox(const Mesh &mesh);
std::vector<Vec3D>::iterator begin() { return _hitBox.begin(); } [[nodiscard]] std::vector<Vec3D>::iterator begin() { return _hitBox.begin(); }
std::vector<Vec3D>::iterator end() { return _hitBox.end(); }
[[nodiscard]] std::vector<Vec3D>::iterator end() { return _hitBox.end(); }
HitBox static Box(const Mesh &mesh); HitBox static Box(const Mesh &mesh);
}; };