Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

agent.h 1.69 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
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
#ifndef M_AGENT_H
#define M_AGENT_H

#include <iostream>

#include "utils.h"
#include "env_map.h"
#include "Algo/MovingObjects/particle_cell_2D.h"

class Simulator;

class Agent
{
public:
	Agent(Simulator* sim, const VEC3& position, Dart d);

	void insertAgentNeighbor(Agent* other);
	void insertAgentNeighbor(Agent* other, float distSq);
	void removeAgentNeighbor(Agent* other);
	void updateAgentNeighbors();
	void clearAgentNeighbors();

	void insertObstacleNeighbor(Dart d);
	void removeObstacleNeighbor(Dart d);
	void updateObstacleNeighbors();
	void clearObstacleNeighbors();

	void update();
	
	void computePrefVelocity();

	void computeNewVelocity();

	bool linearProgram1(
		const std::vector<Line>& lines, unsigned int lineNo,
		float radius, const VEC3& optVelocity,
		bool directionOpt, VEC3& result
	);

	bool linearProgram2(
		const std::vector<Line>& lines, unsigned int num, float radius,
		const VEC3& optVelocity, bool directionOpt,
		VEC3& result
	);

	void linearProgram3(
		const std::vector<Line>& lines, unsigned int numObstLines,
		float radius, VEC3& result
	);

	std::multimap<float, Agent*> agentNeighbors_;
	std::multimap<float, Agent*> newAgentNeighbors_;
	
//	std::map<const Agent*, std::multimap<float, Agent*>::iterator> neighborsIt_;
	
	std::multimap<float, Dart> obstacleNeighbors_;
	std::multimap<float, Dart> newObstacleNeighbors_;
	
	CGoGN::Algo::MovingObjects::ParticleCell2D<PFP> part_;
	
	std::vector<VEC3> goals_;
	unsigned int curGoal_;
	
	size_t maxNeighbors_;
	float maxSpeed_;
	float neighborDistSq_;
	float radius_;
	float timeHorizon_;
	float timeHorizonObst_;
	float rangeSq_;
	
	VEC3 velocity_;
	VEC3 newVelocity_;
	VEC3 prefVelocity_;
	
	Simulator* sim_;
	
	bool treated;
};

#endif