changes per feedback to quiet print debugs throughout

This commit is contained in:
humbletim 2017-06-23 13:09:22 -04:00
parent 0ef623ba06
commit d6eb77e815
3 changed files with 39 additions and 22 deletions

View file

@ -12,6 +12,8 @@
var require = Script.require; var require = Script.require;
var WANT_DEBUG = false;
var DopplegangerClass = require('./doppleganger.js'), var DopplegangerClass = require('./doppleganger.js'),
DopplegangerAttachments = require('./doppleganger-attachments.js'), DopplegangerAttachments = require('./doppleganger-attachments.js'),
modelHelper = require('./model-helper.js').modelHelper; modelHelper = require('./model-helper.js').modelHelper;
@ -57,7 +59,7 @@ var doppleganger = new DopplegangerClass({
var currentHash = dopplegangerAttachments.getAttachmentsHash(); var currentHash = dopplegangerAttachments.getAttachmentsHash();
if (currentHash !== lastHash) { if (currentHash !== lastHash) {
lastHash = currentHash; lastHash = currentHash;
print('app-doppleganger | detect attachment change'); debugPrint('app-doppleganger | detect attachment change');
dopplegangerAttachments.refreshAttachments(); dopplegangerAttachments.refreshAttachments();
} }
} }
@ -86,7 +88,7 @@ button.clicked.connect(doppleganger, 'toggle');
doppleganger.activeChanged.connect(function(active, reason) { doppleganger.activeChanged.connect(function(active, reason) {
if (button) { if (button) {
button.editProperties({ isActive: active }); button.editProperties({ isActive: active });
print('doppleganger.activeChanged', active, reason); debugPrint('doppleganger.activeChanged', active, reason);
} }
}); });
@ -101,9 +103,15 @@ doppleganger.modelLoaded.connect(function(error, result) {
// add debug indicators, but only if the user has configured the settings value // add debug indicators, but only if the user has configured the settings value
if (Settings.getValue('debug.doppleganger', false)) { if (Settings.getValue('debug.doppleganger', false)) {
WANT_DEBUG = true;
DopplegangerClass.addDebugControls(doppleganger); DopplegangerClass.addDebugControls(doppleganger);
} }
function debugPrint() {
if (WANT_DEBUG) {
print('app-doppleganger | ' + [].slice.call(arguments).join(' '));
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
UserActivityLogger.logAction('doppleganger_app_load'); UserActivityLogger.logAction('doppleganger_app_load');
@ -115,7 +123,7 @@ doppleganger.activeChanged.connect(function(active, reason) {
// user intentionally toggled the doppleganger // user intentionally toggled the doppleganger
UserActivityLogger.logAction('doppleganger_disable'); UserActivityLogger.logAction('doppleganger_disable');
} else { } else {
print('doppleganger stopped:', reason); debugPrint('doppleganger stopped:', reason);
UserActivityLogger.logAction('doppleganger_autodisable', { reason: reason }); UserActivityLogger.logAction('doppleganger_autodisable', { reason: reason });
} }
} }

View file

@ -5,6 +5,7 @@
module.exports = DopplegangerAttachments; module.exports = DopplegangerAttachments;
DopplegangerAttachments.version = '0.0.0'; DopplegangerAttachments.version = '0.0.0';
DopplegangerAttachments.WANT_DEBUG = false;
var _modelHelper = require('./model-helper.js'), var _modelHelper = require('./model-helper.js'),
modelHelper = _modelHelper.modelHelper, modelHelper = _modelHelper.modelHelper,
@ -15,6 +16,10 @@ function log() {
print('doppleganger-attachments | ' + [].slice.call(arguments).join(' ')); print('doppleganger-attachments | ' + [].slice.call(arguments).join(' '));
} }
function debugPrint() {
DopplegangerAttachments.WANT_DEBUG && log.apply(this, arguments);
}
function DopplegangerAttachments(doppleganger, options) { function DopplegangerAttachments(doppleganger, options) {
utils.assign(this, { utils.assign(this, {
_options: options, _options: options,
@ -24,7 +29,7 @@ function DopplegangerAttachments(doppleganger, options) {
attachmentsUpdated: utils.signal(function attachmentsUpdated(currentAttachments, previousAttachments){}), attachmentsUpdated: utils.signal(function attachmentsUpdated(currentAttachments, previousAttachments){}),
}); });
this._initialize(); this._initialize();
log('DopplegangerAttachments...', JSON.stringify(options)); debugPrint('DopplegangerAttachments...', JSON.stringify(options));
} }
DopplegangerAttachments.prototype = { DopplegangerAttachments.prototype = {
// "hash" the current attachments (so that changes can be detected) // "hash" the current attachments (so that changes can be detected)
@ -87,7 +92,7 @@ DopplegangerAttachments.prototype = {
jointNames = this.doppleganger.jointNames, jointNames = this.doppleganger.jointNames,
properties = modelHelper.getProperties(this.doppleganger.objectID); properties = modelHelper.getProperties(this.doppleganger.objectID);
log('DopplegangerAttachments..._createAttachmentObjects', JSON.stringify({ debugPrint('DopplegangerAttachments..._createAttachmentObjects', JSON.stringify({
type: properties.type, type: properties.type,
attachments: attachments.length, attachments: attachments.length,
parentID: parentID, parentID: parentID,
@ -96,7 +101,7 @@ DopplegangerAttachments.prototype = {
return attachments.map(utils.bind(this, function(attachment, i) { return attachments.map(utils.bind(this, function(attachment, i) {
var type = modelHelper.type(attachment.properties && attachment.properties.objectID); var type = modelHelper.type(attachment.properties && attachment.properties.objectID);
if (type === 'overlay') { if (type === 'overlay') {
log('skipping already-provisioned attachment object', type, attachment.properties && attachment.properties.name); debugPrint('skipping already-provisioned attachment object', type, attachment.properties && attachment.properties.name);
return attachment; return attachment;
} }
var jointIndex = attachment.$jointIndex, // jointNames.indexOf(attachment.jointName), var jointIndex = attachment.$jointIndex, // jointNames.indexOf(attachment.jointName),
@ -133,7 +138,7 @@ DopplegangerAttachments.prototype = {
modelHelper.deleteObject(objectID); modelHelper.deleteObject(objectID);
return objectID = null; return objectID = null;
} }
log('attachment model ('+modelHelper.type(result.objectID)+') is ready; # joints ==', debugPrint('attachment model ('+modelHelper.type(result.objectID)+') is ready; # joints ==',
result.jointNames && result.jointNames.length, result.naturalDimensions, result.objectID); result.jointNames && result.jointNames.length, result.naturalDimensions, result.objectID);
var properties = modelHelper.getProperties(result.objectID), var properties = modelHelper.getProperties(result.objectID),
naturalDimensions = attachment.properties.naturalDimensions = properties.naturalDimensions; naturalDimensions = attachment.properties.naturalDimensions = properties.naturalDimensions;

View file

@ -28,15 +28,15 @@ var _modelHelper = require('./model-helper.js'),
modelHelper = _modelHelper.modelHelper, modelHelper = _modelHelper.modelHelper,
ModelReadyWatcher = _modelHelper.ModelReadyWatcher; ModelReadyWatcher = _modelHelper.ModelReadyWatcher;
// @property {bool} - toggle verbose debug logging on/off
Doppleganger.WANT_DEBUG = false;
// @property {bool} - when set true, Script.update will be used instead of setInterval for syncing joint data // @property {bool} - when set true, Script.update will be used instead of setInterval for syncing joint data
Doppleganger.USE_SCRIPT_UPDATE = false; Doppleganger.USE_SCRIPT_UPDATE = false;
// @property {int} - the frame rate to target when using setInterval for joint updates // @property {int} - the frame rate to target when using setInterval for joint updates
Doppleganger.TARGET_FPS = 60; Doppleganger.TARGET_FPS = 60;
// @property {int} - the maximum time in seconds to wait for the model overlay to finish loading
Doppleganger.MAX_WAIT_SECS = 10;
// @class Doppleganger - Creates a new instance of a Doppleganger. // @class Doppleganger - Creates a new instance of a Doppleganger.
// @param {Avatar} [options.avatar=MyAvatar] - Avatar used to retrieve position and joint data. // @param {Avatar} [options.avatar=MyAvatar] - Avatar used to retrieve position and joint data.
// @param {bool} [options.mirrored=true] - Apply "symmetric mirroring" of Left/Right joints. // @param {bool} [options.mirrored=true] - Apply "symmetric mirroring" of Left/Right joints.
@ -64,10 +64,10 @@ Doppleganger.prototype = {
// @public @method - toggles doppleganger on/off // @public @method - toggles doppleganger on/off
toggle: function() { toggle: function() {
if (this.active) { if (this.active) {
log('toggling off'); debugPrint('toggling off');
this.stop(); this.stop();
} else { } else {
log('toggling on'); debugPrint('toggling on');
this.start(); this.start();
} }
return this.active; return this.active;
@ -92,7 +92,7 @@ Doppleganger.prototype = {
// note: this mismatch can happen when the avatar's model is actively changing // note: this mismatch can happen when the avatar's model is actively changing
if (size !== translations.length || if (size !== translations.length ||
(this.jointStateCount && size !== this.jointStateCount)) { (this.jointStateCount && size !== this.jointStateCount)) {
log('mismatched joint counts (avatar model likely changed)', size, translations.length, this.jointStateCount); debugPrint('mismatched joint counts (avatar model likely changed)', size, translations.length, this.jointStateCount);
this.stop('avatar_changed_joints'); this.stop('avatar_changed_joints');
return; return;
} }
@ -168,7 +168,7 @@ Doppleganger.prototype = {
Script.scriptEnding.connect(this, function() { Script.scriptEnding.connect(this, function() {
modelHelper.deleteObject(this.objectID); modelHelper.deleteObject(this.objectID);
}); });
log('doppleganger created; objectID =', this.objectID); debugPrint('doppleganger created; objectID =', this.objectID);
// trigger clean up (and stop updates) if the object gets deleted // trigger clean up (and stop updates) if the object gets deleted
this.onObjectDeleted = function(uuid) { this.onObjectDeleted = function(uuid) {
@ -193,14 +193,14 @@ Doppleganger.prototype = {
if (error) { if (error) {
return this.stop(error); return this.stop(error);
} }
log('model ('+modelHelper.type(this.objectID)+')' + ' is ready; # joints == ' + result.jointNames.length); debugPrint('model ('+modelHelper.type(this.objectID)+')' + ' is ready; # joints == ' + result.jointNames.length);
var naturalDimensions = modelHelper.getProperties(this.objectID, ['naturalDimensions']).naturalDimensions; var naturalDimensions = modelHelper.getProperties(this.objectID, ['naturalDimensions']).naturalDimensions;
log('naturalDimensions:', JSON.stringify(naturalDimensions)); debugPrint('naturalDimensions:', JSON.stringify(naturalDimensions));
var props = { visible: true }; var props = { visible: true };
if (naturalDimensions) { if (naturalDimensions) {
props.dimensions = Vec3.multiply(this.scale, naturalDimensions); props.dimensions = Vec3.multiply(this.scale, naturalDimensions);
} }
log('scaledDimensions:', this.scale, JSON.stringify(props.dimensions)); debugPrint('scaledDimensions:', this.scale, JSON.stringify(props.dimensions));
modelHelper.editObject(this.objectID, props); modelHelper.editObject(this.objectID, props);
if (!options.position) { if (!options.position) {
this.syncVerticalPosition(); this.syncVerticalPosition();
@ -250,7 +250,7 @@ Doppleganger.prototype = {
if (this.active) { if (this.active) {
this.activeChanged(this.active = false, reason); this.activeChanged(this.active = false, reason);
} else if (reason) { } else if (reason) {
log('already stopped so not triggering another activeChanged; latest reason was:', reason); debugPrint('already stopped so not triggering another activeChanged; latest reason was:', reason);
} }
}, },
// @public @method - Reposition the doppleganger so it sees "eye to eye" with the Avatar. // @public @method - Reposition the doppleganger so it sees "eye to eye" with the Avatar.
@ -263,7 +263,7 @@ Doppleganger.prototype = {
doppleJointIndex = modelHelper.getJointIndex(this.objectID, byJointName),// names.indexOf(byJointName), doppleJointIndex = modelHelper.getJointIndex(this.objectID, byJointName),// names.indexOf(byJointName),
doppleJointPosition = positions[doppleJointIndex]; doppleJointPosition = positions[doppleJointIndex];
print('........... doppleJointPosition', JSON.stringify({ debugPrint('........... doppleJointPosition', JSON.stringify({
byJointName: byJointName, byJointName: byJointName,
dopplePosition: dopplePosition, dopplePosition: dopplePosition,
doppleJointIndex: doppleJointIndex, doppleJointIndex: doppleJointIndex,
@ -276,7 +276,7 @@ Doppleganger.prototype = {
avatarJointPosition = this.avatar.getJointPosition(avatarJointIndex); avatarJointPosition = this.avatar.getJointPosition(avatarJointIndex);
var offset = (avatarJointPosition.y - doppleJointPosition.y); var offset = (avatarJointPosition.y - doppleJointPosition.y);
log('adjusting for offset', offset); debugPrint('adjusting for offset', offset);
if (properties.type === 'model') { if (properties.type === 'model') {
dopplePosition.y = avatarPosition.y + offset; dopplePosition.y = avatarPosition.y + offset;
} else { } else {
@ -290,11 +290,11 @@ Doppleganger.prototype = {
// @private @method - creates the update thread to synchronize joint data // @private @method - creates the update thread to synchronize joint data
_createUpdateThread: function() { _createUpdateThread: function() {
if (Doppleganger.USE_SCRIPT_UPDATE) { if (Doppleganger.USE_SCRIPT_UPDATE) {
log('creating Script.update thread'); debugPrint('creating Script.update thread');
this.onUpdate = this.update; this.onUpdate = this.update;
Script.update.connect(this, 'onUpdate'); Script.update.connect(this, 'onUpdate');
} else { } else {
log('creating Script.setInterval thread @ ~', Doppleganger.TARGET_FPS +'fps'); debugPrint('creating Script.setInterval thread @ ~', Doppleganger.TARGET_FPS +'fps');
var timeout = 1000 / Doppleganger.TARGET_FPS; var timeout = 1000 / Doppleganger.TARGET_FPS;
this._interval = Script.setInterval(bind(this, 'update'), timeout); this._interval = Script.setInterval(bind(this, 'update'), timeout);
} }
@ -369,6 +369,10 @@ function log() {
print('doppleganger | ' + [].slice.call(arguments).join(' ')); print('doppleganger | ' + [].slice.call(arguments).join(' '));
} }
function debugPrint() {
Doppleganger.WANT_DEBUG && log.apply(this, arguments);
}
// -- ADVANCED DEBUGGING -- // -- ADVANCED DEBUGGING --
// @function - Add debug joint indicators / extra debugging info. // @function - Add debug joint indicators / extra debugging info.
// @param {Doppleganger} - existing Doppleganger instance to add controls to // @param {Doppleganger} - existing Doppleganger instance to add controls to