Copy paste menu icons

Fix OBJ export face directions
Menu.removeAction now supports action as argument
Fix locking of some element types not getting saved
This commit is contained in:
JannisX11 2021-10-13 14:12:55 +03:00
parent 6d28ad47ba
commit 12826ff1cc
6 changed files with 33 additions and 17 deletions

View File

@ -11,6 +11,11 @@ const Clipbench = {
outliner: 'outliner',
texture_selection: 'texture_selection',
},
type_icons: {
face: 'aspect_ratio',
mesh_selection: 'fa-gem',
outliner: 'fas.fa-cube',
},
getCopyType(mode, check) {
// mode: 1 = copy, 2 = paste
let p = Prop.active_panel;
@ -77,6 +82,7 @@ const Clipbench = {
return {
id: option,
name: tl(`menu.paste.${option}`),
icon: Clipbench.type_icons[option],
click() {
resolve(option);
}

View File

@ -424,6 +424,7 @@ ipcRenderer.on('update-available', (event, arg) => {
})
ipcRenderer.on('update-downloaded', (event) => {
action.setName(tl('message.update_after_restart'));
MenuBar.menus.help.removeAction(action);
icon_node.textContent = 'done';
icon_node.classList.remove('spinning');
icon_node.style.color = '#5ef570';

View File

@ -386,11 +386,16 @@ class Menu {
}
removeAction(path) {
var scope = this;
if (path === undefined) path = ''
path = path.split('.')
if (path instanceof Action) {
let action = path;
this.structure.remove(action);
this.structure.remove(action.id);
action.menus.remove(this);
}
if (path === undefined) path = '';
if (typeof path == 'string') path = path.split('.');
function traverse(arr, layer) {
var result;
if (!isNaN(parseInt(path[layer]))) {
result = arr[parseInt(path[layer])]

View File

@ -127,10 +127,10 @@ var codec = new Codec('obj', {
case 'down': vertices = [8, 3, 4, 7]; break;
}
output.push('f '+[
`${vertices[0] + indexVertex}/${i*4 + 1 + indexVertexUvs}/${i+1+indexNormals}`,
`${vertices[1] + indexVertex}/${i*4 + 2 + indexVertexUvs}/${i+1+indexNormals}`,
`${vertices[2] + indexVertex}/${i*4 + 3 + indexVertexUvs}/${i+1+indexNormals}`,
`${vertices[3] + indexVertex}/${i*4 + 4 + indexVertexUvs}/${i+1+indexNormals}`,
`${vertices[2] + indexVertex}/${i*4 + 3 + indexVertexUvs}/${i+1+indexNormals}`,
`${vertices[1] + indexVertex}/${i*4 + 2 + indexVertexUvs}/${i+1+indexNormals}`,
`${vertices[0] + indexVertex}/${i*4 + 1 + indexVertexUvs}/${i+1+indexNormals}`,
].join(' '));
i++;
}

View File

@ -118,7 +118,7 @@ new Property(Locator, 'string', 'name', {default: 'locator'})
new Property(Locator, 'vector', 'from')
new Property(Locator, 'vector', 'rotation')
new Property(Locator, 'boolean', 'ignore_inherited_scale')
new Property(NullObject, 'boolean', 'locked');
new Property(Locator, 'boolean', 'locked');
OutlinerElement.registerType(Locator, 'locator');

View File

@ -1282,7 +1282,6 @@ BARS.defineActions(function() {
mesh.addFaces(new_face);
if (Reusable.vec1.fromArray(reference_face.getNormal(true)).angleTo(Reusable.vec2.fromArray(new_face)) > Math.PI/2) {
console.log(Reusable.vec1.fromArray(reference_face.getNormal(true)).angleTo(Reusable.vec2.fromArray(new_face)))
new_face.invert();
}
}
@ -1611,7 +1610,6 @@ BARS.defineActions(function() {
affected_faces = selected_faces.filter(face => {
return face.vertices.includes(vkey)
})
console.log(affected_faces)
if (affected_faces.length == 0) return;
let inset = [0, 0, 0];
if (affected_faces.length == 3 || affected_faces.length == 1) {
@ -1846,22 +1844,28 @@ BARS.defineActions(function() {
let faces = Object.keys(mesh.faces);
for (let fkey in mesh.faces) {
let face = mesh.faces[fkey];
let side_vertices = faces.includes(fkey) && face.vertices.filter(vkey => selected_vertices.includes(vkey));
let sorted_vertices = face.getSortedVertices();
let side_vertices = faces.includes(fkey) && sorted_vertices.filter(vkey => selected_vertices.includes(vkey));
if (side_vertices && side_vertices.length == 2) {
if (side_vertices[0] == sorted_vertices[0] && side_vertices[1] == sorted_vertices.last()) {
side_vertices.reverse();
}
let original_face_normal = face.getNormal(true);
let sorted_vertices = face.getSortedVertices();
let index_difference = sorted_vertices.indexOf(side_vertices[1]) - sorted_vertices.indexOf(side_vertices[0]);
if (index_difference == -1 || index_difference > 2) side_vertices.reverse();
let other_face = face.getAdjacentFace(sorted_vertices.indexOf(side_vertices[0]));
face.vertices.remove(...side_vertices);
console.log({face, side_vertices, fkey, mesh, other_face});
delete face.uv[side_vertices[0]];
delete face.uv[side_vertices[1]];
let new_vertices = other_face.face.getSortedVertices().filter(vkey => !side_vertices.includes(vkey));
face.vertices.push(...new_vertices);
new_vertices.forEach(vkey => {
face.uv[vkey] = other_face.face.uv[vkey];
})
delete mesh.faces[other_face.key];
if (other_face) {
let new_vertices = other_face.face.getSortedVertices().filter(vkey => !side_vertices.includes(vkey));
face.vertices.push(...new_vertices);
new_vertices.forEach(vkey => {
face.uv[vkey] = other_face.face.uv[vkey];
})
delete mesh.faces[other_face.key];
}
faces.remove(fkey);
if (Reusable.vec1.fromArray(face.getNormal(true)).angleTo(Reusable.vec2.fromArray(original_face_normal)) > Math.PI/2) {
face.invert();