sun_radius vs distance between main planet and sun

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
metri
Above Average
Above Average
Posts: 26
Joined: Sat Feb 14, 2009 9:01 pm

sun_radius vs distance between main planet and sun

Post by metri »

Increasing sun_radius to very high value (400000) will make oolite calculating sun position from main planet to take almost forever.

So "do {} while" code in Universe.m needs some improvement.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: sun_radius vs distance between main planet and sun

Post by Eric Walch »

metri wrote:
Increasing sun_radius to very high value (400000) will make oolite calculating sun position from main planet to take almost forever.

So "do {} while" code in Universe.m needs some improvement.
This large sun diameter took forever with me so I had even to quit Oolite with this value. This is easy fixed by putting a sun_distance += sun_radius; immediately before the do-while loop. This way you don't change the random numbers and the sun-planet vector stays the same. (I checked it in game)

But this fix will putt all suns one diameter further away. So it also needs a check to only do this when the sun diameter is defined larger that normal values. I'll look what values qualify so it does not change distances in a unmodified game.

EDIT: fixed now, added:
if(sun_radius > 250000) sun_distance += sun_radius;

241920 m is the highest possible in-game generated sun_radius. Using a higher value won't change old distances but will put big suns one solar diameter further away and by this avoiding an endless looping while statement. Thanks for spotting metri. 8)
Post Reply