Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Enumerations | Functions | Variables
octaedit.cpp File Reference
#include <SDL_opengl.h>
#include <boost/algorithm/clamp.hpp>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include "inexor/client/network.hpp"
#include "inexor/engine/blend.hpp"
#include "inexor/engine/blob.hpp"
#include "inexor/engine/frame.hpp"
#include "inexor/engine/glemu.hpp"
#include "inexor/engine/glexts.hpp"
#include "inexor/engine/lightmap.hpp"
#include "inexor/engine/material.hpp"
#include "inexor/engine/octa.hpp"
#include "inexor/engine/octaedit.hpp"
#include "inexor/engine/octarender.hpp"
#include "inexor/engine/octree.hpp"
#include "inexor/engine/rendergl.hpp"
#include "inexor/engine/renderva.hpp"
#include "inexor/engine/shader.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/fpsgame/client.hpp"
#include "inexor/fpsgame/fps.hpp"
#include "inexor/fpsgame/player.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/io/input/InputRouter.hpp"
#include "inexor/io/legacy/stream.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/physics/physics.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_endian.hpp"
#include "inexor/shared/cube_formatting.hpp"
#include "inexor/shared/cube_hash.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/texture/slot.hpp"
#include "inexor/texture/texture.hpp"
#include "inexor/ui/legacy/3dgui.hpp"
#include "inexor/ui/legacy/menus.hpp"
#include "inexor/util/legacy_time.hpp"
#include "zconf.h"
#include "zlib.h"

Classes

struct  undolist
 
struct  vslothdr
 
struct  vslotmap
 
struct  prefabheader
 
struct  prefab
 
struct  prefabmesh
 
struct  prefabmesh::vertex
 
struct  vslotref
 
struct  texturegui
 

Namespaces

 hmap
 

Macros

#define loopxy(b)   loop(y,(b).s[C[dimension((b).orient)]]) loop(x,(b).s[R[dimension((b).orient)]])
 
#define loopxyz(b, r, f)   { loop(z,(b).s[D[dimension((b).orient)]]) loopxy((b)) { cube &c = blockcube(x,y,z,b,r); f; } }
 
#define loopselxyz(f)   { if(local) makeundo(); loopxyz(sel, sel.grid, f); changed(sel); }
 
#define selcube(x, y, z)   blockcube(x, y, z, sel, sel.grid)
 
#define protectsel(f)   { undoblock *_u = newundocube(sel); f; if(_u) { pasteundo(_u); freeundo(_u); } }
 
#define editingvslot(...)   vslotref vslotrefs[] = { __VA_ARGS__ }; (void)vslotrefs;
 
#define MAXBRUSH   64
 
#define MAXBRUSHC   63
 
#define MAXBRUSH2   32
 
#define PAINTED   1
 
#define NOTHMAP   2
 
#define MAPPED   16
 
#define pullhmap(I, LT, GT, M, N, A)
 
#define DIAGONAL_RIPPLE(a, b, exp)
 
#define loopbrush(i)   for(int x=bmx; x<=bnx+i; x++) for(int y=bmy; y<=bny+i; y++)
 

Enumerations

enum  { EDITMATF_EMPTY = 0x10000, EDITMATF_NOTEMPTY = 0x20000, EDITMATF_SOLID = 0x30000, EDITMATF_NOTSOLID = 0x40000 }
 

Functions

void boxs (int orient, vec o, const vec &s, float size)
 renders a rectangular box to the target location with faked thick lines More...
 
void boxs (int orient, vec o, const vec &s)
 renders a rectangular box to the target location More...
 
void boxs3D (const vec &o, vec s, int g)
 render cube (6 boxes) to target location More...
 
void boxsgrid (int orient, vec o, vec s, int g)
 renders box grid on the face of the selected volume/area More...
 
 VARF (dragging, 0, 0, 1, if(!dragging||cor[0]< 0) return;lastcur=cur;lastcor=cor;sel.grid=gridsize;sel.orient=orient;)
 dragging is enabled (1) once a grid start cube is selected once you select a cube the selection box will be drawn a little brighter More...
 
 ICOMMAND (moving,"b",(int *n),{if(*n >=0){if(!*n||(moving<=1 &&!pointinsel(sel, vec(cur).add(1)))) moving=0;else if(!moving) moving=1;}intret(moving);})
 
 VARF (gridpower, 0, 3, 12,{if(dragging) return;gridsize=1<< gridpower;if(gridsize >=worldsize) gridsize=worldsize/2;cancelsel();})
 will be called every time the gridpower (gridsize) changes More...
 
 VAR (passthroughsel, 0, 0, 1)
 allow the editor to select new areas/volumes through the current selection otherwise select cubes ON the current selection More...
 
 VAR (editing, 1, 0, 0)
 represent the user's editing status (is he editing or not?) More...
 
 VAR (selectcorners, 0, 0, 1)
 when intruding (pushing towards the inside) a selected cube/face keep the corners rounded More...
 
 VARF (hmapedit, 0, 0, 1, horient=sel.orient)
 start/stop heightmap editing More...
 
void forcenextundo ()
 reset orientation of the last selection this is called every time the user changes grid size or editing status More...
 
void hmapcancel ()
 
void cubecancel ()
 aborts heightsmap editing and resets selection data More...
 
void cancelsel ()
 reset the current selection called every time user changes grid size or editing status More...
 
void toggleedit (bool force)
 change editing status also cancel selection, blendmaps and more More...
 
bool noedit (bool view, bool msg)
 check if user is allowed to edit concerns may be a scene selection which is not in view or disbaled editing status More...
 
void reorient ()
 change the selection orientation according to the cursor's position More...
 
void selextend ()
 extend the selection according to the cursor's position More...
 
 ICOMMAND (edittoggle,"",(), toggleedit(false))
 cubescript command hook: toggle editing More...
 
 COMMAND (entcancel,"")
 cubescript command hook: remove entity selection More...
 
 COMMAND (cubecancel,"")
 cubescript command hook: remove cube selection More...
 
 COMMAND (cancelsel,"")
 cubescript command hook: remove both cube and entity selection More...
 
 COMMAND (reorient,"")
 cubescript command hook: change orientation of selected cubes according to the cursor More...
 
 COMMAND (selextend,"")
 cubescript command hook: extend selection of cubes according to the cursor More...
 
 ICOMMAND (selmoved,"",(),{if(noedit(true)) return;intret(sel.o!=savedsel.o?1:0);})
 
 ICOMMAND (selrestore,"",(),{if(noedit(true)) return;sel=savedsel;})
 
 ICOMMAND (selsave,"",(),{if(noedit(true)) return;savedsel=sel;})
 
 ICOMMAND (selswap,"",(),{if(noedit(true)) return;swap(sel, savedsel);})
 
cubeblockcube (int x, int y, int z, const block3 &b, int rgrid)
 looks up a world cube, based on coordinates mapped by the block More...
 
 ICOMMAND (havesel,"",(), intret(havesel?selchildcount:0))
 cubescript: return number of selected cubes More...
 
void countselchild (cube *c, const ivec &cor, int size)
 count the number of selected child cubes and materials in your selection More...
 
void normalizelookupcube (const ivec &o)
 get the selected cube's position from the origin vector (0,0,0) More...
 
void updateselection ()
 validate the coordinates of the selected face/volume make sure the selected grid is not outside of the map More...
 
bool editmoveplane (const vec &o, const vec &ray, int d, float off, vec &handle, vec &dest, bool first)
 move the selection grid (the "plane") along the selection has an origin and can only be moved in 2 dimensions simultaneously More...
 
bool isheightmap (int orient, int d, bool empty, cube *c)
 
void entdrag (const vec &ray)
 
bool hoveringonent (int ent, int orient)
 
void renderentselection (const vec &o, const vec &ray, bool entmoving)
 
float rayent (const vec &o, const vec &ray, float radius, int mode, int size, int &orient, int &ent)
 
 VAR (gridlookup, 0, 0, 1)
 automaticly select the grid size of the selected face More...
 
 VAR (passthroughcube, 0, 1, 1)
 ignore the first cube when view ray intersects it and select the second ("select through cubes") More...
 
void rendereditcursor ()
 render selection box to the cursor target also moves entities! More...
 
void tryedit ()
 check if editing can be done More...
 
void readychanges (const ivec &bbmin, const ivec &bbmax, cube *c, const ivec &cor, int size)
 checks and validates changes in the octree system More...
 
void commitchanges (bool force)
 commits changes in geometry More...
 
void changed (const block3 &sel, bool commit=true)
 validates editing changes using readychanges() and calls commitchanges() More...
 
static void copycube (const cube &src, cube &dst)
 
static void pastecube (const cube &src, cube &dst)
 
void blockcopy (const block3 &s, int rgrid, block3 *b)
 
block3blockcopy (const block3 &s, int rgrid)
 
void freeblock (block3 *b, bool alloced=true)
 
void selgridmap (selinfo &sel, uchar *g)
 
void freeundo (undoblock *u)
 
void pasteundoblock (block3 *b, uchar *g)
 
void pasteundo (undoblock *u)
 
static int undosize (undoblock *u)
 
 VARP (undomegs, 0, 5, 100)
 
void pruneundos (int maxremain)
 
void clearundos ()
 
 COMMAND (clearundos,"")
 
undoblocknewundocube (selinfo &s)
 
void addundo (undoblock *u)
 
 VARP (nompedit, 0, 1, 1)
 
void makeundo (selinfo &s)
 
void makeundo ()
 
static int countblock (cube *c, int n=8)
 
static int countblock (block3 *b)
 
void swapundo (undolist &a, undolist &b, int op)
 
void editundo ()
 
void editredo ()
 
template<class B >
static void packcube (cube &c, B &buf)
 
template<class B >
static bool packblock (block3 &b, B &buf)
 
static void packvslots (cube &c, vector< uchar > &buf, vector< ushort > &used)
 
static void packvslots (block3 &b, vector< uchar > &buf)
 
template<class B >
static void unpackcube (cube &c, B &buf)
 
template<class B >
static bool unpackblock (block3 *&b, B &buf)
 
static void unpackvslots (cube &c, ucharbuf &buf)
 
static void unpackvslots (block3 &b, ucharbuf &buf)
 
static bool compresseditinfo (const uchar *inbuf, int inlen, uchar *&outbuf, int &outlen)
 
static bool uncompresseditinfo (const uchar *inbuf, int inlen, uchar *&outbuf, int &outlen)
 
bool packeditinfo (editinfo *e, int &inlen, uchar *&outbuf, int &outlen)
 
bool unpackeditinfo (editinfo *&e, const uchar *inbuf, int inlen, int outlen)
 
void freeeditinfo (editinfo *&e)
 
bool packundo (undoblock *u, int &inlen, uchar *&outbuf, int &outlen)
 
bool unpackundo (const uchar *inbuf, int inlen, int outlen)
 
bool packundo (int op, int &inlen, uchar *&outbuf, int &outlen)
 
 SVARP (prefabdir,"prefab")
 
void cleanupprefabs ()
 
void delprefab (char *name)
 
 COMMAND (delprefab,"s")
 
void saveprefab (char *name)
 
 COMMAND (saveprefab,"s")
 
void pasteblock (block3 &b, selinfo &sel, bool local)
 
prefabloadprefab (const char *name, bool msg=true)
 
void pasteprefab (char *name)
 
 COMMAND (pasteprefab,"s")
 
static void genprefabmesh (prefabmesh &r, cube &c, const ivec &co, int size)
 
void genprefabmesh (prefab &p)
 
static void renderprefab (prefab &p, const vec &o, float yaw, float pitch, float roll, float size, const vec &color)
 
void renderprefab (const char *name, const vec &o, float yaw, float pitch, float roll, float size, const vec &color)
 
void previewprefab (const char *name, const vec &color)
 
void mpcopy (editinfo *&e, selinfo &sel, bool local)
 
void mppaste (editinfo *&e, selinfo &sel, bool local)
 
void copy ()
 
void pastehilite ()
 
void paste ()
 
 COMMAND (copy,"")
 
 COMMAND (pastehilite,"")
 
 COMMAND (paste,"")
 
 COMMANDN (undo, editundo,"")
 
 COMMANDN (redo, editredo,"")
 
