mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 09:36:48 +01:00
Fill zero normals of terrain loaded from .btf files
A .btf file written by an older build keeps the zero normals of its text, and it isn't rebuilt while it is newer than the text. Its reader builds the shapes on its own, so it fills them the same way as the text and the .sbt readers.
This commit is contained in:
@@ -87,8 +87,6 @@ shape_node::shapenode_data::serialize( std::ostream &Output ) const {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// legacy scenery shapes frequently come with all-zero normals (e.g. pkp/szafa-przek1.inc).
|
||||
// the shaders normalize the interpolated normal, which turns a zero vector into NaN; with the gl46
|
||||
// lighting (ambient sh, envmap, sky occlusion all depend on the normal) that blackens the whole surface.
|
||||
@@ -118,8 +116,6 @@ fill_missing_normals( std::vector<world_vertex> &Vertices ) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// restores content of the struct from provided input stream
|
||||
void
|
||||
shape_node::shapenode_data::deserialize( std::istream &Input ) {
|
||||
|
||||
@@ -74,6 +74,9 @@ struct node_data {
|
||||
instance_handle instance { 0 }; // include of an *.inc template which defines the node, if it isn't defined directly by a scenery layer file
|
||||
};
|
||||
|
||||
// gives the vertices of each triangle with a zero normal the flat normal of the triangle, by its authored winding
|
||||
void fill_missing_normals( std::vector<world_vertex> &Vertices );
|
||||
|
||||
// holds unique piece of geometry, covered with single material
|
||||
class shape_node
|
||||
{
|
||||
|
||||
@@ -1130,6 +1130,8 @@ void terrain_file::load(basic_section &Section, terrain_block const &Block)
|
||||
vertex.texture.t = std::clamp(vertex.texture.t, 0.001f, 0.999f);
|
||||
}
|
||||
}
|
||||
// a file written by an older build can hold the zero normals of its text
|
||||
fill_missing_normals(shapedata.vertices);
|
||||
|
||||
if (true == shapedata.translucent || shapedata.rangesquared_max <= 90000.0 || shapedata.rangesquared_min > 0.0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user