diff --git a/graph.cpp b/graph.cpp index ab74f8ce..a12a59ab 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4114,8 +4114,12 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } #if CAP_EDIT - if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == 2) - mapeditor::drawtrans = V; + if(c == mapeditor::drawcell) { + if(mapeditor::drawcellShapeGroup() == 2) { + mapeditor::drawtrans = V; + } + qfi_dc = qfi; + } #endif if(it && cellHalfvine(c)) { diff --git a/hyper.h b/hyper.h index c2646365..a9b9571e 100644 --- a/hyper.h +++ b/hyper.h @@ -1549,3 +1549,4 @@ void buildEquidistant(cell *c); void produceGhost(cell *c, eMonster victim, eMonster who); void sideAttack(cell *mf, int dir, eMonster who, int bonus, eItem orb); void sideAttack(cell *mf, int dir, eMonster who, int bonuskill); +void warpfloor(cell *c, const transmatrix& V, int col, int prio, bool warp); diff --git a/mapeditor.cpp b/mapeditor.cpp index 62029822..e692e007 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -1234,7 +1234,6 @@ namespace mapeditor { transmatrix drawtrans, drawtransnew; void loadShape(int sg, int id, hpcshape& sh, int d, int layer) { - initShape(sg, id); usershapelayer *dsCur = &usershapes[sg][id]->d[layer]; dsCur->list.clear(); dsCur->sym = d==2; @@ -1345,6 +1344,7 @@ namespace mapeditor { } else { displaymm('n', 8, 8+fs*5, 2, vid.fsize, XLAT("'n' to start"), 0); + displaymm('u', 8, 8+fs*6, 2, vid.fsize, XLAT("'u' to load current"), 0); if(mousekey == 'a' || mousekey == 'd' || mousekey == 'd' || mousekey == 'c') mousekey = 'n'; } @@ -1369,7 +1369,64 @@ namespace mapeditor { } bool rebuildPolys = false; - + + void loadShapes(int sg, int id) { + delete usershapes[sg][id]; + usershapes[sg][id] = NULL; + + initquickqueue(); + + dynamicval ws(mmspatial, false); + + if(sg == 0) { + multi::cpid = id, drawMonsterType(moPlayer, drawcell, Id, 0xC0C0C0, 0); + } + else if(sg == 1) { + drawMonsterType(eMonster(id), drawcell, Id, minf[id].color, 0); + } + else if(sg == 2) { + drawItemType(eItem(id), drawcell, Id, iinf[id].color, 0, false); + } + else { + warpfloor(drawcell, Id, 0, PPR_FLOOR, isWarped(drawcell)); + } + + sortquickqueue(); + + int layer = 0; + + initShape(sg, id); + + for(int i=0; id[layer]; + dsCur->list.clear(); + dsCur->color = ptd.col; + dsCur->sym = false; + dsCur->rots = 1; + + for(auto& v: symmetriesAt) + if(p.tab == &ourshape[v[0]*3]) { + dsCur->rots = v[1]; + dsCur->sym = v[2] == 2; + } + + int d = dsCur->rots * (dsCur->sym ? 2 : 1); + + for(int i=0; i < cnt/d; i++) + dsCur->list.push_back(p.V * hpxyz(p.tab[3*i], p.tab[3*i+1], p.tab[3*i+2])); + + layer++; + if(layer == USERLAYERS) break; + } + rebuildPolys = true; + } + void applyToShape(int sg, int id, int uni, hyperpoint mh) { bool haveshape = usershapes[sg][id]; bool xnew = false; @@ -1377,8 +1434,9 @@ namespace mapeditor { if(uni == '-') uni = mousekey; if(!haveshape) { - if(uni == 'n' || uni == 'u') + if(uni == 'n') initShape(sg, id); + else if(uni == 'u') ; else if(uni >= '0' && uni <= '9') { initShape(sg, id); xnew = true; @@ -1395,6 +1453,9 @@ namespace mapeditor { rebuildPolys = true; } + if(uni == 'u') + loadShapes(sg, id); + if(uni == 'a' && haveshape) { mh = spin(2*M_PI*-ew.rotid/dsCur->rots) * mh; if(ew.symid) mh = Mirror * mh; @@ -1431,61 +1492,6 @@ namespace mapeditor { rebuildPolys = true; } - if(uni == 'T') { - /* loadShape(sg, id, shFemaleBody, 1, 1); - loadShape(sg, id, shPKnife, 1, 2); - loadShape(sg, id, shFemaleDress, 1, 3); - loadShape(sg, id, shPrincessDress, 1, 4); - loadShape(sg, id, shBeautyHair, 1, 5); - loadShape(sg, id, shPFace, 1, 6); - loadShape(sg, id, shFlowerHair, 1, 7); */ - - loadShape(sg, id, shPBody, 2, 0); - loadShape(sg, id, shTerraArmor1, 2, 1); - loadShape(sg, id, shTerraArmor2, 2, 2); - loadShape(sg, id, shTerraArmor3, 2, 3); - loadShape(sg, id, shPHead, 2, 4); - loadShape(sg, id, shPFace, 2, 5); - - /* loadShape(sg, id, shReptileFrontFoot, 1, 0); - loadShape(sg, id, shReptileRearFoot, 1, 1); - loadShape(sg, id, shReptileFrontLeg, 1, 2); - loadShape(sg, id, shReptileRearLeg, 1, 3); - loadShape(sg, id, shReptileBody, 2, 4); - loadShape(sg, id, shReptileHead, 2, 5); - loadShape(sg, id, shReptileTail, 2, 6); */ - - // loadShape(sg, id, shTrylobite, 2, 0); - - /* for(int i=0; i<8; i++) - loadShape(sg, id, shWave[i][0], 1, i); */ - - /* loadShape(sg, id, shYeti, 2, 0); - loadShape(sg, id, shHumanFoot, 1, 1); */ - - /* loadShape(sg, id, shYeti, 1, 2); - loadShape(sg, id, shRatHead, 1, 3); - loadShape(sg, id, shRatTail, 1, 1); - loadShape(sg, id, shWolf1, 1, 4); - loadShape(sg, id, shWolf2, 1, 5); - loadShape(sg, id, shRatCape1, 1, 7); - loadShape(sg, id, shRatCape2, 1, 6); */ - -// loadShape(sg, id, shTortoise[0][0], 1, 0); -/* loadShape(sg, id, shTentacleX, 1, 0); - loadShape(sg, id, shTentacle, 1, 1); - loadShape(sg, id, shJoint, 1, 2); */ - - /* loadShape(3, 0, shTurtleFloor[0], 12, 0); - loadShape(3, 1, shTurtleFloor[1], 14, 0); */ - - // loadShape(sg, id, shDragonSegment, 2, 0); - // loadShape(sg, id, shEyes, 2, 2); - - // loadShape(sg, id, shFamiliarHead, 2, 0); - rebuildPolys = true; - } - if(uni == 'K') { if(vid.cs.charid >= 4) { loadShape(sg, id, shCatBody, 2, 0); diff --git a/polygons.cpp b/polygons.cpp index 2e9a60a9..bbe33253 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -524,6 +524,15 @@ void initquickqueue() { poly_outline = OUTLINE_NONE; } +void sortquickqueue() { + for(int i=1; i> symmetriesAt; + void bshape(hpcshape& sh, int p, double shzoom, int shapeid) { bshape(sh, p); int whereis = 0; while(polydata[whereis] != NEWSHAPE || polydata[whereis+1] != shapeid) whereis++; int rots = polydata[whereis+2]; int sym = polydata[whereis+3]; + symmetriesAt.emplace_back(array ({qhpc, rots, sym})); whereis += 4; int qty = 0; while(polydata[whereis + 2*qty] != NEWSHAPE) qty++; @@ -830,6 +842,7 @@ void pushShape(const usershapelayer& ds) { void buildpolys() { + symmetriesAt.clear(); geom3::compute(); DEBB(DF_INIT, (debugfile,"buildpolys\n")); @@ -1475,6 +1488,7 @@ void buildpolys() { bshape(shTerraArmor3, PPR_MONSTER_BODY, scalef, 351); bshape(shTerraHead, PPR_MONSTER_HEAD, scalef, 352); bshape(shTerraFace, PPR_MONSTER_FACE, scalef, 353); + bshape(shJiangShi, PPR_MONSTER_BODY, scale, 355); bshape(shPBody, PPR_MONSTER_BODY, scalef, 85); bshape(shYeti, PPR_MONSTER_BODY, scalef, 86); @@ -1755,6 +1769,7 @@ struct qfloorinfo { }; qfloorinfo qfi; +qfloorinfo qfi_dc; int chasmg; @@ -2800,6 +2815,7 @@ NEWSHAPE, 352, 1, 2, 0.060794,0.001192, 0.058426,0.023847, 0.050054,0.030986, 0. NEWSHAPE, 353, 1, 2, -0.006280,-0.006803, -0.001570,-0.039786, 0.007333,-0.062332, 0.014659,-0.042408, 0.019888,-0.016748, 0.027740,-0.009945, NEWSHAPE, 354, 1, 2, 0.250609,-0.000793, 0.091262,-0.024449, 0.090008,-0.008476, -0.131783,-0.007990, -0.229492,-0.028849, -0.208244,0.002239, +NEWSHAPE, 355, 1, 2, -0.120944,-0.046316, -0.118320,-0.065458, -0.026635,-0.134194, 0.069939,-0.150868, 0.257603,-0.099875, 0.263931,-0.098916, 0.295208,-0.074359, 0.292228,-0.069765, 0.274479,-0.081250, 0.293481,-0.057622, 0.290757,-0.055430, 0.266210,-0.078038, 0.289156,-0.044495, 0.286442,-0.042311, 0.263022,-0.071079, 0.275695,-0.039346, 0.256850,-0.068686, 0.254313,-0.048283, 0.242683,-0.074603, 0.079643,-0.108059, 0.017947,-0.089316, 0.039133,-0.032229, NEWSHAPE };