Skip to content

Commit

Permalink
Invert the texture location reading
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffyfreak authored and sturnclaw committed Jan 1, 2025
1 parent 91caceb commit e0f5244
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Sfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ void SfxManager::Add(const Body *b, SFX_TYPE t)

void SfxManager::AddExplosion(Body *b)
{
if (!b) return;

SfxManager *sfxman = AllocSfxInFrame(b->GetFrame());
if (!sfxman) return;

Expand Down Expand Up @@ -311,7 +313,8 @@ void SfxManager::RenderAll(Renderer *renderer, FrameId fId, FrameId camFrameId)
vector2f SfxManager::CalculateOffset(const enum SFX_TYPE type, const Sfx &inst)
{
if (m_materialData[type].effect == Graphics::EFFECT_BILLBOARD_ATLAS) {
const int spriteframe = inst.AgeBlend() * (m_materialData[type].num_textures - 1);
const Uint32 max_texture = (m_materialData[type].num_textures);
const int spriteframe = max_texture - (inst.AgeBlend() * max_texture); // count DOWN from the maximum texture to zero
const Sint32 numImgsWide = m_materialData[type].num_imgs_wide;
const int u = (spriteframe % numImgsWide); // % is the "modulo operator", the remainder of i / width;
const int v = (spriteframe / numImgsWide); // where "/" is an integer division
Expand Down

0 comments on commit e0f5244

Please sign in to comment.