Skip to content

Commit

Permalink
#1015 Add world::get_info and remove unneeded functions
Browse files Browse the repository at this point in the history
* Add world::get_info

* Move world::get_info out of pipeline mixin
  • Loading branch information
ZeroErrors authored Aug 3, 2023
1 parent bc3ec54 commit 40c89f4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 106 deletions.
58 changes: 7 additions & 51 deletions flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19023,27 +19023,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 @@ -19849,6 +19828,13 @@ struct world {
ecs_run_post_frame(m_world, action, ctx);
}

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

/**
* @file addons/cpp/mixins/id/mixin.inl
* @brief Id world mixin.
Expand Down Expand Up @@ -20244,26 +20230,11 @@ void run_pipeline(ecs_ftime_t delta_time = 0.0) const;
*/
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 @@ -28486,23 +28457,8 @@ inline void world::run_pipeline(ecs_ftime_t delta_time) const {

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;
}

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 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
15 changes: 0 additions & 15 deletions include/flecs/addons/cpp/mixins/pipeline/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,8 @@ inline void world::run_pipeline(ecs_ftime_t delta_time) const {

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;
}

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 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
15 changes: 0 additions & 15 deletions include/flecs/addons/cpp/mixins/pipeline/mixin.inl
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,11 @@ void run_pipeline(ecs_ftime_t delta_time = 0.0) const;
*/
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
28 changes: 7 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 Expand Up @@ -1008,6 +987,13 @@ struct world {
ecs_run_post_frame(m_world, action, ctx);
}

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

# include "mixins/id/mixin.inl"
# include "mixins/component/mixin.inl"
# include "mixins/entity/mixin.inl"
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 40c89f4

Please sign in to comment.