mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-23 09:28:45 +00:00
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:
|
||||
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):
|
||||
for dir_source in dirs_source:
|
||||
if needUpdateDirNoSubdirFile(log, root_dir + "/" + dir_source, file_dest):
|
||||
return 1
|
||||
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):
|
||||
latestSourceFile = 0
|
||||
latestDestFile = 0
|
||||
oldestDestFile = 0
|
||||
sourceFiles = os.listdir(dir_source)
|
||||
destFiles = os.listdir(dir_dest)
|
||||
for file in sourceFiles:
|
||||
|
@ -348,9 +393,9 @@ def needUpdateDirNoSubdir(log, dir_source, dir_dest):
|
|||
filePath = dir_dest + "/" + file
|
||||
if os.path.isfile(filePath):
|
||||
fileTime = os.stat(filePath).st_mtime
|
||||
if (fileTime > latestDestFile):
|
||||
latestDestFile = fileTime
|
||||
if latestSourceFile > latestDestFile:
|
||||
if oldestDestFile == 0 or fileTime < oldestDestFile:
|
||||
oldestDestFile = fileTime
|
||||
if latestSourceFile > oldestDestFile:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
|
|
@ -120,39 +120,65 @@ if len(CoarseMeshTextureNames) > 0:
|
|||
mkPath(log, shapeWithCoarseMesh)
|
||||
shapeWithCoarseMeshBuilded = ExportBuildDirectory + "/" + ShapeWithCoarseMeshBuildDirectory
|
||||
mkPath(log, shapeWithCoarseMeshBuilded)
|
||||
cf = open("config_generated.cfg", "w")
|
||||
cf.write("texture_mul_size = " + TextureMulSizeValue + ";\n")
|
||||
cf.write("\n")
|
||||
cf.write("search_path = \n")
|
||||
cf.write("{\n")
|
||||
cf.write("\t\"" + shapeWithCoarseMesh + "\", \n")
|
||||
for dir in MapLookupDirectories:
|
||||
cf.write("\t\"" + ExportBuildDirectory + "/" + dir + "\", \n")
|
||||
cf.write("};\n")
|
||||
cf.write("\n")
|
||||
cf.write("list_mesh = \n")
|
||||
cf.write("{\n")
|
||||
# For each shape with coarse mesh
|
||||
files = findFiles(log, shapeWithCoarseMesh, "", ".shape")
|
||||
for file in files:
|
||||
sourceFile = shapeWithCoarseMesh + "/" + file
|
||||
if os.path.isfile(sourceFile):
|
||||
destFile = shapeWithCoarseMeshBuilded + "/" + file
|
||||
cf.write("\t\"" + file + "\", \"" + destFile + "\", \n")
|
||||
cf.write("};\n")
|
||||
cf.write("\n")
|
||||
cf.write("output_textures = \n")
|
||||
cf.write("{\n")
|
||||
# For each shape with coarse mesh
|
||||
for tn in CoarseMeshTextureNames:
|
||||
cf.write("\t\"" + shapeWithCoarseMesh + "/" + tn + ".tga\", \n")
|
||||
cf.write("};\n")
|
||||
cf.close()
|
||||
subprocess.call([ BuildCoarseMesh, "config_generated.cfg" ])
|
||||
os.remove("config_generated.cfg")
|
||||
# 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.write("texture_mul_size = " + TextureMulSizeValue + ";\n")
|
||||
cf.write("\n")
|
||||
cf.write("search_path = \n")
|
||||
cf.write("{\n")
|
||||
cf.write("\t\"" + shapeWithCoarseMesh + "\", \n")
|
||||
for dir in MapLookupDirectories:
|
||||
cf.write("\t\"" + ExportBuildDirectory + "/" + dir + "\", \n")
|
||||
cf.write("};\n")
|
||||
cf.write("\n")
|
||||
cf.write("list_mesh = \n")
|
||||
cf.write("{\n")
|
||||
# For each shape with coarse mesh
|
||||
files = findFiles(log, shapeWithCoarseMesh, "", ".shape")
|
||||
for file in files:
|
||||
sourceFile = shapeWithCoarseMesh + "/" + file
|
||||
if os.path.isfile(sourceFile):
|
||||
destFile = shapeWithCoarseMeshBuilded + "/" + file
|
||||
cf.write("\t\"" + file + "\", \"" + destFile + "\", \n")
|
||||
cf.write("};\n")
|
||||
cf.write("\n")
|
||||
cf.write("output_textures = \n")
|
||||
cf.write("{\n")
|
||||
# For each shape with coarse mesh
|
||||
for tn in CoarseMeshTextureNames:
|
||||
cf.write("\t\"" + shapeWithCoarseMesh + "/" + tn + ".tga\", \n")
|
||||
cf.write("};\n")
|
||||
cf.close()
|
||||
subprocess.call([ BuildCoarseMesh, "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
|
||||
for tn in CoarseMeshTextureNames:
|
||||
subprocess.call([ TgaToDds, shapeWithCoarseMesh + "/" + tn + ".tga", "-o", shapeWithCoarseMeshBuilded + "/" + tn + ".dds", "-a", "5" ])
|
||||
if needUpdateCoarse:
|
||||
for tn in CoarseMeshTextureNames:
|
||||
subprocess.call([ TgaToDds, shapeWithCoarseMesh + "/" + tn + ".tga", "-o", shapeWithCoarseMeshBuilded + "/" + tn + ".dds", "-a", "5" ])
|
||||
else:
|
||||
printLog(log, ">>> No coarse meshes <<<")
|
||||
|
||||
|
|
Loading…
Reference in a new issue