Вот, я за это и говорю. Просто они как то делают так что мой хит бокс не увеличиваеться...
Это делают с помощью матрицы
примерно так:
Vector3 bottomPoint;
Vector3 topPoint;
if (worldToScreenPoint(moveState.position + Vector3(смещение), vm, bottomPoint)
&& worldToScreenPoint(moveState.position + Vector3(смещение), vm, topPoint))
{
float width = (bottomPoint.y - topPoint.y) / 5;
drawList->AddLine(topPoint + Vector3(width, 0, 0), topPoint, IM_COL32(255, 0, 0, 255), 1);
drawList->AddQuad(
topPoint - Vector3(width, 0, 0),
topPoint + Vector3(width, 0, 0),
bottomPoint + Vector3(width, 0, 0),
bottomPoint - Vector3(width, 0, 0),
IM_COL32(255, 0, 0, 255), 1
);
}
реализация worldToScreenPoint
bool worldToScreenPoint(Vector3 worldPoint, Matrix4x4 vm, Vector3& screenPoint)
{
Vector4 clipPoint = vm * Vector4(worldPoint.x, worldPoint.y, worldPoint.z, 1);
if (clipPoint.w == 0 || clipPoint.z <= 0)
{
return false;
}
else
{
screenPoint.x = (clipPoint.x / clipPoint.w + 1) * .5f * clientWidth;
screenPoint.y = clientHeight - (clipPoint.y / clipPoint.w + 1) * .5f * clientHeight;
screenPoint.z = clipPoint.z;
return true;
}
}
и Vector3:
struct Vector3
{
float x, y, z;
Vector3(float x = 0, float y = 0, float z = 0) : x(x), y(y), z(z) {}
Vector3 operator+(const Vector3& other) const
{
return Vector3(x + other.x, y + other.y, z + other.z);
}
Vector3 operator-(const Vector3& other) const
{
return Vector3(x - other.x, y - other.y, z - other.z);
}
Vector3 operator*(const Vector3& other) const
{
return Vector3(x - other.x, y * other.y, z * other.z);
}
Vector3 operator/(const Vector3& other) const
{
return Vector3(x / other.x, y / other.y, z / other.z);
}
};