use MP update rate

isolation_bkp/dynres
Dominik Madarász 2022-09-14 09:03:00 +00:00 committed by GitHub
parent 9f60890a20
commit 3436bed2ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 9 deletions

View File

@ -62,7 +62,7 @@ void predict_receive_update(entity_view *d, entity_view *data) {
data->tran_time = d->tran_time; data->tran_time = d->tran_time;
} }
#define ENTITY_DO_LERP_SP 0 #define ENTITY_DO_LERP_SP 1
void lerp_entity_positions(uint64_t key, entity_view *data) { void lerp_entity_positions(uint64_t key, entity_view *data) {
(void)key; (void)key;

View File

@ -4,6 +4,8 @@
#define PROF_COLLATE_WINDOW 0.5 #define PROF_COLLATE_WINDOW 0.5
static float profiler_warmup = 3.0f;
// NOTE(zaklaus): KEEP ORDER IN SYNC WITH profiler_kind ENUM !!! // NOTE(zaklaus): KEEP ORDER IN SYNC WITH profiler_kind ENUM !!!
static profiler profilers[] = { static profiler profilers[] = {
{ .id = PROF_TOTAL_TIME, .name = "measured time" }, { .id = PROF_TOTAL_TIME, .name = "measured time" },
@ -33,6 +35,13 @@ void profiler_stop(profiler_kind id) {
} }
void profiler_collate() { void profiler_collate() {
if (profiler_warmup > 0) {
profiler_warmup -= GetFrameTime();
for (uint32_t i = PROF_MAIN_LOOP; i < MAX_PROF; i += 1) {
profiler_reset(i);
}
return;
}
static double frame_counter = 0.0; static double frame_counter = 0.0;
static uint64_t frames = 0; static uint64_t frames = 0;

View File

@ -14,6 +14,8 @@
#include "packets/pkt_send_librg_update.h" #include "packets/pkt_send_librg_update.h"
#define ECO2D_STREAM_ACTIONFILTER 1
ZPL_TABLE(static, world_snapshot, world_snapshot_, entity_view); ZPL_TABLE(static, world_snapshot, world_snapshot_, entity_view);
static world_data world = {0}; static world_data world = {0};
@ -350,15 +352,17 @@ int32_t world_update() {
ecs_progress(world.ecs, 0.0f); ecs_progress(world.ecs, 0.0f);
} }
float fast_ms = WORLD_TRACKER_UPDATE_FAST_MS; float fast_ms = WORLD_TRACKER_UPDATE_MP_FAST_MS;
float normal_ms = WORLD_TRACKER_UPDATE_NORMAL_MS; float normal_ms = WORLD_TRACKER_UPDATE_MP_NORMAL_MS;
float slow_ms = WORLD_TRACKER_UPDATE_SLOW_MS; float slow_ms = WORLD_TRACKER_UPDATE_MP_SLOW_MS;
if (game_get_kind() != GAMEKIND_SINGLE) { #if 0
fast_ms = WORLD_TRACKER_UPDATE_MP_FAST_MS; if (game_get_kind() == GAMEKIND_SINGLE) {
normal_ms = WORLD_TRACKER_UPDATE_MP_NORMAL_MS; fast_ms = WORLD_TRACKER_UPDATE_FAST_MS;
slow_ms = WORLD_TRACKER_UPDATE_MP_SLOW_MS; normal_ms = WORLD_TRACKER_UPDATE_NORMAL_MS;
slow_ms = WORLD_TRACKER_UPDATE_SLOW_MS;
} }
#endif
world_tracker_update(0, fast_ms, 1); world_tracker_update(0, fast_ms, 1);
world_tracker_update(1, normal_ms, 2); world_tracker_update(1, normal_ms, 2);

View File

@ -27,6 +27,9 @@ void IntegratePositions(ecs_iter_t *it) {
Velocity *v = ecs_field(it, Velocity, 2); Velocity *v = ecs_field(it, Velocity, 2);
for (int i = 0; i < it->count; i++) { for (int i = 0; i < it->count; i++) {
if (ecs_get(it->world, it->entities[i], IsInVehicle)) {
continue;
}
if (zpl_abs(v[i].x) >= 0.001f || zpl_abs(v[i].y) >= 0.001f) { if (zpl_abs(v[i].x) >= 0.001f || zpl_abs(v[i].y) >= 0.001f) {
// NOTE(zaklaus): world bounds // NOTE(zaklaus): world bounds
{ {
@ -129,6 +132,9 @@ void ApplyWorldDragOnVelocity(ecs_iter_t *it) {
for (int i = 0; i < it->count; i++) { for (int i = 0; i < it->count; i++) {
if (zpl_abs(v[i].x) < 0.001f && zpl_abs(v[i].y) < 0.001f) continue; if (zpl_abs(v[i].x) < 0.001f && zpl_abs(v[i].y) < 0.001f) continue;
if (ecs_get(it->world, it->entities[i], IsInVehicle)) {
continue;
}
world_block_lookup lookup = world_block_from_realpos(p[i].x, p[i].y); world_block_lookup lookup = world_block_from_realpos(p[i].x, p[i].y);
float drag = zpl_clamp(blocks_get_drag(lookup.bid), 0.0f, 1.0f); float drag = zpl_clamp(blocks_get_drag(lookup.bid), 0.0f, 1.0f);
float friction = blocks_get_friction(lookup.bid); float friction = blocks_get_friction(lookup.bid);

View File

@ -156,7 +156,7 @@ void VehicleHandling(ecs_iter_t *it) {
// NOTE(zaklaus): Update passenger position // NOTE(zaklaus): Update passenger position
{ {
Velocity *v2 = ecs_get_mut(it->world, pe, Velocity); Velocity *v2 = ecs_get_mut(it->world, pe, Velocity);
entity_set_position(pe, p[i].x+v[i].x, p[i].y+v[i].y); entity_set_position(pe, p[i].x, p[i].y);
*v2 = v[i]; *v2 = v[i];
} }
} }