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);
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()) {
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();
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) {
837 return newcoords.
x + newcoords.
y*
m_width;
867 std::vector<Cell*> cells;
868 int32_t dx =
ABS(pt2.
x - pt1.
x);
869 int32_t dy =
ABS(pt2.
y - pt1.
y);
880 int32_t err = dx - dy;
882 bool finished =
false;
894 if (current.
x == pt2.
x && current.
y == pt2.
y) {
898 int32_t err2 = err*2;
903 }
else if (err2 < dx) {
912 std::vector<Cell*> cells;
916 for (; current.
y < target.
y; ++current.
y) {
918 for (; current.
x < target.
x; ++current.
x) {
929 std::vector<Cell*> cells;
931 uint16_t radiusp2 = (radius+1) * radius;
935 for (; current.
y < center.
y; current.
y++) {
936 current.
x = center.
x-radius;
937 for (; current.
x < center.
x; current.
x++) {
943 if (distance <= radiusp2) {
946 current.
x = center.
x + dx;
948 if (c) cells.push_back(c);
950 current.
y = center.
y + dy;
952 if (c) cells.push_back(c);
954 current.
x = center.
x-dx;
956 if (c) cells.push_back(c);
958 current.
y = center.
y-dy;
964 current.
x = center.
x;
965 current.
y = center.
y-radius;
966 for (; current.
y <= target.
y; current.
y++) {
968 if (c) cells.push_back(c);
971 current.
y = center.
y;
972 current.
x = center.
x-radius;
973 for (; current.
x <= target.
x; current.
x++) {
975 if (c) cells.push_back(c);
981 std::pair<std::map<std::string, double>::iterator,
bool> insertiter;
982 insertiter =
m_costsTable.insert(std::pair<std::string, double>(costId, cost));
983 if (insertiter.second ==
false) {
984 double& old_cost = insertiter.first->second;
990 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
998 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1006 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1014 std::list<std::string> costs;
1015 std::map<std::string, double>::iterator it =
m_costsTable.begin();
1017 costs.push_back((*it).first);
1031 for (; it != result.second; ++it) {
1032 if ((*it).second == cell) {
1036 m_costsToCells.insert(std::pair<std::string, Cell*>(costId, cell));
1041 std::vector<Cell*>::const_iterator it = cells.begin();
1042 for (; it != cells.end(); ++it) {
1050 if ((*it).second == cell) {
1061 for (; it != result.second; ++it) {
1062 if ((*it).second == cell) {
1070 std::vector<Cell*>::const_iterator it = cells.begin();
1071 for (; it != cells.end(); ++it) {
1077 std::vector<Cell*> cells;
1080 for (; it != result.second; ++it) {
1081 cells.push_back((*it).second);
1087 std::vector<std::string> costs;
1090 if ((*it).second == cell) {
1091 costs.push_back((*it).first);
1100 for (; it != result.second; ++it) {
1101 if ((*it).second == cell) {
1175 std::pair<std::map<Cell*, double>::iterator,
bool> insertiter =
1177 if (insertiter.second ==
false) {
1178 double& old = insertiter.first->second;
1205 std::pair<std::map<Cell*, double>::iterator,
bool> insertiter =
1207 if (insertiter.second ==
false) {
1208 double& old = insertiter.first->second;
1244 std::vector<Cell*> cells;
1249 if (trans->
m_layer == layer) {
1250 cells.push_back(*it);
1263 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1264 if ((*i)->getId() == id) {
1285 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1286 if ((*i)->getId() == id) {
1301 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1317 std::stack<Cell*> cellstack;
1318 const std::vector<Cell*>& neighbors = cell->
getNeighbors();
1319 for (std::vector<Cell*>::const_iterator nit = neighbors.begin(); nit != neighbors.end(); ++nit) {
1328 while(!cellstack.empty()) {
1329 Cell* c = cellstack.top();
1339 for (std::vector<Cell*>::const_iterator nit = neigh.begin(); nit != neigh.end(); ++nit) {
1354 if (!zone1 || !zone2) {
1357 Zone* addZone = zone2;
1358 Zone* oldZone = zone1;
1368 std::pair<std::set<Cell*>::iterator,
bool> insertiter =
m_narrowCells.insert(cell);
1369 if (insertiter.second) {
1403 m_cellAreas.insert(std::pair<std::string, Cell*>(
id, cell));
1407 std::vector<Cell*>::const_iterator it = cells.begin();
1408 for (; it != cells.end(); ++it) {
1416 if ((*it).second == cell) {
1427 for (; it != result.second; ++it) {
1428 if ((*it).second == cell) {
1436 std::vector<Cell*>::const_iterator it = cells.begin();
1437 for (; it != cells.end(); ++it) {
1455 std::vector<std::string> areas;
1456 std::string last(
"");
1459 if (last != (*it).first) {
1461 areas.push_back(last);
1468 std::vector<std::string> areas;
1471 if ((*it).second == cell) {
1472 areas.push_back((*it).first);
1479 std::vector<Cell*> cells;
1482 for (; it != result.second; ++it) {
1483 cells.push_back((*it).second);
1491 for (; it != result.second; ++it) {
1492 if ((*it).second == cell) {
1503 Rect newsize(min.
x, min.
y, max.
x, max.
y);
1506 if (!interacts.empty()) {
1507 std::vector<Layer*>::const_iterator layit = interacts.begin();
1508 for(; layit != interacts.end(); ++layit) {
1510 (*layit)->getMinMaxCoordinates(min, max,
m_layer);
1511 newsize.
w = std::max(max.
x, newsize.
w);
1512 newsize.
h = std::max(max.
y, newsize.
h);
1513 newsize.
x = std::min(min.
x, newsize.
x);
1514 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.
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)
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.
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.