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: @@ -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: @@ -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

6
client/bvh.js

@ -165,8 +165,10 @@ function bvh_delete_stroke(state, stroke) { @@ -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;
}

27
client/client_recv.js

@ -359,7 +359,7 @@ function handle_event(state, context, event, options = {}) { @@ -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 = {}) { @@ -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 = {}) { @@ -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;
}

7
client/client_send.js

@ -420,3 +420,10 @@ function undo_event(state) { @@ -420,3 +420,10 @@ function undo_event(state) {
'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) { @@ -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) { @@ -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;
}
}

Loading…
Cancel
Save