From ca7bd84308a21671c56503a42c8f95a5932e9043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 19 Oct 2015 01:39:22 +0200 Subject: [PATCH] Simplified project files + lazy init of data files --- src/basics/basics.pro | 58 +----------- src/definition/definition.pro | 60 +----------- src/interface/commandline/commandline.pro | 6 +- src/interface/modeler/extension/extension.pro | 10 +- src/interface/modeler/quickapp/quickapp.pro | 24 +---- src/render/opengl/opengl.pro | 25 +---- .../software/AtmosphereModelBruneton.cpp | 6 +- src/render/software/software.pro | 91 +------------------ src/system/DataFile.cpp | 7 +- src/system/Logs.cpp | 28 +++++- src/system/system.pro | 38 +------- src/tests/BaseTestCase.cpp | 5 - src/tests/googletest/googletest.pro | 5 +- src/tests/tests.pro | 40 +------- 14 files changed, 59 insertions(+), 344 deletions(-) delete mode 100644 src/tests/BaseTestCase.cpp diff --git a/src/basics/basics.pro b/src/basics/basics.pro index 36bd35c..271b244 100644 --- a/src/basics/basics.pro +++ b/src/basics/basics.pro @@ -13,62 +13,8 @@ DEFINES += BASICS_LIBRARY include(../common.pri) -SOURCES += \ - NoiseGenerator.cpp \ - NoiseFunctionPerlin.cpp \ - NoiseFunctionSimplex.cpp \ - Interpolation.cpp \ - Vector3.cpp \ - Vector3.inline.cpp \ - SpaceSegment.cpp \ - Color.cpp \ - Color.inline.cpp \ - ColorHSL.cpp \ - BoundingBox.cpp \ - Matrix4.cpp \ - Curve.cpp \ - ColorProfile.cpp \ - Geometry.cpp \ - Texture2D.cpp \ - Texture3D.cpp \ - Texture4D.cpp \ - NoiseState.cpp \ - FractalNoise.cpp \ - CappedCylinder.cpp \ - InfiniteCylinder.cpp \ - InfiniteRay.cpp \ - Sphere.cpp \ - InfinitePlane.cpp \ - Disk.cpp \ - SpaceGridIterator.cpp - -HEADERS +=\ - basics_global.h \ - NoiseGenerator.h \ - NoiseFunctionPerlin.h \ - NoiseFunctionSimplex.h \ - Interpolation.h \ - Vector3.h \ - SpaceSegment.h \ - Color.h \ - ColorHSL.h \ - BoundingBox.h \ - Matrix4.h \ - Curve.h \ - ColorProfile.h \ - Geometry.h \ - Texture2D.h \ - Texture3D.h \ - Texture4D.h \ - NoiseState.h \ - FractalNoise.h \ - CappedCylinder.h \ - InfiniteCylinder.h \ - InfiniteRay.h \ - Sphere.h \ - InfinitePlane.h \ - Disk.h \ - SpaceGridIterator.h +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) unix:!symbian { maemo5 { diff --git a/src/definition/definition.pro b/src/definition/definition.pro index 944aef8..a973136 100644 --- a/src/definition/definition.pro +++ b/src/definition/definition.pro @@ -13,64 +13,8 @@ DEFINES += DEFINITION_LIBRARY include(../common.pri) -SOURCES += \ - Layers.cpp \ - WaterDefinition.cpp \ - SurfaceMaterial.cpp \ - CameraDefinition.cpp \ - CloudsDefinition.cpp \ - CloudLayerDefinition.cpp \ - AtmosphereDefinition.cpp \ - TexturesDefinition.cpp \ - TextureLayerDefinition.cpp \ - Zone.cpp \ - TerrainDefinition.cpp \ - TerrainHeightMap.cpp \ - Scenery.cpp \ - PaintedGrid.cpp \ - PaintedGridBrush.cpp \ - PaintedGridData.cpp \ - DefinitionNode.cpp \ - FloatNode.cpp \ - DefinitionDiff.cpp \ - FloatDiff.cpp \ - DiffManager.cpp \ - DefinitionWatcher.cpp \ - IntNode.cpp \ - IntDiff.cpp \ - NoiseNode.cpp \ - GodRaysDefinition.cpp \ - TimeManager.cpp - -HEADERS +=\ - definition_global.h \ - Layers.h \ - WaterDefinition.h \ - SurfaceMaterial.h \ - CameraDefinition.h \ - CloudsDefinition.h \ - CloudLayerDefinition.h \ - AtmosphereDefinition.h \ - TexturesDefinition.h \ - TextureLayerDefinition.h \ - Zone.h \ - TerrainDefinition.h \ - TerrainHeightMap.h \ - Scenery.h \ - PaintedGrid.h \ - PaintedGridBrush.h \ - PaintedGridData.h \ - DefinitionNode.h \ - FloatNode.h \ - DefinitionDiff.h \ - FloatDiff.h \ - DiffManager.h \ - DefinitionWatcher.h \ - IntNode.h \ - IntDiff.h \ - NoiseNode.h \ - GodRaysDefinition.h \ - TimeManager.h +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) unix:!symbian { maemo5 { diff --git a/src/interface/commandline/commandline.pro b/src/interface/commandline/commandline.pro index c3fca29..d34d556 100644 --- a/src/interface/commandline/commandline.pro +++ b/src/interface/commandline/commandline.pro @@ -6,10 +6,8 @@ TARGET = paysages-cli include(../../common.pri) -SOURCES += \ - main.cpp \ - tests.cpp \ - render.cpp +SOURCES += $$files(*.cpp) +#HEADERS += $$files(*.h) win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../system/release/ -lpaysages_system else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../system/debug/ -lpaysages_system diff --git a/src/interface/modeler/extension/extension.pro b/src/interface/modeler/extension/extension.pro index 03da2cd..d52d747 100644 --- a/src/interface/modeler/extension/extension.pro +++ b/src/interface/modeler/extension/extension.pro @@ -6,14 +6,8 @@ CONFIG += qt plugin TARGET = $$qtLibraryTarget($$TARGET) uri = Paysages -# Input -SOURCES += \ - extension_plugin.cpp \ - paysages.cpp - -HEADERS += \ - extension_plugin.h \ - paysages.h +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) OTHER_FILES = qmldir diff --git a/src/interface/modeler/quickapp/quickapp.pro b/src/interface/modeler/quickapp/quickapp.pro index b2085b8..feaf0d8 100644 --- a/src/interface/modeler/quickapp/quickapp.pro +++ b/src/interface/modeler/quickapp/quickapp.pro @@ -4,16 +4,8 @@ QT += qml quick widgets include(../../../common.pri) -SOURCES += main.cpp \ - OpenGLView.cpp \ - MainModelerWindow.cpp \ - WaterModeler.cpp \ - AtmosphereModeler.cpp \ - RenderPreviewProvider.cpp \ - RenderProcess.cpp \ - ModelerCameras.cpp \ - FloatPropertyBind.cpp \ - IntPropertyBind.cpp +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) RESOURCES += \ qml/app.qrc @@ -26,18 +18,6 @@ QML_IMPORT_PATH = ../extension # Default rules for deployment. include(deployment.pri) -HEADERS += \ - OpenGLView.h \ - modeler_global.h \ - MainModelerWindow.h \ - WaterModeler.h \ - AtmosphereModeler.h \ - RenderPreviewProvider.h \ - RenderProcess.h \ - ModelerCameras.h \ - FloatPropertyBind.h \ - IntPropertyBind.h - win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../system/release/ -lpaysages_system else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../system/debug/ -lpaysages_system else:unix: LIBS += -L$$OUT_PWD/../../../system/ -lpaysages_system diff --git a/src/render/opengl/opengl.pro b/src/render/opengl/opengl.pro index 8aa40a1..c1034e4 100644 --- a/src/render/opengl/opengl.pro +++ b/src/render/opengl/opengl.pro @@ -13,29 +13,8 @@ DEFINES += OPENGL_LIBRARY include(../../common.pri) -SOURCES += \ - OpenGLRenderer.cpp \ - ExplorerChunkTerrain.cpp \ - OpenGLShaderProgram.cpp \ - OpenGLPart.cpp \ - OpenGLSkybox.cpp \ - OpenGLWater.cpp \ - OpenGLSharedState.cpp \ - OpenGLVariable.cpp \ - OpenGLTerrain.cpp - -HEADERS +=\ - opengl_global.h \ - OpenGLRenderer.h \ - ExplorerChunkTerrain.h \ - OpenGLShaderProgram.h \ - OpenGLPart.h \ - OpenGLSkybox.h \ - OpenGLWater.h \ - OpenGLSharedState.h \ - OpenGLVariable.h \ - OpenGLTerrain.h \ - VertexArray.h +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) unix:!symbian { maemo5 { diff --git a/src/render/software/AtmosphereModelBruneton.cpp b/src/render/software/AtmosphereModelBruneton.cpp index 752fb7b..c387ff1 100644 --- a/src/render/software/AtmosphereModelBruneton.cpp +++ b/src/render/software/AtmosphereModelBruneton.cpp @@ -1147,11 +1147,15 @@ int brunetonInit() return 1; } -static const int _init = brunetonInit(); +static int _inited; AtmosphereModelBruneton::AtmosphereModelBruneton(SoftwareRenderer *parent): parent(parent) { + if (not _inited) + { + _inited = brunetonInit(); + } } AtmosphereModelBruneton::~AtmosphereModelBruneton() diff --git a/src/render/software/software.pro b/src/render/software/software.pro index ab19edf..dff5077 100644 --- a/src/render/software/software.pro +++ b/src/render/software/software.pro @@ -13,94 +13,11 @@ DEFINES += SOFTWARE_LIBRARY include(../../common.pri) -SOURCES += SoftwareRenderer.cpp \ - FluidMediumInterface.cpp \ - FluidMediumManager.cpp \ - AtmosphereRenderer.cpp \ - CloudsRenderer.cpp \ - BaseCloudLayerRenderer.cpp \ - SkyRasterizer.cpp \ - CloudBasicLayerRenderer.cpp \ - clouds/BaseCloudsModel.cpp \ - clouds/CloudModelStratoCumulus.cpp \ - TerrainRasterizer.cpp \ - WaterRasterizer.cpp \ - LightingManager.cpp \ - LightStatus.cpp \ - LightFilter.cpp \ - LightComponent.cpp \ - AtmosphereResult.cpp \ - AtmosphereModelBruneton.cpp \ - TerrainRenderer.cpp \ - TexturesRenderer.cpp \ - WaterRenderer.cpp \ - RayCastingManager.cpp \ - NightSky.cpp \ - TerrainRayWalker.cpp \ - Canvas.cpp \ - CanvasPortion.cpp \ - CanvasPixel.cpp \ - CanvasFragment.cpp \ - SoftwareCanvasRenderer.cpp \ - Rasterizer.cpp \ - CanvasLiveClient.cpp \ - CanvasPreview.cpp \ - RenderConfig.cpp \ - CanvasPixelShader.cpp \ - CanvasPictureWriter.cpp \ - clouds/CloudModelAltoCumulus.cpp \ - clouds/CloudModelCirrus.cpp \ - clouds/CloudModelCumuloNimbus.cpp \ - RenderProgress.cpp \ - LightSource.cpp \ - RayCastingResult.cpp \ - GodRaysSampler.cpp \ - GodRaysResult.cpp +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) -HEADERS += SoftwareRenderer.h\ - software_global.h \ - FluidMediumInterface.h \ - FluidMediumManager.h \ - AtmosphereRenderer.h \ - CloudsRenderer.h \ - BaseCloudLayerRenderer.h \ - SkyRasterizer.h \ - CloudBasicLayerRenderer.h \ - clouds/BaseCloudsModel.h \ - clouds/CloudModelStratoCumulus.h \ - TerrainRasterizer.h \ - WaterRasterizer.h \ - LightingManager.h \ - LightStatus.h \ - LightFilter.h \ - LightComponent.h \ - AtmosphereResult.h \ - AtmosphereModelBruneton.h \ - TerrainRenderer.h \ - TexturesRenderer.h \ - WaterRenderer.h \ - RayCastingManager.h \ - NightSky.h \ - TerrainRayWalker.h \ - Canvas.h \ - CanvasPortion.h \ - CanvasPixel.h \ - CanvasFragment.h \ - SoftwareCanvasRenderer.h \ - Rasterizer.h \ - CanvasLiveClient.h \ - CanvasPreview.h \ - RenderConfig.h \ - CanvasPixelShader.h \ - CanvasPictureWriter.h \ - clouds/CloudModelAltoCumulus.h \ - clouds/CloudModelCirrus.h \ - clouds/CloudModelCumuloNimbus.h \ - RenderProgress.h \ - LightSource.h \ - RayCastingResult.h \ - GodRaysSampler.h \ - GodRaysResult.h +SOURCES += $$files(clouds/*.cpp) +HEADERS += $$files(clouds/*.h) unix:!symbian { maemo5 { diff --git a/src/system/DataFile.cpp b/src/system/DataFile.cpp index 29d61f5..36bf698 100644 --- a/src/system/DataFile.cpp +++ b/src/system/DataFile.cpp @@ -5,6 +5,11 @@ std::string DataFile::findFile(const std::string &relpath) { + if (dataDir.empty()) + { + dataDir = initDataDir(); + } + QDir dir(QString::fromStdString(dataDir)); if (dir.exists(QString::fromStdString(relpath))) { @@ -69,4 +74,4 @@ std::string DataFile::initDataDir() } } -std::string DataFile::dataDir = DataFile::initDataDir(); +std::string DataFile::dataDir; diff --git a/src/system/Logs.cpp b/src/system/Logs.cpp index 097bd2e..1240230 100644 --- a/src/system/Logs.cpp +++ b/src/system/Logs.cpp @@ -2,7 +2,33 @@ #include "Time.h" -static std::ostream NULL_STREAM(0); +#include +#include + +template > +class basic_nullbuf: public std::basic_streambuf { + typename traits::int_type overflow(typename traits::int_type c) + { + return traits::not_eof(c); // indicate success + } +}; + +template > +class basic_onullstream: public std::basic_ostream { + public: + basic_onullstream(): + std::basic_ios(&m_sbuf), + std::basic_ostream(&m_sbuf) + { + this->init(&m_sbuf); + } + + private: + basic_nullbuf m_sbuf; +}; + +typedef basic_onullstream onullstream; +static onullstream NULL_STREAM; static bool enabled = true; std::ostream &Logs::debug() diff --git a/src/system/system.pro b/src/system/system.pro index 36fdf14..b71c581 100644 --- a/src/system/system.pro +++ b/src/system/system.pro @@ -13,42 +13,8 @@ DEFINES += SYSTEM_LIBRARY include(../common.pri) -SOURCES += \ - Thread.cpp \ - Mutex.cpp \ - System.cpp \ - PackStream.cpp \ - RandomGenerator.cpp \ - Memory.cpp \ - ParallelWork.cpp \ - CacheFile.cpp \ - PictureWriter.cpp \ - Logs.cpp \ - ParallelPool.cpp \ - ParallelWorker.cpp \ - Semaphore.cpp \ - FileSystem.cpp \ - DataFile.cpp \ - Time.cpp - -HEADERS += \ - system_global.h \ - Thread.h \ - Mutex.h \ - System.h \ - PackStream.h \ - RandomGenerator.h \ - Memory.h \ - ParallelWork.h \ - CacheFile.h \ - PictureWriter.h \ - Logs.h \ - ParallelPool.h \ - ParallelWorker.h \ - Semaphore.h \ - FileSystem.h \ - DataFile.h \ - Time.h +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) unix:!symbian { maemo5 { diff --git a/src/tests/BaseTestCase.cpp b/src/tests/BaseTestCase.cpp deleted file mode 100644 index 6481b2f..0000000 --- a/src/tests/BaseTestCase.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "BaseTestCase.h" - -BaseTestCase::BaseTestCase() -{ -} diff --git a/src/tests/googletest/googletest.pro b/src/tests/googletest/googletest.pro index 1e38374..bb7aa5a 100644 --- a/src/tests/googletest/googletest.pro +++ b/src/tests/googletest/googletest.pro @@ -15,10 +15,7 @@ QMAKE_CXXFLAGS += -pthread -Wno-missing-field-initializers INCLUDEPATH += ./sources ./sources/include -SOURCES += \ - sources/src/gtest-all.cc - -HEADERS += +SOURCES += sources/src/gtest-all.cc unix:!symbian { maemo5 { diff --git a/src/tests/tests.pro b/src/tests/tests.pro index 109d52d..6a0b9f5 100644 --- a/src/tests/tests.pro +++ b/src/tests/tests.pro @@ -6,44 +6,8 @@ TARGET = paysages-tests include(../common.pri) -SOURCES += main.cpp \ - Layers_Test.cpp \ - PackStream_Test.cpp \ - NoiseGenerator_Test.cpp \ - TerrainPainting_Test.cpp \ - Zone_Test.cpp \ - Euclid_Test.cpp \ - Camera_Test.cpp \ - Clouds_Test.cpp \ - FluidMediumManager_Test.cpp \ - VertexArray_Test.cpp \ - FractalNoise_Test.cpp \ - SpaceSegment_Test.cpp \ - Canvas_Test.cpp \ - CanvasPortion_Test.cpp \ - CanvasPixel_Test.cpp \ - CanvasPreview_Test.cpp \ - AtmosphereDefinition_Test.cpp \ - Scenery_Test.cpp \ - DefinitionNode_Test.cpp \ - FloatNode_Test.cpp \ - DiffManager_Test.cpp \ - ColorHSL_Test.cpp \ - RenderProgress_Test.cpp \ - IntNode_Test.cpp \ - LightingManager_Test.cpp \ - GodRaysSampler_Test.cpp \ - Interpolation_Test.cpp \ - Rasterizer_Test.cpp \ - CappedCylinder_Test.cpp \ - InfiniteCylinder_Test.cpp \ - Sphere_Test.cpp \ - InfinitePlane_Test.cpp \ - Disk_Test.cpp \ - Vector3_Test.cpp - -HEADERS += \ - BaseTestCase.h +SOURCES += $$files(*.cpp) +HEADERS += $$files(*.h) win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/googletest/release/ -lgoogletest else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/googletest/debug/ -lgoogletest