mirror of https://github.com/AxioDL/metaforce.git
CUVElement: Use const where applicable
While we're at it, we can also make conversions to float explicit.
This commit is contained in:
parent
c4ecf972f5
commit
35fb0e4911
|
@ -14,21 +14,29 @@ CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, std::unique_ptr<CIntEle
|
||||||
strideW->GetValue(0, x18_strideW);
|
strideW->GetValue(0, x18_strideW);
|
||||||
strideH->GetValue(0, x1c_strideH);
|
strideH->GetValue(0, x1c_strideH);
|
||||||
|
|
||||||
int width = x4_tex.GetObj()->GetWidth();
|
const int width = int(x4_tex.GetObj()->GetWidth());
|
||||||
int height = x4_tex.GetObj()->GetHeight();
|
const int height = int(x4_tex.GetObj()->GetHeight());
|
||||||
float widthF = width;
|
const float widthF = float(width);
|
||||||
float heightF = height;
|
const float heightF = float(height);
|
||||||
int xTiles = std::max(1, width / x18_strideW);
|
const int xTiles = std::max(1, width / x18_strideW);
|
||||||
int yTiles = std::max(1, height / x1c_strideH);
|
const int yTiles = std::max(1, height / x1c_strideH);
|
||||||
|
|
||||||
x20_tiles = xTiles * yTiles;
|
x20_tiles = xTiles * yTiles;
|
||||||
x2c_uvElems.reserve(x20_tiles);
|
x2c_uvElems.reserve(x20_tiles);
|
||||||
|
|
||||||
for (int y = yTiles - 1; y >= 0; --y) {
|
for (int y = yTiles - 1; y >= 0; --y) {
|
||||||
for (int x = 0; x < xTiles; ++x) {
|
for (int x = 0; x < xTiles; ++x) {
|
||||||
int px = x18_strideW * x;
|
const int px = x18_strideW * x;
|
||||||
int px2 = px + x10_tileW;
|
const int px2 = px + x10_tileW;
|
||||||
int py = x1c_strideH * y;
|
const int py = x1c_strideH * y;
|
||||||
int py2 = py + x14_tileH;
|
const int py2 = py + x14_tileH;
|
||||||
x2c_uvElems.push_back({px / widthF, py / heightF, px2 / widthF, py2 / heightF});
|
|
||||||
|
x2c_uvElems.push_back({
|
||||||
|
float(px) / widthF,
|
||||||
|
float(py) / heightF,
|
||||||
|
float(px2) / widthF,
|
||||||
|
float(py2) / heightF,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,17 +44,19 @@ CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, std::unique_ptr<CIntEle
|
||||||
void CUVEAnimTexture::GetValueUV(int frame, SUVElementSet& valOut) const {
|
void CUVEAnimTexture::GetValueUV(int frame, SUVElementSet& valOut) const {
|
||||||
int cv;
|
int cv;
|
||||||
x28_cycleFrames->GetValue(frame, cv);
|
x28_cycleFrames->GetValue(frame, cv);
|
||||||
float cvf = cv / float(x20_tiles);
|
float cvf = float(cv) / float(x20_tiles);
|
||||||
cvf = frame / cvf;
|
cvf = float(frame) / cvf;
|
||||||
|
|
||||||
int tile = cvf;
|
int tile = int(cvf);
|
||||||
if (x24_loop) {
|
if (x24_loop) {
|
||||||
if (cvf >= x20_tiles)
|
if (cvf >= float(x20_tiles)) {
|
||||||
tile = int(cvf) % x20_tiles;
|
tile = int(cvf) % x20_tiles;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cvf >= x20_tiles)
|
if (cvf >= float(x20_tiles)) {
|
||||||
tile = x20_tiles - 1;
|
tile = x20_tiles - 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
valOut = x2c_uvElems[tile];
|
valOut = x2c_uvElems[tile];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue