18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 05:57:08 +01:00

Merge the review fixes of #535 and #536 from feat/eu07m-instancing into feat/eu07m-skinning

This commit is contained in:
maj00r
2026-11-29 17:54:34 +01:00
9 changed files with 246 additions and 48 deletions
+26 -1
View File
@@ -27,6 +27,8 @@ Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
#include "utilities/wholefile.h"
#include <bit>
#include <filesystem>
#include <initializer_list>
//---------------------------------------------------------------------------
@@ -1801,6 +1803,27 @@ glm::vec3 TSubModel::offset(float const Geometrytestoffsetthreshold) const
namespace
{
// modelformat eu07m: an .eu07m older than the .e3d / .t3d it was made from isn't used, the model was changed after it was
// converted (the hash of the source in its header would need the source read whole to be compared)
bool eu07m_up_to_date(std::string const &Eu07m, std::initializer_list<std::string> const Sources)
{
std::error_code error;
auto const made{std::filesystem::last_write_time(Eu07m, error)};
if (error)
return false;
for (auto const &source : Sources)
{
if (source.empty())
continue;
if (auto const changed{std::filesystem::last_write_time(source, error)}; (false == bool(error)) && (changed > made))
{
WriteLog("Model \"" + source + "\" is newer than its \"" + Eu07m + "\", which isn't used", logtype::model);
return false;
}
}
return true;
}
// Fazy szczegółowości nazwane "<nazwa>_LOD<n>" (części sieci trakcyjnej) dostają zakresy widoczności tutaj,
// żeby nie trzeba było wpisywać ich w modelach: kolejne fazy zmieniają się na 20, 40, 100, 300 i 400 m,
// a ostatnia faza, jaką część ma, zostaje widoczna do 400 m (drobnica: model mieszczący się w promieniu 0,5 m
@@ -1902,7 +1925,8 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic)
Init();
assign_lod_ranges(Root, name);
}
else if (auto const eu07mfile{Global.modelformat_eu07m ? FileCased(name + ".eu07m") : std::string{}}; (false == eu07mfile.empty()) && LoadFromEU07M(eu07mfile, dynamic))
else if (auto const eu07mfile{Global.modelformat_eu07m ? FileCased(name + ".eu07m") : std::string{}};
(false == eu07mfile.empty()) && eu07m_up_to_date(eu07mfile, {binaryfile, textfile}) && LoadFromEU07M(eu07mfile, dynamic))
{
// modelformat eu07m: the .eu07m made from the model takes its place; one which doesn't load leaves the .e3d / .t3d to go on
asBinary = "";
@@ -2775,6 +2799,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
float opacity = mat->get_or_guess_opacity();
// set phase flag based on material opacity
m_passguessed = true;
if (opacity == 0.0f)
iFlags |= 0x20; // translucent
else