Improve prediction calculations
parent
e7f55985db
commit
7059e881fb
|
@ -205,7 +205,7 @@ static ecs_entity_t *demo_npcs = NULL;
|
||||||
void
|
void
|
||||||
ActSpawnDemoNPCs(void) {
|
ActSpawnDemoNPCs(void) {
|
||||||
if (!demo_npcs) zpl_array_init(demo_npcs, zpl_heap());
|
if (!demo_npcs) zpl_array_init(demo_npcs, zpl_heap());
|
||||||
if (zpl_array_count(demo_npcs) >= 10000) return;
|
if (zpl_array_count(demo_npcs) >= 100000) return;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 1000; i++) {
|
for (uint32_t i = 0; i < 1000; i++) {
|
||||||
uint64_t e = entity_spawn(EKIND_DEMO_NPC);
|
uint64_t e = entity_spawn(EKIND_DEMO_NPC);
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#define PREDICT_SMOOTH_FACTOR_LO 0.10
|
#define PREDICT_SMOOTH_FACTOR_LO 10.5
|
||||||
#define PREDICT_SMOOTH_FACTOR_HI 0.01
|
#define PREDICT_SMOOTH_FACTOR_HI 20.5
|
||||||
|
|
||||||
static inline float map_factor(float x) {
|
static inline float map_factor(float x) {
|
||||||
x = 1.0f - zpl_clamp01(x);
|
x = 1.0f - zpl_clamp01(x);
|
||||||
|
@ -42,13 +42,13 @@ float smooth_val(float cur, float tgt, uint64_t dt) {
|
||||||
zpl_exit(0);
|
zpl_exit(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return zpl_lerp(cur, tgt, zpl_lerp(PREDICT_SMOOTH_FACTOR_LO, PREDICT_SMOOTH_FACTOR_HI, factor));
|
return zpl_lerp(cur, tgt, zpl_lerp(PREDICT_SMOOTH_FACTOR_LO, PREDICT_SMOOTH_FACTOR_HI, factor)*platform_frametime());
|
||||||
}
|
}
|
||||||
|
|
||||||
float smooth_val_spherical(float cur, float tgt, uint64_t dt) {
|
float smooth_val_spherical(float cur, float tgt, uint64_t dt) {
|
||||||
float factor = zpl_clamp01(map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_MP_FAST_MS, WORLD_TRACKER_UPDATE_MP_SLOW_MS)));
|
float factor = zpl_clamp01(map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_MP_FAST_MS, WORLD_TRACKER_UPDATE_MP_SLOW_MS)));
|
||||||
|
|
||||||
return spherical_lerp(cur, tgt, zpl_lerp(PREDICT_SMOOTH_FACTOR_LO, PREDICT_SMOOTH_FACTOR_HI, factor));
|
return spherical_lerp(cur, tgt, zpl_lerp(PREDICT_SMOOTH_FACTOR_LO, PREDICT_SMOOTH_FACTOR_HI, factor)*platform_frametime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void predict_receive_update(entity_view *d, entity_view *data) {
|
void predict_receive_update(entity_view *d, entity_view *data) {
|
||||||
|
|
Loading…
Reference in New Issue