29 KyInt32 is_strict_pos = -(-coord >> 31);
30 return (coord - is_strict_pos) / squareSize - 1 + is_strict_pos;
35 KyInt32 is_strict_neg = -(coord >> 31);
36 return (coord + is_strict_neg) / squareSize - is_strict_neg;
41 KyInt64 is_strict_neg = -(coord >> 63);
42 return (coord + is_strict_neg) / squareSize - is_strict_neg;
45 static void LowSquare(
KyInt32 squareSize,
const Vec2i& pos, Vec2i& squarePos)
47 squarePos.x = LowSquare(squareSize, pos.x);
48 squarePos.y = LowSquare(squareSize, pos.y);
51 static void HighSquare(
KyInt32 squareSize,
const Vec2i& pos, Vec2i& squarePos)
53 squarePos.x = HighSquare(squareSize, pos.x);
54 squarePos.y = HighSquare(squareSize, pos.y);
57 static void LowSquare(
KyInt32 squareSize,
const Vec3i& pos, Vec2i& squarePos)
59 squarePos.x = LowSquare(squareSize, pos.x);
60 squarePos.y = LowSquare(squareSize, pos.y);
63 static void HighSquare(
KyInt32 squareSize,
const Vec3i& pos, Vec2i& squarePos)
65 squarePos.x = HighSquare(squareSize, pos.x);
66 squarePos.y = HighSquare(squareSize, pos.y);
70 static void SquareBox(
KyInt32 squareSize,
const Box2i& coordBox, Box2i& squareBox)
72 LowSquare(squareSize, coordBox.m_min, squareBox.m_min);
73 HighSquare(squareSize, coordBox.m_max, squareBox.m_max);
74 squareBox.UpdateCountXY();
78 static void SquareBoxStrict(
KyInt32 squareSize,
const Box2i& coordBox, Box2i& squareBox)
80 HighSquare(squareSize, coordBox.m_min, squareBox.m_min);
81 LowSquare(squareSize, coordBox.m_max, squareBox.m_max);
82 squareBox.UpdateCountXY();
89 return squareCoord * squareSize;
94 return (squareCoord + 1) * squareSize;
97 static void MinCoordPos(
KyInt32 squareSize,
const Vec2i& squarePos, Vec2i& coordPos)
99 coordPos.x = MinCoord(squareSize, squarePos.x);
100 coordPos.y = MinCoord(squareSize, squarePos.y);
103 static void MaxCoordPos(
KyInt32 squareSize,
const Vec2i& squarePos, Vec2i& coordPos)
105 coordPos.x = MaxCoord(squareSize, squarePos.x);
106 coordPos.y = MaxCoord(squareSize, squarePos.y);
109 static void GetCoordBox(
KyInt32 squareSize,
const Box2i& squareBox, Box2i& coordBox)
111 MinCoordPos(squareSize, squareBox.m_min, coordBox.m_min);
112 MaxCoordPos(squareSize, squareBox.m_max, coordBox.m_max);
113 coordBox.UpdateCountXY();
123 return bigCoord * nbSmallsOnBigSide;
128 return (bigCoord + 1) * nbSmallsOnBigSide - 1;
131 static void MinSmallSquarePos(
KyInt32 nbSmallsOnBigSide,
const Vec2i& bigPos, Vec2i& smallPos)
133 smallPos.x = MinSmallSquareCoord(nbSmallsOnBigSide, bigPos.x);
134 smallPos.y = MinSmallSquareCoord(nbSmallsOnBigSide, bigPos.y);
137 static void MaxSmallSquarePos(
KyInt32 nbSmallsOnBigSide,
const Vec2i& bigPos, Vec2i& smallPos)
139 smallPos.x = MaxSmallSquareCoord(nbSmallsOnBigSide, bigPos.x);
140 smallPos.y = MaxSmallSquareCoord(nbSmallsOnBigSide, bigPos.y);
143 static void SmallSquareBox(
KyInt32 nbSmallsOnBigSide,
const Box2i& bigBox, Box2i& smallBox)
145 MinSmallSquarePos(nbSmallsOnBigSide, bigBox.m_min, smallBox.m_min);
146 MaxSmallSquarePos(nbSmallsOnBigSide, bigBox.m_max, smallBox.m_max);
147 smallBox.UpdateCountXY();
150 static void SmallSquareBox(
KyInt32 nbSmallsOnBigSide,
const Vec2i& bigPos, Box2i& smallBox)
152 MinSmallSquarePos(nbSmallsOnBigSide, bigPos, smallBox.m_min);
153 MaxSmallSquarePos(nbSmallsOnBigSide, bigPos, smallBox.m_max);
154 smallBox.UpdateCountXY();
164 KyInt32 is_strict_neg = -(smallCoord >> 31);
165 return (smallCoord + is_strict_neg) / nbSmallsOnBigSide - is_strict_neg;
172 static void BigSquarePos(
KyInt32 nbSmallsOnBigSide,
const Vec2i& smallPos, Vec2i& bigPos)
174 bigPos.x = BigSquareCoord(nbSmallsOnBigSide, smallPos.x);
175 bigPos.y = BigSquareCoord(nbSmallsOnBigSide, smallPos.y);
178 static void BigSquareBox(
KyInt32 nbSmallsOnBigSide,
const Box2i& smallBox, Box2i& bigBox)
180 BigSquarePos(nbSmallsOnBigSide, smallBox.m_min, bigBox.m_min);
181 BigSquarePos(nbSmallsOnBigSide, smallBox.m_max, bigBox.m_max);
182 bigBox.UpdateCountXY();
std::int64_t KyInt64
int64_t
Definition: types.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24