mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-26 17:05:55 +00:00
various camera fixes and filesystem fixes
This commit is contained in:
parent
291d802850
commit
8416ad018f
4 changed files with 111 additions and 14 deletions
|
|
@ -141,7 +141,7 @@ class CameraController extends Object {
|
|||
}
|
||||
|
||||
var factor = isTouch ? Util.lerp(1 / 25, 1 / 15,
|
||||
Settings.controlsSettings.cameraSensitivity) : Util.lerp(1 / 2500, 1 / 100, Settings.controlsSettings.cameraSensitivity);
|
||||
Settings.controlsSettings.cameraSensitivity) : Util.lerp(1 / 1000, 1 / 200, Settings.controlsSettings.cameraSensitivity);
|
||||
|
||||
// CameraPitch += deltaposY * factor;
|
||||
// CameraYaw += deltaposX * factor;
|
||||
|
|
@ -172,7 +172,8 @@ class CameraController extends Object {
|
|||
// camera.position.add(cameraVerticalTranslation);
|
||||
var camera = level.scene.camera;
|
||||
|
||||
var lerpt = Math.pow(0.5, dt / 0.032); // Math.min(1, 1 - Math.pow(0.6, dt / 0.032)); // hxd.Math.min(1, 1 - Math.pow(0.6, dt * 600));
|
||||
var lerpt = hxd.Math.min(1,
|
||||
1 - Math.pow(0.6, dt * 600)); // Math.min(1, 1 - Math.pow(0.6, dt / 0.032)); // hxd.Math.min(1, 1 - Math.pow(0.6, dt * 600));
|
||||
|
||||
var cameraPitchDelta = (Key.isDown(Settings.controlsSettings.camBackward) ? 1 : 0)
|
||||
- (Key.isDown(Settings.controlsSettings.camForward) ? 1 : 0)
|
||||
|
|
@ -188,11 +189,10 @@ class CameraController extends Object {
|
|||
|
||||
nextCameraPitch = Math.max(-Math.PI / 2 + Math.PI / 4, Math.min(Math.PI / 2 - 0.0001, nextCameraPitch));
|
||||
|
||||
CameraYaw = Util.lerp(CameraYaw, nextCameraYaw, lerpt);
|
||||
CameraPitch = Util.lerp(CameraPitch, nextCameraPitch, lerpt);
|
||||
CameraYaw = nextCameraYaw;
|
||||
CameraPitch = nextCameraPitch;
|
||||
|
||||
CameraPitch = Math.max(-Math.PI / 2 + Math.PI / 4,
|
||||
Math.min(Math.PI / 2 - 0.0001, CameraPitch)); // Util.clamp(CameraPitch, -Math.PI / 12, Math.PI / 2);
|
||||
CameraPitch = Math.max(-Math.PI / 2 + Math.PI / 4, Math.min(Math.PI / 2 - 0.0001, CameraPitch)); // Util.clamp(CameraPitch, -Math.PI / 12, Math.PI / 2);
|
||||
|
||||
function getRotQuat(v1:Vector, v2:Vector) {
|
||||
function orthogonal(v:Vector) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import h3d.scene.Object;
|
|||
import haxe.io.Path;
|
||||
import dts.DtsFile;
|
||||
import dif.Dif;
|
||||
import hxd.fs.LocalFileSystem;
|
||||
import fs.TorqueFileSystem;
|
||||
import hxd.fs.FileSystem;
|
||||
import hxd.res.Loader;
|
||||
import src.Resource;
|
||||
|
|
@ -21,9 +21,9 @@ import src.ResourceLoaderWorker;
|
|||
class ResourceLoader {
|
||||
#if (hl && !android)
|
||||
#if MACOS_BUNDLE
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "Resources"])), null);
|
||||
public static var fileSystem:FileSystem = new TorqueFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "Resources"])), null);
|
||||
#else
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(".", null);
|
||||
public static var fileSystem:FileSystem = new TorqueFileSystem(".", null);
|
||||
#end
|
||||
#end
|
||||
#if (js || android)
|
||||
|
|
@ -45,7 +45,7 @@ class ResourceLoader {
|
|||
|
||||
public static function init(scene2d:h2d.Scene, onLoadedFunc:Void->Void) {
|
||||
#if hl
|
||||
@:privateAccess @:privateAccess cast(fileSystem, LocalFileSystem).convert.tmpDir = "data/tmp/";
|
||||
@:privateAccess @:privateAccess cast(fileSystem, TorqueFileSystem).convert.tmpDir = "data/tmp/";
|
||||
#end
|
||||
hxd.res.Resource.LIVE_UPDATE = false; // Disable live update to save frames
|
||||
@:privateAccess hxd.res.Image.ENABLE_AUTO_WATCH = false;
|
||||
|
|
|
|||
98
src/fs/TorqueFileSystem.hx
Normal file
98
src/fs/TorqueFileSystem.hx
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
package fs;
|
||||
|
||||
import hxd.fs.LocalFileSystem;
|
||||
|
||||
#if hl
|
||||
class TorqueFileEntry extends LocalEntry {
|
||||
override function load(?onReady:Void->Void):Void {
|
||||
#if macro
|
||||
onReady();
|
||||
#else
|
||||
// if (Settings.optionsSettings.fastLoad)
|
||||
onReady();
|
||||
// else {
|
||||
// if (onReady != null)
|
||||
// haxe.Timer.delay(onReady, 1);
|
||||
// }
|
||||
#end
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
class TorqueFileSystem extends LocalFileSystem {
|
||||
#if hl
|
||||
public function new(dir:String, configuration:String) {
|
||||
super(dir, configuration);
|
||||
baseDir = dir;
|
||||
if (configuration == null)
|
||||
configuration = "default";
|
||||
|
||||
#if (macro && haxe_ver >= 4.0)
|
||||
var exePath = null;
|
||||
#elseif (haxe_ver >= 3.3)
|
||||
var pr = Sys.programPath();
|
||||
var exePath = pr == null ? null : pr.split("\\").join("/").split("/");
|
||||
#else
|
||||
var exePath = Sys.executablePath().split("\\").join("/").split("/");
|
||||
#end
|
||||
|
||||
if (exePath != null)
|
||||
exePath.pop();
|
||||
var froot = exePath == null ? baseDir : sys.FileSystem.fullPath(exePath.join("/") + "/" + baseDir);
|
||||
if (froot == null || !sys.FileSystem.exists(froot) || !sys.FileSystem.isDirectory(froot)) {
|
||||
froot = sys.FileSystem.fullPath(baseDir);
|
||||
if (froot == null || !sys.FileSystem.exists(froot) || !sys.FileSystem.isDirectory(froot))
|
||||
throw "Could not find dir " + dir;
|
||||
}
|
||||
baseDir = froot.split("\\").join("/");
|
||||
if (!StringTools.endsWith(baseDir, "/"))
|
||||
baseDir += "/";
|
||||
root = new TorqueFileEntry(this, "root", null, baseDir);
|
||||
}
|
||||
|
||||
override function checkPath(path:String) {
|
||||
// make sure the file is loaded with correct case !
|
||||
var baseDir = new haxe.io.Path(path).dir;
|
||||
var c = directoryCache.get(baseDir.toLowerCase());
|
||||
var isNew = false;
|
||||
if (c == null) {
|
||||
isNew = true;
|
||||
c = new Map();
|
||||
for (f in try
|
||||
sys.FileSystem.readDirectory(baseDir)
|
||||
catch (e:Dynamic)
|
||||
[])
|
||||
c.set(f.toLowerCase(), true);
|
||||
directoryCache.set(baseDir.toLowerCase(), c);
|
||||
}
|
||||
if (!c.exists(path.substr(baseDir.length + 1).toLowerCase())) {
|
||||
// added since then?
|
||||
if (!isNew) {
|
||||
directoryCache.remove(baseDir.toLowerCase());
|
||||
return checkPath(path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
override function open(path:String, check = true) {
|
||||
var r = fileCache.get(path.toLowerCase());
|
||||
if (r != null)
|
||||
return r.r;
|
||||
var e = null;
|
||||
var f = sys.FileSystem.fullPath(baseDir + path);
|
||||
if (f == null)
|
||||
return null;
|
||||
f = f.split("\\").join("/");
|
||||
if (!check || (sys.FileSystem.exists(f) && checkPath(f))) {
|
||||
e = new TorqueFileEntry(this, path.split("/").pop(), path, f);
|
||||
convert.run(e);
|
||||
if (e.file == null)
|
||||
e = null;
|
||||
}
|
||||
fileCache.set(path.toLowerCase(), {r: e});
|
||||
return e;
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
|
@ -300,8 +300,7 @@ class OptionsDlg extends GuiImage {
|
|||
audSndKnob.position = new Vector(137, 95);
|
||||
audSndKnob.extent = new Vector(254, 37);
|
||||
audSndKnob.sliderValue = Settings.optionsSettings.soundVolume;
|
||||
var testingSnd = AudioManager.playSound(ResourceLoader.getResource("data/sound/testing.wav", ResourceLoader.getAudio, this.soundResources), null,
|
||||
true);
|
||||
var testingSnd = AudioManager.playSound(ResourceLoader.getResource("data/sound/testing.wav", ResourceLoader.getAudio, this.soundResources), null, true);
|
||||
testingSnd.pause = true;
|
||||
audSndKnob.slidingSound = testingSnd;
|
||||
audSndKnob.pressedAction = (sender) -> {
|
||||
|
|
@ -694,9 +693,9 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
|||
.toTile());
|
||||
mouseSensitivity.position = new Vector(147, 148);
|
||||
mouseSensitivity.extent = new Vector(254, 34);
|
||||
mouseSensitivity.sliderValue = (Settings.controlsSettings.cameraSensitivity - 0.2) / (3 - 0.2);
|
||||
mouseSensitivity.sliderValue = (Settings.controlsSettings.cameraSensitivity - 0.12) / (1.2 - 0.12);
|
||||
mouseSensitivity.pressedAction = (sender) -> {
|
||||
Settings.controlsSettings.cameraSensitivity = 0.2 + (3 - 0.2) * mouseSensitivity.sliderValue;
|
||||
Settings.controlsSettings.cameraSensitivity = 0.12 + (1.2 - 0.12) * mouseSensitivity.sliderValue;
|
||||
}
|
||||
mouseControlsPane.addChild(mouseSensitivity);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue