Pass references to fillVertexBuffers instead of osg::ref_ptr

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

@ -184,8 +184,7 @@ namespace ESMTerrain
}
void Storage::fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
osg::ref_ptr<osg::Vec3Array> positions, osg::ref_ptr<osg::Vec3Array> normals,
osg::ref_ptr<osg::Vec4ubArray> colours)
osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours)
{
// LOD level n means every 2^n-th vertex is kept
size_t increment = static_cast<size_t>(1) << lodLevel;
@ -199,9 +198,9 @@ namespace ESMTerrain
size_t numVerts = static_cast<size_t>(size * (landSize - 1) / increment + 1);
positions->resize(numVerts * numVerts);
normals->resize(numVerts * numVerts);
colours->resize(numVerts * numVerts);
positions.resize(numVerts * numVerts);
normals.resize(numVerts * numVerts);
colours.resize(numVerts * numVerts);
osg::Vec3f normal;
osg::Vec4ub color;
@ -269,7 +268,7 @@ namespace ESMTerrain
height = heightData->getHeights()[col * landSize + row];
if (alteration)
height += getAlteredHeight(col, row);
(*positions)[static_cast<unsigned int>(vertX * numVerts + vertY)]
positions[static_cast<unsigned int>(vertX * numVerts + vertY)]
= osg::Vec3f((vertX / float(numVerts - 1) - 0.5f) * size * LandSizeInUnits,
(vertY / float(numVerts - 1) - 0.5f) * size * LandSizeInUnits, height);
@ -293,7 +292,7 @@ namespace ESMTerrain
assert(normal.z() > 0);
(*normals)[static_cast<unsigned int>(vertX * numVerts + vertY)] = normal;
normals[static_cast<unsigned int>(vertX * numVerts + vertY)] = normal;
if (colourData)
{
@ -315,7 +314,7 @@ namespace ESMTerrain
color.a() = 255;
(*colours)[static_cast<unsigned int>(vertX * numVerts + vertY)] = color;
colours[static_cast<unsigned int>(vertX * numVerts + vertY)] = color;
++vertX;
}
@ -333,7 +332,7 @@ namespace ESMTerrain
{
for (unsigned int iVert = 0; iVert < numVerts * numVerts; iVert++)
{
(*positions)[static_cast<unsigned int>(iVert)] = osg::Vec3f(0.f, 0.f, 0.f);
positions[static_cast<unsigned int>(iVert)] = osg::Vec3f(0.f, 0.f, 0.f);
}
}
}

@ -99,8 +99,7 @@ namespace ESMTerrain
/// @param normals buffer to write vertex normals
/// @param colours buffer to write vertex colours
void fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
osg::ref_ptr<osg::Vec3Array> positions, osg::ref_ptr<osg::Vec3Array> normals,
osg::ref_ptr<osg::Vec4ubArray> colours) override;
osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours) override;
/// Create textures holding layer blend values for a terrain chunk.
/// @note The terrain chunk shouldn't be larger than one cell since otherwise we might

@ -213,7 +213,7 @@ namespace Terrain
osg::ref_ptr<osg::Vec4ubArray> colors(new osg::Vec4ubArray);
colors->setNormalize(true);
mStorage->fillVertexBuffers(lod, chunkSize, chunkCenter, mWorldspace, positions, normals, colors);
mStorage->fillVertexBuffers(lod, chunkSize, chunkCenter, mWorldspace, *positions, *normals, *colors);
osg::ref_ptr<osg::VertexBufferObject> vbo(new osg::VertexBufferObject);
positions->setVertexBufferObject(vbo);

@ -64,8 +64,7 @@ namespace Terrain
/// @param normals buffer to write vertex normals
/// @param colours buffer to write vertex colours
virtual void fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
osg::ref_ptr<osg::Vec3Array> positions, osg::ref_ptr<osg::Vec3Array> normals,
osg::ref_ptr<osg::Vec4ubArray> colours)
osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours)
= 0;
typedef std::vector<osg::ref_ptr<osg::Image>> ImageVector;

Loading…
Cancel
Save