diff --git a/data/cache/atmo-br-inscatter-128-32-8-32-0.cache b/data/cache/atmo-br-inscatter-128-32-8-32-0.cache index d5af9de..5b10eb8 100644 Binary files a/data/cache/atmo-br-inscatter-128-32-8-32-0.cache and b/data/cache/atmo-br-inscatter-128-32-8-32-0.cache differ diff --git a/data/cache/atmo-br-irradiance-256-64-0-0-0.cache b/data/cache/atmo-br-irradiance-256-64-0-0-0.cache index 43da578..9987b7f 100644 Binary files a/data/cache/atmo-br-irradiance-256-64-0-0-0.cache and b/data/cache/atmo-br-irradiance-256-64-0-0-0.cache differ diff --git a/data/cache/atmo-br-transmittance-512-128-0-0-0.cache b/data/cache/atmo-br-transmittance-512-128-0-0-0.cache index 3f14079..3fce617 100644 Binary files a/data/cache/atmo-br-transmittance-512-128-0-0-0.cache and b/data/cache/atmo-br-transmittance-512-128-0-0-0.cache differ diff --git a/src/core/AtmosphereModelBruneton.cpp b/src/core/AtmosphereModelBruneton.cpp index aeb5f2b..34cc12e 100644 --- a/src/core/AtmosphereModelBruneton.cpp +++ b/src/core/AtmosphereModelBruneton.cpp @@ -65,9 +65,9 @@ static constexpr double AVERAGE_GROUND_REFLECTANCE = 0.1; #define INSCATTER_SPHERICAL_INTEGRAL_SAMPLES 8 #endif -Texture2D *_transmittanceTexture = NULL; -Texture2D *_irradianceTexture = NULL; -Texture4D *_inscatterTexture = NULL; +Texture2D *_transmittanceTexture = nullptr; +Texture2D *_irradianceTexture = nullptr; +Texture4D *_inscatterTexture = nullptr; /* Rayleigh */ static const double HR = 8.0; @@ -951,7 +951,7 @@ int brunetonInit() { int x, y, z, w, order; ParallelWork *work; - assert(_inscatterTexture == NULL); + assert(_inscatterTexture == nullptr); /* TODO Deletes */ _transmittanceTexture = new Texture2D(TRANSMITTANCE_W, TRANSMITTANCE_H); diff --git a/src/core/CacheFile.cpp b/src/core/CacheFile.cpp index 613529b..bdb76ff 100644 --- a/src/core/CacheFile.cpp +++ b/src/core/CacheFile.cpp @@ -1,20 +1,14 @@ #include "CacheFile.h" #include "DataFile.h" -#include + +#include CacheFile::CacheFile(const string &module, const string &ext, const string &tag1, int tag2, int tag3, int tag4, int tag5, int tag6) { - filepath = QString("cache/%1-%2-%3-%4-%5-%6-%7.%8") - .arg(QString::fromStdString(module)) - .arg(QString::fromStdString(tag1)) - .arg(tag2) - .arg(tag3) - .arg(tag4) - .arg(tag5) - .arg(tag6) - .arg(QString::fromStdString(ext)) - .toStdString(); + ostringstream buf; + buf << "cache/" << module << "-" << tag1 << "-" << tag2 << "-" << tag3 << "-" << tag4 << "-" << tag5 << "-" << tag6 << "." << ext; + filepath = buf.str(); } bool CacheFile::isReadable() { diff --git a/src/core/CameraDefinition.h b/src/core/CameraDefinition.h index 84a6b11..9c2a168 100644 --- a/src/core/CameraDefinition.h +++ b/src/core/CameraDefinition.h @@ -19,7 +19,7 @@ typedef struct { class CORESHARED_EXPORT CameraDefinition : public DefinitionNode { public: - CameraDefinition(DefinitionNode *parent = NULL); + CameraDefinition(DefinitionNode *parent = nullptr); virtual void save(PackStream *pack) const override; virtual void load(PackStream *pack) override; diff --git a/src/core/CanvasPictureWriter.cpp b/src/core/CanvasPictureWriter.cpp index 17ac07f..daf6403 100644 --- a/src/core/CanvasPictureWriter.cpp +++ b/src/core/CanvasPictureWriter.cpp @@ -76,7 +76,7 @@ Color CanvasPictureWriter::getRawPixel(int x, int y) { cache_width = canvas->getWidth(); cache = new Color[cache_width * antialias]; - CanvasPortion *portion = NULL; + CanvasPortion *portion = nullptr; PackStream *stream = new PackStream; Color *itcolor = cache; diff --git a/src/core/CanvasPixel.cpp b/src/core/CanvasPixel.cpp index cbd3129..7cec820 100644 --- a/src/core/CanvasPixel.cpp +++ b/src/core/CanvasPixel.cpp @@ -9,7 +9,7 @@ CanvasPixel::CanvasPixel() { const CanvasFragment *CanvasPixel::getFrontFragment() const { if (count == 0) { - return NULL; + return nullptr; } else { return fragments + (count - 1); } diff --git a/src/core/CanvasPixelShader.cpp b/src/core/CanvasPixelShader.cpp index c4338d4..40aa40c 100644 --- a/src/core/CanvasPixelShader.cpp +++ b/src/core/CanvasPixelShader.cpp @@ -41,7 +41,7 @@ void CanvasPixelShader::processParallelUnit(int unit) { const CanvasPixel &pixel = portion->at(base_x + x, base_y + y); int n = pixel.getFragmentCount(); Color composite = COLOR_BLACK; - const CanvasFragment *previous = NULL; + const CanvasFragment *previous = nullptr; for (int i = 0; i < n; i++) { const CanvasFragment &fragment = pixel.getFragment(i); const Rasterizer &rasterizer = renderer.getRasterizer(fragment.getClient()); diff --git a/src/core/CanvasPortion.cpp b/src/core/CanvasPortion.cpp index 8ebb780..da95215 100644 --- a/src/core/CanvasPortion.cpp +++ b/src/core/CanvasPortion.cpp @@ -15,7 +15,7 @@ assert(x < width); \ assert(y >= 0); \ assert(y < height); \ - assert(pixels != NULL) + assert(pixels != nullptr) // Keep track of created files to erase them at program exit static vector _files; @@ -31,7 +31,7 @@ CanvasPortion::CanvasPortion(int index, CanvasPreview *preview) : index(index), height = 1; xoffset = 0; yoffset = 0; - pixels = NULL; + pixels = nullptr; } CanvasPortion::~CanvasPortion() { @@ -79,7 +79,7 @@ void CanvasPortion::discardPixels(bool save) { saveToDisk(); } delete[] pixels; - pixels = NULL; + pixels = nullptr; } } diff --git a/src/core/CanvasPortion.h b/src/core/CanvasPortion.h index ce6006f..e4e0cfe 100644 --- a/src/core/CanvasPortion.h +++ b/src/core/CanvasPortion.h @@ -16,7 +16,7 @@ namespace software { */ class CORESHARED_EXPORT CanvasPortion { public: - CanvasPortion(int index = 0, CanvasPreview *preview = NULL); + CanvasPortion(int index = 0, CanvasPreview *preview = nullptr); virtual ~CanvasPortion(); inline int getWidth() const { diff --git a/src/core/CloudsDefinition.cpp b/src/core/CloudsDefinition.cpp index 47ad5c4..292f42b 100644 --- a/src/core/CloudsDefinition.cpp +++ b/src/core/CloudsDefinition.cpp @@ -13,7 +13,7 @@ void CloudsDefinition::applyPreset(CloudsPreset preset, RandomGenerator &random) clear(); if (preset == CLOUDS_PRESET_PARTLY_CLOUDY) { - CloudLayerDefinition layer(NULL, "Strato-cumulus"); + CloudLayerDefinition layer(nullptr, "Strato-cumulus"); layer.type = CloudLayerDefinition::STRATOCUMULUS; layer.noise_state.randomizeOffsets(random); addLayer(layer); diff --git a/src/core/CloudsRenderer.cpp b/src/core/CloudsRenderer.cpp index 2dea700..1f23d84 100644 --- a/src/core/CloudsRenderer.cpp +++ b/src/core/CloudsRenderer.cpp @@ -20,7 +20,7 @@ CloudsRenderer::CloudsRenderer(SoftwareRenderer *parent) : parent(parent) { enabled = true; fake_renderer = new BaseCloudLayerRenderer(parent); - CloudLayerDefinition *fake_layer = new CloudLayerDefinition(NULL, "#fake#"); + CloudLayerDefinition *fake_layer = new CloudLayerDefinition(nullptr, "#fake#"); fake_model = new BaseCloudsModel(fake_layer); } diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 1f9eb2d..a743265 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -1,16 +1,18 @@ #include "DataFile.h" #include "Logs.h" -#include +#include + +using namespace std::filesystem; string DataFile::findFile(const string &relpath) { if (dataDir.empty()) { dataDir = initDataDir(); } - QDir dir(QString::fromStdString(dataDir)); - if (dir.exists(QString::fromStdString(relpath))) { - return dir.absoluteFilePath(QString::fromStdString(relpath)).toStdString(); + auto absPath = path(dataDir) / path(relpath); + if (exists(absPath)) { + return absPath; } else { return ""; } @@ -20,28 +22,29 @@ string DataFile::findDir(const string &relpath) { return findFile(relpath); } -bool DataFile::tryDataDir(const QDir &dir) { - Logs::debug("System") << "Try data dir " << dir.absolutePath().toStdString() << endl; - return dir.exists("data/.paysages_data"); +bool DataFile::tryDataDir(const string &dir) { + const auto abs_path = absolute(path(dir)); + Logs::debug("System") << "Try data dir " << abs_path << endl; + return exists(abs_path / path("data") / path(".paysages_data")); } string DataFile::locateDataDir() { - QDir dir = QDir::current(); + auto dir = absolute(current_path()); int i = 0; // TODO /usr/share/paysages3d/ - while (i++ < 100 and not dir.isRoot()) { + while (i++ < 100 and dir.has_parent_path()) { if (tryDataDir(dir)) { - return dir.absolutePath().toStdString(); + return dir; } - QDir dir2(dir.absoluteFilePath("paysages3d")); + const auto dir2 = dir / path("paysages3d"); if (tryDataDir(dir2)) { - return dir2.absolutePath().toStdString(); + return dir2; } - dir = QDir(QDir(dir.absoluteFilePath("..")).canonicalPath()); + dir = dir.parent_path(); } return ""; @@ -53,7 +56,7 @@ string DataFile::initDataDir() { Logs::warning("System") << "Data files not found" << endl; return parent; } else { - string result = QDir(QString::fromStdString(parent)).absoluteFilePath("data").toStdString(); + string result = parent / path("data"); Logs::debug("System") << "Data files found : " << result << endl; return result; } diff --git a/src/core/DataFile.h b/src/core/DataFile.h index 2cde717..98e5bff 100644 --- a/src/core/DataFile.h +++ b/src/core/DataFile.h @@ -29,7 +29,7 @@ class CORESHARED_EXPORT DataFile { static string findDir(const string &relpath); private: - static bool tryDataDir(const QDir &dir); + static bool tryDataDir(const string &dir); static string locateDataDir(); static string initDataDir(); static string dataDir; diff --git a/src/core/DefinitionNode.cpp b/src/core/DefinitionNode.cpp index e5dee86..dcdebe6 100644 --- a/src/core/DefinitionNode.cpp +++ b/src/core/DefinitionNode.cpp @@ -27,7 +27,7 @@ DefinitionNode::DefinitionNode(DefinitionNode *parent, const string &name, const : parent(parent), type_name(type_name), name(name) { if (parent) { root = parent->root; - diffs = NULL; + diffs = nullptr; parent->addChild(this); } else { root = this; @@ -38,12 +38,12 @@ DefinitionNode::DefinitionNode(DefinitionNode *parent, const string &name, const DefinitionNode::~DefinitionNode() { if (parent) { parent->removeChild(this); - parent = NULL; + parent = nullptr; } if (diffs) { delete diffs; - diffs = NULL; + diffs = nullptr; } // Work on a copy, because the child destructor will modify the array by removing itself using removeChild @@ -63,7 +63,7 @@ const Scenery *DefinitionNode::getScenery() const { if (parent) { return parent->getScenery(); } else { - return NULL; + return nullptr; } } @@ -93,7 +93,7 @@ string DefinitionNode::getPath() const { DefinitionNode *DefinitionNode::findByPath(const string &path) const { if (path.empty()) { - return NULL; + return nullptr; } else if (path[0] == '/') { if (path.length() == 1) { return root; @@ -113,7 +113,7 @@ DefinitionNode *DefinitionNode::findByPath(const string &path) const { return child->findByPath(path.substr(seppos + 1)); } } else { - return NULL; + return nullptr; } } } @@ -218,7 +218,7 @@ void DefinitionNode::addChild(DefinitionNode *child) { void DefinitionNode::removeChild(DefinitionNode *child) { vector::iterator it = find(children.begin(), children.end(), child); if (it != children.end()) { - child->parent = NULL; + child->parent = nullptr; children.erase(it); } else { Logs::warning("Definition") << "Trying to remove not found child '" << child->name << "' from '" << name << "'" @@ -232,7 +232,7 @@ DefinitionNode *DefinitionNode::findChildByName(const string &name) const { return child; } } - return NULL; + return nullptr; } void DefinitionNode::tellChanged() { @@ -267,7 +267,7 @@ void DefinitionNode::setRoot(DefinitionNode *root) { this->root = root; if (diffs) { delete diffs; - diffs = NULL; + diffs = nullptr; } for (auto &child : children) { child->setRoot(root); diff --git a/src/core/DefinitionNode.h b/src/core/DefinitionNode.h index 2f9cc6a..e0aa36e 100644 --- a/src/core/DefinitionNode.h +++ b/src/core/DefinitionNode.h @@ -59,7 +59,7 @@ class CORESHARED_EXPORT DefinitionNode { /** * Find a node in this tree, by its path (as returned by getPath). * - * Return NULL if the path does not exists. + * Return nullptr if the path does not exists. */ DefinitionNode *findByPath(const string &path) const; diff --git a/src/core/FileSystem.cpp b/src/core/FileSystem.cpp index 348ea60..8ed0fff 100644 --- a/src/core/FileSystem.cpp +++ b/src/core/FileSystem.cpp @@ -1,20 +1,27 @@ #include "FileSystem.h" -#include -#include -#include +#include + +using namespace std::filesystem; string FileSystem::getTempFile(const string &filename) { - return QDir::temp().filePath(QString::fromStdString(filename)).toStdString(); + const auto temp_dir = temp_directory_path() / path("paysages3d"); + if (!exists(temp_dir)) { + create_directory(temp_dir); + } + return temp_dir / path(filename); } bool FileSystem::isFile(const string &filepath) { - return QFileInfo(QString::fromStdString(filepath)).exists(); + const auto path(filepath); + return exists(path) && is_regular_file(path); } bool FileSystem::removeFile(const string &filepath) { - if (FileSystem::isFile(filepath)) { - remove(filepath.c_str()); + const auto path(filepath); + + if (exists(path) && is_regular_file(path)) { + remove(filepath); return true; } else { return false; diff --git a/src/core/GodRaysSampler.cpp b/src/core/GodRaysSampler.cpp index 4861c5e..664a82e 100644 --- a/src/core/GodRaysSampler.cpp +++ b/src/core/GodRaysSampler.cpp @@ -19,9 +19,9 @@ GodRaysSampler::GodRaysSampler() { enabled = true; bounds = new SpaceSegment(); - definition = new GodRaysDefinition(NULL); + definition = new GodRaysDefinition(nullptr); camera_location = new Vector3(0, 0, 0); - lighting = NULL; + lighting = nullptr; low_altitude = -1.0; high_altitude = 1.0; sampling_step = 1.0; diff --git a/src/core/Layers.cpp b/src/core/Layers.cpp index 4e8010d..e75309f 100644 --- a/src/core/Layers.cpp +++ b/src/core/Layers.cpp @@ -90,7 +90,7 @@ bool Layers::applyDiff(const DefinitionDiff *diff, bool backward) { Logs::error("Definition") << "Add layer ignored because requested position was incorrect" << endl; return false; } else { - DefinitionNode *layer = layer_constructor(NULL, "temp"); + DefinitionNode *layer = layer_constructor(nullptr, "temp"); layer_diff->restoreSavedLayer(layer); if (position == layer_count) { layers.push_back(layer); @@ -134,7 +134,7 @@ void Layers::addLayer(const DefinitionNode &tocopy) { } void Layers::addLayer(const string &name) { - auto layer = layer_constructor(NULL, name); + auto layer = layer_constructor(nullptr, name); addLayer(*layer); delete layer; } diff --git a/src/core/LayersDiff.cpp b/src/core/LayersDiff.cpp index b8373b5..580dfbb 100644 --- a/src/core/LayersDiff.cpp +++ b/src/core/LayersDiff.cpp @@ -5,11 +5,11 @@ #include "PackStream.h" LayersDiff::LayersDiff(const Layers *layers, LayersDiffOp op, int layer1) - : DefinitionDiff(layers), op(op), layer1(layer1), saved(NULL) { + : DefinitionDiff(layers), op(op), layer1(layer1), saved(nullptr) { } LayersDiff::LayersDiff(const LayersDiff *other, LayersDiff::LayersDiffOp op, int layer1) - : DefinitionDiff(other), op(op), layer1(layer1), saved(NULL) { + : DefinitionDiff(other), op(op), layer1(layer1), saved(nullptr) { } LayersDiff::~LayersDiff() { diff --git a/src/core/MoonRenderer.cpp b/src/core/MoonRenderer.cpp index 695e503..9257aec7 100644 --- a/src/core/MoonRenderer.cpp +++ b/src/core/MoonRenderer.cpp @@ -12,7 +12,7 @@ class MoonRenderer::pimpl { public: - pimpl() : definition(NULL, "moon") { + pimpl() : definition(nullptr, "moon") { } CelestialBodyDefinition definition; }; diff --git a/src/core/NoiseFunctionSimplex.cpp b/src/core/NoiseFunctionSimplex.cpp index 6f849c4..dca272d 100644 --- a/src/core/NoiseFunctionSimplex.cpp +++ b/src/core/NoiseFunctionSimplex.cpp @@ -621,7 +621,7 @@ double NoiseFunctionSimplex::getBase3d(double x, double y, double z) const { } static constexpr double TEXTURE_SCALING = 15.0; -static Texture2D *_valueTexture = NULL; +static Texture2D *_valueTexture = nullptr; const Texture2D *NoiseFunctionSimplex::getValueTexture() { if (!_valueTexture) { @@ -644,7 +644,7 @@ const Texture2D *NoiseFunctionSimplex::getValueTexture() { return _valueTexture; } -static Texture2D *_normalTexture = NULL; +static Texture2D *_normalTexture = nullptr; const Texture2D *NoiseFunctionSimplex::getNormalTexture() { if (!_normalTexture) { diff --git a/src/core/PackStream.cpp b/src/core/PackStream.cpp index c42c332..92480b1 100644 --- a/src/core/PackStream.cpp +++ b/src/core/PackStream.cpp @@ -1,163 +1,137 @@ #include "PackStream.h" #include "Logs.h" -#include -#include -#include -#include + +#include +#include +#include class PackStream::pimpl { public: - QFile *file; - QByteArray *buffer; - QDataStream *stream; + fstream *file; + stringstream *buffer; + iostream* stream; }; PackStream::PackStream() : pv(new pimpl) { - pv->file = NULL; - pv->buffer = new QByteArray(); - pv->stream = new QDataStream(pv->buffer, QIODevice::WriteOnly); - pv->stream->setVersion(QDataStream::Qt_5_4); + pv->file = new fstream(); + pv->buffer = new stringstream(); + pv->stream = pv->buffer; } PackStream::PackStream(const PackStream *other) : pv(new pimpl) { - pv->file = NULL; - pv->buffer = new QByteArray(); - if (other->pv->file) { + pv->file = new fstream(); + pv->buffer = new stringstream(); + if (other->pv->file->is_open()) { Logs::error("System") << "Try to read from a substream bound to a file: " - << other->pv->file->fileName().toStdString() << endl; - pv->stream = new QDataStream(pv->buffer, QIODevice::ReadOnly); + << other->pv->file << endl; } else { - pv->stream = new QDataStream(other->pv->buffer, QIODevice::ReadOnly); + other->pv->buffer->seekg(0); + other->pv->buffer->get(*pv->buffer->rdbuf()); } - pv->stream->setVersion(QDataStream::Qt_5_4); + pv->stream = pv->buffer; } PackStream::PackStream(const string &buffer_content) : pv(new pimpl) { - pv->file = NULL; - pv->buffer = new QByteArray(buffer_content.c_str(), buffer_content.size()); - pv->stream = new QDataStream(pv->buffer, QIODevice::ReadOnly); - pv->stream->setVersion(QDataStream::Qt_5_4); + pv->file = new fstream(); + pv->buffer = new stringstream(buffer_content); + pv->stream = pv->buffer; } PackStream::~PackStream() { + delete pv->file; delete pv->buffer; - delete pv->stream; - if (pv->file) { - delete pv->file; - } } bool PackStream::bindToFile(const string &filepath, bool write) { - if (not pv->file) { - pv->file = new QFile(QString::fromStdString(filepath)); - if (not pv->file->open(write ? QIODevice::WriteOnly : QIODevice::ReadOnly)) { - return false; - } - - QDataStream *new_stream = new QDataStream(pv->file); - if (new_stream) { - delete pv->stream; - pv->stream = new_stream; - pv->stream->setVersion(QDataStream::Qt_5_4); + if (pv->file->is_open()) { + return false; + } else { + pv->file->open(filepath, write ? ios_base::out : ios_base::in); + if (pv->file->is_open()) { + pv->stream = pv->file; return true; } else { return false; } - } else { - return false; } } void PackStream::write(const int *value) { if (value) { - *pv->stream << *value; + // TODO endianness and int size portability + pv->stream->write(reinterpret_cast(value), sizeof(int)); } } void PackStream::write(const double *value) { if (value) { - *pv->stream << *value; - } -} - -void PackStream::write(const char *value, int max_length) { - if (value) { - int length = qstrlen(value); - *pv->stream << QString::fromUtf8(value, length > max_length ? max_length : length); + // TODO float format portability + pv->stream->write(reinterpret_cast(value), sizeof(double)); } } void PackStream::write(const string &value) { - *pv->stream << QString::fromStdString(value); + const int length = value.length(); + write(&length); + pv->stream->write(value.c_str(), length); } void PackStream::writeFromBuffer(const PackStream &other, bool prepend_size) { - if (other.pv->file) { + if (other.pv->file->is_open()) { Logs::error("System") << "Try to write from a substream bound to a file: " - << other.pv->file->fileName().toStdString() << endl; + << other.pv->file << endl; } else { + int buffer_size = other.pv->buffer->rdbuf()->str().length(); if (prepend_size) { - int buffer_size = (int)other.pv->buffer->size(); write(&buffer_size); } - pv->stream->writeRawData(other.pv->buffer->data(), other.pv->buffer->size()); + pv->stream->write(other.pv->buffer->rdbuf()->str().c_str(), buffer_size); } } string PackStream::getBuffer() { - if (pv->file) { - Logs::error("System") << "Try to get buffer on a stream bound to a file: " << pv->file->fileName().toStdString() - << endl; + if (pv->file->is_open()) { + Logs::error("System") << "Try to get buffer on a stream bound to a file: " << pv->file << endl; return ""; } else { - return pv->buffer->toStdString(); + return pv->buffer->rdbuf()->str(); } } void PackStream::read(int *value) { - if (value and not pv->stream->atEnd()) { - int output; - *pv->stream >> output; - *value = output; + if (value and not pv->stream->eof()) { + pv->stream->read(reinterpret_cast(value), sizeof(int)); } } void PackStream::read(double *value) { - if (value and not pv->stream->atEnd()) { - double output; - *pv->stream >> output; - *value = output; - } -} - -void PackStream::read(char *value, int max_length) { - if (value and not pv->stream->atEnd()) { - QString output; - *pv->stream >> output; - QByteArray array = output.toUtf8(); - qstrncpy(value, array.constData(), max_length); + if (value and not pv->stream->eof()) { + pv->stream->read(reinterpret_cast(value), sizeof(double)); } } string PackStream::readString() { - if (not pv->stream->atEnd()) { - QString output; - *pv->stream >> output; - return output.toStdString(); - } else { - return ""; + if (not pv->stream->eof()) { + int size; + read(&size); + if (size > 0) { + std::string str(size, '\0'); + pv->stream->read(&str[0], size); + return str; + } } + return ""; } void PackStream::skip(const int &value, int count) { - pv->stream->skipRawData(sizeof(value) * count); + skipBytes(sizeof(value) * count); } void PackStream::skip(const double &value, int count) { - pv->stream->skipRawData(sizeof(value) * count); + skipBytes(sizeof(value) * count); } void PackStream::skipBytes(int bytes) { - pv->stream->skipRawData(bytes); + pv->stream->seekg(bytes, ios_base::cur); } diff --git a/src/core/PackStream.h b/src/core/PackStream.h index 60b781a..43bf69b 100644 --- a/src/core/PackStream.h +++ b/src/core/PackStream.h @@ -30,7 +30,6 @@ class CORESHARED_EXPORT PackStream { void write(const int *value); void write(const double *value); - void write(const char *value, const int max_length); void write(const string &value); /** @@ -49,7 +48,6 @@ class CORESHARED_EXPORT PackStream { void read(int *value); void read(double *value); - void read(char *value, int max_length); string readString(); void skip(const int &value, int count = 1); diff --git a/src/core/PaintedGrid.cpp b/src/core/PaintedGrid.cpp index dcb2b47..da8e4ae 100644 --- a/src/core/PaintedGrid.cpp +++ b/src/core/PaintedGrid.cpp @@ -44,7 +44,7 @@ bool PaintedGrid::getInterpolatedValue(double x, double y, double *result) const int hit = 0; for (ix = xlow - 1; ix <= xlow + 2 && !hit; ix++) { for (iy = ylow - 1; iy <= ylow + 2 && !hit; iy++) { - if (getDataPointer(brush_data, x, y, NULL, false) || getDataPointer(merged_data, x, y, NULL, false)) { + if (getDataPointer(brush_data, x, y, nullptr, false) || getDataPointer(merged_data, x, y, nullptr, false)) { hit = 1; } } @@ -70,12 +70,12 @@ bool PaintedGrid::getInterpolatedValue(double x, double y, double *result) const bool PaintedGrid::getGridValue(int x, int y, double *result) const { double *dpointer; - dpointer = getDataPointer(brush_data, x, y, NULL, false); + dpointer = getDataPointer(brush_data, x, y, nullptr, false); if (dpointer) { *result = *dpointer; return true; } else { - dpointer = getDataPointer(merged_data, x, y, NULL, false); + dpointer = getDataPointer(merged_data, x, y, nullptr, false); if (dpointer) { *result = *dpointer; return true; @@ -100,7 +100,7 @@ bool PaintedGrid::hasPainting() const { } bool PaintedGrid::isPainted(int x, int y) const { - return getDataPointer(brush_data, x, y, NULL, false) || getDataPointer(merged_data, x, y, NULL, false); + return getDataPointer(brush_data, x, y, nullptr, false) || getDataPointer(merged_data, x, y, nullptr, false); } unsigned long PaintedGrid::getMemoryStats() const { @@ -147,7 +147,7 @@ void PaintedGrid::endBrushStroke() { for (j = 0; j < data->rows[i].pixel_groups_count; j++) { for (k = 0; k < data->rows[i].pixel_groups[j].xend - data->rows[i].pixel_groups[j].xstart + 1; k++) { double *dpointer = - getDataPointer(merged_data, data->rows[i].pixel_groups[j].xstart + k, data->rows[i].y, NULL, true); + getDataPointer(merged_data, data->rows[i].pixel_groups[j].xstart + k, data->rows[i].y, nullptr, true); *dpointer = data->rows[i].pixel_groups[j].height[k]; } } @@ -183,7 +183,7 @@ double *PaintedGrid::getDataPointer(PaintedGridData *data, int x, int y, Painted data->rows_count++; data->memsize += sizeof(PaintedGridData::HeightMapRow); } else { - return NULL; + return nullptr; } #ifndef NDEBUG @@ -194,7 +194,7 @@ double *PaintedGrid::getDataPointer(PaintedGridData *data, int x, int y, Painted #endif /* Find pixel group */ - PaintedGridData::HeightMapPixelGroup *pixel_group = NULL; + PaintedGridData::HeightMapPixelGroup *pixel_group = nullptr; for (i = 0; i < row->pixel_groups_count; i++) { if (x < row->pixel_groups[i].xstart - 1) { break; @@ -214,7 +214,7 @@ double *PaintedGrid::getDataPointer(PaintedGridData *data, int x, int y, Painted int added = 1; if (!pixel_group) { if (!grow) { - return NULL; + return nullptr; } /* Create the pixel group with one pixel */ @@ -231,7 +231,7 @@ double *PaintedGrid::getDataPointer(PaintedGridData *data, int x, int y, Painted data->memsize += sizeof(PaintedGridData::HeightMapPixelGroup) + sizeof(double); } else if (x == pixel_group->xstart - 1) { if (!grow) { - return NULL; + return nullptr; } /* Extend the rowgroup at start */ @@ -241,7 +241,7 @@ double *PaintedGrid::getDataPointer(PaintedGridData *data, int x, int y, Painted data->memsize += sizeof(double); } else if (x == pixel_group->xend + 1) { if (!grow) { - return NULL; + return nullptr; } /* Extend the rowgroup at end */ @@ -273,7 +273,7 @@ double *PaintedGrid::getDataPointer(PaintedGridData *data, int x, int y, Painted /* Reset pixel if it had been added */ if (added) { if (fallback) { - double *dpointer = getDataPointer(fallback, x, y, NULL, false); + double *dpointer = getDataPointer(fallback, x, y, nullptr, false); if (dpointer) { *pixel = *dpointer; } else { diff --git a/src/core/ParallelPool.cpp b/src/core/ParallelPool.cpp index b4e5039..66d112f 100644 --- a/src/core/ParallelPool.cpp +++ b/src/core/ParallelPool.cpp @@ -1,12 +1,13 @@ #include "ParallelPool.h" +#include "Logs.h" #include "System.h" #include "Thread.h" static void *_threadFunction(void *data) { ParallelPool *pool = (ParallelPool *)data; pool->work(); - return NULL; + return nullptr; } ParallelPool::ParallelPool() { @@ -26,7 +27,7 @@ ParallelPool::~ParallelPool() { void ParallelPool::start(int thread_count) { if (running) { - qCritical("Starting an already started parallel pool !"); + Logs::error("System") << "Starting an already started parallel pool !" << endl; return; } running = true; diff --git a/src/core/PictureWriter.cpp b/src/core/PictureWriter.cpp index 77879ae..9d0cc6a 100644 --- a/src/core/PictureWriter.cpp +++ b/src/core/PictureWriter.cpp @@ -1,7 +1,5 @@ #include "PictureWriter.h" -#include - PictureWriter::PictureWriter() { } @@ -9,7 +7,7 @@ PictureWriter::~PictureWriter() { } bool PictureWriter::save(const string &filepath, int width, int height) { - QImage result(width, height, QImage::Format_ARGB32); + /*QImage result(width, height, QImage::Format_ARGB32); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { @@ -17,5 +15,7 @@ bool PictureWriter::save(const string &filepath, int width, int height) { } } - return result.save(QString::fromStdString(filepath)); + return result.save(QString::fromStdString(filepath));*/ + // TODO + return false; } diff --git a/src/core/Scenery.cpp b/src/core/Scenery.cpp index 856cc3b..0ea8fc1 100644 --- a/src/core/Scenery.cpp +++ b/src/core/Scenery.cpp @@ -19,7 +19,7 @@ static const double APP_HEADER = 19866544632.125; static const int DATA_VERSION = 1; -Scenery::Scenery() : DefinitionNode(NULL, "scenery", "scenery") { +Scenery::Scenery() : DefinitionNode(nullptr, "scenery", "scenery") { atmosphere = new AtmosphereDefinition(this); camera = new CameraDefinition(this); clouds = new CloudsDefinition(this); diff --git a/src/core/Semaphore.cpp b/src/core/Semaphore.cpp index 342933f..20d5ae4 100644 --- a/src/core/Semaphore.cpp +++ b/src/core/Semaphore.cpp @@ -1,4 +1,4 @@ #include "Semaphore.h" -Semaphore::Semaphore(int resources) : QSemaphore(resources) { +Semaphore::Semaphore(int resources) : resources(resources) { } diff --git a/src/core/Semaphore.h b/src/core/Semaphore.h index 4c00337..8616ee2 100644 --- a/src/core/Semaphore.h +++ b/src/core/Semaphore.h @@ -2,21 +2,29 @@ #include "core_global.h" -#include +#include +#include namespace paysages { namespace system { -class Semaphore : private QSemaphore { +class Semaphore { public: Semaphore(int resources); inline void acquire() { - QSemaphore::acquire(); + unique_lock lk(mex); + cond.wait(lk, [this]{ return resources > 0; }); } inline void release() { - QSemaphore::release(); + lock_guard lk(mex); + resources++; + cond.notify_one(); } + private: + int resources; + condition_variable cond; + mutex mex; }; } } diff --git a/src/core/SoftwareCanvasRenderer.cpp b/src/core/SoftwareCanvasRenderer.cpp index 6ac5814..231ae3e 100644 --- a/src/core/SoftwareCanvasRenderer.cpp +++ b/src/core/SoftwareCanvasRenderer.cpp @@ -32,7 +32,7 @@ SoftwareCanvasRenderer::SoftwareCanvasRenderer(Scenery *scenery) : SoftwareRende rasterizers.push_back(rasterizer_vegetation = new VegetationRasterizer(this, progress, RASTERIZER_CLIENT_VEGETATION)); - current_work = NULL; + current_work = nullptr; setQuality(0.5); } @@ -170,7 +170,7 @@ void SoftwareCanvasRenderer::applyPixelShader(CanvasPortion *portion) { current_work = &work; work.perform(); - current_work = NULL; + current_work = nullptr; } progress->exitSub(); } diff --git a/src/core/System.cpp b/src/core/System.cpp index 7755c0c..1208ef7 100644 --- a/src/core/System.cpp +++ b/src/core/System.cpp @@ -1,16 +1,18 @@ #include "System.h" -#include -#include +#include "Logs.h" + +#include +#include static int core_count = -1; int System::getCoreCount() { if (core_count < 0) { #ifdef NDEBUG - core_count = QThread::idealThreadCount(); + core_count = thread::hardware_concurrency(); if (core_count <= 0) { - qWarning("Can't find number of CPU cores, using only 1"); + Logs::warning("System") << "Can't find number of CPU cores, using only 1" << endl; core_count = 1; } #else @@ -21,5 +23,5 @@ int System::getCoreCount() { } int System::getProcessId() { - return QCoreApplication::applicationPid(); + return getpid(); } diff --git a/src/core/TerrainRasterizer.cpp b/src/core/TerrainRasterizer.cpp index d93dace..c606220 100644 --- a/src/core/TerrainRasterizer.cpp +++ b/src/core/TerrainRasterizer.cpp @@ -215,7 +215,7 @@ void TerrainRasterizer::processChunk(CanvasPortion *canvas, TerrainChunkInfo *ch int TerrainRasterizer::prepareRasterization() { // TODO Chunks could be saved and reused in rasterizeToCanvas - return performTessellation(NULL); + return performTessellation(nullptr); } void TerrainRasterizer::rasterizeToCanvas(CanvasPortion *canvas) { diff --git a/src/core/TerrainRasterizer.h b/src/core/TerrainRasterizer.h index df925d8..c9d58fa 100644 --- a/src/core/TerrainRasterizer.h +++ b/src/core/TerrainRasterizer.h @@ -56,7 +56,7 @@ class CORESHARED_EXPORT TerrainRasterizer : public Rasterizer { * * Return the number of quads that has been pushed. * - * 'canvas' may be NULL to only simulate the tessellation. + * 'canvas' may be nullptr to only simulate the tessellation. */ int performTessellation(CanvasPortion *canvas); diff --git a/src/core/TexturesDefinition.cpp b/src/core/TexturesDefinition.cpp index 16d9cd9..870d2f6 100644 --- a/src/core/TexturesDefinition.cpp +++ b/src/core/TexturesDefinition.cpp @@ -10,7 +10,7 @@ TexturesDefinition::TexturesDefinition(DefinitionNode *parent) : Layers(parent, } void TexturesDefinition::applyPreset(TexturesPreset preset, RandomGenerator &random) { - TextureLayerDefinition layer(NULL, "temp"); + TextureLayerDefinition layer(nullptr, "temp"); clear(); layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_MUD, random); diff --git a/src/core/Thread.cpp b/src/core/Thread.cpp index fca9c37..60e2a8f 100644 --- a/src/core/Thread.cpp +++ b/src/core/Thread.cpp @@ -1,18 +1,25 @@ #include "Thread.h" Thread::Thread(ThreadFunction function) : data(0), result(0), function(function) { + go.lock(); + systhread = new thread([this]{ wait(); }); } Thread::~Thread() { } +void Thread::wait() { + unique_lock lock(go); + run(); +} + void Thread::start(void *data) { this->data = data; - QThread::start(); + go.unlock(); } void *Thread::join() { - QThread::wait(); + systhread->join(); return result; } diff --git a/src/core/Thread.h b/src/core/Thread.h index 3181519..e1e05ec 100644 --- a/src/core/Thread.h +++ b/src/core/Thread.h @@ -1,7 +1,10 @@ #pragma once #include "core_global.h" -#include + +#include +#include +#include namespace paysages { namespace system { @@ -11,7 +14,7 @@ typedef void *(*ThreadFunction)(void *data); /** * System thread */ -class CORESHARED_EXPORT Thread : private QThread { +class CORESHARED_EXPORT Thread { public: /** * Create a new thread. @@ -41,11 +44,11 @@ class CORESHARED_EXPORT Thread : private QThread { * Return true if the thread is currently running. */ inline bool isWorking() const { - return not isFinished(); + return systhread->joinable(); } static inline void timeSleepMs(unsigned long ms) { - QThread::msleep(ms); + this_thread::sleep_for(chrono::milliseconds(ms)); } protected: @@ -58,7 +61,11 @@ class CORESHARED_EXPORT Thread : private QThread { void *result; private: + void wait(); + ThreadFunction function; + thread* systhread; + mutex go; }; } } diff --git a/src/core/Timing.cpp b/src/core/Timing.cpp index 5dcc78b..f301d49 100644 --- a/src/core/Timing.cpp +++ b/src/core/Timing.cpp @@ -1,9 +1,10 @@ #include "Timing.h" -#include +#include +using namespace std::chrono; -static QTime EPOCH = QTime::currentTime(); +const auto EPOCH = steady_clock::now(); unsigned long Timing::getRelativeTimeMs() { - return EPOCH.msecsTo(QTime::currentTime()); + return duration_cast(steady_clock::now() - EPOCH).count(); } diff --git a/src/core/VegetationRasterizer.cpp b/src/core/VegetationRasterizer.cpp index 8ab5033..0d65385 100644 --- a/src/core/VegetationRasterizer.cpp +++ b/src/core/VegetationRasterizer.cpp @@ -36,7 +36,7 @@ void VegetationRasterizer::rasterizeToCanvas(CanvasPortion *canvas) { } Color VegetationRasterizer::shadeFragment(const CanvasFragment &fragment, const CanvasFragment *previous) const { - assert(previous != NULL); + assert(previous != nullptr); if (not fragment.isFrontFacing() or previous->getClient() == RASTERIZER_CLIENT_SKY) { // This is an exit fragment, or the last before sky @@ -44,7 +44,7 @@ Color VegetationRasterizer::shadeFragment(const CanvasFragment &fragment, const } // Even if we assert, this may happen in rare circumstances (no opaque background fragment), so don't crash - if (previous == NULL) { + if (previous == nullptr) { return COLOR_TRANSPARENT; } diff --git a/src/core/WaterRasterizer.cpp b/src/core/WaterRasterizer.cpp index 868cc62..f018e62 100644 --- a/src/core/WaterRasterizer.cpp +++ b/src/core/WaterRasterizer.cpp @@ -33,7 +33,7 @@ void WaterRasterizer::rasterizeQuad(CanvasPortion *canvas, double x, double z, d } int WaterRasterizer::prepareRasterization() { - return performTessellation(NULL); + return performTessellation(nullptr); } void WaterRasterizer::rasterizeToCanvas(CanvasPortion *canvas) { diff --git a/src/core/core.pro b/src/core/core.pro index 4fec09b..13ced07 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -4,6 +4,8 @@ # #------------------------------------------------- +QT -= core gui + TARGET = paysages_core TEMPLATE = lib diff --git a/src/interface/commandline/main.cpp b/src/interface/commandline/main.cpp index 7a94d90..7daf813 100644 --- a/src/interface/commandline/main.cpp +++ b/src/interface/commandline/main.cpp @@ -33,7 +33,7 @@ static void displayHelp() { int main(int argc, char **argv) { SoftwareCanvasRenderer *renderer; - char *conf_file_path = NULL; + char *conf_file_path = nullptr; RenderConfig conf_render_params(480, 270, 1, 3); int conf_first_picture = 0; int conf_nb_pictures = 1; diff --git a/src/interface/commandline/tests.cpp b/src/interface/commandline/tests.cpp index 2948f5a..4479b01 100644 --- a/src/interface/commandline/tests.cpp +++ b/src/interface/commandline/tests.cpp @@ -112,7 +112,7 @@ static void testGroundShadowQuality() { scenery.getAtmosphere()->applyPreset(AtmosphereDefinition::ATMOSPHERE_PRESET_CLEAR_SUNSET, random); scenery.getAtmosphere()->setDayTime(16, 45); scenery.getTextures()->clear(); - TextureLayerDefinition texture(NULL, "test"); + TextureLayerDefinition texture(nullptr, "test"); texture.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK); texture.terrain_zone->clear(); scenery.getTextures()->addLayer(texture); @@ -356,7 +356,7 @@ static void testVegetationModels() { for (int i = 0; i < 10; i++) { // TODO Make random sequence repeatable - VegetationModelDefinition model(NULL); + VegetationModelDefinition model(nullptr); InstanceRenderer renderer(&scenery, model); renderer.setSize(width, height); renderer.setSoloRasterizer(&renderer); @@ -374,7 +374,7 @@ static void testOpenGLVegetationImpostor() { scenery.autoPreset(i); OpenGLVegetationImpostor impostor(128); - VegetationModelDefinition model(NULL); + VegetationModelDefinition model(nullptr); bool interrupted = false; impostor.prepareTexture(model, scenery, &interrupted); @@ -399,7 +399,7 @@ static void testTextures() { // TODO Customize terrain function for (int i = 0; i < 5; i++) { - TextureLayerDefinition layer(NULL, "test"); + TextureLayerDefinition layer(nullptr, "test"); layer.applyPreset(static_cast(i)); layer.terrain_zone->clear(); scenery.getTextures()->clear(); @@ -502,7 +502,7 @@ static void testCloudsLighting() { scenery.getCamera()->setTarget(VECTOR_ZERO); scenery.getCamera()->setLocation(Vector3(0.0, 10.0, 11.0)); - CloudLayerDefinition layer(NULL, "test"); + CloudLayerDefinition layer(nullptr, "test"); scenery.getClouds()->clear(); scenery.getClouds()->addLayer(layer); diff --git a/src/interface/modeler/FloatPropertyBind.cpp b/src/interface/modeler/FloatPropertyBind.cpp index c0c6df7..c198df0 100644 --- a/src/interface/modeler/FloatPropertyBind.cpp +++ b/src/interface/modeler/FloatPropertyBind.cpp @@ -16,7 +16,7 @@ FloatPropertyBind::FloatPropertyBind(MainModelerWindow *window, const string &ob string signal_name("2" + property_name + "Changed()"); connect(item, signal_name.c_str(), this, SLOT(propertyChanged())); } else { - item = NULL; + item = nullptr; Logs::error("UI") << "Can't find object :" << object_name << endl; } } diff --git a/src/interface/modeler/IntPropertyBind.cpp b/src/interface/modeler/IntPropertyBind.cpp index 7386dd7..b72c29d 100644 --- a/src/interface/modeler/IntPropertyBind.cpp +++ b/src/interface/modeler/IntPropertyBind.cpp @@ -14,7 +14,7 @@ IntPropertyBind::IntPropertyBind(MainModelerWindow *window, const string &object string signal_name("2" + property_name + "Changed()"); connect(item, signal_name.c_str(), this, SLOT(propertyChanged())); } else { - item = NULL; + item = nullptr; Logs::error("UI") << "Can't find object :" << object_name << endl; } } diff --git a/src/interface/modeler/OpenGLView.cpp b/src/interface/modeler/OpenGLView.cpp index 3bb8772..9eeeb3b 100644 --- a/src/interface/modeler/OpenGLView.cpp +++ b/src/interface/modeler/OpenGLView.cpp @@ -8,8 +8,8 @@ OpenGLView::OpenGLView(QQuickItem *parent) : QQuickItem(parent) { initialized = false; - window = NULL; - renderer = NULL; + window = nullptr; + renderer = nullptr; delayed = 10; setAcceptedMouseButtons(Qt::AllButtons); diff --git a/src/interface/modeler/RenderPreviewProvider.cpp b/src/interface/modeler/RenderPreviewProvider.cpp index e4ce0c5..5f47062 100644 --- a/src/interface/modeler/RenderPreviewProvider.cpp +++ b/src/interface/modeler/RenderPreviewProvider.cpp @@ -10,7 +10,7 @@ static inline QColor colorToQColor(Color color) { } RenderPreviewProvider::RenderPreviewProvider() : QQuickImageProvider(QQuickImageProvider::Image) { - canvas = NULL; + canvas = nullptr; pixbuf = new QImage(1, 1, QImage::Format_ARGB32); hide(); } @@ -42,7 +42,7 @@ void RenderPreviewProvider::setCanvas(const Canvas *canvas) { void RenderPreviewProvider::releaseCanvas() { if (canvas) { canvas->getPreview()->updateLive(this); - canvas = NULL; + canvas = nullptr; } } diff --git a/src/interface/modeler/RenderPreviewProvider.h b/src/interface/modeler/RenderPreviewProvider.h index 99f8a3a..ac0f6a8 100644 --- a/src/interface/modeler/RenderPreviewProvider.h +++ b/src/interface/modeler/RenderPreviewProvider.h @@ -17,7 +17,7 @@ class RenderPreviewProvider : public QQuickImageProvider, public CanvasLiveClien virtual ~RenderPreviewProvider(); /** - * Set the canvas to watch and display, null to stop watching. + * Set the canvas to watch and display, nullptr to stop watching. * * This function must be called from the graphics thread. */ diff --git a/src/interface/modeler/RenderProcess.cpp b/src/interface/modeler/RenderProcess.cpp index 194b7e6..d52cd8c 100644 --- a/src/interface/modeler/RenderProcess.cpp +++ b/src/interface/modeler/RenderProcess.cpp @@ -29,8 +29,8 @@ RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *d : window(window), destination(destination) { has_render = false; rendering = false; - renderer = NULL; - render_thread = NULL; + renderer = nullptr; + render_thread = nullptr; QObject *button_quick = window->findQmlObject("tool_render_quick"); if (button_quick) { @@ -172,7 +172,7 @@ void RenderProcess::timerEvent(QTimerEvent *) { render_thread->join(); delete render_thread; - render_thread = NULL; + render_thread = nullptr; window->setQmlProperty("render_dialog", "rendering", false); window->getRenderer()->resume(); diff --git a/src/render/opengl/OpenGLShaderProgram.h b/src/render/opengl/OpenGLShaderProgram.h index afe0627..0c27e97 100644 --- a/src/render/opengl/OpenGLShaderProgram.h +++ b/src/render/opengl/OpenGLShaderProgram.h @@ -32,7 +32,7 @@ class OPENGLSHARED_EXPORT OpenGLShaderProgram { * * 'state' is optional and may add ponctual variables to the global state. */ - void draw(OpenGLVertexArray *vertices, OpenGLSharedState *state = NULL, int start = 0, int count = -1); + void draw(OpenGLVertexArray *vertices, OpenGLSharedState *state = nullptr, int start = 0, int count = -1); /** * Check if the program is currently bound to OpenGL context. @@ -65,7 +65,7 @@ class OPENGLSHARED_EXPORT OpenGLShaderProgram { friend class OpenGLVariable; private: - bool bind(OpenGLSharedState *state = NULL); + bool bind(OpenGLSharedState *state = nullptr); void release(); void compile(); diff --git a/src/render/opengl/OpenGLSharedState.cpp b/src/render/opengl/OpenGLSharedState.cpp index cfb3603..abc699b 100644 --- a/src/render/opengl/OpenGLSharedState.cpp +++ b/src/render/opengl/OpenGLSharedState.cpp @@ -23,7 +23,7 @@ void OpenGLSharedState::destroy(OpenGLFunctions *functions) { OpenGLVariable *OpenGLSharedState::get(const string &name) { OpenGLVariable *&var = variables[name]; - if (var == NULL) { + if (var == nullptr) { var = new OpenGLVariable(name); } return var; diff --git a/src/render/opengl/OpenGLTerrain.cpp b/src/render/opengl/OpenGLTerrain.cpp index ad913aa..392f5b8 100644 --- a/src/render/opengl/OpenGLTerrain.cpp +++ b/src/render/opengl/OpenGLTerrain.cpp @@ -153,7 +153,7 @@ void OpenGLTerrain::performChunksMaintenance() { chunk = pv->queue.back(); pv->queue.pop_back(); } else { - chunk = NULL; + chunk = nullptr; } pv->lock.release(); diff --git a/src/render/opengl/OpenGLVegetation.cpp b/src/render/opengl/OpenGLVegetation.cpp index c2b6bbb..41aee7e 100644 --- a/src/render/opengl/OpenGLVegetation.cpp +++ b/src/render/opengl/OpenGLVegetation.cpp @@ -128,7 +128,7 @@ OpenGLVegetationLayer *OpenGLVegetation::findLayer(VegetationLayerDefinition *la return l; } } - return NULL; + return nullptr; } void OpenGLVegetation::setEnabled(bool enabled) { diff --git a/src/render/opengl/OpenGLVegetationLayer.cpp b/src/render/opengl/OpenGLVegetationLayer.cpp index a109807..60c1dd1 100644 --- a/src/render/opengl/OpenGLVegetationLayer.cpp +++ b/src/render/opengl/OpenGLVegetationLayer.cpp @@ -37,8 +37,8 @@ void OpenGLVegetationLayer::produceInstancesInArea(double xmin, double xmax, dou } } -static bool isNull(void *ptr) { - return ptr == NULL; +static bool isnullptr(void *ptr) { + return ptr == nullptr; } static bool compareInstances(OpenGLVegetationInstance *instance1, OpenGLVegetationInstance *instance2) { @@ -53,10 +53,10 @@ void OpenGLVegetationLayer::removeInstancesOutsideArea(double xmin, double xmax, if (own_instances) { delete instance; } - instance = NULL; + instance = nullptr; } } - instances->erase(remove_if(instances->begin(), instances->end(), isNull), instances->end()); + instances->erase(remove_if(instances->begin(), instances->end(), isnullptr), instances->end()); } void OpenGLVegetationLayer::updateInstances() { diff --git a/src/tests/AtmosphereDefinition_Test.cpp b/src/tests/AtmosphereDefinition_Test.cpp index e9f7845..19a2a40 100644 --- a/src/tests/AtmosphereDefinition_Test.cpp +++ b/src/tests/AtmosphereDefinition_Test.cpp @@ -17,7 +17,7 @@ static void check_auto_daytime(AtmosphereDefinition &atmo, int hour, int minute } TEST(AtmosphereDefinition, setDayTime) { - AtmosphereDefinition atmo(NULL); + AtmosphereDefinition atmo(nullptr); atmo.setDayTime(0.0); check_daytime(atmo, 0); diff --git a/src/tests/CelestialBodyDefinition_Test.cpp b/src/tests/CelestialBodyDefinition_Test.cpp index 385c159..9de66d7 100644 --- a/src/tests/CelestialBodyDefinition_Test.cpp +++ b/src/tests/CelestialBodyDefinition_Test.cpp @@ -4,7 +4,7 @@ #include "FloatNode.h" TEST(CelestialBodyDefinition, getAngularRadius) { - CelestialBodyDefinition moon(NULL, "moon"); + CelestialBodyDefinition moon(nullptr, "moon"); moon.propDistance()->setValue(384403.0); moon.propRadius()->setValue(1737.4); diff --git a/src/tests/ColorNode_Test.cpp b/src/tests/ColorNode_Test.cpp index 2db8f3d..12b0862 100644 --- a/src/tests/ColorNode_Test.cpp +++ b/src/tests/ColorNode_Test.cpp @@ -6,21 +6,21 @@ #include "PackStream.h" TEST(ColorNode, toString) { - ColorNode test(NULL, "test", Color(0.1, 0.2, 0.3, 0.4)); + ColorNode test(nullptr, "test", Color(0.1, 0.2, 0.3, 0.4)); EXPECT_EQ("test 0.1,0.2,0.3,0.4", test.toString(0)); EXPECT_EQ(" test 0.1,0.2,0.3,0.4", test.toString(2)); } TEST(ColorNode, saveLoadAndSkip) { - DefinitionNode root1(NULL, "root"); + DefinitionNode root1(nullptr, "root"); ColorNode testa1(&root1, "testa", COLOR_RED); ColorNode testb1(&root1, "testb", COLOR_GREEN); PackStream stream1; root1.save(&stream1); - DefinitionNode root2(NULL, "root"); + DefinitionNode root2(nullptr, "root"); ColorNode testb2(&root2, "testb"); PackStream stream2(&stream1); @@ -30,9 +30,9 @@ TEST(ColorNode, saveLoadAndSkip) { } TEST(ColorNode, copy) { - ColorNode base(NULL, "test", COLOR_BLUE); - ColorNode other(NULL, "test", COLOR_RED); - DefinitionNode badother(NULL, "test"); + ColorNode base(nullptr, "test", COLOR_BLUE); + ColorNode other(nullptr, "test", COLOR_RED); + DefinitionNode badother(nullptr, "test"); base.copy(&other); EXPECT_EQ(COLOR_BLUE, base.getValue()); @@ -46,7 +46,7 @@ TEST(ColorNode, copy) { } TEST(ColorNode, produceDiff) { - ColorNode node(NULL, "test", COLOR_BLUE); + ColorNode node(nullptr, "test", COLOR_BLUE); const ColorDiff *diff = node.produceDiff(COLOR_RED); EXPECT_EQ("color", diff->getTypeName()); @@ -62,9 +62,9 @@ TEST(ColorNode, produceDiff) { } TEST(ColorNode, applyDiff) { - ColorNode node(NULL, "test", COLOR_BLUE); + ColorNode node(nullptr, "test", COLOR_BLUE); ColorDiff diff(&node, COLOR_BLUE, COLOR_RED); - DefinitionNode onode(NULL, "test", "badtype"); + DefinitionNode onode(nullptr, "test", "badtype"); IntDiff odiff(&onode, 1, 2); bool result; diff --git a/src/tests/DefinitionNode_Test.cpp b/src/tests/DefinitionNode_Test.cpp index cb7edfc..b87b4d7 100644 --- a/src/tests/DefinitionNode_Test.cpp +++ b/src/tests/DefinitionNode_Test.cpp @@ -8,7 +8,7 @@ #include "System.h" TEST(DefinitionNode, toString) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DefinitionNode branch(&root, "branch"); DefinitionNode leaf1(&branch, "leaf1"); DefinitionNode leaf2(&branch, "leaf2"); @@ -18,7 +18,7 @@ TEST(DefinitionNode, toString) { } TEST(DefinitionNode, getPath) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DefinitionNode branch(&root, "branch"); DefinitionNode leaf(&branch, "leaf"); @@ -28,16 +28,16 @@ TEST(DefinitionNode, getPath) { } TEST(DefinitionNode, findByPath) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DefinitionNode branch(&root, "branch"); DefinitionNode leaf(&branch, "leaf"); EXPECT_EQ(&root, root.findByPath("/")); EXPECT_EQ(&branch, root.findByPath("/branch")); - EXPECT_EQ(NULL, root.findByPath("/branche")); + EXPECT_EQ(nullptr, root.findByPath("/branche")); EXPECT_EQ(&leaf, root.findByPath("/branch/leaf")); - EXPECT_EQ(NULL, root.findByPath("/branche/leaf")); - EXPECT_EQ(NULL, root.findByPath("/branch/leave")); + EXPECT_EQ(nullptr, root.findByPath("/branche/leaf")); + EXPECT_EQ(nullptr, root.findByPath("/branch/leave")); EXPECT_EQ(&branch, root.findByPath("branch")); EXPECT_EQ(&leaf, root.findByPath("branch/leaf")); @@ -45,7 +45,7 @@ TEST(DefinitionNode, findByPath) { } TEST(DefinitionNode, attachDetach) { - DefinitionNode *root = new DefinitionNode(NULL, "root"); + DefinitionNode *root = new DefinitionNode(nullptr, "root"); DefinitionNode *child1 = new DefinitionNode(root, "child1"); DefinitionNode *child2 = new DefinitionNode(root, "child2"); @@ -68,7 +68,7 @@ TEST(DefinitionNode, saveLoadCopy) { PackStream *stream; int check_in = 42, check_out = 0; - DefinitionNode *before = new DefinitionNode(NULL, "root"); + DefinitionNode *before = new DefinitionNode(nullptr, "root"); DefinitionNode *before1 = new DefinitionNode(before, "before1"); new FloatNode(before1, "before11", 2.1); new FloatNode(before1, "before12", -4.3); @@ -84,7 +84,7 @@ TEST(DefinitionNode, saveLoadCopy) { delete stream; // Same definition tree, but with missing nodes, and added ones - DefinitionNode *after = new DefinitionNode(NULL, "root"); + DefinitionNode *after = new DefinitionNode(nullptr, "root"); DefinitionNode *after1 = new DefinitionNode(after, "before1"); FloatNode *after12 = new FloatNode(after1, "before12"); FloatNode *after13 = new FloatNode(after1, "before13"); @@ -131,7 +131,7 @@ TEST(DefinitionNode, onChildChange) { vector> changes; }; - CapturingNode root(NULL, "root"); + CapturingNode root(nullptr, "root"); CapturingNode branch(&root, "branch"); IntNode leaf(&branch, "leaf"); diff --git a/src/tests/DefinitionWatcher_Test.cpp b/src/tests/DefinitionWatcher_Test.cpp index d47942b..22434b8 100644 --- a/src/tests/DefinitionWatcher_Test.cpp +++ b/src/tests/DefinitionWatcher_Test.cpp @@ -17,7 +17,7 @@ TEST(DefinitionWatcher, destructor) { int &counter; }; - IntNode root(NULL, "test", 5); + IntNode root(nullptr, "test", 5); int counter = 0; auto watcher = new FakeWatcher(&root, counter); diff --git a/src/tests/DiffManager_Test.cpp b/src/tests/DiffManager_Test.cpp index 03f790c..ce8f3ea 100644 --- a/src/tests/DiffManager_Test.cpp +++ b/src/tests/DiffManager_Test.cpp @@ -8,7 +8,7 @@ #include "TestToolDefinition.h" TEST(DiffManager, undoRedo) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DiffManager *diffs = root.getDiffManager(); FloatNode leaf(&root, "value", 2.6); @@ -34,7 +34,7 @@ TEST(DiffManager, undoRedo) { } TEST(DiffManager, undoTooMuch) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DiffManager *diffs = root.getDiffManager(); FloatNode leaf(&root, "value", 1.1); @@ -54,7 +54,7 @@ TEST(DiffManager, undoTooMuch) { } TEST(DiffManager, redoTooMuch) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DiffManager *diffs = root.getDiffManager(); FloatNode leaf(&root, "value", 1.1); @@ -77,7 +77,7 @@ TEST(DiffManager, redoTooMuch) { } TEST(DiffManager, undoBranch) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); DiffManager *diffs = root.getDiffManager(); FloatNode leaf(&root, "value", 1.1); @@ -141,7 +141,7 @@ class TestWatcher : public DefinitionWatcher { } TEST(DiffManager, addWatcher) { - FloatNode node(NULL, "node"); + FloatNode node(nullptr, "node"); TestWatcher watcher(&node, 1.3, -4.0); node.setValue(1.3); @@ -155,7 +155,7 @@ TEST(DiffManager, addWatcher) { } TEST(DiffManager, addWatcherWithInitDiffs) { - FloatNode node(NULL, "node", 1.3); + FloatNode node(nullptr, "node", 1.3); TestWatcher watcher(&node, 1.3, 1.3); watcher.start(true); @@ -163,7 +163,7 @@ TEST(DiffManager, addWatcherWithInitDiffs) { } TEST(DiffManager, publishToWatcher) { - DefinitionNode root(NULL, "root"); + DefinitionNode root(nullptr, "root"); FloatNode node(&root, "node", 1.3); RecordingDefinitionWatcher watcher; diff --git a/src/tests/FloatNode_Test.cpp b/src/tests/FloatNode_Test.cpp index afc5e9c..6f828c7 100644 --- a/src/tests/FloatNode_Test.cpp +++ b/src/tests/FloatNode_Test.cpp @@ -6,21 +6,21 @@ #include "PackStream.h" TEST(FloatNode, toString) { - FloatNode test(NULL, "test", 2.1); + FloatNode test(nullptr, "test", 2.1); EXPECT_EQ("test 2.1", test.toString(0)); EXPECT_EQ(" test 2.1", test.toString(2)); } TEST(FloatNode, saveLoadAndSkip) { - DefinitionNode root1(NULL, "root"); + DefinitionNode root1(nullptr, "root"); FloatNode testa1(&root1, "testa", 1.5); FloatNode testb1(&root1, "testb", 4.3); PackStream stream1; root1.save(&stream1); - DefinitionNode root2(NULL, "root"); + DefinitionNode root2(nullptr, "root"); FloatNode testb2(&root2, "testb"); PackStream stream2(&stream1); @@ -30,9 +30,9 @@ TEST(FloatNode, saveLoadAndSkip) { } TEST(FloatNode, copy) { - FloatNode base(NULL, "test", 2.1); - FloatNode other(NULL, "test", 4.3); - DefinitionNode badother(NULL, "test"); + FloatNode base(nullptr, "test", 2.1); + FloatNode other(nullptr, "test", 4.3); + DefinitionNode badother(nullptr, "test"); base.copy(&other); EXPECT_DOUBLE_EQ(2.1, base.getValue()); @@ -46,7 +46,7 @@ TEST(FloatNode, copy) { } TEST(FloatNode, produceDiff) { - FloatNode node(NULL, "test", 8.3); + FloatNode node(nullptr, "test", 8.3); const FloatDiff *diff = node.produceDiff(-4.1); EXPECT_EQ("float", diff->getTypeName()); @@ -62,9 +62,9 @@ TEST(FloatNode, produceDiff) { } TEST(FloatNode, applyDiff) { - FloatNode node(NULL, "test", 1.2); + FloatNode node(nullptr, "test", 1.2); FloatDiff diff(&node, 1.2, 2.4); - DefinitionNode onode(NULL, "test", "badtype"); + DefinitionNode onode(nullptr, "test", "badtype"); IntDiff odiff(&onode, 1, 2); bool result; diff --git a/src/tests/IntNode_Test.cpp b/src/tests/IntNode_Test.cpp index 87f5f7f..dcd1fdd 100644 --- a/src/tests/IntNode_Test.cpp +++ b/src/tests/IntNode_Test.cpp @@ -6,21 +6,21 @@ #include "PackStream.h" TEST(IntNode, toString) { - IntNode test(NULL, "test", 2); + IntNode test(nullptr, "test", 2); EXPECT_EQ("test 2", test.toString(0)); EXPECT_EQ(" test 2", test.toString(2)); } TEST(IntNode, saveLoadAndSkip) { - DefinitionNode root1(NULL, "root"); + DefinitionNode root1(nullptr, "root"); IntNode testa1(&root1, "testa", 1); IntNode testb1(&root1, "testb", 4); PackStream stream1; root1.save(&stream1); - DefinitionNode root2(NULL, "root"); + DefinitionNode root2(nullptr, "root"); IntNode testb2(&root2, "testb"); PackStream stream2(&stream1); @@ -30,9 +30,9 @@ TEST(IntNode, saveLoadAndSkip) { } TEST(IntNode, copy) { - IntNode base(NULL, "test", 2); - IntNode other(NULL, "test", 4); - DefinitionNode badother(NULL, "test"); + IntNode base(nullptr, "test", 2); + IntNode other(nullptr, "test", 4); + DefinitionNode badother(nullptr, "test"); base.copy(&other); EXPECT_DOUBLE_EQ(2, base.getValue()); @@ -46,7 +46,7 @@ TEST(IntNode, copy) { } TEST(IntNode, produceDiff) { - IntNode node(NULL, "test", 8); + IntNode node(nullptr, "test", 8); const IntDiff *diff = node.produceDiff(-4); EXPECT_EQ("int", diff->getTypeName()); @@ -62,9 +62,9 @@ TEST(IntNode, produceDiff) { } TEST(IntNode, applyDiff) { - IntNode node(NULL, "test", 1); + IntNode node(nullptr, "test", 1); IntDiff diff(&node, 1, 2); - DefinitionNode onode(NULL, "test", "badtype"); + DefinitionNode onode(nullptr, "test", "badtype"); FloatDiff odiff(&onode, 1.0, 2.0); bool result; diff --git a/src/tests/Layers_Test.cpp b/src/tests/Layers_Test.cpp index 625491c..0fa5401 100644 --- a/src/tests/Layers_Test.cpp +++ b/src/tests/Layers_Test.cpp @@ -8,7 +8,7 @@ #include "System.h" static DefinitionNode *_construc1(Layers *, const string &name) { - return new DefinitionNode(NULL, name); + return new DefinitionNode(nullptr, name); } static DefinitionNode *_construc2(Layers *parent, const string &name) { @@ -17,18 +17,18 @@ static DefinitionNode *_construc2(Layers *parent, const string &name) { } TEST(Layers, Constructor) { - Layers layers1(NULL, "test", _construc1); + Layers layers1(nullptr, "test", _construc1); EXPECT_EQ(0, layers1.getLayerCount()); } -TEST(Layers, NullLayer) { - Layers layers1(NULL, "test", _construc1); +TEST(Layers, nullptrLayer) { + Layers layers1(nullptr, "test", _construc1); for (int i = -2; i < 5; i++) { DefinitionNode *layer = layers1.getLayer(0); - EXPECT_NE((DefinitionNode *)NULL, layer); + EXPECT_NE((DefinitionNode *)nullptr, layer); - EXPECT_EQ(NULL, layer->getParent()); + EXPECT_EQ(nullptr, layer->getParent()); EXPECT_EQ(layer, layer->getRoot()); EXPECT_EQ("#NULL#", layer->getName()); @@ -38,12 +38,12 @@ TEST(Layers, NullLayer) { } TEST(Layers, copy) { - Layers layers1(NULL, "test", _construc2); + Layers layers1(nullptr, "test", _construc2); layers1.addLayer("test"); EXPECT_EQ(1, layers1.getLayerCount()); // Copy with the same constructor - Layers layers2(NULL, "test", _construc2); + Layers layers2(nullptr, "test", _construc2); EXPECT_EQ(0, layers2.getLayerCount()); layers1.copy(&layers2); EXPECT_EQ(1, layers2.getLayerCount()); @@ -55,7 +55,7 @@ TEST(Layers, copy) { } TEST(Layers, maxLayerCount) { - Layers layers1(NULL, "test", _construc1); + Layers layers1(nullptr, "test", _construc1); layers1.setMaxLayerCount(2); EXPECT_EQ(0, layers1.getLayerCount()); @@ -83,7 +83,7 @@ TEST(Layers, maxLayerCount) { TEST(Layers, saveLoad) { PackStream *stream; - Layers layers1(NULL, "test", _construc1); + Layers layers1(nullptr, "test", _construc1); layers1.addLayer("first"); layers1.addLayer("second"); ASSERT_EQ(2, layers1.getLayerCount()); @@ -93,7 +93,7 @@ TEST(Layers, saveLoad) { layers1.save(stream); delete stream; - Layers layers2(NULL, "test", _construc1); + Layers layers2(nullptr, "test", _construc1); stream = new PackStream(); stream->bindToFile(TMP_DIRECTORY "test_paysages_pack"); @@ -125,7 +125,7 @@ static DefinitionNode *_construc3(Layers *parent, const string &name) { } TEST(Layers, undoRedo) { - Layers layers(NULL, "layers", _construc3); + Layers layers(nullptr, "layers", _construc3); EXPECT_EQ(0, layers.getLayerCount()); EXPECT_EQ(0u, layers.getDiffManager()->getDiffCount()); @@ -173,7 +173,7 @@ TEST(Layers, undoRedo) { } TEST(Layers, generateInitDiffs) { - Layers layers(NULL, "layers", _construc1); + Layers layers(nullptr, "layers", _construc1); vector diffs; layers.generateInitDiffs(&diffs); @@ -187,7 +187,7 @@ TEST(Layers, generateInitDiffs) { layers.generateInitDiffs(&diffs); EXPECT_EQ(3, (int)diffs.size()); - Layers layers1(NULL, "layers", _construc1); + Layers layers1(nullptr, "layers", _construc1); for (auto diff : diffs) { layers1.applyDiff(diff); } diff --git a/src/tests/OpenGLSkybox_Test.cpp b/src/tests/OpenGLSkybox_Test.cpp index ff60e01..c161456 100644 --- a/src/tests/OpenGLSkybox_Test.cpp +++ b/src/tests/OpenGLSkybox_Test.cpp @@ -9,8 +9,8 @@ TEST(OpenGLSkybox, glvariable_atmosphereHumidity) { Scenery scenery; OpenGLRenderer renderer(&scenery); - OpenGLSkybox glvegetation(&renderer); - glvegetation.initialize(); + OpenGLSkybox glskybox(&renderer); + glskybox.initialize(); EXPECT_GLVARIABLE_FLOAT(0.0, renderer.getSharedState(), "atmosphereHumidity"); scenery.set("/atmosphere/humidity", 0.8); diff --git a/src/tests/OpenGLVegetationLayer_Test.cpp b/src/tests/OpenGLVegetationLayer_Test.cpp index 0c0d67f..ed6a645 100644 --- a/src/tests/OpenGLVegetationLayer_Test.cpp +++ b/src/tests/OpenGLVegetationLayer_Test.cpp @@ -9,7 +9,7 @@ class FakeLayerRenderer : public OpenGLVegetationLayer { public: - FakeLayerRenderer(VegetationLayerDefinition *definition) : OpenGLVegetationLayer(NULL, definition, false) { + FakeLayerRenderer(VegetationLayerDefinition *definition) : OpenGLVegetationLayer(nullptr, definition, false) { } virtual ~FakeLayerRenderer() { for (auto instance : static_instances) { @@ -30,9 +30,9 @@ class FakeLayerRenderer : public OpenGLVegetationLayer { TEST(OpenGLVegetationLayer, updateInstances) { CameraDefinition camera; - VegetationLayerDefinition definition(NULL, "test"); + VegetationLayerDefinition definition(nullptr, "test"); FakeLayerRenderer rendering(&definition); - VegetationModelDefinition model(NULL); + VegetationModelDefinition model(nullptr); EXPECT_EQ(0, rendering.getInstanceCount()); diff --git a/src/tests/PackStream_Test.cpp b/src/tests/PackStream_Test.cpp index f954793..cb82a3e 100644 --- a/src/tests/PackStream_Test.cpp +++ b/src/tests/PackStream_Test.cpp @@ -8,8 +8,7 @@ TEST(PackStream, All) { int i; int data_i; double data_d; - const char *data_s; - char buffer[100]; + string data_s; /* Writing to pack */ stream = new PackStream(); @@ -20,11 +19,11 @@ TEST(PackStream, All) { data_d = to_double(i); stream->write(&data_d); + data_d = to_double(i + 0.142378632); + stream->write(&data_d); data_s = "Testing string 0123 (accentué) !"; - stream->write(data_s, 100); - stream->write(data_s, 4); - stream->write(data_s, 5); + stream->write(data_s); } delete stream; @@ -37,13 +36,11 @@ TEST(PackStream, All) { stream->read(&data_d); ASSERT_DOUBLE_EQ(to_double(i), data_d); + stream->read(&data_d); + ASSERT_DOUBLE_EQ(to_double(i) + 0.142378632, data_d); - stream->read(buffer, 100); - ASSERT_STREQ("Testing string 0123 (accentué) !", buffer); - stream->read(buffer, 4); - ASSERT_STREQ("Tes", buffer); - stream->read(buffer, 3); - ASSERT_STREQ("Te", buffer); + data_s = stream->readString(); + ASSERT_STREQ("Testing string 0123 (accentué) !", data_s.c_str()); } delete stream; } diff --git a/src/tests/Rasterizer_Test.cpp b/src/tests/Rasterizer_Test.cpp index 2e3f361..be1ec21 100644 --- a/src/tests/Rasterizer_Test.cpp +++ b/src/tests/Rasterizer_Test.cpp @@ -10,7 +10,7 @@ class FakeRasterizer : public Rasterizer { public: - FakeRasterizer(SoftwareRenderer *renderer) : Rasterizer(renderer, NULL, 0, COLOR_WHITE) { + FakeRasterizer(SoftwareRenderer *renderer) : Rasterizer(renderer, nullptr, 0, COLOR_WHITE) { } virtual Color shadeFragment(const CanvasFragment &, const CanvasFragment *) const override { return COLOR_RED; diff --git a/src/tests/TerrainPainting_Test.cpp b/src/tests/TerrainPainting_Test.cpp index 52c978c..6f8854b 100644 --- a/src/tests/TerrainPainting_Test.cpp +++ b/src/tests/TerrainPainting_Test.cpp @@ -44,7 +44,7 @@ class TerrainPainting_Test : public BaseTestCase { protected: virtual void SetUp() { - terrain = new TerrainDefinition(NULL); + terrain = new TerrainDefinition(nullptr); terrain->propHeightNoise()->forceSetGenerator(new SinFractalNoise); terrain->propWaterHeight()->setValue(0.0); } diff --git a/src/tests/TexturesRenderer_Test.cpp b/src/tests/TexturesRenderer_Test.cpp index 1f6389c..05daf33 100644 --- a/src/tests/TexturesRenderer_Test.cpp +++ b/src/tests/TexturesRenderer_Test.cpp @@ -8,20 +8,20 @@ TEST(TexturesRenderer, getLayersPresence) { TexturesRenderer renderer; - TexturesDefinition textures(NULL); + TexturesDefinition textures(nullptr); vector result; result = renderer.getLayersPresence(&textures, VECTOR_ZERO, VECTOR_UP); ASSERT_EQ(0u, result.size()); - TextureLayerDefinition layer1(NULL, "t1"); + TextureLayerDefinition layer1(nullptr, "t1"); textures.addLayer(layer1); result = renderer.getLayersPresence(&textures, VECTOR_ZERO, VECTOR_UP); ASSERT_EQ(1u, result.size()); EXPECT_DOUBLE_EQ(1.0, result[0]); - TextureLayerDefinition layer2(NULL, "t2"); + TextureLayerDefinition layer2(nullptr, "t2"); layer2.terrain_zone->addHeightRangeQuick(0.8, 0.0, 1.0, 2.0, 3.0); textures.addLayer(layer2); diff --git a/src/tests/VegetationRasterizer_Test.cpp b/src/tests/VegetationRasterizer_Test.cpp index 86d75c5..67e20b5 100644 --- a/src/tests/VegetationRasterizer_Test.cpp +++ b/src/tests/VegetationRasterizer_Test.cpp @@ -13,7 +13,7 @@ TEST(VegetationRasterizer, isUseful) { EXPECT_FALSE(rast.isUseful()); - VegetationLayerDefinition layer(NULL, "test"); + VegetationLayerDefinition layer(nullptr, "test"); layer.applyPreset(VegetationLayerDefinition::VEGETATION_BASIC_TREES); scenery.getVegetation()->addLayer(layer);