I thought that the wreckage generated randomly by the game itself did not end up in the cache (regardless of the message generated by the test build), but it seems that this is not the case. I have an idea or two on how to force non-inclusion of game generated auto-scaled wreckage in the cache, but it may have to wait for a little due to RL (always gets in the way, doesn't it?).Fritz wrote:But wreckage could be a problem because it comes in random sizes.
Edit: Just to have it somewhere till I manage to continue getting on with it, this is the patch as it stands so far:
Code: Select all
diff --git a/src/Core/OOMesh.h b/src/Core/OOMesh.h
index 2a28279..3705a3c 100644
--- a/src/Core/OOMesh.h
+++ b/src/Core/OOMesh.h
@@ -98,6 +98,7 @@ typedef struct
OOMeshFaceCount faceCount;
NSString *baseFile;
+ NSString *baseFileCacheRef;
Vector *_vertices;
Vector *_normals;
diff --git a/src/Core/OOMesh.m b/src/Core/OOMesh.m
index dc3ec97..d8f4f5f 100644
--- a/src/Core/OOMesh.m
+++ b/src/Core/OOMesh.m
@@ -286,6 +286,7 @@ static BOOL IsPerVertexNormalMode(OOMeshNormalMode mode)
if (self == nil) return nil;
baseFile = @"No Model";
+ baseFileCacheRef = @"No Model-0.000";
#if OO_MULTITEXTURE
_textureUnitCount = NSNotFound;
#endif
@@ -302,6 +303,7 @@ static BOOL IsPerVertexNormalMode(OOMeshNormalMode mode)
{
unsigned i;
+ DESTROY(baseFileCacheRef);
DESTROY(baseFile);
DESTROY(octree);
@@ -652,7 +654,8 @@ static NSString *NormalModeDescription(OOMeshNormalMode mode)
{
if (octree == nil)
{
- octree = [[OOCacheManager octreeForModel:baseFile] retain];
+ OOLog(@"octree.cache.read", @"Trying to read octree for mesh %@ from cache.", baseFileCacheRef);
+ octree = [[OOCacheManager octreeForModel:baseFileCacheRef] retain];
if (octree == nil)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -671,7 +674,8 @@ static NSString *NormalModeDescription(OOMeshNormalMode mode)
octree = [converter findOctreeToDepth:[self octreeDepth]];
[octree retain];
- [OOCacheManager setOctree:octree forModel:baseFile];
+ OOLog(@"octree.cache.write", @"Writing octree for mesh %@ in cache.", baseFileCacheRef);
+ [OOCacheManager setOctree:octree forModel:baseFileCacheRef];
[pool release];
}
@@ -869,6 +873,7 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)target
PROFILE(@"finished calculateBoundingVolumes (again\?\?)");
baseFile = [name copy];
+ baseFileCacheRef = [[NSString stringWithFormat:@"%@-%.3f", baseFile, scale] copy];
/* New in r3033: save the material-defining parameters here so we
can rebind the materials at any time.
@@ -917,6 +922,7 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)target
if (result != nil)
{
[result->baseFile retain];
+ [result->baseFileCacheRef retain];
[result->octree retain];
[result->_retainedObjects retain];
[result->_materialDict retain];
@@ -1154,7 +1160,7 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)target
if (!using_preloaded)
{
- OOLog(@"mesh.load.uncached", @"Mesh \"%@\" is not in cache, loading.", filename);
+ OOLog(@"mesh.load.uncached", @"Mesh \"%@\" is not in cache, loading ( %@ ).", filename, cacheKey);
NSCharacterSet *whitespaceCharSet = [NSCharacterSet whitespaceCharacterSet];
NSCharacterSet *whitespaceAndNewlineCharSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
@@ -2004,6 +2010,7 @@ static float FaceAreaCorrect(GLuint *vertIndices, Vector *vertices)
[self calculateBoundingVolumes];
DESTROY(octree);
DESTROY(baseFile); // Avoid octree cache.
+ DESTROY(baseFileCacheRef);
}