void compacteditvslots ()
 
 VAR (brushx, 0, MAXBRUSH2, MAXBRUSH)
 
 VAR (brushy, 0, MAXBRUSH2, MAXBRUSH)
 
void clearbrush ()
 
void brushvert (int *x, int *y, int *v)
 
 COMMAND (clearbrush,"")
 
 COMMAND (brushvert,"iii")
 
 COMMAND (hmapcancel,"")
 
 ICOMMAND (hmapselect,"",(), int t=lookupcube(cur).texture[orient];int i=htextures.find(t);if(i< 0) htextures.add(t);else htextures.remove(i);)
 
cubehmap::getcube (ivec t, int f)
 
uint hmap::getface (cube *c, int d)
 
void hmap::pushside (cube &c, int d, int x, int y, int z)
 
void hmap::addpoint (int x, int y, int z, int v)
 
void hmap::select (int x, int y, int z)
 
void hmap::ripple (int x, int y, int z, bool force)
 
void hmap::paint ()
 
void hmap::smooth ()
 
void hmap::rippleandset ()
 
void hmap::run (int dir, int mode)
 
void edithmap (int dir, int mode)
 
int bounded (int n)
 
void pushedge (uchar &edge, int dir, int dc)
 
void linkedpush (cube &c, int d, int x, int y, int dc, int dir)
 
static ushort getmaterial (cube &c)
 
 VAR (invalidcubeguard, 0, 1, 1)
 
void mpeditface (int dir, int mode, selinfo &sel, bool local)
 
void editface (int *dir, int *mode)
 
 VAR (selectionsurf, 0, 0, 1)
 
void pushsel (int *dir)
 
void mpdelcube (selinfo &sel, bool local)
 
void delcube ()
 
 COMMAND (pushsel,"i")
 
 COMMAND (editface,"ii")
 
 COMMAND (delcube,"")
 
void tofronttex ()
 
 VAR (usevdelta, 1, 0, 0)
 
static VSlotremapvslot (int index, bool delta, const VSlot &ds)
 
static void remapvslots (cube &c, bool delta, const VSlot &ds, int orient, bool &findrep, VSlot *&findedit)
 
void edittexcube (cube &c, int tex, int orient, bool &findrep)
 
 VAR (allfaces, 0, 0, 1)
 
void mpeditvslot (int delta, VSlot &ds, int allfaces, selinfo &sel, bool local)
 
bool mpeditvslot (int delta, int allfaces, selinfo &sel, ucharbuf &buf)
 
void vdelta (char *body)
 
 COMMAND (vdelta,"s")
 
void vrotate (int *n)
 
 COMMAND (vrotate,"i")
 
void voffset (int *x, int *y)
 
 COMMAND (voffset,"ii")
 
void vscroll (float *s, float *t)
 
 COMMAND (vscroll,"ff")
 
void vscale (float *scale)
 
 COMMAND (vscale,"f")
 
void vlayer (int *n)
 
 COMMAND (vlayer,"i")
 
void valpha (float *front, float *back)
 
 COMMAND (valpha,"ff")
 
void vcolor (float *r, float *g, float *b)
 
 COMMAND (vcolor,"fff")
 
void vreset ()
 
 COMMAND (vreset,"")
 
void vshaderparam (const char *name, float *x, float *y, float *z, float *w)
 
 COMMAND (vshaderparam,"sffff")
 
void mpedittex (int tex, int allfaces, selinfo &sel, bool local)
 
static int unpacktex (int &tex, ucharbuf &buf, bool insert=true)
 
int shouldpacktex (int index)
 
bool mpedittex (int tex, int allfaces, selinfo &sel, ucharbuf &buf)
 
void filltexlist ()
 
void compactmruvslots ()
 
void edittex (int i, bool save=true)
 
void edittex_ (int *dir)
 
void gettex ()
 
void getcurtex ()
 
void getseltex ()
 
void gettexname (int *tex, int *subslot)
 
 COMMANDN (edittex, edittex_,"i")
 
 COMMAND (gettex,"")
 
 COMMAND (getcurtex,"")
 
 COMMAND (getseltex,"")
 
 ICOMMAND (getreptex,"",(),{if(!noedit()) intret(vslots.inrange(reptex)?reptex:-1);})
 
 COMMAND (gettexname,"ii")
 
void replacetexcube (cube &c, int oldtex, int newtex)
 
bool hastexcube (cube &c, int tex)
 
void mpreplacetex (int oldtex, int newtex, bool insel, selinfo &sel, bool local, bool update)
 
bool mpreplacetex (int oldtex, int newtex, bool insel, selinfo &sel, ucharbuf &buf)
 
void replace (bool insel)
 
 ICOMMAND (replace,"",(), replace(false))
 
 ICOMMAND (replacesel,"",(), replace(true))
 
uint dflip (uint face)
 
uint cflip (uint face)
 
uint rflip (uint face)
 
uint mflip (uint face)
 
void flipcube (cube &c, int d)
 
void rotatequad (cube &a, cube &b, cube &c, cube &d)
 
void rotatecube (cube &c, int d)
 
void mpflip (selinfo &sel, bool local)
 
void flip ()
 
void mprotate (int cw, selinfo &sel, bool local)
 
void rotate (int *cw)
 
 COMMAND (flip,"")
 
 COMMAND (rotate,"i")
 
void setmat (cube &c, ushort mat, ushort matmask, ushort filtermat, ushort filtermask, int filtergeom)
 
void mpeditmat (int matid, int filter, selinfo &sel, bool local)
 
void editmat (char *name, char *filtername)
 
 COMMAND (editmat,"ss")
 
 VARP (texguiwidth, 1, 12, 1000)
 
 VARP (texguiheight, 1, 8, 1000)
 
 VARP (texguitime, 0, 25, 1000)
 
 VARP (texgui2d, 0, 1, 1)
 
void g3d_texturemenu ()
 
void showtexgui (int *n)
 show texture More...
 
 COMMAND (showtexgui,"i")
 
void rendertexturepanel (int w, int h)
 render quick selection preview for surface textures standard edit key binding: press Z More...
 

Variables

SharedVar< int > outline
 
bool boxoutline = false
 
