Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Enumerations | Functions | Variables
blend.cpp File Reference
#include <SDL_opengl.h>
#include <boost/algorithm/clamp.hpp>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include "inexor/client/network.hpp"
#include "inexor/engine/blend.hpp"
#include "inexor/engine/lightmap.hpp"
#include "inexor/engine/octaedit.hpp"
#include "inexor/engine/octree.hpp"
#include "inexor/engine/rendergl.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/io/legacy/stream.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/texture/image.hpp"
#include "inexor/texture/texture.hpp"
#include "inexor/util/legacy_time.hpp"

Classes

struct  BlendMapNode
 
struct  BlendMapBranch
 
struct  BlendMapSolid
 
struct  BlendMapImage
 
struct  BlendMapRoot
 
struct  BlendMapCache
 
struct  BlendBrush
 
union  BlendMapNode.__unnamed__
 

Macros

#define BM_SCALE   1
 
#define BM_IMAGE_SIZE   64
 
#define DEFBMSOLIDS(n)   n, n+1, n+2, n+3, n+4, n+5, n+6, n+7, n+8, n+9, n+10, n+11, n+12, n+13, n+14, n+15
 

Enumerations

enum  { BM_BRANCH = 0, BM_SOLID, BM_IMAGE }
 

Functions

BlendMapCachenewblendmapcache ()
 
void freeblendmapcache (BlendMapCache *&cache)
 
bool setblendmaporigin (BlendMapCache *cache, const ivec &o, int size)
 
bool hasblendmap (BlendMapCache *cache)
 
static uchar lookupblendmap (int x, int y, BlendMapBranch *bm, int bmscale)
 
uchar lookupblendmap (BlendMapCache *cache, const vec &pos)
 
static void fillblendmap (uchar &type, BlendMapNode &node, int size, uchar val, int x1, int y1, int x2, int y2)
 
void fillblendmap (int x, int y, int w, int h, uchar val)
 
static void invertblendmap (uchar &type, BlendMapNode &node, int size, int x1, int y1, int x2, int y2)
 
void invertblendmap (int x, int y, int w, int h)
 
static void optimizeblendmap (uchar &type, BlendMapNode &node)
 
void optimizeblendmap ()
 
 VARF (blendpaintmode, 0, 0, 5,{if(!blendpaintmode) stoppaintblendmap();})
 
static void blitblendmap (uchar &type, BlendMapNode &node, int bmx, int bmy, int bmsize, uchar *src, int sx, int sy, int sw, int sh, int smode)
 
void blitblendmap (uchar *src, int sx, int sy, int sw, int sh, int smode)
 
void resetblendmap ()
 
void enlargeblendmap ()
 
void shrinkblendmap (int octant)
 
void moveblendmap (uchar type, BlendMapNode &node, int size, int x, int y, int dx, int dy)
 
void moveblendmap (int dx, int dy)
 
void cleanupblendmap ()
 
void clearblendbrushes ()
 
void delblendbrush (const char *name)
 
void addblendbrush (const char *name, const char *imgname)
 
void nextblendbrush (int *dir)
 
void setblendbrush (const char *name)
 
void getblendbrushname (int *n)
 
void curblendbrush ()
 
 COMMAND (clearblendbrushes,"")
 
 COMMAND (delblendbrush,"s")
 
 COMMAND (addblendbrush,"ss")
 
 COMMAND (nextblendbrush,"i")
 
 COMMAND (setblendbrush,"s")
 
 COMMAND (getblendbrushname,"i")
 
 COMMAND (curblendbrush,"")
 
bool canpaintblendmap (bool brush=true, bool sel=false, bool msg=true)
 
void rotateblendbrush (int *val)
 
 COMMAND (rotateblendbrush,"i")
 
void paintblendmap (bool msg)
 
 VAR (paintblendmapdelay, 1, 500, 3000)
 
 VAR (paintblendmapinterval, 1, 30, 3000)
 
void stoppaintblendmap ()
 
void trypaintblendmap ()
 
 ICOMMAND (paintblendmap,"D",(int *isdown),{if(*isdown){if(!paintingblendmap){paintblendmap(true);paintingblendmap=totalmillis;}}else stoppaintblendmap();})
 
void clearblendmapsel ()
 
 COMMAND (clearblendmapsel,"")
 
void invertblendmapsel ()
 
 COMMAND (invertblendmapsel,"")
 
