MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / planetPosition

Method planetPosition

source/game/StarSystemWorld.cpp:226–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226Vec2F 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
244SystemObjectConfig SystemWorld::systemObjectConfig(String const& name, Uuid const& uuid) const {
245 RandomSource rand(staticRandomU64(uuid.hex()));

Callers 2

serverUpdateMethod · 0.80

Calls 6

isSystemMethod · 0.80
isSatelliteBodyMethod · 0.80
randfMethod · 0.80
isNullMethod · 0.45
parentMethod · 0.45
timeMethod · 0.45

Tested by

no test coverage detected