ETPro command map clipping and noncoord fall fix


(Jaquboss) #1

credits: Zinx for all shaders and ideas as it is in shader file

  1. noncoord fall fix, well
    in cg_spawn.c
    there is

Here is how to allow etpro style command map clipping, very useful for small compasses

		if( CG_SpawnVector2D( "mapcoordsmins", "-128 128", cg.mapcoordsMins ) &&	// top left
		CG_SpawnVector2D( "mapcoordsmaxs", "128 -128", cg.mapcoordsMaxs ) ) {	// bottom right
		cg.mapcoordsValid = qtrue;
	} else {
		cg.mapcoordsValid = qfalse;
	}t

however CG_SpawnVector2D seems to not use default values, so solution may
a) fix it
b) add default values if fails
eg instead cg.mapcoordsValid = qfalse add

	if( CG_SpawnVector2D( "mapcoordsmins", "-128 128", cg.mapcoordsMins ) &&	// top left
		CG_SpawnVector2D( "mapcoordsmaxs", "128 -128", cg.mapcoordsMaxs ) ) {	// bottom right
		cg.mapcoordsValid = qtrue;
	} else {
		cg.mapcoordsValid = qfalse;
		cg.mapcoordsMaxs[0] = cg.mapcoordsMins[1] = 128;
		cg.mapcoordsMaxs[1] = cg.mapcoordsMins[0] = 128;
	}

not sure if server version flaws too
c) just dont draw command map when nothing is entered

so putting

	if ( cg.mapcoordsValid == qfalse) 
		return;

at begginings of :
CG_DrawNewCompass() ( cg_draw.c)
and CG_LimboPanel_RenderCommandMap() ( cg_limboPanel.c ) removes crashes…

  1. clipping: basicly etpro clippings works in etmain as well, BUT big command map is empty with it and it isnt smooth anyway …
    fixing it is easy
    first
    add above ( cg_commandmap.c
			if( cgs.ccLayers ) {
				CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[cgs.ccSelectedLayer] );
			} else {
				CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[0] );
			}
			CG_DrawPic( x, y, w, h, cgs.media.blackmask );

then in cg_local.c declare blackmask:
for eg just under

qhandle_t	commandCentreAutomapMaskShader;

add

	qhandle_t	blackmask;

and in cg_main.c
for example under

cgs.media.commandCentreAutomapMaskShader = trap_R_RegisterShaderNoMip( "levelshots/automap_mask" );

add

	cgs.media.blackmask = trap_R_RegisterShaderNoMip( "images/blackmask" );

now you need shader, this is pretty unfair to etpro team since it is their job but easiest way is just to take theirs , but you just need to add

depthwrite

to every shader on command map and do blackmask as etpro do

images/blackmask
{
	nopicmip 
	nocompress
	nomipmaps
	{
		map gfx/colors/ablack.tga
		depthwrite
		blendfunc blend
		rgbGen identity
		alphaGen vertex
	}
}

note that this is almost same as compass shader, this is just adding back cm icons on non compass maps
and now you need to smooth dissappearing icons on compass ( so this work has any sense )
it isnt anything hard just in CG_ScissorEntIsCulled() and CG_ScissorPointIsCulled()
(cg_commandmap.c)
change following both has

		if( distSquared > Square( 0.5f  * (scissor->br[0] - scissor->tl[0]) ) )
			return qtrue;

change it to following

		if( distSquared > Square( 0.5f * cg_compassTolerance.value * (scissor->br[0] - scissor->tl[0]) ) )
			return qtrue;

of course you can just change 0.5f to some value or do diffirent tricks but you should take in mind that not shaders will support and if you will remove whole clipping they will fly out of compass


(IneQuation) #2

Hey, thanks for sharing, Jaquboss, this surely will get used properly. :wink:


(Jaquboss) #3

shared because i had no use for it :slight_smile:
and anyway FalckonET has repositary at http://opensvn.csie.org/FalckonET/ so I share a lot :o