Fixed precision problem in daytime management
This commit is contained in:
parent
c99973a42b
commit
b9a51bb2be
2 changed files with 10 additions and 1 deletions
|
@ -74,7 +74,7 @@ void AtmosphereDefinition::setDayTime(double value) {
|
|||
}
|
||||
|
||||
void AtmosphereDefinition::setDayTime(int hour, int minute, int second) {
|
||||
setDayTime(to_double(hour) / 24.0 + to_double(minute) / 1440.0 + to_double(second) / 86400.0);
|
||||
setDayTime(to_double(hour) / 24.0 + to_double(minute) / 1440.0 + (to_double(second) + 0.1) / 86400.0);
|
||||
}
|
||||
|
||||
double AtmosphereDefinition::getDaytime() const {
|
||||
|
|
|
@ -11,6 +11,11 @@ static void check_daytime(const AtmosphereDefinition &atmo, int expected_hour, i
|
|||
EXPECT_EQ(expected_second, second);
|
||||
}
|
||||
|
||||
static void check_auto_daytime(AtmosphereDefinition &atmo, int hour, int minute=0, int second=0) {
|
||||
atmo.setDayTime(hour, minute, second);
|
||||
check_daytime(atmo, hour, minute, second);
|
||||
}
|
||||
|
||||
TEST(AtmosphereDefinition, setDayTime) {
|
||||
AtmosphereDefinition atmo(NULL);
|
||||
|
||||
|
@ -34,4 +39,8 @@ TEST(AtmosphereDefinition, setDayTime) {
|
|||
|
||||
atmo.setDayTime(1.5);
|
||||
check_daytime(atmo, 12);
|
||||
|
||||
check_auto_daytime(atmo, 15);
|
||||
check_auto_daytime(atmo, 15, 12);
|
||||
check_auto_daytime(atmo, 15, 18, 7);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue