Merge branch 'master' of github.com:highfidelity/hifi into motor-action

This commit is contained in:
Seth Alves 2017-05-06 07:49:02 -07:00
commit 5d539bcc17
17 changed files with 171 additions and 70 deletions

View file

@ -5461,7 +5461,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
} }
scriptEngine->registerGlobalObject("Overlays", &_overlays);
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this)); scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
// hook our avatar and avatar hash map object into this script engine // hook our avatar and avatar hash map object into this script engine
@ -5560,6 +5559,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
auto entityScriptServerLog = DependencyManager::get<EntityScriptServerLogClient>(); auto entityScriptServerLog = DependencyManager::get<EntityScriptServerLogClient>();
scriptEngine->registerGlobalObject("EntityScriptServerLog", entityScriptServerLog.data()); scriptEngine->registerGlobalObject("EntityScriptServerLog", entityScriptServerLog.data());
scriptEngine->registerGlobalObject("AvatarInputs", AvatarInputs::getInstance());
qScriptRegisterMetaType(scriptEngine, OverlayIDtoScriptValue, OverlayIDfromScriptValue); qScriptRegisterMetaType(scriptEngine, OverlayIDtoScriptValue, OverlayIDfromScriptValue);

View file

@ -34,7 +34,7 @@ class AvatarInputs : public QQuickItem {
public: public:
static AvatarInputs* getInstance(); static AvatarInputs* getInstance();
float loudnessToAudioLevel(float loudness); Q_INVOKABLE float loudnessToAudioLevel(float loudness);
AvatarInputs(QQuickItem* parent = nullptr); AvatarInputs(QQuickItem* parent = nullptr);
void update(); void update();
bool showAudioTools() const { return _showAudioTools; } bool showAudioTools() const { return _showAudioTools; }

View file

@ -81,6 +81,10 @@ QVariantMap convertOverlayLocationFromScriptSemantics(const QVariantMap& propert
void Base3DOverlay::setProperties(const QVariantMap& originalProperties) { void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
QVariantMap properties = originalProperties; QVariantMap properties = originalProperties;
if (properties["name"].isValid()) {
setName(properties["name"].toString());
}
// carry over some legacy keys // carry over some legacy keys
if (!properties["position"].isValid() && !properties["localPosition"].isValid()) { if (!properties["position"].isValid() && !properties["localPosition"].isValid()) {
if (properties["p1"].isValid()) { if (properties["p1"].isValid()) {
@ -207,6 +211,9 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
} }
QVariant Base3DOverlay::getProperty(const QString& property) { QVariant Base3DOverlay::getProperty(const QString& property) {
if (property == "name") {
return _name;
}
if (property == "position" || property == "start" || property == "p1" || property == "point") { if (property == "position" || property == "start" || property == "p1" || property == "point") {
return vec3toVariant(getPosition()); return vec3toVariant(getPosition());
} }

View file

@ -26,6 +26,9 @@ public:
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); } virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
void setOverlayID(OverlayID overlayID) override { setID(overlayID); } void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
virtual QString getName() const override { return QString("Overlay:") + _name; }
void setName(QString name) { _name = name; }
// getters // getters
virtual bool is3D() const override { return true; } virtual bool is3D() const override { return true; }
@ -74,6 +77,8 @@ protected:
bool _drawInFront; bool _drawInFront;
bool _isAA; bool _isAA;
bool _isGrabbable { false }; bool _isGrabbable { false };
QString _name;
}; };
#endif // hifi_Base3DOverlay_h #endif // hifi_Base3DOverlay_h

View file

@ -288,3 +288,10 @@ void ModelOverlay::locationChanged(bool tellPhysics) {
_model->setTranslation(getPosition()); _model->setTranslation(getPosition());
} }
} }
QString ModelOverlay::getName() const {
if (_name != "") {
return QString("Overlay:") + getType() + ":" + _name;
}
return QString("Overlay:") + getType() + ":" + _url.toString();
}

View file

