Improve performance

This commit is contained in:
JannisX11 2020-10-04 11:13:38 +02:00
parent 8162493621
commit fd39c54bb3
10 changed files with 19 additions and 12 deletions

View File

@ -714,7 +714,7 @@ class BoneAnimator extends GeneralAnimator {
return [...this.rotation, ...this.position, ...this.scale];
}
getGroup() {
this.group = Group.all.findInArray('uuid', this.uuid)
this.group = OutlinerElement.uuids[this.uuid]
if (!this.group) {
if (this.animation && this.animation.animators[this.uuid] && this.animation.animators[this.uuid].type == 'bone') {
delete this.animation.bones[this.uuid];

View File

@ -41,7 +41,7 @@ var codec = new Codec('obj', {
var nbNormals = 0;
var geometry = mesh.geometry;
var element = elements.findInArray('uuid', mesh.name)
var element = OutlinerElement.uuids[mesh.name];
if (!element) return;
if (element.export === false) return;

View File

@ -43,6 +43,9 @@ class ModelProject {
Screencam.stopTimelapse();
Format = 0;
for (var uuid in OutlinerElement.uuids) {
delete OutlinerElement.uuids[uuid];
}
Outliner.elements.empty();
Outliner.root.purge();
Canvas.materials;

View File

@ -211,6 +211,7 @@ class Group extends OutlinerElement {
})
TickUpdates.selection = true
this.constructor.all.remove(this);
delete OutlinerElement.uuids[this.uuid];
if (undo) {
cubes.length = 0
Undo.finishEdit('removed_group')

View File

@ -84,6 +84,7 @@ var markerColors = [
class OutlinerElement {
constructor(uuid) {
this.uuid = uuid || guid()
OutlinerElement.uuids[this.uuid] = this;
this.export = true;
this.locked = false;
}
@ -211,6 +212,7 @@ class OutlinerElement {
}
remove() {
this.constructor.all.remove(this);
delete OutlinerElement.uuids[this.uuid];
this.removeFromParent()
}
rename() {
@ -336,6 +338,7 @@ class OutlinerElement {
this.shade = !val;
}
}
OutlinerElement.uuids = {};
class NonGroup extends OutlinerElement {
constructor(data, uuid) {
super(uuid);

View File

@ -266,7 +266,7 @@ const Canvas = {
Canvas.adaptObjectPosition(obj)
})
if (leave_selection !== true) {
updateSelection()
TickUpdates.selection = true;
}
},
updateSelectedFaces() {

View File

@ -320,7 +320,7 @@ class Preview {
}
if (intersect.isElement) {
this.controls.hasMoved = true
var obj = elements.findInArray('uuid', intersects[0].object.name)
var obj = OutlinerElement.uuids[intersects[0].object.name]
let face = Canvas.face_order[intersects[0].face.materialIndex];
return {

View File

@ -484,7 +484,7 @@ class Texture {
}
//Management
select(event) {
textures.forEach(s => {
Texture.all.forEach(s => {
if (s.selected) s.selected = false;
})
if (event) {
@ -495,7 +495,7 @@ class Texture {
this.scrollTo();
if (Project.layered_textures) {
Canvas.updatePaintingGrid()
} else if (Format.single_texture) {
} else if (Format.single_texture && Texture.all.length > 1) {
Canvas.updateAllFaces()
TickUpdates.selection = true;
}

View File

@ -918,10 +918,10 @@ class UVEditor {
}
}
if (!tex || typeof tex !== 'object') {
if (!Format.single_texture) {
if (!Format.single_texture && Texture.selected) {
unselectTextures()
}
} else {
} else if (Texture.selected != tex) {
tex.select()
}
this.setSize(this.size, true)

View File

@ -227,7 +227,7 @@ var Undo = {
if (save.elements.hasOwnProperty(uuid)) {
var element = save.elements[uuid]
var new_element = elements.findInArray('uuid', uuid)
var new_element = OutlinerElement.uuids[uuid]
if (new_element) {
for (var face in new_element.faces) {
new_element.faces[face].reset()
@ -246,7 +246,7 @@ var Undo = {
}
for (var uuid in reference.elements) {
if (reference.elements.hasOwnProperty(uuid) && !save.elements.hasOwnProperty(uuid)) {
var obj = elements.findInArray('uuid', uuid)
var obj = OutlinerElement.uuids[uuid]
if (obj) {
obj.remove()
}
@ -277,7 +277,7 @@ var Undo = {
if (save.selection_group && !is_session) {
Group.selected = undefined
var sel_group = Group.all.findInArray('uuid', save.selection_group)
var sel_group = OutlinerElement.uuids[save.selection_group]
if (sel_group) {
sel_group.select()
}
@ -293,7 +293,7 @@ var Undo = {
}
if (save.group) {
var group = Group.all.findInArray('uuid', save.group.uuid)
var group = OutlinerElement.uuids[save.group.uuid]
if (group) {
if (is_session) {
delete save.group.isOpen;