projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
patches player visibility
[carveJwlIkooP6JGAAIwe30JlM.git]
/
camera.h
diff --git
a/camera.h
b/camera.h
index dbacc26afd7d89f47308781caeef7767ae0f03e4..c1744d86f23f556deaad3f4e7c2bfc55a8f122ea 100644
(file)
--- a/
camera.h
+++ b/
camera.h
@@
-1,12
+1,10
@@
#ifndef CAMERA_H
#define CAMERA_H
#ifndef CAMERA_H
#define CAMERA_H
-#include "
common
.h"
+#include "
skaterift
.h"
typedef struct camera camera;
typedef struct camera camera;
-
-struct camera
-{
+struct camera{
/* Input */
v3f angles;
v3f pos;
/* Input */
v3f angles;
v3f pos;
@@
-16,19
+14,22
@@
struct camera
m4x3f transform,
transform_inverse;
m4x3f transform,
transform_inverse;
- struct camera_mtx
- {
+ struct camera_mtx{
m4x4f p,
v,
pv;
}
mtx,
mtx_prev;
m4x4f p,
v,
pv;
}
mtx,
mtx_prev;
+};
+
+static void camera_lerp_angles( v3f a, v3f b, float t, v3f d ){
+ d[0] = vg_alerpf( a[0], b[0], t );
+ d[1] = vg_lerpf( a[1], b[1], t );
+ d[2] = vg_lerpf( a[2], b[2], t );
}
}
-VG_STATIC main_camera;
-VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d )
-{
+static void camera_lerp( camera *a, camera *b, float t, camera *d ){
v3_lerp( a->pos, b->pos, t, d->pos );
d->angles[0] = vg_alerpf( a->angles[0], b->angles[0], t );
d->angles[1] = vg_lerpf( a->angles[1], b->angles[1], t );
v3_lerp( a->pos, b->pos, t, d->pos );
d->angles[0] = vg_alerpf( a->angles[0], b->angles[0], t );
d->angles[1] = vg_lerpf( a->angles[1], b->angles[1], t );
@@
-36,13
+37,19
@@
VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d )
d->fov = vg_lerpf( a->fov, b->fov, t );
}
d->fov = vg_lerpf( a->fov, b->fov, t );
}
+static void camera_copy( camera *a, camera *d ){
+ v3_copy( a->pos, d->pos );
+ v3_copy( a->angles, d->angles );
+ d->fov = a->fov;
+}
+
/*
* 1) [angles, pos] -> transform
*/
/*
* 1) [angles, pos] -> transform
*/
-
VG_STATIC
void camera_update_transform( camera *cam )
+
static
void camera_update_transform( camera *cam )
{
v4f qyaw, qpitch, qcam;
{
v4f qyaw, qpitch, qcam;
- q_axis_angle( qyaw,
(v3f){ 0.0f, 1.0f, 0.0f },
-cam->angles[0] );
+ q_axis_angle( qyaw,
(v3f){ 0.0f, 1.0f, 0.0f },
-cam->angles[0] );
q_axis_angle( qpitch, (v3f){ 1.0f, 0.0f, 0.0f }, -cam->angles[1] );
q_mul( qyaw, qpitch, qcam );
q_axis_angle( qpitch, (v3f){ 1.0f, 0.0f, 0.0f }, -cam->angles[1] );
q_mul( qyaw, qpitch, qcam );
@@
-53,7
+60,7
@@
VG_STATIC void camera_update_transform( camera *cam )
/*
* 2) [transform] -> transform_inverse, view matrix
*/
/*
* 2) [transform] -> transform_inverse, view matrix
*/
-
VG_STATIC
void camera_update_view( camera *cam )
+
static
void camera_update_view( camera *cam )
{
m4x4_copy( cam->mtx.v, cam->mtx_prev.v );
m4x3_invert_affine( cam->transform, cam->transform_inverse );
{
m4x4_copy( cam->mtx.v, cam->mtx_prev.v );
m4x3_invert_affine( cam->transform, cam->transform_inverse );
@@
-63,7
+70,7
@@
VG_STATIC void camera_update_view( camera *cam )
/*
* 3) [fov,nearz,farz] -> projection matrix
*/
/*
* 3) [fov,nearz,farz] -> projection matrix
*/
-
VG_STATIC
void camera_update_projection( camera *cam )
+
static
void camera_update_projection( camera *cam )
{
m4x4_copy( cam->mtx.p, cam->mtx_prev.p );
m4x4_projection( cam->mtx.p, cam->fov,
{
m4x4_copy( cam->mtx.p, cam->mtx_prev.p );
m4x4_projection( cam->mtx.p, cam->fov,
@@
-74,7
+81,7
@@
VG_STATIC void camera_update_projection( camera *cam )
/*
* 4) [projection matrix, view matrix] -> previous pv, new pv
*/
/*
* 4) [projection matrix, view matrix] -> previous pv, new pv
*/
-
VG_STATIC
void camera_finalize( camera *cam )
+
static
void camera_finalize( camera *cam )
{
m4x4_copy( cam->mtx.pv, cam->mtx_prev.pv );
m4x4_mul( cam->mtx.p, cam->mtx.v, cam->mtx.pv );
{
m4x4_copy( cam->mtx.pv, cam->mtx_prev.pv );
m4x4_mul( cam->mtx.p, cam->mtx.v, cam->mtx.pv );
@@
-83,7
+90,7
@@
VG_STATIC void camera_finalize( camera *cam )
/*
* http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
*/
/*
* http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
*/
-
VG_STATIC
void m4x4_clip_projection( m4x4f mat, v4f plane )
+
static
void m4x4_clip_projection( m4x4f mat, v4f plane )
{
v4f c =
{
{
v4f c =
{
@@
-104,7
+111,7
@@
VG_STATIC void m4x4_clip_projection( m4x4f mat, v4f plane )
/*
* Undoes the above operation
*/
/*
* Undoes the above operation
*/
-
VG_STATIC
void m4x4_reset_clipping( m4x4f mat, float ffar, float fnear )
+
static
void m4x4_reset_clipping( m4x4f mat, float ffar, float fnear )
{
mat[0][2] = 0.0f;
mat[1][2] = 0.0f;
{
mat[0][2] = 0.0f;
mat[1][2] = 0.0f;