diff --git a/client/client_recv.js b/client/client_recv.js index 154125d..4c8f3d4 100644 --- a/client/client_recv.js +++ b/client/client_recv.js @@ -364,7 +364,7 @@ function handle_event(state, context, event, options = {}) { } case EVENT.UNDO: { - geometry_add_dummy_stroke(context); + geometry_add_dummy_stroke(state, context); need_draw = undo(state, context, event, options); break; } @@ -372,7 +372,7 @@ function handle_event(state, context, event, options = {}) { case EVENT.IMAGE: { const p = {'x': event.x, 'y': event.y}; - geometry_add_dummy_stroke(context); + geometry_add_dummy_stroke(state, context); add_image(context, event.image_id, null, p, event.width, event.height); try { @@ -401,7 +401,7 @@ function handle_event(state, context, event, options = {}) { } case EVENT.IMAGE_MOVE: { - geometry_add_dummy_stroke(context); + geometry_add_dummy_stroke(state, context); const image_id = event.image_id; const image = get_image(context, image_id); @@ -415,7 +415,7 @@ function handle_event(state, context, event, options = {}) { } case EVENT.IMAGE_SCALE: { - geometry_add_dummy_stroke(context); + geometry_add_dummy_stroke(state, context); const image_id = event.image_id; const image = get_image(context, image_id); @@ -428,7 +428,7 @@ function handle_event(state, context, event, options = {}) { } case EVENT.ERASER: { - geometry_add_dummy_stroke(context); + geometry_add_dummy_stroke(state, context); need_draw = true; const stroke = state.events[event.stroke_id]; stroke.deleted = true; diff --git a/client/wasm/lod.c b/client/wasm/lod.c index d494367..a13020c 100644 --- a/client/wasm/lod.c +++ b/client/wasm/lod.c @@ -323,11 +323,11 @@ do_lod(int *clipped_indices, int clipped_count, float zoom, // Compute recommended LOD level, add to current batch or start new batch float sqrt_width = __builtin_sqrtf(width[stroke_index]); - int lod = __builtin_ceil(sqrt_zoom * sqrt_width * 0.3333f); // TODO: round + int lod = __builtin_roundeven(sqrt_zoom * sqrt_width); // NOTE: there is no regular round, but is shouldn't matt:er if (lod > 7) lod = 7; - if (batch_size > 0 && __builtin_abs(lod - last_lod) > 2) { + if (batch_size > 0 && lod != last_lod) { // Start new batch batches[batch_count * 2 + 0] = batch_size; batches[batch_count * 2 + 1] = last_lod; diff --git a/client/wasm/lod.wasm b/client/wasm/lod.wasm index 6fe6fbc..3a4dd81 100755 Binary files a/client/wasm/lod.wasm and b/client/wasm/lod.wasm differ diff --git a/client/webgl_geometry.js b/client/webgl_geometry.js index 27085ea..982fa27 100644 --- a/client/webgl_geometry.js +++ b/client/webgl_geometry.js @@ -31,12 +31,15 @@ async function geometry_write_instances(state, context, callback) { return segment_count; } -function geometry_add_dummy_stroke(context) { +function geometry_add_dummy_stroke(state, context) { context.stroke_data = ser_ensure_by(context.stroke_data, config.bytes_per_stroke); ser_u16(context.stroke_data, 0); ser_u16(context.stroke_data, 0); ser_u16(context.stroke_data, 0); ser_u16(context.stroke_data, 0); + + tv_add(state.wasm.buffers['width'].tv, 0); + state.wasm.buffers['width'].used += 4; } // Real stroke, add forever