Page 1 of 1

Texture alignment with origin brushes and func_door_rotate

Posted: Wed Feb 18, 2015 5:20 am
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?

Re: Texture alignment with origin brushes and func_door_rota

Posted: Wed Feb 18, 2015 8:10 am
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.

Re: Texture alignment with origin brushes and func_door_rota

Posted: Wed Feb 18, 2015 9:31 pm
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.

Re: Texture alignment with origin brushes and func_door_rota

Posted: Wed Feb 18, 2015 9:51 pm
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.

Re: Texture alignment with origin brushes and func_door_rota

Posted: Wed Mar 04, 2015 5:02 am
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.

Re: Texture alignment with origin brushes and func_door_rota

Posted: Sun May 29, 2016 8:44 am
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.

Re: Texture alignment with origin brushes and func_door_rota

Posted: Wed Jun 01, 2016 2:23 am
by jitspoe
Awesome. I'll enable it by default as well. Good call.