Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add world::get_info and remove unneeded functions #1015

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 7 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 @@ -19848,6 +19827,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 @@ -20243,26 +20229,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 @@ -28485,23 +28456,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