54 for(std::vector<Instance*>::iterator i = instances.begin(); i != instances.end(); ++i) {
55 if ((*i)->isMultiCell()) {
61 if (!rotchange && !locchange && !celchange && !blochange) {
65 int32_t oldrotation = (*i)->getOldRotation();
66 int32_t newrotation = (*i)->getRotation();
68 oldrotation = newrotation;
71 if (rotchange || locchange || celchange) {
73 (*i)->updateMultiInstances();
75 if (rotchange || celchange) {
80 oldmc = (*i)->getOldLocationRef().getLayerCoordinates();
81 newmc = (*i)->getLocationRef().getLayerCoordinates();
94 const std::vector<Instance*>& multiinstances = (*i)->getMultiInstances();
95 std::vector<Instance*>::const_iterator it = multiinstances.begin();
96 for (; it != multiinstances.end(); ++it) {
98 std::vector<ModelCoordinate> coordinates =
99 cg->
toMultiCoordinates(oldmc, (*it)->getObject()->getMultiPartCoordinates(oldrotation));
100 std::vector<ModelCoordinate>::iterator mcit = coordinates.begin();
101 for (; mcit != coordinates.end(); ++mcit) {
108 coordinates = cg->
toMultiCoordinates(newmc, (*it)->getObject()->getMultiPartCoordinates(newrotation));
109 mcit = coordinates.begin();
110 for (; mcit != coordinates.end(); ++mcit) {
122 if (oldcell == newcell) {
135 if ((*i)->getObject()->isMultiPart()) {
141 mc = (*i)->getLocationRef().getLayerCoordinates();
155 oldmc = (*i)->getOldLocationRef().getLayerCoordinates();
156 newmc = (*i)->getLocationRef().getLayerCoordinates();
166 if (oldcell == newcell) {
198 std::vector<Instance*>::const_iterator it = multiinstances.begin();
199 for (; it != multiinstances.end(); ++it) {
200 std::vector<ModelCoordinate> coordinates =
202 std::vector<ModelCoordinate>::iterator mcit = coordinates.begin();
203 for (; mcit != coordinates.end(); ++mcit) {
235 std::vector<Instance*>::const_iterator it = multiinstances.begin();
236 for (; it != multiinstances.end(); ++it) {
237 std::vector<ModelCoordinate> coordinates =
239 std::vector<ModelCoordinate>::iterator mcit = coordinates.begin();
240 for (; mcit != coordinates.end(); ++mcit) {
265 for (std::set<Cell*>::iterator i =
m_cells.begin(); i !=
m_cells.end(); ++i) {
278 std::set<Cell*>::iterator i =
m_cells.find(cell);
286 const std::set<Cell*>& cells = zone->
getCells();
287 m_cells.insert(cells.begin(), cells.end());
288 for (std::set<Cell*>::const_iterator it = cells.begin(); it != cells.end(); ++it) {
289 (*it)->setZone(
this);
311 std::vector<Cell*> transitions;
312 std::set<Cell*>::iterator it =
m_cells.begin();
313 for (; it !=
m_cells.end(); ++it) {
319 if (layer == (*it)->getLayer()) {
320 transitions.push_back(*it);
323 transitions.push_back(*it);
352 const std::vector<Cell*>& neighbors = cell->
getNeighbors();
353 std::vector<Cell*>::const_iterator it = neighbors.begin();
354 for (; it != neighbors.end(); ++it) {
355 Zone* z = (*it)->getZone();
373 m_defaultCostMulti(1.0),
374 m_defaultSpeedMulti(1.0),
376 m_blockingUpdate(false),
380 m_searchNarrow(true),
381 m_staticSize(false) {
396 if (!interacts.empty()) {
397 std::vector<Layer*>::const_iterator layit = interacts.begin();
398 for(; layit != interacts.end(); ++layit) {
400 (*layit)->getMinMaxCoordinates(min, max,
m_layer);
425 if (!interacts.empty()) {
426 std::vector<Layer*>::const_iterator layit = interacts.begin();
427 for(; layit != interacts.end(); ++layit) {
439 std::vector<Zone*>::iterator it =
m_zones.begin();
440 for (; it !=
m_zones.end(); ++it) {
454 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
455 for (; it !=
m_cells.end(); ++it) {
456 std::vector<Cell*>::iterator cit = (*it).begin();
457 for (; cit != (*it).end(); ++cit) {
491 std::vector<std::vector<Cell*> > cells;
494 cells[i].resize(h, NULL);
505 if (old_x < 0 || old_x >= static_cast<int32_t>(
m_width) || old_y < 0 || old_y >= static_cast<int32_t>(
m_height)) {
506 int32_t coordId = x + y * w;
510 std::list<Instance*> cell_instances;
512 if (!interacts.empty()) {
514 std::vector<Layer*>::const_iterator it = interacts.begin();
515 std::list<Instance*> interact_instances;
516 for(; it != interacts.end(); ++it) {
521 (*it)->getInstanceTree()->findInstances(inter_mc, 0, 0, interact_instances);
522 if (!interact_instances.empty()) {
523 cell_instances.insert(cell_instances.end(), interact_instances.begin(), interact_instances.end());
524 interact_instances.clear();
528 if (!cell_instances.empty()) {
534 cell =
m_cells[
static_cast<uint32_t>(old_x)][static_cast<uint32_t>(old_y)];
535 m_cells[
static_cast<uint32_t>(old_x)][static_cast<uint32_t>(old_y)] = NULL;
537 int32_t coordId = x + y * w;
544 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
545 for (; it !=
m_cells.end(); ++it) {
546 std::vector<Cell*>::iterator cit = (*it).begin();
547 for (; cit != (*it).end(); ++cit) {
563 for (; it !=
m_cells.end(); ++it) {
564 std::vector<Cell*>::iterator cit = (*it).begin();
565 for (; cit != (*it).end(); ++cit) {
566 int32_t cellZ = (*cit)->getLayerCoordinates().z;
567 std::vector<ModelCoordinate> coordinates;
569 for (std::vector<ModelCoordinate>::iterator mi = coordinates.begin(); mi != coordinates.end(); ++mi) {
571 if (*cit == c || !c) {
579 (*cit)->addNeighbor(c);
597 std::list<Instance*> cell_instances;
599 if (!interacts.empty()) {
601 std::vector<Layer*>::const_iterator it = interacts.begin();
602 std::list<Instance*> interact_instances;
603 for(; it != interacts.end(); ++it) {
608 (*it)->getInstanceTree()->findInstances(inter_mc, 0, 0, interact_instances);
609 if (!interact_instances.empty()) {
610 cell_instances.insert(cell_instances.end(), interact_instances.begin(), interact_instances.end());
611 interact_instances.clear();
615 if (!cell_instances.empty()) {
622 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
623 for (; it !=
m_cells.end(); ++it) {
624 std::vector<Cell*>::iterator cit = (*it).begin();
625 for (; cit != (*it).end(); ++cit) {
628 std::vector<ModelCoordinate> coordinates;
630 for (std::vector<ModelCoordinate>::iterator mi = coordinates.begin(); mi != coordinates.end(); ++mi) {
632 if (*cit == c || !c) {
639 (*cit)->addNeighbor(c);
649 for (; it !=
m_cells.end(); ++it) {
650 std::vector<Cell*>::iterator cit = (*it).begin();
651 for (; cit != (*it).end(); ++cit) {
661 std::stack<Cell*> cellstack;
662 cellstack.push(cell);
663 while(!cellstack.empty()) {
664 Cell* c = cellstack.top();
668 const std::vector<Cell*>& neighbors = c->
getNeighbors();
669 for (std::vector<Cell*>::const_iterator nit = neighbors.begin(); nit != neighbors.end(); ++nit) {
683 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
684 for (; it !=
m_cells.end(); ++it) {
685 std::vector<Cell*>::iterator cit = (*it).begin();
686 for (; cit != (*it).end(); ++cit) {
687 (*cit)->updateCellInfo();
710 if (x < 0 || x >= static_cast<int32_t>(
m_width) || y < 0 || y >= static_cast<int32_t>(
m_height)) {
757 std::list<Instance*> interact_instances;
759 if (!interact_instances.empty()) {
785 std::list<Instance*> interact_instances;
787 if (!interact_instances.empty()) {
789 for (std::list<Instance*>::iterator it = interact_instances.begin(); it != interact_instances.end(); ++it) {
829 if (x < 0 || x >= static_cast<int32_t>(
m_width) || y < 0 || y >= static_cast<int32_t>(
m_height)) {
837 return newcoords.
x + newcoords.
y*
m_width;
867 std::vector<Cell*> cells;
869 for (std::vector<ModelCoordinate>::iterator it = coords.begin(); it != coords.end(); ++it) {
884 std::vector<Cell*> cells;
888 for (; current.
y < target.
y; ++current.
y) {
890 for (; current.
x < target.
x; ++current.
x) {
901 std::vector<Cell*> cells;
903 uint16_t radiusp2 = (radius+1) * radius;
907 for (; current.
y < center.
y; current.
y++) {
908 current.
x = center.
x-radius;
909 for (; current.
x < center.
x; current.
x++) {
915 if (distance <= radiusp2) {
918 current.
x = center.
x + dx;
920 if (c) cells.push_back(c);
922 current.
y = center.
y + dy;
924 if (c) cells.push_back(c);
926 current.
x = center.
x-dx;
928 if (c) cells.push_back(c);
930 current.
y = center.
y-dy;
936 current.
x = center.
x;
937 current.
y = center.
y-radius;
938 for (; current.
y <= target.
y; current.
y++) {
940 if (c) cells.push_back(c);
943 current.
y = center.
y;
944 current.
x = center.
x-radius;
945 for (; current.
x <= target.
x; current.
x++) {
947 if (c) cells.push_back(c);
953 std::vector<Cell*> cells;
956 int32_t s = (sangle + 360) % 360;
957 int32_t e = (eangle + 360) % 360;
958 bool greater = (s > e) ?
true :
false;
959 for (std::vector<Cell*>::iterator it = tmpCells.begin(); it != tmpCells.end(); ++it) {
962 if (angle >= s || angle <= e) {
963 cells.push_back(*it);
966 if (angle >= s && angle <= e) {
967 cells.push_back(*it);
975 std::pair<std::map<std::string, double>::iterator,
bool> insertiter;
976 insertiter =
m_costsTable.insert(std::pair<std::string, double>(costId, cost));
977 if (insertiter.second ==
false) {
978 double& old_cost = insertiter.first->second;
984 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
992 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1000 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1008 std::list<std::string> costs;
1009 std::map<std::string, double>::iterator it =
m_costsTable.begin();
1011 costs.push_back((*it).first);
1025 for (; it != result.second; ++it) {
1026 if ((*it).second == cell) {
1030 m_costsToCells.insert(std::pair<std::string, Cell*>(costId, cell));
1035 std::vector<Cell*>::const_iterator it = cells.begin();
1036 for (; it != cells.end(); ++it) {
1044 if ((*it).second == cell) {
1055 for (; it != result.second; ++it) {
1056 if ((*it).second == cell) {
1064 std::vector<Cell*>::const_iterator it = cells.begin();
1065 for (; it != cells.end(); ++it) {
1071 std::vector<Cell*> cells;
1074 for (; it != result.second; ++it) {
1075 cells.push_back((*it).second);
1081 std::vector<std::string> costs;
1084 if ((*it).second == cell) {
1085 costs.push_back((*it).first);
1094 for (; it != result.second; ++it) {
1095 if ((*it).second == cell) {
1169 std::pair<std::map<Cell*, double>::iterator,
bool> insertiter =
1171 if (insertiter.second ==
false) {
1172 double& old = insertiter.first->second;
1199 std::pair<std::map<Cell*, double>::iterator,
bool> insertiter =
1201 if (insertiter.second ==
false) {
1202 double& old = insertiter.first->second;
1238 std::vector<Cell*> cells;
1243 if (trans->
m_layer == layer) {
1244 cells.push_back(*it);
1257 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1258 if ((*i)->getId() == id) {
1279 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1280 if ((*i)->getId() == id) {
1295 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1311 std::stack<Cell*> cellstack;
1312 const std::vector<Cell*>& neighbors = cell->
getNeighbors();
1313 for (std::vector<Cell*>::const_iterator nit = neighbors.begin(); nit != neighbors.end(); ++nit) {
1322 while(!cellstack.empty()) {
1323 Cell* c = cellstack.top();
1333 for (std::vector<Cell*>::const_iterator nit = neigh.begin(); nit != neigh.end(); ++nit) {
1348 if (!zone1 || !zone2) {
1351 Zone* addZone = zone2;
1352 Zone* oldZone = zone1;
1362 std::pair<std::set<Cell*>::iterator,
bool> insertiter =
m_narrowCells.insert(cell);
1363 if (insertiter.second) {
1397 m_cellAreas.insert(std::pair<std::string, Cell*>(
id, cell));
1401 std::vector<Cell*>::const_iterator it = cells.begin();
1402 for (; it != cells.end(); ++it) {
1410 if ((*it).second == cell) {
1421 for (; it != result.second; ++it) {
1422 if ((*it).second == cell) {
1430 std::vector<Cell*>::const_iterator it = cells.begin();
1431 for (; it != cells.end(); ++it) {
1449 std::vector<std::string> areas;
1450 std::string last(
"");
1453 if (last != (*it).first) {
1455 areas.push_back(last);
1462 std::vector<std::string> areas;
1465 if ((*it).second == cell) {
1466 areas.push_back((*it).first);
1473 std::vector<Cell*> cells;
1476 for (; it != result.second; ++it) {
1477 cells.push_back((*it).second);
1485 for (; it != result.second; ++it) {
1486 if ((*it).second == cell) {
1497 Rect newsize(min.
x, min.
y, max.
x, max.
y);
1500 if (!interacts.empty()) {
1501 std::vector<Layer*>::const_iterator layit = interacts.begin();
1502 for(; layit != interacts.end(); ++layit) {
1504 (*layit)->getMinMaxCoordinates(min, max,
m_layer);
1505 newsize.
w = std::max(max.
x, newsize.
w);
1506 newsize.
h = std::max(max.
y, newsize.
h);
1507 newsize.
x = std::min(min.
x, newsize.
x);
1508 newsize.
y = std::min(min.
y, newsize.
y);
void setZoneProtected(bool protect)
Mark zone on this cell as protected.
virtual double getAdjacentCost(const ModelCoordinate &curpos, const ModelCoordinate &target)=0
Returns distance const from curpos to target point only cells adjacent to curpos are considered in th...
void removeCellsFromCost(const std::string &costId, const std::vector< Cell * > &cells)
Removes cells from a cost identifier.
void removeZone(Zone *zone)
Removes zone.
uint32_t getHeight()
Returns height of the CellCache.
void setStaticSize(bool staticSize)
Sets the cache size to static so that automatic resize is disabled.
virtual std::vector< ModelCoordinate > toMultiCoordinates(const ModelCoordinate &position, const std::vector< ModelCoordinate > &orig, bool reverse=false)=0
Returns point vector with coordinates for a multi object.
StringCellMultimap::iterator StringCellIterator
double getSpeedMultiplier(Cell *cell)
Returns speed multiplier for the cell.
uint32_t m_width
cache width
double getCostMultiplier()
Returns the current cell cost.
void updateMultiInstances()
Updates the visual positions of all instances in case this is a multi object.
int32_t getAngleBetween(const Location &loc1, const Location &loc2)
Gets angle of vector defined by given locations.
void removeInteractOnRuntime(Layer *interact)
Removes a interact layer from the CellCache on runtime and sets all needed layer properties.
bool isUpdated()
Gets whether the CellCache need to be updated.
void unregisterCost(const std::string &costId)
Removes a cost with the given id.
void setLayerCoordinates(const ModelCoordinate &coordinates)
Sets "cell precise" layer coordinates to this location.
Layer * m_layer
target layer
Layer * m_layer
walkable layer
double getCostMultiplier(Cell *cell)
Returns cost multiplier for the cell.
int32_t convertCoordToInt(const ModelCoordinate &coord) const
Convertes coordinate to unique identifier.
void addCell(Cell *cell)
Adds a cell to this zone.
void setSpeedMultiplier(Cell *cell, double multi)
Sets speed multiplier for the cell.
void resize()
Checks the layer size and if the size is different with current size then the cache size is adjusted...
void addInstance(Instance *instance)
Adds a instance to this cell.
int32_t getMaxNeighborZ()
Gets maximal z range for neighbors.
T h
Height of the rectangle.
std::vector< std::string > getCellCosts(Cell *cell)
Returns cost identifiers for cell.
uint32_t next(octet_iterator &it, octet_iterator end)
bool isDefaultSpeed(Cell *cell)
Gets if cell uses default speed multiplier.
void removeTransition(Cell *cell)
Removes a cell as transition.
double getSpeedMultiplier()
Returns the current cell speed.
bool isCellInArea(const std::string &id, Cell *cell)
Returns true if cell is part of the area, otherwise false.
std::set< Cell * > m_cells
cells in the zone
Layer * getLayer()
Returns layer.
Listener interface for changes happening on a cell.
std::set< Cell * > m_narrowCells
special cells which are monitored (zone split and merge)
std::vector< Cell * > getCellsInCircleSegment(const ModelCoordinate ¢er, uint16_t radius, int32_t sangle, int32_t eangle)
Returns all cells in the circle segment.
void setSearchNarrowCells(bool search)
Sets if narrow cells should be searched automatic.
void removeCellFromCost(Cell *cell)
Removes a cell from costs.
std::vector< Cell * > getCellsInRect(const Rect &rec)
Returns all cells in the rect.
StringCellMultimap m_costsToCells
holds cells for each cost
StringCellMultimap m_cellAreas
areas with assigned cells
A CellCache is an abstract depiction of one or a few layers and contains additional information...
bool m_updated
need update
bool m_blockingUpdate
indicates blocking update
void addInstances(const std::list< Instance * > &instances)
Adds instances to this cell.
void resetNarrowCells()
Resets narrow cells.
virtual ~CellCacheChangeListener()
void setDefaultCostMultiplier(double multi)
Sets default cost for this CellCache.
const std::set< Cell * > & getCells() const
Returns all cells of this zone.
void addCellToCost(const std::string &costId, Cell *cell)
Assigns a cell to a cost identifier.
bool isDefaultCost(Cell *cell)
Gets if cell uses default cost multiplier.
void addCellsToArea(const std::string &id, const std::vector< Cell * > &cells)
Adds few cell to a specific area group.
CellCache * getCellCache()
Returns the CellCache of this layer.
void setBlockingUpdate(bool update)
std::vector< std::vector< Cell * > > m_cells
static Logger _log(LM_AUDIO)
virtual void onInstanceCreate(Layer *layer, Instance *instance)
Called when some instance gets created on layer.
void registerCost(const std::string &costId, double cost)
Adds a cost with the given id and value.
std::vector< Cell * > getCellsInLine(const ModelCoordinate &pt1, const ModelCoordinate &pt2, bool blocker=false)
Returns all cells in the line.
void removeInstance(Instance *instance)
Removes a instance from this cell.
bool existsCost(const std::string &costId)
Returns if the cost for the given id exists.
void resetSpeedMultiplier(Cell *cell)
Resets the speed multiplier for the cell.
void addChangeListener(CellChangeListener *listener)
Adds new cell change listener.
double m_defaultCostMulti
default cost
bool defaultCost()
Returns if cell use default cost.
uint32_t getCellCount() const
Returns the number of cells.
std::vector< Cell * > getCostCells(const std::string &costId)
Returns cells for a cost identifier.
InstanceTree * getInstanceTree(void) const
Get the instance tree.
void removeCell(Cell *cell)
Removes a cell from this zone.
Layer * getLayer() const
Gets the layer where this location is pointing to.
void setSize(const Rect &rec)
Sets CellCache size.
uint32_t getId() const
Returns the zone identifier.
Location & getLocationRef()
Gets reference of current location of instance.
std::vector< Zone * > m_zones
zones
void removeArea(const std::string &id)
Removes a area.
ModelCoordinate getLayerCoordinates() const
Gets cell precision layer coordinates set to this location.
virtual void onLayerChanged(Layer *layer, std::vector< Instance * > &instances)
Called when some instance is changed on layer.
void removeCellFromArea(Cell *cell)
Removes the cell from all areas.
void addInteractLayer(Layer *layer)
Adds a interact layer to the walkable layer.
void setFowUpdate(bool update)
int32_t m_neighborZ
max z value for neighbors
const std::vector< Zone * > & getZones()
Returns zones of this CellCache.
virtual void onInstanceExitedCell(Cell *cell, Instance *instance)
Called when some instance exited the cell.
ModelCoordinate convertIntToCoord(const int32_t cell) const
Convertes unique identifier to coordinate.
std::map< Cell *, double > m_speedMultipliers
holds default speed multiplier, only if it is not default(1.0)
void resetCells()
Remove all cells from zone but does not alter the cells.
void unregisterAllCosts()
Removes all costs.
void getMinMaxCoordinates(ModelCoordinate &min, ModelCoordinate &max, const Layer *layer=0) const
Retrieves the minimum/maximum coordinates of instances on the layer.
double getAdjacentCost(const ModelCoordinate &adjacent, const ModelCoordinate &next)
Returns cost for movement between these two adjacent coordinates.
std::map< std::string, double > m_costsTable
holds cost table
const Rect & getSize()
Returns CellCache size.
void findInstances(const ModelCoordinate &point, int32_t w, int32_t h, InstanceList &list)
Find all instances in a given area.
void setZone(Zone *zone)
Sets zone.
Simple class to hold the data for transistions.
void removeChangeListener(LayerChangeListener *listener)
Removes associated change listener.
const std::vector< Instance * > & getMultiInstances()
Returns a vector that contains all instances of a multi object.
bool isInCellCache(const Location &location) const
Checks whether the location is in CellCache range.
double getDefaultSpeedMultiplier()
Gets default speed for this CellCache.
void removeCellsFromArea(const std::string &id, const std::vector< Cell * > &cells)
Removes few cells from a area.
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
bool isZoneProtected()
Returns whether the zone on this cell is protected.
CellCache(Layer *layer)
Constructor.
std::list< std::string > getCosts()
Returns all registered cost ids.
Zone * createZone()
Creates zone.
int32_t getRotation() const
Get the rotation offset of this instance Returns direction where instance is heading.
CellTypeInfo getCellType()
Returns blocker type.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this CellCache.
void addCellsToCost(const std::string &costId, const std::vector< Cell * > &cells)
Assigns cells to a cost identifier.
void setUpdated(bool updated)
Sets whether the CellCache need to be updated.
bool existsCostForCell(const std::string &costId, Cell *cell)
Gets if cell is assigned to cost identifier.
void splitZone(Cell *cell)
Splits zone on the cell.
Listener interface for changes happening on a layer.
bool m_searchNarrow
is automatic seach enabled
CellChangeListener * m_cellZoneListener
listener for zones
void addChangeListener(LayerChangeListener *listener)
Adds new change listener.
double m_defaultSpeedMulti
default speed
const std::vector< Cell * > & getNeighbors()
Returns the layer coordinates of this cell.
ZoneCellChangeListener(CellCache *cache)
ExactModelCoordinate & getExactLayerCoordinatesRef()
Gets reference to exact layer coordinates.
std::vector< std::string > getCellAreas(Cell *cell)
Returns all areas of a cell.
A basic cell on a CellCache.
void forceUpdate()
Updates all cells.
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
void createCells()
Creates cells for this CellCache based on the size of the assigned layer.
CellGrid * getCellGrid() const
Get the Cellgrid.
void addCell(Cell *cell)
Adds cell to this CellCache.
LayerChangeListener * m_cellListener
change listener
bool getCellSpeedMultiplier(const ModelCoordinate &cell, double &multiplier)
Returns speed value from cell.
Rect m_size
Rect holds the min and max size x = min.x, w = max.x, y = min.y, h = max.y.
void setInteract(bool interact, const std::string &id)
Sets interact for the layer.
Zone * getZone(uint32_t id)
Gets zone by identifier.
std::vector< Cell * > getAreaCells(const std::string &id)
Returns all cells of an area.
const std::vector< Layer * > & getInteractLayers()
Returns all assigned interact layer.
void changeInstance(Instance *instance)
Changes a instance on this cell.
const ModelCoordinate getLayerCoordinates() const
Returns the layer coordinates of this cell.
Zone * getZone()
Returns zone.
CellCacheChangeListener(Layer *layer)
void setDefaultSpeedMultiplier(double multi)
Sets default speed for this CellCache.
std::map< Cell *, double > m_costMultipliers
holds default cost multiplier, only if it is not default(1.0)
uint32_t m_height
cache height
virtual void onInstanceEnteredCell(Cell *cell, Instance *instance)
Called when some instance entered the cell.
void mergeZones(Zone *zone1, Zone *zone2)
Merges two zones to one.
bool m_fowUpdate
indicates fow update
bool isStaticSize()
Returns if the cache size is static.
void removeNarrowCell(Cell *cell)
Removes cell from narrow cells.
void addCellToArea(const std::string &id, Cell *cell)
Adds a cell to a specific area group.
Rect calculateCurrentSize()
Returns the current size.
void setCellId(int32_t id)
Sets the cell identifier.
std::vector< Cell * > getCellsInCircle(const ModelCoordinate ¢er, uint16_t radius)
Returns all cells in the circle.
void mergeZone(Zone *zone)
Merge two zones to one.
const std::string & getId() const
Get the id of this layer.
virtual void onBlockingChangedCell(Cell *cell, CellTypeInfo type, bool blocks)
Called when some instance changed its blocking property.
DoublePoint intPt2doublePt(Point pt)
Convert from 2D int32_t point to 2D double point.
LayerChangeListener * getCellCacheChangeListener()
Returns change listener.
void setSizeUpdate(bool update)
void setInserted(bool inserted)
Mark cell as inserted.
void removeCell(Cell *cell)
Removes cell from CellCache.
const std::vector< std::vector< Cell * > > & getCells()
Returns all cells of this CellCache.
void resetNeighbors()
Removes all neighbors from cell.
void addTransition(Cell *cell)
Adds a cell as transition.
virtual std::vector< ModelCoordinate > getCoordinatesInLine(const ModelCoordinate &start, const ModelCoordinate &end)=0
Returns point vector with coordinates for a line from start to end.
Cell * createCell(const ModelCoordinate &mc)
Creates cell on this CellCache.
std::pair< StringCellIterator, StringCellIterator > StringCellPair
void removeInteractLayer(Layer *layer)
Removes a interact layer from the walkable layer.
virtual void onInstanceDelete(Layer *layer, Instance *instance)
Called when some instance gets deleted on layer.
bool m_staticSize
is automatic size update enabled/disabled
Zone(uint32_t id)
Constructor.
void addNarrowCell(Cell *cell)
Adds cell to narrow cells.
std::vector< std::string > getAreas()
Returns all area ids.
bool m_sizeUpdate
indicates size update
double getCost(const std::string &costId)
Returns the cost value for the given id.
virtual ~ZoneCellChangeListener()
void getAccessibleCoordinates(const ModelCoordinate &curpos, std::vector< ModelCoordinate > &coordinates)
Gets the coordinates that are accesible from given point only cells adjacent to given cell are consid...
bool isInserted()
Returns whether the cell is part of a zone.
const std::set< Cell * > & getNarrowCells()
Returns narrow cells.
ExactModelCoordinate toMapCoordinates(const ModelCoordinate &layer_coords)
Transforms given point from layer coordinates to map coordinates.
double getDefaultCostMultiplier()
Gets default cost for this CellCache.
void setMaxNeighborZ(int32_t z)
Sets maximal z range for neighbors.
bool isMultiCell()
Returns true if it is multi cell otherwise false.
uint32_t getWidth()
Returns width of the CellCache.
bool existsArea(const std::string &id)
Checks whether the area exists.
bool defaultSpeed()
Returns if cell use default speed.
T w
Width of the rectangle.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this zone.
std::vector< Cell * > m_transitions
cells with transitions
int32_t getMaxIndex() const
Returns the number of cells on this CellCache.
An Instance is an "instantiation" of an Object at a Location.
bool isSearchNarrowCells()
Gets if narrow cells should be searched automatic.
void resetCostMultiplier(Cell *cell)
Resets the cost multiplier for the cell.
void addInteractOnRuntime(Layer *interact)
Adds a interact layer to the CellCache on runtime and sets all needed layer properties.
A Zone is an abstract depiction of a CellCache or of a part of it.
virtual ModelCoordinate toLayerCoordinates(const ExactModelCoordinate &map_coord)=0
Transforms given point from map coordinates to layer coordinates.
void setCostMultiplier(Cell *cell, double multi)
Sets cost multiplier for the cell.
void reset()
Resets the CellCache.