mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-09 23:49:53 +00:00
drawing tool:: improved performance of snapping, by caching
This commit is contained in:
parent
ec79bb156b
commit
31e911ba15
@ -161,15 +161,26 @@ EX namespace mapeditor {
|
||||
|
||||
EX void clear_dtshapes() { dtshapes.clear(); }
|
||||
|
||||
/** cache the result of full_mouseh */
|
||||
EX shiftpoint fmh;
|
||||
|
||||
EX bool fmh_known;
|
||||
|
||||
EX shiftpoint full_mouseh() {
|
||||
if(!fmh_known) {
|
||||
fmh_known = true;
|
||||
#if CAP_EDIT
|
||||
if(GDIM == 3) return find_mouseh3();
|
||||
if(snapping) return mouse_snap();
|
||||
if(GDIM == 3) fmh = find_mouseh3();
|
||||
else if(snapping) fmh = mouse_snap();
|
||||
else
|
||||
#endif
|
||||
return mouseh;
|
||||
fmh = mouseh;
|
||||
}
|
||||
return fmh;
|
||||
}
|
||||
|
||||
EX void draw_dtshapes() {
|
||||
fmh_known = false;
|
||||
#if CAP_EDIT
|
||||
for(auto& shp: dtshapes) {
|
||||
if(shp == nullptr) continue;
|
||||
@ -192,7 +203,7 @@ EX namespace mapeditor {
|
||||
torus_rug_jump(moh, lstart);
|
||||
queueline(lstart, moh, dtcolor, 4 + vid.linequality, PPR::LINE);
|
||||
}
|
||||
else if(!holdmouse) {
|
||||
else if(!holdmouse && !mouseout()) {
|
||||
shiftmatrix T = rgpushxto0(moh);
|
||||
queueline(T * xpush0(-.1), T * xpush0(.1), dtcolor);
|
||||
queueline(T * ypush0(-.1), T * ypush0(.1), dtcolor);
|
||||
@ -2151,7 +2162,7 @@ EX namespace mapeditor {
|
||||
queueline(drawtrans*ccenter, drawtrans*coldcenter, gridcolor, 4 + vid.linequality);
|
||||
|
||||
if(snapping && !mouseout())
|
||||
queuestr(mouse_snap(), 10, "x", 0xC040C0);
|
||||
queuestr(fmh, 10, "x", 0xC040C0);
|
||||
}
|
||||
|
||||
static ld brush_sizes[10] = {
|
||||
|
Loading…
Reference in New Issue
Block a user