Changeset 13041 for OpenSceneGraph/trunk/src/osg/Geometry.cpp
 Timestamp:
 03/21/12 18:36:20 (5 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

OpenSceneGraph/trunk/src/osg/Geometry.cpp
r12434 r13041 1 /* *c++* OpenSceneGraph  Copyright (C) 19982006 Robert Osfield 1 /* *c++* OpenSceneGraph  Copyright (C) 19982006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 93 93 } 94 94 } 95 95 96 96 } 97 97 … … 100 100 // do dirty here to keep the getGLObjectSizeHint() estimate on the ball 101 101 dirtyDisplayList(); 102 102 103 103 // no need to delete, all automatically handled by ref_ptr :) 104 104 } … … 119 119 void Geometry::setVertexArray(Array* array) 120 120 { 121 _vertexData.array = array; 122 computeFastPathsUsed(); 123 dirtyDisplayList(); 121 _vertexData.array = array; 122 computeFastPathsUsed(); 123 dirtyDisplayList(); 124 124 dirtyBound(); 125 125 … … 129 129 void Geometry::setVertexIndices(IndexArray* array) 130 130 { 131 _vertexData.indices = array; 132 computeFastPathsUsed(); 133 dirtyDisplayList(); 131 _vertexData.indices = array; 132 computeFastPathsUsed(); 133 dirtyDisplayList(); 134 134 dirtyBound(); 135 135 } … … 137 137 void Geometry::setVertexData(const ArrayData& arrayData) 138 138 { 139 _vertexData = arrayData; 140 computeFastPathsUsed(); 141 dirtyDisplayList(); 139 _vertexData = arrayData; 140 computeFastPathsUsed(); 141 dirtyDisplayList(); 142 142 dirtyBound(); 143 143 … … 147 147 void Geometry::setNormalArray(Array* array) 148 148 { 149 _normalData.array = array; 150 if (!_normalData.array.valid()) _normalData.binding=BIND_OFF; 151 computeFastPathsUsed(); 149 _normalData.array = array; 150 if (!_normalData.array.valid()) _normalData.binding=BIND_OFF; 151 computeFastPathsUsed(); 152 152 dirtyDisplayList(); 153 153 … … 157 157 void Geometry::setNormalIndices(IndexArray* array) 158 158 { 159 _normalData.indices = array; 160 computeFastPathsUsed(); 161 dirtyDisplayList(); 159 _normalData.indices = array; 160 computeFastPathsUsed(); 161 dirtyDisplayList(); 162 162 } 163 163 164 164 void Geometry::setNormalData(const ArrayData& arrayData) 165 165 { 166 _normalData = arrayData; 167 computeFastPathsUsed(); 166 _normalData = arrayData; 167 computeFastPathsUsed(); 168 168 dirtyDisplayList(); 169 169 … … 174 174 { 175 175 _colorData.array = array; 176 if (!_colorData.array.valid()) _colorData.binding=BIND_OFF; 177 computeFastPathsUsed(); 176 if (!_colorData.array.valid()) _colorData.binding=BIND_OFF; 177 computeFastPathsUsed(); 178 178 dirtyDisplayList(); 179 179 … … 183 183 void Geometry::setColorIndices(IndexArray* array) 184 184 { 185 _colorData.indices = array; 186 computeFastPathsUsed(); 187 dirtyDisplayList(); 185 _colorData.indices = array; 186 computeFastPathsUsed(); 187 dirtyDisplayList(); 188 188 } 189 189 190 190 void Geometry::setColorData(const ArrayData& arrayData) 191 191 { 192 _colorData = arrayData; 193 computeFastPathsUsed(); 192 _colorData = arrayData; 193 computeFastPathsUsed(); 194 194 dirtyDisplayList(); 195 195 … … 200 200 void Geometry::setSecondaryColorArray(Array* array) 201 201 { 202 _secondaryColorData.array = array; 203 if (!_secondaryColorData.array.valid()) _secondaryColorData.binding=BIND_OFF; 204 computeFastPathsUsed(); 202 _secondaryColorData.array = array; 203 if (!_secondaryColorData.array.valid()) _secondaryColorData.binding=BIND_OFF; 204 computeFastPathsUsed(); 205 205 dirtyDisplayList(); 206 206 … … 210 210 void Geometry::setSecondaryColorIndices(IndexArray* array) 211 211 { 212 _secondaryColorData.indices = array; 213 computeFastPathsUsed(); 212 _secondaryColorData.indices = array; 213 computeFastPathsUsed(); 214 214 dirtyDisplayList(); 215 215 } … … 217 217 void Geometry::setSecondaryColorData(const ArrayData& arrayData) 218 218 { 219 _secondaryColorData = arrayData; 220 computeFastPathsUsed(); 219 _secondaryColorData = arrayData; 220 computeFastPathsUsed(); 221 221 dirtyDisplayList(); 222 222 … … 226 226 void Geometry::setFogCoordArray(Array* array) 227 227 { 228 _fogCoordData.array = array; 229 if (!_fogCoordData.array.valid()) _fogCoordData.binding=BIND_OFF; 230 computeFastPathsUsed(); 231 dirtyDisplayList(); 228 _fogCoordData.array = array; 229 if (!_fogCoordData.array.valid()) _fogCoordData.binding=BIND_OFF; 230 computeFastPathsUsed(); 231 dirtyDisplayList(); 232 232 233 233 if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); … … 236 236 void Geometry::setFogCoordIndices(IndexArray* array) 237 237 { 238 _fogCoordData.indices = array; 239 computeFastPathsUsed(); 238 _fogCoordData.indices = array; 239 computeFastPathsUsed(); 240 240 dirtyDisplayList(); 241 241 } … … 243 243 void Geometry::setFogCoordData(const ArrayData& arrayData) 244 244 { 245 _fogCoordData = arrayData; 246 computeFastPathsUsed(); 245 _fogCoordData = arrayData; 246 computeFastPathsUsed(); 247 247 dirtyDisplayList(); 248 248 … … 250 250 } 251 251 252 void Geometry::setNormalBinding(AttributeBinding ab) 252 void Geometry::setNormalBinding(AttributeBinding ab) 253 253 { 254 254 if (_normalData.binding == ab) return; 255 255 256 256 _normalData.binding = ab; 257 257 computeFastPathsUsed(); 258 dirtyDisplayList(); 258 dirtyDisplayList(); 259 259 } 260 260 … … 265 265 _colorData.binding = ab; 266 266 computeFastPathsUsed(); 267 dirtyDisplayList(); 267 dirtyDisplayList(); 268 268 } 269 269 … … 274 274 _secondaryColorData.binding = ab; 275 275 computeFastPathsUsed(); 276 dirtyDisplayList(); 276 dirtyDisplayList(); 277 277 } 278 278 … … 283 283 _fogCoordData.binding = ab; 284 284 computeFastPathsUsed(); 285 dirtyDisplayList(); 285 dirtyDisplayList(); 286 286 } 287 287 … … 290 290 if (_texCoordList.size()<=unit) 291 291 _texCoordList.resize(unit+1); 292 292 293 293 _texCoordList[unit] = arrayData; 294 294 … … 300 300 if (_texCoordList.size()<=unit) 301 301 _texCoordList.resize(unit+1); 302 302 303 303 return _texCoordList[unit]; 304 304 } … … 308 308 if (_texCoordList.size()<=unit) 309 309 return s_InvalidArrayData; 310 310 311 311 return _texCoordList[unit]; 312 312 } … … 363 363 if (_vertexAttribList.size()<=index) 364 364 _vertexAttribList.resize(index+1); 365 365 366 366 _vertexAttribList[index] = attrData; 367 367 368 368 computeFastPathsUsed(); 369 369 dirtyDisplayList(); … … 376 376 if (_vertexAttribList.size()<=index) 377 377 _vertexAttribList.resize(index+1); 378 378 379 379 return _vertexAttribList[index]; 380 380 } … … 384 384 if (_vertexAttribList.size()<=_vertexAttribList.size()) 385 385 return s_InvalidArrayData; 386 386 387 387 return _vertexAttribList[index]; 388 388 } … … 506 506 return addPrimitiveSet(primitiveset); 507 507 } 508 508 509 509 } 510 510 OSG_WARN<<"Warning: invalid index i or primitiveset passed to osg::Geometry::insertPrimitiveSet(i,primitiveset), ignoring call."<<std::endl; … … 544 544 _primitives.erase(_primitives.begin()+i,_primitives.end()); 545 545 } 546 546 547 547 dirtyDisplayList(); 548 548 dirtyBound(); … … 574 574 else if (_secondaryColorData.binding==BIND_PER_PRIMITIVE  (_secondaryColorData.binding==BIND_PER_VERTEX && _secondaryColorData.indices.valid())) _fastPath = false; 575 575 else if (_fogCoordData.binding==BIND_PER_PRIMITIVE  (_fogCoordData.binding==BIND_PER_VERTEX && _fogCoordData.indices.valid())) _fastPath = false; 576 else 576 else 577 577 { 578 578 for( unsigned int va = 0; va < _vertexAttribList.size(); ++va ) … … 588 588 const IndexArray * idxArray = _vertexAttribList[va].indices.get(); 589 589 590 if( _vertexAttribList[va].binding==BIND_PER_VERTEX && 590 if( _vertexAttribList[va].binding==BIND_PER_VERTEX && 591 591 array && array>getNumElements()>0 && 592 idxArray && idxArray>getNumElements()>0 ) 592 idxArray && idxArray>getNumElements()>0 ) 593 593 { 594 594 _fastPath = false; … … 612 612 if (texcoordData.indices>getNumElements()>0) 613 613 { 614 _fastPath = false; 614 _fastPath = false; 615 615 break; 616 616 } … … 618 618 } 619 619 } 620 620 621 621 _supportsVertexBufferObjects = _fastPath; 622 622 623 623 //_supportsVertexBufferObjects = false; 624 624 //_useVertexBufferObjects = false; … … 656 656 { 657 657 const Array* array = _vertexAttribList[index].array.get(); 658 if (array) totalSize += array>getTotalDataSize(); 658 if (array) totalSize += array>getTotalDataSize(); 659 659 } 660 660 } … … 677 677 { 678 678 unsigned int startSize = arrayList.size(); 679 679 680 680 if (_vertexData.array.valid()) arrayList.push_back(_vertexData.array.get()); 681 681 if (_normalData.array.valid()) arrayList.push_back(_normalData.array.get()); … … 683 683 if (_secondaryColorData.array.valid()) arrayList.push_back(_secondaryColorData.array.get()); 684 684 if (_fogCoordData.array.valid()) arrayList.push_back(_fogCoordData.array.get()); 685 685 686 686 for(unsigned int unit=0;unit<_texCoordList.size();++unit) 687 687 { … … 702 702 { 703 703 unsigned int startSize = drawElementsList.size(); 704 704 705 705 for(PrimitiveSetList::const_iterator itr = _primitives.begin(); 706 706 itr != _primitives.end(); … … 710 710 if (de) drawElementsList.push_back(de); 711 711 } 712 712 713 713 return drawElementsList.size()!=startSize; 714 714 } … … 774 774 { 775 775 // flag = true; 776 776 777 777 // OSG_NOTICE<<"Geometry::setUseVertexBufferObjects("<<flag<<")"<<std::endl; 778 778 … … 780 780 781 781 Drawable::setUseVertexBufferObjects(flag); 782 782 783 783 ArrayList arrayList; 784 784 getArrayList(arrayList); … … 792 792 if (_useVertexBufferObjects) 793 793 { 794 if (!arrayList.empty()) 794 if (!arrayList.empty()) 795 795 { 796 796 797 797 VertexBufferObjectList vboList; 798 798 799 799 osg::ref_ptr<osg::VertexBufferObject> vbo; 800 800 … … 819 819 } 820 820 821 if (!drawElementsList.empty()) 821 if (!drawElementsList.empty()) 822 822 { 823 823 ElementBufferObjectList eboList; 824 824 825 825 osg::ref_ptr<osg::ElementBufferObject> ebo; 826 826 … … 1007 1007 } 1008 1008 #endif 1009 1009 1010 1010 if (_internalOptimizedGeometry.valid()) 1011 1011 { … … 1018 1018 bool checkForGLErrors = state.getCheckForGLErrors()==osg::State::ONCE_PER_ATTRIBUTE; 1019 1019 if (checkForGLErrors) state.checkGLErrors("start of Geometry::drawImplementation()"); 1020 1020 1021 1021 bool useFastPath = areFastPathsUsed(); 1022 1022 // useFastPath = false; … … 1285 1285 { 1286 1286 public: 1287 1287 1288 1288 AttributeFunctorArrayVisitor(Drawable::AttributeFunctor& af): 1289 1289 _af(af), 1290 1290 _type(0) {} 1291 1291 1292 1292 virtual ~AttributeFunctorArrayVisitor() {} 1293 1293 … … 1307 1307 virtual void apply(Vec3dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } 1308 1308 virtual void apply(Vec4dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } 1309 1310 1309 1310 1311 1311 inline void applyArray(Drawable::AttributeType type,Array* array) 1312 1312 { … … 1318 1318 } 1319 1319 1320 protected: 1321 1320 protected: 1321 1322 1322 AttributeFunctorArrayVisitor& operator = (const AttributeFunctorArrayVisitor&) { return *this; } 1323 1323 Drawable::AttributeFunctor& _af; … … 1343 1343 afav.applyArray(SECONDARY_COLORS,_secondaryColorData.array.get()); 1344 1344 afav.applyArray(FOG_COORDS,_fogCoordData.array.get()); 1345 1345 1346 1346 for(unsigned unit=0;unit<_texCoordList.size();++unit) 1347 1347 { … … 1358 1358 { 1359 1359 public: 1360 1360 1361 1361 ConstAttributeFunctorArrayVisitor(Drawable::ConstAttributeFunctor& af): 1362 1362 _af(af), 1363 1363 _type(0) {} 1364 1364 1365 1365 virtual ~ConstAttributeFunctorArrayVisitor() {} 1366 1366 … … 1380 1380 virtual void apply(const Vec3dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } 1381 1381 virtual void apply(const Vec4dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } 1382 1383 1382 1383 1384 1384 inline void applyArray(Drawable::AttributeType type,const Array* array) 1385 1385 { … … 1390 1390 } 1391 1391 } 1392 1392 1393 1393 protected: 1394 1394 … … 1402 1402 { 1403 1403 ConstAttributeFunctorArrayVisitor afav(af); 1404 1404 1405 1405 if (_vertexData.array.valid()) 1406 1406 { … … 1447 1447 switch(vertices>getType()) 1448 1448 { 1449 case(Array::Vec2ArrayType): 1449 case(Array::Vec2ArrayType): 1450 1450 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec2*>(vertices>getDataPointer())); 1451 1451 break; 1452 case(Array::Vec3ArrayType): 1452 case(Array::Vec3ArrayType): 1453 1453 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec3*>(vertices>getDataPointer())); 1454 1454 break; 1455 case(Array::Vec4ArrayType): 1455 case(Array::Vec4ArrayType): 1456 1456 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec4*>(vertices>getDataPointer())); 1457 1457 break; 1458 case(Array::Vec2dArrayType): 1458 case(Array::Vec2dArrayType): 1459 1459 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec2d*>(vertices>getDataPointer())); 1460 1460 break; 1461 case(Array::Vec3dArrayType): 1461 case(Array::Vec3dArrayType): 1462 1462 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec3d*>(vertices>getDataPointer())); 1463 1463 break; 1464 case(Array::Vec4dArrayType): 1464 case(Array::Vec4dArrayType): 1465 1465 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec4d*>(vertices>getDataPointer())); 1466 1466 break; … … 1469 1469 return; 1470 1470 } 1471 1471 1472 1472 for(PrimitiveSetList::const_iterator itr=_primitives.begin(); 1473 1473 itr!=_primitives.end(); … … 1488 1488 switch(type) 1489 1489 { 1490 case(Array::Vec2ArrayType): 1490 case(Array::Vec2ArrayType): 1491 1491 vec2Array = static_cast<const Vec2*>(vertices>getDataPointer()); 1492 1492 break; 1493 case(Array::Vec3ArrayType): 1493 case(Array::Vec3ArrayType): 1494 1494 vec3Array = static_cast<const Vec3*>(vertices>getDataPointer()); 1495 1495 break; 1496 case(Array::Vec4ArrayType): 1496 case(Array::Vec4ArrayType): 1497 1497 vec4Array = static_cast<const Vec4*>(vertices>getDataPointer()); 1498 1498 break; 1499 case(Array::Vec2dArrayType): 1499 case(Array::Vec2dArrayType): 1500 1500 vec2dArray = static_cast<const Vec2d*>(vertices>getDataPointer()); 1501 1501 break; 1502 case(Array::Vec3dArrayType): 1502 case(Array::Vec3dArrayType): 1503 1503 vec3dArray = static_cast<const Vec3d*>(vertices>getDataPointer()); 1504 1504 break; 1505 case(Array::Vec4dArrayType): 1505 case(Array::Vec4dArrayType): 1506 1506 vec4dArray = static_cast<const Vec4d*>(vertices>getDataPointer()); 1507 1507 break; … … 1531 1531 switch(type) 1532 1532 { 1533 case(Array::Vec2ArrayType): 1533 case(Array::Vec2ArrayType): 1534 1534 functor.vertex(vec2Array[_vertexData.indices>index(vindex)]); 1535 1535 break; 1536 case(Array::Vec3ArrayType): 1536 case(Array::Vec3ArrayType): 1537 1537 functor.vertex(vec3Array[_vertexData.indices>index(vindex)]); 1538 1538 break; 1539 case(Array::Vec4ArrayType): 1539 case(Array::Vec4ArrayType): 1540 1540 functor.vertex(vec4Array[_vertexData.indices>index(vindex)]); 1541 1541 break; 1542 case(Array::Vec2dArrayType): 1542 case(Array::Vec2dArrayType): 1543 1543 functor.vertex(vec2dArray[_vertexData.indices>index(vindex)]); 1544 1544 break; 1545 case(Array::Vec3dArrayType): 1545 case(Array::Vec3dArrayType): 1546 1546 functor.vertex(vec3dArray[_vertexData.indices>index(vindex)]); 1547 1547 break; 1548 case(Array::Vec4dArrayType): 1548 case(Array::Vec4dArrayType): 1549 1549 functor.vertex(vec4dArray[_vertexData.indices>index(vindex)]); 1550 1550 break; … … 1574 1574 switch(type) 1575 1575 { 1576 case(Array::Vec2ArrayType): 1576 case(Array::Vec2ArrayType): 1577 1577 functor.vertex(vec2Array[_vertexData.indices>index(vindex)]); 1578 1578 break; 1579 case(Array::Vec3ArrayType): 1579 case(Array::Vec3ArrayType): 1580 1580 functor.vertex(vec3Array[_vertexData.indices>index(vindex)]); 1581 1581 break; 1582 case(Array::Vec4ArrayType): 1582 case(Array::Vec4ArrayType): 1583 1583 functor.vertex(vec4Array[_vertexData.indices>index(vindex)]); 1584 1584 break; 1585 case(Array::Vec2dArrayType): 1585 case(Array::Vec2dArrayType): 1586 1586 functor.vertex(vec2dArray[_vertexData.indices>index(vindex)]); 1587 1587 break; 1588 case(Array::Vec3dArrayType): 1588 case(Array::Vec3dArrayType): 1589 1589 functor.vertex(vec3dArray[_vertexData.indices>index(vindex)]); 1590 1590 break; 1591 case(Array::Vec4dArrayType): 1591 case(Array::Vec4dArrayType): 1592 1592 functor.vertex(vec4dArray[_vertexData.indices>index(vindex)]); 1593 1593 break; … … 1616 1616 switch(type) 1617 1617 { 1618 case(Array::Vec2ArrayType): 1618 case(Array::Vec2ArrayType): 1619 1619 functor.vertex(vec2Array[_vertexData.indices>index(vindex)]); 1620 1620 break; 1621 case(Array::Vec3ArrayType): 1621 case(Array::Vec3ArrayType): 1622 1622 functor.vertex(vec3Array[_vertexData.indices>index(vindex)]); 1623 1623 break; 1624 case(Array::Vec4ArrayType): 1624 case(Array::Vec4ArrayType): 1625 1625 functor.vertex(vec4Array[_vertexData.indices>index(vindex)]); 1626 1626 break; 1627 case(Array::Vec2dArrayType): 1627 case(Array::Vec2dArrayType): 1628 1628 functor.vertex(vec2dArray[_vertexData.indices>index(vindex)]); 1629 1629 break; 1630 case(Array::Vec3dArrayType): 1630 case(Array::Vec3dArrayType): 1631 1631 functor.vertex(vec3dArray[_vertexData.indices>index(vindex)]); 1632 1632 break; 1633 case(Array::Vec4dArrayType): 1633 case(Array::Vec4dArrayType): 1634 1634 functor.vertex(vec4dArray[_vertexData.indices>index(vindex)]); 1635 1635 break; … … 1654 1654 switch(type) 1655 1655 { 1656 case(Array::Vec2ArrayType): 1656 case(Array::Vec2ArrayType): 1657 1657 functor.vertex(vec2Array[_vertexData.indices>index(vindex)]); 1658 1658 break; 1659 case(Array::Vec3ArrayType): 1659 case(Array::Vec3ArrayType): 1660 1660 functor.vertex(vec3Array[_vertexData.indices>index(vindex)]); 1661 1661 break; 1662 case(Array::Vec4ArrayType): 1662 case(Array::Vec4ArrayType): 1663 1663 functor.vertex(vec4Array[_vertexData.indices>index(vindex)]); 1664 1664 break; 1665 case(Array::Vec2dArrayType): 1665 case(Array::Vec2dArrayType): 1666 1666 functor.vertex(vec2dArray[_vertexData.indices>index(vindex)]); 1667 1667 break; 1668 case(Array::Vec3dArrayType): 1668 case(Array::Vec3dArrayType): 1669 1669 functor.vertex(vec3dArray[_vertexData.indices>index(vindex)]); 1670 1670 break; 1671 case(Array::Vec4dArrayType): 1671 case(Array::Vec4dArrayType): 1672 1672 functor.vertex(vec4dArray[_vertexData.indices>index(vindex)]); 1673 1673 break; … … 1692 1692 switch(type) 1693 1693 { 1694 case(Array::Vec2ArrayType): 1694 case(Array::Vec2ArrayType): 1695 1695 functor.vertex(vec2Array[_vertexData.indices>index(vindex)]); 1696 1696 break; 1697 case(Array::Vec3ArrayType): 1697 case(Array::Vec3ArrayType): 1698 1698 functor.vertex(vec3Array[_vertexData.indices>index(vindex)]); 1699 1699 break; 1700 case(Array::Vec4ArrayType): 1700 case(Array::Vec4ArrayType): 1701 1701 functor.vertex(vec4Array[_vertexData.indices>index(vindex)]); 1702 1702 break; 1703 case(Array::Vec2dArrayType): 1703 case(Array::Vec2dArrayType): 1704 1704 functor.vertex(vec2dArray[_vertexData.indices>index(vindex)]); 1705 1705 break; 1706 case(Array::Vec3dArrayType): 1706 case(Array::Vec3dArrayType): 1707 1707 functor.vertex(vec3dArray[_vertexData.indices>index(vindex)]); 1708 1708 break; 1709 case(Array::Vec4dArrayType): 1709 case(Array::Vec4dArrayType): 1710 1710 functor.vertex(vec4dArray[_vertexData.indices>index(vindex)]); 1711 1711 break; … … 1744 1744 switch(vertices>getType()) 1745 1745 { 1746 case(Array::Vec2ArrayType): 1746 case(Array::Vec2ArrayType): 1747 1747 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec2*>(vertices>getDataPointer())); 1748 1748 break; 1749 case(Array::Vec3ArrayType): 1749 case(Array::Vec3ArrayType): 1750 1750 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec3*>(vertices>getDataPointer())); 1751 1751 break; 1752 case(Array::Vec4ArrayType): 1752 case(Array::Vec4ArrayType): 1753 1753 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec4*>(vertices>getDataPointer())); 1754 1754 break; 1755 case(Array::Vec2dArrayType): 1755 case(Array::Vec2dArrayType): 1756 1756 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec2d*>(vertices>getDataPointer())); 1757 1757 break; 1758 case(Array::Vec3dArrayType): 1758 case(Array::Vec3dArrayType): 1759 1759 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec3d*>(vertices>getDataPointer())); 1760 1760 break; 1761 case(Array::Vec4dArrayType): 1761 case(Array::Vec4dArrayType): 1762 1762 functor.setVertexArray(vertices>getNumElements(),static_cast<const Vec4d*>(vertices>getDataPointer())); 1763 1763 break; … … 1798 1798 functor.vertex(indices>index(vindex)); 1799 1799 } 1800 1800 1801 1801 functor.end(); 1802 1802 break; … … 1819 1819 ++vindex; 1820 1820 } 1821 1821 1822 1822 functor.end(); 1823 1823 … … 1888 1888 1889 1889 unsigned int totalNumberOfPrimitives = 0; 1890 1890 1891 1891 for(Geometry::PrimitiveSetList::const_iterator itr=geom.getPrimitiveSetList().begin(); 1892 1892 itr!=geom.getPrimitiveSetList().end(); … … 1959 1959 unsigned int numVertices = geom.getVertexIndices()?geom.getVertexIndices()>getNumElements(): 1960 1960 geom.getVertexArray()?geom.getVertexArray()>getNumElements():0; 1961 if (numElements!=numVertices) return false; 1961 if (numElements!=numVertices) return false; 1962 1962 break; 1963 1963 } 1964 } 1964 } 1965 1965 return true; 1966 1966 } … … 1977 1977 // correct binding if not correct. 1978 1978 if (arrayData.binding!=osg::Geometry::BIND_OFF) 1979 { 1979 { 1980 1980 out<<"Warning: in osg::Geometry::computeCorrectBindingsAndArraySizes() "<<std::endl 1981 1981 <<" "<<arrayName<<" binding has been reset to BIND_OFF"<<std::endl; … … 1990 1990 // correct binding if not correct. 1991 1991 if (arrayData.binding!=osg::Geometry::BIND_OVERALL) 1992 { 1992 { 1993 1993 out<<"Warning: in osg::Geometry::computeCorrectBindingsAndArraySizes() "<<std::endl 1994 1994 <<" "<<arrayName<<" binding has been reset to BIND_OVERALL"<<std::endl; … … 2001 2001 unsigned int numVertices = geom.getVertexIndices()?geom.getVertexIndices()>getNumElements(): 2002 2002 geom.getVertexArray()?geom.getVertexArray()>getNumElements():0; 2003 2003 2004 2004 if ( numVertices==0 ) 2005 2005 { … … 2014 2014 } 2015 2015 } 2016 2016 2017 2017 if (numElements==numVertices) 2018 2018 { … … 2029 2029 2030 2030 2031 // check to see if binding might be per primitive set 2031 // check to see if binding might be per primitive set 2032 2032 unsigned int numPrimitiveSets = geom.getPrimitiveSetList().size(); 2033 2033 2034 2034 if (numElements==numPrimitiveSets) 2035 2035 { … … 2042 2042 return; 2043 2043 } 2044 2045 // check to see if binding might be per primitive 2044 2045 // check to see if binding might be per primitive 2046 2046 unsigned int numPrimitives = _computeNumberOfPrimitives(geom); 2047 2047 if (numElements==numPrimitives) … … 2077 2077 } 2078 2078 arrayData.binding = osg::Geometry::BIND_OFF; 2079 2080 } 2079 2080 } 2081 2081 2082 2082 bool Geometry::verifyBindings(const ArrayData& arrayData) const … … 2127 2127 { 2128 2128 // if (verifyBindings()) return; 2129 2129 2130 2130 computeCorrectBindingsAndArraySizes(_normalData,"_normalData"); 2131 2131 computeCorrectBindingsAndArraySizes(_colorData,"_colorData"); … … 2154 2154 _indices(indices), 2155 2155 _targetArray(targetArray) {} 2156 2156 2157 2157 virtual ~ExpandIndexedArray() {} 2158 2158 2159 // Create when both of the arrays are predefined templated classes. We 2159 // Create when both of the arrays are predefined templated classes. We 2160 2160 // can do some optimizations in this case that aren't possible in the general 2161 2161 // case. … … 2168 2168 if (_targetArray && _targetArray>getType()==array.getType() && _targetArray!=(osg::Array*)(&array)) 2169 2169 { 2170 // reuse exisiting target array 2170 // reuse exisiting target array 2171 2171 newArray = static_cast<T*>(_targetArray); 2172 2172 if (newArray>size()!=indices.size()) … … 2191 2191 2192 2192 // Create when one of the arrays isn't one of the predefined templated classes. The 2193 // template parameter is the type of the array that will get created. This is always 2194 // one of the predefined classes. We could call clone to get one of the same type as 2195 // the input array, but the interface of the osg::Array class doesn't include a way 2193 // template parameter is the type of the array that will get created. This is always 2194 // one of the predefined classes. We could call clone to get one of the same type as 2195 // the input array, but the interface of the osg::Array class doesn't include a way 2196 2196 // to set an element. 2197 2197 template <class T> … … 2216 2216 osg::Array* create_noinline(const osg::Array& array, const osg::IndexArray& indices) 2217 2217 { 2218 switch (array.getType()) 2218 switch (array.getType()) 2219 2219 { 2220 2220 case(osg::Array::ByteArrayType): return create_noinline<osg::ByteArray>(array,indices); … … 2240 2240 osg::Array* create(const TA& array, const osg::IndexArray& indices) 2241 2241 { 2242 // We know that indices.getType returned the same thing as TI, but 2243 // we need to determine whether it is really an instance of TI, or 2244 // perhaps another subclass of osg::Array that contains the same 2242 // We know that indices.getType returned the same thing as TI, but 2243 // we need to determine whether it is really an instance of TI, or 2244 // perhaps another subclass of osg::Array that contains the same 2245 2245 // type of data. 2246 2246 const TI* ba(dynamic_cast<const TI*>(&indices)); … … 2266 2266 default: return create_noinline(array, _indices); 2267 2267 } 2268 2268 2269 2269 } 2270 2270 … … 2312 2312 if (getTexCoordIndices(ti)) hasIndices = true; 2313 2313 } 2314 2314 2315 2315 for(unsigned int vi=0;vi<getNumVertexAttribArrays();++vi) 2316 2316 { … … 2403 2403 { 2404 2404 ExpandIndexedArray eia(*(getTexCoordIndices(ti)),target.getTexCoordArray(ti)); 2405 2405 2406 2406 getTexCoordArray(ti)>accept(eia); 2407 2407 … … 2409 2409 target.setTexCoordIndices(ti,0); 2410 2410 } 2411 else if (getTexCoordArray(ti)) 2411 else if (getTexCoordArray(ti)) 2412 2412 { 2413 2413 if (!copyToSelf) target.setTexCoordArray(ti,getTexCoordArray(ti)); 2414 2414 } 2415 2415 } 2416 2416 2417 2417 for(unsigned int vi=0;vi<_vertexAttribList.size();++vi) 2418 2418 { … … 2434 2434 { 2435 2435 unsigned int numSharedArrays = 0; 2436 2436 2437 2437 if (getVertexArray() && getVertexArray()>referenceCount()>1) ++numSharedArrays; 2438 2438 if (getNormalArray() && getNormalArray()>referenceCount()>1) ++numSharedArrays; … … 2445 2445 if (getTexCoordArray(ti) && getTexCoordArray(ti)>referenceCount()>1) ++numSharedArrays; 2446 2446 } 2447 2447 2448 2448 for(unsigned int vi=0;vi<_vertexAttribList.size();++vi) 2449 2449 { … … 2475 2475 } 2476 2476 } 2477 2477 2478 2478 for(unsigned int vi=0;vi<_vertexAttribList.size();++vi) 2479 2479 {