WS30: Disable texture cache for material atlas
The texture cache interacts badly with the code creating the WS30 texture atlas, resulting in a bad atlas. This change adds a new SGReaderWriterOptions::LoadOriginHint::ORIGIN_MATERIAL_ATLAS which causes the material cache not to cache the texture.
This commit is contained in:
@@ -327,9 +327,9 @@ SGMaterial *SGMaterialCache::find(int lc) const
|
||||
}
|
||||
|
||||
// Generate a texture atlas for this location
|
||||
SGMaterialCache::Atlas SGMaterialLib::getMaterialTextureAtlas(SGVec2f center, const simgear::SGReaderWriterOptions* options)
|
||||
SGMaterialCache::Atlas SGMaterialLib::getMaterialTextureAtlas(SGVec2f center, const simgear::SGReaderWriterOptions* const_options)
|
||||
{
|
||||
SGMaterialCache::Atlas atlas;
|
||||
SGMaterialCache::Atlas atlas;
|
||||
|
||||
// Non-VPB does not use the Atlas, so save some effort and return
|
||||
if (! SGSceneFeatures::instance()->getVPBActive()) return atlas;
|
||||
@@ -349,10 +349,13 @@ SGMaterialCache::Atlas SGMaterialLib::getMaterialTextureAtlas(SGVec2f center, co
|
||||
if (atlas_iter != _atlasCache.end()) return atlas_iter->second;
|
||||
|
||||
// Cache lookup failure - generate a new atlas, but only if we have a chance of reading any textures
|
||||
if (options == 0) {
|
||||
if (const_options == 0) {
|
||||
return atlas;
|
||||
}
|
||||
|
||||
osg::ref_ptr<SGReaderWriterOptions> options = SGReaderWriterOptions::copyOrCreate(const_options);
|
||||
options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_MATERIAL_ATLAS);
|
||||
|
||||
atlas.image = new osg::Texture2DArray();
|
||||
|
||||
SG_LOG(SG_TERRAIN, SG_DEBUG, "Generating atlas of size " << landclasslib.size());
|
||||
|
||||
@@ -299,7 +299,7 @@ ModelRegistry::readImage(const string& fileName,
|
||||
ec.addFromMap(sgoptC->getModelData()->getErrorContext());
|
||||
}
|
||||
|
||||
if (cache_active && (!sgoptC || sgoptC->getLoadOriginHint() != SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN)) {
|
||||
if (cache_active && (!sgoptC || (sgoptC->getLoadOriginHint() != SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN && sgoptC->getLoadOriginHint() != SGReaderWriterOptions::LoadOriginHint::ORIGIN_MATERIAL_ATLAS))) {
|
||||
if (fileExtension != "dds" && fileExtension != "gz") {
|
||||
|
||||
std::string root = getPathRoot(absFileName);
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
ORIGIN_EFFECTS_NORMALIZED,
|
||||
ORIGIN_SPLASH_SCREEN,
|
||||
ORIGIN_CANVAS,
|
||||
ORIGIN_MATERIAL_ATLAS
|
||||
};
|
||||
|
||||
//SGReaderWriterOptions* cloneOptions(const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) const { return static_cast<SGReaderWriterOptions*>(clone(copyop)); }
|
||||
|
||||
Reference in New Issue
Block a user