selinfo sel
 Bot Movement, according to waypoints (saved within the map in an excluded file). More...
 
selinfo lastsel
 
selinfo savedsel
 
int orient = 0
 
int gridsize = 8
 
ivec cor
 
ivec lastcor
 
ivec cur
 
ivec lastcur
 
SharedVar< int > entediting
 
bool editmode = false
 
bool havesel = false
 
bool hmapsel = false
 
int horient = 0
 
int entmoving
 
int moving = 0
 moving will be set to 1 as soon as you right-click a selected area/volume to move it once you release the key, moving(0) will be called More...
 
int selchildcount = 0
 the amount of selected child cubes they will be displayed in the bottom left of you screen in coopedit mode More...
 
int selchildmat = -1
 
static bool haschanged = false
 
undolist undos
 
undolist redos
 
int totalundos = 0
 
vector< editinfo * > editinfos
 
editinfolocaledit = nullptr
 
static vector< vslotmapunpackingvslots
 
static hashnameset< prefabprefabs
 
SharedVar< int > outlinecolour
 
static vector< int * > editingvslots
 
int brush [MAXBRUSH][MAXBRUSH]
 
bool paintbrush = 0
 
int brushmaxx = 0
 
int brushminx = MAXBRUSH
 
int brushmaxy = 0
 
int brushminy = MAXBRUSH
 
vector< int > htextures
 
uchar hmap::flags [MAXBRUSH][MAXBRUSH]
 
cubehmap::cmap [MAXBRUSHC][MAXBRUSHC][4]
 
int hmap::mapz [MAXBRUSHC][MAXBRUSHC]
 
int hmap::map [MAXBRUSH][MAXBRUSH]
 
selinfo hmap::changes
 
bool hmap::selecting
 
int hmap::d
 
int hmap::dc
 
int hmap::dr
 
int hmap::dcr
 
int hmap::biasup
 
int hmap::br
 
int hmap::hws
 
int hmap::fg
 
int hmap::gx
 
int hmap::gy
 
int hmap::gz
 
int hmap::mx
 
int hmap::my
 
int hmap::mz
 
int hmap::nx
 
int hmap::ny
 
int hmap::nz
 
int hmap::bmx
 
int hmap::bmy
 
int hmap::bnx
 
int hmap::bny
 
uint hmap::fs
 
selinfo hmap::hundo
 
int curtexindex = -1
 
int lasttex = 0
 
int lasttexmillis = -1
 
int texpaneltimer = 0
 
vector< ushorttexmru
 
selinfo repsel
 
int reptex = -1
 
static vector< vslotmapremappedvslots
 
struct {
const char * name
 
int filter
 
editmatfilters []
 
SharedVar< int > menudistance
 
SharedVar< int > menuautoclose
 
static int lastthumbnail = 0
 
texturegui gui
 

Class Documentation

struct vslothdr
Class Members
ushort index
ushort slot
struct prefabheader
Class Members
char magic[4]
int version
struct prefabmesh::vertex
Class Members
bvec4 norm
vec pos

Macro Definition Documentation

#define DIAGONAL_RIPPLE (   a,
  b,
  exp 
)
Value:
if(exp) { \
if(flags[x a][ y] & PAINTED) \
ripple(x a, y b, mapz[x a][y], true); \
else if(flags[x][y b] & PAINTED) \
ripple(x a, y b, mapz[x][y b], true); \
}
void ripple(int x, int y, int z, bool force)
Definition: octaedit.cpp:1853
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
#define PAINTED
Definition: octaedit.cpp:1739
uchar flags[MAXBRUSH][MAXBRUSH]
Definition: octaedit.cpp:1742
int mapz[MAXBRUSHC][MAXBRUSHC]
Definition: octaedit.cpp:1744

Referenced by hmap::ripple().

#define editingvslot (   ...)    vslotref vslotrefs[] = { __VA_ARGS__ }; (void)vslotrefs;

Referenced by mpeditvslot(), mpreplacetex(), and vlayer().

#define loopbrush (   i)    for(int x=bmx; x<=bnx+i; x++) for(int y=bmy; y<=bny+i; y++)
#define loopselxyz (   f)    { if(local) makeundo(); loopxyz(sel, sel.grid, f); changed(sel); }
#define loopxy (   b)    loop(y,(b).s[C[dimension((b).orient)]]) loop(x,(b).s[R[dimension((b).orient)]])

Referenced by mpflip(), and mprotate().

#define loopxyz (   b,
  r,
  f 
)    { loop(z,(b).s[D[dimension((b).orient)]]) loopxy((b)) { cube &c = blockcube(x,y,z,b,r); f; } }
#define MAPPED   16

Referenced by hmap::addpoint(), and hmap::smooth().

#define MAXBRUSH   64

Referenced by brushvert(), clearbrush(), and hmap::run().

#define MAXBRUSH2   32

Referenced by brushvert(), and hmap::run().

#define MAXBRUSHC   63
#define NOTHMAP   2

Referenced by hmap::ripple(), and hmap::select().

#define PAINTED   1

Referenced by hmap::ripple(), and hmap::select().

#define protectsel (   f)    { undoblock *_u = newundocube(sel); f; if(_u) { pasteundo(_u); freeundo(_u); } }

Referenced by mpcopy(), and saveprefab().

#define pullhmap (   I,
  LT,
  GT,
  M,
  N,
 
)
Value:
do { \
best = I; \
loopi(4) if(*o[i] LT best) best = *o[q = i] - M; \
par = (best&(~7)) + N; \
/* dual layer for extra smoothness */ \
if(*o[q^3] GT par && !(*o[q^1] LT par || *o[q^2] LT par)) { \
if(*o[q^3] GT par A 8 || *o[q^1] != par || *o[q^2] != par) { \
*o[q^3] = (*o[q^3] GT par A 8 ? par A 8 : *o[q^3]); \
*o[q^1] = *o[q^2] = par; \
changed = true; \
} \
/* single layer */ \
} else { \
loopj(4) if(*o[j] GT par) { \
*o[j] = par; \
changed = true; \
} \
} \
} while(0)
else loopi(numargs)
Definition: command.cpp:3019
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
#define loopj(m)
Definition: cube_loops.hpp:9
void changed(const block3 &sel, bool commit=true)
validates editing changes using readychanges() and calls commitchanges()
Definition: octaedit.cpp:725

Referenced by hmap::ripple().

#define selcube (   x,
  y,
 
)    blockcube(x, y, z, sel, sel.grid)

Referenced by mpflip(), and mprotate().

Enumeration Type Documentation

anonymous enum
Enumerator
EDITMATF_EMPTY 
EDITMATF_NOTEMPTY 
EDITMATF_SOLID 
EDITMATF_NOTSOLID 

Function Documentation

void addundo ( undoblock u)
void blockcopy ( const block3 s,
int  rgrid,
block3 b 
)

References block3::c(), copycube(), and loopxyz.

Referenced by blockcopy(), mpcopy(), newundocube(), and saveprefab().

block3* blockcopy ( const block3 s,
int  rgrid 
)

References blockcopy(), and block3::size().

cube& blockcube ( int  x,
int  y,
int  z,
const block3 b,
int  rgrid 
)

looks up a world cube, based on coordinates mapped by the block

References ivec::add(), hmap::dc, dimcoord, dimension, block3::grid, lookupcube(), block3::o, block3::orient, and block3::s.

Referenced by mpeditface().

int bounded ( int  n)

Referenced by pushedge().

void boxs ( int  orient,
vec  o,
const vec s,
float  size 
)

renders a rectangular box to the target location with faked thick lines

References vec::add(), gle::attrib(), gle::begin(), boxoutline, C, D, hmap::d, hmap::dc, dimcoord, dimension, gle::end(), f(), R, and xtraverts.

Referenced by boxs3D(), rendereditcursor(), and renderentselection().

void boxs ( int  orient,
vec  o,
const vec s 
)

renders a rectangular box to the target location

Parameters
orientcube face orientation index (3 dimensions x 2 directions = 6 possible orientation indices)
otarget rendering position
sa constant scalar vector

References gle::attrib(), gle::begin(), boxoutline, C, D, hmap::d, hmap::dc, dimcoord, dimension, gle::end(), f(), R, and xtraverts.

void boxs3D ( const vec o,
vec  s,
int  g 
)

render cube (6 boxes) to target location

Parameters
oselection start vector
sselection end vector
ggridsize

References boxs(), loopi(), and vec::mul().

Referenced by rendereditcursor(), and renderentselection().

void boxsgrid ( int  orient,
vec  o,
vec  s,
int  g 
)

renders box grid on the face of the selected volume/area

Parameters
orientorientation
oorigin vector (start)
send vector
ggrid size

References gle::attrib(), gle::begin(), boxoutline, C, D, hmap::d, hmap::dc, dimcoord, dimension, gle::end(), f(), loop, R, and xtraverts.

Referenced by rendereditcursor().

void brushvert ( int *  x,
int *  y,
int *  v 
)
void cancelsel ( )

reset the current selection called every time user changes grid size or editing status

See Also
cubecancel
entcancel

References cubecancel(), and entcancel().

Referenced by resetmap(), and toggleedit().

uint cflip ( uint  face)

Referenced by flipcube(), and rotatecube().

void changed ( const block3 sel,
bool  commit = true 
)
void cleanupprefabs ( )

References prefab::cleanup(), enumerate, and prefabs.

Referenced by resetgl().

void clearbrush ( )
void clearundos ( )

References pruneundos().

COMMAND ( entcancel  ,
""   
)

cubescript command hook: remove entity selection

COMMAND ( cubecancel  ,
""   
)

cubescript command hook: remove cube selection

COMMAND ( cancelsel  ,
""   
)

cubescript command hook: remove both cube and entity selection

COMMAND ( reorient  ,
""   
)

cubescript command hook: change orientation of selected cubes according to the cursor

COMMAND ( selextend  ,
""   
)

cubescript command hook: extend selection of cubes according to the cursor

COMMAND ( clearundos  ,
""   
)
COMMAND ( delprefab  ,
"s"   
)
COMMAND ( saveprefab  ,
"s"   
)
COMMAND ( pasteprefab  ,
"s"   
)
COMMAND ( copy  ,
""   
)
COMMAND ( pastehilite  ,
""   
)
COMMAND ( paste  ,
""   
)
COMMAND ( clearbrush  ,
""   
)
COMMAND ( brushvert  ,
"iii"   
)
COMMAND ( hmapcancel  ,
""   
)
COMMAND ( pushsel  ,
"i"   
)
COMMAND ( editface  ,
"ii"   
)
COMMAND ( delcube  ,
""   
)
COMMAND ( vdelta  ,
"s"   
)
COMMAND ( vrotate  ,
"i"   
)
COMMAND ( voffset  ,
"ii"   
)
COMMAND ( vscroll  ,
"ff"   
)
COMMAND ( vscale  ,
"f"   
)
COMMAND ( vlayer  ,
"i"   
)
COMMAND ( valpha  ,
"ff"   
)
COMMAND ( vcolor  ,
"fff"   
)
COMMAND ( vreset  ,
""   
)
COMMAND ( vshaderparam  ,
"sffff"   
)
COMMAND ( gettex  ,
""   
)
COMMAND ( getcurtex  ,
""   
)
COMMAND ( getseltex  ,
""   
)
COMMAND ( gettexname  ,
"ii"   
)
COMMAND ( flip  ,
""   
)
COMMAND ( rotate  ,
"i"   
)
COMMAND ( editmat  ,
"ss"   
)
COMMAND ( showtexgui  ,
"i"   
)
COMMANDN ( undo  ,
editundo  ,
""   
)
COMMANDN ( redo  ,
editredo  ,
""   
)
COMMANDN ( edittex  ,
edittex_  ,
"i"   
)
void commitchanges ( bool  force)
void compacteditvslots ( )
void compactmruvslots ( )
static bool compresseditinfo ( const uchar inbuf,
int  inlen,
uchar *&  outbuf,
int &  outlen 
)
static

Referenced by packeditinfo(), and packundo().

void copy ( )

References localedit, mpcopy(), noedit(), and sel.

Referenced by loadprefab(), and prefab::~prefab().

