Improve overall motion + single-player now pushes out fast layer as fast as possible
parent
a607515424
commit
a589845065
|
@ -1,50 +1,52 @@
|
||||||
#include "zpl.h"
|
#include "zpl.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "entity_view.h"
|
#include "platform.h"
|
||||||
#include "game.h"
|
#include "entity_view.h"
|
||||||
|
#include "game.h"
|
||||||
#define CAMERA_LERP_FACTOR 0.13
|
|
||||||
|
#define CAMERA_LERP_FACTOR 11.2f
|
||||||
static camera main_camera;
|
|
||||||
|
static camera main_camera;
|
||||||
void camera_reset(void) {
|
|
||||||
zpl_zero_item(&main_camera);
|
void camera_reset(void) {
|
||||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
zpl_zero_item(&main_camera);
|
||||||
main_camera.first_time = true;
|
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||||
}
|
main_camera.first_time = true;
|
||||||
|
}
|
||||||
void camera_update(void) {
|
|
||||||
switch (main_camera.mode) {
|
void camera_update(void) {
|
||||||
case CAMERA_MODE_FOLLOW: {
|
switch (main_camera.mode) {
|
||||||
world_view *world = game_world_view_get_active();
|
case CAMERA_MODE_FOLLOW: {
|
||||||
if (!world) break;
|
world_view *world = game_world_view_get_active();
|
||||||
entity_view *view = entity_view_get(&world->entities, main_camera.ent_id);
|
if (!world) break;
|
||||||
if (!view) break;
|
entity_view *view = entity_view_get(&world->entities, main_camera.ent_id);
|
||||||
|
if (!view) break;
|
||||||
main_camera.x = zpl_lerp(main_camera.x, view->x, CAMERA_LERP_FACTOR);
|
float smooth_ms = zpl_clamp((float)platform_frametime(), 0.0f, 1.0f);
|
||||||
main_camera.y = zpl_lerp(main_camera.y, view->y, CAMERA_LERP_FACTOR);
|
|
||||||
|
main_camera.x = zpl_lerp(main_camera.x, view->x, CAMERA_LERP_FACTOR*smooth_ms);
|
||||||
if (main_camera.first_time) {
|
main_camera.y = zpl_lerp(main_camera.y, view->y, CAMERA_LERP_FACTOR*smooth_ms);
|
||||||
main_camera.first_time = false;
|
|
||||||
main_camera.x = view->x;
|
if (main_camera.first_time) {
|
||||||
main_camera.y = view->y;
|
main_camera.first_time = false;
|
||||||
}
|
main_camera.x = view->x;
|
||||||
}break;
|
main_camera.y = view->y;
|
||||||
|
}
|
||||||
default: {
|
}break;
|
||||||
|
|
||||||
}break;
|
default: {
|
||||||
}
|
|
||||||
}
|
}break;
|
||||||
void camera_set_follow(uint64_t ent_id) {
|
}
|
||||||
main_camera.mode = CAMERA_MODE_FOLLOW;
|
}
|
||||||
main_camera.ent_id = ent_id;
|
void camera_set_follow(uint64_t ent_id) {
|
||||||
}
|
main_camera.mode = CAMERA_MODE_FOLLOW;
|
||||||
void camera_set_pos(double x, double y) {
|
main_camera.ent_id = ent_id;
|
||||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
}
|
||||||
main_camera.x = x;
|
void camera_set_pos(double x, double y) {
|
||||||
main_camera.y = y;
|
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||||
}
|
main_camera.x = x;
|
||||||
camera camera_get(void) {
|
main_camera.y = y;
|
||||||
return main_camera;
|
}
|
||||||
}
|
camera camera_get(void) {
|
||||||
|
return main_camera;
|
||||||
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#define PREDICT_SMOOTH_FACTOR_LO 10.5
|
#define PREDICT_SMOOTH_FACTOR_LO 7.5
|
||||||
#define PREDICT_SMOOTH_FACTOR_HI 20.5
|
#define PREDICT_SMOOTH_FACTOR_HI 12.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);
|
||||||
|
@ -69,7 +69,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 1
|
#define ENTITY_DO_LERP_SP 0
|
||||||
|
|
||||||
void lerp_entity_positions(uint64_t key, entity_view *data) {
|
void lerp_entity_positions(uint64_t key, entity_view *data) {
|
||||||
(void)key;
|
(void)key;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#define WORLD_LAYERING 0
|
#define WORLD_LAYERING 0
|
||||||
#define WORLD_TRACKER_LAYERS 3
|
#define WORLD_TRACKER_LAYERS 3
|
||||||
#define WORLD_TRACKER_UPDATE_FAST_MS 10
|
#define WORLD_TRACKER_UPDATE_FAST_MS 0
|
||||||
#define WORLD_TRACKER_UPDATE_NORMAL_MS 50
|
#define WORLD_TRACKER_UPDATE_NORMAL_MS 50
|
||||||
#define WORLD_TRACKER_UPDATE_SLOW_MS 100
|
#define WORLD_TRACKER_UPDATE_SLOW_MS 100
|
||||||
#define WORLD_TRACKER_UPDATE_MP_FAST_MS 50
|
#define WORLD_TRACKER_UPDATE_MP_FAST_MS 50
|
||||||
|
|
|
@ -82,7 +82,7 @@ void EnterVehicle(ecs_iter_t *it) {
|
||||||
#define VEHICLE_DECEL 0.28f
|
#define VEHICLE_DECEL 0.28f
|
||||||
#define VEHICLE_STEER 9.89f
|
#define VEHICLE_STEER 9.89f
|
||||||
#define VEHICLE_STEER_REVERT 6.0941816f
|
#define VEHICLE_STEER_REVERT 6.0941816f
|
||||||
#define VEHICLE_POWER 34.89f
|
#define VEHICLE_POWER 97.89f
|
||||||
#define VEHICLE_BRAKE_FORCE 0.84f
|
#define VEHICLE_BRAKE_FORCE 0.84f
|
||||||
|
|
||||||
void VehicleHandling(ecs_iter_t *it) {
|
void VehicleHandling(ecs_iter_t *it) {
|
||||||
|
|
Loading…
Reference in New Issue