remove useless manual move/copy constructors/assignment operators (pls stop killing my hands bjarne)
This commit is contained in:
@ -1,13 +1,14 @@
|
|||||||
#ifndef __PHYSICS_HPP_
|
#ifndef __PHYSICS_HPP_
|
||||||
#define __PHYSICS_HPP_
|
#define __PHYSICS_HPP_
|
||||||
|
|
||||||
#include "config.hpp"
|
|
||||||
#include "puzzle.hpp"
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
|
#include "puzzle.hpp"
|
||||||
|
|
||||||
class Mass {
|
class Mass {
|
||||||
public:
|
public:
|
||||||
const float mass;
|
const float mass;
|
||||||
@ -22,22 +23,6 @@ public:
|
|||||||
: mass(mass), position(position), previous_position(position),
|
: mass(mass), position(position), previous_position(position),
|
||||||
velocity(Vector3Zero()), force(Vector3Zero()), fixed(fixed) {}
|
velocity(Vector3Zero()), force(Vector3Zero()), fixed(fixed) {}
|
||||||
|
|
||||||
Mass(const Mass ©)
|
|
||||||
: mass(copy.mass), position(copy.position),
|
|
||||||
previous_position(copy.previous_position), velocity(copy.velocity),
|
|
||||||
force(copy.force), fixed(copy.fixed) {};
|
|
||||||
|
|
||||||
Mass &operator=(const Mass ©) = delete;
|
|
||||||
|
|
||||||
Mass(Mass &&move)
|
|
||||||
: mass(move.mass), position(move.position),
|
|
||||||
previous_position(move.previous_position), velocity(move.velocity),
|
|
||||||
force(move.force), fixed(move.fixed) {};
|
|
||||||
|
|
||||||
Mass &operator=(Mass &&move) = delete;
|
|
||||||
|
|
||||||
~Mass() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto ClearForce() -> void;
|
auto ClearForce() -> void;
|
||||||
|
|
||||||
@ -62,30 +47,13 @@ public:
|
|||||||
: massA(massA), massB(massB), spring_constant(spring_constant),
|
: massA(massA), massB(massB), spring_constant(spring_constant),
|
||||||
dampening_constant(dampening_constant), rest_length(rest_length) {}
|
dampening_constant(dampening_constant), rest_length(rest_length) {}
|
||||||
|
|
||||||
Spring(const Spring ©)
|
|
||||||
: massA(copy.massA), massB(copy.massB),
|
|
||||||
spring_constant(copy.spring_constant),
|
|
||||||
dampening_constant(copy.dampening_constant),
|
|
||||||
rest_length(copy.rest_length) {};
|
|
||||||
|
|
||||||
Spring &operator=(const Spring ©) = delete;
|
|
||||||
|
|
||||||
Spring(Spring &&move)
|
|
||||||
: massA(move.massA), massB(move.massB),
|
|
||||||
spring_constant(move.spring_constant),
|
|
||||||
dampening_constant(move.dampening_constant),
|
|
||||||
rest_length(move.rest_length) {}
|
|
||||||
|
|
||||||
Spring &operator=(Spring &&move) = delete;
|
|
||||||
|
|
||||||
~Spring() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto CalculateSpringForce() const -> void;
|
auto CalculateSpringForce() const -> void;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MassSpringSystem {
|
class MassSpringSystem {
|
||||||
private:
|
private:
|
||||||
|
// Uniform grid
|
||||||
std::vector<Mass *> mass_pointers;
|
std::vector<Mass *> mass_pointers;
|
||||||
std::vector<int> mass_indices;
|
std::vector<int> mass_indices;
|
||||||
std::vector<int64_t> cell_ids;
|
std::vector<int64_t> cell_ids;
|
||||||
|
|||||||
@ -10,8 +10,6 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// #define DBG_PRINT
|
|
||||||
|
|
||||||
enum Direction {
|
enum Direction {
|
||||||
NOR = 1 << 0,
|
NOR = 1 << 0,
|
||||||
EAS = 1 << 1,
|
EAS = 1 << 1,
|
||||||
@ -39,10 +37,6 @@ public:
|
|||||||
std::cerr << "Block must fit on a 9x9 board!" << std::endl;
|
std::cerr << "Block must fit on a 9x9 board!" << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBG_PRINT
|
|
||||||
std::cout << ToString() << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Block(int x, int y, std::string block) : x(x), y(y) {
|
Block(int x, int y, std::string block) : x(x), y(y) {
|
||||||
@ -82,25 +76,8 @@ public:
|
|||||||
std::cerr << "Block representation must have length [2]!" << std::endl;
|
std::cerr << "Block representation must have length [2]!" << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBG_PRINT
|
|
||||||
std::cout << "At: (" << x << ", " << y << "), Size: (" << width << ", "
|
|
||||||
<< height << "), Target: " << target << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Block(const Block ©)
|
|
||||||
: x(copy.x), y(copy.y), width(copy.width), height(copy.height),
|
|
||||||
target(copy.target) {}
|
|
||||||
|
|
||||||
Block &operator=(const Block ©) = delete;
|
|
||||||
|
|
||||||
Block(Block &&move)
|
|
||||||
: x(move.x), y(move.y), width(move.width), height(move.height),
|
|
||||||
target(move.target) {}
|
|
||||||
|
|
||||||
Block &operator=(Block &&move) = delete;
|
|
||||||
|
|
||||||
bool operator==(const Block &other) {
|
bool operator==(const Block &other) {
|
||||||
return x == other.x && y == other.y && width && other.width &&
|
return x == other.x && y == other.y && width && other.width &&
|
||||||
target == other.target;
|
target == other.target;
|
||||||
@ -108,8 +85,6 @@ public:
|
|||||||
|
|
||||||
bool operator!=(const Block &other) { return !(*this == other); }
|
bool operator!=(const Block &other) { return !(*this == other); }
|
||||||
|
|
||||||
~Block() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto Hash() const -> int;
|
auto Hash() const -> int;
|
||||||
|
|
||||||
@ -183,11 +158,6 @@ public:
|
|||||||
std::cerr << "State width/height must be in [1, 9]!" << std::endl;
|
std::cerr << "State width/height must be in [1, 9]!" << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBG_PRINT
|
|
||||||
std::cout << "State(" << width << ", " << height << "): \"" << state << "\""
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit State(std::string state)
|
explicit State(std::string state)
|
||||||
@ -206,33 +176,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
State(const State ©)
|
|
||||||
: width(copy.width), height(copy.height), restricted(copy.restricted),
|
|
||||||
state(copy.state) {}
|
|
||||||
|
|
||||||
State &operator=(const State ©) {
|
|
||||||
if (*this != copy) {
|
|
||||||
width = copy.width;
|
|
||||||
height = copy.height;
|
|
||||||
restricted = copy.restricted;
|
|
||||||
state = copy.state;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
State(State &&move)
|
|
||||||
: width(move.width), height(move.height), restricted(move.restricted),
|
|
||||||
state(std::move(move.state)) {}
|
|
||||||
|
|
||||||
State &operator=(State &&move) {
|
|
||||||
if (*this != move) {
|
|
||||||
width = move.width;
|
|
||||||
height = move.height;
|
|
||||||
restricted = move.restricted, state = std::move(move.state);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool operator==(const State &other) const { return state == other.state; }
|
bool operator==(const State &other) const { return state == other.state; }
|
||||||
|
|
||||||
bool operator!=(const State &other) const { return !(*this == other); }
|
bool operator!=(const State &other) const { return !(*this == other); }
|
||||||
@ -247,8 +190,6 @@ public:
|
|||||||
|
|
||||||
BlockIterator end() const { return BlockIterator(*this, width * height); }
|
BlockIterator end() const { return BlockIterator(*this, width * height); }
|
||||||
|
|
||||||
~State() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto Hash() const -> int;
|
auto Hash() const -> int;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user