mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-04 04:37:55 +03:00
Update camera before draw
This commit is contained in:
+8
-4
@@ -246,15 +246,19 @@ void camera::set_position(const vec3&& pos) {
|
||||
}
|
||||
|
||||
void camera::update() {
|
||||
update_data();
|
||||
|
||||
fast_change_hist1 = fast_change_hist0;
|
||||
fast_change_hist0 = fast_change;
|
||||
fast_change = false;
|
||||
}
|
||||
|
||||
void camera::update_data() {
|
||||
camera_calculate_projection(this);
|
||||
camera_calculate_view(this);
|
||||
|
||||
mat4_mul(&view, &projection, &view_projection);
|
||||
mat4_invert(&view_projection, &inv_view_projection);
|
||||
|
||||
fast_change_hist1 = fast_change_hist0;
|
||||
fast_change_hist0 = fast_change;
|
||||
fast_change = false;
|
||||
}
|
||||
|
||||
static void camera_calculate_forward(camera* c) {
|
||||
|
||||
@@ -98,6 +98,7 @@ struct camera {
|
||||
void set_position(const vec3& pos);
|
||||
void set_position(const vec3&& pos);
|
||||
void update();
|
||||
void update_data();
|
||||
};
|
||||
|
||||
struct cam_struct {
|
||||
|
||||
@@ -1154,15 +1154,19 @@ void image_filter_scale(RenderTexture* dst, texture* src, const vec4& scale) {
|
||||
void draw_pass_set_camera() {
|
||||
render_context* rctx = rctx_ptr;
|
||||
camera* cam = rctx->camera;
|
||||
cam->update_data();
|
||||
rctx->view_mat = cam->view;
|
||||
rctx->proj_mat = cam->projection;
|
||||
rctx->vp_mat = cam->view_projection;
|
||||
rctx->obj_scene.set_projection_view(cam->view, cam->projection);
|
||||
rctx->obj_scene.set_projection_view(rctx->view_mat, rctx->proj_mat);
|
||||
cam->get_view_point(rctx->obj_scene.g_view_position);
|
||||
rctx->obj_scene.g_view_position.w = 0.0f;
|
||||
|
||||
float_t max_distance = cam->max_distance;
|
||||
float_t min_distance = cam->min_distance;
|
||||
rctx->g_near_far = {
|
||||
(float_t)(cam->max_distance / (cam->max_distance - cam->min_distance)),
|
||||
(float_t)(-(cam->max_distance * cam->min_distance) / (cam->max_distance - cam->min_distance)),
|
||||
(float_t)(max_distance / (max_distance - min_distance)),
|
||||
(float_t)(-(max_distance * min_distance) / (max_distance - min_distance)),
|
||||
0.0f, 0.0f
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user