diff --git a/components/esm3terrain/storage.cpp b/components/esm3terrain/storage.cpp index 71051df847..dc68fccf92 100644 --- a/components/esm3terrain/storage.cpp +++ b/components/esm3terrain/storage.cpp @@ -184,8 +184,7 @@ namespace ESMTerrain } void Storage::fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace, - osg::ref_ptr positions, osg::ref_ptr normals, - osg::ref_ptr 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(1) << lodLevel; @@ -199,9 +198,9 @@ namespace ESMTerrain size_t numVerts = static_cast(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(vertX * numVerts + vertY)] + positions[static_cast(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(vertX * numVerts + vertY)] = normal; + normals[static_cast(vertX * numVerts + vertY)] = normal; if (colourData) { @@ -315,7 +314,7 @@ namespace ESMTerrain color.a() = 255; - (*colours)[static_cast(vertX * numVerts + vertY)] = color; + colours[static_cast(vertX * numVerts + vertY)] = color; ++vertX; } @@ -333,7 +332,7 @@ namespace ESMTerrain { for (unsigned int iVert = 0; iVert < numVerts * numVerts; iVert++) { - (*positions)[static_cast(iVert)] = osg::Vec3f(0.f, 0.f, 0.f); + positions[static_cast(iVert)] = osg::Vec3f(0.f, 0.f, 0.f); } } } diff --git a/components/esm3terrain/storage.hpp b/components/esm3terrain/storage.hpp index 5efa996c6f..17b94a7ee5 100644 --- a/components/esm3terrain/storage.hpp +++ b/components/esm3terrain/storage.hpp @@ -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 positions, osg::ref_ptr normals, - osg::ref_ptr 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 diff --git a/components/terrain/chunkmanager.cpp b/components/terrain/chunkmanager.cpp index 03643390bf..0364a0a4fd 100644 --- a/components/terrain/chunkmanager.cpp +++ b/components/terrain/chunkmanager.cpp @@ -213,7 +213,7 @@ namespace Terrain osg::ref_ptr 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 vbo(new osg::VertexBufferObject); positions->setVertexBufferObject(vbo); diff --git a/components/terrain/storage.hpp b/components/terrain/storage.hpp index c4a44f5024..7a99478929 100644 --- a/components/terrain/storage.hpp +++ b/components/terrain/storage.hpp @@ -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 positions, osg::ref_ptr normals, - osg::ref_ptr colours) + osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours) = 0; typedef std::vector> ImageVector;