void invertblendmap ()
 
 COMMAND (invertblendmap,"")
 
void showblendmap ()
 
 COMMAND (showblendmap,"")
 
 COMMAND (optimizeblendmap,"")
 
 ICOMMAND (clearblendmap,"",(),{if(noedit(true)||(nompedit &&multiplayer())) return;resetblendmap();showblendmap();})
 
 ICOMMAND (moveblendmap,"ii",(int *dx, int *dy),{if(noedit(true)||(nompedit &&multiplayer())) return;if(*dx%(BM_IMAGE_SIZE<< BM_SCALE)||*dy%(BM_IMAGE_SIZE<< BM_SCALE)){Log.std->error("blendmap movement must be in multiples of {}",(BM_IMAGE_SIZE<< BM_SCALE));return;}if(*dx<=-worldsize||*dx >=worldsize||*dy<=-worldsize||*dy >=worldsize) resetblendmap();else moveblendmap(*dx >>BM_SCALE,*dy >>BM_SCALE);showblendmap();})
 
void renderblendbrush ()
 
bool loadblendmap (stream *f, uchar &type, BlendMapNode &node)
 
bool loadblendmap (stream *f, int info)
 
void saveblendmap (stream *f, uchar type, BlendMapNode &node)
 
void saveblendmap (stream *f)
 
uchar shouldsaveblendmap ()
 

Variables

static BlendMapSolid bmsolids [256]
 
static BlendMapRoot blendmap
 
static vector< BlendBrush * > brushes
 
static int curbrush = -1
 
SharedVar< int > nompedit
 
int paintingblendmap = 0
 
int lastpaintblendmap = 0
 

Class Documentation

struct BlendMapImage
Class Members
uchar data[BM_IMAGE_SIZE *BM_IMAGE_SIZE]
struct BlendMapCache
Class Members
BlendMapRoot node
ivec2 origin
int scale
union BlendMapNode.__unnamed__
Class Members
BlendMapBranch * branch
BlendMapImage * image
BlendMapSolid * solid

Macro Definition Documentation

#define BM_IMAGE_SIZE   64
#define BM_SCALE   1
#define DEFBMSOLIDS (   n)    n, n+1, n+2, n+3, n+4, n+5, n+6, n+7, n+8, n+9, n+10, n+11, n+12, n+13, n+14, n+15

Enumeration Type Documentation

anonymous enum
Enumerator
BM_BRANCH 
BM_SOLID 
BM_IMAGE 

Function Documentation

void addblendbrush ( const char *  name,
const char *  imgname 
)
static void blitblendmap ( uchar type,
BlendMapNode node,
int  bmx,
int  bmy,
int  bmsize,
uchar src,
int  sx,
int  sy,
int  sw,
int  sh,
int  smode 
)
static
void blitblendmap ( uchar src,
int  sx,
int  sy,
int  sw,
int  sh,
int  smode 
)
bool canpaintblendmap ( bool  brush = true,
bool  sel = false,
bool  msg = true 
)
void cleanupblendmap ( )

References loopv.

Referenced by resetgl().

void clearblendbrushes ( )
void clearblendmapsel ( )
COMMAND ( clearblendbrushes  ,
""   
)
COMMAND ( delblendbrush  ,
"s"   
)
COMMAND ( addblendbrush  ,
"ss"   
)
COMMAND ( nextblendbrush  ,
"i"   
)
COMMAND ( setblendbrush  ,
"s"   
)
COMMAND ( getblendbrushname  ,
"i"   
)
COMMAND ( curblendbrush  ,
""   
)
COMMAND ( rotateblendbrush  ,
"i"   
)
COMMAND ( clearblendmapsel  ,
""   
)
COMMAND ( invertblendmapsel  ,
""   
)
COMMAND ( invertblendmap  ,
""   
)
COMMAND ( showblendmap  ,
""   
)
COMMAND ( optimizeblendmap  ,
""   
)
void curblendbrush ( )

References intret().

void delblendbrush ( const char *  name)
void enlargeblendmap ( )
static void fillblendmap ( uchar type,
BlendMapNode node,
int  size,
uchar  val,
int  x1,
int  y1,
int  x2,
int  y2 
)
static
void fillblendmap ( int  x,
int  y,
int  w,
int  h,
uchar  val 
)
void freeblendmapcache ( BlendMapCache *&  cache)
void getblendbrushname ( int *  n)
bool hasblendmap ( BlendMapCache cache)

