This commit is contained in:
luboslenco
2019-03-21 23:18:35 +01:00
parent f4a6aa1350
commit df528f95f0
3 changed files with 43 additions and 37 deletions
+2 -2
View File
@@ -307,8 +307,8 @@ class App extends iron.Trait {
@:access(zui.Zui)
static function renderFiles(g:kha.graphics2.Graphics) {
// modalW = Std.int(625 * uimodal.SCALE);
// modalH = Std.int(545 * uimodal.SCALE);
modalW = Std.int(625 * uimodal.SCALE);
modalH = Std.int(545 * uimodal.SCALE);
var appw = kha.System.windowWidth();
var apph = kha.System.windowHeight();
+21 -17
View File
@@ -433,11 +433,30 @@ class UITrait extends iron.Trait {
isScrolling = ui.isScrolling;
updateUI();
for (p in Plugin.plugins) if (p.update != null) p.update();
var kb = iron.system.Input.getKeyboard();
var shift = kb.down("shift");
var ctrl = kb.down("control");
var alt = kb.down("alt");
alt = false; // TODO: gets stuck after alt+tab
if (!arm.App.uimodal.isTyping) {
if (kb.started("escape")) {
arm.App.showFiles = false;
arm.App.showBox = false;
}
if (arm.App.showFiles) {
if (kb.started("enter")) {
arm.App.showFiles = false;
arm.App.filesDone(arm.App.path);
UITrait.inst.ddirty = 2;
}
}
}
if (!arm.App.uienabled) return;
if (kb.started("tab")) {
if (ctrl) { // Cycle objects
var i = (paintObjects.indexOf(paintObject) + 1) % paintObjects.length;
@@ -461,20 +480,6 @@ class UITrait extends iron.Trait {
else if (ctrl && shift && kb.started("s")) Project.projectSaveAs();
else if (ctrl && kb.started("o")) Project.projectOpen();
if (!arm.App.uimodal.isTyping) {
if (kb.started("escape")) {
arm.App.showFiles = false;
arm.App.showBox = false;
}
if (arm.App.showFiles) {
if (kb.started("enter")) {
arm.App.showFiles = false;
arm.App.filesDone(arm.App.path);
UITrait.inst.ddirty = 2;
}
}
}
if (kb.started("f11")) {
show = !show;
arm.App.resize();
@@ -585,8 +590,6 @@ class UITrait extends iron.Trait {
brushCanUnlock = true;
}
}
for (p in Plugin.plugins) if (p.update != null) p.update();
}
function selectMaterial(i:Int) {
@@ -2037,7 +2040,8 @@ class UITrait extends iron.Trait {
ui.row([1/2, 1/2]);
var upHandle = Id.handle();
var lastUp = upHandle.position;
var axisUp = ui.combo(upHandle, ["Z", "Y"], "Up Axis", true);
// TODO: Turn into axis rotation instead
var axisUp = ui.combo(upHandle, ["Z", "-Z", "Y", "-Y"], "Up Axis", true);
if (upHandle.changed && axisUp != lastUp) {
MeshUtil.switchUpAxis(axisUp);
ddirty = 2;
+20 -18
View File
@@ -76,42 +76,44 @@ class MeshUtil {
var verticesDepth = g.vertexBufferMap.get("pos").lockInt16();
if (!g.vertexBufferMap.exists("posnor")) g.get([{name: "pos", data: 'short4norm'}, {name: "nor", data: 'short2norm'}]);
var verticesVox = g.vertexBufferMap.get("posnor").lockInt16();
if (axisUp == 1) { // Y
if (axisUp == 2 || axisUp == 3) { // Y / -Y
var sign = axisUp == 2 ? 1 : -1;
for (i in 0...Std.int(vertices.length / 8)) {
// Swap Y/Z
var f = vertices[i * 8 + 1];
vertices[i * 8 + 1] = vertices[i * 8 + 2];
var f = vertices[i * 8 + 1] * sign;
vertices[i * 8 + 1] = vertices[i * 8 + 2] * sign;
vertices[i * 8 + 2] = -f;
f = vertices[i * 8 + 5];
vertices[i * 8 + 5] = vertices[i * 8 + 3];
f = vertices[i * 8 + 5] * sign;
vertices[i * 8 + 5] = vertices[i * 8 + 3] * sign;
vertices[i * 8 + 3] = -f;
f = verticesDepth[i * 4 + 1];
verticesDepth[i * 4 + 1] = verticesDepth[i * 4 + 2];
f = verticesDepth[i * 4 + 1] * sign;
verticesDepth[i * 4 + 1] = verticesDepth[i * 4 + 2] * sign;
verticesDepth[i * 4 + 2] = -f;
f = verticesVox[i * 6 + 1];
verticesVox[i * 6 + 1] = verticesVox[i * 6 + 2];
f = verticesVox[i * 6 + 1] * sign;
verticesVox[i * 6 + 1] = verticesVox[i * 6 + 2] * sign;
verticesVox[i * 6 + 2] = -f;
}
}
else { // Z
else if (axisUp == 0 || axisUp == 1) { // Z / -Z
var sign = axisUp == 0 ? 1 : -1;
for (i in 0...Std.int(vertices.length / 8)) {
var f = vertices[i * 8 + 1];
vertices[i * 8 + 1] = -vertices[i * 8 + 2];
var f = vertices[i * 8 + 1] * sign;
vertices[i * 8 + 1] = -vertices[i * 8 + 2] * sign;
vertices[i * 8 + 2] = f;
f = vertices[i * 8 + 5];
vertices[i * 8 + 5] = -vertices[i * 8 + 3];
f = vertices[i * 8 + 5] * sign;
vertices[i * 8 + 5] = -vertices[i * 8 + 3] * sign;
vertices[i * 8 + 3] = f;
f = verticesDepth[i * 4 + 1];
verticesDepth[i * 4 + 1] = -verticesDepth[i * 4 + 2];
f = verticesDepth[i * 4 + 1] * sign;
verticesDepth[i * 4 + 1] = -verticesDepth[i * 4 + 2] * sign;
verticesDepth[i * 4 + 2] = f;
f = verticesVox[i * 6 + 1];
verticesVox[i * 6 + 1] = -verticesVox[i * 6 + 2];
f = verticesVox[i * 6 + 1] * sign;
verticesVox[i * 6 + 1] = -verticesVox[i * 6 + 2] * sign;
verticesVox[i * 6 + 2] = f;
}
}