From cf24d2f7c02336296930b16235a4aa10ed23087b Mon Sep 17 00:00:00 2001 From: Jens Ayton Date: Fri, 11 Jun 2010 22:12:37 +0000 Subject: [PATCH] Like r3494, but useful. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3501 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/OOCacheManager.m | 2 +- src/Core/OOMesh.m | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Core/OOCacheManager.m b/src/Core/OOCacheManager.m index 9814ee05..3620c16c 100644 --- a/src/Core/OOCacheManager.m +++ b/src/Core/OOCacheManager.m @@ -75,7 +75,7 @@ static NSString * const kCacheKeyCaches = @"caches"; enum { kEndianTagValue = 0x0123456789ABCDEFULL, - kFormatVersionValue = 40 + kFormatVersionValue = 41 }; diff --git a/src/Core/OOMesh.m b/src/Core/OOMesh.m index 8cf8e5d5..17d4de30 100644 --- a/src/Core/OOMesh.m +++ b/src/Core/OOMesh.m @@ -812,9 +812,7 @@ shaderBindingTarget:(id)target if (self == nil) return nil; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - _normalMode = smooth ? kNormalModeSmooth : kNormalModePerFace; - - if (cacheKey != nil && smooth) cacheKey = [cacheKey stringByAppendingString:@":smooth"]; + _normalMode = smooth ? kNormalModeSmooth : kNormalModePerFace; #if OOMESH_PROFILE _stopwatch = [[OOProfilingStopwatch alloc] init]; @@ -1080,10 +1078,11 @@ shaderBindingTarget:(id)target NSString *failString = @"***** "; unsigned i, j; NSMutableDictionary *texFileName2Idx = nil; + NSString *cacheKey = nil; + BOOL using_preloaded = NO; - BOOL using_preloaded = NO; - - cacheData = [OOCacheManager meshDataForName:filename]; + cacheKey = [NSString stringWithFormat:@"%@:%u", filename, _normalMode]; + cacheData = [OOCacheManager meshDataForName:cacheKey]; if (cacheData != nil) { if ([self setModelFromModelData:cacheData name:filename]) @@ -1516,7 +1515,7 @@ shaderBindingTarget:(id)target } // save the resulting data for possible reuse - [OOCacheManager setMeshData:[self modelData] forName:filename]; + [OOCacheManager setMeshData:[self modelData] forName:cacheKey]; PROFILE(@"saved to cache"); if (failFlag)