2013-12-01 18:24:53 +00:00
|
|
|
#include "BaseCloudLayerRenderer.h"
|
|
|
|
|
2013-12-04 21:52:18 +00:00
|
|
|
#include "clouds/BaseCloudsModel.h"
|
2013-12-08 19:54:34 +00:00
|
|
|
#include "Vector3.h"
|
2013-12-01 18:24:53 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
BaseCloudLayerRenderer::BaseCloudLayerRenderer(SoftwareRenderer *parent) : parent(parent) {
|
2015-09-13 16:58:11 +00:00
|
|
|
setQuality(0.5);
|
2013-12-01 18:24:53 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
BaseCloudLayerRenderer::~BaseCloudLayerRenderer() {
|
2013-12-01 18:24:53 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
Color BaseCloudLayerRenderer::getColor(BaseCloudsModel *, const Vector3 &, const Vector3 &) {
|
2013-12-01 18:24:53 +00:00
|
|
|
return COLOR_TRANSPARENT;
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
bool BaseCloudLayerRenderer::alterLight(BaseCloudsModel *, LightComponent *, const Vector3 &, const Vector3 &) {
|
2013-12-01 18:24:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void BaseCloudLayerRenderer::setQuality(double quality) {
|
2015-09-13 16:58:11 +00:00
|
|
|
this->quality = quality;
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
bool BaseCloudLayerRenderer::optimizeSearchLimits(BaseCloudsModel *model, Vector3 *start, Vector3 *end) {
|
2013-12-01 18:24:53 +00:00
|
|
|
Vector3 diff;
|
2013-12-04 21:52:18 +00:00
|
|
|
double min_altitude, max_altitude;
|
|
|
|
|
|
|
|
model->getAltitudeRange(&min_altitude, &max_altitude);
|
2013-12-01 18:24:53 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
if (start->y > max_altitude) {
|
|
|
|
if (end->y >= max_altitude) {
|
2013-12-01 18:24:53 +00:00
|
|
|
return false;
|
2015-11-09 21:30:46 +00:00
|
|
|
} else {
|
2013-12-11 10:32:10 +00:00
|
|
|
diff = end->sub(*start);
|
|
|
|
*start = start->add(diff.scale((max_altitude - start->y) / diff.y));
|
2015-11-09 21:30:46 +00:00
|
|
|
if (end->y < min_altitude) {
|
2013-12-11 10:32:10 +00:00
|
|
|
*end = end->add(diff.scale((min_altitude - end->y) / diff.y));
|
2013-12-01 18:24:53 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-09 21:30:46 +00:00
|
|
|
} else if (start->y < min_altitude) {
|
|
|
|
if (end->y <= min_altitude) {
|
2013-12-01 18:24:53 +00:00
|
|
|
return false;
|
2015-11-09 21:30:46 +00:00
|
|
|
} else {
|
2013-12-11 10:32:10 +00:00
|
|
|
diff = end->sub(*start);
|
|
|
|
*start = start->add(diff.scale((min_altitude - start->y) / diff.y));
|
2015-11-09 21:30:46 +00:00
|
|
|
if (end->y >= max_altitude) {
|
2013-12-11 10:32:10 +00:00
|
|
|
*end = end->add(diff.scale((max_altitude - end->y) / diff.y));
|
2013-12-01 18:24:53 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-09 21:30:46 +00:00
|
|
|
} else /* start is inside layer */
|
2013-12-01 18:24:53 +00:00
|
|
|
{
|
2013-12-11 10:32:10 +00:00
|
|
|
diff = end->sub(*start);
|
2015-11-09 21:30:46 +00:00
|
|
|
if (end->y > max_altitude) {
|
2013-12-11 10:32:10 +00:00
|
|
|
*end = start->add(diff.scale((max_altitude - start->y) / diff.y));
|
2015-11-09 21:30:46 +00:00
|
|
|
} 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));
|
2013-12-01 18:24:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|