References BlendMapCache::node.

ICOMMAND ( paintblendmap  ,
"D"  ,
(int *isdown)  ,
{if(*isdown){if(!paintingblendmap){paintblendmap(true);paintingblendmap=totalmillis;}}else stoppaintblendmap();}   
)
ICOMMAND ( clearblendmap  ,
""  ,
()  ,
{if(noedit(true)||(nompedit &&multiplayer())) return;resetblendmap();showblendmap();}   
)
ICOMMAND ( moveblendmap  ,
"ii"  ,
(int *dx, int *dy)  ,
{if(noedit(true)||(nompedit &&multiplayer())) return;if(*dx%(BM_IMAGE_SIZE<< BM_SCALE)||*dy%(BM_IMAGE_SIZE<< BM_SCALE)){Log.std->error("blendmap movement must be in multiples of {}",(BM_IMAGE_SIZE<< BM_SCALE));return;}if(*dx<=-worldsize||*dx >=worldsize||*dy<=-worldsize||*dy >=worldsize) resetblendmap();else moveblendmap(*dx >>BM_SCALE,*dy >>BM_SCALE);showblendmap();}   
)
static void invertblendmap ( uchar type,
BlendMapNode node,
int  size,
int  x1,
int  y1,
int  x2,
int  y2 
)
static
void invertblendmap ( int  x,
int  y,
int  w,
int  h 
)
void invertblendmap ( )
void invertblendmapsel ( )
bool loadblendmap ( stream f,
uchar type,
BlendMapNode node 
)
bool loadblendmap ( stream f,
int  info 
)
static uchar lookupblendmap ( int  x,
int  y,
BlendMapBranch bm,
int  bmscale 
)
static
uchar lookupblendmap ( BlendMapCache cache,
const vec pos 
)
void moveblendmap ( uchar  type,
BlendMapNode node,
int  size,
int  x,
int  y,
int  dx,
int  dy 
)
void moveblendmap ( int  dx,
int  dy 
)
BlendMapCache* newblendmapcache ( )
void nextblendbrush ( int *  dir)
static void optimizeblendmap ( uchar type,
BlendMapNode node 
)
static
void optimizeblendmap ( )
void paintblendmap ( bool  msg)
void renderblendbrush ( )
void resetblendmap ( )
void rotateblendbrush ( int *  val)
void saveblendmap ( stream f,
uchar  type,
BlendMapNode node 
)
void saveblendmap ( stream f)
void setblendbrush ( const char *  name)

References loopv.

bool setblendmaporigin ( BlendMapCache cache,
const ivec o,
int  size 
)
uchar shouldsaveblendmap ( )

Referenced by save_world().

void showblendmap ( )
void shrinkblendmap ( int  octant)

References BlendMapRoot::shrink().

Referenced by shrinkmap().

void stoppaintblendmap ( )

References lastpaintblendmap.

Referenced by toggleedit().

void trypaintblendmap ( )

References lastpaintblendmap, paintblendmap(), and totalmillis.

Referenced by tryedit().

VAR ( paintblendmapdelay  ,
,
500  ,
3000   
)
VAR ( paintblendmapinterval  ,
,
30  ,
3000   
)
VARF ( blendpaintmode  ,
,
,
,
{if(!blendpaintmode) stoppaintblendmap();}   
)

Variable Documentation

BlendMapRoot blendmap
static
BlendMapSolid bmsolids[256]
static
Initial value:
=
{
DEFBMSOLIDS(0x00), DEFBMSOLIDS(0x10), DEFBMSOLIDS(0x20), DEFBMSOLIDS(0x30),
DEFBMSOLIDS(0x40), DEFBMSOLIDS(0x50), DEFBMSOLIDS(0x60), DEFBMSOLIDS(0x70),
DEFBMSOLIDS(0x80), DEFBMSOLIDS(0x90), DEFBMSOLIDS(0xA0), DEFBMSOLIDS(0xB0),
DEFBMSOLIDS(0xC0), DEFBMSOLIDS(0xD0), DEFBMSOLIDS(0xE0), DEFBMSOLIDS(0xF0),
}
#define DEFBMSOLIDS(n)
Definition: blend.cpp:89
vector<BlendBrush *> brushes
static
int curbrush = -1
static
int lastpaintblendmap = 0
SharedVar<int> nompedit
int paintingblendmap = 0