mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Merge pull request #10943 from zfox23/spectatorCamera_removeAvatarEntityWorkaround
Workaround the bug where Avatar Entities can't get deleted after switching domains
This commit is contained in:
commit
5af5b4516a
1 changed files with 33 additions and 10 deletions
|
@ -110,23 +110,38 @@
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// -Call this function to shut down the spectator camera and
|
// -Call this function to shut down the spectator camera and
|
||||||
// destroy the camera entity.
|
// destroy the camera entity. "isChangingDomains" is true when this function is called
|
||||||
function spectatorCameraOff() {
|
// from the "Window.domainChanged()" signal.
|
||||||
|
var WAIT_AFTER_DOMAIN_SWITCH_BEFORE_CAMERA_DELETE_MS = 1 * 1000;
|
||||||
|
function spectatorCameraOff(isChangingDomains) {
|
||||||
|
|
||||||
|
function deleteCamera() {
|
||||||
|
Entities.deleteEntity(camera);
|
||||||
|
camera = false;
|
||||||
|
// Change button to active when window is first openend OR if the camera is on, false otherwise.
|
||||||
|
button.editProperties({ isActive: onSpectatorCameraScreen || camera });
|
||||||
|
}
|
||||||
|
|
||||||
spectatorCameraConfig.attachedEntityId = false;
|
spectatorCameraConfig.attachedEntityId = false;
|
||||||
spectatorCameraConfig.enableSecondaryCameraRenderConfigs(false);
|
spectatorCameraConfig.enableSecondaryCameraRenderConfigs(false);
|
||||||
if (camera) {
|
if (camera) {
|
||||||
Entities.deleteEntity(camera);
|
// Workaround for Avatar Entities not immediately having properties after
|
||||||
|
// the "Window.domainChanged()" signal is emitted.
|
||||||
|
// Should be removed after FB6155 is fixed.
|
||||||
|
if (isChangingDomains) {
|
||||||
|
Script.setTimeout(function () {
|
||||||
|
deleteCamera();
|
||||||
|
spectatorCameraOn();
|
||||||
|
}, WAIT_AFTER_DOMAIN_SWITCH_BEFORE_CAMERA_DELETE_MS);
|
||||||
|
} else {
|
||||||
|
deleteCamera();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (viewFinderOverlay) {
|
if (viewFinderOverlay) {
|
||||||
Overlays.deleteOverlay(viewFinderOverlay);
|
Overlays.deleteOverlay(viewFinderOverlay);
|
||||||
}
|
}
|
||||||
camera = false;
|
|
||||||
viewFinderOverlay = false;
|
viewFinderOverlay = false;
|
||||||
setDisplay(monitorShowsCameraView);
|
setDisplay(monitorShowsCameraView);
|
||||||
// Change button to active when window is first openend OR if the camera is on, false otherwise.
|
|
||||||
if (button) {
|
|
||||||
button.editProperties({ isActive: onSpectatorCameraScreen || camera });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function Name: addOrRemoveButton()
|
// Function Name: addOrRemoveButton()
|
||||||
|
@ -179,7 +194,7 @@
|
||||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
addOrRemoveButton(false, HMD.active);
|
addOrRemoveButton(false, HMD.active);
|
||||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
tablet.screenChanged.connect(onTabletScreenChanged);
|
||||||
Window.domainChanged.connect(spectatorCameraOff);
|
Window.domainChanged.connect(onDomainChanged);
|
||||||
Window.geometryChanged.connect(resizeViewFinderOverlay);
|
Window.geometryChanged.connect(resizeViewFinderOverlay);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
HMD.displayModeChanged.connect(onHMDChanged);
|
HMD.displayModeChanged.connect(onHMDChanged);
|
||||||
|
@ -470,7 +485,7 @@
|
||||||
// -shutdown() will be called when the script ends (i.e. is stopped).
|
// -shutdown() will be called when the script ends (i.e. is stopped).
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
spectatorCameraOff();
|
spectatorCameraOff();
|
||||||
Window.domainChanged.disconnect(spectatorCameraOff);
|
Window.domainChanged.disconnect(onDomainChanged);
|
||||||
Window.geometryChanged.disconnect(resizeViewFinderOverlay);
|
Window.geometryChanged.disconnect(resizeViewFinderOverlay);
|
||||||
addOrRemoveButton(true, HMD.active);
|
addOrRemoveButton(true, HMD.active);
|
||||||
if (tablet) {
|
if (tablet) {
|
||||||
|
@ -486,6 +501,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function Name: onDomainChanged()
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
// -A small utility function used when the Window.domainChanged() signal is fired.
|
||||||
|
function onDomainChanged() {
|
||||||
|
spectatorCameraOff(true);
|
||||||
|
}
|
||||||
|
|
||||||
// These functions will be called when the script is loaded.
|
// These functions will be called when the script is loaded.
|
||||||
startup();
|
startup();
|
||||||
Script.scriptEnding.connect(shutdown);
|
Script.scriptEnding.connect(shutdown);
|
||||||
|
|
Loading…
Reference in a new issue