pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.64k stars 380 forks source link

Achernar9 (4 -9 -16) Brown Dwarf has no effect on player's ship #1626

Closed docwild closed 12 years ago

docwild commented 12 years ago

There doesn't seem to be any gravity to it and you can fly straight through it, the autopilot will not compute an orbit. I'm unsure of any other locations of brown dwarves but I will go exploring (is there an easier way to do this?). I have tried in an int shuttle and an eagle IV.

Brianetta commented 12 years ago

This brown dwarf has a ridiculously large radius (far larger than is possible on a real one - 3.5AU!). I suspect that all its orbits are inside it somewhere.

Brianetta commented 12 years ago

Also, the mass is very, very large. This thing has the dimensions of a black hole.

Brianetta commented 12 years ago

Over to you, @fluffyfreak. Things to note:

  1. rotation_period is the body's day length, not its year. Orbital revolution period is calculated from semi_major_axis and body masses.
  2. Brown dwarfs are specified as if they were stars, meaning that the mass must be given in Solar masses, not Earth masses, and radius must be given in Solar radii, not Earth radii.
fluffyfreak commented 12 years ago

@Brianetta Cool I'll look into it, and maybe I should try and write a tool to help us build custom systems so we don't have this kind of manual data wrangling in the future. Something it discuss in the mailing list I guess.

fluffyfreak commented 12 years ago

@Brianetta I'm trying to fix this right now but something is most definitely not right, masses do appear to be in Solar masses but the radius seems to be in Earth radii. Unfortunately this is the only BROWN_DWARF used in the custom systems so there's no other working example to compare it to.

fluffyfreak commented 12 years ago

@Brianetta Okay there were several things wrong with the mass and radius, I'm trying to fix them but what I'm getting is almost nonsensical without knowing about celestial mass vs radius vs density etc which I know precisely nothing about.

I've given the brown dwarf (Achernar9) a mass of 0.06537 Sols, and a radius of 0.7526 this gives it a surface gravity 31.672m/s^2 that seems light but I don't know what good values would actually be.

I've also removed it's rotation_period entirely since I couldn't find another example of a star supplying that.

However nothing I do, even replacing it entirely with a 1:1 replica of Sol, can make the autopilot work with it. It is simply never able to compute an orbit.

fluffyfreak commented 12 years ago

Where is the autopilot code? is it in Lua because I can't find it (even whilst looking in Lua!)

Brianetta commented 12 years ago

Autopilot code is not in Lua.

johnbartholomew commented 12 years ago

Where is the autopilot code? is it in Lua because I can't find it (even whilst looking in Lua!)

Amazingly, there is information about this on the wiki: Ship AI (of course it's slightly out of date, but not too much; the same files are relevant anyway)

fluffyfreak commented 12 years ago

Yep found it now, it's the AiCmdFlyAround, it seems that the altitude is just too big to be within the brown dwarfs frame so it gives up.

fluffyfreak commented 12 years ago

Okay I've tried a few things, making sure it was trying to get the correct mass and suchlike but I simply don't understand that code or what it's doing. Someone who understands it is going to have to workout what the correct approach to fixing this is.

My suggestions would include not presenting those options for stars (or other objects) that aren't the systems main star or are too big to have orbits. Or somehow fix it so that it can compute an orbit but ... no idea how you'd go about doing that.

Ae-2222 commented 12 years ago

I've glanced through the code and posted a quick fix. This fixes the star orbit frames being zero if there are no issues. A proper solution for the autopilot will require discussion with JohnJ.


For people reading this in the future: The autopilot calculates the minimum radius at which it can orbit a body based on the weakest thruster being used to cancel out the gravitational field and on the radius. A multiplier of this radius (rather than an altitude as the variable name in (the now outdated) worldview.cpp suggests) is used to determine if an orbit is high, medium or low. The issue arises because there's also a check to ensure that the desired radius is within the non-rotating frame of the body. Small, very dense bodies like neutron stars/white dwarfs will still have an issue as it stands. (If it arises in a custom system before the autopilot issue is fixed it can be sidestepped by placing an asteroid or something far enough away).