switch to reverse z and get rid of tilt sign flip
This commit is contained in:
parent
538849e607
commit
3b7d593f4e
@ -874,27 +874,27 @@ namespace M {
|
||||
}
|
||||
|
||||
M4x4 view(V3 player_pos, float tilt, float camera_distance) {
|
||||
float s = sinf(-tilt);
|
||||
float c = cosf(-tilt);
|
||||
float s = sinf(tilt);
|
||||
float c = cosf(tilt);
|
||||
|
||||
return M4x4_(
|
||||
return {
|
||||
1, 0, 0, -player_pos.x,
|
||||
0, c, s, c * -player_pos.y,
|
||||
0, -s, c, s * player_pos.y + camera_distance,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
0, -s, c, s * player_pos.y - camera_distance,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
}
|
||||
|
||||
M4x4 inverse_view(V3 player_pos, float tilt, float camera_distance) {
|
||||
float s = sinf(-tilt);
|
||||
float c = cosf(-tilt);
|
||||
float s = sinf(tilt);
|
||||
float c = cosf(tilt);
|
||||
|
||||
return M4x4_(
|
||||
1, 0, 0, player_pos.x,
|
||||
0, c, -s, s * camera_distance + player_pos.y,
|
||||
0, s, c, c * -camera_distance,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
return {
|
||||
1, 0, 0, player_pos.x,
|
||||
0, c, -s, -s * camera_distance + player_pos.y,
|
||||
0, s, c, c * camera_distance,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
}
|
||||
|
||||
M4x4 projection(float fovy, float aspect, float near) {
|
||||
@ -904,7 +904,7 @@ namespace M {
|
||||
g / aspect, 0, 0, 0,
|
||||
0, g, 0, 0,
|
||||
0, 0, 0, near,
|
||||
0, 0, 1, 0,
|
||||
0, 0, -1, 0,
|
||||
};
|
||||
}
|
||||
|
||||
@ -912,10 +912,10 @@ namespace M {
|
||||
float g = 1.0 / tanf(fovy * 0.5);
|
||||
|
||||
return {
|
||||
aspect / g, 0, 0, 0,
|
||||
0, 1 / g, 0, 0,
|
||||
0, 0, 0, 1,
|
||||
0, 0, 1 / near, 0,
|
||||
aspect / g, 0, 0, 0,
|
||||
0, 1 / g, 0, 0,
|
||||
0, 0, 0, -1,
|
||||
0, 0, 1 / near, 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user