moving_obstacle.h 1.8 KB
Newer Older
pitiot's avatar
maj  
pitiot committed
1 2 3 4 5 6 7
#ifndef M_MOVING_OBSTACLE_H
#define M_MOVING_OBSTACLE_H

#include <iostream>

#include "utils.h"
#include "env_map.h"
8
#include <set>
pitiot's avatar
maj  
pitiot committed
9 10 11 12
#include "Algo/MovingObjects/particle_cell_2D_memo.h"
using namespace std;
PFP::VEC3 rotate (PFP::VEC3 pos1, PFP::VEC3 center, float angle);
float get_angle (PFP::VEC3 v1, PFP::VEC3 v2);
13
PFP::VEC3 get_center (ArticulatedObstacle * art, int index);
pitiot's avatar
maj  
pitiot committed
14 15 16 17 18
class Simulator ;

class MovingObstacle
{
public:
19
	MovingObstacle(Simulator* sim, int index, std::vector<PFP::VEC3> pos, std::vector<VEC3> goals,bool spin, ArticulatedObstacle * art=NULL, int ind2=-1);
pitiot's avatar
maj  
pitiot committed
20
	bool test_opposition(VEC3 o, VEC3 p1, VEC3 p2);
pitiot's avatar
pitiot committed
21 22 23
//	void contournerBatiment();
	void updateAgentNeighbors() ;
	void updateObstacleNeighbors() ;
pitiot's avatar
maj  
pitiot committed
24 25
	bool is_inside (VEC3 p);
	void computePrefVelocity();
pitiot's avatar
pitiot committed
26
	void computeNewVelocity();
27
	std::vector<Dart> getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1);
pitiot's avatar
maj  
pitiot committed
28 29 30 31

	void update();

	unsigned int nbVertices;
32 33
	CGoGN::Algo::MovingObjects::ParticleCell2DMemo<PFP> *registering_part;
	std::vector<PFP::VEC3> vertices;
pitiot's avatar
maj  
pitiot committed
34 35 36 37 38 39 40
	float gravity_dist;
	VEC3 center;
	int nb_agents_voisins;
	int nb_register_cells;
	int index;
	int max_x_ind;
	int min_x_ind;
41

pitiot's avatar
maj  
pitiot committed
42
	Obstacle* * obstacles_;
43 44
	std::vector<Dart> * belonging_cells;
	std::vector<Dart> * neighbor_cells;
45
	std::set<Dart> general_belonging;
46
	VEC3 front;
pitiot's avatar
maj  
pitiot committed
47 48

	VEC3 finalGoal;
pitiot's avatar
pitiot committed
49
	float angle;
Pierre Kraemer's avatar
Pierre Kraemer committed
50
//	Dart finalDart;
pitiot's avatar
pitiot committed
51 52 53 54
	std::vector<VEC3> goals_ ;

	unsigned int curGoal_;

Pierre Kraemer's avatar
Pierre Kraemer committed
55
//	static float neighborDistSq_;
pitiot's avatar
maj  
pitiot committed
56 57
	static unsigned int maxNeighbors_;
	static float detectionFixedObst;
pitiot's avatar
pitiot committed
58 59
	static float neighborDist_;
	static float neighborDistSq_;
pitiot's avatar
maj  
pitiot committed
60 61 62 63 64 65 66 67
	static float maxSpeed_;
	float obstacle_range;
	static float timeHorizonObst_;
	float velocity_factor;
	VEC3 velocity_;
	VEC3 newVelocity_;
	VEC3 prefVelocity_;
	Simulator* sim_;
pitiot's avatar
pitiot committed
68
	bool spinning;
69 70
	ArticulatedObstacle * parent;
	int index_parent;
pitiot's avatar
maj  
pitiot committed
71 72 73
};

#endif