Browse Source

Fixed render precision sometimes being 0

Michael Lemaire 3 years ago
parent
commit
ce33390321
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/render/software/SoftwareRenderer.cpp

+ 3 - 1
src/render/software/SoftwareRenderer.cpp

@@ -24,6 +24,7 @@
 #include "VegetationRenderer.h"
 #include "WaterRasterizer.h"
 #include "WaterRenderer.h"
+#include <algorithm>
 
 SoftwareRenderer::SoftwareRenderer(Scenery *scenery) : scenery(scenery) {
     render_camera = new CameraDefinition;
@@ -163,7 +164,8 @@ double SoftwareRenderer::getPrecision(const Vector3 &location) {
     projected.x += 1.0;
     // projected.y += 1.0;
 
-    return render_camera->unproject(projected).sub(location).getNorm() * 0.1 / to_double(render_quality);
+    double result = render_camera->unproject(projected).sub(location).getNorm() * 0.1 / to_double(render_quality);
+    return max(result, 0.000001);
 }
 
 Vector3 SoftwareRenderer::projectPoint(const Vector3 &point) {