| 413 | } |
| 414 | |
| 415 | void EnvironmentPainter::drawOrbiter(float pixelRatio, Vec2F const& screenSize, SkyRenderData const& sky, SkyOrbiter const& orbiter) { |
| 416 | float alpha = 1.0f; |
| 417 | Vec2F position; |
| 418 | |
| 419 | // The way Starbound positions these is weird. |
| 420 | // It's a random point on a 400 by 400 area from the bottom left of the screen. |
| 421 | // That origin point is then multiplied by the zoom level. |
| 422 | // This does not intuitively scale with higher-resolution monitors, so lets fix that. |
| 423 | if (orbiter.type == SkyOrbiterType::Moon) { |
| 424 | const Vec2F correctionOrigin = { 320, 180 }; |
| 425 | // correctionOrigin is 1920x1080 / default zoom level / 2, the most likely dev setup at the time. |
| 426 | Vec2F offset = orbiter.position - correctionOrigin; |
| 427 | position = (screenSize / 2) + offset * pixelRatio; |
| 428 | } |
| 429 | else |
| 430 | position = orbiter.position * pixelRatio; |
| 431 | |
| 432 | if (orbiter.type == SkyOrbiterType::Sun) { |
| 433 | alpha = sky.dayLevel; |
| 434 | drawRays(pixelRatio, sky, position, std::max(screenSize[0], screenSize[1]), m_timer, sky.skyAlpha); |
| 435 | } |
| 436 | |
| 437 | TexturePtr texture = m_textureGroup->loadTexture(orbiter.image); |
| 438 | Vec2F texSize = Vec2F(texture->size()); |
| 439 | |
| 440 | Mat3F renderMatrix = Mat3F::rotation(orbiter.angle, position); |
| 441 | RectF renderRect = RectF::withCenter(position, texSize * orbiter.scale * pixelRatio); |
| 442 | Vec4B renderColor = Vec4B(255, 255, 255, 255 * alpha); |
| 443 | |
| 444 | m_renderer->immediatePrimitives().emplace_back(std::in_place_type_t<RenderQuad>(), std::move(texture), |
| 445 | renderMatrix.transformVec2(renderRect.min()), Vec2F(0, 0), |
| 446 | renderMatrix.transformVec2(Vec2F{renderRect.xMax(), renderRect.yMin()}), Vec2F(texSize[0], 0), |
| 447 | renderMatrix.transformVec2(renderRect.max()), Vec2F(texSize[0], texSize[1]), |
| 448 | renderMatrix.transformVec2(Vec2F{renderRect.xMin(), renderRect.yMax()}), Vec2F(0, texSize[1]), |
| 449 | renderColor, 0.0f); |
| 450 | } |
| 451 | |
| 452 | uint64_t EnvironmentPainter::starsHash(SkyRenderData const& sky, Vec2F const& viewSize) const { |
| 453 | XXHash64 hasher; |
nothing calls this directly
no test coverage detected