mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #3595 from Atlante45/attenuation_zones
Coefficients reordering
This commit is contained in:
commit
9ba636314e
6 changed files with 118 additions and 46 deletions
|
@ -194,20 +194,12 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(AudioMixerClientData* l
|
||||||
|
|
||||||
attenuationCoefficient *= offAxisCoefficient;
|
attenuationCoefficient *= offAxisCoefficient;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wantBreak = false;
|
|
||||||
float attenuationPerDoublingInDistance = _attenuationPerDoublingInDistance;
|
float attenuationPerDoublingInDistance = _attenuationPerDoublingInDistance;
|
||||||
foreach (const QString& source, _attenuationCoefficients.keys()) {
|
for (int i = 0; i < _zonesSettings.length(); ++i) {
|
||||||
if (_audioZones[source].contains(streamToAdd->getPosition())) {
|
if (_audioZones[_zonesSettings[i].source].contains(streamToAdd->getPosition()) &&
|
||||||
foreach (const QString& listener, _attenuationCoefficients[source].keys()) {
|
_audioZones[_zonesSettings[i].listener].contains(listeningNodeStream->getPosition())) {
|
||||||
if (_audioZones[listener].contains(listeningNodeStream->getPosition())) {
|
attenuationPerDoublingInDistance = _zonesSettings[i].coefficient;
|
||||||
attenuationPerDoublingInDistance = _attenuationCoefficients[source][listener];
|
|
||||||
wantBreak = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (wantBreak) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1025,21 +1017,18 @@ void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) {
|
||||||
coefficientObject.contains(LISTENER) &&
|
coefficientObject.contains(LISTENER) &&
|
||||||
coefficientObject.contains(COEFFICIENT)) {
|
coefficientObject.contains(COEFFICIENT)) {
|
||||||
|
|
||||||
bool ok;
|
ZonesSettings settings;
|
||||||
QString source = coefficientObject.value(SOURCE).toString();
|
|
||||||
QString listener = coefficientObject.value(LISTENER).toString();
|
|
||||||
float coefficient = coefficientObject.value(COEFFICIENT).toString().toFloat(&ok);
|
|
||||||
|
|
||||||
if (ok && coefficient >= 0.0f && coefficient <= 1.0f &&
|
bool ok;
|
||||||
_audioZones.contains(source) && _audioZones.contains(listener)) {
|
settings.source = coefficientObject.value(SOURCE).toString();
|
||||||
|
settings.listener = coefficientObject.value(LISTENER).toString();
|
||||||
|
settings.coefficient = coefficientObject.value(COEFFICIENT).toString().toFloat(&ok);
|
||||||
|
|
||||||
|
if (ok && settings.coefficient >= 0.0f && settings.coefficient <= 1.0f &&
|
||||||
|
_audioZones.contains(settings.source) && _audioZones.contains(settings.listener)) {
|
||||||
|
|
||||||
if (!_attenuationCoefficients.contains(source)) {
|
_zonesSettings.push_back(settings);
|
||||||
_attenuationCoefficients.insert(source, QHash<QString, float>());
|
qDebug() << "Added Coefficient:" << settings.source << settings.listener << settings.coefficient;
|
||||||
}
|
|
||||||
if (!_attenuationCoefficients[source].contains(listener)) {
|
|
||||||
_attenuationCoefficients[source].insert(listener, coefficient);
|
|
||||||
qDebug() << "Added Coefficient:" << source << listener << coefficient;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,14 @@ private:
|
||||||
int _numStatFrames;
|
int _numStatFrames;
|
||||||
int _sumListeners;
|
int _sumListeners;
|
||||||
int _sumMixes;
|
int _sumMixes;
|
||||||
|
|
||||||
QHash<QString, AABox> _audioZones;
|
QHash<QString, AABox> _audioZones;
|
||||||
QHash<QString, QHash<QString, float> > _attenuationCoefficients;
|
struct ZonesSettings {
|
||||||
|
QString source;
|
||||||
|
QString listener;
|
||||||
|
float coefficient;
|
||||||
|
};
|
||||||
|
QVector<ZonesSettings> _zonesSettings;
|
||||||
|
|
||||||
static InboundAudioStream::Settings _streamSettings;
|
static InboundAudioStream::Settings _streamSettings;
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@
|
||||||
"type": "table",
|
"type": "table",
|
||||||
"label": "Attenuation Coefficients",
|
"label": "Attenuation Coefficients",
|
||||||
"help": "In this table you can set custom attenuation coefficients between audio zones",
|
"help": "In this table you can set custom attenuation coefficients between audio zones",
|
||||||
"numbered": false,
|
"numbered": true,
|
||||||
|
"can_order": true,
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"name": "source",
|
"name": "source",
|
||||||
|
@ -158,7 +159,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "audio_buffer",
|
"name": "audio_buffer",
|
||||||
"label": "Audio Buffer",
|
"label": "Audio Buffers",
|
||||||
"assignment-types": [0],
|
"assignment-types": [0],
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,12 +79,19 @@ td.buttons {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.buttons .glyphicon {
|
td .glyphicon {
|
||||||
display: block;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td.add-del-buttons .glyphicon {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.reorder-buttons .glyphicon {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
tr.new-row {
|
tr.new-row {
|
||||||
color: #3c763d;
|
color: #3c763d;
|
||||||
background-color: #dff0d8;
|
background-color: #dff0d8;
|
||||||
|
|
|
@ -8,7 +8,15 @@ var Settings = {
|
||||||
ADD_ROW_SPAN_CLASSES: 'glyphicon glyphicon-plus add-row',
|
ADD_ROW_SPAN_CLASSES: 'glyphicon glyphicon-plus add-row',
|
||||||
DEL_ROW_BUTTON_CLASS: 'del-row',
|
DEL_ROW_BUTTON_CLASS: 'del-row',
|
||||||
DEL_ROW_SPAN_CLASSES: 'glyphicon glyphicon-remove del-row',
|
DEL_ROW_SPAN_CLASSES: 'glyphicon glyphicon-remove del-row',
|
||||||
|
MOVE_UP_BUTTON_CLASS: 'move-up',
|
||||||
|
MOVE_UP_SPAN_CLASSES: 'glyphicon glyphicon-chevron-up move-up',
|
||||||
|
MOVE_DOWN_BUTTON_CLASS: 'move-down',
|
||||||
|
MOVE_DOWN_SPAN_CLASSES: 'glyphicon glyphicon-chevron-down move-down',
|
||||||
TABLE_BUTTONS_CLASS: 'buttons',
|
TABLE_BUTTONS_CLASS: 'buttons',
|
||||||
|
ADD_DEL_BUTTONS_CLASS: 'add-del-buttons',
|
||||||
|
ADD_DEL_BUTTONS_CLASSES: 'buttons add-del-buttons',
|
||||||
|
REORDER_BUTTONS_CLASS: 'reorder-buttons',
|
||||||
|
REORDER_BUTTONS_CLASSES: 'buttons reorder-buttons',
|
||||||
NEW_ROW_CLASS: 'new-row'
|
NEW_ROW_CLASS: 'new-row'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,6 +118,14 @@ $(document).ready(function(){
|
||||||
$('#settings-form').on('click', '.' + Settings.DEL_ROW_BUTTON_CLASS, function(){
|
$('#settings-form').on('click', '.' + Settings.DEL_ROW_BUTTON_CLASS, function(){
|
||||||
deleteTableRow(this);
|
deleteTableRow(this);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$('#settings-form').on('click', '.' + Settings.MOVE_UP_BUTTON_CLASS, function(){
|
||||||
|
moveTableRow(this, true);
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#settings-form').on('click', '.' + Settings.MOVE_DOWN_BUTTON_CLASS, function(){
|
||||||
|
moveTableRow(this, false);
|
||||||
|
})
|
||||||
|
|
||||||
$('#settings-form').on('keypress', 'table input', function(e){
|
$('#settings-form').on('keypress', 'table input', function(e){
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode == 13) {
|
||||||
|
@ -120,7 +136,7 @@ $(document).ready(function(){
|
||||||
if (sibling.hasClass(Settings.DATA_COL_CLASS)) {
|
if (sibling.hasClass(Settings.DATA_COL_CLASS)) {
|
||||||
// set focus to next input
|
// set focus to next input
|
||||||
sibling.find('input').focus()
|
sibling.find('input').focus()
|
||||||
} else if (sibling.hasClass(Settings.TABLE_BUTTONS_CLASS)) {
|
} else if (sibling.hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) {
|
||||||
sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click()
|
sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click()
|
||||||
|
|
||||||
// set focus to the first input in the new row
|
// set focus to the first input in the new row
|
||||||
|
@ -239,6 +255,10 @@ $('body').on('click', '.save-button', function(e){
|
||||||
function makeTable(setting, setting_name, setting_value) {
|
function makeTable(setting, setting_name, setting_value) {
|
||||||
var isArray = !_.has(setting, 'key')
|
var isArray = !_.has(setting, 'key')
|
||||||
|
|
||||||
|
if (!isArray && setting.can_order) {
|
||||||
|
setting.can_order = false;
|
||||||
|
}
|
||||||
|
|
||||||
var html = (setting.label) ? "<label class='control-label'>" + setting.label + "</label>" : ""
|
var html = (setting.label) ? "<label class='control-label'>" + setting.label + "</label>" : ""
|
||||||
html += "<span class='help-block'>" + setting.help + "</span>"
|
html += "<span class='help-block'>" + setting.help + "</span>"
|
||||||
html += "<table class='table table-bordered' data-short-name='" + setting.name + "' name='" + setting_name
|
html += "<table class='table table-bordered' data-short-name='" + setting.name + "' name='" + setting_name
|
||||||
|
@ -259,7 +279,11 @@ function makeTable(setting, setting_name, setting_value) {
|
||||||
html += "<td class='data'><strong>" + col.label + "</strong></td>" // Data
|
html += "<td class='data'><strong>" + col.label + "</strong></td>" // Data
|
||||||
})
|
})
|
||||||
|
|
||||||
html += "<td class='buttons'></td></tr>"
|
if (setting.can_order) {
|
||||||
|
html += "<td class=" + Settings.REORDER_BUTTONS_CLASSES +
|
||||||
|
"><span class='glyphicon glyphicon-sort'></span></td>";
|
||||||
|
}
|
||||||
|
html += "<td class=" + Settings.ADD_DEL_BUTTONS_CLASSES + "></td></tr>"
|
||||||
|
|
||||||
// populate rows in the table from existing values
|
// populate rows in the table from existing values
|
||||||
var row_num = 1
|
var row_num = 1
|
||||||
|
@ -293,7 +317,13 @@ function makeTable(setting, setting_name, setting_value) {
|
||||||
html += "</td>"
|
html += "</td>"
|
||||||
})
|
})
|
||||||
|
|
||||||
html += "<td class='buttons'><span class='" + Settings.DEL_ROW_SPAN_CLASSES + "'></span></td>"
|
if (setting.can_order) {
|
||||||
|
html += "<td class='" + Settings.REORDER_BUTTONS_CLASSES+
|
||||||
|
"'><span class='" + Settings.MOVE_UP_SPAN_CLASSES + "'></span><span class='" +
|
||||||
|
Settings.MOVE_DOWN_SPAN_CLASSES + "'></span></td>"
|
||||||
|
}
|
||||||
|
html += "<td class='" + Settings.ADD_DEL_BUTTONS_CLASSES +
|
||||||
|
"'><span class='" + Settings.DEL_ROW_SPAN_CLASSES + "'></span></td>"
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
|
|
||||||
row_num++
|
row_num++
|
||||||
|
@ -324,8 +354,12 @@ function makeTableInputs(setting) {
|
||||||
<input type='text' class='form-control' placeholder='" + (col.placeholder ? col.placeholder : "") + "' value=''>\
|
<input type='text' class='form-control' placeholder='" + (col.placeholder ? col.placeholder : "") + "' value=''>\
|
||||||
</td>"
|
</td>"
|
||||||
})
|
})
|
||||||
|
|
||||||
html += "<td class='buttons'><span class='glyphicon glyphicon-plus " + Settings.ADD_ROW_BUTTON_CLASS + "'></span></td>"
|
if (setting.can_order) {
|
||||||
|
html += "<td class='" + Settings.REORDER_BUTTONS_CLASSES + "'></td>"
|
||||||
|
}
|
||||||
|
html += "<td class='" + Settings.ADD_DEL_BUTTONS_CLASSES +
|
||||||
|
"'><span class='glyphicon glyphicon-plus " + Settings.ADD_ROW_BUTTON_CLASS + "'></span></td>"
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
@ -418,7 +452,10 @@ function addTableRow(add_glyphicon) {
|
||||||
} else {
|
} else {
|
||||||
$(element).html(1)
|
$(element).html(1)
|
||||||
}
|
}
|
||||||
} else if ($(element).hasClass("buttons")) {
|
} else if ($(element).hasClass(Settings.REORDER_BUTTONS_CLASS)) {
|
||||||
|
$(element).html("<td class='" + Settings.REORDER_BUTTONS_CLASSES + "'><span class='" + Settings.MOVE_UP_SPAN_CLASSES +
|
||||||
|
"'></span><span class='" + Settings.MOVE_DOWN_SPAN_CLASSES + "'></span></td>")
|
||||||
|
} else if ($(element).hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) {
|
||||||
// Change buttons
|
// Change buttons
|
||||||
var span = $(element).children("span")
|
var span = $(element).children("span")
|
||||||
span.removeClass(Settings.ADD_ROW_SPAN_CLASSES)
|
span.removeClass(Settings.ADD_ROW_SPAN_CLASSES)
|
||||||
|
@ -499,7 +536,32 @@ function deleteTableRow(delete_glyphicon) {
|
||||||
|
|
||||||
// we need to fire a change event on one of the remaining inputs so that the sidebar badge is updated
|
// we need to fire a change event on one of the remaining inputs so that the sidebar badge is updated
|
||||||
badgeSidebarForDifferences($(table))
|
badgeSidebarForDifferences($(table))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveTableRow(move_glyphicon, move_up) {
|
||||||
|
var row = $(move_glyphicon).closest('tr')
|
||||||
|
|
||||||
|
var table = $(row).closest('table')
|
||||||
|
var isArray = table.data('setting-type') === 'array'
|
||||||
|
if (!isArray) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move_up) {
|
||||||
|
var prev_row = row.prev()
|
||||||
|
if (prev_row.hasClass(Settings.DATA_ROW_CLASS)) {
|
||||||
|
prev_row.before(row)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var next_row = row.next()
|
||||||
|
if (next_row.hasClass(Settings.DATA_ROW_CLASS)) {
|
||||||
|
next_row.after(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need to fire a change event on one of the remaining inputs so that the sidebar badge is updated
|
||||||
|
badgeSidebarForDifferences($(table))
|
||||||
|
}
|
||||||
|
|
||||||
function updateDataChangedForSiblingRows(row, forceTrue) {
|
function updateDataChangedForSiblingRows(row, forceTrue) {
|
||||||
// anytime a new row is added to an array we need to set data-changed for all sibling row inputs to true
|
// anytime a new row is added to an array we need to set data-changed for all sibling row inputs to true
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button id="advanced-toggle-button" class="btn btn-info">Show advanced</button>
|
<button id="advanced-toggle-button" hidden=true class="btn btn-info">Show advanced</button>
|
||||||
<button class="btn btn-success save-button">Save and restart</button>
|
<button class="btn btn-success save-button">Save and restart</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,25 +32,32 @@
|
||||||
|
|
||||||
<script id="panels-template" type="text/template">
|
<script id="panels-template" type="text/template">
|
||||||
<% _.each(descriptions, function(group){ %>
|
<% _.each(descriptions, function(group){ %>
|
||||||
<div class="panel panel-default" id="<%- group.name %>">
|
<% split_settings = _.partition(group.settings, function(value, index) { return !value.advanced }) %>
|
||||||
|
<% isAdvanced = _.isEmpty(split_settings[0]) %>
|
||||||
|
<% if (isAdvanced) { %>
|
||||||
|
<% $("a[href=#" + group.name + "]").addClass('advanced-setting').hide() %>
|
||||||
|
<% } %>
|
||||||
|
<div class="panel panel-default <%- (isAdvanced) ? 'advanced-setting' : '' %>" id="<%- group.name %>">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title"><%- group.label %></h3>
|
<h3 class="panel-title"><%- group.label %></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<% split_settings = _.partition(group.settings, function(value, index) { return !value.advanced }) %>
|
|
||||||
<% _.each(split_settings[0], function(setting) { %>
|
<% _.each(split_settings[0], function(setting) { %>
|
||||||
<%= getFormGroup(group.name, setting, values, false,
|
<%= getFormGroup(group.name, setting, values, false,
|
||||||
(_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %>
|
(_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% _.each(split_settings[1], function(setting) { %>
|
<% if (!_.isEmpty(split_settings[1])) { %>
|
||||||
<%= getFormGroup(group.name, setting, values, true,
|
<% $("#advanced-toggle-button").show() %>
|
||||||
(_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %>
|
<% _.each(split_settings[1], function(setting) { %>
|
||||||
<% }); %>
|
<%= getFormGroup(group.name, setting, values, true,
|
||||||
|
(_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %>
|
||||||
|
<% }); %>
|
||||||
|
<% }%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="panels"></div>
|
<div id="panels"></div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue