1
1
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
13
13
#include <stdlib.h>
117
118
if(str.find("~MAKE_FAST_GEOMETRY")!=std::string::npos) options ^= MAKE_FAST_GEOMETRY;
118
119
else if(str.find("MAKE_FAST_GEOMETRY")!=std::string::npos) options |= MAKE_FAST_GEOMETRY;
120
121
if(str.find("~FLATTEN_BILLBOARDS")!=std::string::npos) options ^= FLATTEN_BILLBOARDS;
121
122
else if(str.find("FLATTEN_BILLBOARDS")!=std::string::npos) options |= FLATTEN_BILLBOARDS;
123
124
if(str.find("~TEXTURE_ATLAS_BUILDER")!=std::string::npos) options ^= TEXTURE_ATLAS_BUILDER;
124
125
else if(str.find("TEXTURE_ATLAS_BUILDER")!=std::string::npos) options |= TEXTURE_ATLAS_BUILDER;
126
127
if(str.find("~STATIC_OBJECT_DETECTION")!=std::string::npos) options ^= STATIC_OBJECT_DETECTION;
127
128
else if(str.find("STATIC_OBJECT_DETECTION")!=std::string::npos) options |= STATIC_OBJECT_DETECTION;
186
187
OSG_INFO<<"Optimizer::optimize() doing COMBINE_ADJACENT_LODS"<<std::endl;
188
189
CombineLODsVisitor clv(this);
190
191
clv.combineLODs();
193
194
if (options & OPTIMIZE_TEXTURE_SETTINGS)
195
196
OSG_INFO<<"Optimizer::optimize() doing OPTIMIZE_TEXTURE_SETTINGS"<<std::endl;
197
TextureVisitor tv(true,true, // unref image
198
TextureVisitor tv(true,true, // unref image
198
199
false,false, // client storage
199
200
false,1.0, // anisotropic filtering
758
759
// for all current objects associated this transform with them.
759
760
registerWithCurrentObjects(&transform);
762
763
virtual void apply(osg::Geode& geode)
767
768
virtual void apply(osg::Billboard& geode)
773
774
void collectDataFor(osg::Node* node)
775
776
_currentObjectList.push_back(node);
777
778
node->accept(*this);
779
780
_currentObjectList.pop_back();
782
783
void collectDataFor(osg::Billboard* billboard)
784
785
_currentObjectList.push_back(billboard);
786
787
billboard->accept(*this);
788
789
_currentObjectList.pop_back();
791
792
void collectDataFor(osg::Drawable* drawable)
793
794
_currentObjectList.push_back(drawable);
941
942
osg::Matrix matrix_no_trans = matrix;
942
943
matrix_no_trans.setTrans(0.0f,0.0f,0.0f);
944
945
osg::Vec3 v111(1.0f,1.0f,1.0f);
945
946
osg::Vec3 new_v111 = v111*matrix_no_trans;
946
947
float ratio = new_v111.length()/v111.length();
948
949
// move center point.
949
950
lod->setCenter(lod->getCenter()*matrix);
951
952
// adjust ranges to new scale.
952
953
for(unsigned int i=0;i<lod->getNumRanges();++i)
954
955
lod->setRange(i,lod->getMinRange(i)*ratio,lod->getMaxRange(i)*ratio);
957
958
lod->dirtyBound();
1055
// disable all the objects which have more than one matrix associated
1056
// with them, and then disable all transforms which have an object associated
1056
// disable all the objects which have more than one matrix associated
1057
// with them, and then disable all transforms which have an object associated
1057
1058
// them that can't be applied, and then disable all objects which have
1058
// disabled transforms associated, recursing until all disabled
1059
// disabled transforms associated, recursing until all disabled
1059
1060
// associativity.
1060
1061
// and disable all objects that the operation is not permisable for)
1061
1062
for(oitr=_objectMap.begin();
1354
1355
if (group.getNumParents()>0)
1356
1357
// only remove empty groups, but not empty occluders.
1357
if (group.getNumChildren()==0 && isOperationPermissibleForObject(&group) &&
1358
(typeid(group)==typeid(osg::Group) || (dynamic_cast<osg::Transform*>(&group) && !dynamic_cast<osg::CameraView*>(&group))))
1358
if (group.getNumChildren()==0 && isOperationPermissibleForObject(&group) &&
1359
(typeid(group)==typeid(osg::Group) || (dynamic_cast<osg::Transform*>(&group) && !dynamic_cast<osg::CameraView*>(&group))) &&
1360
(group.getNumChildrenRequiringUpdateTraversal()==0 && group.getNumChildrenRequiringEventTraversal()==0) )
1360
1362
_redundantNodeList.insert(&group);
1411
1413
return node.getNumParents()>0 &&
1412
1414
!node.getStateSet() &&
1413
!node.getUserData() &&
1414
!node.getUpdateCallback() &&
1415
node.getName().empty() &&
1416
!node.getUserDataContainer() &&
1417
!node.getCullCallback() &&
1415
1418
!node.getEventCallback() &&
1416
1419
!node.getUpdateCallback() &&
1417
node.getDescriptions().empty() &&
1418
isOperationPermissibleForObject(&node);
1420
isOperationPermissibleForObject(&node);
1421
1423
void Optimizer::RemoveRedundantNodesVisitor::apply(osg::Group& group)
1423
if (group.getNumChildren()==1 &&
1425
if (group.getNumChildren()==1 &&
1424
1426
typeid(group)==typeid(osg::Group) &&
1425
1427
isOperationPermissible(group))
1676
1678
// code to merge geometry object which share, state, and attribute bindings.
1677
1679
////////////////////////////////////////////////////////////////////////////
1681
#define COMPARE_BINDING(lhs, rhs) \
1682
if (osg::getBinding(lhs)<osg::getBinding(rhs)) return true; \
1683
if (osg::getBinding(rhs)<osg::getBinding(lhs)) return false;
1679
1686
struct LessGeometry
1681
1688
bool operator() (const osg::Geometry* lhs,const osg::Geometry* rhs) const
1683
1690
if (lhs->getStateSet()<rhs->getStateSet()) return true;
1684
1691
if (rhs->getStateSet()<lhs->getStateSet()) return false;
1686
if (rhs->getVertexIndices()) { if (!lhs->getVertexIndices()) return true; }
1687
else if (lhs->getVertexIndices()) return false;
1689
if (lhs->getNormalBinding()<rhs->getNormalBinding()) return true;
1690
if (rhs->getNormalBinding()<lhs->getNormalBinding()) return false;
1692
if (rhs->getNormalIndices()) { if (!lhs->getNormalIndices()) return true; }
1693
else if (lhs->getNormalIndices()) return false;
1695
if (lhs->getColorBinding()<rhs->getColorBinding()) return true;
1696
if (rhs->getColorBinding()<lhs->getColorBinding()) return false;
1698
if (rhs->getColorIndices()) { if (!lhs->getColorIndices()) return true; }
1699
else if (lhs->getColorIndices()) return false;
1701
if (lhs->getSecondaryColorBinding()<rhs->getSecondaryColorBinding()) return true;
1702
if (rhs->getSecondaryColorBinding()<lhs->getSecondaryColorBinding()) return false;
1704
if (rhs->getSecondaryColorIndices()) { if (!lhs->getSecondaryColorIndices()) return true; }
1705
else if (lhs->getSecondaryColorIndices()) return false;
1707
if (lhs->getFogCoordBinding()<rhs->getFogCoordBinding()) return true;
1708
if (rhs->getFogCoordBinding()<lhs->getFogCoordBinding()) return false;
1710
if (rhs->getFogCoordIndices()) { if (!lhs->getFogCoordIndices()) return true; }
1711
else if (lhs->getFogCoordIndices()) return false;
1693
COMPARE_BINDING(lhs->getNormalArray(), rhs->getNormalArray())
1694
COMPARE_BINDING(lhs->getColorArray(), rhs->getColorArray())
1695
COMPARE_BINDING(lhs->getSecondaryColorArray(), rhs->getSecondaryColorArray())
1696
COMPARE_BINDING(lhs->getFogCoordArray(), rhs->getFogCoordArray())
1713
1699
if (lhs->getNumTexCoordArrays()<rhs->getNumTexCoordArrays()) return true;
1714
1700
if (rhs->getNumTexCoordArrays()<lhs->getNumTexCoordArrays()) return false;
1716
1702
// therefore lhs->getNumTexCoordArrays()==rhs->getNumTexCoordArrays()
1718
1704
unsigned int i;
1719
1705
for(i=0;i<lhs->getNumTexCoordArrays();++i)
1721
if (rhs->getTexCoordArray(i))
1707
if (rhs->getTexCoordArray(i))
1723
1709
if (!lhs->getTexCoordArray(i)) return true;
1725
1711
else if (lhs->getTexCoordArray(i)) return false;
1727
if (rhs->getTexCoordIndices(i)) { if (!lhs->getTexCoordIndices(i)) return true; }
1728
else if (lhs->getTexCoordIndices(i)) return false;
1731
1714
for(i=0;i<lhs->getNumVertexAttribArrays();++i)
1733
if (rhs->getVertexAttribArray(i))
1716
if (rhs->getVertexAttribArray(i))
1735
1718
if (!lhs->getVertexAttribArray(i)) return true;
1737
1720
else if (lhs->getVertexAttribArray(i)) return false;
1739
if (rhs->getVertexAttribIndices(i)) { if (!lhs->getVertexAttribIndices(i)) return true; }
1740
else if (lhs->getVertexAttribIndices(i)) return false;
1744
if (lhs->getNormalBinding()==osg::Geometry::BIND_OVERALL)
1724
if (osg::getBinding(lhs->getNormalArray())==osg::Array::BIND_OVERALL)
1746
1726
// assumes that the bindings and arrays are set up correctly, this
1747
1727
// should be the case after running computeCorrectBindingsAndArraySizes();
2183
2167
if (geom->getNumPrimitiveSets()>0 &&
2184
geom->getNormalBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET &&
2185
geom->getColorBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET &&
2186
geom->getSecondaryColorBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET &&
2187
geom->getFogCoordBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET)
2168
osg::getBinding(geom->getNormalArray())!=osg::Array::BIND_PER_PRIMITIVE_SET &&
2169
osg::getBinding(geom->getColorArray())!=osg::Array::BIND_PER_PRIMITIVE_SET &&
2170
osg::getBinding(geom->getSecondaryColorArray())!=osg::Array::BIND_PER_PRIMITIVE_SET &&
2171
osg::getBinding(geom->getFogCoordArray())!=osg::Array::BIND_PER_PRIMITIVE_SET)
2191
2175
bool doneCombine = false;
2356
2340
if (geom.getColorArray() && geom.getColorArray()->referenceCount()>1) return true;
2357
2341
if (geom.getSecondaryColorArray() && geom.getSecondaryColorArray()->referenceCount()>1) return true;
2358
2342
if (geom.getFogCoordArray() && geom.getFogCoordArray()->referenceCount()>1) return true;
2361
2345
for(unsigned int unit=0;unit<geom.getNumTexCoordArrays();++unit)
2363
2347
osg::Array* tex = geom.getTexCoordArray(unit);
2364
2348
if (tex && tex->referenceCount()>1) return true;
2367
2351
// shift the indices of the incoming primitives to account for the pre existing geometry.
2368
2352
for(osg::Geometry::PrimitiveSetList::iterator primItr=geom.getPrimitiveSetList().begin();
2369
2353
primItr!=geom.getPrimitiveSetList().end();
2386
2370
MergeArrayVisitor() :
2391
2375
/// try to merge the content of two arrays.
2392
2376
bool merge(osg::Array* lhs,osg::Array* rhs, int offset=0)
2394
2378
if (lhs==0 || rhs==0) return true;
2395
2379
if (lhs->getType()!=rhs->getType()) return false;
2398
2382
_offset = offset;
2400
2384
rhs->accept(*this);
2404
2388
template<typename T>
2405
2389
void _merge(T& rhs)
2407
T* lhs = static_cast<T*>(_lhs);
2391
T* lhs = static_cast<T*>(_lhs);
2408
2392
lhs->insert(lhs->end(),rhs.begin(),rhs.end());
2411
2395
template<typename T>
2412
2396
void _mergeAndOffset(T& rhs)
2414
T* lhs = static_cast<T*>(_lhs);
2398
T* lhs = static_cast<T*>(_lhs);
2416
2400
typename T::iterator itr;
2417
2401
for(itr = rhs.begin();
2436
2420
virtual void apply(osg::Vec2Array& rhs) { _merge(rhs); }
2437
2421
virtual void apply(osg::Vec3Array& rhs) { _merge(rhs); }
2438
2422
virtual void apply(osg::Vec4Array& rhs) { _merge(rhs); }
2440
2424
virtual void apply(osg::DoubleArray& rhs) { _merge(rhs); }
2441
2425
virtual void apply(osg::Vec2dArray& rhs) { _merge(rhs); }
2442
2426
virtual void apply(osg::Vec3dArray& rhs) { _merge(rhs); }
2443
2427
virtual void apply(osg::Vec4dArray& rhs) { _merge(rhs); }
2445
2429
virtual void apply(osg::Vec2bArray& rhs) { _merge(rhs); }
2446
2430
virtual void apply(osg::Vec3bArray& rhs) { _merge(rhs); }
2447
virtual void apply(osg::Vec4bArray& rhs) { _merge(rhs); }
2431
virtual void apply(osg::Vec4bArray& rhs) { _merge(rhs); }
2448
2432
virtual void apply(osg::Vec2sArray& rhs) { _merge(rhs); }
2449
2433
virtual void apply(osg::Vec3sArray& rhs) { _merge(rhs); }
2450
2434
virtual void apply(osg::Vec4sArray& rhs) { _merge(rhs); }
2472
2455
lhs.setVertexArray(rhs.getVertexArray());
2475
if (lhs.getVertexIndices() && rhs.getVertexIndices())
2478
base = lhs.getVertexIndices()->getNumElements();
2479
if (!merger.merge(lhs.getVertexIndices(),rhs.getVertexIndices(),vbase))
2481
OSG_DEBUG << "MergeGeometry: vertex indices not merged. Some data may be lost." <<std::endl;
2484
else if (rhs.getVertexIndices())
2487
lhs.setVertexIndices(rhs.getVertexIndices());
2491
unsigned int nbase = lhs.getNormalArray() ? lhs.getNormalArray()->getNumElements() : 0;
2492
if (lhs.getNormalArray() && rhs.getNormalArray() && lhs.getNormalBinding()!=osg::Geometry::BIND_OVERALL)
2459
if (lhs.getNormalArray() && rhs.getNormalArray() && lhs.getNormalArray()->getBinding()!=osg::Array::BIND_OVERALL)
2494
2461
if (!merger.merge(lhs.getNormalArray(),rhs.getNormalArray()))
2501
2468
lhs.setNormalArray(rhs.getNormalArray());
2504
if (lhs.getNormalIndices() && rhs.getNormalIndices() && lhs.getNormalBinding()!=osg::Geometry::BIND_OVERALL)
2506
if (!merger.merge(lhs.getNormalIndices(),rhs.getNormalIndices(),nbase))
2508
OSG_DEBUG << "MergeGeometry: Vertex Array not merged. Some data may be lost." <<std::endl;
2511
else if (rhs.getNormalIndices())
2513
// this assignment makes the assumption that lhs.NormalArray is empty as well and NormalIndices
2514
lhs.setNormalIndices(rhs.getNormalIndices());
2518
unsigned int cbase = lhs.getColorArray() ? lhs.getColorArray()->getNumElements() : 0;
2519
if (lhs.getColorArray() && rhs.getColorArray() && lhs.getColorBinding()!=osg::Geometry::BIND_OVERALL)
2472
if (lhs.getColorArray() && rhs.getColorArray() && lhs.getColorArray()->getBinding()!=osg::Array::BIND_OVERALL)
2521
2474
if (!merger.merge(lhs.getColorArray(),rhs.getColorArray()))
2528
2481
lhs.setColorArray(rhs.getColorArray());
2531
if (lhs.getColorIndices() && rhs.getColorIndices() && lhs.getColorBinding()!=osg::Geometry::BIND_OVERALL)
2533
if (!merger.merge(lhs.getColorIndices(),rhs.getColorIndices(),cbase))
2535
OSG_DEBUG << "MergeGeometry: color indices not merged. Some data may be lost." <<std::endl;
2538
else if (rhs.getColorIndices())
2540
// this assignment makes the assumption that lhs.ColorArray is empty as well and ColorIndices
2541
lhs.setColorIndices(rhs.getColorIndices());
2544
unsigned int scbase = lhs.getSecondaryColorArray() ? lhs.getSecondaryColorArray()->getNumElements() : 0;
2545
if (lhs.getSecondaryColorArray() && rhs.getSecondaryColorArray() && lhs.getSecondaryColorBinding()!=osg::Geometry::BIND_OVERALL)
2484
if (lhs.getSecondaryColorArray() && rhs.getSecondaryColorArray() && lhs.getSecondaryColorArray()->getBinding()!=osg::Array::BIND_OVERALL)
2547
2486
if (!merger.merge(lhs.getSecondaryColorArray(),rhs.getSecondaryColorArray()))
2554
2493
lhs.setSecondaryColorArray(rhs.getSecondaryColorArray());
2557
if (lhs.getSecondaryColorIndices() && rhs.getSecondaryColorIndices() && lhs.getSecondaryColorBinding()!=osg::Geometry::BIND_OVERALL)
2559
if (!merger.merge(lhs.getSecondaryColorIndices(),rhs.getSecondaryColorIndices(),scbase))
2561
OSG_DEBUG << "MergeGeometry: secondary color indices not merged. Some data may be lost." <<std::endl;
2564
else if (rhs.getSecondaryColorIndices())
2566
// this assignment makes the assumption that lhs.SecondaryColorArray is empty as well and SecondaryColorIndices
2567
lhs.setSecondaryColorIndices(rhs.getSecondaryColorIndices());
2570
unsigned int fcbase = lhs.getFogCoordArray() ? lhs.getFogCoordArray()->getNumElements() : 0;
2571
if (lhs.getFogCoordArray() && rhs.getFogCoordArray() && lhs.getFogCoordBinding()!=osg::Geometry::BIND_OVERALL)
2496
if (lhs.getFogCoordArray() && rhs.getFogCoordArray() && lhs.getFogCoordArray()->getBinding()!=osg::Array::BIND_OVERALL)
2573
2498
if (!merger.merge(lhs.getFogCoordArray(),rhs.getFogCoordArray()))
2580
2505
lhs.setFogCoordArray(rhs.getFogCoordArray());
2583
if (lhs.getFogCoordIndices() && rhs.getFogCoordIndices() && lhs.getFogCoordBinding()!=osg::Geometry::BIND_OVERALL)
2585
if (!merger.merge(lhs.getFogCoordIndices(),rhs.getFogCoordIndices(),fcbase))
2587
OSG_DEBUG << "MergeGeometry: fog coord indices not merged. Some data may be lost." <<std::endl;
2590
else if (rhs.getFogCoordIndices())
2592
// this assignment makes the assumption that lhs.FogCoordArray is empty as well and FogCoordIndices
2593
lhs.setFogCoordIndices(rhs.getFogCoordIndices());
2597
2509
unsigned int unit;
2598
2510
for(unit=0;unit<lhs.getNumTexCoordArrays();++unit)
2600
unsigned int tcbase = lhs.getTexCoordArray(unit) ? lhs.getTexCoordArray(unit)->getNumElements() : 0;
2601
2512
if (!merger.merge(lhs.getTexCoordArray(unit),rhs.getTexCoordArray(unit)))
2603
2514
OSG_DEBUG << "MergeGeometry: tex coord array not merged. Some data may be lost." <<std::endl;
2606
if (lhs.getTexCoordIndices(unit) && rhs.getTexCoordIndices(unit))
2608
if (!merger.merge(lhs.getTexCoordIndices(unit),rhs.getTexCoordIndices(unit),tcbase))
2610
OSG_DEBUG << "MergeGeometry: tex coord indices not merged. Some data may be lost." <<std::endl;
2615
2518
for(unit=0;unit<lhs.getNumVertexAttribArrays();++unit)
2617
unsigned int vabase = lhs.getVertexAttribArray(unit) ? lhs.getVertexAttribArray(unit)->getNumElements() : 0;
2618
2520
if (!merger.merge(lhs.getVertexAttribArray(unit),rhs.getVertexAttribArray(unit)))
2620
2522
OSG_DEBUG << "MergeGeometry: vertex attrib array not merged. Some data may be lost." <<std::endl;
2623
if (lhs.getVertexAttribIndices(unit) && rhs.getVertexAttribIndices(unit))
2625
if (!merger.merge(lhs.getVertexAttribIndices(unit),rhs.getVertexAttribIndices(unit),vabase))
2627
OSG_DEBUG << "MergeGeometry: vertex attrib indices not merged. Some data may be lost." <<std::endl;
2795
2689
if (divide(*itr,maxNumTreesPerCell)) divided = true;
2798
2692
for(GeodesToDivideList::iterator geode_itr=_geodesToDivideList.begin();
2799
2693
geode_itr!=_geodesToDivideList.end();
2802
2696
if (divide(*geode_itr,maxNumTreesPerCell)) divided = true;
2805
2699
return divided;
2808
2702
bool Optimizer::SpatializeGroupsVisitor::divide(osg::Group* group, unsigned int maxNumTreesPerCell)
2810
2704
if (group->getNumChildren()<=maxNumTreesPerCell) return false;
2812
2706
// create the original box.
2813
2707
osg::BoundingBox bb;
2814
2708
unsigned int i;
2824
2718
bool zAxis = (bb.zMax()-bb.zMin())>divide_distance;
2826
2720
OSG_INFO<<"Dividing "<<group->className()<<" num children = "<<group->getNumChildren()<<" xAxis="<<xAxis<<" yAxis="<<yAxis<<" zAxis="<<zAxis<<std::endl;
2828
2722
if (!xAxis && !yAxis && !zAxis)
2830
2724
OSG_INFO<<" No axis to divide, stopping division."<<std::endl;
2834
2728
unsigned int numChildrenOnEntry = group->getNumChildren();
2836
2730
typedef std::pair< osg::BoundingBox, osg::ref_ptr<osg::Group> > BoxGroupPair;
2837
2731
typedef std::vector< BoxGroupPair > Boxes;
2839
2733
boxes.push_back( BoxGroupPair(bb,new osg::Group) );
2841
// divide up on each axis
2735
// divide up on each axis
2844
2738
unsigned int numCellsToDivide=boxes.size();
3793
3687
// border colours don't match
3794
3688
if (_texture->getBorderColor() != sourceTexture->getBorderColor()) return DOES_NOT_FIT_IN_ANY_ROW;
3797
3691
if (_texture->getFilter(osg::Texture2D::MIN_FILTER) != sourceTexture->getFilter(osg::Texture2D::MIN_FILTER))
3799
3693
// inconsitent min filters
3800
3694
return DOES_NOT_FIT_IN_ANY_ROW;
3803
3697
if (_texture->getFilter(osg::Texture2D::MAG_FILTER) != sourceTexture->getFilter(osg::Texture2D::MAG_FILTER))
3805
3699
// inconsitent mag filters
3806
3700
return DOES_NOT_FIT_IN_ANY_ROW;
3809
3703
if (_texture->getMaxAnisotropy() != sourceTexture->getMaxAnisotropy())
3811
3705
// anisotropy different.
3812
3706
return DOES_NOT_FIT_IN_ANY_ROW;
3815
3709
if (_texture->getInternalFormat() != sourceTexture->getInternalFormat())
3817
3711
// internal formats inconistent
3818
3712
return DOES_NOT_FIT_IN_ANY_ROW;
3821
3715
if (_texture->getShadowCompareFunc() != sourceTexture->getShadowCompareFunc())
3823
3717
// shadow functions inconsitent
3824
3718
return DOES_NOT_FIT_IN_ANY_ROW;
3827
3721
if (_texture->getShadowTextureMode() != sourceTexture->getShadowTextureMode())
3829
3723
// shadow texture mode inconsitent
3903
3797
_texture->setWrap(osg::Texture2D::WRAP_S, sourceTexture->getWrap(osg::Texture2D::WRAP_S));
3904
3798
_texture->setWrap(osg::Texture2D::WRAP_T, sourceTexture->getWrap(osg::Texture2D::WRAP_T));
3906
3800
_texture->setBorderColor(sourceTexture->getBorderColor());
3907
3801
_texture->setBorderWidth(0);
3909
3803
_texture->setFilter(osg::Texture2D::MIN_FILTER, sourceTexture->getFilter(osg::Texture2D::MIN_FILTER));
3910
3804
_texture->setFilter(osg::Texture2D::MAG_FILTER, sourceTexture->getFilter(osg::Texture2D::MAG_FILTER));
4391
4285
// safe to convert into CLAMP wrap mode.
4392
4286
OSG_INFO<<"Changing wrap mode to CLAMP"<<std::endl;
4393
texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture::CLAMP);
4394
texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture::CLAMP);
4287
texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
4288
texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
4397
4291
//typedef std::list<osg::Texture2D *> SourceListTmp;
4478
// remap the textures in the StateSet's
4372
// remap the textures in the StateSet's
4479
4373
for(sitr = _statesetMap.begin();
4480
4374
sitr != _statesetMap.end();
4483
4377
osg::StateSet* stateset = sitr->first;
4484
osg::StateSet::TextureAttributeList& tal = stateset->getTextureAttributeList();
4378
const osg::StateSet::TextureAttributeList& tal = stateset->getTextureAttributeList();
4485
4379
for(unsigned int unit=0; unit<tal.size(); ++unit)
4487
4381
osg::Texture2D* texture = dynamic_cast<osg::Texture2D*>(stateset->getTextureAttribute(unit,osg::StateAttribute::TEXTURE));