Implement skip for coarse mesh build process
This commit is contained in:
parent
c04eea9a22
commit
23cf77ea2f
2 changed files with 107 additions and 36 deletions
|
@ -327,15 +327,60 @@ def needUpdateDirNoSubdirFile(log, dir_source, file_dest):
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def needUpdateDirNoSubdirMultiFile(log, dir_source, root_file, files_dest):
|
||||||
|
for file_dest in files_dest:
|
||||||
|
if needUpdateDirNoSubdirFile(log, dir_source, root_file + "/" + file_dest):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def needUpdateDirNoSubdirMultiFileExt(log, dir_source, root_file, files_dest, file_ext):
|
||||||
|
for file_dest in files_dest:
|
||||||
|
if needUpdateDirNoSubdirFile(log, dir_source, root_file + "/" + file_dest + file_ext):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
def needUpdateMultiDirNoSubdirFile(log, root_dir, dirs_source, file_dest):
|
def needUpdateMultiDirNoSubdirFile(log, root_dir, dirs_source, file_dest):
|
||||||
for dir_source in dirs_source:
|
for dir_source in dirs_source:
|
||||||
if needUpdateDirNoSubdirFile(log, root_dir + "/" + dir_source, file_dest):
|
if needUpdateDirNoSubdirFile(log, root_dir + "/" + dir_source, file_dest):
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def needUpdateMultiDirNoSubdirMultiFileExt(log, root_dir, dirs_source, root_file, files_dest, file_ext):
|
||||||
|
for file_dest in files_dest:
|
||||||
|
if needUpdateMultiDirNoSubdirFile(log, root_dir, dirs_source, root_file + "/" + file_dest + file_ext):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def needUpdateMultiDirNoSubdir(log, root_dir, dirs_source, dir_dest):
|
||||||
|
for dir_source in dirs_source:
|
||||||
|
if needUpdateDirNoSubdir(log, root_dir + "/" + dir_source, dir_dest):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def needUpdateDirNoSubdirExtFile(log, dir_source, dir_ext, file_dest):
|
||||||
|
if not os.path.isfile(file_dest):
|
||||||
|
return 1
|
||||||
|
destTime = os.stat(file_dest).st_mtime
|
||||||
|
sourceFiles = os.listdir(dir_source)
|
||||||
|
for file in sourceFiles:
|
||||||
|
if file.endswith(dir_ext):
|
||||||
|
filePath = dir_source + "/" + file
|
||||||
|
if os.path.isfile(filePath):
|
||||||
|
fileTime = os.stat(filePath).st_mtime
|
||||||
|
if fileTime > destTime:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def needUpdateDirNoSubdirExtMultiFileExt(log, dir_source, dir_ext, root_file, files_dest, file_ext):
|
||||||
|
for file_dest in files_dest:
|
||||||
|
if needUpdateDirNoSubdirExtFile(log, dir_source, dir_ext, root_file + "/" + file_dest + file_ext):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
def needUpdateDirNoSubdir(log, dir_source, dir_dest):
|
def needUpdateDirNoSubdir(log, dir_source, dir_dest):
|
||||||
latestSourceFile = 0
|
latestSourceFile = 0
|
||||||
latestDestFile = 0
|
oldestDestFile = 0
|
||||||
sourceFiles = os.listdir(dir_source)
|
sourceFiles = os.listdir(dir_source)
|
||||||
destFiles = os.listdir(dir_dest)
|
destFiles = os.listdir(dir_dest)
|
||||||
for file in sourceFiles:
|
for file in sourceFiles:
|
||||||
|
@ -348,9 +393,9 @@ def needUpdateDirNoSubdir(log, dir_source, dir_dest):
|
||||||
filePath = dir_dest + "/" + file
|
filePath = dir_dest + "/" + file
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
fileTime = os.stat(filePath).st_mtime
|
fileTime = os.stat(filePath).st_mtime
|
||||||
if (fileTime > latestDestFile):
|
if oldestDestFile == 0 or fileTime < oldestDestFile:
|
||||||
latestDestFile = fileTime
|
oldestDestFile = fileTime
|
||||||
if latestSourceFile > latestDestFile:
|
if latestSourceFile > oldestDestFile:
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -120,6 +120,26 @@ if len(CoarseMeshTextureNames) > 0:
|
||||||
mkPath(log, shapeWithCoarseMesh)
|
mkPath(log, shapeWithCoarseMesh)
|
||||||
shapeWithCoarseMeshBuilded = ExportBuildDirectory + "/" + ShapeWithCoarseMeshBuildDirectory
|
shapeWithCoarseMeshBuilded = ExportBuildDirectory + "/" + ShapeWithCoarseMeshBuildDirectory
|
||||||
mkPath(log, shapeWithCoarseMeshBuilded)
|
mkPath(log, shapeWithCoarseMeshBuilded)
|
||||||
|
# This builds from shapeWithCoarseMesh .shape to shapeWithCoarseMesh .tga
|
||||||
|
# And from shapeWithCoarseMesh .shape to shapeWithCoarseMeshBuilded .shape
|
||||||
|
# Then builds from shapeWithCoarseMesh .tga to shapeWithCoarseMeshBuilded .tga
|
||||||
|
# Depends on MapLookupDirectories
|
||||||
|
needUpdateMaps = needUpdateMultiDirNoSubdirMultiFileExt(log, ExportBuildDirectory, MapLookupDirectories, shapeWithCoarseMesh, CoarseMeshTextureNames, ".tga") or needUpdateMultiDirNoSubdir(log, ExportBuildDirectory, MapLookupDirectories, shapeWithCoarseMeshBuilded)
|
||||||
|
if needUpdateMaps:
|
||||||
|
printLog(log, "DETECT UPDATE Maps->*")
|
||||||
|
else:
|
||||||
|
printLog(log, "DETECT SKIP Maps->*")
|
||||||
|
needUpdateShapeShape = needUpdateDirByTagLog(log, shapeWithCoarseMesh, ".shape", shapeWithCoarseMeshBuilded, ".shape")
|
||||||
|
if needUpdateShapeShape:
|
||||||
|
printLog(log, "DETECT UPDATE Shape->Shape")
|
||||||
|
else:
|
||||||
|
printLog(log, "DETECT SKIP Shape->Shape")
|
||||||
|
needUpdateShapeCoarse = needUpdateDirNoSubdirExtMultiFileExt(log, shapeWithCoarseMesh, ".shape", shapeWithCoarseMesh, CoarseMeshTextureNames, ".tga")
|
||||||
|
if needUpdateShapeCoarse:
|
||||||
|
printLog(log, "DETECT UPDATE Shape->Coarse")
|
||||||
|
else:
|
||||||
|
printLog(log, "DETECT SKIP Shape->Coarse")
|
||||||
|
if needUpdateMaps or needUpdateShapeShape or needUpdateShapeCoarse:
|
||||||
cf = open("config_generated.cfg", "w")
|
cf = open("config_generated.cfg", "w")
|
||||||
cf.write("texture_mul_size = " + TextureMulSizeValue + ";\n")
|
cf.write("texture_mul_size = " + TextureMulSizeValue + ";\n")
|
||||||
cf.write("\n")
|
cf.write("\n")
|
||||||
|
@ -150,7 +170,13 @@ if len(CoarseMeshTextureNames) > 0:
|
||||||
cf.close()
|
cf.close()
|
||||||
subprocess.call([ BuildCoarseMesh, "config_generated.cfg" ])
|
subprocess.call([ BuildCoarseMesh, "config_generated.cfg" ])
|
||||||
os.remove("config_generated.cfg")
|
os.remove("config_generated.cfg")
|
||||||
|
needUpdateCoarse = needUpdateDirNoSubdirExtMultiFileExt(log, shapeWithCoarseMesh, ".tga", shapeWithCoarseMeshBuilded, CoarseMeshTextureNames, ".dds")
|
||||||
|
if needUpdateCoarse:
|
||||||
|
printLog(log, "DETECT UPDATE Coarse->DDS")
|
||||||
|
else:
|
||||||
|
printLog(log, "DETECT SKIP Coarse->DDS")
|
||||||
# Convert the coarse texture to dds
|
# Convert the coarse texture to dds
|
||||||
|
if needUpdateCoarse:
|
||||||
for tn in CoarseMeshTextureNames:
|
for tn in CoarseMeshTextureNames:
|
||||||
subprocess.call([ TgaToDds, shapeWithCoarseMesh + "/" + tn + ".tga", "-o", shapeWithCoarseMeshBuilded + "/" + tn + ".dds", "-a", "5" ])
|
subprocess.call([ TgaToDds, shapeWithCoarseMesh + "/" + tn + ".tga", "-o", shapeWithCoarseMeshBuilded + "/" + tn + ".dds", "-a", "5" ])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue