t3du - Restore VR code

This commit is contained in:
2025-07-02 05:14:05 +00:00
parent ccb8b358d3
commit 0e60951ec9

View File

@ -31,11 +31,21 @@ class CameraObject extends Object {
static var vcenter = new Vec4();
static var vup = new Vec4();
#if lnx_vr
var helpMat = Mat4.identity();
public var leftV = Mat4.identity();
public var rightV = Mat4.identity();
#end
public function new(data: CameraData) {
super();
this.data = data;
#if lnx_vr
iron.system.VR.initButton();
#end
buildProjection();
V = Mat4.identity();
@ -117,6 +127,26 @@ class CameraObject extends Object {
V.getInverse(transform.world);
VP.multmats(P, V);
#if lnx_vr
var vr = kha.vr.VrInterface.instance;
if (vr != null && vr.IsPresenting()) {
leftV.setFrom(V);
helpMat.self = vr.GetViewMatrix(0);
leftV.multmat(helpMat);
rightV.setFrom(V);
helpMat.self = vr.GetViewMatrix(1);
rightV.multmat(helpMat);
}
else {
leftV.setFrom(V);
}
VP.multmats(P, leftV);
#else
VP.multmats(P, V);
#end
if (data.raw.frustum_culling) {
buildViewFrustum(VP, frustumPlanes);
}