Validate fillVertexBuffers arguments

macos_ci_fix
elsid 1 year ago
parent fbd3d1f61d
commit 28436557b1
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -1,6 +1,7 @@
#include "storage.hpp"
#include <algorithm>
#include <stdexcept>
#include <osg/Image>
#include <osg/Plane>
@ -186,6 +187,12 @@ namespace ESMTerrain
void Storage::fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours)
{
if (lodLevel < 0 || 63 < lodLevel)
throw std::invalid_argument("Invalid terrain lod level: " + std::to_string(lodLevel));
if (size <= 0)
throw std::invalid_argument("Invalid terrain size: " + std::to_string(size));
// LOD level n means every 2^n-th vertex is kept
const std::size_t sampleSize = std::size_t{ 1 } << lodLevel;

Loading…
Cancel
Save