shader fix, vehicle move feature

This commit is contained in:
milek7
2019-03-17 23:55:40 +01:00
parent a0738d109b
commit e6e5d6645b
11 changed files with 42 additions and 32 deletions

View File

@@ -3507,6 +3507,20 @@ glm::dvec3 TDynamicObject::get_future_movement() const
return m_future_movement;
}
void TDynamicObject::move_set(double distance)
{
TDynamicObject *d = this;
while( d ) {
d->Move( distance * d->DirectionGet() );
d = d->Next(); // pozostałe też
}
d = Prev();
while( d ) {
d->Move( distance * d->DirectionGet() );
d = d->Prev(); // w drugą stronę też
}
}
bool TDynamicObject::FastUpdate(double dt)
{
if (dt == 0.0)

View File

@@ -633,6 +633,7 @@ private:
void DestinationSet(std::string to, std::string numer);
void OverheadTrack(float o);
glm::dvec3 get_future_movement() const;
void move_set(double distance);
double MED[9][8]; // lista zmiennych do debugowania hamulca ED
static std::string const MED_labels[ 8 ];

View File

@@ -351,7 +351,6 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::generictoggle8, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle9, &TTrain::OnCommand_generictoggle },
{ user_command::vehiclemove, &TTrain::OnCommand_vehiclemove },
{ user_command::vehiclemoveforwards, &TTrain::OnCommand_vehiclemoveforwards },
{ user_command::vehiclemovebackwards, &TTrain::OnCommand_vehiclemovebackwards },
{ user_command::vehicleboost, &TTrain::OnCommand_vehicleboost },
@@ -5008,38 +5007,18 @@ void TTrain::OnCommand_cabchangebackward( TTrain *Train, command_data const &Com
}
}
void TTrain::vehiclemove(float distance) {
TDynamicObject *d = DynamicObject;
while( d ) {
d->Move( distance * d->DirectionGet() );
d = d->Next(); // pozostałe też
}
d = DynamicObject->Prev();
while( d ) {
d->Move( distance * d->DirectionGet() );
d = d->Prev(); // w drugą stronę też
}
}
void TTrain::OnCommand_vehiclemove(TTrain *Train, const command_data &Command) {
if (Command.action == GLFW_RELEASE || !DebugModeFlag)
return;
Train->vehiclemove(Command.param1);
}
void TTrain::OnCommand_vehiclemoveforwards(TTrain *Train, const command_data &Command) {
if (Command.action == GLFW_RELEASE || !DebugModeFlag)
return;
Train->vehiclemove(100.0);
Train->DynamicObject->move_set(100.0);
}
void TTrain::OnCommand_vehiclemovebackwards(TTrain *Train, const command_data &Command) {
if (Command.action == GLFW_RELEASE || !DebugModeFlag)
return;
Train->vehiclemove(-100.0);
Train->DynamicObject->move_set(-100.0);
}
void TTrain::OnCommand_vehicleboost(TTrain *Train, const command_data &Command) {

View File

@@ -349,14 +349,10 @@ class TTrain
static void OnCommand_cabchangeforward( TTrain *Train, command_data const &Command );
static void OnCommand_cabchangebackward( TTrain *Train, command_data const &Command );
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
static void OnCommand_vehiclemove( TTrain *Train, command_data const &Command );
static void OnCommand_vehiclemoveforwards( TTrain *Train, command_data const &Command );
static void OnCommand_vehiclemovebackwards( TTrain *Train, command_data const &Command );
static void OnCommand_vehicleboost( TTrain *Train, command_data const &Command );
void vehiclemove(float distance);
// members
TDynamicObject *DynamicObject { nullptr }; // przestawia zmiana pojazdu [F5]
TMoverParameters *mvControlled { nullptr }; // człon, w którym sterujemy silnikiem

View File

@@ -236,7 +236,6 @@ commanddescription_sequence Commands_descriptions = {
{ "setdatetime", command_target::simulation, command_mode::oneoff },
{ "setweather", command_target::simulation, command_mode::oneoff },
{ "settemperature", command_target::simulation, command_mode::oneoff },
{ "vehiclemove", command_target::vehicle, command_mode::oneoff },
{ "vehiclemoveforwards", command_target::vehicle, command_mode::oneoff },
{ "vehiclemovebackwards", command_target::vehicle, command_mode::oneoff },
{ "vehicleboost", command_target::vehicle, command_mode::oneoff },
@@ -249,6 +248,7 @@ commanddescription_sequence Commands_descriptions = {
{ "setlight", command_target::simulation, command_mode::oneoff },
{ "insertmodel", command_target::simulation, command_mode::oneoff },
{ "deletemodel", command_target::simulation, command_mode::oneoff },
{ "trainsetmove", command_target::simulation, command_mode::oneoff },
};
} // simulation

View File

@@ -230,7 +230,6 @@ enum class user_command {
setdatetime,
setweather,
settemperature,
vehiclemove,
vehiclemoveforwards,
vehiclemovebackwards,
vehicleboost,
@@ -243,6 +242,7 @@ enum class user_command {
setlight,
insertmodel,
deletemodel,
dynamicmove,
none = -1
};

View File

@@ -203,6 +203,12 @@ void state_manager::process_commands() {
}
}
if (commanddata.command == user_command::dynamicmove) {
TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload);
if (vehicle)
vehicle->move_set(commanddata.param1);
}
if (DebugModeFlag) {
if (commanddata.command == user_command::timejump) {
Time.update(commanddata.param1);

View File

@@ -117,6 +117,8 @@ init() {
"Vehicle parameters",
"Radiostop",
"Reset trainset",
"Move +500m",
"Move -500m",
"master controller",
"master controller",
@@ -320,6 +322,8 @@ init() {
u8"Parametry pojazdu",
u8"Radiostop",
u8"Zresetuj skład",
u8"Przesuń +500m",
u8"Przesuń -500m",
u8"nastawnik jazdy",
u8"nastawnik jazdy",

View File

@@ -106,6 +106,8 @@ enum string {
vehicleparams_window,
vehicleparams_radiostop,
vehicleparams_reset,
vehicleparams_move500f,
vehicleparams_move500b,
cab_mainctrl,
cab_jointctrl,

View File

@@ -18,7 +18,7 @@ ui::map_panel::map_panel() : ui_panel(LOC_STR(ui_map), false)
gl::shader frag("map.frag");
m_track_shader = std::unique_ptr<gl::program>(new gl::program({vert, frag}));
if (GLAD_GL_EXT_geometry_shader) {
if (!Global.gfx_usegles || GLAD_GL_EXT_geometry_shader) {
gl::shader poi_frag("map_poi.frag");
gl::shader poi_geom("map_poi.geom");
m_poi_shader = std::unique_ptr<gl::program>(new gl::program({vert, poi_frag, poi_geom}));
@@ -123,7 +123,7 @@ void ui::map_panel::render_map_texture(glm::mat4 transform, glm::vec2 surface_si
scene_ubo->update(scene_ubs);
GfxRenderer.Draw_Geometry(m_switch_handles.begin(), m_switch_handles.end());
if (GLAD_GL_EXT_geometry_shader) {
if (!Global.gfx_usegles || GLAD_GL_EXT_geometry_shader) {
GfxRenderer.Bind_Texture(0, m_icon_atlas);
m_poi_shader->bind();
scene_ubs.scene_extra = glm::vec3(1.0f / (surface_size / 200.0f), 1.0f);

View File

@@ -186,9 +186,17 @@ void ui::vehicleparams_panel::render_contents()
if (ImGui::Button(LOC_STR(vehicleparams_radiostop)))
m_relay.post(user_command::radiostop, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition());
ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_reset)))
m_relay.post(user_command::resettrainset, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_move500f)))
m_relay.post(user_command::dynamicmove, 500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_move500b)))
m_relay.post(user_command::dynamicmove, -500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine();
}