From: <sv...@ww...> - 2004-12-14 22:08:30
|
Author: delta Date: 2004-12-14 14:08:23 -0800 (Tue, 14 Dec 2004) New Revision: 1380 Modified: trunk/CSP/CSPSim/Include/Systems/AircraftInputSystem.h trunk/CSP/CSPSim/Include/Systems/AircraftSimpleFCS.h trunk/CSP/SimCore/Battlefield/LocalBattlefield.cpp Log: * Minor anti-warnings changes in SimCore/Battlefield/LocalBattlefield.cpp. * Slighty flatten the joystick inputs. * Other minor changes. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1380 Modified: trunk/CSP/CSPSim/Include/Systems/AircraftInputSystem.h =================================================================== --- trunk/CSP/CSPSim/Include/Systems/AircraftInputSystem.h 2004-12-14 10:19:14 UTC (rev 1379) +++ trunk/CSP/CSPSim/Include/Systems/AircraftInputSystem.h 2004-12-14 22:08:23 UTC (rev 1380) @@ -63,7 +63,7 @@ } m_Channel->value() = simdata::clampTo(v, m_Minimum, m_Maximum); } - double getValue() { + double getValue() const { return m_Channel->value(); } void setValue(double value) { Modified: trunk/CSP/CSPSim/Include/Systems/AircraftSimpleFCS.h =================================================================== --- trunk/CSP/CSPSim/Include/Systems/AircraftSimpleFCS.h 2004-12-14 10:19:14 UTC (rev 1379) +++ trunk/CSP/CSPSim/Include/Systems/AircraftSimpleFCS.h 2004-12-14 22:08:23 UTC (rev 1380) @@ -29,9 +29,11 @@ #include <algorithm> #include <cmath> -#include <System.h> +#include <SimData/Math.h> + #include <SimCore/Util/Log.h> +#include <System.h> class AircraftSimpleFCS: public System { @@ -61,10 +63,16 @@ void registerOutput(Bus *bus, std::string const &name) { b_Output = bus->registerLocalDataChannel(name, 0.0); } - void update(double dt) { + // experiment a poor flatting function + virtual double flat(double x) const { + double abs_x = abs(x); + double scale = x*x*(3.0 - 2.0*abs_x); + return scale * x; + } + virtual void update(double dt) { double input = 0.0; double output = b_Output->value(); - if (b_Input.valid()) input = b_Input->value() * m_Limit; + if (b_Input.valid()) input = flat(b_Input->value()) * m_Limit; double smooth = std::min(1.0, 10.0*std::abs(output-input)); if (output < input) { output = std::min(output + smooth*m_Rate*dt, m_Limit1); Modified: trunk/CSP/SimCore/Battlefield/LocalBattlefield.cpp =================================================================== --- trunk/CSP/SimCore/Battlefield/LocalBattlefield.cpp 2004-12-14 10:19:14 UTC (rev 1379) +++ trunk/CSP/SimCore/Battlefield/LocalBattlefield.cpp 2004-12-14 22:08:23 UTC (rev 1380) @@ -173,7 +173,7 @@ * @param interval The interval between updates, in seconds. * @param detail The level of detail for updates sent to this peer (0-9). */ - void setUpdateParameters(PeerId id, double interval, int detail); + void setUpdateParameters(PeerId id, double interval, simdata::uint16 detail); }; @@ -755,7 +755,7 @@ // finally, send all pending updates for (int i = 0; i < target_count; ++i) { const int detail = targets[i] >> 24; - const int id = targets[i] & 0xffffff; + const PeerId id = static_cast<PeerId>(targets[i] & 0xffffff); simnet::NetworkMessage::Ref msg = m_DetailCache[detail].msg; if (msg.valid()) { m_Connection->send(msg, static_cast<PeerId>(id)); @@ -768,7 +768,7 @@ return (m_PeerUpdates[0].next_update - m_UpdateTime) * 1e-3; } -void LocalBattlefield::UnitUpdateProxy::setUpdateParameters(PeerId id, double interval, int detail) { +void LocalBattlefield::UnitUpdateProxy::setUpdateParameters(PeerId id, double interval, simdata::uint16 detail) { assert(detail >= 0 && detail < DETAIL_LEVELS); simdata::uint16 interval_ms = static_cast<simdata::uint16>(interval * 1000.0); const unsigned n = m_PeerUpdates.size(); @@ -821,7 +821,7 @@ // 2 = 3.2-6.4 km // 1 = 6.4-12.8 km // 0 = >12.8 km - int detail = std::max(0, 9 - static_cast<int>(1.4427 * log(std::max(1.0, distance / 25.0)))); + simdata::uint16 detail = static_cast<simdata::uint16>(std::max(0, 9 - static_cast<int>(1.4427 * log(std::max(1.0, distance / 25.0))))); m_UpdateProxy->setUpdateParameters(id, interval, detail); } |