Merge pull request #692 from Sx50/patch-1
Make worldtoscreen great again
This commit is contained in:
commit
cdf6482458
@ -315,12 +315,38 @@ VMatrix wts{};
|
||||
|
||||
void UpdateWTS()
|
||||
{
|
||||
memcpy(&wts, &g_IEngine->WorldToScreenMatrix(), sizeof(VMatrix));
|
||||
CViewSetup gay;
|
||||
VMatrix _, __, ___;
|
||||
g_IBaseClient->GetPlayerView(gay);
|
||||
g_IVRenderView->GetMatricesForView(gay, &_, &__, &wts, &___);
|
||||
}
|
||||
|
||||
bool WorldToScreen(const Vector &origin, Vector &screen)
|
||||
{
|
||||
return g_IVDebugOverlay->ScreenPosition(origin, screen) == 0;
|
||||
float w;
|
||||
screen.z = 0;
|
||||
w = wts[3][0] * origin[0] + wts[3][1] * origin[1] + wts[3][2] * origin[2] +
|
||||
wts[3][3];
|
||||
if (w > 0.001)
|
||||
{
|
||||
float odw = 1.0f / w;
|
||||
screen.x = (draw::width / 2) +
|
||||
(0.5 *
|
||||
((wts[0][0] * origin[0] + wts[0][1] * origin[1] +
|
||||
wts[0][2] * origin[2] + wts[0][3]) *
|
||||
odw) *
|
||||
draw::width +
|
||||
0.5);
|
||||
screen.y = (draw::height / 2) -
|
||||
(0.5 *
|
||||
((wts[1][0] * origin[0] + wts[1][1] * origin[1] +
|
||||
wts[1][2] * origin[2] + wts[1][3]) *
|
||||
odw) *
|
||||
draw::height +
|
||||
0.5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#if ENABLE_ENGINE_DRAWING
|
||||
bool Texture::load()
|
||||
|
Reference in New Issue
Block a user