mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-30 15:42:42 +08:00
Fix texture updating when painting across multiple textures
Remove unused code for changing cursor when clicking locked element
This commit is contained in:
parent
baafb8d326
commit
db9e83f98f
@ -478,6 +478,7 @@
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
pointer-events: none;
|
||||
color: inherit;
|
||||
}
|
||||
.outliner_object > input.renaming {
|
||||
pointer-events: auto;
|
||||
|
@ -757,15 +757,7 @@ class Preview {
|
||||
|
||||
let select_mode = BarItems.selection_mode.value
|
||||
|
||||
if (data.element && data.element.locked) {
|
||||
$('#preview').css('cursor', 'not-allowed')
|
||||
function resetCursor() {
|
||||
$('#preview').css('cursor', (Toolbox.selected.cursor ? Toolbox.selected.cursor : 'default'))
|
||||
removeEventListeners(document, 'mouseup touchend', resetCursor, false)
|
||||
}
|
||||
addEventListeners(document, 'mouseup touchend', resetCursor, false)
|
||||
|
||||
} else if (Toolbox.selected.selectElements && Modes.selected.selectElements && data.type === 'element') {
|
||||
if (Toolbox.selected.selectElements && Modes.selected.selectElements && data.type === 'element') {
|
||||
if (Toolbox.selected.selectFace && data.face) {
|
||||
if (data.element instanceof Mesh && select_mode == 'face' && (event.ctrlOrCmd || Pressing.overrides.ctrl || event.shiftKey || Pressing.overrides.shift)) {
|
||||
UVEditor.vue.selected_faces.safePush(data.face)
|
||||
|
@ -7,7 +7,7 @@ const Painter = {
|
||||
mirror_painting: false,
|
||||
lock_alpha: false,
|
||||
erase_mode: false,
|
||||
edit(texture, cb, options) {
|
||||
edit(texture, callback, options) {
|
||||
if (!options.no_undo && !options.no_undo_init) {
|
||||
Undo.initEdit({textures: [texture], bitmap: true})
|
||||
}
|
||||
@ -16,40 +16,38 @@ const Painter = {
|
||||
texture.mode = 'bitmap'
|
||||
texture.saved = false
|
||||
}
|
||||
var instance = Painter.current.canvas;
|
||||
if (!Painter.current.cached_canvases) Painter.current.cached_canvases = {};
|
||||
|
||||
var edit_name = options.no_undo ? null : (options.edit_name || 'Edit texture');
|
||||
let edit_name = options.no_undo ? null : (options.edit_name || 'Edit texture');
|
||||
let canvas;
|
||||
|
||||
if (options.use_cache &&
|
||||
texture === Painter.current.texture &&
|
||||
typeof instance === 'object'
|
||||
Painter.current.cached_canvases[texture.uuid]
|
||||
) {
|
||||
//IS CACHED
|
||||
instance = cb(instance) || instance
|
||||
canvas = Painter.current.cached_canvases[texture.uuid];
|
||||
Painter.current.ctx = canvas.getContext('2d');
|
||||
callback(canvas);
|
||||
if (options.no_update === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.no_undo) {
|
||||
let map = texture.getMaterial().map
|
||||
map.image = Painter.current.canvas;
|
||||
map.needsUpdate = true;
|
||||
texture.display_canvas = true;
|
||||
UVEditor.vue.updateTextureCanvas();
|
||||
} else {
|
||||
texture.updateSource(instance.toDataURL())
|
||||
if (!options.no_undo_finish) {
|
||||
Undo.finishEdit(edit_name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//IS UNCACHED
|
||||
Painter.current.texture = texture
|
||||
var c = Painter.current.canvas = Painter.getCanvas(texture)
|
||||
Painter.current.ctx = c.getContext('2d');
|
||||
c = cb(c) || c;
|
||||
canvas = Painter.current.cached_canvases[texture.uuid] = Painter.getCanvas(texture);
|
||||
Painter.current.ctx = canvas.getContext('2d');
|
||||
callback(canvas);
|
||||
}
|
||||
|
||||
texture.updateSource(c.toDataURL())
|
||||
if (!options.no_undo && !options.no_undo_finish) {
|
||||
if (options.no_undo) {
|
||||
let map = texture.getMaterial().map;
|
||||
map.image = canvas;
|
||||
map.needsUpdate = true;
|
||||
texture.display_canvas = true;
|
||||
UVEditor.vue.updateTextureCanvas();
|
||||
} else {
|
||||
texture.updateSource(canvas.toDataURL())
|
||||
if (!options.no_undo_finish) {
|
||||
Undo.finishEdit(edit_name)
|
||||
}
|
||||
}
|
||||
@ -226,6 +224,7 @@ const Painter = {
|
||||
Painter.current.face = data.face
|
||||
Painter.current.element = data.element
|
||||
new_face = true
|
||||
UVEditor.vue.texture = texture;
|
||||
if (texture !== Painter.current.texture) {
|
||||
Undo.current_save.addTexture(texture)
|
||||
}
|
||||
@ -355,6 +354,7 @@ const Painter = {
|
||||
}
|
||||
delete Painter.current.alpha_matrix;
|
||||
delete Painter.editing_area;
|
||||
delete Painter.current.cached_canvases;
|
||||
Painter.painting = false;
|
||||
Painter.currentPixel = [-1, -1];
|
||||
},
|
||||
@ -1805,9 +1805,6 @@ BARS.defineActions(function() {
|
||||
offset_even_radius: true,
|
||||
onStrokeStart({texture, event, x, y, raycast_data}) {
|
||||
if (event.ctrlOrCmd || Pressing.overrides.ctrl) {
|
||||
if (!Painter.current.canvas) {
|
||||
Painter.current.canvas = Painter.getCanvas(texture);
|
||||
}
|
||||
let size = BarItems.slider_brush_size.get();
|
||||
copy_source = {
|
||||
data: texture.canvas.getContext('2d').getImageData(0, 0, texture.width, texture.height).data,
|
||||
|
@ -413,7 +413,6 @@ const TextureGenerator = {
|
||||
makeTexture.source = 'data:image/png;base64,' + makeTexture.getBase64();
|
||||
makeTexture.mode = 'bitmap';
|
||||
makeTexture.saved = false;
|
||||
delete Painter.current.canvas;
|
||||
}
|
||||
canvas.width = Math.max(new_resolution[0] * res_multiple, makeTexture.width);
|
||||
canvas.height = Math.max(new_resolution[1] * res_multiple, makeTexture.height);
|
||||
@ -1193,7 +1192,6 @@ const TextureGenerator = {
|
||||
makeTexture.source = 'data:image/png;base64,' + makeTexture.getBase64();
|
||||
makeTexture.mode = 'bitmap';
|
||||
makeTexture.saved = false;
|
||||
delete Painter.current.canvas;
|
||||
}
|
||||
canvas.width = Math.max(new_resolution[0] * res_multiple, makeTexture.width);
|
||||
canvas.height = Math.max(new_resolution[1] * res_multiple, makeTexture.height);
|
||||
|
@ -1109,9 +1109,6 @@ class Texture {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Painter.current && Painter.current.canvas) {
|
||||
delete Painter.current.canvas;
|
||||
}
|
||||
scope.keep_size = true;
|
||||
if (formResult.fill === 'repeat' && Format.animated_textures && formResult.size[0] < formResult.size[1]) {
|
||||
// Animated
|
||||
|
@ -410,7 +410,7 @@ const UVEditor = {
|
||||
updateSize() {
|
||||
this.vue.updateSize();
|
||||
},
|
||||
setFace(face, update = true) {
|
||||
setFace(face) {
|
||||
this.vue.selected_faces.replace([face]);
|
||||
return this;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user