static void copycube ( const cube src,
cube dst 
)
inlinestatic
static int countblock ( cube c,
int  n = 8 
)
inlinestatic

References loopi().

Referenced by countblock(), and swapundo().

static int countblock ( block3 b)
static
void countselchild ( cube c,
const ivec cor,
int  size 
)

count the number of selected child cubes and materials in your selection

See Also
gl_drawhud
selchildcount

selected volume * grid = list of child cubes

References selinfo::grid, loopoctaboxsize, MAT_AIR, cube::material, ivec::mul(), selinfo::o, selinfo::s, sel, selchildcount, and selchildmat.

Referenced by rendereditcursor().

void cubecancel ( )

aborts heightsmap editing and resets selection data

See Also
forcenextundo
forcenextundo

References forcenextundo(), havesel, hmapcancel(), and moving.

Referenced by cancelsel().

void delcube ( )

References mpdelcube(), noedit(), and sel.

void delprefab ( char *  name)
uint dflip ( uint  face)

References F_EMPTY.

Referenced by flipcube(), and rotatecube().

void editface ( int *  dir,
int *  mode 
)

References edithmap(), moving, mpeditface(), noedit(), and sel.

void edithmap ( int  dir,
int  mode 
)

References hmapsel, multiplayer(), nompedit, and hmap::run().

Referenced by editface().

void editmat ( char *  name,
char *  filtername 
)
bool editmoveplane ( const vec o,
const vec ray,
int  d,
float  off,
vec handle,
vec dest,
bool  first 
)

move the selection grid (the "plane") along the selection has an origin and can only be moved in 2 dimensions simultaneously

References vec::add(), vec::mul(), physent::o, player, plane::rayintersect(), and vec::sub().

Referenced by entdrag(), and rendereditcursor().

void editredo ( )

References EDIT_REDO, redos, swapundo(), and undos.

void edittex ( int  i,
bool  save = true 
)
void edittex_ ( int *  dir)
void edittexcube ( cube c,
int  tex,
int  orient,
bool &  findrep 
)
void editundo ( )

References EDIT_UNDO, redos, swapundo(), and undos.

void entdrag ( const vec ray)
void filltexlist ( )
void flip ( )
void flipcube ( cube c,
int  d 
)

References C, cflip(), cube::children, D, hmap::d, dflip(), loopi(), octadim, R, rflip(), and cube::texture.

Referenced by mpflip().

void forcenextundo ( )

reset orientation of the last selection this is called every time the user changes grid size or editing status

References lastsel, and selinfo::orient.

Referenced by cubecancel(), hmap::run(), and swapundo().

void freeblock ( block3 b,
bool  alloced = true 
)
void freeeditinfo ( editinfo *&  e)

References editinfo::copy, editinfos, and freeblock().

Referenced by fpsent::~fpsent().

void freeundo ( undoblock u)
void g3d_texturemenu ( )

Referenced by g3d_render().

static void genprefabmesh ( prefabmesh r,
cube c,
const ivec co,
int  size 
)
static
void genprefabmesh ( prefab p)
void getcurtex ( )
static ushort getmaterial ( cube c)
static

References cube::children, loopi(), MAT_AIR, and cube::material.

Referenced by mpeditface().

void getseltex ( )
void gettex ( )
void gettexname ( int *  tex,
int *  subslot 
)
bool hastexcube ( cube c,
int  tex 
)
void hmapcancel ( )

References htextures, and vector< T, MINSIZE >::setsize().

Referenced by cubecancel().

bool hoveringonent ( int  ent,
int  orient 
)
ICOMMAND ( moving  ,
"b"  ,
(int *n)  ,
{if(*n >=0){if(!*n||(moving<=1 &&!pointinsel(sel, vec(cur).add(1)))) moving=0;else if(!moving) moving=1;}intret(moving);}   
)
ICOMMAND ( edittoggle  ,
""  ,
()  ,
toggleedit(false)   
)

cubescript command hook: toggle editing

ICOMMAND ( selmoved  ,
""  ,
()  ,
{if(noedit(true)) return;intret(sel.o!=savedsel.o?1:0);}   
)
ICOMMAND ( selrestore  ,
""  ,
()  ,
{if(noedit(true)) return;sel=savedsel;}   
)
ICOMMAND ( selsave  ,
""  ,
()  ,
{if(noedit(true)) return;savedsel=sel;}   
)
ICOMMAND ( selswap  ,
""  ,
()  ,
{if(noedit(true)) return;swap(sel, savedsel);}   
)
ICOMMAND ( havesel  ,
""  ,
()  ,
intret(havesel?selchildcount:0)   
)

cubescript: return number of selected cubes

See Also
selchildcount
ICOMMAND ( hmapselect  ,
""  ,
()  ,
int  t = lookupcube(cur).texture[orient];int i=htextures.find(t);if(i< 0) htextures.add(t);else htextures.remove(i); 
)
ICOMMAND ( getreptex  ,
""  ,
()  ,
{if(!noedit()) intret(vslots.inrange(reptex)?reptex:-1);}   
)
ICOMMAND ( replace  ,
""  ,
()  ,
replace(false)   
)
ICOMMAND ( replacesel  ,
""  ,
()  ,
replace(true)   
)
bool isheightmap ( int  orient,
int  d,
bool  empty,
cube c 
)
inline
void linkedpush ( cube c,
int  d,
int  x,
int  y,
int  dc,
int  dir 
)

References cubeedge, getcubevector(), loopi(), loopj, and pushedge().

Referenced by mpeditface().

prefab* loadprefab ( const char *  name,
bool  msg = true 
)
void makeundo ( selinfo s)

References addundo(), and newundocube().

Referenced by makeundo(), mpflip(), mprotate(), and hmap::select().

void makeundo ( )
uint mflip ( uint  face)

Referenced by rotatecube().

void mpcopy ( editinfo *&  e,
selinfo sel,
bool  local 
)
void mpdelcube ( selinfo sel,
bool  local 
)
void mpeditface ( int  dir,
int  mode,
selinfo sel,
bool  local 
)
void mpeditmat ( int  matid,
int  filter,
selinfo sel,
bool  local 
)
void mpedittex ( int  tex,
int  allfaces,
selinfo sel,
bool  local 
)
bool mpedittex ( int  tex,
int  allfaces,
selinfo sel,
ucharbuf buf 
)

