feat(entities): derivar collision_radius del shape + scale/collision_factor al YAML
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -41,7 +40,12 @@ auto PlayerConfig::fromYaml(const fkyaml::node& node) -> std::optional<PlayerCon
|
||||
std::cerr << "[PlayerConfig] Error: falta 'shape.path'" << '\n';
|
||||
return std::nullopt;
|
||||
}
|
||||
cfg.shape.path = node["shape"]["path"].get_value<std::string>();
|
||||
const auto& shape = node["shape"];
|
||||
cfg.shape.path = shape["path"].get_value<std::string>();
|
||||
cfg.shape.scale = shape.contains("scale") ? shape["scale"].get_value<float>() : 1.0F;
|
||||
cfg.shape.collision_factor = shape.contains("collision_factor")
|
||||
? shape["collision_factor"].get_value<float>()
|
||||
: 1.0F;
|
||||
|
||||
// physics
|
||||
if (!node.contains("physics")) {
|
||||
@@ -53,7 +57,6 @@ auto PlayerConfig::fromYaml(const fkyaml::node& node) -> std::optional<PlayerCon
|
||||
cfg.physics.restitution = physics["restitution"].get_value<float>();
|
||||
cfg.physics.linear_damping = physics["linear_damping"].get_value<float>();
|
||||
cfg.physics.angular_damping = physics["angular_damping"].get_value<float>();
|
||||
cfg.physics.collision_radius = physics["collision_radius"].get_value<float>();
|
||||
cfg.physics.rotation_speed = physics["rotation_speed"].get_value<float>();
|
||||
cfg.physics.acceleration = physics["acceleration"].get_value<float>();
|
||||
cfg.physics.max_velocity = physics["max_velocity"].get_value<float>();
|
||||
|
||||
Reference in New Issue
Block a user