2020-05-27 09:21:20 +02:00
|
|
|
#include "framework.h"
|
2021-09-19 23:41:26 +03:00
|
|
|
#include "control/control.h"
|
2020-01-05 18:48:16 +01:00
|
|
|
#include "lara.h"
|
2021-09-16 05:06:03 +03:00
|
|
|
#include "animation.h"
|
2021-09-25 16:00:30 +03:00
|
|
|
#include "effects/groundfx.h"
|
|
|
|
#include "effects/footprint.h"
|
2020-05-27 09:21:20 +02:00
|
|
|
#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 {
|
2021-09-14 01:22:08 +03:00
|
|
|
namespace Effects {
|
|
|
|
namespace Footprints {
|
|
|
|
|
|
|
|
std::deque<FOOTPRINT_STRUCT> footprints = std::deque<FOOTPRINT_STRUCT>();
|
|
|
|
|
2021-11-02 02:01:04 +03:00
|
|
|
bool CheckFootOnFloor(ITEM_INFO const & item, int mesh, Vector3& outFootprintPosition)
|
2021-09-14 01:22:08 +03:00
|
|
|
{
|
|
|
|
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 ||
|
2021-09-14 01:22:08 +03:00
|
|
|
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);
|
2021-09-14 01:22:08 +03:00
|
|
|
|
2021-11-02 02:01:04 +03:00
|
|
|
outFootprintPosition.x = pos.x;
|
|
|
|
outFootprintPosition.y = height - 8;
|
|
|
|
outFootprintPosition.z = pos.z;
|
2021-09-14 01:22:08 +03:00
|
|
|
|
|
|
|
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;
|
2021-11-02 02:01:04 +03:00
|
|
|
footprint.Life--;
|
2021-09-14 01:22:08 +03:00
|
|
|
|
2021-11-02 02:01:04 +03:00
|
|
|
if (footprint.Life <= 0)
|
2021-09-14 01:22:08 +03:00
|
|
|
{
|
|
|
|
numInvalidFootprints++;
|
|
|
|
continue;
|
2020-05-28 22:17:55 +02:00
|
|
|
}
|
2021-09-14 01:22:08 +03:00
|
|
|
|
2021-11-02 02:01:04 +03:00
|
|
|
if (footprint.Life > footprint.LifeStartFading)
|
2020-05-28 22:17:55 +02:00
|
|
|
{
|
2021-11-02 02:01:04 +03:00
|
|
|
footprint.Opacity = footprint.StartOpacity;
|
2020-05-28 22:17:55 +02:00
|
|
|
}
|
2021-09-14 01:22:08 +03:00
|
|
|
else
|
|
|
|
{
|
2021-11-02 02:01:04 +03:00
|
|
|
float opacity = lerp(0, footprint.StartOpacity, fmax(0, fmin(1, footprint.Life / (float)footprint.LifeStartFading)));
|
|
|
|
footprint.Opacity = opacity;
|
2021-09-14 01:22:08 +03:00
|
|
|
}
|
|
|
|
}
|
2020-04-22 14:12:10 +02:00
|
|
|
|
2021-09-14 01:22:08 +03:00
|
|
|
for (int i = 0; i < numInvalidFootprints; i++)
|
|
|
|
{
|
|
|
|
footprints.pop_back();
|
2020-01-05 18:48:16 +01:00
|
|
|
}
|
2020-01-06 19:44:18 +01:00
|
|
|
}
|
2021-09-14 01:22:08 +03:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 22:17:55 +02:00
|
|
|
}
|