mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 03:52:52 +01:00
fix(model): a light source added in the editor lights its surroundings
The renderer lights a light point of a model only past its threshold of self-illumination, which E3D keeps in the material of the submodel. A LGHT node without an LMAT (made in the editor, or exported anew) had the threshold -1, never lit, so a light added to a lamp post and saved lit nothing. Such a light now shines whenever its node is shown, as one of a .t3d with "selfillum: true"; the lamp slot of its parent still switches it. The converter gives every light of E3D an LMAT with the threshold it had, so the converted models don't change. TModel3d::AddEditorLight gives the light it adds the same threshold. Self-test: modelsave and modelbrightness, and modelplace takes the parameters of the node after the skin (lights 3). Tested on a lamp post imported from E3D: a light added in the editor, saved, and after a new run the lamp lights the vehicle beside it, both from the scenery file and when it is put in later.
This commit is contained in:
@@ -5879,14 +5879,14 @@ bool editor_mode::enter_cab(TDynamicObject &Vehicle)
|
||||
return true;
|
||||
}
|
||||
|
||||
void editor_mode::place_model_file(std::string const &File)
|
||||
void editor_mode::place_model_file(std::string const &File, std::string const &Parameters)
|
||||
{
|
||||
// on the ground some way ahead of the camera, as far as Insert would put it by a click there
|
||||
auto const view{GfxRenderer->Camera_View_Matrix()};
|
||||
glm::dvec3 ahead{-view[0][2], 0.0, -view[2][2]};
|
||||
ahead = glm::length(ahead) > 1e-6 ? glm::normalize(ahead) : glm::dvec3{0.0, 0.0, 1.0};
|
||||
auto const where{placement_on_ground(Camera.Pos + ahead * 12.0)};
|
||||
auto *placed{simulation::State.create_model("node -1 0 none model 0 0 0 0 " + File + " none endmodel", "editor_", where)};
|
||||
auto *placed{simulation::State.create_model("node -1 0 none model 0 0 0 0 " + File + " none " + (Parameters.empty() ? std::string{} : Parameters + " ") + "endmodel", "editor_", where)};
|
||||
if (placed == nullptr)
|
||||
{
|
||||
ui()->set_status(format(STR_C("The model %s couldn't be put in, the log says why"), File.c_str()), true);
|
||||
|
||||
Reference in New Issue
Block a user