Brush opacity now goes up to 255

Improve drawing performance
Default recent model list type is now grid
Fix UV pasting not working in preview
Fix #1041 Copy pasting UV on meshes can sometimes twist region
Fix #1092 Rescaling is not calculated correctly with 22.5 degree elements
master
JannisX11 2021-10-14 16:39:02 +02:00
parent 33b8b9e62d
commit e6ce9eac47
6 changed files with 21 additions and 20 deletions

View File

@ -73,7 +73,7 @@ const Clipbench = {
if (Mesh.selected[0] && Mesh.selected[0].getSelectedVertices().length && Clipbench.vertices) {
options.push(Clipbench.types.mesh_selection);
}
if (UVEditor.getMappableElements().length && Clipbench.faces && Object.keys(Clipbench.faces).length) {
if (UVEditor.getMappableElements().length && UVEditor.clipboard.length) {
options.push(Clipbench.types.face);
}
if (options.length > 1) {
@ -93,10 +93,10 @@ const Clipbench = {
return options[0]
}
}
if (p == 'uv' && Modes.edit) {
if (p == 'uv' && Modes.edit && UVEditor.clipboard.length) {
return Clipbench.types.face;
}
if (p == 'textures' && Texture.selected) {
if (p == 'textures') {
return Clipbench.types.texture;
}
if (p == 'outliner' && Modes.edit) {
@ -240,7 +240,6 @@ const Clipbench = {
let new_vkey = new_vertices[old_vertices.indexOf(old_vkey)];
new_face.uv[new_vkey] = new_face.uv[old_vkey];
delete new_face.uv[old_vkey];
console.log(old_vertices.indexOf(old_vkey), new_vkey)
return new_vkey;
})
new_face.vertices.replace(new_face_vertices);

View File

@ -122,7 +122,7 @@ onVueSetup(function() {
data: {
formats: Formats,
recent: isApp ? recent_projects : [],
list_type: StateMemory.start_screen_list_type || 'list',
list_type: StateMemory.start_screen_list_type || 'grid',
redact_names: settings.streamer_mode.value,
redacted: tl('generic.redacted'),
isApp,

View File

@ -5,10 +5,10 @@ function getRescalingFactor(angle) {
return 1.4142
break;
case 22.5:
return 1.127
return 1.0824
break;
case 67.5:
return 1.127
return 1.0824
break;
case 45:
return 1.4142

View File

@ -308,7 +308,7 @@ const Painter = {
var color = tinycolor(ColorPanel.get()).toRgb();
var size = BarItems.slider_brush_size.get();
let softness = BarItems.slider_brush_softness.get()/100;
let b_opacity = BarItems.slider_brush_opacity.get()/100;
let b_opacity = BarItems.slider_brush_opacity.get()/255;
let tool = Toolbox.selected.id;
ctx.clip()
@ -371,7 +371,7 @@ const Painter = {
},
useFilltool(texture, ctx, x, y, area) {
var color = tinycolor(ColorPanel.get()).toRgb();
let b_opacity = BarItems.slider_brush_opacity.get()/100;
let b_opacity = BarItems.slider_brush_opacity.get()/255;
var fill_mode = BarItems.fill_mode.get()
var element = Painter.current.element;
let {rect, uvFactorX, uvFactorY, w, h} = area;
@ -564,7 +564,6 @@ const Painter = {
} else {
point_on_uv = point_on_uv.map(v => Math.floor(v))
}
console.log([x, y], point_on_uv)
let old_mesh = Painter.current.element;
Painter.current.element = mesh;
@ -602,7 +601,7 @@ const Painter = {
ctx.drawImage(Painter.current.clear, 0, 0)
let color = tinycolor(ColorPanel.get()).toRgb();
let b_opacity = BarItems.slider_brush_opacity.get()/100;
let b_opacity = BarItems.slider_brush_opacity.get()/255;
var width = BarItems.slider_brush_size.get();
let shape = BarItems.draw_shape_type.get();
let hollow = shape.substr(-1) == 'h';
@ -722,7 +721,7 @@ const Painter = {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(Painter.current.clear, 0, 0)
let b_opacity = BarItems.slider_brush_opacity.get()/100;
let b_opacity = BarItems.slider_brush_opacity.get()/255;
let rect = Painter.setupRectFromFace(uvTag, texture);
var [w, h] = [rect[2] - rect[0], rect[3] - rect[1]];
@ -1221,17 +1220,17 @@ BARS.defineActions(function() {
condition: () => (Toolbox && ['brush_tool', 'eraser', 'fill_tool', 'draw_shape_tool', 'gradient_tool'].includes(Toolbox.selected.id)),
tool_setting: 'brush_opacity',
settings: {
min: 0, max: 100, default: 100,
min: 0, max: 255, default: 255,
show_bar: true,
interval: function(event) {
if (event.shiftKey && event.ctrlOrCmd) {
return 0.25;
return 1;
} else if (event.shiftKey) {
return 5;
return 4;
} else if (event.ctrlOrCmd) {
return 1;
} else {
return 10;
return 8;
}
}
}

View File

@ -155,6 +155,7 @@ class Texture {
this.img.onload = function() {
if (!this.src || Texture.all.indexOf(scope) == -1) return;
this.tex.needsUpdate = true;
let dimensions_changed = scope.width !== img.naturalWidth || scope.height !== img.naturalHeight;
scope.width = img.naturalWidth;
scope.height = img.naturalHeight;
@ -207,8 +208,10 @@ class Texture {
size_control.old_height = img.naturalHeight
}
TextureAnimator.updateButton()
Canvas.updateAllFaces(scope)
if (dimensions_changed) {
TextureAnimator.updateButton()
Canvas.updateAllFaces(scope)
}
if (typeof scope.load_callback === 'function') {
scope.load_callback(scope);
delete scope.load_callback;
@ -572,7 +575,6 @@ class Texture {
this.folder = 'textures/' + this.folder;
}
} else {
console.log(2)
var arr = path.split(osfs)
this.folder = arr[arr.length-2]
if (Format.id === 'java_block' && isApp && settings.dialog_loose_texture.value) {

View File

@ -1101,6 +1101,7 @@ const UVEditor = {
var new_face;
if (elements[0] instanceof Mesh) {
new_face = new MeshFace(null, tag);
new_face.vertices = tag.getSortedVertices();
new_face.direction = key;
} else {
new_face = new CubeFace(key, tag);
@ -1141,7 +1142,7 @@ const UVEditor = {
tag.vertices.forEach(vkey => {
uv_points.push(tag.uv[vkey]);
})
face.vertices.forEach((vkey, i) => {
face.getSortedVertices().forEach((vkey, i) => {
if (uv_points[i]) face.uv[vkey].replace(uv_points[i]);
})
} else {