texture:: texture ghosts are now shown correctly

This commit is contained in:
Zeno Rogue 2019-01-03 15:12:45 +01:00
parent 34d4223bed
commit 7a589090d3
3 changed files with 39 additions and 34 deletions

View File

@ -3583,6 +3583,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
draw_qfi(c, V, 0xFFFFFFFF);
return;
}
if((cmode & sm::DRAW) && texture::config.tstate == texture::tsActive && !mouseout() && c)
mapeditor::draw_texture_ghosts(c, V);
#endif
bool orig = false;

View File

@ -1203,8 +1203,8 @@ namespace mapeditor {
enum eShapegroup { sgPlayer, sgMonster, sgItem, sgFloor };
static const int USERSHAPEGROUPS = 4;
bool haveUserShape(eShapegroup group, int id);
bool haveUserShape(eShapegroup group, int id);
void draw_texture_ghosts(cell *c, const transmatrix& V);
}
struct renderbuffer;

View File

@ -1680,6 +1680,40 @@ namespace mapeditor {
return usershapes[group].count(id) && usershapes[group][id];
#endif
}
void draw_texture_ghosts(cell *c, const transmatrix& V) {
if(!c) return;
if(holdmouse && !lstartcell) return;
cell *ls = lstartcell ? lstartcell : lmouseover;
if(!ls) return;
auto sio = patterns::getpatterninfo0(ls);
auto sih = patterns::getpatterninfo0(c);
if(sio.id == sih.id) {
if(c == ls)
textrans = inverse(V * applyPatterndir(ls, sio));
transmatrix mh = textrans * rgpushxto0(mouseh);
transmatrix ml = textrans * rgpushxto0(lstart);
for(int j=0; j<=texture::texturesym; j++)
for(int i=0; i<c->type; i += sih.symmetries) {
transmatrix M2 = V * applyPatterndir(c, sih) * spin(2*M_PI*i/c->type);
if(j) M2 = M2 * Mirror;
switch(holdmouse ? mousekey : 'd') {
case 'c':
queue_hcircle(M2 * ml, hdist(lstart, mouseh));
break;
case 'l':
queueline(M2 * mh * C0, M2 * ml * C0, texture::config.paint_color, 4 + vid.linequality, PPR::LINE);
break;
default:
queue_hcircle(M2 * mh, texture::penwidth);
}
}
}
}
bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio) {
#if !CAP_EDIT
@ -1704,38 +1738,6 @@ namespace mapeditor {
if(cmode & sm::DRAW) {
#if CAP_TEXTURE
if(texture::config.tstate == texture::tsActive && lmouseover && !mouseout() && (lstartcell || !holdmouse) && c) {
cell *ls = lstartcell ? lstartcell : lmouseover;
auto sio = patterns::getpatterninfo0(ls);
auto sih = patterns::getpatterninfo0(c);
if(sio.id == sih.id) {
if(c == ls)
textrans = inverse(V * applyPatterndir(ls, sio));
transmatrix mh = textrans * rgpushxto0(mouseh);
transmatrix ml = textrans * rgpushxto0(lstart);
for(int j=0; j<=texture::texturesym; j++)
for(int i=0; i<c->type; i += sih.symmetries) {
transmatrix M2 = V * applyPatterndir(c, sih) * spin(2*M_PI*i/c->type);
if(j) M2 = M2 * Mirror;
switch(holdmouse ? mousekey : 'd') {
case 'c':
queue_hcircle(M2 * ml, hdist(lstart, mouseh));
break;
case 'l':
queueline(M2 * mh * C0, M2 * ml * C0, texture::config.paint_color, 4 + vid.linequality, PPR::LINE);
break;
default:
queue_hcircle(M2 * mh, texture::penwidth);
}
}
}
}
#endif
if(mapeditor::editingShape(group, id)) {
/* for(int a=0; a<isize(ds.list); a++) {