mirror of
https://github.com/enduro2d/enduro2d.git
synced 2026-03-22 04:44:09 +07:00
add physics framerate parameter, ecs::entity formatter
This commit is contained in:
@@ -112,7 +112,7 @@ namespace e2d
|
||||
u32 minimal_framerate() const noexcept;
|
||||
u32 maximal_framerate() const noexcept;
|
||||
private:
|
||||
u32 minimal_framerate_{30u};
|
||||
u32 minimal_framerate_{15u};
|
||||
u32 maximal_framerate_{1000u};
|
||||
};
|
||||
|
||||
|
||||
@@ -124,3 +124,40 @@ namespace sol
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d::strings
|
||||
{
|
||||
template <>
|
||||
class format_arg<ecs::entity> {
|
||||
ecs::entity value_;
|
||||
u8 width_;
|
||||
public:
|
||||
template < typename U >
|
||||
explicit format_arg(U&& value, u8 width = 0) noexcept
|
||||
: value_(std::forward<U>(value)), width_(width) {}
|
||||
|
||||
std::ptrdiff_t write(char* dst, size_t size) const {
|
||||
return math::numeric_cast<std::ptrdiff_t>(
|
||||
format(dst, size, "(%0,%1)",
|
||||
make_format_arg(ecs::detail::entity_id_index(value_.id()), width_),
|
||||
make_format_arg(ecs::detail::entity_id_version(value_.id()), width_)));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class format_arg<ecs::const_entity> {
|
||||
ecs::const_entity value_;
|
||||
u8 width_;
|
||||
public:
|
||||
template < typename U >
|
||||
explicit format_arg(U&& value, u8 width = 0) noexcept
|
||||
: value_(std::forward<U>(value)), width_(width) {}
|
||||
|
||||
std::ptrdiff_t write(char* dst, size_t size) const {
|
||||
return math::numeric_cast<std::ptrdiff_t>(
|
||||
format(dst, size, "(%0,%1)",
|
||||
make_format_arg(ecs::detail::entity_id_index(value_.id()), width_),
|
||||
make_format_arg(ecs::detail::entity_id_version(value_.id()), width_)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace e2d
|
||||
~physics() noexcept final;
|
||||
|
||||
const v2f& gravity() const noexcept;
|
||||
u32 update_framerate() const noexcept;
|
||||
u32 velocity_iterations() const noexcept;
|
||||
u32 position_iterations() const noexcept;
|
||||
private:
|
||||
|
||||
@@ -62,16 +62,19 @@ namespace e2d
|
||||
class starter::physics_parameters {
|
||||
public:
|
||||
physics_parameters& gravity(const v2f& value) noexcept;
|
||||
physics_parameters& update_framerate(u32 value) noexcept;
|
||||
physics_parameters& velocity_iterations(u32 value) noexcept;
|
||||
physics_parameters& position_iterations(u32 value) noexcept;
|
||||
|
||||
const v2f& gravity() const noexcept;
|
||||
u32 update_framerate() const noexcept;
|
||||
u32 velocity_iterations() const noexcept;
|
||||
u32 position_iterations() const noexcept;
|
||||
private:
|
||||
v2f gravity_ = v2f::zero();
|
||||
u32 velocity_iterations_ = 8u;
|
||||
u32 position_iterations_ = 3u;
|
||||
u32 update_framerate_ = 50u;
|
||||
u32 velocity_iterations_ = 6u;
|
||||
u32 position_iterations_ = 2u;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@@ -17,6 +17,10 @@ namespace e2d
|
||||
return params_.gravity();
|
||||
}
|
||||
|
||||
u32 physics::update_framerate() const noexcept {
|
||||
return params_.update_framerate();
|
||||
}
|
||||
|
||||
u32 physics::velocity_iterations() const noexcept {
|
||||
return params_.velocity_iterations();
|
||||
}
|
||||
|
||||
@@ -189,6 +189,11 @@ namespace e2d
|
||||
return *this;
|
||||
}
|
||||
|
||||
starter::physics_parameters& starter::physics_parameters::update_framerate(u32 value) noexcept {
|
||||
update_framerate_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
starter::physics_parameters& starter::physics_parameters::velocity_iterations(u32 value) noexcept {
|
||||
velocity_iterations_ = value;
|
||||
return *this;
|
||||
@@ -203,6 +208,10 @@ namespace e2d
|
||||
return gravity_;
|
||||
}
|
||||
|
||||
u32 starter::physics_parameters::update_framerate() const noexcept {
|
||||
return update_framerate_;
|
||||
}
|
||||
|
||||
u32 starter::physics_parameters::velocity_iterations() const noexcept {
|
||||
return velocity_iterations_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user