Texture alignment with origin brushes and func_door_rotate

Discuss the construction of maps and the tools to create maps for 3D games.
Post Reply
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Texture alignment with origin brushes and func_door_rotate

Post by jitspoe »

I thought I saw this mentioned here somewhere, but I can't seem to find it.

I've just run into an issue working on a Quake2 map where converting my carefully aligned brushes into a func_door_rotating causes the textures to get all messed up. It seems the offsets are relative to the origin brush, instead of the world origin. Is this an editor bug? Compiler bug? Engine bug? What's the best way to go about fixing this?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Texture alignment with origin brushes and func_door_rota

Post by Spike »

I'm gonna say its a compiler bug, seeing as that's the one that actually adjusts the verticies+brushes ny subtacting the origin, that's the one that should also adjust the texture coords to match that new origin too.
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Texture alignment with origin brushes and func_door_rota

Post by jitspoe »

That's kind of what I was thinking. I just didn't want to try to fix it there, then discover it was misaligned in other Quake2 engines because the bug was fixed elsewhere.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Texture alignment with origin brushes and func_door_rota

Post by Spike »

if you fix it in the engine, you risk breaking vanilla content.
that said, few advanced quake2 engines can still run vanilla properly so I'm not sure it matters that much anyway.
fixing it in the engine requires parsing the entity lump to match model and origin fields. which is ugly enough that I doubt anyone sane bothered to do it.
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Texture alignment with origin brushes and func_door_rota

Post by jitspoe »

Well, when I was in the process of converting DeWan's modifications to the GPL codebase, I noticed this bit of code in TexinfoForBrushTexture():

Code: Select all

	/* Originally:
	 shift[0] = DotProduct (origin, vecs[0]);
	 shift[1] = DotProduct (origin, vecs[1]);
	*/

	if (!bt->scale[0])
		bt->scale[0] = 1;
	if (!bt->scale[1])
		bt->scale[1] = 1;


	// 
	if(origfix)
	{
		VectorScale(origin,1.0/bt->scale[0],scaled_origin);
		shift[0] = DotProduct (scaled_origin, vecs[0]);
		VectorScale(origin,1.0/bt->scale[1],scaled_origin);
		shift[1] = DotProduct (scaled_origin, vecs[1]);
	}
	else
	{
		shift[0] = DotProduct (origin, vecs[0]);
		shift[1] = DotProduct (origin, vecs[1]);
	}


// rotate axis
	if (bt->rotate == 0)
		{ sinv = 0 ; cosv = 1; }
	else if (bt->rotate == 90)
		{ sinv = 1 ; cosv = 0; }
	else if (bt->rotate == 180)
		{ sinv = 0 ; cosv = -1; }
	else if (bt->rotate == 270)
		{ sinv = -1 ; cosv = 0; }
	else
	{	
		ang = bt->rotate / 180 * Q_PI;
		sinv = sin(ang);
		cosv = cos(ang);
	}

	 // DWH: and again...
	 if(origfix)
	 {
	  ns = cosv * shift[0] - sinv * shift[1];
	  nt = sinv * shift[0] + cosv * shift[1];
	  shift[0] = ns;
	  shift[1] = nt;
	 }
So it looks like he at least made an attempt to fix it. I'll have to go back and revisit that later.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: Texture alignment with origin brushes and func_door_rota

Post by Knightmare »

That code in DeWan's QBSP3 DOES fix the texture alignment issue, you just have to add the -origfix parameter at the command line. My own KMQBSP3, which is derived from it, has this option enabled by default.
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Texture alignment with origin brushes and func_door_rota

Post by jitspoe »

Awesome. I'll enable it by default as well. Good call.
Post Reply