diff --git a/README.txt b/README.txt index b2d3331..80a726b 100644 --- a/README.txt +++ b/README.txt @@ -9,8 +9,8 @@ Release: + SIMD for LOD? + Multithreading for LOD + Textured quads (pictures, code already written in older version) + + Resize and move pictures (draw handles) - Z-prepass fringe bug (also, when do we enable the prepass?) - - Resize and move pictures (draw handles) + Bugs + GC stalls!!! + Stroke previews get connected when drawn without panning on touch devices @@ -41,10 +41,11 @@ Release: + Color picker (or at the very least an Open Color color pallete) + EYE DROPPER! + Dynamic svg cursor to represent the brush - - Eraser + + Eraser - Line drawing + Undo - - Undo for images + - Undo for images (add, move, scale) + - Undo for eraser - Redo * Polish + Use typedvector where appropriate diff --git a/client/bvh.js b/client/bvh.js index d330e98..345bf2c 100644 --- a/client/bvh.js +++ b/client/bvh.js @@ -165,8 +165,10 @@ function bvh_delete_stroke(state, stroke) { while (node.parent_index !== null) { if (node.is_fullnode) { let index_index = node.stroke_indices.data.indexOf(stroke.index); - node.stroke_indices.data[index_index] = node.stroke_indices.data[node.stroke_indices.size - 1]; - tv_pop(node.stroke_indices); + if (index_index !== -1) { + node.stroke_indices.data[index_index] = node.stroke_indices.data[node.stroke_indices.size - 1]; + tv_pop(node.stroke_indices); + } break; } diff --git a/client/client_recv.js b/client/client_recv.js index a22328e..21741ba 100644 --- a/client/client_recv.js +++ b/client/client_recv.js @@ -359,7 +359,7 @@ function handle_event(state, context, event, options = {}) { if (other_event.user_id === event.user_id && !other_event.deleted) { if (other_event.type === EVENT.STROKE) { other_event.deleted = true; - if (other_event.bvh_node) { + if (other_event.bvh_node && !options.skip_bvh) { bvh_delete_stroke(state, other_event); } need_draw = true; @@ -374,6 +374,10 @@ function handle_event(state, context, event, options = {}) { // TODO console.log('TODO: undo image scale'); break; + } else if (other_event.type === EVENT.ERASER) { + // TODO + console.log('TODO: undo eraser'); + break; } else { console.error('cant undo event type', other_event.type); break; @@ -445,22 +449,11 @@ function handle_event(state, context, event, options = {}) { case EVENT.ERASER: { need_draw = true; - console.error('todo'); - // if (event.deleted) { - // break; - // } - - // for (const other_event of state.events) { - // if (other_event.type === EVENT.STROKE && other_event.stroke_id === event.stroke_id) { - // // Might already be deleted because of local prediction - // if (!other_event.deleted) { - // other_event.deleted = true; - // const stats = stroke_stats(other_event.points, state.cursor.width); - // redraw_region(stats.bbox); - // } - // break; - // } - // } + const stroke = state.events[event.stroke_id]; + stroke.deleted = true; + if (!options.skip_bvh) { + bvh_delete_stroke(state, stroke); + } break; } diff --git a/client/client_send.js b/client/client_send.js index ba8f0f5..8f1aecb 100644 --- a/client/client_send.js +++ b/client/client_send.js @@ -420,3 +420,10 @@ function undo_event(state) { 'type': EVENT.UNDO, }; } + +function eraser_event(stroke_id) { + return { + 'type': EVENT.ERASER, + 'stroke_id': stroke_id, + } +} diff --git a/client/webgl_listeners.js b/client/webgl_listeners.js index b97cd3c..bef11d7 100644 --- a/client/webgl_listeners.js +++ b/client/webgl_listeners.js @@ -151,7 +151,7 @@ function keydown(e, state, context) { document.querySelector('.debug-window').classList.toggle('dhide'); } else if (e.code === 'KeyZ') { if (e.ctrlKey) { - queue_event(state, undo_event(state)); + queue_event(state, endo_event(state)); } else { state.zoomdown = true; } @@ -402,6 +402,7 @@ function mousemove(e, state, context) { if (!stroke.deleted && stroke_intersects_cursor(state, stroke, canvasp, radius)) { stroke.deleted = true; bvh_delete_stroke(state, stroke); + queue_event(state, eraser_event(stroke_id)); do_draw = true; } }