#pragma once
#include <set>
#include <span>
#include <vector>
#include <whiteout/models/m3/structures.h>
#include <whiteout/models/wem/anim/clip.h>
namespace whiteout {
namespace models {
namespace wem {
namespace m3_sink {
enum class Stream : u32 {
None = 0,
Sd2v = 1,
Sd3v = 2,
Sd4q = 3,
Sdcc = 4,
Sdr3 = 5,
Sds6 = 7,
Sdu3 = 10,
Sdfg = 11,
};
i32 Ticks(f32 seconds);
bool WarcraftWindow(const Clip& clip);
struct StreamSpec {
Stream stream = Stream::None;
geom::AttrType type = geom::AttrType::F32;
bool unrebaseVector = false;
bool unrebaseQuaternion = false;
const Quaternion* restQuaternion = nullptr;
};
u32 WriteStream(m3::SubTrackContainer& stc, const StreamSpec& spec, const SubTrack& track,
i32 origin, f32 duration, bool warcraft);
class Wiring {
public:
template <class T>
void wire(m3::AnimRef<T>& ref, u32 animId, Interpolation interp) {
ref.animId = animId;
if (interp != Interpolation::Step) {
moving_.insert(animId);
}
const bool step = interp == Interpolation::Step && moving_.count(animId) == 0;
ref.flags = kBound;
ref.interpType = step ? u16(0) : u16(1);
}
static constexpr u16 kBound = 0x6;
private:
std::set<u32> moving_;
};
void SortLookup(m3::SubTrackContainer& stc);
void AddToContainer(m3::Model& out, u32 stcIndex, u32 animId, u32 animRef);
std::vector<u32*> KeyableAnimIds(m3::Model& out);
void UnshareAnimIds(m3::Model& out);
SubTrack MergeColorAlpha(const SubTrack* color, const SubTrack* alpha, const Vector3f& restColor,
f32 restAlpha);
} } } }