74 int32_t x = target.
x-curpos.
x;
75 int32_t y = target.
y-curpos.
y;
77 if (
ABS(x) <= 1 &&
ABS(y) <= 1) {
80 }
else if (curpos.
y & 1) {
81 if (x >= 0)
return true;
82 }
else if (x <= 0)
return true;
88 if (curpos == target) {
95 return static_cast<double>(
ABS(target.
x - curpos.
x) +
ABS(target.
y - curpos.
y));
99 static std::string type(
"hexagonal");
104 static std::string hexGrid(
"Hex Grid");
112 int32_t i_layer_y =
static_cast<int32_t
>(ay);
113 double offset = ay -
static_cast<double>(i_layer_y);
114 if ((i_layer_y % 2) == 1) {
125 FL_DBG(
_log,
LMsg(
"layercoords ") << layer_coords <<
" converted to map: " << result);
133 FL_DBG(
_log,
LMsg(
"mapcoords ") << map_coord <<
" converted to layer: " << layer_coords);
138 FL_DBG(
_log,
LMsg(
"==============\nConverting map coords ") << map_coord <<
" to int32_t layer coords...");
143 if( static_cast<int32_t>(round(elc.
y)) & 1 )
147 int32_t x =
static_cast<int32_t
>(lc.
x);
148 int32_t y =
static_cast<int32_t
>(lc.
y);
149 int32_t z =
static_cast<int32_t
>(lc.
z);
184 FL_DBG(
_log,
LMsg(
"===============\ngetting vertices for ") << cell);
186 double x =
static_cast<double>(cell.
x);
187 double y =
static_cast<double>(cell.
y);
188 double horiz_shift = 0;
189 if (cell.
y % 2 != 0) {
195 #define ADD_PT(_x, _y) vtx.push_back(ExactModelCoordinate(_x, _y));
223 std::vector<ModelCoordinate> coords;
224 std::vector<ModelCoordinate>::const_iterator it = orig.begin();
226 for (; it != orig.end(); ++it) {
238 coords.push_back(mc);
241 for (; it != orig.end(); ++it) {
253 coords.push_back(mc);
static const double VERTICAL_MULTIP_INV
double getXZigzagOffset(double y)
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
void setZShift(const double zshift)
Set the cellgrid z shift.
double getAdjacentCost(const ModelCoordinate &curpos, const ModelCoordinate &target)
Returns distance const from curpos to target point only cells adjacent to curpos are considered in th...
ExactModelCoordinate toExactLayerCoordinates(const ExactModelCoordinate &map_coord)
Transforms given point from map coordinates to layer coordinates.
std::vector< ModelCoordinate > toMultiCoordinates(const ModelCoordinate &position, const std::vector< ModelCoordinate > &orig, bool reverse)
Returns point vector with coordinates for a multi object.
static const double HEX_EDGE_GRADIENT
static Logger _log(LM_AUDIO)
DoubleMatrix m_inverse_matrix
void setXShift(const double &xshift)
Set the cellgrid x shift.
void setYScale(const double scale)
Set the cellgrid y-scaling.
ExactModelCoordinate toMapCoordinates(const ExactModelCoordinate &layer_coords)
Transforms given point from layer coordinates to map coordinates.
void setXScale(const double scale)
Set the cellgrid x-scaling.
static const double HEX_TO_EDGE
static const double HEX_WIDTH
void setYShift(const double yshift)
Set the cellgrid y shift.
CellGrid * clone()
Returns clone of this cellgrid.
double getHeuristicCost(const ModelCoordinate &curpos, const ModelCoordinate &target)
Returns distance const from curpos to target point.
const std::string & getType() const
Type of cellgrid.
void setAllowDiagonals(const bool allow_diagonals)
Set whether diagonal cell access is allowed.
DoublePoint3D ExactModelCoordinate
static const double HEX_TO_CORNER
const std::string & getName() const
Name of the cellgrid (DEPRECATED? -jwt)
void getVertices(std::vector< ExactModelCoordinate > &vtx, const ModelCoordinate &cell)
Fills given point vector with vertices from selected cell.
void setRotation(const double rotation)
Set the cellgrid rotation.
static const double VERTICAL_MULTIP
static const double HEX_EDGE_HALF
ModelCoordinate toLayerCoordinates(const ExactModelCoordinate &map_coord)
Transforms given point from map coordinates to layer coordinates.
bool isAccessible(const ModelCoordinate &curpos, const ModelCoordinate &target)
Tells if given target point is accessible from curpos only cells adjacent to curpos are considered in...
#define FL_DBG(logger, msg)