Code style cleanup

#837
This commit is contained in:
Wojtek Figat
2022-11-28 23:35:27 +01:00
parent 853fa482f6
commit 3f3697fbfa
4 changed files with 41 additions and 47 deletions

View File

@@ -101,7 +101,7 @@ bool WaveDecoder::ParseHeader(AudioDataInfo& info)
}
}
// PE: Support wav with "extra format bytes", just ignore not needed.
// Support wav with "extra format bytes", just ignore not needed.
while (totalread < subChunkSize)
{
uint8 singlebyte;
@@ -167,7 +167,7 @@ void WaveDecoder::Read(byte* samples, uint32 numSamples)
samples[i] = *((uint8*)&val);
}
}
// IEEE float need to be converted into signed PCM data
// IEEE float need to be converted into signed PCM data
else if (mFormat == WAVE_FORMAT_IEEE_FLOAT)
{
AudioTool::ConvertFromFloat((const float*)samples, (int32*)samples, numSamples);

View File

@@ -229,48 +229,54 @@ struct OpenFbxImporterData
ImportMaterialTexture(result, mat, ofbx::Texture::EMISSIVE, material.Emissive.TextureIndex, TextureEntry::TypeHint::ColorRGB);
ImportMaterialTexture(result, mat, ofbx::Texture::NORMAL, material.Normals.TextureIndex, TextureEntry::TypeHint::Normals);
// PE: FBX dont always store normal maps inside the object.
// FBX don't always store normal maps inside the object
if (material.Diffuse.TextureIndex != -1 && material.Normals.TextureIndex == -1)
{
// PE: If missing , try to locate a normal map in the same path as the diffuse.
// If missing, try to locate a normal map in the same path as the diffuse
const String srcFolder = String(StringUtils::GetDirectoryName(result.Textures[material.Diffuse.TextureIndex].FilePath));
const String srcName = StringUtils::GetFileNameWithoutExtension(result.Textures[material.Diffuse.TextureIndex].FilePath);
String srcSearch;
const int32 num = srcName.FindLast('_');
String srcSmallName = srcName;
if (num != -1)
{
srcSmallName = srcName.Substring(0, num);
}
bool bNormal = false;
for (int iext = 0; iext < 6; iext++)
bool isNormal = false;
for (int32 iExt = 0; iExt < 6; iExt++)
{
String sext = TEXT(".dds");
if (iext == 1) sext = TEXT(".png");
if (iext == 2) sext = TEXT(".jpg");
if (iext == 3) sext = TEXT(".jpeg");
if (iext == 4) sext = TEXT(".tif");
if (iext == 5) sext = TEXT(".tga");
for (int i = 0; i < 5; i++)
String sExit = TEXT(".dds");
if (iExt == 1)
sExit = TEXT(".png");
else if (iExt == 2)
sExit = TEXT(".jpg");
else if (iExt == 3)
sExit = TEXT(".jpeg");
else if (iExt == 4)
sExit = TEXT(".tif");
else if (iExt == 5)
sExit = TEXT(".tga");
for (int32 i = 0; i < 5; i++)
{
String sfind = TEXT("_normal" + sext);
if (i == 1) sfind = TEXT("_n" + sext);
if (i == 2) sfind = TEXT("_nm" + sext);
if (i == 3) sfind = TEXT("_nmp" + sext);
if (i == 4) sfind = TEXT("_nor" + sext);
srcSearch = srcFolder + TEXT("/") + srcSmallName + sfind;
String sFind = TEXT("_normal" + sExit);
if (i == 1)
sFind = TEXT("_n" + sExit);
else if (i == 2)
sFind = TEXT("_nm" + sExit);
else if (i == 3)
sFind = TEXT("_nmp" + sExit);
else if (i == 4)
sFind = TEXT("_nor" + sExit);
srcSearch = srcFolder + TEXT("/") + srcSmallName + sFind;
if (FileSystem::FileExists(srcSearch))
{
bNormal = true;
isNormal = true;
break;
}
}
if (bNormal)
if (isNormal)
break;
}
if (bNormal)
if (isNormal)
{
auto& texture = result.Textures.AddOne();
texture.FilePath = srcSearch;

View File

@@ -1275,25 +1275,17 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
// Trim the animation keyframes range if need to
if (options.Duration == AnimationDuration::Custom)
{
// PE: This is wrong, FramesRange is Frame Index start end, not the frame time.
// PE: To extract Frame Index you has to enter Frame*FramesPerSecond or it will not work.
// PE: This also makes another problem as the "length" get wrong and your not able to loop animatons.
// const float start = (float)(options.FramesRange.X / data.Animation.FramesPerSecond);
// const float end = (float)(options.FramesRange.Y / data.Animation.FramesPerSecond);
// data.Animation.Duration = (end - start); // *data.Animation.FramesPerSecond;
// PE: Custom animation import , frame index start and end, is now correct and the real index.
const float start = (float)(options.FramesRange.X);
const float end = (float)(options.FramesRange.Y);
// Custom animation import, frame index start and end
const float start = options.FramesRange.X;
const float end = options.FramesRange.Y;
for (int32 i = 0; i < data.Animation.Channels.Count(); i++)
{
auto& anim = data.Animation.Channels[i];
anim.Position.Trim(start, end);
anim.Rotation.Trim(start, end);
anim.Scale.Trim(start, end);
}
data.Animation.Duration = (end - start);
data.Animation.Duration = end - start;
}
// Change the sampling rate if need to

View File

@@ -624,16 +624,12 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path
}
bool bKeepAsIs = false;
if (!options.FlipY &&options.Compress && type == ImageType::DDS && mipLevels == sourceMipLevels && DirectX::IsCompressed(sourceDxgiFormat))
if (!options.FlipY && options.Compress && type == ImageType::DDS && mipLevels == sourceMipLevels && DirectX::IsCompressed(sourceDxgiFormat) && !DirectX::IsSRGB(sourceDxgiFormat))
{
if (!DirectX::IsSRGB(sourceDxgiFormat))
{
// PE: Keep image in the current compressed format (artist choice) so we dont have to run the slow mipmap generation.
// PE: Also converting a BC1 normal map to BC5 will not improve it but just use double gpu mem.
bKeepAsIs = true;
targetDxgiFormat = sourceDxgiFormat;
targetFormat = ToPixelFormat(currentImage->GetMetadata().format);
}
// Keep image in the current compressed format (artist choice) so we don't have to run the slow mipmap generation
bKeepAsIs = true;
targetDxgiFormat = sourceDxgiFormat;
targetFormat = ToPixelFormat(currentImage->GetMetadata().format);
}
// Decompress if texture is compressed (next steps need decompressed input data, for eg. mip maps generation or format changing)
@@ -897,7 +893,7 @@ bool TextureTool::ConvertDirectXTex(TextureData& dst, const TextureData& src, co
return true;
}
}
// Check if convert data
// Check if convert data
else if (inImage->GetMetadata().format != dstFormatDxgi)
{
result = DirectX::Convert(inImage->GetImages(), inImage->GetImageCount(), inImage->GetMetadata(), dstFormatDxgi, DirectX::TEX_FILTER_DEFAULT, DirectX::TEX_THRESHOLD_DEFAULT, dstImage);