mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-18 07:27:40 +00:00
drawing tool:: improved the performance of mouse_snap
This commit is contained in:
@@ -2218,14 +2218,12 @@ EX namespace mapeditor {
|
|||||||
|
|
||||||
EX shiftpoint mouse_snap() {
|
EX shiftpoint mouse_snap() {
|
||||||
ld xdist = HUGE_VAL;
|
ld xdist = HUGE_VAL;
|
||||||
shiftpoint resh;
|
shiftpoint resh = mouseh;
|
||||||
auto snap_to = [&] (shiftpoint h) {
|
auto snap_to = [&] (shiftpoint h) {
|
||||||
ld dist = hdist(h, mouseh);
|
ld dist = hdist(h, mouseh);
|
||||||
if(dist < xdist) xdist = dist, resh = h;
|
if(dist < xdist) xdist = dist, resh = h;
|
||||||
};
|
};
|
||||||
for(auto& p: gmatrix) {
|
auto snap_to_tile_matrix = [&] (cell *c, const shiftmatrix& T) {
|
||||||
cell *c = p.first;
|
|
||||||
auto& T = p.second;
|
|
||||||
snap_to(T * C0);
|
snap_to(T * C0);
|
||||||
for(int i=0; i<c->type; i++) {
|
for(int i=0; i<c->type; i++) {
|
||||||
hyperpoint h1 = get_corner_position(c, i);
|
hyperpoint h1 = get_corner_position(c, i);
|
||||||
@@ -2233,7 +2231,13 @@ EX namespace mapeditor {
|
|||||||
snap_to(T * h1);
|
snap_to(T * h1);
|
||||||
snap_to(T * mid(h1, h2));
|
snap_to(T * mid(h1, h2));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
auto snap_to_tile = [&] (cell *c) {
|
||||||
|
auto p = at_or_null(gmatrix, c);
|
||||||
|
if(!p) return;
|
||||||
|
snap_to_tile_matrix(c, *p);
|
||||||
|
};
|
||||||
|
snap_to_tile(mouseover);
|
||||||
return resh;
|
return resh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user