paysages3d/src/render/software/WaterIntersector.cpp
2016-07-29 13:57:55 +02:00

23 lines
789 B
C++

#include "WaterIntersector.h"
#include "InfinitePlane.h"
#include "InfiniteRay.h"
#include "WaterRenderer.h"
WaterIntersector::WaterIntersector(WaterRenderer *renderer): renderer(renderer) {
}
int WaterIntersector::getPriority() const {
return 10;
}
bool WaterIntersector::findIntersection(const Vector3 &eye, const Vector3 &direction, double, Vector3 *out_hit) const {
InfinitePlane water(Vector3(0.0, renderer->getHeightInfo().base_height, 0.0), VECTOR_UP);
int intersect = water.checkRayIntersection(InfiniteRay(eye, direction), out_hit);
return intersect == 1 && direction.dotProduct(out_hit->sub(eye)) > 0.0;
}
Color WaterIntersector::getColorAtHit(const Vector3 &, const Vector3 &location) const {
return renderer->getResult(location.x, location.z).final;
}