And also made the camera react to gravity, not fall through the floor

This commit is contained in:
2018-02-08 00:52:01 -08:00
parent c698711fdf
commit 176d9f7a54
5 changed files with 54 additions and 38 deletions

View File

@@ -7,9 +7,12 @@ CLCaster::~CLCaster() {
//release_map();
//release_camera();
//release_octree();
release_viewport();
//clReleaseKernel(kernel_map.at("raycaster"));
// clReleaseProgram()
//release_viewport();
delete[] viewport_matrix;
delete[] viewport_image;
delete[] viewport_image;
camera.reset();
@@ -864,7 +867,6 @@ bool CLCaster::release_buffer(std::string buffer_name) {
if (buffer_map.count(buffer_name) > 0) {
clFinish(command_queue);
int error = clReleaseMemObject(buffer_map.at(buffer_name));
if (cl_assert(error)) {

View File

@@ -53,7 +53,9 @@ int Camera::add_relative_impulse(DIRECTION impulse_direction, float speed) {
}
float val = movement.z;
movement += SphereToCart(dir) * speed;
movement.z = val;
return 1;
}
@@ -79,8 +81,16 @@ int Camera::update(double delta_time) {
position.y += static_cast<float>(movement.y * delta_time * multiplier);
position.z += static_cast<float>(movement.z * delta_time * multiplier);
movement *= static_cast<float>(friction_coefficient * delta_time * multiplier);
movement.x *= static_cast<float>(friction_coefficient * delta_time * multiplier);
movement.y *= static_cast<float>(friction_coefficient * delta_time * multiplier);
if (position.z < 3.0f){
position.z = 3.0f;
movement.z = -0.1;
} else {
// gravity
movement.z -= 0.7f * delta_time;
}
return 1;
}
@@ -117,6 +127,8 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
else if (held_event->code == sf::Keyboard::D) {
add_relative_impulse(Camera::DIRECTION::RIGHT, default_impulse);
}
}
else if (event->type == vr::Event::KeyPressed) {
@@ -128,6 +140,8 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
mouse_enabled = false;
else
mouse_enabled = true;
} else if (key_event->code == sf::Keyboard::Space) {
movement.z = 0.25f;
}
}
@@ -198,20 +212,20 @@ void Camera::render_gui() {
ImGui::Begin("Camera");
ImGui::Columns(2);
ImGui::Text("Camera Inclination");
ImGui::Text("Camera Azimuth");
ImGui::Text("Camera Pos_X");
ImGui::Text("Camera Poz_Y");
ImGui::Text("Camera Poz_Z");
ImGui::NextColumn();
ImGui::Text("%f", direction.x);
ImGui::Text("%f", direction.y);
ImGui::Text("%f", position.x);
ImGui::Text("%f", position.y);
ImGui::Columns(2);
ImGui::Text("Camera Inclination");
ImGui::Text("Camera Azimuth");
ImGui::Text("Camera Pos_X");
ImGui::Text("Camera Poz_Y");
ImGui::Text("Camera Poz_Z");
ImGui::NextColumn();
ImGui::Text("%f", direction.x);
ImGui::Text("%f", direction.y);
ImGui::Text("%f", position.x);
ImGui::Text("%f", position.y);
ImGui::Text("%f", position.z);
ImGui::Separator();