Skip to content
Snippets Groups Projects
Commit ae516c00 authored by Martin Štourač's avatar Martin Štourač
Browse files

remove enum class from parameter definitions

parent 00a970a9
No related branches found
No related tags found
No related merge requests found
...@@ -29,11 +29,11 @@ class Connector : public ObjectBase ...@@ -29,11 +29,11 @@ class Connector : public ObjectBase
friend class VoxelGraph; friend class VoxelGraph;
protected: protected:
std::pair<voxel_weak_ptr, voxel_weak_ptr> connection = std::pair(voxel_weak_ptr(), voxel_weak_ptr()); std::pair<voxel_weak_ptr, voxel_weak_ptr> connection = std::pair(voxel_weak_ptr(), voxel_weak_ptr());
std::pair<enum class side, enum class side> voxel_side = std::pair(side::undefined, side::undefined); std::pair<side, side> voxel_side = std::pair(side::undefined, side::undefined);
virtual void connectVoxel(enum class side s, voxel_weak_ptr voxel); virtual void connectVoxel(side s, voxel_weak_ptr voxel);
virtual void disconnectVoxel(voxel_weak_ptr voxel); virtual void disconnectVoxel(voxel_weak_ptr voxel);
virtual void disconnectVoxel(enum class side s); virtual void disconnectVoxel(side s);
Connector(const Connector &other); Connector(const Connector &other);
Connector(const Connector &&other); Connector(const Connector &&other);
...@@ -58,9 +58,9 @@ public: ...@@ -58,9 +58,9 @@ public:
node_ptr getNode() { return node; } node_ptr getNode() { return node; }
voxel_weak_ptr getOppositeConnection(); voxel_weak_ptr getOppositeConnection();
voxel_weak_ptr getOppositeConnection(enum class side s); voxel_weak_ptr getOppositeConnection(side s);
const std::pair<voxel_weak_ptr, voxel_weak_ptr> &getConnection() { return connection; } const std::pair<voxel_weak_ptr, voxel_weak_ptr> &getConnection() { return connection; }
const std::pair<enum class side, enum class side> &getVoxelSide() { return voxel_side; } const std::pair<side, side> &getVoxelSide() { return voxel_side; }
voxel_weak_ptr getModuleLink() const; voxel_weak_ptr getModuleLink() const;
virtual const connector_type getType(voxel_weak_ptr) const = 0; virtual const connector_type getType(voxel_weak_ptr) const = 0;
...@@ -113,7 +113,7 @@ class RotationConnector : public Connector ...@@ -113,7 +113,7 @@ class RotationConnector : public Connector
bool is_head; bool is_head;
std::pair<connector_weak_ptr, connector_weak_ptr> bound_connectors = std::pair(connector_weak_ptr(), connector_weak_ptr()); std::pair<connector_weak_ptr, connector_weak_ptr> bound_connectors = std::pair(connector_weak_ptr(), connector_weak_ptr());
enum class connector_type semantic_type = connector_type::empty; connector_type semantic_type = connector_type::empty;
float neg_rotation_limit = -90.0f; float neg_rotation_limit = -90.0f;
float pos_rotation_limit = 90.0f; float pos_rotation_limit = 90.0f;
float current_rotation = 0.0f; float current_rotation = 0.0f;
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
static std::shared_ptr<RotationConnector> copy(std::shared_ptr<RotationConnector> other_rotation_connector); static std::shared_ptr<RotationConnector> copy(std::shared_ptr<RotationConnector> other_rotation_connector);
const enum class connector_type getType(voxel_weak_ptr from_voxel) const override const connector_type getType(voxel_weak_ptr from_voxel) const override
{ {
if (connection.first.expired()) if (connection.first.expired())
return connector_type::rotation; return connector_type::rotation;
...@@ -202,8 +202,8 @@ public: ...@@ -202,8 +202,8 @@ public:
void setRotationAxis(glm::vec3 _rotation_axis) { rotation_axis = _rotation_axis; } void setRotationAxis(glm::vec3 _rotation_axis) { rotation_axis = _rotation_axis; }
}; };
enum class side vec_to_enum(glm::vec3 local_direction); side vec_to_enum(glm::vec3 local_direction);
glm::vec3 enum_to_vec(enum class side s); glm::vec3 enum_to_vec(side s);
cardinal degree_to_cardinal(float degree_angle); cardinal degree_to_cardinal(float degree_angle);
float cardinal_to_degree(cardinal orientation); float cardinal_to_degree(cardinal orientation);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
namespace rofi namespace rofi
{ {
class Connector; class Connector;
enum class side vec_to_enum(glm::vec3 local_direction); side vec_to_enum(glm::vec3 local_direction);
using connector_weak_ptr = std::weak_ptr<Connector>; using connector_weak_ptr = std::weak_ptr<Connector>;
...@@ -22,7 +22,7 @@ using voxel_ptr = std::shared_ptr<Voxel>; ...@@ -22,7 +22,7 @@ using voxel_ptr = std::shared_ptr<Voxel>;
class Voxel : public ObjectBase class Voxel : public ObjectBase
{ {
using enum connector_type; using enum connector_type;
std::map<const enum class side, std::map<const enum class rofi::connector_type, bool>> slots = { std::map<const side, std::map<const rofi::connector_type, bool>> slots = {
{side::x_pos, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}}, {side::x_pos, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}},
{side::x_neg, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}}, {side::x_neg, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}},
{side::y_pos, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}}, {side::y_pos, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}},
...@@ -33,21 +33,21 @@ class Voxel : public ObjectBase ...@@ -33,21 +33,21 @@ class Voxel : public ObjectBase
protected: protected:
node_ptr node; node_ptr node;
std::map<enum class side, connector_weak_ptr> connections; std::map<side, connector_weak_ptr> connections;
friend class VoxelGraph; friend class VoxelGraph;
void connectConnection(enum class side s, connector_weak_ptr connector); void connectConnection(side s, connector_weak_ptr connector);
void disconnectConnection(enum class side s); void disconnectConnection(side s);
void disconnectConnection(connector_weak_ptr connector); void disconnectConnection(connector_weak_ptr connector);
const std::map<enum class side, connector_weak_ptr> &getConnections() { return connections; } const std::map<side, connector_weak_ptr> &getConnections() { return connections; }
void restrictSlotsRotation(const enum class side s, connector_weak_ptr connector); void restrictSlotsRotation(const side s, connector_weak_ptr connector);
void restrictSlotsSharedRotation(const enum class side s); void restrictSlotsSharedRotation(const side s);
void releaseSlotsRotation(const enum class side s, connector_weak_ptr connector); void releaseSlotsRotation(const side s, connector_weak_ptr connector);
void releaseSlotsSharedRotation(const enum class side s); void releaseSlotsSharedRotation(const side s);
Voxel(const Voxel &other); Voxel(const Voxel &other);
Voxel(const Voxel &&other); Voxel(const Voxel &&other);
...@@ -64,36 +64,36 @@ public: ...@@ -64,36 +64,36 @@ public:
virtual ~Voxel() = default; virtual ~Voxel() = default;
node_ptr getNode() const { return node; } node_ptr getNode() const { return node; }
bool isConnectedAt(enum class side s) const { return connections.contains(s); } bool isConnectedAt(side s) const { return connections.contains(s); }
bool isConnectedAt(glm::vec3 side_direction) const { return isConnectedAt(vec_to_enum(side_direction)); } bool isConnectedAt(glm::vec3 side_direction) const { return isConnectedAt(vec_to_enum(side_direction)); }
side getSideWithConnector(connector_weak_ptr connector) const; side getSideWithConnector(connector_weak_ptr connector) const;
connector_weak_ptr getConnectorAt(enum class side s) const; connector_weak_ptr getConnectorAt(side s) const;
connector_weak_ptr getConnectorAt(glm::vec3 side_direction) const { return getConnectorAt(vec_to_enum(side_direction)); }; connector_weak_ptr getConnectorAt(glm::vec3 side_direction) const { return getConnectorAt(vec_to_enum(side_direction)); };
connector_weak_ptr getOppositeConnector(connector_weak_ptr connector) const; connector_weak_ptr getOppositeConnector(connector_weak_ptr connector) const;
connector_weak_ptr getSharedConnector() const; connector_weak_ptr getSharedConnector() const;
connector_weak_ptr getRotationConnector() const; connector_weak_ptr getRotationConnector() const;
voxel_weak_ptr getVoxelAt(enum class side s) const; voxel_weak_ptr getVoxelAt(side s) const;
voxel_weak_ptr getVoxelAt(glm::vec3 side_direction) const { return getVoxelAt(vec_to_enum(side_direction)); } voxel_weak_ptr getVoxelAt(glm::vec3 side_direction) const { return getVoxelAt(vec_to_enum(side_direction)); }
bool hasNoConnections() const { return connections.empty(); } bool hasNoConnections() const { return connections.empty(); }
bool hasSharedRotation() const; bool hasSharedRotation() const;
bool hasRotationConnector() const; bool hasRotationConnector() const;
bool slotCompatible(const enum class side s, const connector_type type) const; bool slotCompatible(const side s, const connector_type type) const;
bool slotCompatible(const glm::vec3 side_direction, const connector_type type) const { return slotCompatible(vec_to_enum(side_direction), type); } bool slotCompatible(const glm::vec3 side_direction, const connector_type type) const { return slotCompatible(vec_to_enum(side_direction), type); }
void restrictSlots(const enum class side s, connector_weak_ptr connector); void restrictSlots(const side s, connector_weak_ptr connector);
void releaseSlots(const enum class side s, connector_weak_ptr connector); void releaseSlots(const side s, connector_weak_ptr connector);
}; };
class ModuleLink : public Voxel class ModuleLink : public Voxel
{ {
using enum connector_type; using enum connector_type;
std::map<const enum class side, std::map<const enum class rofi::connector_type, bool>> slots = { std::map<const side, std::map<const rofi::connector_type, bool>> slots = {
{side::x_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::x_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}},
{side::x_neg, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::x_neg, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}},
{side::y_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::y_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}},
...@@ -120,7 +120,7 @@ public: ...@@ -120,7 +120,7 @@ public:
class PadBoard : public Voxel class PadBoard : public Voxel
{ {
using enum connector_type; using enum connector_type;
std::map<const enum class side, std::map<const enum class rofi::connector_type, bool>> slots = { std::map<const side, std::map<const rofi::connector_type, bool>> slots = {
{side::x_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::x_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}},
{side::x_neg, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::x_neg, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}},
{side::y_pos, {{fixed, false}, {open, true}, {rotation, false}, {shared_rotation, false}}}, {side::y_pos, {{fixed, false}, {open, true}, {rotation, false}, {shared_rotation, false}}},
......
...@@ -56,9 +56,9 @@ public: ...@@ -56,9 +56,9 @@ public:
voxel_ptr addVoxel(node_ptr node); voxel_ptr addVoxel(node_ptr node);
voxel_ptr addModuleLink(node_ptr node); voxel_ptr addModuleLink(node_ptr node);
voxel_ptr addPadBoard(node_ptr node); voxel_ptr addPadBoard(node_ptr node);
connector_ptr addConnector(node_ptr node, enum class connector_type t); connector_ptr addConnector(node_ptr node, connector_type t);
connector_ptr addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis); connector_ptr addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis);
connector_ptr addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction); connector_ptr addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction);
void removeVoxel(voxel_ptr voxel); void removeVoxel(voxel_ptr voxel);
void removeConnector(connector_ptr connector); void removeConnector(connector_ptr connector);
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
}; };
// NOTE: now only by position, no rotation taken into account // NOTE: now only by position, no rotation taken into account
enum class side in_proximity(connector_ptr connector, voxel_ptr voxel); side in_proximity(connector_ptr connector, voxel_ptr voxel);
} }
......
...@@ -127,7 +127,7 @@ voxel_weak_ptr Connector::getModuleLink() const ...@@ -127,7 +127,7 @@ voxel_weak_ptr Connector::getModuleLink() const
return connection.first; return connection.first;
} }
void Connector::connectVoxel(enum class side s, voxel_weak_ptr voxel) void Connector::connectVoxel(side s, voxel_weak_ptr voxel)
{ {
ASSUMPTION(!isFull()); ASSUMPTION(!isFull());
...@@ -355,7 +355,7 @@ std::shared_ptr<SharedRotationConnector> SharedRotationConnector::copy(std::shar ...@@ -355,7 +355,7 @@ std::shared_ptr<SharedRotationConnector> SharedRotationConnector::copy(std::shar
return std::shared_ptr<SharedRotationConnector>{ new SharedRotationConnector(*other_shared_rotation_connector) }; return std::shared_ptr<SharedRotationConnector>{ new SharedRotationConnector(*other_shared_rotation_connector) };
} }
enum class side vec_to_enum(glm::vec3 local_direction) side vec_to_enum(glm::vec3 local_direction)
{ {
using enum side; using enum side;
float epsilon = 0.0001f; float epsilon = 0.0001f;
......
...@@ -256,7 +256,7 @@ connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t) ...@@ -256,7 +256,7 @@ connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t)
return connections.back(); return connections.back();
} }
connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis) connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis)
{ {
using enum connector_type; using enum connector_type;
ASSUMPTION(t == shared_rotation); ASSUMPTION(t == shared_rotation);
...@@ -266,7 +266,7 @@ connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type ...@@ -266,7 +266,7 @@ connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type
return connections.back(); return connections.back();
} }
connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction) connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction)
{ {
using enum connector_type; using enum connector_type;
ASSUMPTION(t == rotation); ASSUMPTION(t == rotation);
...@@ -503,7 +503,7 @@ void VoxelGraph::joinImplicit() ...@@ -503,7 +503,7 @@ void VoxelGraph::joinImplicit()
} }
} }
enum class side in_proximity(connector_ptr connector, voxel_ptr voxel) side in_proximity(connector_ptr connector, voxel_ptr voxel)
{ {
// TO DO: adjust for rotations // TO DO: adjust for rotations
auto con_position = connector->getNode()->getPositionWorld(); auto con_position = connector->getNode()->getPositionWorld();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment