summaryrefslogtreecommitdiff
path: root/mm/2s2h/resource/type/TextureAnimation.cpp
blob: 69aab10078454969cc4b4c554e821432d8ed7a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "TextureAnimation.h"

namespace SOH {
TextureAnimation::~TextureAnimation() {
    for (auto& a : anims) {
        switch ((TextureAnimationParamsType)a.type) {
            case TextureAnimationParamsType::SingleScroll:
                // a.params is a void* and must be allocated and freed with malloc/free
                free(a.params);
                break;
            case TextureAnimationParamsType::DualScroll:
                free(a.params);
                break;
            case TextureAnimationParamsType::ColorChange:
            case TextureAnimationParamsType::ColorChangeLERP:
            case TextureAnimationParamsType::ColorChangeLagrange:
                delete[]((AnimatedMatColorParams*)a.params)->keyFrames;
                delete[]((AnimatedMatColorParams*)a.params)->primColors;
                delete[]((AnimatedMatColorParams*)a.params)->envColors;
                free(a.params);
                break;
            case TextureAnimationParamsType::TextureCycle:
                // BENTODO free the textures
                delete[]((AnimatedMatTexCycleParams*)a.params)->textureIndexList;
                delete[]((AnimatedMatTexCycleParams*)a.params)->textureList;
                free(a.params);
                break;
        }
    }
}
AnimatedMaterial* TextureAnimation::GetPointer() {
    return anims.data();
}
size_t TextureAnimation::GetPointerSize() {
    return anims.size() * sizeof(AnimatedMaterial);
}
} // namespace SOH