This commit is contained in:
Michaël Lemaire 2016-04-01 00:30:57 +02:00
parent 2b02215566
commit 599e24611e
2 changed files with 10 additions and 12 deletions

View file

@ -38,6 +38,7 @@
#include "Zone.h"
#include "MaterialNode.h"
#include "TerrainRayWalker.h"
#include "Logs.h"
#include <cmath>
#include <sstream>
@ -633,16 +634,19 @@ static void testTerrainRayMarching() {
// Draw ray marcher hits
TerrainRayWalker walker(&renderer);
walker.setQuality(1.0, 0.1, 5.0, 1.0, to_double(height), 0.1);
walker.setQuality(1.0, 0.1, 5.0, 1.0, to_double(height) * 2.0, 0.1);
walker.update();
for (int x = 0; x < width * multisample; x++) {
TerrainRayWalker::TerrainHitResult hit;
double max_height = terrain->getHeightInfo().max_height;
walker.startWalking(Vector3(to_double(x) / to_double(multisample) - to_double(max_height) * offset, to_double(max_height), 0.0), direction, 0.0, hit);
int hx = round_to_int(hit.hit_location.x);
int hy = height / 2 + round_to_int(hit.hit_location.y);
if (hx >= 0 && hx < width && hy >= 0 && hy < height) {
result.setPixel(hx, hy, COLOR_RED);
if (walker.startWalking(Vector3(to_double(x) / to_double(multisample) - to_double(max_height) * offset, to_double(max_height), 0.0), direction, 0.0, hit)) {
int hx = round_to_int(hit.hit_location.x);
int hy = height / 2 + round_to_int(hit.hit_location.y);
if (hx >= 0 && hx < width && hy >= 0 && hy < height) {
result.setPixel(hx, hy, COLOR_RED);
}
} else {
Logs::debug("terrain_ray_marching") << "No hit for " << i << " at " << x << std::endl;
}
}

View file

@ -88,12 +88,6 @@ bool TerrainRayWalker::startWalking(const Vector3 &start, Vector3 direction, dou
}
if (hit) {
// TODO Refine the hit with dichotomy at high quality
/*if (renderer->render_quality > 7)
{
cursor = refineHit(previous_cursor, cursor, step_length);
}*/
// Shift ray to escape terrain
if (escape_angle != 0.0) {
result.escape_angle += shift_step;