Merge branch 'master' of https://github.com/highfidelity/hifi into eye-correction

This commit is contained in:
Howard Stearns 2015-08-20 16:54:52 -07:00
commit 7a79abd278
9 changed files with 102 additions and 95 deletions

View file

@ -183,6 +183,24 @@ var CHECK_MARK_COLOR = {
this.onValueChanged(resetValue); this.onValueChanged(resetValue);
}; };
Slider.prototype.setMinValue = function(minValue) {
var currentValue = this.getValue();
this.minValue = minValue;
this.setValue(currentValue);
};
Slider.prototype.getMinValue = function() {
return this.minValue;
};
Slider.prototype.setMaxValue = function(maxValue) {
var currentValue = this.getValue();
this.maxValue = maxValue;
this.setValue(currentValue);
};
Slider.prototype.getMaxValue = function() {
return this.maxValue;
};
Slider.prototype.onValueChanged = function(value) {}; Slider.prototype.onValueChanged = function(value) {};
Slider.prototype.getHeight = function() { Slider.prototype.getHeight = function() {
@ -1396,6 +1414,14 @@ var CHECK_MARK_COLOR = {
return null; return null;
}; };
Panel.prototype.getWidget = function(name) {
var item = this.items[name];
if (item != null) {
return item.widget;
}
return null;
};
Panel.prototype.update = function(name) { Panel.prototype.update = function(name) {
var item = this.items[name]; var item = this.items[name];
if (item != null) { if (item != null) {

View file

@ -12,60 +12,56 @@ Script.include("cookies.js");
var panel = new Panel(10, 100); var panel = new Panel(10, 100);
panel.newSlider("Num Feed Opaques", 0, 1000, function CounterWidget(parentPanel, name, feedGetter, drawGetter, capSetter, capGetter) {
function(value) { }, this.subPanel = panel.newSubPanel(name);
function() { return Scene.getEngineNumFeedOpaqueItems(); },
function(value) { return (value); }
);
panel.newSlider("Num Drawn Opaques", 0, 1000, this.subPanel.newSlider("Num Feed", 0, 1,
function(value) { }, function(value) { },
function() { return Scene.getEngineNumDrawnOpaqueItems(); }, feedGetter,
function(value) { return (value); } function(value) { return (value); });
); this.subPanel.newSlider("Num Drawn", 0, 1,
function(value) { },
drawGetter,
function(value) { return (value); });
this.subPanel.newSlider("Max Drawn", -1, 1,
capSetter,
capGetter,
function(value) { return (value); });
panel.newSlider("Max Drawn Opaques", -1, 1000, this.update = function () {
var numFeed = this.subPanel.get("Num Feed");
this.subPanel.set("Num Feed", numFeed);
this.subPanel.set("Num Drawn", this.subPanel.get("Num Drawn"));
var numMax = Math.max(numFeed, 1);
this.subPanel.getWidget("Num Feed").setMaxValue(numMax);
this.subPanel.getWidget("Num Drawn").setMaxValue(numMax);
this.subPanel.getWidget("Max Drawn").setMaxValue(numMax);
};
};
var opaquesCounter = new CounterWidget(panel, "Opaques",
function () { return Scene.getEngineNumFeedOpaqueItems(); },
function () { return Scene.getEngineNumDrawnOpaqueItems(); },
function(value) { Scene.setEngineMaxDrawnOpaqueItems(value); }, function(value) { Scene.setEngineMaxDrawnOpaqueItems(value); },
function() { return Scene.getEngineMaxDrawnOpaqueItems(); }, function () { return Scene.getEngineMaxDrawnOpaqueItems(); }
function(value) { return (value); }
); );
panel.newSlider("Num Feed Transparents", 0, 100, var transparentsCounter = new CounterWidget(panel, "Transparents",
function(value) { }, function () { return Scene.getEngineNumFeedTransparentItems(); },
function() { return Scene.getEngineNumFeedTransparentItems(); }, function () { return Scene.getEngineNumDrawnTransparentItems(); },
function(value) { return (value); }
);
panel.newSlider("Num Drawn Transparents", 0, 100,
function(value) { },
function() { return Scene.getEngineNumDrawnTransparentItems(); },
function(value) { return (value); }
);
panel.newSlider("Max Drawn Transparents", -1, 100,
function(value) { Scene.setEngineMaxDrawnTransparentItems(value); }, function(value) { Scene.setEngineMaxDrawnTransparentItems(value); },
function() { return Scene.getEngineMaxDrawnTransparentItems(); }, function () { return Scene.getEngineMaxDrawnTransparentItems(); }
function(value) { return (value); }
); );
panel.newSlider("Num Feed Overlay3Ds", 0, 100, var overlaysCounter = new CounterWidget(panel, "Overlays",
function(value) { }, function () { return Scene.getEngineNumFeedOverlay3DItems(); },
function() { return Scene.getEngineNumFeedOverlay3DItems(); }, function () { return Scene.getEngineNumDrawnOverlay3DItems(); },
function(value) { return (value); }
);
panel.newSlider("Num Drawn Overlay3Ds", 0, 100,
function(value) { },
function() { return Scene.getEngineNumDrawnOverlay3DItems(); },
function(value) { return (value); }
);
panel.newSlider("Max Drawn Overlay3Ds", -1, 100,
function(value) { Scene.setEngineMaxDrawnOverlay3DItems(value); }, function(value) { Scene.setEngineMaxDrawnOverlay3DItems(value); },
function() { return Scene.getEngineMaxDrawnOverlay3DItems(); }, function () { return Scene.getEngineMaxDrawnOverlay3DItems(); }
function(value) { return (value); }
); );
panel.newCheckbox("Display status", panel.newCheckbox("Display status",
function(value) { Scene.setEngineDisplayItemStatus(value); }, function(value) { Scene.setEngineDisplayItemStatus(value); },
function() { return Scene.doEngineDisplayItemStatus(); }, function() { return Scene.doEngineDisplayItemStatus(); },
@ -75,31 +71,9 @@ panel.newCheckbox("Display status",
var tickTackPeriod = 500; var tickTackPeriod = 500;
function updateCounters() { function updateCounters() {
var numFeedOpaques = panel.get("Num Feed Opaques"); opaquesCounter.update();
var numFeedTransparents = panel.get("Num Feed Transparents"); transparentsCounter.update();
var numFeedOverlay3Ds = panel.get("Num Feed Overlay3Ds"); overlaysCounter.update();
panel.set("Num Feed Opaques", numFeedOpaques);
panel.set("Num Drawn Opaques", panel.get("Num Drawn Opaques"));
panel.set("Num Feed Transparents", numFeedTransparents);
panel.set("Num Drawn Transparents", panel.get("Num Drawn Transparents"));
panel.set("Num Feed Overlay3Ds", numFeedOverlay3Ds);
panel.set("Num Drawn Overlay3Ds", panel.get("Num Drawn Overlay3Ds"));
var numMax = Math.max(numFeedOpaques * 1.2, 1);
panel.getWidget("Num Feed Opaques").setMaxValue(numMax);
panel.getWidget("Num Drawn Opaques").setMaxValue(numMax);
panel.getWidget("Max Drawn Opaques").setMaxValue(numMax);
numMax = Math.max(numFeedTransparents * 1.2, 1);
panel.getWidget("Num Feed Transparents").setMaxValue(numMax);
panel.getWidget("Num Drawn Transparents").setMaxValue(numMax);
panel.getWidget("Max Drawn Transparents").setMaxValue(numMax);
numMax = Math.max(numFeedOverlay3Ds * 1.2, 1);
panel.getWidget("Num Feed Overlay3Ds").setMaxValue(numMax);
panel.getWidget("Num Drawn Overlay3Ds").setMaxValue(numMax);
panel.getWidget("Max Drawn Overlay3Ds").setMaxValue(numMax);
} }
Script.setInterval(updateCounters, tickTackPeriod); Script.setInterval(updateCounters, tickTackPeriod);

View file

@ -444,6 +444,7 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderFocusIndicator, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderFocusIndicator, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowWhosLookingAtMe, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowWhosLookingAtMe, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, addCheckableActionToQMenuAndActionHash(avatarDebugMenu,
MenuOption::Connexion, MenuOption::Connexion,
0, false, 0, false,

View file

@ -168,6 +168,7 @@ namespace MenuOption {
const QString DecreaseAvatarSize = "Decrease Avatar Size"; const QString DecreaseAvatarSize = "Decrease Avatar Size";
const QString DeleteBookmark = "Delete Bookmark..."; const QString DeleteBookmark = "Delete Bookmark...";
const QString DisableActivityLogger = "Disable Activity Logger"; const QString DisableActivityLogger = "Disable Activity Logger";
const QString DisableEyelidAdjustment = "Disable Eyelid Adjustment";
const QString DisableLightEntities = "Disable Light Entities"; const QString DisableLightEntities = "Disable Light Entities";
const QString DisableNackPackets = "Disable Entity NACK Packets"; const QString DisableNackPackets = "Disable Entity NACK Packets";
const QString DiskCacheEditor = "Disk Cache Editor"; const QString DiskCacheEditor = "Disk Cache Editor";

View file

@ -277,6 +277,10 @@ void Head::calculateMouthShapes() {
void Head::applyEyelidOffset(glm::quat headOrientation) { void Head::applyEyelidOffset(glm::quat headOrientation) {
// Adjusts the eyelid blendshape coefficients so that the eyelid follows the iris as the head pitches. // Adjusts the eyelid blendshape coefficients so that the eyelid follows the iris as the head pitches.
if (Menu::getInstance()->isOptionChecked(MenuOption::DisableEyelidAdjustment)) {
return;
}
glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FRONT, getLookAtPosition() - _eyePosition); glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FRONT, getLookAtPosition() - _eyePosition);
eyeRotation = eyeRotation * glm::angleAxis(safeEulerAngles(headOrientation).y, IDENTITY_UP); // Rotation w.r.t. head eyeRotation = eyeRotation * glm::angleAxis(safeEulerAngles(headOrientation).y, IDENTITY_UP); // Rotation w.r.t. head
float eyePitch = safeEulerAngles(eyeRotation).x; float eyePitch = safeEulerAngles(eyeRotation).x;

View file

@ -77,9 +77,9 @@ void AudioInjector::injectAudio() {
int byteOffset = (int) floorf(AudioConstants::SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f)); int byteOffset = (int) floorf(AudioConstants::SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f));
byteOffset *= sizeof(int16_t); byteOffset *= sizeof(int16_t);
_currentSendPosition = byteOffset; _currentSendOffset = byteOffset;
} else { } else {
_currentSendPosition = 0; _currentSendOffset = 0;
} }
if (_options.localOnly) { if (_options.localOnly) {
@ -119,7 +119,7 @@ void AudioInjector::injectLocally() {
_localBuffer->setVolume(_options.volume); _localBuffer->setVolume(_options.volume);
// give our current send position to the local buffer // give our current send position to the local buffer
_localBuffer->setCurrentOffset(_currentSendPosition); _localBuffer->setCurrentOffset(_currentSendOffset);
success = _localAudioInterface->outputLocalInjector(_options.stereo, this); success = _localAudioInterface->outputLocalInjector(_options.stereo, this);
@ -144,9 +144,9 @@ void AudioInjector::injectLocally() {
const uchar MAX_INJECTOR_VOLUME = 0xFF; const uchar MAX_INJECTOR_VOLUME = 0xFF;
void AudioInjector::injectToMixer() { void AudioInjector::injectToMixer() {
if (_currentSendPosition < 0 || if (_currentSendOffset < 0 ||
_currentSendPosition >= _audioData.size()) { _currentSendOffset >= _audioData.size()) {
_currentSendPosition = 0; _currentSendOffset = 0;
} }
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
@ -203,15 +203,15 @@ void AudioInjector::injectToMixer() {
// loop to send off our audio in NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL byte chunks // loop to send off our audio in NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL byte chunks
quint16 outgoingInjectedAudioSequenceNumber = 0; quint16 outgoingInjectedAudioSequenceNumber = 0;
while (_currentSendPosition < _audioData.size() && !_shouldStop) { while (_currentSendOffset < _audioData.size() && !_shouldStop) {
int bytesToCopy = std::min(((_options.stereo) ? 2 : 1) * AudioConstants::NETWORK_FRAME_BYTES_PER_CHANNEL, int bytesToCopy = std::min(((_options.stereo) ? 2 : 1) * AudioConstants::NETWORK_FRAME_BYTES_PER_CHANNEL,
_audioData.size() - _currentSendPosition); _audioData.size() - _currentSendOffset);
// Measure the loudness of this frame // Measure the loudness of this frame
_loudness = 0.0f; _loudness = 0.0f;
for (int i = 0; i < bytesToCopy; i += sizeof(int16_t)) { for (int i = 0; i < bytesToCopy; i += sizeof(int16_t)) {
_loudness += abs(*reinterpret_cast<int16_t*>(_audioData.data() + _currentSendPosition + i)) / _loudness += abs(*reinterpret_cast<int16_t*>(_audioData.data() + _currentSendOffset + i)) /
(AudioConstants::MAX_SAMPLE_VALUE / 2.0f); (AudioConstants::MAX_SAMPLE_VALUE / 2.0f);
} }
_loudness /= (float)(bytesToCopy / sizeof(int16_t)); _loudness /= (float)(bytesToCopy / sizeof(int16_t));
@ -232,7 +232,7 @@ void AudioInjector::injectToMixer() {
audioPacket->seek(audioDataOffset); audioPacket->seek(audioDataOffset);
// copy the next NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL bytes to the packet // copy the next NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL bytes to the packet
audioPacket->write(_audioData.data() + _currentSendPosition, bytesToCopy); audioPacket->write(_audioData.data() + _currentSendOffset, bytesToCopy);
// set the correct size used for this packet // set the correct size used for this packet
audioPacket->setPayloadSize(audioPacket->pos()); audioPacket->setPayloadSize(audioPacket->pos());
@ -246,11 +246,11 @@ void AudioInjector::injectToMixer() {
outgoingInjectedAudioSequenceNumber++; outgoingInjectedAudioSequenceNumber++;
} }
_currentSendPosition += bytesToCopy; _currentSendOffset += bytesToCopy;
// send two packets before the first sleep so the mixer can start playback right away // send two packets before the first sleep so the mixer can start playback right away
if (_currentSendPosition != bytesToCopy && _currentSendPosition < _audioData.size()) { if (_currentSendOffset != bytesToCopy && _currentSendOffset < _audioData.size()) {
// process events in case we have been told to stop and be deleted // process events in case we have been told to stop and be deleted
QCoreApplication::processEvents(); QCoreApplication::processEvents();
@ -268,8 +268,8 @@ void AudioInjector::injectToMixer() {
} }
} }
if (shouldLoop && _currentSendPosition >= _audioData.size()) { if (shouldLoop && _currentSendOffset >= _audioData.size()) {
_currentSendPosition = 0; _currentSendOffset = 0;
} }
} }
} }

View file

@ -31,7 +31,6 @@ class AbstractAudioInterface;
class AudioInjector : public QObject { class AudioInjector : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(AudioInjectorOptions options WRITE setOptions READ getOptions)
public: public:
AudioInjector(QObject* parent); AudioInjector(QObject* parent);
AudioInjector(Sound* sound, const AudioInjectorOptions& injectorOptions); AudioInjector(Sound* sound, const AudioInjectorOptions& injectorOptions);
@ -39,7 +38,8 @@ public:
bool isFinished() const { return _isFinished; } bool isFinished() const { return _isFinished; }
int getCurrentSendPosition() const { return _currentSendPosition; } int getCurrentSendOffset() const { return _currentSendOffset; }
void setCurrentSendOffset(int currentSendOffset) { _currentSendOffset = currentSendOffset; }
AudioInjectorLocalBuffer* getLocalBuffer() const { return _localBuffer; } AudioInjectorLocalBuffer* getLocalBuffer() const { return _localBuffer; }
bool isLocalOnly() const { return _options.localOnly; } bool isLocalOnly() const { return _options.localOnly; }
@ -60,7 +60,6 @@ public slots:
const AudioInjectorOptions& getOptions() const { return _options; } const AudioInjectorOptions& getOptions() const { return _options; }
void setOptions(const AudioInjectorOptions& options) { _options = options; } void setOptions(const AudioInjectorOptions& options) { _options = options; }
void setCurrentSendPosition(int currentSendPosition) { _currentSendPosition = currentSendPosition; }
float getLoudness() const { return _loudness; } float getLoudness() const { return _loudness; }
bool isPlaying() const { return _isPlaying; } bool isPlaying() const { return _isPlaying; }
void restartPortionAfterFinished(); void restartPortionAfterFinished();
@ -82,7 +81,7 @@ private:
bool _isStarted = false; bool _isStarted = false;
bool _isFinished = false; bool _isFinished = false;
bool _shouldDeleteAfterFinish = false; bool _shouldDeleteAfterFinish = false;
int _currentSendPosition = 0; int _currentSendOffset = 0;
AbstractAudioInterface* _localAudioInterface = NULL; AbstractAudioInterface* _localAudioInterface = NULL;
AudioInjectorLocalBuffer* _localBuffer = NULL; AudioInjectorLocalBuffer* _localBuffer = NULL;
}; };

View file

@ -371,7 +371,7 @@ void Player::setAudioInjectorPosition() {
int MSEC_PER_SEC = 1000; int MSEC_PER_SEC = 1000;
int FRAME_SIZE = sizeof(AudioConstants::AudioSample) * _recording->numberAudioChannel(); int FRAME_SIZE = sizeof(AudioConstants::AudioSample) * _recording->numberAudioChannel();
int currentAudioFrame = elapsed() * FRAME_SIZE * (AudioConstants::SAMPLE_RATE / MSEC_PER_SEC); int currentAudioFrame = elapsed() * FRAME_SIZE * (AudioConstants::SAMPLE_RATE / MSEC_PER_SEC);
_injector->setCurrentSendPosition(currentAudioFrame); _injector->setCurrentSendOffset(currentAudioFrame);
} }
void Player::setPlayFromCurrentLocation(bool playFromCurrentLocation) { void Player::setPlayFromCurrentLocation(bool playFromCurrentLocation) {

View file

@ -21,6 +21,7 @@ class ScriptAudioInjector : public QObject {
Q_PROPERTY(bool isPlaying READ isPlaying) Q_PROPERTY(bool isPlaying READ isPlaying)
Q_PROPERTY(float loudness READ getLoudness) Q_PROPERTY(float loudness READ getLoudness)
Q_PROPERTY(AudioInjectorOptions options WRITE setOptions READ getOptions)
public: public:
ScriptAudioInjector(AudioInjector* injector); ScriptAudioInjector(AudioInjector* injector);
~ScriptAudioInjector(); ~ScriptAudioInjector();
@ -28,6 +29,7 @@ public slots:
void restart() { _injector->restart(); } void restart() { _injector->restart(); }
void stop() { _injector->stop(); } void stop() { _injector->stop(); }
const AudioInjectorOptions& getOptions() const { return _injector->getOptions(); }
void setOptions(const AudioInjectorOptions& options) { _injector->setOptions(options); } void setOptions(const AudioInjectorOptions& options) { _injector->setOptions(options); }
float getLoudness() const { return _injector->getLoudness(); } float getLoudness() const { return _injector->getLoudness(); }