FlightGear next
AIThermal.hxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: AIThermal.hxx
3 * SPDX-FileComment: AIBase-derived class creates an AI thermal. An attempt to refine the thermal shape and behaviour by WooT 2009
4 * SPDX-FileCopyrightText: Copyright (C) 2009 Patrice Poly ( WooT )
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#pragma once
9
10#include <string_view>
11
12#include "AIBase.hxx"
13#include "AIManager.hxx"
14
15#include <string>
16
17
18class FGAIThermal : public FGAIBase
19{
20public:
22 virtual ~FGAIThermal() = default;
23
24 std::string_view getTypeString(void) const override { return "thermal"; }
25 void readFromScenario(SGPropertyNode* scFileNode) override;
26
27 bool init(ModelSearchOrder searchOrder) override;
28 void bind() override;
29 void update(double dt) override;
30
31 inline void setMaxStrength(double s) { max_strength = s; };
32 inline void setDiameter(double d) { diameter = d; };
33 inline void setHeight(double h) { height = h; };
34 inline void setMaxUpdraft(double lift) { v_up_max = lift; };
35 inline void setMinUpdraft(double sink) { v_up_min = sink; };
36 inline void setR_up_frac(double r) { r_up_frac = r; };
37
38 inline double getStrength() const { return strength; };
39 inline double getDiameter() const { return diameter; };
40 inline double getHeight() const { return height; };
41 inline double getV_up_max() const { return v_up_max; };
42 inline double getV_up_min() const { return v_up_min; };
43 inline double getR_up_frac() const { return r_up_frac; };
44
45 void getGroundElev(double dt);
46
47private:
48 void Run(double dt);
49
50 double get_strength_fac(double alt_frac);
51 double max_strength{0.0};
52 double strength{0.0};
53 double diameter{0.0};
54 double height{0.0};
55 double factor{0.0};
56 double alt_rel{0.0};
57 double alt{0.0};
58 double v_up_max{0.0}; //max updraft at the user altitude and time
59 double v_up_min{0.0}; //min updraft at the user altitude and time, this is a negative number
60 double r_up_frac{0.9}; //the relative radius of the thermal where we have updraft, between 0 an 1
61 double cycle_timer{0.0};
62 double dt_count{0.0};
63 double time{0.0};
64 double xx{0.0};
65 double ground_elev_ft{0.0}; // ground level in ft
66
67 bool do_agl_calc = false;
68 bool is_forming = false;
69 bool is_formed = false;
70 bool is_dying = false;
71 bool is_dead = false;
72
73 SGPropertyNode_ptr _surface_wind_from_deg_node;
74 SGPropertyNode_ptr _surface_wind_speed_node;
75 SGPropertyNode_ptr _aloft_wind_from_deg_node;
76 SGPropertyNode_ptr _aloft_wind_speed_node;
77};
FGAIBase(object_type ot, bool enableHot)
Definition AIBase.cxx:146
ModelSearchOrder
Definition AIBase.hxx:63
void setHeight(double h)
Definition AIThermal.hxx:33
double getDiameter() const
Definition AIThermal.hxx:39
void setMaxStrength(double s)
Definition AIThermal.hxx:31
void readFromScenario(SGPropertyNode *scFileNode) override
Definition AIThermal.cxx:32
virtual ~FGAIThermal()=default
double getR_up_frac() const
Definition AIThermal.hxx:43
void bind() override
Definition AIThermal.cxx:60
void getGroundElev(double dt)
double getStrength() const
Definition AIThermal.hxx:38
double getHeight() const
Definition AIThermal.hxx:40
void setDiameter(double d)
Definition AIThermal.hxx:32
void setMaxUpdraft(double lift)
Definition AIThermal.hxx:34
double getV_up_max() const
Definition AIThermal.hxx:41
double getV_up_min() const
Definition AIThermal.hxx:42
std::string_view getTypeString(void) const override
Definition AIThermal.hxx:24
void update(double dt) override
Definition AIThermal.cxx:73
void setR_up_frac(double r)
Definition AIThermal.hxx:36
bool init(ModelSearchOrder searchOrder) override
Definition AIThermal.cxx:44
void setMinUpdraft(double sink)
Definition AIThermal.hxx:35