diff --git a/kernels/ray_caster_kernel.cl b/kernels/ray_caster_kernel.cl index e496356..f8bd989 100644 --- a/kernels/ray_caster_kernel.cl +++ b/kernels/ray_caster_kernel.cl @@ -236,7 +236,7 @@ __kernel void raycaster( // Determine where on the 2d plane the ray intersected float3 face_position = (float)(0); - float2 texture_position = (float)(0); + float2 tile_face_position = (float)(0); // First determine the percent of the way the ray is towards the next intersection_t @@ -249,7 +249,7 @@ __kernel void raycaster( // Since we intersected face x, we know that we are at the face (1.0) // Not entirely sure what is causing the 1.0 vs 1.001 rendering bug face_position = (float3)(1.001f, y_percent, z_percent); - texture_position = (float2)(y_percent, z_percent); + tile_face_position = (float2)(y_percent, z_percent); } else if (face_mask.y == -1) { @@ -257,7 +257,7 @@ __kernel void raycaster( float z_percent = (intersection_t.z - (intersection_t.y - delta_t.y)) / delta_t.z; face_position = (float3)(x_percent, 1.001f, z_percent); - texture_position = (float2)(x_percent, z_percent); + tile_face_position = (float2)(x_percent, z_percent); } else if (face_mask.z == -1) { @@ -266,7 +266,7 @@ __kernel void raycaster( float y_percent = (intersection_t.y - (intersection_t.z - delta_t.z)) / delta_t.y; face_position = (float3)(x_percent, y_percent, 1.001f); - texture_position = (float2)(x_percent, y_percent); + tile_face_position = (float2)(x_percent, y_percent); } @@ -277,26 +277,30 @@ __kernel void raycaster( if (ray_dir.x > 0) { face_position.x = -face_position.x + 1; - texture_position.x = -texture_position.x + 1.0; + //tile_face_position.x = -tile_face_position.x + 1.0; + } + if (ray_dir.x < 0) { + //face_position.x = face_position.x + 0; + //tile_face_position.x = tile_face_position.x; } - //if (ray_dir.x < 0) - // face_position.x = face_position.x + 0; if (ray_dir.y > 0){ face_position.y = - face_position.y + 1; - texture_position.y = -texture_position.y + 1.0; + //tile_face_position.y = -tile_face_position.y + 1.0; + } + if (ray_dir.y < 0) { + //face_position.y = face_position.y + 0; + //tile_face_position.y = -tile_face_position.y + 1.0; } - - //if (ray_dir.y < 0) - // face_position.y = face_position.y + 0; if (ray_dir.z > 0) { face_position.z = - face_position.z + 1; - texture_position.y = -texture_position.y + 1.0; + //tile_face_position.y = tile_face_position.y + 0.0; } - //if (ray_dir.z < 0) - // face_position.z = face_position.z + 0; + if (ray_dir.z < 0) { + //face_position.z = face_position.z + 0; + } // Now either use the face position to retrieve a texture sample, or @@ -307,7 +311,7 @@ __kernel void raycaster( } else if (voxel_data == 5) { float2 tile_size = convert_float2(*atlas_dim / *tile_dim); - voxel_color = read_imagef(texture_atlas, convert_int2(texture_position * tile_size) + convert_int2((float2)(3, 0) * tile_size)); + voxel_color = read_imagef(texture_atlas, convert_int2(tile_face_position * tile_size) + convert_int2((float2)(3, 0) * tile_size)); //voxel_color = (float4)(0.25, 0.52, 0.30, 0.1); } else if (voxel_data == 1) { diff --git a/src/Camera.cpp b/src/Camera.cpp index 2c37f6c..4775a29 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -94,7 +94,7 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr(event.get()); if (held_event->code == sf::Keyboard::LShift) { - default_impulse = 0.1f; + default_impulse = 0.01f; } if (held_event->code == sf::Keyboard::RShift) { default_impulse = 1.0f; diff --git a/src/main.cpp b/src/main.cpp index 36091fb..8f8c227 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "Old_Map.h" #include "util.hpp" #include "RayCaster.h" @@ -40,8 +41,8 @@ const int WINDOW_X = 1000; const int WINDOW_Y = 1000; const int WORK_SIZE = WINDOW_X * WINDOW_Y; -const int MAP_X = 1024; -const int MAP_Y = 1024; +const int MAP_X = 256; +const int MAP_Y = 256; const int MAP_Z = 256; float elap_time(){ @@ -64,9 +65,66 @@ sf::Texture window_texture; // Y: -1.57 is straight up // Y: 1.57 is straight down +struct CustomPacket { + + char data[1024]; + int position = 0; + int size = 12; + +}; int main() { + + + // Create a listener to wait for incoming connections on port 55001 + sf::TcpListener listener; + listener.listen(5000); + + // Wait for a connection + sf::TcpSocket socket; + listener.accept(socket); + std::cout << "New client connected: " << socket.getRemoteAddress() << std::endl; + + // Receive a message from the client + char buffer[1024]; + + std::vector packets; + + sf::TcpSocket::Status status; + + do { + + std::size_t received = 0; + status = socket.receive(buffer, 1024, received); + + while (received < 12) { + std::size_t tack_on; + status = socket.receive(&buffer[received], 1024 - received, tack_on); + received += tack_on; + } + + + int position = 0; + while (position < received) { + CustomPacket p; + memcpy(p.data, &buffer[position], p.size); + packets.push_back(p); + position += p.size; + } + + std::cout << "packet_count = " << packets.size() << std::endl; + + int left_over = 12 - (position - received); + memcpy(buffer, &buffer[received - left_over], left_over); + + } while (status != sf::TcpSocket::Status::Disconnected); + + + + + + //Map _map(sf::Vector3i(0, 0, 0)); //_map.generate_octree();