WIP
This commit is contained in:
parent
2b02215566
commit
599e24611e
2 changed files with 10 additions and 12 deletions
|
@ -38,6 +38,7 @@
|
||||||
#include "Zone.h"
|
#include "Zone.h"
|
||||||
#include "MaterialNode.h"
|
#include "MaterialNode.h"
|
||||||
#include "TerrainRayWalker.h"
|
#include "TerrainRayWalker.h"
|
||||||
|
#include "Logs.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -633,17 +634,20 @@ static void testTerrainRayMarching() {
|
||||||
|
|
||||||
// Draw ray marcher hits
|
// Draw ray marcher hits
|
||||||
TerrainRayWalker walker(&renderer);
|
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();
|
walker.update();
|
||||||
for (int x = 0; x < width * multisample; x++) {
|
for (int x = 0; x < width * multisample; x++) {
|
||||||
TerrainRayWalker::TerrainHitResult hit;
|
TerrainRayWalker::TerrainHitResult hit;
|
||||||
double max_height = terrain->getHeightInfo().max_height;
|
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);
|
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 hx = round_to_int(hit.hit_location.x);
|
||||||
int hy = height / 2 + round_to_int(hit.hit_location.y);
|
int hy = height / 2 + round_to_int(hit.hit_location.y);
|
||||||
if (hx >= 0 && hx < width && hy >= 0 && hy < height) {
|
if (hx >= 0 && hx < width && hy >= 0 && hy < height) {
|
||||||
result.setPixel(hx, hy, COLOR_RED);
|
result.setPixel(hx, hy, COLOR_RED);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Logs::debug("terrain_ray_marching") << "No hit for " << i << " at " << x << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.saveToFile(getFileName("terrain_ray_marching", i));
|
result.saveToFile(getFileName("terrain_ray_marching", i));
|
||||||
|
|
|
@ -88,12 +88,6 @@ bool TerrainRayWalker::startWalking(const Vector3 &start, Vector3 direction, dou
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hit) {
|
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
|
// Shift ray to escape terrain
|
||||||
if (escape_angle != 0.0) {
|
if (escape_angle != 0.0) {
|
||||||
result.escape_angle += shift_step;
|
result.escape_angle += shift_step;
|
||||||
|
|
Loading…
Reference in a new issue