W2S Laggy

DavidRO99

Active member
Joined
Nov 5, 2017
Messages
60
Reaction score
8
Hello!

I know, I ask a ton of questions and post nothing  :sadpepe: , i'll try to change that.
Anyways, I have made some Present hook custom D3D Nametags, ofcourse to bypass the current version of the SAMPCAC anti-cheat.
I got W2S working and my nametags how I wanted them to look, but they lag behind, creating a very unpleasant effect.
I suspect its either the W2S function being too slow or the present hook not being called too often.

Is there any alternative W2S function that is faster, or another method to just get screen x and y from 3D pos?

Here is my current W2S:
Code:
void CalcScreenCoors(CVector * vecWorld, CVector * vecScreen)
{
	/** C++-ifyed function 0x71DA00, formerly called by CHudSA::CalcScreenCoors **/

	// Get the static view matrix as D3DXMATRIX
	D3DXMATRIX m((float*)(0xB6FA2C));

	// Get the static virtual screen (x,y)-sizes
	DWORD *dwLenX = (DWORD*)(0xC17044);
	DWORD *dwLenY = (DWORD*)(0xC17048);

	// Do a transformation
	vecScreen->fX = vecWorld->fZ * m._31 + vecWorld->fY * m._21 + vecWorld->fX * m._11 + m._41;
	vecScreen->fY = vecWorld->fZ * m._32 + vecWorld->fY * m._22 + vecWorld->fX * m._12 + m._42;
	vecScreen->fZ = vecWorld->fZ * m._33 + vecWorld->fY * m._23 + vecWorld->fX * m._13 + m._43;

	// Get the correct screen coordinates

	float fRecip = 1.0f / vecScreen->fZ;
	vecScreen->fX *= fRecip * (*dwLenX);
	vecScreen->fY *= fRecip * (*dwLenY);
}
 
Top