Add configuration option for ghost reset distance. Improve documentation.
This commit is contained in:
@@ -8,6 +8,7 @@ Player::Player(glm::vec3 startpos, float startyaw) {
|
||||
position = startpos;
|
||||
yaw = startyaw;
|
||||
|
||||
// Initialize neutral view/camera defaults; yaw follows spawn while pitch starts level.
|
||||
pitch = 0.0f;
|
||||
first_mouse = false;
|
||||
first_frame = false;
|
||||
@@ -66,6 +67,7 @@ float Player::get_fov() {
|
||||
|
||||
void Player::mouse_callback(GLFWwindow* window, double xposI, double yposI) {
|
||||
|
||||
// Track relative mouse deltas to drive FPS-style look controls.
|
||||
float xpos = static_cast<float>(xposI);
|
||||
float ypos = static_cast<float>(yposI);
|
||||
|
||||
@@ -102,6 +104,7 @@ void Player::mouse_callback(GLFWwindow* window, double xposI, double yposI) {
|
||||
|
||||
void Player::process_input(GLFWwindow *window)
|
||||
{
|
||||
// Poll keyboard state and convert to world-space velocity.
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
@@ -185,6 +188,7 @@ bool Player::is_in_air() {
|
||||
|
||||
void Player::set_light_offset(float xoffset, float yoffset) {
|
||||
|
||||
// Ease in flashlight offsets so the beam trails behind head motion.
|
||||
xoffset *= light_movement_multiplier;
|
||||
yoffset *= light_movement_multiplier;
|
||||
|
||||
@@ -205,6 +209,7 @@ void Player::set_light_offset(float xoffset, float yoffset) {
|
||||
|
||||
void Player::apply_movement(float timed) {
|
||||
|
||||
// Apply accumulated mouse/keyboard input, then integrate velocity with collision resolution.
|
||||
// mouse movement
|
||||
glm::vec3 front;
|
||||
front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
|
||||
@@ -274,6 +279,7 @@ glm::vec3 Player::get_vec3_from_indices(int ix, int jx) {
|
||||
|
||||
glm::vec3 Player::check_intersection(glm::vec3 movement) {
|
||||
|
||||
// Raycast against wall quads to zero out components that would clip into geometry.
|
||||
glm::vec3 vec_start, vec_stop, p1, p2, p3, res;
|
||||
bool gotX = false, gotZ = false;
|
||||
vec_start = get_camera_pos();
|
||||
@@ -286,6 +292,7 @@ glm::vec3 Player::check_intersection(glm::vec3 movement) {
|
||||
if (gotX && gotZ) {
|
||||
break;
|
||||
}
|
||||
// Only test faces whose normals oppose our intended direction.
|
||||
glm::vec3 norm = get_normal_from_index(ix);
|
||||
if (!gotX) {
|
||||
if ((movement.x > 0 && norm.x < 0) || (movement.x < 0 && norm.x > 0)) {
|
||||
@@ -324,4 +331,3 @@ void Player::scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
||||
fov = 90.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user