mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-11 21:44:00 +00:00
CFluidUVMotion: Return std::array by value from CalculateFluidTextureOffset()
Same behavior, but allows for easier use of API and makes it harder to misuse. It also makes it easier for analysis to determine out of bounds, given we leverage std::array rather than a pointer that causes arrays to decay and lose their size information.
This commit is contained in:
@@ -25,15 +25,16 @@ CFluidUVMotion::CFluidUVMotion(float timeToWrap, float orientation)
|
||||
x0_fluidLayers[2].x8_orientation = 0.78539819f;
|
||||
}
|
||||
|
||||
void CFluidUVMotion::CalculateFluidTextureOffset(float t, float offsets[3][2]) const {
|
||||
float totalYOffset = t * x4c_ooTimeToWrap * std::cos(x50_orientation);
|
||||
float totalXOffset = t * x4c_ooTimeToWrap * std::sin(x50_orientation);
|
||||
CFluidUVMotion::FluidOffsets CFluidUVMotion::CalculateFluidTextureOffset(float t) const {
|
||||
FluidOffsets offsets;
|
||||
const float totalYOffset = t * x4c_ooTimeToWrap * std::cos(x50_orientation);
|
||||
const float totalXOffset = t * x4c_ooTimeToWrap * std::sin(x50_orientation);
|
||||
|
||||
for (u32 i = 0; i < x0_fluidLayers.size(); ++i) {
|
||||
for (size_t i = 0; i < x0_fluidLayers.size(); ++i) {
|
||||
const SFluidLayerMotion& layer = x0_fluidLayers[i];
|
||||
|
||||
float speedT = t * layer.x4_ooTimeToWrap;
|
||||
float cycleT = speedT - std::floor(speedT);
|
||||
const float speedT = t * layer.x4_ooTimeToWrap;
|
||||
const float cycleT = speedT - std::floor(speedT);
|
||||
float localY;
|
||||
float localX;
|
||||
switch (layer.x0_motion) {
|
||||
@@ -42,7 +43,7 @@ void CFluidUVMotion::CalculateFluidTextureOffset(float t, float offsets[3][2]) c
|
||||
localY = 0.f;
|
||||
} break;
|
||||
case EFluidUVMotion::Circular: {
|
||||
float angle = (M_PIF * 2) * cycleT;
|
||||
const float angle = (M_PIF * 2) * cycleT;
|
||||
localY = layer.xc_magnitude * std::sin(angle);
|
||||
localX = layer.xc_magnitude * std::cos(angle);
|
||||
} break;
|
||||
@@ -55,11 +56,13 @@ void CFluidUVMotion::CalculateFluidTextureOffset(float t, float offsets[3][2]) c
|
||||
break;
|
||||
}
|
||||
|
||||
float x = localX * std::sin(layer.x8_orientation) + localY * std::cos(layer.x8_orientation) + totalXOffset;
|
||||
float y = localY * std::sin(layer.x8_orientation) + localX * std::cos(layer.x8_orientation) + totalYOffset;
|
||||
const float x = localX * std::sin(layer.x8_orientation) + localY * std::cos(layer.x8_orientation) + totalXOffset;
|
||||
const float y = localY * std::sin(layer.x8_orientation) + localX * std::cos(layer.x8_orientation) + totalYOffset;
|
||||
|
||||
offsets[i][0] = x - std::floor(x);
|
||||
offsets[i][1] = y - std::floor(y);
|
||||
}
|
||||
|
||||
return offsets;
|
||||
}
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user