refactor enums: CursorShape, InterpolationType, ParticleSpawnShape
This commit is contained in:
@@ -1,26 +1,8 @@
|
||||
#define VC_ENABLE_REFLECTION
|
||||
|
||||
#include "ParticlesPreset.hpp"
|
||||
|
||||
#include "data/dv_util.hpp"
|
||||
|
||||
std::string to_string(ParticleSpawnShape shape) {
|
||||
static std::string names[] = {
|
||||
"ball",
|
||||
"sphere",
|
||||
"box"
|
||||
};
|
||||
return names[static_cast<int>(shape)];
|
||||
}
|
||||
|
||||
ParticleSpawnShape ParticleSpawnShape_from(std::string_view s) {
|
||||
if (s == "ball") {
|
||||
return ParticleSpawnShape::BALL;
|
||||
} else if (s == "sphere") {
|
||||
return ParticleSpawnShape::SPHERE;
|
||||
} else {
|
||||
return ParticleSpawnShape::BOX;
|
||||
}
|
||||
}
|
||||
|
||||
dv::value ParticlesPreset::serialize() const {
|
||||
auto root = dv::object();
|
||||
if (frames.empty()) {
|
||||
@@ -47,7 +29,7 @@ dv::value ParticlesPreset::serialize() const {
|
||||
root["min_angular_vel"] = minAngularVelocity;
|
||||
root["max_angular_vel"] = maxAngularVelocity;
|
||||
root["spawn_spread"] = dv::to_value(size);
|
||||
root["spawn_shape"] = to_string(spawnShape);
|
||||
root["spawn_shape"] = ParticleSpawnShapeMeta.getName(spawnShape);
|
||||
root["random_sub_uv"] = randomSubUV;
|
||||
return root;
|
||||
}
|
||||
@@ -82,7 +64,7 @@ void ParticlesPreset::deserialize(const dv::value& src) {
|
||||
dv::get_vec(src["explosion"], explosion);
|
||||
}
|
||||
if (src.has("spawn_shape")) {
|
||||
spawnShape = ParticleSpawnShape_from(src["spawn_shape"].asString());
|
||||
ParticleSpawnShapeMeta.getItem(src["spawn_shape"].asString(), spawnShape);
|
||||
}
|
||||
if (src.has("frames")) {
|
||||
for (const auto& frame : src["frames"]) {
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include "interfaces/Serializable.hpp"
|
||||
#include "util/EnumMetadata.hpp"
|
||||
|
||||
enum ParticleSpawnShape {
|
||||
enum class ParticleSpawnShape {
|
||||
/// @brief Coordinates are regulary distributed within
|
||||
/// the volume of a ball.
|
||||
BALL = 0,
|
||||
@@ -18,8 +19,11 @@ enum ParticleSpawnShape {
|
||||
BOX
|
||||
};
|
||||
|
||||
std::string to_string(ParticleSpawnShape shape);
|
||||
ParticleSpawnShape ParticleSpawnShape_from(std::string_view s);
|
||||
VC_ENUM_METADATA(ParticleSpawnShape)
|
||||
{"ball", ParticleSpawnShape::BALL},
|
||||
{"sphere", ParticleSpawnShape::SPHERE},
|
||||
{"box", ParticleSpawnShape::BOX},
|
||||
VC_ENUM_END
|
||||
|
||||
struct ParticlesPreset : public Serializable {
|
||||
/// @brief Collision detection
|
||||
@@ -53,7 +57,7 @@ struct ParticlesPreset : public Serializable {
|
||||
/// @brief Maximum angular velocity
|
||||
float maxAngularVelocity = 0.0f;
|
||||
/// @brief Spawn spread shape
|
||||
ParticleSpawnShape spawnShape = BALL;
|
||||
ParticleSpawnShape spawnShape = ParticleSpawnShape::BALL;
|
||||
/// @brief Spawn spread
|
||||
glm::vec3 spawnSpread {};
|
||||
/// @brief Texture name
|
||||
|
||||
Reference in New Issue
Block a user