Speed up weapon draw

This commit is contained in:
Vladislav Khorev committed 2026-11-17 19:12:53 +06:00
1 parent 53328484b8
commit 4e40a1825a
3 files changed
+88 -2

No files matched your search

+8 -2
View File
@@ -40,6 +40,9 @@ void CharacterState::configureAsPlayer() {
Eigen::AngleAxisf(-PI * 0.5f, Eigen::Vector3f::UnitX()));
canAttack = true;
isPlayer = true;
animationPlaybackRates.fill(1.0f);
animationPlaybackRates[static_cast<std::size_t>(AnimationState::STAND_TO_ACTION)] = 2.0f;
animationPlaybackRates[static_cast<std::size_t>(AnimationState::ACTION_TO_STAND)] = 2.0f;
}
void CharacterState::configureNavigationRetryCooldowns(
@@ -452,7 +455,11 @@ CharacterUpdateEvents CharacterState::update(
? static_cast<float>(animationStartFrames[index]) : 0.f;
}
const int previousFrame = static_cast<int>(animationFrame);
animationFrame += static_cast<float>(deltaMs) / 24.f;
const auto animationIndex = static_cast<std::size_t>(currentState);
const float playbackRate =
animationIndex < animationPlaybackRates.size()
? animationPlaybackRates[animationIndex] : 1.0f;
animationFrame += static_cast<float>(deltaMs) / 24.f * playbackRate;
if (previousFrame < 19 && static_cast<int>(animationFrame) >= 19 &&
(currentState == AnimationState::ACTION_ATTACK ||
@@ -482,7 +489,6 @@ CharacterUpdateEvents CharacterState::update(
currentState == AnimationState::ACTION_ATTACK ||
currentState == AnimationState::ACTION_IDLE;
const auto animationIndex = static_cast<std::size_t>(currentState);
const int frameCount = animationIndex < animationFrameCounts.size()
? animationFrameCounts[animationIndex] : 1;
if (frameCount > 1 && static_cast<int>(animationFrame) >= frameCount - 1) {
+3
View File
@@ -107,6 +107,9 @@ public:
float animationFrame = 0.0f;
std::array<int, 9> animationStartFrames = {{0, 0, 0, 0, 0, 0, 0, 0, 0}};
std::array<int, 9> animationFrameCounts = {{1, 1, 1, 1, 1, 1, 1, 1, 1}};
std::array<float, 9> animationPlaybackRates = {{
1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f}};
// --- Movement / visual parameters ---
fp walkSpeed = static_cast<fp>(3.0f);