-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFormationWorld.h
102 lines (74 loc) · 2.16 KB
/
FormationWorld.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef FormationWorld_h
#define FormationWorld_h
#include <unordered_map>
#include "fastmath.h"
#include "Vec2.h"
#include "geom2D.h"
#include "HashMap2D.h"
#include "Body2D.h"
#include "TileBuffer2D.h"
#include "Ruler2DFast.h"
#include "TerrainCubic.h"
#include "FormationTacticsCommon.h"
#include "Formation.h"
#include "BattleLine.h"
#include "Faction.h"
#include "geom2D.h"
/*
class TargetArea{ public:
double rateOfFire;
SoldierType* type = 0; //
Formation* from = 0;
Formation* attached = 0;
Ellipse2D spot;
double getShotDensity(const Vec2d& p){
double dens = spot.pointDistInterp(p);
};
}
*/
class FormationWorld{
public:
//std::vector<BattleLine*> battleLines;
std::vector<Formation*> formations;
std::vector<Faction*> factions;
std::vector<SoldierType> soldierTypes;
//std::unordered_map<std::string,SoldierType*> name2soldierType;
SoldierTypeDict name2soldierType;
double RmaxInteract = 1.5;
Ruler2DFast colruler;
TileBuffer2D<Soldier*,16,16,64> colbuf;
TerrainCubic terrain;
int nSoldierInteractions = 0;
int nSoldiers = 0;
//HashMap2D<Particle2D> map;
double dt_frame = 0.1;
int per_frame = 1;
double damping = 0.2;
double damp;
double dt;
void init();
void update();
void simulationStep( double dt );
int formationInteractions( );
int formationInteractions_buff( );
void refreshFormations( );
int loadSoldierTypes( char * fname );
void updateSoldierTypeMap();
//void assembleForces( ULONG i );
//void assembleForces_offside( ULONG i, ULONG j, UINT ni, Particle2D** buf_i );
//bool moveParticle ( Particle2D* pi );
inline void setSimParams( double dt_frame_, double per_frame_, double damping_ ){
dt_frame = dt_frame_;
per_frame = per_frame_;
damping = damping_;
evalAuxSimParams();
//printf( " dt_frame, per_frame, dt, damp " );
}
inline void evalAuxSimParams(){
const double dampMin = 0.5;
dt = dt_frame / per_frame;
damp = ( 1 - damping * dt );
if( damp < dampMin ){ damp = dampMin; }
};
};
#endif