Add delete operator to meshes tab

This commit is contained in:
Lubos Lenco
2021-05-15 15:36:54 +02:00
parent edc0f7568d
commit 0895fa512a
2 changed files with 31 additions and 2 deletions
+9
View File
@@ -155,6 +155,15 @@ class ImportMesh {
object.name = mesh.name;
object.skip_context = "paint";
// Ensure unique names
for (p in Project.paintObjects) {
if (p.name == object.name) {
p.name += ".001";
p.data.handle += ".001";
Data.cachedMeshes.set(p.data.handle, p.data);
}
}
Project.paintObjects.push(object);
md.handle = raw.name;
+22 -2
View File
@@ -65,7 +65,8 @@ class TabMeshes {
ui.endSticky();
for (o in Project.paintObjects) {
for (i in 0...Project.paintObjects.length) {
var o = Project.paintObjects[i];
var h = Id.handle();
h.selected = o.visible;
o.visible = ui.check(h, o.name);
@@ -75,7 +76,26 @@ class TabMeshes {
if (ui.button(tr("Export"), Left)) {
BoxExport.showMesh();
}
}, 2);
if (Project.paintObjects.length > 1 && ui.button(tr("Delete"), Left)) {
Project.paintObjects.remove(o);
while (o.children.length > 0) {
var child = o.children[0];
o.removeChild(child);
if (Project.paintObjects[0] != child) {
Project.paintObjects[0].addChild(child);
}
if (o.children.length == 0) {
Project.paintObjects[0].transform.scale.setFrom(o.transform.scale);
Project.paintObjects[0].transform.buildMatrix();
}
}
iron.data.Data.deleteMesh(o.data.handle);
o.remove();
Context.paintObject = Context.mainObject();
MeshUtil.mergeMesh();
Context.ddirty = 2;
}
}, Project.paintObjects.length > 1 ? 3 : 2);
}
if (h.changed) {
var visibles: Array<MeshObject> = [];