mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
Fixed mapediting floorshapes. Also works nicely for all geometries now. Enum used for shapegroups.
This commit is contained in:
parent
e54da982d1
commit
ff84f63abd
@ -572,19 +572,21 @@ namespace gp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
qfloorinfo qfi;
|
qfloorinfo qfi;
|
||||||
qfloorinfo qfi_dc;
|
|
||||||
|
|
||||||
int chasmg;
|
int chasmg;
|
||||||
|
|
||||||
void set_no_floor() {
|
void set_no_floor() {
|
||||||
qfi.fshape = NULL;
|
qfi.fshape = NULL;
|
||||||
qfi.shape = NULL;
|
qfi.shape = NULL;
|
||||||
|
qfi.tinf = NULL;
|
||||||
|
qfi.usershape = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_floor(floorshape& sh) {
|
void set_floor(floorshape& sh) {
|
||||||
qfi.fshape = &sh;
|
qfi.fshape = &sh;
|
||||||
qfi.shape = NULL;
|
qfi.shape = NULL;
|
||||||
qfi.tinf = NULL;
|
qfi.tinf = NULL;
|
||||||
|
qfi.usershape = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_floor(hpcshape& sh) {
|
void set_floor(hpcshape& sh) {
|
||||||
@ -592,12 +594,14 @@ void set_floor(hpcshape& sh) {
|
|||||||
qfi.fshape = NULL;
|
qfi.fshape = NULL;
|
||||||
qfi.spin = Id;
|
qfi.spin = Id;
|
||||||
qfi.tinf = NULL;
|
qfi.tinf = NULL;
|
||||||
|
qfi.usershape = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_floor(const transmatrix& spin, hpcshape& sh) {
|
void set_floor(const transmatrix& spin, hpcshape& sh) {
|
||||||
qfi.shape = &sh;
|
qfi.shape = &sh;
|
||||||
qfi.fshape = NULL;
|
qfi.fshape = NULL;
|
||||||
qfi.spin = spin;
|
qfi.spin = spin;
|
||||||
|
qfi.usershape = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &shv, int col, int prio = -1) {
|
void draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &shv, int col, int prio = -1) {
|
||||||
@ -639,6 +643,9 @@ void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, int c
|
|||||||
void draw_qfi(cell *c, const transmatrix& V, int col, int prio = -1, vector<hpcshape> floorshape::* tab = &floorshape::b) {
|
void draw_qfi(cell *c, const transmatrix& V, int col, int prio = -1, vector<hpcshape> floorshape::* tab = &floorshape::b) {
|
||||||
if(qfi.shape)
|
if(qfi.shape)
|
||||||
queuepolyat(V * qfi.spin, *qfi.shape, col, prio);
|
queuepolyat(V * qfi.spin, *qfi.shape, col, prio);
|
||||||
|
else if(qfi.usershape >= 0) {
|
||||||
|
mapeditor::drawUserShape(V * qfi.spin, mapeditor::sgFloor, qfi.usershape, col, c);
|
||||||
|
}
|
||||||
else if(!qfi.fshape) ;
|
else if(!qfi.fshape) ;
|
||||||
#if CAP_TEXTURE
|
#if CAP_TEXTURE
|
||||||
else if(qfi.tinf) {
|
else if(qfi.tinf) {
|
||||||
|
56
graph.cpp
56
graph.cpp
@ -604,6 +604,9 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
|
|||||||
|
|
||||||
if(c && conformal::includeHistory && conformal::infindhistory.count(c)) poly_outline = OUTLINE_DEAD;
|
if(c && conformal::includeHistory && conformal::infindhistory.count(c)) poly_outline = OUTLINE_DEAD;
|
||||||
|
|
||||||
|
if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgItem)
|
||||||
|
mapeditor::drawtrans = V;
|
||||||
|
|
||||||
if(!mmitem && it) return true;
|
if(!mmitem && it) return true;
|
||||||
|
|
||||||
else if(it == itSavedPrincess) {
|
else if(it == itSavedPrincess) {
|
||||||
@ -659,7 +662,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
|
|||||||
xsh = NULL;
|
xsh = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(mapeditor::drawUserShape(V, 2, it, darkena(icol, 0, 0xFF), c)) ;
|
else if(mapeditor::drawUserShape(V, mapeditor::sgItem, it, darkena(icol, 0, 0xFF), c)) ;
|
||||||
|
|
||||||
else if(it == itRose) {
|
else if(it == itRose) {
|
||||||
for(int u=0; u<4; u++)
|
for(int u=0; u<4; u++)
|
||||||
@ -767,6 +770,9 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou
|
|||||||
else if(where && !(isMetalBeast(m) && where->stuntime == 1))
|
else if(where && !(isMetalBeast(m) && where->stuntime == 1))
|
||||||
drawStunStars(V, where->stuntime);
|
drawStunStars(V, where->stuntime);
|
||||||
|
|
||||||
|
if(where == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == (m == moPlayer ? mapeditor::sgPlayer : mapeditor::sgMonster))
|
||||||
|
mapeditor::drawtrans = V;
|
||||||
|
|
||||||
if(m == moTortoise) {
|
if(m == moTortoise) {
|
||||||
int bits = where ? tortoise::getb(where) : tortoise::last;
|
int bits = where ? tortoise::getb(where) : tortoise::last;
|
||||||
tortoise::draw(V, bits, 0, where ? where->stuntime : 0);
|
tortoise::draw(V, bits, 0, where ? where->stuntime : 0);
|
||||||
@ -778,9 +784,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou
|
|||||||
|
|
||||||
charstyle& cs = getcs();
|
charstyle& cs = getcs();
|
||||||
|
|
||||||
bool havus = mapeditor::drawUserShape(V, 0, cs.charid, cs.skincolor, where);
|
if(mapeditor::drawplayer && !mapeditor::drawUserShape(V, mapeditor::sgPlayer, cs.charid, cs.skincolor, where)) {
|
||||||
|
|
||||||
if(mapeditor::drawplayer && !havus) {
|
|
||||||
|
|
||||||
if(cs.charid >= 8) {
|
if(cs.charid >= 8) {
|
||||||
if(!mmspatial && !footphase)
|
if(!mmspatial && !footphase)
|
||||||
@ -906,12 +910,14 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(mapeditor::drawUserShape(V, 1, m, darkena(col, 0, 0xFF), where)) return false;
|
else if(mapeditor::drawUserShape(V, mapeditor::sgMonster, m, darkena(col, 0, 0xFF), where)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
else if(isMimic(m) || m == moShadow || m == moIllusion) {
|
else if(isMimic(m) || m == moShadow || m == moIllusion) {
|
||||||
charstyle& cs = getcs();
|
charstyle& cs = getcs();
|
||||||
|
|
||||||
if(mapeditor::drawUserShape(V, 0, (cs.charid&1)?1:0, darkena(col, 0, 0x80), where)) return false;
|
if(mapeditor::drawUserShape(V, mapeditor::sgPlayer, cs.charid, darkena(col, 0, 0x80), where)) return false;
|
||||||
|
|
||||||
if(cs.charid >= 8) {
|
if(cs.charid >= 8) {
|
||||||
queuepoly(VABODY, shWolfBody, darkena(col, 0, 0xC0));
|
queuepoly(VABODY, shWolfBody, darkena(col, 0, 0xC0));
|
||||||
@ -1870,7 +1876,13 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
|||||||
length = cellgfxdist(c, c->mondir);
|
length = cellgfxdist(c, c->mondir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mapeditor::drawUserShape(Vb, 1, c->monst, (col << 8) + 0xFF, c)) return false;
|
if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == 1)
|
||||||
|
mapeditor::drawtrans = Vb;
|
||||||
|
|
||||||
|
if(mapeditor::drawUserShape(Vb, mapeditor::sgMonster, c->monst, (col << 8) + 0xFF, c)) {
|
||||||
|
if(c == mapeditor::drawcell) mapeditor::drawtrans = Vb;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(isIvy(c) || isMutantIvy(c) || c->monst == moFriendlyIvy)
|
if(isIvy(c) || isMutantIvy(c) || c->monst == moFriendlyIvy)
|
||||||
queuepoly(Vb, shIBranch, (col << 8) + 0xFF);
|
queuepoly(Vb, shIBranch, (col << 8) + 0xFF);
|
||||||
@ -3117,6 +3129,8 @@ void floorShadow(cell *c, const transmatrix& V, int col) {
|
|||||||
if(qfi.shape) {
|
if(qfi.shape) {
|
||||||
queuepolyat(V * qfi.spin * shadowmulmatrix, *qfi.shape, col, PPR_WALLSHADOW);
|
queuepolyat(V * qfi.spin * shadowmulmatrix, *qfi.shape, col, PPR_WALLSHADOW);
|
||||||
}
|
}
|
||||||
|
else if(qfi.usershape >= 0)
|
||||||
|
mapeditor::drawUserShape(V * qfi.spin * shadowmulmatrix, mapeditor::sgFloor, qfi.usershape, col, c, PPR_WALLSHADOW);
|
||||||
else
|
else
|
||||||
draw_shapevec(c, V, qfi.fshape->shadow, col, PPR_WALLSHADOW);
|
draw_shapevec(c, V, qfi.fshape->shadow, col, PPR_WALLSHADOW);
|
||||||
}
|
}
|
||||||
@ -3173,7 +3187,7 @@ void escherSidewall(cell *c, int sidepar, const transmatrix& V, int col) {
|
|||||||
|
|
||||||
bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, int col) {
|
bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, int col) {
|
||||||
|
|
||||||
if(!qfi.fshape || !qfi.fshape->is_plain || !validsidepar[sidepar]) {
|
if(!qfi.fshape || !qfi.fshape->is_plain || !validsidepar[sidepar] || qfi.usershape >= 0) {
|
||||||
escherSidewall(c, sidepar, V, col);
|
escherSidewall(c, sidepar, V, col);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3743,6 +3757,11 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
|
|
||||||
int fd = getfd(c);
|
int fd = getfd(c);
|
||||||
|
|
||||||
|
int flooralpha = 255;
|
||||||
|
|
||||||
|
if((cmode & sm::DRAW) && mapeditor::drawcell && mapeditor::drawcellShapeGroup() == 3)
|
||||||
|
flooralpha = 0xC0;
|
||||||
|
|
||||||
if(c->wall == waMagma) fd = 0;
|
if(c->wall == waMagma) fd = 0;
|
||||||
|
|
||||||
poly_outline = OUTLINE_DEFAULT;
|
poly_outline = OUTLINE_DEFAULT;
|
||||||
@ -3766,6 +3785,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
poly_outline = OUTLINE_DEFAULT;
|
poly_outline = OUTLINE_DEFAULT;
|
||||||
|
|
||||||
if(!wmascii) {
|
if(!wmascii) {
|
||||||
|
int gc;
|
||||||
|
|
||||||
// floor
|
// floor
|
||||||
|
|
||||||
@ -3775,6 +3795,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
|
|
||||||
bool eoh = euclid || nonbitrunc;
|
bool eoh = euclid || nonbitrunc;
|
||||||
|
|
||||||
|
if(c == mapeditor::drawcell)
|
||||||
|
mapeditor::drawtrans = V * applyPatterndir(c, si);
|
||||||
|
|
||||||
if(c->wall == waChasm) {
|
if(c->wall == waChasm) {
|
||||||
zcol = 0;
|
zcol = 0;
|
||||||
int rd = rosedist(c);
|
int rd = rosedist(c);
|
||||||
@ -3790,8 +3813,10 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CAP_EDIT
|
#if CAP_EDIT
|
||||||
else if(mapeditor::drawUserShape(V * applyPatterndir(c, si), 3, si.id,
|
else if(mapeditor::haveUserShape(mapeditor::sgFloor, gc = si.id + patterns::subcode(c, si))) {
|
||||||
darkena(fcol, fd, (cmode & sm::DRAW) ? 0xC0 : 0xFF), c));
|
qfi.usershape = gc;
|
||||||
|
qfi.spin = applyPatterndir(c, si);
|
||||||
|
}
|
||||||
|
|
||||||
else if(patterns::whichShape == '7')
|
else if(patterns::whichShape == '7')
|
||||||
set_floor(shBigHepta);
|
set_floor(shBigHepta);
|
||||||
@ -4183,7 +4208,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
draw_qfi(c, (*Vdp), darkena(fcol, fd0, 0x80), PPR_LAKELEV);
|
draw_qfi(c, (*Vdp), darkena(fcol, fd0, 0x80), PPR_LAKELEV);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
draw_qfi(c, V, darkena(fcol, fd, 0xFF));
|
draw_qfi(c, V, darkena(fcol, fd, flooralpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
// walls
|
// walls
|
||||||
@ -4612,15 +4637,6 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAP_EDIT
|
|
||||||
if(c == mapeditor::drawcell) {
|
|
||||||
if(mapeditor::drawcellShapeGroup() == 2) {
|
|
||||||
mapeditor::drawtrans = V;
|
|
||||||
}
|
|
||||||
qfi_dc = qfi;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(it) {
|
if(it) {
|
||||||
if((c->land == laWhirlwind || c->item == itBabyTortoise) && c->wall != waBoat) {
|
if((c->land == laWhirlwind || c->item == itBabyTortoise) && c->wall != waBoat) {
|
||||||
double footphase = 0;
|
double footphase = 0;
|
||||||
|
9
hyper.h
9
hyper.h
@ -1095,6 +1095,13 @@ namespace mapeditor {
|
|||||||
void initdraw(cell *c);
|
void initdraw(cell *c);
|
||||||
void showMapEditor();
|
void showMapEditor();
|
||||||
void showDrawEditor();
|
void showDrawEditor();
|
||||||
|
|
||||||
|
enum eShapegroup { sgPlayer, sgMonster, sgItem, sgFloor };
|
||||||
|
static const int USERSHAPEGROUPS = 4;
|
||||||
|
|
||||||
|
bool drawUserShape(transmatrix V, eShapegroup group, int id, int color, cell *c, int priority = -1);
|
||||||
|
bool haveUserShape(eShapegroup group, int id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct renderbuffer;
|
struct renderbuffer;
|
||||||
@ -3538,10 +3545,10 @@ struct qfloorinfo {
|
|||||||
const hpcshape *shape;
|
const hpcshape *shape;
|
||||||
const floorshape *fshape;
|
const floorshape *fshape;
|
||||||
textureinfo *tinf;
|
textureinfo *tinf;
|
||||||
|
int usershape;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern qfloorinfo qfi;
|
extern qfloorinfo qfi;
|
||||||
extern qfloorinfo qfi_dc;
|
|
||||||
extern int chasmg;
|
extern int chasmg;
|
||||||
|
|
||||||
struct hpcshape {
|
struct hpcshape {
|
||||||
|
@ -172,13 +172,13 @@ namespace mapstream {
|
|||||||
int32_t id = cellids.count(cwt.at) ? cellids[cwt.at] : -1;
|
int32_t id = cellids.count(cwt.at) ? cellids[cwt.at] : -1;
|
||||||
save(id);
|
save(id);
|
||||||
|
|
||||||
for(int i=0; i<USERSHAPEGROUPS; i++) for(int j=0; j<USERSHAPEIDS; j++) {
|
for(int i=0; i<mapeditor::USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
|
||||||
usershape *us = usershapes[i][j];
|
usershape *us = usp.second;
|
||||||
if(!us) continue;
|
if(!us) continue;
|
||||||
|
|
||||||
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
|
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
|
||||||
usershapelayer& ds(us->d[l]);
|
usershapelayer& ds(us->d[l]);
|
||||||
save(i); save(j); save(l); save(ds.sym); save(ds.rots); save(ds.color);
|
save(i); save(usp.first); save(l); save(ds.sym); save(ds.rots); save(ds.color);
|
||||||
n = isize(ds.list); save(n);
|
n = isize(ds.list); save(n);
|
||||||
savePoint(ds.shift);
|
savePoint(ds.shift);
|
||||||
savePoint(ds.spin);
|
savePoint(ds.spin);
|
||||||
@ -335,8 +335,7 @@ namespace mapstream {
|
|||||||
int i = loadInt();
|
int i = loadInt();
|
||||||
if(i == -1) break;
|
if(i == -1) break;
|
||||||
int j = loadInt(), l = loadInt();
|
int j = loadInt(), l = loadInt();
|
||||||
if(i<0 || i >= USERSHAPEGROUPS) break;
|
if(i<0 || i >= mapeditor::USERSHAPEGROUPS) break;
|
||||||
if(j<0 || j >= USERSHAPEIDS) break;
|
|
||||||
if(l<0 || l >= USERLAYERS) break;
|
if(l<0 || l >= USERLAYERS) break;
|
||||||
|
|
||||||
initShape(i, j);
|
initShape(i, j);
|
||||||
@ -532,18 +531,19 @@ namespace mapeditor {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drawcellShapeGroup() {
|
eShapegroup drawcellShapeGroup() {
|
||||||
if(drawcell == cwt.at && drawplayer) return 0;
|
if(drawcell == cwt.at && drawplayer) return sgPlayer;
|
||||||
if(drawcell->monst) return 1;
|
if(drawcell->monst) return sgMonster;
|
||||||
if(drawcell->item) return 2;
|
if(drawcell->item) return sgItem;
|
||||||
return 3;
|
return sgFloor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drawcellShapeID() {
|
int drawcellShapeID() {
|
||||||
if(drawcell == cwt.at && drawplayer) return vid.cs.charid;
|
if(drawcell == cwt.at && drawplayer) return vid.cs.charid;
|
||||||
if(drawcell->monst) return drawcell->monst;
|
if(drawcell->monst) return drawcell->monst;
|
||||||
if(drawcell->item) return drawcell->item;
|
if(drawcell->item) return drawcell->item;
|
||||||
return patterns::getpatterninfo0(drawcell).id;
|
auto si = patterns::getpatterninfo0(drawcell);
|
||||||
|
return si.id + patterns::subcode(drawcell, si);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool editingShape(int group, int id) {
|
bool editingShape(int group, int id) {
|
||||||
@ -995,30 +995,26 @@ namespace mapeditor {
|
|||||||
sg = drawcellShapeGroup();
|
sg = drawcellShapeGroup();
|
||||||
|
|
||||||
switch(sg) {
|
switch(sg) {
|
||||||
case 0:
|
case sgPlayer:
|
||||||
line1 = XLAT("character");
|
line1 = XLAT("character");
|
||||||
line2 = csname(vid.cs);
|
line2 = csname(vid.cs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case sgMonster:
|
||||||
line1 = XLAT("monster");
|
line1 = XLAT("monster");
|
||||||
line2 = XLAT1(minf[drawcell->monst].name);
|
line2 = XLAT1(minf[drawcell->monst].name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case sgItem:
|
||||||
line1 = XLAT("item");
|
line1 = XLAT("item");
|
||||||
line2 = XLAT1(iinf[drawcell->item].name);
|
line2 = XLAT1(iinf[drawcell->item].name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case sgFloor:
|
||||||
line1 = XLAT("floor");
|
line1 = XLAT("floor");
|
||||||
line2 = XLAT(ishept(drawcell) ? "heptagonal" :
|
line2 = "#" + its(drawcellShapeID());
|
||||||
ishex1(drawcell) ? "hexagonal #1" : "hexagonal");
|
/* line2 = XLAT(ishept(drawcell) ? "heptagonal" :
|
||||||
break;
|
ishex1(drawcell) ? "hexagonal #1" : "hexagonal"); */
|
||||||
|
|
||||||
default:
|
|
||||||
line1 = XLAT("floor/pattern");
|
|
||||||
line2 = "#" + its(patterns::getpatterninfo0(drawcell).id);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1027,7 @@ namespace mapeditor {
|
|||||||
displayfr(8, 8+fs, 2, vid.fsize, line1, 0xC0C0C0, 0);
|
displayfr(8, 8+fs, 2, vid.fsize, line1, 0xC0C0C0, 0);
|
||||||
|
|
||||||
if(!intexture) {
|
if(!intexture) {
|
||||||
if(sg >= 3)
|
if(sg == sgFloor)
|
||||||
displayButton(8, 8+fs*2, line2 + XLAT(" (r = complex tesselations)"), 'r', 0);
|
displayButton(8, 8+fs*2, line2 + XLAT(" (r = complex tesselations)"), 'r', 0);
|
||||||
else
|
else
|
||||||
displayfr(8, 8+fs*2, 2, vid.fsize, line2, 0xC0C0C0, 0);
|
displayfr(8, 8+fs*2, 2, vid.fsize, line2, 0xC0C0C0, 0);
|
||||||
@ -1387,14 +1383,14 @@ namespace mapeditor {
|
|||||||
fprintf(f, "%x\n", VERNUM_HEX);
|
fprintf(f, "%x\n", VERNUM_HEX);
|
||||||
if(VERNUM_HEX >= 0xA0A0)
|
if(VERNUM_HEX >= 0xA0A0)
|
||||||
fprintf(f, "%d %d %d %d\n", geometry, nonbitrunc, patterns::whichPattern, patterns::subpattern_flags);
|
fprintf(f, "%d %d %d %d\n", geometry, nonbitrunc, patterns::whichPattern, patterns::subpattern_flags);
|
||||||
for(int i=0; i<USERSHAPEGROUPS; i++) for(int j=0; j<USERSHAPEIDS; j++) {
|
for(int i=0; i<USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
|
||||||
usershape *us = usershapes[i][j];
|
usershape *us = usp.second;
|
||||||
if(!us) continue;
|
if(!us) continue;
|
||||||
|
|
||||||
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
|
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
|
||||||
usershapelayer& ds(us->d[l]);
|
usershapelayer& ds(us->d[l]);
|
||||||
fprintf(f, "\n%d %d %d %d %d %6x %d\n",
|
fprintf(f, "\n%d %d %d %d %d %6x %d\n",
|
||||||
i, j, l, ds.sym, ds.rots, ds.color, int(isize(ds.list)));
|
i, usp.first, l, ds.sym, ds.rots, ds.color, int(isize(ds.list)));
|
||||||
writeHyperpoint(f, ds.shift);
|
writeHyperpoint(f, ds.shift);
|
||||||
writeHyperpoint(f, ds.spin);
|
writeHyperpoint(f, ds.spin);
|
||||||
fprintf(f,"\n");
|
fprintf(f,"\n");
|
||||||
@ -1552,10 +1548,7 @@ namespace mapeditor {
|
|||||||
else {
|
else {
|
||||||
dslayer %= USERLAYERS;
|
dslayer %= USERLAYERS;
|
||||||
|
|
||||||
int sg = drawcellShapeGroup();
|
applyToShape(drawcellShapeGroup(), drawcellShapeID(), uni, mh);
|
||||||
|
|
||||||
for(int i=0; i<USERSHAPEIDS; i++) if(editingShape(sg, i))
|
|
||||||
applyToShape(sg, i, uni, mh);
|
|
||||||
|
|
||||||
if(uni == 'e' || (uni == '-' && mousekey == 'e')) {
|
if(uni == 'e' || (uni == '-' && mousekey == 'e')) {
|
||||||
initdraw(mouseover ? mouseover : cwt.at);
|
initdraw(mouseover ? mouseover : cwt.at);
|
||||||
@ -1568,13 +1561,13 @@ namespace mapeditor {
|
|||||||
if(uni == 'b') autochoose = !autochoose;
|
if(uni == 'b') autochoose = !autochoose;
|
||||||
|
|
||||||
if(uni == 'S') {
|
if(uni == 'S') {
|
||||||
for(int i=0; i<USERSHAPEGROUPS; i++) for(int j=0; j<USERSHAPEIDS; j++) {
|
for(int i=0; i<USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
|
||||||
usershape *us = usershapes[i][j];
|
auto us = usp.second;
|
||||||
if(!us) continue;
|
if(!us) continue;
|
||||||
|
|
||||||
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
|
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
|
||||||
usershapelayer& ds(us->d[l]);
|
usershapelayer& ds(us->d[l]);
|
||||||
printf("// %d %d %d [%06X]\n", i, j, l, ds.color);
|
printf("// %d %d %d [%06X]\n", i, usp.first, l, ds.color);
|
||||||
printf(" ID, %d, %d, ", us->d[l].rots, us->d[l].sym?2:1);
|
printf(" ID, %d, %d, ", us->d[l].rots, us->d[l].sym?2:1);
|
||||||
for(int i=0; i<isize(us->d[l].list); i++)
|
for(int i=0; i<isize(us->d[l].list); i++)
|
||||||
printf("%lf,%lf, ", double(us->d[l].list[i][0]), double(us->d[l].list[i][1]));
|
printf("%lf,%lf, ", double(us->d[l].list[i][0]), double(us->d[l].list[i][1]));
|
||||||
@ -1603,9 +1596,11 @@ namespace mapeditor {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(sym == SDLK_F5) {
|
if(sym == SDLK_F5) {
|
||||||
for(int i=0; i<USERSHAPEGROUPS; i++)
|
for(int i=0; i<USERSHAPEGROUPS; i++) {
|
||||||
for(int j=0; j<USERSHAPEIDS; j++)
|
for(auto us: usershapes[i])
|
||||||
if(usershapes[i][j]) delete usershapes[i][j];
|
if(us.second) delete us.second;
|
||||||
|
usershapes[i].clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1656,12 +1651,18 @@ namespace mapeditor {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool drawUserShape(transmatrix V, int group, int id, int color, cell *c) {
|
bool haveUserShape(eShapegroup group, int id) {
|
||||||
#if !CAP_EDIT
|
#if !CAP_EDIT
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
|
return usershapes[group].count(id) && usershapes[group][id];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
id = id % USERSHAPEIDS;
|
bool drawUserShape(transmatrix V, eShapegroup group, int id, int color, cell *c, int priority) {
|
||||||
|
#if !CAP_EDIT
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
|
||||||
usershape *us = usershapes[group][id];
|
usershape *us = usershapes[group][id];
|
||||||
if(us) {
|
if(us) {
|
||||||
@ -1671,7 +1672,7 @@ namespace mapeditor {
|
|||||||
hpcshape& sh(ds.sh);
|
hpcshape& sh(ds.sh);
|
||||||
|
|
||||||
if(sh.s != sh.e)
|
if(sh.s != sh.e)
|
||||||
queuepoly(V, sh, ds.color ? ds.color : color);
|
queuepolyat(V, sh, ds.color ? ds.color : color, priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
pattern2.cpp
10
pattern2.cpp
@ -1882,6 +1882,16 @@ namespace patterns {
|
|||||||
pushScreen(showChangeablePatterns);
|
pushScreen(showChangeablePatterns);
|
||||||
computeCgroup();
|
computeCgroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int subcode(cell *c, const patterninfo& si) {
|
||||||
|
if(irr::on)
|
||||||
|
return irr::cellindex[c] << 8;
|
||||||
|
else if(archimedean)
|
||||||
|
return arcm::id_of(c->master) << 8;
|
||||||
|
else if(!gp::on) return 0;
|
||||||
|
else if(c == c->master->c7) return (fixdir(si.dir, c) << 8);
|
||||||
|
else return (get_code(gp::get_local_info(c)) << 16) | (fixdir(si.dir, c) << 8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_master(cell *c) {
|
bool is_master(cell *c) {
|
||||||
|
@ -1363,8 +1363,6 @@ hpcshape
|
|||||||
ld tentacle_length;
|
ld tentacle_length;
|
||||||
|
|
||||||
#define USERLAYERS 32
|
#define USERLAYERS 32
|
||||||
#define USERSHAPEGROUPS 4
|
|
||||||
#define USERSHAPEIDS 4096
|
|
||||||
|
|
||||||
struct usershapelayer {
|
struct usershapelayer {
|
||||||
vector<hyperpoint> list;
|
vector<hyperpoint> list;
|
||||||
@ -1379,7 +1377,7 @@ struct usershape {
|
|||||||
usershapelayer d[USERLAYERS];
|
usershapelayer d[USERLAYERS];
|
||||||
};
|
};
|
||||||
|
|
||||||
usershape *usershapes[USERSHAPEGROUPS][USERSHAPEIDS];
|
array<map<int, usershape*>, mapeditor::USERSHAPEGROUPS> usershapes;
|
||||||
|
|
||||||
transmatrix ddi(int a, ld x) { return xspinpush(a * M_PI / S42, x); }
|
transmatrix ddi(int a, ld x) { return xspinpush(a * M_PI / S42, x); }
|
||||||
|
|
||||||
@ -2433,8 +2431,8 @@ void buildpolys() {
|
|||||||
prehpc = isize(hpc);
|
prehpc = isize(hpc);
|
||||||
DEBB(DF_INIT, (debugfile,"hpc = %d\n", prehpc));
|
DEBB(DF_INIT, (debugfile,"hpc = %d\n", prehpc));
|
||||||
|
|
||||||
for(int i=0; i<USERSHAPEGROUPS; i++) for(int j=0; j<USERSHAPEIDS; j++) {
|
for(int i=0; i<mapeditor::USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
|
||||||
usershape *us = usershapes[i][j];
|
auto us = usp.second;
|
||||||
if(!us) continue;
|
if(!us) continue;
|
||||||
for(int l=0; l<USERLAYERS; l++) {
|
for(int l=0; l<USERLAYERS; l++) {
|
||||||
bshape(us->d[l].sh, us->d[l].sh.prio);
|
bshape(us->d[l].sh, us->d[l].sh.prio);
|
||||||
|
18
textures.cpp
18
textures.cpp
@ -284,16 +284,6 @@ int getTriangleID(cell *c, patterns::patterninfo& si, hyperpoint h) {
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
int goldbergcode(cell *c, const patterns::patterninfo& si) {
|
|
||||||
if(irr::on)
|
|
||||||
return irr::cellindex[c] << 8;
|
|
||||||
else if(archimedean)
|
|
||||||
return arcm::id_of(c->master) << 8;
|
|
||||||
else if(!gp::on) return 0;
|
|
||||||
else if(c == c->master->c7) return (fixdir(si.dir, c) << 8);
|
|
||||||
else return (get_code(gp::get_local_info(c)) << 16) | (fixdir(si.dir, c) << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mapTexture(cell *c, textureinfo& mi, patterns::patterninfo &si, const transmatrix& T, int shift = 0) {
|
void mapTexture(cell *c, textureinfo& mi, patterns::patterninfo &si, const transmatrix& T, int shift = 0) {
|
||||||
mi.c = c;
|
mi.c = c;
|
||||||
mi.symmetries = si.symmetries;
|
mi.symmetries = si.symmetries;
|
||||||
@ -347,7 +337,7 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
auto& mi = texture_map.at(si.id + goldbergcode(c, si));
|
auto& mi = texture_map.at(si.id + patterns::subcode(c, si));
|
||||||
|
|
||||||
set_floor(shFullFloor);
|
set_floor(shFullFloor);
|
||||||
qfi.tinf = &mi;
|
qfi.tinf = &mi;
|
||||||
@ -382,7 +372,7 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(out_of_range&) {
|
catch(out_of_range&) {
|
||||||
// printf("Ignoring tile #%d / %08x: not mapped\n", si.id, goldbergcode(c, si));
|
// printf("Ignoring tile #%d / %08x: not mapped\n", si.id, patterns::subcode(c, si));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,7 +415,7 @@ void texture_config::perform_mapping() {
|
|||||||
|
|
||||||
// int sgn = sphere ? -1 : 1;
|
// int sgn = sphere ? -1 : 1;
|
||||||
|
|
||||||
si.id += goldbergcode(c, si);
|
si.id += patterns::subcode(c, si);
|
||||||
|
|
||||||
if(!texture_map.count(si.id))
|
if(!texture_map.count(si.id))
|
||||||
replace = true;
|
replace = true;
|
||||||
@ -1458,7 +1448,7 @@ void texture_config::true_remap() {
|
|||||||
auto si = patterns::getpatterninfo0(c);
|
auto si = patterns::getpatterninfo0(c);
|
||||||
int oldid = si.id;
|
int oldid = si.id;
|
||||||
|
|
||||||
si.id += goldbergcode(c, si);
|
si.id += patterns::subcode(c, si);
|
||||||
|
|
||||||
if(texture_map.count(si.id)) continue;
|
if(texture_map.count(si.id)) continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user