CAP_POLY part 1

This commit is contained in:
? 2019-02-17 18:41:40 +01:00 committed by Zeno Rogue
parent 31037574f5
commit 99aa7e420b
10 changed files with 201 additions and 104 deletions

View File

@ -953,7 +953,7 @@ color_t gradient(color_t c0, color_t c1, ld v0, ld v, ld v1) {
void drawCircle(int x, int y, int size, color_t color, color_t fillcolor) {
if(size < 0) size = -size;
#if CAP_GL
#if CAP_GL && CAP_POLY
if(vid.usingGL) {
glflush();
glhr::be_nontextured();

View File

@ -214,8 +214,13 @@ void drawArrowTraps() {
try {
transmatrix& t0 = gmatrix.at(r[0]);
transmatrix& t1 = gmatrix.at(r[4]);
ignore(t0);
ignore(t1);
#if CAP_QUEUE
queueline(tC0(t0), tC0(t1), 0xFF0000FF, 4 + vid.linequality, PPR::ITEM);
#endif
#if CAP_POLY
if((c->wparam & 7) == 3 && !shmup::on) {
// queueline(t0 * randomPointIn(r[0]->type), t1 * randomPointIn(r[1]->type), 0xFFFFFFFF, 4, PPR::ITEM);
int tt = int(fractick(64) * 401);
@ -228,6 +233,7 @@ void drawArrowTraps() {
queuepoly(tpartial * ypush(.05), shTrapArrow, 0xFFFFFFFF);
}
}
#endif
}
catch(out_of_range&) {}
}

View File

@ -644,6 +644,7 @@ namespace conformal {
"the point z is mapped to f(z). You can also use the underlying coordinates ux, uy, uz."
) + "\n\n" + parser_help()
);
#if CAP_POLY
dialog::extra_options = [] () {
initquickqueue();
queuereset(mdUnchanged, PPR::LINE);
@ -658,6 +659,7 @@ namespace conformal {
queuereset(pmodel, PPR::LINE);
quickqueue();
};
#endif
dialog::reaction_final = [] () {
pmodel = mdFormula;
};

View File

@ -1,5 +1,5 @@
namespace hr {
#if CAP_POLY
vector<plain_floorshape*> all_plain_floorshapes;
vector<escher_floorshape*> all_escher_floorshapes;

115
graph.cpp
View File

@ -337,8 +337,10 @@ void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
else {
int& ang = angle[multi::cpid];
ang %= S42;
#if CAP_QUEUE || CAP_POLY
transmatrix Vnow = gmatrix[c] * rgpushxto0(inverse(gmatrix[c]) * tC0(V)) * ddspin(c,0,M_PI); // (IRREGULAR ? ddspin(c,0,M_PI) : spin(-hexshiftat(c)));
#endif
#if CAP_QUEUE
if(!euclid) for(int a=0; a<S42; a++) {
@ -620,10 +622,10 @@ bool drawing_usershape_on(cell *c, mapeditor::eShapegroup sg) {
}
bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int pticks, bool hidden) {
char xch = iinf[it].glyph;
#if !CAP_POLY
return it;
#else
char xch = iinf[it].glyph;
auto sinptick = [c, pticks] (int period) { return c ? sintick(period) : sin(animation_factor * pticks / period);};
auto spinptick = [c, pticks] (int period, ld phase=0) { return c ? spintick(period, phase) : spin((animation_factor * pticks + phase) / period); };
int ct6 = c ? ctof(c) : 1;
@ -822,9 +824,9 @@ void drawTerraWarrior(const transmatrix& V, int t, int hp, double footphase) {
bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase) {
#if CAP_POLY
char xch = minf[m].glyph;
#if CAP_POLY
if(m == moTortoise && where && where->stuntime >= 3)
drawStunStars(V, where->stuntime-2);
else if (m == moTortoise || m == moPlayer || (where && !where->stuntime)) ;
@ -1915,6 +1917,7 @@ void drawWormSegments() {
bool dont_face_pc = false;
bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) {
#if CAP_POLY
bool darkhistory = conformal::includeHistory && conformal::inkillhistory.count(c);
@ -2271,6 +2274,9 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) {
}
return false;
#else
return false;
#endif
}
double downspin;
@ -2530,6 +2536,7 @@ transmatrix applyDowndir(cell *c, const cellfunction& cf) {
return ddspin(c, patterns::downdir(c, cf), M_PI);
}
#if CAP_POLY
void set_towerfloor(cell *c, const cellfunction& cf = coastvalEdge) {
if(weirdhyperbolic || sphere) {
set_floor(shFloor);
@ -2719,6 +2726,7 @@ void drawMovementArrows(cell *c, transmatrix V) {
}
}
}
#endif
int celldistAltPlus(cell *c) { return 1000000 + celldistAlt(c); }
@ -3325,6 +3333,7 @@ bool use_swapped_duals() {
return (masterless && !a4) || GOLDBERG;
}
#if CAP_POLY
void floorShadow(cell *c, const transmatrix& V, color_t col) {
if(pmodel == mdHyperboloid || pmodel == mdBall || pmodel == mdHemisphere || noshadow)
return; // shadows break the depth testing
@ -3421,6 +3430,7 @@ bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, color_t co
queuepolyat(V2, qfi.fshape->side[sidepar][pseudohept(c)], col, prio);
return false;
}
#endif
bool openorsafe(cell *c) {
return c->wall == waMineOpen || mineMarkedSafe(c);
@ -3450,6 +3460,7 @@ int gridcolor(cell *c1, cell *c2) {
return Dark(0x202020);
}
#if CAP_POLY
void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, bool repriority) {
// since we might be changing priorities, we have to make sure that we are sorting correctly
@ -3495,6 +3506,7 @@ void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, b
ptd.prio = PPR::LAKEWALL_FALLANIM;
}
}
#endif
// 1 : (floor, water); 2 : (water, bottom); 4 : (bottom, inf)
@ -3599,6 +3611,7 @@ int getSnakelevColor(cell *c, int i, int last, int fd, color_t wcol) {
return darkena(col, fd, 0xFF);
}
#if CAP_POLY
void draw_wall(cell *c, const transmatrix& V, color_t wcol, color_t& zcol, int ct6, int fd) {
zcol = wcol;
color_t wcol0 = wcol;
@ -3668,6 +3681,7 @@ void draw_wall(cell *c, const transmatrix& V, color_t wcol, color_t& zcol, int c
}
}
}
#endif
bool just_gmatrix;
@ -3675,6 +3689,7 @@ int colorhash(color_t i) {
return (i * 0x471211 + i*i*0x124159 + i*i*i*0x982165) & 0xFFFFFF;
}
#if CAP_POLY
void draw_gravity_particles(cell *c, const transmatrix V) {
int u = (int)(size_t)(c);
u = ((u * 137) + (u % 1000) * 51) % 1000;
@ -3743,7 +3758,7 @@ void draw_gravity_particles(cell *c, const transmatrix V) {
}
}
}
#endif
void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
@ -3773,7 +3788,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
if(just_gmatrix) return;
#if CAP_POLY
set_floor(shFloor);
#endif
ivoryz = isGravityLand(c->land);
// if(behindsphere(V)) return;
@ -3796,7 +3813,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
buildAutomatonRule(c);
#endif
#if CAP_POLY
viewBuggyCells(c,V);
#endif
if(conformal::on || inHighQual || sightrange_bonus > gamerange_bonus) checkTide(c);
@ -4021,7 +4040,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
int ctype = c->type;
#if CAP_POLY
int ct6 = ctof(c);
#endif
bool error = false;
@ -4029,7 +4050,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
int fd = getfd(c);
#if CAP_POLY
int flooralpha = 255;
#endif
#if CAP_EDIT && CAP_TEXTURE
if((cmode & sm::DRAW) && mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgFloor && texture::config.tstate != texture::tsActive)
@ -4042,7 +4065,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
int sl = snakelevel(c);
transmatrix Vd0, Vf0, Vboat0;
transmatrix Vd0, Vboat0;
const transmatrix *Vdp =
(!wmspatial) ? &V :
sl ? &(Vd0= mscale(V, geom3::SLEV[sl])) :
@ -4050,18 +4073,17 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
(chasmg==1) ? &(Vd0 = mscale(V, geom3::LAKE)) :
&V;
#if CAP_POLY
transmatrix Vf0;
const transmatrix& Vf = (chasmg && wmspatial) ? (Vf0=mscale(V, geom3::BOTTOM)) : V;
#endif
const transmatrix *Vboat = &(*Vdp);
shmup::drawMonster(V, c, Vboat, Vboat0, Vdp);
poly_outline = OUTLINE_DEFAULT;
if(!wmascii) {
// floor
bool eoh = euclid || !BITRUNCATED;
if(!wmascii) {
#if CAP_EDIT
auto si = patterns::getpatterninfo0(c);
@ -4069,6 +4091,10 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
mapeditor::drawtrans = V * applyPatterndir(c, si);
#endif
#if CAP_POLY
// floor
bool eoh = euclid || !BITRUNCATED;
if(c->wall == waChasm) {
zcol = 0;
int rd = rosedist(c);
@ -4823,6 +4849,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
error = true;
}
}
#else
error = true;
#endif
}
else {
@ -4844,6 +4873,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(!(it || c->monst || c->cpdist == 0)) error = true;
}
#if CAP_POLY
int sha = shallow(c);
if(wmspatial && sha) {
@ -4880,22 +4910,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
placeSidewall(c, i, SIDE_BTOI, V, 0x101010FF);
}
}
if(false) if(chasmg == 2 && wmspatial && sphere) {
forCellIdEx(c2, i, c) if(chasmgraph(c2) == 0) {
transmatrix V2 = V * cellrelmatrix(c, i);
// if(!behindsphere(V2)) continue;
color_t wcol2, fcol2;
setcolors(c2, wcol2, fcol2);
color_t col = (highwall(c2) || c->wall == waTower) ? wcol2 : fcol2;
col = gradient(0, col, 0, spherity(V), 1);
int j = c->c.spin(i);
placeSidewall(c2, j, SIDE_LAKE, V2, darkena(gradient(0, col, 0, .8, 1), fd, 0xFF));
placeSidewall(c2, j, SIDE_LTOB, V2, darkena(gradient(0, col, 0, .7, 1), fd, 0xFF));
placeSidewall(c2, j, SIDE_BTOI, V2, darkena(gradient(0, col, 0, .6, 1), fd, 0xFF));
}
}
if(chasmg) {
int q = isize(ptds);
int maxtime = euclid || sphere ? 20000 : 1500;
@ -4939,6 +4954,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(erase) fallanims.erase(c);
}
}
#endif
if(it) {
if((c->land == laWhirlwind || c->item == itBabyTortoise || c->land == laWestWall) && c->wall != waBoat) {
@ -4998,6 +5014,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
}
#if CAP_POLY
if(c->land == laBlizzard) {
if(vid.backeffects) {
if(c->cpdist <= getDistLimit())
@ -5041,7 +5058,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
}
#endif
#if CAP_QUEUE
if(error) {
queuechr(V, 1, ch, darkenedby(asciicol, darken), 2);
}
@ -5232,14 +5251,17 @@ void fallingMonsterAnimation(cell *c, eMonster m, int id) {
// drawParticles(c, darkenedby(linf[c->land].color, 1), 4, 50);
}
#if CAP_QUEUE
void queuecircleat(cell *c, double rad, color_t col) {
if(!c) return;
if(!gmatrix.count(c)) return;
#if CAP_POLY
if(vid.stereo_mode || sphere) {
dynamicval<color_t> p(poly_outline, col);
queuepolyat(gmatrix[c] * spintick(100), shGem[1], 0, PPR::LINE);
return;
}
#endif
queuecircle(gmatrix[c], rad, col);
if(!wmspatial) return;
if(highwall(c))
@ -5251,6 +5273,7 @@ void queuecircleat(cell *c, double rad, color_t col) {
if(chasmgraph(c))
queuecircle(mscale(gmatrix[c], geom3::LAKE), rad, col);
}
#endif
#define G(x) x && gmatrix.count(x)
#define IG(x) if(G(x))
@ -5268,19 +5291,27 @@ void drawMarkers() {
if(!(cmode & sm::NORMAL)) return;
callhooks(hooks_markers);
#if CAP_POLY
viewmat();
#endif
#if CAP_QUEUE
for(cell *c1: crush_now)
queuecircleat(c1, .8, darkena(minf[moCrusher].color, 0, 0xFF));
#endif
if(!inHighQual) {
bool ok = !ISPANDORA || mousepressed;
ignore(ok);
#if CAP_QUEUE
if(G(dragon::target) && haveMount()) {
queuechr(Gm0(dragon::target), 2*vid.fsize, 'X',
gradient(0, iinf[itOrbDomination].color, -1, sintick(dragon::whichturn == turncount ? 75 : 150), 1));
}
#endif
/* for(int i=0; i<12; i++) if(c->type == 5 && c->master == &dodecahedron[i])
queuechr(xc, yc, sc, 4*vid.fsize, 'A'+i, iinf[itOrbDomination].color); */
@ -5302,8 +5333,10 @@ void drawMarkers() {
keycell = c;
}
hyperpoint H = tC0(ggmatrix(keycell));
#if CAP_QUEUE
queuechr(H, 2*vid.fsize, 'X', 0x10101 * int(128 + 100 * sintick(150)));
queuestr(H, vid.fsize, its(celldistance(cwt.at, yi[yii].key())), 0x10101 * int(128 - 100 * sintick(150)));
#endif
addauraspecial(H, iinf[itOrbYendor].color, 0);
}
}
@ -5312,7 +5345,8 @@ void drawMarkers() {
#if CAP_RACING
racing::markers();
#endif
#if CAP_QUEUE
if(lmouseover && vid.drawmousecircle && ok && DEFAULTCONTROL && MOBON) {
queuecircleat(lmouseover, .8, darkena(lmouseover->cpdist > 1 ? 0x00FFFF : 0xFF0000, 0, 0xFF));
}
@ -5320,17 +5354,21 @@ void drawMarkers() {
if(global_pushto && vid.drawmousecircle && ok && DEFAULTCONTROL && MOBON) {
queuecircleat(global_pushto, .6, darkena(0xFFD500, 0, 0xFF));
}
#endif
#if CAP_SDLJOY
#if CAP_SDLJOY && CAP_QUEUE
if(joydir.d >= 0)
queuecircleat(cwt.at->modmove(joydir.d+cwt.spin), .78 - .02 * sintick(199),
darkena(0x00FF00, 0, 0xFF));
#endif
bool m = true;
ignore(m);
#if CAP_MODEL
m = netgen::mode == 0;
#endif
#if CAP_QUEUE
if(centerover.at && !playermoved && m && !anims::any_animation())
queuecircleat(centerover.at, .70 - .06 * sintick(200),
darkena(int(175 + 25 * sintick(200)), 0, 0xFF));
@ -5341,9 +5379,10 @@ void drawMarkers() {
cell *ctgt = multi::multiPlayerTarget(i);
queuecircleat(ctgt, .40 - .06 * sintick(200, i / numplayers()), getcs().uicolor);
}
#endif
// process mouse
#if CAP_POLY
if((vid.axes == 4 || (vid.axes == 1 && !mousing)) && !shmup::on) {
if(multi::players == 1) {
forCellIdAll(c2, d, cwt.at) IG(c2) drawMovementArrows(c2, confusingGeometry() ? Gm(cwt.at) * calc_relative_matrix(c2, cwt.at, d) : Gm(c2));
@ -5358,6 +5397,7 @@ void drawMarkers() {
}
}
}
#endif
}
monsterToSummon = moNone;
@ -5366,6 +5406,7 @@ void drawMarkers() {
if(mouseover && targetclick) {
shmup::cpid = 0;
orbToTarget = targetRangedOrb(mouseover, roCheck);
#if CAP_QUEUE
if(orbToTarget == itOrbSummon) {
monsterToSummon = summonedAt(mouseover);
queuechr(mousex, mousey, 0, vid.fsize, minf[monsterToSummon].glyph, minf[monsterToSummon].color);
@ -5375,6 +5416,8 @@ void drawMarkers() {
queuechr(mousex, mousey, 0, vid.fsize, '@', iinf[orbToTarget].color);
queuecircleat(mouseover, 0.6, darkena(iinf[orbToTarget].color, 0, 0xFF));
}
#endif
#if CAP_POLY
if(orbToTarget && rand() % 200 < ticks - lastt) {
if(orbToTarget == itOrbDragon)
drawFireParticles(mouseover, 2);
@ -5400,10 +5443,12 @@ void drawMarkers() {
c1 = c2;
}
}
#endif
}
}
void drawFlashes() {
#if CAP_QUEUE && CAP_POLY
for(int k=0; k<isize(flashes); k++) {
flashdata& f = flashes[k];
transmatrix V;
@ -5460,6 +5505,7 @@ void drawFlashes() {
flashes.pop_back(); k--;
}
}
#endif
}
bool allowIncreasedSight() {
@ -5714,13 +5760,17 @@ void drawmovestar(double dx, double dy) {
if(rax == 0 || vid.axes == 4) return;
int starcol = getcs().uicolor;
ignore(starcol);
if(0);
#if CAP_POLY
if(vid.axes == 3)
else if(vid.axes == 3)
queuepoly(Centered, shMovestar, starcol);
#endif
else for(int d=0; d<8; d++) {
#if CAP_QUEUE
color_t col = starcol;
#if ISPANDORA
if(leftclick && (d == 2 || d == 6 || d == 1 || d == 7)) col &= 0xFFFFFF3F;
@ -5729,7 +5779,6 @@ void drawmovestar(double dx, double dy) {
#endif
// EUCLIDEAN
#if CAP_QUEUE
queueline(tC0(Centered), Centered * xspinpush0(d * M_PI / 4, euclid ? 0.5 : d==0?.7:d==2?.5:.2), col, 3 + vid.linequality);
#endif
}
@ -5817,10 +5866,12 @@ void drawfullmap() {
}
*/
#if CAP_POLY && CAP_QUEUE
draw_boundary(0);
draw_boundary(1);
draw_model_elements();
#endif
/* if(vid.wallmode < 2 && !euclid && !patterns::whichShape) {
int ls = isize(lines);
@ -5850,7 +5901,9 @@ void drawfullmap() {
profile_start(2);
drawaura();
#if CAP_QUEUE
drawqueue();
#endif
profile_stop(2);
}

View File

@ -301,6 +301,7 @@ bool nohud, nomenukey;
hookset<bool()> *hooks_prestats;
#if CAP_POLY
void drawMobileArrow(int i) {
int dir = i;
@ -340,6 +341,7 @@ void drawMobileArrow(int i) {
queuepolyat(atscreenpos(dx, dy, scale) * spin(-alpha), shArrow, col, PPR::MOBILE_ARROW);
}
#endif
bool nofps = false;
@ -364,11 +366,15 @@ void drawStats() {
initquickqueue();
using namespace shmupballs;
calc();
#if CAP_QUEUE
queuecircle(xmove, yb, rad, 0xFF0000FF);
queuecircle(xmove, yb, rad*SKIPFAC,
legalmoves[MAX_EDGE] ? 0xFF0000FF : 0xFF000080
);
#endif
#if CAP_POLY
for(int i=0; i<cwt.at->type; i++) drawMobileArrow(i);
#endif
if(hypot(mousex-xmove, mousey-yb) <= rad) getcstat = '-';
quickqueue();
}

View File

@ -22,8 +22,6 @@ void camrotate(ld& hx, ld& hy) {
hyperpoint perspective_to_space(hyperpoint h, ld alpha = vid.alpha, eGeometryClass geo = ginf[geometry].cclass);
hyperpoint dhp(ld x, ld y, ld z) { return hpxyz(x, y, z); }
bool non_spatial_model() {
if(among(pmodel, mdRotatedHyperboles, mdJoukowsky, mdJoukowskyInverted, mdPolygonal, mdPolynomial))
return true;
@ -1217,6 +1215,7 @@ transmatrix atscreenpos(ld x, ld y, ld size) {
}
void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) {
#if CAP_QUEUE
if(among(pmodel, mdDisk, mdEquiarea, mdEquidistant, mdFisheye) && !(pmodel == mdDisk && hyperbolic && vid.alpha <= -1) && vid.camera_angle == 0) {
hyperpoint ret;
applymodel(xpush0(radius), ret);
@ -1224,6 +1223,8 @@ void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio)
queuecircle(current_display->xcenter, current_display->ycenter, r * current_display->radius, linecol, prio, fillcol);
return;
}
#endif
#if CAP_POLY && CAP_QUEUE
for(int i=0; i<=360; i++) curvepoint(xspinpush0(i * degree, 10));
auto& c = queuecurve(linecol, fillcol, prio);
if(pmodel == mdDisk && hyperbolic && vid.alpha <= -1)
@ -1231,12 +1232,14 @@ void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio)
if(pmodel == mdJoukowsky)
c.flags |= POLY_FORCE_INVERTED;
c.flags |= POLY_ALWAYS_IN;
#endif
}
color_t periodcolor = 0x00FF0080;
color_t ringcolor = darkena(0xFF, 0, 0xFF);
color_t modelcolor = 0;
#if CAP_QUEUE && CAP_POLY
void draw_model_elements() {
switch(pmodel) {
@ -1529,6 +1532,7 @@ void draw_boundary(int w) {
if(sphere && !among(pmodel, mdEquidistant, mdEquiarea)) return;
circle_around_center(fakeinf, lc, fc, p);
}
#endif
ld band_shift = 0;
void fix_the_band(transmatrix& T) {

View File

@ -186,6 +186,7 @@ namespace mapstream {
int32_t id = cellids.count(cwt.at) ? cellids[cwt.at] : -1;
f.write(id);
#if CAP_POLY
for(int i=0; i<mapeditor::USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
usershape *us = usp.second;
if(!us) continue;
@ -199,6 +200,7 @@ namespace mapstream {
for(int i=0; i<isize(ds.list); i++) f.write(ds.list[i]);
}
}
#endif
n = -1; f.write(n);
f.write(mutantphase);
@ -409,6 +411,7 @@ namespace mapstream {
if(vernum >= 7400) while(true) {
int i = f.get<int>();
if(i == -1) break;
#if CAP_POLY
int j = f.get<int>(), l = f.get<int>();
if(i >= 4) i = 3;
if(i<0 || i >= mapeditor::USERSHAPEGROUPS) break;
@ -426,6 +429,9 @@ namespace mapstream {
for(int i=0; i<siz; i++)
ds.list.push_back(f.get<hyperpoint>());
#else
printf("cannot read shapes\n"); exit(1);
#endif
}
if(vernum >= 11005) {
@ -994,6 +1000,7 @@ namespace mapeditor {
transmatrix drawtrans, drawtransnew;
#if CAP_POLY
void loadShape(int sg, int id, hpcshape& sh, int d, int layer) {
usershapelayer *dsCur = &usershapes[sg][id]->d[layer];
dsCur->list.clear();
@ -1001,6 +1008,7 @@ namespace mapeditor {
for(int i=sh.s; i < sh.s + (sh.e-sh.s)/d; i++)
dsCur->list.push_back(hpc[i]);
}
#endif
void drawGhosts(cell *c, const transmatrix& V, int ct) {
}
@ -1084,6 +1092,7 @@ namespace mapeditor {
}
void showDrawEditor() {
#if CAP_POLY
cmode = sm::DRAW;
gamescreen(0);
drawGrid();
@ -1238,10 +1247,14 @@ namespace mapeditor {
displayFunctionKeys();
keyhandler = drawHandleKey;
#else
popScreen();
#endif
}
bool rebuildPolys = false;
#if CAP_POLY
void loadShapes(int sg, int id) {
delete usershapes[sg][id];
usershapes[sg][id] = NULL;
@ -1298,7 +1311,7 @@ namespace mapeditor {
}
rebuildPolys = true;
}
void applyToShape(int sg, int id, int uni, hyperpoint mh) {
bool haveshape = usershapes[sg][id];
bool xnew = false;
@ -1728,6 +1741,7 @@ namespace mapeditor {
if(rebuildPolys)
buildpolys(), rebuildPolys = false;
}
#endif
auto hooks = addHook(clearmemory, 0, [] () {
if(mapeditor::painttype == 4)
@ -1772,6 +1786,7 @@ namespace mapeditor {
}
#endif
#if CAP_POLY
bool haveUserShape(eShapegroup group, int id) {
#if !CAP_EDIT
return false;
@ -1779,7 +1794,9 @@ namespace mapeditor {
return usershapes[group].count(id) && usershapes[group][id];
#endif
}
#endif
#if CAP_TEXTURE
void draw_texture_ghosts(cell *c, const transmatrix& V) {
if(!c) return;
if(holdmouse && !lstartcell) return;
@ -1812,10 +1829,11 @@ namespace mapeditor {
queue_hcircle(M2 * mh, texture::penwidth);
}
}
#endif
}
}
#endif
#if CAP_POLY
bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio) {
#if !CAP_EDIT
return false;
@ -1938,6 +1956,7 @@ namespace mapeditor {
return us;
#endif
}
#endif
void map_settings() {
cmode = sm::SIDE | sm::MAYDARK;
@ -1986,7 +2005,9 @@ int read_editor_args() {
if(argis("-lev")) { shift(); levelfile = args(); }
else if(argis("-pic")) { shift(); picfile = args(); }
else if(argis("-load")) { PHASE(3); shift(); mapstream::loadMap(args()); }
#if CAP_POLY
else if(argis("-picload")) { PHASE(3); shift(); mapeditor::loadPicFile(args()); }
#endif
else return 1;
return 0;
}

View File

@ -121,12 +121,80 @@ void chasmifyPoly(double fac, double fac2, int k) {
last->flags |= POLY_ISSIDE;
}
#if CAP_GL
color_t text_color;
int text_shift;
GLuint text_texture;
int texts_merged;
int shapes_merged;
vector<glhr::textured_vertex> text_vertices;
void glflush() {
#if MINIMIZE_GL_CALLS
if(isize(triangle_vertices)) {
// printf("%08X %08X | %d shapes, %d/%d vertices\n", triangle_color, line_color, shapes_merged, isize(triangle_vertices), isize(line_vertices));
if(triangle_color) {
glhr::be_nontextured();
glapplymatrix(Id);
glhr::current_vertices = NULL;
glhr::vertices(triangle_vertices);
glhr::color2(triangle_color);
glDrawArrays(GL_TRIANGLES, 0, isize(triangle_vertices));
}
triangle_vertices.clear();
}
if(isize(line_vertices)) {
if(line_color) {
glhr::be_nontextured();
glapplymatrix(Id);
glhr::current_vertices = NULL;
glhr::vertices(line_vertices);
glhr::color2(line_color);
glDrawArrays(GL_LINES, 0, isize(line_vertices));
}
line_vertices.clear();
}
shapes_merged = 0;
#endif
if(isize(text_vertices)) {
// printf("%08X | %d texts, %d vertices\n", text_color, texts_merged, isize(text_vertices));
if(!svg::in) current_display->set_projection(0, false);
glhr::be_textured();
glBindTexture(GL_TEXTURE_2D, text_texture);
glhr::color2(text_color);
glhr::set_depthtest(false);
for(int ed = (current_display->stereo_active() && text_shift)?-1:0; ed<2; ed+=2) {
if(vid.scale < 0)
glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text) * glhr::scale(-1,-1,-1));
else
glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text));
current_display->set_mask(ed);
glhr::current_vertices = NULL;
glhr::prepare(text_vertices);
glDrawArrays(GL_TRIANGLES, 0, isize(text_vertices));
GLERR("print");
}
if(current_display->stereo_active() && text_shift && !svg::in) current_display->set_mask(0);
texts_merged = 0;
text_vertices.clear();
}
}
#endif
#if CAP_POLY
void shift(hpcshape& sh, double dx, double dy, double dz) {
hyperpoint H = hpxyz(dx, dy, dz);
transmatrix m = rgpushxto0(H);
for(int i=sh.s; i<sh.e; i++)
hpc[i] = m * hpc[i];
}
#endif
#if ISMOBILE==0
SDL_Surface *aux;
@ -157,6 +225,8 @@ void extra_vertices() {
#endif
int spherespecial, spherephase;
#if CAP_POLY
int polyi;
@ -168,8 +238,6 @@ void add1(const hyperpoint& H) {
glcoords.push_back(make_array<GLfloat>(H[0], H[1], H[2]));
}
int spherespecial, spherephase;
bool is_behind(const hyperpoint& H) {
return pmodel == mdDisk && (hyperbolic ? H[2] >= 0 : true) && vid.alpha + H[2] <= BEHIND_LIMIT;
}
@ -207,7 +275,6 @@ int get_side(const hyperpoint& H) {
double curnorm = H[0]*H[0]+H[1]*H[1]+H[2]*H[2];
double horizon = curnorm / vid.alpha;
return (H[2] <= -horizon) ? -1 : 1;
;
}
if(pmodel == mdRotatedHyperboles)
return H[1] > 0 ? -1 : 1;
@ -405,70 +472,6 @@ vector<glvertex> triangle_vertices;
vector<glvertex> line_vertices;
#endif
color_t text_color;
int text_shift;
GLuint text_texture;
int texts_merged;
int shapes_merged;
vector<glhr::textured_vertex> text_vertices;
void glflush() {
#if MINIMIZE_GL_CALLS
if(isize(triangle_vertices)) {
// printf("%08X %08X | %d shapes, %d/%d vertices\n", triangle_color, line_color, shapes_merged, isize(triangle_vertices), isize(line_vertices));
if(triangle_color) {
glhr::be_nontextured();
glapplymatrix(Id);
glhr::current_vertices = NULL;
glhr::vertices(triangle_vertices);
glhr::color2(triangle_color);
glDrawArrays(GL_TRIANGLES, 0, isize(triangle_vertices));
}
triangle_vertices.clear();
}
if(isize(line_vertices)) {
if(line_color) {
glhr::be_nontextured();
glapplymatrix(Id);
glhr::current_vertices = NULL;
glhr::vertices(line_vertices);
glhr::color2(line_color);
glDrawArrays(GL_LINES, 0, isize(line_vertices));
}
line_vertices.clear();
}
shapes_merged = 0;
#endif
if(isize(text_vertices)) {
// printf("%08X | %d texts, %d vertices\n", text_color, texts_merged, isize(text_vertices));
if(!svg::in) current_display->set_projection(0, false);
glhr::be_textured();
glBindTexture(GL_TEXTURE_2D, text_texture);
glhr::color2(text_color);
glhr::set_depthtest(false);
for(int ed = (current_display->stereo_active() && text_shift)?-1:0; ed<2; ed+=2) {
if(vid.scale < 0)
glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text) * glhr::scale(-1,-1,-1));
else
glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text));
current_display->set_mask(ed);
glhr::current_vertices = NULL;
glhr::prepare(text_vertices);
glDrawArrays(GL_TRIANGLES, 0, isize(text_vertices));
GLERR("print");
}
if(current_display->stereo_active() && text_shift && !svg::in) current_display->set_mask(0);
texts_merged = 0;
text_vertices.clear();
}
}
void glapplymatrix(const transmatrix& V) {
GLfloat mat[16];
int id = 0;

View File

@ -3316,6 +3316,7 @@ bool boatAt(cell *c) {
hookset<bool(const transmatrix&, cell*, shmup::monster*)> *hooks_draw;
bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, transmatrix& Vboat0, const transmatrix *Vdp) {
#if CAP_POLY
pair<mit, mit> p =
monstersAt.equal_range(c);
@ -3442,6 +3443,7 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans
}
}
#endif
return false;
}