All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TrafficSimulationCell.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Navigation.h"
7 #include "Traffic.h"
8 #include "Camera.h"
9 #include "Terrain.h"
10 #include "Rendering.h"
11 #include <string>
12 
13 namespace Eegeo
14 {
15  namespace Traffic
16  {
18  {
19  public:
21  IVehicleFactory& vehicleFactory,
22  VehicleRenderablesModel* vehicleRenderables,
24  const Rendering::EnvironmentFlatteningService& environmentFlatteningService);
25 
27 
28  const TVehicleVector& GetVehicles() const { return m_vehicles; }
29  const Resources::Roads::Navigation::NavigationGraph* GetGraph() const { return m_graph; }
30 
31 
32  void ManagePopulation(bool isOutsideView);
33  void Update(float deltaSeconds, float speedMultiplier, const dv3& ecefInterestPoint);
34  void AddVehicles(const TVehicleVector vehicles);
35  void AddVehicle(IVehicle* vehicle);
36  void RemoveVehicle(IVehicle* vehicle);
37  void PopulateInitialVehicles();
38 
39  void PopulateRenderableList(const float maxDistanceForLandVehiclesSq, const dv3& cameraEcefLocation);
40 
41  void SetModelNameSuffixOnVehicles(const std::string suffix);
42 
43  void ReleaseVehicles();
44  private:
45  void SpawnVehicles();
46  void DespawnVehicles();
47 
48  void InitialiseVehicles(const dv3& ecefInterestPoint);
49  void UpdateVehicles(float deltaSeconds, float speedMultiplier, const dv3& ecefInterestPoint);
50  void PerformVehicleCollision();
51  void TransferVehiclesToOtherCells();
52  void RemoveVehicles();
53 
54  void UpdateVehicleIsUnderground(IVehicle& vehicle);
55 
56  static int CollideVehicles(TVehicleVector& vehicles, float maxRadius);
57 
59  IVehicleFactory& m_vehicleFactory;
60  TVehicleVector m_vehicles;
61  TVehicleVector m_vehiclesToTransferBetweenCells;
62  TVehicleVector m_vehiclesToDelete;
63  TVehicleVector m_vehiclesToCollide;
64  VehicleRenderablesModel* m_renderableList;
65  int m_targetVehicleCount;
66 
67  int m_collisionDebugCount;
68 
70  const Rendering::EnvironmentFlatteningService& m_environmentFlatteningService;
71  };
72  }
73 
74 }