2005-08-26 22:49:36 +00:00
# include "quakedef.h"
2007-05-25 22:16:29 +00:00
2012-04-09 19:12:12 +00:00
# ifdef TERRAIN
2005-08-26 22:49:36 +00:00
# include "glquake.h"
2009-11-04 21:16:50 +00:00
# include "shader.h"
2005-08-26 22:49:36 +00:00
2012-04-09 19:12:12 +00:00
# include "pr_common.h"
2012-07-21 04:43:31 +00:00
//#define STRICTEDGES //strict (ugly) grid
# define TERRAINTHICKNESS 16
2012-07-21 08:06:07 +00:00
# define TERRAINACTIVESECTIONS 1000
2012-07-21 04:43:31 +00:00
2012-11-27 03:23:19 +00:00
/*
a note on networking :
By default terrain is NOT networked . This means content is loaded without networking delays .
If you wish to edit the terrain collaboratively , you can enable the mod_terrain_networked cvar .
When set , changes on the server will notify clients that a section has changed , and the client will reload it as needed .
Changes on the client WILL NOT notify the server , and will get clobbered if the change is also made on the server .
This means for editing purposes , you MUST funnel it via ssqc with your own permission checks .
It also means for explosions and local stuff , the server will merely restate changes from impacts if you do them early . BUT DO NOT CALL THE EDIT FUNCTION IF THE SERVER HAS ALREADY APPLIED THE CHANGE .
*/
cvar_t mod_terrain_networked = CVARD ( " mod_terrain_networked " , " 0 " , " Terrain edits are networked. Clients will download sections on demand, and servers will notify clients of changes. " ) ;
2005-08-26 22:49:36 +00:00
//heightmaps work thusly:
//there is one raw heightmap file
//the file is split to 4*4 sections.
2012-04-09 19:12:12 +00:00
//each section is textured independantly (remember banshees are capped at 256*256 pixels)
2005-08-26 22:49:36 +00:00
//it's built into 16 seperate display lists, these display lists are individually culled, but the drivers are expected to optimise them too.
2012-04-09 19:12:12 +00:00
//Tei claims 14x speedup with a single display list. hopefully we can achieve the same speed by culling per-section.
2005-08-26 22:49:36 +00:00
//we get 20->130
2006-03-06 01:41:09 +00:00
//perhaps we should build it with multitexture? (no - slower on ati)
2005-08-26 22:49:36 +00:00
2012-09-30 05:52:03 +00:00
int Surf_NewLightmaps ( int count , int width , int height , qboolean deluxe ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-04-09 19:12:12 +00:00
# define MAXSECTIONS 64 //this many sections max in each direction
# define SECTTEXSIZE 64 //this many texture samples per section
2012-07-22 02:56:22 +00:00
# define SECTHEIGHTSIZE 17 //this many height samples per section
2005-08-26 22:49:36 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
//each section is this many sections higher in world space, to keep the middle centered at '0 0'
# define CHUNKBIAS (MAXSECTIONS*MAXSECTIONS / 2)
# define CHUNKLIMIT (MAXSECTIONS*MAXSECTIONS)
# define LMCHUNKS 2
# define HMLMSTRIDE (LMCHUNKS*SECTTEXSIZE)
# define SECTION_MAGIC (*(int*)"HMMS")
2012-07-22 02:56:22 +00:00
# define SECTION_VER 1
/*simple version history:
ver = 0
SECTHEIGHTSIZE = 16
*/
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
enum
{
2012-07-20 01:46:05 +00:00
//these flags can be found on disk
TSF_HASWATER = 1u < < 0 ,
2012-08-04 11:28:39 +00:00
TSF_HASCOLOURS = 1u < < 1 ,
2012-07-20 01:46:05 +00:00
//these flags should not be found on disk
2012-11-29 13:37:48 +00:00
TSF_NOTIFY = 1u < < 28 , //modified on server, waiting for clients to be told about the change.
2012-07-20 01:46:05 +00:00
TSF_RELIGHT = 1u < < 29 , //height edited, needs relighting.
TSF_DIRTY = 1u < < 30 , //its heightmap has changed, the mesh needs rebuilding
TSF_EDITED = 1u < < 31 //says it needs to be written if saved
2012-11-29 13:37:48 +00:00
# define TSF_INTERNAL (TSF_RELIGHT|TSF_DIRTY|TSF_EDITED|TSF_NOTIFY)
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
} ;
2012-07-20 01:46:05 +00:00
typedef struct
{
int size ;
vec3_t axisorg [ 4 ] ;
float scale ;
int reserved3 ;
int reserved2 ;
int reserved1 ;
//char modelname[1+];
} dsmesh_t ;
2012-04-09 19:12:12 +00:00
typedef struct
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
int magic ;
int ver ;
unsigned int flags ;
2012-04-09 19:12:12 +00:00
char texname [ 4 ] [ 32 ] ;
unsigned int texmap [ SECTTEXSIZE ] [ SECTTEXSIZE ] ;
float heights [ SECTHEIGHTSIZE * SECTHEIGHTSIZE ] ;
unsigned short holes ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
float waterheight ;
2012-07-14 17:25:21 +00:00
float minh ;
float maxh ;
2012-08-04 11:28:39 +00:00
int ents_num ;
int reserved1 ;
int reserved4 ;
2012-07-20 01:46:05 +00:00
int reserved3 ;
int reserved2 ;
2012-04-09 19:12:12 +00:00
} dsection_t ;
2012-08-04 11:28:39 +00:00
typedef struct hmpolyset_s
{
struct hmpolyset_s * next ;
shader_t * shader ;
mesh_t mesh ;
mesh_t * amesh ;
vbo_t vbo ;
} hmpolyset_t ;
2012-04-09 19:12:12 +00:00
typedef struct
{
2012-07-21 08:06:07 +00:00
link_t recycle ;
int sx , sy ;
2012-04-09 19:12:12 +00:00
float heights [ SECTHEIGHTSIZE * SECTHEIGHTSIZE ] ;
unsigned short holes ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
unsigned int flags ;
float waterheight ;
2012-07-14 17:25:21 +00:00
float minh , maxh ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
struct heightmap_s * hmmod ;
2012-04-09 19:12:12 +00:00
# ifndef SERVERONLY
2012-08-04 11:28:39 +00:00
vec4_t colours [ SECTHEIGHTSIZE * SECTHEIGHTSIZE ] ;
2012-04-09 19:12:12 +00:00
char texname [ 4 ] [ 32 ] ;
int lightmap ;
int lmx , lmy ;
texnums_t textures ;
vbo_t vbo ;
mesh_t mesh ;
mesh_t * amesh ;
2012-07-20 01:46:05 +00:00
int numents ;
int maxents ;
entity_t * ents ;
2012-08-04 11:28:39 +00:00
hmpolyset_t * polys ;
2012-04-09 19:12:12 +00:00
# endif
} hmsection_t ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
typedef struct
{
hmsection_t * section [ MAXSECTIONS * MAXSECTIONS ] ;
} hmcluster_t ;
2012-07-21 08:06:07 +00:00
typedef struct heightmap_s
{
2005-08-26 22:49:36 +00:00
char path [ MAX_QPATH ] ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
int firstsegx , firstsegy ;
int maxsegx , maxsegy ; //tex/cull sections
2012-04-09 19:12:12 +00:00
float sectionsize ; //each section is this big, in world coords
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
hmcluster_t * cluster [ MAXSECTIONS * MAXSECTIONS ] ;
2011-05-20 04:10:46 +00:00
shader_t * skyshader ;
shader_t * shader ;
2012-09-30 05:52:03 +00:00
shader_t * watershader ;
2011-05-20 04:10:46 +00:00
mesh_t skymesh ;
mesh_t * askymesh ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
unsigned int exteriorcontents ;
2012-08-04 11:28:39 +00:00
int tiled ;
int tilecount [ 2 ] ;
int tilepixcount [ 2 ] ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-07-21 08:06:07 +00:00
int activesections ;
link_t recycle ;
2012-07-14 17:25:21 +00:00
# ifndef SERVERONLY
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
struct lmsect_s
{
struct lmsect_s * next ;
int lm , x , y ;
} * unusedlmsects ;
2012-07-14 17:25:21 +00:00
# endif
2012-07-20 01:46:05 +00:00
# ifndef SERVERONLY
//I'm putting this here because we might have some quite expensive lighting routines going on
//and that'll make editing the terrain jerky as fook, so relighting it a few texels at a time will help maintain a framerate while editing
hmsection_t * relight ;
unsigned int relightidx ;
vec2_t relightmin ;
# endif
2005-08-26 22:49:36 +00:00
} heightmap_t ;
2012-07-20 01:46:05 +00:00
static void ted_dorelight ( heightmap_t * hm ) ;
2013-03-31 04:21:08 +00:00
static qboolean Terr_Collect ( heightmap_t * hm ) ;
2012-07-20 01:46:05 +00:00
2012-07-21 04:43:31 +00:00
# ifndef SERVERONLY
static texid_t Terr_LoadTexture ( char * name )
{
extern texid_t missing_texture ;
texid_t id ;
if ( * name )
{
id = R_LoadHiResTexture ( name , NULL , 0 ) ;
if ( ! TEXVALID ( id ) )
{
id = missing_texture ;
Con_Printf ( " Unable to load texture %s \n " , name ) ;
}
}
else
id = missing_texture ;
return id ;
}
# endif
2012-07-20 01:46:05 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
static void Terr_LoadSectionTextures ( hmsection_t * s )
2012-04-09 19:12:12 +00:00
{
# ifndef SERVERONLY
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
extern texid_t missing_texture ;
2012-04-09 19:12:12 +00:00
//CL_CheckOrEnqueDownloadFile(s->texname[0], NULL, 0);
//CL_CheckOrEnqueDownloadFile(s->texname[1], NULL, 0);
//CL_CheckOrEnqueDownloadFile(s->texname[2], NULL, 0);
//CL_CheckOrEnqueDownloadFile(s->texname[3], NULL, 0);
2012-08-04 11:28:39 +00:00
if ( s - > hmmod - > tiled )
{
s - > textures . base = Terr_LoadTexture ( va ( " maps/%s/atlas.tga " , s - > hmmod - > path ) ) ;
s - > textures . fullbright = Terr_LoadTexture ( va ( " maps/%s/atlas_luma.tga " , s - > hmmod - > path ) ) ;
s - > textures . bump = Terr_LoadTexture ( va ( " maps/%s/atlas_norm.tga " , s - > hmmod - > path ) ) ;
s - > textures . specular = Terr_LoadTexture ( va ( " maps/%s/atlas_spec.tga " , s - > hmmod - > path ) ) ;
s - > textures . upperoverlay = missing_texture ;
s - > textures . loweroverlay = missing_texture ;
}
else
{
s - > textures . base = Terr_LoadTexture ( s - > texname [ 0 ] ) ;
s - > textures . upperoverlay = Terr_LoadTexture ( s - > texname [ 1 ] ) ;
s - > textures . loweroverlay = Terr_LoadTexture ( s - > texname [ 2 ] ) ;
s - > textures . fullbright = Terr_LoadTexture ( s - > texname [ 3 ] ) ;
s - > textures . bump = * s - > texname [ 0 ] ? R_LoadHiResTexture ( va ( " %s_norm " , s - > texname [ 0 ] ) , NULL , 0 ) : r_nulltex ;
s - > textures . specular = * s - > texname [ 0 ] ? R_LoadHiResTexture ( va ( " %s_spec " , s - > texname [ 0 ] ) , NULL , 0 ) : r_nulltex ;
}
2012-04-09 19:12:12 +00:00
# endif
}
2012-07-14 17:25:21 +00:00
# ifndef SERVERONLY
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
static void Terr_InitLightmap ( hmsection_t * s )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
heightmap_t * hm = s - > hmmod ;
struct lmsect_s * lms ;
if ( ! hm - > unusedlmsects )
{
int lm ;
int i ;
2012-09-30 05:52:03 +00:00
lm = Surf_NewLightmaps ( 1 , SECTTEXSIZE * LMCHUNKS , SECTTEXSIZE * LMCHUNKS , false ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( i = 0 ; i < LMCHUNKS * LMCHUNKS ; i + + )
{
2013-03-31 04:21:08 +00:00
lms = BZ_Malloc ( sizeof ( * lms ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lms - > lm = lm ;
lms - > x = ( i & ( LMCHUNKS - 1 ) ) * SECTTEXSIZE ;
lms - > y = ( i / LMCHUNKS ) * SECTTEXSIZE ;
lms - > next = hm - > unusedlmsects ;
hm - > unusedlmsects = lms ;
}
}
lms = hm - > unusedlmsects ;
hm - > unusedlmsects = lms - > next ;
s - > lightmap = lms - > lm ;
s - > lmx = lms - > x ;
s - > lmy = lms - > y ;
2013-03-31 04:21:08 +00:00
Z_Free ( lms ) ;
2012-04-09 19:12:12 +00:00
}
2012-07-14 17:25:21 +00:00
# endif
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
static char * Terr_DiskSectionName ( heightmap_t * hm , int sx , int sy )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
sx - = CHUNKBIAS ;
sy - = CHUNKBIAS ;
//wrap cleanly
sx & = CHUNKLIMIT - 1 ;
sy & = CHUNKLIMIT - 1 ;
return va ( " maps/%s/sect_%03x_%03x.hms " , hm - > path , sx , sy ) ;
}
2012-11-27 03:23:19 +00:00
static char * Terr_TempDiskSectionName ( heightmap_t * hm , int sx , int sy )
{
sx - = CHUNKBIAS ;
sy - = CHUNKBIAS ;
//wrap cleanly
sx & = CHUNKLIMIT - 1 ;
sy & = CHUNKLIMIT - 1 ;
return va ( " temp/%s/sect_%03x_%03x.hms " , hm - > path , sx , sy ) ;
}
2012-11-29 13:37:48 +00:00
static int dehex_e ( int i , qboolean * error )
{
if ( i > = ' 0 ' & & i < = ' 9 ' )
return ( i - ' 0 ' ) ;
else if ( i > = ' A ' & & i < = ' F ' )
return ( i - ' A ' + 10 ) ;
else if ( i > = ' a ' & & i < = ' f ' )
return ( i - ' a ' + 10 ) ;
else
* error = true ;
return 0 ;
}
static qboolean Terr_IsSectionFName ( heightmap_t * hm , char * fname , int * sx , int * sy )
{
int l ;
qboolean error = false ;
* sx = 0xdeafbeef ; //something clearly invalid
* sy = 0xdeafbeef ;
//not this model...
if ( ! hm )
return false ;
//expect the first 5 chars to be maps/ or temp/
fname + = 5 ;
l = strlen ( hm - > path ) ;
if ( strncmp ( fname , hm - > path , l ) | | fname [ l ] ! = ' / ' )
return false ;
fname + = l + 1 ;
//fname now has a fixed length.
if ( strlen ( fname ) ! = 16 )
return false ;
if ( strncmp ( fname , " sect_ " , 5 ) | | fname [ 8 ] ! = ' _ ' | | ( strcmp ( fname + 12 , " .hms " ) & & strcmp ( fname + 12 , " .tmp " ) ) )
return false ;
* sx = 0 ;
* sx + = dehex_e ( fname [ 5 ] , & error ) < < 8 ;
* sx + = dehex_e ( fname [ 6 ] , & error ) < < 4 ;
* sx + = dehex_e ( fname [ 7 ] , & error ) < < 0 ;
* sy = 0 ;
* sy + = dehex_e ( fname [ 9 ] , & error ) < < 8 ;
* sy + = dehex_e ( fname [ 10 ] , & error ) < < 4 ;
* sy + = dehex_e ( fname [ 11 ] , & error ) < < 0 ;
* sx + = CHUNKBIAS ;
* sy + = CHUNKBIAS ;
if ( ( unsigned ) * sx > = CHUNKLIMIT )
* sx - = CHUNKLIMIT ;
if ( ( unsigned ) * sy > = CHUNKLIMIT )
* sy - = CHUNKLIMIT ;
//make sure its a valid section index.
if ( ( unsigned ) * sx > = CHUNKLIMIT )
return false ;
if ( ( unsigned ) * sy > = CHUNKLIMIT )
return false ;
return true ;
}
static hmsection_t * Terr_ReadSection ( heightmap_t * hm , hmsection_t * s , int sx , int sy , dsection_t * ds , unsigned int dslen )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
2013-03-31 04:21:08 +00:00
int i , j ;
2012-04-09 19:12:12 +00:00
# ifndef SERVERONLY
2012-07-20 01:55:42 +00:00
dsmesh_t * dm ;
2012-04-09 19:12:12 +00:00
unsigned char * lm ;
2012-08-04 11:28:39 +00:00
float * colours ;
2012-09-30 10:54:43 +00:00
# endif
2012-08-04 11:28:39 +00:00
void * ptr ;
2012-04-09 19:12:12 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ds )
{
if ( ds - > magic ! = SECTION_MAGIC )
return NULL ;
if ( ds - > ver ! = SECTION_VER )
2012-07-22 02:56:22 +00:00
{
2012-11-29 13:37:48 +00:00
//generate a new one if the version doesn't match
2012-07-22 02:56:22 +00:00
ds = NULL ;
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
}
2012-04-09 19:12:12 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! s )
2012-04-09 19:12:12 +00:00
{
2013-03-31 04:21:08 +00:00
s = Z_Malloc ( sizeof ( * s ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! s )
{
FS_FreeFile ( ds ) ;
return NULL ;
}
2012-07-21 08:06:07 +00:00
InsertLinkBefore ( & s - > recycle , & hm - > recycle ) ;
s - > sx = sx ;
s - > sy = sy ;
hm - > activesections + + ;
2012-07-14 17:25:21 +00:00
# ifndef SERVERONLY
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
s - > lightmap = - 1 ;
2012-07-14 17:25:21 +00:00
# endif
2012-04-09 19:12:12 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
s - > hmmod = hm ;
# ifndef SERVERONLY
2012-07-20 01:46:05 +00:00
s - > flags | = TSF_DIRTY ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( s - > lightmap < 0 & & qrenderer ! = QR_NONE )
Terr_InitLightmap ( s ) ;
2012-04-09 19:12:12 +00:00
# endif
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ds )
2012-04-09 19:12:12 +00:00
{
2012-07-20 01:46:05 +00:00
s - > flags = ds - > flags | TSF_DIRTY ;
2012-07-22 04:30:09 +00:00
/*load the heights*/
for ( i = 0 ; i < SECTHEIGHTSIZE * SECTHEIGHTSIZE ; i + + )
{
s - > heights [ i ] = LittleFloat ( ds - > heights [ i ] ) ;
}
s - > minh = ds - > minh ;
s - > maxh = ds - > maxh ;
s - > waterheight = ds - > waterheight ;
s - > holes = ds - > holes ;
2012-08-04 11:28:39 +00:00
ptr = ds + 1 ;
2012-04-09 19:12:12 +00:00
# ifndef SERVERONLY
2012-07-22 04:30:09 +00:00
/*deal with textures*/
2012-04-09 19:12:12 +00:00
Q_strncpyz ( s - > texname [ 0 ] , ds - > texname [ 0 ] , sizeof ( s - > texname [ 0 ] ) ) ;
Q_strncpyz ( s - > texname [ 1 ] , ds - > texname [ 1 ] , sizeof ( s - > texname [ 1 ] ) ) ;
Q_strncpyz ( s - > texname [ 2 ] , ds - > texname [ 2 ] , sizeof ( s - > texname [ 2 ] ) ) ;
Q_strncpyz ( s - > texname [ 3 ] , ds - > texname [ 3 ] , sizeof ( s - > texname [ 3 ] ) ) ;
2012-11-29 13:37:48 +00:00
if ( * s - > texname [ 0 ] )
CL_CheckOrEnqueDownloadFile ( s - > texname [ 0 ] , NULL , 0 ) ;
if ( * s - > texname [ 1 ] )
CL_CheckOrEnqueDownloadFile ( s - > texname [ 1 ] , NULL , 0 ) ;
if ( * s - > texname [ 2 ] )
CL_CheckOrEnqueDownloadFile ( s - > texname [ 2 ] , NULL , 0 ) ;
if ( * s - > texname [ 3 ] )
CL_CheckOrEnqueDownloadFile ( s - > texname [ 3 ] , NULL , 0 ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-07-22 04:30:09 +00:00
/*load in the mixture/lighting*/
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( s - > lightmap > = 0 )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lm = lightmap [ s - > lightmap ] - > lightmaps ;
2012-08-04 11:28:39 +00:00
lm + = ( s - > lmy * HMLMSTRIDE + s - > lmx ) * lightmap_bytes ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( i = 0 ; i < SECTTEXSIZE ; i + + )
{
memcpy ( lm , ds - > texmap + i , sizeof ( ds - > texmap [ 0 ] ) ) ;
lm + = ( HMLMSTRIDE ) * lightmap_bytes ;
}
lightmap [ s - > lightmap ] - > modified = true ;
lightmap [ s - > lightmap ] - > rectchange . l = 0 ;
lightmap [ s - > lightmap ] - > rectchange . t = 0 ;
lightmap [ s - > lightmap ] - > rectchange . w = HMLMSTRIDE ;
lightmap [ s - > lightmap ] - > rectchange . h = HMLMSTRIDE ;
2012-04-09 19:12:12 +00:00
}
2012-08-04 11:28:39 +00:00
s - > mesh . colors4f_array = s - > colours ;
if ( ds - > flags & TSF_HASCOLOURS )
{
for ( i = 0 , colours = ( float * ) ptr ; i < SECTHEIGHTSIZE * SECTHEIGHTSIZE ; i + + , colours + = 4 )
{
s - > colours [ i ] [ 0 ] = LittleFloat ( colours [ 0 ] ) ;
s - > colours [ i ] [ 1 ] = LittleFloat ( colours [ 1 ] ) ;
s - > colours [ i ] [ 2 ] = LittleFloat ( colours [ 2 ] ) ;
s - > colours [ i ] [ 3 ] = LittleFloat ( colours [ 3 ] ) ;
}
ptr = colours ;
}
else
{
for ( i = 0 ; i < SECTHEIGHTSIZE * SECTHEIGHTSIZE ; i + + )
{
s - > colours [ i ] [ 0 ] = 1 ;
s - > colours [ i ] [ 1 ] = 1 ;
s - > colours [ i ] [ 2 ] = 1 ;
s - > colours [ i ] [ 3 ] = 1 ;
}
}
2012-07-22 04:30:09 +00:00
/*load any static ents*/
2012-08-04 11:28:39 +00:00
s - > numents = ds - > ents_num ;
2012-07-20 01:46:05 +00:00
s - > maxents = s - > numents ;
2012-07-21 04:43:31 +00:00
if ( s - > maxents )
2013-03-31 04:21:08 +00:00
s - > ents = Z_Malloc ( sizeof ( * s - > ents ) * s - > maxents ) ;
2012-07-21 04:43:31 +00:00
else
s - > ents = NULL ;
2012-07-20 01:46:05 +00:00
if ( ! s - > ents )
s - > numents = s - > maxents = 0 ;
2012-08-04 11:28:39 +00:00
for ( i = 0 , dm = ( dsmesh_t * ) ptr ; i < s - > numents ; i + + , dm = ( dsmesh_t * ) ( ( qbyte * ) dm + dm - > size ) )
2012-07-20 01:46:05 +00:00
{
s - > ents [ i ] . model = Mod_ForName ( ( char * ) ( dm + 1 ) , false ) ;
if ( ! s - > ents [ i ] . model | | s - > ents [ i ] . model - > type = = mod_dummy )
{
s - > numents - - ;
i - - ;
continue ;
}
s - > ents [ i ] . scale = dm - > scale ;
VectorCopy ( dm - > axisorg [ 0 ] , s - > ents [ i ] . axis [ 0 ] ) ;
VectorCopy ( dm - > axisorg [ 1 ] , s - > ents [ i ] . axis [ 1 ] ) ;
VectorCopy ( dm - > axisorg [ 2 ] , s - > ents [ i ] . axis [ 2 ] ) ;
VectorCopy ( dm - > axisorg [ 3 ] , s - > ents [ i ] . origin ) ;
s - > ents [ i ] . origin [ 0 ] + = ( sx - CHUNKBIAS ) * hm - > sectionsize ;
s - > ents [ i ] . origin [ 1 ] + = ( sy - CHUNKBIAS ) * hm - > sectionsize ;
s - > ents [ i ] . shaderRGBAf [ 0 ] = 1 ;
s - > ents [ i ] . shaderRGBAf [ 1 ] = 1 ;
s - > ents [ i ] . shaderRGBAf [ 2 ] = 1 ;
s - > ents [ i ] . shaderRGBAf [ 3 ] = 1 ;
}
2012-07-20 01:55:42 +00:00
# endif
2012-04-09 19:12:12 +00:00
}
else
{
2013-03-31 04:21:08 +00:00
// s->flags |= TSF_RELIGHT;
2012-07-20 01:46:05 +00:00
2012-09-30 10:54:43 +00:00
# ifndef SERVERONLY
2012-09-30 05:52:03 +00:00
if ( s - > lightmap > = 0 )
{
lm = lightmap [ s - > lightmap ] - > lightmaps ;
lm + = ( s - > lmy * HMLMSTRIDE + s - > lmx ) * lightmap_bytes ;
for ( i = 0 ; i < SECTTEXSIZE ; i + + )
{
2013-03-31 04:21:08 +00:00
for ( j = 0 ; j < SECTTEXSIZE ; j + + )
{
lm [ j * 4 + 0 ] = 0 ;
lm [ j * 4 + 0 ] = 0 ;
lm [ j * 4 + 0 ] = 0 ;
lm [ j * 4 + 3 ] = 255 ;
}
2012-09-30 05:52:03 +00:00
lm + = ( HMLMSTRIDE ) * lightmap_bytes ;
}
lightmap [ s - > lightmap ] - > modified = true ;
lightmap [ s - > lightmap ] - > rectchange . l = 0 ;
lightmap [ s - > lightmap ] - > rectchange . t = 0 ;
lightmap [ s - > lightmap ] - > rectchange . w = HMLMSTRIDE ;
lightmap [ s - > lightmap ] - > rectchange . h = HMLMSTRIDE ;
}
for ( i = 0 ; i < SECTHEIGHTSIZE * SECTHEIGHTSIZE ; i + + )
{
s - > colours [ i ] [ 0 ] = 1 ;
s - > colours [ i ] [ 1 ] = 1 ;
s - > colours [ i ] [ 2 ] = 1 ;
s - > colours [ i ] [ 3 ] = 1 ;
}
2012-09-30 10:54:43 +00:00
# endif
2012-09-30 05:52:03 +00:00
2012-04-09 19:12:12 +00:00
#if 0 //def DEBUG
void * f ;
if ( lightmap_bytes = = 4 & & lightmap_bgra & & FS_LoadFile ( va ( " maps/%s/splatt.png " , hm - > path ) , & f ) > = 0 )
{
//temp
int vx , vy ;
int x , y ;
extern qbyte * Read32BitImageFile ( qbyte * buf , int len , int * width , int * height , qboolean * hasalpha , char * fname ) ;
int sw , sh ;
qboolean hasalpha ;
unsigned char * splatter = Read32BitImageFile ( f , com_filesize , & sw , & sh , & hasalpha , " splattermap " ) ;
if ( splatter )
{
lm = lightmap [ s - > lightmap ] - > lightmaps ;
2012-08-04 11:28:39 +00:00
lm + = ( s - > lmy * HMLMSTRIDE + s - > lmx ) * lightmap_bytes ;
2012-04-09 19:12:12 +00:00
for ( vx = 0 ; vx < SECTTEXSIZE ; vx + + )
{
x = sw * ( ( ( float ) sy ) + ( ( float ) vx / ( SECTTEXSIZE - 1 ) ) ) / hm - > numsegsx ;
if ( x > sw - 1 )
x = sw - 1 ;
for ( vy = 0 ; vy < SECTTEXSIZE ; vy + + )
{
y = sh * ( ( ( float ) sx ) + ( ( float ) vy / ( SECTTEXSIZE - 1 ) ) ) / hm - > numsegsy ;
if ( y > sh - 1 )
y = sh - 1 ;
lm [ 2 ] = splatter [ ( y + x * sh ) * 4 + 0 ] ;
lm [ 1 ] = splatter [ ( y + x * sh ) * 4 + 1 ] ;
lm [ 0 ] = splatter [ ( y + x * sh ) * 4 + 2 ] ;
lm [ 3 ] = splatter [ ( y + x * sh ) * 4 + 3 ] ;
lm + = 4 ;
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lm + = ( HMLMSTRIDE - SECTTEXSIZE ) * lightmap_bytes ;
2012-04-09 19:12:12 +00:00
}
BZ_Free ( splatter ) ;
lightmap [ s - > lightmap ] - > modified = true ;
lightmap [ s - > lightmap ] - > rectchange . l = 0 ;
lightmap [ s - > lightmap ] - > rectchange . t = 0 ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lightmap [ s - > lightmap ] - > rectchange . w = HMLMSTRIDE ;
lightmap [ s - > lightmap ] - > rectchange . h = HMLMSTRIDE ;
2012-04-09 19:12:12 +00:00
}
FS_FreeFile ( f ) ;
}
if ( lightmap_bytes = = 4 & & lightmap_bgra & & FS_LoadFile ( va ( " maps/%s/heightmap.png " , hm - > path ) , & f ) > = 0 )
{
//temp
int vx , vy ;
int x , y ;
extern qbyte * Read32BitImageFile ( qbyte * buf , int len , int * width , int * height , qboolean * hasalpha , char * fname ) ;
int sw , sh ;
float * h ;
qboolean hasalpha ;
unsigned char * hmimage = Read32BitImageFile ( f , com_filesize , & sw , & sh , & hasalpha , " heightmap " ) ;
if ( hmimage )
{
h = s - > heights ;
for ( vx = 0 ; vx < SECTHEIGHTSIZE ; vx + + )
{
x = sw * ( ( ( float ) sy ) + ( ( float ) vx / ( SECTHEIGHTSIZE - 1 ) ) ) / hm - > numsegsx ;
if ( x > sw - 1 )
x = sw - 1 ;
for ( vy = 0 ; vy < SECTHEIGHTSIZE ; vy + + )
{
y = sh * ( ( ( float ) sx ) + ( ( float ) vy / ( SECTHEIGHTSIZE - 1 ) ) ) / hm - > numsegsy ;
if ( y > sh - 1 )
y = sh - 1 ;
* h = 0 ;
* h + = hmimage [ ( y + x * sh ) * 4 + 0 ] ;
* h + = hmimage [ ( y + x * sh ) * 4 + 1 ] < < 8 ;
* h + = hmimage [ ( y + x * sh ) * 4 + 2 ] < < 16 ;
* h * = 4.0f / ( 1 < < 16 ) ;
h + + ;
}
}
BZ_Free ( hmimage ) ;
}
FS_FreeFile ( f ) ;
}
# endif
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
Terr_LoadSectionTextures ( s ) ;
2012-04-09 19:12:12 +00:00
return s ;
}
2012-11-29 13:37:48 +00:00
# ifndef SERVERONLY
qboolean Terr_DownloadedSection ( char * fname )
{
int len ;
void * fileptr ;
int x , y ;
heightmap_t * hm ;
if ( ! cl . worldmodel )
return false ;
hm = cl . worldmodel - > terrain ;
if ( Terr_IsSectionFName ( hm , fname , & x , & y ) )
{
len = FS_LoadFile ( fname , & fileptr ) ;
if ( len < 0 )
fileptr = NULL ;
{
int cx = x / MAXSECTIONS ;
int cy = y / MAXSECTIONS ;
int sx = x & ( MAXSECTIONS - 1 ) ;
int sy = y & ( MAXSECTIONS - 1 ) ;
hmcluster_t * cluster = hm - > cluster [ cx + cy * MAXSECTIONS ] ;
if ( ! cluster )
{
2013-03-31 04:21:08 +00:00
cluster = Z_Malloc ( sizeof ( * cluster ) ) ;
2012-11-29 13:37:48 +00:00
if ( cluster )
hm - > cluster [ cx + cy * MAXSECTIONS ] = cluster ;
}
if ( cluster )
cluster - > section [ sx + sy * MAXSECTIONS ] = Terr_ReadSection ( hm , cluster - > section [ sx + sy * MAXSECTIONS ] , x , y , fileptr , len ) ;
}
if ( fileptr )
FS_FreeFile ( fileptr ) ;
return true ;
}
return false ;
}
# endif
2013-03-31 04:21:08 +00:00
static hmsection_t * Terr_LoadSection ( heightmap_t * hm , hmsection_t * s , int sx , int sy , qboolean force )
2012-11-29 13:37:48 +00:00
{
hmsection_t * sect ;
void * diskimage ;
int len ;
# ifndef SERVERONLY
//when using networked terrain, the client will never load a section from disk, but only loading it from the server
if ( mod_terrain_networked . ival & & ! sv . state )
{
//try to download it now...
if ( ! cl . downloadlist )
CL_CheckOrEnqueDownloadFile ( Terr_DiskSectionName ( hm , sx , sy ) , Terr_TempDiskSectionName ( hm , sx , sy ) , DLLF_OVERWRITE | DLLF_TEMPORARY ) ;
return NULL ;
}
# endif
diskimage = NULL ;
len = FS_LoadFile ( Terr_DiskSectionName ( hm , sx , sy ) , ( void * * ) & diskimage ) ;
/*queue the file for download if we don't have it yet*/
if ( len < 0 )
{
2013-03-31 04:21:08 +00:00
if ( ! force )
2012-11-29 13:37:48 +00:00
{
# ifndef SERVERONLY
if ( ! cl . downloadlist )
CL_CheckOrEnqueDownloadFile ( Terr_DiskSectionName ( hm , sx , sy ) , NULL , 0 ) ;
# endif
return NULL ;
}
}
sect = Terr_ReadSection ( hm , s , sx , sy , diskimage , len ) ;
if ( diskimage )
FS_FreeFile ( diskimage ) ;
return sect ;
}
2012-11-27 03:23:19 +00:00
//doesn't clear edited/dirty flags or anything
static qboolean Terr_SaveSection ( heightmap_t * hm , hmsection_t * s , int sx , int sy , char * fname )
2012-04-09 19:12:12 +00:00
{
# ifndef SERVERONLY
dsection_t ds ;
2012-07-20 01:46:05 +00:00
dsmesh_t dm ;
2012-04-09 19:12:12 +00:00
unsigned char * lm ;
2012-07-20 01:46:05 +00:00
vfsfile_t * f ;
int nothing = 0 ;
2012-04-09 19:12:12 +00:00
int i ;
2012-08-04 11:28:39 +00:00
vec4_t dcolours [ SECTHEIGHTSIZE * SECTHEIGHTSIZE ] ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
//if its invalid or doesn't contain all the data...
2012-04-09 19:12:12 +00:00
if ( ! s | | s - > lightmap < 0 )
2012-07-21 04:43:31 +00:00
return true ;
2012-04-09 19:12:12 +00:00
2012-07-20 01:46:05 +00:00
memset ( & ds , 0 , sizeof ( ds ) ) ;
memset ( & dm , 0 , sizeof ( dm ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
ds . magic = SECTION_MAGIC ;
ds . ver = SECTION_VER ;
2012-07-20 01:46:05 +00:00
//mask off the flags which are only valid in memory
ds . flags = s - > flags & ~ ( TSF_INTERNAL ) ;
//kill the haswater flag if its entirely above any possible water anyway.
if ( s - > waterheight < s - > minh )
ds . flags & = ~ TSF_HASWATER ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
ds . flags & = ~ TSF_HASCOLOURS ; //recalculated
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-04-09 19:12:12 +00:00
Q_strncpyz ( ds . texname [ 0 ] , s - > texname [ 0 ] , sizeof ( ds . texname [ 0 ] ) ) ;
Q_strncpyz ( ds . texname [ 1 ] , s - > texname [ 1 ] , sizeof ( ds . texname [ 1 ] ) ) ;
Q_strncpyz ( ds . texname [ 2 ] , s - > texname [ 2 ] , sizeof ( ds . texname [ 2 ] ) ) ;
Q_strncpyz ( ds . texname [ 3 ] , s - > texname [ 3 ] , sizeof ( ds . texname [ 3 ] ) ) ;
lm = lightmap [ s - > lightmap ] - > lightmaps ;
2012-08-04 11:28:39 +00:00
lm + = ( s - > lmy * HMLMSTRIDE + s - > lmx ) * lightmap_bytes ;
2012-04-09 19:12:12 +00:00
for ( i = 0 ; i < SECTTEXSIZE ; i + + )
{
memcpy ( ds . texmap + i , lm , sizeof ( ds . texmap [ 0 ] ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lm + = ( HMLMSTRIDE ) * lightmap_bytes ;
2012-04-09 19:12:12 +00:00
}
for ( i = 0 ; i < SECTHEIGHTSIZE * SECTHEIGHTSIZE ; i + + )
{
ds . heights [ i ] = LittleFloat ( s - > heights [ i ] ) ;
2012-08-04 11:28:39 +00:00
if ( s - > colours [ i ] [ 0 ] ! = 1 | | s - > colours [ i ] [ 1 ] ! = 1 | | s - > colours [ i ] [ 2 ] ! = 1 | | s - > colours [ i ] [ 3 ] ! = 1 )
{
ds . flags | = TSF_HASCOLOURS ;
dcolours [ i ] [ 0 ] = LittleFloat ( s - > colours [ i ] [ 0 ] ) ;
dcolours [ i ] [ 1 ] = LittleFloat ( s - > colours [ i ] [ 1 ] ) ;
dcolours [ i ] [ 2 ] = LittleFloat ( s - > colours [ i ] [ 2 ] ) ;
dcolours [ i ] [ 3 ] = LittleFloat ( s - > colours [ i ] [ 3 ] ) ;
}
else
{
dcolours [ i ] [ 0 ] = dcolours [ i ] [ 1 ] = dcolours [ i ] [ 2 ] = dcolours [ i ] [ 3 ] = LittleFloat ( 1 ) ;
}
2012-04-09 19:12:12 +00:00
}
2012-07-20 01:46:05 +00:00
ds . waterheight = s - > waterheight ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
ds . holes = s - > holes ;
2012-07-14 17:33:44 +00:00
ds . minh = s - > minh ;
ds . maxh = s - > maxh ;
2012-08-04 11:28:39 +00:00
ds . ents_num = s - > numents ;
2012-04-09 19:12:12 +00:00
2012-07-21 04:43:31 +00:00
FS_CreatePath ( fname , FS_GAMEONLY ) ;
f = FS_OpenVFS ( fname , " wb " , FS_GAMEONLY ) ;
if ( ! f )
{
Con_Printf ( " Failed to open %s \n " , fname ) ;
return false ;
}
2012-07-20 01:46:05 +00:00
VFS_WRITE ( f , & ds , sizeof ( ds ) ) ;
2012-08-04 11:28:39 +00:00
if ( ds . flags & TSF_HASCOLOURS )
VFS_WRITE ( f , dcolours , sizeof ( dcolours ) ) ;
2012-07-20 01:46:05 +00:00
for ( i = 0 ; i < s - > numents ; i + + )
{
int pad ;
dm . scale = s - > ents [ i ] . scale ;
VectorCopy ( s - > ents [ i ] . axis [ 0 ] , dm . axisorg [ 0 ] ) ;
VectorCopy ( s - > ents [ i ] . axis [ 1 ] , dm . axisorg [ 1 ] ) ;
VectorCopy ( s - > ents [ i ] . axis [ 2 ] , dm . axisorg [ 2 ] ) ;
VectorCopy ( s - > ents [ i ] . origin , dm . axisorg [ 3 ] ) ;
dm . axisorg [ 3 ] [ 0 ] + = ( CHUNKBIAS - sx ) * hm - > sectionsize ;
dm . axisorg [ 3 ] [ 1 ] + = ( CHUNKBIAS - sy ) * hm - > sectionsize ;
dm . size = sizeof ( dm ) + strlen ( s - > ents [ i ] . model - > name ) + 1 ;
if ( dm . size & 3 )
pad = 4 - ( dm . size & 3 ) ;
else
pad = 0 ;
dm . size + = pad ;
VFS_WRITE ( f , & dm , sizeof ( dm ) ) ;
VFS_WRITE ( f , s - > ents [ i ] . model - > name , strlen ( s - > ents [ i ] . model - > name ) + 1 ) ;
if ( pad )
VFS_WRITE ( f , & nothing , pad ) ;
}
VFS_CLOSE ( f ) ;
2012-04-09 19:12:12 +00:00
# endif
2012-07-21 04:43:31 +00:00
return true ;
2012-04-09 19:12:12 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
/*convienience function*/
2013-03-31 04:21:08 +00:00
# define TGS_NOLOAD 0
# define TGS_LOAD 1
# define TGS_FORCELOAD 2
static hmsection_t * Terr_GetSection ( heightmap_t * hm , int x , int y , unsigned int flags )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
hmcluster_t * cluster ;
hmsection_t * section ;
int cx = x / MAXSECTIONS ;
int cy = y / MAXSECTIONS ;
int sx = x & ( MAXSECTIONS - 1 ) ;
int sy = y & ( MAXSECTIONS - 1 ) ;
cluster = hm - > cluster [ cx + cy * MAXSECTIONS ] ;
if ( ! cluster )
{
2013-03-31 04:21:08 +00:00
if ( flags & ( TGS_LOAD | TGS_FORCELOAD ) )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
2013-03-31 04:21:08 +00:00
cluster = Z_Malloc ( sizeof ( * cluster ) ) ;
2012-07-20 01:46:05 +00:00
if ( ! cluster )
return NULL ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
hm - > cluster [ cx + cy * MAXSECTIONS ] = cluster ;
}
else
return NULL ;
}
section = cluster - > section [ sx + sy * MAXSECTIONS ] ;
if ( ! section )
{
2013-03-31 04:21:08 +00:00
if ( flags & ( TGS_LOAD | TGS_FORCELOAD ) )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
// while (hm->activesections > TERRAINACTIVESECTIONS)
// Terr_Collect(hm);
2013-03-31 04:21:08 +00:00
section = cluster - > section [ sx + sy * MAXSECTIONS ] = Terr_LoadSection ( hm , section , x , y , ! ! ( flags & TGS_FORCELOAD ) ) ;
}
}
# ifndef SERVERONLY
//when using networked terrain, the client will never load a section from disk, but only loading it from the server
if ( section & & ( section - > flags & TSF_NOTIFY ) & & mod_terrain_networked . ival & & ! sv . state )
{
//try to download it now...
if ( ! cl . downloadlist )
{
CL_CheckOrEnqueDownloadFile ( Terr_DiskSectionName ( hm , x , y ) , Terr_TempDiskSectionName ( hm , x , y ) , DLLF_OVERWRITE | DLLF_TEMPORARY ) ;
section - > flags & = ~ TSF_NOTIFY ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
}
}
2013-03-31 04:21:08 +00:00
# endif
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
return section ;
}
2012-04-09 19:12:12 +00:00
/*save all currently loaded sections*/
2012-11-27 03:23:19 +00:00
int Heightmap_Save ( heightmap_t * hm )
2012-04-09 19:12:12 +00:00
{
hmsection_t * s ;
int x , y ;
2012-07-20 01:46:05 +00:00
int sectionssaved = 0 ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( x = hm - > firstsegx ; x < hm - > maxsegx ; x + + )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( y = hm - > firstsegy ; y < hm - > maxsegy ; y + + )
2012-04-09 19:12:12 +00:00
{
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_NOLOAD ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! s )
continue ;
2012-07-20 01:46:05 +00:00
if ( s - > flags & TSF_EDITED )
{
2012-11-27 03:23:19 +00:00
if ( Terr_SaveSection ( hm , s , x , y , Terr_DiskSectionName ( hm , x , y ) ) )
2012-07-21 04:43:31 +00:00
{
s - > flags & = ~ TSF_EDITED ;
sectionssaved + + ;
}
2012-07-20 01:46:05 +00:00
}
2012-04-09 19:12:12 +00:00
}
}
2012-07-20 01:46:05 +00:00
return sectionssaved ;
2012-04-09 19:12:12 +00:00
}
2012-11-27 03:23:19 +00:00
# ifndef CLIENTONLY
//on servers, we can get requests to download current map sections. if so, give them it.
qboolean Terrain_LocateSection ( char * name , flocation_t * loc )
{
heightmap_t * hm ;
hmsection_t * s ;
int x , y ;
int nlen = strlen ( name ) ;
//reject if its not in maps
if ( strncmp ( name , " maps/ " , 5 ) )
return false ;
2012-11-29 13:37:48 +00:00
if ( ! sv . world . worldmodel )
2012-11-27 03:23:19 +00:00
return false ;
hm = sv . world . worldmodel - > terrain ;
2012-11-29 13:37:48 +00:00
if ( ! Terr_IsSectionFName ( hm , name , & x , & y ) )
2012-11-27 03:23:19 +00:00
return false ;
//verify that its valid
if ( strcmp ( name , Terr_DiskSectionName ( hm , x , y ) ) )
return false ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_NOLOAD ) ;
2012-11-27 03:23:19 +00:00
if ( ! s | | ! ( s - > flags & TSF_EDITED ) )
return false ; //its not been edited, might as well just use the regular file
name = Terr_TempDiskSectionName ( hm , x , y ) ;
if ( ! Terr_SaveSection ( hm , s , x , y , name ) )
return false ;
return FS_FLocateFile ( name , FSLFRT_IFFOUND , loc ) ;
}
# endif
2012-07-21 05:52:35 +00:00
void Terr_DestroySection ( heightmap_t * hm , hmsection_t * s , qboolean lightmapreusable )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
2012-07-21 08:06:07 +00:00
RemoveLink ( & s - > recycle ) ;
2012-07-14 17:25:21 +00:00
# ifndef SERVERONLY
2012-07-21 05:52:35 +00:00
if ( lightmapreusable & & s - > lightmap > = 0 )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
struct lmsect_s * lms ;
2013-03-31 04:21:08 +00:00
lms = BZ_Malloc ( sizeof ( * lms ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lms - > lm = s - > lightmap ;
lms - > x = s - > lmx ;
lms - > y = s - > lmy ;
lms - > next = hm - > unusedlmsects ;
hm - > unusedlmsects = lms ;
}
2012-07-21 08:06:07 +00:00
if ( hm - > relight = = s )
hm - > relight = NULL ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
# ifdef GLQUAKE
2012-11-27 03:23:19 +00:00
if ( qrenderer = = QR_OPENGL & & qglDeleteBuffersARB )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
qglDeleteBuffersARB ( 1 , & s - > vbo . coord . gl . vbo ) ;
qglDeleteBuffersARB ( 1 , & s - > vbo . indicies . gl . vbo ) ;
}
# endif
2013-03-31 04:21:08 +00:00
Z_Free ( s - > ents ) ;
Z_Free ( s - > mesh . xyz_array ) ;
Z_Free ( s - > mesh . indexes ) ;
2012-07-14 17:25:21 +00:00
# endif
2013-03-31 04:21:08 +00:00
Z_Free ( s ) ;
2012-07-21 08:06:07 +00:00
hm - > activesections - - ;
}
2013-03-31 04:21:08 +00:00
static void Terr_DoEditNotify ( heightmap_t * hm )
{
int i ;
char * cmd ;
hmsection_t * s ;
link_t * ln = & hm - > recycle ;
if ( ! sv . state )
return ;
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
{
if ( svs . clients [ i ] . state > cs_zombie & & svs . clients [ i ] . netchan . remote_address . type ! = NA_LOOPBACK )
{
if ( svs . clients [ i ] . backbuf . cursize )
return ;
}
}
for ( ln = & hm - > recycle ; ln - > next ! = & hm - > recycle ; ln = & s - > recycle )
{
s = ( hmsection_t * ) ln - > next ;
if ( s - > flags & TSF_NOTIFY )
{
s - > flags & = ~ TSF_NOTIFY ;
cmd = va ( " mod_terrain_reload %s %i %i \n " , hm - > path , s - > sx - CHUNKBIAS , s - > sy - CHUNKBIAS ) ;
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
{
if ( svs . clients [ i ] . state > cs_zombie & & svs . clients [ i ] . netchan . remote_address . type ! = NA_LOOPBACK )
{
SV_StuffcmdToClient ( & svs . clients [ i ] , cmd ) ;
}
}
return ;
}
}
}
2012-07-21 08:06:07 +00:00
//garbage collect the oldest section, to make space for another
2013-03-31 04:21:08 +00:00
static qboolean Terr_Collect ( heightmap_t * hm )
2012-07-21 08:06:07 +00:00
{
hmcluster_t * c ;
hmsection_t * s ;
int cx , cy ;
int sx , sy ;
link_t * ln = & hm - > recycle ;
for ( ln = & hm - > recycle ; ln - > next ! = & hm - > recycle ; )
{
s = ( hmsection_t * ) ln - > next ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( s - > flags & TSF_EDITED )
ln = & s - > recycle ;
else
{
cx = s - > sx / MAXSECTIONS ;
cy = s - > sy / MAXSECTIONS ;
c = hm - > cluster [ cx + cy * MAXSECTIONS ] ;
sx = s - > sx & ( MAXSECTIONS - 1 ) ;
sy = s - > sy & ( MAXSECTIONS - 1 ) ;
if ( c - > section [ sx + sy * MAXSECTIONS ] ! = s )
Sys_Error ( " invalid section collection " ) ;
c - > section [ sx + sy * MAXSECTIONS ] = NULL ;
Terr_DestroySection ( hm , s , true ) ;
2013-03-31 04:21:08 +00:00
return true ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
}
2012-07-21 08:06:07 +00:00
}
2013-03-31 04:21:08 +00:00
return false ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
}
/*purge all sections
lightmaps only are purged whenever the client rudely kills lightmaps
we ' ll reload those when its next seen .
( lightmaps will already have been destroyed , so no poking them )
*/
2012-07-21 05:52:35 +00:00
void Terr_PurgeTerrainModel ( model_t * mod , qboolean lightmapsonly , qboolean lightmapreusable )
2012-04-09 19:12:12 +00:00
{
heightmap_t * hm = mod - > terrain ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
hmcluster_t * c ;
2012-04-09 19:12:12 +00:00
hmsection_t * s ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
int cx , cy ;
int sx , sy ;
2012-07-21 05:52:35 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( cy = 0 ; cy < MAXSECTIONS ; cy + + )
for ( cx = 0 ; cx < MAXSECTIONS ; cx + + )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
c = hm - > cluster [ cx + cy * MAXSECTIONS ] ;
if ( ! c )
continue ;
for ( sy = 0 ; sy < MAXSECTIONS ; sy + + )
for ( sx = 0 ; sx < MAXSECTIONS ; sx + + )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
s = c - > section [ sx + sy * MAXSECTIONS ] ;
if ( ! s )
{
}
else if ( lightmapsonly )
2012-07-14 17:25:21 +00:00
{
# ifndef SERVERONLY
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
s - > lightmap = - 1 ;
2012-07-14 17:25:21 +00:00
# endif
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
else
{
c - > section [ sx + sy * MAXSECTIONS ] = NULL ;
2012-07-21 05:52:35 +00:00
Terr_DestroySection ( hm , s , lightmapreusable ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
}
}
if ( ! lightmapsonly )
{
hm - > cluster [ cx + cy * MAXSECTIONS ] = NULL ;
2013-03-31 04:21:08 +00:00
BZ_Free ( c ) ;
2012-04-09 19:12:12 +00:00
}
}
2012-07-14 17:25:21 +00:00
# ifndef SERVERONLY
2012-07-21 05:52:35 +00:00
if ( ! lightmapreusable )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
2012-07-21 05:52:35 +00:00
while ( hm - > unusedlmsects )
{
struct lmsect_s * lms ;
lms = hm - > unusedlmsects ;
hm - > unusedlmsects = lms - > next ;
2013-03-31 04:21:08 +00:00
BZ_Free ( lms ) ;
2012-07-21 05:52:35 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
}
2012-07-14 17:25:21 +00:00
# endif
2012-04-09 19:12:12 +00:00
}
# ifndef SERVERONLY
2012-09-30 05:52:03 +00:00
void Terr_DrawTerrainWater ( heightmap_t * hm , float * mins , float * maxs , float waterz , float r , float g , float b , float a )
2012-07-20 01:46:05 +00:00
{
scenetris_t * t ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
int flags = BEF_NOSHADOWS ;
2012-09-30 05:52:03 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( cl_numstris & & cl_stris [ cl_numstris - 1 ] . shader = = hm - > watershader & & cl_stris [ cl_numstris - 1 ] . flags = = flags )
2012-07-20 01:46:05 +00:00
{
t = & cl_stris [ cl_numstris - 1 ] ;
}
else
{
if ( cl_numstris = = cl_maxstris )
{
cl_maxstris + = 8 ;
cl_stris = BZ_Realloc ( cl_stris , sizeof ( * cl_stris ) * cl_maxstris ) ;
}
t = & cl_stris [ cl_numstris + + ] ;
2012-09-30 05:52:03 +00:00
t - > shader = hm - > watershader ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
t - > flags = flags ;
2012-07-20 01:46:05 +00:00
t - > firstidx = cl_numstrisidx ;
t - > firstvert = cl_numstrisvert ;
t - > numvert = 0 ;
t - > numidx = 0 ;
}
if ( cl_numstrisidx + 12 > cl_maxstrisidx )
{
cl_maxstrisidx = cl_numstrisidx + 12 + 64 ;
cl_strisidx = BZ_Realloc ( cl_strisidx , sizeof ( * cl_strisidx ) * cl_maxstrisidx ) ;
}
if ( cl_numstrisvert + 4 > cl_maxstrisvert )
{
cl_maxstrisvert + = 64 ;
cl_strisvertv = BZ_Realloc ( cl_strisvertv , sizeof ( * cl_strisvertv ) * cl_maxstrisvert ) ;
cl_strisvertt = BZ_Realloc ( cl_strisvertt , sizeof ( * cl_strisvertt ) * cl_maxstrisvert ) ;
cl_strisvertc = BZ_Realloc ( cl_strisvertc , sizeof ( * cl_strisvertc ) * cl_maxstrisvert ) ;
}
{
VectorSet ( cl_strisvertv [ cl_numstrisvert ] , mins [ 0 ] , mins [ 1 ] , waterz ) ;
Vector4Set ( cl_strisvertc [ cl_numstrisvert ] , r , g , b , a ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert ] , mins [ 0 ] / 64 , mins [ 1 ] / 64 ) ;
cl_numstrisvert + + ;
VectorSet ( cl_strisvertv [ cl_numstrisvert ] , mins [ 0 ] , maxs [ 1 ] , waterz ) ;
Vector4Set ( cl_strisvertc [ cl_numstrisvert ] , r , g , b , a ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert ] , mins [ 0 ] / 64 , maxs [ 1 ] / 64 ) ;
cl_numstrisvert + + ;
VectorSet ( cl_strisvertv [ cl_numstrisvert ] , maxs [ 0 ] , maxs [ 1 ] , waterz ) ;
Vector4Set ( cl_strisvertc [ cl_numstrisvert ] , r , g , b , a ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert ] , maxs [ 0 ] / 64 , maxs [ 1 ] / 64 ) ;
cl_numstrisvert + + ;
VectorSet ( cl_strisvertv [ cl_numstrisvert ] , maxs [ 0 ] , mins [ 1 ] , waterz ) ;
Vector4Set ( cl_strisvertc [ cl_numstrisvert ] , r , g , b , a ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert ] , maxs [ 0 ] / 64 , mins [ 1 ] / 64 ) ;
cl_numstrisvert + + ;
}
/*build the triangles*/
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 0 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 1 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 2 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 0 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 2 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 3 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 3 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 2 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 1 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 3 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 1 ;
cl_strisidx [ cl_numstrisidx + + ] = t - > numvert + 0 ;
t - > numidx = cl_numstrisidx - t - > firstidx ;
t - > numvert + = 4 ;
}
void Terr_RebuildMesh ( hmsection_t * s , int x , int y )
{
int vx , vy ;
int v ;
mesh_t * mesh = & s - > mesh ;
heightmap_t * hm = s - > hmmod ;
if ( s - > lightmap < 0 )
{
Terr_InitLightmap ( s ) ;
}
s - > minh = 9999999999999999.f ;
s - > maxh = - 9999999999999999.f ;
2012-08-04 11:28:39 +00:00
if ( hm - > tiled )
2012-07-20 01:46:05 +00:00
{
2012-08-04 11:28:39 +00:00
if ( mesh - > xyz_array )
BZ_Free ( mesh - > xyz_array ) ;
2012-07-20 01:46:05 +00:00
{
2012-08-04 11:28:39 +00:00
mesh - > xyz_array = BZ_Malloc ( ( sizeof ( vecV_t ) + sizeof ( vec2_t ) + sizeof ( vec2_t ) ) * ( SECTHEIGHTSIZE - 1 ) * ( SECTHEIGHTSIZE - 1 ) * 4 * 3 ) ;
mesh - > st_array = ( void * ) ( mesh - > xyz_array + ( SECTHEIGHTSIZE - 1 ) * ( SECTHEIGHTSIZE - 1 ) * 4 * 3 ) ;
mesh - > lmst_array [ 0 ] = ( void * ) ( mesh - > st_array + ( SECTHEIGHTSIZE - 1 ) * ( SECTHEIGHTSIZE - 1 ) * 4 * 3 ) ;
2012-07-20 01:46:05 +00:00
}
2012-08-04 11:28:39 +00:00
mesh - > numvertexes = 0 ;
2012-07-20 01:46:05 +00:00
2012-08-04 11:28:39 +00:00
if ( mesh - > indexes )
BZ_Free ( mesh - > indexes ) ;
mesh - > indexes = BZ_Malloc ( sizeof ( index_t ) * SECTHEIGHTSIZE * SECTHEIGHTSIZE * 6 * 3 ) ;
mesh - > numindexes = 0 ;
2012-09-30 05:52:03 +00:00
mesh - > colors4f_array = NULL ;
2012-07-20 01:46:05 +00:00
for ( vy = 0 ; vy < SECTHEIGHTSIZE - 1 ; vy + + )
{
2012-08-04 11:28:39 +00:00
for ( vx = 0 ; vx < SECTHEIGHTSIZE - 1 ; vx + + )
{
float st [ 2 ] , inst [ 2 ] ;
2012-07-20 01:46:05 +00:00
# if SECTHEIGHTSIZE >= 4
2012-08-04 11:28:39 +00:00
int holebit ;
2012-07-20 01:46:05 +00:00
2012-08-04 11:28:39 +00:00
//skip generation of the mesh above holes
holebit = 1u < < ( vx / ( SECTHEIGHTSIZE > > 2 ) + ( vy / ( SECTHEIGHTSIZE > > 2 ) ) * 4 ) ;
if ( s - > holes & holebit )
continue ;
2012-07-20 01:46:05 +00:00
# endif
2012-08-04 11:28:39 +00:00
//top face
v = mesh - > numvertexes ;
mesh - > numvertexes + = 4 ;
mesh - > xyz_array [ v + 0 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 0 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 0 ] [ 2 ] = s - > heights [ vx + vy * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 1 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 1 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 1 ] [ 2 ] = s - > heights [ vx + vy * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 2 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 2 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 2 ] [ 2 ] = s - > heights [ vx + vy * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 3 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 3 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 3 ] [ 2 ] = s - > heights [ vx + vy * SECTHEIGHTSIZE ] ;
if ( s - > maxh < mesh - > xyz_array [ v ] [ 2 ] )
s - > maxh = mesh - > xyz_array [ v ] [ 2 ] ;
if ( s - > minh > mesh - > xyz_array [ v ] [ 2 ] )
s - > minh = mesh - > xyz_array [ v ] [ 2 ] ;
st [ 0 ] = 1.0f / hm - > tilecount [ 0 ] * vx ;
st [ 1 ] = 1.0f / hm - > tilecount [ 1 ] * vy ;
inst [ 0 ] = 0.5f / ( hm - > tilecount [ 0 ] * hm - > tilepixcount [ 0 ] ) ;
inst [ 1 ] = 0.5f / ( hm - > tilecount [ 1 ] * hm - > tilepixcount [ 1 ] ) ;
mesh - > st_array [ v + 0 ] [ 0 ] = st [ 0 ] + inst [ 0 ] ;
mesh - > st_array [ v + 0 ] [ 1 ] = st [ 1 ] + inst [ 1 ] ;
mesh - > st_array [ v + 1 ] [ 0 ] = st [ 0 ] - inst [ 0 ] + 1.0f / hm - > tilecount [ 0 ] ;
mesh - > st_array [ v + 1 ] [ 1 ] = st [ 1 ] + inst [ 1 ] ;
mesh - > st_array [ v + 2 ] [ 0 ] = st [ 0 ] + inst [ 0 ] ;
mesh - > st_array [ v + 2 ] [ 1 ] = st [ 1 ] - inst [ 1 ] + 1.0f / hm - > tilecount [ 1 ] ;
mesh - > st_array [ v + 3 ] [ 0 ] = st [ 0 ] - inst [ 0 ] + 1.0f / hm - > tilecount [ 0 ] ;
mesh - > st_array [ v + 3 ] [ 1 ] = st [ 1 ] - inst [ 1 ] + 1.0f / hm - > tilecount [ 1 ] ;
//calc the position in the range -0.5 to 0.5
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] = ( ( ( float ) vx / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] = ( ( ( float ) vy / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
//scale down to a half-texel
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
//bias it
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmx ) / HMLMSTRIDE ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmy ) / HMLMSTRIDE ) ;
2012-07-20 01:46:05 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 0 ;
2012-08-04 11:28:39 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 2 ;
2012-07-20 01:46:05 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
2012-08-04 11:28:39 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 2 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 + 2 ;
//x boundary
v = mesh - > numvertexes ;
mesh - > numvertexes + = 4 ;
mesh - > xyz_array [ v + 0 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 0 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 0 ] [ 2 ] = s - > heights [ vx + 0 + vy * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 1 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 1 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 1 ] [ 2 ] = s - > heights [ ( vx + 1 ) + vy * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 2 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 2 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 2 ] [ 2 ] = s - > heights [ ( vx + 0 ) + vy * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 3 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 3 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 3 ] [ 2 ] = s - > heights [ ( vx + 1 ) + vy * SECTHEIGHTSIZE ] ;
if ( s - > maxh < mesh - > xyz_array [ v ] [ 2 ] )
s - > maxh = mesh - > xyz_array [ v ] [ 2 ] ;
if ( s - > minh > mesh - > xyz_array [ v ] [ 2 ] )
s - > minh = mesh - > xyz_array [ v ] [ 2 ] ;
st [ 0 ] = 1.0f / hm - > tilecount [ 0 ] * vx ;
st [ 1 ] = 1.0f / hm - > tilecount [ 1 ] * vy ;
inst [ 0 ] = 0.5f / ( hm - > tilecount [ 0 ] * hm - > tilepixcount [ 0 ] ) ;
inst [ 1 ] = 0.5f / ( hm - > tilecount [ 1 ] * hm - > tilepixcount [ 1 ] ) ;
mesh - > st_array [ v + 0 ] [ 0 ] = st [ 0 ] + inst [ 0 ] ;
mesh - > st_array [ v + 0 ] [ 1 ] = st [ 1 ] + inst [ 1 ] ;
mesh - > st_array [ v + 1 ] [ 0 ] = st [ 0 ] + inst [ 0 ] ;
mesh - > st_array [ v + 1 ] [ 1 ] = st [ 1 ] - inst [ 1 ] + 1.0f / hm - > tilecount [ 1 ] ;
mesh - > st_array [ v + 2 ] [ 0 ] = st [ 0 ] - inst [ 0 ] + 1.0f / hm - > tilecount [ 0 ] ;
mesh - > st_array [ v + 2 ] [ 1 ] = st [ 1 ] + inst [ 1 ] ;
mesh - > st_array [ v + 3 ] [ 0 ] = st [ 0 ] - inst [ 0 ] + 1.0f / hm - > tilecount [ 0 ] ;
mesh - > st_array [ v + 3 ] [ 1 ] = st [ 1 ] - inst [ 1 ] + 1.0f / hm - > tilecount [ 1 ] ;
//calc the position in the range -0.5 to 0.5
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] = ( ( ( float ) vx / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] = ( ( ( float ) vy / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
//scale down to a half-texel
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
//bias it
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmx ) / HMLMSTRIDE ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmy ) / HMLMSTRIDE ) ;
2012-07-20 01:46:05 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 0 ;
2012-08-04 11:28:39 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 2 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 2 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 + 2 ;
//y boundary
v = mesh - > numvertexes ;
mesh - > numvertexes + = 4 ;
mesh - > xyz_array [ v + 0 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 0 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 0 ] [ 2 ] = s - > heights [ vx + ( vy + 0 ) * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 1 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 1 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 1 ] [ 2 ] = s - > heights [ vx + ( vy + 0 ) * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 2 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 0 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 2 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 2 ] [ 2 ] = s - > heights [ vx + ( vy + 1 ) * SECTHEIGHTSIZE ] ;
mesh - > xyz_array [ v + 3 ] [ 0 ] = ( x - CHUNKBIAS + ( vx + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 3 ] [ 1 ] = ( y - CHUNKBIAS + ( vy + 1 ) / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v + 3 ] [ 2 ] = s - > heights [ vx + ( vy + 1 ) * SECTHEIGHTSIZE ] ;
if ( s - > maxh < mesh - > xyz_array [ v ] [ 2 ] )
s - > maxh = mesh - > xyz_array [ v ] [ 2 ] ;
if ( s - > minh > mesh - > xyz_array [ v ] [ 2 ] )
s - > minh = mesh - > xyz_array [ v ] [ 2 ] ;
st [ 0 ] = 1.0f / hm - > tilecount [ 0 ] * vx ;
st [ 1 ] = 1.0f / hm - > tilecount [ 1 ] * vy ;
inst [ 0 ] = 0.5f / ( hm - > tilecount [ 0 ] * hm - > tilepixcount [ 0 ] ) ;
inst [ 1 ] = 0.5f / ( hm - > tilecount [ 1 ] * hm - > tilepixcount [ 1 ] ) ;
mesh - > st_array [ v + 0 ] [ 0 ] = st [ 0 ] + inst [ 0 ] ;
mesh - > st_array [ v + 0 ] [ 1 ] = st [ 1 ] + inst [ 1 ] ;
mesh - > st_array [ v + 1 ] [ 0 ] = st [ 0 ] - inst [ 0 ] + 1.0f / hm - > tilecount [ 0 ] ;
mesh - > st_array [ v + 1 ] [ 1 ] = st [ 1 ] + inst [ 1 ] ;
mesh - > st_array [ v + 2 ] [ 0 ] = st [ 0 ] + inst [ 0 ] ;
mesh - > st_array [ v + 2 ] [ 1 ] = st [ 1 ] - inst [ 1 ] + 1.0f / hm - > tilecount [ 1 ] ;
mesh - > st_array [ v + 3 ] [ 0 ] = st [ 0 ] - inst [ 0 ] + 1.0f / hm - > tilecount [ 0 ] ;
mesh - > st_array [ v + 3 ] [ 1 ] = st [ 1 ] - inst [ 1 ] + 1.0f / hm - > tilecount [ 1 ] ;
//calc the position in the range -0.5 to 0.5
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] = ( ( ( float ) vx / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] = ( ( ( float ) vy / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
//scale down to a half-texel
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
//bias it
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmx ) / HMLMSTRIDE ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmy ) / HMLMSTRIDE ) ;
2012-07-20 01:46:05 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 0 ;
2012-08-04 11:28:39 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 2 ;
2012-07-20 01:46:05 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
2012-08-04 11:28:39 +00:00
mesh - > indexes [ mesh - > numindexes + + ] = v + 2 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 + 2 ;
}
}
}
else
{
if ( ! mesh - > xyz_array )
{
mesh - > xyz_array = BZ_Malloc ( ( sizeof ( vecV_t ) + sizeof ( vec2_t ) + sizeof ( vec2_t ) ) * ( SECTHEIGHTSIZE ) * ( SECTHEIGHTSIZE ) ) ;
mesh - > st_array = ( void * ) ( mesh - > xyz_array + ( SECTHEIGHTSIZE ) * ( SECTHEIGHTSIZE ) ) ;
mesh - > lmst_array [ 0 ] = ( void * ) ( mesh - > st_array + ( SECTHEIGHTSIZE ) * ( SECTHEIGHTSIZE ) ) ;
}
2012-09-30 05:52:03 +00:00
mesh - > colors4f_array = s - > colours ;
2012-08-04 11:28:39 +00:00
mesh - > numvertexes = 0 ;
/*64 quads across requires 65 verticies*/
for ( vy = 0 ; vy < SECTHEIGHTSIZE ; vy + + )
{
for ( vx = 0 ; vx < SECTHEIGHTSIZE ; vx + + )
{
v = mesh - > numvertexes + + ;
mesh - > xyz_array [ v ] [ 0 ] = ( x - CHUNKBIAS + vx / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v ] [ 1 ] = ( y - CHUNKBIAS + vy / ( SECTHEIGHTSIZE - 1.0f ) ) * hm - > sectionsize ;
mesh - > xyz_array [ v ] [ 2 ] = s - > heights [ vx + vy * SECTHEIGHTSIZE ] ;
if ( s - > maxh < mesh - > xyz_array [ v ] [ 2 ] )
s - > maxh = mesh - > xyz_array [ v ] [ 2 ] ;
if ( s - > minh > mesh - > xyz_array [ v ] [ 2 ] )
s - > minh = mesh - > xyz_array [ v ] [ 2 ] ;
mesh - > st_array [ v ] [ 0 ] = mesh - > xyz_array [ v ] [ 0 ] / 128 ;
mesh - > st_array [ v ] [ 1 ] = mesh - > xyz_array [ v ] [ 1 ] / 128 ;
//calc the position in the range -0.5 to 0.5
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] = ( ( ( float ) vx / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] = ( ( ( float ) vy / ( SECTHEIGHTSIZE - 1 ) ) - 0.5 ) ;
//scale down to a half-texel
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] * = ( SECTTEXSIZE - 1.0f ) / HMLMSTRIDE ;
//bias it
mesh - > lmst_array [ 0 ] [ v ] [ 0 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmx ) / HMLMSTRIDE ) ;
mesh - > lmst_array [ 0 ] [ v ] [ 1 ] + = ( ( float ) SECTTEXSIZE / ( HMLMSTRIDE * 2 ) ) + ( ( float ) ( s - > lmy ) / HMLMSTRIDE ) ;
}
}
if ( ! mesh - > indexes )
mesh - > indexes = BZ_Malloc ( sizeof ( index_t ) * SECTHEIGHTSIZE * SECTHEIGHTSIZE * 6 ) ;
mesh - > numindexes = 0 ;
for ( vy = 0 ; vy < SECTHEIGHTSIZE - 1 ; vy + + )
{
for ( vx = 0 ; vx < SECTHEIGHTSIZE - 1 ; vx + + )
{
# ifndef STRICTEDGES
float d1 , d2 ;
# endif
# if SECTHEIGHTSIZE >= 4
int holebit ;
//skip generation of the mesh above holes
holebit = 1u < < ( vx / ( SECTHEIGHTSIZE > > 2 ) + ( vy / ( SECTHEIGHTSIZE > > 2 ) ) * 4 ) ;
if ( s - > holes & holebit )
continue ;
# endif
v = vx + vy * ( SECTHEIGHTSIZE ) ;
# ifndef STRICTEDGES
d1 = fabs ( mesh - > xyz_array [ v ] [ 2 ] - mesh - > xyz_array [ v + 1 + SECTHEIGHTSIZE ] [ 2 ] ) ;
d2 = fabs ( mesh - > xyz_array [ v + 1 ] [ 2 ] - mesh - > xyz_array [ v + SECTHEIGHTSIZE ] [ 2 ] ) ;
if ( d1 < d2 )
{
mesh - > indexes [ mesh - > numindexes + + ] = v + 0 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 + SECTHEIGHTSIZE ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 0 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + SECTHEIGHTSIZE ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 + SECTHEIGHTSIZE ;
}
else
# endif
{
mesh - > indexes [ mesh - > numindexes + + ] = v + 0 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + SECTHEIGHTSIZE ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 ;
mesh - > indexes [ mesh - > numindexes + + ] = v + SECTHEIGHTSIZE ;
mesh - > indexes [ mesh - > numindexes + + ] = v + 1 + SECTHEIGHTSIZE ;
}
2012-07-20 01:46:05 +00:00
}
}
}
# ifdef GLQUAKE
2012-10-08 01:30:41 +00:00
if ( qrenderer = = QR_OPENGL & & qglGenBuffersARB )
2012-07-20 01:46:05 +00:00
{
2012-09-30 05:52:03 +00:00
if ( s - > vbo . coord . gl . vbo )
2012-08-04 11:28:39 +00:00
{
qglDeleteBuffersARB ( 1 , & s - > vbo . coord . gl . vbo ) ;
qglDeleteBuffersARB ( 1 , & s - > vbo . indicies . gl . vbo ) ;
s - > vbo . coord . gl . vbo = 0 ;
s - > vbo . indicies . gl . vbo = 0 ;
}
2012-07-20 01:46:05 +00:00
if ( ! s - > vbo . coord . gl . vbo )
2012-08-04 11:28:39 +00:00
{
2012-07-20 01:46:05 +00:00
qglGenBuffersARB ( 1 , & s - > vbo . coord . gl . vbo ) ;
2012-08-04 11:28:39 +00:00
GL_SelectVBO ( s - > vbo . coord . gl . vbo ) ;
qglBufferDataARB ( GL_ARRAY_BUFFER_ARB , ( sizeof ( vecV_t ) + sizeof ( vec2_t ) + sizeof ( vec2_t ) + sizeof ( vec4_t ) ) * ( mesh - > numvertexes ) , NULL , GL_STATIC_DRAW_ARB ) ;
}
else
GL_SelectVBO ( s - > vbo . coord . gl . vbo ) ;
qglBufferSubDataARB ( GL_ARRAY_BUFFER_ARB , 0 , ( sizeof ( vecV_t ) + sizeof ( vec2_t ) + sizeof ( vec2_t ) ) * mesh - > numvertexes , mesh - > xyz_array ) ;
2012-09-30 05:52:03 +00:00
if ( mesh - > colors4f_array )
2012-08-04 11:28:39 +00:00
qglBufferSubDataARB ( GL_ARRAY_BUFFER_ARB , ( sizeof ( vecV_t ) + sizeof ( vec2_t ) + sizeof ( vec2_t ) ) * mesh - > numvertexes , sizeof ( vec4_t ) * mesh - > numvertexes , mesh - > colors4f_array ) ;
2012-07-20 01:46:05 +00:00
GL_SelectVBO ( 0 ) ;
2012-08-04 11:28:39 +00:00
s - > vbo . coord . gl . addr = 0 ;
2012-07-20 01:46:05 +00:00
s - > vbo . texcoord . gl . addr = ( void * ) ( ( char * ) mesh - > st_array - ( char * ) mesh - > xyz_array ) ;
s - > vbo . texcoord . gl . vbo = s - > vbo . coord . gl . vbo ;
s - > vbo . lmcoord [ 0 ] . gl . addr = ( void * ) ( ( char * ) mesh - > lmst_array [ 0 ] - ( char * ) mesh - > xyz_array ) ;
s - > vbo . lmcoord [ 0 ] . gl . vbo = s - > vbo . coord . gl . vbo ;
2012-08-04 11:28:39 +00:00
s - > vbo . colours . gl . addr = ( void * ) ( ( sizeof ( vecV_t ) + sizeof ( vec2_t ) + sizeof ( vec2_t ) ) * mesh - > numvertexes ) ;
s - > vbo . colours . gl . vbo = s - > vbo . coord . gl . vbo ;
2012-07-20 01:46:05 +00:00
// Z_Free(mesh->xyz_array);
// mesh->xyz_array = NULL;
// mesh->st_array = NULL;
// mesh->lmst_array = NULL;
if ( ! s - > vbo . indicies . gl . vbo )
qglGenBuffersARB ( 1 , & s - > vbo . indicies . gl . vbo ) ;
s - > vbo . indicies . gl . addr = 0 ;
GL_SelectEBO ( s - > vbo . indicies . gl . vbo ) ;
qglBufferDataARB ( GL_ELEMENT_ARRAY_BUFFER_ARB , sizeof ( index_t ) * mesh - > numindexes , mesh - > indexes , GL_STATIC_DRAW_ARB ) ;
GL_SelectEBO ( 0 ) ;
// Z_Free(mesh->indexes);
// mesh->indexes = NULL;
}
# endif
2012-09-30 05:52:03 +00:00
# ifdef D3D11QUAKE
if ( qrenderer = = QR_DIRECT3D11 )
{
void D3D11BE_GenBatchVBOs ( vbo_t * * vbochain , batch_t * firstbatch , batch_t * stopbatch ) ;
batch_t batch = { 0 } ;
mesh_t * meshes = & s - > mesh ;
vbo_t * vbo = NULL ;
batch . maxmeshes = 1 ;
batch . mesh = & meshes ;
//BE_ClearVBO(&s->vbo);
D3D11BE_GenBatchVBOs ( & vbo , & batch , NULL ) ;
s - > vbo = * vbo ;
}
# endif
2012-07-20 01:46:05 +00:00
}
2012-11-29 13:37:48 +00:00
struct tdibctx
{
heightmap_t * hm ;
int vx ;
int vy ;
entity_t * ent ;
batch_t * * batches ;
} ;
void Terr_DrawInBounds ( struct tdibctx * ctx , int x , int y , int w , int h )
{
vec3_t mins , maxs ;
hmsection_t * s ;
int i ;
batch_t * b ;
heightmap_t * hm = ctx - > hm ;
if ( w = = 1 & & h = = 1 )
{
mins [ 0 ] = ( x + 0 - CHUNKBIAS ) * hm - > sectionsize ;
maxs [ 0 ] = ( x + w - CHUNKBIAS ) * hm - > sectionsize ;
mins [ 1 ] = ( y + 0 - CHUNKBIAS ) * hm - > sectionsize ;
maxs [ 1 ] = ( y + h - CHUNKBIAS ) * hm - > sectionsize ;
mins [ 2 ] = - 999999 ;
maxs [ 2 ] = 999999 ;
if ( R_CullBox ( mins , maxs ) )
return ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_LOAD ) ;
2012-11-29 13:37:48 +00:00
if ( ! s )
return ;
if ( s - > lightmap < 0 )
2013-03-31 04:21:08 +00:00
Terr_LoadSection ( hm , s , x , y , false ) ;
2012-11-29 13:37:48 +00:00
if ( s - > flags & TSF_RELIGHT )
{
if ( ! hm - > relight )
{
hm - > relight = s ;
hm - > relightidx = 0 ;
hm - > relightmin [ 0 ] = mins [ 0 ] ;
hm - > relightmin [ 1 ] = mins [ 1 ] ;
}
}
if ( s - > flags & TSF_DIRTY )
{
s - > flags & = ~ TSF_DIRTY ;
Terr_RebuildMesh ( s , x , y ) ;
}
//chuck out any batches for models in this section
for ( i = 0 ; i < s - > numents ; i + + )
{
if ( s - > ents [ i ] . model & & s - > ents [ i ] . model - > type = = mod_alias )
{
R_GAlias_GenerateBatches ( & s - > ents [ i ] , ctx - > batches ) ;
}
}
if ( s - > flags & TSF_HASWATER )
{
mins [ 2 ] = s - > waterheight ;
maxs [ 2 ] = s - > waterheight ;
if ( ! R_CullBox ( mins , maxs ) )
{
Terr_DrawTerrainWater ( hm , mins , maxs , s - > waterheight , 1 , 1 , 1 , 1 ) ;
}
}
mins [ 2 ] = s - > minh ;
maxs [ 2 ] = s - > maxh ;
// if (!BoundsIntersect(mins, maxs, r_refdef.vieworg, r_refdef.vieworg))
if ( R_CullBox ( mins , maxs ) )
return ;
b = BE_GetTempBatch ( ) ;
if ( ! b )
return ;
b - > ent = ctx - > ent ;
b - > shader = hm - > shader ;
b - > flags = 0 ;
b - > mesh = & s - > amesh ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
b - > mesh [ 0 ] = & s - > mesh ;
2012-11-29 13:37:48 +00:00
b - > meshes = 1 ;
b - > buildmeshes = NULL ;
b - > skin = & s - > textures ;
b - > texture = NULL ;
b - > vbo = NULL ; //&s->vbo;
b - > lightmap [ 0 ] = s - > lightmap ;
b - > lightmap [ 1 ] = - 1 ;
b - > lightmap [ 2 ] = - 1 ;
b - > lightmap [ 3 ] = - 1 ;
b - > next = ctx - > batches [ b - > shader - > sort ] ;
ctx - > batches [ b - > shader - > sort ] = b ;
}
else if ( w & & h )
{
//divide and conquer, radiating outwards from the view.
if ( w > h )
{
i = x + w ;
w = x + w / 2 ;
if ( ctx - > vx > = w )
{
Terr_DrawInBounds ( ctx , w , y , i - w , h ) ;
Terr_DrawInBounds ( ctx , x , y , w - x , h ) ;
}
else
{
Terr_DrawInBounds ( ctx , x , y , w - x , h ) ;
Terr_DrawInBounds ( ctx , w , y , i - w , h ) ;
}
}
else
{
i = y + h ;
h = y + h / 2 ;
if ( ctx - > vy > = h )
{
Terr_DrawInBounds ( ctx , x , h , w , i - h ) ;
Terr_DrawInBounds ( ctx , x , y , w , h - y ) ;
}
else
{
Terr_DrawInBounds ( ctx , x , y , w , h - y ) ;
Terr_DrawInBounds ( ctx , x , h , w , i - h ) ;
}
}
}
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
void Terr_DrawTerrainModel ( batch_t * * batches , entity_t * e )
2005-08-26 22:49:36 +00:00
{
model_t * m = e - > model ;
heightmap_t * hm = m - > terrain ;
2011-05-20 04:10:46 +00:00
batch_t * b ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
int bounds [ 4 ] ;
2012-11-29 13:37:48 +00:00
struct tdibctx tdibctx ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( ! r_refdef . recurse )
2013-03-31 04:21:08 +00:00
{
Terr_DoEditNotify ( hm ) ;
// while (hm->activesections > 0)
// if (!Terr_Collect(hm))
// break;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
while ( hm - > activesections > TERRAINACTIVESECTIONS )
2013-03-31 04:21:08 +00:00
if ( ! Terr_Collect ( hm ) )
break ;
}
2012-07-20 01:46:05 +00:00
if ( hm - > relight )
ted_dorelight ( hm ) ;
2005-08-26 22:49:36 +00:00
2005-10-15 20:06:34 +00:00
if ( e - > model = = cl . worldmodel )
{
2011-05-20 04:10:46 +00:00
b = BE_GetTempBatch ( ) ;
if ( b )
{
2012-07-05 19:42:36 +00:00
b - > lightmap [ 0 ] = - 1 ;
b - > lightmap [ 1 ] = - 1 ;
b - > lightmap [ 2 ] = - 1 ;
b - > lightmap [ 3 ] = - 1 ;
2011-05-20 04:10:46 +00:00
b - > ent = e ;
b - > shader = hm - > skyshader ;
b - > flags = 0 ;
b - > mesh = & hm - > askymesh ;
b - > mesh [ 0 ] = & hm - > skymesh ;
b - > meshes = 1 ;
b - > buildmeshes = NULL ;
b - > skin = & b - > shader - > defaulttextures ;
b - > texture = NULL ;
2012-04-09 19:12:12 +00:00
// vbo = b->vbo = hm->vbo[x+y*MAXSECTIONS];
2011-05-20 04:10:46 +00:00
b - > vbo = NULL ;
b - > next = batches [ b - > shader - > sort ] ;
batches [ b - > shader - > sort ] = b ;
}
2005-10-15 20:06:34 +00:00
}
2012-07-20 01:46:05 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( r_refdef . gfog_rgbd [ 3 ] | | gl_maxdist . value > 0 )
{
float culldist ;
extern cvar_t r_fog_exp2 ;
if ( r_refdef . gfog_rgbd [ 3 ] )
{
//figure out the eyespace distance required to reach that fog value
culldist = log ( 0.5 / 255.0f ) ;
if ( r_fog_exp2 . ival )
culldist = sqrt ( culldist / ( - r_refdef . gfog_rgbd [ 3 ] * r_refdef . gfog_rgbd [ 3 ] ) ) ;
else
culldist = culldist / ( - r_refdef . gfog_rgbd [ 3 ] ) ;
//anything drawn beyond this point is fully obscured by fog
culldist + = 4096 ;
}
else
2012-07-14 17:33:44 +00:00
culldist = 999999999999999.f ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( culldist > gl_maxdist . value & & gl_maxdist . value > 0 )
culldist = gl_maxdist . value ;
bounds [ 0 ] = bound ( hm - > firstsegx , ( r_refdef . vieworg [ 0 ] + ( CHUNKBIAS + 0 ) * hm - > sectionsize - culldist ) / hm - > sectionsize , hm - > maxsegx ) ;
bounds [ 1 ] = bound ( hm - > firstsegx , ( r_refdef . vieworg [ 0 ] + ( CHUNKBIAS + 1 ) * hm - > sectionsize + culldist ) / hm - > sectionsize , hm - > maxsegx ) ;
bounds [ 2 ] = bound ( hm - > firstsegy , ( r_refdef . vieworg [ 1 ] + ( CHUNKBIAS + 0 ) * hm - > sectionsize - culldist ) / hm - > sectionsize , hm - > maxsegy ) ;
bounds [ 3 ] = bound ( hm - > firstsegy , ( r_refdef . vieworg [ 1 ] + ( CHUNKBIAS + 1 ) * hm - > sectionsize + culldist ) / hm - > sectionsize , hm - > maxsegy ) ;
}
else
{
bounds [ 0 ] = hm - > firstsegx ;
bounds [ 1 ] = hm - > maxsegx ;
bounds [ 2 ] = hm - > firstsegy ;
bounds [ 3 ] = hm - > maxsegy ;
}
2012-11-29 13:37:48 +00:00
tdibctx . hm = hm ;
tdibctx . batches = batches ;
tdibctx . ent = e ;
tdibctx . vx = ( r_refdef . vieworg [ 0 ] + CHUNKBIAS * hm - > sectionsize ) / hm - > sectionsize ;
tdibctx . vy = ( r_refdef . vieworg [ 1 ] + CHUNKBIAS * hm - > sectionsize ) / hm - > sectionsize ;
Terr_DrawInBounds ( & tdibctx , bounds [ 0 ] , bounds [ 2 ] , bounds [ 1 ] - bounds [ 0 ] , bounds [ 3 ] - bounds [ 2 ] ) ;
/*
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( x = bounds [ 0 ] ; x < bounds [ 1 ] ; x + + )
2005-08-26 22:49:36 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
mins [ 0 ] = ( x + 0 - CHUNKBIAS ) * hm - > sectionsize ;
maxs [ 0 ] = ( x + 1 - CHUNKBIAS ) * hm - > sectionsize ;
for ( y = bounds [ 2 ] ; y < bounds [ 3 ] ; y + + )
2005-08-26 22:49:36 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
mins [ 1 ] = ( y + 0 - CHUNKBIAS ) * hm - > sectionsize ;
maxs [ 1 ] = ( y + 1 - CHUNKBIAS ) * hm - > sectionsize ;
2005-08-26 22:49:36 +00:00
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_LOAD ) ;
2012-04-09 19:12:12 +00:00
if ( ! s )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
continue ;
if ( s - > lightmap < 0 )
Terr_LoadSection ( hm , s , x , y ) ;
2012-07-20 01:46:05 +00:00
if ( s - > flags & TSF_RELIGHT )
2005-08-26 22:49:36 +00:00
{
2012-07-20 01:46:05 +00:00
if ( ! hm - > relight )
2012-04-09 19:12:12 +00:00
{
2012-07-20 01:46:05 +00:00
hm - > relight = s ;
hm - > relightidx = 0 ;
hm - > relightmin [ 0 ] = mins [ 0 ] ;
hm - > relightmin [ 1 ] = mins [ 1 ] ;
2012-04-09 19:12:12 +00:00
}
2012-07-20 01:46:05 +00:00
}
2011-05-20 04:10:46 +00:00
2012-07-20 01:46:05 +00:00
mesh = & s - > mesh ;
if ( s - > flags & TSF_DIRTY )
{
s - > flags & = ~ TSF_DIRTY ;
2005-08-26 22:49:36 +00:00
2012-07-20 01:46:05 +00:00
Terr_RebuildMesh ( s , x , y ) ;
}
2005-08-26 22:49:36 +00:00
2012-07-20 01:46:05 +00:00
//chuck out any batches for models in this section
for ( i = 0 ; i < s - > numents ; i + + )
{
if ( s - > ents [ i ] . model & & s - > ents [ i ] . model - > type = = mod_alias )
2011-05-20 04:10:46 +00:00
{
2012-07-20 01:46:05 +00:00
R_GAlias_GenerateBatches ( & s - > ents [ i ] , batches ) ;
2005-08-26 22:49:36 +00:00
}
2012-07-20 01:46:05 +00:00
}
2011-05-20 04:10:46 +00:00
2012-07-20 01:46:05 +00:00
if ( s - > flags & TSF_HASWATER )
{
mins [ 2 ] = s - > waterheight ;
maxs [ 2 ] = s - > waterheight ;
if ( ! R_CullBox ( mins , maxs ) )
2012-04-09 19:12:12 +00:00
{
2012-09-30 05:52:03 +00:00
Terr_DrawTerrainWater ( hm , mins , maxs , s - > waterheight , 1 , 1 , 1 , 1 ) ;
2012-04-09 19:12:12 +00:00
}
2005-08-26 22:49:36 +00:00
}
2011-05-20 04:10:46 +00:00
2012-04-09 19:12:12 +00:00
mins [ 2 ] = s - > minh ;
maxs [ 2 ] = s - > maxh ;
2011-05-20 04:10:46 +00:00
2012-04-09 19:12:12 +00:00
// if (!BoundsIntersect(mins, maxs, r_refdef.vieworg, r_refdef.vieworg))
2011-05-20 04:10:46 +00:00
if ( R_CullBox ( mins , maxs ) )
continue ;
b = BE_GetTempBatch ( ) ;
if ( ! b )
continue ;
b - > ent = e ;
b - > shader = hm - > shader ;
b - > flags = 0 ;
2012-04-09 19:12:12 +00:00
b - > mesh = & s - > amesh ;
2011-05-20 04:10:46 +00:00
b - > mesh [ 0 ] = mesh ;
b - > meshes = 1 ;
b - > buildmeshes = NULL ;
2012-04-09 19:12:12 +00:00
b - > skin = & s - > textures ;
2011-05-20 04:10:46 +00:00
b - > texture = NULL ;
2012-09-30 05:52:03 +00:00
b - > vbo = NULL ; //&s->vbo;
2012-07-05 19:42:36 +00:00
b - > lightmap [ 0 ] = s - > lightmap ;
b - > lightmap [ 1 ] = - 1 ;
b - > lightmap [ 2 ] = - 1 ;
b - > lightmap [ 3 ] = - 1 ;
2011-05-20 04:10:46 +00:00
b - > next = batches [ b - > shader - > sort ] ;
batches [ b - > shader - > sort ] = b ;
2005-08-26 22:49:36 +00:00
}
}
2012-11-29 13:37:48 +00:00
*/
2005-08-26 22:49:36 +00:00
}
2012-08-04 11:28:39 +00:00
typedef struct fragmentdecal_s fragmentdecal_t ;
void Fragment_ClipPoly ( fragmentdecal_t * dec , int numverts , float * inverts ) ;
void Terrain_ClipDecal ( fragmentdecal_t * dec , float * center , float radius , model_t * model )
{
int min [ 2 ] , max [ 2 ] , mint [ 2 ] , maxt [ 2 ] ;
int x , y , tx , ty ;
vecV_t vert [ 6 ] ;
hmsection_t * s ;
heightmap_t * hm = model - > terrain ;
min [ 0 ] = floor ( ( center [ 0 ] - radius ) / ( hm - > sectionsize ) ) + CHUNKBIAS ;
min [ 1 ] = floor ( ( center [ 1 ] - radius ) / ( hm - > sectionsize ) ) + CHUNKBIAS ;
max [ 0 ] = ceil ( ( center [ 0 ] + radius ) / ( hm - > sectionsize ) ) + CHUNKBIAS ;
max [ 1 ] = ceil ( ( center [ 1 ] + radius ) / ( hm - > sectionsize ) ) + CHUNKBIAS ;
min [ 0 ] = bound ( hm - > firstsegx , min [ 0 ] , hm - > maxsegx ) ;
min [ 1 ] = bound ( hm - > firstsegy , min [ 1 ] , hm - > maxsegy ) ;
max [ 0 ] = bound ( hm - > firstsegx , max [ 0 ] , hm - > maxsegx ) ;
max [ 1 ] = bound ( hm - > firstsegy , max [ 1 ] , hm - > maxsegy ) ;
for ( y = min [ 1 ] ; y < max [ 1 ] ; y + + )
{
for ( x = min [ 0 ] ; x < max [ 0 ] ; x + + )
{
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_LOAD ) ;
2012-08-04 11:28:39 +00:00
if ( ! s )
continue ;
mint [ 0 ] = floor ( ( center [ 0 ] - radius ) * ( SECTHEIGHTSIZE - 1 ) / ( hm - > sectionsize ) + ( CHUNKBIAS - x ) * ( SECTHEIGHTSIZE - 1 ) ) ;
mint [ 1 ] = floor ( ( center [ 1 ] - radius ) * ( SECTHEIGHTSIZE - 1 ) / ( hm - > sectionsize ) + ( CHUNKBIAS - y ) * ( SECTHEIGHTSIZE - 1 ) ) ;
maxt [ 0 ] = ceil ( ( center [ 0 ] + radius ) * ( SECTHEIGHTSIZE - 1 ) / ( hm - > sectionsize ) + ( CHUNKBIAS - x ) * ( SECTHEIGHTSIZE - 1 ) ) ;
maxt [ 1 ] = ceil ( ( center [ 1 ] + radius ) * ( SECTHEIGHTSIZE - 1 ) / ( hm - > sectionsize ) + ( CHUNKBIAS - y ) * ( SECTHEIGHTSIZE - 1 ) ) ;
mint [ 0 ] = bound ( 0 , mint [ 0 ] , ( SECTHEIGHTSIZE - 1 ) ) ;
mint [ 1 ] = bound ( 0 , mint [ 1 ] , ( SECTHEIGHTSIZE - 1 ) ) ;
maxt [ 0 ] = bound ( 0 , maxt [ 0 ] , ( SECTHEIGHTSIZE - 1 ) ) ;
maxt [ 1 ] = bound ( 0 , maxt [ 1 ] , ( SECTHEIGHTSIZE - 1 ) ) ;
for ( ty = mint [ 1 ] ; ty < maxt [ 1 ] ; ty + + )
{
for ( tx = mint [ 0 ] ; tx < maxt [ 0 ] ; tx + + )
{
# ifndef STRICTEDGES
float d1 , d2 ;
d1 = fabs ( s - > heights [ ( tx + 0 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] - s - > heights [ ( tx + 1 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ) ;
d2 = fabs ( s - > heights [ ( tx + 1 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] - s - > heights [ ( tx + 0 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ) ;
if ( d1 < d2 )
{
vert [ 0 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 0 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 1 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 1 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 2 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 2 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 3 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 3 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 4 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 4 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 5 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 5 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 0 ] [ 2 ] = s - > heights [ ( tx + 0 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ;
vert [ 1 ] [ 2 ] = s - > heights [ ( tx + 1 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ;
vert [ 2 ] [ 2 ] = s - > heights [ ( tx + 1 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ;
vert [ 3 ] [ 2 ] = s - > heights [ ( tx + 0 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ;
vert [ 4 ] [ 2 ] = s - > heights [ ( tx + 0 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ;
vert [ 5 ] [ 2 ] = s - > heights [ ( tx + 1 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ;
}
else
# endif
{
vert [ 0 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 0 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 1 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 1 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 2 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 2 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 3 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 3 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 4 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 0 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 4 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 5 ] [ 0 ] = ( x - CHUNKBIAS ) * hm - > sectionsize + ( tx + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ; vert [ 5 ] [ 1 ] = ( y - CHUNKBIAS ) * hm - > sectionsize + ( ty + 1 ) / ( float ) ( SECTHEIGHTSIZE - 1 ) * hm - > sectionsize ;
vert [ 0 ] [ 2 ] = s - > heights [ ( tx + 0 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ;
vert [ 1 ] [ 2 ] = s - > heights [ ( tx + 0 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ;
vert [ 2 ] [ 2 ] = s - > heights [ ( tx + 1 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ;
vert [ 3 ] [ 2 ] = s - > heights [ ( tx + 1 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ;
vert [ 4 ] [ 2 ] = s - > heights [ ( tx + 0 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ;
vert [ 5 ] [ 2 ] = s - > heights [ ( tx + 1 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ;
}
Fragment_ClipPoly ( dec , 3 , & vert [ 0 ] [ 0 ] ) ;
Fragment_ClipPoly ( dec , 3 , & vert [ 3 ] [ 0 ] ) ;
}
}
}
}
}
2012-04-09 19:12:12 +00:00
# endif
2007-05-25 22:16:29 +00:00
2006-03-04 20:43:48 +00:00
unsigned int Heightmap_PointContentsHM ( heightmap_t * hm , float clipmipsz , vec3_t org )
2005-08-26 22:49:36 +00:00
{
float x , y ;
float z , tz ;
int sx , sy ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
unsigned int holebit ;
2012-04-09 19:12:12 +00:00
hmsection_t * s ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
const float wbias = CHUNKBIAS * hm - > sectionsize ;
sx = ( org [ 0 ] + wbias ) / hm - > sectionsize ;
sy = ( org [ 1 ] + wbias ) / hm - > sectionsize ;
if ( sx < hm - > firstsegx | | sy < hm - > firstsegy )
return hm - > exteriorcontents ;
if ( sx > = hm - > maxsegx | | sy > = hm - > maxsegy )
return hm - > exteriorcontents ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , sx , sy , TGS_LOAD ) ;
2012-04-09 19:12:12 +00:00
if ( ! s )
2005-08-26 22:49:36 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
return FTECONTENTS_SOLID ;
2005-08-26 22:49:36 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
x = ( org [ 0 ] + wbias - ( sx * hm - > sectionsize ) ) * ( SECTHEIGHTSIZE - 1 ) / hm - > sectionsize ;
y = ( org [ 1 ] + wbias - ( sy * hm - > sectionsize ) ) * ( SECTHEIGHTSIZE - 1 ) / hm - > sectionsize ;
2012-04-09 19:12:12 +00:00
z = ( org [ 2 ] + clipmipsz ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( z < s - > minh - 16 )
return hm - > exteriorcontents ;
2005-08-26 22:49:36 +00:00
sx = x ; x - = sx ;
sy = y ; y - = sy ;
2012-08-04 11:28:39 +00:00
holebit = 1u < < ( sx / ( SECTHEIGHTSIZE > > 2 ) + ( sy / ( SECTHEIGHTSIZE > > 2 ) ) * 4 ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( s - > holes & ( 1u < < holebit ) )
return FTECONTENTS_EMPTY ;
2005-08-26 22:49:36 +00:00
//made of two triangles:
if ( x + y > 1 ) //the 1, 1 triangle
{
float v1 , v2 , v3 ;
v3 = 1 - y ;
v2 = x + y - 1 ;
v1 = 1 - x ;
//0, 1
//1, 1
//1, 0
2012-04-09 19:12:12 +00:00
tz = ( s - > heights [ ( sx + 0 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] * v1 +
s - > heights [ ( sx + 1 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] * v2 +
s - > heights [ ( sx + 1 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] * v3 ) ;
2005-08-26 22:49:36 +00:00
}
else
{
float v1 , v2 , v3 ;
v1 = y ;
v2 = x ;
v3 = 1 - y - x ;
//0, 1
//1, 0
//0, 0
2012-04-09 19:12:12 +00:00
tz = ( s - > heights [ ( sx + 0 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] * v1 +
s - > heights [ ( sx + 1 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] * v2 +
s - > heights [ ( sx + 0 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] * v3 ) ;
2005-08-26 22:49:36 +00:00
}
if ( z < = tz )
return FTECONTENTS_SOLID ; //contained within
2012-07-20 01:46:05 +00:00
if ( s - > flags & TSF_HASWATER )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( z < s - > waterheight )
return FTECONTENTS_WATER ;
2005-08-26 22:49:36 +00:00
return FTECONTENTS_EMPTY ;
}
2010-08-28 17:14:38 +00:00
unsigned int Heightmap_PointContents ( model_t * model , vec3_t axis [ 3 ] , vec3_t org )
2005-08-26 22:49:36 +00:00
{
heightmap_t * hm = model - > terrain ;
return Heightmap_PointContentsHM ( hm , 0 , org ) ;
}
2010-08-28 17:14:38 +00:00
unsigned int Heightmap_NativeBoxContents ( model_t * model , int hulloverride , int frame , vec3_t axis [ 3 ] , vec3_t org , vec3_t mins , vec3_t maxs )
2006-03-06 01:41:09 +00:00
{
heightmap_t * hm = model - > terrain ;
return Heightmap_PointContentsHM ( hm , mins [ 2 ] , org ) ;
}
2005-08-26 22:49:36 +00:00
2005-09-21 01:21:35 +00:00
void Heightmap_Normal ( heightmap_t * hm , vec3_t org , vec3_t norm )
2005-08-26 22:49:36 +00:00
{
2012-07-20 01:46:05 +00:00
#if 0
2012-04-09 19:12:12 +00:00
norm [ 0 ] = 0 ;
norm [ 1 ] = 0 ;
norm [ 2 ] = 1 ;
2012-07-20 01:46:05 +00:00
# else
2005-08-26 22:49:36 +00:00
float x , y ;
int sx , sy ;
2011-05-20 04:10:46 +00:00
vec3_t d1 , d2 ;
2012-07-20 01:46:05 +00:00
const float wbias = CHUNKBIAS * hm - > sectionsize ;
hmsection_t * s ;
norm [ 0 ] = 0 ;
norm [ 1 ] = 0 ;
norm [ 2 ] = 1 ;
2005-08-26 22:49:36 +00:00
2012-07-20 01:46:05 +00:00
sx = ( org [ 0 ] + wbias ) / hm - > sectionsize ;
sy = ( org [ 1 ] + wbias ) / hm - > sectionsize ;
if ( sx < hm - > firstsegx | | sy < hm - > firstsegy )
return ;
if ( sx > = hm - > maxsegx | | sy > = hm - > maxsegy )
return ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , sx , sy , TGS_LOAD ) ;
2012-07-20 01:46:05 +00:00
if ( ! s )
return ;
2005-08-26 22:49:36 +00:00
2012-07-20 01:46:05 +00:00
x = ( org [ 0 ] + wbias - ( sx * hm - > sectionsize ) ) * ( SECTHEIGHTSIZE - 1 ) / hm - > sectionsize ;
y = ( org [ 1 ] + wbias - ( sy * hm - > sectionsize ) ) * ( SECTHEIGHTSIZE - 1 ) / hm - > sectionsize ;
2012-08-04 11:28:39 +00:00
2005-08-26 22:49:36 +00:00
sx = x ; x - = sx ;
sy = y ; y - = sy ;
if ( x + y > 1 ) //the 1, 1 triangle
{
//0, 1
//1, 1
//1, 0
2012-07-20 01:46:05 +00:00
d1 [ 0 ] = ( hm - > sectionsize / SECTHEIGHTSIZE ) ;
2011-05-20 04:10:46 +00:00
d1 [ 1 ] = 0 ;
2012-07-20 01:46:05 +00:00
d1 [ 2 ] = ( s - > heights [ ( sx + 1 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] - s - > heights [ ( sx + 0 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] ) ;
2011-05-20 04:10:46 +00:00
d2 [ 0 ] = 0 ;
2012-07-20 01:46:05 +00:00
d2 [ 1 ] = ( hm - > sectionsize / SECTHEIGHTSIZE ) ;
d2 [ 2 ] = ( s - > heights [ ( sx + 1 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] - s - > heights [ ( sx + 1 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] ) ;
2005-08-26 22:49:36 +00:00
}
else
2012-04-09 19:12:12 +00:00
{ //the 0,0 triangle
2005-08-26 22:49:36 +00:00
//0, 1
//1, 0
//0, 0
2012-07-20 01:46:05 +00:00
d1 [ 0 ] = ( hm - > sectionsize / SECTHEIGHTSIZE ) ;
2011-05-20 04:10:46 +00:00
d1 [ 1 ] = 0 ;
2012-07-20 01:46:05 +00:00
d1 [ 2 ] = ( s - > heights [ ( sx + 1 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] - s - > heights [ ( sx + 0 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] ) ;
2011-05-20 04:10:46 +00:00
d2 [ 0 ] = 0 ;
2012-07-20 01:46:05 +00:00
d2 [ 1 ] = ( hm - > sectionsize / SECTHEIGHTSIZE ) ;
d2 [ 2 ] = ( s - > heights [ ( sx + 0 ) + ( sy + 1 ) * SECTHEIGHTSIZE ] - s - > heights [ ( sx + 0 ) + ( sy + 0 ) * SECTHEIGHTSIZE ] ) ;
2005-08-26 22:49:36 +00:00
}
2012-04-09 19:12:12 +00:00
VectorNormalize ( d1 ) ;
VectorNormalize ( d2 ) ;
2011-05-20 04:10:46 +00:00
CrossProduct ( d1 , d2 , norm ) ;
2005-08-26 22:49:36 +00:00
VectorNormalize ( norm ) ;
2012-07-20 01:46:05 +00:00
# endif
2005-08-26 22:49:36 +00:00
}
typedef struct {
vec3_t start ;
vec3_t end ;
vec3_t impact ;
2012-04-09 19:12:12 +00:00
vec4_t plane ;
float frac ;
2012-07-20 01:46:05 +00:00
float htilesize ;
2005-08-26 22:49:36 +00:00
heightmap_t * hm ;
int contents ;
} hmtrace_t ;
2012-07-20 01:46:05 +00:00
2012-07-21 04:43:31 +00:00
static void Heightmap_Trace_Brush ( hmtrace_t * tr , vec4_t * planes , int numplanes )
{
qboolean startout ;
float * enterplane ;
double enterfrac , exitfrac , nearfrac = 0 ;
double enterdist = 0 ;
double dist , d1 , d2 , f ;
int i ;
startout = false ;
enterplane = NULL ;
enterfrac = - 1 ;
exitfrac = 10 ;
for ( i = 0 ; i < numplanes ; i + + )
{
/*calculate the distance based upon the shape of the object we're tracing for*/
dist = planes [ i ] [ 3 ] ;
d1 = DotProduct ( tr - > start , planes [ i ] ) - dist ;
d2 = DotProduct ( tr - > end , planes [ i ] ) - dist ;
//if we're fully outside any plane, then we cannot possibly enter the brush, skip to the next one
if ( d1 > 0 & & d2 > = d1 )
2012-07-21 05:52:35 +00:00
return ;
2012-07-21 04:43:31 +00:00
if ( d1 > 0 )
startout = true ;
//if we're fully inside the plane, then whatever is happening is not relevent for this plane
if ( d1 < = 0 & & d2 < = 0 )
continue ;
f = ( d1 ) / ( d1 - d2 ) ;
if ( d1 > d2 )
{
//entered the brush. favour the furthest fraction to avoid extended edges (yay for convex shapes)
if ( enterfrac < f )
{
enterfrac = f ;
nearfrac = ( d1 - ( 0.03125 ) ) / ( d1 - d2 ) ;
enterplane = planes [ i ] ;
enterdist = dist ;
}
}
else
{
//left the brush, favour the nearest plane (smallest frac)
if ( exitfrac > f )
{
exitfrac = f ;
}
}
}
if ( ! startout )
{
tr - > frac = - 1 ;
return ;
}
if ( enterfrac ! = - 1 & & enterfrac < exitfrac )
{
//impact!
if ( enterfrac < tr - > frac )
{
if ( nearfrac < 0 )
nearfrac = 0 ;
tr - > frac = nearfrac ; //enterfrac;
tr - > plane [ 3 ] = enterdist ;
VectorCopy ( enterplane , tr - > plane ) ;
}
}
}
2012-07-20 01:46:05 +00:00
//sx,sy are the tile coord
//note that tile SECTHEIGHTSIZE-1 does not exist, as the last sample overlaps the first sample of the next section
2012-07-21 04:43:31 +00:00
static void Heightmap_Trace_Square ( hmtrace_t * tr , int tx , int ty )
2005-08-26 22:49:36 +00:00
{
2012-04-09 19:12:12 +00:00
vec3_t d [ 2 ] ;
2012-07-20 01:46:05 +00:00
vec3_t p [ 4 ] ;
2012-04-09 19:12:12 +00:00
vec4_t n [ 5 ] ;
2012-07-21 04:43:31 +00:00
int t ;
2012-04-09 19:12:12 +00:00
2012-07-21 04:43:31 +00:00
# ifndef STRICTEDGES
float d1 , d2 ;
# endif
2012-07-20 01:46:05 +00:00
int sx , sy ;
hmsection_t * s ;
2012-07-21 04:43:31 +00:00
unsigned int holebit ;
2012-04-09 19:12:12 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
sx = tx / ( SECTHEIGHTSIZE - 1 ) ;
sy = ty / ( SECTHEIGHTSIZE - 1 ) ;
if ( sx < tr - > hm - > firstsegx | | sx > = tr - > hm - > maxsegx )
s = NULL ;
else if ( sy < tr - > hm - > firstsegy | | sy > = tr - > hm - > maxsegy )
s = NULL ;
else
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( tr - > hm , sx , sy , TGS_LOAD ) ;
2012-07-20 01:46:05 +00:00
2012-07-21 08:06:07 +00:00
if ( ! s )
{
//you're not allowed to walk into sections that have not loaded.
//might as well check the entire section instead of just one tile
Vector4Set ( n [ 0 ] , 1 , 0 , 0 , ( tx / ( SECTHEIGHTSIZE - 1 ) + 1 - CHUNKBIAS ) * tr - > hm - > sectionsize ) ;
Vector4Set ( n [ 1 ] , - 1 , 0 , 0 , - ( tx / ( SECTHEIGHTSIZE - 1 ) + 0 - CHUNKBIAS ) * tr - > hm - > sectionsize ) ;
Vector4Set ( n [ 2 ] , 0 , 1 , 0 , ( ty / ( SECTHEIGHTSIZE - 1 ) + 1 - CHUNKBIAS ) * tr - > hm - > sectionsize ) ;
Vector4Set ( n [ 3 ] , 0 , - 1 , 0 , - ( ty / ( SECTHEIGHTSIZE - 1 ) + 0 - CHUNKBIAS ) * tr - > hm - > sectionsize ) ;
Heightmap_Trace_Brush ( tr , n , 4 ) ;
return ;
}
2012-07-21 04:43:31 +00:00
sx = tx - CHUNKBIAS * ( SECTHEIGHTSIZE - 1 ) ;
sy = ty - CHUNKBIAS * ( SECTHEIGHTSIZE - 1 ) ;
2012-07-20 01:46:05 +00:00
tx = tx % ( SECTHEIGHTSIZE - 1 ) ;
ty = ty % ( SECTHEIGHTSIZE - 1 ) ;
2012-07-21 04:43:31 +00:00
holebit = 1u < < ( tx / ( SECTHEIGHTSIZE > > 2 ) + ( ty / ( SECTHEIGHTSIZE > > 2 ) ) * 4 ) ;
2012-07-21 08:06:07 +00:00
if ( s - > holes & holebit )
2012-07-21 04:43:31 +00:00
return ; //no collision with holes
2012-08-04 11:28:39 +00:00
if ( tr - > hm - > tiled )
{
//left-most
Vector4Set ( n [ 0 ] , - 1 , 0 , 0 , - tr - > htilesize * ( sx + 0 ) ) ;
//bottom-most
Vector4Set ( n [ 1 ] , 0 , 1 , 0 , tr - > htilesize * ( sy + 1 ) ) ;
//right-most
Vector4Set ( n [ 2 ] , 1 , 0 , 0 , tr - > htilesize * ( sx + 1 ) ) ;
//top-most
Vector4Set ( n [ 3 ] , 0 , - 1 , 0 , - tr - > htilesize * ( sy + 0 ) ) ;
//top
Vector4Set ( n [ 4 ] , 0 , 0 , 1 , s - > heights [ ( tx + 0 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ) ;
Heightmap_Trace_Brush ( tr , n , 5 ) ;
return ;
}
2012-07-20 01:46:05 +00:00
VectorSet ( p [ 0 ] , tr - > htilesize * ( sx + 0 ) , tr - > htilesize * ( sy + 0 ) , s - > heights [ ( tx + 0 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ) ;
VectorSet ( p [ 1 ] , tr - > htilesize * ( sx + 1 ) , tr - > htilesize * ( sy + 0 ) , s - > heights [ ( tx + 1 ) + ( ty + 0 ) * SECTHEIGHTSIZE ] ) ;
VectorSet ( p [ 2 ] , tr - > htilesize * ( sx + 0 ) , tr - > htilesize * ( sy + 1 ) , s - > heights [ ( tx + 0 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ) ;
VectorSet ( p [ 3 ] , tr - > htilesize * ( sx + 1 ) , tr - > htilesize * ( sy + 1 ) , s - > heights [ ( tx + 1 ) + ( ty + 1 ) * SECTHEIGHTSIZE ] ) ;
2012-04-09 19:12:12 +00:00
2012-08-04 11:28:39 +00:00
2012-07-21 04:43:31 +00:00
# ifndef STRICTEDGES
d1 = fabs ( p [ 0 ] [ 2 ] - p [ 3 ] [ 2 ] ) ;
d2 = fabs ( p [ 1 ] [ 2 ] - p [ 2 ] [ 2 ] ) ;
if ( d1 < d2 )
2012-04-09 19:12:12 +00:00
{
2012-07-21 04:43:31 +00:00
for ( t = 0 ; t < 2 ; t + + )
2012-04-09 19:12:12 +00:00
{
2012-07-21 04:43:31 +00:00
/*generate the brush (in world space*/
if ( t = = 0 )
2012-04-09 19:12:12 +00:00
{
2012-07-21 04:43:31 +00:00
VectorSubtract ( p [ 3 ] , p [ 2 ] , d [ 0 ] ) ;
VectorSubtract ( p [ 2 ] , p [ 0 ] , d [ 1 ] ) ;
//left-most
Vector4Set ( n [ 0 ] , - 1 , 0 , 0 , - tr - > htilesize * ( sx + 0 ) ) ;
//bottom-most
Vector4Set ( n [ 1 ] , 0 , 1 , 0 , tr - > htilesize * ( sy + 1 ) ) ;
//top-right
VectorSet ( n [ 2 ] , 0.70710678118654752440084436210485 , - 0.70710678118654752440084436210485 , 0 ) ;
n [ 2 ] [ 3 ] = DotProduct ( n [ 2 ] , p [ 0 ] ) ;
//top
VectorNormalize ( d [ 0 ] ) ;
VectorNormalize ( d [ 1 ] ) ;
CrossProduct ( d [ 0 ] , d [ 1 ] , n [ 3 ] ) ;
VectorNormalize ( n [ 3 ] ) ;
n [ 3 ] [ 3 ] = DotProduct ( n [ 3 ] , p [ 0 ] ) ;
//down
VectorNegate ( n [ 3 ] , n [ 4 ] ) ;
n [ 4 ] [ 3 ] = DotProduct ( n [ 4 ] , p [ 0 ] ) - n [ 4 ] [ 2 ] * TERRAINTHICKNESS ;
2012-04-09 19:12:12 +00:00
}
else
{
2012-07-21 04:43:31 +00:00
VectorSubtract ( p [ 1 ] , p [ 0 ] , d [ 0 ] ) ;
VectorSubtract ( p [ 3 ] , p [ 1 ] , d [ 1 ] ) ;
//right-most
Vector4Set ( n [ 0 ] , 1 , 0 , 0 , tr - > htilesize * ( sx + 1 ) ) ;
//top-most
Vector4Set ( n [ 1 ] , 0 , - 1 , 0 , - tr - > htilesize * ( sy + 0 ) ) ;
//bottom-left
VectorSet ( n [ 2 ] , - 0.70710678118654752440084436210485 , 0.70710678118654752440084436210485 , 0 ) ;
n [ 2 ] [ 3 ] = DotProduct ( n [ 2 ] , p [ 0 ] ) ;
//top
VectorNormalize ( d [ 0 ] ) ;
VectorNormalize ( d [ 1 ] ) ;
CrossProduct ( d [ 0 ] , d [ 1 ] , n [ 3 ] ) ;
VectorNormalize ( n [ 3 ] ) ;
n [ 3 ] [ 3 ] = DotProduct ( n [ 3 ] , p [ 0 ] ) ;
//down
VectorNegate ( n [ 3 ] , n [ 4 ] ) ;
n [ 4 ] [ 3 ] = DotProduct ( n [ 4 ] , p [ 0 ] ) - n [ 4 ] [ 2 ] * TERRAINTHICKNESS ;
2012-04-09 19:12:12 +00:00
}
2012-07-21 04:43:31 +00:00
Heightmap_Trace_Brush ( tr , n , 5 ) ;
2012-04-09 19:12:12 +00:00
}
2012-07-21 04:43:31 +00:00
}
else
# endif
{
for ( t = 0 ; t < 2 ; t + + )
2012-04-09 19:12:12 +00:00
{
2012-07-21 04:43:31 +00:00
/*generate the brush (in world space*/
if ( t = = 0 )
2012-04-09 19:12:12 +00:00
{
2012-07-21 04:43:31 +00:00
VectorSubtract ( p [ 1 ] , p [ 0 ] , d [ 0 ] ) ;
VectorSubtract ( p [ 2 ] , p [ 0 ] , d [ 1 ] ) ;
//left-most
Vector4Set ( n [ 0 ] , - 1 , 0 , 0 , - tr - > htilesize * ( sx + 0 ) ) ;
//top-most
Vector4Set ( n [ 1 ] , 0 , - 1 , 0 , - tr - > htilesize * ( sy + 0 ) ) ;
//bottom-right
VectorSet ( n [ 2 ] , 0.70710678118654752440084436210485 , 0.70710678118654752440084436210485 , 0 ) ;
n [ 2 ] [ 3 ] = DotProduct ( n [ 2 ] , p [ 1 ] ) ;
//top
VectorNormalize ( d [ 0 ] ) ;
VectorNormalize ( d [ 1 ] ) ;
CrossProduct ( d [ 0 ] , d [ 1 ] , n [ 3 ] ) ;
VectorNormalize ( n [ 3 ] ) ;
n [ 3 ] [ 3 ] = DotProduct ( n [ 3 ] , p [ 1 ] ) ;
//down
VectorNegate ( n [ 3 ] , n [ 4 ] ) ;
n [ 4 ] [ 3 ] = DotProduct ( n [ 4 ] , p [ 1 ] ) - n [ 4 ] [ 2 ] * TERRAINTHICKNESS ;
2012-04-09 19:12:12 +00:00
}
2012-07-21 04:43:31 +00:00
else
{
VectorSubtract ( p [ 3 ] , p [ 2 ] , d [ 0 ] ) ;
VectorSubtract ( p [ 3 ] , p [ 1 ] , d [ 1 ] ) ;
//right-most
Vector4Set ( n [ 0 ] , 1 , 0 , 0 , tr - > htilesize * ( sx + 1 ) ) ;
//bottom-most
Vector4Set ( n [ 1 ] , 0 , 1 , 0 , tr - > htilesize * ( sy + 1 ) ) ;
//top-left
VectorSet ( n [ 2 ] , - 0.70710678118654752440084436210485 , - 0.70710678118654752440084436210485 , 0 ) ;
n [ 2 ] [ 3 ] = DotProduct ( n [ 2 ] , p [ 1 ] ) ;
//top
VectorNormalize ( d [ 0 ] ) ;
VectorNormalize ( d [ 1 ] ) ;
CrossProduct ( d [ 0 ] , d [ 1 ] , n [ 3 ] ) ;
VectorNormalize ( n [ 3 ] ) ;
n [ 3 ] [ 3 ] = DotProduct ( n [ 3 ] , p [ 1 ] ) ;
//down
VectorNegate ( n [ 3 ] , n [ 4 ] ) ;
n [ 4 ] [ 3 ] = DotProduct ( n [ 4 ] , p [ 1 ] ) - n [ 4 ] [ 2 ] * TERRAINTHICKNESS ;
}
Heightmap_Trace_Brush ( tr , n , 5 ) ;
2005-08-26 22:49:36 +00:00
}
}
}
2012-07-20 01:46:05 +00:00
# define DIST_EPSILON 0
2005-08-26 22:49:36 +00:00
/*
Heightmap_TraceRecurse
Traces an arbitary box through a heightmap . ( interface with outside )
Why is recursion good ?
1 : it is consistant with bsp models . : )
2 : it allows us to use any size model we want
3 : we don ' t have to work out the height of the terrain every X units , but can be more precise .
Obviously , we don ' t care all that much about 1
*/
2012-07-20 01:46:05 +00:00
qboolean Heightmap_Trace ( struct model_s * model , int hulloverride , int frame , vec3_t mataxis [ 3 ] , vec3_t start , vec3_t end , vec3_t mins , vec3_t maxs , unsigned int against , struct trace_s * trace )
2005-08-26 22:49:36 +00:00
{
2012-07-20 01:46:05 +00:00
vec2_t pos , npos ;
qboolean nudge [ 2 ] ;
vec2_t dir ;
vec2_t frac ;
vec2_t emins ;
vec2_t emaxs ;
int x , y ;
int axis ;
int breaklimit = 1000 ;
2012-07-21 05:52:35 +00:00
float wbias ;
2005-08-26 22:49:36 +00:00
hmtrace_t hmtrace ;
hmtrace . hm = model - > terrain ;
2012-07-20 01:46:05 +00:00
hmtrace . htilesize = hmtrace . hm - > sectionsize / ( SECTHEIGHTSIZE - 1 ) ;
hmtrace . frac = 1 ;
hmtrace . contents = 0 ;
hmtrace . plane [ 0 ] = 0 ;
hmtrace . plane [ 1 ] = 0 ;
2012-07-21 04:43:31 +00:00
hmtrace . plane [ 2 ] = 0 ;
2012-07-20 01:46:05 +00:00
hmtrace . plane [ 3 ] = 0 ;
2005-08-26 22:49:36 +00:00
2012-07-20 01:46:05 +00:00
memset ( trace , 0 , sizeof ( * trace ) ) ;
trace - > fraction = 1 ;
//to tile space
2012-07-21 04:43:31 +00:00
hmtrace . start [ 0 ] = ( start [ 0 ] ) ;
hmtrace . start [ 1 ] = ( start [ 1 ] ) ;
2012-04-09 19:12:12 +00:00
hmtrace . start [ 2 ] = ( start [ 2 ] + mins [ 2 ] ) ;
2012-07-21 04:43:31 +00:00
hmtrace . end [ 0 ] = ( end [ 0 ] ) ;
hmtrace . end [ 1 ] = ( end [ 1 ] ) ;
2012-04-09 19:12:12 +00:00
hmtrace . end [ 2 ] = ( end [ 2 ] + mins [ 2 ] ) ;
2012-07-20 01:46:05 +00:00
dir [ 0 ] = ( hmtrace . end [ 0 ] - hmtrace . start [ 0 ] ) / hmtrace . htilesize ;
dir [ 1 ] = ( hmtrace . end [ 1 ] - hmtrace . start [ 1 ] ) / hmtrace . htilesize ;
2012-07-21 04:43:31 +00:00
pos [ 0 ] = ( hmtrace . start [ 0 ] + CHUNKBIAS * hmtrace . hm - > sectionsize ) / hmtrace . htilesize ;
pos [ 1 ] = ( hmtrace . start [ 1 ] + CHUNKBIAS * hmtrace . hm - > sectionsize ) / hmtrace . htilesize ;
2012-07-21 05:52:35 +00:00
wbias = CHUNKBIAS * hmtrace . hm - > sectionsize ;
2012-07-20 01:46:05 +00:00
emins [ 0 ] = ( mins [ 0 ] - 1 ) / hmtrace . htilesize ;
emins [ 1 ] = ( mins [ 1 ] - 1 ) / hmtrace . htilesize ;
emaxs [ 0 ] = ( maxs [ 0 ] + 1 ) / hmtrace . htilesize ;
emaxs [ 1 ] = ( maxs [ 1 ] + 1 ) / hmtrace . htilesize ;
/*fixme:
set pos to the leading corner instead
on boundary changes , scan across multiple blocks
*/
//make sure the start tile is valid
for ( y = pos [ 1 ] + emins [ 1 ] ; y < = pos [ 1 ] + emaxs [ 1 ] ; y + + )
for ( x = pos [ 0 ] + emins [ 0 ] ; x < = pos [ 0 ] + emaxs [ 0 ] ; x + + )
Heightmap_Trace_Square ( & hmtrace , x , y ) ;
for ( ; ; )
{
if ( breaklimit - - < 0 )
break ;
for ( axis = 0 ; axis < 2 ; axis + + )
{
if ( dir [ axis ] > 0 )
{
nudge [ axis ] = false ;
npos [ axis ] = pos [ axis ] + 1 - ( pos [ axis ] - ( int ) pos [ axis ] ) ;
2012-07-21 05:52:35 +00:00
frac [ axis ] = ( npos [ axis ] * hmtrace . htilesize - wbias - hmtrace . start [ axis ] ) / ( hmtrace . end [ axis ] - hmtrace . start [ axis ] ) ;
2012-07-20 01:46:05 +00:00
}
else if ( dir [ axis ] < 0 )
{
npos [ axis ] = pos [ axis ] ;
nudge [ axis ] = ( float ) ( int ) pos [ axis ] = = pos [ axis ] ;
npos [ axis ] = ( int ) npos [ axis ] ;
2012-07-21 05:52:35 +00:00
frac [ axis ] = ( npos [ axis ] * hmtrace . htilesize - wbias - hmtrace . start [ axis ] ) / ( hmtrace . end [ axis ] - hmtrace . start [ axis ] ) ;
2012-07-20 01:46:05 +00:00
npos [ axis ] - = nudge [ axis ] ;
}
else
2012-09-30 05:52:03 +00:00
frac [ axis ] = 1000000000000000.0 ;
2012-07-20 01:46:05 +00:00
}
//which side are we going down?
if ( frac [ 0 ] < frac [ 1 ] )
axis = 0 ;
else
axis = 1 ;
2005-08-26 22:49:36 +00:00
2012-07-20 01:46:05 +00:00
if ( frac [ axis ] > = 1 )
break ;
//touch the neighbour(s)
if ( dir [ axis ] > 0 )
{
pos [ axis ] = ( int ) pos [ axis ] + 1 ;
pos [ axis ] = npos [ axis ] ;
Heightmap_Trace_Square ( & hmtrace , pos [ 0 ] , pos [ 1 ] ) ;
}
else
{
pos [ axis ] = npos [ axis ] ;
Heightmap_Trace_Square ( & hmtrace , pos [ 0 ] , pos [ 1 ] ) ;
}
//and make sure our position on the other axis is correct, for the next time around the loop
if ( frac [ axis ] > hmtrace . frac )
break ;
2012-07-21 05:52:35 +00:00
pos [ ! axis ] = ( ( hmtrace . end [ ! axis ] * frac [ axis ] ) + ( hmtrace . start [ ! axis ] * ( 1 - frac [ axis ] ) ) + CHUNKBIAS * hmtrace . hm - > sectionsize ) / hmtrace . htilesize ;
2012-07-20 01:46:05 +00:00
}
2012-04-09 19:12:12 +00:00
trace - > plane . dist = hmtrace . plane [ 3 ] ;
trace - > plane . normal [ 0 ] = hmtrace . plane [ 0 ] ;
trace - > plane . normal [ 1 ] = hmtrace . plane [ 1 ] ;
trace - > plane . normal [ 2 ] = hmtrace . plane [ 2 ] ;
if ( hmtrace . frac = = - 1 )
{
trace - > fraction = 0 ;
trace - > startsolid = true ;
trace - > allsolid = true ;
2012-07-20 01:46:05 +00:00
VectorCopy ( start , trace - > endpos ) ;
2012-04-09 19:12:12 +00:00
}
else
{
2012-07-20 01:46:05 +00:00
if ( hmtrace . frac < 0 )
hmtrace . frac = 0 ;
2012-04-09 19:12:12 +00:00
trace - > fraction = hmtrace . frac ;
VectorInterpolate ( start , hmtrace . frac , end , trace - > endpos ) ;
}
return trace - > fraction < 1 ;
2005-08-26 22:49:36 +00:00
}
2006-03-06 01:41:09 +00:00
2009-07-11 18:23:57 +00:00
unsigned int Heightmap_FatPVS ( model_t * mod , vec3_t org , qbyte * pvsbuffer , unsigned int pvssize , qboolean add )
2005-08-26 22:49:36 +00:00
{
2009-07-11 18:23:57 +00:00
return 0 ;
2005-08-26 22:49:36 +00:00
}
2007-08-30 18:27:39 +00:00
# ifndef CLIENTONLY
2010-07-11 02:22:39 +00:00
qboolean Heightmap_EdictInFatPVS ( model_t * mod , struct pvscache_s * edict , qbyte * pvsdata )
2005-08-26 22:49:36 +00:00
{
return true ;
}
2010-07-11 02:22:39 +00:00
void Heightmap_FindTouchedLeafs ( model_t * mod , pvscache_t * ent , float * mins , float * maxs )
2005-08-26 22:49:36 +00:00
{
}
2007-08-30 18:27:39 +00:00
# endif
2005-08-26 22:49:36 +00:00
2006-09-17 00:59:22 +00:00
void Heightmap_LightPointValues ( model_t * mod , vec3_t point , vec3_t res_diffuse , vec3_t res_ambient , vec3_t res_dir )
2005-08-26 22:49:36 +00:00
{
2012-04-09 19:12:12 +00:00
float time = realtime ;
res_diffuse [ 0 ] = 128 ;
res_diffuse [ 1 ] = 128 ;
res_diffuse [ 2 ] = 128 ;
res_ambient [ 0 ] = 64 ;
res_ambient [ 1 ] = 64 ;
res_ambient [ 2 ] = 64 ;
res_dir [ 0 ] = sin ( time ) ;
res_dir [ 1 ] = cos ( time ) ;
res_dir [ 2 ] = sin ( time ) ;
VectorNormalize ( res_dir ) ;
2005-08-26 22:49:36 +00:00
}
void Heightmap_StainNode ( mnode_t * node , float * parms )
{
}
void Heightmap_MarkLights ( dlight_t * light , int bit , mnode_t * node )
{
}
2009-07-11 18:23:57 +00:00
qbyte * Heightmap_LeafnumPVS ( model_t * model , int num , qbyte * buffer , unsigned int buffersize )
2005-08-26 22:49:36 +00:00
{
static qbyte heightmappvs = 255 ;
return & heightmappvs ;
}
int Heightmap_LeafForPoint ( model_t * model , vec3_t point )
{
return 0 ;
}
2012-04-09 19:12:12 +00:00
# ifndef SERVERONLY
static unsigned char * ted_getlightmap ( hmsection_t * s , int idx )
{
unsigned char * lm ;
int x = idx % SECTTEXSIZE , y = idx / SECTTEXSIZE ;
if ( s - > lightmap < 0 )
{
2013-03-31 04:21:08 +00:00
Terr_LoadSection ( s - > hmmod , s , x , y , true ) ;
2012-07-20 01:46:05 +00:00
if ( s - > lightmap < 0 )
Terr_InitLightmap ( s ) ;
2012-04-09 19:12:12 +00:00
}
2006-03-06 01:41:09 +00:00
2012-07-20 01:46:05 +00:00
s - > flags | = TSF_EDITED ;
2012-04-09 19:12:12 +00:00
lightmap [ s - > lightmap ] - > modified = true ;
lightmap [ s - > lightmap ] - > rectchange . l = 0 ;
lightmap [ s - > lightmap ] - > rectchange . t = 0 ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
lightmap [ s - > lightmap ] - > rectchange . w = HMLMSTRIDE ;
lightmap [ s - > lightmap ] - > rectchange . h = HMLMSTRIDE ;
2012-04-09 19:12:12 +00:00
lm = lightmap [ s - > lightmap ] - > lightmaps ;
2012-08-04 11:28:39 +00:00
lm + = ( ( s - > lmy + y ) * HMLMSTRIDE + ( s - > lmx + x ) ) * lightmap_bytes ;
2012-04-09 19:12:12 +00:00
return lm ;
}
2012-07-20 01:46:05 +00:00
static void ted_dorelight ( heightmap_t * hm )
{
unsigned char * lm = ted_getlightmap ( hm - > relight , 0 ) ;
int x , y ;
# define EXPAND 2
vec3_t surfnorms [ ( SECTTEXSIZE + EXPAND * 2 ) * ( SECTTEXSIZE + EXPAND * 2 ) ] ;
// float scaletab[EXPAND*2*EXPAND*2];
vec3_t ldir = { 0.4 , 0.7 , 2 } ;
hmsection_t * s = hm - > relight ;
2012-07-21 08:06:07 +00:00
s - > flags & = ~ TSF_RELIGHT ;
2012-07-20 01:46:05 +00:00
hm - > relight = NULL ;
2012-09-30 05:52:03 +00:00
if ( s - > lightmap < 0 )
return ;
2012-07-20 01:46:05 +00:00
for ( y = - EXPAND ; y < SECTTEXSIZE + EXPAND ; y + + )
for ( x = - EXPAND ; x < SECTTEXSIZE + EXPAND ; x + + )
{
vec3_t pos ;
pos [ 0 ] = hm - > relightmin [ 0 ] + ( x * hm - > sectionsize / ( SECTTEXSIZE - 1 ) ) ;
pos [ 1 ] = hm - > relightmin [ 1 ] + ( y * hm - > sectionsize / ( SECTTEXSIZE - 1 ) ) ;
pos [ 2 ] = 0 ;
Heightmap_Normal ( s - > hmmod , pos , surfnorms [ x + EXPAND + ( y + EXPAND ) * ( SECTTEXSIZE + EXPAND * 2 ) ] ) ;
}
VectorNormalize ( ldir ) ;
for ( y = 0 ; y < SECTTEXSIZE ; y + + , lm + = ( HMLMSTRIDE - SECTTEXSIZE ) * 4 )
for ( x = 0 ; x < SECTTEXSIZE ; x + + , lm + = 4 )
{
vec3_t norm ;
float d ;
int sx , sy ;
VectorClear ( norm ) ;
for ( sy = - EXPAND ; sy < = EXPAND ; sy + + )
for ( sx = - EXPAND ; sx < = EXPAND ; sx + + )
{
d = sqrt ( ( EXPAND * 2 + 1 ) * ( EXPAND * 2 + 1 ) - sx * sx + sy * sy ) ;
VectorMA ( norm , d , surfnorms [ x + sx + EXPAND + ( y + sy + EXPAND ) * ( SECTTEXSIZE + EXPAND * 2 ) ] , norm ) ;
}
VectorNormalize ( norm ) ;
d = DotProduct ( ldir , norm ) ;
if ( d < 0 )
d = 0 ;
// lm[0] = norm[0]*127 + 128;
// lm[1] = norm[1]*127 + 128;
// lm[2] = norm[2]*127 + 128;
lm [ 3 ] = d * 255 ;
}
2012-09-30 05:52:03 +00:00
lightmap [ s - > lightmap ] - > modified = true ;
lightmap [ s - > lightmap ] - > rectchange . l = 0 ;
lightmap [ s - > lightmap ] - > rectchange . t = 0 ;
lightmap [ s - > lightmap ] - > rectchange . w = HMLMSTRIDE ;
lightmap [ s - > lightmap ] - > rectchange . h = HMLMSTRIDE ;
2012-07-20 01:46:05 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
static void ted_sethole ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned int bit ;
unsigned int mask ;
mask = 1u < < idx ;
if ( * ( float * ) ctx )
bit = mask ;
else
bit = 0 ;
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_DIRTY | TSF_EDITED ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
s - > holes = ( s - > holes & ~ mask ) | bit ;
}
2012-04-09 19:12:12 +00:00
static void ted_heighttally ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
/*raise the terrain*/
( ( float * ) ctx ) [ 0 ] + = s - > heights [ idx ] * w ;
( ( float * ) ctx ) [ 1 ] + = w ;
}
static void ted_heightsmooth ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_DIRTY | TSF_EDITED | TSF_RELIGHT ;
2012-04-09 19:12:12 +00:00
/*interpolate the terrain towards a certain value*/
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( IS_NAN ( s - > heights [ idx ] ) )
s - > heights [ idx ] = * ( float * ) ctx ;
else
s - > heights [ idx ] = s - > heights [ idx ] * ( 1 - w ) + w * * ( float * ) ctx ;
2012-04-09 19:12:12 +00:00
}
static void ted_heightraise ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float strength )
{
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_DIRTY | TSF_EDITED | TSF_RELIGHT ;
2012-04-09 19:12:12 +00:00
/*raise the terrain*/
s - > heights [ idx ] + = strength ;
}
static void ted_heightset ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float strength )
{
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_DIRTY | TSF_EDITED | TSF_RELIGHT ;
2012-04-09 19:12:12 +00:00
/*set the terrain to a specific value*/
s - > heights [ idx ] = * ( float * ) ctx ;
}
static void ted_mixconcentrate ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned char * lm = ted_getlightmap ( s , idx ) ;
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_EDITED ;
2012-04-09 19:12:12 +00:00
/*concentrate the lightmap values to a single channel*/
if ( lm [ 0 ] > lm [ 1 ] & & lm [ 0 ] > lm [ 2 ] & & lm [ 0 ] > ( 255 - ( lm [ 0 ] + lm [ 1 ] + lm [ 2 ] ) ) )
{
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + 255 * ( w ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + 0 * ( w ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + 0 * ( w ) ;
}
else if ( lm [ 1 ] > lm [ 2 ] & & lm [ 1 ] > ( 255 - ( lm [ 0 ] + lm [ 1 ] + lm [ 2 ] ) ) )
{
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + 0 * ( w ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + 255 * ( w ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + 0 * ( w ) ;
}
else if ( lm [ 2 ] > ( 255 - ( lm [ 0 ] + lm [ 1 ] + lm [ 2 ] ) ) )
{
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + 0 * ( w ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + 0 * ( w ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + 255 * ( w ) ;
}
else
{
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + 0 * ( w ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + 0 * ( w ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + 0 * ( w ) ;
}
}
static void ted_mixnoise ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned char * lm = ted_getlightmap ( s , idx ) ;
vec4_t v ;
float sc ;
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_EDITED ;
2012-04-09 19:12:12 +00:00
/*randomize the lightmap somewhat (you'll probably want to concentrate it a bit after)*/
v [ 0 ] = ( rand ( ) & 255 ) ;
v [ 1 ] = ( rand ( ) & 255 ) ;
v [ 2 ] = ( rand ( ) & 255 ) ;
v [ 3 ] = ( rand ( ) & 255 ) ;
sc = v [ 0 ] + v [ 1 ] + v [ 2 ] + v [ 3 ] ;
Vector4Scale ( v , 255 / sc , v ) ;
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + ( v [ 0 ] * ( w ) ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + ( v [ 1 ] * ( w ) ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + ( v [ 2 ] * ( w ) ) ;
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
static void ted_mixpaint ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned char * lm = ted_getlightmap ( s , idx ) ;
char * texname = ctx ;
int t ;
vec3_t newval ;
if ( w > 1 )
w = 1 ;
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_EDITED ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( t = 0 ; t < 4 ; t + + )
{
if ( ! strncmp ( s - > texname [ t ] , texname , sizeof ( s - > texname [ t ] ) - 1 ) )
{
newval [ 0 ] = ( t = = 0 ) ;
newval [ 1 ] = ( t = = 1 ) ;
newval [ 2 ] = ( t = = 2 ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + ( 255 * newval [ 0 ] * ( w ) ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + ( 255 * newval [ 1 ] * ( w ) ) ;
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + ( 255 * newval [ 2 ] * ( w ) ) ;
return ;
}
}
2012-07-22 02:56:22 +00:00
/*special handling to make a section accept the first texture painted on it as a base texture. no more chessboard*/
if ( ! * s - > texname [ 0 ] & & ! * s - > texname [ 1 ] & & ! * s - > texname [ 2 ] & & ! * s - > texname [ 3 ] )
{
Q_strncpyz ( s - > texname [ 3 ] , texname , sizeof ( s - > texname [ 3 ] ) ) ;
Terr_LoadSectionTextures ( s ) ;
for ( idx = 0 ; idx < SECTTEXSIZE * SECTTEXSIZE ; idx + + )
{
lm = ted_getlightmap ( s , idx ) ;
lm [ 2 ] = 0 ;
lm [ 1 ] = 0 ;
lm [ 0 ] = 0 ;
}
return ;
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( t = 0 ; t < 4 ; t + + )
{
if ( ! * s - > texname [ t ] )
{
Q_strncpyz ( s - > texname [ t ] , texname , sizeof ( s - > texname [ t ] ) ) ;
newval [ 0 ] = ( t = = 0 ) ;
newval [ 1 ] = ( t = = 1 ) ;
newval [ 2 ] = ( t = = 2 ) ;
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + ( 255 * newval [ 0 ] * ( w ) ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + ( 255 * newval [ 1 ] * ( w ) ) ;
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + ( 255 * newval [ 2 ] * ( w ) ) ;
Terr_LoadSectionTextures ( s ) ;
return ;
}
}
}
2012-07-20 01:46:05 +00:00
/*
static void ted_mixlight ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned char * lm = ted_getlightmap ( s , idx ) ;
vec3_t pos , pos2 ;
vec3_t norm , tnorm ;
vec3_t ldir = { 0.4 , 0.7 , 2 } ;
float d ;
int x , y ;
trace_t tr ;
VectorClear ( norm ) ;
for ( y = - 4 ; y < 4 ; y + + )
for ( x = - 4 ; x < 4 ; x + + )
{
pos [ 0 ] = wx - ( CHUNKBIAS + x / 64.0 ) * s - > hmmod - > sectionsize ;
pos [ 1 ] = wy - ( CHUNKBIAS + y / 64.0 ) * s - > hmmod - > sectionsize ;
#if 0
pos [ 2 ] = 10000 ;
pos2 [ 0 ] = wx - ( CHUNKBIAS + x / 64.0 ) * s - > hmmod - > sectionsize ;
pos2 [ 1 ] = wy - ( CHUNKBIAS + y / 64.0 ) * s - > hmmod - > sectionsize ;
pos2 [ 2 ] = - 10000 ;
Heightmap_Trace ( cl . worldmodel , 0 , 0 , NULL , pos , pos2 , vec3_origin , vec3_origin , FTECONTENTS_SOLID , & tr ) ;
VectorCopy ( tr . plane . normal , tnorm ) ;
# else
Heightmap_Normal ( s - > hmmod , pos , tnorm ) ;
# endif
d = sqrt ( 32 - x * x + y * y ) ;
VectorMA ( norm , d , tnorm , norm ) ;
}
VectorNormalize ( ldir ) ;
VectorNormalize ( norm ) ;
d = DotProduct ( ldir , norm ) ;
if ( d < 0 )
d = 0 ;
lm [ 3 ] = d * 255 ;
}
*/
2012-04-09 19:12:12 +00:00
static void ted_mixset ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned char * lm = ted_getlightmap ( s , idx ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( w > 1 )
w = 1 ;
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_EDITED ;
2012-04-09 19:12:12 +00:00
lm [ 2 ] = lm [ 2 ] * ( 1 - w ) + ( 255 * ( ( float * ) ctx ) [ 0 ] * ( w ) ) ;
lm [ 1 ] = lm [ 1 ] * ( 1 - w ) + ( 255 * ( ( float * ) ctx ) [ 1 ] * ( w ) ) ;
lm [ 0 ] = lm [ 0 ] * ( 1 - w ) + ( 255 * ( ( float * ) ctx ) [ 2 ] * ( w ) ) ;
}
static void ted_mixtally ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
unsigned char * lm = ted_getlightmap ( s , idx ) ;
( ( float * ) ctx ) [ 0 ] + = lm [ 0 ] * w ;
( ( float * ) ctx ) [ 1 ] + = lm [ 1 ] * w ;
( ( float * ) ctx ) [ 2 ] + = lm [ 2 ] * w ;
( ( float * ) ctx ) [ 3 ] + = w ;
}
2012-08-04 11:28:39 +00:00
static void ted_tint ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float w )
{
float * col = s - > colours [ idx ] ;
float * newval = ctx ;
if ( w > 1 )
w = 1 ;
2012-11-29 13:37:48 +00:00
s - > flags | = TSF_NOTIFY | TSF_DIRTY | TSF_EDITED | TSF_HASCOLOURS ; /*dirty because of the vbo*/
2012-08-04 11:28:39 +00:00
col [ 0 ] = col [ 0 ] * ( 1 - w ) + ( newval [ 0 ] * ( w ) ) ;
col [ 1 ] = col [ 1 ] * ( 1 - w ) + ( newval [ 1 ] * ( w ) ) ;
col [ 2 ] = col [ 2 ] * ( 1 - w ) + ( newval [ 2 ] * ( w ) ) ;
col [ 3 ] = col [ 3 ] * ( 1 - w ) + ( newval [ 3 ] * ( w ) ) ;
}
2012-04-09 19:12:12 +00:00
2012-08-04 11:28:39 +00:00
enum
{
tid_linear ,
tid_exponential
} ;
2012-04-09 19:12:12 +00:00
//calls 'func' for each tile upon the terrain. the 'tile' can be either height or texel
2012-08-04 11:28:39 +00:00
static void ted_itterate ( heightmap_t * hm , int distribution , float * pos , float radius , float strength , int steps , void ( * func ) ( void * ctx , hmsection_t * s , int idx , float wx , float wy , float strength ) , void * ctx )
2012-04-09 19:12:12 +00:00
{
int tx , ty ;
float wx , wy ;
float sc [ 2 ] ;
int min [ 2 ] , max [ 2 ] ;
int sx , sy ;
hmsection_t * s ;
float w , xd , yd ;
2012-08-04 11:28:39 +00:00
min [ 0 ] = floor ( ( pos [ 0 ] - radius ) / ( hm - > sectionsize ) - 1.5 ) ;
min [ 1 ] = floor ( ( pos [ 1 ] - radius ) / ( hm - > sectionsize ) - 1.5 ) ;
max [ 0 ] = ceil ( ( pos [ 0 ] + radius ) / ( hm - > sectionsize ) + 1.5 ) ;
max [ 1 ] = ceil ( ( pos [ 1 ] + radius ) / ( hm - > sectionsize ) + 1.5 ) ;
2012-04-09 19:12:12 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
min [ 0 ] = bound ( hm - > firstsegx , min [ 0 ] , hm - > maxsegx ) ;
2012-08-04 11:28:39 +00:00
min [ 1 ] = bound ( hm - > firstsegy , min [ 1 ] , hm - > maxsegy ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
max [ 0 ] = bound ( hm - > firstsegx , max [ 0 ] , hm - > maxsegx ) ;
2012-08-04 11:28:39 +00:00
max [ 1 ] = bound ( hm - > firstsegy , max [ 1 ] , hm - > maxsegy ) ;
2012-04-09 19:12:12 +00:00
sc [ 0 ] = hm - > sectionsize / ( steps - 1 ) ;
sc [ 1 ] = hm - > sectionsize / ( steps - 1 ) ;
2012-08-04 11:28:39 +00:00
for ( sy = min [ 1 ] ; sy < max [ 1 ] ; sy + + )
2012-04-09 19:12:12 +00:00
{
2012-08-04 11:28:39 +00:00
for ( sx = min [ 0 ] ; sx < max [ 0 ] ; sx + + )
2012-04-09 19:12:12 +00:00
{
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , sx , sy , TGS_FORCELOAD ) ;
2012-04-09 19:12:12 +00:00
if ( ! s )
continue ;
2012-08-04 11:28:39 +00:00
for ( ty = 0 ; ty < steps ; ty + + )
2012-04-09 19:12:12 +00:00
{
2012-08-04 11:28:39 +00:00
wy = ( sy * ( steps - 1.0 ) + ty ) * sc [ 1 ] ;
yd = wy - pos [ 1 ] ; // - sc[1]/4;
// if (yd < 0)
// yd = 0;
for ( tx = 0 ; tx < steps ; tx + + )
2012-04-09 19:12:12 +00:00
{
/*both heights and textures have an overlapping/matching sample at the edge, there's no need for any half-pixels or anything here*/
wx = ( sx * ( steps - 1.0 ) + tx ) * sc [ 0 ] ;
2012-08-04 11:28:39 +00:00
xd = wx - pos [ 0 ] ; // - sc[0]/4;
// if (xd < 0)
// xd = 0;
if ( radius * radius > = ( xd * xd + yd * yd ) )
2012-04-09 19:12:12 +00:00
{
2012-08-04 11:28:39 +00:00
if ( distribution = = tid_exponential )
w = sqrt ( ( radius * radius ) - ( ( xd * xd ) + ( yd * yd ) ) ) ;
else
w = radius - sqrt ( xd * xd + yd * yd ) ;
if ( w > 0 )
func ( ctx , s , tx + ty * steps , wx , wy , w * strength / ( radius ) ) ;
2012-04-09 19:12:12 +00:00
}
}
}
}
}
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
void QCBUILTIN PF_terrain_edit ( pubprogfuncs_t * prinst , struct globalvars_s * pr_globals )
2011-05-20 04:10:46 +00:00
{
2012-04-09 19:12:12 +00:00
world_t * vmw = prinst - > parms - > user ;
int action = G_FLOAT ( OFS_PARM0 ) ;
2012-07-20 01:46:05 +00:00
vec3_t pos ; // G_VECTOR(OFS_PARM1);
2012-04-09 19:12:12 +00:00
float radius = G_FLOAT ( OFS_PARM2 ) ;
float quant = G_FLOAT ( OFS_PARM3 ) ;
// G_FLOAT(OFS_RETURN) = Heightmap_Edit(w->worldmodel, action, pos, radius, quant);
2012-08-04 11:28:39 +00:00
model_t * mod = vmw - > Get_CModel ( vmw , ( ( wedict_t * ) PROG_TO_EDICT ( prinst , * vmw - > g . self ) ) - > v - > modelindex ) ;
2012-04-09 19:12:12 +00:00
heightmap_t * hm ;
vec4_t tally ;
2011-05-20 04:10:46 +00:00
2012-04-09 19:12:12 +00:00
G_FLOAT ( OFS_RETURN ) = 0 ;
2011-05-20 04:10:46 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! mod | | ! mod - > terrain )
2012-04-09 19:12:12 +00:00
return ;
hm = mod - > terrain ;
2011-05-20 04:10:46 +00:00
2012-07-20 01:46:05 +00:00
pos [ 0 ] = G_FLOAT ( OFS_PARM1 + 0 ) + hm - > sectionsize * CHUNKBIAS ;
pos [ 1 ] = G_FLOAT ( OFS_PARM1 + 1 ) + hm - > sectionsize * CHUNKBIAS ;
pos [ 2 ] = G_FLOAT ( OFS_PARM1 + 2 ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2011-05-20 04:10:46 +00:00
switch ( action )
{
case ter_reload :
2013-03-12 23:24:15 +00:00
G_FLOAT ( OFS_RETURN ) = 1 ;
2012-07-21 05:52:35 +00:00
Terr_PurgeTerrainModel ( mod , false , true ) ;
2011-05-20 04:10:46 +00:00
break ;
case ter_save :
2013-03-12 23:24:15 +00:00
quant = Heightmap_Save ( hm ) ;
Con_DPrintf ( " ter_save: %g sections saved \n " , quant ) ;
G_FLOAT ( OFS_RETURN ) = quant ;
2011-05-20 04:10:46 +00:00
break ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
case ter_sethole :
2012-08-04 11:28:39 +00:00
/* {
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
int x , y ;
hmsection_t * s ;
x = pos [ 0 ] * 4 / hm - > sectionsize ;
y = pos [ 1 ] * 4 / hm - > sectionsize ;
x = bound ( hm - > firstsegx * 4 , x , hm - > maxsegy * 4 - 1 ) ;
y = bound ( hm - > firstsegy * 4 , y , hm - > maxsegy * 4 - 1 ) ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x / 4 , y / 4 , TGS_FORCELOAD ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! s )
return ;
ted_sethole ( & quant , s , ( x & 3 ) + ( y & 3 ) * 4 , x / 4 , y / 4 , 0 ) ;
}
2012-08-04 11:28:39 +00:00
*/ ted_itterate ( hm , tid_linear , pos , radius , 1 , 4 , ted_sethole , & quant ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
break ;
2012-04-09 19:12:12 +00:00
case ter_height_set :
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_linear , pos , radius , 1 , SECTHEIGHTSIZE , ted_heightset , & quant ) ;
break ;
case ter_height_flatten :
tally [ 0 ] = 0 ;
tally [ 1 ] = 0 ;
ted_itterate ( hm , tid_exponential , pos , radius , 1 , SECTHEIGHTSIZE , ted_heighttally , & tally ) ;
tally [ 0 ] / = tally [ 1 ] ;
if ( IS_NAN ( tally [ 0 ] ) )
tally [ 0 ] = 0 ;
ted_itterate ( hm , tid_exponential , pos , radius , quant , SECTHEIGHTSIZE , ted_heightsmooth , & tally ) ;
2012-04-09 19:12:12 +00:00
break ;
case ter_height_smooth :
tally [ 0 ] = 0 ;
tally [ 1 ] = 0 ;
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_linear , pos , radius , 1 , SECTHEIGHTSIZE , ted_heighttally , & tally ) ;
2012-04-09 19:12:12 +00:00
tally [ 0 ] / = tally [ 1 ] ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( IS_NAN ( tally [ 0 ] ) )
tally [ 0 ] = 0 ;
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_linear , pos , radius , quant , SECTHEIGHTSIZE , ted_heightsmooth , & tally ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
break ;
case ter_height_spread :
tally [ 0 ] = 0 ;
tally [ 1 ] = 0 ;
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius / 2 , 1 , SECTHEIGHTSIZE , ted_heighttally , & tally ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
tally [ 0 ] / = tally [ 1 ] ;
if ( IS_NAN ( tally [ 0 ] ) )
tally [ 0 ] = 0 ;
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , 1 , SECTHEIGHTSIZE , ted_heightsmooth , & tally ) ;
2011-05-20 04:10:46 +00:00
break ;
2012-07-20 01:46:05 +00:00
case ter_water_set :
{
int x , y ;
hmsection_t * s ;
x = pos [ 0 ] / hm - > sectionsize ;
y = pos [ 1 ] / hm - > sectionsize ;
x = bound ( hm - > firstsegx , x , hm - > maxsegy - 1 ) ;
y = bound ( hm - > firstsegy , y , hm - > maxsegy - 1 ) ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_LOAD ) ;
2012-07-20 01:46:05 +00:00
if ( ! s )
return ;
s - > flags | = TSF_HASWATER | TSF_EDITED ;
s - > waterheight = quant ;
}
break ;
2012-04-09 19:12:12 +00:00
case ter_lower :
quant * = - 1 ;
2011-05-20 04:10:46 +00:00
case ter_raise :
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , quant , SECTHEIGHTSIZE , ted_heightraise , & quant ) ;
break ;
case ter_tint :
ted_itterate ( hm , tid_exponential , pos , radius , quant , SECTHEIGHTSIZE , ted_tint , G_VECTOR ( OFS_PARM4 ) ) ; //and parm5 too
2012-04-09 19:12:12 +00:00
break ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
// case ter_mixset:
2012-08-04 11:28:39 +00:00
// ted_itterate(hm, tid_exponential, pos, radius, 1, SECTTEXSIZE, ted_mixset, G_VECTOR(OFS_PARM4));
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
// break;
2012-11-27 03:23:19 +00:00
case ter_mix_paint :
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , quant / 10 , SECTTEXSIZE , ted_mixpaint , PR_GetStringOfs ( prinst , OFS_PARM4 ) ) ;
2012-04-09 19:12:12 +00:00
break ;
2012-11-27 03:23:19 +00:00
case ter_mix_concentrate :
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , 1 , SECTTEXSIZE , ted_mixconcentrate , NULL ) ;
2012-04-09 19:12:12 +00:00
break ;
2012-11-27 03:23:19 +00:00
case ter_mix_noise :
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , 1 , SECTTEXSIZE , ted_mixnoise , NULL ) ;
2012-04-09 19:12:12 +00:00
break ;
2012-11-27 03:23:19 +00:00
case ter_mix_blur :
2012-04-09 19:12:12 +00:00
Vector4Set ( tally , 0 , 0 , 0 , 0 ) ;
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , 1 , SECTTEXSIZE , ted_mixtally , & tally ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
VectorScale ( tally , 1 / ( tally [ 3 ] * 255 ) , tally ) ;
2012-08-04 11:28:39 +00:00
ted_itterate ( hm , tid_exponential , pos , radius , quant , SECTTEXSIZE , ted_mixset , & tally ) ;
2012-04-09 19:12:12 +00:00
break ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
case ter_tex_get :
{
int x , y ;
hmsection_t * s ;
x = pos [ 0 ] / hm - > sectionsize ;
y = pos [ 1 ] / hm - > sectionsize ;
x = bound ( hm - > firstsegx , x , hm - > maxsegy - 1 ) ;
y = bound ( hm - > firstsegy , y , hm - > maxsegy - 1 ) ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_LOAD ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! s )
return ;
x = bound ( 0 , quant , 3 ) ;
G_INT ( OFS_RETURN ) = PR_TempString ( prinst , s - > texname [ x ] ) ;
}
break ;
case ter_tex_kill :
2011-05-20 04:10:46 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
char * killtex = PR_GetStringOfs ( prinst , OFS_PARM4 ) ;
int x , y , t , to ;
hmsection_t * s ;
x = pos [ 0 ] / hm - > sectionsize ;
y = pos [ 1 ] / hm - > sectionsize ;
x = bound ( hm - > firstsegx , x , hm - > maxsegy - 1 ) ;
y = bound ( hm - > firstsegy , y , hm - > maxsegy - 1 ) ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_FORCELOAD ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! s )
return ;
2012-07-20 01:46:05 +00:00
s - > flags | = TSF_EDITED ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( t = 0 ; t < 4 ; t + + )
2011-05-20 04:10:46 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! strcmp ( s - > texname [ t ] , killtex ) )
2011-05-20 04:10:46 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
unsigned char * lm = ted_getlightmap ( s , 0 ) ;
s - > texname [ t ] [ 0 ] = 0 ;
for ( to = 0 ; to < 4 ; to + + )
if ( * s - > texname [ to ] )
break ;
if ( to = = 4 )
to = 0 ;
if ( to = = 0 | | to = = 2 )
to = 2 - to ;
if ( t = = 0 | | t = = 2 )
t = 2 - t ;
for ( y = 0 ; y < SECTTEXSIZE ; y + + )
2012-04-09 19:12:12 +00:00
{
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
for ( x = 0 ; x < SECTTEXSIZE ; x + + , lm + = 4 )
{
if ( t = = 3 )
{
//to won't be 3
lm [ to ] = lm [ to ] + ( 255 - ( lm [ 0 ] + lm [ 1 ] + lm [ 2 ] ) ) ;
}
else
{
if ( to ! = 3 )
lm [ to ] + = lm [ t ] ;
lm [ t ] = 0 ;
}
}
lm + = SECTTEXSIZE * 4 * ( LMCHUNKS - 1 ) ;
2012-04-09 19:12:12 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( t = = 0 | | t = = 2 )
t = 2 - t ;
Terr_LoadSectionTextures ( s ) ;
2011-05-20 04:10:46 +00:00
}
}
}
break ;
2012-07-20 01:46:05 +00:00
case ter_mesh_add :
{
entity_t * e ;
float * epos ;
int x , y ;
hmsection_t * s ;
epos = ( ( wedict_t * ) G_EDICT ( prinst , OFS_PARM1 ) ) - > v - > origin ;
x = ( epos [ 0 ] / hm - > sectionsize ) + CHUNKBIAS ;
y = ( epos [ 1 ] / hm - > sectionsize ) + CHUNKBIAS ;
x = bound ( hm - > firstsegx , x , hm - > maxsegy - 1 ) ;
y = bound ( hm - > firstsegy , y , hm - > maxsegy - 1 ) ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_FORCELOAD ) ;
2012-07-20 01:46:05 +00:00
if ( ! s )
return ;
s - > flags | = TSF_EDITED ;
if ( s - > maxents = = s - > numents )
{
s - > maxents + + ;
s - > ents = realloc ( s - > ents , sizeof ( * s - > ents ) * ( s - > maxents ) ) ;
}
e = & s - > ents [ s - > numents + + ] ;
memset ( e , 0 , sizeof ( * e ) ) ;
e - > scale = ( ( wedict_t * ) G_EDICT ( prinst , OFS_PARM1 ) ) - > xv - > scale ;
e - > shaderRGBAf [ 0 ] = 1 ;
e - > shaderRGBAf [ 1 ] = 1 ;
e - > shaderRGBAf [ 2 ] = 1 ;
e - > shaderRGBAf [ 3 ] = 1 ;
VectorCopy ( epos , e - > origin ) ;
AngleVectorsFLU ( ( ( wedict_t * ) G_EDICT ( prinst , OFS_PARM1 ) ) - > v - > angles , e - > axis [ 0 ] , e - > axis [ 1 ] , e - > axis [ 2 ] ) ;
e - > model = vmw - > Get_CModel ( vmw , ( ( wedict_t * ) G_EDICT ( prinst , OFS_PARM1 ) ) - > v - > modelindex ) ;
}
break ;
case ter_mesh_kill :
{
// int i;
// entity_t *e;
int x , y ;
// float r;
hmsection_t * s ;
x = pos [ 0 ] / hm - > sectionsize ;
y = pos [ 1 ] / hm - > sectionsize ;
x = bound ( hm - > firstsegx , x , hm - > maxsegy - 1 ) ;
y = bound ( hm - > firstsegy , y , hm - > maxsegy - 1 ) ;
2013-03-31 04:21:08 +00:00
s = Terr_GetSection ( hm , x , y , TGS_FORCELOAD ) ;
2012-07-20 01:46:05 +00:00
if ( ! s )
return ;
s - > numents = 0 ;
s - > flags | = TSF_EDITED ;
/*for (i = 0; i < s->numents; i++)
{
} */
}
break ;
2011-05-20 04:10:46 +00:00
}
}
2012-04-09 19:12:12 +00:00
# else
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
void QCBUILTIN PF_terrain_edit ( pubprogfuncs_t * prinst , struct globalvars_s * pr_globals )
2012-04-09 19:12:12 +00:00
{
G_FLOAT ( OFS_RETURN ) = 0 ;
}
# endif
2011-05-20 04:10:46 +00:00
2012-08-04 11:28:39 +00:00
void Terr_ParseEntityLump ( char * data , heightmap_t * heightmap )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
char key [ 128 ] ;
2012-08-04 11:28:39 +00:00
heightmap - > sectionsize = 1024 ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( data )
if ( ( data = COM_Parse ( data ) ) ) //read the map info.
if ( com_token [ 0 ] = = ' { ' )
while ( 1 )
{
if ( ! ( data = COM_Parse ( data ) ) )
break ; // error
if ( com_token [ 0 ] = = ' } ' )
break ; // end of worldspawn
if ( com_token [ 0 ] = = ' _ ' )
strcpy ( key , com_token + 1 ) ; //_ vars are for comments/utility stuff that arn't visible to progs. Ignore them.
else
strcpy ( key , com_token ) ;
if ( ! ( ( data = COM_Parse ( data ) ) ) )
break ; // error
2012-07-20 01:46:05 +00:00
if ( ! strcmp ( " segmentsize " , key ) )
2012-08-04 11:28:39 +00:00
heightmap - > sectionsize = atof ( com_token ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
else if ( ! strcmp ( " minxsegment " , key ) )
2012-08-04 11:28:39 +00:00
heightmap - > firstsegx = atoi ( com_token ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
else if ( ! strcmp ( " minysegment " , key ) )
2012-08-04 11:28:39 +00:00
heightmap - > firstsegy = atoi ( com_token ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
else if ( ! strcmp ( " maxxsegment " , key ) )
2012-08-04 11:28:39 +00:00
heightmap - > maxsegx = atoi ( com_token ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
else if ( ! strcmp ( " maxysegment " , key ) )
2012-08-04 11:28:39 +00:00
heightmap - > maxsegy = atoi ( com_token ) ;
else if ( ! strcmp ( " tiles " , key ) )
{
char * d ;
heightmap - > tiled = true ;
d = com_token ;
d = COM_ParseOut ( d , key , sizeof ( key ) ) ;
heightmap - > tilepixcount [ 0 ] = atoi ( key ) ;
d = COM_ParseOut ( d , key , sizeof ( key ) ) ;
heightmap - > tilepixcount [ 1 ] = atoi ( key ) ;
d = COM_ParseOut ( d , key , sizeof ( key ) ) ;
heightmap - > tilecount [ 0 ] = atoi ( key ) ;
d = COM_ParseOut ( d , key , sizeof ( key ) ) ;
heightmap - > tilecount [ 1 ] = atoi ( key ) ;
}
}
/*bias and bound it*/
heightmap - > firstsegx + = CHUNKBIAS ;
heightmap - > firstsegy + = CHUNKBIAS ;
heightmap - > maxsegx + = CHUNKBIAS ;
heightmap - > maxsegy + = CHUNKBIAS ;
if ( heightmap - > firstsegx < 0 )
heightmap - > firstsegx = 0 ;
if ( heightmap - > firstsegy < 0 )
heightmap - > firstsegy = 0 ;
if ( heightmap - > maxsegx > CHUNKLIMIT )
heightmap - > maxsegx = CHUNKLIMIT ;
if ( heightmap - > maxsegy > CHUNKLIMIT )
heightmap - > maxsegy = CHUNKLIMIT ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
}
2012-08-04 11:28:39 +00:00
void Terr_FinishTerrain ( heightmap_t * hm , char * shadername , char * skyname )
{
# ifndef SERVERONLY
if ( qrenderer ! = QR_NONE )
{
hm - > skyshader = R_RegisterCustom ( va ( " skybox_%s " , skyname ) , Shader_DefaultSkybox , NULL ) ;
if ( hm - > tiled )
hm - > shader = R_RegisterShader ( " terraintileshader " ,
" { \n "
" { \n "
" map $diffuse \n "
" } \n "
" } \n "
) ;
else
hm - > shader = R_RegisterShader ( shadername ,
" { \n "
" { \n "
" map $diffuse \n "
" } \n "
" { \n "
" map $upperoverlay \n "
" } \n "
" { \n "
" map $loweroverlay \n "
" } \n "
" { \n "
" map $fullbright \n "
" } \n "
" { \n "
" map $lightmap \n "
" } \n "
" program terrain \n "
" if r_terraindebug \n "
" program terraindebug \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2012-08-04 11:28:39 +00:00
" } \n "
) ;
2012-09-30 05:52:03 +00:00
hm - > watershader = R_RegisterCustom ( " warp/terrain " , Shader_DefaultBSPQ2 , NULL ) ;
if ( ! TEXVALID ( hm - > watershader - > defaulttextures . base ) )
hm - > watershader - > defaulttextures . base = R_LoadHiResTexture ( " terwater " , NULL , IF_NOALPHA ) ;
if ( ! TEXVALID ( hm - > watershader - > defaulttextures . bump ) )
hm - > watershader - > defaulttextures . bump = R_LoadBumpmapTexture ( " terwater_bump " , NULL ) ;
if ( ! TEXVALID ( hm - > watershader - > defaulttextures . bump ) )
{
unsigned char dat [ 64 * 64 ] = { 0 } ;
int i ;
for ( i = 0 ; i < 64 * 64 ; i + + )
dat [ i ] = rand ( ) & 15 ;
hm - > watershader - > defaulttextures . bump = R_LoadTexture8BumpPal ( " terwater_bump " , 64 , 64 , dat , 0 ) ;
}
2012-08-04 11:28:39 +00:00
}
# endif
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
qboolean Terr_LoadTerrainModel ( model_t * mod , void * buffer )
2005-08-26 22:49:36 +00:00
{
heightmap_t * hm ;
2005-10-15 20:06:34 +00:00
float skyrotate ;
vec3_t skyaxis ;
2012-04-09 19:12:12 +00:00
char shadername [ MAX_QPATH ] ;
2005-10-15 20:06:34 +00:00
char skyname [ MAX_QPATH ] ;
2012-04-09 19:12:12 +00:00
int sectsize = 0 ;
COM_FileBase ( mod - > name , shadername , sizeof ( shadername ) ) ;
strcpy ( shadername , " terrainshader " ) ;
2005-10-15 20:06:34 +00:00
strcpy ( skyname , " night " ) ;
skyrotate = 0 ;
skyaxis [ 0 ] = 0 ;
skyaxis [ 1 ] = 0 ;
skyaxis [ 2 ] = 0 ;
2005-08-26 22:49:36 +00:00
buffer = COM_Parse ( buffer ) ;
if ( strcmp ( com_token , " terrain " ) )
2006-03-12 09:19:31 +00:00
{
2007-09-23 15:28:06 +00:00
Con_Printf ( CON_ERROR " %s wasn't terrain map \n " , mod - > name ) ; //shouldn't happen
2006-03-12 09:19:31 +00:00
return false ;
}
2007-05-25 22:16:29 +00:00
2012-04-09 19:12:12 +00:00
mod - > type = mod_heightmap ;
2005-08-26 22:49:36 +00:00
2012-07-21 05:52:35 +00:00
hm = Hunk_Alloc ( sizeof ( * hm ) ) ;
2005-08-26 22:49:36 +00:00
memset ( hm , 0 , sizeof ( * hm ) ) ;
2012-07-21 08:06:07 +00:00
ClearLink ( & hm - > recycle ) ;
2012-04-09 19:12:12 +00:00
COM_FileBase ( mod - > name , hm - > path , sizeof ( hm - > path ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
mod - > entities = Hunk_AllocName ( strlen ( buffer ) + 1 , mod - > name ) ;
strcpy ( mod - > entities , buffer ) ;
2011-05-20 04:10:46 +00:00
2012-04-09 19:12:12 +00:00
hm - > sectionsize = sectsize ;
2012-07-21 04:43:31 +00:00
hm - > firstsegx = - 1 ;
hm - > firstsegy = - 1 ;
hm - > maxsegx = + 1 ;
hm - > maxsegy = + 1 ;
2012-07-20 01:46:05 +00:00
hm - > exteriorcontents = FTECONTENTS_SOLID ; //sky outside the map
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-08-04 11:28:39 +00:00
Terr_ParseEntityLump ( mod - > entities , hm ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-07-20 01:46:05 +00:00
mod - > mins [ 0 ] = ( hm - > firstsegx - CHUNKBIAS ) * hm - > sectionsize ;
mod - > mins [ 1 ] = ( hm - > firstsegy - CHUNKBIAS ) * hm - > sectionsize ;
mod - > mins [ 2 ] = - 999999999999999999999999.f ;
mod - > maxs [ 0 ] = ( hm - > maxsegy - CHUNKBIAS ) * hm - > sectionsize ;
mod - > maxs [ 1 ] = ( hm - > maxsegy - CHUNKBIAS ) * hm - > sectionsize ;
mod - > maxs [ 2 ] = 999999999999999999999999.f ;
2012-01-17 07:57:46 +00:00
mod - > funcs . NativeTrace = Heightmap_Trace ;
2005-08-26 22:49:36 +00:00
mod - > funcs . PointContents = Heightmap_PointContents ;
2006-03-06 01:41:09 +00:00
mod - > funcs . NativeContents = Heightmap_NativeBoxContents ;
2005-08-26 22:49:36 +00:00
mod - > funcs . LightPointValues = Heightmap_LightPointValues ;
mod - > funcs . StainNode = Heightmap_StainNode ;
mod - > funcs . MarkLights = Heightmap_MarkLights ;
mod - > funcs . LeafnumForPoint = Heightmap_LeafForPoint ;
mod - > funcs . LeafPVS = Heightmap_LeafnumPVS ;
# ifndef CLIENTONLY
2010-07-11 02:22:39 +00:00
mod - > funcs . FindTouchedLeafs = Heightmap_FindTouchedLeafs ;
2005-08-26 22:49:36 +00:00
mod - > funcs . EdictInFatPVS = Heightmap_EdictInFatPVS ;
mod - > funcs . FatPVS = Heightmap_FatPVS ;
# endif
/* mod->hulls[0].funcs.HullPointContents = Heightmap_PointContents;
mod - > hulls [ 1 ] . funcs . HullPointContents = Heightmap_PointContents ;
mod - > hulls [ 2 ] . funcs . HullPointContents = Heightmap_PointContents ;
mod - > hulls [ 3 ] . funcs . HullPointContents = Heightmap_PointContents ;
*/
mod - > terrain = hm ;
2006-03-12 09:19:31 +00:00
2012-08-04 11:28:39 +00:00
Terr_FinishTerrain ( hm , shadername , skyname ) ;
2006-03-12 09:19:31 +00:00
return true ;
2005-08-26 22:49:36 +00:00
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
void * Mod_LoadTerrainInfo ( model_t * mod , char * loadname )
{
heightmap_t * hm ;
2012-08-04 11:28:39 +00:00
heightmap_t potential ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! mod - > entities )
return NULL ;
2012-08-04 11:28:39 +00:00
memset ( & potential , 0 , sizeof ( potential ) ) ;
Terr_ParseEntityLump ( mod - > entities , & potential ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
2012-08-04 11:28:39 +00:00
if ( potential . firstsegx = = potential . maxsegx | | potential . firstsegy = = potential . maxsegy )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
return NULL ;
hm = Z_Malloc ( sizeof ( * hm ) ) ;
2012-08-04 11:28:39 +00:00
* hm = potential ;
2012-07-21 08:06:07 +00:00
ClearLink ( & hm - > recycle ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
Q_strncpyz ( hm - > path , loadname , sizeof ( hm - > path ) ) ;
hm - > exteriorcontents = FTECONTENTS_EMPTY ; //bsp geometry outside the heightmap
2012-08-04 11:28:39 +00:00
Terr_FinishTerrain ( hm , " terrainshader " , loadname ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
return hm ;
}
2012-11-27 03:23:19 +00:00
2013-03-31 04:21:08 +00:00
void Mod_Terrain_Create_f ( void )
{
char * mname ;
char * mdata ;
mname = va ( " maps/%s.hmp " , Cmd_Argv ( 1 ) ) ;
mdata = va (
" terrain \n "
" { \n "
" classname worldspawn \n "
" _segmentsize 1024 \n "
" _minxsegment -2048 \n "
" _minysegment -2048 \n "
" _maxxsegment 2048 \n "
" _maxysegment 2048 \n "
" _segmentsize 1024 \n "
// "_tiles 64 64 8 8\n"
" } \n "
" { \n "
" classname info_player_start \n "
" origin \" 0 0 1024 \" \n "
" } \n "
, mname ) ;
COM_WriteFile ( mname , mdata , strlen ( mdata ) ) ;
}
void Mod_Terrain_Reload_f ( void )
{
model_t * mod ;
heightmap_t * hm ;
if ( Cmd_Argc ( ) > = 2 )
mod = Mod_FindName ( va ( " maps/%s.hmp " , Cmd_Argv ( 1 ) ) ) ;
# ifndef SERVERONLY
else if ( cls . state )
mod = cl . worldmodel ;
# endif
else
mod = NULL ;
if ( ! mod | | mod - > type = = mod_dummy )
return ;
hm = mod - > terrain ;
if ( ! hm )
return ;
if ( Cmd_Argc ( ) > = 4 )
{
hmsection_t * s ;
int sx = atoi ( Cmd_Argv ( 2 ) ) + CHUNKBIAS ;
int sy = atoi ( Cmd_Argv ( 3 ) ) + CHUNKBIAS ;
if ( hm )
{
s = Terr_GetSection ( hm , sx , sy , TGS_NOLOAD ) ;
if ( s )
{
s - > flags | = TSF_NOTIFY ;
}
}
}
else
Terr_PurgeTerrainModel ( mod , false , true ) ;
}
2012-11-27 03:23:19 +00:00
void Terr_Init ( void )
{
Cvar_Register ( & mod_terrain_networked , " Terrain " ) ;
2013-03-31 04:21:08 +00:00
Cmd_AddCommand ( " mod_terrain_create " , Mod_Terrain_Create_f ) ;
Cmd_AddCommand ( " mod_terrain_reload " , Mod_Terrain_Reload_f ) ;
2012-11-27 03:23:19 +00:00
}
2005-08-26 22:49:36 +00:00
# endif