parent
198e067f75
commit
b469511ce3
|
@ -1963,7 +1963,7 @@ void Renderer::renderItem(const RenderListEntry& rle,
|
||||||
case RenderListEntry::RenderableCometTail:
|
case RenderListEntry::RenderableCometTail:
|
||||||
renderCometTail(*rle.body,
|
renderCometTail(*rle.body,
|
||||||
rle.position,
|
rle.position,
|
||||||
observer.getTime(),
|
observer,
|
||||||
rle.discSizeInPixels);
|
rle.discSizeInPixels);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -5541,9 +5541,11 @@ static float cometDustTailLength(float distanceToSun,
|
||||||
// TODO: Remove unused parameters??
|
// TODO: Remove unused parameters??
|
||||||
void Renderer::renderCometTail(const Body& body,
|
void Renderer::renderCometTail(const Body& body,
|
||||||
const Vector3f& pos,
|
const Vector3f& pos,
|
||||||
double now,
|
const Observer& observer,
|
||||||
float discSizeInPixels)
|
float discSizeInPixels)
|
||||||
{
|
{
|
||||||
|
double now = observer.getTime();
|
||||||
|
|
||||||
Vector3f cometPoints[MaxCometTailPoints];
|
Vector3f cometPoints[MaxCometTailPoints];
|
||||||
Vector3d pos0 = body.getOrbit(now)->positionAtTime(now);
|
Vector3d pos0 = body.getOrbit(now)->positionAtTime(now);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -5553,8 +5555,6 @@ void Renderer::renderCometTail(const Body& body,
|
||||||
double t = now;
|
double t = now;
|
||||||
|
|
||||||
float distanceFromSun, irradiance_max = 0.0f;
|
float distanceFromSun, irradiance_max = 0.0f;
|
||||||
unsigned int li_eff = 0; // Select the first sun as default to
|
|
||||||
// shut up compiler warnings
|
|
||||||
|
|
||||||
// Adjust the amount of triangles used for the comet tail based on
|
// Adjust the amount of triangles used for the comet tail based on
|
||||||
// the screen size of the comet.
|
// the screen size of the comet.
|
||||||
|
@ -5565,21 +5565,27 @@ void Renderer::renderCometTail(const Body& body,
|
||||||
// Find the sun with the largest irrradiance of light onto the comet
|
// Find the sun with the largest irrradiance of light onto the comet
|
||||||
// as function of the comet's position;
|
// as function of the comet's position;
|
||||||
// irradiance = sun's luminosity / square(distanceFromSun);
|
// irradiance = sun's luminosity / square(distanceFromSun);
|
||||||
|
Vector3d sunPos(Vector3d::Zero());
|
||||||
for (unsigned int li = 0; li < lightSourceList.size(); li++)
|
for (const auto star : nearStars)
|
||||||
{
|
{
|
||||||
distanceFromSun = (float) (pos.cast<double>() - lightSourceList[li].position).norm();
|
if (star->getVisibility())
|
||||||
float irradiance = lightSourceList[li].luminosity / square(distanceFromSun);
|
|
||||||
if (irradiance > irradiance_max)
|
|
||||||
{
|
{
|
||||||
li_eff = li;
|
Vector3d p = star->getPosition(t).offsetFromKm(observer.getPosition());
|
||||||
irradiance_max = irradiance;
|
distanceFromSun = (float) (pos.cast<double>() - p).norm();
|
||||||
|
float irradiance = star->getBolometricLuminosity() / square(distanceFromSun);
|
||||||
|
|
||||||
|
if (irradiance > irradiance_max)
|
||||||
|
{
|
||||||
|
irradiance_max = irradiance;
|
||||||
|
sunPos = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float fadeDistance = 1.0f / (float) (COMET_TAIL_ATTEN_DIST_SOL * sqrt(irradiance_max));
|
float fadeDistance = 1.0f / (float) (COMET_TAIL_ATTEN_DIST_SOL * sqrt(irradiance_max));
|
||||||
|
|
||||||
// direction to sun with dominant light irradiance:
|
// direction to sun with dominant light irradiance:
|
||||||
Vector3f sunDir = (pos.cast<double>() - lightSourceList[li_eff].position).cast<float>().normalized();
|
Vector3f sunDir = (pos.cast<double>() - sunPos).cast<float>().normalized();
|
||||||
|
|
||||||
float dustTailLength = cometDustTailLength((float) pos0.norm(), body.getRadius());
|
float dustTailLength = cometDustTailLength((float) pos0.norm(), body.getRadius());
|
||||||
float dustTailRadius = dustTailLength * 0.1f;
|
float dustTailRadius = dustTailLength * 0.1f;
|
||||||
|
|
|
@ -527,7 +527,7 @@ class Renderer
|
||||||
|
|
||||||
void renderCometTail(const Body& body,
|
void renderCometTail(const Body& body,
|
||||||
const Eigen::Vector3f& pos,
|
const Eigen::Vector3f& pos,
|
||||||
double now,
|
const Observer& observer,
|
||||||
float discSizeInPixels);
|
float discSizeInPixels);
|
||||||
|
|
||||||
void renderObjectAsPoint_nosprite(const Eigen::Vector3f& center,
|
void renderObjectAsPoint_nosprite(const Eigen::Vector3f& center,
|
||||||
|
|
Loading…
Reference in New Issue