paysages3d/src/render/software/BaseCloudLayerRenderer.cpp

80 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)
{
}
BaseCloudLayerRenderer::~BaseCloudLayerRenderer()
{
}
2013-12-04 21:52:18 +00:00
Color BaseCloudLayerRenderer::getColor(BaseCloudsModel *, const Vector3 &, const Vector3 &)
{
return COLOR_TRANSPARENT;
}
bool BaseCloudLayerRenderer::alterLight(BaseCloudsModel *, LightComponent *, const Vector3 &, const Vector3 &)
{
return false;
}
2013-12-04 21:52:18 +00:00
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);
2013-12-04 21:52:18 +00:00
if (start->y > max_altitude)
{
2013-12-04 21:52:18 +00:00
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));
2013-12-04 21:52:18 +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-04 21:52:18 +00:00
else if (start->y < min_altitude)
{
2013-12-04 21:52:18 +00:00
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));
2013-12-04 21:52:18 +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));
}
}
}
else /* start is inside layer */
{
2013-12-11 10:32:10 +00:00
diff = end->sub(*start);
2013-12-04 21:52:18 +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));
}
2013-12-04 21:52:18 +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));
}
}
return true;
}