From 0095c138a4e35a101857d58ae7376ae66ecbd1ef Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Tue, 28 Feb 2017 14:49:47 -0400 Subject: [PATCH] Assorted changes. --- .clang_complete | 3 ++- Makefile | 4 ++-- main.cpp | 9 +++++---- photon_tracer.cpp | 5 +++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.clang_complete b/.clang_complete index ff5d913..974eff0 100644 --- a/.clang_complete +++ b/.clang_complete @@ -2,4 +2,5 @@ -pedantic -Wall -DGLM_FORCE_RADIANS --fopenmp \ No newline at end of file +-fopenmp +-std=c++11 diff --git a/Makefile b/Makefile index fd8e19d..8e2bb82 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,11 @@ OBJECTS = main.o sampling.o camera.o environment.o disk.o plane.o sphere.o \ spot_light.o sphere_area_light.o disk_area_light.o scene.o tracer.o \ path_tracer.o whitted_tracer.o rgbe.o kd_tree.o photon_tracer.o DEPENDS = $(OBJECTS:.o=.d) -CXXFLAGS = -ansi -pedantic -Wall -DGLM_FORCE_RADIANS -fopenmp +CXXFLAGS = -ansi -pedantic -Wall -DGLM_FORCE_RADIANS -fopenmp -std=c++11 LDLIBS = -lfreeimage -ljson_spirit .PHONY: all -all: CXXFLAGS += -O2 -DNDEBUG +all: CXXFLAGS += -O3 -DNDEBUG all: $(TARGET) .PHONY: debug diff --git a/main.cpp b/main.cpp index 8a0ec18..56e4be9 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -69,8 +70,8 @@ int main(int argc, char ** argv) { vec2 sample; Tracer * tracer; PhotonTracer * p_tracer; - size_t total; - size_t current = 0; + uint64_t total; + uint64_t current = 0; FIBITMAP * input_bitmap; FIBITMAP * output_bitmap; FREE_IMAGE_FORMAT fif; @@ -122,7 +123,7 @@ int main(int argc, char ** argv) { } // Generate the image. - total = g_h * g_w * g_samples; + total = static_cast(g_h) * static_cast(g_w) * static_cast(g_samples); cout << "Tracing a total of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary rays:" << endl; #pragma omp parallel for schedule(dynamic, 1) private(r, sample) shared(current) for (int i = 0; i < g_h; i++) { @@ -138,7 +139,7 @@ int main(int argc, char ** argv) { image[i][j] /= g_samples; } #pragma omp critical - cout << "\r" << setw(3) << static_cast((static_cast(current) / static_cast(total)) * 100.0) << "% done."; + cout << "\r" << ANSI_BOLD_YELLOW << current << ANSI_RESET_STYLE << " of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary rays traced."; } cout << endl; diff --git a/photon_tracer.cpp b/photon_tracer.cpp index bd840b6..69bf75d 100644 --- a/photon_tracer.cpp +++ b/photon_tracer.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include @@ -159,12 +160,12 @@ void PhotonTracer::build_photon_map(Scene * s, const size_t n_photons_per_ligth, Vec3 ls, dir; float r1, r2; Photon ph; - size_t total = 0, current = 0; + uint64_t total = 0, current = 0; for (vector::iterator it = s->m_lights.begin(); it != s->m_lights.end(); it++) { total += (*it)->light_type() == Light::AREA ? 1 : 0; } - total *= n_photons_per_ligth; + total *= static_cast(n_photons_per_ligth); cout << "Tracing a total of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary photons:" << endl;