check m2 version on model loading. +update some enums

This commit is contained in:
T1ti
2024-09-08 22:03:50 +02:00
parent 43a89a5490
commit f31a3c1ccf
5 changed files with 59 additions and 8 deletions

View File

@@ -35,15 +35,45 @@ void Model::finishLoading()
if (f.isEof() || f.getSize() < sizeof(ModelHeader))
{
LogError << "Error loading file \"" << _file_key.stringRepr() << "\". Aborting to load model." << std::endl;
finished = true;
return;
// LogError << "Error loading file \"" << _file_key.stringRepr() << "\". Aborting to load model." << std::endl;
// finished = true;
throw std::runtime_error("Error loading file \"" + _file_key.stringRepr() + "\". Aborting to load model.");
}
memcpy(&header, f.getBuffer(), sizeof(ModelHeader));
uint32_t packed_version = 0;
std::memcpy(&packed_version, header.version, sizeof(packed_version));
bool valid_version = false;
// Noggit::Application::NoggitApplication::instance()->clientData()->version()// either should work
switch (Noggit::Project::CurrentProject::get()->projectVersion )
{
case Noggit::Project::ProjectVersion::WOTLK:
if (packed_version == m2_version_wrath)
valid_version = true;
break;
case Noggit::Project::ProjectVersion::SL:
if (packed_version == m2_version_legion_bfa_sl)
valid_version = true;
break;
default:
assert(false);
}
if (!valid_version)
[[unlikely]]
{
LogError << "Error loading file \"" << _file_key.stringRepr() << "\". Wrong M2 version " << std::to_string(packed_version) << std::endl;
throw std::runtime_error("Error loading file \"" + _file_key.stringRepr() + "\". Wrong M2 version " + std::to_string(packed_version));
}
// blend mode override
if (header.Flags & 8)
if (header.Flags & m2_flag_use_texture_combiner_combos)
{
// go to the end of the header (where the blend override data is)
uint32_t const* blend_override_info = reinterpret_cast<uint32_t const*>(f.getBuffer() + sizeof(ModelHeader));

View File

@@ -31,6 +31,26 @@ namespace Noggit::Rendering
struct ModelRenderPass;
}
enum M2Versions
{
m2_version_pre_release = 256, // < 257
m2_version_classic = 257, // 256-257
m2_version_burning_crusade = 263, // 260-263
m2_version_wrath = 264,
m2_version_cataclysm = 272, // 265-272
m2_version_pandaria_draenor = 272,
m2_version_legion_bfa_sl = 274, // 272-274 Legion, Battle for Azeroth, Shadowlands
};
enum M2GlobalFlags
{
m2_flag_tilt_x = 0x1,
m2_flag_tilt_x = 0x2,
// m2_flag_unk_0x4 = 0x4,
m2_flag_use_texture_combiner_combos = 0x8,
// m2_flag_unk_0x10 = 0x10
// TODO : MOP +
};
glm::vec3 fixCoordSystem(glm::vec3 v);

View File

@@ -115,7 +115,7 @@ union wmo_group_flags
uint32_t flag_0x20 : 1;
uint32_t exterior_lit : 1; // 0x40
uint32_t unreacheable : 1; // 0x80
uint32_t flag_0x100: 1;
uint32_t show_exterior_sky: 1;
uint32_t has_light : 1; // 0x200
uint32_t flag_0x400 : 1;
uint32_t has_doodads : 1; // 0x800

View File

@@ -317,7 +317,7 @@ void ModelRender::fixShaderIdBlendOverride()
}
int shader = 0;
bool blend_mode_override = (_model->header.Flags & 8);
bool blend_mode_override = (_model->header.Flags & m2_flag_use_texture_combiner_combos);
// fuckporting check
if (pass.texture_coord_combo_index + pass.texture_count - 1 >= _model->_texture_unit_lookup.size())

View File

@@ -169,7 +169,8 @@ AssetBrowserWidget::AssetBrowserWidget(MapView* map_view, QWidget *parent)
for (int i = 0; i != _sort_model->rowCount(index); ++i)
{
auto child = index.child(i, 0);
auto child = _sort_model->index(i, 0, index);
// auto child = index.child(i, 0);
auto path = child.data(Qt::UserRole).toString();
if (path.endsWith(".wmo") || path.endsWith(".m2"))
{
@@ -314,7 +315,7 @@ bool AssetBrowserWidget::validateBrowseMode(const QString& wow_file_path)
return true;
case asset_browse_mode::world:
{
if (wow_file_path.startsWith("World", Qt::CaseInsensitive))
if (wow_file_path.startsWith("World", Qt::CaseInsensitive) /*&& !wow_file_path.startsWith("world/nodxt/detail/", Qt::CaseInsensitive)*/)
return true;
return false;
}