Ship doesn't really stop with key [S] (WIN32)

Report bugs, bug fixes and workarounds here.
Avatar
Topic author
Adirondack M
Posts: 528
Joined: 01.03.2004
With us: 20 years 8 months

Ship doesn't really stop with key [S] (WIN32)

Post #1by Adirondack » 31.07.2006, 23:06

Imagine the Celestia window is the front window of your space ship.
Start Celestia and wait until the Earth is in front of you.
Press [A] to start you space ship (let's say about: 300 m/sec.) and then press [S] to stop your space ship immediately.
The speed (display at the lower left corner) counts down fast to 0.00000. Okay, so far so good.

Now press [A] again and move your ship to the left by pressing the arrow key (#4 at the num pad) to prevent crashnig down onto Earth.
Then press [S] to stop your ship and watch the speed display at the lower left corner.
It will not stop to count down the speed at 0.00000 but it continues to count down like 0.000000000000000000000000000%xxx.

This doesn't occur with 1.3.2 or 1.40pre6.


This is a real bug, isn't it?


Celestia 1.4.1 (Windows-version) on XP home SP2 with nVidia GT6600.


Adirondack
Last edited by Adirondack on 01.08.2006, 13:16, edited 1 time in total.
We all live under the same sky, but we do not have the same horizon. (K. Adenauer)
The horizon of some people is a circle with the radius zero - and they call it their point of view. (A. Einstein)

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #2by Christophe » 01.08.2006, 07:21

This comes from the fact that the method used to display floating point numbers has been changed to allow internationalisation. There are a few places that need adjusting, the speed indicator is one of them, the flash message is another one (press K a couple of times).
Christophe

Avatar
Joe
Posts: 162
Joined: 29.02.2004
With us: 20 years 8 months
Location: United Kingdom

Post #3by Joe » 03.08.2006, 10:22

Christophe wrote:This comes from the fact that the method used to display floating point numbers has been changed to allow internationalisation.


It is certainly caused by floating point numbers, but maybe not at the stage of displaying them. I looked into the source code and found out the culprit:

In source file observer.cpp, the code block


Code: Select all

//Tick the simulation by dt seconds
void Observer::update(double dt, double timeScale)
{
 ...
 ...
 if (getVelocity() != targetVelocity)
 {
     double t = clamp((realTime - beginAccelTime) / VELOCITY_CHANGE_TIME);
     ...
     ...
 }
 ...
 ...
}


I tried to fix the bug by changing

Code: Select all

if (getVelocity() != targetVelocity)

into

Code: Select all

if (astro::microLightYearsToKilometers((getVelocity() - targetVelocity).length()) > 1e-9)


This fix stops the speed changing problem, but speed may be displayed as a VERY small value nearly to be zero. If it is to be displayed as zero when S key is pressed, my guess is that the FormattedNumber class in source file formatnum.cpp needs to be adjusted so that the function SigDigitNum in source file celestiacore.cpp will be able to display a specified number of digits after the decimal point.
Joe
8O


Return to “Bugs”