Skip to content

Commit

Permalink
Add world::get_info
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroErrors committed Aug 2, 2023
1 parent 36338a9 commit f913e08
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 106 deletions.
60 changes: 9 additions & 51 deletions flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19022,27 +19022,6 @@ struct world {
return m_world;
}

/** Get last delta_time.
*/
ecs_ftime_t delta_time() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->delta_time;
}

/** Get current tick.
*/
int64_t tick() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->frame_count_total;
}

/** Get current simulation time.
*/
ecs_ftime_t time() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->world_time_total;
}

/** Signal application should quit.
* After calling this operation, the next call to progress() returns false.
*/
Expand Down Expand Up @@ -20238,31 +20217,21 @@ void run_pipeline(const flecs::entity_t pip, ecs_ftime_t delta_time = 0.0) const
template <typename Pipeline, if_not_t< is_enum<Pipeline>::value > = 0>
void run_pipeline(ecs_ftime_t delta_time = 0.0) const;

/** Get the world info.
* @see ecs_get_world_info
*/
const flecs::world_info_t* get_info() const;

/** Set timescale.
* @see ecs_set_time_scale
*/
void set_time_scale(ecs_ftime_t mul) const;

/** Get timescale.
* @see ecs_get_time_scale
*/
ecs_ftime_t get_time_scale() const;

/** Get tick.
* @return Monotonically increasing frame count.
*/
int64_t get_tick() const;

/** Set target FPS.
* @see ecs_set_target_fps
*/
void set_target_fps(ecs_ftime_t target_fps) const;

/** Get target FPS.
* @return Configured frames per second.
*/
ecs_ftime_t get_target_fps() const;

/** Reset simulation clock.
* @see ecs_reset_clock
*/
Expand Down Expand Up @@ -28483,25 +28452,14 @@ inline void world::run_pipeline(ecs_ftime_t delta_time) const {
return ecs_run_pipeline(m_world, _::cpp_type<Pipeline>::id(m_world), delta_time);
}

inline void world::set_time_scale(ecs_ftime_t mul) const {
ecs_set_time_scale(m_world, mul);
}

inline ecs_ftime_t world::get_time_scale() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->time_scale;
const flecs::world_info_t* world::get_info() const {
return ecs_get_world_info(m_world);
}

inline int64_t world::get_tick() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->frame_count_total;
inline void world::set_time_scale(ecs_ftime_t mul) const {
ecs_set_time_scale(m_world, mul);
}

inline ecs_ftime_t world::get_target_fps() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->target_fps;
}

inline void world::set_target_fps(ecs_ftime_t target_fps) const {
ecs_set_target_fps(m_world, target_fps);
}
Expand Down
19 changes: 4 additions & 15 deletions include/flecs/addons/cpp/mixins/pipeline/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,14 @@ inline void world::run_pipeline(ecs_ftime_t delta_time) const {
return ecs_run_pipeline(m_world, _::cpp_type<Pipeline>::id(m_world), delta_time);
}

inline void world::set_time_scale(ecs_ftime_t mul) const {
ecs_set_time_scale(m_world, mul);
}

inline ecs_ftime_t world::get_time_scale() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->time_scale;
const flecs::world_info_t* world::get_info() const {
return ecs_get_world_info(m_world);
}

inline int64_t world::get_tick() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->frame_count_total;
inline void world::set_time_scale(ecs_ftime_t mul) const {
ecs_set_time_scale(m_world, mul);
}

inline ecs_ftime_t world::get_target_fps() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->target_fps;
}

inline void world::set_target_fps(ecs_ftime_t target_fps) const {
ecs_set_target_fps(m_world, target_fps);
}
Expand Down
20 changes: 5 additions & 15 deletions include/flecs/addons/cpp/mixins/pipeline/mixin.inl
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,21 @@ void run_pipeline(const flecs::entity_t pip, ecs_ftime_t delta_time = 0.0) const
template <typename Pipeline, if_not_t< is_enum<Pipeline>::value > = 0>
void run_pipeline(ecs_ftime_t delta_time = 0.0) const;

/** Get the world info.
* @see ecs_get_world_info
*/
const flecs::world_info_t* get_info() const;

/** Set timescale.
* @see ecs_set_time_scale
*/
void set_time_scale(ecs_ftime_t mul) const;

/** Get timescale.
* @see ecs_get_time_scale
*/
ecs_ftime_t get_time_scale() const;

/** Get tick.
* @return Monotonically increasing frame count.
*/
int64_t get_tick() const;

/** Set target FPS.
* @see ecs_set_target_fps
*/
void set_target_fps(ecs_ftime_t target_fps) const;

/** Get target FPS.
* @return Configured frames per second.
*/
ecs_ftime_t get_target_fps() const;

/** Reset simulation clock.
* @see ecs_reset_clock
*/
Expand Down
21 changes: 0 additions & 21 deletions include/flecs/addons/cpp/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,6 @@ struct world {
return m_world;
}

/** Get last delta_time.
*/
ecs_ftime_t delta_time() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->delta_time;
}

/** Get current tick.
*/
int64_t tick() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->frame_count_total;
}

/** Get current simulation time.
*/
ecs_ftime_t time() const {
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
return stats->world_time_total;
}

/** Signal application should quit.
* After calling this operation, the next call to progress() returns false.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/cpp_api/src/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void Misc_app_run_target_fps() {
int32_t count = 0;
ecs.system().iter([&](flecs::iter& it) {
count ++;
test_int(it.world().get_target_fps(), 10);
test_int(it.world().get_info()->target_fps, 10);
it.world().quit();
});

Expand Down
6 changes: 3 additions & 3 deletions test/cpp_api/src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,15 +1546,15 @@ void World_reset_all() {
void World_get_tick() {
flecs::world ecs;

test_int(ecs.tick(), 0);
test_int(ecs.get_info()->frame_count_total, 0);

ecs.progress();

test_int(ecs.tick(), 1);
test_int(ecs.get_info()->frame_count_total, 1);

ecs.progress();

test_int(ecs.tick(), 2);
test_int(ecs.get_info()->frame_count_total, 2);
}

struct Scope { };
Expand Down

0 comments on commit f913e08

Please sign in to comment.