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);
348 m_cache->splitZone(cell);
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();
362 m_cache->mergeZones(z1, z2);
373 m_defaultCostMulti(1.0),
374 m_defaultSpeedMulti(1.0),
376 m_blockingUpdate(false),
378 m_searchNarrow(true),
379 m_staticSize(false) {
394 if (!interacts.empty()) {
395 std::vector<Layer*>::const_iterator layit = interacts.begin();
396 for(; layit != interacts.end(); ++layit) {
398 (*layit)->getMinMaxCoordinates(min, max,
m_layer);
423 if (!interacts.empty()) {
424 std::vector<Layer*>::const_iterator layit = interacts.begin();
425 for(; layit != interacts.end(); ++layit) {
437 std::vector<Zone*>::iterator it =
m_zones.begin();
438 for (; it !=
m_zones.end(); ++it) {
452 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
453 for (; it !=
m_cells.end(); ++it) {
454 std::vector<Cell*>::iterator cit = (*it).begin();
455 for (; cit != (*it).end(); ++cit) {
489 std::vector<std::vector<Cell*> > cells;
492 cells[i].resize(h, NULL);
503 if (old_x < 0 || old_x >= static_cast<int32_t>(
m_width) || old_y < 0 || old_y >= static_cast<int32_t>(
m_height)) {
504 int32_t coordId = x + y * w;
508 std::list<Instance*> cell_instances;
510 if (!interacts.empty()) {
512 std::vector<Layer*>::const_iterator it = interacts.begin();
513 std::list<Instance*> interact_instances;
514 for(; it != interacts.end(); ++it) {
519 (*it)->getInstanceTree()->findInstances(inter_mc, 0, 0, interact_instances);
520 if (!interact_instances.empty()) {
521 cell_instances.insert(cell_instances.end(), interact_instances.begin(), interact_instances.end());
522 interact_instances.clear();
526 if (!cell_instances.empty()) {
532 cell =
m_cells[
static_cast<uint32_t>(old_x)][static_cast<uint32_t>(old_y)];
533 m_cells[
static_cast<uint32_t>(old_x)][static_cast<uint32_t>(old_y)] = NULL;
535 int32_t coordId = x + y * w;
542 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
543 for (; it !=
m_cells.end(); ++it) {
544 std::vector<Cell*>::iterator cit = (*it).begin();
545 for (; cit != (*it).end(); ++cit) {
561 for (; it !=
m_cells.end(); ++it) {
562 std::vector<Cell*>::iterator cit = (*it).begin();
563 for (; cit != (*it).end(); ++cit) {
564 int32_t cellZ = (*cit)->getLayerCoordinates().z;
565 std::vector<ModelCoordinate> coordinates;
567 for (std::vector<ModelCoordinate>::iterator mi = coordinates.begin(); mi != coordinates.end(); ++mi) {
569 if (*cit == c || !c) {
577 (*cit)->addNeighbor(c);
595 std::list<Instance*> cell_instances;
597 if (!interacts.empty()) {
599 std::vector<Layer*>::const_iterator it = interacts.begin();
600 std::list<Instance*> interact_instances;
601 for(; it != interacts.end(); ++it) {
606 (*it)->getInstanceTree()->findInstances(inter_mc, 0, 0, interact_instances);
607 if (!interact_instances.empty()) {
608 cell_instances.insert(cell_instances.end(), interact_instances.begin(), interact_instances.end());
609 interact_instances.clear();
613 if (!cell_instances.empty()) {
620 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
621 for (; it !=
m_cells.end(); ++it) {
622 std::vector<Cell*>::iterator cit = (*it).begin();
623 for (; cit != (*it).end(); ++cit) {
626 std::vector<ModelCoordinate> coordinates;
628 for (std::vector<ModelCoordinate>::iterator mi = coordinates.begin(); mi != coordinates.end(); ++mi) {
630 if (*cit == c || !c) {
637 (*cit)->addNeighbor(c);
647 for (; it !=
m_cells.end(); ++it) {
648 std::vector<Cell*>::iterator cit = (*it).begin();
649 for (; cit != (*it).end(); ++cit) {
659 std::stack<Cell*> cellstack;
660 cellstack.push(cell);
661 while(!cellstack.empty()) {
662 Cell* c = cellstack.top();
666 const std::vector<Cell*>& neighbors = c->
getNeighbors();
667 for (std::vector<Cell*>::const_iterator nit = neighbors.begin(); nit != neighbors.end(); ++nit) {
681 std::vector<std::vector<Cell*> >::iterator it =
m_cells.begin();
682 for (; it !=
m_cells.end(); ++it) {
683 std::vector<Cell*>::iterator cit = (*it).begin();
684 for (; cit != (*it).end(); ++cit) {
685 (*cit)->updateCellInfo();
708 if (x < 0 || x >= static_cast<int32_t>(
m_width) || y < 0 || y >= static_cast<int32_t>(
m_height)) {
755 std::list<Instance*> interact_instances;
757 if (!interact_instances.empty()) {
783 std::list<Instance*> interact_instances;
785 if (!interact_instances.empty()) {
787 for (std::list<Instance*>::iterator it = interact_instances.begin(); it != interact_instances.end(); ++it) {
827 if (x < 0 || x >= static_cast<int32_t>(
m_width) || y < 0 || y >= static_cast<int32_t>(
m_height)) {
835 return newcoords.
x + newcoords.
y*
m_width;
857 std::vector<Cell*> cells;
859 for (std::vector<ModelCoordinate>::iterator it = coords.begin(); it != coords.end(); ++it) {
874 std::vector<Cell*> cells;
875 cells.reserve(rec.
w * rec.
h);
879 for (; current.
y < target.
y; ++current.
y) {
881 for (; current.
x < target.
x; ++current.
x) {
892 std::vector<Cell*> cells;
893 cells.reserve(rec.
w * rec.
h);
897 for (; current.
y < target.
y; ++current.
y) {
899 for (; current.
x < target.
x; ++current.
x) {
910 std::vector<Cell*> cells;
912 uint16_t radiusp2 = (radius+1) * radius;
916 for (; current.
y < center.
y; current.
y++) {
917 current.
x = center.
x-radius;
918 for (; current.
x < center.
x; current.
x++) {
924 if (distance <= radiusp2) {
927 current.
x = center.
x + dx;
929 if (c) cells.push_back(c);
931 current.
y = center.
y + dy;
933 if (c) cells.push_back(c);
935 current.
x = center.
x-dx;
937 if (c) cells.push_back(c);
939 current.
y = center.
y-dy;
945 current.
x = center.
x;
946 current.
y = center.
y-radius;
947 for (; current.
y <= target.
y; current.
y++) {
949 if (c) cells.push_back(c);
952 current.
y = center.
y;
953 current.
x = center.
x-radius;
954 for (; current.
x <= target.
x; current.
x++) {
956 if (c) cells.push_back(c);
962 std::vector<Cell*> cells;
965 int32_t s = (sangle + 360) % 360;
966 int32_t e = (eangle + 360) % 360;
967 bool greater = (s > e) ?
true :
false;
968 for (std::vector<Cell*>::iterator it = tmpCells.begin(); it != tmpCells.end(); ++it) {
971 if (angle >= s || angle <= e) {
972 cells.push_back(*it);
975 if (angle >= s && angle <= e) {
976 cells.push_back(*it);
984 std::pair<std::map<std::string, double>::iterator,
bool> insertiter;
985 insertiter =
m_costsTable.insert(std::pair<std::string, double>(costId, cost));
986 if (insertiter.second ==
false) {
987 double& old_cost = insertiter.first->second;
993 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1001 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1009 std::map<std::string, double>::iterator it =
m_costsTable.find(costId);
1017 std::list<std::string> costs;
1018 std::map<std::string, double>::iterator it =
m_costsTable.begin();
1020 costs.push_back((*it).first);
1034 for (; it != result.second; ++it) {
1035 if ((*it).second == cell) {
1039 m_costsToCells.insert(std::pair<std::string, Cell*>(costId, cell));
1044 std::vector<Cell*>::const_iterator it = cells.begin();
1045 for (; it != cells.end(); ++it) {
1053 if ((*it).second == cell) {
1064 for (; it != result.second; ++it) {
1065 if ((*it).second == cell) {
1073 std::vector<Cell*>::const_iterator it = cells.begin();
1074 for (; it != cells.end(); ++it) {
1080 std::vector<Cell*> cells;
1083 for (; it != result.second; ++it) {
1084 cells.push_back((*it).second);
1090 std::vector<std::string> costs;
1093 if ((*it).second == cell) {
1094 costs.push_back((*it).first);
1103 for (; it != result.second; ++it) {
1104 if ((*it).second == cell) {
1178 std::pair<std::map<Cell*, double>::iterator,
bool> insertiter =
1180 if (insertiter.second ==
false) {
1181 double& old = insertiter.first->second;
1208 std::pair<std::map<Cell*, double>::iterator,
bool> insertiter =
1210 if (insertiter.second ==
false) {
1211 double& old = insertiter.first->second;
1247 std::vector<Cell*> cells;
1252 if (trans->
m_layer == layer) {
1253 cells.push_back(*it);
1266 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1267 if ((*i)->getId() == id) {
1288 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1289 if ((*i)->getId() == id) {
1304 for (std::vector<Zone*>::iterator i =
m_zones.begin(); i !=
m_zones.end(); ++i) {
1320 std::stack<Cell*> cellstack;
1321 const std::vector<Cell*>& neighbors = cell->
getNeighbors();
1322 for (std::vector<Cell*>::const_iterator nit = neighbors.begin(); nit != neighbors.end(); ++nit) {
1331 while(!cellstack.empty()) {
1332 Cell* c = cellstack.top();
1342 for (std::vector<Cell*>::const_iterator nit = neigh.begin(); nit != neigh.end(); ++nit) {
1357 if (!zone1 || !zone2) {
1360 Zone* addZone = zone2;
1361 Zone* oldZone = zone1;
1371 std::pair<std::set<Cell*>::iterator,
bool> insertiter =
m_narrowCells.insert(cell);
1372 if (insertiter.second) {
1406 m_cellAreas.insert(std::pair<std::string, Cell*>(
id, cell));
1410 std::vector<Cell*>::const_iterator it = cells.begin();
1411 for (; it != cells.end(); ++it) {
1419 if ((*it).second == cell) {
1430 for (; it != result.second; ++it) {
1431 if ((*it).second == cell) {
1439 std::vector<Cell*>::const_iterator it = cells.begin();
1440 for (; it != cells.end(); ++it) {
1458 std::vector<std::string> areas;
1459 std::string last(
"");
1462 if (last != (*it).first) {
1464 areas.push_back(last);
1471 std::vector<std::string> areas;
1474 if ((*it).second == cell) {
1475 areas.push_back((*it).first);
1482 std::vector<Cell*> cells;
1485 for (; it != result.second; ++it) {
1486 cells.push_back((*it).second);
1494 for (; it != result.second; ++it) {
1495 if ((*it).second == cell) {
1506 Rect newsize(min.
x, min.
y, max.
x, max.
y);
1509 if (!interacts.empty()) {
1510 std::vector<Layer*>::const_iterator layit = interacts.begin();
1511 for(; layit != interacts.end(); ++layit) {
1513 (*layit)->getMinMaxCoordinates(min, max,
m_layer);
1514 newsize.
w = std::max(max.
x, newsize.
w);
1515 newsize.
h = std::max(max.
y, newsize.
h);
1516 newsize.
x = std::min(min.
x, newsize.
x);
1517 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 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.
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.
void removeCellsFromCost(const std::string &costId, const std::vector< Cell *> &cells)
Removes cells from a cost identifier.
void addCellsToArea(const std::string &id, const std::vector< Cell *> &cells)
Adds few cell to a specific area group.
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...
int32_t getMaxIndex() const
Returns the number of cells on this CellCache.
void addInstance(Instance *instance)
Adds a instance to this cell.
int32_t getMaxNeighborZ()
Gets maximal z range for neighbors.
Layer * getLayer() const
Gets the layer where this location is pointing to.
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_blockingUpdate
indicates blocking update
const std::string & getId() const
Get the id of this layer.
void removeCellsFromArea(const std::string &id, const std::vector< Cell *> &cells)
Removes few cells from a area.
void resetNarrowCells()
Resets narrow cells.
virtual ~CellCacheChangeListener()
void setDefaultCostMultiplier(double multi)
Sets default cost for this CellCache.
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.
CellCache * getCellCache()
Returns the CellCache of this layer.
void setBlockingUpdate(bool update)
std::vector< std::vector< Cell * > > m_cells
static Logger _log(LM_AUDIO)
void addInstances(const std::list< Instance *> &instances)
Adds instances to this cell.
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.
void addCellsToCost(const std::string &costId, const std::vector< Cell *> &cells)
Assigns cells to a cost identifier.
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.
std::vector< Cell * > getCostCells(const std::string &costId)
Returns cells for a cost identifier.
void removeCell(Cell *cell)
Removes a cell from this zone.
void setSize(const Rect &rec)
Sets CellCache size.
Location & getLocationRef()
Gets reference of current location of instance.
std::vector< Zone * > m_zones
zones
void removeArea(const std::string &id)
Removes a area.
void removeCellFromArea(Cell *cell)
Removes the cell from all areas.
void addInteractLayer(Layer *layer)
Adds a interact layer to the walkable layer.
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.
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.
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.
double getDefaultSpeedMultiplier()
Gets default speed for this CellCache.
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.
CellTypeInfo getCellType()
Returns blocker type.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this CellCache.
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.
const ModelCoordinate getLayerCoordinates() const
Returns the layer coordinates of this cell.
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.
ModelCoordinate convertIntToCoord(const int32_t cell) const
Convertes unique identifier to coordinate.
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.
std::vector< Cell * > getBlockingCellsInRect(const Rect &rec)
Returns all blocking cells in the rect.
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.
int32_t convertCoordToInt(const ModelCoordinate &coord) const
Convertes coordinate to unique identifier.
std::vector< Cell * > getAreaCells(const std::string &id)
Returns all cells of an area.
const std::set< Cell * > & getCells() const
Returns all cells of this zone.
const std::vector< Layer * > & getInteractLayers()
Returns all assigned interact layer.
void changeInstance(Instance *instance)
Changes a instance on 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.
void getMinMaxCoordinates(ModelCoordinate &min, ModelCoordinate &max, const Layer *layer=0) const
Retrieves the minimum/maximum coordinates of instances on the layer.
InstanceTree * getInstanceTree(void) const
Get the instance tree.
CellGrid * getCellGrid() const
Get the Cellgrid.
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.
bool isInCellCache(const Location &location) const
Checks whether the location is in CellCache range.
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.
ModelCoordinate getLayerCoordinates() const
Gets cell precision layer coordinates set to this location.
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.
uint32_t getCellCount() const
Returns the number of cells.
void addNarrowCell(Cell *cell)
Adds cell to narrow cells.
std::vector< std::string > getAreas()
Returns all area ids.
virtual void onLayerChanged(Layer *layer, std::vector< Instance *> &instances)
Called when some instance is changed on layer.
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 getRotation() const
Get the rotation offset of this instance Returns direction where instance is heading.
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.
uint32_t getId() const
Returns the zone identifier.
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.