Fix #2088 Paint cursor offset when using higher template resolutions

Fix #2091 Using delete after Select All in UV tab does not erase texture
Fix issue when loading in multiple image projects at once
This commit is contained in:
JannisX11 2023-11-14 20:12:02 +01:00
parent ed9456c68d
commit 3f23cad8f4
3 changed files with 15 additions and 7 deletions

View File

@ -1050,8 +1050,8 @@ class Preview {
let world_normal = Reusable.vec1.copy(intersect.face.normal).applyQuaternion(world_quaternion);
// UV
let uv_factor_x = Project.texture_width / texture.width;
let uv_factor_y = Project.texture_height / texture.display_height;
let uv_factor_x = texture.getUVWidth() / texture.width;
let uv_factor_y = texture.getUVHeight() / texture.display_height;
let offset = 0;
let x = intersect.uv.x * texture.width;
let y = (1-intersect.uv.y) * texture.height;

View File

@ -1880,7 +1880,7 @@ class IntMatrix {
this.array = new_array;
}
toBoxes() {
if (!this.is_custom) return [0, 0, this.width, this.height];
if (!this.is_custom) return [[0, 0, this.width, this.height]];
let boxes = [];
this.forEachPixel((x, y, value) => {
if (value !== 1) return;

View File

@ -176,7 +176,7 @@ class Texture {
let dimensions_changed = scope.width !== img.naturalWidth || scope.height !== img.naturalHeight;
scope.width = img.naturalWidth;
scope.height = img.naturalHeight;
scope.selection.changeSize(scope.width, scope.height);
if (scope.selection) scope.selection.changeSize(scope.width, scope.height);
if (img.naturalWidth > 16384 || img.naturalHeight > 16384) {
scope.error = 2;
}
@ -263,7 +263,11 @@ class Texture {
if (typeof data === 'object') {
this.extend(data);
if (this.layers_enabled) {
setTimeout(() => this.updateLayerChanges(), 40);
setTimeout(() => {
Project.whenNextOpen(() => {
this.updateLayerChanges()
})
}, 40);
}
}
if (!this.id) {
@ -1612,7 +1616,9 @@ class Texture {
}
this.ctx.filter = '';
this.getMaterial().map.needsUpdate = true;
if (!Format.image_editor) {
this.getMaterial().map.needsUpdate = true;
}
if (update_data_url) {
this.source = this.canvas.toDataURL();
this.updateImageFromCanvas();
@ -1622,7 +1628,9 @@ class Texture {
if (this.layers_enabled) {
return this.updateLayerChanges(true);
}
this.getMaterial().map.needsUpdate = true;
if (!Format.image_editor) {
this.getMaterial().map.needsUpdate = true;
}
this.source = this.canvas.toDataURL();
this.updateImageFromCanvas();
}