@ -22,6 +22,8 @@ public:
static QString const TYPE; static QString const TYPE;
virtual QString getType() const override { return TYPE; } virtual QString getType() const override { return TYPE; }
virtual QString getName() const override;
ModelOverlay(); ModelOverlay();
ModelOverlay(const ModelOverlay* modelOverlay); ModelOverlay(const ModelOverlay* modelOverlay);

View file

@ -357,6 +357,8 @@ class AvatarData : public QObject, public SpatiallyNestable {
public: public:
virtual QString getName() const override { return QString("Avatar:") + _displayName; }
static const QString FRAME_NAME; static const QString FRAME_NAME;
static void fromFrame(const QByteArray& frameData, AvatarData& avatar, bool useFrameSkeleton = true); static void fromFrame(const QByteArray& frameData, AvatarData& avatar, bool useFrameSkeleton = true);

View file

@ -281,7 +281,7 @@ public:
float getAngularDamping() const; float getAngularDamping() const;
void setAngularDamping(float value); void setAngularDamping(float value);
QString getName() const; virtual QString getName() const override;
void setName(const QString& value); void setName(const QString& value);
QString getDebugName(); QString getDebugName();

View file

@ -407,9 +407,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
// return QUuid(); // return QUuid();
// } // }
bool entityFound { false };
_entityTree->withReadLock([&] { _entityTree->withReadLock([&] {
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
if (entity) { if (entity) {
entityFound = true;
// make sure the properties has a type, so that the encode can know which properties to include // make sure the properties has a type, so that the encode can know which properties to include
properties.setType(entity->getType()); properties.setType(entity->getType());
bool hasTerseUpdateChanges = properties.hasTerseUpdateChanges(); bool hasTerseUpdateChanges = properties.hasTerseUpdateChanges();
@ -464,6 +466,27 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
}); });
} }
}); });
if (!entityFound) {
// we've made an edit to an entity we don't know about, or to a non-entity. If it's a known non-entity,
// print a warning and don't send an edit packet to the entity-server.
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
if (parentFinder) {
bool success;
auto nestableWP = parentFinder->find(id, success, static_cast<SpatialParentTree*>(_entityTree.get()));
if (success) {
auto nestable = nestableWP.lock();
if (nestable) {
NestableType nestableType = nestable->getNestableType();
if (nestableType == NestableType::Overlay || nestableType == NestableType::Avatar) {
qCWarning(entities) << "attempted edit on non-entity: " << id << nestable->getName();
return QUuid(); // null UUID to indicate failure
}
}
}
}
}
// we queue edit packets even if we don't know about the entity. This is to allow AC agents
// to edit entities they know only by ID.
queueEntityMessage(PacketType::EntityEdit, entityID, properties); queueEntityMessage(PacketType::EntityEdit, entityID, properties);
return id; return id;
} }
@ -1515,6 +1538,24 @@ bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) {
return isChild; return isChild;
} }
QString EntityScriptingInterface::getNestableType(QUuid id) {
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
if (!parentFinder) {
return "unknown";
}
bool success;
SpatiallyNestableWeakPointer objectWP = parentFinder->find(id, success);
if (!success) {
return "unknown";
}
SpatiallyNestablePointer object = objectWP.lock();
if (!object) {
return "unknown";
}
NestableType nestableType = object->getNestableType();
return SpatiallyNestable::nestableTypeToString(nestableType);
}
QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) { QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
QVector<QUuid> result; QVector<QUuid> result;
if (!_entityTree) { if (!_entityTree) {

View file

@ -304,6 +304,8 @@ public slots:
Q_INVOKABLE QVector<QUuid> getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex); Q_INVOKABLE QVector<QUuid> getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex);
Q_INVOKABLE bool isChildOfParent(QUuid childID, QUuid parentID); Q_INVOKABLE bool isChildOfParent(QUuid childID, QUuid parentID);
Q_INVOKABLE QString getNestableType(QUuid id);
Q_INVOKABLE QUuid getKeyboardFocusEntity() const; Q_INVOKABLE QUuid getKeyboardFocusEntity() const;
Q_INVOKABLE void setKeyboardFocusEntity(QUuid id); Q_INVOKABLE void setKeyboardFocusEntity(QUuid id);

View file

@ -990,6 +990,17 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
entityItemID, properties); entityItemID, properties);
endDecode = usecTimestampNow(); endDecode = usecTimestampNow();
EntityItemPointer existingEntity;
if (!isAdd) {
// search for the entity by EntityItemID
startLookup = usecTimestampNow();
existingEntity = findEntityByEntityItemID(entityItemID);
endLookup = usecTimestampNow();
if (!existingEntity) {
// this is not an add-entity operation, and we don't know about the identified entity.
validEditPacket = false;
}
}
if (validEditPacket && !_entityScriptSourceWhitelist.isEmpty() && !properties.getScript().isEmpty()) { if (validEditPacket && !_entityScriptSourceWhitelist.isEmpty() && !properties.getScript().isEmpty()) {
bool passedWhiteList = false; bool passedWhiteList = false;
@ -1036,12 +1047,6 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
// If we got a valid edit packet, then it could be a new entity or it could be an update to // If we got a valid edit packet, then it could be a new entity or it could be an update to
// an existing entity... handle appropriately // an existing entity... handle appropriately
if (validEditPacket) { if (validEditPacket) {
// search for the entity by EntityItemID
startLookup = usecTimestampNow();
EntityItemPointer existingEntity = findEntityByEntityItemID(entityItemID);
endLookup = usecTimestampNow();
startFilter = usecTimestampNow(); startFilter = usecTimestampNow();
bool wasChanged = false; bool wasChanged = false;
// Having (un)lock rights bypasses the filter, unless it's a physics result. // Having (un)lock rights bypasses the filter, unless it's a physics result.

View file

@ -1138,3 +1138,17 @@ SpatiallyNestablePointer SpatiallyNestable::findByID(QUuid id, bool& success) {
} }
return parentWP.lock(); return parentWP.lock();
} }
QString SpatiallyNestable::nestableTypeToString(NestableType nestableType) {
switch(nestableType) {
case NestableType::Entity:
return "entity";
case NestableType::Avatar:
return "avatar";
case NestableType::Overlay:
return "overlay";
default:
return "unknown";
}
}

View file

@ -42,6 +42,8 @@ public:
virtual const QUuid getID() const; virtual const QUuid getID() const;
virtual void setID(const QUuid& id); virtual void setID(const QUuid& id);
virtual QString getName() const { return "SpatiallyNestable"; }
virtual const QUuid getParentID() const; virtual const QUuid getParentID() const;
virtual void setParentID(const QUuid& parentID); virtual void setParentID(const QUuid& parentID);
@ -62,6 +64,8 @@ public:
static glm::vec3 localToWorldAngularVelocity(const glm::vec3& angularVelocity, static glm::vec3 localToWorldAngularVelocity(const glm::vec3& angularVelocity,
const QUuid& parentID, int parentJointIndex, bool& success); const QUuid& parentID, int parentJointIndex, bool& success);
static QString nestableTypeToString(NestableType nestableType);
// world frame // world frame
virtual const Transform getTransform(bool& success, int depth = 0) const; virtual const Transform getTransform(bool& success, int depth = 0) const;
virtual const Transform getTransform() const; virtual const Transform getTransform() const;

View file

@ -3881,6 +3881,7 @@ function MyController(hand) {
// we appear to be holding something and this script isn't in a state that would be holding something. // we appear to be holding something and this script isn't in a state that would be holding something.
// unhook it. if we previously took note of this entity's parent, put it back where it was. This // unhook it. if we previously took note of this entity's parent, put it back where it was. This
// works around some problems that happen when more than one hand or avatar is passing something around. // works around some problems that happen when more than one hand or avatar is passing something around.
var childType = Entities.getNestableType(childID);
if (_this.previousParentID[childID]) { if (_this.previousParentID[childID]) {
var previousParentID = _this.previousParentID[childID]; var previousParentID = _this.previousParentID[childID];
var previousParentJointIndex = _this.previousParentJointIndex[childID]; var previousParentJointIndex = _this.previousParentJointIndex[childID];
@ -3898,7 +3899,7 @@ function MyController(hand) {
} }
_this.previouslyUnhooked[childID] = now; _this.previouslyUnhooked[childID] = now;
if (Overlays.getProperty(childID, "grabbable")) { if (childType == "overlay" && Overlays.getProperty(childID, "grabbable")) {
// only auto-unhook overlays that were flagged as grabbable. this avoids unhooking overlays // only auto-unhook overlays that were flagged as grabbable. this avoids unhooking overlays
// used in tutorial. // used in tutorial.
Overlays.editOverlay(childID, { Overlays.editOverlay(childID, {
@ -3906,12 +3907,20 @@ function MyController(hand) {
parentJointIndex: previousParentJointIndex parentJointIndex: previousParentJointIndex
}); });
} }
Entities.editEntity(childID, { parentID: previousParentID, parentJointIndex: previousParentJointIndex }); if (childType == "entity") {
Entities.editEntity(childID, {
parentID: previousParentID,
parentJointIndex: previousParentJointIndex
});
}
} else { } else {
Entities.editEntity(childID, { parentID: NULL_UUID }); if (childType == "entity") {
if (Overlays.getProperty(childID, "grabbable")) { Entities.editEntity(childID, { parentID: NULL_UUID });
Overlays.editOverlay(childID, { parentID: NULL_UUID }); } else if (childType == "overlay") {
if (Overlays.getProperty(childID, "grabbable")) {
Overlays.editOverlay(childID, { parentID: NULL_UUID });
}
} }
} }
} }

View file

@ -275,7 +275,8 @@ WebTablet.prototype.getLocation = function() {
}; };
WebTablet.prototype.setHomeButtonTexture = function() { WebTablet.prototype.setHomeButtonTexture = function() {
Entities.editEntity(this.tabletEntityID, {textures: JSON.stringify({"tex.close": HOME_BUTTON_TEXTURE})}); // TODO - is this still needed?
// Entities.editEntity(this.tabletEntityID, {textures: JSON.stringify({"tex.close": HOME_BUTTON_TEXTURE})});
}; };
WebTablet.prototype.setURL = function (url) { WebTablet.prototype.setURL = function (url) {
@ -338,7 +339,8 @@ WebTablet.prototype.geometryChanged = function (geometry) {
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
Entities.editEntity(this.tabletEntityID, tabletProperties); // TODO -- is this still needed?
// Entities.editEntity(this.tabletEntityID, tabletProperties);
} }
}; };
@ -439,7 +441,8 @@ WebTablet.prototype.onHmdChanged = function () {
var tabletProperties = {}; var tabletProperties = {};
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
Entities.editEntity(this.tabletEntityID, tabletProperties); // TODO -- is this still needed?
// Entities.editEntity(this.tabletEntityID, tabletProperties);
// Full scene FXAA should be disabled on the overlay when the tablet in desktop mode. // Full scene FXAA should be disabled on the overlay when the tablet in desktop mode.
// This should make the text more readable. // This should make the text more readable.
@ -530,7 +533,8 @@ WebTablet.prototype.cameraModeChanged = function (newMode) {
var tabletProperties = {}; var tabletProperties = {};
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
self.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); self.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
Entities.editEntity(self.tabletEntityID, tabletProperties); // TODO -- is this still needed?
// Entities.editEntity(self.tabletEntityID, tabletProperties);
} }
}; };

View file

@ -13,7 +13,7 @@
// //
/* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays, /* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays,
MyAvatar, Menu, Vec3 */ MyAvatar, Menu, AvatarInputs, Vec3 */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
var tabletRezzed = false; var tabletRezzed = false;
@ -25,9 +25,18 @@
var debugTablet = false; var debugTablet = false;
var tabletScalePercentage = 100.0; var tabletScalePercentage = 100.0;
UIWebTablet = null; UIWebTablet = null;
var MSECS_PER_SEC = 1000.0;
var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone";
var gTablet = null;
Script.include("../libraries/WebTablet.js"); Script.include("../libraries/WebTablet.js");
function checkTablet() {
if (gTablet === null) {
gTablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
}
}
function tabletIsValid() { function tabletIsValid() {
if (!UIWebTablet) { if (!UIWebTablet) {
return false; return false;
@ -49,7 +58,8 @@
} }
function getTabletScalePercentageFromSettings() { function getTabletScalePercentageFromSettings() {
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode; checkTablet()
var toolbarMode = gTablet.toolbarMode;
var tabletScalePercentage = DEFAULT_TABLET_SCALE; var tabletScalePercentage = DEFAULT_TABLET_SCALE;
if (!toolbarMode) { if (!toolbarMode) {
if (HMD.active) { if (HMD.active) {
@ -77,6 +87,7 @@
if (debugTablet) { if (debugTablet) {
print("TABLET rezzing"); print("TABLET rezzing");
} }
checkTablet()
tabletScalePercentage = getTabletScalePercentageFromSettings(); tabletScalePercentage = getTabletScalePercentageFromSettings();
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml",
@ -92,7 +103,8 @@
} }
function showTabletUI() { function showTabletUI() {
Tablet.getTablet("com.highfidelity.interface.tablet.system").tabletShown = true; checkTablet()
gTablet.tabletShown = true;
if (!tabletRezzed || !tabletIsValid()) { if (!tabletRezzed || !tabletIsValid()) {
closeTabletUI(); closeTabletUI();
@ -114,7 +126,8 @@
} }
function hideTabletUI() { function hideTabletUI() {
Tablet.getTablet("com.highfidelity.interface.tablet.system").tabletShown = false; checkTablet()
gTablet.tabletShown = false;
if (!UIWebTablet) { if (!UIWebTablet) {
return; return;
} }
@ -130,7 +143,8 @@
} }
function closeTabletUI() { function closeTabletUI() {
Tablet.getTablet("com.highfidelity.interface.tablet.system").tabletShown = false; checkTablet()
gTablet.tabletShown = false;
if (UIWebTablet) { if (UIWebTablet) {
if (UIWebTablet.onClose) { if (UIWebTablet.onClose) {
UIWebTablet.onClose(); UIWebTablet.onClose();
@ -149,17 +163,19 @@
print("TABLET closeTabletUI, UIWebTablet is null"); print("TABLET closeTabletUI, UIWebTablet is null");
} }
tabletRezzed = false; tabletRezzed = false;
gTablet = null
} }
function updateShowTablet() { function updateShowTablet() {
var MSECS_PER_SEC = 1000.0;
var now = Date.now(); var now = Date.now();
checkTablet()
// close the WebTablet if it we go into toolbar mode. // close the WebTablet if it we go into toolbar mode.
var tabletShown = Tablet.getTablet("com.highfidelity.interface.tablet.system").tabletShown; var tabletShown = gTablet.tabletShown;
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode; var toolbarMode = gTablet.toolbarMode;
var landscape = Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape; var landscape = gTablet.landscape;
if (tabletShown && toolbarMode) { if (tabletShown && toolbarMode) {
closeTabletUI(); closeTabletUI();
@ -167,18 +183,20 @@
return; return;
} }
//TODO: move to tablet qml?
if (tabletShown) { if (tabletShown) {
var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone";
var currentMicEnabled = !Menu.isOptionChecked(MUTE_MICROPHONE_MENU_ITEM); var currentMicEnabled = !Menu.isOptionChecked(MUTE_MICROPHONE_MENU_ITEM);
var currentMicLevel = getMicLevel(); var currentMicLevel = getMicLevel();
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); gTablet.updateMicEnabled(currentMicEnabled);
tablet.updateMicEnabled(currentMicEnabled); gTablet.updateAudioBar(currentMicLevel);
tablet.updateAudioBar(currentMicLevel);
} }
updateTabletWidthFromSettings(); if (validCheckTime - now > MSECS_PER_SEC/4) {
if (UIWebTablet) { //each 250ms should be just fine
UIWebTablet.setLandscape(landscape); updateTabletWidthFromSettings();
if (UIWebTablet) {
UIWebTablet.setLandscape(landscape);
}
} }
if (validCheckTime - now > MSECS_PER_SEC) { if (validCheckTime - now > MSECS_PER_SEC) {
@ -217,21 +235,20 @@
// also cause the stylus model to be loaded // also cause the stylus model to be loaded
var tmpStylusID = Overlays.addOverlay("model", { var tmpStylusID = Overlays.addOverlay("model", {
name: "stylus", name: "stylus",
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
loadPriority: 10.0, loadPriority: 10.0,
position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.1, z: -2})), position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.1, z: -2})),
dimensions: { x: 0.01, y: 0.01, z: 0.2 }, dimensions: { x: 0.01, y: 0.01, z: 0.2 },
solid: true, solid: true,
visible: true, visible: true,
ignoreRayIntersection: true, ignoreRayIntersection: true,
drawInFront: false, drawInFront: false,
lifetime: 3 lifetime: 3
}); });
Script.setTimeout(function() { Script.setTimeout(function() {
Overlays.deleteOverlay(tmpStylusID); Overlays.deleteOverlay(tmpStylusID);
}, 300); }, 300);
} else if (!tabletShown) { } else if (!tabletShown) {
hideTabletUI(); hideTabletUI();
} }
@ -246,7 +263,8 @@
} }
if (channel === "home") { if (channel === "home") {
if (UIWebTablet) { if (UIWebTablet) {
Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape = false; checkTablet()
gTablet.landscape = false;
} }
} }
} }
@ -257,30 +275,10 @@
Script.setInterval(updateShowTablet, 100); Script.setInterval(updateShowTablet, 100);
// Initialise variables used to calculate audio level
var accumulatedLevel = 0.0;
// Note: Might have to tweak the following two based on the rate we're getting the data
var AVERAGING_RATIO = 0.05;
// Calculate microphone level with the same scaling equation (log scale, exponentially averaged) in AvatarInputs and pal.js // Calculate microphone level with the same scaling equation (log scale, exponentially averaged) in AvatarInputs and pal.js
function getMicLevel() { function getMicLevel() {
var LOUDNESS_FLOOR = 11.0; //reuse already existing C++ code
var LOUDNESS_SCALE = 2.8 / 5.0; return AvatarInputs.loudnessToAudioLevel(MyAvatar.audioLoudness)
var LOG2 = Math.log(2.0);
var micLevel = 0.0;
accumulatedLevel = AVERAGING_RATIO * accumulatedLevel + (1 - AVERAGING_RATIO) * (MyAvatar.audioLoudness);
// Convert to log base 2
var logLevel = Math.log(accumulatedLevel + 1) / LOG2;
if (logLevel <= LOUDNESS_FLOOR) {
micLevel = logLevel / LOUDNESS_FLOOR * LOUDNESS_SCALE;
} else {
micLevel = (logLevel - (LOUDNESS_FLOOR - 1.0)) * LOUDNESS_SCALE;
}
if (micLevel > 1.0) {
micLevel = 1.0;
}
return micLevel;
} }
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {

View file

@ -42,7 +42,7 @@ const appIcon = path.join(__dirname, '../resources/console.png');
const DELETE_LOG_FILES_OLDER_THAN_X_SECONDS = 60 * 60 * 24 * 7; // 7 Days const DELETE_LOG_FILES_OLDER_THAN_X_SECONDS = 60 * 60 * 24 * 7; // 7 Days
const LOG_FILE_REGEX = /(domain-server|ac-monitor|ac)-.*-std(out|err).txt/; const LOG_FILE_REGEX = /(domain-server|ac-monitor|ac)-.*-std(out|err).txt/;
const HOME_CONTENT_URL = "http://cdn.highfidelity.com/content-sets/home-tutorial-28.tar.gz"; const HOME_CONTENT_URL = "http://cdn.highfidelity.com/content-sets/home-tutorial-RC39.tar.gz";
function getBuildInfo() { function getBuildInfo() {
var buildInfoPath = null; var buildInfoPath = null;