rodecomp/Source/Contents/Models/ModelTextureAnimation.cpp
ragnarok-clanker a47d20f8be Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.

Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
2026-10-25 07:42:41 +00:00

34 lines
1 KiB
C++

#include "Contents/Models/ModelNode.h"
// OFFSET: 0x00540EA0
// FUNCTION: fn_01727
void SampleModelTexture(const ModelTextureChannels& channels, float frame, ModelTextureTransform& output) {
for (int channel = 0; channel < 5; ++channel) {
const auto found = channels.find(channel);
if (found == channels.end()) {
continue;
}
const auto& keys = found->second;
const int last = keys.back().frame;
if (frame >= static_cast<float>(last)) {
output.values[channel] = keys.back().value;
continue;
}
unsigned next = 1;
while (next < keys.size() && !(static_cast<float>(keys[next].frame) > frame)) {
++next;
}
const int previous = keys[next - 1].frame;
const int difference = keys[next].frame - keys[next - 1].frame;
const float amount = (frame - static_cast<float>(previous)) / static_cast<float>(difference);
const float first = (1.0f - amount) * keys[next - 1].value;
const float second = amount * keys[next].value;
output.values[channel] = first + second;
}
}