Fixed render precision sometimes being 0

This commit is contained in:
Michaël Lemaire 2016-07-25 18:27:09 +02:00
parent 10bbf8078b
commit ce33390321

View file

@ -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) {