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 "camera.h"
|
||||
#include "entity_view.h"
|
||||
#include "game.h"
|
||||
|
||||
#define CAMERA_LERP_FACTOR 0.13
|
||||
|
||||
static camera main_camera;
|
||||
|
||||
void camera_reset(void) {
|
||||
zpl_zero_item(&main_camera);
|
||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||
main_camera.first_time = true;
|
||||
}
|
||||
|
||||
void camera_update(void) {
|
||||
switch (main_camera.mode) {
|
||||
case CAMERA_MODE_FOLLOW: {
|
||||
world_view *world = game_world_view_get_active();
|
||||
if (!world) 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);
|
||||
main_camera.y = zpl_lerp(main_camera.y, view->y, CAMERA_LERP_FACTOR);
|
||||
|
||||
if (main_camera.first_time) {
|
||||
main_camera.first_time = false;
|
||||
main_camera.x = view->x;
|
||||
main_camera.y = view->y;
|
||||
}
|
||||
}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_pos(double x, double y) {
|
||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||
main_camera.x = x;
|
||||
main_camera.y = y;
|
||||
}
|
||||
camera camera_get(void) {
|
||||
return main_camera;
|
||||
}
|
||||
#include "zpl.h"
|
||||
#include "camera.h"
|
||||
#include "platform.h"
|
||||
#include "entity_view.h"
|
||||
#include "game.h"
|
||||
|
||||
#define CAMERA_LERP_FACTOR 11.2f
|
||||
|
||||
static camera main_camera;
|
||||
|
||||
void camera_reset(void) {
|
||||
zpl_zero_item(&main_camera);
|
||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||
main_camera.first_time = true;
|
||||
}
|
||||
|
||||
void camera_update(void) {
|
||||
switch (main_camera.mode) {
|
||||
case CAMERA_MODE_FOLLOW: {
|
||||
world_view *world = game_world_view_get_active();
|
||||
if (!world) break;
|
||||
entity_view *view = entity_view_get(&world->entities, main_camera.ent_id);
|
||||
if (!view) break;
|
||||
float smooth_ms = zpl_clamp((float)platform_frametime(), 0.0f, 1.0f);
|
||||
|
||||
main_camera.x = zpl_lerp(main_camera.x, view->x, CAMERA_LERP_FACTOR*smooth_ms);
|
||||
main_camera.y = zpl_lerp(main_camera.y, view->y, CAMERA_LERP_FACTOR*smooth_ms);
|
||||
|
||||
if (main_camera.first_time) {
|
||||
main_camera.first_time = false;
|
||||
main_camera.x = view->x;
|
||||
main_camera.y = view->y;
|
||||
}
|
||||
}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_pos(double x, double y) {
|
||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||
main_camera.x = x;
|
||||
main_camera.y = y;
|
||||
}
|
||||
camera camera_get(void) {
|
||||
return main_camera;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "world/world.h"
|
||||
#include "game.h"
|
||||
|
||||
#define PREDICT_SMOOTH_FACTOR_LO 10.5
|
||||
#define PREDICT_SMOOTH_FACTOR_HI 20.5
|
||||
#define PREDICT_SMOOTH_FACTOR_LO 7.5
|
||||
#define PREDICT_SMOOTH_FACTOR_HI 12.5
|
||||
|
||||
static inline float map_factor(float 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;
|
||||
}
|
||||
|
||||
#define ENTITY_DO_LERP_SP 1
|
||||
#define ENTITY_DO_LERP_SP 0
|
||||
|
||||
void lerp_entity_positions(uint64_t key, entity_view *data) {
|
||||
(void)key;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define WORLD_LAYERING 0
|
||||
#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_SLOW_MS 100
|
||||
#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_STEER 9.89f
|
||||
#define VEHICLE_STEER_REVERT 6.0941816f
|
||||
#define VEHICLE_POWER 34.89f
|
||||
#define VEHICLE_POWER 97.89f
|
||||
#define VEHICLE_BRAKE_FORCE 0.84f
|
||||
|
||||
void VehicleHandling(ecs_iter_t *it) {
|
||||
|
|
Loading…
Reference in New Issue