TombEngine/TR5Main/Game/effects/footprint.cpp

84 lines
1.9 KiB
C++
Raw Normal View History

#include "framework.h"
2021-09-19 23:41:26 +03:00
#include "control/control.h"
#include "lara.h"
#include "animation.h"
2021-09-25 16:00:30 +03:00
#include "effects/groundfx.h"
#include "effects/footprint.h"
#include "level.h"
2020-05-28 22:17:55 +02:00
#include "items.h"
2021-09-25 11:27:47 +02:00
2021-08-30 18:03:21 +03:00
namespace TEN {
namespace Effects {
namespace Footprints {
std::deque<FOOTPRINT_STRUCT> footprints = std::deque<FOOTPRINT_STRUCT>();
bool CheckFootOnFloor(ITEM_INFO const & item, int mesh, PHD_3DPOS& outFootprintPosition)
{
int x = item.pos.xPos;
int y = item.pos.yPos;
int z = item.pos.zPos;
short roomNumber = item.roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
2021-09-14 17:04:57 +03:00
if (!(floor->Material == GroundMaterial::Sand ||
floor->Material == GroundMaterial::Snow ||
floor->Material == GroundMaterial::Gravel ||
floor->Material == GroundMaterial::Mud))
{
return false;
}
PHD_VECTOR pos;
pos.x = pos.z = 0;
pos.y = FOOT_HEIGHT_OFFSET;
GetLaraJointPosition(&pos, mesh);
2021-11-01 04:38:09 +03:00
int height = GetFloorHeight(floor, pos.x, pos.y - STEP_SIZE, pos.z);
outFootprintPosition.xPos = pos.x;
outFootprintPosition.zPos = pos.z;
2021-11-01 04:38:09 +03:00
outFootprintPosition.yPos = height - 8;
outFootprintPosition.yRot = item.pos.yRot + ANGLE(180);
return abs(pos.y - height) < 32;
}
void UpdateFootprints()
{
if (footprints.size() == 0)
return;
int numInvalidFootprints = 0;
for (auto i = footprints.begin(); i != footprints.end(); i++)
{
FOOTPRINT_STRUCT& footprint = *i;
footprint.life--;
if (footprint.life <= 0)
{
numInvalidFootprints++;
continue;
2020-05-28 22:17:55 +02:00
}
if (footprint.life > footprint.lifeStartFading)
2020-05-28 22:17:55 +02:00
{
footprint.opacity = footprint.startOpacity;
2020-05-28 22:17:55 +02:00
}
else
{
float opacity = lerp(0, footprint.startOpacity, fmax(0, fmin(1, footprint.life / (float)footprint.lifeStartFading)));
footprint.opacity = opacity;
}
}
for (int i = 0; i < numInvalidFootprints; i++)
{
footprints.pop_back();
}
}
}
}
2020-05-28 22:17:55 +02:00
}