Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Memfis

How do TNT animated switches work?

Recommended Posts

The textures are ordered like this:

BLODGR1
SW1SKULL
BLOD3
BLODGR4

WFALL1
SW2SKULL
FALL3
WFALL4

OK, that's clever: they made the switches animated by putting them inside of the standard animations. But how does the engine know that it needs to change the texture if I press the switch while it's not in its SW1SKULL frame? Why does it treat every frame as a switch texture? Logically, I would expect this to work only 25% of the time.

Share this post


Link to post

Because the texture is still SW1SKULL technically.

 

Animation works by looking up the texture name used and translating it if needed. If you want to check the source code for that, grep for texturetranslation in the vanilla code. Here's an example:

//
// R_RenderMaskedSegRange
//
void
R_RenderMaskedSegRange
( drawseg_t*	ds,
  int		x1,
  int		x2 )
{
    unsigned	index;
    column_t*	col;
    int		lightnum;
    int		texnum;
    
    // Calculate light table.
    // Use different light tables
    //   for horizontal / vertical / diagonal. Diagonal?
    // OPTIMIZE: get rid of LIGHTSEGSHIFT globally
    curline = ds->curline;
    frontsector = curline->frontsector;
    backsector = curline->backsector;
    texnum = texturetranslation[curline->sidedef->midtexture];
	
    lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;

I'm skipping the rest of it. But you can see that the drawing function will look for the texture that is the translation of the sidedef's actual texture. Which means that the sidedef's actual texture isn't changed! Switches, on the other hand, check for and change the actual texture.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×