2018-08-19 09:46:58 +02:00
|
|
|
#include "draw.h"
|
2019-11-21 07:43:34 +01:00
|
|
|
#include "Lara.h"
|
2019-01-13 21:57:16 +01:00
|
|
|
#include "..\Renderer\Renderer11.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-01-13 21:57:16 +01:00
|
|
|
Renderer11* g_Renderer;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2020-01-16 19:14:35 +01:00
|
|
|
int Outside;
|
|
|
|
int Underwater;
|
|
|
|
short BoundList[128];
|
|
|
|
short DrawnRooms[128];
|
|
|
|
int BoundStart;
|
|
|
|
int BoundEnd;
|
|
|
|
int NumberDrawnRooms;
|
|
|
|
int OutsideTop;
|
|
|
|
int OutsideBottom;
|
|
|
|
int OutsideLeft;
|
|
|
|
int OutsideRight;
|
|
|
|
bool OutsideRoomExists;
|
|
|
|
PHD_VECTOR DoorBuffer[4];
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
int DrawPhaseGame()
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
|
|
|
// Control routines uses joints calculated here for getting Lara joint positions
|
|
|
|
CalcLaraMatrices(0);
|
|
|
|
phd_PushUnitMatrix();
|
|
|
|
CalcLaraMatrices(1);
|
|
|
|
|
|
|
|
// Calls my new rock & roll renderer :)
|
|
|
|
g_Renderer->Draw();
|
2019-05-31 21:45:13 +02:00
|
|
|
Camera.numberFrames = g_Renderer->SyncRenderer();
|
2018-08-19 09:46:58 +02:00
|
|
|
|
|
|
|
// We need to pop the matrix stack or the game will crash
|
2019-11-24 17:01:13 +01:00
|
|
|
phd_PopMatrix();
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
return Camera.numberFrames;
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void DrawAnimatingItem(ITEM_INFO* item)
|
2019-11-25 13:18:24 +01:00
|
|
|
{
|
2019-12-02 09:11:21 +01:00
|
|
|
/*OBJECT_INFO* obj;
|
2019-11-25 13:18:24 +01:00
|
|
|
CREATURE_INFO* creature;
|
|
|
|
int* bones;
|
|
|
|
int clip, i, poppush, frac, rate, bit;
|
2019-11-27 15:12:35 +01:00
|
|
|
short* frames[2];
|
|
|
|
short* extra_rotation;
|
|
|
|
short* rotation1, *rotation2;
|
|
|
|
short** mesh;
|
2019-11-25 13:18:24 +01:00
|
|
|
|
|
|
|
creature = (CREATURE_INFO*)item->data;
|
|
|
|
frac = GetFrame_D2(item, frames, &rate);
|
|
|
|
obj = &Objects[item->objectNumber];
|
|
|
|
|
|
|
|
//if (obj->shadowSize)
|
|
|
|
// S_PrintShadow(obj->shadowSize, frames[0], item, NULL);
|
|
|
|
|
|
|
|
phd_PushMatrix();
|
|
|
|
phd_TranslateAbs(item->pos.xPos, item->pos.yPos, item->pos.zPos);
|
|
|
|
phd_RotYXZ(item->pos.yRot, item->pos.xRot, item->pos.zRot);
|
|
|
|
|
|
|
|
// checking objectMip there, deleted !
|
|
|
|
|
|
|
|
sub_42B4C0(item, frames[0]);
|
|
|
|
if (phd_ClipBoundingBox(frames[0]))
|
|
|
|
{
|
2019-12-06 15:26:18 +01:00
|
|
|
//CalculateObjectLighting(item, frames[0]);
|
2019-11-25 13:18:24 +01:00
|
|
|
|
|
|
|
if (item->data == NULL)
|
|
|
|
extra_rotation = NullRotations;
|
|
|
|
else
|
2019-11-27 15:12:35 +01:00
|
|
|
extra_rotation = (short*)item->data;
|
2019-11-25 13:18:24 +01:00
|
|
|
|
|
|
|
mesh = &Meshes[Objects[item->objectNumber].meshIndex];
|
|
|
|
bones = &Bones[obj->boneIndex];
|
|
|
|
bit = 1;
|
|
|
|
|
|
|
|
if (!frac)
|
|
|
|
{
|
|
|
|
phd_TranslateRel((int)*(frames[0] + 6), (int)*(frames[0] + 7), (int)*(frames[0] + 8)); // can be [0][6] etc.. ?
|
2019-11-27 15:12:35 +01:00
|
|
|
rotation1 = (short*)(frames[0] + 9);
|
2019-11-25 13:18:24 +01:00
|
|
|
gar_RotYXZsuperpack(&rotation1, 0);
|
|
|
|
|
|
|
|
if (item->meshBits & bit)
|
|
|
|
phd_PutPolygons(*mesh);
|
|
|
|
|
|
|
|
for (i = (obj->nmeshes - 1); i > 0; i--, bones += 4, mesh += 2)
|
|
|
|
{
|
|
|
|
poppush = *bones;
|
|
|
|
|
|
|
|
if (poppush & 1)
|
|
|
|
{
|
|
|
|
phd_PopMatrix();
|
|
|
|
phd_PopDxMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (poppush & 2)
|
|
|
|
phd_PushMatrix();
|
|
|
|
|
|
|
|
phd_TranslateRel(*(bones + 1), *(bones + 2), *(bones + 3));
|
|
|
|
gar_RotYXZsuperpack(&rotation1, 0);
|
|
|
|
|
|
|
|
if (extra_rotation && (poppush & (ROT_X | ROT_Y | ROT_Z)))
|
|
|
|
{
|
|
|
|
if (poppush & ROT_Y)
|
|
|
|
phd_RotY(*(extra_rotation++));
|
|
|
|
if (poppush & ROT_X)
|
|
|
|
phd_RotX(*(extra_rotation++));
|
|
|
|
if (poppush & ROT_Z)
|
|
|
|
phd_RotZ(*(extra_rotation++));
|
|
|
|
}
|
|
|
|
|
|
|
|
bit <<= 1;
|
|
|
|
if (item->meshBits & bit)
|
|
|
|
phd_PutPolygons(*mesh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InitInterpolate(frac, rate);
|
|
|
|
phd_TranslateRel_ID((int)*(frames[0] + 6), (int)*(frames[0] + 7), (int)*(frames[0] + 8), (int)*(frames[1] + 6), (int)*(frames[1] + 7), (int)*(frames[1] + 8));
|
|
|
|
rotation1 = (short*)(frames[0] + 9);
|
|
|
|
rotation2 = (short*)(frames[1] + 9);
|
|
|
|
gar_RotYXZsuperpack_I(&rotation1, &rotation2, 0);
|
|
|
|
|
|
|
|
if (item->meshBits & bit)
|
|
|
|
phd_PutPolygons_I(*mesh);
|
|
|
|
|
|
|
|
for (i = (obj->nmeshes - 1); i > 0; i--, bones += 4, mesh += 2)
|
|
|
|
{
|
|
|
|
poppush = *bones;
|
|
|
|
if (poppush & 1)
|
|
|
|
phd_PopMatrix_I();
|
|
|
|
|
|
|
|
if (poppush & 2)
|
|
|
|
phd_PushMatrix_I();
|
|
|
|
|
|
|
|
phd_TranslateRel_I(*(bones + 1), *(bones + 2), *(bones + 3));
|
|
|
|
gar_RotYXZsuperpack_I(&rotation1, &rotation2, 0);
|
|
|
|
|
|
|
|
if (extra_rotation && (poppush & (ROT_X | ROT_Y | ROT_Z)))
|
|
|
|
{
|
|
|
|
if (poppush & ROT_Y)
|
|
|
|
phd_RotY_I(*(extra_rotation++));
|
|
|
|
if (poppush & ROT_X)
|
|
|
|
phd_RotX_I(*(extra_rotation++));
|
|
|
|
if (poppush & ROT_Z)
|
|
|
|
phd_RotZ_I(*(extra_rotation++));
|
|
|
|
}
|
|
|
|
|
|
|
|
bit <<= 1;
|
|
|
|
if (item->meshBits & bit)
|
|
|
|
phd_PutPolygons_I(*mesh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PhdRight = PhdWidth;
|
|
|
|
PhdLeft = 0;
|
|
|
|
PhdTop = 0;
|
|
|
|
PhdBottom = PhdHeight;
|
|
|
|
phd_PopMatrix();
|
2019-12-02 09:11:21 +01:00
|
|
|
phd_PopDxMatrix();*/
|
2019-11-25 13:18:24 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
int GetFrame_D2(ITEM_INFO* item, short* framePtr[], int* rate)
|
2018-09-12 20:37:37 +02:00
|
|
|
{
|
|
|
|
ANIM_STRUCT *anim;
|
2019-11-25 13:18:24 +01:00
|
|
|
int frm;
|
|
|
|
int first, second;
|
|
|
|
int frame_size;
|
|
|
|
int interp, rat;
|
2018-09-12 20:37:37 +02:00
|
|
|
|
|
|
|
frm = item->frameNumber;
|
|
|
|
anim = &Anims[item->animNumber];
|
|
|
|
framePtr[0] = framePtr[1] = anim->framePtr;
|
|
|
|
rat = *rate = anim->interpolation & 0x00ff;
|
|
|
|
frame_size = anim->interpolation >> 8;
|
|
|
|
frm -= anim->frameBase;
|
|
|
|
first = frm / rat;
|
|
|
|
interp = frm % rat;
|
|
|
|
framePtr[0] += first * frame_size; // Get Frame pointers
|
|
|
|
framePtr[1] = framePtr[0] + frame_size; // and store away
|
|
|
|
if (interp == 0)
|
|
|
|
return(0);
|
|
|
|
second = first * rat + rat;
|
|
|
|
if (second>anim->frameEnd) // Clamp KeyFrame to End if need be
|
|
|
|
*rate = anim->frameEnd - (second - rat);
|
|
|
|
return(interp);
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
void _InitInterpolate(void)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_PushMatrix(void)
|
|
|
|
{
|
|
|
|
}
|
2019-05-31 21:45:13 +02:00
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
void _phd_PushMatrix_I(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_PushUnitMatrix(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotYXZ(short ry, short rx, short rz)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotY(short ry)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotY_I(short ry)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotX(short rx)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotX_I(short rx)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotZ(short rz)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotZ_I(short rz)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_PutPolygons(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_PutPolygons_I(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_TranslateRel(int x, int y, int z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_TranslateRel_I(int x, int y, int z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_TranslateRel_ID(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_TranslateAbs(int x, int y, int z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_RotYXZpack(short ry, short rx, short rz)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _gar_RotYXZsuperpack(short** pproc, int skip)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _gar_RotYXZsuperpack_I(short** pproc1, short** pproc2, int skip)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_ClipBoundingBox(short* frames)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxTranslateRel(int x, int y, int z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxTranslateAbs(int x, int y, int z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxRotY(short ry)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxRotX(short rx)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxRotZ(short rz)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxRotYXZ(short ry, short rx, short rz)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_DxRotYXZpack(int rangle)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void phd_PopMatrix(void)
|
|
|
|
{
|
|
|
|
MatrixPtr -= 12;
|
2019-12-30 21:10:01 +01:00
|
|
|
DxMatrixPtr -= 48;
|
2019-11-27 15:12:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void _phd_PopMatrix_I(void)
|
|
|
|
{
|
|
|
|
MatrixPtr -= 12;
|
|
|
|
DxMatrixPtr -= 48;
|
2020-01-16 19:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CollectRooms(short roomNumber)
|
|
|
|
{
|
|
|
|
roomNumber = Camera.pos.roomNumber;
|
|
|
|
|
|
|
|
if (roomNumber < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ROOM_INFO* r = &Rooms[roomNumber];
|
|
|
|
|
|
|
|
r->testLeft = 0;
|
|
|
|
PhdLeft = 0;
|
|
|
|
r->testTop = 0;
|
|
|
|
PhdTop = 0;
|
|
|
|
r->testRight = PhdWindowXmax;
|
|
|
|
PhdRight = PhdWindowXmax;
|
|
|
|
r->testBottom = PhdWindowYmax;
|
|
|
|
PhdBottom = PhdWindowYmax;
|
|
|
|
|
|
|
|
OutsideRoomExists = false;
|
|
|
|
Outside = r->flags & ENV_FLAG_OUTSIDE;
|
|
|
|
Underwater = r->flags & ENV_FLAG_WATER;
|
|
|
|
|
|
|
|
r->boundActive = 2;
|
|
|
|
|
|
|
|
BoundList[0] = roomNumber;
|
|
|
|
BoundStart = 0;
|
|
|
|
BoundEnd = 1;
|
|
|
|
NumberDrawnRooms = 0;
|
|
|
|
|
|
|
|
if (Outside)
|
|
|
|
{
|
|
|
|
OutsideTop = 0;
|
|
|
|
OutsideLeft = 0;
|
|
|
|
OutsideRight = PhdWindowXmax;
|
|
|
|
OutsideBottom = PhdWindowYmax;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OutsideLeft = PhdWindowXmax;
|
|
|
|
OutsideTop = PhdWindowYmax;
|
|
|
|
OutsideBottom = 0;
|
|
|
|
OutsideRight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetRoomBounds();
|
|
|
|
|
|
|
|
printf("Number rooms: %d\n", NumberDrawnRooms);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetRoomBounds()
|
|
|
|
{
|
|
|
|
short roomNumber;
|
|
|
|
ROOM_INFO* r;
|
|
|
|
short* door;
|
|
|
|
short numDoors;
|
|
|
|
|
|
|
|
while (BoundStart != BoundEnd)
|
|
|
|
{
|
|
|
|
roomNumber = BoundList[(BoundStart++) % 128];
|
|
|
|
r = &Rooms[roomNumber];
|
|
|
|
r->boundActive -= 2;
|
|
|
|
|
|
|
|
if (r->testLeft < r->left)
|
|
|
|
r->left = r->testLeft;
|
|
|
|
if (r->testTop < r->top)
|
|
|
|
r->top = r->testTop;
|
|
|
|
if (r->testRight > r->right)
|
|
|
|
r->right = r->testRight;
|
|
|
|
if (r->testBottom > r->bottom)
|
|
|
|
r->bottom = r->testBottom;
|
|
|
|
|
|
|
|
if (!(r->boundActive & 1))
|
|
|
|
{
|
|
|
|
DrawnRooms[NumberDrawnRooms++] = roomNumber;
|
|
|
|
|
|
|
|
if (r->flags & ENV_FLAG_OUTSIDE)
|
|
|
|
Outside = ENV_FLAG_OUTSIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r->flags & ENV_FLAG_OUTSIDE)
|
|
|
|
{
|
|
|
|
if (r->left < OutsideLeft)
|
|
|
|
OutsideLeft = r->left;
|
|
|
|
if (r->right > OutsideRight)
|
|
|
|
OutsideRight = r->right;
|
|
|
|
if (r->top < OutsideTop)
|
|
|
|
OutsideTop = r->top;
|
|
|
|
if (r->bottom > OutsideBottom)
|
|
|
|
OutsideBottom = r->bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
phd_PushMatrix();
|
|
|
|
phd_TranslateAbs(r->x, r->y, r->z);
|
|
|
|
|
|
|
|
door = r->door;
|
|
|
|
if (door)
|
|
|
|
{
|
|
|
|
numDoors = *(door++);
|
|
|
|
|
|
|
|
for (int i = 0; i < numDoors; i++, door += 15)
|
|
|
|
{
|
|
|
|
roomNumber = *(door++);
|
|
|
|
|
|
|
|
if (Rooms[roomNumber].flags & ENV_FLAG_OUTSIDE)
|
|
|
|
OutsideRoomExists = true;
|
|
|
|
|
|
|
|
int xc = W2VMatrix[M03];
|
|
|
|
int yc = W2VMatrix[M13];
|
|
|
|
int zc = W2VMatrix[M23];
|
|
|
|
|
|
|
|
// TODO: discard W2VMatrix and use directly camera position
|
|
|
|
if ((int)(door[0] * (r->x + door[3] - W2VMatrix[M03]))
|
|
|
|
+ (int)(door[1] * (r->y + door[4] - W2VMatrix[M13]))
|
|
|
|
+ (int)(door[2] * (r->z + door[5] - W2VMatrix[M23]))
|
|
|
|
>= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SetRoomBounds(door, roomNumber, r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
phd_PopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetRoomBounds(short* door, int roomNumber, ROOM_INFO* parent)
|
|
|
|
{
|
|
|
|
ROOM_INFO* r = &Rooms[roomNumber];
|
|
|
|
PHD_VECTOR* dest;
|
|
|
|
PHD_VECTOR* last;
|
|
|
|
int xv, yv, zv;
|
|
|
|
int xs, ys, zs;
|
|
|
|
|
|
|
|
if (r->left <= parent->testLeft
|
|
|
|
&& r->right >= parent->testRight
|
|
|
|
&& r->top <= parent->testTop
|
|
|
|
&& r->bottom >= parent->testBottom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int left = parent->testRight;
|
|
|
|
int right = parent->testLeft;
|
|
|
|
int top = parent->testBottom;
|
|
|
|
int bottom = parent->testTop;
|
|
|
|
|
|
|
|
door += 3;
|
|
|
|
|
|
|
|
int zBehind = 0;
|
|
|
|
int zTooFar = 0;
|
|
|
|
|
|
|
|
dest = DoorBuffer;
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++, dest++, door += 3)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
printf("M%d: %d ", i, MatrixPtr[i]);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
dest->x = xv = (int)(MatrixPtr[M00] * door[0] + MatrixPtr[M01] * door[1] + MatrixPtr[M02] * door[2] + MatrixPtr[M03]);
|
|
|
|
dest->y = yv = (int)(MatrixPtr[M10] * door[0] + MatrixPtr[M11] * door[1] + MatrixPtr[M12] * door[2] + MatrixPtr[M13]);
|
|
|
|
dest->z = zv = (int)(MatrixPtr[M20] * door[0] + MatrixPtr[M21] * door[1] + MatrixPtr[M22] * door[2] + MatrixPtr[M23]);
|
|
|
|
|
|
|
|
/* Convert to screen space (special if -z behind you) */
|
|
|
|
if (zv > 0)
|
|
|
|
{
|
|
|
|
/* Keep count of number of points too far away */
|
|
|
|
if (zv > PhdZFar)
|
|
|
|
zTooFar++;
|
|
|
|
|
|
|
|
zv /= PhdPerspective;
|
|
|
|
if (zv)
|
|
|
|
{
|
|
|
|
xs = xv / zv + PhdCentreX;
|
|
|
|
ys = yv / zv + PhdCentreY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xs = (xv >= 0) ? PhdRight : PhdLeft;
|
|
|
|
ys = (yv >= 0) ? PhdBottom : PhdTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See if change bounds */
|
|
|
|
if (xs - 1 < left)
|
|
|
|
left = xs - 1;
|
|
|
|
if (xs + 1 > right)
|
|
|
|
right = xs + 1;
|
|
|
|
|
|
|
|
if (ys - 1 < top)
|
|
|
|
top = ys - 1;
|
|
|
|
if (ys + 1 > bottom)
|
|
|
|
bottom = ys + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
zBehind++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zBehind == 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (zBehind > 0)
|
|
|
|
{
|
|
|
|
dest = &DoorBuffer[0];
|
|
|
|
last = &DoorBuffer[3];
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++, last = dest, dest++)
|
|
|
|
{
|
|
|
|
/* Only if one point in front and one behind z=0 */
|
|
|
|
if ((dest->z <= 0) ^ (last->z <= 0))
|
|
|
|
{
|
|
|
|
/* x-clip */
|
|
|
|
if (dest->x < 0 && last->x < 0)
|
|
|
|
left = 0;
|
|
|
|
else if (dest->x > 0 && last->x > 0)
|
|
|
|
right = PhdWindowXmax;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
left = 0;
|
|
|
|
right = PhdWindowXmax;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* y-clip */
|
|
|
|
if (dest->y < 0 && last->y < 0)
|
|
|
|
top = 0;
|
|
|
|
else if (dest->y > 0 && last->y > 0)
|
|
|
|
bottom = PhdWindowYmax;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
top = 0;
|
|
|
|
bottom = PhdWindowYmax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clip bounds to parent window */
|
|
|
|
if (left < parent->testLeft)
|
|
|
|
left = parent->testLeft;
|
|
|
|
if (right > parent->testRight)
|
|
|
|
right = parent->testRight;
|
|
|
|
if (top < parent->testTop)
|
|
|
|
top = parent->testTop;
|
|
|
|
if (bottom > parent->testBottom)
|
|
|
|
bottom = parent->testBottom;
|
|
|
|
|
|
|
|
if (left >= right || top >= bottom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (r->boundActive & 2)
|
|
|
|
{
|
|
|
|
if (r->testLeft > left)
|
|
|
|
{
|
|
|
|
r->Separator5[0] = left;
|
|
|
|
r->testLeft = left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r->testTop > top)
|
|
|
|
{
|
|
|
|
r->Separator5[2] = top;
|
|
|
|
r->testTop = top;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r->testRight < right)
|
|
|
|
{
|
|
|
|
r->Separator5[1] = right;
|
|
|
|
r->testRight = right;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r->testBottom < bottom)
|
|
|
|
{
|
|
|
|
r->Separator5[3] = bottom;
|
|
|
|
r->testBottom = bottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BoundList[(BoundEnd++) % 128] = roomNumber;
|
|
|
|
|
|
|
|
r->boundActive |= 2u;
|
|
|
|
r->testLeft = left;
|
|
|
|
r->testRight = right;
|
|
|
|
r->testTop = top;
|
|
|
|
r->testBottom = bottom;
|
|
|
|
r->Separator5[0] = left;
|
|
|
|
r->Separator5[1] = right;
|
|
|
|
r->Separator5[2] = top;
|
|
|
|
r->Separator5[3] = bottom;
|
|
|
|
}
|
2019-11-27 15:12:35 +01:00
|
|
|
}
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
void Inject_Draw()
|
|
|
|
{
|
2019-11-25 13:18:24 +01:00
|
|
|
//INJECT(0x0042B900, DrawAnimatingItem);
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|