From b77ba2e90a7d122ccb521a700fdfe82c7ca4b4b1 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Sat, 5 Feb 2022 15:39:11 +0100 Subject: [PATCH] Fix #1276 Button removes wrong data point Fix #1275 new-line character in empty keyframe script fields Fix gizmo not disappearing after unselecting Resizing textures with multiple face-uv textures now adjusts mapping correctly --- js/animations/keyframe.js | 8 ++++--- js/preview/transformer.js | 1 + js/texturing/painter.js | 2 +- js/texturing/textures.js | 47 ++++++++++++++++++++++++++++++++++++--- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/js/animations/keyframe.js b/js/animations/keyframe.js index 7b56d0f..70c2cf9 100644 --- a/js/animations/keyframe.js +++ b/js/animations/keyframe.js @@ -267,12 +267,14 @@ class Keyframe { scripts.push(...data_point.script.split('\n')); } }) + scripts = scripts.filter(script => !!script.replace(/[\n\s;.]+/g, '')) return scripts.length <= 1 ? scripts[0] : scripts; } else { let points = []; this.data_points.forEach(data_point => { if (data_point.effect) { let script = data_point.script || undefined; + if (script && !script.replace(/[\n\s;.]+/g, '')) script = undefined; if (script && !script.match(/;$/)) script += ';'; points.push({ effect: data_point.effect, @@ -980,11 +982,11 @@ Interface.definePanels(function() { Animator.preview() Undo.finishEdit('Add keyframe data point') }, - removeDataPoint(data_point) { + removeDataPoint(data_point_index) { Undo.initEdit({keyframes: Timeline.selected}) Timeline.selected.forEach(kf => { if (kf.data_points.length >= 2) { - kf.data_points.splice(data_point, 1); + kf.data_points.splice(data_point_index, 1); } }) Animator.preview() @@ -1045,7 +1047,7 @@ Interface.definePanels(function() {
-
+
clear
diff --git a/js/preview/transformer.js b/js/preview/transformer.js index 4ad4767..360d320 100644 --- a/js/preview/transformer.js +++ b/js/preview/transformer.js @@ -768,6 +768,7 @@ } else if (Group.selected && getRotationObject() == Group.selected) { scope.attach(Group.selected) } else { + this.update() return this; } } diff --git a/js/texturing/painter.js b/js/texturing/painter.js index 88d61fb..391d9e0 100644 --- a/js/texturing/painter.js +++ b/js/texturing/painter.js @@ -18,7 +18,7 @@ const Painter = { var instance = Painter.current[options.method === 'jimp' ? 'image' : 'canvas'] Painter.current[options.method === 'jimp' ? 'canvas' : 'image'] = undefined - var edit_name = options.no_undo ? null : (options.edit_name || 'edit texture'); + var edit_name = options.no_undo ? null : (options.edit_name || 'Edit texture'); if (options.use_cache && texture === Painter.current.texture && diff --git a/js/texturing/textures.js b/js/texturing/textures.js index 3e7dc83..e27cdd8 100644 --- a/js/texturing/textures.js +++ b/js/texturing/textures.js @@ -861,6 +861,22 @@ class Texture { let old_width = scope.width; let old_height = scope.height; + let elements_to_change = null; + if (formResult.fill !== 'stretch' && Texture.length >= 2 && !Format.single_texture) { + let elements = [...Cube.all, ...Mesh.all].filter(el => { + for (let fkey in el.faces) { + if (el.faces[fkey].texture == scope.uuid) return true; + } + }) + if (elements.length) elements_to_change = elements; + } + + Undo.initEdit({ + textures: [scope], + bitmap: true, + elements: elements_to_change, + uv_only: true + }) scope.edit((canvas) => { @@ -907,13 +923,38 @@ class Texture { Project.texture_width = Project.texture_width * (formResult.size[0] / old_width); Project.texture_height = Project.texture_height * (formResult.size[1] / old_height); Canvas.updateAllUVs() + + } else if (formResult.fill !== 'stretch' && Texture.length >= 2 && elements_to_change) { + elements_to_change.forEach(element => { + if (element instanceof Cube) { + for (var key in element.faces) { + if (element.faces[key].texture !== scope.uuid) continue; + var uv = element.faces[key].uv; + uv[0] /= formResult.size[0] / old_width; + uv[2] /= formResult.size[0] / old_width; + uv[1] /= formResult.size[1] / old_height; + uv[3] /= formResult.size[1] / old_height; + } + } else if (element instanceof Mesh) { + for (var key in element.faces) { + if (element.faces[key].texture !== scope.uuid) continue; + var uv = element.faces[key].uv; + for (let vkey in uv) { + uv[vkey][0] /= formResult.size[0] / old_width; + uv[vkey][1] /= formResult.size[1] / old_height; + } + } + } + }) + Canvas.updateView({elements: elements_to_change, element_aspects: {uv: true}}) } return new_canvas - }) - setTimeout(updateSelection, 100); + }, {no_undo: true}) - dialog.hide() + Undo.finishEdit('Resize texture'); + + setTimeout(updateSelection, 100); } }) dialog.show()