42 if (!m_start_spline || !m_stop_spline)
47 float calculated_output = m_last_output;
48 float last_output = m_last_output;
50 float rel_diff = fabs(cmd_input) - fabs(last_output);
52 float abs_diff = cmd_input - last_output;
54 if (fabs(abs_diff) < 0.002)
59 const float start_factor = m_start_delay * m_time;
60 const float stop_factor = m_stop_delay * m_time;
65 calculated_output = last_output + this->CalculateCmdOutput(start_factor, m_start_spline);
68 calculated_output = last_output + this->CalculateCmdOutput(stop_factor, m_stop_spline);
69 if (calculated_output > cmd_input)
71 calculated_output = cmd_input;
77 calculated_output = last_output - this->CalculateCmdOutput(start_factor, m_start_spline);
79 calculated_output = last_output - this->CalculateCmdOutput(stop_factor, m_stop_spline);
80 if (calculated_output < cmd_input)
81 calculated_output = cmd_input;
83 m_last_output = calculated_output;
84 return calculated_output;
91 m_start_delay = start_delay;
93 RoR::LogFormat(
"[RoR|Inertia] Warning: Start Delay '%f', should be >0, using 0", start_delay);
96 m_stop_delay = stop_delay;
98 RoR::LogFormat(
"[RoR|Inertia] Warning: Stop Delay '%f', should be >0, using 0", start_delay);
101 m_start_function = start_function;
102 Ogre::SimpleSpline* start_spline = cfg.
GetSplineByName(start_function);
103 if (start_spline !=
nullptr)
104 m_start_spline = start_spline;
106 RoR::LogFormat(
"[RoR|Inertia] Start Function '%s' not found", start_function.c_str());
108 m_stop_function = stop_function;
110 if (stop_spline !=
nullptr)
111 m_stop_spline = stop_spline;
113 RoR::LogFormat(
"[RoR|Inertia] Stop Function '%s' not found", stop_function.c_str());
144 Ogre::DataStreamPtr ds = Ogre::ResourceGroupManager::getSingleton().openResource(
"inertia_models.cfg", Ogre::RGN_AUTODETECT);
145 std::string current_model;
149 Ogre::StringUtil::trim(line);
151 if (line.empty() || line[0] ==
';')
154 Ogre::StringVector args = Ogre::StringUtil::split(line,
",");
155 if (args.size() == 1)
157 current_model = line;
159 else if (args.size() == 2 && !current_model.empty())
162 if (m_splines.find(current_model) == m_splines.end())
164 m_splines[current_model] = Ogre::SimpleSpline();
168 const float point_x = Ogre::StringConverter::parseReal(args[0]);
169 const float point_y = Ogre::StringConverter::parseReal(args[1]);
172 m_splines[current_model].addPoint(Ogre::Vector3(point_x, point_y, 0.0f));
176 catch (std::exception& e)
178 RoR::LogFormat(
"[RoR|Inertia] Failed to load 'inertia_models.cfg', message: '%s'", e.what());
195 m_start_delay = start_delay;
197 RoR::LogFormat(
"[RoR|SimpleInertia] Warning: Start Delay '%f', should be >0, using 0", start_delay);
200 m_stop_delay = stop_delay;
202 RoR::LogFormat(
"[RoR|SimpleInertia] Warning: Stop Delay '%f', should be >0, using 0", start_delay);
205 Ogre::SimpleSpline* start_spline = cfg.
GetSplineByName(start_function);
206 if (start_spline !=
nullptr)
207 m_start_spline = start_spline;
209 RoR::LogFormat(
"[RoR|SimpleInertia] Start Function '%s' not found", start_function.c_str());
212 if (stop_spline !=
nullptr)
213 m_stop_spline = stop_spline;
215 RoR::LogFormat(
"[RoR|SimpleInertia] Stop Function '%s' not found", stop_function.c_str());