Lots of tweaking. Tenative buggy reflection implimented.

This commit is contained in:
MitchellHansen
2017-04-13 03:41:05 -07:00
parent 2421f7bdce
commit 8806777dc9
8 changed files with 139 additions and 49 deletions

View File

@@ -201,3 +201,11 @@ sf::Vector3f Camera::get_position() {
sf::Vector2f Camera::get_direction() {
return direction;
}
void Camera::setSpeed(float speed) {
default_impulse = speed;;
}
float Camera::getSpeed() {
return default_impulse;
}

View File

@@ -74,6 +74,8 @@ sf::Texture window_texture;
// - Diffuse fog hard cut off
// - Infinite light distance, no inverse square
// - Inconsistent lighting constants. GUI manipulation
// - Far pointers, attachment lookup and aux buffer, contour lookup & masking
int main() {
@@ -87,10 +89,6 @@ int main() {
// Do nothing, extension wrangling handled by macOS
#endif
// The socket listener for interacting with the TCP streaming android controller
// NetworkInput ni;
// ni.listen_for_clients(5000);
// ni.stop_listening_for_clients();
// =============================
Map _map(32);
@@ -184,13 +182,16 @@ int main() {
float light_pos[4] = { 100, 100, 30 };
char screenshot_buf[128]{0};
bool paused = false;
float camera_speed = 1.0;
while (window.isOpen()) {
input_handler.consume_sf_events(&window);
input_handler.handle_held_keys();
input_handler.dispatch_events();
// Time keeping
// Time keeping
elapsed_time = elap_time();
delta_time = elapsed_time - current_time;
current_time = elapsed_time;
@@ -198,21 +199,26 @@ int main() {
delta_time = 0.2f;
accumulator_time += delta_time;
while ((accumulator_time - step_size) >= step_size) {
accumulator_time -= step_size;
accumulator_time -= step_size;
// ==== DELTA TIME LOCKED ====
}
// ==== DELTA TIME LOCKED ====
}
// ==== FPS LOCKED ====
window.clear(sf::Color::Black);
ImGui::SFML::Update(window, sf_delta_clock.restart());
camera->update(delta_time);
handle->update(delta_time);
// Run the raycast
raycaster->compute();
if (!paused) {
camera->update(delta_time);
handle->update(delta_time);
// Run the raycast
raycaster->compute();
}
window.clear(sf::Color::Black);
raycaster->draw(&window);
// Give the frame counter the frame time and draw the average frame time
@@ -274,6 +280,10 @@ int main() {
if (ImGui::Button("Recompile kernel")) {
while (raycaster->debug_quick_recompile() != 0);
}
if (ImGui::Button("Pause")) {
paused = !paused;
}
ImGui::End();
ImGui::Begin("Lights");
@@ -283,16 +293,15 @@ int main() {
handle->set_rgbi(light);
}
if (ImGui::SliderFloat("Camera Speed", &camera_speed, 0, 4)) {
camera->setSpeed(camera_speed);
}
if (ImGui::SliderFloat3("Position", light_pos, 0, MAP_X)) {
sf::Vector3f light(light_pos[0], light_pos[1], light_pos[2]);
handle->set_position(light);
}
// Menu
if (ImGui::CollapsingHeader("Window options"))
{
if (ImGui::TreeNode("Style"))
@@ -301,11 +310,6 @@ int main() {
ImGui::TreePop();
}
}
//light_pos[0] = static_cast<float>(sin(elapsed_time) * 100.0f + 300.0f);
//light_pos[1] = static_cast<float>(sin(elapsed_time) * 100.0f + 300.0f);
//sf::Vector3f light(light_pos[0], light_pos[1], light_pos[2]);
//handle->set_position(light);
ImGui::End();

View File

@@ -101,7 +101,7 @@ void Old_Map::generate_terrain() {
int DATA_SIZE = dimensions.x + 1;
//an initial seed value for the corners of the data
//srand(f_rand());
double SEED = rand() % 40 + 40;
double SEED = rand() % 10 + 30;
//seed the data
set_sample(0, 0, SEED);
@@ -109,7 +109,7 @@ void Old_Map::generate_terrain() {
set_sample(dimensions.x, 0, SEED);
set_sample(dimensions.x, dimensions.y, SEED);
double h = 40.0;//the range (-h -> +h) for the average offset
double h = 20.0;//the range (-h -> +h) for the average offset
//for the new value in range of h
//side length is distance of a single square side
//or distance of diagonal in diamond
@@ -188,7 +188,7 @@ void Old_Map::generate_terrain() {
for (int y = 100; y < 150; y += 10) {
for (int z = 0; z < 10; z += 1) {
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 5;
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
}
}
@@ -222,12 +222,19 @@ void Old_Map::generate_terrain() {
}
}
for (int x = 60; x < 65; x++) {
for (int y = 60; y < 65; y++) {
for (int z = 30; z < 35; z++) {
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 5;
}
}
}
for (int x = 0; x < dimensions.x; x++) {
for (int y = 0; y < dimensions.y; y++) {
// for (int z = 0; z < dimensions.z; z++) {
//if (rand() % 1000 < 1)
voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 6;
voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 5;
// }
}
}

View File

@@ -630,7 +630,7 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
// Try and build the program
// "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations"
error = clBuildProgram(program, 1, &device_id, "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations", NULL, NULL);
error = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
// Check to see if it errored out
if (vr_assert(error, "clBuildProgram")) {