Fixed atmosphere saving to file

This commit is contained in:
Michaël Lemaire 2015-08-19 22:07:44 +02:00
parent 87acc42041
commit bbec14d904
5 changed files with 20 additions and 1 deletions

1
.gitignore vendored
View file

@ -7,6 +7,7 @@
/nbproject/ /nbproject/
/output/ /output/
/perf.* /perf.*
/pic*.png
*.pro.user *.pro.user
*.pro.user.* *.pro.user.*
qrc_*.cpp qrc_*.cpp

View file

@ -16,6 +16,8 @@ AtmosphereDefinition::~AtmosphereDefinition()
void AtmosphereDefinition::save(PackStream* stream) const void AtmosphereDefinition::save(PackStream* stream) const
{ {
DefinitionNode::save(stream);
stream->write((int*)&model); stream->write((int*)&model);
sun_color.save(stream); sun_color.save(stream);
stream->write(&sun_radius); stream->write(&sun_radius);
@ -37,6 +39,8 @@ void AtmosphereDefinition::save(PackStream* stream) const
void AtmosphereDefinition::load(PackStream* stream) void AtmosphereDefinition::load(PackStream* stream)
{ {
DefinitionNode::load(stream);
stream->read((int*)&model); stream->read((int*)&model);
sun_color.load(stream); sun_color.load(stream);
stream->read(&sun_radius); stream->read(&sun_radius);
@ -64,6 +68,8 @@ void AtmosphereDefinition::load(PackStream* stream)
void AtmosphereDefinition::copy(DefinitionNode* _destination) const void AtmosphereDefinition::copy(DefinitionNode* _destination) const
{ {
DefinitionNode::copy(_destination);
AtmosphereDefinition* destination = (AtmosphereDefinition*)_destination; AtmosphereDefinition* destination = (AtmosphereDefinition*)_destination;
daytime->copy(destination->daytime); daytime->copy(destination->daytime);

View file

@ -138,7 +138,7 @@ void Scenery::autoPreset(int seed)
validate(); validate();
Logs::debug() << "New scenery generated from seed " << seed << ":\n" << toString() << std::endl; Logs::debug() << "New scenery generated from seed " << seed << std::endl;
} }
void Scenery::setAtmosphere(AtmosphereDefinition* atmosphere) void Scenery::setAtmosphere(AtmosphereDefinition* atmosphere)

View file

@ -105,6 +105,10 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
{ {
render_process->showPreviousRender(); render_process->showPreviousRender();
} }
else if (event->key() == Qt::Key_F12)
{
Logs::warning() << "Current scenery dump:" << std::endl << scenery->toString() << std::endl;
}
else if (event->key() == Qt::Key_Q) else if (event->key() == Qt::Key_Q)
{ {
if (event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)

View file

@ -2,11 +2,16 @@
#include "Scenery.h" #include "Scenery.h"
#include "Logs.h" #include "Logs.h"
#include "TerrainDefinition.h"
#include "AtmosphereDefinition.h"
#include "FloatNode.h"
TEST(Scenery, saveGlobal) TEST(Scenery, saveGlobal)
{ {
Scenery scenery1; Scenery scenery1;
scenery1.autoPreset(); scenery1.autoPreset();
scenery1.getTerrain()->propWaterHeight()->setValue(0.2);
scenery1.getAtmosphere()->propDayTime()->setValue(0.53);
Scenery::FileOperationResult result = scenery1.saveGlobal("/tmp/test_paysages_scenery"); Scenery::FileOperationResult result = scenery1.saveGlobal("/tmp/test_paysages_scenery");
EXPECT_EQ((int)Scenery::FILE_OPERATION_OK, result); EXPECT_EQ((int)Scenery::FILE_OPERATION_OK, result);
@ -14,4 +19,7 @@ TEST(Scenery, saveGlobal)
Scenery scenery2; Scenery scenery2;
result = scenery2.loadGlobal("/tmp/test_paysages_scenery"); result = scenery2.loadGlobal("/tmp/test_paysages_scenery");
EXPECT_EQ((int)Scenery::FILE_OPERATION_OK, result); EXPECT_EQ((int)Scenery::FILE_OPERATION_OK, result);
EXPECT_DOUBLE_EQ(0.2, scenery2.getTerrain()->propWaterHeight()->getValue());
EXPECT_DOUBLE_EQ(0.53, scenery2.getAtmosphere()->propDayTime()->getValue());
} }