mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-16 23:11:42 +00:00
Fix LMAP parsing and don't resolve till after ptr is ready.
This commit is contained in:
@@ -32,13 +32,10 @@ namespace
|
|||||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||||
|
|
||||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
|
||||||
|
|
||||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||||
|
|
||||||
std::string imageName;
|
std::string imageName;
|
||||||
int8_t samplerState;
|
int8_t samplerState;
|
||||||
int8_t lmapLookupStart;
|
|
||||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||||
std::getline(*file.m_stream, imageName, '\0');
|
std::getline(*file.m_stream, imageName, '\0');
|
||||||
|
|
||||||
@@ -53,6 +50,8 @@ namespace
|
|||||||
lightDef->attenuation.samplerState = samplerState;
|
lightDef->attenuation.samplerState = samplerState;
|
||||||
lightDef->attenuation.image = imageDependency->Asset();
|
lightDef->attenuation.image = imageDependency->Asset();
|
||||||
|
|
||||||
|
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,10 @@ namespace
|
|||||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||||
|
|
||||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
|
||||||
|
|
||||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||||
|
|
||||||
std::string imageName;
|
std::string imageName;
|
||||||
int8_t samplerState;
|
int8_t samplerState;
|
||||||
int8_t lmapLookupStart;
|
|
||||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||||
std::getline(*file.m_stream, imageName, '\0');
|
std::getline(*file.m_stream, imageName, '\0');
|
||||||
|
|
||||||
@@ -52,7 +49,8 @@ namespace
|
|||||||
|
|
||||||
lightDef->attenuation.samplerState = samplerState;
|
lightDef->attenuation.samplerState = samplerState;
|
||||||
lightDef->attenuation.image = imageDependency->Asset();
|
lightDef->attenuation.image = imageDependency->Asset();
|
||||||
lightDef->lmapLookupStart = static_cast<int>(static_cast<uint8_t>(lmapLookupStart));
|
|
||||||
|
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ namespace
|
|||||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||||
|
|
||||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
|
||||||
|
|
||||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||||
|
|
||||||
int8_t attenuationSamplerState;
|
int8_t attenuationSamplerState;
|
||||||
@@ -55,24 +53,22 @@ namespace
|
|||||||
|
|
||||||
std::string cucolorisName;
|
std::string cucolorisName;
|
||||||
std::getline(*file.m_stream, cucolorisName, '\0');
|
std::getline(*file.m_stream, cucolorisName, '\0');
|
||||||
auto* cucolorisImageDependency = context.LoadDependency<AssetImage>(cucolorisName);
|
if (!cucolorisName.empty())
|
||||||
if (!cucolorisImageDependency)
|
|
||||||
{
|
|
||||||
con::warn("Could not load GfxLightDef \"{}\" due to missing cucoloris image \"{}\"", assetName, cucolorisName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
auto* cucolorisImageDependency = context.LoadDependency<AssetImage>(cucolorisName);
|
||||||
|
if (!cucolorisImageDependency)
|
||||||
|
{
|
||||||
|
con::warn("Could not load GfxLightDef \"{}\" due to missing cucoloris image \"{}\"", assetName, cucolorisName);
|
||||||
|
return AssetCreationResult::Failure();
|
||||||
|
}
|
||||||
registration.AddDependency(cucolorisImageDependency);
|
registration.AddDependency(cucolorisImageDependency);
|
||||||
|
lightDef->cucoloris.image = cucolorisImageDependency->Asset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t lmapLookupStart;
|
|
||||||
file.m_stream->read(reinterpret_cast<char*>(&lmapLookupStart), sizeof(int8_t));
|
|
||||||
|
|
||||||
lightDef->attenuation.samplerState = attenuationSamplerState;
|
lightDef->attenuation.samplerState = attenuationSamplerState;
|
||||||
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
||||||
lightDef->cucoloris.samplerState = cucolorisSamplerState;
|
lightDef->cucoloris.samplerState = cucolorisSamplerState;
|
||||||
lightDef->cucoloris.image = cucolorisImageDependency->Asset();
|
|
||||||
lightDef->lmapLookupStart = static_cast<int>(static_cast<uint8_t>(lmapLookupStart));
|
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,20 +35,19 @@ namespace
|
|||||||
|
|
||||||
std::string attenuationName;
|
std::string attenuationName;
|
||||||
int8_t samplerState;
|
int8_t samplerState;
|
||||||
int8_t lmapLookupStart;
|
|
||||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||||
std::getline(*file.m_stream, attenuationName, '\0');
|
std::getline(*file.m_stream, attenuationName, '\0');
|
||||||
|
|
||||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
auto* attenuationImageDependency = context.LoadDependency<AssetImage>(attenuationName);
|
||||||
if (!imageDependency)
|
if (!attenuationImageDependency)
|
||||||
{
|
{
|
||||||
con::error("Could not load GfxLightDef \"{}\" due to missing image \"{}\"", assetName, imageName);
|
con::error("Could not load GfxLightDef \"{}\" due to missing attenuation image \"{}\"", assetName, attenuationName);
|
||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
}
|
}
|
||||||
registration.AddDependency(imageDependency);
|
registration.AddDependency(attenuationImageDependency);
|
||||||
|
|
||||||
lightDef->attenuation.samplerState = samplerState;
|
lightDef->attenuation.samplerState = samplerState;
|
||||||
lightDef->attenuation.image = imageDependency->Asset();
|
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
||||||
lightDef->lmapLookupStart = 0;
|
lightDef->lmapLookupStart = 0;
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||||
|
|||||||
@@ -35,20 +35,19 @@ namespace
|
|||||||
|
|
||||||
std::string attenuationName;
|
std::string attenuationName;
|
||||||
int8_t samplerState;
|
int8_t samplerState;
|
||||||
int8_t lmapLookupStart;
|
|
||||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||||
std::getline(*file.m_stream, attenuationName, '\0');
|
std::getline(*file.m_stream, attenuationName, '\0');
|
||||||
|
|
||||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
auto* attenuationImageDependency = context.LoadDependency<AssetImage>(attenuationName);
|
||||||
if (!imageDependency)
|
if (!attenuationImageDependency)
|
||||||
{
|
{
|
||||||
con::error("Could not load GfxLightDef \"{}\" due to missing image \"{}\"", assetName, imageName);
|
con::error("Could not load GfxLightDef \"{}\" due to missing attenuation image \"{}\"", assetName, attenuationName);
|
||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
}
|
}
|
||||||
registration.AddDependency(imageDependency);
|
registration.AddDependency(attenuationImageDependency);
|
||||||
|
|
||||||
lightDef->attenuation.samplerState = samplerState;
|
lightDef->attenuation.samplerState = samplerState;
|
||||||
lightDef->attenuation.image = imageDependency->Asset();
|
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
||||||
lightDef->lmapLookupStart = 0;
|
lightDef->lmapLookupStart = 0;
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||||
|
|||||||
@@ -10,9 +10,15 @@ namespace light_def
|
|||||||
{
|
{
|
||||||
const auto* lightDef = asset.Asset();
|
const auto* lightDef = asset.Asset();
|
||||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||||
|
if (!assetFile)
|
||||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
|
||||||
{
|
{
|
||||||
|
con::error("Could not open GfxLightDef file for dumping!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||||
|
{
|
||||||
|
con::error("GfxLightDef attenuation data was invalid!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +28,6 @@ namespace light_def
|
|||||||
if (imageName[0] == ',')
|
if (imageName[0] == ',')
|
||||||
imageName = &imageName[1];
|
imageName = &imageName[1];
|
||||||
|
|
||||||
stream << lightDef->attenuation.samplerState << imageName;
|
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||||
}
|
}
|
||||||
} // namespace light_def
|
} // namespace light_def
|
||||||
|
|||||||
@@ -10,9 +10,17 @@ namespace light_def
|
|||||||
{
|
{
|
||||||
const auto* lightDef = asset.Asset();
|
const auto* lightDef = asset.Asset();
|
||||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||||
|
if (!assetFile)
|
||||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
{
|
||||||
|
con::error("Could not open GfxLightDef file for dumping!");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||||
|
{
|
||||||
|
con::error("GfxLightDef attenuation data was invalid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& stream = *assetFile;
|
auto& stream = *assetFile;
|
||||||
|
|
||||||
@@ -20,6 +28,6 @@ namespace light_def
|
|||||||
if (imageName[0] == ',')
|
if (imageName[0] == ',')
|
||||||
imageName = &imageName[1];
|
imageName = &imageName[1];
|
||||||
|
|
||||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||||
}
|
}
|
||||||
} // namespace light_def
|
} // namespace light_def
|
||||||
|
|||||||
@@ -13,20 +13,30 @@ namespace light_def
|
|||||||
const auto* lightDef = asset.Asset();
|
const auto* lightDef = asset.Asset();
|
||||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||||
auto& stream = *assetFile;
|
auto& stream = *assetFile;
|
||||||
|
if (!assetFile)
|
||||||
|
{
|
||||||
|
con::error("Could not open GfxLightDef file for dumping!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||||
|
{
|
||||||
|
con::error("GfxLightDef attenuation data was invalid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert(lightDef->attenuation.image != nullptr);
|
|
||||||
const auto* attenuationImageName = lightDef->attenuation.image->name;
|
const auto* attenuationImageName = lightDef->attenuation.image->name;
|
||||||
if (attenuationImageName && attenuationImageName[0] == ',')
|
if (attenuationImageName && attenuationImageName[0] == ',')
|
||||||
attenuationImageName = &attenuationImageName[1];
|
attenuationImageName = &attenuationImageName[1];
|
||||||
|
|
||||||
const auto* cucolorisImageName = "";
|
const auto* cucolorisImageName = "";
|
||||||
if (lightDef->cucoloris.image)
|
if (lightDef->cucoloris.image && lightDef->cucoloris.image->name)
|
||||||
{
|
{
|
||||||
cucolorisImageName = lightDef->cucoloris.image->name;
|
cucolorisImageName = lightDef->cucoloris.image->name;
|
||||||
if (cucolorisImageName && cucolorisImageName[0] == ',')
|
if (cucolorisImageName && cucolorisImageName[0] == ',')
|
||||||
cucolorisImageName = &cucolorisImageName[1];
|
cucolorisImageName = &cucolorisImageName[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << lightDef->attenuation.samplerState << attenuationImageName << '\0' << lightDef->cucoloris.samplerState << cucolorisImageName;
|
stream << lightDef->attenuation.samplerState << attenuationImageName << '\0' << lightDef->cucoloris.samplerState << cucolorisImageName << '\0';
|
||||||
}
|
}
|
||||||
} // namespace light_def
|
} // namespace light_def
|
||||||
|
|||||||
@@ -10,9 +10,17 @@ namespace light_def
|
|||||||
{
|
{
|
||||||
const auto* lightDef = asset.Asset();
|
const auto* lightDef = asset.Asset();
|
||||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||||
|
if (!assetFile)
|
||||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
{
|
||||||
|
con::error("Could not open GfxLightDef file for dumping!");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||||
|
{
|
||||||
|
con::error("GfxLightDef attenuation data was invalid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& stream = *assetFile;
|
auto& stream = *assetFile;
|
||||||
|
|
||||||
@@ -20,6 +28,6 @@ namespace light_def
|
|||||||
if (imageName[0] == ',')
|
if (imageName[0] == ',')
|
||||||
imageName = &imageName[1];
|
imageName = &imageName[1];
|
||||||
|
|
||||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||||
}
|
}
|
||||||
} // namespace light_def
|
} // namespace light_def
|
||||||
|
|||||||
@@ -10,9 +10,17 @@ namespace light_def
|
|||||||
{
|
{
|
||||||
const auto* lightDef = asset.Asset();
|
const auto* lightDef = asset.Asset();
|
||||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||||
|
if (!assetFile)
|
||||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
{
|
||||||
|
con::error("Could not open GfxLightDef file for dumping!");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||||
|
{
|
||||||
|
con::error("GfxLightDef attenuation data was invalid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& stream = *assetFile;
|
auto& stream = *assetFile;
|
||||||
|
|
||||||
@@ -20,6 +28,6 @@ namespace light_def
|
|||||||
if (imageName[0] == ',')
|
if (imageName[0] == ',')
|
||||||
imageName = &imageName[1];
|
imageName = &imageName[1];
|
||||||
|
|
||||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||||
}
|
}
|
||||||
} // namespace light_def
|
} // namespace light_def
|
||||||
|
|||||||
Reference in New Issue
Block a user