diff --git a/src/osgPlugins/dae/daeRGeometry.cpp b/src/osgPlugins/dae/daeRGeometry.cpp index f4d4f7cb6..afde51959 100644 --- a/src/osgPlugins/dae/daeRGeometry.cpp +++ b/src/osgPlugins/dae/daeRGeometry.cpp @@ -462,7 +462,7 @@ void daeReader::processSinglePPrimitive(osg::Geode* geode, osg::ref_ptr geometry = new osg::Geometry(); if (NULL != group->getMaterial()) geometry->setName(group->getMaterial()); - + osg::ref_ptr pDrawElements = new osg::DrawElementsUInt(mode); geometry->addPrimitiveSet(pDrawElements.get()); @@ -773,7 +773,7 @@ struct VertexIndices return false; } - /// Templated getter for memebers, used for createGeometryData() + /// Templated getter for memebers, used for createGeometryArray() enum ValueType { POSITION, COLOR, NORMAL, TEXCOORD }; template inline int get() const; @@ -796,12 +796,12 @@ inline int VertexIndices::get() const { typedef std::map VertexIndicesIndexMap; -/// Creates a value array, packed in a osg::Geometry::ArrayData, corresponding to indexed values. +/// Creates a value array, packed in a osg::Array, corresponding to indexed values. template -osg::Geometry::ArrayData createGeometryData(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, int texcoordNum=-1) { +ArrayType createGeometryArray(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, int texcoordNum=-1) { const ArrayType * source = sourceReader.getArray(); - if (!source) return osg::Geometry::ArrayData(); - ArrayType * pArray = new ArrayType; + if (!source) return 0; + ArrayType * pArray = new ArrayType(osg::Geometry::BIND_PER_VERTEX); for (VertexIndicesIndexMap::const_iterator it = vertexIndicesIndexMap.begin(), end = vertexIndicesIndexMap.end(); it != end; ++it) { int index = texcoordNum>=0 ? it->first.texcoord_indices[texcoordNum] : it->first.get(); if (index>=0 && static_cast(index)size()) pArray->push_back(source->at(index)); @@ -809,17 +809,17 @@ osg::Geometry::ArrayData createGeometryData(domSourceReader & sourceReader, cons // Invalid data (index out of bounds) //LOG_WARN << ... //pArray->push_back(0); - return osg::Geometry::ArrayData(); + return 0; } } - return osg::Geometry::ArrayData(pArray, osg::Geometry::BIND_PER_VERTEX); + return pArray; } template -inline osg::Geometry::ArrayData createGeometryData(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, bool useDoublePrecision, int texcoordNum=-1) { - if (useDoublePrecision) return createGeometryData(sourceReader, vertexIndicesIndexMap, texcoordNum); - else return createGeometryData(sourceReader, vertexIndicesIndexMap, texcoordNum); +inline osg::Array* createGeometryArray(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, bool useDoublePrecision, int texcoordNum=-1) { + if (useDoublePrecision) return createGeometryArray(sourceReader, vertexIndicesIndexMap, texcoordNum); + else return createGeometryArray(sourceReader, vertexIndicesIndexMap, texcoordNum); } @@ -919,28 +919,28 @@ void daeReader::resolveMeshArrays(const domP_Array& domPArray, // Vertices { - osg::Geometry::ArrayData arrayData( createGeometryData(sources[position_source], vertexIndicesIndexMap, readDoubleVertices) ); - if (arrayData.array.valid()) + osg::ref_ptr array( createGeometryArray(sources[position_source], vertexIndicesIndexMap, readDoubleVertices) ); + if (array.valid()) { - geometry->setVertexData(arrayData); + geometry->setVertexArray(array.get()); } } if (color_source) { - osg::Geometry::ArrayData arrayData( createGeometryData(sources[color_source], vertexIndicesIndexMap, readDoubleColors) ); - if (arrayData.array.valid()) + osg::ref_ptr array( createGeometryArray(sources[color_source], vertexIndicesIndexMap, readDoubleColors) ); + if (array.valid()) { - geometry->setColorData(arrayData); + geometry->setColorArray(array.get()); } } if (normal_source) { - osg::Geometry::ArrayData arrayData( createGeometryData(sources[normal_source], vertexIndicesIndexMap, readDoubleNormals) ); - if (arrayData.array.valid()) + osg::ref_ptr array( createGeometryArray(sources[normal_source], vertexIndicesIndexMap, readDoubleNormals) ); + if (array.valid()) { - geometry->setNormalData(arrayData); + geometry->setNormalArray(array.get()); } } @@ -952,18 +952,18 @@ void daeReader::resolveMeshArrays(const domP_Array& domPArray, //We keep somewhere the mapping between daeElement id and created arrays _texCoordIdMap.insert(std::pair(id,texcoord_set)); // 2D Texcoords - osg::Geometry::ArrayData arrayData( createGeometryData(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) ); - if (arrayData.array.valid()) + osg::ref_ptr array( createGeometryArray(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) ); + if (array.valid()) { - geometry->setTexCoordData(texcoord_set, arrayData); + geometry->setTexCoordArray(texcoord_set, array.get()); } else { // 3D Textcoords - osg::Geometry::ArrayData arrayData( createGeometryData(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) ); - if (arrayData.array.valid()) + osg::ref_ptr array( createGeometryArray(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) ); + if (array.valid()) { - geometry->setTexCoordData(texcoord_set, arrayData); + geometry->setTexCoordArray(texcoord_set, array.get()); } } }