mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 23:33:26 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into tot
This commit is contained in:
commit
cb1850e082
15 changed files with 233 additions and 156 deletions
|
@ -96,6 +96,7 @@ function printVector(string, vector) {
|
|||
|
||||
function shootBullet(position, velocity) {
|
||||
var BULLET_SIZE = 0.01;
|
||||
var BULLET_LIFETIME = 20.0;
|
||||
var BULLET_GRAVITY = -0.02;
|
||||
Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
|
@ -103,6 +104,7 @@ function shootBullet(position, velocity) {
|
|||
dimensions: { x: BULLET_SIZE, y: BULLET_SIZE, z: BULLET_SIZE },
|
||||
color: { red: 10, green: 10, blue: 10 },
|
||||
velocity: velocity,
|
||||
lifetime: BULLET_LIFETIME,
|
||||
gravity: { x: 0, y: BULLET_GRAVITY, z: 0 },
|
||||
damping: 0 });
|
||||
|
||||
|
@ -118,6 +120,7 @@ function shootBullet(position, velocity) {
|
|||
function shootTarget() {
|
||||
var TARGET_SIZE = 0.25;
|
||||
var TARGET_GRAVITY = -0.6;
|
||||
var TARGET_LIFETIME = 300.0;
|
||||
var TARGET_UP_VELOCITY = 3.0;
|
||||
var TARGET_FWD_VELOCITY = 5.0;
|
||||
var DISTANCE_TO_LAUNCH_FROM = 3.0;
|
||||
|
@ -140,7 +143,7 @@ function shootTarget() {
|
|||
color: { red: 0, green: 200, blue: 200 },
|
||||
velocity: velocity,
|
||||
gravity: { x: 0, y: TARGET_GRAVITY, z: 0 },
|
||||
lifetime: 1000.0,
|
||||
lifetime: TARGET_LIFETIME,
|
||||
damping: 0.99 });
|
||||
|
||||
// Record start time
|
||||
|
|
|
@ -205,7 +205,9 @@ SelectionDisplay = (function () {
|
|||
|
||||
var MINIMUM_DIMENSION = 0.001;
|
||||
|
||||
var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.015;
|
||||
var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.0075;
|
||||
|
||||
var showExtendedStretchHandles = false;
|
||||
|
||||
var spaceMode = SPACE_LOCAL;
|
||||
var mode = "UNKNOWN";
|
||||
|
@ -260,6 +262,7 @@ SelectionDisplay = (function () {
|
|||
var grabberColorFace = { red: 120, green: 120, blue: 120 };
|
||||
var grabberLineWidth = 0.5;
|
||||
var grabberSolid = true;
|
||||
var grabberMoveUpPosition = { x: 0, y: 0, z: 0 };
|
||||
|
||||
var grabberPropertiesCorner = {
|
||||
position: { x:0, y: 0, z: 0},
|
||||
|
@ -270,6 +273,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
dashed: false,
|
||||
lineWidth: grabberLineWidth,
|
||||
drawInFront: true,
|
||||
borderSize: 1.4,
|
||||
};
|
||||
|
||||
var grabberPropertiesEdge = {
|
||||
|
@ -281,6 +286,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
dashed: false,
|
||||
lineWidth: grabberLineWidth,
|
||||
drawInFront: true,
|
||||
borderSize: 1.4,
|
||||
};
|
||||
|
||||
var grabberPropertiesFace = {
|
||||
|
@ -292,6 +299,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
dashed: false,
|
||||
lineWidth: grabberLineWidth,
|
||||
drawInFront: true,
|
||||
borderSize: 1.4,
|
||||
};
|
||||
|
||||
var highlightBox = Overlays.addOverlay("cube", {
|
||||
|
@ -325,7 +334,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: true
|
||||
isFacingAvatar: true,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
// var normalLine = Overlays.addOverlay("line3d", {
|
||||
|
@ -532,7 +542,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: false
|
||||
isFacingAvatar: false,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
|
||||
|
@ -544,7 +555,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: false
|
||||
isFacingAvatar: false,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
|
||||
|
@ -556,7 +568,8 @@ SelectionDisplay = (function () {
|
|||
visible: false,
|
||||
size: 0.1,
|
||||
scale: 0.1,
|
||||
isFacingAvatar: false
|
||||
isFacingAvatar: false,
|
||||
drawInFront: true,
|
||||
});
|
||||
|
||||
var allOverlays = [
|
||||
|
@ -1056,21 +1069,23 @@ SelectionDisplay = (function () {
|
|||
EdgeFL = Vec3.sum(position, EdgeFL);
|
||||
|
||||
var stretchHandlesVisible = spaceMode == SPACE_LOCAL;
|
||||
var extendedStretchHandlesVisible = stretchHandlesVisible && showExtendedStretchHandles;
|
||||
Overlays.editOverlay(grabberLBN, { visible: stretchHandlesVisible, rotation: rotation, position: LBN });
|
||||
Overlays.editOverlay(grabberRBN, { visible: stretchHandlesVisible, rotation: rotation, position: RBN });
|
||||
Overlays.editOverlay(grabberLBF, { visible: stretchHandlesVisible, rotation: rotation, position: LBF });
|
||||
Overlays.editOverlay(grabberRBF, { visible: stretchHandlesVisible, rotation: rotation, position: RBF });
|
||||
Overlays.editOverlay(grabberLTN, { visible: stretchHandlesVisible, rotation: rotation, position: LTN });
|
||||
Overlays.editOverlay(grabberRTN, { visible: stretchHandlesVisible, rotation: rotation, position: RTN });
|
||||
Overlays.editOverlay(grabberLTF, { visible: stretchHandlesVisible, rotation: rotation, position: LTF });
|
||||
Overlays.editOverlay(grabberRTF, { visible: stretchHandlesVisible, rotation: rotation, position: RTF });
|
||||
|
||||
Overlays.editOverlay(grabberLTN, { visible: extendedStretchHandlesVisible, rotation: rotation, position: LTN });
|
||||
Overlays.editOverlay(grabberRTN, { visible: extendedStretchHandlesVisible, rotation: rotation, position: RTN });
|
||||
Overlays.editOverlay(grabberLTF, { visible: extendedStretchHandlesVisible, rotation: rotation, position: LTF });
|
||||
Overlays.editOverlay(grabberRTF, { visible: extendedStretchHandlesVisible, rotation: rotation, position: RTF });
|
||||
|
||||
Overlays.editOverlay(grabberTOP, { visible: stretchHandlesVisible, rotation: rotation, position: TOP });
|
||||
Overlays.editOverlay(grabberBOTTOM, { visible: stretchHandlesVisible, rotation: rotation, position: BOTTOM });
|
||||
Overlays.editOverlay(grabberLEFT, { visible: stretchHandlesVisible, rotation: rotation, position: LEFT });
|
||||
Overlays.editOverlay(grabberRIGHT, { visible: stretchHandlesVisible, rotation: rotation, position: RIGHT });
|
||||
Overlays.editOverlay(grabberNEAR, { visible: stretchHandlesVisible, rotation: rotation, position: NEAR });
|
||||
Overlays.editOverlay(grabberFAR, { visible: stretchHandlesVisible, rotation: rotation, position: FAR });
|
||||
Overlays.editOverlay(grabberLEFT, { visible: extendedStretchHandlesVisible, rotation: rotation, position: LEFT });
|
||||
Overlays.editOverlay(grabberRIGHT, { visible: extendedStretchHandlesVisible, rotation: rotation, position: RIGHT });
|
||||
Overlays.editOverlay(grabberNEAR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: NEAR });
|
||||
Overlays.editOverlay(grabberFAR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: FAR });
|
||||
|
||||
Overlays.editOverlay(selectionBox, {
|
||||
position: position,
|
||||
|
@ -1079,21 +1094,22 @@ SelectionDisplay = (function () {
|
|||
visible: !(mode == "ROTATE_YAW" || mode == "ROTATE_PITCH" || mode == "ROTATE_ROLL"),
|
||||
});
|
||||
|
||||
Overlays.editOverlay(grabberEdgeTR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTR });
|
||||
Overlays.editOverlay(grabberEdgeTL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTL });
|
||||
Overlays.editOverlay(grabberEdgeTF, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTF });
|
||||
Overlays.editOverlay(grabberEdgeTN, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeTN });
|
||||
Overlays.editOverlay(grabberEdgeTR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTR });
|
||||
Overlays.editOverlay(grabberEdgeTL, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTL });
|
||||
Overlays.editOverlay(grabberEdgeTF, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTF });
|
||||
Overlays.editOverlay(grabberEdgeTN, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeTN });
|
||||
Overlays.editOverlay(grabberEdgeBR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBR });
|
||||
Overlays.editOverlay(grabberEdgeBL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBL });
|
||||
Overlays.editOverlay(grabberEdgeBF, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBF });
|
||||
Overlays.editOverlay(grabberEdgeBN, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeBN });
|
||||
Overlays.editOverlay(grabberEdgeNR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeNR });
|
||||
Overlays.editOverlay(grabberEdgeNL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeNL });
|
||||
Overlays.editOverlay(grabberEdgeFR, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeFR });
|
||||
Overlays.editOverlay(grabberEdgeFL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeFL });
|
||||
Overlays.editOverlay(grabberEdgeNR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeNR });
|
||||
Overlays.editOverlay(grabberEdgeNL, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeNL });
|
||||
Overlays.editOverlay(grabberEdgeFR, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeFR });
|
||||
Overlays.editOverlay(grabberEdgeFL, { visible: extendedStretchHandlesVisible, rotation: rotation, position: EdgeFL });
|
||||
|
||||
var grabberMoveUpOffset = 0.1;
|
||||
Overlays.editOverlay(grabberMoveUp, { visible: activeTool == null || mode == "TRANSLATE_UP_DOWN", position: { x: position.x, y: position.y + worldTop + grabberMoveUpOffset, z: position.z } });
|
||||
grabberMoveUpPosition = { x: position.x, y: position.y + worldTop + grabberMoveUpOffset, z: position.z }
|
||||
Overlays.editOverlay(grabberMoveUp, { visible: activeTool == null || mode == "TRANSLATE_UP_DOWN" });
|
||||
};
|
||||
|
||||
that.setOverlaysVisible = function(isVisible) {
|
||||
|
@ -1505,10 +1521,10 @@ SelectionDisplay = (function () {
|
|||
addStretchTool(grabberEdgeTL, "STRETCH_EdgeTL", null, {x: -1, y: 1, z: 0});
|
||||
addStretchTool(grabberEdgeTF, "STRETCH_EdgeTF", null, {x: 0, y: 1, z: -1});
|
||||
addStretchTool(grabberEdgeTN, "STRETCH_EdgeTN", null, {x: 0, y: 1, z: 1});
|
||||
addStretchTool(grabberEdgeBR, "STRETCH_EdgeBR", null, {x: 1, y: -1, z: 0});
|
||||
addStretchTool(grabberEdgeBL, "STRETCH_EdgeBL", null, {x: -1, y: -1, z: 0});
|
||||
addStretchTool(grabberEdgeBF, "STRETCH_EdgeBF", null, {x: 0, y: -1, z: 1});
|
||||
addStretchTool(grabberEdgeBN, "STRETCH_EdgeBN", null, {x: 0, y: -1, z: -1});
|
||||
addStretchTool(grabberEdgeBR, "STRETCH_EdgeBR", null, {x: -1, y: 0, z: 0});
|
||||
addStretchTool(grabberEdgeBL, "STRETCH_EdgeBL", null, {x: 1, y: 0, z: 0});
|
||||
addStretchTool(grabberEdgeBF, "STRETCH_EdgeBF", null, {x: 0, y: 0, z: -1});
|
||||
addStretchTool(grabberEdgeBN, "STRETCH_EdgeBN", null, {x: 0, y: 0, z: 1});
|
||||
addStretchTool(grabberEdgeNR, "STRETCH_EdgeNR", null, {x: -1, y: 0, z: 1});
|
||||
addStretchTool(grabberEdgeNL, "STRETCH_EdgeNL", null, {x: 1, y: 0, z: 1});
|
||||
addStretchTool(grabberEdgeFR, "STRETCH_EdgeFR", null, {x: -1, y: 0, z: -1});
|
||||
|
@ -2287,7 +2303,7 @@ SelectionDisplay = (function () {
|
|||
size: grabberSize,
|
||||
});
|
||||
}
|
||||
var handleSize = Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 5;
|
||||
var handleSize = Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 10;
|
||||
Overlays.editOverlay(yawHandle, {
|
||||
scale: handleSize,
|
||||
});
|
||||
|
@ -2297,8 +2313,10 @@ SelectionDisplay = (function () {
|
|||
Overlays.editOverlay(rollHandle, {
|
||||
scale: handleSize,
|
||||
});
|
||||
var pos = Vec3.sum(grabberMoveUpPosition, { x: 0, y: Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 3, z: 0 });
|
||||
Overlays.editOverlay(grabberMoveUp, {
|
||||
scale: handleSize,
|
||||
position: pos,
|
||||
scale: handleSize / 2,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2836,7 +2836,12 @@ void Application::updateShadowMap() {
|
|||
// render JS/scriptable overlays
|
||||
{
|
||||
PerformanceTimer perfTimer("3dOverlays");
|
||||
_overlays.render3D(RenderArgs::SHADOW_RENDER_MODE);
|
||||
_overlays.render3D(false, RenderArgs::SHADOW_RENDER_MODE);
|
||||
}
|
||||
|
||||
{
|
||||
PerformanceTimer perfTimer("3dOverlaysFront");
|
||||
_overlays.render3D(true, RenderArgs::SHADOW_RENDER_MODE);
|
||||
}
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
@ -3051,7 +3056,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
// render JS/scriptable overlays
|
||||
{
|
||||
PerformanceTimer perfTimer("3dOverlays");
|
||||
_overlays.render3D();
|
||||
_overlays.render3D(false);
|
||||
}
|
||||
|
||||
// render the ambient occlusion effect if enabled
|
||||
|
@ -3135,6 +3140,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
// Render 3D overlays that should be drawn in front
|
||||
{
|
||||
PerformanceTimer perfTimer("3dOverlaysFront");
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
_overlays.render3D(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) {
|
||||
|
|
|
@ -989,7 +989,8 @@ void Audio::processReceivedSamples(const QByteArray& inputBuffer, QByteArray& ou
|
|||
QByteArray buffer = inputBuffer;
|
||||
|
||||
// Accumulate direct transmission of audio from sender to receiver
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncludeOriginal)) {
|
||||
bool includeOriginal = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncludeOriginal)
|
||||
if (includeOriginal) {
|
||||
emit preProcessOriginalInboundAudio(sampleTime, buffer, _desiredOutputFormat);
|
||||
addSpatialAudioToBuffer(sampleTime, buffer, numNetworkOutputSamples);
|
||||
}
|
||||
|
@ -1264,7 +1265,8 @@ void Audio::selectAudioSourceSine440() {
|
|||
}
|
||||
|
||||
void Audio::toggleAudioSpatialProcessing() {
|
||||
_processSpatialAudio = !_processSpatialAudio;
|
||||
// spatial audio disabled for now
|
||||
_processSpatialAudio = false; //!_processSpatialAudio;
|
||||
if (_processSpatialAudio) {
|
||||
_spatialAudioStart = 0;
|
||||
_spatialAudioFinish = 0;
|
||||
|
|
|
@ -66,10 +66,15 @@ AudioReflector::AudioReflector(QObject* parent) :
|
|||
}
|
||||
|
||||
bool AudioReflector::haveAttributesChanged() {
|
||||
bool withDiffusion = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions);
|
||||
bool dontDistanceAttenuate = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingDontDistanceAttenuate);
|
||||
bool alternateDistanceAttenuate = Menu::getInstance()->isOptionChecked(
|
||||
MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate);
|
||||
|
||||
// Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions);
|
||||
bool withDiffusion = true;
|
||||
|
||||
// Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingDontDistanceAttenuate);
|
||||
bool dontDistanceAttenuate = false;
|
||||
|
||||
//Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate);
|
||||
bool alternateDistanceAttenuate = false;
|
||||
|
||||
bool attributesChange = (_withDiffusion != withDiffusion
|
||||
|| _lastPreDelay != _preDelay
|
||||
|
@ -107,7 +112,8 @@ void AudioReflector::render() {
|
|||
calculateAllReflections();
|
||||
|
||||
// only render if we've been asked to do so
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingRenderPaths)) {
|
||||
bool renderPaths = false; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingRenderPaths)
|
||||
if (renderPaths) {
|
||||
drawRays();
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +122,8 @@ void AudioReflector::render() {
|
|||
// = 3ms per meter
|
||||
float AudioReflector::getDelayFromDistance(float distance) {
|
||||
float delay = (_soundMsPerMeter * distance);
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay)) {
|
||||
bool includePreDelay = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay)
|
||||
if (includePreDelay) {
|
||||
delay += _preDelay;
|
||||
}
|
||||
return delay;
|
||||
|
@ -126,12 +133,11 @@ float AudioReflector::getDelayFromDistance(float distance) {
|
|||
float AudioReflector::getDistanceAttenuationCoefficient(float distance) {
|
||||
|
||||
|
||||
bool doDistanceAttenuation = !Menu::getInstance()->isOptionChecked(
|
||||
MenuOption::AudioSpatialProcessingDontDistanceAttenuate);
|
||||
//!Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingDontDistanceAttenuate);
|
||||
bool doDistanceAttenuation = true;
|
||||
|
||||
bool originalFormula = !Menu::getInstance()->isOptionChecked(
|
||||
MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate);
|
||||
|
||||
//!Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate);
|
||||
bool originalFormula = true;
|
||||
|
||||
float distanceCoefficient = 1.0f;
|
||||
|
||||
|
@ -170,7 +176,8 @@ float AudioReflector::getDistanceAttenuationCoefficient(float distance) {
|
|||
}
|
||||
|
||||
glm::vec3 AudioReflector::getFaceNormal(BoxFace face) {
|
||||
bool wantSlightRandomness = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSlightlyRandomSurfaces);
|
||||
// Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSlightlyRandomSurfaces);
|
||||
bool wantSlightRandomness = true;
|
||||
glm::vec3 faceNormal;
|
||||
const float MIN_RANDOM_LENGTH = 0.99f;
|
||||
const float MAX_RANDOM_LENGTH = 1.0f;
|
||||
|
@ -202,8 +209,8 @@ const int NUMBER_OF_CHANNELS = 2;
|
|||
void AudioReflector::injectAudiblePoint(AudioSource source, const AudiblePoint& audiblePoint,
|
||||
const QByteArray& samples, unsigned int sampleTime, int sampleRate) {
|
||||
|
||||
bool wantEarSeparation = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSeparateEars);
|
||||
bool wantStereo = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingStereoSource);
|
||||
bool wantEarSeparation = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSeparateEars);
|
||||
bool wantStereo = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingStereoSource);
|
||||
glm::vec3 rightEarPosition = wantEarSeparation ? _myAvatar->getHead()->getRightEarPosition() :
|
||||
_myAvatar->getHead()->getPosition();
|
||||
glm::vec3 leftEarPosition = wantEarSeparation ? _myAvatar->getHead()->getLeftEarPosition() :
|
||||
|
@ -316,7 +323,8 @@ void AudioReflector::preProcessOriginalInboundAudio(unsigned int sampleTime,
|
|||
}
|
||||
|
||||
void AudioReflector::processLocalAudio(unsigned int sampleTime, const QByteArray& samples, const QAudioFormat& format) {
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio)) {
|
||||
bool processLocalAudio = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio)
|
||||
if (processLocalAudio) {
|
||||
const int NUM_CHANNELS_INPUT = 1;
|
||||
const int NUM_CHANNELS_OUTPUT = 2;
|
||||
const int EXPECTED_SAMPLE_RATE = 24000;
|
||||
|
@ -458,7 +466,7 @@ void AudioReflector::identifyAudioSources() {
|
|||
void AudioReflector::calculateAllReflections() {
|
||||
// only recalculate when we've moved, or if the attributes have changed
|
||||
// TODO: what about case where new voxels are added in front of us???
|
||||
bool wantHeadOrientation = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingHeadOriented);
|
||||
bool wantHeadOrientation = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingHeadOriented);
|
||||
glm::quat orientation = wantHeadOrientation ? _myAvatar->getHead()->getFinalOrientationInWorldFrame() : _myAvatar->getOrientation();
|
||||
glm::vec3 origin = _myAvatar->getHead()->getPosition();
|
||||
glm::vec3 listenerPosition = _myAvatar->getHead()->getPosition();
|
||||
|
@ -505,7 +513,8 @@ void AudioReflector::drawRays() {
|
|||
}
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio)) {
|
||||
bool processLocalAudio = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio)
|
||||
if (processLocalAudio) {
|
||||
// draw the paths for local audio
|
||||
foreach(AudioPath* const& path, _localAudioPaths) {
|
||||
// if this is an original reflection, draw it in RED
|
||||
|
@ -575,7 +584,8 @@ void AudioReflector::analyzePaths() {
|
|||
|
||||
float initialAttenuation = 1.0f;
|
||||
|
||||
float preDelay = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay) ? _preDelay : 0.0f;
|
||||
bool wantPreDelay = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay)
|
||||
float preDelay = wantPreDelay ? _preDelay : 0.0f;
|
||||
|
||||
// NOTE: we're still calculating our initial paths based on the listeners position. But the analysis code has been
|
||||
// updated to support individual sound sources (which is how we support diffusion), we can use this new paradigm to
|
||||
|
@ -701,7 +711,7 @@ void AudioReflector::handlePathPoint(AudioPath* path, float distance, OctreeElem
|
|||
float reflectiveAttenuation = currentReflectiveAttenuation * material.reflectiveRatio;
|
||||
float totalDiffusionAttenuation = currentReflectiveAttenuation * material.diffusionRatio;
|
||||
|
||||
bool wantDiffusions = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions);
|
||||
bool wantDiffusions = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions);
|
||||
int fanout = wantDiffusions ? _diffusionFanout : 0;
|
||||
|
||||
float partialDiffusionAttenuation = fanout < 1 ? 0.0f : totalDiffusionAttenuation / (float)fanout;
|
||||
|
|
|
@ -620,58 +620,6 @@ Menu::Menu() :
|
|||
audioScopeFramesGroup->addAction(fiftyFrames);
|
||||
}
|
||||
|
||||
QMenu* spatialAudioMenu = audioDebugMenu->addMenu("Spatial Audio");
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessing,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_M,
|
||||
false,
|
||||
appInstance->getAudio(),
|
||||
SLOT(toggleAudioSpatialProcessing()));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingIncludeOriginal,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_O,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingSeparateEars,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_E,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingPreDelay,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_D,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingStereoSource,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_S,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingHeadOriented,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_H,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingWithDiffusions,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_W,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingRenderPaths,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_R,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingSlightlyRandomSurfaces,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_X,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingProcessLocalAudio,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_A,
|
||||
true);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingDontDistanceAttenuate,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_Y,
|
||||
false);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(spatialAudioMenu, MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_U,
|
||||
false);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioStats,
|
||||
Qt::CTRL | Qt::Key_A,
|
||||
false,
|
||||
|
|
|
@ -341,18 +341,6 @@ namespace MenuOption {
|
|||
const QString AudioScopeTwentyFrames = "Twenty";
|
||||
const QString AudioStats = "Audio Stats";
|
||||
const QString AudioStatsShowInjectedStreams = "Audio Stats Show Injected Streams";
|
||||
const QString AudioSpatialProcessingAlternateDistanceAttenuate = "Alternate distance attenuation";
|
||||
const QString AudioSpatialProcessing = "Audio Spatial Processing";
|
||||
const QString AudioSpatialProcessingDontDistanceAttenuate = "Don't calculate distance attenuation";
|
||||
const QString AudioSpatialProcessingHeadOriented = "Head Oriented";
|
||||
const QString AudioSpatialProcessingIncludeOriginal = "Includes Network Original";
|
||||
const QString AudioSpatialProcessingPreDelay = "Add Pre-Delay";
|
||||
const QString AudioSpatialProcessingProcessLocalAudio = "Process Local Audio";
|
||||
const QString AudioSpatialProcessingRenderPaths = "Render Paths";
|
||||
const QString AudioSpatialProcessingSeparateEars = "Separate Ears";
|
||||
const QString AudioSpatialProcessingSlightlyRandomSurfaces = "Slightly Random Surfaces";
|
||||
const QString AudioSpatialProcessingStereoSource = "Stereo Source";
|
||||
const QString AudioSpatialProcessingWithDiffusions = "With Diffusions";
|
||||
const QString AudioSourceInject = "Generated Audio";
|
||||
const QString AudioSourcePinkNoise = "Pink Noise";
|
||||
const QString AudioSourceSine440 = "Sine 440hz";
|
||||
|
|
|
@ -460,7 +460,8 @@ void Stats::display(
|
|||
VoxelSystem* voxels = Application::getInstance()->getVoxels();
|
||||
|
||||
lines = _expanded ? 14 : 3;
|
||||
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessing)) {
|
||||
bool wantSpatialProcessing = false; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessing)
|
||||
if (_expanded && wantSpatialProcessing) {
|
||||
lines += 10; // spatial audio processing adds 1 spacing line and 8 extra lines of info
|
||||
}
|
||||
|
||||
|
@ -652,7 +653,7 @@ void Stats::display(
|
|||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
||||
}
|
||||
|
||||
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessing)) {
|
||||
if (_expanded && wantSpatialProcessing) {
|
||||
verticalOffset += STATS_PELS_PER_LINE; // space one line...
|
||||
|
||||
const AudioReflector* audioReflector = Application::getInstance()->getAudioReflector();
|
||||
|
@ -660,23 +661,24 @@ void Stats::display(
|
|||
// add some reflection stats
|
||||
char reflectionsStatus[128];
|
||||
|
||||
bool includeOriginal = true; //Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncludeOriginal)
|
||||
bool separateEars = true; //Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSeparateEars)
|
||||
bool stereoSource = true; //Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingStereoSource)
|
||||
bool randomSurfaces = true; //Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSlightlyRandomSurfaces)
|
||||
|
||||
sprintf(reflectionsStatus, "Reflections: %d, Original: %s, Ears: %s, Source: %s, Normals: %s",
|
||||
audioReflector->getReflections(),
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncludeOriginal)
|
||||
? "included" : "silent"),
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSeparateEars)
|
||||
? "two" : "one"),
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingStereoSource)
|
||||
? "stereo" : "mono"),
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSlightlyRandomSurfaces)
|
||||
? "random" : "regular")
|
||||
(includeOriginal ? "included" : "silent"),
|
||||
(separateEars ? "two" : "one"),
|
||||
(stereoSource ? "stereo" : "mono"),
|
||||
(randomSurfaces ? "random" : "regular")
|
||||
);
|
||||
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color);
|
||||
|
||||
float preDelay = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay) ?
|
||||
audioReflector->getPreDelay() : 0.0f;
|
||||
bool wantPreDelay = true; //Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay)
|
||||
float preDelay = wantPreDelay ? audioReflector->getPreDelay() : 0.0f;
|
||||
|
||||
sprintf(reflectionsStatus, "Delay: pre: %6.3f, average %6.3f, max %6.3f, min %6.3f, speed: %6.3f",
|
||||
preDelay,
|
||||
|
@ -688,12 +690,12 @@ void Stats::display(
|
|||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color);
|
||||
|
||||
bool distanceAttenuationDisabled = Menu::getInstance()->isOptionChecked(
|
||||
MenuOption::AudioSpatialProcessingDontDistanceAttenuate);
|
||||
|
||||
bool alternateDistanceAttenuationEnabled = Menu::getInstance()->isOptionChecked(
|
||||
MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate);
|
||||
//Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingDontDistanceAttenuate);
|
||||
bool distanceAttenuationDisabled = false;
|
||||
|
||||
// Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingAlternateDistanceAttenuate);
|
||||
bool alternateDistanceAttenuationEnabled = false;
|
||||
|
||||
sprintf(reflectionsStatus, "Attenuation: average %5.3f, max %5.3f, min %5.3f, %s: %5.3f",
|
||||
audioReflector->getAverageAttenuation(),
|
||||
|
@ -706,15 +708,14 @@ void Stats::display(
|
|||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color);
|
||||
|
||||
sprintf(reflectionsStatus, "Local Audio: %s Attenuation: %5.3f",
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio)
|
||||
? "yes" : "no"),
|
||||
bool localAudio = true; // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio);
|
||||
sprintf(reflectionsStatus, "Local Audio: %s Attenuation: %5.3f", (localAudio ? "yes" : "no"),
|
||||
audioReflector->getLocalAudioAttenuationFactor());
|
||||
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color);
|
||||
|
||||
bool diffusionEnabled = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions);
|
||||
bool diffusionEnabled = true; //Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions);
|
||||
int fanout = diffusionEnabled ? audioReflector->getDiffusionFanout() : 0;
|
||||
int diffusionPaths = diffusionEnabled ? audioReflector->getDiffusionPathCount() : 0;
|
||||
sprintf(reflectionsStatus, "Diffusion: %s, Fanout: %d, Paths: %d",
|
||||
|
|
|
@ -27,7 +27,8 @@ Base3DOverlay::Base3DOverlay() :
|
|||
_rotation(),
|
||||
_isSolid(DEFAULT_IS_SOLID),
|
||||
_isDashedLine(DEFAULT_IS_DASHED_LINE),
|
||||
_ignoreRayIntersection(false)
|
||||
_ignoreRayIntersection(false),
|
||||
_drawInFront(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,6 +49,13 @@ Base3DOverlay::~Base3DOverlay() {
|
|||
void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
Overlay::setProperties(properties);
|
||||
|
||||
QScriptValue drawInFront = properties.property("drawInFront");
|
||||
|
||||
if (drawInFront.isValid()) {
|
||||
bool value = drawInFront.toVariant().toBool();
|
||||
setDrawInFront(value);
|
||||
}
|
||||
|
||||
QScriptValue position = properties.property("position");
|
||||
|
||||
// if "position" property was not there, check to see if they included aliases: start, point, p1
|
||||
|
@ -151,6 +159,9 @@ QScriptValue Base3DOverlay::getProperty(const QString& property) {
|
|||
if (property == "ignoreRayIntersection") {
|
||||
return _ignoreRayIntersection;
|
||||
}
|
||||
if (property == "drawInFront") {
|
||||
return _drawInFront;
|
||||
}
|
||||
|
||||
return Overlay::getProperty(property);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
bool getIsSolidLine() const { return !_isDashedLine; }
|
||||
const glm::quat& getRotation() const { return _rotation; }
|
||||
bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; }
|
||||
bool getDrawInFront() const { return _drawInFront; }
|
||||
|
||||
// setters
|
||||
void setPosition(const glm::vec3& position) { _position = position; }
|
||||
|
@ -44,6 +45,7 @@ public:
|
|||
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
|
||||
void setRotation(const glm::quat& value) { _rotation = value; }
|
||||
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
|
||||
void setDrawInFront(bool value) { _drawInFront = value; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
@ -64,6 +66,7 @@ protected:
|
|||
bool _isSolid;
|
||||
bool _isDashedLine;
|
||||
bool _ignoreRayIntersection;
|
||||
bool _drawInFront;
|
||||
};
|
||||
|
||||
#endif // hifi_Base3DOverlay_h
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "Cube3DOverlay.h"
|
||||
#include "renderer/GlowEffect.h"
|
||||
|
||||
Cube3DOverlay::Cube3DOverlay() {
|
||||
Cube3DOverlay::Cube3DOverlay() : _borderSize(0) {
|
||||
}
|
||||
|
||||
Cube3DOverlay::Cube3DOverlay(const Cube3DOverlay* cube3DOverlay) :
|
||||
|
@ -63,8 +63,27 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
if (_isSolid) {
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||
if (_borderSize > 0) {
|
||||
// Draw a cube at a larger size behind the main cube, creating
|
||||
// a border effect.
|
||||
// Disable writing to the depth mask so that the "border" cube will not
|
||||
// occlude the main cube. This means the border could be covered by
|
||||
// overlays that are further back and drawn later, but this is good
|
||||
// enough for the use-case.
|
||||
glDepthMask(GL_FALSE);
|
||||
glPushMatrix();
|
||||
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||
glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize);
|
||||
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||
glPopMatrix();
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||
glPopMatrix();
|
||||
} else {
|
||||
glLineWidth(_lineWidth);
|
||||
|
||||
|
@ -111,3 +130,22 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
Cube3DOverlay* Cube3DOverlay::createClone() const {
|
||||
return new Cube3DOverlay(this);
|
||||
}
|
||||
|
||||
void Cube3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
Volume3DOverlay::setProperties(properties);
|
||||
|
||||
QScriptValue borderSize = properties.property("borderSize");
|
||||
|
||||
if (borderSize.isValid()) {
|
||||
float value = borderSize.toVariant().toFloat();
|
||||
setBorderSize(value);
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue Cube3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "borderSize") {
|
||||
return _borderSize;
|
||||
}
|
||||
|
||||
return Volume3DOverlay::getProperty(property);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,16 @@ public:
|
|||
virtual void render(RenderArgs* args);
|
||||
|
||||
virtual Cube3DOverlay* createClone() const;
|
||||
|
||||
float getBorderSize() const { return _borderSize; }
|
||||
|
||||
void setBorderSize(float value) { _borderSize = value; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
private:
|
||||
float _borderSize;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void Overlays::render2D() {
|
|||
}
|
||||
}
|
||||
|
||||
void Overlays::render3D(RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
|
||||
void Overlays::render3D(bool drawFront, RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
|
||||
QReadLocker lock(&_lock);
|
||||
if (_overlays3D.size() == 0) {
|
||||
return;
|
||||
|
@ -112,6 +112,10 @@ void Overlays::render3D(RenderArgs::RenderMode renderMode, RenderArgs::RenderSid
|
|||
|
||||
|
||||
foreach(Overlay* thisOverlay, _overlays3D) {
|
||||
Base3DOverlay* overlay3D = static_cast<Base3DOverlay*>(thisOverlay);
|
||||
if (overlay3D->getDrawInFront() != drawFront) {
|
||||
continue;
|
||||
}
|
||||
glPushMatrix();
|
||||
switch (thisOverlay->getAnchor()) {
|
||||
case Overlay::MY_AVATAR:
|
||||
|
@ -301,6 +305,7 @@ void OverlayPropertyResultFromScriptValue(const QScriptValue& value, OverlayProp
|
|||
|
||||
RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) {
|
||||
float bestDistance = std::numeric_limits<float>::max();
|
||||
bool bestIsFront = false;
|
||||
RayToOverlayIntersectionResult result;
|
||||
QMapIterator<unsigned int, Overlay*> i(_overlays3D);
|
||||
i.toBack();
|
||||
|
@ -313,7 +318,9 @@ RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray)
|
|||
BoxFace thisFace;
|
||||
QString thisExtraInfo;
|
||||
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance, thisFace, thisExtraInfo)) {
|
||||
if (thisDistance < bestDistance) {
|
||||
bool isDrawInFront = thisOverlay->getDrawInFront();
|
||||
if (thisDistance < bestDistance && (!bestIsFront || isDrawInFront)) {
|
||||
bestIsFront = isDrawInFront;
|
||||
bestDistance = thisDistance;
|
||||
result.intersects = true;
|
||||
result.distance = thisDistance;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <QString>
|
||||
#include <QScriptValue>
|
||||
#include <QSignalMapper>
|
||||
|
||||
#include "Overlay.h"
|
||||
|
||||
|
@ -51,7 +52,7 @@ public:
|
|||
~Overlays();
|
||||
void init(QGLWidget* parent);
|
||||
void update(float deltatime);
|
||||
void render3D(RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE,
|
||||
void render3D(bool drawFront, RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE,
|
||||
RenderArgs::RenderSide renderSide = RenderArgs::MONO);
|
||||
void render2D();
|
||||
|
||||
|
|
|
@ -653,7 +653,6 @@ void EntityTree::update() {
|
|||
}
|
||||
|
||||
void EntityTree::updateChangedEntities(quint64 now, QSet<EntityItemID>& entitiesToDelete) {
|
||||
// TODO: switch these to iterators so we can remove items that get deleted
|
||||
foreach (EntityItem* thisEntity, _changedEntities) {
|
||||
// check to see if the lifetime has expired, for immortal entities this is always false
|
||||
if (thisEntity->lifetimeHasExpired()) {
|
||||
|
@ -675,15 +674,17 @@ void EntityTree::updateMovingEntities(quint64 now, QSet<EntityItemID>& entitiesT
|
|||
{
|
||||
PerformanceTimer perfTimer("_movingEntities");
|
||||
|
||||
// TODO: switch these to iterators so we can remove items that get deleted
|
||||
for (int i = 0; i < _movingEntities.size(); i++) {
|
||||
EntityItem* thisEntity = _movingEntities[i];
|
||||
QList<EntityItem*>::iterator item_itr = _movingEntities.begin();
|
||||
while (item_itr != _movingEntities.end()) {
|
||||
EntityItem* thisEntity = *item_itr;
|
||||
|
||||
// always check to see if the lifetime has expired, for immortal entities this is always false
|
||||
if (thisEntity->lifetimeHasExpired()) {
|
||||
qDebug() << "Lifetime has expired for entity:" << thisEntity->getEntityItemID();
|
||||
entitiesToDelete << thisEntity->getEntityItemID();
|
||||
clearEntityState(thisEntity);
|
||||
// remove thisEntity from the list
|
||||
item_itr = _movingEntities.erase(item_itr);
|
||||
thisEntity->setSimulationState(EntityItem::Static);
|
||||
} else {
|
||||
AACube oldCube = thisEntity->getMaximumAACube();
|
||||
thisEntity->update(now);
|
||||
|
@ -694,10 +695,22 @@ void EntityTree::updateMovingEntities(quint64 now, QSet<EntityItemID>& entitiesT
|
|||
if (!domainBounds.touches(newCube)) {
|
||||
qDebug() << "Entity " << thisEntity->getEntityItemID() << " moved out of domain bounds.";
|
||||
entitiesToDelete << thisEntity->getEntityItemID();
|
||||
clearEntityState(thisEntity);
|
||||
// remove thisEntity from the list
|
||||
item_itr = _movingEntities.erase(item_itr);
|
||||
thisEntity->setSimulationState(EntityItem::Static);
|
||||
} else {
|
||||
moveOperator.addEntityToMoveList(thisEntity, oldCube, newCube);
|
||||
updateEntityState(thisEntity);
|
||||
EntityItem::SimulationState newState = thisEntity->computeSimulationState();
|
||||
if (newState != EntityItem::Moving) {
|
||||
if (newState == EntityItem::Mortal) {
|
||||
_mortalEntities.push_back(thisEntity);
|
||||
}
|
||||
// remove thisEntity from the list
|
||||
item_itr = _movingEntities.erase(item_itr);
|
||||
thisEntity->setSimulationState(newState);
|
||||
} else {
|
||||
++item_itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -710,18 +723,30 @@ void EntityTree::updateMovingEntities(quint64 now, QSet<EntityItemID>& entitiesT
|
|||
}
|
||||
|
||||
void EntityTree::updateMortalEntities(quint64 now, QSet<EntityItemID>& entitiesToDelete) {
|
||||
// TODO: switch these to iterators so we can remove items that get deleted
|
||||
for (int i = 0; i < _mortalEntities.size(); i++) {
|
||||
EntityItem* thisEntity = _mortalEntities[i];
|
||||
QList<EntityItem*>::iterator item_itr = _mortalEntities.begin();
|
||||
while (item_itr != _mortalEntities.end()) {
|
||||
EntityItem* thisEntity = *item_itr;
|
||||
thisEntity->update(now);
|
||||
// always check to see if the lifetime has expired, for immortal entities this is always false
|
||||
if (thisEntity->lifetimeHasExpired()) {
|
||||
qDebug() << "Lifetime has expired for entity:" << thisEntity->getEntityItemID();
|
||||
entitiesToDelete << thisEntity->getEntityItemID();
|
||||
clearEntityState(thisEntity);
|
||||
// remove thisEntity from the list
|
||||
item_itr = _mortalEntities.erase(item_itr);
|
||||
thisEntity->setSimulationState(EntityItem::Static);
|
||||
} else {
|
||||
// check to see if this entity is no longer moving
|
||||
updateEntityState(thisEntity);
|
||||
EntityItem::SimulationState newState = thisEntity->computeSimulationState();
|
||||
if (newState != EntityItem::Mortal) {
|
||||
if (newState == EntityItem::Moving) {
|
||||
_movingEntities.push_back(thisEntity);
|
||||
}
|
||||
// remove thisEntity from the list
|
||||
item_itr = _mortalEntities.erase(item_itr);
|
||||
thisEntity->setSimulationState(newState);
|
||||
} else {
|
||||
++item_itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue