second pass of cleaning on the code to make it ready for merge

This commit is contained in:
Sam Gateau 2019-09-26 16:56:00 -07:00
parent 675dbc3f7f
commit 24cc302a8b
13 changed files with 140 additions and 221 deletions

View file

@ -240,6 +240,7 @@ void GraphicsEngine::render_performFrame() {
renderArgs._context->setStereoViews(stereoEyeOffsets);
}
}
gpu::FramebufferPointer finalFramebuffer;
QSize finalFramebufferSize;
{

View file

@ -50,6 +50,8 @@ namespace scriptable {
* @property {string} emissiveMap
* @property {string} albedoMap
* @property {string} opacityMap
* @property {string} opacityMapMode
* @property {number|string} opacityCutoff
* @property {string} metallicMap
* @property {string} specularMap
* @property {string} roughnessMap
@ -63,7 +65,6 @@ namespace scriptable {
* @property {Mat4|string} texCoordTransform1
* @property {string} lightmapParams
* @property {string} materialParams
* @property {string} opacityMode
* @property {boolean} defaultFallthrough
*/
class ScriptableMaterial {
@ -79,13 +80,14 @@ namespace scriptable {
float roughness;
float metallic;
float scattering;
float alphaCutoff;
bool unlit;
glm::vec3 emissive;
glm::vec3 albedo;
QString emissiveMap;
QString albedoMap;
QString opacityMap;
QString opacityMapMode;
float opacityCutoff;
QString metallicMap;
QString specularMap;
QString roughnessMap;
@ -96,7 +98,6 @@ namespace scriptable {
QString lightMap;
QString scatteringMap;
std::array<glm::mat4, graphics::Material::NUM_TEXCOORD_TRANSFORMS> texCoordTransforms;
QString opacityMode;
bool defaultFallthrough;
std::unordered_map<uint, bool> propertyFallthroughs; // not actually exposed to script

View file

@ -420,18 +420,16 @@ namespace scriptable {
obj.setProperty("opacityMap", material.opacityMap);
}
obj.setProperty("keys.isOpaque", material.key.isOpaque());
obj.setProperty("keys.isOpacityMaskMap", material.key.isOpacityMaskMap());
obj.setProperty("keys.isTexelOpaque", material.key.isTexelOpaque());
obj.setProperty("keys.isSurfaceOpaque", material.key.isSurfaceOpaque());
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT)) {
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT | graphics::MaterialKey::OPACITY_MASK_MAP_BIT)) {
obj.setProperty("opacityMapMode", FALLTHROUGH);
obj.setProperty("alphaCutoff", FALLTHROUGH);
} else if (material.key.isGlossy()) {
obj.setProperty("opacityMapMode", material.opacityMode);
obj.setProperty("alphaCutoff", material.alphaCutoff);
} else if (material.key.getOpacityMapMode() != graphics::Material::DEFAULT_OPACITY_MAP_MODE) {
obj.setProperty("opacityMapMode", material.opacityMapMode);
}
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OPACITY_CUTOFF_VAL_BIT)) {
obj.setProperty("opacityCutoff", FALLTHROUGH);
} else if (!material.key.isOpacityCutoff()) {
obj.setProperty("opacityCutoff", material.opacityCutoff);
}
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OCCLUSION_MAP_BIT)) {

View file

@ -165,7 +165,7 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
}
bool Material::resetOpacityMap() const {
auto previous = _key.getAlphaMapMode();
auto previous = _key.getOpacityMapMode();
// Clear the previous flags
_key.setOpacityMaskMap(false);
_key.setTranslucentMap(false);
@ -189,7 +189,7 @@ bool Material::resetOpacityMap() const {
}
}
}
auto newious = _key.getAlphaMapMode();
auto newious = _key.getOpacityMapMode();
if (previous != newious) {
//opacity change detected for this material
return true;

View file

@ -43,7 +43,7 @@ public:
OPACITY_VAL_BIT,
OPACITY_MASK_MAP_BIT, // Opacity Map and Opacity MASK map are mutually exclusive
OPACITY_TRANSLUCENT_MAP_BIT,
ALPHA_CUTOFF_VAL_BIT,
OPACITY_CUTOFF_VAL_BIT,
SCATTERING_VAL_BIT,
// THe map bits must be in the same sequence as the enum names for the map channels
@ -73,12 +73,12 @@ public:
NUM_MAP_CHANNELS,
};
enum AlphaMapMode {
ALPHA_MAP_OPAQUE = 0,
ALPHA_MAP_MASK,
ALPHA_MAP_BLEND,
enum OpacityMapMode {
OPACITY_MAP_OPAQUE = 0,
OPACITY_MAP_MASK,
OPACITY_MAP_BLEND,
};
static std::string getAlphaMapModeName(AlphaMapMode mode);
static std::string getOpacityMapModeName(OpacityMapMode mode);
// The signature is the Flags
Flags _flags;
@ -101,8 +101,26 @@ public:
Builder& withGlossy() { _flags.set(GLOSSY_VAL_BIT); return (*this); }
Builder& withTranslucentFactor() { _flags.set(OPACITY_VAL_BIT); return (*this); }
Builder& withAlphaCutoff() { _flags.set(ALPHA_CUTOFF_VAL_BIT); return (*this); }
Builder& withTranslucentMap() { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
Builder& withMaskMap() { _flags.set(OPACITY_MASK_MAP_BIT); return (*this); }
Builder& withOpacityMapMode(OpacityMapMode mode) {
switch (mode) {
case OPACITY_MAP_OPAQUE:
_flags.reset(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.reset(OPACITY_MASK_MAP_BIT);
break;
case OPACITY_MAP_MASK:
_flags.reset(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.set(OPACITY_MASK_MAP_BIT);
break;
case OPACITY_MAP_BLEND:
_flags.set(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.reset(OPACITY_MASK_MAP_BIT);
break;
};
return (*this);
}
Builder& withOpacityCutoff() { _flags.set(OPACITY_CUTOFF_VAL_BIT); return (*this); }
Builder& withScattering() { _flags.set(SCATTERING_VAL_BIT); return (*this); }
@ -111,26 +129,6 @@ public:
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
Builder& withRoughnessMap() { _flags.set(ROUGHNESS_MAP_BIT); return (*this); }
Builder& withTranslucentMap() { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
Builder& withMaskMap() { _flags.set(OPACITY_MASK_MAP_BIT); return (*this); }
Builder& withAlphaMapMode(AlphaMapMode mode) {
switch (mode) {
case ALPHA_MAP_OPAQUE:
_flags.reset(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.reset(OPACITY_MASK_MAP_BIT);
break;
case ALPHA_MAP_MASK:
_flags.reset(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.set(OPACITY_MASK_MAP_BIT);
break;
case ALPHA_MAP_BLEND:
_flags.set(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.reset(OPACITY_MASK_MAP_BIT);
break;
};
return (*this);
}
Builder& withNormalMap() { _flags.set(NORMAL_MAP_BIT); return (*this); }
Builder& withOcclusionMap() { _flags.set(OCCLUSION_MAP_BIT); return (*this); }
Builder& withLightMap() { _flags.set(LIGHT_MAP_BIT); return (*this); }
@ -171,15 +169,15 @@ public:
void setTranslucentFactor(bool value) { _flags.set(OPACITY_VAL_BIT, value); }
bool isTranslucentFactor() const { return _flags[OPACITY_VAL_BIT]; }
void setAlphaCutoff(bool value) { _flags.set(ALPHA_CUTOFF_VAL_BIT, value); }
bool isAlphaCutoff() const { return _flags[ALPHA_CUTOFF_VAL_BIT]; }
void setTranslucentMap(bool value) { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT, value); }
bool isTranslucentMap() const { return _flags[OPACITY_TRANSLUCENT_MAP_BIT]; }
void setOpacityMaskMap(bool value) { _flags.set(OPACITY_MASK_MAP_BIT, value); }
bool isOpacityMaskMap() const { return _flags[OPACITY_MASK_MAP_BIT]; }
void setOpacityCutoff(bool value) { _flags.set(OPACITY_CUTOFF_VAL_BIT, value); }
bool isOpacityCutoff() const { return _flags[OPACITY_CUTOFF_VAL_BIT]; }
void setNormalMap(bool value) { _flags.set(NORMAL_MAP_BIT, value); }
bool isNormalMap() const { return _flags[NORMAL_MAP_BIT]; }
@ -200,23 +198,23 @@ public:
// Translucency and Opacity Heuristics are combining several flags:
void setAlphaMapMode(AlphaMapMode mode) {
void setOpacityMapMode(OpacityMapMode mode) {
switch (mode) {
case ALPHA_MAP_OPAQUE:
case OPACITY_MAP_OPAQUE:
_flags.reset(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.reset(OPACITY_MASK_MAP_BIT);
break;
case ALPHA_MAP_MASK:
case OPACITY_MAP_MASK:
_flags.reset(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.set(OPACITY_MASK_MAP_BIT);
break;
case ALPHA_MAP_BLEND:
case OPACITY_MAP_BLEND:
_flags.set(OPACITY_TRANSLUCENT_MAP_BIT);
_flags.reset(OPACITY_MASK_MAP_BIT);
break;
};
}
AlphaMapMode getAlphaMapMode() const { return (isOpacityMaskMap() ? ALPHA_MAP_MASK : (isTranslucentMap() ? ALPHA_MAP_BLEND : ALPHA_MAP_OPAQUE)); }
OpacityMapMode getOpacityMapMode() const { return (isOpacityMaskMap() ? OPACITY_MAP_MASK : (isTranslucentMap() ? OPACITY_MAP_BLEND : OPACITY_MAP_OPAQUE)); }
bool isTranslucent() const { return isTranslucentFactor() || isTranslucentMap(); }
bool isOpaque() const { return !isTranslucent(); }
@ -270,15 +268,15 @@ public:
Builder& withoutTranslucentFactor() { _value.reset(MaterialKey::OPACITY_VAL_BIT); _mask.set(MaterialKey::OPACITY_VAL_BIT); return (*this); }
Builder& withTranslucentFactor() { _value.set(MaterialKey::OPACITY_VAL_BIT); _mask.set(MaterialKey::OPACITY_VAL_BIT); return (*this); }
Builder& withoutAlphaCutoff() { _value.reset(MaterialKey::ALPHA_CUTOFF_VAL_BIT); _mask.set(MaterialKey::ALPHA_CUTOFF_VAL_BIT); return (*this); }
Builder& withAlphaCutoff() { _value.set(MaterialKey::ALPHA_CUTOFF_VAL_BIT); _mask.set(MaterialKey::ALPHA_CUTOFF_VAL_BIT); return (*this); }
Builder& withoutTranslucentMap() { _value.reset(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); _mask.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
Builder& withTranslucentMap() { _value.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); _mask.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
Builder& withoutMaskMap() { _value.reset(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
Builder& withMaskMap() { _value.set(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
Builder& withoutOpacityCutoff() { _value.reset(MaterialKey::OPACITY_CUTOFF_VAL_BIT); _mask.set(MaterialKey::OPACITY_CUTOFF_VAL_BIT); return (*this); }
Builder& withOpacityCutoff() { _value.set(MaterialKey::OPACITY_CUTOFF_VAL_BIT); _mask.set(MaterialKey::OPACITY_CUTOFF_VAL_BIT); return (*this); }
Builder& withoutNormalMap() { _value.reset(MaterialKey::NORMAL_MAP_BIT); _mask.set(MaterialKey::NORMAL_MAP_BIT); return (*this); }
Builder& withNormalMap() { _value.set(MaterialKey::NORMAL_MAP_BIT); _mask.set(MaterialKey::NORMAL_MAP_BIT); return (*this); }
@ -333,13 +331,13 @@ public:
void setOpacity(float opacity);
float getOpacity() const { return _opacity; }
static const MaterialKey::AlphaMapMode DEFAULT_ALPHA_MAP_MODE;
void setAlphaMapMode(MaterialKey::AlphaMapMode alphaMode);
MaterialKey::AlphaMapMode getAlphaMapMode() const;
static const MaterialKey::OpacityMapMode DEFAULT_OPACITY_MAP_MODE;
void setOpacityMapMode(MaterialKey::OpacityMapMode alphaMode);
MaterialKey::OpacityMapMode getOpacityMapMode() const;
static const float DEFAULT_ALPHA_CUTOFF;
void setAlphaCutoff(float alphaCutoff);
float getAlphaCutoff() const { return _alphaCutoff; }
static const float DEFAULT_OPACITY_CUTOFF;
void setOpacityCutoff(float opacityCutoff);
float getOpacityCutoff() const { return _opacityCutoff; }
void setUnlit(bool value);
bool isUnlit() const { return _key.isUnlit(); }
@ -416,7 +414,7 @@ private:
float _roughness { DEFAULT_ROUGHNESS };
float _metallic { DEFAULT_METALLIC };
float _scattering { DEFAULT_SCATTERING };
float _alphaCutoff { DEFAULT_ALPHA_CUTOFF };
float _opacityCutoff { DEFAULT_OPACITY_CUTOFF };
std::array<glm::mat4, NUM_TEXCOORD_TRANSFORMS> _texcoordTransforms;
glm::vec2 _lightmapParams { 0.0, 1.0 };
glm::vec2 _materialParams { 0.0, 1.0 };
@ -485,7 +483,7 @@ public:
float _metallic { Material::DEFAULT_METALLIC }; // Not Metallic
float _scattering { Material::DEFAULT_SCATTERING }; // Scattering info
float _alphaCutoff { Material::DEFAULT_ALPHA_CUTOFF }; // Alpha cutoff applyed when using alphaMa as Mask
float _opacityCutoff { Material::DEFAULT_OPACITY_CUTOFF }; // Opacity cutoff applyed when using opacityMap as Mask
uint32_t _key { 0 }; // a copy of the materialKey
// Texture Coord Transform Array

View file

@ -49,7 +49,7 @@ struct TexMapArray {
struct Material {
vec4 _emissiveOpacity;
vec4 _albedoRoughness;
vec4 _metallicScatteringAlphaCutoffKey;
vec4 _metallicScatteringOpacityCutoffKey;
};
LAYOUT_STD140(binding=GRAPHICS_BUFFER_MATERIAL) uniform materialBuffer {
@ -71,11 +71,11 @@ vec3 getMaterialAlbedo(Material m) { return m._albedoRoughness.rgb; }
float getMaterialRoughness(Material m) { return m._albedoRoughness.a; }
float getMaterialShininess(Material m) { return 1.0 - getMaterialRoughness(m); }
float getMaterialMetallic(Material m) { return m._metallicScatteringAlphaCutoffKey.x; }
float getMaterialScattering(Material m) { return m._metallicScatteringAlphaCutoffKey.y; }
float getMaterialAlphaCutoff(Material m) { return m._metallicScatteringAlphaCutoffKey.z; }
float getMaterialMetallic(Material m) { return m._metallicScatteringOpacityCutoffKey.x; }
float getMaterialScattering(Material m) { return m._metallicScatteringOpacityCutoffKey.y; }
float getMaterialOpacityCutoff(Material m) { return m._metallicScatteringOpacityCutoffKey.z; }
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._metallicScatteringAlphaCutoffKey.w); }
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._metallicScatteringOpacityCutoffKey.w); }
const BITFIELD EMISSIVE_VAL_BIT = 0x00000001;
const BITFIELD UNLIT_VAL_BIT = 0x00000002;
@ -85,7 +85,7 @@ const BITFIELD GLOSSY_VAL_BIT = 0x00000010;
const BITFIELD OPACITY_VAL_BIT = 0x00000020;
const BITFIELD OPACITY_MASK_MAP_BIT = 0x00000040;
const BITFIELD OPACITY_TRANSLUCENT_MAP_BIT = 0x00000080;
const BITFIELD ALPHA_CUTOFF_VAL_BIT = 0x00000100;
const BITFIELD OPACITY_CUTOFF_VAL_BIT = 0x00000100;
const BITFIELD SCATTERING_VAL_BIT = 0x00000200;

View file

@ -214,21 +214,22 @@ vec3 fetchLightMap(vec2 uv) {
}
<@endfunc@>
<@func evalMaterialOpacityMask(fetchedOpacity, materialAlphaCutoff, opacity)@>
<@func evalMaterialOpacityMask(fetchedOpacity, materialOpacityCutoff, opacity)@>
{
<$opacity$> = step(<$materialAlphaCutoff$>, <$fetchedOpacity$>);
// This path only valid for opaque or texel opaque material
<$opacity$> = step(<$materialOpacityCutoff$>, <$fetchedOpacity$>);
}
<@endfunc@>
<@func evalMaterialOpacity(fetchedOpacity, materialOpacity, matKey, opacity)@>
<@func evalMaterialOpacity(fetchedOpacity, materialOpacityCutoff, materialOpacity, matKey, opacity)@>
{
const float OPACITY_MASK_THRESHOLD = 0.5;
<$opacity$> = mix(1.0,
mix(<$fetchedOpacity$>,
step(OPACITY_MASK_THRESHOLD, <$fetchedOpacity$>),
float((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0)),
float((<$matKey$> & (OPACITY_TRANSLUCENT_MAP_BIT | OPACITY_MASK_MAP_BIT)) != 0)) * <$materialOpacity$>;
// This path only valid for transparent material
// Assert that float((<$matKey$> & (OPACITY_TRANSLUCENT_MAP_BIT | OPACITY_MASK_MAP_BIT)) != 0)) == 1.0
<$opacity$> = mix(<$fetchedOpacity$>,
step(<$materialOpacityCutoff$>, <$fetchedOpacity$>),
float((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0))
* <$materialOpacity$>;
}
<@endfunc@>

View file

@ -258,6 +258,22 @@ std::pair<std::string, std::shared_ptr<NetworkMaterial>> NetworkMaterialResource
} else if (value.isDouble()) {
material->setMetallic(value.toDouble());
}
} else if (key == "opacityCuttoff") {
auto value = materialJSON.value(key);
if (value.isString() && value.toString() == FALLTHROUGH) {
material->setPropertyDoesFallthrough(graphics::MaterialKey::FlagBit::OPACITY_CUTOFF_VAL_BIT);
}
else if (value.isDouble()) {
material->setOpacityCutoff(value.toDouble());
}
/* SG TODO: Implement the set opacityMapMOde intentionaly } else if (key == "opacityMapMode") {
auto value = materialJSON.value(key);
if (value.isString() && value.toString() == FALLTHROUGH) {
material->setPropertyDoesFallthrough(graphics::MaterialKey::FlagBit::OPACITY_MAP_MODE_BIT);
}
else if (value.isDouble()) {
material->setOpacityCutoff(value.toDouble());
}**/
} else if (key == "scattering") {
auto value = materialJSON.value(key);
if (value.isString() && value.toString() == FALLTHROUGH) {

View file

@ -103,11 +103,12 @@ void main(void) {
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
<@if HIFI_USE_TRANSLUCENT@>
float cutoff = getMaterialOpacityCutoff(mat);
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$evalMaterialOpacity(albedoTex.a, cutoff, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
<@else@>
float cutoff = getMaterialAlphaCutoff(mat);
float cutoff = getMaterialOpacityCutoff(mat);
float opacity = 1.0;
<$evalMaterialOpacityMask(albedoTex.a, cutoff, opacity)$>;
<$discardTransparent(opacity)$>;
@ -154,6 +155,7 @@ void main(void) {
<@endif@>
<@if HIFI_USE_TRANSLUCENT@>
float cutoff = getMaterialOpacityCutoff(mat);
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
@ -215,13 +217,13 @@ void main(void) {
_fragColor0 = color;
<@else@>
_fragColor0 = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
<@endif@>
<@else@>
<@if not HIFI_USE_LIGHTMAP@>
@ -239,13 +241,13 @@ void main(void) {
opacity);
<@else@>
_fragColor0 = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
<@endif@>
<@endif@>
<@else@>
@ -313,13 +315,13 @@ void main(void) {
opacity);
<@else@>
_fragColor0 = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
<@endif@>
<@endif@>
<@endif@>

View file

@ -1,11 +1,11 @@
"use strict";
var Page = Script.require('./cash/Page.js');
var Page = Script.require('../lib/skit/Page.js');
function openView() {
//window.closed.connect(function() { Script.stop(); });
var pages = new Pages();
var pages = new Pages(Script.resolvePath("."));
function fromQml(message) {
console.log(JSON.stringify(message))
if (message.method == "inspectResource") {
@ -40,13 +40,13 @@ function openView() {
}
pages.addPage('Cash', 'Cash', "../cash.qml", 300, 500, fromQml, openCashWindow, closeCashWindow);
pages.addPage('openModelCacheInspector', 'Model Cache Inspector', "./ModelCacheInspector.qml", 300, 500, fromQml);
pages.addPage('openMaterialCacheInspector', 'Material Cache Inspector', "./MaterialCacheInspector.qml", 300, 500, fromQml);
pages.addPage('openTextureCacheInspector', 'Texture Cache Inspector', "./TextureCacheInspector.qml", 300, 500, fromQml);
pages.addPage('openAnimationCacheInspector', 'Animation Cache Inspector', "./AnimationCacheInspector.qml", 300, 500);
pages.addPage('openSoundCacheInspector', 'Sound Cache Inspector', "./SoundCacheInspector.qml", 300, 500);
pages.addPage('openResourceInspector', 'Resource Inspector', "./ResourceInspector.qml", 300, 500);
pages.addPage('Cash', 'Cash', "cash.qml", 300, 500, fromQml, openCashWindow, closeCashWindow);
pages.addPage('openModelCacheInspector', 'Model Cache Inspector', "cash/ModelCacheInspector.qml", 300, 500, fromQml);
pages.addPage('openMaterialCacheInspector', 'Material Cache Inspector', "cash/MaterialCacheInspector.qml", 300, 500, fromQml);
pages.addPage('openTextureCacheInspector', 'Texture Cache Inspector', "cash/TextureCacheInspector.qml", 300, 500, fromQml);
pages.addPage('openAnimationCacheInspector', 'Animation Cache Inspector', "cash/AnimationCacheInspector.qml", 300, 500);
pages.addPage('openSoundCacheInspector', 'Sound Cache Inspector', "cash/SoundCacheInspector.qml", 300, 500);
pages.addPage('openResourceInspector', 'Resource Inspector', "cash/ResourceInspector.qml", 300, 500);
pages.open('Cash');

View file

@ -12,7 +12,7 @@
(function() {
function Page(title, qmlurl, width, height, onFromQml, onViewCreated, onViewClosed) {
this.title = title;
this.qml = qmlurl;
this.qmlurl = qmlurl;
this.width = width;
this.height = height;
this.onFromQml = onFromQml;
@ -43,7 +43,7 @@ Page.prototype.createView = function () {
var that = this;
if (!this.window) {
print("Page: New window for page:" + this.title);
this.window = Desktop.createWindow(Script.resolvePath(this.qml), {
this.window = Desktop.createWindow(this.qmlurl, {
title: this.title,
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: this.width, y: this.height}
@ -60,7 +60,9 @@ Page.prototype.createView = function () {
};
Pages = function () {
Pages = function (relativePath) {
print(relativePath)
this._relativePath = relativePath
this._pages = {};
};
@ -73,7 +75,7 @@ Pages.prototype.addPage = function (command, title, qmlurl, width, height, onFro
// Workaround for bad linter
onViewClosed = function() {};
}
this._pages[command] = new Page(title, qmlurl, width, height, onFromQml, onViewCreated, onViewClosed);
this._pages[command] = new Page(title, Script.resolvePath(this._relativePath + qmlurl), width, height, onFromQml, onViewCreated, onViewClosed);
};
Pages.prototype.open = function (command) {

View file

@ -1,14 +1,13 @@
var MaterialInspector = Script.require('./materialInspector.js');
var Page = Script.require('./luci/Page.js');
var Page = Script.require('../lib/skit/Page.js');
function openView() {
//window.closed.connect(function() { Script.stop(); });
var pages = new Pages(Script.resolvePath("."));
var pages = new Pages();
function fromQml(message) {
if (pages.open(message.method)) {
return;
@ -17,12 +16,6 @@ function openView() {
var luciWindow
function openLuciWindow(window) {
if (luciWindow !== undefined) {
activeWindow.fromQml.disconnect(fromQml);
}
if (window !== undefined) {
window.fromQml.connect(fromQml);
}
luciWindow = window;
@ -57,9 +50,6 @@ function openView() {
}
function closeLuciWindow() {
if (luciWindow !== undefined) {
activeWindow.fromQml.disconnect(fromQml);
}
luciWindow = {};
Controller.mousePressEvent.disconnect(onMousePressEvent);
@ -68,10 +58,10 @@ function openView() {
pages.clear();
}
pages.addPage('Luci', 'Luci', '../luci.qml', 300, 420, openLuciWindow, closeLuciWindow);
pages.addPage('openEngineInspectorView', 'Render Engine Inspector', '../engineInspector.qml', 300, 400);
pages.addPage('openEngineLODView', 'Render LOD', '../lod.qml', 300, 400);
pages.addPage('openMaterialInspectorView', 'Material Inspector', '../materialInspector.qml', 300, 400, MaterialInspector.setWindow, MaterialInspector.setWindow);
pages.addPage('Luci', 'Luci', 'luci.qml', 300, 420, fromQml, openLuciWindow, closeLuciWindow);
pages.addPage('openEngineInspectorView', 'Render Engine Inspector', 'engineInspector.qml', 300, 400);
pages.addPage('openEngineLODView', 'Render LOD', 'lod.qml', 300, 400);
pages.addPage('openMaterialInspectorView', 'Material Inspector', 'materialInspector.qml', 300, 400, null, MaterialInspector.setWindow, MaterialInspector.setWindow);
pages.open('Luci');

View file

@ -1,90 +0,0 @@
//
// Page.js
//
// Sam Gateau, created on 4/19/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
"use strict";
(function() {
function Page(title, qmlurl, width, height, onViewCreated, onViewClosed) {
this.title = title;
this.qml = qmlurl;
this.width = width;
this.height = height;
this.onViewCreated = onViewCreated;
this.onViewClosed = onViewClosed;
this.window;
print("Page: New Page:" + JSON.stringify(this));
}
Page.prototype.killView = function () {
print("Page: Kill window for page:" + JSON.stringify(this));
if (this.window) {
print("Page: Kill window for page:" + this.title);
//this.window.closed.disconnect(function () {
// this.killView();
//});
this.window.close();
this.window = false;
}
};
Page.prototype.createView = function () {
var that = this;
if (!this.window) {
print("Page: New window for page:" + this.title);
this.window = Desktop.createWindow(Script.resolvePath(this.qml), {
title: this.title,
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: this.width, y: this.height}
});
this.onViewCreated(this.window);
this.window.closed.connect(function () {
that.killView();
that.onViewClosed();
});
}
};
Pages = function () {
this._pages = {};
};
Pages.prototype.addPage = function (command, title, qmlurl, width, height, onViewCreated, onViewClosed) {
if (onViewCreated === undefined) {
// Workaround for bad linter
onViewCreated = function(window) {};
}
if (onViewClosed === undefined) {
// Workaround for bad linter
onViewClosed = function() {};
}
this._pages[command] = new Page(title, qmlurl, width, height, onViewCreated, onViewClosed);
};
Pages.prototype.open = function (command) {
print("Pages: command = " + command);
if (!this._pages[command]) {
print("Pages: unknown command = " + command);
return;
}
this._pages[command].createView();
};
Pages.prototype.clear = function () {
for (var p in this._pages) {
print("Pages: kill page: " + p);
this._pages[p].killView();
delete this._pages[p];
}
this._pages = {};
};
}());