port TestLaraPosition

This commit is contained in:
rr- 2021-02-24 21:00:34 +01:00
parent 12e1492346
commit 08766e37a2
4 changed files with 49 additions and 7 deletions

View file

@ -147,7 +147,7 @@
<rect width="12.00" height="12.00" x="616.00" y="45.00" fill="forestgreen"/> <rect width="12.00" height="12.00" x="616.00" y="45.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="630.00" y="45.00" fill="forestgreen"/> <rect width="12.00" height="12.00" x="630.00" y="45.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="644.00" y="45.00" fill="forestgreen"/> <rect width="12.00" height="12.00" x="644.00" y="45.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="658.00" y="45.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="658.00" y="45.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="672.00" y="45.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="672.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="686.00" y="45.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="686.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="0.00" y="59.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="0.00" y="59.00" fill="lightpink"/>
@ -973,7 +973,7 @@
<rect width="13.24" height="13.36" x="622.09" y="322.31" fill="lightpink"/> <rect width="13.24" height="13.36" x="622.09" y="322.31" fill="lightpink"/>
<rect width="13.24" height="13.36" x="637.33" y="322.31" fill="lightpink"/> <rect width="13.24" height="13.36" x="637.33" y="322.31" fill="lightpink"/>
<rect width="13.19" height="13.36" x="652.57" y="322.31" fill="forestgreen"/> <rect width="13.19" height="13.36" x="652.57" y="322.31" fill="forestgreen"/>
<rect width="13.14" height="13.36" x="667.76" y="322.31" fill="lightpink"/> <rect width="13.14" height="13.36" x="667.76" y="322.31" fill="forestgreen"/>
<rect width="13.09" height="13.36" x="682.91" y="322.31" fill="forestgreen"/> <rect width="13.09" height="13.36" x="682.91" y="322.31" fill="forestgreen"/>
<rect width="12.48" height="14.02" x="497.63" y="337.67" fill="forestgreen"/> <rect width="12.48" height="14.02" x="497.63" y="337.67" fill="forestgreen"/>
<rect width="12.48" height="14.02" x="497.63" y="353.69" fill="mistyrose"/> <rect width="12.48" height="14.02" x="497.63" y="353.69" fill="mistyrose"/>
@ -1459,10 +1459,10 @@
<rect width="-0.46" height="0.42" x="695.22" y="535.58" fill="mistyrose"/> <rect width="-0.46" height="0.42" x="695.22" y="535.58" fill="mistyrose"/>
<rect width="-0.76" height="-0.18" x="696.76" y="535.58" fill="mistyrose"/> <rect width="-0.76" height="-0.18" x="696.76" y="535.58" fill="mistyrose"/>
<rect width="-0.76" height="-1.39" x="696.76" y="537.39" fill="lightpink"/> <rect width="-0.76" height="-1.39" x="696.76" y="537.39" fill="lightpink"/>
<rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 31.14%</text> <rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 31.28%</text>
<rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 30.72%</text> <rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 30.84%</text>
<rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 54.87%</text> <rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 54.73%</text>
<rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 53.31%</text> <rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 53.19%</text>
<rect width="12.00" height="12.00" x="0.00" y="636.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="642.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (count): 13.99%</text> <rect width="12.00" height="12.00" x="0.00" y="636.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="642.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (count): 13.99%</text>
<rect width="12.00" height="12.00" x="0.00" y="654.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="660.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (bytesize): 15.97%</text> <rect width="12.00" height="12.00" x="0.00" y="654.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="660.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (bytesize): 15.97%</text>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Before After
Before After

View file

@ -185,7 +185,7 @@ DoorCollision 0x004129F0 0x0000007B +
TrapCollision 0x00412A70 0x00000096 + TrapCollision 0x00412A70 0x00000096 +
ItemPushLara 0x00412B10 0x00000335 + ItemPushLara 0x00412B10 0x00000335 +
TestBoundsCollide 0x00412E50 0x000000D1 + TestBoundsCollide 0x00412E50 0x000000D1 +
TestLaraPosition 0x00412F30 0x00000137 - TestLaraPosition 0x00412F30 0x00000137 +
AlignLaraPosition 0x00413070 0x000000C1 - AlignLaraPosition 0x00413070 0x000000C1 -
MoveLaraPosition 0x00413140 0x000000E4 - MoveLaraPosition 0x00413140 0x000000E4 -
Move3DPosTo3DPos 0x00413230 0x00000172 - Move3DPosTo3DPos 0x00413230 0x00000172 -

View file

@ -1,3 +1,4 @@
#include "3dsystem/3d_gen.h"
#include "3dsystem/phd_math.h" #include "3dsystem/phd_math.h"
#include "game/collide.h" #include "game/collide.h"
#include "game/const.h" #include "game/const.h"
@ -793,6 +794,44 @@ int32_t TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* lara_item, int32_t radius)
return 0; return 0;
} }
int32_t TestLaraPosition(int16_t* bounds, ITEM_INFO* item, ITEM_INFO* lara_item)
{
PHD_ANGLE xrotrel = lara_item->pos.x_rot - item->pos.x_rot;
PHD_ANGLE yrotrel = lara_item->pos.y_rot - item->pos.y_rot;
PHD_ANGLE zrotrel = lara_item->pos.z_rot - item->pos.z_rot;
if (xrotrel < bounds[6] || xrotrel > bounds[7]) {
return 0;
}
if (yrotrel < bounds[8] || yrotrel > bounds[9]) {
return 0;
}
if (zrotrel < bounds[10] || zrotrel > bounds[11]) {
return 0;
}
int32_t x = lara_item->pos.x - item->pos.x;
int32_t y = lara_item->pos.y - item->pos.y;
int32_t z = lara_item->pos.z - item->pos.z;
phd_PushUnitMatrix();
phd_RotYXZ(item->pos.y_rot, item->pos.x_rot, item->pos.z_rot);
PHD_MATRIX* mptr = PhdMatrixPtr;
int32_t rx = (mptr->_00 * x + mptr->_10 * y + mptr->_20 * z) >> W2V_SHIFT;
int32_t ry = (mptr->_01 * x + mptr->_11 * y + mptr->_21 * z) >> W2V_SHIFT;
int32_t rz = (mptr->_02 * x + mptr->_12 * y + mptr->_22 * z) >> W2V_SHIFT;
phd_PopMatrix();
if (rx < bounds[0] || rx > bounds[1]) {
return 0;
}
if (ry < bounds[2] || ry > bounds[3]) {
return 0;
}
if (rz < bounds[4] || rz > bounds[5]) {
return 0;
}
return 1;
}
void T1MInjectGameCollide() void T1MInjectGameCollide()
{ {
INJECT(0x00411780, GetCollisionInfo); INJECT(0x00411780, GetCollisionInfo);
@ -807,4 +846,5 @@ void T1MInjectGameCollide()
INJECT(0x00412A70, TrapCollision); INJECT(0x00412A70, TrapCollision);
INJECT(0x00412B10, ItemPushLara); INJECT(0x00412B10, ItemPushLara);
INJECT(0x00412E50, TestBoundsCollide); INJECT(0x00412E50, TestBoundsCollide);
INJECT(0x00412F30, TestLaraPosition);
} }

View file

@ -28,6 +28,8 @@ void ItemPushLara(
int32_t bigpush); int32_t bigpush);
int32_t int32_t
TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* lara_item, int32_t radius); TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* lara_item, int32_t radius);
int32_t
TestLaraPosition(int16_t* bounds, ITEM_INFO* item, ITEM_INFO* lara_item);
void T1MInjectGameCollide(); void T1MInjectGameCollide();