paysages3d/src/render/software/BaseCloudLayerRenderer.cpp

63 lines
1.9 KiB
C++
Raw Normal View History

#include "BaseCloudLayerRenderer.h"
2013-12-04 21:52:18 +00:00
#include "clouds/BaseCloudsModel.h"
#include "Vector3.h"
BaseCloudLayerRenderer::BaseCloudLayerRenderer(SoftwareRenderer *parent) : parent(parent) {
setQuality(0.5);
}
BaseCloudLayerRenderer::~BaseCloudLayerRenderer() {
}
Color BaseCloudLayerRenderer::getColor(BaseCloudsModel *, const Vector3 &, const Vector3 &) {
return COLOR_TRANSPARENT;
}
bool BaseCloudLayerRenderer::alterLight(BaseCloudsModel *, LightComponent *, const Vector3 &, const Vector3 &) {
return false;
}
void BaseCloudLayerRenderer::setQuality(double quality) {
this->quality = quality;
}
bool BaseCloudLayerRenderer::optimizeSearchLimits(BaseCloudsModel *model, Vector3 *start, Vector3 *end) {
Vector3 diff;
2013-12-04 21:52:18 +00:00
double min_altitude, max_altitude;
model->getAltitudeRange(&min_altitude, &max_altitude);
if (start->y > max_altitude) {
if (end->y >= max_altitude) {
return false;
} else {
2013-12-11 10:32:10 +00:00
diff = end->sub(*start);
*start = start->add(diff.scale((max_altitude - start->y) / diff.y));
if (end->y < min_altitude) {
2013-12-11 10:32:10 +00:00
*end = end->add(diff.scale((min_altitude - end->y) / diff.y));
}
}
} else if (start->y < min_altitude) {
if (end->y <= min_altitude) {
return false;
} else {
2013-12-11 10:32:10 +00:00
diff = end->sub(*start);
*start = start->add(diff.scale((min_altitude - start->y) / diff.y));
if (end->y >= max_altitude) {
2013-12-11 10:32:10 +00:00
*end = end->add(diff.scale((max_altitude - end->y) / diff.y));
}
}
} else /* start is inside layer */
{
2013-12-11 10:32:10 +00:00
diff = end->sub(*start);
if (end->y > max_altitude) {
2013-12-11 10:32:10 +00:00
*end = start->add(diff.scale((max_altitude - start->y) / diff.y));
} else if (end->y < min_altitude) {
2013-12-11 10:32:10 +00:00
*end = start->add(diff.scale((min_altitude - start->y) / diff.y));
}
}
return true;
}