Вопрос Проблема с отрисовкой линий до игроков

Новичок
Статус
Оффлайн
Регистрация
21 Сен 2020
Сообщения
1
Реакции[?]
0
Поинты[?]
0
Криво работает отрисовка линий до игроков. Как я понял это связано с получением мировой матрицы, потому что origin игрока один и тот же, но при worldtoscreen координаты на экране иногда становятся не правильными.

Отрисовка до игрока
C++:
IBasePlayer* pLocalPlayer = (IBasePlayer*)g_Interfaces.pClientEntityList->GetClientEntity(g_Interfaces.pEngineClient->GetLocalPlayer());
        
                for (unsigned int i = 1, j = 0; i <= MAX_PLAYERS; ++i)
                {
                    IBasePlayer* pPlayer = (IBasePlayer*)g_Interfaces.pClientEntityList->GetClientEntity(i);
        
                    if (!pPlayer || pPlayer->GetClientClass()->iClassID != 40 || pPlayer == pLocalPlayer || pPlayer->IsDead())
                        continue;
        
                    Vector PlayerOrigin = pPlayer->GetOrigin();
        
                    Vector on_screen;
        
                    if (Utils::Math::WorldToScreen(PlayerOrigin, on_screen))
                    {
                        draw_list->AddLine({ (float)g_Globals.iScreenCenter[0], (float)g_Globals.iScreenSize[1] }, { on_screen.x, on_screen.y }, ImColor(255, 255, 255, 255));
                    }
                }
worldtoscreen
C++:
bool ScreenTransform(const Vector& point, Vector& screen)
    {
        static const D3DXMATRIX& worldToScreen = (const D3DXMATRIX&)g_Interfaces.pEngineClient->WorldToScreenMatrix();
    
        screen.x = worldToScreen._11 * point[0] + worldToScreen._12 * point[1] + worldToScreen._13 * point[2] + worldToScreen._14;
        screen.y = worldToScreen._21 * point[0] + worldToScreen._22 * point[1] + worldToScreen._23 * point[2] + worldToScreen._24;
        screen.z = 0.0f;
    
        float w = worldToScreen._41 * point[0] + worldToScreen._42 * point[1] + worldToScreen._43 * point[2] + worldToScreen._44;
    
        if (w < 0.001f) {
            screen.x *= 100000;
            screen.y *= 100000;
            return false;
        }
    
        screen.x /= w;
        screen.y /= w;
    
        return true;
    }
    
    bool WorldToScreen(const Vector& point, Vector& screen)
    {
       // return g_Interfaces.pDebugOverlay->ScreenPosition(point, screen) != 1;
    
        if (Utils::Math::ScreenTransform(point, screen))
        {
            screen.x = (g_Globals.iScreenSize[0] / 2.0f) + (screen.x * g_Globals.iScreenSize[0]) / 2.0f;
            screen.y = (g_Globals.iScreenSize[1] / 2.0f) - (screen.y * g_Globals.iScreenSize[1]) / 2.0f;
        
            return true;
        }
        
        return false;
    }
 
Сверху Снизу