References mpedittex(), and unpacktex().

void mpeditvslot ( int  delta,
VSlot ds,
int  allfaces,
selinfo sel,
bool  local 
)
bool mpeditvslot ( int  delta,
int  allfaces,
selinfo sel,
ucharbuf buf 
)
void mpflip ( selinfo sel,
bool  local 
)
void mppaste ( editinfo *&  e,
selinfo sel,
bool  local 
)
void mpreplacetex ( int  oldtex,
int  newtex,
bool  insel,
selinfo sel,
bool  local,
bool  update 
)
bool mpreplacetex ( int  oldtex,
int  newtex,
bool  insel,
selinfo sel,
ucharbuf buf 
)
void mprotate ( int  cw,
selinfo sel,
bool  local 
)
undoblock* newundocube ( selinfo s)
bool noedit ( bool  view,
bool  msg 
)
void normalizelookupcube ( const ivec o)

get the selected cube's position from the origin vector (0,0,0)

References gridsize, lu, and lusize.

Referenced by rendereditcursor().

template<class B >
static bool packblock ( block3 b,
B &  buf 
)
static
template<class B >
static void packcube ( cube c,
B &  buf 
)
static
bool packeditinfo ( editinfo e,
int &  inlen,
uchar *&  outbuf,
int &  outlen 
)
bool packundo ( undoblock u,
int &  inlen,
uchar *&  outbuf,
int &  outlen 
)
bool packundo ( int  op,
int &  inlen,
uchar *&  outbuf,
int &  outlen 
)
static void packvslots ( cube c,
vector< uchar > &  buf,
vector< ushort > &  used 
)
static
static void packvslots ( block3 b,
vector< uchar > &  buf 
)
static
void paste ( )

References localedit, mppaste(), noedit(), and sel.

void pasteblock ( block3 b,
selinfo sel,
bool  local 
)
static void pastecube ( const cube src,
cube dst 
)
inlinestatic
void pastehilite ( )
void pasteprefab ( char *  name)
void pasteundo ( undoblock u)
void pasteundoblock ( block3 b,
uchar g 
)
void previewprefab ( const char *  name,
const vec color 
)
void pruneundos ( int  maxremain)
void pushedge ( uchar edge,
int  dir,
int  dc 
)

References bounded(), edgeget, and edgeset.

Referenced by linkedpush().

void pushsel ( int *  dir)
float rayent ( const vec o,
const vec ray,
float  radius,
int  mode,
int  size,
int &  orient,
int &  ent 
)
void readychanges ( const ivec bbmin,
const ivec bbmax,
cube c,
const ivec cor,
int  size 
)
static VSlot* remapvslot ( int  index,
bool  delta,
const VSlot ds 
)
static
static void remapvslots ( cube c,
bool  delta,
const VSlot ds,
int  orient,
bool &  findrep,
VSlot *&  findedit 
)
static
void rendereditcursor ( )
void renderentselection ( const vec o,
const vec ray,
bool  entmoving 
)
static void renderprefab ( prefab p,
const vec o,
float  yaw,
float  pitch,
float  roll,
float  size,
const vec color 
)
static
void renderprefab ( const char *  name,
const vec o,
float  yaw,
float  pitch,
float  roll,
float  size,
const vec color 
)

References loadprefab(), and renderprefab().

void rendertexturepanel ( int  w,
int  h 
)
void reorient ( )

change the selection orientation according to the cursor's position

References C, selinfo::cx, selinfo::cxs, selinfo::cy, selinfo::cys, dimension, orient, selinfo::orient, R, selinfo::s, and sel.

Referenced by pastehilite(), and swapundo().

void replace ( bool  insel)
void replacetexcube ( cube c,
int  oldtex,
int  newtex 
)

References cube::children, loopi(), and cube::texture.

Referenced by mpreplacetex().

uint rflip ( uint  face)

Referenced by flipcube(), and rotatecube().

void rotate ( int *  cw)

References mprotate(), noedit(), and sel.

Referenced by renderentarrow(), and renderentcone().

void rotatecube ( cube c,
int  d 
)
void rotatequad ( cube a,
cube b,
cube c,
cube d 
)
void saveprefab ( char *  name)
void selextend ( )

extend the selection according to the cursor's position

References cur, selinfo::grid, loopi(), noedit(), selinfo::o, selinfo::s, and sel.

void selgridmap ( selinfo sel,
uchar g 
)

References bitscan(), selinfo::grid, loopxyz, and lusize.

Referenced by newundocube().

void setmat ( cube c,
ushort  mat,
ushort  matmask,
ushort  filtermat,
ushort  filtermask,
int  filtergeom 
)
int shouldpacktex ( int  index)
void showtexgui ( int *  n)

show texture

References inexor::util::log_manager::edit, editmode, and Log.

SVARP ( prefabdir  ,
"prefab"   
)
void swapundo ( undolist a,
undolist b,
int  op 
)
void tofronttex ( )
void toggleedit ( bool  force)
void tryedit ( )

check if editing can be done

Warning
please note that editing is not allowed when the HUD (head up dispaly) is disabled!

References blendpaintmode, editmode, mainmenu, and trypaintblendmap().

Referenced by main().

static bool uncompresseditinfo ( const uchar inbuf,
int  inlen,
uchar *&  outbuf,
int &  outlen 
)
static

Referenced by unpackeditinfo(), and unpackundo().

static int undosize ( undoblock u)
inlinestatic
template<class B >
static bool unpackblock ( block3 *&  b,
B &  buf 
)
static
template<class B >
static void unpackcube ( cube c,
B &  buf 
)
static
bool unpackeditinfo ( editinfo *&  e,
const uchar inbuf,
int  inlen,
int  outlen 
)
static int unpacktex ( int &  tex,
ucharbuf buf,
bool  insert = true 
)
static
bool unpackundo ( const uchar inbuf,
int  inlen,
int  outlen 
)
static void unpackvslots ( cube c,
ucharbuf buf 
)
static
static void unpackvslots ( block3 b,
ucharbuf buf 
)
static
void updateselection ( )

validate the coordinates of the selected face/volume make sure the selected grid is not outside of the map

See Also
sel

References cur, selinfo::grid, lastcur, inexor::rpc::min(), selinfo::o, selinfo::s, and sel.

Referenced by rendereditcursor().

void valpha ( float *  front,
float *  back 
)
VAR ( passthroughsel  ,
,
,
 
)

allow the editor to select new areas/volumes through the current selection otherwise select cubes ON the current selection

VAR ( editing  ,
,
,
 
)

represent the user's editing status (is he editing or not?)

VAR ( selectcorners  ,
,
,
 
)

when intruding (pushing towards the inside) a selected cube/face keep the corners rounded

VAR ( gridlookup  ,
,
,
 
)

automaticly select the grid size of the selected face

VAR ( passthroughcube  ,
,
,
 
)

ignore the first cube when view ray intersects it and select the second ("select through cubes")

VAR ( brushx  ,
,
MAXBRUSH2  ,
MAXBRUSH   
)
VAR ( brushy  ,
,
MAXBRUSH2  ,
MAXBRUSH   
)
VAR ( invalidcubeguard  ,
,
,
 
)
VAR ( selectionsurf  ,
,
,
 
)
VAR ( usevdelta  ,
,
,
 
)
VAR ( allfaces  ,
,
,
 
)
VARF ( dragging  ,
,
,
,
if(!dragging||cor[0]< 0) return;  lastcur = cur;lastcor=cor;sel.grid=gridsize;sel.orient=orient; 
)

dragging is enabled (1) once a grid start cube is selected once you select a cube the selection box will be drawn a little brighter

Warning
this has nothing to do with particles, pickups or entities!
VARF ( gridpower  ,
,
,
12  ,
{if(dragging) return;gridsize=1<< gridpower;if(gridsize >=worldsize) gridsize=worldsize/2;cancelsel();}   
)

will be called every time the gridpower (gridsize) changes

VARF ( hmapedit  ,
,
,
,
horient  = sel.orient 
)

start/stop heightmap editing

VARP ( undomegs  ,
,
,
100   
)
VARP ( nompedit  ,
,
,
 
)
VARP ( texguiwidth  ,
,
12  ,
1000   
)
VARP ( texguiheight  ,
,
,
1000   
)
VARP ( texguitime  ,
,
25  ,
1000   
)
VARP ( texgui2d  ,
,
,
 
)
void vcolor ( float *  r,
float *  g,
float *  b 
)
void vdelta ( char *  body)

References execute(), and noedit().

void vlayer ( int *  n)
void voffset ( int *  x,
int *  y 
)
void vreset ( )

References mpeditvslot(), noedit(), and sel.

void vrotate ( int *  n)
void vscale ( float *  scale)
void vscroll ( float *  s,
float *  t 
)
void vshaderparam ( const char *  name,
float *  x,
float *  y,
float *  z,
float *  w 
)

Variable Documentation

bool boxoutline = false

Referenced by boxs(), boxsgrid(), and rendereditcursor().

int brush[MAXBRUSH][MAXBRUSH]
int brushmaxx = 0

Referenced by brushvert(), clearbrush(), and hmap::run().

int brushmaxy = 0

Referenced by brushvert(), clearbrush(), and hmap::run().

int brushminx = MAXBRUSH

Referenced by brushvert(), clearbrush(), and hmap::run().

int brushminy = MAXBRUSH

Referenced by brushvert(), clearbrush(), and hmap::run().

ivec cor

Referenced by rendereditcursor().

ivec cur
int curtexindex = -1
vector<editinfo *> editinfos
vector<int *> editingvslots
static
const { ... } editmatfilters[]
Initial value:
=
{
{ "empty", EDITMATF_EMPTY },
{ "notempty", EDITMATF_NOTEMPTY },
{ "solid", EDITMATF_SOLID },
{ "notsolid", EDITMATF_NOTSOLID }
}
Definition: octaedit.cpp:2738
Definition: octaedit.cpp:2739
Definition: octaedit.cpp:2736
Definition: octaedit.cpp:2737

Referenced by editmat().

bool editmode = false
SharedVar<int> entediting
int entmoving

Referenced by entdrag(), entpush(), and rendereditcursor().

int gridsize = 8
bool haschanged = false
static

Referenced by changed(), and commitchanges().

bool havesel = false
bool hmapsel = false
int horient = 0

Referenced by rendereditcursor().

vector<int> htextures

Referenced by hmapcancel(), and isheightmap().

ivec lastcor

Referenced by rendereditcursor().

ivec lastcur

Referenced by updateselection().

selinfo lastsel
int lasttex = 0
int lasttexmillis = -1
int lastthumbnail = 0
static

Referenced by texturegui::gui().

editinfo* localedit = nullptr
SharedVar<int> menuautoclose

Referenced by g3d_mainmenu(), and texturegui::show().

SharedVar<int> menudistance

Referenced by menuinfrontofplayer().

int moving = 0

moving will be set to 1 as soon as you right-click a selected area/volume to move it once you release the key, moving(0) will be called

Warning
this has nothing to do with particles, pickups or entities!

Referenced by cubecancel(), editface(), pushsel(), and rendereditcursor().

int orient = 0
SharedVar<int> outline

Referenced by gl_drawframe(), and rendereditcursor().

SharedVar<int> outlinecolour

Referenced by renderoutline(), and renderprefab().

bool paintbrush = 0

Referenced by brushvert(), clearbrush(), and hmap::run().

hashnameset<prefab> prefabs
static
undolist redos
vector<vslotmap> remappedvslots
static
selinfo repsel

Referenced by mpedittex(), and mpeditvslot().

int reptex = -1
selinfo savedsel
selinfo sel
int selchildcount = 0

the amount of selected child cubes they will be displayed in the bottom left of you screen in coopedit mode

Referenced by countselchild(), gl_drawhud(), and rendereditcursor().

int selchildmat = -1
vector<ushort> texmru
int texpaneltimer = 0

Referenced by edittex_(), and rendertexturepanel().

int totalundos = 0

Referenced by addundo(), and pruneundos().

undolist undos
vector<vslotmap> unpackingvslots
static

Referenced by compacteditvslots(), and unpackvslots().