Browse Source

Eraser has gone on-line!

ssao
A.Olokhtonov 5 months ago
parent
commit
803b7f80cb
  1. 7
      README.txt
  2. 6
      client/bvh.js
  3. 27
      client/client_recv.js
  4. 7
      client/client_send.js
  5. 3
      client/webgl_listeners.js

7
README.txt

@ -9,8 +9,8 @@ Release:
+ SIMD for LOD? + SIMD for LOD?
+ Multithreading for LOD + Multithreading for LOD
+ Textured quads (pictures, code already written in older version) + 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?) - Z-prepass fringe bug (also, when do we enable the prepass?)
- Resize and move pictures (draw handles)
+ Bugs + Bugs
+ GC stalls!!! + GC stalls!!!
+ Stroke previews get connected when drawn without panning on touch devices + 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) + Color picker (or at the very least an Open Color color pallete)
+ EYE DROPPER! + EYE DROPPER!
+ Dynamic svg cursor to represent the brush + Dynamic svg cursor to represent the brush
- Eraser + Eraser
- Line drawing - Line drawing
+ Undo + Undo
- Undo for images - Undo for images (add, move, scale)
- Undo for eraser
- Redo - Redo
* Polish * Polish
+ Use typedvector where appropriate + Use typedvector where appropriate

6
client/bvh.js

@ -165,8 +165,10 @@ function bvh_delete_stroke(state, stroke) {
while (node.parent_index !== null) { while (node.parent_index !== null) {
if (node.is_fullnode) { if (node.is_fullnode) {
let index_index = node.stroke_indices.data.indexOf(stroke.index); 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]; if (index_index !== -1) {
tv_pop(node.stroke_indices); node.stroke_indices.data[index_index] = node.stroke_indices.data[node.stroke_indices.size - 1];
tv_pop(node.stroke_indices);
}
break; break;
} }

27
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.user_id === event.user_id && !other_event.deleted) {
if (other_event.type === EVENT.STROKE) { if (other_event.type === EVENT.STROKE) {
other_event.deleted = true; other_event.deleted = true;
if (other_event.bvh_node) { if (other_event.bvh_node && !options.skip_bvh) {
bvh_delete_stroke(state, other_event); bvh_delete_stroke(state, other_event);
} }
need_draw = true; need_draw = true;
@ -374,6 +374,10 @@ function handle_event(state, context, event, options = {}) {
// TODO // TODO
console.log('TODO: undo image scale'); console.log('TODO: undo image scale');
break; break;
} else if (other_event.type === EVENT.ERASER) {
// TODO
console.log('TODO: undo eraser');
break;
} else { } else {
console.error('cant undo event type', other_event.type); console.error('cant undo event type', other_event.type);
break; break;
@ -445,22 +449,11 @@ function handle_event(state, context, event, options = {}) {
case EVENT.ERASER: { case EVENT.ERASER: {
need_draw = true; need_draw = true;
console.error('todo'); const stroke = state.events[event.stroke_id];
// if (event.deleted) { stroke.deleted = true;
// break; if (!options.skip_bvh) {
// } bvh_delete_stroke(state, stroke);
}
// 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;
// }
// }
break; break;
} }

7
client/client_send.js

@ -420,3 +420,10 @@ function undo_event(state) {
'type': EVENT.UNDO, 'type': EVENT.UNDO,
}; };
} }
function eraser_event(stroke_id) {
return {
'type': EVENT.ERASER,
'stroke_id': stroke_id,
}
}

3
client/webgl_listeners.js

@ -151,7 +151,7 @@ function keydown(e, state, context) {
document.querySelector('.debug-window').classList.toggle('dhide'); document.querySelector('.debug-window').classList.toggle('dhide');
} else if (e.code === 'KeyZ') { } else if (e.code === 'KeyZ') {
if (e.ctrlKey) { if (e.ctrlKey) {
queue_event(state, undo_event(state)); queue_event(state, endo_event(state));
} else { } else {
state.zoomdown = true; state.zoomdown = true;
} }
@ -402,6 +402,7 @@ function mousemove(e, state, context) {
if (!stroke.deleted && stroke_intersects_cursor(state, stroke, canvasp, radius)) { if (!stroke.deleted && stroke_intersects_cursor(state, stroke, canvasp, radius)) {
stroke.deleted = true; stroke.deleted = true;
bvh_delete_stroke(state, stroke); bvh_delete_stroke(state, stroke);
queue_event(state, eraser_event(stroke_id));
do_draw = true; do_draw = true;
} }
} }

Loading…
Cancel
Save