|
|
@ -105,28 +105,13 @@ function des_event(d, state = null) { |
|
|
|
const width = des_u16(d); |
|
|
|
const width = des_u16(d); |
|
|
|
const color = des_u32(d); |
|
|
|
const color = des_u32(d); |
|
|
|
|
|
|
|
|
|
|
|
const coords = des_f32array(d, point_count * 2); |
|
|
|
event.coords = des_f32array(d, point_count * 2); |
|
|
|
const press = des_u8array(d, point_count); |
|
|
|
event.press = des_u8array(d, point_count); |
|
|
|
|
|
|
|
|
|
|
|
des_align(d, 4); |
|
|
|
des_align(d, 4); |
|
|
|
|
|
|
|
|
|
|
|
wasm_ensure_by(state, 1, coords.length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const coordinates = state.wasm.buffers['coordinates']; |
|
|
|
|
|
|
|
const pressures = state.wasm.buffers['pressures']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_add(state.wasm.buffers['coords_from'].tv, coordinates.tv.size + point_count * 2); |
|
|
|
|
|
|
|
state.wasm.buffers['coords_from'].used += 4; // 4 bytes, not 4 ints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: remove, this is duplicate data
|
|
|
|
// TODO: remove, this is duplicate data
|
|
|
|
event.coords_from = coordinates.tv.size; |
|
|
|
|
|
|
|
event.coords_to = coordinates.tv.size + point_count * 2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_append(coordinates.tv, coords); |
|
|
|
|
|
|
|
state.wasm.buffers['coordinates'].used += point_count * 2 * 4; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_append(pressures.tv, press); |
|
|
|
|
|
|
|
state.wasm.buffers['pressures'].used += point_count; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event.stroke_id = stroke_id; |
|
|
|
event.stroke_id = stroke_id; |
|
|
|
|
|
|
|
|
|
|
@ -255,6 +240,28 @@ function handle_event(state, context, event, options = {}) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case EVENT.STROKE: { |
|
|
|
case EVENT.STROKE: { |
|
|
|
|
|
|
|
const point_count = event.coords.length / 2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wasm_ensure_by(state, 1, event.coords.length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const coordinates = state.wasm.buffers['coordinates']; |
|
|
|
|
|
|
|
const pressures = state.wasm.buffers['pressures']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event.coords_from = coordinates.tv.size; |
|
|
|
|
|
|
|
event.coords_to = coordinates.tv.size + point_count * 2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_add(state.wasm.buffers['coords_from'].tv, coordinates.tv.size + point_count * 2); |
|
|
|
|
|
|
|
state.wasm.buffers['coords_from'].used += 4; // 4 bytes, not 4 ints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_append(coordinates.tv, event.coords); |
|
|
|
|
|
|
|
state.wasm.buffers['coordinates'].used += point_count * 2 * 4; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_append(pressures.tv, event.press); |
|
|
|
|
|
|
|
state.wasm.buffers['pressures'].used += point_count; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete event.coords; |
|
|
|
|
|
|
|
delete event.press; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: do not do this for my own strokes when we bake locally
|
|
|
|
// TODO: do not do this for my own strokes when we bake locally
|
|
|
|
geometry_clear_player(state, context, event.user_id); |
|
|
|
geometry_clear_player(state, context, event.user_id); |
|
|
|
need_draw = true; |
|
|
|
need_draw = true; |
|
|
|