Skip to content

Commit

Permalink
little focus fix. Enabled optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipPragerUrbina committed Apr 2, 2022
1 parent 1dbee20 commit 247aebd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
7 changes: 6 additions & 1 deletion DogeRay.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<Optimization>Custom</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WholeProgramOptimization>true</WholeProgramOptimization>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -87,6 +91,7 @@
<CudaCompile>
<TargetMachinePlatform>64</TargetMachinePlatform>
<Include>%(AdditionalIncludeDirectories)</Include>
<FastMath>false</FastMath>
</CudaCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions classes/bvhtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Bvhtree {
//build BVH tree
void build() {
//split
std::cout << "building BVH \n";
std::cout << "building BVH\n";
recursivesplit(traingles);
std::cout << "linking BVH \n";
createlinks(0, -1);
Expand Down Expand Up @@ -106,15 +106,14 @@ class Bvhtree {
nodes.push_back(parent);
return parentindex;
}

//push current node
nodes.push_back(parent);
//get axis with most difference
int axis = (parent.box.max - parent.box.min).extent();
//split by middle
int mid = remaining.size() / 2;
//sort and split by center of bounding box
std::nth_element(remaining.begin(),remaining.begin()+mid, remaining.end(),
std::nth_element(remaining.begin(), remaining.begin() + mid, remaining.end(),
[axis](const Tri& a, const Tri& b) {
return a.box.center[axis] < b.box.center[axis];
});
Expand Down
4 changes: 2 additions & 2 deletions classes/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class Camera {
float degreefov = 45;
Vec3 up{ 0, 1, 0 };
float aperture = 0;
float focusoffset = 0;
float focus = 1;

//no constructor to allow this to be in struct
//calculate camera parameters
void calculate() {
//autofocus
Vec3 focusdistance = (position - lookposition).length() + focusoffset;
Vec3 focusdistance = focus;
//convert fov from degrees to radians
radfov = degreefov * M_PI / 180.0f;
float h = tan(radfov / 2);
Expand Down
2 changes: 1 addition & 1 deletion classes/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Gui {
changed |= ImGui::DragFloat3("camera position", settings->cam.position.values);
//more camera options
if (ImGui::CollapsingHeader("Lens")) {
changed |= ImGui::DragFloat("focus distance", &settings->cam.focusoffset);
changed |= ImGui::DragFloat("Focus distance", &settings->cam.focus);
changed |= ImGui::SliderFloat("aperture", &settings->cam.aperture, 0, 5);
changed |= ImGui::SliderFloat("FOV", &settings->cam.degreefov, 0, 180);
if (settings->cam.lookat) {
Expand Down
2 changes: 1 addition & 1 deletion classes/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Program {
\:\/.:| |\:\_\ \ \\:\_\ \ \ \:\____/\\ \ `\ \ \\:.\ \ \ \ \::\ \ \:\____/\
\____/_/ \_____\/ \_____\/ \_____\/ \_\/ \_\/ \__\/\__\/ \__\/ \_____\/ )" << std::endl;

std::cout << "V.2.0 by Philip Prager Urbina 2022" << std::endl;
std::cout << "V.2.0.0 by Philip Prager Urbina 2022" << std::endl;
std::cout << "Find on github: https://github.com/PhilipPragerUrbina/DOGERAY2" << std::endl;
}

Expand Down

0 comments on commit 247aebd

Please sign in to comment.