| 224 | } |
| 225 | |
| 226 | Vec2F SystemWorld::planetPosition(CelestialCoordinate const& coordinate) const { |
| 227 | if (coordinate.isNull() || coordinate.isSystem()) |
| 228 | return {0.0, 0.0}; |
| 229 | |
| 230 | RandomSource random(coordinateSeed(coordinate, "PlanetSystemPosition")); |
| 231 | |
| 232 | Vec2F parentPosition = planetPosition(coordinate.parent()); |
| 233 | float distance = planetOrbitDistance(coordinate); |
| 234 | float interval = orbitInterval(distance, coordinate.isSatelliteBody()); |
| 235 | |
| 236 | double start = random.randf(); |
| 237 | double offset = (fmod(m_universeClock->time(), interval) / interval); |
| 238 | int direction = random.randf() > 0.5 ? 1 : -1; |
| 239 | float angle = (start + direction * offset) * (Constants::pi * 2); |
| 240 | |
| 241 | return parentPosition + Vec2F(cos(angle), sin(angle)) * distance; |
| 242 | } |
| 243 | |
| 244 | SystemObjectConfig SystemWorld::systemObjectConfig(String const& name, Uuid const& uuid) const { |
| 245 | RandomSource rand(staticRandomU64(uuid.hex())); |