diff --git a/include/Application.h b/include/Application.h index 93be54e..69688ac 100644 --- a/include/Application.h +++ b/include/Application.h @@ -41,10 +41,10 @@ class CLCaster; class Application { public: - static const int WINDOW_X = 1366; - static const int WINDOW_Y = 768; -// static const int WINDOW_X = 1920; -// static const int WINDOW_Y = 1080; +// static const int WINDOW_X = 1366; +// static const int WINDOW_Y = 768; + static const int WINDOW_X = 1920; + static const int WINDOW_Y = 1080; static const int MAP_X; static const int MAP_Y; static const int MAP_Z; diff --git a/include/Camera.h b/include/Camera.h index dc5d262..ef69179 100644 --- a/include/Camera.h +++ b/include/Camera.h @@ -47,8 +47,8 @@ public: private: - float friction_coefficient = 0.1f; - float default_impulse = 0.3f; + float friction_coefficient = 0.001f; + float default_impulse = 0.1f; // 3D vector sf::Vector3f movement; diff --git a/kernels/ray_caster_kernel.cl b/kernels/ray_caster_kernel.cl index 1a5fdda..e1df386 100644 --- a/kernels/ray_caster_kernel.cl +++ b/kernels/ray_caster_kernel.cl @@ -466,21 +466,21 @@ __kernel void raycaster( constant int vox_dim = OCTDIM; // If we hit a voxel - if (voxel.x < (*map_dim).x && voxel.y < (*map_dim).x && voxel.z < (*map_dim).x){ - if (get_oct_vox( - voxel, - octree_descriptor_buffer, - octree_attachment_lookup_buffer, - octree_attachment_buffer, - settings_buffer - )){ - voxel_data = 5; - } else { - voxel_data = 0; - } - } else { + // if (voxel.x < (*map_dim).x && voxel.y < (*map_dim).x && voxel.z < (*map_dim).x){ + // if (get_oct_vox( + // voxel, + // octree_descriptor_buffer, + // octree_attachment_lookup_buffer, + // octree_attachment_buffer, + // settings_buffer + // )){ + // voxel_data = 5; + // } else { + // voxel_data = 0; + // } + // } else { voxel_data = map[voxel.x + (*map_dim).x * (voxel.y + (*map_dim).z * (voxel.z))]; - } + //} diff --git a/src/CLCaster.cpp b/src/CLCaster.cpp index 72e623f..fce3204 100644 --- a/src/CLCaster.cpp +++ b/src/CLCaster.cpp @@ -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)) { diff --git a/src/Camera.cpp b/src/Camera.cpp index 6f3b787..1784061 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -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(movement.y * delta_time * multiplier); position.z += static_cast(movement.z * delta_time * multiplier); - movement *= static_cast(friction_coefficient * delta_time * multiplier); - + movement.x *= static_cast(friction_coefficient * delta_time * multiplier); + movement.y *= static_cast(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_ptrcode == 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_ptrcode == 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();