From f878ae5568c1f980dd9ea6a2b7dd6832dd701018 Mon Sep 17 00:00:00 2001 From: cochrane Date: Mon, 19 Mar 2018 22:05:10 +0100 Subject: [PATCH] Use default when loading model that does not specify some textures This fixes #86. --- GLLara/GLLItemMesh.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GLLara/GLLItemMesh.m b/GLLara/GLLItemMesh.m index b0bc8c4..acf7300 100644 --- a/GLLara/GLLItemMesh.m +++ b/GLLara/GLLItemMesh.m @@ -212,7 +212,13 @@ - (void)_createTextureAndShaderAssignments; GLLItemMeshTexture *texture = [NSEntityDescription insertNewObjectForEntityForName:@"GLLItemMeshTexture" inManagedObjectContext:self.managedObjectContext]; texture.mesh = self; texture.identifier = self.mesh.shader.textureUniformNames[i]; - texture.textureURL = self.mesh.textures[i]; + if (i >= self.mesh.textures.count) { + // Grrr, idiot forgot to set texture that the shader is clearly + // using. Need to use some default. + texture.textureURL = [self.mesh.model.parameters defaultValueForTexture:texture.identifier]; + } else { + texture.textureURL = self.mesh.textures[i]; + } } // Find shader value