mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
add 'frames' particles setting
This commit is contained in:
parent
39893ee940
commit
b9b122dc83
6 changed files with 48 additions and 1 deletions
|
|
@ -36,6 +36,12 @@ dv::value ParticlesPreset::serialize() const {
|
|||
root["spawn_spread"] = dv::to_value(size);
|
||||
root["spawn_shape"] = to_string(spawnShape);
|
||||
root["random_sub_uv"] = randomSubUV;
|
||||
if (!frames.empty()) {
|
||||
auto& arr = root.list("animation");
|
||||
for (const auto& frame : frames) {
|
||||
arr.add(frame);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
@ -63,4 +69,13 @@ void ParticlesPreset::deserialize(const dv::value& src) {
|
|||
if (src.has("spawn_shape")) {
|
||||
spawnShape = ParticleSpawnShape_from(src["spawn_shape"].asString());
|
||||
}
|
||||
if (src.has("frames")) {
|
||||
for (const auto& frame : src["frames"]) {
|
||||
frames.push_back(frame.asString());
|
||||
}
|
||||
if (!frames.empty()) {
|
||||
texture = frames.at(0);
|
||||
randomSubUV = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ struct ParticlesPreset : public Serializable {
|
|||
std::string texture = "";
|
||||
/// @brief Size of random sub-uv region
|
||||
float randomSubUV = 1.0f;
|
||||
/// @brief Animation frames
|
||||
std::vector<std::string> frames {};
|
||||
|
||||
dv::value serialize() const override;
|
||||
void deserialize(const dv::value& src) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue