Fix various checks for whether or not we should generate tex files
This commit is contained in:
parent
51296bd36b
commit
39244b11aa
|
@ -885,7 +885,7 @@ void DynOS_Tex_Write(FILE* aFile, GfxData* aGfxData, DataNode<TexData> *aNode);
|
|||
DataNode<TexData>* DynOS_Tex_Load(FILE *aFile, GfxData *aGfxData);
|
||||
DataNode<TexData>* DynOS_Tex_LoadFromBinary(const SysPath &aPackFolder, const SysPath &aFilename, const char *aTexName, bool aAddToPack);
|
||||
void DynOS_Tex_ConvertTextureDataToPng(GfxData *aGfxData, TexData* aTexture);
|
||||
void DynOS_Tex_GeneratePack(const SysPath &aPackFolder, SysPath &aOutputFolder);
|
||||
void DynOS_Tex_GeneratePack(const SysPath &aPackFolder, SysPath &aOutputFolder, bool aAllowCustomTextures);
|
||||
|
||||
DataNode<TexData*>* DynOS_TexList_Parse(GfxData* aGfxData, DataNode<TexData*>* aNode);
|
||||
void DynOS_TexList_Write(FILE* aFile, GfxData* aGfxData, DataNode<TexData*> *aNode);
|
||||
|
|
|
@ -304,13 +304,14 @@ DataNode<TexData>* DynOS_Tex_LoadFromBinary(const SysPath &aPackFolder, const Sy
|
|||
// Generate //
|
||||
//////////////
|
||||
|
||||
static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath &aOutputFolder, SysPath& aRelativePath, SysPath& aPrefix, GfxData *aGfxData) {
|
||||
// skip generation if any .c files exist
|
||||
if (FileTypeExists(aOutputFolder, ".c")) {
|
||||
static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath &aOutputFolder, SysPath& aRelativePath, SysPath& aPrefix, GfxData *aGfxData, bool aAllowCustomTextures) {
|
||||
SysPath _DirPath = fstring("%s/%s", aPackFolder.c_str(), aRelativePath.c_str());
|
||||
|
||||
// skip generation if any .c files exist
|
||||
if (FileTypeExists(_DirPath, ".c")) {
|
||||
return;
|
||||
}
|
||||
|
||||
SysPath _DirPath = fstring("%s/%s", aPackFolder.c_str(), aRelativePath.c_str());
|
||||
DIR *_PackDir = opendir(_DirPath.c_str());
|
||||
if (!_PackDir) { return; }
|
||||
|
||||
|
@ -327,7 +328,7 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath
|
|||
if (fs_sys_dir_exists(_Path.c_str())) {
|
||||
SysPath _NextPath = fstring("%s%s/", aRelativePath.c_str(), _PackEnt->d_name);
|
||||
SysPath _Prefix = fstring("%s.", _PackEnt->d_name);
|
||||
DynOS_Tex_GeneratePack_Recursive(aPackFolder, aOutputFolder, _NextPath, _Prefix, aGfxData);
|
||||
DynOS_Tex_GeneratePack_Recursive(aPackFolder, aOutputFolder, _NextPath, _Prefix, aGfxData, aAllowCustomTextures);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -356,6 +357,13 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath
|
|||
_BaseName = _PackEnt->d_name;
|
||||
_BaseName = _BaseName.SubString(0, nameLen - 4);
|
||||
}
|
||||
|
||||
// if we aren't overriding a texture, only generate textures in the output directory
|
||||
SysPath _OutputFolder = fstring("%s/", aOutputFolder.c_str());
|
||||
if (_OverrideName == NULL && (!aAllowCustomTextures || strcmp(_DirPath.c_str(), _OutputFolder.c_str()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SysPath _OutputPath = fstring("%s/%s.tex", aOutputFolder.c_str(), _BaseName.begin());
|
||||
|
||||
// create output dir if it doesn't exist
|
||||
|
@ -369,7 +377,7 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath
|
|||
closedir(_PackDir);
|
||||
}
|
||||
|
||||
void DynOS_Tex_GeneratePack(const SysPath &aPackFolder, SysPath &aOutputFolder) {
|
||||
void DynOS_Tex_GeneratePack(const SysPath &aPackFolder, SysPath &aOutputFolder, bool aAllowCustomTextures) {
|
||||
Print("---------- Texture pack folder: \"%s\" ----------", aPackFolder.c_str());
|
||||
|
||||
// skip generation if any .tex files exist
|
||||
|
@ -380,6 +388,6 @@ void DynOS_Tex_GeneratePack(const SysPath &aPackFolder, SysPath &aOutputFolder)
|
|||
GfxData *_GfxData = New<GfxData>();
|
||||
_GfxData->mModelIdentifier = 0;
|
||||
SysPath _Empty = "";
|
||||
DynOS_Tex_GeneratePack_Recursive(aPackFolder, aOutputFolder, _Empty, _Empty, _GfxData);
|
||||
DynOS_Tex_GeneratePack_Recursive(aPackFolder, aOutputFolder, _Empty, _Empty, _GfxData, aAllowCustomTextures);
|
||||
DynOS_Gfx_Free(_GfxData);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void DynOS_Gfx_GeneratePacks(const char* directory) {
|
|||
SysPath _TexturePackFolder = fstring("%s/%s", directory, dir->d_name);
|
||||
SysPath _TexturePackOutputFolder = fstring("%s/%s/textures", directory, dir->d_name);
|
||||
if (fs_sys_dir_exists(_TexturePackFolder.c_str())) {
|
||||
DynOS_Tex_GeneratePack(_TexturePackFolder, _TexturePackOutputFolder);
|
||||
DynOS_Tex_GeneratePack(_TexturePackFolder, _TexturePackOutputFolder, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ static void ScanPacksFolder(SysPath _DynosPacksFolder) {
|
|||
if (fs_sys_dir_exists(_PackFolder.c_str())) {
|
||||
struct PackData* _Pack = DynOS_Pack_Add(_PackFolder);
|
||||
DynOS_Actor_GeneratePack(_PackFolder);
|
||||
DynOS_Tex_GeneratePack(_PackFolder, _PackFolder);
|
||||
DynOS_Tex_GeneratePack(_PackFolder, _PackFolder, false);
|
||||
ScanPackBins(_PackFolder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) {
|
|||
if (!strcmp(_DynosCustomTexs[i].first, aTexName)) {
|
||||
auto& _Data = _DynosCustomTexs[i].second->mData;
|
||||
|
||||
// load the texture if it hasn't been yet
|
||||
// load the texture if it hasn't been yet
|
||||
if (_Data->mRawData.begin() == NULL) {
|
||||
u8 *_RawData = stbi_load_from_memory(_Data->mPngData.begin(), _Data->mPngData.Count(), &_Data->mRawWidth, &_Data->mRawHeight, NULL, 4);
|
||||
_Data->mRawFormat = G_IM_FMT_RGBA;
|
||||
|
|
Loading…
Reference in New Issue