Files
mtgodot-poc/extension/src/water_depth.h
T

13 lines
429 B
C++

#pragma once
#include <cmath>
namespace mtgodot {
// 40250 MapOutdoor.cpp / AreaTerrain.cpp. Arguments in scaled centimetres.
inline float water_depth_alpha(double depth_cm, double height_scale) {
if (!std::isfinite(depth_cm) || !std::isfinite(height_scale) ||
height_scale <= 0.0 || depth_cm <= 0.0) return 0.0f;
double alpha = depth_cm / (400.0 * height_scale);
return static_cast<float>(alpha > 0.8 ? 0.8 : alpha);
}
}