mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
add EnumMetadata
This commit is contained in:
parent
d888ddec4c
commit
7749675a61
20 changed files with 156 additions and 206 deletions
|
|
@ -2,26 +2,6 @@
|
|||
|
||||
#include <stdexcept>
|
||||
|
||||
std::optional<BodyType> BodyType_from(std::string_view str) {
|
||||
if (str == "kinematic") {
|
||||
return BodyType::KINEMATIC;
|
||||
} else if (str == "dynamic") {
|
||||
return BodyType::DYNAMIC;
|
||||
} else if (str == "static") {
|
||||
return BodyType::STATIC;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string to_string(BodyType type) {
|
||||
switch (type) {
|
||||
case BodyType::KINEMATIC: return "kinematic";
|
||||
case BodyType::DYNAMIC: return "dynamic";
|
||||
case BodyType::STATIC: return "static";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
Hitbox::Hitbox(BodyType type, glm::vec3 position, glm::vec3 halfsize)
|
||||
: type(type),
|
||||
position(position),
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
#include "maths/aabb.hpp"
|
||||
#include "typedefs.hpp"
|
||||
#include "util/EnumMetadata.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
|
@ -41,8 +41,11 @@ enum class BodyType {
|
|||
STATIC, KINEMATIC, DYNAMIC
|
||||
};
|
||||
|
||||
std::optional<BodyType> BodyType_from(std::string_view str);
|
||||
std::string to_string(BodyType type);
|
||||
VC_ENUM_METADATA(BodyType)
|
||||
{"static", BodyType::STATIC},
|
||||
{"kinematic", BodyType::KINEMATIC},
|
||||
{"dynamic", BodyType::DYNAMIC},
|
||||
VC_ENUM_END
|
||||
|
||||
struct Hitbox {
|
||||
BodyType type;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue