mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
add vertex deduplication range to config, multiply tolerancescale through whole chain
This commit is contained in:
@@ -488,6 +488,11 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
Parser.getTokens(1, false);
|
||||
Parser >> iConvertModels;
|
||||
}
|
||||
else if (token == "convertindexrange")
|
||||
{
|
||||
Parser.getTokens(1, false);
|
||||
Parser >> iConvertIndexRange;
|
||||
}
|
||||
else if (token == "file.binary.terrain")
|
||||
{
|
||||
// binary terrain (de)serialization
|
||||
|
||||
@@ -70,6 +70,7 @@ struct global_settings {
|
||||
std::string SceneryFile;
|
||||
std::string local_start_vehicle{ "EU07-424" };
|
||||
int iConvertModels{ 0 }; // tworzenie plików binarnych
|
||||
int iConvertIndexRange{ 1000 }; // range of duplicate vertex scan
|
||||
bool file_binary_terrain{ true }; // enable binary terrain (de)serialization
|
||||
// logs
|
||||
int iWriteLogEnabled{ 3 }; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
|
||||
|
||||
15
Model3d.cpp
15
Model3d.cpp
@@ -455,7 +455,8 @@ std::pair<int, int> TSubModel::Load( cParser &parser, bool dynamic )
|
||||
// transformation matrix
|
||||
fMatrix = new float4x4();
|
||||
readMatrix(parser, *fMatrix); // wczytanie transform
|
||||
float transformscale = 1.0f;
|
||||
if (Parent != nullptr)
|
||||
transformscalestack = Parent->transformscalestack;
|
||||
if( !fMatrix->IdentityIs() ) {
|
||||
iFlags |= 0x8000; // transform niejedynkowy - trzeba go przechować
|
||||
// check the scaling
|
||||
@@ -473,7 +474,7 @@ std::pair<int, int> TSubModel::Load( cParser &parser, bool dynamic )
|
||||
rescale :
|
||||
normalize );
|
||||
}
|
||||
transformscale = (scale.x + scale.y + scale.z) / 3.0f;
|
||||
transformscalestack *= (scale.x + scale.y + scale.z) / 3.0f;
|
||||
}
|
||||
if (eType < TP_ROTATOR)
|
||||
{ // wczytywanie wierzchołków
|
||||
@@ -655,7 +656,7 @@ std::pair<int, int> TSubModel::Load( cParser &parser, bool dynamic )
|
||||
}
|
||||
}
|
||||
Vertices.resize( m_geometry.vertex_count ); // in case we had some degenerate triangles along the way
|
||||
gfx::calculate_indices( Indices, Vertices, transformscale );
|
||||
gfx::calculate_indices( Indices, Vertices, transformscalestack );
|
||||
gfx::calculate_tangents( Vertices, Indices, GL_TRIANGLES );
|
||||
// update values potentially changed by indexing
|
||||
m_geometry.index_count = Indices.size();
|
||||
@@ -2195,13 +2196,17 @@ void TModel3d::LoadFromTextFile(std::string const &FileName, bool dynamic)
|
||||
break;
|
||||
}
|
||||
SubModel = new TSubModel();
|
||||
SubModel->Parent = GetFromName(parent);
|
||||
if (SubModel->Parent == nullptr && parent != "none")
|
||||
ErrorLog("Bad model: parent for sub-model \"" + SubModel->pName +"\" doesn't exist or is located later in the model data", logtype::model);
|
||||
|
||||
{
|
||||
auto const result { SubModel->Load( parser, dynamic ) };
|
||||
m_indexcount += result.first;
|
||||
m_vertexcount += result.second;
|
||||
}
|
||||
// będzie potrzebne do wyliczenia pozycji, np. pantografu
|
||||
SubModel->Parent = AddToNamed(parent.c_str(), SubModel);
|
||||
|
||||
AddTo(SubModel->Parent, SubModel);
|
||||
|
||||
parser.getTokens();
|
||||
parser >> token;
|
||||
|
||||
@@ -105,6 +105,7 @@ private:
|
||||
float4x4 *fMatrix = nullptr; // pojedyncza precyzja wystarcza
|
||||
int iMatrix; // w pliku binarnym jest numer matrycy
|
||||
};
|
||||
float transformscalestack { 1.0f }; // tolerancescale used in calculate_indices for whole matrix chain
|
||||
int iTexture { 0 }; // numer nazwy tekstury, -1 wymienna, 0 brak
|
||||
float fLight { -1.0f }; // próg jasności światła do zadziałania selfillum
|
||||
glm::vec4
|
||||
|
||||
@@ -202,7 +202,7 @@ void calculate_indices( index_array &Indices, vertex_array &Vertices, float tole
|
||||
// if found, remap these to use our current vertex instead
|
||||
auto vertex { Vertices[ idx ] };
|
||||
auto matchiter { std::cbegin( Vertices ) + idx };
|
||||
for( auto matchidx = idx + 1; matchidx < Indices.size() && matchidx < idx + 1000; ++matchidx ) {
|
||||
for( auto matchidx = idx + 1; matchidx < Indices.size() && matchidx < idx + Global.iConvertIndexRange; ++matchidx ) {
|
||||
++matchiter;
|
||||
if( ( glm::all( glm::epsilonEqual( vertex.position, matchiter->position, matchtolerance ) ) )
|
||||
&& ( glm::all( glm::epsilonEqual( vertex.normal, matchiter->normal, matchtolerance ) ) )
|
||||
|
||||
Reference in New Issue
Block a user