Added Translocator ammo feature from UT2k4.

Prefixed mk_math classes for cross-compat with any other mods that use them.
Fixed incorrect uses of gametic.
Fixed crash caused by incorrect ordering of PendingWeapon checks.
This commit is contained in:
Marisa the Magician 2018-12-17 16:32:15 +01:00
commit 931f89832c
23 changed files with 179 additions and 107 deletions

View file

@ -5,7 +5,7 @@
See https://www.gnu.org/licenses/lgpl-3.0.txt for its terms.
*/
Class mkCoordUtil
Class dt_CoordUtil
{
// projects a world point onto screen
// view matrix setup mostly pulled from gutawer's code
@ -21,32 +21,32 @@ Class mkCoordUtil
double apitch = asin(angy/alen);
double ayaw = yaw-90;
// rotations
Matrix4 mRoll = Matrix4.rotate((0,0,1),roll);
Matrix4 mPitch = Matrix4.rotate((1,0,0),apitch);
Matrix4 mYaw = Matrix4.rotate((0,-1,0),ayaw);
dt_Matrix4 mRoll = dt_Matrix4.rotate((0,0,1),roll);
dt_Matrix4 mPitch = dt_Matrix4.rotate((1,0,0),apitch);
dt_Matrix4 mYaw = dt_Matrix4.rotate((0,-1,0),ayaw);
// scaling
Matrix4 mScale = Matrix4.identity();
dt_Matrix4 mScale = dt_Matrix4.identity();
mScale.set(1,1,pr);
// YZ swap
Matrix4 mYZ = Matrix4.create();
dt_Matrix4 mYZ = dt_Matrix4.create();
mYZ.set(0,0,1);
mYZ.set(2,1,1);
mYZ.set(1,2,-1);
mYZ.set(3,3,1);
// translation
Matrix4 mMove = Matrix4.identity();
dt_Matrix4 mMove = dt_Matrix4.identity();
mMove.set(3,0,-eye.x);
mMove.set(3,1,-eye.y);
mMove.set(3,2,-eye.z);
// perspective
Matrix4 mPerspective = Matrix4.perspective(fov,ar,5,65535);
dt_Matrix4 mPerspective = dt_Matrix4.perspective(fov,ar,5,65535);
// full matrix
Matrix4 mView = mRoll.mul(mPitch);
dt_Matrix4 mView = mRoll.mul(mPitch);
mView = mView.mul(mYaw);
mView = mView.mul(mScale);
mView = mView.mul(mYZ);
mView = mView.mul(mMove);
Matrix4 mWorldToScreen = mPerspective.mul(mView);
dt_Matrix4 mWorldToScreen = mPerspective.mul(mView);
return mWorldToScreen.vmat(vect);
}